[RTL] When taking system volume ownership, assert that we succeeded to restore privileges

CORE-17637
This commit is contained in:
Jérôme Gardou 2021-06-17 15:39:40 +02:00 committed by Jérôme Gardou
parent 9c5b39e25a
commit fb9ebe17bf

View file

@ -412,7 +412,9 @@ Cleanup:
return Status;
}
static NTSTATUS
_Must_inspect_result_
static
NTSTATUS
RtlpSysVolTakeOwnership(IN PUNICODE_STRING DirectoryPath,
IN PSECURITY_DESCRIPTOR SecurityDescriptor)
{
@ -511,12 +513,16 @@ RtlpSysVolTakeOwnership(IN PUNICODE_STRING DirectoryPath,
Cleanup:
if (TokenEnabled)
{
ZwAdjustPrivilegesToken(hToken,
FALSE,
&TokenPrivileges,
0,
NULL,
NULL);
/* Disable privileges that we had to enable, whetever the result was. */
NTSTATUS Status2 = ZwAdjustPrivilegesToken(hToken,
FALSE,
&TokenPrivileges,
0,
NULL,
NULL);
/* This must succeed */
ASSERT(NT_SUCCESS(Status2));
(void)Status2;
}
if (AdminSid != NULL)