From: Wayne Davison Date: Sun, 5 Apr 2020 23:41:15 +0000 (-0700) Subject: Don't throw an error if a potential fuzzy dir isn't a dir X-Git-Tag: v3.2.0pre1~187 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f06cc7ed0bc74628592fb7c669827e28b625582;p=thirdparty%2Frsync.git Don't throw an error if a potential fuzzy dir isn't a dir Add a flag for calling get_dirlist() and for send_directory() that indicates that the dirname is allowed to not be a directory. Based on a patch by Ben Rubson. Fixes bug #13445. --- diff --git a/flist.c b/flist.c index c275e995..7d7d2c0f 100644 --- a/flist.c +++ b/flist.c @@ -1704,6 +1704,8 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len, interpret_stat_error(fbuf, True); return; } + if (errno == ENOTDIR && (flags & FLAG_PERHAPS_DIR)) + return; io_error |= IOERR_GENERAL; rsyserr(FERROR_XFER, errno, "opendir %s failed", full_fname(fbuf)); return; @@ -3229,6 +3231,7 @@ struct file_list *get_dirlist(char *dirname, int dlen, int flags) int save_xfer_dirs = xfer_dirs; int save_prune_empty_dirs = prune_empty_dirs; int senddir_fd = flags & GDL_IGNORE_FILTER_RULES ? -2 : -1; + int senddir_flags = FLAG_CONTENT_DIR; if (dlen < 0) { dlen = strlcpy(dirbuf, dirname, MAXPATHLEN); @@ -3239,9 +3242,12 @@ struct file_list *get_dirlist(char *dirname, int dlen, int flags) dirlist = flist_new(FLIST_TEMP, "get_dirlist"); + if (flags & GDL_PERHAPS_DIR) + senddir_flags |= FLAG_PERHAPS_DIR; + recurse = 0; xfer_dirs = 1; - send_directory(senddir_fd, dirlist, dirname, dlen, FLAG_CONTENT_DIR); + send_directory(senddir_fd, dirlist, dirname, dlen, senddir_flags); xfer_dirs = save_xfer_dirs; recurse = save_recurse; if (INFO_GTE(PROGRESS, 1)) diff --git a/generator.c b/generator.c index 0ceab185..3857151a 100644 --- a/generator.c +++ b/generator.c @@ -1305,7 +1305,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, for (i = 0; i < fuzzy_basis; i++) { if (i && pathjoin(fnamecmpbuf, MAXPATHLEN, basis_dir[i-1], dn) >= MAXPATHLEN) continue; - fuzzy_dirlist[i] = get_dirlist(fnamecmpbuf, -1, GDL_IGNORE_FILTER_RULES); + fuzzy_dirlist[i] = get_dirlist(fnamecmpbuf, -1, GDL_IGNORE_FILTER_RULES | GDL_PERHAPS_DIR); if (fuzzy_dirlist[i] && fuzzy_dirlist[i]->used == 0) { flist_free(fuzzy_dirlist[i]); fuzzy_dirlist[i] = NULL; diff --git a/rsync.h b/rsync.h index 641ba740..b1d16b37 100644 --- a/rsync.h +++ b/rsync.h @@ -87,9 +87,11 @@ /* These flags are passed to functions but not stored. */ #define FLAG_DIVERT_DIRS (1<<16) /* sender, but must be unique */ +#define FLAG_PERHAPS_DIR (1<<17) /* generator */ /* These flags are for get_dirlist(). */ #define GDL_IGNORE_FILTER_RULES (1<<0) +#define GDL_PERHAPS_DIR (1<<1) /* Some helper macros for matching bits. */ #define BITS_SET(val,bits) (((val) & (bits)) == (bits))