aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-04-13 12:14:59 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-04-13 12:14:59 +0000
commit71ffba498c27887a8bf58c01a8d3d1ce82a76792 (patch)
treef091e8373e7d70907f658f513b7a843c3b9646c9
parent7e044afdafa7a37c0c065bb819af0acaf1a7bea1 (diff)
downloadnewlib-71ffba498c27887a8bf58c01a8d3d1ce82a76792.zip
newlib-71ffba498c27887a8bf58c01a8d3d1ce82a76792.tar.gz
newlib-71ffba498c27887a8bf58c01a8d3d1ce82a76792.tar.bz2
* autoload.cc (NtQuerySecurityObject): Add.
* ntdll.h (STATUS_BUFFER_TOO_SMALL): Add definition. (NtQuerySecurityObject): Add declaration. * security.cc (get_nt_object_attribute): Always use NtQuerySecurityObject to retrieve security descriptor.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/autoload.cc1
-rw-r--r--winsup/cygwin/ntdll.h3
-rw-r--r--winsup/cygwin/security.cc55
4 files changed, 35 insertions, 32 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 5ef03f5..35bde4d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2004-04-13 Corinna Vinschen <corinna@vinschen.de>
+
+ * autoload.cc (NtQuerySecurityObject): Add.
+ * ntdll.h (STATUS_BUFFER_TOO_SMALL): Add definition.
+ (NtQuerySecurityObject): Add declaration.
+ * security.cc (get_nt_object_attribute): Always use
+ NtQuerySecurityObject to retrieve security descriptor.
+
2004-04-13 Gerd Spalink <Gerd.Spalink@t-online.de>
* fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::stop): Add optional
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index d64674c..c8916fe 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -392,6 +392,7 @@ LoadDLLfuncEx (NtQueryInformationFile, 20, ntdll, 1)
LoadDLLfuncEx (NtQueryInformationProcess, 20, ntdll, 1)
LoadDLLfuncEx2 (NtQueryObject, 20, ntdll, 1, 1)
LoadDLLfuncEx (NtQuerySystemInformation, 16, ntdll, 1)
+LoadDLLfuncEx (NtQuerySecurityObject, 20, ntdll, 1)
LoadDLLfuncEx (NtQueryVirtualMemory, 24, ntdll, 1)
LoadDLLfuncEx (NtUnmapViewOfSection, 8, ntdll, 1)
LoadDLLfuncEx (RtlInitUnicodeString, 8, ntdll, 1)
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index 33aa129..1548443 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -9,6 +9,7 @@
details. */
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xc0000004)
+#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xc0000023)
#define PDI_MODULES 0x01
#define PDI_HEAPS 0x04
#define LDRP_IMAGE_DLL 0x00000004
@@ -407,6 +408,8 @@ extern "C"
ULONG, ULONG *);
NTSTATUS NTAPI NtQuerySystemInformation (SYSTEM_INFORMATION_CLASS,
PVOID, ULONG, PULONG);
+ NTSTATUS NTAPI NtQuerySecurityObject (HANDLE, SECURITY_INFORMATION,
+ PSECURITY_DESCRIPTOR, ULONG, PULONG);
NTSTATUS NTAPI NtQueryVirtualMemory (HANDLE, PVOID, MEMORY_INFORMATION_CLASS,
PVOID, ULONG, PULONG);
NTSTATUS NTAPI NtUnmapViewOfSection (HANDLE, PVOID);
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index d9a1e5f..8420f85 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -1374,44 +1374,35 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
{
security_descriptor sd;
PSECURITY_DESCRIPTOR psd = NULL;
- LONG ret;
-
- if (object_type == SE_REGISTRY_KEY)
- {
- /* use different code for registry handles, for performance reasons */
- DWORD len = 0;
- if ((ret = RegGetKeySecurity ((HKEY) handle,
- DACL_SECURITY_INFORMATION
- | GROUP_SECURITY_INFORMATION
- | OWNER_SECURITY_INFORMATION,
- sd, &len)) != ERROR_INSUFFICIENT_BUFFER)
- __seterrno_from_win_error (ret);
- else if (!sd.malloc (len))
+
+ NTSTATUS ret;
+ ULONG len = 0;
+ ret = NtQuerySecurityObject (handle,
+ DACL_SECURITY_INFORMATION
+ | GROUP_SECURITY_INFORMATION
+ | OWNER_SECURITY_INFORMATION,
+ sd, len, &len);
+ if (ret == STATUS_BUFFER_TOO_SMALL)
+ {
+ if (!sd.malloc (len))
set_errno (ENOMEM);
- else if ((ret = RegGetKeySecurity ((HKEY) handle,
- DACL_SECURITY_INFORMATION
- | GROUP_SECURITY_INFORMATION
- | OWNER_SECURITY_INFORMATION,
- sd, &len)) != ERROR_SUCCESS)
- __seterrno_from_win_error (ret);
else
- psd = sd;
- get_info_from_sd (psd, attribute, uidret, gidret);
+ ret = NtQuerySecurityObject (handle,
+ DACL_SECURITY_INFORMATION
+ | GROUP_SECURITY_INFORMATION
+ | OWNER_SECURITY_INFORMATION,
+ sd, len, &len);
}
- else if ((ret = GetSecurityInfo (handle, object_type,
- DACL_SECURITY_INFORMATION
- | GROUP_SECURITY_INFORMATION
- | OWNER_SECURITY_INFORMATION,
- NULL, NULL, NULL, NULL, &psd)))
+ if (ret != STATUS_SUCCESS)
{
- __seterrno_from_win_error (ret);
- return -1;
+ __seterrno_from_win_error (RtlNtStatusToDosError (ret));
+ if (object_type == SE_FILE_OBJECT)
+ return -1;
}
else
- {
- get_info_from_sd (psd, attribute, uidret, gidret);
- LocalFree (psd);
- }
+ psd = sd;
+ get_info_from_sd (psd, attribute, uidret, gidret);
+
return 0;
}