openSUSE Leap 16

SELinux : SETroubleShoot を活用する2025/10/22

 

SELinux による AVC 拒否のログは リンク先のように、ログファイルの直接参照 または ツール経由でのレポート出力により確認可能ですが、SETroubleShoot を利用すると、問題解決に有用なログを追加出力することができます。

[1]

SETroubleShoot のメッセージは Audit イベント ディスパッチャーによって Systemd Journald ( Rsyslog 稼働の場合は [/var/log/messages] ) へ送信されます。
よって、こちらを参考に Auditd を起動しておく必要があります

[2] SETroubleShoot をインストールします。
dlp:~ #
zypper -n install setroubleshoot-server
[3]

AVC 拒否が発生した場合は Systemd Journald や、Rsyslog 稼働の場合 [/var/log/messages] に以下のようなログが記録されます。

[/var/log/messages] に記録されたログを例にすると、
下例の場合、2 行目に推測される原因と対策が 2 パターン記載されており、可能性のより高いとされている方は、[Plugin bind_ports (99.5 confidence) suggests] で提案された内容となります。下例の場合、その提案通り、[semanage port -a -t http_port_t -p tcp 82] とコマンド投入することで解決します。 解決しない場合は、[Plugin catchall (1.49 confidence) suggests] で提案された内容を試してみることになります。
dlp:~ #
grep -E 'setroubleshoot|preventing' /var/log/messages

2025-10-22T11:53:29.488357+09:00 dlp setroubleshoot: SELinux is preventing httpd-prefork from name_bind access on the tcp_socket port 85. For complete SELinux messages run: sealert -l fa5c5bfe-dd41-410f-84c5-c5c353a3842e
2025-10-22T11:53:29.495297+09:00 dlp setroubleshoot[1245]: SELinux is preventing httpd-prefork from name_bind access on the tcp_socket port 85.#012#012*****  Plugin bind_ports (99.5 confidence) suggests   ************************#012#012If you want to allow httpd-prefork to bind to network port 85#012Then you need to modify the port type.#012Do#012# semanage port -a -t PORT_TYPE -p tcp 85#012    where PORT_TYPE is one of the following: http_cache_port_t, http_port_t, jboss_management_port_t, jboss_messaging_port_t, ntop_port_t, puppet_port_t.#012#012*****  Plugin catchall (1.49 confidence) suggests   **************************#012#012If you believe that httpd-prefork should be allowed name_bind access on the port 85 tcp_socket by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'httpd-prefork' --raw | audit2allow -M my-httpdprefork#012# semodule -X 300 -i my-httpdprefork.pp#012
2025-10-22T11:53:31.079744+09:00 dlp setroubleshoot: SELinux is preventing httpd-prefork from name_bind access on the tcp_socket port 85. For complete SELinux messages run: sealert -l fa5c5bfe-dd41-410f-84c5-c5c353a3842e
[4] なお、上記ログの例 1 行目には、より詳細な情報を出力可能なコマンドが記載されているため、その通りにコマンドを投入すると以下のように内容が確認できます。 原因と対策の内容についてはログに記載してある内容と同じですが、より詳細により読みやすく表示されます。
dlp:~ #
sealert -l fa5c5bfe-dd41-410f-84c5-c5c353a3842e

SELinux is preventing httpd-prefork from name_bind access on the tcp_socket port 85.

*****  Plugin bind_ports (99.5 confidence) suggests   ************************

If you want to allow httpd-prefork to bind to network port 85
Then you need to modify the port type.
Do
# semanage port -a -t PORT_TYPE -p tcp 85
    where PORT_TYPE is one of the following: http_cache_port_t, http_port_t, jboss_management_port_t, jboss_messaging_port_t, ntop_port_t, puppet_port_t.

*****  Plugin catchall (1.49 confidence) suggests   **************************

If you believe that httpd-prefork should be allowed name_bind access on the port 85 tcp_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 'httpd-prefork' --raw | audit2allow -M my-httpdprefork
# semodule -X 300 -i my-httpdprefork.pp


Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                system_u:object_r:reserved_port_t:s0
Target Objects                port 85 [ tcp_socket ]
Source                        httpd-prefork
Source Path                   httpd-prefork
Port                          85
Host                          dlp.srv.world
Source RPM Packages
Target RPM Packages
SELinux Policy RPM            selinux-policy-targeted-20250627+git66.15675827a-
                              160000.1.2.noarch
Local Policy RPM              selinux-policy-targeted-20250627+git66.15675827a-
                              160000.1.2.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     dlp.srv.world
Platform                      Linux dlp.srv.world 6.12.0-160000.5-default #1 SMP
                              PREEMPT_DYNAMIC Wed Sep 10 15:26:25 UTC 2025
                              (3545bbd) x86_64 x86_64
Alert Count                   2
First Seen                    2025-10-22 11:53:24 JST
Last Seen                     2025-10-22 11:53:24 JST
Local ID                      fa5c5bfe-dd41-410f-84c5-c5c353a3842e

Raw Audit Messages
type=AVC msg=audit(1761101604.691:115): avc:  denied  { name_bind } for  pid=1230 comm="httpd-prefork" src=85 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:reserved_port_t:s0 tclass=tcp_socket permissive=0


Hash: httpd-prefork,httpd_t,reserved_port_t,tcp_socket,name_bind
関連コンテンツ