]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-posix: Fix iterating nonexistent symlinks when readdir() returns DT_UNKNOWN
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 29 Mar 2018 18:24:11 +0000 (14:24 -0400)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 30 Apr 2018 13:18:35 +0000 (16:18 +0300)
This especially broke "doveadm fs delete -R" when the symlink destination
was deleted before the symlink.

src/lib-fs/fs-posix.c

index 33bde79c58a45c5feb13a648f10429db68cab857..e059829cee89c5ce1afc607b2b48c5b68c74e11d 100644 (file)
@@ -827,7 +827,8 @@ static bool fs_posix_iter_want(struct posix_fs_iter *iter, const char *fname)
                const char *path = t_strdup_printf("%s/%s", iter->path, fname);
                struct stat st;
 
-               if (stat(path, &st) < 0)
+               if (stat(path, &st) < 0 &&
+                   lstat(path, &st) < 0)
                        ret = FALSE;
                else if (!S_ISDIR(st.st_mode))
                        ret = (iter->iter.flags & FS_ITER_FLAG_DIRS) == 0;