git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] credential-cache: don't cache items without context
Date: Fri, 23 Sep 2011 17:53:24 -0400	[thread overview]
Message-ID: <20110923215324.GA3013@sigill.intra.peff.net> (raw)

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

                 reply	other threads:[~2011-09-23 21:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110923215324.GA3013@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).