3 @@ -1043,6 +1043,7 @@ int daemon_main(void)
4 fprintf(stderr, "Failed to parse config file: %s\n", config_file);
5 exit_cleanup(RERR_SYNTAX);
18 +extern item_list dparam_list;
20 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
21 #define strequal(a,b) (strcasecmp(a,b)==0)
22 #define BOOLSTR(b) ((b) ? "Yes" : "No")
23 @@ -780,8 +783,11 @@ static BOOL do_section(char *sectionname)
26 /* if we were in a global section then do the local inits */
27 - if (bInGlobalSection && !isglobal)
28 + if (bInGlobalSection && !isglobal) {
34 /* if we've just struck a global section, note the fact. */
35 bInGlobalSection = isglobal;
36 @@ -844,6 +850,29 @@ BOOL lp_load(char *pszFname, int globals_only)
40 +BOOL set_dparams(int syntax_check_only)
42 + char *equal, *val, **params = dparam_list.items;
45 + for (j = 0; j < dparam_list.count; j++) {
46 + equal = strchr(params[j], '='); /* options.c verified this */
48 + if (syntax_check_only) {
49 + if (map_parameter(params[j]) < 0) {
50 + rprintf(FCLIENT, "Unknown parameter \"%s\"\n", params[j]);
55 + for (val = equal+1; isSpace(val); val++) {}
56 + do_parameter(params[j], val);
64 /***************************************************************************
65 * return the max number of services
68 @@ -124,6 +124,7 @@ int inplace = 0;
69 int delay_updates = 0;
70 long block_size = 0; /* "long" because popt can't set an int32. */
71 char *skip_compress = NULL;
72 +item_list dparam_list = EMPTY_ITEM_LIST;
74 /** Network address family. **/
76 @@ -652,6 +653,7 @@ static struct poptOption long_options[] = {
77 /* All the following options switch us into daemon-mode option-parsing. */
78 {"config", 0, POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 },
79 {"daemon", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
80 + {"dparam", 0, POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 },
81 {"detach", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
82 {"no-detach", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
84 @@ -666,6 +668,7 @@ static void daemon_usage(enum logcode F)
85 rprintf(F," --address=ADDRESS bind to the specified address\n");
86 rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
87 rprintf(F," --config=FILE specify alternate rsyncd.conf file\n");
88 + rprintf(F," -M, --dparam=OVERRIDE override global daemon config parameter\n");
89 rprintf(F," --no-detach do not detach from the parent\n");
90 rprintf(F," --port=PORT listen on alternate port number\n");
91 rprintf(F," --log-file=FILE override the \"log file\" setting\n");
92 @@ -687,6 +690,7 @@ static struct poptOption long_daemon_options[] = {
93 {"bwlimit", 0, POPT_ARG_INT, &daemon_bwlimit, 0, 0, 0 },
94 {"config", 0, POPT_ARG_STRING, &config_file, 0, 0, 0 },
95 {"daemon", 0, POPT_ARG_NONE, &daemon_opt, 0, 0, 0 },
96 + {"dparam", 'M', POPT_ARG_STRING, 0, 'M', 0, 0 },
97 {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 },
98 {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 },
99 {"detach", 0, POPT_ARG_VAL, &no_detach, 0, 0, 0 },
100 @@ -970,11 +974,24 @@ int parse_arguments(int *argc_p, const char ***argv_p)
101 pc = poptGetContext(RSYNC_NAME, argc, argv,
102 long_daemon_options, 0);
103 while ((opt = poptGetNextOpt(pc)) != -1) {
111 + arg = poptGetOptArg(pc);
112 + if (!strchr(arg, '=')) {
114 + "--dparam value is missing an '=': %s\n",
118 + cpp = EXPAND_ITEM_LIST(&dparam_list, char *, 4);
119 + *cpp = strdup(arg);
125 @@ -988,6 +1005,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
129 + if (dparam_list.count && !set_dparams(1))
130 + exit_cleanup(RERR_SYNTAX);
132 if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {
133 snprintf(err_buf, sizeof err_buf,
134 "the --temp-dir path is WAY too long.\n");
137 @@ -435,6 +435,7 @@ accepted: verb(
138 --address=ADDRESS bind to the specified address
139 --bwlimit=KBPS limit I/O bandwidth; KBytes per second
140 --config=FILE specify alternate rsyncd.conf file
141 + -M, --dparam=OVERRIDE override global daemon config parameter
142 --no-detach do not detach from the parent
143 --port=PORT listen on alternate port number
144 --log-file=FILE override the "log file" setting
145 @@ -2131,6 +2132,14 @@ The default is /etc/rsyncd.conf unless the daemon is running over
146 a remote shell program and the remote user is not the super-user; in that case
147 the default is rsyncd.conf in the current directory (typically $HOME).
149 +dit(bf(-M, --dparam=OVERRIDE)) This option can be used to set a daemon-config
150 +parameter when starting up rsync in daemon mode. It is equivalent to adding
151 +the parameter at the end of the global settings prior to the first module's
152 +definition. The parameter names can be specified without spaces, if you so
153 +desire. For instance:
155 +verb( rsync --daemon -M pidfile=/path/rsync.pid )
157 dit(bf(--no-detach)) When running as a daemon, this option instructs
158 rsync to not detach itself and become a background process. This
159 option is required when running as a service on Cygwin, and may also
162 @@ -83,10 +83,14 @@ dit(bf(motd file)) This parameter allows you to specify a
163 "message of the day" to display to clients on each connect. This
164 usually contains site information and any legal notices. The default
166 +This can be overridden by the bf(--dparam=motdfile=FILE)
167 +command-line option when starting the daemon.
169 dit(bf(pid file)) This parameter tells the rsync daemon to write
170 its process ID to that file. If the file already exists, the rsync
171 daemon will abort rather than overwrite the file.
172 +This can be overridden by the bf(--dparam=pidfile=FILE)
173 +command-line option when starting the daemon.
175 dit(bf(port)) You can override the default port the daemon will listen on
176 by specifying this value (defaults to 873). This is ignored if the daemon
177 @@ -101,8 +105,8 @@ who like to tune their systems to the utmost degree. You can set all
178 sorts of socket options which may make transfers faster (or
179 slower!). Read the man page for the code(setsockopt()) system call for
180 details on some of the options you may be able to set. By default no
181 -special socket options are set. These settings are superseded by the
182 -bf(--sockopts) command-line option.
183 +special socket options are set. These settings can also be specified
184 +via the bf(--sockopts) command-line option.
188 @@ -260,6 +264,12 @@ If the daemon fails to open to specified file, it will fall back to
189 using syslog and output an error about the failure. (Note that the
190 failure to open the specified log file used to be a fatal error.)
192 +This setting can be overridden by using the bf(--log-file=FILE) or
193 +bf(--dparam=logfile=FILE) command-line options. The former overrides
194 +all the log-file parameters of the daemon and all module settings.
195 +The latter sets the daemon's log file and the default for all the
196 +modules, which still allows modules to override the default setting.
198 dit(bf(syslog facility)) This parameter allows you to
199 specify the syslog facility name to use when logging messages from the
200 rsync daemon. You may use any standard syslog facility name which is