Web lists-archives.com

Re: "test" producing unexpected results after "chmod"




Am 23.12.2018 um 06:59 schrieb Steven Penny:
With Linux, these commands produce expected results:

    $ cd /tmp
    $ touch alpha.txt
    $ test -r alpha.txt; echo "$?"
    0
    $ chmod -r alpha.txt
    $ test -r alpha.txt; echo "$?"
    1
    $ chmod +r alpha.txt
    $ test -r alpha.txt; echo "$?"
    0

However with Cygwin, unexpected results are produced:

    $ cd /tmp
    $ touch alpha.txt
    $ test -r alpha.txt; echo "$?"
    0
    $ chmod -r alpha.txt
    $ test -r alpha.txt; echo "$?"
    0

It seems Cygwin is not able to produce non-readable files.


you are missing the point that the Windows filesystem
has additional ACL permission as indicated by the "+"
in the ls output.
If you remove those permissions the test case replicate
Linux results.


$ mkdir pippo

$ ls -l | grep pippo
drwx------+ 1 Marco Kein    0 Dec 23 07:03 pippo
          ^ ACL additional permissions


$ getfacl pippo/
# file: pippo/
# owner: Marco
# group: Kein
user::rwx
group::---
other::---
default:user::rwx
default:group::r-x
default:other::r-x

$ setfacl -k pippo

$ ls -l |grep pippo
drwx------  1 Marco Kein    0 Dec 23 07:05 pippo

$ getfacl pippo/
# file: pippo/
# owner: Marco
# group: Kein
user::rwx
group::---
other::---


$ cd pippo
$ touch alpha.txt
$ test -r alpha.txt; echo "$?"
0

$ chmod -r alpha.txt
$ test -r alpha.txt; echo "$?"
1

$ chmod +r alpha.txt
$ test -r alpha.txt; echo "$?"
0

---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple