git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] credential-cache: don't cache items without context
@ 2011-09-23 21:53 Jeff King
  0 siblings, 0 replies; only message in thread
From: Jeff King @ 2011-09-23 21:53 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-09-23 21:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-23 21:53 [PATCH] credential-cache: don't cache items without context Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).