RtlImpersonateSelf(): Set impersonation level in call to NtDuplicateToken().
authorEric Kohl <eric.kohl@reactos.org>
Tue, 13 Jul 2004 11:52:09 +0000 (11:52 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 13 Jul 2004 11:52:09 +0000 (11:52 +0000)
svn path=/trunk/; revision=10106

reactos/lib/rtl/security.c

index c50ec28..6939ed8 100644 (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);