]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Don't throw an error if a potential fuzzy dir isn't a dir
authorWayne Davison <wayned@samba.org>
Sun, 5 Apr 2020 23:41:15 +0000 (16:41 -0700)
committerWayne Davison <wayned@samba.org>
Sun, 5 Apr 2020 23:41:15 +0000 (16:41 -0700)
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.

flist.c
generator.c
rsync.h

diff --git a/flist.c b/flist.c
index c275e995eadde216e63d849993705b03d5d17ad2..7d7d2c0ff1356886e71cc8db6a70e28f6b255ca8 100644 (file)
--- 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))
index 0ceab185db97aaa0d1163c5cd2f139b77155203b..3857151aa931f464ef1c3e7843cb431e18c997de 100644 (file)
@@ -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 641ba74073de318da89c454ec8c0fce4d102094b..b1d16b37826887ac2bac652a4167886c6da68d7c 100644 (file)
--- a/rsync.h
+++ b/rsync.h
 /* 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))