+ snprintf(err_buf, sizeof err_buf,
+ "--write-batch and --read-batch can not be used together\n");
+ return 0;
+ }
+ if (write_batch || read_batch) {
+ if (dry_run) {
+ snprintf(err_buf, sizeof err_buf,
+ "--%s-batch cannot be used with --dry_run (-n)\n",
+ write_batch ? "write" : "read");
+ return 0;
+ }
+ if (am_server) {
+ rprintf(FINFO,
+ "ignoring --%s-batch option sent to server\n",
+ write_batch ? "write" : "read");
+ /* We don't actually exit_cleanup(), so that we can
+ * still service older version clients that still send
+ * batch args to server. */
+ read_batch = write_batch = 0;
+ batch_name = NULL;
+ }
+ }
+ if (read_batch && files_from) {
+ snprintf(err_buf, sizeof err_buf,
+ "--read-batch cannot be used with --files-from\n");
+ return 0;
+ }
+ if (batch_name && strlen(batch_name) > MAX_BATCH_NAME_LEN) {
+ snprintf(err_buf, sizeof err_buf,
+ "the batch-file name must be %d characters or less.\n",
+ MAX_BATCH_NAME_LEN);
+ return 0;
+ }
+
+ if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {
+ snprintf(err_buf, sizeof err_buf,
+ "the --temp-dir path is WAY too long.\n");
+ return 0;
+ }
+
+ if (archive_mode) {
+ if (!files_from)
+ recurse = 1;
+#if SUPPORT_LINKS
+ preserve_links = 1;
+#endif
+ preserve_perms = 1;
+ preserve_times = 1;
+ preserve_gid = 1;
+ preserve_uid = 1;
+ preserve_devices = 1;
+ }
+
+ if (relative_paths < 0)
+ relative_paths = files_from? 1 : 0;
+
+ *argv = poptGetArgs(pc);
+ if (*argv)
+ *argc = count_args(*argv);
+ else
+ *argc = 0;
+
+ 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;