chcon: '/usr/sbin/httpd'의 컨텍스트를 변경할 수 없습니다. 권한이 거부되었습니다.

chcon: '/usr/sbin/httpd'의 컨텍스트를 변경할 수 없습니다. 권한이 거부되었습니다.

나는 SELiunx 개념을 처음 접했습니다.RHEL7 > SELinux 사용자 및 관리자 가이드 > 3.2. 무제한 프로세스

감사 로그

type=IPC msg=audit(1624375715.312:4225): ouid=0 ogid=0 mode=0666 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
type=PROCTITLE msg=audit(1624375715.312:4225): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=AVC msg=audit(1624375724.580:4226): avc:  denied  { unix_read unix_write } for  pid=25626 comm="httpd" key=1392707921  scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=shm permissive=0
type=SYSCALL msg=audit(1624375724.580:4226): arch=c000003e syscall=29 success=no exit=-13 a0=53030951 a1=4338 a2=1b6 a3=6b items=0 ppid=25612 pid=25626 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)

도메인에서 실행 되도록 httpd를 변경했지만 이제 httpd를 다시 도메인 unconfind_t으로 변경할 수 없습니다 .httpd_t

httpd가 호스팅하는 PHP 프로세스에 의해 호출되는 함수가 작동 unconfined_t하도록 도메인 으로 httpd를 설정했습니다 .shmget

[user@rhel7 ~]$ sudo chcon -t bin_t /usr/sbin/httpd
[user@rhel7 ~]$ ls -Z /usr/sbin/httpd
-rwxr-xr-x. root root system_u:object_r:bin_t:s0       /usr/sbin/httpd
[user@rhel7 ~]$ systemctl start httpd.service

[root@rhel7 user]# chcon -r system_r -t httpd_t /usr/sbin/httpd
chcon: failed to change context of ‘/usr/sbin/httpd’ to ‘system_u:system_r:httpd_t:s0’: Permission denied
[root@rhel7 user]#

답변1

restorecon -v /usr/sbin/httpd기본값으로 다시 실행할 수 있어야 합니다 .

수동으로 변경하려면 httpd_exec_t파일 유형으로 사용해야 합니다.

답변2

RH 8.5에서 루트로 로그인한 동안 비슷한 문제가 발생하여 파일 을 unconfined_t. unconfined_t올바른 접근 방식은 위의 사용자가 제안한 대로 파일을 기존의 올바른 유형의 일부로 만든 다음 이를 사용하여 semanage fcontext변경 사항을 영구적으로 만들거나 새로운 유형 및 보안 정책을 정의하는 것입니다. 귀하의 경우에는 적합하기 때문에 새로운 정책이 필요하지 않습니다 httpd_t.

새로운 서비스의 종류를 unconfined_t. 하지만:

chcon -t unconfined_t my_file

제공된 권한이 거부되었습니다.

해결책을 찾는 다른 사람들을 위해 제가 한 일은 다음과 같습니다.

# setenforce 0
# chcon -t unconfined_t my_file
# setenforce 1
# getenforce 
Enforcing

이것이 올바른 접근 방식인지는 확실하지 않지만 제게는 도움이 되었습니다. 나중에 새로운 전략을 작성하고 어떤 유형을 사용할지 알아낼 것입니다.

관련 정보