summaryrefslogtreecommitdiff
path: root/credential-cache--daemon.c
diff options
context:
space:
mode:
authorJon Griffiths <jon_p_griffiths@yahoo.com>2016-02-23 07:16:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-23 22:48:03 (GMT)
commit6e6144905188a76ef75c5418bd48c333adeebdcd (patch)
tree23bb7809cc65e736afad1c98ec857df3b041905f /credential-cache--daemon.c
parentbd93b8d9becb01d21871b63e34c2e824c60b1e8c (diff)
downloadgit-6e6144905188a76ef75c5418bd48c333adeebdcd.zip
git-6e6144905188a76ef75c5418bd48c333adeebdcd.tar.gz
git-6e6144905188a76ef75c5418bd48c333adeebdcd.tar.bz2
credential-cache--daemon: change to the socket dir on startup
Changing to the socket path stops the daemon holding open the directory the user was in when it was started, preventing umount from working. We're already holding open a socket in that directory, so there's no downside. Thanks-to: 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>
Diffstat (limited to 'credential-cache--daemon.c')
-rw-r--r--credential-cache--daemon.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index fe37794..6b00ee0 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -236,6 +236,15 @@ static void init_socket_directory(const char *path)
if (mkdir(dir, 0700) < 0)
die_errno("unable to mkdir '%s'", dir);
}
+
+ if (chdir(dir))
+ /*
+ * We don't actually care what our cwd is; we chdir here just to
+ * be a friendly daemon and avoid tying up our original cwd.
+ * If this fails, it's OK to just continue without that benefit.
+ */
+ ;
+
free(path_copy);
}