* 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:
Corinna Vinschen
2006-10-22 14:57:43 +00:00
parent 2b26c2fc41
commit 2be593d961
5 changed files with 96 additions and 106 deletions

View File

@ -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 {