Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 31 Jul 2019 21:35:54 +0100
From: Stephane Chazelas <stephane.chazelas@...il.com>
To: musl@...ts.openwall.com
Subject: Re: Re: [PATCH] In glob(), do not require that the target of a
 symlink exists.

2019-07-30 12:13:36 -0400, Rich Felker:
> On Tue, Jul 30, 2019 at 12:04:57PM -0400, James Y Knight wrote:
[...]
> > > Now, be consistent and allow broken symlinks in both cases, by using
> > > lstat to determine file existence.
[...]

Hello,

Note that there's a related discussion on the POSIX mailing list
where that unusual behaviour of musl libc (of using stat()
instead of lstat()) was noted:

https://www.mail-archive.com/austin-group-l@opengroup.org/msg04585.html

The discussion itself was about what is reported with GLOB_ERR
or when an errfunc is passed where the current POSIX spec is
unclear and implementations differ. The austin-group bug is
http://austingroupbugs.net/view.php?id=1273 where I argue
implementations shouldn't report ENOTDIR errors at least even
with GLOB_ERR.

musl is quite unique in that it does report the errors of
stat() in addition to those of opendir(). While POSIX currently
kind of implies it shouldn't, it seems to me it would make for a
more useful interface. That is still being discussed there.

musl's glob will still report errors for system calls failing
with ENOTDIR if it encounters them. At the moment, in globs like
*/*.c, and on systems and file systems where readdir() returns
the type of entries, it will generally not report ENOTDIR errors
because it wouldn't call opendir() on non-directory files in the
first place. But it would on systems where readdir() doesn't
return the type of entries or if there's a symlink to a
non-directory file in the current directory, which makes for a
not very consistent interface.

IMO, it should also ignore ENOTDIR errors (for both opendir()
and lstat()) as a backup even if that means that no error would
be reported for things like /etc/passwd/*

Most implementations ignore ENOTDIR errors, even dietlibc that
even tries harder than musl to avoid calling opendir() on
non-directory files.

-- 
Stephane

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.