+ if (sanitize_paths) {
+ int i;
+ for (i = *argc; i-- > 0; )
+ (*argv)[i] = sanitize_path(NULL, (*argv)[i], "", 0);
+ if (tmpdir)
+ tmpdir = sanitize_path(NULL, tmpdir, NULL, 0);
+ if (partial_dir)
+ partial_dir = sanitize_path(NULL, partial_dir, NULL, 0);
+ if (compare_dest)
+ compare_dest = sanitize_path(NULL, compare_dest, NULL, 0);
+ if (backup_dir)
+ backup_dir = sanitize_path(NULL, backup_dir, NULL, 0);
+ if (files_from)
+ files_from = sanitize_path(NULL, files_from, NULL, 0);
+ }
+ if (server_exclude_list.head && !am_sender) {
+ struct exclude_list_struct *elp = &server_exclude_list;
+ if (tmpdir) {
+ clean_fname(tmpdir, 1);
+ if (check_exclude(elp, tmpdir, 1) < 0)
+ goto options_rejected;
+ }
+ if (partial_dir) {
+ clean_fname(partial_dir, 1);
+ if (check_exclude(elp, partial_dir, 1) < 0)
+ goto options_rejected;
+ }
+ if (compare_dest) {
+ clean_fname(compare_dest, 1);
+ if (check_exclude(elp, compare_dest, 1) < 0)
+ goto options_rejected;
+ }
+ if (backup_dir) {
+ clean_fname(backup_dir, 1);
+ if (check_exclude(elp, backup_dir, 1) < 0)
+ goto options_rejected;
+ }
+ }
+ if (server_exclude_list.head && files_from) {
+ clean_fname(files_from, 1);
+ if (check_exclude(&server_exclude_list, files_from, 0) < 0) {
+ options_rejected:
+ snprintf(err_buf, sizeof err_buf,
+ "Your options have been rejected by the server.\n");
+ return 0;
+ }
+ }
+
+ if (daemon_opt) {
+ daemon_opt = 0;
+ am_daemon = 1;
+ return 1;
+ }
+
+ if (!backup_suffix)
+ backup_suffix = backup_dir ? "" : BACKUP_SUFFIX;
+ backup_suffix_len = strlen(backup_suffix);
+ if (strchr(backup_suffix, '/') != NULL) {
+ snprintf(err_buf, sizeof err_buf,
+ "--suffix cannot contain slashes: %s\n",
+ backup_suffix);
+ return 0;
+ }
+ if (backup_dir) {
+ backup_dir_len = strlcpy(backup_dir_buf, backup_dir, sizeof backup_dir_buf);
+ backup_dir_remainder = sizeof backup_dir_buf - backup_dir_len;
+ if (backup_dir_remainder < 32) {
+ snprintf(err_buf, sizeof err_buf,
+ "the --backup-dir path is WAY too long.\n");
+ return 0;
+ }
+ if (backup_dir_buf[backup_dir_len - 1] != '/') {
+ backup_dir_buf[backup_dir_len++] = '/';
+ backup_dir_buf[backup_dir_len] = '\0';
+ }
+ if (verbose > 1 && !am_sender)
+ rprintf(FINFO, "backup_dir is %s\n", backup_dir_buf);
+ } else if (!backup_suffix_len && (!am_server || !am_sender)) {
+ snprintf(err_buf, sizeof err_buf,
+ "--suffix cannot be a null string without --backup-dir\n");
+ return 0;
+ }
+
+ if (do_progress && !verbose)
+ verbose = 1;
+
+ if (bwlimit) {
+ bwlimit_writemax = (size_t)bwlimit * 128;
+ if (bwlimit_writemax < 512)
+ bwlimit_writemax = 512;
+ }
+
+ if (inplace) {
+#if HAVE_FTRUNCATE
+ if (partial_dir) {
+ snprintf(err_buf, sizeof err_buf,
+ "--inplace cannot be used with --partial-dir\n");
+ return 0;
+ }
+ keep_partial = 0;
+#else
+ snprintf(err_buf, sizeof err_buf,
+ "--inplace is not supported on this %s\n",
+ am_server ? "server" : "client");
+ return 0;
+#endif
+ if (compare_dest) {
+ snprintf(err_buf, sizeof err_buf,
+ "--inplace does not yet work with %s\n",
+ link_dest ? "--link-dest" : "--compare-dest");
+ return 0;
+ }
+ } else {
+ if (keep_partial && !partial_dir)
+ partial_dir = getenv("RSYNC_PARTIAL_DIR");
+ if (partial_dir) {
+ if (!*partial_dir || strcmp(partial_dir, ".") == 0)
+ partial_dir = NULL;
+ keep_partial = 1;
+ }
+ }
+