* flock.cc (allow_others_to_sync): Use RtlGetDaclSecurityDescriptor

rather than accessing the SECURITY_DESCRIPTOR structure directly.
	Take no DACL and NULL DACL into account.
This commit is contained in:
Corinna Vinschen 2012-03-02 17:07:17 +00:00
parent 52cbb05cfb
commit b4ad7197fb
2 changed files with 22 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2012-03-02 Corinna Vinschen <corinna@vinschen.de>
* flock.cc (allow_others_to_sync): Use RtlGetDaclSecurityDescriptor
rather than accessing the SECURITY_DESCRIPTOR structure directly.
Take no DACL and NULL DACL into account.
2012-03-02 Corinna Vinschen <corinna@vinschen.de> 2012-03-02 Corinna Vinschen <corinna@vinschen.de>
* fhandler_console.cc (fhandler_console::input_tcsetattr): Revert * fhandler_console.cc (fhandler_console::input_tcsetattr): Revert

View File

@ -176,8 +176,22 @@ allow_others_to_sync ()
/* Create a valid dacl pointer and set its size to be as big as /* Create a valid dacl pointer and set its size to be as big as
there's room in the temporary buffer. Note that the descriptor there's room in the temporary buffer. Note that the descriptor
is in self-relative format. */ is in self-relative format. */
dacl = (PACL) ((char *) sd + (uintptr_t) sd->Dacl); BOOLEAN present, defaulted;
dacl->AclSize = NT_MAX_PATH * sizeof (WCHAR) - ((char *) dacl - (char *) sd); RtlGetDaclSecurityDescriptor (sd, &present, &dacl, &defaulted);
if (dacl == NULL) /* Everyone has all access anyway */
{
done = true;
return;
}
else if (!present)
{
dacl = (PACL) (sd + 1);
RtlCreateAcl (dacl, MAX_PROCESS_SD_SIZE - sizeof *sd, ACL_REVISION);
}
else
{
dacl->AclSize = MAX_PROCESS_SD_SIZE - ((PBYTE) dacl - (PBYTE) sd);
}
/* Allow everyone to SYNCHRONIZE with this process. */ /* Allow everyone to SYNCHRONIZE with this process. */
status = RtlAddAccessAllowedAce (dacl, ACL_REVISION, SYNCHRONIZE, status = RtlAddAccessAllowedAce (dacl, ACL_REVISION, SYNCHRONIZE,
well_known_world_sid); well_known_world_sid);