diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/debug.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/source3/lib/debug.c b/source3/lib/debug.c index c88f4e1a41..ed27b93cfd 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -239,26 +239,52 @@ void reopen_logs( void ) * ************************************************************************** ** */ void force_check_log_size( void ) - { +{ debug_count = 100; - } /* force_check_log_size */ +} + +/*************************************************************************** + Check to see if there is any need to check if the logfile has grown too big. +**************************************************************************/ + +BOOL need_to_check_log_size( void ) +{ + int maxlog; + + if( debug_count++ < 100 ) + return( False ); + + maxlog = lp_max_log_size() * 1024; + if( !dbf || maxlog <= 0 ) { + debug_count = 0; + return(False); + } + return( True ); +} /* ************************************************************************** ** * Check to see if the log has grown to be too big. * ************************************************************************** ** */ -static void check_log_size( void ) + +void check_log_size( void ) { int maxlog; SMB_STRUCT_STAT st; - if( debug_count++ < 100 || geteuid() != 0 ) + /* + * We need to be root to check/change log-file, skip this and let the main + * loop check do a new check as root. + */ + + if( geteuid() != 0 ) return; - maxlog = lp_max_log_size() * 1024; - if( !dbf || maxlog <= 0 ) + if( !need_to_check_log_size() ) return; + maxlog = lp_max_log_size() * 1024; + if( sys_fstat( fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) { (void)fclose( dbf ); |