git ไม่สามารถดำเนินการ 'pack-objects': ปฏิเสธการอนุญาต
ฉันได้รับข้อผิดพลาดนี้เมื่อดึงจากรีโมตคอมไพล์ที่โฮสต์เองฉันเพิ่งเพิ่ม
$ 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
Googling " cannot exec 'pack-objects': Permission denied" ที่มีเครื่องหมายคำพูดไม่มีผลลัพธ์ดังนั้นจึงไม่ซ้ำกัน มีหลายคำถามเกี่ยวกับการเป็น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
สำหรับบริบทรีโมตคือ VPS ที่ใช้ Debian 10 ในขณะที่ไคลเอนต์เป็นเดสก์ท็อป Intel Celron รุ่นเก่าประมาณปี 2003 ซึ่งใช้ Ubuntu 18.04 ดังนั้นข้อ จำกัด ด้านทรัพยากรบนเครื่องดึงอาจมีบทบาท
แก้ไข :
ไบนารีคอมไพล์ทั้งหมดสามารถเรียกใช้งานได้โดยผู้ใช้ทั้งหมด:
$ 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อยู่ในเส้นทางของฉัน:
$ 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 :
.gitdir ดูเหมือนจะมีสิทธิ์ที่ถูกต้องมากเกินไป:
$ 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 's ข้อเสนอแนะที่จะตรวจสอบ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
ตอนนี้ฉันเห็นผู้ร้ายแล้ว
คำตอบ
แก้ไข 4 มีเบาะแสสุดท้าย: ปัญหาเกิดขึ้นจริงบนเซิร์ฟเวอร์ซึ่งด้วยเหตุผลบางประการมี/usr/lib/git-core/gitไบนารีเป็นโหมด 754 ( rwxr-xr--) แทนที่จะเป็นโหมด 755 ( rwxr-xr-x) ซึ่งหมายความว่าทุกคนที่ไม่ใช่ผู้ใช้รูทและไม่ได้อยู่ในรูทกลุ่มจะไม่ได้รับอนุญาตให้เรียกใช้งานและchmodไบนารีง่ายๆบนเซิร์ฟเวอร์จะแก้ไขปัญหาได้
คุณอาจต้องการที่จะดูที่คุณท้องถิ่น พื้นที่เก็บข้อมูลโดยเฉพาะอย่างยิ่งภายใต้.git .git/objectsตรวจสอบหนี้และสิทธิ์ของไฟล์และดูว่าคอมไพล์มีสิทธิ์ในการสร้างหรือไม่
สิ่งที่มีแนวโน้มมากที่สุดที่เกิดขึ้นคือการที่คุณอาจจะมีการเรียกใช้gitครั้งเดียวทั้งที่มีsudoหรือถูกชั่วคราวบันทึกไว้เป็นรากsuใช้ ตราบใดที่ไฟล์มีอยู่แล้วก็จะไม่มีปัญหาเพราะจะรักษาสิทธิ์เดิมและเจ้าของ แต่ถ้า Git ต้องสร้างไฟล์ที่ยังไม่มีอยู่จริงเช่นไดเร็กทอรีย่อยของอ็อบเจ็กต์ที่บรรจุถ้าเขาทำในฐานะรูทก็ เป็นเรื่องปกติที่จะไม่สามารถใช้ประโยชน์จากสิ่งเหล่านี้เป็นข้อมูลประจำตัวของคุณได้ในภายหลัง
และสิ่งนี้อาจเกิดขึ้นได้ด้วยคำสั่งใด ๆ ไม่ใช่แค่ Git ดังนั้นข้อความแสดงข้อผิดพลาดซึ่งรายงานเฉพาะสาเหตุของข้อผิดพลาดที่กำหนดโดยระบบ
แก้ไข
เมื่อพิจารณาจากความคิดเห็นด้านล่างคุณอาจต้องการตรวจสอบเนื้อหา/usr/libexec/git-core/เช่นกัน ซึ่งประกอบด้วยไฟล์ปฏิบัติการทั้งหมดที่เกี่ยวข้องกับคำสั่ง git และคำสั่งย่อย
ในหมู่พวกเขาโกหกซึ่งดำเนินการโดยgit-pack-objects git-upload-packทั้งสองเป็นไฟล์ปฏิบัติการที่แตกต่างกันและแตกต่างกัน
ยังไม่สามารถอธิบายได้ว่าทำไมสิทธิ์จึงหายไปที่นี่ แต่ก็ยังคงเป็นสถานที่ที่น่าสนใจ
โชคดี.