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>

Jon Griffiths committed Feb 23, 2016 at 02:16 UTC 6e6144905188a76ef75c5418bd48c333adeebdcd
1 file changed +9
credential-cache--daemon.c
+9
@@ -236,6 +236,15 @@ static void init_socket_directory(const char *path)
236 if (mkdir(dir, 0700) < 0)
237 die_errno("unable to mkdir '%s'", dir);
238 }
239 +
240 + if (chdir(dir))
241 + /*
242 + * We don't actually care what our cwd is; we chdir here just to
243 + * be a friendly daemon and avoid tying up our original cwd.
244 + * If this fails, it's OK to just continue without that benefit.
245 + */
246 + ;
247 +
248 free(path_copy);
249 }
250