Skip to content

Commit

Permalink
daemon.c: fix arg parsing bugs
Browse files Browse the repository at this point in the history
Allow --init-timeout and --timeout to be specified without falling
through to usage().

Make sure openlog() is called even if implied by --inetd, or messages
will be sent to wherever LOG_USER ends up.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Andreas Ericsson authored and Junio C Hamano committed Nov 17, 2005
1 parent fbba222 commit a888328
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ int main(int argc, char **argv)
}
if (!strcmp(arg, "--inetd")) {
inetd_mode = 1;
log_syslog = 1;
continue;
}
if (!strcmp(arg, "--verbose")) {
Expand All @@ -602,7 +603,6 @@ int main(int argc, char **argv)
}
if (!strcmp(arg, "--syslog")) {
log_syslog = 1;
openlog("git-daemon", 0, LOG_DAEMON);
continue;
}
if (!strcmp(arg, "--export-all")) {
Expand All @@ -611,9 +611,11 @@ int main(int argc, char **argv)
}
if (!strncmp(arg, "--timeout=", 10)) {
timeout = atoi(arg+10);
continue;
}
if (!strncmp(arg, "--init-timeout=", 15)) {
init_timeout = atoi(arg+15);
continue;
}
if (!strcmp(arg, "--")) {
ok_paths = &argv[i+1];
Expand All @@ -626,9 +628,11 @@ int main(int argc, char **argv)
usage(daemon_usage);
}

if (log_syslog)
openlog("git-daemon", 0, LOG_DAEMON);

if (inetd_mode) {
fclose(stderr); //FIXME: workaround
log_syslog = 1;
return execute();
}

Expand Down

0 comments on commit a888328

Please sign in to comment.