public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: NTFS write-protect flag translation (tar? rsync?) only one-way?
@ 2011-04-06  6:16 Christian Gelinek
  2011-04-06  6:54 ` Larry Hall (Cygwin)
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Gelinek @ 2011-04-06  6:16 UTC (permalink / raw)
  To: cygwin

-----Original Message-----
From: Cygwin On Behalf Of Larry Hall (Cygwin)
Sent: Wednesday, 6 April 2011 1:20 AM
Subject: Re: NTFS write-protect flag translation (tar? rsync?) only one-way?

> On 4/5/2011 3:36 AM, Christian Gelinek wrote:
> > Hi everyone,
> >
> > I have a problem with the tar command with the "extract permissions
> > information" option being set.
> >
> > I am running Cygwin (CYGWIN_NT-6.1-WOW64 1.7.8(0.236/5/3) 2011-03-01 09:36)
> > under Windows 7 (Windows 7 Professional N Ver 6.1 Build 7600) with NTFS and
> > the CYGWIN=ntsec environment variable.
> >
> > It appears that when tar reads files for adding to archives, it correctly
> > interprets the Windows-set "R" attribute, which is also seen by ls under
> > Cygwin. After extracting the files using tar though, only Cygwin's ls
> > command seems to be aware of the read-only attribute; the attrib command (as
> > well as Explorer and other Windows-apps) see and handle the file as being
> > writeable.
> 
> The read-only attribute is a "Windows" thing.  Cygwin's utilities focus on
> supporting POSIXy/Linuxy ways of doing things.  You can't expect Cygwin's
> tools to manage all of Window's permission facilities in the same way as
> Windows does.  The read-only flag is one case where you'll see a divergence.
> If you need that flag set, you'll need your own wrapper to set it based on
> the POSIX (or ACL) permissions.  The read-only attribute really is quite
> anachronistic though IMO.  It conflicts with the more powerful ACLs.  If
> you have the option, it's better not to use that flag.

IMO the behaviour is inconsistent if the flag is used/interpreted on one (the read) operation but NOT being written/changed on the other (write) operation. My approach would be either drop it completely or support it on both ends (the preferred option). By the looks of it 
(see http://sourceware.org/ml/cygwin/2002-05/msg00317.html), this problem has been addressed and potentially solved before, so I wonder if something is broken here.

The background to all this is that I am using RCS (I know, almost as anachronistic as the read-only attribute, but that's dictated by my workplace) under both Windows and Linux and RCS relies heavily on the read-only attribute of files to be correct. IMO, it wouldn't hurt if the Cygwin tools would write the Windows read-only attribute when they create a Cygwin read-only file?

Regards,
Christian



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

* Re: NTFS write-protect flag translation (tar? rsync?) only one-way?
  2011-04-06  6:16 NTFS write-protect flag translation (tar? rsync?) only one-way? Christian Gelinek
@ 2011-04-06  6:54 ` Larry Hall (Cygwin)
  2011-04-07  6:01   ` Christian Gelinek
  2011-04-18 10:25   ` Corinna Vinschen
  0 siblings, 2 replies; 6+ messages in thread
From: Larry Hall (Cygwin) @ 2011-04-06  6:54 UTC (permalink / raw)
  To: cygwin

On 4/5/2011 8:35 PM, Christian Gelinek wrote:
> From: Cygwin On Behalf Of Larry Hall (Cygwin)
>> On 4/5/2011 3:36 AM, Christian Gelinek wrote:
>>> It appears that when tar reads files for adding to archives, it
>>> correctly interprets the Windows-set "R" attribute, which is also seen by
>>> ls under Cygwin. After extracting the files using tar though, only
>>> Cygwin's ls command seems to be aware of the read-only attribute; the
>>> attrib command (as well as Explorer and other Windows-apps) see and
>>> handle the file as being writeable.
>>
>> The read-only attribute is a "Windows" thing.  Cygwin's utilities focus on
>> supporting POSIXy/Linuxy ways of doing things.  You can't expect Cygwin's
>> tools to manage all of Window's permission facilities in the same way as
>> Windows does.  The read-only flag is one case where you'll see a divergence.
>> If you need that flag set, you'll need your own wrapper to set it based on
>> the POSIX (or ACL) permissions.  The read-only attribute really is quite
>> anachronistic though IMO.  It conflicts with the more powerful ACLs.  If
>> you have the option, it's better not to use that flag.
>
> IMO the behaviour is inconsistent if the flag is used/interpreted on one (the
> read) operation but NOT being written/changed on the other (write) operation.
> My approach would be either drop it completely or support it on both ends
> (the preferred option).

