Domanda

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.

È stato utile?

Soluzione 2

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.

Altri suggerimenti

In my case, it looks like Git (v 2.6.3) tried to create its own read/write permissions on the Samba drive. This would prevent the pack files and/or objects from getting written (unpack error)

remote: error: unable to write sha1 filename ./objects/pack/pack-<some_hex_string>.pack: Permission denied
remote: fatal: cannot store pack file
error: unpack failed: index-pack abnormal exit
To z:\git\<repo name>
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs

I went back and forth on trying to fix. Finally, since I had control of the Samba machine, I added a line to the samba drive config, which says "inherit permissions = yes". I restarted Samba and tried to push. It worked!

This worked for me since I'm the only person using the Samba server. For others, you may have the play around with "force directory mode" or "force create mode". You can find the man pages for those over here:

https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/AccessControls.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top