diff --git a/ChangeLog b/ChangeLog index d36c3dbf5..bc12dddf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-03-19 Richard Frith-Macdonald + + * Tools/gdomap.c: Don't open syslog connection until after we have + forked and closed old descriptors .. fix for bug #41751 + 2014-03-11 Richard Frith-Macdonald * Source/Additions/GSMime.m: diff --git a/Tools/gdomap.c b/Tools/gdomap.c index 23da197a4..4b6aeeb4f 100644 --- a/Tools/gdomap.c +++ b/Tools/gdomap.c @@ -296,7 +296,7 @@ static char ebuf[2048]; # define syslog(prio, msg,...) slogf(_SLOG_SETCODE(_SLOG_SYSLOG, 0), prio, msg, __VA_ARGS__) # endif -static int log_priority; +static int log_priority = 0; static void gdomap_log (int prio) @@ -4481,16 +4481,7 @@ main(int argc, char** argv) const char *machine = 0; const char *lookupf = 0; int donamesf = 0; - -#if defined(HAVE_SYSLOG) - /* Initially, gdomap_log errors to stderr as well as to syslogd. */ -#if defined(SYSLOG_4_2) - openlog ("gdomap", LOG_NDELAY); - log_priority = LOG_DAEMON; -#elif !defined(HAVE_SLOGF) - openlog ("gdomap", LOG_NDELAY, LOG_DAEMON); -#endif -#endif + int forked = 0; #if defined(__MINGW__) WORD wVersionRequested; @@ -4851,7 +4842,6 @@ printf( #else if (nofork == 0) { - is_daemon = 1; /* * Now fork off child process to run in background. */ @@ -4865,6 +4855,7 @@ printf( /* * Try to run in background. */ + forked = 1; #if defined(NeXT) setpgrp(0, getpid()); #else @@ -4924,6 +4915,19 @@ printf( #endif /* !__MINGW__ */ + if (forked) + { + is_daemon = 1; +#if defined(HAVE_SYSLOG) +#if defined(SYSLOG_4_2) + openlog ("gdomap", LOG_NDELAY); + log_priority = LOG_DAEMON; +#elif !defined(HAVE_SLOGF) + openlog ("gdomap", LOG_NDELAY, LOG_DAEMON); +#endif +#endif + } + init_my_port(); /* Determine port to listen on. */ init_ports(); /* Create ports to handle requests. */