From 977e1c75d8fcd7e727d20d8e4ac9b5b79ea9d667 Mon Sep 17 00:00:00 2001 From: dana Date: Wed, 15 Jan 2020 19:31:16 -0600 Subject: 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 --- ChangeLog | 3 +++ Test/D02glob.ztst | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index d6ad77e3b..c317f04c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2020-01-15 dana + * 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. diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index b8946c5b1..7fd22d795 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -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 -- cgit 1.4.1