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>
This commit is contained in:
Jon Griffiths 2016-02-23 02:16:04 -05:00 коммит произвёл Junio C Hamano
Родитель bd93b8d9be
Коммит 6e61449051
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -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);
}