diff options
author | Stefan Metzmacher <metze@samba.org> | 2017-07-20 15:48:35 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2017-08-07 15:20:02 +0200 |
commit | a6ae9da98dff49e37e23481e8932eb18c8e45c02 (patch) | |
tree | e894d6bf42030717dd1118516d6a04643a5fe050 /source4/lib | |
parent | bdece1df9cad4dbe1b41215d21dbcf34bfee1c66 (diff) | |
download | samba-a6ae9da98dff49e37e23481e8932eb18c8e45c02.tar.gz |
s4:lib/http: pass a generic prefix blob to http_parse_auth_response()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/http/http_auth.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/source4/lib/http/http_auth.c b/source4/lib/http/http_auth.c index 654183391e2..288a664fdb8 100644 --- a/source4/lib/http/http_auth.c +++ b/source4/lib/http/http_auth.c @@ -54,7 +54,7 @@ static NTSTATUS http_copy_header(const struct http_request *src, * Retrieve the WWW-Authenticate header from server response based on the * authentication scheme being used. */ -static NTSTATUS http_parse_auth_response(enum http_auth_method auth, +static NTSTATUS http_parse_auth_response(const DATA_BLOB prefix, struct http_request *auth_response, DATA_BLOB *in) { @@ -68,16 +68,15 @@ static NTSTATUS http_parse_auth_response(enum http_auth_method auth, continue; } - switch (auth) { - case HTTP_AUTH_NTLM: - if (strncasecmp(h->value, "NTLM ", 5) == 0) { - *in = data_blob_string_const(h->value); - return NT_STATUS_OK; - } - break; - default: - break; + cmp = strncasecmp(h->value, + (const char *)prefix.data, + prefix.length); + if (cmp != 0) { + continue; } + + *in = data_blob_string_const(h->value); + return NT_STATUS_OK; } return NT_STATUS_NOT_SUPPORTED; @@ -90,6 +89,7 @@ struct http_auth_state { struct tevent_queue *send_queue; enum http_auth_method auth; + DATA_BLOB prefix; struct gensec_security *gensec_ctx; NTSTATUS gensec_status; @@ -149,9 +149,11 @@ struct tevent_req *http_send_auth_request_send(TALLOC_CTX *mem_ctx, switch (state->auth) { case HTTP_AUTH_BASIC: mech_name = "http_basic"; + state->prefix = data_blob_string_const("Basic"); break; case HTTP_AUTH_NTLM: mech_name = "http_ntlm"; + state->prefix = data_blob_string_const("NTLM"); break; default: tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED); @@ -327,7 +329,7 @@ static void http_send_auth_request_http_rep_done(struct tevent_req *subreq) return; } - status = http_parse_auth_response(state->auth, + status = http_parse_auth_response(state->prefix, state->auth_response, &gensec_in); if (tevent_req_nterror(req, status)) { |