Nixers Book Club - Book #1: The UNIX Programming Environment - Community & Forums Related Discussions

Users browsing this thread: 9 Guest(s)
movq
Long time nixers
(21-11-2020, 12:55 PM)phillbush Wrote: Until just recently I thought that you could access a file from a directory you have --x permission given that you have the full path of it.

Wait, but that’s correct, isn’t it?

Code:
$ uname -rs
OpenBSD 6.8

$ ls -ld foo
d--x------  2 void  wheel  512 Nov 21 18:59 foo

$ cat foo/hi
Sat Nov 21 18:59:48 CET 2020

With only “r--”, both OpenBSD and Linux give somewhat strange results:
Code:
$ uname -rs
Linux 5.9.8-arch1-1

$ ls -ld foo
dr-------- 2 void users 60 Nov 21 19:01 foo

$ ls -l foo
ls: cannot access 'foo/hi': Permission denied
total 0
-????????? ? ? ? ?            ? hi
vs.
Code:
$ uname -rs
OpenBSD 6.8

$ ls -ld foo
dr--------  2 void  wheel  512 Nov 21 18:59 foo

$ ls -l foo; echo $?
0

$ ls foo
hi

Note that OpenBSD’s output of “ls -l foo” is empty, but it works as “ls foo”. Probably does something like stat(2) on the files it finds and, if that fails, silently skips the directory entry.


Messages In This Thread
RE: Nixers Book Club - Book #1: The UNIX Programming Environment - by movq - 21-11-2020, 03:11 PM