Re: [PATCHv3 10/13] credentials: add "cache" helper

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

 



Hi,

Jeff King wrote:

> This patch introduces a credential helper that will cache
> passwords in memory for a short period of time.
>
> Signed-off-by: Jeff King <peff@xxxxxxxx>
[...]
> t/t0301-credential-cache.sh                    |   18 ++

This test is failing for me:

	expecting success: 
			check fill $HELPER <<-\EOF
			protocol=https
			host=example.com
			--
			username=askpass-username
			password=askpass-password
			--
			askpass: Username for 'https://example.com':
			askpass: Password for 'https://askpass-username@xxxxxxxxxxx':
			EOF

	--- expect-stderr       2012-01-10 00:07:02.398365248 +0000
	+++ stderr      2012-01-10 00:07:02.418364996 +0000
	@@ -1,2 +1,3 @@
	+fatal: socket path is too long to fit in sockaddr
	 askpass: Username for 'https://example.com':
	 askpass: Password for 'https://askpass-username@xxxxxxxxxxx':
	not ok - 1 helper (cache) has no existing data

I didn't notice until recently because typically the cwd is short.
The sun_path[] array on this machine is 108 bytes; POSIX informs me
that some platforms make it as small as 96 bytes and there's no
guaranteed lower limit.  The machines[*] triggering it were running
tests in a chroot, hence the long path.

So you should be able to reproduce this with

	longpath=foo/bar; # > 6 chars
	longpath=$longpath/$longpath/$longpath/$longpath; # > 24
	longpath=$longpath/$longpath/$longpath/$longpath; # > 96
	longpath=/tmp/$longpath/$longpath
	mkdir -p $longpath
	sh t0301-credential-cache.sh --root=$longpath

Ideas?
---
[*] https://buildd.debian.org/status/logs.php?pkg=git&ver=1%3A1.7.9~rc0-1

 credential-cache.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/credential-cache.c b/credential-cache.c
index dc98372e..fd9304e6 100644
--- a/credential-cache.c
+++ b/credential-cache.c
@@ -82,7 +82,7 @@ static void do_cache(const char *socket, const char *action, int timeout,
 
 int main(int argc, const char **argv)
 {
-	char *socket_path = NULL;
+	const char *socket_path = NULL;
 	int timeout = 900;
 	const char *op;
 	const char * const usage[] = {
@@ -102,10 +102,18 @@ int main(int argc, const char **argv)
 		usage_with_options(usage, options);
 	op = argv[0];
 
-	if (!socket_path)
-		socket_path = expand_user_path("~/.git-credential-cache/socket");
-	if (!socket_path)
-		die("unable to find a suitable socket path; use --socket");
+	if (!socket_path) {
+		char *home = expand_user_path("~");
+		if (!home)
+			die("unable to find a suitable socket path; use --socket");
+
+		if (!chdir(home))
+			socket_path = ".git-credential-cache/socket";
+		else if (errno == ENOENT && !strcmp(op, "exit"))
+			return 0;
+		else
+			die("cannot enter home directory");
+	}
 
 	if (!strcmp(op, "exit"))
 		do_cache(socket_path, op, timeout, 0);
-- 
1.7.8.2

--
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]