![SELinux에서 예외를 추가하는 방법은 무엇입니까?](https://linux55.com/image/138986/SELinux%EC%97%90%EC%84%9C%20%EC%98%88%EC%99%B8%EB%A5%BC%20%EC%B6%94%EA%B0%80%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
SELinux를 비활성화하면 문제가 없지만 강제로 적용하면 이런 문제가 발생합니다.
[systemd] failed to get d-bus session: Failed to connect to socket /run/dbus/system_bus_socket: Permission denied
감사 로그
sealert -a /var/log/audit/audit.log
100% done
found 2 alerts in /var/log/audit/audit.log
--------------------------------------------------------------------------------
SELinux is preventing /usr/sbin/zabbix_agentd from connectto access on the unix_stream_socket /run/dbus/system_bus_socket.
***** Plugin catchall (100. confidence) suggests **************************
If you believe that zabbix_agentd should be allowed connectto access on the system_bus_socket unix_stream_socket by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'zabbix_agentd' --raw | audit2allow -M my-zabbixagentd
# semodule -i my-zabbixagentd.pp
위에서 제안한 대로 정책을 생성하고 zabbix-agent를 다시 시작한 후 이제 zabbix 에이전트 로그에서 가져옵니다.
[systemd] failed to get d-bus session: An SELinux policy prevents this sender from sending this message to this recipient, 0 matched rules; type="method_call", sender="(null)" (inactive) interface="org.freedesktop.DBus" member="Hello" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)
sealert -a /var/log/audit/audit.log
39% donetype=AVC msg=audit(1534885076.573:250): avc: denied { connectto } for pid=10654 comm="zabbix_agentd" path="/run/dbus/system_bus_socket" scontext=system_u:system_r:zabbix_agent_t:s0 tcontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tclass=unix_stream_socket
**** Invalid AVC allowed in current policy ***
답변1
음, 먼저 해야 할 일확인하다SELinux에서 얻은 거부입니다. (제 생각에는) 가장 쉬운 방법은 sealert
유틸리티를 이용하는 것입니다.
먼저 다음 명령을 사용하여 패키지를 설치하십시오 setroubleshoot-server
.
yum install setroubleshoot-server
그런 다음 다음을 실행하십시오.
sealert -a /var/log/audit/audit.log
많은 결과를 얻을 수 있습니다.당신의아니오라고 구체적으로 말하고 조언을 따르십시오. 하지만 허용되어서는 안되는 일은 허용하지 않도록 주의하세요!
다음은 거부의 예와 sealert
(필자가 강조하는) 제안된 해결 방법입니다.
SELinux는 rlimitinh를 사용하는 프로세스에 대한 /usr/libexec/postfix/qmgr 액세스를 차단합니다. ***** 플러그인 올인클루시브 (100. Confidence) 추천**************************** qmgr은 기본적으로 postfix_qmgr_t로 표시된 프로세스에 대해 rlimitinh 액세스를 허용해야 한다고 생각합니다. 그러면 이것을 버그로 보고해야 합니다. 이 액세스를 허용하는 로컬 정책 모듈을 생성할 수 있습니다. 하다 다음 명령을 실행하여 일시적으로 이 액세스를 허용합니다. # ausearch -c 'qmgr' --raw audit2allow -M my-qmgr | # semodule -i my-qmgr.pp 추가 정보: 소스 컨텍스트 system_u:system_r:postfix_master_t:s0 대상 컨텍스트 system_u:system_r:postfix_qmgr_t:s0 대상 객체를 알 수 없음 [절차] 소스qmgr 소스 경로/usr/libexec/postfix/qmgr 포트 주인 소스 RPM 패키지 postfix-2.10.1-6.el7.x86_64 목표 RPM 패키지 정책RPM selinux-policy-3.13.1-102.el7_3.16.noarch Selinux 활성화True 정책 유형 목표 힘 모드 힘 호스트 이름 Centos PlatformLinux centos 3.10.0-514.26.2.el7.x86_64 #1 SMP 화요일 2017년 7월 4일 15:04:05 UTC x86_64 x86_64 경고 횟수 5 2018-04-18 18:02:32 CEST에 처음 등장했습니다. 마지막 확인 날짜: 2018-08-22 09:11:22 CEST 로컬 ID 855f168c-1e47-4c6b-8a1e-f8fddce5d426
위의 예는 다시 Postfix 찾기에 관한 것입니다.당신의로컬 정책을 거부하고 삽입합니다.