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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/src/transports/auth.c b/src/transports/auth.c
index 773e302..4fcf73c 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 d727851..7ec681c 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;
}