test -r or -x always return false on an NFS mount?

Mario Emmenlauer mario@emmenlauer.de
Tue Oct 6 16:10:55 GMT 2020

Dear Andrey,

On 06.10.20 17:46, Andrey Repin wrote:
> Greetings, Mario Emmenlauer!
>> thanks for the awesome Cygwin, its really great!
>> Everything seems to work quite well, and in `ls -la` I can see the
>> file permissions and user and group entries. But when using `test`
>> to check for read (`test -r`) or execute permissions (`test -x`), it
>> always returns false, even for readable files. `ls` on the other hand
>> shows the permissions correctly, and `cat`ing the files works without
>> problems.
> This is a known issue. For years known.
> test only guess -r/-w/-x results based on permissions as it sees them.
> But it do not actually try to read/write/execute the subject, which, as you
> can imagine, may lead to all sorts of false positives/negatives on filesystems
> with less than trivial access control setups.
> In other words, don't test for rwx if you can avoid it. The results MAY be
> wrong.

Ok, this explains a lot, and I almost guessed as much! But can I ask,
do you happen to know why `ls -l` shows the "correct" permissions
including 'r' and 'x'? It seems `ls` has some magic that `test` is
lacking? And I can not imagine that `ls` would try to open every
file, or does it?.

So could this "magic" be ported from `ls` to `test`?


    Mario Emmenlauer

More information about the Cygwin mailing list