public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Filemode change by windows applications
@ 2018-03-28  8:16 Kjetil Østerås
  2018-03-28 13:37 ` Eliot Moss
  2018-03-28 14:27 ` Andrey Repin
  0 siblings, 2 replies; 8+ messages in thread
From: Kjetil Østerås @ 2018-03-28  8:16 UTC (permalink / raw)
  To: cygwin

Hi,

I notice that when I edit and save a file in a windows application this
file sometimes get the execute file permission set in cygwin. Some windows
applications do this and some don't. For instance in my setup if i modify a
.c file using Meld then the execute bit is set, however when I modify the
same file with sublime text 3 then the execute bit is not set.

Why does this happen? and is there anything I can do to prevent windows
applications from setting the execute bit on my files?

-- 
Kjetil Østerås

--
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] 8+ messages in thread

* Re: Filemode change by windows applications
  2018-03-28  8:16 Filemode change by windows applications Kjetil Østerås
@ 2018-03-28 13:37 ` Eliot Moss
  2018-03-28 14:40   ` Kjetil Østerås
  2018-03-28 14:27 ` Andrey Repin
  1 sibling, 1 reply; 8+ messages in thread
From: Eliot Moss @ 2018-03-28 13:37 UTC (permalink / raw)
  To: cygwin

On 3/28/2018 3:09 AM, Kjetil Østerås wrote:

> I notice that when I edit and save a file in a windows application this
> file sometimes get the execute file permission set in cygwin. Some windows
> applications do this and some don't. For instance in my setup if i modify a
> .c file using Meld then the execute bit is set, however when I modify the
> same file with sublime text 3 then the execute bit is not set.
> 
> Why does this happen? and is there anything I can do to prevent windows
> applications from setting the execute bit on my files?

The Windows file permissions (access control) is substantially different
from the Posix model that Cygwin attempts to present.  The mapping from
Windows to Posix that Cygwin implements is arguably the best / most
reasonable mapping between the disparate schemes, and has been carefully
refined over time.  But it is just a mapping from the underlying scheme.

So, if some Windows program sets permissions a particular way, that it how
they show up under Cygwin.  To answer your question more directly: No, you
can't prevent a Windows program from setting (the underlying access modes
that translate to what is presented as) the execute bit under Cygwin -
short of preventing the programs from accessing the file altogether,
presumably not what you want.

File access translation is perhaps one of the roughest edges that Cygwin
*tries* to smooth over.  I think it does a good job with what it has, but
the Windows scheme is complex and there is no perfect way to do this.

Note, though, that there is no good way to prevent a Unix program from
setting execute bits on a particular file either (well, the umask, and
possibly ACLs may give you some control if you want to go to the bother).
It's just that Unix programs don't tend to set that bit unless they are
creating an executable.

Someone more versed in the Windows access control scheme and the intention
of various permissions might be able to clarify why some many Windows
programs think it is a good thing to set the access mode(s) that Cygwin
reflects as the x bit ...

Regards - Eliot Moss

--
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] 8+ messages in thread

* Re: Filemode change by windows applications
  2018-03-28  8:16 Filemode change by windows applications Kjetil Østerås
  2018-03-28 13:37 ` Eliot Moss
@ 2018-03-28 14:27 ` Andrey Repin
  2018-03-28 14:45   ` Eliot Moss
  1 sibling, 1 reply; 8+ messages in thread
From: Andrey Repin @ 2018-03-28 14:27 UTC (permalink / raw)
  To: Kjetil Østerås, cygwin

Greetings, Kjetil Østerås!

> I notice that when I edit and save a file in a windows application this
> file sometimes get the execute file permission set in cygwin. Some windows
> applications do this and some don't. For instance in my setup if i modify a
> .c file using Meld then the execute bit is set, however when I modify the
> same file with sublime text 3 then the execute bit is not set.

> Why does this happen?

This is how Windows operates. Please do not use Windows programs inside Cygwin
installation tree.

> and is there anything I can do to prevent windows
> applications from setting the execute bit on my files?

No, and you will be unable to use Windows associations, if you clear execute bit
on documents.


-- 
With best regards,
Andrey Repin
Wednesday, March 28, 2018 17:09:24

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] 8+ messages in thread

