SOURCES: rsync-dparam.patch (NEW) - backport of dparam option from 3.1

arekm arekm at pld-linux.org
Mon Jul 28 10:36:44 CEST 2008


Author: arekm                        Date: Mon Jul 28 08:36:44 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- backport of dparam option from 3.1

---- Files affected:
SOURCES:
   rsync-dparam.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/rsync-dparam.patch
diff -u /dev/null SOURCES/rsync-dparam.patch:1.1
--- /dev/null	Mon Jul 28 10:36:45 2008
+++ SOURCES/rsync-dparam.patch	Mon Jul 28 10:36:39 2008
@@ -0,0 +1,200 @@
+--- a/clientserver.c
++++ b/clientserver.c
+@@ -1043,6 +1043,7 @@ int daemon_main(void)
+ 		fprintf(stderr, "Failed to parse config file: %s\n", config_file);
+ 		exit_cleanup(RERR_SYNTAX);
+ 	}
++	set_dparams(0);
+ 
+ 	if (no_detach)
+ 		create_pid_file();
+--- a/loadparm.c
++++ b/loadparm.c
+@@ -51,6 +51,9 @@
+ 
+ #include "rsync.h"
+ #include "ifuncs.h"
++
++extern item_list dparam_list;
++
+ #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
+ #define strequal(a,b) (strcasecmp(a,b)==0)
+ #define BOOLSTR(b) ((b) ? "Yes" : "No")
+@@ -780,8 +783,11 @@ static BOOL do_section(char *sectionname)
+    bRetval = False;
+ 
+    /* if we were in a global section then do the local inits */
+-   if (bInGlobalSection && !isglobal)
++   if (bInGlobalSection && !isglobal) {
++     if (!iNumServices)
++	set_dparams(0);
+      init_locals();
++   }
+ 
+    /* if we've just struck a global section, note the fact. */
+    bInGlobalSection = isglobal;
+@@ -844,6 +850,29 @@ BOOL lp_load(char *pszFname, int globals_only)
+ 	return (bRetval);
+ }
+ 
++BOOL set_dparams(int syntax_check_only)
++{
++	char *equal, *val, **params = dparam_list.items;
++	unsigned j;
++
++	for (j = 0; j < dparam_list.count; j++) {
++		equal = strchr(params[j], '='); /* options.c verified this */
++		*equal = '\0';
++		if (syntax_check_only) {
++			if (map_parameter(params[j]) < 0) {
++				rprintf(FCLIENT, "Unknown parameter \"%s\"\n", params[j]);
++				*equal = '=';
++				return False;
++			}
++		} else {
++			for (val = equal+1; isSpace(val); val++) {}
++			do_parameter(params[j], val);
++		}
++		*equal = '=';
++	}
++
++	return True;
++}
+ 
+ /***************************************************************************
+ * return the max number of services
+--- a/options.c
++++ b/options.c
+@@ -124,6 +124,7 @@ int inplace = 0;
+ int delay_updates = 0;
+ long block_size = 0; /* "long" because popt can't set an int32. */
+ char *skip_compress = NULL;
++item_list dparam_list = EMPTY_ITEM_LIST;
+ 
+ /** Network address family. **/
+ int default_af_hint
+@@ -652,6 +653,7 @@ static struct poptOption long_options[] = {
+   /* All the following options switch us into daemon-mode option-parsing. */
+   {"config",           0,  POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 },
+   {"daemon",           0,  POPT_ARG_NONE,   0, OPT_DAEMON, 0, 0 },
++  {"dparam",           0,  POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 },
+   {"detach",           0,  POPT_ARG_NONE,   0, OPT_DAEMON, 0, 0 },
+   {"no-detach",        0,  POPT_ARG_NONE,   0, OPT_DAEMON, 0, 0 },
+   {0,0,0,0, 0, 0, 0}
+@@ -666,6 +668,7 @@ static void daemon_usage(enum logcode F)
+   rprintf(F,"     --address=ADDRESS       bind to the specified address\n");
+   rprintf(F,"     --bwlimit=KBPS          limit I/O bandwidth; KBytes per second\n");
+   rprintf(F,"     --config=FILE           specify alternate rsyncd.conf file\n");
++  rprintf(F," -M, --dparam=OVERRIDE       override global daemon config parameter\n");
+   rprintf(F,"     --no-detach             do not detach from the parent\n");
+   rprintf(F,"     --port=PORT             listen on alternate port number\n");
+   rprintf(F,"     --log-file=FILE         override the \"log file\" setting\n");
+@@ -687,6 +690,7 @@ static struct poptOption long_daemon_options[] = {
+   {"bwlimit",          0,  POPT_ARG_INT,    &daemon_bwlimit, 0, 0, 0 },
+   {"config",           0,  POPT_ARG_STRING, &config_file, 0, 0, 0 },
+   {"daemon",           0,  POPT_ARG_NONE,   &daemon_opt, 0, 0, 0 },
++  {"dparam",          'M', POPT_ARG_STRING, 0, 'M', 0, 0 },
+   {"ipv4",            '4', POPT_ARG_VAL,    &default_af_hint, AF_INET, 0, 0 },
+   {"ipv6",            '6', POPT_ARG_VAL,    &default_af_hint, AF_INET6, 0, 0 },
+   {"detach",           0,  POPT_ARG_VAL,    &no_detach, 0, 0, 0 },
+@@ -970,11 +974,24 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+ 			pc = poptGetContext(RSYNC_NAME, argc, argv,
+ 					    long_daemon_options, 0);
+ 			while ((opt = poptGetNextOpt(pc)) != -1) {
++				char **cpp;
+ 				switch (opt) {
+ 				case 'h':
+ 					daemon_usage(FINFO);
+ 					exit_cleanup(0);
+ 
++				case 'M':
++					arg = poptGetOptArg(pc);
++					if (!strchr(arg, '=')) {
++						rprintf(FERROR,
++						    "--dparam value is missing an '=': %s\n",
++						    arg);
++						goto daemon_error;
++					}
++					cpp = EXPAND_ITEM_LIST(&dparam_list, char *, 4);
++					*cpp = strdup(arg);
++					break;
++
+ 				case 'v':
+ 					verbose++;
+ 					break;
+@@ -988,6 +1005,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+ 				}
+ 			}
+ 
++			if (dparam_list.count && !set_dparams(1))
++				exit_cleanup(RERR_SYNTAX);
++
+ 			if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {
+ 				snprintf(err_buf, sizeof err_buf,
+ 					 "the --temp-dir path is WAY too long.\n");
+--- a/rsync.yo
++++ b/rsync.yo
+@@ -435,6 +435,7 @@ accepted: verb(
+      --address=ADDRESS       bind to the specified address
+      --bwlimit=KBPS          limit I/O bandwidth; KBytes per second
+      --config=FILE           specify alternate rsyncd.conf file
++ -M, --dparam=OVERRIDE       override global daemon config parameter
+      --no-detach             do not detach from the parent
+      --port=PORT             listen on alternate port number
+      --log-file=FILE         override the "log file" setting
+@@ -2131,6 +2132,14 @@ The default is /etc/rsyncd.conf unless the daemon is running over
+ a remote shell program and the remote user is not the super-user; in that case
+ the default is rsyncd.conf in the current directory (typically $HOME).
+ 
++dit(bf(-M, --dparam=OVERRIDE)) This option can be used to set a daemon-config
++parameter when starting up rsync in daemon mode.  It is equivalent to adding
++the parameter at the end of the global settings prior to the first module's
++definition.  The parameter names can be specified without spaces, if you so
++desire.  For instance:
++
++verb(    rsync --daemon -M pidfile=/path/rsync.pid )
++
+ dit(bf(--no-detach)) When running as a daemon, this option instructs
+ rsync to not detach itself and become a background process.  This
+ option is required when running as a service on Cygwin, and may also
+--- a/rsyncd.conf.yo
++++ b/rsyncd.conf.yo
+@@ -83,10 +83,14 @@ dit(bf(motd file)) This parameter allows you to specify a
+ "message of the day" to display to clients on each connect. This
+ usually contains site information and any legal notices. The default
+ is no motd file.
++This can be overridden by the bf(--dparam=motdfile=FILE)
++command-line option when starting the daemon.
+ 
+ dit(bf(pid file)) This parameter tells the rsync daemon to write
+ its process ID to that file.  If the file already exists, the rsync
+ daemon will abort rather than overwrite the file.
++This can be overridden by the bf(--dparam=pidfile=FILE)
++command-line option when starting the 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
+@@ -101,8 +105,8 @@ who like to tune their systems to the utmost degree. You can set all
+ sorts of socket options which may make transfers faster (or
+ slower!). Read the man page for the code(setsockopt()) system call for
+ details on some of the options you may be able to set. By default no
+-special socket options are set.  These settings are superseded by the
+-bf(--sockopts) command-line option.
++special socket options are set.  These settings can also be specified
++via the bf(--sockopts) command-line option.
+ 
+ enddit()
+ 
+@@ -260,6 +264,12 @@ 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.)
+ 
++This setting can be overridden by using the bf(--log-file=FILE) or
++bf(--dparam=logfile=FILE) command-line options.  The former overrides
++all the log-file parameters of the daemon and all module settings.
++The latter sets the daemon's log file and the default for all the
++modules, which still allows modules to override the default setting.
++
+ dit(bf(syslog facility)) This parameter 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
================================================================


More information about the pld-cvs-commit mailing list