Re: [PATCH] daemon: print "access denied" if a service does not work
From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:52:10
Nguyễn Thái Ngọc Duy wrote:
quoted hunk ↗ jump to hunk
--- a/daemon.c +++ b/daemon.c@@ -562,7 +562,10 @@ static int execute(void) * Note: The directory here is probably context sensitive, * and might depend on the actual service being performed. */ - return run_service(line + namelen + 5, s); + if (!run_service(line + namelen + 5, s)) + return 0; + packet_write(1, "ERR %s: access denied", line + namelen + 5); + return -1; }
At first I liked the simplification relative to the patch I sent.
This means the error message is shown when
1. the service is not enabled at all
2. path not allowed (for example because it doesn't exist, because
of permission problems, or because it is blacklisted)
3. the repository is not exported
4. the service is not enabled for $path
5. the service command exited with nonzero status
Unfortunately I think that last case (#5) would be confusing and would
break protocol, especially when the command dies at an inconvenient
moment. Better for the service command to send an appropriate error
indicator and to just hang up when it fails to do so.