Commit 1c847169 by Edward Thomson

http: allow dummy negotiation scheme to fail to act

The dummy negotiation scheme is used for known authentication strategies
that do not wish to act.  For example, when a server requests the
"Negotiate" scheme but libgit2 is not built with Negotiate support, and
will use the "dummy" strategy which will simply not act.

Instead of setting `out` to NULL and returning a successful code, return
`GIT_PASSTHROUGH` to indicate that it did not act and catch that error
code.
parent 0f40e68e
...@@ -70,6 +70,6 @@ int git_http_auth_dummy( ...@@ -70,6 +70,6 @@ int git_http_auth_dummy(
GIT_UNUSED(url); GIT_UNUSED(url);
*out = NULL; *out = NULL;
return 0; return GIT_PASSTHROUGH;
} }
...@@ -430,6 +430,7 @@ static int init_auth(http_server *server) ...@@ -430,6 +430,7 @@ static int init_auth(http_server *server)
git_http_auth_scheme *s, *scheme = NULL; git_http_auth_scheme *s, *scheme = NULL;
char *c, *challenge = NULL; char *c, *challenge = NULL;
size_t i; size_t i;
int error;
git_vector_foreach(&server->auth_challenges, i, c) { git_vector_foreach(&server->auth_challenges, i, c) {
s = scheme_for_challenge(c); s = scheme_for_challenge(c);
...@@ -446,12 +447,14 @@ static int init_auth(http_server *server) ...@@ -446,12 +447,14 @@ static int init_auth(http_server *server)
return -1; return -1;
} }
if (scheme->init_context(&server->auth_context, &server->url) < 0) if ((error = scheme->init_context(&server->auth_context, &server->url)) == GIT_PASSTHROUGH)
return -1; return 0;
else if (error < 0)
return error;
if (server->auth_context->set_challenge && if (server->auth_context->set_challenge &&
server->auth_context->set_challenge(server->auth_context, challenge) < 0) (error = server->auth_context->set_challenge(server->auth_context, challenge)) < 0)
return -1; return error;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment