SELinux

1.1 SELinuxの状態確認
[root@sv ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted
上記の様にenabledとなっていたら有効になっている。
[root@sv ~]# getenforce
Enforcing
上記の場合もSELinuxが有効

1.2 SELinuxの無効化
[root@sv ~]# vim /etc/selinux/config
#SELINUX=enforcing   ←コメントアウト
SELINUX=disabled   ←追加

1.3 SELinux セキュリティコンテキストの確認
[root@sv ~]# ll -dZ /var/ftp/pub
drwxrwxrwx. root root system_u:object_r:public_content_t:s0 /var/ftp/pub/

1.4 SELinux セキュリティコンテキストの変更
[root@sv ~]# chcon -t public_content_rw_t /var/ftp/pub

1.5 SELinux セキュリティコンテキストの復元
[root@sv ~]# restorecon /var/ftp/pub

1.6 seboolの確認
以下、FTP関連のbool値のみ抜粋
[root@sv ~]# getsebool  -a
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_[[nfs]] --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_use_fusefs --> off
ftpd_use_passive_mode --> off
参考:SELinux Booleans

1.7 seboolの設定
以下、anonymousの書き込み権限を許可(-P オプションは再起動後も有効になるが、実行に時間が掛かるっぽい・・・)
[root@sv ~]# setsebool -P allow_ftpd_anon_write=1

1.8 samba用の設定
selinuxがデフォルト設定の場合はsambaでファイル共有を掛けても、selinuxによりアクセスが制限される。
共有フォルダが/home/shareの場合のselinuxのデフォルトタイプはhome_root_t
[root@sv ~]# ll -dZ /home/share
drwxrwxrwx. nobody nobody unconfined_u:object_r:home_root_t:s0 /home/share
chconによりselinuxのタイプをsamba_share_tに変更する。
[root@sv ~]# chcon -t samba_share_t /home/share -R
drwxrwxrwx. nobody nobody unconfined_u:object_r:samba_share_t:s0 /home/share

1.9 ftp用の設定
ftpのanonymousはSELinuxにより制限を受ける。そのため、セキュリティコンテキストとブール値を変更する。
[root@sv ~]# chcon -t public_content_rw_t /var/ftp/pub
[root@sv ~]# setsebool -P allow_ftpd_anon_write=1
最終更新:2014年08月14日 04:49