+++ /dev/null
-This patch adds a daemon option, --dparam (-M), that lets you override
-global/default items in the config file when starting the daemon up.
-
-To use this patch, run these commands for a successful build:
-
- patch -p1 <patches/dparam.diff
- ./configure (optional if already run)
- make
-
-diff --git a/clientserver.c b/clientserver.c
---- a/clientserver.c
-+++ b/clientserver.c
-@@ -1045,6 +1045,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();
-diff --git a/loadparm.c b/loadparm.c
---- 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
-diff --git a/options.c b/options.c
---- 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
-@@ -653,6 +654,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}
-@@ -667,6 +669,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");
-@@ -688,6 +691,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 },
-@@ -971,11 +975,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;
-@@ -989,6 +1006,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");
-diff --git a/rsync.yo b/rsync.yo
---- a/rsync.yo
-+++ b/rsync.yo
-@@ -439,6 +439,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
-@@ -2147,6 +2148,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
-diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo
---- 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
-@@ -260,6 +264,12 @@ If the daemon fails to open the 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