Search code examples
gitsamba

Git over samba cannot fetch/add/commit anymore


I have used git trough samba for several times without any issue.

In the last days however, it seems impossible to git all/fetch/commit

The error is :

error: insufficient permission for adding an object to repository database .git/objects

Using strace I can see that error is due to a call on open:

[pid 31303] open(".git/objects/b7/tmp_obj_6wi717", O_RDWR|O_CREAT|O_EXCL, 0444) = -1 EACCES (Permission denied)
[pid 31303] write(2, "error: insufficient permission f"..., 88error: insufficient permission for adding an object to repository database .git/objects

I cannot understand what has changed nor why git is trying to open a file in 444 (read for everybody) with the flag RDRW (read/write ?).

I use git 1.8.5.1 and samba 4.1.3-1 on archlinux, the samba server is a windows (git 1.8.4-1 does not solve the issue even if I used it while it was still working)

I have read other SO questions such as Git over samba - unable to write sha1 filename | Permission denied without finding any hint on how to solve the issue.


Solution

  • You can see various way to debug this in "Debugging git repo permissions on samba share":

    • setting different permissions for share
    • mounting manually
    • downgrading samba and git to earlier versions
    • sudo - this works but I wouldn't want to use it unless absolutely necessary
    • changing owner and group after using sudo

    Andrew Myers suggests making sure your bare repo has core.sharedRepository set to group.
    If not, set it and run

    cd /path/to/repo.git
    chgrp -R groupname .
    chmod -R g+rwX .
    find . -type d -exec chmod g+s '{}' +
    

    If nothing works, make sure it isn't an issue related to the kernel version:

    I've downgraded kernel to 3.11.6 and git add/commit as user started working again.


    Update: The OP kamaradclimber reports (or tried to) that is was a kernel issue (bug 66251):

    Git doesn't work correctly on samba share after upgrading kernel from 3.11.6 to 3.12.1

    Fixed by this patch.