SELinux 문제 - git status fatal: 메모리 부족? mmap 실패: 권한이 거부되었습니다.

SELinux 문제 - git status fatal: 메모리 부족? mmap 실패: 권한이 거부되었습니다.

Apache와 Git으로 Centos 7.9 서버를 실행하고 있지만

[root@a]# git status
fatal: Out of memory? mmap failed: Permission denied

그러나 아래 명령을 통해 SE-Linux를 비활성화하거나 허용하면 제대로 작동하기 시작합니다.

setenforce Permissive

SELinux를 활성화한 상태에서 이 문제를 영구적으로 해결하는 방법에 대한 아이디어가 있습니까?

감사 로그에 따르면

node=a type=PROCTITLE msg=audit(1630636505.296:37076): proctitle=67697400737461747573
node=a type=MMAP msg=audit(1630636505.296:37076): fd=3 flags=0x2
node=a type=SYSCALL msg=audit(1630636505.296:37076): arch=c000003e syscall=9 success=no exit=-13 a0=0 a1=3ebd0 a2=3 a3=2 items=0 ppid=8008 pid=8156 auid=1001 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=570 comm="git" exe="/usr/bin/git" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
node=a type=AVC msg=audit(1630636505.296:37076): avc:  denied  { map } for  pid=8156 comm="git" path="/www/site/.git/index" dev="sda2" ino=540400 scontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:httpd_t:s0 tclass=file permissive=0

답변1

문제는 매핑 중인 이 파일입니다.

/www/site/.git/index

그러나 이 파일의 형식은 httpd_t실제로 합법적인 파일 형식이 아니라 프로세스(또는 알려진 도메인 형식)입니다.

웹 서버가 이에 쓸 수 있도록 허용하려면 의 컨텍스트를 /www존재로 설정해야 할 것입니다 .httpd_sys_content_thttpd_sys_content_rw_t

내가 추측해야 한다면, 당신이 실수로 chcon -t httpd_ton을 했다고 가정하겠습니다 ./www

이 문제를 올바르게 해결하는 가장 좋은 방법은 파일 컨텍스트를 재설정하고 복원하는 것입니다.

# semanage fcontext -a -t httpd_sys_content_t '/www(/.*)?'
# restorecon -rv /www

이렇게 하면 올바른 컨텍스트를 설정하고 향후 컨텍스트 사고를 방지할 수 있습니다.

그런 다음 다시 테스트하여 git status작동하는지 확인하십시오.

관련 정보