Removed duplicate function tables, respecting WITH_NATIVE_SSPI
authorArmin Novak <armin.novak@thincast.com>
Wed, 17 Jun 2015 11:24:11 +0000 (13:24 +0200)
committerArmin Novak <armin.novak@thincast.com>
Wed, 17 Jun 2015 11:24:11 +0000 (13:24 +0200)
winpr/libwinpr/sspi/sspi.c

index e2d495a..d47e7d3 100644 (file)
@@ -40,10 +40,13 @@ static HMODULE g_SspiModule = NULL;
 static SecurityFunctionTableW* g_SspiW = NULL;
 static SecurityFunctionTableA* g_SspiA = NULL;
 
-SecurityFunctionTableA sspi_SecurityFunctionTableA;
-SecurityFunctionTableW sspi_SecurityFunctionTableW;
+static BOOL ShouldUseNativeSspi(void);
+#if defined(WITH_NATIVE_SSPI)
+static BOOL InitializeSspiModule_Native(void);
+#endif
+static void InitializeSspiModule(DWORD flags);
 
-BOOL ShouldUseNativeSspi()
+BOOL ShouldUseNativeSspi(void)
 {
        BOOL status = FALSE;
 #ifdef _WIN32
@@ -70,6 +73,7 @@ BOOL ShouldUseNativeSspi()
        return status;
 }
 
+#if defined(WITH_NATIVE_SSPI)
 BOOL InitializeSspiModule_Native(void)
 {
        INIT_SECURITY_INTERFACE_W pInitSecurityInterfaceW;
@@ -94,6 +98,7 @@ BOOL InitializeSspiModule_Native(void)
 
        return TRUE;
 }
+#endif
 
 void InitializeSspiModule(DWORD flags)
 {
@@ -108,6 +113,7 @@ void InitializeSspiModule(DWORD flags)
 
        g_Log = WLog_Get("com.winpr.sspi");
 
+#if defined(WITH_NATIVE_SSPI)
        if (flags && (flags & SSPI_INTERFACE_NATIVE))
        {
                status = InitializeSspiModule_Native();
@@ -123,6 +129,7 @@ void InitializeSspiModule(DWORD flags)
        {
                status = InitializeSspiModule_Native();
        }
+#endif
 
        if (!status)
        {
@@ -315,7 +322,7 @@ SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceExW(DWORD flags)
 
        WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceExW");
 
-       return &sspi_SecurityFunctionTableW;
+       return g_SspiW;
 }
 
 SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceExA(DWORD flags)
@@ -325,7 +332,7 @@ SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceExA(DWORD flags)
 
        WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceExA");
 
-       return &sspi_SecurityFunctionTableA;
+       return g_SspiA;
 }
 
 /**
@@ -375,7 +382,7 @@ SecurityFunctionTableW* SEC_ENTRY sspi_InitSecurityInterfaceW(void)
 
        WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceW");
 
-       return &sspi_SecurityFunctionTableW;
+       return g_SspiW;
 }
 
 SecurityFunctionTableA* SEC_ENTRY sspi_InitSecurityInterfaceA(void)
@@ -385,7 +392,7 @@ SecurityFunctionTableA* SEC_ENTRY sspi_InitSecurityInterfaceA(void)
 
        WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceA");
 
-       return &sspi_SecurityFunctionTableA;
+       return g_SspiA;
 }
 
 SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo)
@@ -425,8 +432,8 @@ SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityPackageInfoA(SEC_CHAR* pszPackageNam
 /* Credential Management */
 
 SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage,
-               ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
-               void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
+                                                        ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
+                                                        void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        SECURITY_STATUS status;
 
@@ -437,7 +444,7 @@ SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal
                return SEC_E_UNSUPPORTED_FUNCTION;
 
        status = g_SspiW->AcquireCredentialsHandleW(pszPrincipal, pszPackage, fCredentialUse,
-               pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
+                                                   pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
 
        WLog_Print(g_Log, WLOG_DEBUG, "AcquireCredentialsHandleW: %s (0x%04X)", GetSecurityStatusString(status), status);
 
@@ -445,8 +452,8 @@ SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleW(SEC_WCHAR* pszPrincipal
 }
 
 SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage,
-               ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
-               void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
+                                                        ULONG fCredentialUse, void* pvLogonID, void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
+                                                        void* pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
 {
        SECURITY_STATUS status;
 
@@ -457,7 +464,7 @@ SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleA(SEC_CHAR* pszPrincipal,
                return SEC_E_UNSUPPORTED_FUNCTION;
 
        status = g_SspiA->AcquireCredentialsHandleA(pszPrincipal, pszPackage, fCredentialUse,
-               pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
+                                                   pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
 
        WLog_Print(g_Log, WLOG_DEBUG, "AcquireCredentialsHandleA: %s (0x%04X)", GetSecurityStatusString(status), status);
 
@@ -569,8 +576,8 @@ SECURITY_STATUS SEC_ENTRY sspi_QueryCredentialsAttributesA(PCredHandle phCredent
 /* Context Management */
 
 SECURITY_STATUS SEC_ENTRY sspi_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext,
-               PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
+                                                    PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
+                                                    PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
 {
        SECURITY_STATUS status;
 
@@ -581,7 +588,7 @@ SECURITY_STATUS SEC_ENTRY sspi_AcceptSecurityContext(PCredHandle phCredential, P
                return SEC_E_UNSUPPORTED_FUNCTION;
 
        status = g_SspiW->AcceptSecurityContext(phCredential, phContext, pInput, fContextReq,
-               TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsTimeStamp);
+                                               TargetDataRep, phNewContext, pOutput, pfContextAttr, ptsTimeStamp);
 
        WLog_Print(g_Log, WLOG_DEBUG, "AcceptSecurityContext: %s (0x%04X)", GetSecurityStatusString(status), status);
 
@@ -674,9 +681,9 @@ SECURITY_STATUS SEC_ENTRY sspi_ImpersonateSecurityContext(PCtxtHandle phContext)
 }
 
 SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
-               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
+                                                         SEC_WCHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+                                                         PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+                                                         PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        SECURITY_STATUS status;
 
@@ -687,8 +694,8 @@ SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextW(PCredHandle phCredenti
                return SEC_E_UNSUPPORTED_FUNCTION;
 
        status = g_SspiW->InitializeSecurityContextW(phCredential, phContext,
-               pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
-               Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
+                                                    pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
+                                                    Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
 
        WLog_Print(g_Log, WLOG_DEBUG, "InitializeSecurityContextW: %s (0x%04X)", GetSecurityStatusString(status), status);
 
@@ -696,9 +703,9 @@ SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextW(PCredHandle phCredenti
 }
 
 SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext,
-               SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
-               PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
-               PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
+                                                         SEC_CHAR* pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep,
+                                                         PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext,
+                                                         PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
 {
        SECURITY_STATUS status;
 
@@ -709,8 +716,8 @@ SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextA(PCredHandle phCredenti
                return SEC_E_UNSUPPORTED_FUNCTION;
 
        status = g_SspiA->InitializeSecurityContextA(phCredential, phContext,
-               pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
-               Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
+                                                    pszTargetName, fContextReq, Reserved1, TargetDataRep, pInput,
+                                                    Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
 
        WLog_Print(g_Log, WLOG_DEBUG, "InitializeSecurityContextA: %s (0x%04X)", GetSecurityStatusString(status), status);