From: Wayne Davison Date: Fri, 28 Jan 2005 17:14:14 +0000 (+0000) Subject: Added check to ensure that a read-only daemon doesn't honor X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/commitdiff_plain/8af144e1ca43235afa9d81a545b8a0ae829cbb56 Added check to ensure that a read-only daemon doesn't honor --delete-sent-files. --- diff --git a/remove-sent-files.diff b/remove-sent-files.diff index ffdecd6..5dc442f 100644 --- a/remove-sent-files.diff +++ b/remove-sent-files.diff @@ -4,7 +4,7 @@ command before "make": make proto ---- orig/io.c 2005-01-19 20:11:10 +--- orig/io.c 2005-01-28 06:51:59 +++ io.c 2005-01-10 10:49:17 @@ -244,6 +244,14 @@ static void read_msg_fd(void) read_loop(fd, buf, 4); @@ -38,9 +38,17 @@ command before "make": case MSG_INFO: case MSG_ERROR: if (remaining >= sizeof line) { ---- orig/main.c 2005-01-24 01:43:10 -+++ main.c 2004-08-13 08:24:23 -@@ -43,6 +43,7 @@ extern int list_only; +--- orig/main.c 2005-01-27 22:25:43 ++++ main.c 2005-01-28 17:13:25 +@@ -36,6 +36,7 @@ extern int delete_mode; + extern int delete_before; + extern int delete_after; + extern int delete_excluded; ++extern int delete_sent_files; + extern int daemon_over_rsh; + extern int do_stats; + extern int dry_run; +@@ -43,6 +44,7 @@ extern int list_only; extern int local_server; extern int log_got_error; extern int module_id; @@ -48,7 +56,20 @@ command before "make": extern int orig_umask; extern int copy_links; extern int keep_dirlinks; -@@ -649,6 +650,8 @@ void start_server(int f_in, int f_out, i +@@ -437,6 +439,12 @@ static void do_server_sender(int f_in, i + exit_cleanup(RERR_SYNTAX); + return; + } ++ if (am_daemon && lp_read_only(module_id) && delete_sent_files) { ++ rprintf(FERROR, ++ "ERROR: --delete-sent-files cannot be used with a read-only module\n"); ++ exit_cleanup(RERR_SYNTAX); ++ return; ++ } + + if (!relative_paths && !push_dir(dir)) { + rsyserr(FERROR, errno, "push_dir#3 %s failed", +@@ -671,6 +679,8 @@ void start_server(int f_in, int f_out, i if (am_sender) { keep_dirlinks = 0; /* Must be disabled on the sender. */ @@ -57,7 +78,7 @@ command before "make": recv_filter_list(f_in); if (cvs_exclude) -@@ -731,6 +734,9 @@ int client_run(int f_in, int f_out, pid_ +@@ -753,6 +763,9 @@ int client_run(int f_in, int f_out, pid_ exit_cleanup(status); } @@ -67,7 +88,7 @@ command before "make": if (argc == 0) list_only |= 1; ---- orig/options.c 2005-01-25 03:26:51 +--- orig/options.c 2005-01-28 17:12:13 +++ options.c 2005-01-23 07:30:51 @@ -59,6 +59,7 @@ int delete_during = 0; int delete_before = 0; @@ -77,7 +98,7 @@ command before "make": int one_file_system = 0; int protocol_version = PROTOCOL_VERSION; int sparse_files = 0; -@@ -94,6 +95,7 @@ int bwlimit = 0; +@@ -93,6 +94,7 @@ int bwlimit = 0; size_t bwlimit_writemax = 0; int only_existing = 0; int opt_ignore_existing = 0; @@ -85,7 +106,7 @@ command before "make": int max_delete = 0; OFF_T max_size = 0; int ignore_errors = 0; -@@ -282,6 +284,7 @@ void usage(enum logcode F) +@@ -287,6 +289,7 @@ void usage(enum logcode F) rprintf(F," --delete-during receiver deletes during transfer, not before\n"); rprintf(F," --delete-after receiver deletes after transfer, not before\n"); rprintf(F," --delete-excluded also delete excluded files on the receiving side\n"); @@ -93,7 +114,7 @@ command before "make": rprintf(F," --ignore-errors delete even if there are I/O errors\n"); rprintf(F," --force force deletion of directories even if not empty\n"); rprintf(F," --max-delete=NUM don't delete more than NUM files\n"); -@@ -354,6 +357,7 @@ static struct poptOption long_options[] +@@ -361,6 +364,7 @@ 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 }, @@ -101,7 +122,7 @@ command before "make": {"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 }, {"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 }, {"filter", 'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 }, -@@ -905,6 +909,9 @@ int parse_arguments(int *argc, const cha +@@ -919,6 +923,9 @@ int parse_arguments(int *argc, const cha else if (delete_mode || delete_excluded) delete_mode = delete_before = 1; @@ -111,7 +132,7 @@ command before "make": *argv = poptGetArgs(pc); *argc = count_args(*argv); -@@ -1293,6 +1300,9 @@ void server_options(char **args,int *arg +@@ -1315,6 +1322,9 @@ void server_options(char **args,int *arg if (!implied_dirs && !am_sender) args[ac++] = "--no-implied-dirs"; @@ -121,7 +142,7 @@ command before "make": *argc = ac; return; ---- orig/receiver.c 2005-01-24 01:43:10 +--- orig/receiver.c 2005-01-27 23:57:45 +++ receiver.c 2004-08-13 08:38:51 @@ -42,6 +42,7 @@ extern int basis_dir_cnt; extern int make_backups; @@ -131,16 +152,16 @@ command before "make": extern int module_id; extern int ignore_errors; extern int orig_umask; -@@ -270,7 +271,7 @@ int recv_files(int f_in, struct file_lis +@@ -271,7 +272,7 @@ int recv_files(int f_in, struct file_lis char *fname, fbuf[MAXPATHLEN]; char template[MAXPATHLEN]; char fnametmp[MAXPATHLEN]; - char *fnamecmp, *partialptr; + char *fnamecmp, *partialptr, numbuf[4]; char fnamecmpbuf[MAXPATHLEN]; + uchar *delayed_bits = NULL; struct file_struct *file; - struct stats initial_stats; -@@ -516,7 +517,12 @@ int recv_files(int f_in, struct file_lis +@@ -527,7 +528,12 @@ int recv_files(int f_in, struct file_lis cleanup_disable(); @@ -154,7 +175,7 @@ command before "make": int msgtype = csum_length == SUM_LENGTH || read_batch ? FERROR : FINFO; if (msgtype == FERROR || verbose) { -@@ -540,9 +546,8 @@ int recv_files(int f_in, struct file_lis +@@ -551,9 +557,8 @@ int recv_files(int f_in, struct file_lis keptstr, redostr); } if (csum_length != SUM_LENGTH) { @@ -166,7 +187,7 @@ command before "make": } } } ---- orig/rsync.h 2005-01-25 00:53:58 +--- orig/rsync.h 2005-01-28 17:12:14 +++ rsync.h 2004-07-03 20:17:10 @@ -60,6 +60,7 @@ #define FLAG_DEL_START (1<<0) @@ -176,7 +197,7 @@ command before "make": /* update this if you make incompatible changes */ #define PROTOCOL_VERSION 29 -@@ -144,6 +145,7 @@ enum logcode { FERROR=1, FINFO=2, FLOG=3 +@@ -145,6 +146,7 @@ enum logcode { FERROR=1, FINFO=2, FLOG=3 /* Messages types that are sent over the message channel. The logcode * values must all be present here with identical numbers. */ enum msgcode { @@ -184,9 +205,9 @@ command before "make": MSG_DONE=5, /* current phase is done */ MSG_REDO=4, /* reprocess indicated flist index */ MSG_ERROR=FERROR, MSG_INFO=FINFO, MSG_LOG=FLOG, /* remote logging */ ---- orig/rsync.yo 2005-01-25 03:26:51 +--- orig/rsync.yo 2005-01-28 17:12:14 +++ rsync.yo 2005-01-23 07:31:03 -@@ -347,6 +347,7 @@ verb( +@@ -349,6 +349,7 @@ verb( --delete-during receiver deletes during xfer, not before --delete-after receiver deletes after transfer, not before --delete-excluded also delete excluded files on receiver @@ -194,7 +215,7 @@ command before "make": --ignore-errors delete even if there are I/O errors --force force deletion of dirs even if not empty --max-delete=NUM don't delete more than NUM files -@@ -725,6 +726,11 @@ receiving side that are not on the sendi +@@ -738,6 +739,11 @@ receiving side that are not on the sendi delete any files on the receiving side that are excluded (see --exclude). See --delete (which is implied) for more details on file-deletion.