* Re: Filemode change by windows applications
  2018-03-28 13:37 ` Eliot Moss
@ 2018-03-28 14:40   ` Kjetil Østerås
  2018-03-28 16:20     ` Eliot Moss
  0 siblings, 1 reply; 8+ messages in thread
From: Kjetil Østerås @ 2018-03-28 14:40 UTC (permalink / raw)
  To: moss, cygwin

Hi Eliot,

Do you know where I can find documentation or source code that describes
the mapping that cygwin implements?

2018-03-28 15:06 GMT+02:00 Eliot Moss <moss@cs.umass.edu>:

> On 3/28/2018 3:09 AM, Kjetil Østerås wrote:
>
> I notice that when I edit and save a file in a windows application this
>> file sometimes get the execute file permission set in cygwin. Some windows
>> applications do this and some don't. For instance in my setup if i modify
>> a
>> .c file using Meld then the execute bit is set, however when I modify the
>> same file with sublime text 3 then the execute bit is not set.
>>
>> Why does this happen? and is there anything I can do to prevent windows
>> applications from setting the execute bit on my files?
>>
>
> The Windows file permissions (access control) is substantially different
> from the Posix model that Cygwin attempts to present.  The mapping from
> Windows to Posix that Cygwin implements is arguably the best / most
> reasonable mapping between the disparate schemes, and has been carefully
> refined over time.  But it is just a mapping from the underlying scheme.
>
> So, if some Windows program sets permissions a particular way, that it how
> they show up under Cygwin.  To answer your question more directly: No, you
> can't prevent a Windows program from setting (the underlying access modes
> that translate to what is presented as) the execute bit under Cygwin -
> short of preventing the programs from accessing the file altogether,
> presumably not what you want.
>
> File access translation is perhaps one of the roughest edges that Cygwin
> *tries* to smooth over.  I think it does a good job with what it has, but
> the Windows scheme is complex and there is no perfect way to do this.
>
> Note, though, that there is no good way to prevent a Unix program from
> setting execute bits on a particular file either (well, the umask, and
> possibly ACLs may give you some control if you want to go to the bother).
> It's just that Unix programs don't tend to set that bit unless they are
> creating an executable.
>
> Someone more versed in the Windows access control scheme and the intention
> of various permissions might be able to clarify why some many Windows
> programs think it is a good thing to set the access mode(s) that Cygwin
> reflects as the x bit ...
>
> Regards - Eliot Moss
>
> --
> 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
>
>


-- 
Kjetil Østerås

--
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] 8+ messages in thread

* Re: Filemode change by windows applications
  2018-03-28 14:27 ` Andrey Repin
@ 2018-03-28 14:45   ` Eliot Moss
  2018-03-28 14:50     ` Eliot Moss
  0 siblings, 1 reply; 8+ messages in thread
From: Eliot Moss @ 2018-03-28 14:45 UTC (permalink / raw)
  To: cygwin

On 3/28/2018 10:11 AM, Andrey Repin wrote:

>> and is there anything I can do to prevent windows
>> applications from setting the execute bit on my files?
> 
> No, and you will be unable to use Windows associations, if you clear execute bit
> on documents.

Interesting that you think so, Andrey.  I just tested this on my Windows 10
Surface Book.  I used Windows Explorer to navigate to a folder where I had
cleared the x bits from a .docx file (setting mode to 660 with chmod in
Cygwin), and clicking on the file opened Word on the file just fine.  Maybe
this behavior is dependent on some other things as well?

Regards - Eliot

--
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] 8+ messages in thread

* Re: Filemode change by windows applications
  2018-03-28 14:45   ` Eliot Moss
@ 2018-03-28 14:50     ` Eliot Moss
  2018-03-28 16:56       ` Andrey Repin
  0 siblings, 1 reply; 8+ messages in thread
From: Eliot Moss @ 2018-03-28 14:50 UTC (permalink / raw)
  To: cygwin

On 3/28/2018 10:40 AM, Eliot Moss wrote:
> On 3/28/2018 10:11 AM, Andrey Repin wrote:
> 
>>> and is there anything I can do to prevent windows
>>> applications from setting the execute bit on my files?
>>
>> No, and you will be unable to use Windows associations, if you clear execute bit
>> on documents.
> 
> Interesting that you think so, Andrey.  I just tested this on my Windows 10
> Surface Book.  I used Windows Explorer to navigate to a folder where I had
> cleared the x bits from a .docx file (setting mode to 660 with chmod in
> Cygwin), and clicking on the file opened Word on the file just fine.  Maybe
> this behavior is dependent on some other things as well?

Here is getfacl output for the file in question:

# file: Progress Letters S16.docx
# owner: moss
# group: moss
user::rw-
group::---
group:SYSTEM:r-x                        #effective:r--
group:Cygwin:rwx                        #effective:rw-
mask:rw-
other:---

So there are underlying x bits of some kind, but Cygwin does display
mode 660 via ls -l (for example).

Still, we entirely agree that there is not really a way to prevent a
Windows program from setting the x bits.  Here is getfacl from another
file in the same folder, reflecting how Word sets the permissions:

# file: Progress Letters S17.docx
# owner: moss
# group: moss
# flags: -s-
user::rwx
group::---
group:SYSTEM:r-x
group:Cygwin:rwx
mask:rwx
other:r-x

I think the key difference is "mask".

Regards - Eliot

--
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] 8+ messages in thread

* Re: Filemode change by windows applications
  2018-03-28 14:40   ` Kjetil Østerås
