]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/bugs/git_test_receive_wrapper_fails.mdwn
Add ikistrap plugin for ikistrap theme.
[git.ikiwiki.info.git] / doc / bugs / git_test_receive_wrapper_fails.mdwn
1 Getting this when a git push to git:// runs the pre-receive hook
2 which is set up by the `git_test_receive_wrapper`:
4         remote: fatal: Not a git repository (or any of the parent directories): .git
5         remote: 'git log --pretty=raw --raw --abbrev=40 --always -c -r 21161ba01a093534ef97188eae098d83554dbcc6..73820a1d7e76318d8b1ac23e1c6d47e50a3e8ca2 --no-renames -- .' failed: 
6         To git://git-annex.branchable.com/
7          ! [remote rejected]     master -> master (pre-receive hook declined)
8         error: failed to push some refs to 'git://git-annex.branchable.com/'
10 Relevant code:
12                 # Avoid chdir when running git here, because the changes
13                 # are in the master git repo, not the srcdir repo.
14                 # (Also, if a subdir is involved, we don't want to chdir to
15                 # it and only see changes in it.)
16                 # The pre-receive hook already puts us in the right place.
17                 push @rets, git_parse_changes('.', 0, git_commit_info('.', $oldrev."..".$newrev));
19 This is with  git 1:2.11.0-3+deb9u2 on debian stable, ikiwiki 3.20171002.
21 Tossing a call to pwd in there, it's at the top of the master (bare) git
22 repository, which seems right. I can do a similar git log at that location
23 manually (using different revs). Looking at the environment at that point
24 (in another wiki that has the same problem), I found only these
25 git env vars:
27         remote: GIT_ALTERNATE_OBJECT_DIRECTORIES=/home/b-joeyh/source.git/./objects
28         remote: GIT_OBJECT_DIRECTORY=/home/b-joeyh/source.git/./objects/incoming-hVfXvD
29         remote: GIT_QUARANTINE_PATH=/home/b-joeyh/source.git/./objects/incoming-hVfXvD
31 [[!commit 6fb43c29f63b85c3424520819427903e5a204426]] is relevant to that,
32 and I guess it didn't fully solve the problem.
33 --[[Joey]]
35 Stracing git-daemon -f I noticed this:
37         [pid 22616] lstat64("/home/b-ikiwiki/source.git/HEAD", {st_mode=S_IFREG|0664, st_size=23, ...}) = 0
38         [pid 22616] openat(AT_FDCWD, "/home/b-ikiwiki/source.git/HEAD", O_RDONLY|O_LARGEFILE) = 3
39         [pid 22616] read(3, "ref: refs/heads/master\n", 255) = 23
40         [pid 22616] read(3, "", 232)            = 0
41         [pid 22616] close(3)                    = 0
42         [pid 22616] lstat64("/home/b-ikiwiki/source.git/commondir", 0xbf83896c) = -1 ENOENT (No such file or directory)
43         [pid 22616] access("/home/b-ikiwiki/source.git/./objects/incoming-gXNPXm", X_OK) = -1 EACCES (Permission denied)
44         [pid 22616] stat64("/home/b-ikiwiki", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
46 So the git diff is in the right cwd, it gets as far as reading HEAD. But then
47 this permissions error on this incoming directory happens, and it then seems to
48 give up and search for a different git repo to use in the parent directory (and all the way up to root).
50 The directory is created by git earlier in the strace:
52         [pid 22559] mkdir("./objects/incoming-gXNPXm", 0700) = 0
54 And here's how it looks:
56         drwx------+ 7 ikiwiki-anon ikiwiki-anon 4096 Jun 14 00:22 incoming-y6a8pe/
58 And I think that's the problem, by the time ikiwiki runs it's switched
59 away from the ikiwiki-anon user that git-daemon uses, and over to the
60 site user. Which can't read that.
62 source.git has an ACL set to let ikiwiki-anon write to it. 
64         ikisite:                eval { shell("setfacl", "-R", "-m", "d:g:$config{gitdaemonuser}:rwX,d:g:$user:rwX,g:$config{gitdaemonuser}:rwX,g:$user:rwX", "$home/source.git") };
66 Can this ACL be adjusted so that all directories created under it will be readable
67  by the site user (b-ikiwiki)? I don't know ACLs very well.
69 Alternatively, `GIT_QUARANTINE_PATH` is set to the directory, so
70 the C wrapper could fix up its permissions. The wrapper is suid,
71 so either would need to switch user ID back to ikiwiki-anon, if that's allowed,
72 or there would need to be an outer wrapper that's not suid (just a shell
73 script would work) that then runs the regular suid wrapper.
75 > This was not a bug in ikiwiki, but ikiwiki-hosting. Fixed there (using
76 > the wrapper wrapper approach). [[done]] --[[Joey]]