--- lib/debug.c.orig 2009-05-23 17:30:48.000000000 +0000 +++ lib/debug.c 2009-05-24 02:40:15.000000000 +0000 @@ -119,6 +119,8 @@ * * syslog_level - Internal copy of the message debug level. Written by * dbghdr() and read by Debug1(). + * + * syslog_only - Permanent syslog only logging flag * * format_bufr - Used to format debug messages. The dbgtext() function * prints debug messages to a string, and then passes the @@ -138,6 +140,7 @@ static int debug_count = 0; #ifdef WITH_SYSLOG static int syslog_level = 0; +static bool syslog_only = False; #endif static char *format_bufr = NULL; static size_t format_pos = 0; @@ -606,6 +609,15 @@ } /*************************************************************************** + Set the syslog only flag. +**************************************************************************/ + +void debug_set_syslog_only( void ) +{ + syslog_only = true; +} + +/*************************************************************************** Set the logfile name. **************************************************************************/ @@ -656,21 +668,26 @@ } debugf = fname; - new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644); +#ifdef WITH_SYSLOG + if( !syslog_only && !lp_syslog_only() ) +#endif + { + new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644); - if (!new_dbf) { - log_overflow = True; - DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno))); - log_overflow = False; - if (dbf) - x_fflush(dbf); - ret = False; - } else { - x_setbuf(new_dbf, NULL); - old_dbf = dbf; - dbf = new_dbf; - if (old_dbf) - (void) x_fclose(old_dbf); + if (!new_dbf) { + log_overflow = True; + DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno))); + log_overflow = False; + if (dbf) + x_fflush(dbf); + ret = False; + } else { + x_setbuf(new_dbf, NULL); + old_dbf = dbf; + dbf = new_dbf; + if (old_dbf) + (void) x_fclose(old_dbf); + } } /* Fix from klausr@ITAP.Physik.Uni-Stuttgart.De @@ -810,7 +827,7 @@ goto done; #ifdef WITH_SYSLOG - if( !lp_syslog_only() ) + if( !syslog_only && !lp_syslog_only() ) #endif { if( !dbf ) { @@ -828,7 +845,7 @@ } #ifdef WITH_SYSLOG - if( syslog_level < lp_syslog() ) { + if( syslog_level < lp_syslog() || syslog_only ) { /* map debug levels to syslog() priorities * note that not all DEBUG(0, ...) calls are * necessarily errors */ @@ -861,7 +878,7 @@ check_log_size(); #ifdef WITH_SYSLOG - if( !lp_syslog_only() ) + if( !syslog_only && !lp_syslog_only() ) #endif { va_start( ap, format_str );