daemon.c: fix arg parsing bugs
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>
Andreas Ericsson committed
Nov 17, 2005 at 00:38 UTC
a8883288fa1240996a9c5715e060a88a03796fe0
1 file changed
+6
-2
daemon.c
+6
-2
@@ -594,6 +594,7 @@ int main(int argc, char **argv)
594
}
595
if (!strcmp(arg, "--inetd")) {
596
inetd_mode = 1;
597
+ log_syslog = 1;
598
continue;
599
}
600
if (!strcmp(arg, "--verbose")) {
@@ -602,7 +603,6 @@ int main(int argc, char **argv)
603
}
604
if (!strcmp(arg, "--syslog")) {
605
log_syslog = 1;
605
- openlog("git-daemon", 0, LOG_DAEMON);
606
continue;
607
}
608
if (!strcmp(arg, "--export-all")) {
@@ -611,9 +611,11 @@ int main(int argc, char **argv)
611
}
612
if (!strncmp(arg, "--timeout=", 10)) {
613
timeout = atoi(arg+10);
614
+ continue;
615
}
616
if (!strncmp(arg, "--init-timeout=", 15)) {
617
init_timeout = atoi(arg+15);
618
+ continue;
619
}
620
if (!strcmp(arg, "--")) {
621
ok_paths = &argv[i+1];
@@ -626,9 +628,11 @@ int main(int argc, char **argv)
628
usage(daemon_usage);
629
}
630
631
+ if (log_syslog)
632
+ openlog("git-daemon", 0, LOG_DAEMON);
633
+
634
if (inetd_mode) {
635
fclose(stderr); //FIXME: workaround
631
- log_syslog = 1;
636
return execute();
637
}
638