Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] A glob with a trailing slash will now match unreadable/unexecutable directories.



On 12 Jan 2020, at 18:27, Daniel Shahaf <danielsh@xxxxxxxxxx> wrote:
> This fixes the issue, but I'd appreciate some review.

The change seems good, though i only looked at it briefly.

A cool thing about it is that it apparently also fixes workers/42891 (globs
misbehaving with sudo on macOS). Not sure if there are cases where it'd still
be an issue, but a simple test (see below) run with root now passes where it
wouldn't before.

There is an issue with the D02 test you added before, though: Making the
directories unwriteable prevents ztst from cleaning up properly afterwards
(unless you're root), which causes other tests to fail the next time i run the
script:

  % make check TESTNUM=D02
  ...
  ./D02glob.ztst: starting.
  ./D02glob.ztst: all tests successful.
  rm: /Users/dana/Development/sf.net/zsh/zsh/Test/glob.tmp/secret-d000: Permission denied
  rm: /Users/dana/Development/sf.net/zsh/zsh/Test/glob.tmp/secret-d111: Permission denied
  rm: /Users/dana/Development/sf.net/zsh/zsh/Test/glob.tmp: Directory not empty
  ...

  % make check TESTNUM=D02
  ...
  ./D02glob.ztst: starting.
  ...
  Test ./D02glob.ztst failed: output differs from expected as shown above for:
    ( regress_absolute_path_and_core_dump )
  Was testing: exclusions regression test
  ./D02glob.ztst: test failed.
  ...

dana


diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 50b0f6716..0d4fde2f9 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -741,3 +741,14 @@
 >glob.tmp/secret-s000/  glob.tmp/secret-s000
 >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 ,



Messages sorted by: Reverse Date, Date, Thread, Author