Re: git credential cache and sudo
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 13, 2021, 02:51 UTC
- Message-ID
- <YEwoyeYM7ac+6aIx@google.com>
- In-Reply-To
- <YEvPQS1+1sxd/aGw@coredump.intra.peff.net>
Jeff King wrote:
Show 7 quoted lines
> Note that it's a little funky to be accessing the cache as a different user than > the one who created it. This should work reliably when the cache was created by > your normal user, but then accessed as root, because root has permissions to > access the socket. But if you spawn a cache daemon as root (because the _first_ > operation you perform is as root, which automatically starts a daemon to store > the cached credential), then it's likely you won't be able to access it as your > regular user.
I wonder if this suggests a missing feature in git-credential-cache(1): if the manpage advertised a way to launch the daemon through an explicit command, similar to 'ssh-agent', then a user could run that as themselves before running other commands that communicate with it as another user.
All that said: John, why are you running git as root in the first place? It's likely that it's safer to run git as a different user and use a separate command such as rsync to perform the privileged deploy action.
Thanks, Jonathan