From 6ddd8f6bd9beec1e408ed5dff5d8cb988f0fbd40 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 24 May 2012 15:51:48 +0300 Subject: [PATCH] Put Windows NTLM stuff inside consistent preprocessor directives. QNtlmWindowsHandles was placed inside Q_OS_WIN in some places and in other places inside Q_OS_WIN32. It seems that Q_OS_WIN is correct define everywhere. In addition placed "InitSecurityInterfaceW" inside L macro to convert argument to wide characters in WinCE. WinCE GetProcAddress takes LPCWSTR instead of LPCSTR. This fixes the QtNetwork build for WEC7, where Q_OS_WIN32 apparently is not defined. Should it be defined, is another story... Change-Id: Id309d20c46b66139e2cb2e62349067848d8ebb4e Reviewed-by: Shane Kearns --- src/network/kernel/qauthenticator.cpp | 24 ++++++++++++++++-------- src/network/kernel/qauthenticator_p.h | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 9d3159407a..b52e5c0da9 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -51,7 +51,7 @@ #include #include -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN #include #include #include @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE static QByteArray qNtlmPhase1(); static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phase2data); -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN static QByteArray qNtlmPhase1_SSPI(QAuthenticatorPrivate *ctx); static QByteArray qNtlmPhase3_SSPI(QAuthenticatorPrivate *ctx, const QByteArray& phase2data); #endif @@ -327,7 +327,7 @@ bool QAuthenticator::isNull() const return !d; } -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN class QNtlmWindowsHandles { public: @@ -353,7 +353,7 @@ QAuthenticatorPrivate::QAuthenticatorPrivate() QAuthenticatorPrivate::~QAuthenticatorPrivate() { -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN if (ntlmWindowsHandles) delete ntlmWindowsHandles; #endif @@ -484,7 +484,7 @@ QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMet case QAuthenticatorPrivate::Ntlm: methodString = "NTLM "; if (challenge.isEmpty()) { -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN QByteArray phase1Token; if (user.isEmpty()) // Only pull from system if no user was specified in authenticator phase1Token = qNtlmPhase1_SSPI(this); @@ -501,7 +501,7 @@ QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMet phase = Phase2; } } else { -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN QByteArray phase3Token; if (ntlmWindowsHandles) phase3Token = qNtlmPhase3_SSPI(this, QByteArray::fromBase64(challenge)); @@ -1475,7 +1475,7 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas return rc; } -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN // See http://davenport.sourceforge.net/ntlm.html // and libcurl http_ntlm.c @@ -1493,9 +1493,15 @@ static bool q_NTLM_SSPI_library_load() if (pSecurityFunctionTable == NULL) { securityDLLHandle = LoadLibrary(L"secur32.dll"); if (securityDLLHandle != NULL) { +#if defined(Q_OS_WINCE) + INIT_SECURITY_INTERFACE pInitSecurityInterface = + (INIT_SECURITY_INTERFACE)GetProcAddress(securityDLLHandle, + L"InitSecurityInterfaceW"); +#else INIT_SECURITY_INTERFACE pInitSecurityInterface = (INIT_SECURITY_INTERFACE)GetProcAddress(securityDLLHandle, "InitSecurityInterfaceW"); +#endif if (pInitSecurityInterface != NULL) pSecurityFunctionTable = pInitSecurityInterface(); } @@ -1507,7 +1513,7 @@ static bool q_NTLM_SSPI_library_load() return true; } - +#ifdef Q_OS_WIN // Phase 1: static QByteArray qNtlmPhase1_SSPI(QAuthenticatorPrivate *ctx) { @@ -1631,6 +1637,8 @@ static QByteArray qNtlmPhase3_SSPI(QAuthenticatorPrivate *ctx, const QByteArray& return result; } +#endif // Q_OS_WIN + #endif QT_END_NAMESPACE diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index 491e004737..f4736de3e7 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE class QHttpResponseHeader; -#ifdef Q_OS_WIN32 +#ifdef Q_OS_WIN class QNtlmWindowsHandles; #endif