From: Jeff King <peff@peff.net>
To: Jon Griffiths <jon_p_griffiths@yahoo.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] credential-cache--daemon: Change to root dir on startup
Date: Sun, 21 Feb 2016 18:52:26 -0500 [thread overview]
Message-ID: <20160221235225.GE4094@sigill.intra.peff.net> (raw)
In-Reply-To: <1456037497-9895-1-git-send-email-jon_p_griffiths@yahoo.com>
On Sun, Feb 21, 2016 at 07:51:37PM +1300, Jon Griffiths wrote:
> Stop the daemon from preventing umount of the directory it
> was started in.
>
> Without this change the daemon prevents umount because it
> it holds open its cwd. If it starts in a directory we want
> to unmount we have to manually kill the process which is
> undesirable and also uncaches any credentials it is holding.
>
> Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
> ---
> credential-cache--daemon.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
> index cc65a9c..d911b40 100644
> --- a/credential-cache--daemon.c
> +++ b/credential-cache--daemon.c
> @@ -270,6 +270,8 @@ int main(int argc, const char **argv)
> if (ignore_sighup)
> signal(SIGHUP, SIG_IGN);
>
> + chdir("/");
> +
> serve_cache(socket_path, debug);
> delete_tempfile(&socket_file);
What happens if socket_path is relative here?
I don't know how common that would be in practice. In general, the
daemon is running out of $GIT_DIR or the top-level of the work-tree, I'd
guess, which is inappropriate for any user-level config, and probably
simply confusing even for repo-level config. I'm actually tempted to
just disallow relative paths entirely.
I think your patch _just_ helps the case where the git repository is
being unmounted (and our daemon's cwd happened to be there). It doesn't
help the case that the socket path is unmounted (which will still get
EBUSY because we have the socket open).
I can't think of any reason that chdir() to "/" would be a bad thing (if
you get EPERM going to "/", you probably have bigger problems), but
another option would be:
1. chdir(dirname(socket_path));
2. serve_cache(basename(socket_path));
That works with relative paths, and it puts all of our open files in the
same part of the hierarchy.
-Peff
parent reply other threads:[~2016-02-21 23:52 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1456037497-9895-1-git-send-email-jon_p_griffiths@yahoo.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160221235225.GE4094@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=jon_p_griffiths@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).