Using max level allowed when getting current token
authorHenric Müller <hemuller@microsoft.com>
Tue, 6 Sep 2016 08:08:50 +0000 (10:08 +0200)
committerHenric Müller <hemuller@microsoft.com>
Tue, 6 Sep 2016 08:08:50 +0000 (10:08 +0200)
Reference source of WindowsIdentity is using `MAXIMUM_ALLOWED`
as desired level by default when getting current token.
Changing to same behaviour to enable duplicate and impersonation
to be made on the token retrieved by GetCurrentToken.

mono/metadata/mono-security.c

index 0b2d4a8c039fecae0ff326da57ced48c9ee52b9d..865b9ca1e04236ec1a7c7840436fca8c6e02de8a 100644 (file)
@@ -276,9 +276,9 @@ ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (void)
         */
 
        /* thread may be impersonating somebody */
-       if (OpenThreadToken (GetCurrentThread (), TOKEN_QUERY, 1, &token) == 0) {
+       if (OpenThreadToken (GetCurrentThread (), MAXIMUM_ALLOWED, 1, &token) == 0) {
                /* if not take the process identity */
-               OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &token);
+               OpenProcessToken (GetCurrentProcess (), MAXIMUM_ALLOWED, &token);
        }
 #else
        token = GINT_TO_POINTER (geteuid ());