unlabeled_tを使用したくない場合は、/etc/zabbix/のカスタムファイルコンテキストタイプを作成する必要がありますか?

unlabeled_tを使用したくない場合は、/etc/zabbix/のカスタムファイルコンテキストタイプを作成する必要がありますか?

CentOS 7システムにzabbix(モニタリングアプリケーション)をインストールしました。セキュリティ上の理由からselinuxを強制モードにしておきたい。そのため、zabbixが機能するにはいくつかの権限を付与する必要がありました。次のコマンドを実行すると:

ausearch -c zabbix_server -m AVC -i -ts today | audit2allow -m ztest

次の結果が表示されます。

...
require {
     type unlabeled_t;
     type zabbix_var_run_t;
     type zabbix_t;
     class sock_file { create unlink };
     class unix_stream_socket connectto;
     class file { getattr open read };
}

#========== zabbix_t ==============

#!!!!! This avc can be allowed using the boolean 'daemons_enable_cluster_mode'
allow zabbix_t self:unix_stream_socket connectto;

#!!!!! WARNING 'unlabeled_t' is a base type.
allow zabbix_t unlabeled_t:file { getattr open read };
allow zabbix_t zabbix_var_run_t:sock_file { create unlink };

いくつかの調査の終わりに、/etc/zabbix/zabbix_server.confファイルのファイルコンテキストタイプがunlabeled_tであることがわかりました。これが、audit2allowがzabbix_serverがunlabeled_tを使用できるようにすることを提案した理由です。しかし、生の型を許可するのは悪い考えなので、この問題を解決する方法を探しています。 zabbix_selinuxのマンページを確認しました(https://www.systutorials.com/docs/linux/man/8-zabbix_selinux/)しかし、実際には適切なコンテキストファイル形式はありません。私は独自のファイルコンテキストタイプを作成できますが、実際には専門家ではないので、これが最善の解決策であるかどうかはわかりません。だから私の質問にはより良い方法がありますか、それともデフォルトの型unlabeled_tを使用したくない場合は、実際に独自のファイルコンテキスト型を作成する必要がありますか?

ベストアンサー1

SELinuxをサポートしていないソースからZabbixをインストールしたか、インストール中にSELinuxを無効にした可能性があります。

ZabbixがSELinuxサポートパッケージからインストールされていない場合、ランタイムはrestorecon -R -v /etc自動的にunlabeled_tラベルを別のラベルに変更する可能性があります。おそらく、etc_tこれはファイルとディレクトリのデフォルトのラベルとして表示されるためです/etc。おそらく使用する前にこれを行う必要がありますaudit2allow

etc_tこれはほとんどのプロファイルに適したコンテキストタイプです。

RHEL / CentOS 7.x用のSELinuxルールセットには、実際にZabbixに関するいくつかの組み込み条項があります。つまり、ディレクトリ/etc/zabbix/web/とその中のすべてのファイルにタグが付けられ、httpd_sys_rw_content_tZabbixの起動スクリプト(サーバーとエージェント)は適切なタグzabbix_initrc_exec_tですzabbix_agent_initrc_exec_t

以下は、Zabbixパッケージがまったくインストールされていない「標準」RHEL 7.7テストVMからのものです。

[root@localhost etc]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.7 (Maipo)

[root@localhost etc]# semanage fcontext -l |grep zabbix
/var/log/zabbix.*                                  all files          system_u:object_r:zabbix_log_t:s0 
/etc/zabbix/web(/.*)?                              all files          system_u:object_r:httpd_sys_rw_content_t:s0 
/var/lib/zabbix(/.*)?                              all files          system_u:object_r:zabbix_var_lib_t:s0 
/var/run/zabbix(/.*)?                              all files          system_u:object_r:zabbix_var_run_t:s0 
/etc/rc\.d/init\.d/(zabbix|zabbix-server)          regular file       system_u:object_r:zabbix_initrc_exec_t:s0 
/var/lib/zabbixsrv(/.*)?                           all files          system_u:object_r:zabbix_var_lib_t:s0 
/usr/lib/zabbix/externalscripts(/.*)?              all files          system_u:object_r:zabbix_script_exec_t:s0 
/var/lib/zabbix/externalscripts(/.*)?              all files          system_u:object_r:zabbix_script_exec_t:s0 
/usr/bin/zabbix_server                             regular file       system_u:object_r:zabbix_exec_t:s0 
/usr/bin/zabbix_agentd                             regular file       system_u:object_r:zabbix_agent_exec_t:s0 
/usr/sbin/zabbix_proxy                             regular file       system_u:object_r:zabbix_exec_t:s0 
/usr/sbin/zabbix_agentd                            regular file       system_u:object_r:zabbix_agent_exec_t:s0 
/usr/sbin/zabbix_server                            regular file       system_u:object_r:zabbix_exec_t:s0 
/usr/sbin/zabbix_proxy_mysql                       regular file       system_u:object_r:zabbix_exec_t:s0 
/usr/sbin/zabbix_proxy_pgsql                       regular file       system_u:object_r:zabbix_exec_t:s0 
/usr/sbin/zabbix_server_mysql                      regular file       system_u:object_r:zabbix_exec_t:s0 
/usr/sbin/zabbix_server_pgsql                      regular file       system_u:object_r:zabbix_exec_t:s0 
/etc/rc\.d/init\.d/zabbix-agentd                   regular file       system_u:object_r:zabbix_agent_initrc_exec_t:s0 
/usr/sbin/zabbix_proxy_sqlite3                     regular file       system_u:object_r:zabbix_exec_t:s0 
/usr/sbin/zabbix_server_sqlite3                    regular file       system_u:object_r:zabbix_exec_t:s0 

おすすめ記事