Skip to content

Commit

Permalink
credential-cache--daemon: disallow relative socket path
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jon Griffiths authored and Junio C Hamano committed Feb 23, 2016
1 parent a6e5e28 commit bd93b8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Documentation/git-credential-cache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------
Expand Down
3 changes: 3 additions & 0 deletions credential-cache--daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit bd93b8d

Please sign in to comment.