1
0
mirror of https://github.com/moparisthebest/curl synced 2025-03-11 15:50:48 -04:00

ntlm: Only define ntlm data structure when USE_NTLM is defined

This commit is contained in:
Steve Holme 2014-10-25 22:32:46 +01:00
parent 28ff8babad
commit 3fe5b462f7
4 changed files with 23 additions and 12 deletions

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -35,10 +35,6 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
void Curl_http_ntlm_cleanup(struct connectdata *conn); void Curl_http_ntlm_cleanup(struct connectdata *conn);
#else
#define Curl_http_ntlm_cleanup(a) Curl_nop_stmt
#endif #endif
#endif /* HEADER_CURL_NTLM_H */ #endif /* HEADER_CURL_NTLM_H */

View File

@ -420,6 +420,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
conn->bits.rewindaftersend = FALSE; /* default */ conn->bits.rewindaftersend = FALSE; /* default */
if((expectsend == -1) || (expectsend > bytessent)) { if((expectsend == -1) || (expectsend > bytessent)) {
#if defined(USE_NTLM)
/* There is still data left to send */ /* There is still data left to send */
if((data->state.authproxy.picked == CURLAUTH_NTLM) || if((data->state.authproxy.picked == CURLAUTH_NTLM) ||
(data->state.authhost.picked == CURLAUTH_NTLM) || (data->state.authhost.picked == CURLAUTH_NTLM) ||
@ -439,6 +440,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
return CURLE_OK; return CURLE_OK;
} }
if(conn->bits.close) if(conn->bits.close)
/* this is already marked to get closed */ /* this is already marked to get closed */
return CURLE_OK; return CURLE_OK;
@ -447,9 +449,9 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
CURL_FORMAT_CURL_OFF_T " bytes\n", CURL_FORMAT_CURL_OFF_T " bytes\n",
(curl_off_t)(expectsend - bytessent)); (curl_off_t)(expectsend - bytessent));
} }
#endif
/* This is not NTLM or many bytes left to send: close /* This is not NTLM or many bytes left to send: close */
*/
connclose(conn, "Mid-auth HTTP and much data left to send"); connclose(conn, "Mid-auth HTTP and much data left to send");
data->req.size = 0; /* don't download any more than 0 bytes */ data->req.size = 0; /* don't download any more than 0 bytes */

View File

