[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Sat Apr 29 20:51:09 UTC 2017


The branch, master has been updated
       via  ce854cf Add "syslog tag" to rsync daemon config.
      from  9e7b8ab Don't allow --daemon or --server alias via popt. Fixes bug 12576.

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ce854cf021cb7207ee504c6badf97b4ffbb2021a
Author: Wayne Davison <wayned at samba.org>
Date:   Sat Apr 29 11:07:39 2017 -0700

    Add "syslog tag" to rsync daemon config.

-----------------------------------------------------------------------

Summary of changes:
 loadparm.c     |  4 ++++
 log.c          | 17 ++++++++---------
 rsyncd.conf.yo | 11 +++++++++++
 3 files changed, 23 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/loadparm.c b/loadparm.c
index 6d75b4d..21703ef 100644
--- a/loadparm.c
+++ b/loadparm.c
@@ -129,6 +129,7 @@ typedef struct {
 	char *prexfer_exec;
 	char *refuse_options;
 	char *secrets_file;
+	char *syslog_tag;
 	char *temp_dir;
 	char *uid;
 /* NOTE: update this macro if the last char* variable changes! */
@@ -205,6 +206,7 @@ static const all_vars Defaults = {
  /* prexfer_exec; */		NULL,
  /* refuse_options; */		NULL,
  /* secrets_file; */		NULL,
+ /* syslog_tag; */		"rsyncd",
  /* temp_dir; */ 		NULL,
  /* uid; */			NULL,
 
@@ -357,6 +359,7 @@ static struct parm_struct parm_table[] =
  {"secrets file",      P_STRING, P_LOCAL, &Vars.l.secrets_file,        NULL,0},
  {"strict modes",      P_BOOL,   P_LOCAL, &Vars.l.strict_modes,        NULL,0},
  {"syslog facility",   P_ENUM,   P_LOCAL, &Vars.l.syslog_facility,     enum_facilities,0},
+ {"syslog tag",        P_STRING, P_LOCAL, &Vars.l.syslog_tag,          NULL,0},
  {"temp dir",          P_PATH,   P_LOCAL, &Vars.l.temp_dir,            NULL,0},
  {"timeout",           P_INTEGER,P_LOCAL, &Vars.l.timeout,             NULL,0},
  {"transfer logging",  P_BOOL,   P_LOCAL, &Vars.l.transfer_logging,    NULL,0},
@@ -474,6 +477,7 @@ FN_LOCAL_STRING(lp_postxfer_exec, postxfer_exec)
 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_STRING(lp_syslog_tag, syslog_tag)
 FN_LOCAL_STRING(lp_temp_dir, temp_dir)
 FN_LOCAL_STRING(lp_uid, uid)
 
diff --git a/log.c b/log.c
index f7da1e5..b145ee1 100644
--- a/log.c
+++ b/log.c
@@ -134,21 +134,16 @@ static void logit(int priority, const char *buf)
 
 static void syslog_init()
 {
-	static int been_here = 0;
 	int options = LOG_PID;
 
-	if (been_here)
-		return;
-	been_here = 1;
-
 #ifdef LOG_NDELAY
 	options |= LOG_NDELAY;
 #endif
 
 #ifdef LOG_DAEMON
-	openlog("rsyncd", options, lp_syslog_facility(module_id));
+	openlog(lp_syslog_tag(module_id), options, lp_syslog_facility(module_id));
 #else
-	openlog("rsyncd", options);
+	openlog(lp_syslog_tag(module_id), options);
 #endif
 
 #ifndef LOG_NDELAY
@@ -168,14 +163,16 @@ static void logfile_open(void)
 		rsyserr(FERROR, fopen_errno,
 			"failed to open log-file %s", logfile_name);
 		rprintf(FINFO, "Ignoring \"log file\" setting.\n");
+		logfile_name = "";
 	}
 }
 
 void log_init(int restart)
 {
 	if (log_initialised) {
-		if (!restart)
+		if (!restart) /* Note: a restart only happens with am_daemon */
 			return;
+		assert(logfile_name); /* all am_daemon procs got at least an empty string */
 		if (strcmp(logfile_name, lp_log_file(module_id)) != 0) {
 			if (logfile_fp) {
 				fclose(logfile_fp);
@@ -185,7 +182,8 @@ void log_init(int restart)
 			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))
+		else if (lp_syslog_facility(-1) != lp_syslog_facility(module_id)
+		      || strcmp(lp_syslog_tag(-1), lp_syslog_tag(module_id)) != 0)
 			closelog();
 		else
 			return; /* unchanged syslog settings */
@@ -207,6 +205,7 @@ void log_init(int restart)
 		syslog_init();
 }
 
+/* Note that this close & reopen idiom intentionally ignores syslog logging. */
 void logfile_close(void)
 {
 	if (logfile_fp) {
diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo
index 64156ae..b6fc2b5 100644
--- a/rsyncd.conf.yo
+++ b/rsyncd.conf.yo
@@ -316,6 +316,17 @@ 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(syslog tag)) This parameter allows you to specify the syslog
+tag to use when logging messages from the rsync daemon. The default is
+"rsyncd".  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).
+
+For example, if you wanted each authenticated user's name to be
+included in the syslog tag, you could do something like this:
+
+verb(    syslog tag = rsyncd.%RSYNC_USER_NAME%)
+
 dit(bf(max verbosity)) This parameter 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,


-- 
The rsync repository.



More information about the rsync-cvs mailing list