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 32e6ccd..157dbb6 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 1ba5544..9db8f1a 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 0a8ace9..254d1c7 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 ff31e06..1ac0955 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 ad4fb0a..d9a6c81 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 9074e06..75a6d63 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 da90b5b..ce6b739 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 b306fdb..44131a9 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 6f5bfc5..27894a1 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;
        }