git无法执行"pack-objects":权限被拒绝 [英] git cannot exec 'pack-objects': Permission denied
问题描述
从我刚刚添加的自托管git远程目录中提取消息时,出现此错误.
I'm getting this error when pulling from a self-hosted git remote I just added.
$ git pull myremote master
fatal: cannot exec 'pack-objects': Permission denied
fatal: git upload-pack: unable to fork git-pack-objects
fatal: The remote end hung up unexpectedly
fatal: protocol error: bad pack header
谷歌搜索"不能执行'pack-objects':权限被拒绝
"带引号的结果为零,因此这不是重复的.关于致命的:协议错误:错误的包头
部分,有几个问题,例如这个问题建议在 .gitconfig
中添加一些内存限制行.那没有解决我的问题.
Googling "cannot exec 'pack-objects': Permission denied
" with quotes got zero results, so this is not a duplicate. There are several questions about the fatal: protocol error: bad pack header
part, with answers like this one proposing adding a few memory-limiting lines to .gitconfig
. That didn't solve my problem.
基于第一行,我认为某些 pack-objects
可执行文件缺少其 x
权限.但这不是这个:
Based on the first line, I reckon some pack-objects
executable somewhere is missing its x
permission. But it's not this one:
$ ls -l $(which git-upload-pack)
-rwxr-xr-x 1 root root 1559256 Apr 20 10:20 /usr/bin/git-upload-pack
就上下文而言,远程服务器是运行Debian 10的VPS,而客户端是运行于Ubuntu 18.04的古老的Intel Celron桌面,大约在2003年.因此,拉力机上的资源限制可能会发挥作用.
For context, the remote is a VPS running Debian 10, while the client is an ancient Intel Celron desktop circa 2003, running Ubuntu 18.04. So resource limitation on the pulling machine could be playing a role.
编辑:
所有用户均可执行所有git二进制文件:
All the git binaries are executable by all users:
$ ls -l /usr/bin/git*
-rwxr-xr-x 1 root root 2759388 Apr 20 10:20 /usr/bin/git
lrwxrwxrwx 1 root root 3 Apr 20 10:20 /usr/bin/git-receive-pack -> git
-rwxr-xr-x 1 root root 1546968 Apr 20 10:20 /usr/bin/git-shell
lrwxrwxrwx 1 root root 3 Apr 20 10:20 /usr/bin/git-upload-archive -> git
-rwxr-xr-x 1 root root 1559256 Apr 20 10:20 /usr/bin/git-upload-pack
/usr/bin
在我的PATH中:
$ echo $PATH
/home/keith/bin:/home/keith/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
我可以在没有sudo的情况下运行它们:
And I can run them without sudo:
$ git-upload-pack
usage: git upload-pack [<options>] <dir>
--stateless-rpc quit after a single request/response exchange
--advertise-refs exit immediately after initial ref advertisement
--strict do not try <directory>/.git/ if <directory> is no Git directory
--timeout <n> interrupt transfer after <n> seconds of inactivity
编辑2 :
.git
目录似乎也具有正确的权限:
The .git
dir appears to have correct permissions too:
$ ls -la .git{,/objects}
.git:
total 56
drwxr-xr-x 8 keith keith 4096 Sep 21 11:36 .
drwxr-xr-x 22 keith keith 4096 Sep 21 13:09 ..
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 branches
-rw-r--r-- 1 keith keith 290 Sep 21 11:36 config
-rw-r--r-- 1 keith keith 73 Jul 25 2017 description
-rw-r--r-- 1 keith keith 0 Sep 21 12:51 FETCH_HEAD
-rw-r--r-- 1 keith keith 23 Jul 25 2017 HEAD
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 hooks
-rw-rw-r-- 1 keith keith 1555 Sep 21 10:47 index
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 info
drwxr-xr-x 3 keith keith 4096 Jul 25 2017 logs
drwxr-xr-x 37 keith keith 4096 Jul 25 2017 objects
-rw-rw-r-- 1 keith keith 41 Apr 2 2018 ORIG_HEAD
-rw-rw-r-- 1 keith keith 46 Sep 21 10:47 packed-refs
drwxr-xr-x 5 keith keith 4096 Jul 25 2017 refs
.git/objects:
total 148
drwxr-xr-x 37 keith keith 4096 Jul 25 2017 .
drwxr-xr-x 8 keith keith 4096 Sep 21 11:36 ..
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 06
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 0a
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 17
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 22
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 29
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 2d
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 30
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 32
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 35
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 3c
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 3f
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 43
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 4f
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 50
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 53
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 5a
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 5f
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 6e
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 72
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 82
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 96
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 a5
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 a8
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 b4
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 b7
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 b9
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 bc
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 c0
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 c3
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 c9
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 cd
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 e7
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 ea
drwxr-xr-x 2 keith keith 4096 Jul 25 2017 info
drwxr-xr-x 2 keith keith 4096 Apr 2 2018 pack
编辑3 :
我没有安装SELinux,所以除了Linux权限外,我不知道要检查什么上下文.
I don't have SELinux installed so I don't know what context to check except linux permissions.
我看着/usr/lib/git-core
.所有文件(可执行文件和符号链接)均为root拥有,但对所有用户都具有rx权限.最重要的是:
I looked at /usr/lib/git-core
. All the files (executables and symlinks) were root-owned but had rx permissions for all users. Most importantly:
$ ls -lhZ /usr/lib/git-core/{git-upload-pack,git-pack-objects}
lrwxrwxrwx 1 root root ? 3 Apr 20 10:20 /usr/lib/git-core/git-pack-objects -> git
-rwxr-xr-x 1 root root ? 1.5M Apr 20 10:20 /usr/lib/git-core/git-upload-pack
除了这些:
$ ls -lhZ /usr/lib/git-core/git-sh-*
-rw-r--r-- 1 root root ? 2.3K Apr 20 10:20 /usr/lib/git-core/git-sh-i18n
-rwxr-xr-x 1 root root ? 1.5M Apr 20 10:20 /usr/lib/git-core/git-sh-i18n--envsubst
-rw-r--r-- 1 root root ? 16K Apr 20 10:20 /usr/lib/git-core/git-sh-prompt
-rw-r--r-- 1 root root ? 9.1K Apr 20 10:20 /usr/lib/git-core/git-sh-setup
编辑4 :
在 torek 的
Following torek's suggestion to check myremote
, I logged in there and checked the same suspects:
$ ls -lhZ /usr/bin/git*
-rwxr-xr-x 1 root root ? 2.7M Apr 19 18:19 /usr/bin/git
lrwxrwxrwx 1 root root ? 3 Apr 19 18:19 /usr/bin/git-receive-pack -> git
-rwxr-xr-x 1 root root ? 1.5M Apr 19 18:19 /usr/bin/git-shell
lrwxrwxrwx 1 root root ? 3 Apr 19 18:19 /usr/bin/git-upload-archive -> git
lrwxrwxrwx 1 root root ? 3 Apr 19 18:19 /usr/bin/git-upload-pack ->
$ ls -lhZ /usr/lib/git-core/{git-upload-pack,git-pack-objects,git}
-rwxr-xr-- 1 root root ? 2.7M Apr 19 18:19 /usr/lib/git-core/git
lrwxrwxrwx 1 root root ? 3 Apr 19 18:19 /usr/lib/git-core/git-pack-objects -> git
lrwxrwxrwx 1 root root ? 3 Apr 19 18:19 /usr/lib/git-core/git-upload-pack -> git
现在我看到了罪魁祸首.
Now I see the culprit.
推荐答案
Edit 4具有最终线索:问题实际上出在服务器上,由于某种原因,该服务器使用了/usr/lib/git-core/git
二进制模式754( rwxr-xr-
),而不是模式755( rwxr-xr-x
).这意味着不允许非用户root用户和不在组root用户的任何人运行它,并且在服务器上对该二进制文件进行简单的 chmod
即可解决此问题.
Edit 4 has the final clues: the problem was in fact on the server, which for some reason had the /usr/lib/git-core/git
binary as mode 754 (rwxr-xr--
), instead of mode 755 (rwxr-xr-x
). This meant anyone not user root, and not in group root, was not allowed to run it, and a simple chmod
of that binary on the server would fix the problem.
这篇关于git无法执行"pack-objects":权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!