時刻の同期-SELinuxでのラベル付とポリシー
Windowsクライアントの時刻同期のポリシーをセット
# chcon -u system_u -t ntpd_t /usr/local/samba/var/lib/ntp_signd
ポリシーを永続的にする
# semanage -a -t ntpd_t "/usr/local/samba/var/lib/ntp_signd"
変更を確認
# cat /etc/selinux/targeted/contexts/files/file_contexts.local
次のような行が表示されます:
/usr/local/samba/var/lib/ntp_signd system_u:object_r:ntpd_t:s0
以下のポリシーファイルは、RHEL 6.5の4.1.6に基づいており、参照用にしてください。 ベースポリシーファイルを作成した後は、常に以下のegrepコマンドを実行してください。 その後、システム上でntpdとSamba ADサービスを停止/起動し、競合するまで基本ポリシーに追加します。
egrep "samba|ntpd" /var/log/audit/audit.log | audit2allow
すべてがうまくいけば、ポリシーファイルの下の各 "allow"行にこれが表示されます。
#!!! This avc is allowed in the current policy allow ntpd_t self:capability sys_admin; etc.
samba4.te ポリシー:
module samba4 1.0;
require {
type ntpd_t;
type usr_t;
type initrc_t;
type fs_t;
type setfiles_t;
type lib_t;
type unconfined_t;
type locate_t;
class dir write;
class dir search;
class dir open;
class dir read;
class dir getattr;
class dir remove_name;
class dir add_name;
class dir relabelto;
class unix_stream_socket connectto;
class sock_file write;
class sock_file create;
class sock_file unlink;
class filesystem associate;
class capability sys_admin;
}
#============= initrc_t ==============
allow initrc_t ntpd_t:dir { write remove_name add_name };
allow initrc_t ntpd_t:sock_file create;
allow initrc_t ntpd_t:sock_file unlink;
#============= ntpd_t ==============
allow ntpd_t usr_t:sock_file write;
allow ntpd_t initrc_t:unix_stream_socket connectto;
allow ntpd_t fs_t:filesystem associate;
allow ntpd_t lib_t:sock_file write;
allow ntpd_t unconfined_t:unix_stream_socket connectto;
allow ntpd_t self:sock_file write;
allow ntpd_t self:capability sys_admin;
#============= locate_t ==============
allow locate_t ntpd_t:dir { read getattr open search };
#============= setfiles_t ==============
allow setfiles_t ntpd_t:dir relabelto;
ポリシーの確認と読み込み:
$ checkmodule -M -m -o samba4.mod samba4.te $ semodule_package -o samba4.pp -m samba4.mod $ semodule -i samba4.pp