Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 468512

Summary: dev-vcs/git-1.8.1.5 - init.d script fails to start git-daemon: unable to access '/root/.config/git/config': Permission denied
Product: Gentoo Linux Reporter: Timo Rothenpieler <timo>
Component: [OLD] DevelopmentAssignee: Robin Johnson <robbat2>
Status: RESOLVED DUPLICATE    
Severity: normal CC: hakan, mail, mattst88, staff
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://www.spinics.net/lists/git/msg209279.html
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: patch to work around the issue

Description Timo Rothenpieler 2013-05-03 20:20:11 UTC
git-daemon always tries to access a config file in /root, but fails for obvious reasons:

unable to access '/root/.config/git/config': Permission denied

According to some git devs, this happens because the env is not propperly cleaned, so that it still contains HOME. I checked that, and it's not the case, the env does not contain HOME inside the init scripts start() function.

Clearly a git bug, but blaming it on gentoo init-system seems to be easier.

Quick-Fix for this is to use start-stop-daemon --user/--group options to change the user instead of git daemon options.

Reproducible: Always

Steps to Reproduce:
1. Install dev-vcs/git-1.8.1.5
2. Configure git-daemon to run as non-root user.
3. Try to clone a repo, and check /var/log/messages for the permission denied error.
Actual Results:  
Clone fails, because git-daemon tries to read /root/.config/git/config and fails because of missing permissions.

Expected Results:  
It shouldn't touch /root at all when run with --user option in my opinion, but it seems like git upstream doesn't see it that way.
Comment 1 Matt Turner gentoo-dev 2013-06-10 06:30:19 UTC
Confirmed. It's broken, but known and fixed in master. The commit (4698c8f) is not in any released version, nor in any tag currently in git's repo.

Stable git (1.8.1.5) daemon cannot serve repos as the git user.
Comment 2 Matt Turner gentoo-dev 2013-06-10 06:32:48 UTC
Temporary work-around: add HOME=/var/git before start-stop-daemon ... in /etc/init.d/git-daemon.
Comment 3 Timo Rothenpieler 2013-06-10 09:26:05 UTC
If i got that right, the upstream "fix" is to silently ignore EACCESS error when reading config files.
The real problem, that the --user/--group options don't fully change the user(they obviously at least don't change HOME) and are quite useless this way. Noone usualy changes $HOME before running a daemon which changes the user.
Just ignoring any configs in case of --user change can't be right.

The only real fix i see for this is to not use --user/--group at all, and instead use start-stop-daemon to change the user and write the pidfile.
Comment 4 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-07-09 06:52:55 UTC
Out of curiosity...

start-stop-daemon has the --env option which could be of help here (see "man start-stop-daemon").

Did anyone test this?
Comment 5 Oleh 2013-10-02 01:42:39 UTC
any updates on this issue?
Comment 6 Dirk Best 2013-11-10 11:50:06 UTC
Created attachment 362974 [details, diff]
patch to work around the issue

This simply sets HOME to empty, allowing the git-daemon to work correctly.
Comment 7 Oleh 2013-12-18 07:50:48 UTC
this doesn't happen anymore with latest versions of git (>1.8.3)
Comment 8 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-04 08:42:10 UTC

*** This bug has been marked as a duplicate of bug 460370 ***