我已经使用samba共享克隆了git仓库大约一年了,除了设置方面的一些问题外,没有任何问题。最近,我尝试将一些文件添加到现有存储库中,并惊讶地看到“权限被拒绝”错误。
现在我可以初始化空仓库,但是当我尝试运行时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)
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
我在64位Archlinux(内核版本:3.12.1)上使用git 1.8.4.2,samba 4.1.1。自古以来,我从未在git和samba配置中进行任何更改。
使用/ etc / fstab中的systemd automount挂载共享:
//SERVER/DATA /media/smb cifs user,noauto,credentials=/etc/samba/creds,\
workgroup=PRV,uid=1000,gid=users,_netdev,comment=systemd.automount 0 0
安装显示为:
//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)
权限:
$ 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 ..
我已经尝试过:
- 为共享设置不同的权限-相同的结果
- 手动安装-相同
- 将samba和git降级到早期版本-没什么区别
- sudo-这可行,但除非绝对必要,否则我不想使用它
- 出于好奇(出于好奇)-克隆git repo失败,将hg repos克隆出来没有任何问题
- 在使用sudo之后更改所有者和组-发出命令之前和之后它们似乎保持不变
我还有什么可以做调试的吗?我很愿意留下git,但是我不知道权限有什么问题。
关于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
它创建具有0755
权限的对象。如果没有sudo
临时对象文件,则保留0555
。看起来问题出在0444
以普通用户身份创建文件时,该文件似乎具有对整个存储库的写入权限。
sudo git add
或sudo git commit
仅使用了其中一部分-当我恢复工作时,将尝试将它们穿上。除此之外,我怀疑未发行的回购协议sudo git
是否将被根拥有。