- 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.
}
-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)
{
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);
* 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;
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;
}
}
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");
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;
}
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;
}
if (!ignore_filename
- && check_filter(&daemon_filter_list, path, 1) < 0) {
+ && check_filter(&daemon_filter_list, FLOG, path, 1) < 0) {
errno = ENOENT;
return 1;
}
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;
}
}
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
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);
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");
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;
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) {
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;
}
}
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);
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);
}
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;
}
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. */
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;
}
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;
}