,

SELinuxのドメインを作ってみました。

tracerouteするためにはraw socketにアクセスできないとだめなんですが、SELinuxがオンだとcgiからアクセスできません。ポリシーを追加するだけだとcgiすべてからraw socketにアクセス可能になりますので、tracerouteのみ可能にすべくドメインの追加をして見ました。取り合えず/etc/selinux/targeted/src/policy/domains/program/apache.teに以下のようにドメインの定義を作って

type httpd_sys_traceroute_t, domain;
type httpd_exec_traceroute_t, file_type, exec_type;
role system_r types httpd_sys_traceroute_t;
domain_auto_trans(httpd_sys_script_t, httpd_exec_traceroute_t,httpd_sys_traceroute_t)
uses_shlib(httpd_sys_script_t)

を足して、/bin/tracerouteを/bin/traceroute.cgiにコピーして
.../file_contexts/program/apache.fcに

/bin/traceroute.cgi     --      system_u:object_r:httpd_exec_traceroute_t

を追加
#make file_context/file_context
#/usr/sbin/setfiles file_contexts/file_contexts /bin/traceroute.cgi
でファイルのコンテキストが変わるので、cgiから/bin/traceroute.cgiを呼び出したときのプロセスのドメインが遷移して、httpd_sys_traceroute_tになるようになります。あとはこの新しいドメインにいろいろなアクセス権限を与えてやればよいのです。そのためにまず
#echo 0 > /seclinux/enforce
でpermissiveモードにして
#make reload
で設定を反映。
#audit2allow -d -l
の出力中でhttpd_sys_traceroute_tを含むものをさっきのdomains/programs/apache.teに足してやると動きました。

大体良いはず