Tweak the copyright year.
[rsync.git] / options.c
index 308443bdab3bad80a7d7a4d980c3f7aa098045fd..e5b0cb68280ed5e1d5cfea93e314c1c67c74ebe9 100644 (file)
--- a/options.c
+++ b/options.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
  * Copyright (C) 2000, 2001, 2002 Martin Pool <mbp@samba.org>
- * Copyright (C) 2002-2015 Wayne Davison
+ * Copyright (C) 2002-2019 Wayne Davison
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -612,7 +612,7 @@ static void print_rsync_version(enum logcode f)
 
        rprintf(f, "%s  version %s  protocol version %d%s\n",
                RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
-       rprintf(f, "Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.\n");
+       rprintf(f, "Copyright (C) 1996-2019 by Andrew Tridgell, Wayne Davison, and others.\n");
        rprintf(f, "Web site: http://rsync.samba.org/\n");
        rprintf(f, "Capabilities:\n");
        rprintf(f, "    %d-bit files, %d-bit inums, %d-bit timestamps, %d-bit long ints,\n",
@@ -714,7 +714,7 @@ void usage(enum logcode F)
 #ifdef SUPPORT_XATTRS
   rprintf(F,"     --fake-super            store/recover privileged attrs using xattrs\n");
 #endif
-  rprintf(F," -S, --sparse                handle sparse files efficiently\n");
+  rprintf(F," -S, --sparse                turn sequences of nulls into sparse blocks\n");
 #ifdef SUPPORT_PREALLOCATION
   rprintf(F,"     --preallocate           allocate dest files before writing them\n");
 #else
@@ -1281,6 +1281,22 @@ static void create_refuse_error(int which)
        }
 }
 
+/* This is used to make sure that --daemon & --server cannot be aliased to
+ * something else. These options have always disabled popt aliases for the
+ * parsing of a daemon or server command-line, but we have to make sure that
+ * these options cannot vanish so that the alias disabling can take effect. */
+static void popt_unalias(poptContext con, const char *opt)
+{
+       struct poptAlias unalias;
+
+       unalias.longName = opt + 2; /* point past the leading "--" */
+       unalias.shortName = '\0';
+       unalias.argc = 1;
+       unalias.argv = new_array(const char*, 1);
+       unalias.argv[0] = strdup(opt);
+
+       poptAddAlias(con, unalias, 0);
+}
 
 /**
  * Process command line arguments.  Called on both local and remote.
@@ -1297,7 +1313,12 @@ int parse_arguments(int *argc_p, const char ***argv_p)
        const char *arg, **argv = *argv_p;
        int argc = *argc_p;
        int opt;
+       int orig_protect_args = protect_args;
 
+       if (argc == 0) {
+               strlcpy(err_buf, "argc is zero!\n", sizeof err_buf);
+               return 0;
+       }
        if (ref && *ref)
                set_refuse_options(ref);
        if (am_daemon) {
@@ -1320,8 +1341,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
        if (pc)
                poptFreeContext(pc);
        pc = poptGetContext(RSYNC_NAME, argc, argv, long_options, 0);
-       if (!am_server)
+       if (!am_server) {
                poptReadDefaultConfig(pc, 0);
+               popt_unalias(pc, "--daemon");
+               popt_unalias(pc, "--server");
+       }
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                /* most options are handled automatically by popt;
@@ -1915,6 +1939,10 @@ int parse_arguments(int *argc_p, const char ***argv_p)
        if (fuzzy_basis > 1)
                fuzzy_basis = basis_dir_cnt + 1;
 
+       /* Don't let the client reset protect_args if it was already processed */
+       if (orig_protect_args == 2 && am_server)
+               protect_args = orig_protect_args;
+
        if (protect_args == 1 && am_server)
                return 1;
 
@@ -2237,14 +2265,6 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        bwlimit_writemax = 512;
        }
 
-       if (sparse_files && inplace) {
-               /* Note: we don't check for this below, because --append is
-                * OK with --sparse (as long as redos are handled right). */
-               snprintf(err_buf, sizeof err_buf,
-                        "--sparse cannot be used with --inplace\n");
-               return 0;
-       }
-
        if (append_mode) {
                if (whole_file > 0) {
                        snprintf(err_buf, sizeof err_buf,