Merge branch 'nd/git-daemon-error-msgs'

* nd/git-daemon-error-msgs:
  daemon: return "access denied" if a service is not allowed
This commit is contained in:
Junio C Hamano 2011-10-13 19:03:21 -07:00
commit 522a54568e

View File

@ -257,11 +257,11 @@ static int run_service(char *dir, struct daemon_service *service)
if (!enabled && !service->overridable) { if (!enabled && !service->overridable) {
logerror("'%s': service not enabled.", service->name); logerror("'%s': service not enabled.", service->name);
errno = EACCES; errno = EACCES;
return -1; goto failed;
} }
if (!(path = path_ok(dir))) if (!(path = path_ok(dir)))
return -1; goto failed;
/* /*
* Security on the cheap. * Security on the cheap.
@ -277,7 +277,7 @@ static int run_service(char *dir, struct daemon_service *service)
if (!export_all_trees && access("git-daemon-export-ok", F_OK)) { if (!export_all_trees && access("git-daemon-export-ok", F_OK)) {
logerror("'%s': repository not exported.", path); logerror("'%s': repository not exported.", path);
errno = EACCES; errno = EACCES;
return -1; goto failed;
} }
if (service->overridable) { if (service->overridable) {
@ -291,7 +291,7 @@ static int run_service(char *dir, struct daemon_service *service)
logerror("'%s': service not enabled for '%s'", logerror("'%s': service not enabled for '%s'",
service->name, path); service->name, path);
errno = EACCES; errno = EACCES;
return -1; goto failed;
} }
/* /*
@ -301,6 +301,10 @@ static int run_service(char *dir, struct daemon_service *service)
signal(SIGTERM, SIG_IGN); signal(SIGTERM, SIG_IGN);
return service->fn(); return service->fn();
failed:
packet_write(1, "ERR %s: access denied", dir);
return -1;
} }
static void copy_to_log(int fd) static void copy_to_log(int fd)