about summary refs log tree commit diff
diff options
context:
space:
mode:
-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