muninのズーム機能をSELinuxを有効にした状態で利用する
muninの各グラフはCGIによりズーム表示することができます。2.0.16ではデフォルトで設定されているのですが、2.0.6では少し手を加える必要があります。
環境
手順
ズーム機能の設定
http://d.hatena.ne.jp/pospome/20130221/1361447896 を参考にさせて頂きました。
- munin-cgi がインストールされていない場合はインストールする
- muninの設定ファイル /etc/munin/munin.conf に次の記述がなければ追記する
cgiurl_graph /munin-cgi/munin-cgi-graph
- httpdの設定ファイル /etc/httpd/conf.d/munin.conf に次の記述がない場合は追記する
ScriptAlias /munin-cgi/munin-cgi-graph /var/www/cgi-bin/munin-cgi-graph
- httpdのCGI設定ファイル /etc/httpd/conf.d/munin-cgi.conf がある場合は削除する
- munin-node と httpd を再起動する
SELinuxのポリシーファイルの作成
SELinuxを無効にしておくとグラフが個別に表示され、ズームすることができるのですが、有効にしておくと、グラフが表示されません。setroubleshootパッケージをインストールしておけば、/var/log/audit/audit.logにdeniedが出力されるので、これをもとに、ポリシーファイルを作成します。エラーは次のようなものが出力されます(何度かアクセスエラー+設定を繰り返します)。
type=AVC msg=audit(1374249069.044:764787): avc: denied { search } for pid=31282 comm="munin-cgi-graph" name="munin" dev=sda2 ino=281106 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:munin_var_lib_t:s0 tclass=dir type=AVC msg=audit(1374249989.708:764820): avc: denied { getattr } for pid=32987 comm="munin-cgi-graph" path="/var/lib/munin/datafile.storable" dev=sda2 ino=304179 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:munin_var_lib_t:s0 tclass=file type=AVC msg=audit(1374250204.627:764848): avc: denied { unix_read unix_write } for pid=33159 comm="mysql_network_t" key=1667461225 scontext=unconfined_u:system_r:munin_services_plugin_t:s0 tcontext=system_u:system_r:munin_services_plugin_t:s0 tclass=shm type=AVC msg=audit(1374250438.152:764892): avc: denied { read } for pid=33653 comm="munin-cgi-graph" name="datafile.storable" dev=sda2 ino=304184 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:munin_var_lib_t:s0 tclass=file type=AVC msg=audit(1374250438.158:764893): avc: denied { search } for pid=33653 comm="munin-cgi-graph" name="munin" dev=sda2 ino=281767 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:munin_log_t:s0 tclass=dir type=AVC msg=audit(1374250893.404:765016): avc: denied { open } for pid=34755 comm="munin-cgi-graph" name="datafile.storable" dev=sda2 ino=304185 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:munin_var_lib_t:s0 tclass=file type=AVC msg=audit(1374250893.413:765017): avc: denied { open } for pid=34755 comm="munin-cgi-graph" name="munin-cgi-graph.log" dev=sda2 ino=281111 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=unconfined_u:object_r:munin_log_t:s0 tclass=file type=AVC msg=audit(1374251968.585:765185): avc: denied { ioctl } for pid=36533 comm="munin-cgi-graph" path="/var/lib/munin/datafile.storable" dev=sda2 ino=304179 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:munin_var_lib_t:s0 tclass=file type=AVC msg=audit(1374251102.485:765022): avc: denied { associate } for pid=34814 comm="mysql_innodb_bp" key=1667461225 scontext=unconfined_u:system_r:munin_services_plugin_t:s0 tcontext=system_u:system_r:munin_services_plugin_t:s0 tclass=shm type=AVC msg=audit(1374252419.524:765299): avc: denied { ioctl } for pid=37619 comm="munin-cgi-graph" path="/var/lib/munin/datafile.storable" dev=sda2 ino=304185 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:munin_var_lib_t:s0 tclass=file type=AVC msg=audit(1374252419.540:765300): avc: denied { open } for pid=37619 comm="munin-cgi-graph" name="munin-cgi-graph.log" dev=sda2 ino=281111 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=unconfined_u:object_r:munin_log_t:s0 tclass=file
これをもとに、次のTEファイルを作成します(仮に、munin-cgi-graph-policy.te とします)。
module munin-cgi-graph-policy 1.0; require { type httpd_sys_script_t; type munin_var_lib_t; type munin_services_plugin_t; type munin_log_t; class dir { search }; class file { getattr read open ioctl }; class shm { unix_read unix_write associate }; } allow httpd_sys_script_t munin_var_lib_t:dir { search }; allow httpd_sys_script_t munin_var_lib_t:file { getattr read open ioctl }; allow httpd_sys_script_t munin_log_t:dir { search }; allow httpd_sys_script_t munin_log_t:file { open }; allow munin_services_plugin_t self:shm { unix_read unix_write associate };
作成したらコンパイルして、適用します。
make -f /usr/share/selinux/devel/Makefile semodule -i munin-cgi-graph-policy.pp
セキュリティコンテキストの設定でもっとうまくできないかが今後の課題。