[PATCH 04/18] posix: Allow glob to match dangling symlinks [BZ #866]

Paul Eggert eggert@cs.ucla.edu
Thu Aug 31 22:11:00 GMT 2017


Thanks for working to clear up this longstanding problem in glibc glob. 
Here are the issues I found with the proposed patch:

* glob_in_dir calls gl_stat, which is a typo; it should call gl_lstat.

* The GLOB_MARK checks should use stat not lstat, since symlinks to 
directories should be marked.

* For GLOB_TILDE and GLOB_TILDE_CHECK, the revised code still tests for 
existence of the home directory as a directory. Other glob 
implementations merely expand the ~ or ~foo and treat the result as a 
literal string, and glibc should be consistent here.  This is simpler 
and avoids a stat call.

* __lstat64 needs to be defined in the !_LIBC case too.

* While looking into this I noticed that glob ignores directory entries 
with d_ino == 0. Although currently GNU/Linux cannot return such 
entries, POSIX allows d_ino == 0 so this assumption is not portable, and 
this bug is in the neighborhood so we might as well fix it in a 
separated patch (which simplifies the code).

* commit message says "remove tst-glob3" but the patch actually removes 
bug-glob1-ARGS.

I fixed these problems (except for the last one) while merging the patch 
into Gnulib, and this resulted in the attached patches which I installed 
into Gnulib master. I'll CC: this to bug-gnulib accordingly. Please 
consider merging the glibc-relevant parts of these patches back into 
glibc, for your next iteration of this glibc proposal. As always, the 
goal is for glob.c and related files to be identical in glibc and Gnulib.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-glob-simplify-symlink-detection.patch
Type: text/x-patch
Size: 5917 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170831/56380961/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-glob-backupfile-inode-0-is-a-valid-inode-number.patch
Type: text/x-patch
Size: 6924 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170831/56380961/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-glob-match-dangling-symlinks.patch
Type: text/x-patch
Size: 18477 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170831/56380961/attachment-0002.bin>


More information about the Libc-alpha mailing list