SELunxの設定をします。
CentOS7ではSELinuxはデフォルトで有効の設定になっています。無効にする場合は /etc/sysconfig/selinux を変更します。
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
SELINUX=enforcing を SELINUX=disabled に変更します。
getenforce コマンドを実行し、SELinuxの動作状態を確認します。コマンドを実行し、"Enforcing"が表示される場合はSELinuxが起動しています。
サーバー系のサービスを動作させる場合は、SELinuxによりディスクへの書き込みがブロックされることがあるため、SELinuxを無効にしておいたほうが良い場合があります。
CentOS6.5ではSELinuxはデフォルトで常に起動する設定になっており、GUIでの設定が無いため、無効にする場合は、設定ファイルを変更します。
getenforce コマンドを実行し、SELinuxの動作状態を確認します。コマンドを実行し、"Enforcing"が表示される場合はSELinuxが起動しています。
エディタで /etc/sysconfig/selinux ファイルを開き編集します。
設定ファイル中の"SELINUX=enforcing"の部分を"SELINUX=disabled"に書き換えます。
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
マシンを再起動します。起動後、getenforceコマンドを実行します。SELinuxの動作が停止していれば、"Disabled"が表示されます。
CentOS6では、たいていのプログラムはSELinuxが有効であっても正常に動作しますので、設定を変更するケースは少ないです。
また、/etc/grab.conf ファイルの変更も必要無いようです。
メニューの[システム]>[管理]>[セキュリティレベルとファイアウォールの設定]をクリックします。
セキュリティレベルの設定ダイアログが開きます。
[SELinux]タブをクリックします。
SELinux設定のコンボボックスを開き変更したいレベルを選択します。
コンボボックスで変更したいレベルを選択後[適用]または[OK]ボタンをクリックします。
GUIで設定を変更した場合、変更後に起動できなくなる場合があります。起動できなくなった場合はこちらの記事を参照してください。
設定ファイルを編集する場合は/etc/selinux/configファイルを編集します
となっている部分を
と変更することでSELinuxの設定を変更できます。
/etc/selinux/configファイルの修正のみでは、再起動時にkernel panicになる場合があります。
/etc/grab.conf の修正も必要です。
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_shouji-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-220.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_shouji-lv_root rd_NO_LUKS rd_NO_MD quiet rhgb crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=jp106 rd_LVM_LV=vg_shouji/lv_swap LANG=ja_JP.UTF-8 rd_NO_DM rd_LVM_LV=vg_shouji/lv_root
initrd /initramfs-2.6.32-220.el6.x86_64.img
kernel の起動オプションの末尾に "selinux=0"を追加します。
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_shouji-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-220.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_shouji-lv_root rd_NO_LUKS rd_NO_MD quiet rhgb crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=jp106 rd_LVM_LV=vg_shouji/lv_swap LANG=ja_JP.UTF-8 rd_NO_DM rd_LVM_LV=vg_shouji/lv_root selinux=0
initrd /initramfs-2.6.32-220.el6.x86_64.img