The Samba-Bugzilla – Attachment 1954 Details for
Bug 3809
Feature Request: Individual log file per module
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
The log-file settings can be set differently for each module
module-logging.patch (text/plain), 14.92 KB, created by
Wayne Davison
on 2006-06-07 18:04:18 UTC
(
hide
)
Description:
The log-file settings can be set differently for each module
Filename:
MIME Type:
Creator:
Wayne Davison
Created:
2006-06-07 18:04:18 UTC
Size:
14.92 KB
patch
obsolete
>--- clientserver.c 30 May 2006 17:15:24 -0000 1.185 >+++ clientserver.c 7 Jun 2006 23:01:22 -0000 >@@ -389,7 +389,7 @@ static int rsync_module(int f_in, int f_ > parse_rule(&server_filter_list, p, MATCHFLG_WORD_SPLIT, > XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES); > >- log_init(); >+ log_init(1); > > #ifdef HAVE_PUTENV > if (*lp_prexfer_exec(i) || *lp_postxfer_exec(i)) { >@@ -836,7 +836,7 @@ int daemon_main(void) > if (bind_address == NULL && *lp_bind_address()) > bind_address = lp_bind_address(); > >- log_init(); >+ log_init(0); > > rprintf(FLOG, "rsyncd version %s starting, listening on port %d\n", > RSYNC_VERSION, rsync_port); >--- loadparm.c 25 Apr 2006 23:51:15 -0000 1.69 >+++ loadparm.c 7 Jun 2006 23:01:22 -0000 >@@ -57,6 +57,10 @@ > typedef char pstring[1024]; > #define pstrcpy(a,b) strlcpy(a,b,sizeof(pstring)) > >+#ifndef LOG_DAEMON >+#define LOG_DAEMON 0 >+#endif >+ > /* the following are used by loadparm for option lists */ > typedef enum > { >@@ -99,13 +103,11 @@ struct parm_struct > typedef struct > { > char *bind_address; >- char *log_file; > char *motd_file; > char *pid_file; > char *socket_options; > > int rsync_port; >- int syslog_facility; > } global; > > static global Globals; >@@ -131,6 +133,7 @@ typedef struct > char *include_from; > char *incoming_chmod; > char *lock_file; >+ char *log_file; > char *log_format; > char *name; > char *outgoing_chmod; >@@ -144,6 +147,7 @@ typedef struct > > int max_connections; > int max_verbosity; >+ int syslog_facility; > int timeout; > > BOOL ignore_errors; >@@ -176,6 +180,7 @@ static service sDefault = > /* include_from; */ NULL, > /* incoming_chmod; */ NULL, > /* lock_file; */ DEFAULT_LOCK_FILE, >+ /* log_file; */ NULL, > /* log_format; */ "%o %h [%a] %m (%u) %f %l", > /* name; */ NULL, > /* outgoing_chmod; */ NULL, >@@ -189,6 +194,7 @@ static service sDefault = > > /* max_connections; */ 0, > /* max_verbosity; */ 1, >+ /* syslog_facility; */ LOG_DAEMON, > /* timeout; */ 0, > > /* ignore_errors; */ False, >@@ -282,12 +288,10 @@ static struct enum_list enum_facilities[ > static struct parm_struct parm_table[] = > { > {"address", P_STRING, P_GLOBAL,&Globals.bind_address, NULL,0}, >- {"log file", P_STRING, P_GLOBAL,&Globals.log_file, NULL,0}, > {"motd file", P_STRING, P_GLOBAL,&Globals.motd_file, NULL,0}, > {"pid file", P_STRING, P_GLOBAL,&Globals.pid_file, NULL,0}, > {"port", P_INTEGER,P_GLOBAL,&Globals.rsync_port, NULL,0}, > {"socket options", P_STRING, P_GLOBAL,&Globals.socket_options, NULL,0}, >- {"syslog facility", P_ENUM, P_GLOBAL,&Globals.syslog_facility,enum_facilities,0}, > > {"auth users", P_STRING, P_LOCAL, &sDefault.auth_users, NULL,0}, > {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL,0}, >@@ -305,6 +309,7 @@ static struct parm_struct parm_table[] = > {"incoming chmod", P_STRING, P_LOCAL, &sDefault.incoming_chmod, NULL,0}, > {"list", P_BOOL, P_LOCAL, &sDefault.list, NULL,0}, > {"lock file", P_STRING, P_LOCAL, &sDefault.lock_file, NULL,0}, >+ {"log file", P_STRING, P_LOCAL, &sDefault.log_file, NULL,0}, > {"log format", P_STRING, P_LOCAL, &sDefault.log_format, NULL,0}, > {"max connections", P_INTEGER,P_LOCAL, &sDefault.max_connections, NULL,0}, > {"max verbosity", P_INTEGER,P_LOCAL, &sDefault.max_verbosity, NULL,0}, >@@ -319,6 +324,7 @@ static struct parm_struct parm_table[] = > {"refuse options", P_STRING, P_LOCAL, &sDefault.refuse_options, NULL,0}, > {"secrets file", P_STRING, P_LOCAL, &sDefault.secrets_file, NULL,0}, > {"strict modes", P_BOOL, P_LOCAL, &sDefault.strict_modes, NULL,0}, >+ {"syslog facility", P_ENUM, P_LOCAL, &sDefault.syslog_facility,enum_facilities,0}, > {"temp dir", P_PATH, P_LOCAL, &sDefault.temp_dir, NULL,0}, > {"timeout", P_INTEGER,P_LOCAL, &sDefault.timeout, NULL,0}, > {"transfer logging", P_BOOL, P_LOCAL, &sDefault.transfer_logging, NULL,0}, >@@ -335,9 +341,6 @@ Initialise the global parameter structur > static void init_globals(void) > { > memset(&Globals, 0, sizeof Globals); >-#ifdef LOG_DAEMON >- Globals.syslog_facility = LOG_DAEMON; >-#endif > } > > /*************************************************************************** >@@ -373,13 +376,11 @@ static void init_locals(void) > > > FN_GLOBAL_STRING(lp_bind_address, &Globals.bind_address) >-FN_GLOBAL_STRING(lp_log_file, &Globals.log_file) > FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file) > FN_GLOBAL_STRING(lp_pid_file, &Globals.pid_file) > FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options) > > FN_GLOBAL_INTEGER(lp_rsync_port, &Globals.rsync_port) >-FN_GLOBAL_INTEGER(lp_syslog_facility, &Globals.syslog_facility) > > FN_LOCAL_STRING(lp_auth_users, auth_users) > FN_LOCAL_STRING(lp_comment, comment) >@@ -394,6 +395,7 @@ FN_LOCAL_STRING(lp_include, include) > FN_LOCAL_STRING(lp_include_from, include_from) > FN_LOCAL_STRING(lp_incoming_chmod, incoming_chmod) > FN_LOCAL_STRING(lp_lock_file, lock_file) >+FN_LOCAL_STRING(lp_log_file, log_file) > FN_LOCAL_STRING(lp_log_format, log_format) > FN_LOCAL_STRING(lp_name, name) > FN_LOCAL_STRING(lp_outgoing_chmod, outgoing_chmod) >@@ -402,6 +404,7 @@ FN_LOCAL_STRING(lp_postxfer_exec, postxf > FN_LOCAL_STRING(lp_prexfer_exec, prexfer_exec) > FN_LOCAL_STRING(lp_refuse_options, refuse_options) > FN_LOCAL_STRING(lp_secrets_file, secrets_file) >+FN_LOCAL_INTEGER(lp_syslog_facility, syslog_facility) > FN_LOCAL_STRING(lp_temp_dir, temp_dir) > FN_LOCAL_STRING(lp_uid, uid) > >--- log.c 1 Jun 2006 08:04:43 -0000 1.154 >+++ log.c 7 Jun 2006 23:01:23 -0000 >@@ -129,7 +129,7 @@ static void syslog_init() > #endif > > #ifdef LOG_DAEMON >- openlog("rsyncd", options, lp_syslog_facility()); >+ openlog("rsyncd", options, lp_syslog_facility(module_id)); > #else > openlog("rsyncd", options); > #endif >@@ -154,11 +154,26 @@ static void logfile_open(void) > } > } > >-void log_init(void) >+void log_init(int restart) > { >- if (log_initialised) >- return; >- log_initialised = 1; >+ if (log_initialised) { >+ if (!restart) >+ return; >+ if (strcmp(logfile_name, lp_log_file(module_id)) != 0) { >+ if (logfile_fp) { >+ fclose(logfile_fp); >+ logfile_fp = NULL; >+ } else >+ closelog(); >+ logfile_name = NULL; >+ } else if (*logfile_name) >+ return; /* unchanged, non-empty "log file" names */ >+ else if (lp_syslog_facility(-1) != lp_syslog_facility(module_id)) >+ closelog(); >+ else >+ return; /* unchanged syslog settings */ >+ } else >+ log_initialised = 1; > > /* This looks pointless, but it is needed in order for the > * C library on some systems to fetch the timezone info >@@ -168,7 +183,7 @@ void log_init(void) > /* Optionally use a log file instead of syslog. (Non-daemon > * rsyncs will have already set logfile_name, as needed.) */ > if (am_daemon && !logfile_name) >- logfile_name = lp_log_file(); >+ logfile_name = lp_log_file(module_id); > if (logfile_name && *logfile_name) > logfile_open(); > else >@@ -245,7 +260,7 @@ void rwrite(enum logcode code, char *buf > return; > in_block = 1; > if (!log_initialised) >- log_init(); >+ log_init(0); > strlcpy(msg, buf, MIN((int)sizeof msg, len + 1)); > logit(priority, msg); > in_block = 0; >--- options.c 1 Jun 2006 08:04:47 -0000 1.345 >+++ options.c 7 Jun 2006 23:01:23 -0000 >@@ -1327,7 +1327,7 @@ int parse_arguments(int *argc, const cha > if (logfile_format_has_i || log_format_has(logfile_format, 'o')) > logfile_format_has_o_or_i = 1; > } >- log_init(); >+ log_init(0); > } else if (!am_daemon) > logfile_format = NULL; > >--- proto.h 29 May 2006 22:56:42 -0000 1.306 >+++ proto.h 7 Jun 2006 23:01:23 -0000 >@@ -141,12 +141,10 @@ void close_multiplexing_out(void); > void start_write_batch(int fd); > void stop_write_batch(void); > char *lp_bind_address(void); >-char *lp_log_file(void); > char *lp_motd_file(void); > char *lp_pid_file(void); > char *lp_socket_options(void); > int lp_rsync_port(void); >-int lp_syslog_facility(void); > char *lp_auth_users(int ); > char *lp_comment(int ); > char *lp_dont_compress(int ); >@@ -160,6 +158,7 @@ char *lp_include(int ); > char *lp_include_from(int ); > char *lp_incoming_chmod(int ); > char *lp_lock_file(int ); >+char *lp_log_file(int ); > char *lp_log_format(int ); > char *lp_name(int ); > char *lp_outgoing_chmod(int ); >@@ -168,6 +167,7 @@ char *lp_postxfer_exec(int ); > char *lp_prexfer_exec(int ); > char *lp_refuse_options(int ); > char *lp_secrets_file(int ); >+int lp_syslog_facility(int ); > char *lp_temp_dir(int ); > char *lp_uid(int ); > int lp_max_connections(int ); >@@ -184,7 +184,7 @@ BOOL lp_write_only(int ); > BOOL lp_load(char *pszFname, int globals_only); > int lp_numservices(void); > int lp_number(char *name); >-void log_init(void); >+void log_init(int restart); > void logfile_close(void); > void logfile_reopen(void); > void rwrite(enum logcode code, char *buf, int len); >--- rsyncd.conf.5 22 Apr 2006 15:39:57 -0000 1.127 >+++ rsyncd.conf.5 7 Jun 2006 23:01:23 -0000 >@@ -96,28 +96,10 @@ The "motd file" option allows you to spe > usually contains site information and any legal notices\&. The default > is no motd file\&. > .IP >-.IP "\fBlog file\fP" >-The "log file" option tells the rsync daemon to log >-messages to that file rather than using syslog\&. This is particularly >-useful on systems (such as AIX) where \f(CWsyslog()\fP doesn\&'t work for >-chrooted programs\&. If the daemon fails to open to specified file, it >-will fall back to using syslog and output an error about the failure\&. >-(Note that a failure to open the specified log file used to be a fatal >-error\&.) >-.IP > .IP "\fBpid file\fP" > The "pid file" option tells the rsync daemon to write > its process ID to that file\&. > .IP >-.IP "\fBsyslog facility\fP" >-The "syslog facility" option allows you to >-specify the syslog facility name to use when logging messages from the >-rsync daemon\&. You may use any standard syslog facility name which is >-defined on your system\&. Common names are auth, authpriv, cron, daemon, >-ftp, kern, lpr, mail, news, security, syslog, user, uucp, local0, >-local1, local2, local3, local4, local5, local6 and local7\&. The default >-is daemon\&. >-.IP > .IP "\fBport\fP" > You can override the default port the daemon will listen on > by specifying this value (defaults to 873)\&. This is ignored if the daemon >@@ -199,6 +181,31 @@ Any clients connecting when the maximum > message telling them to try later\&. The default is 0 which means no limit\&. > See also the "lock file" option\&. > .IP >+.IP "\fBlog file\fP" >+When the "log file" option is set to a non-empty >+string, the rsync daemon will log messages to the indicated file rather >+than using syslog\&. This is particularly useful on systems (such as AIX) >+where \f(CWsyslog()\fP doesn\&'t work for chrooted programs\&. The file is >+opened before \f(CWchroot()\fP is called, allowing it to be placed outside >+the transfer\&. If this value is set on a per-module basis instead of >+globally, the global log will still contain any authorization failures >+or config-file error messages\&. >+.IP >+If the daemon fails to open to specified file, it will fall back to >+using syslog and output an error about the failure\&. (Note that the >+failure to open the specified log file used to be a fatal error\&.) >+.IP >+.IP "\fBsyslog facility\fP" >+The "syslog facility" option allows you to >+specify the syslog facility name to use when logging messages from the >+rsync daemon\&. You may use any standard syslog facility name which is >+defined on your system\&. Common names are auth, authpriv, cron, daemon, >+ftp, kern, lpr, mail, news, security, syslog, user, uucp, local0, >+local1, local2, local3, local4, local5, local6 and local7\&. The default >+is daemon\&. This setting has no effect if the "log file" setting is a >+non-empty string (either set in the per-modules settings, or inherited >+from the global settings)\&. >+.IP > .IP "\fBmax verbosity\fP" > The "max verbosity" option allows you to control > the maximum amount of verbose information that you\&'ll allow the daemon to >--- rsyncd.conf.yo 22 Apr 2006 15:39:57 -0000 1.131 >+++ rsyncd.conf.yo 7 Jun 2006 23:01:24 -0000 >@@ -84,25 +84,9 @@ dit(bf(motd file)) The "motd file" optio > usually contains site information and any legal notices. The default > is no motd file. > >-dit(bf(log file)) The "log file" option tells the rsync daemon to log >-messages to that file rather than using syslog. This is particularly >-useful on systems (such as AIX) where code(syslog()) doesn't work for >-chrooted programs. If the daemon fails to open to specified file, it >-will fall back to using syslog and output an error about the failure. >-(Note that a failure to open the specified log file used to be a fatal >-error.) >- > dit(bf(pid file)) The "pid file" option tells the rsync daemon to write > its process ID to that file. > >-dit(bf(syslog facility)) The "syslog facility" option allows you to >-specify the syslog facility name to use when logging messages from the >-rsync daemon. You may use any standard syslog facility name which is >-defined on your system. Common names are auth, authpriv, cron, daemon, >-ftp, kern, lpr, mail, news, security, syslog, user, uucp, local0, >-local1, local2, local3, local4, local5, local6 and local7. The default >-is daemon. >- > dit(bf(port)) You can override the default port the daemon will listen on > by specifying this value (defaults to 873). This is ignored if the daemon > is being run by inetd, and is superseded by the bf(--port) command-line option. >@@ -180,6 +164,29 @@ Any clients connecting when the maximum > message telling them to try later. The default is 0 which means no limit. > See also the "lock file" option. > >+dit(bf(log file)) When the "log file" option is set to a non-empty >+string, the rsync daemon will log messages to the indicated file rather >+than using syslog. This is particularly useful on systems (such as AIX) >+where code(syslog()) doesn't work for chrooted programs. The file is >+opened before code(chroot()) is called, allowing it to be placed outside >+the transfer. If this value is set on a per-module basis instead of >+globally, the global log will still contain any authorization failures >+or config-file error messages. >+ >+If the daemon fails to open to specified file, it will fall back to >+using syslog and output an error about the failure. (Note that the >+failure to open the specified log file used to be a fatal error.) >+ >+dit(bf(syslog facility)) The "syslog facility" option allows you to >+specify the syslog facility name to use when logging messages from the >+rsync daemon. You may use any standard syslog facility name which is >+defined on your system. Common names are auth, authpriv, cron, daemon, >+ftp, kern, lpr, mail, news, security, syslog, user, uucp, local0, >+local1, local2, local3, local4, local5, local6 and local7. The default >+is daemon. This setting has no effect if the "log file" setting is a >+non-empty string (either set in the per-modules settings, or inherited >+from the global settings). >+ > dit(bf(max verbosity)) The "max verbosity" option allows you to control > the maximum amount of verbose information that you'll allow the daemon to > generate (since the information goes into the log file). The default is 1,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 3809
: 1954