@ 2018-03-28 16:20     ` Eliot Moss
  0 siblings, 0 replies; 8+ messages in thread
From: Eliot Moss @ 2018-03-28 16:20 UTC (permalink / raw)
  To: cygwin

On 3/28/2018 10:27 AM, Kjetil Østerås wrote:

> Do you know where I can find documentation or source code that describes
> the mapping that cygwin implements?

See: https://cygwin.com/cygwin-ug-net/ntsec.html

This is referenced in the Cygwin FAQ.

It's complicated, but I think the doc explains it.  Corinna (or someone)
can correct us if the doc is not up to date ...

As for source code, all the source for Cygwin is available.  Probably
not for the average user of Cygwin to try to dig into, since you need
pretty deep knowledge of both Windows APIs and of Posix semantics, but
everything is there, and useful patches will always be considered.

Regards - Eliot

--
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] 8+ messages in thread

* Re: Filemode change by windows applications
  2018-03-28 14:50     ` Eliot Moss
@ 2018-03-28 16:56       ` Andrey Repin
  0 siblings, 0 replies; 8+ messages in thread
From: Andrey Repin @ 2018-03-28 16:56 UTC (permalink / raw)
  To: Eliot Moss, cygwin

Greetings, Eliot Moss!

> On 3/28/2018 10:40 AM, Eliot Moss wrote:
>> On 3/28/2018 10:11 AM, Andrey Repin wrote:
>> 
>>>> and is there anything I can do to prevent windows
>>>> applications from setting the execute bit on my files?
>>>
>>> No, and you will be unable to use Windows associations, if you clear execute bit
>>> on documents.
>> 
>> Interesting that you think so, Andrey.  I just tested this on my Windows 10
>> Surface Book.  I used Windows Explorer to navigate to a folder where I had
>> cleared the x bits from a .docx file (setting mode to 660 with chmod in
>> Cygwin), and clicking on the file opened Word on the file just fine.  Maybe
>> this behavior is dependent on some other things as well?

> Here is getfacl output for the file in question:

> # file: Progress Letters S16.docx
> # owner: moss
> # group: moss
> user::rw-
> group::---
> group:SYSTEM:r-x                        #effective:r--
> group:Cygwin:rwx                        #effective:rw-
> mask:rw-
> other:---

If you ANSOLUTELY remove execute bit (this is often happens on samba shares
managed by POSIX ACL for example, when you create file with POSIX tools before
Samba have a say about permissions), things break hard.

> So there are underlying x bits of some kind, but Cygwin does display
> mode 660 via ls -l (for example).

> Still, we entirely agree that there is not really a way to prevent a
> Windows program from setting the x bits.  Here is getfacl from another
> file in the same folder, reflecting how Word sets the permissions:

> # file: Progress Letters S17.docx
> # owner: moss
> # group: moss
> # flags: -s-
> user::rwx
> group::---
> group:SYSTEM:r-x
> group:Cygwin:rwx
> mask:rwx
> other:r-x

> I think the key difference is "mask".

Cygwin way of treating Windows ACL's is still kind of mystery to me.
I know they works… somehow. But I prefer to stay away from them, where
possible. I need interoperability over "zealous POSIX compatibility".


-- 
With best regards,
Andrey Repin
Wednesday, March 28, 2018 19:10:43

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] 8+ messages in thread

end of thread, other threads:[~2018-03-28 16:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28  8:16 Filemode change by windows applications Kjetil Østerås
2018-03-28 13:37 ` Eliot Moss
2018-03-28 14:40   ` Kjetil Østerås
2018-03-28 16:20     ` Eliot Moss
2018-03-28 14:27 ` Andrey Repin
2018-03-28 14:45   ` Eliot Moss
2018-03-28 14:50     ` Eliot Moss
2018-03-28 16:56       ` 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).