I've been working with git repositories cloned on samba share for about one year and apart from few problems with setting it up there weren't any issues with it. Recently I tried to add some files to existing repository and was surprised to see "permission denied" errors.
Now I'm able to init empty repo, but when I try to run strace git add
test
, I get:
open(".git/objects/info/alternates", O_RDONLY|O_NOATIME) = -1 ENOENT (No such file or directory)
access(".git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391", F_OK) = -1 ENOENT (No such file or directory)
open(".git/objects/e6/tmp_obj_GvIyn7", O_RDWR|O_CREAT|O_EXCL, 0444) = -1 EACCES (Permission denied)
write(2, "error: insufficient permission f"..., 88error: insufficient permission for adding an object to repository database .git/objects
) = 88
close(4) = 0
write(2, "error: test: failed to insert in"..., 44error: test: failed to insert into database
) = 44
write(2, "error: unable to index file test"..., 33error: unable to index file test
) = 33
I'm using git 1.8.4.2, samba 4.1.1 on 64-bit Archlinux (kernel version: 3.12.1). I haven't been changing anything in git nor samba configuration since ages.
Share is mounted using systemd automount in /etc/fstab:
//SERVER/DATA /media/smb cifs user,noauto,credentials=/etc/samba/creds,\
workgroup=PRV,uid=1000,gid=users,_netdev,comment=systemd.automount 0 0
mount appears as:
//SERVER/DATA on /media/smb type cifs (rw,nosuid,nodev,noexec,relatime,vers=1.0,
cache=strict,domain=PRV,uid=1000,forceuid,gid=100,forcegid,addr=10.1.1.5,
file_mode=0755,dir_mode=0755,nounix,serverino,rsize=61440,wsize=65536,actimeo=1)
Permissions:
$ ls -lan .git/objects
total 0
drwxr-xr-x 2 1000 100 0 11-27 09:04 .
drwxr-xr-x 2 1000 100 0 2013-11-27 ..
drwxr-xr-x 2 1000 100 0 11-27 09:39 e6
drwxr-xr-x 2 1000 100 0 11-27 09:04 info
drwxr-xr-x 2 1000 100 0 11-27 09:04 pack
$ ls -lan .git/objects/pack
total 0
drwxr-xr-x 2 1000 100 0 11-27 09:04 .
drwxr-xr-x 2 1000 100 0 11-27 09:04 ..
I've already tried:
- setting different permissions for share - same result
- mounting manually - same
- downgrading samba and git to earlier versions - no difference
- sudo - this works but I wouldn't want to use it unless absolutely necessary
- mercurial (out of curiosity) - cloning git repo fails, hg repos are cloned without any problems
- changing owner and group after using sudo - they seem to remain the same before and after issuing the command
Is there anything more I can do to debug it? I'm quite inclined to stay with git, but I'm left clueless what is wrong with permissions.
Regarding sudo:
$ touch test
$ sudo strace git add test
open(".git/objects/info/alternates", O_RDONLY|O_NOATIME) = -1 ENOENT (No such file or directory)
access(".git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, ".git/objects/pack", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
getdents(5, /* 2 entries */, 32768) = 48
getdents(5, /* 0 entries */, 32768) = 0
close(5) = 0
open(".git/objects/e6/tmp_obj_i4e0C8", O_RDWR|O_CREAT|O_EXCL, 0444) = 5
brk(0xd5a000) = 0xd5a000
write(5, "x\1K\312\311OR0`\0\0\t\260\1\360", 15) = 15
brk(0xd4a000) = 0xd4a000
brk(0xd3a000) = 0xd3a000
close(5) = 0
link(".git/objects/e6/tmp_obj_i4e0C8", ".git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391") = 0
unlink(".git/objects/e6/tmp_obj_i4e0C8") = 0
lstat(".git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391", {st_mode=S_IFREG|0755, st_size=15, ...}) = 0
close(4)
$ ls -lan .git/objects/e6
total 1
drwxr-xr-x 2 1000 100 0 11-28 10:11 .
drwxr-xr-x 2 1000 100 0 11-28 10:10 ..
-rwxr-xr-x 1 1000 100 15 11-28 10:11 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
-r-xr-xr-x 1 1000 100 0 11-28 10:11 tmp_obj_9Z8UgU
-r-xr-xr-x 1 1000 100 0 11-28 10:10 tmp_obj_d0yhDJ
It creates the objects with 0755
permissions. Without sudo
temporary
object files are left with 0555
. Looks like the problem is in
creating file with 0444
as regular user, which seems to have write permissions
to whole repo.