Skip to content

Commit

Permalink
Added XFLG_DIR2WILD3 flag that the daemon uses to transform any
Browse files Browse the repository at this point in the history
config-file dir/ exclude rule into a dir/*** rule.
  • Loading branch information
Wayne Davison committed Mar 22, 2008
1 parent 4c74d44 commit f5aeb6f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
10 changes: 5 additions & 5 deletions clientserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,24 +533,24 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)

p = lp_filter(i);
parse_rule(&daemon_filter_list, p, MATCHFLG_WORD_SPLIT,
XFLG_ABS_IF_SLASH);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3);

p = lp_include_from(i);
parse_filter_file(&daemon_filter_list, p, MATCHFLG_INCLUDE,
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);

p = lp_include(i);
parse_rule(&daemon_filter_list, p,
MATCHFLG_INCLUDE | MATCHFLG_WORD_SPLIT,
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);

p = lp_exclude_from(i);
parse_filter_file(&daemon_filter_list, p, 0,
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);

p = lp_exclude(i);
parse_rule(&daemon_filter_list, p, MATCHFLG_WORD_SPLIT,
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);

log_init(1);

Expand Down
19 changes: 17 additions & 2 deletions exclude.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct filter_list_struct daemon_filter_list = { 0, 0, " [daemon]" };
#define MODIFIERS_INCL_EXCL "/!Crsp"
#define MODIFIERS_HIDE_PROTECT "/!p"

#define SLASH_WILD3_SUFFIX "/***"
/* The dirbuf is set by push_local_filters() to the current subdirectory
* relative to curr_dir that is being processed. The path always has a
* trailing slash appended, and the variable dirbuf_len contains the length
Expand Down Expand Up @@ -119,7 +121,7 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
{
struct filter_struct *ret;
const char *cp;
unsigned int pre_len, slash_cnt = 0;
unsigned int pre_len, suf_len, slash_cnt = 0;

if (verbose > 2) {
rprintf(FINFO, "[%s] add_rule(%s%.*s%s)%s\n",
Expand Down Expand Up @@ -166,7 +168,15 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
} else
pre_len = 0;

if (!(ret->pattern = new_array(char, pre_len + pat_len + 1)))
/* The daemon wants dir-exclude rules to get an appended "/" + "***". */
if (xflags & XFLG_DIR2WILD3
&& BITS_SETnUNSET(mflags, MATCHFLG_DIRECTORY, MATCHFLG_INCLUDE)) {
mflags &= ~MATCHFLG_DIRECTORY;
suf_len = sizeof SLASH_WILD3_SUFFIX - 1;
} else
suf_len = 0;

if (!(ret->pattern = new_array(char, pre_len + pat_len + suf_len + 1)))
out_of_memory("add_rule");
if (pre_len) {
memcpy(ret->pattern, dirbuf + module_dirlen, pre_len);
Expand All @@ -177,6 +187,11 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
}
strlcpy(ret->pattern + pre_len, pat, pat_len + 1);
pat_len += pre_len;
if (suf_len) {
memcpy(ret->pattern + pat_len, SLASH_WILD3_SUFFIX, suf_len+1);
pat_len += suf_len;
slash_cnt++;
}

if (strpbrk(ret->pattern, "*[?")) {
mflags |= MATCHFLG_WILD;
Expand Down
5 changes: 3 additions & 2 deletions rsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@

#define XFLG_FATAL_ERRORS (1<<0)
#define XFLG_OLD_PREFIXES (1<<1)
#define XFLG_ANCHORED2ABS (1<<2)
#define XFLG_ABS_IF_SLASH (1<<3)
#define XFLG_ANCHORED2ABS (1<<2) /* leading slash indicates absolute */
#define XFLG_ABS_IF_SLASH (1<<3) /* leading or interior slash is absolute */
#define XFLG_DIR2WILD3 (1<<4) /* dir/ match gets trailing *** added */

#define ATTRS_REPORT (1<<0)
#define ATTRS_SKIP_MTIME (1<<1)
Expand Down

0 comments on commit f5aeb6f

Please sign in to comment.