public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* "test" producing unexpected results after "chmod"
@ 2018-12-23  6:15 Steven Penny
  2018-12-23 17:12 ` Marco Atzeri
  2018-12-23 23:05 ` Andrey Repin
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Penny @ 2018-12-23  6:15 UTC (permalink / raw)
  To: cygwin

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.


--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "test" producing unexpected results after "chmod"
  2018-12-23  6:15 "test" producing unexpected results after "chmod" Steven Penny
@ 2018-12-23 17:12 ` Marco Atzeri
  2018-12-23 23:05 ` Andrey Repin
  1 sibling, 0 replies; 3+ messages in thread
From: Marco Atzeri @ 2018-12-23 17:12 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "test" producing unexpected results after "chmod"
  2018-12-23  6:15 "test" producing unexpected results after "chmod" Steven Penny
  2018-12-23 17:12 ` Marco Atzeri
@ 2018-12-23 23:05 ` Andrey Repin
  1 sibling, 0 replies; 3+ messages in thread
From: Andrey Repin @ 2018-12-23 23:05 UTC (permalink / raw)
  To: Steven Penny, cygwin

Greetings, 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.

It's not Cygwin, it's test, like many other programs in this case, make false
assumptions on file readability/writability based on their interpretation of
file permissions.

The only true test for readability is to open file for reading.
The only true test for writability is to open file for writing.
Successfully.

The rest is merely a guesswork.


-- 
With best regards,
Andrey Repin
Monday, December 24, 2018 1:17:48

Sorry for my terrible english...


--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-23 22:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-23  6:15 "test" producing unexpected results after "chmod" Steven Penny
2018-12-23 17:12 ` Marco Atzeri
2018-12-23 23:05 ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).