Actually, the read-only attribute is not used by Cygwin to determine POSIX
permissions.

> By the looks of it (see
> http://sourceware.org/ml/cygwin/2002-05/msg00317.html), this problem has
> been addressed and potentially solved before, so I wonder if something is
> broken here.

No, nothing is broken.  Things have changed since 2002.  If you want the gory
details, you can look in the email archives.  The short of it is, making
read-only, Windows ACLs, and POSIX permissions all agree is overly
complicated.  So we've dropped read-only support now.

> The background to all this is that I am using RCS (I know, almost as
> anachronistic as the read-only attribute, but that's dictated by my
> workplace) under both Windows and Linux and RCS relies heavily on the
> read-only attribute of files to be correct. IMO, it wouldn't hurt if the
> Cygwin tools would write the Windows read-only attribute when they create a
> Cygwin read-only file?

Cygwin has a package for RCS.  Perhaps that could solve your problem?

-- 
Larry

_____________________________________________________________________

A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?

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

* RE: NTFS write-protect flag translation (tar? rsync?) only one-way?
  2011-04-06  6:54 ` Larry Hall (Cygwin)
@ 2011-04-07  6:01   ` Christian Gelinek
  2011-04-18 10:25   ` Corinna Vinschen
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Gelinek @ 2011-04-07  6:01 UTC (permalink / raw)
  To: cygwin

-----Original Message-----
From: Cygwin On Behalf Of Larry Hall (Cygwin)
Sent: Wednesday, 6 April 2011 11:04 AM
Subject: Re: NTFS write-protect flag translation (tar? rsync?) only one-way?

>On 4/5/2011 8:35 PM, Christian Gelinek wrote:
>> From: Cygwin On Behalf Of Larry Hall (Cygwin)
>>> On 4/5/2011 3:36 AM, Christian Gelinek wrote:
>>>> It appears that when tar reads files for adding to archives, it
>>>> correctly interprets the Windows-set "R" attribute, which is also seen by
>>>> ls under Cygwin. After extracting the files using tar though, only
>>>> Cygwin's ls command seems to be aware of the read-only attribute; the
>>>> attrib command (as well as Explorer and other Windows-apps) see and
>>>> handle the file as being writeable.
>>>
>>> The read-only attribute is a "Windows" thing.  Cygwin's utilities focus on
>>> supporting POSIXy/Linuxy ways of doing things.  You can't expect Cygwin's
>>> tools to manage all of Window's permission facilities in the same way as
>>> Windows does.  The read-only flag is one case where you'll see a divergence.
>>> If you need that flag set, you'll need your own wrapper to set it based on
>>> the POSIX (or ACL) permissions.  The read-only attribute really is quite
>>> anachronistic though IMO.  It conflicts with the more powerful ACLs.  If
>>> you have the option, it's better not to use that flag.
>>
>> IMO the behaviour is inconsistent if the flag is used/interpreted on one (the
>> read) operation but NOT being written/changed on the other (write) operation.
>> My approach would be either drop it completely or support it on both ends
>> (the preferred option).
>
>Actually, the read-only attribute is not used by Cygwin to determine POSIX
>permissions.

According to what I have seen, the command 

attrib +R wp.txt

changes ONLY the read-only flag - when I look at the Security page of the file properties dialog in Windows Explorer, the ACLs are not modified by attrib. Still Cygwin would see the file as read-only after the attrib call (please see my original post for the complete sequence of commands).

>> By the looks of it (see
>> http://sourceware.org/ml/cygwin/2002-05/msg00317.html), this problem has
>> been addressed and potentially solved before, so I wonder if something is
>> broken here.
>
>No, nothing is broken.  Things have changed since 2002.  If you want the gory
>details, you can look in the email archives.  The short of it is, making
>read-only, Windows ACLs, and POSIX permissions all agree is overly
>complicated.  So we've dropped read-only support now.

But AFAIK (see above) only for write operations.

I also agree that there is a complicating overlap between the read-only attribute and the ACLs. Nevertheless, most Windows programs honour the read-only flag and Explorer can display a column listing such attributes as opposed to effective ACL permissions. 

The Samba server struggles with similar problems, as it also has to translate between POSIX and Windows permissions. Samba's solution is to emulate ACLs AND the read-only flag. It would be interesting how Samba treats changes to the read-only flag done by Windows, how it translates them to Linux permissions and back to Windows (does it change ACLs as well?). When I've got some time, I'll look into this.

>> The background to all this is that I am using RCS (I know, almost as
>> anachronistic as the read-only attribute, but that's dictated by my
>> workplace) under both Windows and Linux and RCS relies heavily on the
>> read-only attribute of files to be correct. IMO, it wouldn't hurt if the
>> Cygwin tools would write the Windows read-only attribute when they create a
>> Cygwin read-only file?
>
>Cygwin has a package for RCS.  Perhaps that could solve your problem?

Thanks for pointing that out, I will have a look at that as well.

Regards,
Christian



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

* Re: NTFS write-protect flag translation (tar? rsync?) only one-way?
  2011-04-06  6:54 ` Larry Hall (Cygwin)
  2011-04-07  6:01   ` Christian Gelinek
@ 2011-04-18 10:25   ` Corinna Vinschen
  1 sibling, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2011-04-18 10:25 UTC (permalink / raw)
  To: cygwin

On Apr  5 21:33, Larry Hall (Cygwin) wrote:
> On 4/5/2011 8:35 PM, Christian Gelinek wrote:
> >From: Cygwin On Behalf Of Larry Hall (Cygwin)
> >>On 4/5/2011 3:36 AM, Christian Gelinek wrote:
> >>>It appears that when tar reads files for adding to archives, it
> >>>correctly interprets the Windows-set "R" attribute, which is also seen by
> >>>ls under Cygwin. After extracting the files using tar though, only
> >>>Cygwin's ls command seems to be aware of the read-only attribute; the
> >>>attrib command (as well as Explorer and other Windows-apps) see and
> >>>handle the file as being writeable.
> >>
> >>The read-only attribute is a "Windows" thing.  Cygwin's utilities focus on
> >>supporting POSIXy/Linuxy ways of doing things.  You can't expect Cygwin's
> >>tools to manage all of Window's permission facilities in the same way as
> >>Windows does.  The read-only flag is one case where you'll see a divergence.
> >>If you need that flag set, you'll need your own wrapper to set it based on
> >>the POSIX (or ACL) permissions.  The read-only attribute really is quite
> >>anachronistic though IMO.  It conflicts with the more powerful ACLs.  If
> >>you have the option, it's better not to use that flag.
> >
> >IMO the behaviour is inconsistent if the flag is used/interpreted on one (the
> >read) operation but NOT being written/changed on the other (write) operation.
> >My approach would be either drop it completely or support it on both ends
> >(the preferred option).
> 
> Actually, the read-only attribute is not used by Cygwin to determine POSIX
> permissions.

Actually if it is set it is used to remove the write bits from the
permission bits in calls to stat.  However, since the DOS attributes
are only in the way in terms of POSIX permissions, it's never set
in calls to chmod.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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

* Re: NTFS write-protect flag translation (tar? rsync?) only one-way?
  2011-04-05 13:04 Christian Gelinek
@ 2011-04-05 21:46 ` Larry Hall (Cygwin)
  0 siblings, 0 replies; 6+ messages in thread
From: Larry Hall (Cygwin) @ 2011-04-05 21:46 UTC (permalink / raw)
  To: cygwin

On 4/5/2011 3:36 AM, Christian Gelinek wrote:
> Hi everyone,
>
> I have a problem with the tar command with the "extract permissions
> information" option being set.
>
> I am running Cygwin (CYGWIN_NT-6.1-WOW64 1.7.8(0.236/5/3) 2011-03-01 09:36)
> under Windows 7 (Windows 7 Professional N Ver 6.1 Build 7600) with NTFS and
> the CYGWIN=ntsec environment variable.
>
> It appears that when tar reads files for adding to archives, it correctly
> interprets the Windows-set "R" attribute, which is also seen by ls under
> Cygwin. After extracting the files using tar though, only Cygwin's ls
> command seems to be aware of the read-only attribute; the attrib command (as
> well as Explorer and other Windows-apps) see and handle the file as being
> writeable.

The read-only attribute is a "Windows" thing.  Cygwin's utilities focus on
supporting POSIXy/Linuxy ways of doing things.  You can't expect Cygwin's
tools to manage all of Window's permission facilities in the same way as
Windows does.  The read-only flag is one case where you'll see a divergence.
If you need that flag set, you'll need your own wrapper to set it based on
the POSIX (or ACL) permissions.  The read-only attribute really is quite
anachronistic though IMO.  It conflicts with the more powerful ACLs.  If
you have the option, it's better not to use that flag.

-- 
Larry

_____________________________________________________________________

A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?

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

* NTFS write-protect flag translation (tar? rsync?) only one-way?
@ 2011-04-05 13:04 Christian Gelinek
  2011-04-05 21:46 ` Larry Hall (Cygwin)
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Gelinek @ 2011-04-05 13:04 UTC (permalink / raw)
  To: cygwin

Hi everyone,

I have a problem with the tar command with the "extract permissions
information" option being set. 

I am running Cygwin (CYGWIN_NT-6.1-WOW64 1.7.8(0.236/5/3) 2011-03-01 09:36)
under Windows 7 (Windows 7 Professional N Ver 6.1 Build 7600) with NTFS and
the CYGWIN=ntsec environment variable.

It appears that when tar reads files for adding to archives, it correctly
interprets the Windows-set "R" attribute, which is also seen by ls under
Cygwin. After extracting the files using tar though, only Cygwin's ls
command seems to be aware of the read-only attribute; the attrib command (as
well as Explorer and other Windows-apps) see and handle the file as being
writeable.

There are some rather old posts in the archives stating the same (or
similar) problems, but I couldn't find anything suggesting that there is
anything wrong with my setup:
http://sourceware.org/ml/cygwin/2002-05/msg00317.html

I think this problem also applies to the rsync command, but I haven't tested
it to that extent.

Please see the following sequence of commands, partly in a Cygwin shell,
partly in a Windows CMD shell:

=== Cygwin ===
cgelinek@gar ~/permission-test
$ echo "I'll be write-protected" > wp.txt

cgelinek@gar ~/permission-test
$ echo "I'll be writable" > rw.txt

cgelinek@gar ~/permission-test
$ ls -l
total 2
-rw-r--r-- 1 cgelinek None 17 Apr  5 16:36 rw.txt
-rw-r--r-- 1 cgelinek None 24 Apr  5 16:35 wp.txt

=== CMD ===
C:\cygwin\home\cgelinek\permission-test>attrib
A            C:\cygwin\home\cgelinek\permission-test\rw.txt
A            C:\cygwin\home\cgelinek\permission-test\wp.txt

C:\cygwin\home\cgelinek\permission-test>attrib +R wp.txt

C:\cygwin\home\cgelinek\permission-test>attrib
A            C:\cygwin\home\cgelinek\permission-test\rw.txt
A    R       C:\cygwin\home\cgelinek\permission-test\wp.txt

=== Cygwin ===
cgelinek@gar ~/permission-test
$ ls -l
total 2
-rw-r--r-- 1 cgelinek None 17 Apr  5 16:36 rw.txt
-r--r--r-- 1 cgelinek None 24 Apr  5 16:35 wp.txt

cgelinek@gar ~/permission-test
$ tar -pcf files.tar rw.txt wp.txt 

cgelinek@gar ~/permission-test
$ tar -pxf files.tar

cgelinek@gar ~/permission-test
$ ls -l
total 14
-rw-r--r-- 1 cgelinek None 10240 Apr  5 16:39 files.tar
-rw-r--r-- 1 cgelinek None    17 Apr  5 16:36 rw.txt
-r--r--r-- 1 cgelinek None    24 Apr  5 16:35 wp.txt

=== CMD ===
C:\cygwin\home\cgelinek\permission-test>attrib
A            C:\cygwin\home\cgelinek\permission-test\files.tar
A            C:\cygwin\home\cgelinek\permission-test\rw.txt
A            C:\cygwin\home\cgelinek\permission-test\wp.txt


Any suggestions or pointers on how to solve this would be appreciated.

Regards,
Christian



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

end of thread, other threads:[~2011-04-18  8:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-06  6:16 NTFS write-protect flag translation (tar? rsync?) only one-way? Christian Gelinek
2011-04-06  6:54 ` Larry Hall (Cygwin)
2011-04-07  6:01   ` Christian Gelinek
2011-04-18 10:25   ` Corinna Vinschen
  -- strict thread matches above, loose matches on Subject: below --
2011-04-05 13:04 Christian Gelinek
2011-04-05 21:46 ` Larry Hall (Cygwin)

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