git can exec 'pack-objects': Permission denied

Sep 22 2020

방금 추가 한 자체 호스팅 자식 원격에서 가져올 때이 오류가 발생합니다.

$ 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

cannot exec 'pack-objects': Permission denied따옴표가있는 ' ' 검색 결과가 0 개이므로 중복이 아닙니다. [정보] 몇 가지 질문이 있습니다 fatal: protocol error: bad pack header같은 답변 부분 이 하나 개 에 몇 메모리 제한 라인을 추가 제안하는가 .gitconfig. 내 문제가 해결되지 않았습니다.

첫 번째 줄에 따르면 pack-objects어딘가에서 x권한 이 누락 된 실행 파일이 있다고 생각 합니다. 하지만 이건 아닙니다.

$ 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를 실행하는 2003 년경 고대 Intel Celron 데스크톱입니다. 따라서 당기는 기계에 대한 자원 제한이 역할을 할 수 있습니다.

편집 :

모든 git 바이너리는 모든 사용자가 실행할 수 있습니다.

 $ 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없이 실행할 수 있습니다.

$ 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디렉토리도 올바른 사용 권한이 나타납니다 :

$ 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 권한을 제외하고 어떤 컨텍스트를 확인할지 모르겠습니다.

나는을 보았다 /usr/lib/git-core. 모든 파일 (실행 파일 및 심볼릭 링크)은 루트 소유 였지만 모든 사용자에 대한 rx 권한이 있습니다. 가장 중요한 것은:

$ 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 의 확인 제안 에 따라 myremote로그인하여 동일한 용의자를 확인했습니다.

$ 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

이제 범인을 봅니다.

답변

1 torek Sep 23 2020 at 04:37

편집 4에는 최종 단서가 있습니다. 문제는 실제로 서버에 있었으며 어떤 이유로 /usr/lib/git-core/git바이너리 rwxr-xr--가 모드 755 ( rwxr-xr-x) 대신 모드 754 ( )로 사용되었습니다 . 이는 루트 사용자가 아니고 그룹 루트에 속하지 않는 사람은 누구나 실행할 수 없음 chmod을 의미하며 서버에서 해당 바이너리 중 간단한 것만 으로 문제를 해결할 수 있습니다.

Obsidian Sep 22 2020 at 02:21

특히 .NET에서 로컬 .git 저장소를 살펴보고 싶을 것입니다 .git/objects. 파일의 권한과 권한을 확인하고 git이 파일을 생성 할 권한이 있는지 확인하십시오.

가장 가능성이 높은 것은 아마도를 사용하여 루트 로 git한 번 실행 sudo했거나 임시로 로그인 한 것 입니다. 파일이 이미 존재하는 한 원래 권한과 소유자를 유지하기 때문에 문제가되지 않지만 Git이 압축 된 객체 하위 디렉토리와 같이 아직 존재하지 않는 파일을 만들어야했다면 root로 수행 하면 문제가 발생합니다. 나중에 일반 신분으로 악용 할 수 없습니다.su

그리고 이것은 실제로 단순히 Git이 아닌 모든 명령으로 발생할 수 있습니다. 따라서 시스템에서 제공 한 오류 이유 만보고하는 오류 메시지입니다.

편집하다

아래의 설명을 고려하면의 내용도 확인하고 싶을 것입니다 /usr/libexec/git-core/. 여기에는 실제로 git 명령 및 하위 명령과 관련된 모든 실행 파일이 포함됩니다.

그중에 git-pack-objects는 git-upload-pack. 둘 다 다르고 별개의 실행 파일입니다.

여기에서 권리를 잃어버린 이유는 여전히 설명되지 않지만 여전히 살펴볼 곳입니다.

행운을 빕니다.