From 7e5424b806e8eea053016268ad186276e9083b77 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 1 Aug 2022 07:00:51 -0700 Subject: [PATCH] More improvements to file-list checking - Avoid implied rules on generator and (with extra certainty) on server - Add -R implied-directory path elements as directory includes - Log about extra file-list checking using a new --debug=FILTER3 level --- exclude.c | 21 ++++++++++++++++----- main.c | 1 + options.c | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) --- a/exclude.c +++ b/exclude.c @@ -25,6 +25,7 @@ extern int am_server; extern int am_sender; +extern int am_generator; extern int eol_nulls; extern int io_error; extern int xfer_dirs; @@ -309,7 +310,7 @@ void add_implied_include(const char *arg int slash_cnt = 1; /* We know we're adding a leading slash. */ const char *cp; char *p; - if (old_style_args || list_only || filesfrom_host != NULL) + if (am_server || old_style_args || list_only || filesfrom_host != NULL) return; if (relative_paths) { cp = strstr(arg, "/./"); @@ -363,11 +364,16 @@ void add_implied_include(const char *arg } if (!found) { filter_rule *R_rule = new0(filter_rule); - R_rule->rflags = FILTRULE_INCLUDE + (saw_wild ? FILTRULE_WILD : 0); + R_rule->rflags = FILTRULE_INCLUDE | FILTRULE_DIRECTORY + | (saw_wild ? FILTRULE_WILD : 0); R_rule->pattern = strdup(rule->pattern); R_rule->u.slash_cnt = slash_cnt; R_rule->next = implied_filter_list.head; implied_filter_list.head = R_rule; + if (DEBUG_GTE(FILTER, 3)) { + rprintf(FINFO, "[%s] add_implied_include(%s/)\n", + who_am_i(), rule->pattern); + } } } slash_cnt++; @@ -381,6 +387,8 @@ void add_implied_include(const char *arg *p = '\0'; rule->u.slash_cnt = slash_cnt; arg = (const char *)rule->pattern; + if (DEBUG_GTE(FILTER, 3)) + rprintf(FINFO, "[%s] add_implied_include(%s)\n", who_am_i(), rule->pattern); } if (recurse || xfer_dirs) { @@ -416,6 +424,8 @@ void add_implied_include(const char *arg rule->u.slash_cnt = slash_cnt + 1; rule->next = implied_filter_list.head; implied_filter_list.head = rule; + if (DEBUG_GTE(FILTER, 3)) + rprintf(FINFO, "[%s] add_implied_include(%s)\n", who_am_i(), rule->pattern); } } @@ -833,11 +843,12 @@ static void report_filter_result(enum lo filter_rule const *ent, int name_flags, const char *type) { + int log_level = am_sender || am_generator ? 1 : 3; + /* If a trailing slash is present to match only directories, * then it is stripped out by add_rule(). So as a special - * case we add it back in here. */ - - if (DEBUG_GTE(FILTER, 1)) { + * case we add it back in the log output. */ + if (DEBUG_GTE(FILTER, log_level)) { static char *actions[2][2] = { {"show", "hid"}, {"risk", "protect"} }; const char *w = who_am_i(); --- a/main.c +++ b/main.c @@ -1078,6 +1078,7 @@ static int do_recv(int f_in, int f_out, } am_generator = 1; + implied_filter_list.head = implied_filter_list.tail = NULL; flist_receiving_enabled = True; io_end_multiplex_in(MPLX_SWITCHING); --- a/options.c +++ b/options.c @@ -293,7 +293,7 @@ static struct output_struct debug_words[ DEBUG_WORD(DELTASUM, W_SND|W_REC, "Debug delta-transfer checksumming (levels 1-4)"), DEBUG_WORD(DUP, W_REC, "Debug weeding of duplicate names"), DEBUG_WORD(EXIT, W_CLI|W_SRV, "Debug exit events (levels 1-3)"), - DEBUG_WORD(FILTER, W_SND|W_REC, "Debug filter actions (levels 1-2)"), + DEBUG_WORD(FILTER, W_SND|W_REC, "Debug filter actions (levels 1-3)"), DEBUG_WORD(FLIST, W_SND|W_REC, "Debug file-list operations (levels 1-4)"), DEBUG_WORD(FUZZY, W_REC, "Debug fuzzy scoring (levels 1-2)"), DEBUG_WORD(GENR, W_REC, "Debug generator functions"),