about summary refs log tree commit diff
diff options
context:
space:
mode:
authordana <dana@dana.is>2020-01-15 19:31:16 -0600
committerdana <dana@dana.is>2020-01-15 19:31:16 -0600
commit977e1c75d8fcd7e727d20d8e4ac9b5b79ea9d667 (patch)
tree9df5dd62614fe969509796ad63d18682e87e88d4
parentedc04bd94656a152e17f06188bcef172d62a3ad4 (diff)
downloadzsh-977e1c75d8fcd7e727d20d8e4ac9b5b79ea9d667.tar.gz
zsh-977e1c75d8fcd7e727d20d8e4ac9b5b79ea9d667.tar.xz
zsh-977e1c75d8fcd7e727d20d8e4ac9b5b79ea9d667.zip
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
-rw-r--r--ChangeLog3
-rw-r--r--Test/D02glob.ztst11
2 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d6ad77e3b..c317f04c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
 
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