This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Inconsistent setting of readonly attribute in 1.7 ?
- From: Christian Franke <Christian dot Franke at t-online dot de>
- To: cygwin at cygwin dot com
- Date: Wed, 26 Aug 2009 20:37:50 +0200
- Subject: Inconsistent setting of readonly attribute in 1.7 ?
If ACLs are used, Cygwin 1.7 chmod() does never set R/O attribute, but
open() sets it if a R/O file is created:
$ touch test1
$ chmod a=r test1
$ cp -p test1 test2
$ ls -l test1 test2
-r--r--r-- 1 franke users 0 Aug 26 19:33 test1
-r--r--r-- 1 franke users 0 Aug 26 19:33 test2
$ attrib 'test?'
A C:\cygwin\tmp\test1
A R C:\cygwin\tmp\test2
The chmod() behavior is intentional:
fhandler_disk_file::fchmod (mode_t mode)
...
if (mode & (S_IWUSR | S_IWGRP | S_IWOTH))
pc &= (DWORD) ~FILE_ATTRIBUTE_READONLY;
else if (!pc.has_acls ()) /* Never set DOS R/O if security is used. */
pc |= (DWORD) FILE_ATTRIBUTE_READONLY;
This change might be enough (or not):
fhandler_base::open (int flags, mode_t mode)
...
-if (!(mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
+if (!pc.has_acls () && !(mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
file_attributes |= FILE_ATTRIBUTE_READONLY;
--
Regards,
Christian Franke
--
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