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

Re: [Bug] Strange Globing Behaviour when used with sudo

> 2018/05/31 17:44, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Wed, 30 May 2018 22:49:32 +0200
> Bengt Brodersen <bengt.brodersen@xxxxxxxxx> wrote:
>> Just found a paragraph in stat(2) manpage on macos
> If I've read this correctly, it sounds like it's worth trying to
> #define _DARWIN_NO_64_BIT_INODE

I think the problem is not related with these macros (or inode size),
but anyway I manually added

#undef _DARWIN_USE_64_BIT_INODE   (this is defined by AC_SYS_LARGEFILE)

to config.h and built zsh; still the same problem for root.

As Phil Pennock pointed out, the problem originates from:

> 2018/05/31 5:23, Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> non-root:
> stat64("./dummy/.\0", 0x7FFF5F8A1948, 0x1000)		 = -1 Err#20
> root:
> stat64("./dummy/.\0", 0x7FFF547477C8, 0x1000)		 = 0 0

I believe this is a bug of macOS (or a "feature" related with the "rootless"
nature of the OS?).

% ls dummy/.
ls: dummy/.: Not a directory
% sudo ls dummy/.

Same for "stat dummy/.".

I've tested three system calls stat(2), lstat(2) and access(2) with
the path "dummy/." and found that all succeed if called by root.

If we want to workaround this "bug", we need to check st_mode of dummy
somewhere in glob.c.

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