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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]