http NTLM: Further tiding up to libcurl standards

This commit is contained in:
Yang Tse
2011-08-09 22:56:17 +02:00
parent 5ed17de326
commit c7fb556f26
3 changed files with 57 additions and 60 deletions

View File

@@ -33,9 +33,6 @@
#define DEBUG_ME 0 #define DEBUG_ME 0
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@@ -1127,15 +1124,15 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
ntlm->identity.DomainLength = domlen; ntlm->identity.DomainLength = domlen;
ntlm->identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; ntlm->identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
} }
else { else
ntlm->p_identity = NULL; ntlm->p_identity = NULL;
}
if(s_pSecFn->AcquireCredentialsHandleA(NULL, (char *)"NTLM", SECPKG_CRED_OUTBOUND, status = s_pSecFn->AcquireCredentialsHandleA(NULL, (char *)"NTLM",
NULL, ntlm->p_identity, NULL, NULL, SECPKG_CRED_OUTBOUND, NULL,
&ntlm->handle, &tsDummy) != SEC_E_OK) { ntlm->p_identity, NULL, NULL,
&ntlm->handle, &tsDummy);
if(status != SEC_E_OK)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
}
desc.ulVersion = SECBUFFER_VERSION; desc.ulVersion = SECBUFFER_VERSION;
desc.cBuffers = 1; desc.cBuffers = 1;
@@ -1154,9 +1151,9 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
&ntlm->c_handle, &desc, &ntlm->c_handle, &desc,
&attrs, &tsDummy); &attrs, &tsDummy);
if(status == SEC_I_COMPLETE_AND_CONTINUE || status == SEC_I_CONTINUE_NEEDED) { if(status == SEC_I_COMPLETE_AND_CONTINUE ||
status == SEC_I_CONTINUE_NEEDED)
s_pSecFn->CompleteAuthToken(&ntlm->c_handle, &desc); s_pSecFn->CompleteAuthToken(&ntlm->c_handle, &desc);
}
else if(status != SEC_E_OK) { else if(status != SEC_E_OK) {
s_pSecFn->FreeCredentialsHandle(&ntlm->handle); s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
return CURLE_RECV_ERROR; return CURLE_RECV_ERROR;
@@ -1313,7 +1310,6 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
0, &ntlm->c_handle, 0, &ntlm->c_handle,
&type_3_desc, &type_3_desc,
&attrs, &tsDummy); &attrs, &tsDummy);
if(status != SEC_E_OK) if(status != SEC_E_OK)
return CURLE_RECV_ERROR; return CURLE_RECV_ERROR;
@@ -1543,8 +1539,8 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
0x0, 0x0, 0x0, 0x0,
LONGQUARTET(ntlm->flags)); LONGQUARTET(ntlm->flags));
DEBUGASSERT(size==64);
DEBUGASSERT(size==64);
DEBUGASSERT(size == (size_t)lmrespoff); DEBUGASSERT(size == (size_t)lmrespoff);
/* We append the binary hashes */ /* We append the binary hashes */
@@ -1656,10 +1652,9 @@ void Curl_http_ntlm_cleanup(struct connectdata *conn)
#ifdef USE_WINDOWS_SSPI #ifdef USE_WINDOWS_SSPI
ntlm_sspi_cleanup(&conn->ntlm); ntlm_sspi_cleanup(&conn->ntlm);
ntlm_sspi_cleanup(&conn->proxyntlm); ntlm_sspi_cleanup(&conn->proxyntlm);
#else #elif defined(WINBIND_NTLM_AUTH_ENABLED)
#ifdef WINBIND_NTLM_AUTH_ENABLED
sso_ntlm_close(conn); sso_ntlm_close(conn);
#endif #else
(void)conn; (void)conn;
#endif #endif
} }

View File

@@ -44,7 +44,11 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
CURLcode Curl_output_ntlm_sso(struct connectdata *conn, bool proxy); CURLcode Curl_output_ntlm_sso(struct connectdata *conn, bool proxy);
#endif #endif
#ifdef USE_NTLM
void Curl_http_ntlm_cleanup(struct connectdata *conn); void Curl_http_ntlm_cleanup(struct connectdata *conn);
#else
#define Curl_http_ntlm_cleanup(x)
#endif
/* Flag bits definitions based on http://davenport.sourceforge.net/ntlm.html */ /* Flag bits definitions based on http://davenport.sourceforge.net/ntlm.html */

View File

@@ -2617,9 +2617,7 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
if(has_host_ntlm || has_proxy_ntlm) { if(has_host_ntlm || has_proxy_ntlm) {
data->state.authproblem = FALSE; data->state.authproblem = FALSE;
#ifdef USE_NTLM
Curl_http_ntlm_cleanup(conn); Curl_http_ntlm_cleanup(conn);
#endif
} }
} }