RtlImpersonateSelf(): Set impersonation level in call to NtDuplicateToken().

svn path=/trunk/; revision=10106
This commit is contained in:
Eric Kohl 2004-07-13 11:52:09 +00:00
parent 3ed7b52fb9
commit 3e7bd9bd79

View file

@ -1,4 +1,4 @@
/* $Id: security.c,v 1.1 2004/05/31 19:29:02 gdalsnes Exp $
/* $Id: security.c,v 1.2 2004/07/13 11:52:09 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -24,8 +24,6 @@
NTSTATUS STDCALL
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
{
OBJECT_ATTRIBUTES ObjectAttributes;
SECURITY_QUALITY_OF_SERVICE SecQos;
HANDLE ProcessToken;
HANDLE ImpersonationToken;
NTSTATUS Status;
@ -34,28 +32,20 @@ RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
TOKEN_DUPLICATE,
&ProcessToken);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtOpenProcessToken() failed (Status %lx)\n", Status);
return(Status);
SecQos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
SecQos.ImpersonationLevel = ImpersonationLevel;
SecQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
SecQos.EffectiveOnly = FALSE;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = 0;
ObjectAttributes.ObjectName = NULL;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = &SecQos;
}
Status = NtDuplicateToken(ProcessToken,
TOKEN_IMPERSONATE,
&ObjectAttributes,
0,
NULL,
ImpersonationLevel,
TokenImpersonation,
&ImpersonationToken);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtDuplicateToken() failed (Status %lx)\n", Status);
NtClose(ProcessToken);
return(Status);
}
@ -64,6 +54,11 @@ RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
ThreadImpersonationToken,
&ImpersonationToken,
sizeof(HANDLE));
if (!NT_SUCCESS(Status))
{
DPRINT1("NtSetInformationThread() failed (Status %lx)\n", Status);
}
NtClose(ImpersonationToken);
NtClose(ProcessToken);