git ne peut pas exécuter 'pack-objects': autorisation refusée

Sep 22 2020

J'obtiens cette erreur lors de l'extraction d'une télécommande git auto-hébergée que je viens d'ajouter.

$ 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

Google " cannot exec 'pack-objects': Permission denied" avec des guillemets n'a donné aucun résultat, il ne s'agit donc pas d'un doublon. Il y a plusieurs questions sur la fatal: protocol error: bad pack headerpièce, avec des réponses comme celle-ci proposant d'ajouter quelques lignes de limitation de mémoire à .gitconfig. Cela n'a pas résolu mon problème.

Sur la base de la première ligne, je pense qu'un pack-objectsexécutable quelque part manque sa xpermission. Mais ce n'est pas celui-ci:

$ ls -l $(which git-upload-pack)
-rwxr-xr-x 1 root root 1559256 Apr 20 10:20 /usr/bin/git-upload-pack

Pour le contexte, la télécommande est un VPS exécutant Debian 10, tandis que le client est un ancien bureau Intel Celron vers 2003, exécutant Ubuntu 18.04. La limitation des ressources sur la machine de traction pourrait donc jouer un rôle.

MODIFIER :

Tous les binaires git sont exécutables par tous les utilisateurs:

 $ 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

Et /usr/binest dans mon CHEMIN:

$ 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

Et je peux les exécuter sans 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

MODIFIER 2 :

Le .gitrépertoire semble également avoir les autorisations correctes:

$ 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

MODIFIER 3 :

Je n'ai pas installé SELinux, donc je ne sais pas quel contexte vérifier sauf les autorisations Linux.

J'ai regardé /usr/lib/git-core. Tous les fichiers (exécutables et liens symboliques) appartenaient à root mais avaient des autorisations rx pour tous les utilisateurs. Plus important encore:

$ 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

Sauf ceux-ci:

$ 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

MODIFIER 4 :

Suite à la suggestion de torek de vérifier , je me suis connecté là-bas et j'ai vérifié les mêmes suspects: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

Maintenant, je vois le coupable.

Réponses

1 torek Sep 23 2020 at 04:37

Edit 4 a les derniers indices: le problème était en fait sur le serveur, qui pour une raison quelconque avait le /usr/lib/git-core/gitbinaire en mode 754 ( rwxr-xr--), au lieu du mode 755 ( rwxr-xr-x). Cela signifiait que quiconque n'était pas root et pas dans le groupe root n'était pas autorisé à l'exécuter, et un simple chmodde ce binaire sur le serveur résoudrait le problème.

Obsidian Sep 22 2020 at 02:21

Vous voudrez probablement jeter un œil à votre référentiel local .git , en particulier sous .git/objects. Vérifiez les pouvoirs et les autorisations des fichiers et voyez si git a le droit de les créer.

Ce qui est le plus probable, c'est que vous avez probablement exécuté gitune fois avec sudoou été temporairement connecté en tant que root en utilisant su. Tant que les fichiers existent déjà, ce ne sera pas un problème car ils conserveront leurs droits et propriétaires d'origine, mais si Git devait créer des fichiers inexistants tels que le sous-répertoire de l'objet compressé, s'il l'a fait en tant que root , c'est normal de ne pas pouvoir les exploiter comme identité habituelle par la suite.

Et cela peut arriver avec n'importe quelle commande, pas simplement avec Git. Ainsi, le message d'erreur, qui ne rapporte que la raison de l'erreur donnée par le système.

ÉDITER

Compte tenu des commentaires ci-dessous, vous voudrez probablement également consulter le contenu de /usr/libexec/git-core/. Il contient tous les exécutables qui sont réellement associés aux commandes et sous-commandes git.

Parmi eux, des mensonges git-pack-objectsqui se passent git-upload-pack. Les deux sont des exécutables différents et distincts.

Cela n'explique toujours pas pourquoi les droits auraient été perdus ici, mais cela reste un endroit à regarder.

Bonne chance.