]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Don't send daemon-config filter-action messages back to the user.
authorWayne Davison <wayned@samba.org>
Mon, 24 Mar 2008 17:09:00 +0000 (10:09 -0700)
committerWayne Davison <wayned@samba.org>
Mon, 24 Mar 2008 17:14:59 +0000 (10:14 -0700)
NEWS
exclude.c
flist.c
generator.c
main.c
options.c
receiver.c
t_stub.c
util.c

diff --git a/NEWS b/NEWS
index 32e6ccde43f293fca20350013db1e50e64fb89cc..157dbb6b8491a63e898b1d5446970e4267c3f729 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -47,7 +47,8 @@ Changes since 3.0.0:
     - Improved the daemon-exclude handling to do a better job of applying the
       exclude rules to path entries.  It also sends the user an error just as
       if the files were actually missing (instead of silently ignoring the
-      user's args).
+      user's args), and avoids sending the user the filter-action messages
+      for these non-user-initiated rules.
 
     - Fixed some glitches with the dry-run code's missing-directory
       handling, including a problem when combined with --fuzzy.
index 1ba5544350a508f4706bf5b06227b919ca2b7b7f..9db8f1af17e516c423033e8b4d44095082b38e76 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -620,7 +620,7 @@ static int rule_matches(const char *fname, struct filter_struct *ex, int name_is
 }
 
 
-static void report_filter_result(char const *name,
+static void report_filter_result(enum logcode code, char const *name,
                                  struct filter_struct const *ent,
                                  int name_is_dir, const char *type)
 {
@@ -632,7 +632,7 @@ static void report_filter_result(char const *name,
                static char *actions[2][2]
                    = { {"show", "hid"}, {"risk", "protect"} };
                const char *w = who_am_i();
-               rprintf(FINFO, "[%s] %sing %s %s because of pattern %s%s%s\n",
+               rprintf(code, "[%s] %sing %s %s because of pattern %s%s%s\n",
                    w, actions[*w!='s'][!(ent->match_flags&MATCHFLG_INCLUDE)],
                    name_is_dir ? "directory" : "file", name, ent->pattern,
                    ent->match_flags & MATCHFLG_DIRECTORY ? "/" : "", type);
@@ -644,7 +644,8 @@ static void report_filter_result(char const *name,
  * Return -1 if file "name" is defined to be excluded by the specified
  * exclude list, 1 if it is included, and 0 if it was not matched.
  */
-int check_filter(struct filter_list_struct *listp, const char *name, int name_is_dir)
+int check_filter(struct filter_list_struct *listp, enum logcode code,
+                const char *name, int name_is_dir)
 {
        struct filter_struct *ent;
 
@@ -652,22 +653,22 @@ int check_filter(struct filter_list_struct *listp, const char *name, int name_is
                if (ignore_perishable && ent->match_flags & MATCHFLG_PERISHABLE)
                        continue;
                if (ent->match_flags & MATCHFLG_PERDIR_MERGE) {
-                       int rc = check_filter(ent->u.mergelist, name,
+                       int rc = check_filter(ent->u.mergelist, code, name,
                                              name_is_dir);
                        if (rc)
                                return rc;
                        continue;
                }
                if (ent->match_flags & MATCHFLG_CVS_IGNORE) {
-                       int rc = check_filter(&cvs_filter_list, name,
+                       int rc = check_filter(&cvs_filter_list, code, name,
                                              name_is_dir);
                        if (rc)
                                return rc;
                        continue;
                }
                if (rule_matches(name, ent, name_is_dir)) {
-                       report_filter_result(name, ent, name_is_dir,
-                                             listp->debug_type);
+                       report_filter_result(code, name, ent, name_is_dir,
+                                            listp->debug_type);
                        return ent->match_flags & MATCHFLG_INCLUDE ? 1 : -1;
                }
        }
@@ -1036,7 +1037,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
                if (daemon_filter_list.head) {
                        strlcpy(line, fname, sizeof line);
                        clean_fname(line, CFN_COLLAPSE_DOT_DOT_DIRS);
-                       if (check_filter(&daemon_filter_list, line, 0) < 0)
+                       if (check_filter(&daemon_filter_list, FLOG, line, 0) < 0)
                                fp = NULL;
                        else
                                fp = fopen(line, "rb");
diff --git a/flist.c b/flist.c
index 0a8ace99a305f5b291f989f8fd351ec0c4bba658..254d1c7be7ef417ae66a4641f06a862de7084e5b 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -235,7 +235,7 @@ int link_stat(const char *path, STRUCT_STAT *stp, int follow_dirlinks)
 static inline int is_daemon_excluded(const char *fname, int is_dir)
 {
        if (daemon_filter_list.head
-        && check_filter(&daemon_filter_list, fname, is_dir) < 0) {
+        && check_filter(&daemon_filter_list, FLOG, fname, is_dir) < 0) {
                errno = ENOENT;
                return 1;
        }
@@ -250,7 +250,7 @@ static inline int path_is_daemon_excluded(char *path, int ignore_filename)
                while ((slash = strchr(slash+1, '/')) != NULL) {
                        int ret;
                        *slash = '\0';
-                       ret = check_filter(&daemon_filter_list, path, 1);
+                       ret = check_filter(&daemon_filter_list, FLOG, path, 1);
                        *slash = '/';
                        if (ret < 0) {
                                errno = ENOENT;
@@ -259,7 +259,7 @@ static inline int path_is_daemon_excluded(char *path, int ignore_filename)
                }
 
                if (!ignore_filename
-                && check_filter(&daemon_filter_list, path, 1) < 0) {
+                && check_filter(&daemon_filter_list, FLOG, path, 1) < 0) {
                        errno = ENOENT;
                        return 1;
                }
@@ -293,7 +293,7 @@ static int is_excluded(const char *fname, int is_dir, int filter_level)
        if (filter_level != ALL_FILTERS)
                return 0;
        if (filter_list.head
-           && check_filter(&filter_list, fname, is_dir) < 0)
+           && check_filter(&filter_list, FINFO, fname, is_dir) < 0)
                return 1;
        return 0;
 }
index ff31e0631ec78acb073ba545878c8e329e015a62..1ac09553068b70f45a94a05943942f79dceac29a 100644 (file)
@@ -1282,7 +1282,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
        }
 
        if (daemon_filter_list.head) {
-               if (check_filter(&daemon_filter_list, fname, is_dir) < 0) {
+               if (check_filter(&daemon_filter_list, FLOG, fname, is_dir) < 0) {
                        if (is_dir < 0)
                                return;
 #ifdef SUPPORT_HARD_LINKS
diff --git a/main.c b/main.c
index ad4fb0afb02b741f561776b20623aa23739e4fe6..d9a6c81861295d15bcb61491cbd95f692f9de594 100644 (file)
--- a/main.c
+++ b/main.c
@@ -508,8 +508,8 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
                return NULL;
 
        if (daemon_filter_list.head
-        && (check_filter(&daemon_filter_list, dest_path, 0 != 0) < 0
-         || check_filter(&daemon_filter_list, dest_path, 1 != 0) < 0)) {
+        && (check_filter(&daemon_filter_list, FLOG, dest_path, 0 != 0) < 0
+         || check_filter(&daemon_filter_list, FLOG, dest_path, 1 != 0) < 0)) {
                rprintf(FERROR, "skipping daemon-excluded destination \"%s\"\n",
                        dest_path);
                exit_cleanup(RERR_FILESELECT);
@@ -916,11 +916,11 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
                        char *dir = *dir_p;
                        if (*dir == '/')
                                dir += module_dirlen;
-                       if (check_filter(elp, dir, 1) < 0)
+                       if (check_filter(elp, FLOG, dir, 1) < 0)
                                goto options_rejected;
                }
                if (partial_dir && *partial_dir == '/'
-                && check_filter(elp, partial_dir + module_dirlen, 1) < 0) {
+                && check_filter(elp, FLOG, partial_dir + module_dirlen, 1) < 0) {
                    options_rejected:
                        rprintf(FERROR,
                                "Your options have been rejected by the server.\n");
index 9074e06edaa0399f549ff02debec040894c6207a..75a6d6377b9a58fcf937733bb8bad3e696033ab5 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1044,7 +1044,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                                        goto options_rejected;
                                dir = cp + (*cp == '/' ? module_dirlen : 0);
                                clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
-                               rej = check_filter(&daemon_filter_list, dir, 0) < 0;
+                               rej = check_filter(&daemon_filter_list, FLOG, dir, 0) < 0;
                                free(cp);
                                if (rej)
                                        goto options_rejected;
@@ -1462,7 +1462,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                                goto options_rejected;
                        dir = tmpdir + (*tmpdir == '/' ? module_dirlen : 0);
                        clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
-                       if (check_filter(elp, dir, 1) < 0)
+                       if (check_filter(elp, FLOG, dir, 1) < 0)
                                goto options_rejected;
                }
                if (backup_dir) {
@@ -1471,7 +1471,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                                goto options_rejected;
                        dir = backup_dir + (*backup_dir == '/' ? module_dirlen : 0);
                        clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
-                       if (check_filter(elp, dir, 1) < 0)
+                       if (check_filter(elp, FLOG, dir, 1) < 0)
                                goto options_rejected;
                }
        }
@@ -1667,7 +1667,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                                        goto options_rejected;
                                dir = files_from + (*files_from == '/' ? module_dirlen : 0);
                                clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
-                               if (check_filter(&daemon_filter_list, dir, 0) < 0)
+                               if (check_filter(&daemon_filter_list, FLOG, dir, 0) < 0)
                                        goto options_rejected;
                        }
                        filesfrom_fd = open(files_from, O_RDONLY|O_BINARY);
index da90b5bcd4b11dce74a3eea04bc44e6a72e56454..ce6b739487fe3136430e53fd02ab6bf20ac79a3e 100644 (file)
@@ -490,7 +490,7 @@ int recv_files(int f_in, char *local_name)
                cleanup_got_literal = 0;
 
                if (daemon_filter_list.head
-                   && check_filter(&daemon_filter_list, fname, 0) < 0) {
+                   && check_filter(&daemon_filter_list, FLOG, fname, 0) < 0) {
                        rprintf(FERROR, "attempt to hack rsync failed.\n");
                        exit_cleanup(RERR_PROTOCOL);
                }
@@ -556,7 +556,7 @@ int recv_files(int f_in, char *local_name)
                                break;
                        }
                        if (!fnamecmp || (daemon_filter_list.head
-                         && check_filter(&daemon_filter_list, fname, 0) < 0)) {
+                         && check_filter(&daemon_filter_list, FLOG, fname, 0) < 0)) {
                                fnamecmp = fname;
                                fnamecmp_type = FNAMECMP_FNAME;
                        }
index b306fdbd8b65facb9555c93d718da293a5771af5..44131a9f91bc79adb4887795a4bdafcb636379ad 100644 (file)
--- a/t_stub.c
+++ b/t_stub.c
@@ -56,8 +56,8 @@ struct filter_list_struct daemon_filter_list;
        exit(code);
 }
 
- int check_filter(UNUSED(struct filter_list_struct *listp), UNUSED(const char *name),
-                  UNUSED(int name_is_dir))
+ int check_filter(UNUSED(struct filter_list_struct *listp), UNUSED(enum logcode code),
+                 UNUSED(const char *name), UNUSED(int name_is_dir))
 {
        /* This function doesn't really get called in this test context, so
         * just return 0. */
diff --git a/util.c b/util.c
index 6f5bfc55e897b9adf643ad48843c59bc6cd74dd9..27894a1cf283bf1145909f16592d67dc10f3c31e 100644 (file)
--- a/util.c
+++ b/util.c
@@ -593,7 +593,7 @@ static inline void call_glob_match(const char *name, int len, int from_glob,
                        return;
 
                if (daemon_filter_list.head
-                && check_filter(&daemon_filter_list, use_buf, is_dir) < 0)
+                && check_filter(&daemon_filter_list, FLOG, use_buf, is_dir) < 0)
                        return;
        }
 
@@ -1070,10 +1070,10 @@ char *partial_dir_fname(const char *fname)
        if (daemon_filter_list.head) {
                t = strrchr(partial_fname, '/');
                *t = '\0';
-               if (check_filter(&daemon_filter_list, partial_fname, 1) < 0)
+               if (check_filter(&daemon_filter_list, FLOG, partial_fname, 1) < 0)
                        return NULL;
                *t = '/';
-               if (check_filter(&daemon_filter_list, partial_fname, 0) < 0)
+               if (check_filter(&daemon_filter_list, FLOG, partial_fname, 0) < 0)
                        return NULL;
        }