Skip to content

Commit 1c84716

Browse files
committed
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 parent 0f40e68 commit 1c84716

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/transports/auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ int git_http_auth_dummy(
7070
GIT_UNUSED(url);
7171

7272
*out = NULL;
73-
return 0;
73+
return GIT_PASSTHROUGH;
7474
}
7575

src/transports/http.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ static int init_auth(http_server *server)
430430
git_http_auth_scheme *s, *scheme = NULL;
431431
char *c, *challenge = NULL;
432432
size_t i;
433+
int error;
433434

434435
git_vector_foreach(&server->auth_challenges, i, c) {
435436
s = scheme_for_challenge(c);
@@ -446,12 +447,14 @@ static int init_auth(http_server *server)
446447
return -1;
447448
}
448449

449-
if (scheme->init_context(&server->auth_context, &server->url) < 0)
450-
return -1;
450+
if ((error = scheme->init_context(&server->auth_context, &server->url)) == GIT_PASSTHROUGH)
451+
return 0;
452+
else if (error < 0)
453+
return error;
451454

452455
if (server->auth_context->set_challenge &&
453-
server->auth_context->set_challenge(server->auth_context, challenge) < 0)
454-
return -1;
456+
(error = server->auth_context->set_challenge(server->auth_context, challenge)) < 0)
457+
return error;
455458

456459
return 0;
457460
}

0 commit comments

Comments
 (0)