diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-03-08 14:26:15 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-03-08 14:26:15 +0000 |
commit | 69d7815eae1b235e4ca81bbc22293402435da2da (patch) | |
tree | 58ca20e6dcdcc57afbf8f1199f950c621a6767fa /winsup/cygwin/fhandler_socket.cc | |
parent | 6777e53972bd4587dca1d740a9b9e0622d5016ba (diff) | |
download | cygnal-69d7815eae1b235e4ca81bbc22293402435da2da.tar.gz cygnal-69d7815eae1b235e4ca81bbc22293402435da2da.tar.bz2 cygnal-69d7815eae1b235e4ca81bbc22293402435da2da.zip |
* fhandler.cc (fhandler_base::open): When creating a file on a
filesystem supporting ACLs, create the file with WRITE_DAC access.
Explain why.
* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for
directories.
* fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets.
* path.cc (symlink_worker): Ditto for symlinks.
* security.cc (get_file_sd): Always call GetSecurityInfo for directories
on XP and Server 2003. Improve comment to explain why.
(set_file_attribute): Explicitely cast mode_t value to bool in call to
get_file_sd.
* wincap.h (wincaps::use_get_sec_info_on_dirs): New element.
* wincap.cc: Implement above element throughout.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 1b4bf2925..22ae05f88 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -996,10 +996,17 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen) HANDLE fh; OBJECT_ATTRIBUTES attr; IO_STATUS_BLOCK io; + ULONG access = DELETE | FILE_GENERIC_WRITE; - status = NtCreateFile (&fh, DELETE | FILE_GENERIC_WRITE, - pc.get_object_attr (attr, sa), &io, NULL, fattr, - 0, FILE_CREATE, + /* If the filesystem supports ACLs, we will overwrite the DACL after the + call to NtCreateFile. This requires a handle with READ_CONTROL and + WRITE_DAC access, otherwise get_file_sd and set_file_sd both have to + open the file again. */ + if (pc.has_acls ()) + access |= READ_CONTROL | WRITE_DAC; + + status = NtCreateFile (&fh, access, pc.get_object_attr (attr, sa), &io, + NULL, fattr, 0, FILE_CREATE, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_BACKUP_INTENT, |