From 2be593d961e3ccd21a7a19b5a0b716e43d0137dc Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 22 Oct 2006 14:57:43 +0000 Subject: * external.cc (cygwin_internal): Use security_descriptor::copy method. * sec_helper.cc (security_descriptor::malloc): Use own free method. Set type. (security_descriptor::realloc): Handle the case that psd has been allocated using LocalAlloc. Set type. (security_descriptor::free): Ditto. * security.cc (get_nt_attribute): Remove. (get_reg_security): Remove. (get_nt_object_security): Use GetSecurityInfo which handles all securable objects. (get_nt_object_attribute): Remove. (get_object_attribute): Call get_nt_object_security instead of get_nt_object_attribute. (get_file_attribute): Ditto. (check_registry_access): Call get_nt_object_security instead of get_reg_security. * security.h (cygpsid::operator PSID): Make method const, not the result. (class security_descriptor): Add type member. Accomodate throughout. (security_descriptor::copy): New method. (security_descriptor::operator PSECURITY_DESCRIPTOR *): New operator. --- winsup/cygwin/security.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'winsup/cygwin/security.h') diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h index 94e3cc3f5..2b5b57275 100644 --- a/winsup/cygwin/security.h +++ b/winsup/cygwin/security.h @@ -43,7 +43,7 @@ protected: public: cygpsid () {} cygpsid (PSID nsid) { psid = nsid; } - operator const PSID () { return psid; } + operator PSID () const { return psid; } const PSID operator= (PSID nsid) { return psid = nsid;} __uid32_t get_id (BOOL search_grp, int *type = NULL); int get_uid () { return get_id (FALSE); } @@ -182,16 +182,28 @@ class security_descriptor { protected: PSECURITY_DESCRIPTOR psd; DWORD sd_size; + enum { local_alloced, malloced } type; public: - security_descriptor () : psd (NULL), sd_size (0) {} + security_descriptor () : psd (NULL), sd_size (0), type (local_alloced) {} ~security_descriptor () { free (); } PSECURITY_DESCRIPTOR malloc (size_t nsize); PSECURITY_DESCRIPTOR realloc (size_t nsize); void free (); - inline DWORD size () const { return sd_size; } + inline DWORD size () { + if (!sd_size && psd && type == local_alloced) + sd_size = LocalSize (psd); + return sd_size; + } + inline DWORD copy (void *buf, DWORD buf_size) { + if (buf_size < size ()) + return sd_size; + memcpy (buf, psd, sd_size); + return 0; + } inline operator const PSECURITY_DESCRIPTOR () { return psd; } + inline operator PSECURITY_DESCRIPTOR *() { return &psd; } }; class user_groups { -- cgit v1.2.3