summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-04-15 00:31:56 +0000
committerJeremy Allison <jra@samba.org>2000-04-15 00:31:56 +0000
commitce5e230952c18b2308d0e41fff39f0bfdf2cc32b (patch)
tree85cef5ef4a02825f4cd7c3b568775605d88fe32a /source3
parent067b341a01319577f59e4c742f7bf11b42381ecc (diff)
downloadsamba-ce5e230952c18b2308d0e41fff39f0bfdf2cc32b.tar.gz
samba-ce5e230952c18b2308d0e41fff39f0bfdf2cc32b.tar.bz2
samba-ce5e230952c18b2308d0e41fff39f0bfdf2cc32b.zip
Log file check patch from Mattias Gronlund <Mattias.Gronlund@sa.erisoft.se>.
Modified to do checks in timeout processing not in main loop. This (IMHO) is the correct place as (a) we are already root, and (b) it is guarenteed to be called every 200 smb requests. Jeremy. (This used to be commit c3794fd29fdc4e5a0dbd725cdc24fe210934caf2)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/lib/debug.c38
-rw-r--r--source3/smbd/process.c6
3 files changed, 40 insertions, 7 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a02ea38bd9..e30d24b81b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -54,6 +54,8 @@ void sig_usr1( int sig );
void setup_logging( char *pname, BOOL interactive );
void reopen_logs( void );
void force_check_log_size( void );
+BOOL need_to_check_log_size( void );
+void check_log_size( void );
void dbgflush( void );
BOOL dbghdr( int level, char *file, char *func, int line );
@@ -1262,7 +1264,6 @@ BOOL lp_nis_home_map(void);
BOOL lp_bind_interfaces_only(void);
BOOL lp_unix_password_sync(void);
BOOL lp_passwd_chat_debug(void);
-BOOL lp_ole_locking_compat(void);
BOOL lp_nt_smb_support(void);
BOOL lp_nt_pipe_support(void);
BOOL lp_nt_acl_support(void);
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 );
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 2383b7a3a5..f378550282 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -971,6 +971,12 @@ machine %s in domain %s.\n", global_myname, global_myworkgroup ));
process_pending_change_notify_queue(t);
/*
+ * Now we are root, check if the log files need pruning.
+ */
+ if(need_to_check_log_size())
+ check_log_size();
+
+ /*
* Modify the select timeout depending upon
* what we have remaining in our queues.
*/