Make AdjustTokenPrivileges confirm to MSDN-documented behaviour:

- return FALSE on error with appropriate LastError
- return TRUE with LastError == ERROR_NOT_ALL_ASSIGNED if not all
  privileges could be adjusted
- return TRUE with LastError == ERROR_SUCCESS if all privileges
  were successfully adjusted

svn path=/trunk/; revision=10004
This commit is contained in:
Gé van Geldorp 2004-07-06 22:07:26 +00:00
parent f54f6b9018
commit 37635ba853
2 changed files with 16 additions and 10 deletions

View file

@ -1,4 +1,4 @@
/* $Id: token.c,v 1.10 2004/03/25 11:30:07 ekohl Exp $
/* $Id: token.c,v 1.11 2004/07/06 22:07:25 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -61,12 +61,18 @@ AdjustTokenPrivileges (HANDLE TokenHandle,
BufferLength,
PreviousState,
(PULONG)ReturnLength);
if (!NT_SUCCESS (Status))
if (STATUS_NOT_ALL_ASSIGNED == Status)
{
SetLastError (RtlNtStatusToDosError (Status));
SetLastError(ERROR_NOT_ALL_ASSIGNED);
return TRUE;
}
if (! NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
SetLastError(ERROR_SUCCESS); /* AdjustTokenPrivileges is documented to do this */
return TRUE;
}

View file

@ -1,4 +1,4 @@
/* $Id: token.c,v 1.35 2004/05/18 12:23:48 ekohl Exp $
/* $Id: token.c,v 1.36 2004/07/06 22:07:26 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -989,6 +989,7 @@ NtAdjustPrivilegesToken (IN HANDLE TokenHandle,
ULONG i;
ULONG j;
ULONG k;
ULONG Count;
#if 0
ULONG a;
ULONG b;
@ -1059,9 +1060,11 @@ NtAdjustPrivilegesToken (IN HANDLE TokenHandle,
Token->Privileges[i].Attributes &= ~SE_PRIVILEGE_ENABLED;
}
}
Status = STATUS_SUCCESS;
}
else
{
Count = 0;
for (i = 0; i < Token->PrivilegeCount; i++)
{
for (j = 0; j < NewState->PrivilegeCount; j++)
@ -1094,9 +1097,11 @@ NtAdjustPrivilegesToken (IN HANDLE TokenHandle,
DPRINT ("New attributes %lx\n",
Token->Privileges[i].Attributes);
}
Count++;
}
}
}
Status = Count < NewState->PrivilegeCount ? STATUS_NOT_ALL_ASSIGNED : STATUS_SUCCESS;
}
if (ReturnLength != NULL)
@ -1113,12 +1118,7 @@ NtAdjustPrivilegesToken (IN HANDLE TokenHandle,
DPRINT ("NtAdjustPrivilegesToken() done\n");
if (k < NewState->PrivilegeCount)
{
return STATUS_NOT_ALL_ASSIGNED;
}
return STATUS_SUCCESS;
return Status;
}