summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-08-21 16:38:59 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2019-08-21 16:45:38 -0400
commit1c847169db1c68864c43e95cf96380cec71ba72a (patch)
tree206d176bca6938a12efbbe3af9411534657018cb
parent0f40e68e2f468169d711a806f6839781ae4f7a3e (diff)
downloadlibgit2-1c847169db1c68864c43e95cf96380cec71ba72a.tar.gz
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.
-rw-r--r--src/transports/auth.c2
-rw-r--r--src/transports/http.c11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/transports/auth.c b/src/transports/auth.c
index 773e3020a..4fcf73cb5 100644
--- a/src/transports/auth.c
+++ b/src/transports/auth.c
@@ -70,6 +70,6 @@ int git_http_auth_dummy(
GIT_UNUSED(url);
*out = NULL;
- return 0;
+ return GIT_PASSTHROUGH;
}
diff --git a/src/transports/http.c b/src/transports/http.c
index d727851b7..7ec681c41 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -430,6 +430,7 @@ static int init_auth(http_server *server)
git_http_auth_scheme *s, *scheme = NULL;
char *c, *challenge = NULL;
size_t i;
+ int error;
git_vector_foreach(&server->auth_challenges, i, c) {
s = scheme_for_challenge(c);
@@ -446,12 +447,14 @@ static int init_auth(http_server *server)
return -1;
}
- if (scheme->init_context(&server->auth_context, &server->url) < 0)
- return -1;
+ if ((error = scheme->init_context(&server->auth_context, &server->url)) == GIT_PASSTHROUGH)
+ return 0;
+ else if (error < 0)
+ return error;
if (server->auth_context->set_challenge &&
- server->auth_context->set_challenge(server->auth_context, challenge) < 0)
- return -1;
+ (error = server->auth_context->set_challenge(server->auth_context, challenge)) < 0)
+ return error;
return 0;
}