threads / discuss / 62597

git-daemon not consulting ~/.gitconfig

Subject: git-daemon not consulting ~/.gitconfig

## tl;dr

2 messages between Dec 4, 2024 and Dec 4, 2024.

replies: 1people: 2as markdown or json

martin f krafft· Dec 4, 2024, 10:23 UTC · lore
Hello,

I found that git-daemon stopped serving repositories managed by gitolite, i.e. by a different Unix user. Hence, no big surprise that I would get

```
git-daemon[3126249]: detected dubious ownership in repository at '/srv/git/repositories/madduck/pub/etc/ssh.git'
                      To add an exception for this directory, call:
                      git config --global --add safe.directory /srv/git/repositories/madduck/pub/etc/ssh.git
```

in the logs. However, adding the config to `~gitdaemon/.gitconfig` did not have the desired effect. Neither did adding it to `~root/.gitconfig` and only `/etc/gitconfig` works.

So I checked `strace` and found that when invoked by `git-daemon`, Git doesn't even consult `~/.gitconfig`, and I think this may be a bug.

Here is the relevant strace for an access to git-daemon that triggers the above error:

``` root@alan:~# strace -fp 3146653 -e file 2>&1 | grep config [pid 3154713] access("/etc/gitconfig", R_OK) = 0 [pid 3154713] openat(AT_FDCWD, "/etc/gitconfig", O_RDONLY) = 3 [pid 3154713] access("/etc/gitconfig", R_OK) = 0 [pid 3154713] openat(AT_FDCWD, "/etc/gitconfig", O_RDONLY) = 4 [pid 3154713] openat(AT_FDCWD, "./config", O_RDONLY) = 4 [pid 3154713] access("/etc/gitconfig", R_OK) = 0 [pid 3154713] openat(AT_FDCWD, "/etc/gitconfig", O_RDONLY) = 4 [pid 3154713] access("config", R_OK) = 0 [pid 3154713] openat(AT_FDCWD, "config", O_RDONLY) = 4 [pid 3154714] access("/etc/gitconfig", R_OK) = 0 [pid 3154714] openat(AT_FDCWD, "/etc/gitconfig", O_RDONLY) = 3 [pid 3154714] access("/etc/gitconfig", R_OK) = 0 [pid 3154714] openat(AT_FDCWD, "/etc/gitconfig", O_RDONLY) = 3 [pid 3154714] openat(AT_FDCWD, "./config", O_RDONLY) = 3 [pid 3154714] access("/etc/gitconfig", R_OK) = 0 [pid 3154714] openat(AT_FDCWD, "/etc/gitconfig", O_RDONLY) = 3 [pid 3154714] access("config", R_OK) = 0 [pid 3154714] openat(AT_FDCWD, "config", O_RDONLY) = 3 ```

[System Info] git version: git version 2.39.5 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.1.0-28-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.119-1 (2024-11-22) x86_64 compiler info: gnuc: 12.2 libc info: glibc: 2.36 $SHELL (typically, interactive shell): /bin/bash

-- 
martin krafft | https://matrix.to/#/#madduck:madduck.net
 
officer, arrest that man! he's whistling a copyrighted song.
{: .blockquote }
 
spamtraps: madduck.bogus@madduck.net
{: .hidden }
Konstantin Khomoutov· Dec 4, 2024, 15:57 UTC · re: martin f krafft · lore

Re: git-daemon not consulting ~/.gitconfig

On Wed, Dec 04, 2024 at 11:23:36AM +0100, martin f krafft wrote:
[...]
Show 6 quoted lines
> in the logs. However, adding the config to `~gitdaemon/.gitconfig` did not
> have the desired effect. Neither did adding it to `~root/.gitconfig` and
> only `/etc/gitconfig` works.
> 
> So I checked `strace` and found that when invoked by `git-daemon`, Git
> doesn't even consult `~/.gitconfig`, and I think this may be a bug.
[...]
Given the following passage from the docs, describing the "--user" option,
| Like many programs that switch user id, the daemon does not reset
| environment variables such as $HOME when it runs git programs, e.g.
| upload-pack and receive-pack. When using this option, you may also want to
| set and export HOME to point at the home directory of <user> before starting
| the daemon, and make sure any Git configuration files in that directory are
| readable by <user>.
the behavior does indeed look like a bug.

← back to recent threads