Skip to content
Permalink
Browse files

http_ntlm_wb: Move the type-2 message processing into a dedicated fun…

…ction

This brings the code inline with the other HTTP authentication mechanisms.
  • Loading branch information...
captain-caveman2k committed May 15, 2019
1 parent e832d1e commit 9b705ae239d2176e9f4974a7e994715e2da50e4f
Showing with 32 additions and 16 deletions.
  1. +26 −0 lib/curl_ntlm_wb.c
  2. +5 −2 lib/curl_ntlm_wb.h
  3. +1 −14 lib/http.c
@@ -53,6 +53,8 @@
#include "url.h"
#include "strerror.h"
#include "strdup.h"
#include "strcase.h"

/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -333,6 +335,30 @@ static CURLcode ntlm_wb_response(struct connectdata *conn,
return CURLE_REMOTE_ACCESS_DENIED;
}

CURLcode Curl_input_ntlm_wb(struct connectdata *conn,
bool proxy,
const char *header)
{
(void) proxy;

if(!checkprefix("NTLM", header))
return CURLE_BAD_CONTENT_ENCODING;

header += strlen("NTLM");
while(*header && ISSPACE(*header))
header++;

if(*header) {
conn->challenge_header = strdup(header);
if(!conn->challenge_header)
return CURLE_OUT_OF_MEMORY;
}
else
return CURLE_BAD_CONTENT_ENCODING;

return CURLE_OK;
}

/*
* This is for creating ntlm header output by delegating challenge/response
* to Samba's winbind daemon helper ntlm_auth.
@@ -27,8 +27,11 @@
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
defined(NTLM_WB_ENABLED)

/* this is for creating ntlm header output by delegating challenge/response
to Samba's winbind daemon helper ntlm_auth */
/* this is for ntlm header input */
CURLcode Curl_input_ntlm_wb(struct connectdata *conn, bool proxy,
const char *header);

/* this is for creating ntlm header output */
CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy);

void Curl_http_auth_cleanup_ntlm_wb(struct connectdata *conn);
@@ -919,20 +919,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
*availp |= CURLAUTH_NTLM_WB;
authp->avail |= CURLAUTH_NTLM_WB;

/* Get the challenge-message which will be passed to
* ntlm_auth for generating the type 3 message later */
while(*auth && ISSPACE(*auth))
auth++;
if(checkprefix("NTLM", auth)) {
auth += strlen("NTLM");
while(*auth && ISSPACE(*auth))
auth++;
if(*auth) {
conn->challenge_header = strdup(auth);
if(!conn->challenge_header)
return CURLE_OUT_OF_MEMORY;
}
}
result = Curl_input_ntlm_wb(conn, proxy, auth);
}
#endif
}

0 comments on commit 9b705ae

Please sign in to comment.
You can’t perform that action at this time.