From a818f6fad3c2e719dbf490b743a4b04d04a0bdb2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 8 Feb 2019 12:14:09 +0300 Subject: netlibsecurity: more logs --- src/mir_app/src/netlibsecurity.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp index 46c4d9fa0d..c5f0ea449b 100644 --- a/src/mir_app/src/netlibsecurity.cpp +++ b/src/mir_app/src/netlibsecurity.cpp @@ -64,13 +64,13 @@ static mir_cs csSec; static void ReportSecError(SECURITY_STATUS scRet, int line) { - char szMsgBuf[256]; - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + wchar_t szMsgBuf[256]; + FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, scRet, LANG_USER_DEFAULT, szMsgBuf, _countof(szMsgBuf), nullptr); - char *p = strchr(szMsgBuf, 13); if (p) *p = 0; + wchar_t *p = wcschr(szMsgBuf, 13); if (p) *p = 0; - Netlib_Logf(nullptr, "Security error 0x%x on line %u (%s)", scRet, line, szMsgBuf); + Netlib_LogfW(nullptr, L"Security error 0x%x on line %u (%s)", scRet, line, szMsgBuf); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -209,11 +209,12 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, SecBufferDesc outputBufferDescriptor, inputBufferDescriptor; SecBuffer outputSecurityToken, inputSecurityToken; - TimeStamp tokenExpiration; - ULONG contextAttributes; char *szOutputToken; NtlmHandleType *hNtlm = (NtlmHandleType*)hSecurity; + + Netlib_Logf(nullptr, "NtlmCreateResponseFromChallenge (%s): chl=%s {%S:%S} => %d", hNtlm->szProvider, szChallenge, login, psw, complete); + if (mir_wstrcmpi(hNtlm->szProvider, L"Basic")) { bool isGSSAPI = mir_wstrcmpi(hNtlm->szProvider, L"Kerberos") == 0; bool hasChallenge = szChallenge != nullptr && szChallenge[0] != '\0'; @@ -313,6 +314,8 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, outputSecurityToken.cbBuffer = hNtlm->cbMaxToken; outputSecurityToken.pvBuffer = alloca(outputSecurityToken.cbBuffer); + ULONG contextAttributes; + TimeStamp tokenExpiration; SECURITY_STATUS sc = InitializeSecurityContext(&hNtlm->hClientCredential, hasChallenge ? &hNtlm->hClientContext : nullptr, hNtlm->szPrincipal, isGSSAPI ? ISC_REQ_MUTUAL_AUTH | ISC_REQ_STREAM : 0, 0, SECURITY_NATIVE_DREP, -- cgit v1.2.3