--- nmbd/nmbd.c.orig 2009-05-23 17:38:05.000000000 +0000 +++ nmbd/nmbd.c 2009-05-24 02:34:13.000000000 +0000 @@ -740,7 +740,10 @@ static bool opt_interactive; static bool Fork = true; static bool no_process_group; - static bool log_stdout; + static bool log_stdout = false; +#ifdef WITH_SYSLOG + static bool syslog_only = false; +#endif poptContext pc; char *p_lmhosts = NULL; int opt; @@ -749,6 +752,9 @@ OPT_INTERACTIVE, OPT_FORK, OPT_NO_PROCESS_GROUP, +#ifdef WITH_SYSLOG + OPT_SYSLOG_ONLY, +#endif OPT_LOG_STDOUT }; struct poptOption long_options[] = { @@ -758,6 +764,9 @@ {"foreground", 'F', POPT_ARG_NONE, NULL, OPT_FORK, "Run daemon in foreground (for daemontools & etc)" }, {"no-process-group", 0, POPT_ARG_NONE, NULL, OPT_NO_PROCESS_GROUP, "Don't create a new process group" }, {"log-stdout", 'S', POPT_ARG_NONE, NULL, OPT_LOG_STDOUT, "Log to stdout" }, +#ifdef WITH_SYSLOG + {"syslog-only", 'L', POPT_ARG_NONE, NULL, OPT_SYSLOG_ONLY, "Log to syslog" }, +#endif {"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, POPT_COMMON_SAMBA @@ -787,6 +796,11 @@ case OPT_LOG_STDOUT: log_stdout = true; break; +#ifdef WITH_SYSLOG + case OPT_SYSLOG_ONLY: + syslog_only = true; + break; +#endif default: d_fprintf(stderr, "\nInvalid option %s: %s\n\n", poptBadOption(pc, 0), poptStrerror(opt)); @@ -838,11 +852,24 @@ log_stdout = True; } +#ifdef WITH_SYSLOG + if( syslog_only ) { + debug_set_syslog_only(); + } +#endif + if ( log_stdout && Fork ) { DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n")); exit(1); } +#ifdef WITH_SYSLOG + if ( log_stdout && syslog_only ) { + DEBUG(0,("ERROR: Can't log to stdout (-S) and syslog only (-L) at the same time\n")); + exit(1); + } +#endif + setup_logging( argv[0], log_stdout ); reopen_logs();