]> 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, 9 Apr 2018 15:53:25 +0000 (15:53 +0000)
This especially broke "doveadm fs delete -R" when the symlink destination
was deleted before the symlink.

src/lib-fs/fs-posix.c

index 0d416d77af8ea18e2737146d49871da732332552..121448ffcd99477d22f96fb774ce0f57f6ef7fac 100644 (file)
@@ -816,7 +816,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;