![맞춤 systemd 서비스에 대한 SELinux 정책 만들기](https://rvso.com/image/134423/%EB%A7%9E%EC%B6%A4%20systemd%20%EC%84%9C%EB%B9%84%EC%8A%A4%EC%97%90%20%EB%8C%80%ED%95%9C%20SELinux%20%EC%A0%95%EC%B1%85%20%EB%A7%8C%EB%93%A4%EA%B8%B0.png)
OS 부팅과 함께 Fedora Workstation 27 Live
사용자 정의 서비스를 실행하려는 OS를 사용하고 있습니다 . 이것이 작동하려면 내 환경에서 문제를 일으키는 것을 EnableBIOS.service
비활성화해야 합니다 . SELinux
따라서 비활성화할 수 없습니다 SELinux
.
대안으로 SELinux policy
맞춤형 서비스를 생성하려고 시도했지만 아무런 진전이 없었습니다.
서비스가 아래 메시지를 기록하고 있습니다 /var/log/audit/audit.log
.
type=SERVICE_START msg=audit(1527782475.777:239): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=EnableHBA comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=AVC msg=audit(1527782475.779:240): avc: denied { execute } for pid=4223 comm="(leHBA.sh)" name="enableHBA.sh" dev="dm-0" ino=38164 scontext=system_u:system_r:init_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=SERVICE_STOP msg=audit(1527782475.782:241): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=EnableHBA comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
그리고,
[root@localserver]# audit2allow -w -a
type=AVC msg=audit(1527782475.779:240): avc: denied { execute } for pid=4223 comm="(leHBA.sh)" name="enableHBA.sh" dev="dm-0" ino=38164 scontext=system_u:system_r:init_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
Was caused by:
Unknown - would be allowed by active policy
Possible mismatch between this policy and the one under which the audit message was generated.
Possible mismatch between current in-memory boolean settings vs. permanent ones.
생성을 위해 SELinux policy
아래 명령을 실행했습니다.
[root@localserver]# grep enableHBA /var/log/audit/audit.log | audit2allow -M enablehba
[root@localserver]# semodule -i enablehba.pp
이 작업을 수행한 후 서비스를 다시 실행하려고 시도했는데 기록된 메시지는 다음과 같습니다.
[root@localserver]# audit2allow -w -a
type=AVC msg=audit(1527782959.912:250): avc: denied { read open } for pid=4612 comm="(leHBA.sh)" path="/root/enableHBA/enableHBA.sh" dev="dm-0" ino=38164 scontext=system_u:system_r:init_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
Was caused by:
Missing type enforcement (TE) allow rule.
You can use audit2allow to generate a loadable module to allow this access.
내가 어디에서 잘못하고 있는지, 아니면 내 요구 사항을 달성할 수 있는 다른 방법이 있는지 알고 싶습니다.
답변1
스크립트를 /usr/local/sbin으로 이동하고 스크립트의 레이블이 다음과 같이 올바르게 지정되었는지 확인하세요.bin_t
스크립트는 제한 없이 실행되어야 하며 필요한 모든 권한을 가지고 있어야 합니다.