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

[PATCH 2/3] credential-cache--daemon: disallow relative socket path

From
Jeff King <peff@peff.net>
Date
Feb 23, 2016, 07:15 UTC
Message-ID
<20160223071541.GB8395@sigill.intra.peff.net>
In-Reply-To
<20160223071427.GA7489@sigill.intra.peff.net>
From: Jon Griffiths <jon_p_griffiths@yahoo.com>

Relative socket paths are dangerous since the user cannot generally control when the daemon starts (initially, after a timeout, kill or crash). Since the daemon creates but does not delete the socket directory, this could lead to spurious directory creation relative to the users cwd.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 Documentation/git-credential-cache.txt | 2 +-
 credential-cache--daemon.c             | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-credential-cache.txt b/Documentation/git-credential-cache.txt
index 89b7306..96208f8 100644
--- a/Documentation/git-credential-cache.txt
+++ b/Documentation/git-credential-cache.txt
@@ -36,7 +36,7 @@ OPTIONS
 	cache daemon if one is not started). Defaults to
 	`~/.git-credential-cache/socket`. If your home directory is on a
 	network-mounted filesystem, you may need to change this to a
-	local filesystem.
+	local filesystem. You must specify an absolute path.
 
 CONTROLLING THE DAEMON
 ----------------------
diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index 3403f48..7cfcd37 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -262,6 +262,9 @@ int main(int argc, const char **argv)
 	if (!socket_path)
 		usage_with_options(usage, options);
 
+	if (!is_absolute_path(socket_path))
+		die("socket directory must be an absolute path");
+
 	init_socket_directory(socket_path);
 	register_tempfile(&socket_file, socket_path);
 
-- 
2.7.2.645.g4e1306c
Previous: Jeff KingNext: Jeff King
Message 3 of 8 in “credential-cache: give daemon a predictable cwd”
  1. 0/3 credential-cache: give daemon a predictable cwdJeff King, Feb 23, 2016
  2. 1/3 credential-cache--daemon: refactor check_socket_directoryJeff King, Feb 23, 2016
  3. 2/3 credential-cache--daemon: disallow relative socket pathJeff King, Feb 23, 2016
  4. 3/3 credential-cache--daemon: change to the socket dir on startupJeff King, Feb 23, 2016
  5. Junio C HamanoFeb 23, 2016
  6. Jeff KingFeb 23, 2016
  7. Junio C HamanoFeb 23, 2016
  8. Jeff KingFeb 23, 2016

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.