* 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.
This commit is contained in:
@@ -224,20 +224,37 @@ get_sids_info (cygpsid owner_sid, cygpsid group_sid, __uid32_t * uidret, __gid32
|
||||
PSECURITY_DESCRIPTOR
|
||||
security_descriptor::malloc (size_t nsize)
|
||||
{
|
||||
if (psd)
|
||||
::free (psd);
|
||||
psd = (PSECURITY_DESCRIPTOR) ::malloc (nsize);
|
||||
sd_size = psd ? nsize : 0;
|
||||
free ();
|
||||
if ((psd = (PSECURITY_DESCRIPTOR) ::malloc (nsize)))
|
||||
{
|
||||
sd_size = nsize;
|
||||
type = malloced;
|
||||
}
|
||||
return psd;
|
||||
}
|
||||
|
||||
PSECURITY_DESCRIPTOR
|
||||
security_descriptor::realloc (size_t nsize)
|
||||
{
|
||||
PSECURITY_DESCRIPTOR tmp = (PSECURITY_DESCRIPTOR) ::realloc (psd, nsize);
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
PSECURITY_DESCRIPTOR tmp;
|
||||
|
||||
if (type == malloced)
|
||||
{
|
||||
if (!(tmp = (PSECURITY_DESCRIPTOR) ::realloc (psd, nsize)))
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(tmp = (PSECURITY_DESCRIPTOR) ::malloc (nsize)))
|
||||
return NULL;
|
||||
if (psd)
|
||||
{
|
||||
memcpy (tmp, psd, LocalSize (psd));
|
||||
LocalFree (psd);
|
||||
}
|
||||
}
|
||||
sd_size = nsize;
|
||||
type = malloced;
|
||||
return psd = tmp;
|
||||
}
|
||||
|
||||
@@ -245,9 +262,15 @@ void
|
||||
security_descriptor::free ()
|
||||
{
|
||||
if (psd)
|
||||
::free (psd);
|
||||
{
|
||||
if (type == local_alloced)
|
||||
LocalFree (psd);
|
||||
else
|
||||
::free (psd);
|
||||
}
|
||||
psd = NULL;
|
||||
sd_size = 0;
|
||||
type = local_alloced;
|
||||
}
|
||||
|
||||
#if 0 // unused
|
||||
|
Reference in New Issue
Block a user