linux - setgid bit not preserved by git on new directory in `.git` folder? -
i have bare git repository setup user fred
:
/home/fred/foo.git
i have set group of every file in foo.git
bar
:
$ chown -r fred:bar /home/fred/foo.git
(note fred
not member of group bar
)
and have set setgid
bit on every directory in foo.git
:
$ find foo.git -type d -print0 | xargs -0 chmod g+s
however when fred
commits git repository, group not preserved in files.
specifically in objects
directory see:
foo.git/objects: drwxrws--- 46 fred bar 4096 apr 7 23:43 . drwxrws--- 7 fred bar 4096 apr 6 17:12 .. drwxrws--- 2 fred bar 4096 apr 6 17:11 07 drwxrws--- 2 fred bar 4096 apr 6 17:11 10 drwxrwx--- 2 fred bar 4096 apr 7 22:14 14 <--- here drwxrws--- 2 fred bar 4096 apr 6 17:11 17 ^--- here
notice in objects/14
setgid
bit not set. consequently when new object added directory:
foo.git/objects/14: drwxrwx--- 2 fred bar 4096 apr 7 22:14 . drwxrws--- 46 fred bar 4096 apr 7 23:43 .. -r--r----- 1 fred fred 2595 apr 7 22:14 95482f8..9d6bfe21
so 95482..
file doesn't have group bar
, has group fred
.
i suspect when fred
commited, git created new directory on-demand called objects/14
hold new object, when did unknown reason setgid
bit on new 14
directory not set, though parent directory objects
has setgid
bit set.
if try reproduce manually:
$ su fred # user fred $ mkdir test1 # create test1 dir $ sudo chgrp bar test1 # set group bar $ sudo chmod g+s test1 # set setgid bit $ ls -l drwxrwsr-x 2 fred bar 4096 apr 8 21:33 test1 $ mkdir test1/test2 # create dir test1/test2 $ ls -l drwxrwsr-x 2 fred bar 4096 apr 8 21:35 test2 ^--- here
notice setgid
bit in new test1/test2
is preserved, when i...
$ touch test1/test2/test3
the new file still group bar
expected:
$ ls -l test1/test2 -rw-rw-r-- 1 fred bar 0 apr 8 21:36 test3
why doesn't git
seem preserve setgid
bit when creates new directories in .git
directory?
is there git setting can make fix this? or can explain causing this?
it turns out when specify core.sharedrepository
config, git chmod()
s on files creates. way, result correct despite filesystem types , mount options, except in 1 case repository owner isn't member of group it's shared with.
that bad result happens because git's chmod()
appears succeed -- can see in strace -- ignores issuing user isn't authorized ask for.
so avoid weirdity, thing is
git config --unset core.sharedrepository
(or not specify --shared @ on init) git doesn't touch filesystem's default permissions @ all. amusingly enough makes work:
~/sandbox/75276/s$ find ../s.git -ls 12193569 4 drwxrws--- 4 jthill mail 4096 apr 9 13:52 ../s.git 12193571 4 -rw-rw---- 1 jthill mail 73 apr 8 20:40 ../s.git/description 12193572 4 -rw-rw---- 1 jthill mail 23 apr 8 20:40 ../s.git/head 12721086 4 drwxrws--- 2 jthill mail 4096 apr 9 13:52 ../s.git/objects 12193570 4 drwxrws--- 2 jthill mail 4096 apr 9 13:52 ../s.git/refs 12193578 4 -rw-rw---- 1 jthill mail 104 apr 9 13:37 ../s.git/config ~/sandbox/75276/s$ cat ../s.git/config [core] repositoryformatversion = 0 filemode = true bare = true [receive] denynonfastforwards = true ~/sandbox/75276/s$ git push origin master counting objects: 3, done. writing objects: 100% (3/3), 198 bytes, done. total 3 (delta 0), reused 0 (delta 0) /home/jthill/sandbox/75276/s.git * [new branch] master -> master ~/sandbox/75276/s$ find ../s.git -ls 12193569 4 drwxrws--- 4 jthill mail 4096 apr 9 13:52 ../s.git 12193571 4 -rw-rw---- 1 jthill mail 73 apr 8 20:40 ../s.git/description 12193572 4 -rw-rw---- 1 jthill mail 23 apr 8 20:40 ../s.git/head 12721086 4 drwxrws--- 5 jthill mail 4096 apr 9 13:53 ../s.git/objects 16777964 4 drwxrwsr-x 2 jthill mail 4096 apr 9 13:53 ../s.git/objects/58 16777965 4 -r--r--r-- 1 jthill mail 17 apr 9 13:53 ../s.git/objects/58/7be6b4c3f93f93c489c0111bba5596147a26cb 16777962 4 drwxrwsr-x 2 jthill mail 4096 apr 9 13:53 ../s.git/objects/ab 16777963 4 -r--r--r-- 1 jthill mail 46 apr 9 13:53 ../s.git/objects/ab/69b4abf3bb84d4e268bd42d84e4a9a5e242bd3 16777960 4 drwxrwsr-x 2 jthill mail 4096 apr 9 13:53 ../s.git/objects/81 16777961 4 -r--r--r-- 1 jthill mail 120 apr 9 13:53 ../s.git/objects/81/210f2df9629e5df5f6dfa0923a2cf72369314d 12193570 4 drwxrws--- 3 jthill mail 4096 apr 9 13:53 ../s.git/refs 12193573 4 drwxrwsr-x 2 jthill mail 4096 apr 9 13:53 ../s.git/refs/heads 12193574 4 -rw-rw-r-- 1 jthill mail 41 apr 9 13:53 ../s.git/refs/heads/master 12193578 4 -rw-rw---- 1 jthill mail 104 apr 9 13:37 ../s.git/config ~/sandbox/75276/s$
Comments
Post a Comment