1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-04 22:51:42 +02:00

45292: D02glob: Add regression test for macOS stat(2) misbehaviour

On macOS, a privileged stat(2) call can erroneously treat files as
directories, which can produce unexpected glob results. This was reported at
workers/42891. A side-effect of the change from workers/45291 is that it seems
to work around this issue, at least in the obvious cases
This commit is contained in:
dana 2020-01-15 19:31:16 -06:00
parent edc04bd946
commit 977e1c75d8
2 changed files with 14 additions and 0 deletions

View file

@ -1,5 +1,8 @@
2020-01-15 dana <dana@dana.is>
* 45292: Test/D02glob.ztst: Add regression test for macOS stat(2)
misbehaviour, now worked around by previous fix (see workers/42891)
* Daniel: 45291: Src/glob.c, Test/D02glob.ztst: A glob with a
trailing slash will now match unreadable/unexecutable directories.

View file

@ -742,6 +742,17 @@
>glob.tmp/secret-s111/ glob.tmp/secret-s111
>glob.tmp/secret-s444/ glob.tmp/secret-s444
# On macOS, stat(2) allows files to be treated as directories if the calling
# process has super-user privileges. e.g., stat() on /my/regular/file/. will
# succeed as root but (correctly) fail otherwise. This can produce strange
# results when globbing, depending on how it's implemented. This test should,
# when run with privileges, confirm that the implementation avoids this
# problem. See workers/42891 and workers/45291
: > glob.tmp/not-a-directory
print -r - glob.tmp/not-a-dir*(N) , glob.tmp/not-a-dir*/(N)
0:non-directories not globbed as directories
>glob.tmp/not-a-directory ,
%clean
# Fix unreadable-directory permissions so ztst can clean up properly