X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/6dc9b74bc661cf421dd2e9db0af9eb73824cced8..2dc7b8bd0e8d4a2d91334b9bb458df146b1700e8:/options.c diff --git a/options.c b/options.c index f84c32ff..5fd29932 100644 --- a/options.c +++ b/options.c @@ -65,7 +65,7 @@ int delete_during = 0; int delete_before = 0; int delete_after = 0; int delete_excluded = 0; -int remove_sent_files = 0; +int remove_source_files = 0; int one_file_system = 0; int protocol_version = PROTOCOL_VERSION; int sparse_files = 0; @@ -164,6 +164,7 @@ char *dest_option = NULL; int verbose = 0; int quiet = 0; +int output_motd = 1; int log_before_transfer = 0; int stdout_format_has_i = 0; int stdout_format_has_o_or_i = 0; @@ -281,6 +282,7 @@ void usage(enum logcode F) rprintf(F,"Options\n"); rprintf(F," -v, --verbose increase verbosity\n"); rprintf(F," -q, --quiet suppress non-error messages\n"); + rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n"); rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n"); rprintf(F," -a, --archive archive mode; same as -rlptgoD (no -H)\n"); rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n"); @@ -303,7 +305,7 @@ void usage(enum logcode F) rprintf(F," -H, --hard-links preserve hard links\n"); rprintf(F," -p, --perms preserve permissions\n"); rprintf(F," -E, --executability preserve the file's executability\n"); - rprintf(F," --chmod=CHMOD change destination permissions\n"); + rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n"); rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); @@ -321,7 +323,7 @@ void usage(enum logcode F) rprintf(F," --rsync-path=PROGRAM specify the rsync to run on the remote machine\n"); rprintf(F," --existing skip creating new files on receiver\n"); rprintf(F," --ignore-existing skip updating files that already exist on receiver\n"); - rprintf(F," --remove-sent-files sender removes successfully sent files (non-dirs)\n"); + rprintf(F," --remove-source-files sender removes synchronized files (non-dirs)\n"); rprintf(F," --del an alias for --delete-during\n"); rprintf(F," --delete delete extraneous files from destination dirs\n"); rprintf(F," --delete-before receiver deletes before transfer (default)\n"); @@ -407,6 +409,8 @@ static struct poptOption long_options[] = { {"no-verbose", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 }, {"no-v", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 }, {"quiet", 'q', POPT_ARG_NONE, 0, 'q', 0, 0 }, + {"motd", 0, POPT_ARG_VAL, &output_motd, 1, 0, 0 }, + {"no-motd", 0, POPT_ARG_VAL, &output_motd, 0, 0, 0 }, {"stats", 0, POPT_ARG_NONE, &do_stats, 0, 0, 0 }, {"human-readable", 'h', POPT_ARG_NONE, 0, 'h', 0, 0}, {"dry-run", 'n', POPT_ARG_NONE, &dry_run, 0, 0, 0 }, @@ -475,7 +479,8 @@ static struct poptOption long_options[] = { {"delete-during", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 }, {"delete-after", 0, POPT_ARG_NONE, &delete_after, 0, 0, 0 }, {"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 }, - {"remove-sent-files",0, POPT_ARG_NONE, &remove_sent_files, 0, 0, 0 }, + {"remove-sent-files",0, POPT_ARG_VAL, &remove_source_files, 2, 0, 0 }, /* deprecated */ + {"remove-source-files",0,POPT_ARG_VAL, &remove_source_files, 1, 0, 0 }, {"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 }, {"ignore-errors", 0, POPT_ARG_NONE, &ignore_errors, 0, 0, 0 }, {"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 }, @@ -612,8 +617,9 @@ static char err_buf[200]; void option_error(void) { if (!err_buf[0]) { - strcpy(err_buf, "Error parsing options: " - "option may be supported on client but not on server?\n"); + strlcpy(err_buf, "Error parsing options: option may " + "be supported on client but not on server?\n", + sizeof err_buf); } rprintf(FERROR, RSYNC_NAME ": %s", err_buf); @@ -709,9 +715,9 @@ static OFF_T parse_size_arg(char **size_arg, char def_suf) const char *arg; OFF_T size = 1; - for (arg = *size_arg; isdigit(*(uchar*)arg); arg++) {} + for (arg = *size_arg; isDigit(arg); arg++) {} if (*arg == '.') - for (arg++; isdigit(*(uchar*)arg); arg++) {} + for (arg++; isDigit(arg); arg++) {} switch (*arg && *arg != '+' && *arg != '-' ? *arg++ : def_suf) { case 'b': case 'B': reps = 0; @@ -831,7 +837,9 @@ int parse_arguments(int *argc, const char ***argv, int frommain) case OPT_DAEMON: if (am_daemon) { - strcpy(err_buf, "Attempt to hack rsync thwarted!\n"); + strlcpy(err_buf, + "Attempt to hack rsync thwarted!\n", + sizeof err_buf); return 0; } poptFreeContext(pc); @@ -901,10 +909,8 @@ int parse_arguments(int *argc, const char ***argv, int frommain) case OPT_EXCLUDE_FROM: case OPT_INCLUDE_FROM: arg = poptGetOptArg(pc); - if (sanitize_paths) { + if (sanitize_paths) arg = sanitize_path(NULL, arg, NULL, 0, NULL); - die_on_unsafe_path((char*)arg, 0); - } if (server_filter_list.head) { char *cp = strdup(arg); if (!cp) @@ -1204,8 +1210,8 @@ int parse_arguments(int *argc, const char ***argv, int frommain) return 0; } - if (remove_sent_files) { - /* We only want to infer this refusal of --remove-sent-files + if (remove_source_files) { + /* We only want to infer this refusal of --remove-source-files * via the refusal of "delete", not any of the "delete-FOO" * options. */ if (refused_delete && am_sender) { @@ -1222,14 +1228,10 @@ int parse_arguments(int *argc, const char ***argv, int frommain) int i; for (i = *argc; i-- > 0; ) (*argv)[i] = sanitize_path(NULL, (*argv)[i], "", 0, NULL); - if (tmpdir) { + if (tmpdir) tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, NULL); - die_on_unsafe_path(tmpdir, 0); - } - if (backup_dir) { + if (backup_dir) backup_dir = sanitize_path(NULL, backup_dir, NULL, 0, NULL); - die_on_unsafe_path(backup_dir, 0); - } } if (server_filter_list.head && !am_sender) { struct filter_list_struct *elp = &server_filter_list; @@ -1396,7 +1398,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain) clean_fname(partial_dir, 1); if (!*partial_dir || strcmp(partial_dir, ".") == 0) partial_dir = NULL; - else if (*partial_dir != '/') { + else if (*partial_dir != '/' && !am_server) { parse_rule(&filter_list, partial_dir, MATCHFLG_NO_PREFIXES|MATCHFLG_DIRECTORY, 0); } @@ -1504,7 +1506,7 @@ void server_options(char **args,int *argc) argstr[x++] = 'n'; if (preserve_links) argstr[x++] = 'l'; - if (xfer_dirs > (recurse || !delete_mode || !am_sender)) + if (xfer_dirs > (recurse || !delete_mode || !am_sender ? 1 : 0)) argstr[x++] = 'd'; if (am_sender) { if (keep_dirlinks) @@ -1756,7 +1758,9 @@ void server_options(char **args,int *argc) if (fuzzy_basis && am_sender) args[ac++] = "--fuzzy"; - if (remove_sent_files) + if (remove_source_files == 1) + args[ac++] = "--remove-source-files"; + else if (remove_source_files) args[ac++] = "--remove-sent-files"; *argc = ac; @@ -1777,10 +1781,10 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr) { char *p; int not_host; + int hostlen; if (port_ptr && strncasecmp(URL_PREFIX, s, strlen(URL_PREFIX)) == 0) { char *path; - int hostlen; s += strlen(URL_PREFIX); if ((p = strchr(s, '/')) != NULL) { hostlen = p - s; @@ -1809,6 +1813,7 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr) if (*s == '[' && (p = strchr(s, ']')) != NULL && p[1] == ':') { s++; + hostlen = p - s; *p = '\0'; not_host = strchr(s, '/') || !strchr(s, ':'); *p = ']'; @@ -1818,6 +1823,7 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr) } else { if (!(p = strchr(s, ':'))) return NULL; + hostlen = p - s; *p = '\0'; not_host = strchr(s, '/') != NULL; *p = ':'; @@ -1825,8 +1831,8 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr) return NULL; } - *host_ptr = new_array(char, p - s + 1); - strlcpy(*host_ptr, s, p - s + 1); + *host_ptr = new_array(char, hostlen + 1); + strlcpy(*host_ptr, s, hostlen + 1); if (p[1] == ':') { if (port_ptr && !*port_ptr)