From 338da730e8bc23e227e26b094cba6bb6233c42de Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Fri, 25 Oct 2013 10:56:01 +0200 Subject: network: fix multi-phased NTLM authentication tested manually with internal NTLM proxy. Patch-by: Jonathan Lauvernier Change-Id: Ib3ed7aff12cb8d59ffc2b11ecc1c4fdc04acb368 Reviewed-by: Richard J. Moore --- src/network/kernel/qauthenticator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/network/kernel') diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index e1a24a226f..8c16486878 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -189,7 +189,7 @@ QAuthenticator &QAuthenticator::operator=(const QAuthenticator &other) d->realm = other.d->realm; d->method = other.d->method; d->options = other.d->options; - } else { + } else if (d->phase == QAuthenticatorPrivate::Start) { delete d; d = 0; } @@ -267,7 +267,8 @@ void QAuthenticator::detach() return; } - d->phase = QAuthenticatorPrivate::Start; + if (d->phase == QAuthenticatorPrivate::Done) + d->phase = QAuthenticatorPrivate::Start; } /*! -- cgit v1.2.3 From 3655d71719a4746938f364bfe0d82c1609c3eacb Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 18 Jul 2013 18:20:42 +0200 Subject: Fix the network proxy code for windows to detect properly services This patch makes it so even sub processes of services are also detected to be running in the context of a service. With the previous code it would only detect that the current process is a service and not the sub processes. This fix makes sure we detect properly if the current process is running in the context of a service. This is important to detect properly the proxy configuration of the current user. Change-Id: I110dee62597aec3f8e2f6925166a428f72d14fd0 Reviewed-by: Joerg Bornemann Reviewed-by: Friedemann Kleint --- src/network/kernel/qnetworkproxy_win.cpp | 52 ++++++++++++-------------------- 1 file changed, 20 insertions(+), 32 deletions(-) (limited to 'src/network/kernel') diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp index f1893ae322..e16d7e557e 100644 --- a/src/network/kernel/qnetworkproxy_win.cpp +++ b/src/network/kernel/qnetworkproxy_win.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include "qnetworkfunctions_wince.h" /* @@ -115,48 +116,38 @@ typedef HINTERNET (WINAPI * PtrWinHttpOpen)(LPCWSTR, DWORD, LPCWSTR, LPCWSTR,DWO typedef BOOL (WINAPI * PtrWinHttpGetDefaultProxyConfiguration)(WINHTTP_PROXY_INFO*); typedef BOOL (WINAPI * PtrWinHttpGetIEProxyConfigForCurrentUser)(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG*); typedef BOOL (WINAPI * PtrWinHttpCloseHandle)(HINTERNET); -typedef SC_HANDLE (WINAPI * PtrOpenSCManager)(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess); -typedef BOOL (WINAPI * PtrEnumServicesStatusEx)(SC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, - LPDWORD lpServicesReturned, LPDWORD lpResumeHandle, LPCWSTR pszGroupName); typedef BOOL (WINAPI * PtrCloseServiceHandle)(SC_HANDLE hSCObject); static PtrWinHttpGetProxyForUrl ptrWinHttpGetProxyForUrl = 0; static PtrWinHttpOpen ptrWinHttpOpen = 0; static PtrWinHttpGetDefaultProxyConfiguration ptrWinHttpGetDefaultProxyConfiguration = 0; static PtrWinHttpGetIEProxyConfigForCurrentUser ptrWinHttpGetIEProxyConfigForCurrentUser = 0; static PtrWinHttpCloseHandle ptrWinHttpCloseHandle = 0; -static PtrOpenSCManager ptrOpenSCManager = 0; -static PtrEnumServicesStatusEx ptrEnumServicesStatusEx = 0; -static PtrCloseServiceHandle ptrCloseServiceHandle = 0; +#ifndef Q_OS_WINCE static bool currentProcessIsService() { - if (!ptrOpenSCManager || !ptrEnumServicesStatusEx|| !ptrCloseServiceHandle) - return false; - - SC_HANDLE hSCM = ptrOpenSCManager(0, 0, SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_CONNECT); - if (!hSCM) - return false; - - ULONG bufSize = 0; - ULONG nbServices = 0; - if (ptrEnumServicesStatusEx(hSCM, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_ACTIVE, 0, bufSize, &bufSize, &nbServices, 0, 0)) - return false; //error case - - LPENUM_SERVICE_STATUS_PROCESS info = reinterpret_cast(malloc(bufSize)); - bool foundService = false; - if (ptrEnumServicesStatusEx(hSCM, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_ACTIVE, (LPBYTE)info, bufSize, &bufSize, &nbServices, 0, 0)) { - DWORD currProcId = GetCurrentProcessId(); - for (ULONG i = 0; i < nbServices && !foundService; i++) { - if (info[i].ServiceStatusProcess.dwProcessId == currProcId) - foundService = true; + typedef BOOL (WINAPI *PtrGetUserName)(LPTSTR lpBuffer, LPDWORD lpnSize); + typedef BOOL (WINAPI *PtrLookupAccountName)(LPCTSTR lpSystemName, LPCTSTR lpAccountName, PSID Sid, + LPDWORD cbSid, LPTSTR ReferencedDomainName, LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse); + static PtrGetUserName ptrGetUserName = (PtrGetUserName)QSystemLibrary::resolve(QLatin1String("Advapi32"), "GetUserNameW"); + static PtrLookupAccountName ptrLookupAccountName = (PtrLookupAccountName)QSystemLibrary::resolve(QLatin1String("Advapi32"), "LookupAccountNameW"); + + if (ptrGetUserName && ptrLookupAccountName) { + wchar_t userName[UNLEN + 1] = L""; + DWORD size = UNLEN; + if (ptrGetUserName(userName, &size)) { + SID_NAME_USE type = SidTypeUser; + DWORD dummy = MAX_PATH; + wchar_t dummyStr[MAX_PATH] = L""; + PSID psid = 0; + if (ptrLookupAccountName(NULL, userName, &psid, &dummy, dummyStr, &dummy, &type)) + return type != SidTypeUser; //returns true if the current user is not a user } } - - ptrCloseServiceHandle(hSCM); - free(info); - return foundService; + return false; } +#endif // ! Q_OS_WINCE static QStringList splitSpaceSemicolon(const QString &source) { @@ -418,9 +409,6 @@ void QWindowsSystemProxy::init() ptrWinHttpGetProxyForUrl = (PtrWinHttpGetProxyForUrl)lib.resolve("WinHttpGetProxyForUrl"); ptrWinHttpGetDefaultProxyConfiguration = (PtrWinHttpGetDefaultProxyConfiguration)lib.resolve("WinHttpGetDefaultProxyConfiguration"); ptrWinHttpGetIEProxyConfigForCurrentUser = (PtrWinHttpGetIEProxyConfigForCurrentUser)lib.resolve("WinHttpGetIEProxyConfigForCurrentUser"); - ptrOpenSCManager = (PtrOpenSCManager) QSystemLibrary(L"advapi32").resolve("OpenSCManagerW"); - ptrEnumServicesStatusEx = (PtrEnumServicesStatusEx) QSystemLibrary(L"advapi32").resolve("EnumServicesStatusExW"); - ptrCloseServiceHandle = (PtrCloseServiceHandle) QSystemLibrary(L"advapi32").resolve("CloseServiceHandle"); // Try to obtain the Internet Explorer configuration. WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxyConfig; -- cgit v1.2.3 From 43684a20d044de6d4daac750809750777b68c9e5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 31 Oct 2013 13:34:10 +0100 Subject: use private linkage where possible Change-Id: Ie8eaa71bee87654c21218a23efd7e9d65b71f022 Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira --- src/network/kernel/kernel.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/network/kernel') diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index a4a19988b3..97f52fdb6e 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -35,7 +35,7 @@ android { win32: { HEADERS += kernel/qnetworkinterface_win_p.h SOURCES += kernel/qdnslookup_win.cpp kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp - LIBS += -ldnsapi + LIBS_PRIVATE += -ldnsapi } integrity:SOURCES += kernel/qdnslookup_unix.cpp kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp -- cgit v1.2.3