diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-03-19 21:34:38 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-03-19 21:34:38 +0000 |
commit | b1897d27a8be9c830f5fc30d7a91b754ad0de6fd (patch) | |
tree | 555d48b779ee5b421f5684ee82253b8ce621c792 /winsup/cygwin/security.cc | |
parent | c16d09466bcdfd94ee3566ed8c6e662ffd084ffd (diff) | |
download | cygnal-b1897d27a8be9c830f5fc30d7a91b754ad0de6fd.tar.gz cygnal-b1897d27a8be9c830f5fc30d7a91b754ad0de6fd.tar.bz2 cygnal-b1897d27a8be9c830f5fc30d7a91b754ad0de6fd.zip |
* fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Fix
wrong usage of S_IFDIR.
* security.cc (get_attribute_from_acl): Ditto.
(get_file_attribute): Fix wrong usage of S_IFLNK.
(get_object_attribute): Ditto.
(alloc_sd): Fix wrong usage of S_IFDIR.
* syscalls.cc (chmod): Allow chmod'ing of socket files.
Diffstat (limited to 'winsup/cygwin/security.cc')
-rw-r--r-- | winsup/cygwin/security.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index a4fdf8426..0c9e24cb5 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1267,7 +1267,7 @@ get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid, *flags |= ((!(*anti & S_IXOTH)) ? S_IXOTH : 0) | ((!(*anti & S_IXGRP)) ? S_IXGRP : 0) | ((!(*anti & S_IXUSR)) ? S_IXUSR : 0); - if ((*attribute & S_IFDIR) && + if ((S_ISDIR (*attribute)) && (ace->Mask & (FILE_WRITE_DATA | FILE_EXECUTE | FILE_DELETE_CHILD)) == (FILE_WRITE_DATA | FILE_EXECUTE)) *flags |= S_ISVTX; @@ -1404,7 +1404,7 @@ get_file_attribute (int use_ntsec, const char *file, if (gidret) *gidret = ILLEGAL_GID; } - else if (attribute && (*attribute & S_IFLNK) == S_IFLNK) + else if (attribute && S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return 0; } @@ -1427,7 +1427,7 @@ get_file_attribute (int use_ntsec, const char *file, res = 0; /* symlinks are everything for everyone! */ - if ((*attribute & S_IFLNK) == S_IFLNK) + if (S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return res > 0 ? 0 : -1; @@ -1498,7 +1498,7 @@ get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, { int res = get_nt_object_attribute (handle, object_type, attribute, uidret, gidret); - if (attribute && (*attribute & S_IFLNK) == S_IFLNK) + if (attribute && S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return res; } @@ -1512,7 +1512,7 @@ get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, return 0; /* symlinks are everything for everyone! */ - if ((*attribute & S_IFLNK) == S_IFLNK) + if (S_ISLNK (*attribute)) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; return 0; @@ -1652,8 +1652,8 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, owner_allow |= FILE_GENERIC_WRITE; if (attribute & S_IXUSR) owner_allow |= FILE_GENERIC_EXECUTE; - if ((attribute & (S_IFDIR | S_IWUSR | S_IXUSR)) - == (S_IFDIR | S_IWUSR | S_IXUSR)) + if (S_ISDIR (attribute) + && (attribute & (S_IWUSR | S_IXUSR)) == (S_IWUSR | S_IXUSR)) owner_allow |= FILE_DELETE_CHILD; /* Construct allow attribute for group. */ @@ -1665,8 +1665,9 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, group_allow |= STANDARD_RIGHTS_WRITE | FILE_GENERIC_WRITE; if (attribute & S_IXGRP) group_allow |= FILE_GENERIC_EXECUTE; - if ((attribute & (S_IFDIR | S_IWGRP | S_IXGRP)) - == (S_IFDIR | S_IWGRP | S_IXGRP) && !(attribute & S_ISVTX)) + if (S_ISDIR (attribute) + && (attribute & (S_IWGRP | S_IXGRP)) == (S_IWGRP | S_IXGRP) + && !(attribute & S_ISVTX)) group_allow |= FILE_DELETE_CHILD; /* Construct allow attribute for everyone. */ @@ -1678,8 +1679,8 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, other_allow |= STANDARD_RIGHTS_WRITE | FILE_GENERIC_WRITE; if (attribute & S_IXOTH) other_allow |= FILE_GENERIC_EXECUTE; - if ((attribute & (S_IFDIR | S_IWOTH | S_IXOTH)) - == (S_IFDIR | S_IWOTH | S_IXOTH) + if (S_ISDIR (attribute) + && (attribute & (S_IWOTH | S_IXOTH)) == (S_IWOTH | S_IXOTH) && !(attribute & S_ISVTX)) other_allow |= FILE_DELETE_CHILD; @@ -1788,7 +1789,7 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute, } /* Construct appropriate inherit attribute for new directories */ - if (attribute & S_IFDIR && !acl_exists ) + if (S_ISDIR (attribute) && !acl_exists ) { const DWORD inherit = SUB_CONTAINERS_AND_OBJECTS_INHERIT | INHERIT_ONLY; |