aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/security.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-03-27 09:40:25 +0000
committerCorinna Vinschen <corinna@vinschen.de>2003-03-27 09:40:25 +0000
commit98b36ec8eded5c0aa1a179b12e9ee69d0ec0fdda (patch)
tree9d4f530508c81f3c98b2a6e240143ee162ce1799 /winsup/cygwin/security.cc
parent2f4be7367ec358897546ec8b5972163b5d7cb816 (diff)
downloadnewlib-98b36ec8eded5c0aa1a179b12e9ee69d0ec0fdda.zip
newlib-98b36ec8eded5c0aa1a179b12e9ee69d0ec0fdda.tar.gz
newlib-98b36ec8eded5c0aa1a179b12e9ee69d0ec0fdda.tar.bz2
* autoload.cc: added RegGetKeySecurity()
* security.cc (get_nt_object_attribute): use RegGetKeySecurity() for performance.
Diffstat (limited to 'winsup/cygwin/security.cc')
-rw-r--r--winsup/cygwin/security.cc78
1 files changed, 66 insertions, 12 deletions
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 0c9e24c..f05fb39 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -1443,19 +1443,73 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
PSECURITY_DESCRIPTOR psd = NULL;
cygpsid owner_sid;
cygpsid group_sid;
- PACL acl;
-
- if (ERROR_SUCCESS != GetSecurityInfo (handle, object_type,
- DACL_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- OWNER_SECURITY_INFORMATION,
- (PSID *) &owner_sid,
- (PSID *) &group_sid,
- &acl, NULL, &psd))
+ PACL acl = NULL;
+
+ if (object_type == SE_REGISTRY_KEY)
+ {
+ // use different code for registry handles, for performance reasons
+ char sd_buf[4096];
+ PSECURITY_DESCRIPTOR psd2 = (PSECURITY_DESCRIPTOR) & sd_buf[0];
+ DWORD len = sizeof (sd_buf);
+ if (ERROR_SUCCESS != RegGetKeySecurity ((HKEY) handle,
+ DACL_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ OWNER_SECURITY_INFORMATION,
+ psd2, &len))
+ {
+ __seterrno ();
+ debug_printf ("RegGetKeySecurity %E");
+ return -1;
+ }
+
+ BOOL bDaclPresent;
+ BOOL bDaclDefaulted;
+ if (!GetSecurityDescriptorDacl (psd2,
+ &bDaclPresent, &acl, &bDaclDefaulted))
+ {
+ __seterrno ();
+ debug_printf ("GetSecurityDescriptorDacl %E");
+ return -1;
+ }
+ if (!bDaclPresent)
+ {
+ acl = NULL;
+ }
+
+ BOOL bGroupDefaulted;
+ if (!GetSecurityDescriptorGroup (psd2,
+ (PSID *) & group_sid,
+ &bGroupDefaulted))
+ {
+ __seterrno ();
+ debug_printf ("GetSecurityDescriptorGroup %E");
+ return -1;
+ }
+
+ BOOL bOwnerDefaulted;
+ if (!GetSecurityDescriptorOwner (psd2,
+ (PSID *) & owner_sid,
+ &bOwnerDefaulted))
+ {
+ __seterrno ();
+ debug_printf ("GetSecurityDescriptorOwner %E");
+ return -1;
+ }
+ }
+ else
{
- __seterrno ();
- debug_printf ("GetSecurityInfo %E");
- return -1;
+ if (ERROR_SUCCESS != GetSecurityInfo (handle, object_type,
+ DACL_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ OWNER_SECURITY_INFORMATION,
+ (PSID *) & owner_sid,
+ (PSID *) & group_sid,
+ &acl, NULL, &psd))
+ {
+ __seterrno ();
+ debug_printf ("GetSecurityInfo %E");
+ return -1;
+ }
}
__uid32_t uid;