@ -2650,8 +2650,10 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
Curl_hostcache_prune(data); /* kill old DNS cache entries */ Curl_hostcache_prune(data); /* kill old DNS cache entries */
#if defined(USE_NTLM)
/* Cleanup NTLM connection-related data */ /* Cleanup NTLM connection-related data */
Curl_http_ntlm_cleanup(conn); Curl_http_ntlm_cleanup(conn);
#endif
if(conn->handler->disconnect) if(conn->handler->disconnect)
/* This is set if protocol-specific cleanups should be made */ /* This is set if protocol-specific cleanups should be made */
@ -3198,6 +3200,7 @@ ConnectionExists(struct SessionHandle *data,
} }
if(match) { if(match) {
#if defined(USE_NTLM)
/* If we are looking for an HTTP+NTLM connection, check if this is /* If we are looking for an HTTP+NTLM connection, check if this is
already authenticating with the right credentials. If not, keep already authenticating with the right credentials. If not, keep
looking so that we can reuse NTLM connections if looking so that we can reuse NTLM connections if
@ -3216,6 +3219,7 @@ ConnectionExists(struct SessionHandle *data,
chosen = check; chosen = check;
continue; continue;
} }
#endif
if(canPipeline) { if(canPipeline) {
/* We can pipeline if we want to. Let's continue looking for /* We can pipeline if we want to. Let's continue looking for
@ -5616,6 +5620,7 @@ static CURLcode create_conn(struct SessionHandle *data,
ConnectionStore(data, conn); ConnectionStore(data, conn);
} }
#if defined(USE_NTLM)
/* If NTLM is requested in a part of this connection, make sure we don't /* If NTLM is requested in a part of this connection, make sure we don't
assume the state is fine as this is a fresh connection and NTLM is assume the state is fine as this is a fresh connection and NTLM is
connection based. */ connection based. */
@ -5624,12 +5629,13 @@ static CURLcode create_conn(struct SessionHandle *data,
infof(data, "NTLM picked AND auth done set, clear picked!\n"); infof(data, "NTLM picked AND auth done set, clear picked!\n");
data->state.authhost.picked = CURLAUTH_NONE; data->state.authhost.picked = CURLAUTH_NONE;
} }
if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) && if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) &&
data->state.authproxy.done) { data->state.authproxy.done) {
infof(data, "NTLM-proxy picked AND auth done set, clear picked!\n"); infof(data, "NTLM-proxy picked AND auth done set, clear picked!\n");
data->state.authproxy.picked = CURLAUTH_NONE; data->state.authproxy.picked = CURLAUTH_NONE;
} }
#endif
} }
/* Mark the connection as used */ /* Mark the connection as used */
@ -5886,9 +5892,12 @@ CURLcode Curl_done(struct connectdata **connp,
but currently we have no such detail knowledge. but currently we have no such detail knowledge.
*/ */
if((data->set.reuse_forbid && !(conn->ntlm.state == NTLMSTATE_TYPE2 || if((data->set.reuse_forbid
conn->proxyntlm.state == NTLMSTATE_TYPE2)) #if defined(USE_NTLM)
|| conn->bits.close || premature) { && !(conn->ntlm.state == NTLMSTATE_TYPE2 ||
conn->proxyntlm.state == NTLMSTATE_TYPE2)
#endif
) || conn->bits.close || premature) {
CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */ CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */
/* If we had an error already, make sure we return that one. But /* If we had an error already, make sure we return that one. But

View File

@ -432,6 +432,7 @@ struct kerberos5data {
#endif #endif
/* Struct used for NTLM challenge-response authentication */ /* Struct used for NTLM challenge-response authentication */
#if defined(USE_NTLM)
struct ntlmdata { struct ntlmdata {
curlntlm state; curlntlm state;
#ifdef USE_WINDOWS_SSPI #ifdef USE_WINDOWS_SSPI
@ -450,6 +451,7 @@ struct ntlmdata {
unsigned int target_info_len; unsigned int target_info_len;
#endif #endif
}; };
#endif
#ifdef USE_SPNEGO #ifdef USE_SPNEGO
struct negotiatedata { struct negotiatedata {
@ -1009,17 +1011,19 @@ struct connectdata {
curl_read_callback fread_func; /* function that reads the input */ curl_read_callback fread_func; /* function that reads the input */
void *fread_in; /* pointer to pass to the fread() above */ void *fread_in; /* pointer to pass to the fread() above */
#if defined(USE_NTLM)
struct ntlmdata ntlm; /* NTLM differs from other authentication schemes struct ntlmdata ntlm; /* NTLM differs from other authentication schemes
because it authenticates connections, not because it authenticates connections, not
single requests! */ single requests! */
struct ntlmdata proxyntlm; /* NTLM data for proxy */ struct ntlmdata proxyntlm; /* NTLM data for proxy */
#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) #if defined(NTLM_WB_ENABLED)
/* used for communication with Samba's winbind daemon helper ntlm_auth */ /* used for communication with Samba's winbind daemon helper ntlm_auth */
curl_socket_t ntlm_auth_hlpr_socket; curl_socket_t ntlm_auth_hlpr_socket;
pid_t ntlm_auth_hlpr_pid; pid_t ntlm_auth_hlpr_pid;
char* challenge_header; char* challenge_header;
char* response_header; char* response_header;
#endif
#endif #endif
char syserr_buf [256]; /* buffer for Curl_strerror() */ char syserr_buf [256]; /* buffer for Curl_strerror() */