Windows: npdll do not retrieve auth id
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 28 Jun 2015 17:21:35 +0000 (13:21 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Thu, 24 Sep 2015 04:19:33 +0000 (00:19 -0400)
The authentication id for the process will always be obtained in kernel
so no longer try to fetch it in userland.

Change-Id: I8d35af1349e137b8a3d7d8299b16e443710c6482
Reviewed-on: http://gerrit.openafs.org/11911
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/npdll/AFS_Npdll.c

index d0b23c3..6487928 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2015 Your File System, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -133,9 +133,6 @@ static wchar_t wszServerComment[] = OPENAFS_SERVER_COMMENT;
 
 static BOOL bServerNameRead = FALSE;
 
-LARGE_INTEGER
-AFSRetrieveAuthId( void);
-
 void
 ReadProviderNameString( void)
 {
@@ -817,14 +814,6 @@ NPAddConnection3( HWND            hwndOwner,
 
         pConnectCB->Type = lpNetResource->dwType;
 
-        pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPAddConnection3 Retrieved authentication id %08lX-%08lX\n",
-                     pConnectCB->AuthenticationId.HighPart,
-                     pConnectCB->AuthenticationId.LowPart);
-#endif
-
         hControlDevice = OpenRedirector();
 
         if( hControlDevice == NULL)
@@ -1133,14 +1122,6 @@ NPCancelConnection( LPWSTR  lpName,
 
         pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
 
-        pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPCancelConnection Retrieved authentication id %08lX-%08lX\n",
-                     pConnectCB->AuthenticationId.HighPart,
-                     pConnectCB->AuthenticationId.LowPart);
-#endif
-
         hControlDevice = OpenRedirector();
 
         if( hControlDevice == NULL)
@@ -1576,14 +1557,6 @@ NPGetConnectionCommon( LPWSTR  lpLocalName,
 
         pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
 
-        pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPGetConnection Retrieved authentication id %08lX-%08lX\n",
-                     pConnectCB->AuthenticationId.HighPart,
-                     pConnectCB->AuthenticationId.LowPart);
-#endif
-
         hControlDevice = OpenRedirector();
 
         if( hControlDevice == NULL)
@@ -1842,14 +1815,6 @@ NPGetConnection3Common( IN     LPCWSTR lpLocalName,
 
         pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
 
-        pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPGetConnection3 Retrieved authentication id %08lX-%08lX\n",
-                     pConnectCB->AuthenticationId.HighPart,
-                     pConnectCB->AuthenticationId.LowPart);
-#endif
-
         hControlDevice = OpenRedirector();
 
         if( hControlDevice == NULL)
@@ -1962,8 +1927,6 @@ NPGetConnectionPerformance( LPCWSTR lpRemoteName,
 
         pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
 
-        pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
         hControlDevice = OpenRedirector();
 
         if( hControlDevice == NULL)
@@ -2724,14 +2687,6 @@ NPEnumResource( HANDLE  hEnum,
                           pEnumCB->RemoteName);
         }
 
-        pConnectionCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPEnumResource Retrieved authentication id %08lX-%08lX\n",
-                     pConnectionCB->AuthenticationId.HighPart,
-                     pConnectionCB->AuthenticationId.LowPart);
-#endif
-
         dwError = DeviceIoControl( hControlDevice,
                                    IOCTL_AFS_LIST_CONNECTIONS,
                                    pConnectionCB,
@@ -3206,14 +3161,6 @@ NPGetResourceInformation( LPNETRESOURCE   lpNetResource,
 
         pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
 
-        pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPGetResourceInformation Retrieved authentication id %08lX-%08lX\n",
-                     pConnectCB->AuthenticationId.HighPart,
-                     pConnectCB->AuthenticationId.LowPart);
-#endif
-
         hControlDevice = OpenRedirector();
 
         if( hControlDevice == NULL)
@@ -3727,14 +3674,6 @@ NPGetUniversalNameCommon( LPCWSTR lpLocalPath,
 
         pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
 
-        pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"NPGetUniversalName Retrieved authentication id %08lX-%08lX\n",
-                     pConnectCB->AuthenticationId.HighPart,
-                     pConnectCB->AuthenticationId.LowPart);
-#endif
-
         hControlDevice = OpenRedirector();
 
         if( hControlDevice == NULL)
@@ -4232,74 +4171,6 @@ OpenRedirector()
     return hControlDevice;
 }
 
-LARGE_INTEGER
-AFSRetrieveAuthId()
-{
-
-    LARGE_INTEGER liAuthId = {0,0};
-    HANDLE hToken = NULL;
-    TOKEN_STATISTICS stTokenInfo;
-    DWORD dwCopyBytes = 0;
-
-    if ( !OpenThreadToken( GetCurrentThread(),
-                           TOKEN_QUERY,
-                           FALSE,       // Impersonation
-                           &hToken))
-    {
-        if( !OpenProcessToken( GetCurrentProcess(),
-                               TOKEN_QUERY,
-                               &hToken))
-        {
-
-#ifdef AFS_DEBUG_TRACE
-            AFSDbgPrint( L"AFSRetrieveAuthId Failed to retrieve Thread and Process tokens 0x%X\n",
-                         GetLastError());
-#endif
-        }
-        else
-        {
-
-#ifdef AFS_DEBUG_TRACE
-            AFSDbgPrint( L"AFSRetrieveAuthId Retrieved Process Token\n");
-#endif
-        }
-    }
-    else
-    {
-
-#ifdef AFS_DEBUG_TRACE
-        AFSDbgPrint( L"AFSRetrieveAuthId Retrieved Thread Token\n");
-#endif
-    }
-
-    if ( hToken != NULL)
-    {
-
-        if( !GetTokenInformation( hToken,
-                                  TokenStatistics,
-                                  &stTokenInfo,
-                                  sizeof( TOKEN_STATISTICS),
-                                  &dwCopyBytes))
-        {
-
-#ifdef AFS_DEBUG_TRACE
-            AFSDbgPrint( L"AFSRetrieveAuthId Failed to retrieve token information 0x%X\n",
-                         GetLastError());
-#endif
-        }
-        else
-        {
-
-            liAuthId.HighPart = stTokenInfo.AuthenticationId.HighPart;
-            liAuthId.LowPart = stTokenInfo.AuthenticationId.LowPart;
-        }
-
-        CloseHandle( hToken);
-    }
-
-    return liAuthId;
-}
-
 static DWORD
 Debug(void)
 {