]> git.pld-linux.org Git - packages/rsync.git/blob - rsync-dparam.patch
use delaycompress option to avoid file changed during compress errors
[packages/rsync.git] / rsync-dparam.patch
1 --- a/clientserver.c
2 +++ b/clientserver.c
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);
6         }
7 +       set_dparams(0);
8  
9         if (no_detach)
10                 create_pid_file();
11 --- a/loadparm.c
12 +++ b/loadparm.c
13 @@ -51,6 +51,9 @@
14  
15  #include "rsync.h"
16  #include "ifuncs.h"
17 +
18 +extern item_list dparam_list;
19 +
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)
24     bRetval = False;
25  
26     /* if we were in a global section then do the local inits */
27 -   if (bInGlobalSection && !isglobal)
28 +   if (bInGlobalSection && !isglobal) {
29 +     if (!iNumServices)
30 +       set_dparams(0);
31       init_locals();
32 +   }
33  
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)
37         return (bRetval);
38  }
39  
40 +BOOL set_dparams(int syntax_check_only)
41 +{
42 +       char *equal, *val, **params = dparam_list.items;
43 +       unsigned j;
44 +
45 +       for (j = 0; j < dparam_list.count; j++) {
46 +               equal = strchr(params[j], '='); /* options.c verified this */
47 +               *equal = '\0';
48 +               if (syntax_check_only) {
49 +                       if (map_parameter(params[j]) < 0) {
50 +                               rprintf(FCLIENT, "Unknown parameter \"%s\"\n", params[j]);
51 +                               *equal = '=';
52 +                               return False;
53 +                       }
54 +               } else {
55 +                       for (val = equal+1; isSpace(val); val++) {}
56 +                       do_parameter(params[j], val);
57 +               }
58 +               *equal = '=';
59 +       }
60 +
61 +       return True;
62 +}
63  
64  /***************************************************************************
65  * return the max number of services
66 --- a/options.c
67 +++ b/options.c
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;
73  
74  /** Network address family. **/
75  int default_af_hint
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 },
83    {0,0,0,0, 0, 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) {
104 +                               char **cpp;
105                                 switch (opt) {
106                                 case 'h':
107                                         daemon_usage(FINFO);
108                                         exit_cleanup(0);
109  
110 +                               case 'M':
111 +                                       arg = poptGetOptArg(pc);
112 +                                       if (!strchr(arg, '=')) {
113 +                                               rprintf(FERROR,
114 +                                                   "--dparam value is missing an '=': %s\n",
115 +                                                   arg);
116 +                                               goto daemon_error;
117 +                                       }
118 +                                       cpp = EXPAND_ITEM_LIST(&dparam_list, char *, 4);
119 +                                       *cpp = strdup(arg);
120 +                                       break;
121 +
122                                 case 'v':
123                                         verbose++;
124                                         break;
125 @@ -988,6 +1005,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
126                                 }
127                         }
128  
129 +                       if (dparam_list.count && !set_dparams(1))
130 +                               exit_cleanup(RERR_SYNTAX);
131 +
132                         if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {
133                                 snprintf(err_buf, sizeof err_buf,
134                                          "the --temp-dir path is WAY too long.\n");
135 --- a/rsync.yo
136 +++ b/rsync.yo
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).
148  
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:
154 +
155 +verb(    rsync --daemon -M pidfile=/path/rsync.pid )
156 +
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
160 --- a/rsyncd.conf.yo
161 +++ b/rsyncd.conf.yo
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
165  is no motd file.
166 +This can be overridden by the bf(--dparam=motdfile=FILE)
167 +command-line option when starting the daemon.
168  
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.
174  
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 @@ -260,6 +264,12 @@ If the daemon fails to open to specified file, it will fall back to
178  using syslog and output an error about the failure.  (Note that the
179  failure to open the specified log file used to be a fatal error.)
180  
181 +This setting can be overridden by using the bf(--log-file=FILE) or
182 +bf(--dparam=logfile=FILE) command-line options.  The former overrides
183 +all the log-file parameters of the daemon and all module settings.
184 +The latter sets the daemon's log file and the default for all the
185 +modules, which still allows modules to override the default setting.
186 +
187  dit(bf(syslog facility)) This parameter allows you to
188  specify the syslog facility name to use when logging messages from the
189  rsync daemon. You may use any standard syslog facility name which is
This page took 0.042923 seconds and 3 git commands to generate.