git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] credential-cache: don't cache items without context

From
Jeff King <peff@peff.net>
Date
Sep 23, 2011, 21:53 UTC
Message-ID
<20110923215324.GA3013@sigill.intra.peff.net>

The credential helper should get a --unique=<whatever> context from the callers. It would be meaningless to cache a username and password combination without being given any context, since we have no idea when we should use them again. The current code will reuse them next time we have no context again, but that is probably not sane; there is no guarantee that it is the same "lack of context" situation.

Git doesn't currently actually make requests of credential helpers without a context, so this is a non-issue outside of specialized testing. But it should do the sane thing given any input, and it's nice to set a good example for other helpers (which may not be tied to a specific git version, and so arguments like "git doesn't currently do this" don't apply to them).

Signed-off-by: Jeff King <peff@peff.net>
---
On top of jk/http-auth-keyring, naturally.
 credential-cache.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/credential-cache.c b/credential-cache.c
index f495043..14d751e 100644
--- a/credential-cache.c
+++ b/credential-cache.c
@@ -155,9 +155,11 @@ int main(int argc, const char **argv)
 	printf("username=%s\n", c.username);
 	printf("password=%s\n", c.password);
 
-	if (do_cache(socket_path, "store", &c, timeout) < 0) {
-		spawn_daemon(socket_path);
-		do_cache(socket_path, "store", &c, timeout);
+	if (c.unique) {
+		if (do_cache(socket_path, "store", &c, timeout) < 0) {
+			spawn_daemon(socket_path);
+			do_cache(socket_path, "store", &c, timeout);
+		}
 	}
 	return 0;
 }
-- 
1.7.7.rc2.4.ga9aee2.dirty
Message 1 of 1 in “credential-cache: don't cache items without context”
  1. credential-cache: don't cache items without contextJeff King, Sep 23, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.