X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/852e763b89af5145c4b52d5da649d625a7ff3f43..d48810ba5b0b8d09b272092a70da1255c2346ab8:/options.c diff --git a/options.c b/options.c index 7972121b..f2d23f62 100644 --- a/options.c +++ b/options.c @@ -25,11 +25,12 @@ #include "zlib/zlib.h" extern int module_id; +extern int local_server; extern int sanitize_paths; extern int daemon_over_rsh; extern unsigned int module_dirlen; extern struct filter_list_struct filter_list; -extern struct filter_list_struct server_filter_list; +extern struct filter_list_struct daemon_filter_list; int make_backups = 0; @@ -577,6 +578,7 @@ static struct poptOption long_options[] = { {"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 }, {"fuzzy", 'y', POPT_ARG_VAL, &fuzzy_basis, 1, 0, 0 }, {"no-fuzzy", 0, POPT_ARG_VAL, &fuzzy_basis, 0, 0, 0 }, + {"no-y", 0, POPT_ARG_VAL, &fuzzy_basis, 0, 0, 0 }, {"compress", 'z', POPT_ARG_NONE, 0, 'z', 0, 0 }, {"no-compress", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 }, {"no-z", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 }, @@ -888,7 +890,7 @@ static void create_refuse_error(int which) * * @retval 0 on error, with err_buf containing an explanation **/ -int parse_arguments(int *argc_p, const char ***argv_p, int frommain) +int parse_arguments(int *argc_p, const char ***argv_p) { static poptContext pc; char *ref = lp_refuse_options(module_id); @@ -900,8 +902,10 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) set_refuse_options(ref); if (am_daemon) { set_refuse_options("log-file*"); +#ifdef ICONV_OPTION if (!*lp_charset(module_id)) set_refuse_options("iconv"); +#endif } #ifdef ICONV_OPTION @@ -1028,8 +1032,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) case OPT_INCLUDE_FROM: arg = poptGetOptArg(pc); if (sanitize_paths) - arg = sanitize_path(NULL, arg, NULL, 0); - if (server_filter_list.head) { + arg = sanitize_path(NULL, arg, NULL, 0, SP_DEFAULT); + if (daemon_filter_list.head) { int rej; char *dir, *cp = strdup(arg); if (!cp) @@ -1038,7 +1042,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) goto options_rejected; dir = cp + (*cp == '/' ? module_dirlen : 0); clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS); - rej = check_filter(&server_filter_list, dir, 0) < 0; + rej = check_filter(&daemon_filter_list, dir, 0) < 0; free(cp); if (rej) goto options_rejected; @@ -1091,8 +1095,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) break; case 'q': - if (frommain) - quiet++; + quiet++; break; case 'x': @@ -1289,12 +1292,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) } #endif - if (protect_args == 1) { - if (!frommain) - protect_args = 0; - else if (am_server) - return 1; - } + if (protect_args == 1 && am_server) + return 1; #ifndef SUPPORT_LINKS if (preserve_links && !am_sender) { @@ -1314,7 +1313,13 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) } #endif -#ifndef SUPPORT_XATTRS +#ifdef SUPPORT_XATTRS + if (am_root < 0 && preserve_xattrs > 1) { + snprintf(err_buf, sizeof err_buf, + "--fake-super conflicts with -XX\n"); + return 0; + } +#else if (am_root < 0) { snprintf(err_buf, sizeof err_buf, "--fake-super requires an rsync with extended attributes enabled\n"); @@ -1433,14 +1438,14 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) if (sanitize_paths) { int i; for (i = argc; i-- > 0; ) - argv[i] = sanitize_path(NULL, argv[i], "", 0); + argv[i] = sanitize_path(NULL, argv[i], "", 0, SP_KEEP_DOT_DIRS); if (tmpdir) - tmpdir = sanitize_path(NULL, tmpdir, NULL, 0); + tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, SP_DEFAULT); if (backup_dir) - backup_dir = sanitize_path(NULL, backup_dir, NULL, 0); + backup_dir = sanitize_path(NULL, backup_dir, NULL, 0, SP_DEFAULT); } - if (server_filter_list.head && !am_sender) { - struct filter_list_struct *elp = &server_filter_list; + if (daemon_filter_list.head && !am_sender) { + struct filter_list_struct *elp = &daemon_filter_list; if (tmpdir) { char *dir; if (!*tmpdir) @@ -1645,14 +1650,14 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain) } } else { if (sanitize_paths) - files_from = sanitize_path(NULL, files_from, NULL, 0); - if (server_filter_list.head) { + files_from = sanitize_path(NULL, files_from, NULL, 0, SP_DEFAULT); + if (daemon_filter_list.head) { char *dir; if (!*files_from) goto options_rejected; dir = files_from + (*files_from == '/' ? module_dirlen : 0); clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS); - if (check_filter(&server_filter_list, dir, 0) < 0) + if (check_filter(&daemon_filter_list, dir, 0) < 0) goto options_rejected; } filesfrom_fd = open(files_from, O_RDONLY|O_BINARY); @@ -1826,7 +1831,7 @@ void server_options(char **args, int *argc_p) } #endif - if (protect_args) /* initial args break here */ + if (protect_args && !local_server) /* unprotected args stop here */ args[ac++] = NULL; if (list_only > 1)