Added get_xattr_acl(), set_xattr_acl(), and del_def_xattr_acl().
[rsync/rsync.git] / options.c
index 9b1d4c4..ff7c143 100644 (file)
--- a/options.c
+++ b/options.c
@@ -20,6 +20,7 @@
  */
 
 #include "rsync.h"
+#include "ifuncs.h"
 #include <popt.h>
 #include "zlib/zlib.h"
 
@@ -463,7 +464,6 @@ static struct poptOption long_options[] = {
   {"no-inc-recursive", 0,  POPT_ARG_VAL,    &allow_inc_recurse, 0, 0, 0 },
   {"i-r",              0,  POPT_ARG_VAL,    &allow_inc_recurse, 1, 0, 0 },
   {"no-i-r",           0,  POPT_ARG_VAL,    &allow_inc_recurse, 0, 0, 0 },
-  {"no-ir",            0,  POPT_ARG_VAL,    &allow_inc_recurse, 0, 0, 0 }, /* XXX remove soon */
   {"dirs",            'd', POPT_ARG_VAL,    &xfer_dirs, 2, 0, 0 },
   {"no-dirs",          0,  POPT_ARG_VAL,    &xfer_dirs, 0, 0, 0 },
   {"no-d",             0,  POPT_ARG_VAL,    &xfer_dirs, 0, 0, 0 },
@@ -878,7 +878,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
                set_refuse_options("log-file*");
 
 #ifdef ICONV_OPTION
-       if (!am_daemon && (arg = getenv("RSYNC_ICONV")) != NULL && *arg)
+       if (!am_daemon && !protect_args && (arg = getenv("RSYNC_ICONV")) != NULL && *arg)
                iconv_opt = strdup(arg);
 #endif
 
@@ -1003,15 +1003,17 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
                        if (sanitize_paths)
                                arg = sanitize_path(NULL, arg, NULL, 0, NULL);
                        if (server_filter_list.head) {
+                               int rej;
                                char *cp = strdup(arg);
                                if (!cp)
                                        out_of_memory("parse_arguments");
                                if (!*cp)
                                        goto options_rejected;
                                clean_fname(cp, 1);
-                               if (check_filter(&server_filter_list, cp, 0) < 0)
-                                       goto options_rejected;
+                               rej = check_filter(&server_filter_list, cp, 0) < 0;
                                free(cp);
+                               if (rej)
+                                       goto options_rejected;
                        }
                        parse_filter_file(&filter_list, arg,
                                opt == OPT_INCLUDE_FROM ? MATCHFLG_INCLUDE : 0,
@@ -1240,22 +1242,23 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
                exit_cleanup(0);
        }
 
-       if (protect_args) {
-               if (!frommain)
-                       protect_args = 0;
-               else if (am_server)
-                       return 1;
-       }
-
 #ifdef ICONV_OPTION
-       if (iconv_opt) {
+       if (iconv_opt && protect_args != 2) {
                if (!am_server && strcmp(iconv_opt, "-") == 0)
                        iconv_opt = NULL;
                else
                        need_unsorted_flist = 1;
        }
+       setup_iconv();
 #endif
 
+       if (protect_args == 1) {
+               if (!frommain)
+                       protect_args = 0;
+               else if (am_server)
+                       return 1;
+       }
+
 #ifndef SUPPORT_LINKS
        if (preserve_links && !am_sender) {
                snprintf(err_buf, sizeof err_buf,
@@ -1663,6 +1666,10 @@ void server_options(char **args, int *argc_p)
 
        x = 1;
        argstr[0] = '-';
+
+       if (protect_args)
+               argstr[x++] = 's';
+
        for (i = 0; i < verbose; i++)
                argstr[x++] = 'v';
 
@@ -1765,6 +1772,22 @@ void server_options(char **args, int *argc_p)
        if (x != 1)
                args[ac++] = argstr;
 
+#ifdef ICONV_OPTION
+       if (iconv_opt) {
+               char *set = strchr(iconv_opt, ',');
+               if (set)
+                       set++;
+               else
+                       set = iconv_opt;
+               if (asprintf(&arg, "--iconv=%s", set) < 0)
+                       goto oom;
+               args[ac++] = arg;
+       }
+#endif
+
+       if (protect_args) /* initial args break here */
+               args[ac++] = NULL;
+
        if (list_only > 1)
                args[ac++] = "--list-only";
 
@@ -1800,19 +1823,6 @@ void server_options(char **args, int *argc_p)
                        args[ac++] = "--log-format=X";
        }
 
-#ifdef ICONV_OPTION
-       if (iconv_opt) {
-               char *set = strchr(iconv_opt, ',');
-               if (set)
-                       set++;
-               else
-                       set = iconv_opt;
-               if (asprintf(&arg, "--iconv=%s", set) < 0)
-                       goto oom;
-               args[ac++] = arg;
-       }
-#endif
-
        if (block_size) {
                if (asprintf(&arg, "-B%lu", block_size) < 0)
                        goto oom;
@@ -1922,7 +1932,7 @@ void server_options(char **args, int *argc_p)
                args[ac++] = "--numeric-ids";
 
        if (!allow_inc_recurse)
-               args[ac++] = "--no-ir"; /* XXX change to --no-i-r soon */
+               args[ac++] = "--no-i-r";
 
        if (am_sender) {
                if (ignore_existing)
@@ -1970,7 +1980,8 @@ void server_options(char **args, int *argc_p)
                if (!relative_paths)
                        args[ac++] = "--no-relative";
        }
-       if (relative_paths && !implied_dirs && !am_sender)
+       /* It's OK that this checks the upper-bound of the protocol_version. */
+       if (relative_paths && !implied_dirs && (!am_sender || protocol_version >= 30))
                args[ac++] = "--no-implied-dirs";
 
        if (fuzzy_basis && am_sender)