Viktor Dukhovni: > On Tue, Apr 21, 2015 at 07:14:37PM +0300, Mika Ilmaranta wrote: > > > It's empty and SeLinux context is correct. > > > > [root@foo7 ~]# ls -la /etc/postfix/dynamicmaps.cf.d/ > > total 4 > > drwxr-xr-x. 2 root root 6 Apr 21 18:46 . > > drwxr-xr-x. 4 root root 4096 Apr 21 18:51 .. > > Thanks, so in your case, errno was simple "left-over" from other > system call. It is however possible to encounter ENOENT due to > broken symlinks or races against file deletion. For these it makes > more sense to report the problem in dymap_read_conf() if it is to > be reported at all.
In that case I think that the bug is that readdir() does not reset errno. Rationale: errno is part of the readdir() API, therefore readdir() must reset errno so that the caller can distinguish between "no more entries" and "there was an error". We can work around that in Postfix. The workaround is to reset errno before calling readdir(), i.e. in the scan_dir_next() function. Not in any scan_dir_next() caller, because then we would have to modify all the callers of the scan_dir_next() function! PS: I don't buy the argument that readdir() cannot report a dangling symlink. It reports directory entries. There is no need for readdir() to dereference a symlink. Wietse --- /var/tmp/postfix-3.1-20150330/src/util/scan_dir.c 2014-12-06 20:35:33.000000000 -0500 +++ ./scan_dir.c 2015-04-21 12:47:06.072252950 -0400 @@ -177,6 +177,8 @@ #define STREQ(x,y) (strcmp((x),(y)) == 0) if (info) { + /* Some implementations report spurious errors. */ + errno = 0; while ((dp = readdir(info->dir)) != 0) { if (STREQ(dp->d_name, ".") || STREQ(dp->d_name, "..")) { if (msg_verbose > 1)