{"thread":{"id":"62597","subject":"git-daemon not consulting ~/.gitconfig","startedAt":"2024-12-04T10:23:39Z","lastAt":"2024-12-04T16:43:41Z","messageCount":2,"participants":["martin f krafft","Konstantin Khomoutov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"508609","messageId":"fj5vgwmc5wtyzcxxnmcgw7whclm6qf7p5sxzh3nbao3feyutj6@daizbooxk22j","threadId":"62597","inReplyTo":null,"subject":"git-daemon not consulting ~/.gitconfig","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2024-12-04T10:23:36Z","receivedAt":"2024-12-04T10:23:39Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"Hello,\n\nI found that git-daemon stopped serving repositories managed by \ngitolite, i.e. by a different Unix user. Hence, no big surprise that \nI would get\n\n```\ngit-daemon[3126249]: detected dubious ownership in repository at '/srv/git/repositories/madduck/pub/etc/ssh.git'\n                      To add an exception for this directory, call:\n                      git config --global --add safe.directory /srv/git/repositories/madduck/pub/etc/ssh.git\n```\n\nin the logs. However, adding the config to `~gitdaemon/.gitconfig` \ndid not have the desired effect. Neither did adding it to \n`~root/.gitconfig` and only `/etc/gitconfig` works.\n\nSo I checked `strace` and found that when invoked by `git-daemon`, \nGit doesn't even consult `~/.gitconfig`, and I think this may be a \nbug.\n\nHere is the relevant strace for an access to git-daemon that \ntriggers the above\nerror:\n\n```\nroot@alan:~# strace -fp 3146653 -e file 2>&1 | grep config\n[pid 3154713] access(\"/etc/gitconfig\", R_OK) = 0\n[pid 3154713] openat(AT_FDCWD, \"/etc/gitconfig\", O_RDONLY) = 3\n[pid 3154713] access(\"/etc/gitconfig\", R_OK) = 0\n[pid 3154713] openat(AT_FDCWD, \"/etc/gitconfig\", O_RDONLY) = 4\n[pid 3154713] openat(AT_FDCWD, \"./config\", O_RDONLY) = 4\n[pid 3154713] access(\"/etc/gitconfig\", R_OK) = 0\n[pid 3154713] openat(AT_FDCWD, \"/etc/gitconfig\", O_RDONLY) = 4\n[pid 3154713] access(\"config\", R_OK)    = 0\n[pid 3154713] openat(AT_FDCWD, \"config\", O_RDONLY) = 4\n[pid 3154714] access(\"/etc/gitconfig\", R_OK) = 0\n[pid 3154714] openat(AT_FDCWD, \"/etc/gitconfig\", O_RDONLY) = 3\n[pid 3154714] access(\"/etc/gitconfig\", R_OK) = 0\n[pid 3154714] openat(AT_FDCWD, \"/etc/gitconfig\", O_RDONLY) = 3\n[pid 3154714] openat(AT_FDCWD, \"./config\", O_RDONLY) = 3\n[pid 3154714] access(\"/etc/gitconfig\", R_OK) = 0\n[pid 3154714] openat(AT_FDCWD, \"/etc/gitconfig\", O_RDONLY) = 3\n[pid 3154714] access(\"config\", R_OK)    = 0\n[pid 3154714] openat(AT_FDCWD, \"config\", O_RDONLY) = 3\n```\n\n[System Info]\ngit version:\ngit version 2.39.5\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 6.1.0-28-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.119-1 (2024-11-22) x86_64\ncompiler info: gnuc: 12.2\nlibc info: glibc: 2.36\n$SHELL (typically, interactive shell): /bin/bash\n\n\n-- \nmartin krafft | https://matrix.to/#/#madduck:madduck.net\n \nofficer, arrest that man! he's whistling a copyrighted song.\n{: .blockquote }\n \nspamtraps: madduck.bogus@madduck.net\n{: .hidden }\n\n"},{"id":"508616","messageId":"20241204155704.sxti6mn7zyr3vmyt@carbon","threadId":"62597","inReplyTo":"fj5vgwmc5wtyzcxxnmcgw7whclm6qf7p5sxzh3nbao3feyutj6@daizbooxk22j","subject":"Re: git-daemon not consulting ~/.gitconfig","fromName":"Konstantin Khomoutov","fromEmail":"kostix@bswap.ru","sentAt":"2024-12-04T15:57:04Z","receivedAt":"2024-12-04T16:43:41Z","isPatch":false,"sender":{"key":"kostix@bswap.ru","avatar":null},"body":"On Wed, Dec 04, 2024 at 11:23:36AM +0100, martin f krafft wrote:\n\n[...]\n> in the logs. However, adding the config to `~gitdaemon/.gitconfig` did not\n> have the desired effect. Neither did adding it to `~root/.gitconfig` and\n> only `/etc/gitconfig` works.\n> \n> So I checked `strace` and found that when invoked by `git-daemon`, Git\n> doesn't even consult `~/.gitconfig`, and I think this may be a bug.\n[...]\n\nGiven the following passage from the docs, describing the \"--user\" option,\n\n| Like many programs that switch user id, the daemon does not reset\n| environment variables such as $HOME when it runs git programs, e.g.\n| upload-pack and receive-pack. When using this option, you may also want to\n| set and export HOME to point at the home directory of <user> before starting\n| the daemon, and make sure any Git configuration files in that directory are\n| readable by <user>.\n\nthe behavior does indeed look like a bug.\n\n"}]}