First cut of full implementation of new permission handling
* fhandler.cc (fhandler_base::open_with_arch): Call open with mode not umasked. (fhandler_base::open): Explicitely umask mode on NFS here. Call new set_created_file_access rather than set_file_attribute. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Reimplement setting permissions on filesystems supporting ACLs using the new set_posix_access call. (fhandler_disk_file::fchown): Ditto. (fhandler_disk_file::mkdir): Call new set_created_file_access rather than set_file_attribute. * fhandler_socket.cc (fhandler_socket::bind): Don't umask here. Add WRITE_OWNER access to allow writing group in case of SGID bit set. Call new set_created_file_access rather than set_file_attribute. * path.cc (symlink_worker): Call new set_created_file_access rather than set_file_attribute. * sec_acl.cc (searchace): Un-staticize. (set_posix_access): New, complementary functionality to get_posix_access. (setacl): Implement in terms of get_posix_access/set_posix_access. (get_posix_access): Add handling for just created files requiring their first Cygwin ACL. Fix new_style recognition. Handle SGID bit. For old-style ACLs, ignore SYSTEM and Administrators when computing the {DEF_}CLASS_OBJ perms. * security.cc (get_file_sd): Revamp comment. Change and (hopefully) speed up inheritance processing for just created files. (alloc_sd): Remove. (set_security_attribute): Call set_posix_access instead of alloc_sd. (get_object_attribute): Fix return value. (create_object_sd_from_attribute): Call set_posix_access instead of alloc_sd. (set_file_attribute): Remove. (set_created_file_access): New function implemented in terms of get_posix_access/set_posix_access. * security.h (set_file_attribute): Remove prototype. (set_created_file_access): Add prototype. (searchace): Ditto. (set_posix_access): Ditto. * syscalls.cc (open): Call open_with_arch with mode not umasked. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
@ -463,7 +463,7 @@ fhandler_base::open_with_arch (int flags, mode_t mode)
|
||||
{
|
||||
int res;
|
||||
if (!(res = (archetype && archetype->io_handle)
|
||||
|| open (flags, (mode & 07777) & ~cygheap->umask)))
|
||||
|| open (flags, mode & 07777)))
|
||||
{
|
||||
if (archetype)
|
||||
delete archetype;
|
||||
@ -662,9 +662,10 @@ fhandler_base::open (int flags, mode_t mode)
|
||||
+ p->EaNameLength + 1);
|
||||
memset (nfs_attr, 0, sizeof (fattr3));
|
||||
nfs_attr->type = NF3REG;
|
||||
nfs_attr->mode = mode;
|
||||
nfs_attr->mode = (mode & 07777) & ~cygheap->umask;
|
||||
}
|
||||
else if (!has_acls () && !(mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
|
||||
else if (!has_acls ()
|
||||
&& !(mode & ~cygheap->umask & (S_IWUSR | S_IWGRP | S_IWOTH)))
|
||||
/* If mode has no write bits set, and ACLs are not used, we set
|
||||
the DOS R/O attribute. */
|
||||
file_attributes |= FILE_ATTRIBUTE_READONLY;
|
||||
@ -716,7 +717,7 @@ fhandler_base::open (int flags, mode_t mode)
|
||||
This is the result of a discussion on the samba-technical list, starting at
|
||||
http://lists.samba.org/archive/samba-technical/2008-July/060247.html */
|
||||
if (io.Information == FILE_CREATED && has_acls ())
|
||||
set_file_attribute (fh, pc, ILLEGAL_UID, ILLEGAL_GID, S_JUSTCREATED | mode);
|
||||
set_created_file_access (fh, pc, mode);
|
||||
|
||||
/* If you O_TRUNC a file on Linux, the data is truncated, but the EAs are
|
||||
preserved. If you open a file on Windows with FILE_OVERWRITE{_IF} or
|
||||
|
Reference in New Issue
Block a user