Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added more local-network IPs to the "hosts allow" rsyncd config
[rsync/rsync.git]
/
options.c
diff --git
a/options.c
b/options.c
index
77cbe10
..
b6eab10
100644
(file)
--- a/
options.c
+++ b/
options.c
@@
-90,6
+90,7
@@
char *files_from = NULL;
int filesfrom_fd = -1;
char *filesfrom_host = NULL;
int eol_nulls = 0;
int filesfrom_fd = -1;
char *filesfrom_host = NULL;
int eol_nulls = 0;
+int protect_args = 0;
int human_readable = 0;
int recurse = 0;
int allow_inc_recurse = 1;
int human_readable = 0;
int recurse = 0;
int allow_inc_recurse = 1;
@@
-397,6
+398,7
@@
void usage(enum logcode F)
rprintf(F," --include-from=FILE read include patterns from FILE\n");
rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n");
rprintf(F," --include-from=FILE read include patterns from FILE\n");
rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n");
+ rprintf(F," -s, --protect-args no space-splitting; only wildcard special-chars\n");
rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n");
rprintf(F," --port=PORT specify double-colon alternate port number\n");
rprintf(F," --sockopts=OPTIONS specify custom TCP options\n");
rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n");
rprintf(F," --port=PORT specify double-colon alternate port number\n");
rprintf(F," --sockopts=OPTIONS specify custom TCP options\n");
@@
-591,6
+593,9
@@
static struct poptOption long_options[] = {
{"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
{"from0", '0', POPT_ARG_VAL, &eol_nulls, 1, 0, 0},
{"no-from0", 0, POPT_ARG_VAL, &eol_nulls, 0, 0, 0},
{"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
{"from0", '0', POPT_ARG_VAL, &eol_nulls, 1, 0, 0},
{"no-from0", 0, POPT_ARG_VAL, &eol_nulls, 0, 0, 0},
+ {"protect-args", 's', POPT_ARG_VAL, &protect_args, 1, 0, 0},
+ {"no-protect-args", 0, POPT_ARG_VAL, &protect_args, 0, 0, 0},
+ {"no-s", 0, POPT_ARG_VAL, &protect_args, 0, 0, 0},
{"numeric-ids", 0, POPT_ARG_VAL, &numeric_ids, 1, 0, 0 },
{"no-numeric-ids", 0, POPT_ARG_VAL, &numeric_ids, 0, 0, 0 },
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
{"numeric-ids", 0, POPT_ARG_VAL, &numeric_ids, 1, 0, 0 },
{"no-numeric-ids", 0, POPT_ARG_VAL, &numeric_ids, 0, 0, 0 },
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
@@
-856,12
+861,13
@@
static void create_refuse_error(int which)
*
* @retval 0 on error, with err_buf containing an explanation
**/
*
* @retval 0 on error, with err_buf containing an explanation
**/
-int parse_arguments(int *argc
, const char ***argv
, int frommain)
+int parse_arguments(int *argc
_p, const char ***argv_p
, int frommain)
{
{
-
int opt
;
+
static poptContext pc
;
char *ref = lp_refuse_options(module_id);
char *ref = lp_refuse_options(module_id);
- const char *arg;
- poptContext pc;
+ const char *arg, **argv = *argv_p;
+ int argc = *argc_p;
+ int opt;
if (ref && *ref)
set_refuse_options(ref);
if (ref && *ref)
set_refuse_options(ref);
@@
-877,8
+883,11
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
/* The context leaks in case of an error, but if there's a
* problem we always exit anyhow. */
/* The context leaks in case of an error, but if there's a
* problem we always exit anyhow. */
- pc = poptGetContext(RSYNC_NAME, *argc, *argv, long_options, 0);
- poptReadDefaultConfig(pc, 0);
+ if (pc)
+ poptFreeContext(pc);
+ pc = poptGetContext(RSYNC_NAME, argc, argv, long_options, 0);
+ if (!am_server)
+ poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
/* most options are handled automatically by popt;
while ((opt = poptGetNextOpt(pc)) != -1) {
/* most options are handled automatically by popt;
@@
-894,7
+903,7
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
/* Disable popt aliases on the server side and
* then start parsing the options again. */
poptFreeContext(pc);
/* Disable popt aliases on the server side and
* then start parsing the options again. */
poptFreeContext(pc);
- pc = poptGetContext(RSYNC_NAME,
*argc, *
argv,
+ pc = poptGetContext(RSYNC_NAME,
argc,
argv,
long_options, 0);
am_server = 1;
}
long_options, 0);
am_server = 1;
}
@@
-922,7
+931,7
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
iconv_opt = NULL;
#endif
poptFreeContext(pc);
iconv_opt = NULL;
#endif
poptFreeContext(pc);
- pc = poptGetContext(RSYNC_NAME,
*argc, *
argv,
+ pc = poptGetContext(RSYNC_NAME,
argc,
argv,
long_daemon_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
long_daemon_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
@@
-957,8
+966,8
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
exit_cleanup(RERR_SYNTAX);
}
exit_cleanup(RERR_SYNTAX);
}
- *argv = poptGetArgs(pc);
- *argc
= count_args(*
argv);
+ *argv
_p = argv
= poptGetArgs(pc);
+ *argc
_p = argc = count_args(
argv);
am_starting_up = 0;
daemon_opt = 0;
am_daemon = 1;
am_starting_up = 0;
daemon_opt = 0;
am_daemon = 1;
@@
-1222,12
+1231,19
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
}
}
}
}
- if (human_readable &&
*
argc == 2) {
+ if (human_readable && argc == 2) {
/* Allow the old meaning of 'h' (--help) on its own. */
usage(FINFO);
exit_cleanup(0);
}
/* Allow the old meaning of 'h' (--help) on its own. */
usage(FINFO);
exit_cleanup(0);
}
+ if (protect_args) {
+ if (!frommain)
+ protect_args = 0;
+ else if (am_server)
+ return 1;
+ }
+
#ifdef ICONV_OPTION
if (iconv_opt) {
if (!am_server && strcmp(iconv_opt, "-") == 0)
#ifdef ICONV_OPTION
if (iconv_opt) {
if (!am_server && strcmp(iconv_opt, "-") == 0)
@@
-1367,13
+1383,13
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
need_messages_from_generator = 1;
}
need_messages_from_generator = 1;
}
- *argv = poptGetArgs(pc);
- *argc
= count_args(*
argv);
+ *argv
_p = argv
= poptGetArgs(pc);
+ *argc
_p = argc = count_args(
argv);
if (sanitize_paths) {
int i;
if (sanitize_paths) {
int i;
- for (i =
*
argc; i-- > 0; )
-
(*argv)[i] = sanitize_path(NULL, (*argv)
[i], "", 0, NULL);
+ for (i = argc; i-- > 0; )
+
argv[i] = sanitize_path(NULL, argv
[i], "", 0, NULL);
if (tmpdir)
tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, NULL);
if (backup_dir)
if (tmpdir)
tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, NULL);
if (backup_dir)
@@
-1558,7
+1574,7
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
if (files_from) {
char *h, *p;
int q;
if (files_from) {
char *h, *p;
int q;
- if (
*argc > 2 || (!am_daemon && *
argc == 1)) {
+ if (
argc > 2 || (!am_daemon &&
argc == 1)) {
usage(FERROR);
exit_cleanup(RERR_SYNTAX);
}
usage(FERROR);
exit_cleanup(RERR_SYNTAX);
}
@@
-1618,10
+1634,10
@@
int parse_arguments(int *argc, const char ***argv, int frommain)
* behave, and also filtering out options that are processed only
* locally.
**/
* behave, and also filtering out options that are processed only
* locally.
**/
-void server_options(char **args,
int *argc
)
+void server_options(char **args,
int *argc_p
)
{
static char argstr[64];
{
static char argstr[64];
- int ac = *argc;
+ int ac = *argc
_p
;
char *arg;
int i, x;
char *arg;
int i, x;
@@
-1634,7
+1650,7
@@
void server_options(char **args,int *argc)
if (daemon_over_rsh > 0) {
args[ac++] = "--daemon";
if (daemon_over_rsh > 0) {
args[ac++] = "--daemon";
- *argc = ac;
+ *argc
_p
= ac;
/* if we're passing --daemon, we're done */
return;
}
/* if we're passing --daemon, we're done */
return;
}
@@
-1962,7
+1978,7
@@
void server_options(char **args,int *argc)
else if (remove_source_files)
args[ac++] = "--remove-sent-files";
else if (remove_source_files)
args[ac++] = "--remove-sent-files";
- *argc = ac;
+ *argc
_p
= ac;
return;
oom:
return;
oom: