mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:23:01 +00:00
RtlImpersonateSelf(): Set impersonation level in call to NtDuplicateToken().
svn path=/trunk/; revision=10106
This commit is contained in:
parent
3ed7b52fb9
commit
3e7bd9bd79
1 changed files with 12 additions and 17 deletions
|
@ -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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -24,8 +24,6 @@
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
SECURITY_QUALITY_OF_SERVICE SecQos;
|
|
||||||
HANDLE ProcessToken;
|
HANDLE ProcessToken;
|
||||||
HANDLE ImpersonationToken;
|
HANDLE ImpersonationToken;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -34,28 +32,20 @@ RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
||||||
TOKEN_DUPLICATE,
|
TOKEN_DUPLICATE,
|
||||||
&ProcessToken);
|
&ProcessToken);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("NtOpenProcessToken() failed (Status %lx)\n", Status);
|
||||||
return(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,
|
Status = NtDuplicateToken(ProcessToken,
|
||||||
TOKEN_IMPERSONATE,
|
TOKEN_IMPERSONATE,
|
||||||
&ObjectAttributes,
|
NULL,
|
||||||
0,
|
ImpersonationLevel,
|
||||||
TokenImpersonation,
|
TokenImpersonation,
|
||||||
&ImpersonationToken);
|
&ImpersonationToken);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
DPRINT1("NtDuplicateToken() failed (Status %lx)\n", Status);
|
||||||
NtClose(ProcessToken);
|
NtClose(ProcessToken);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -64,6 +54,11 @@ RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
||||||
ThreadImpersonationToken,
|
ThreadImpersonationToken,
|
||||||
&ImpersonationToken,
|
&ImpersonationToken,
|
||||||
sizeof(HANDLE));
|
sizeof(HANDLE));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("NtSetInformationThread() failed (Status %lx)\n", Status);
|
||||||
|
}
|
||||||
|
|
||||||
NtClose(ImpersonationToken);
|
NtClose(ImpersonationToken);
|
||||||
NtClose(ProcessToken);
|
NtClose(ProcessToken);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue