RHEL 7 – RHCSA ノート (チート シート)
SELinux モード
SELinux は、システム内のリソースに追加のセキュリティ レイヤーを提供します。 DAC (任意アクセス制御) とは対照的に、MAC (強制アクセス制御) を提供します。 SELinux モードの設定に入る前に、さまざまな SELinux 操作モードとは何か、およびそれらがどのように機能するかを見てみましょう。 SELinux は 3 つのモードのいずれかで動作できます:
<強い>1.強制 :ポリシーに反するアクションはブロックされ、対応するイベントが監査ログに記録されます。
2.許容 :ポリシーに反するアクションは、監査ログにのみ記録されます。
3.無効 :SELinux は完全に無効になっています。
構成ファイル
SELinux 構成ファイル /etc/selinux/config :
# cat /etc/selinux/config # 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 モードの切り替え (一時的)
SELinux モードを一時的に切り替えるには、以下に示すように setenforce コマンドを使用できます。
# setenforce [ Enforcing | Permissive | 1 | 0 ]
0 –> 許容
1 –> 強制
SELinux の現在のモードを確認してください:
# getenforce Enforcing
または、sestatus コマンドを使用して詳細なステータスを取得することもできます:
# sestatus SELinux status: enabled SELinuxfs mount: /selinux --> virtual FS similar to /proc Current mode: enforcing --> current mode of operation Mode from config file: permissive --> mode set in the /etc/sysconfig/selinux file. Policy version: 24 Policy from config file: targeted
SELinux モードの切り替え (永続的) [再起動が必要]
SELinux モードは、次のいずれかの方法で永続的に設定できます:
1. /etc/selinux/config ファイルの編集
2.カーネル起動オプションの編集
1. /etc/selinux/config ファイルの編集
SELinux を permissive に設定するには、ファイル /etc/selinux/config 内の以下の行を :
に設定します。vi /etc/selinux/config .... SELINUX=permissive ...
同様に、同じ行でモードを設定することにより、モードを強制/無効に設定できます。
2.カーネル起動オプションの編集
カーネル ブート行を編集し、enforcing=0 を追加します カーネルの起動オプションに。例:
title Red Hat Enterprise Linux AS (2.6.9-42.ELsmp) root (hd0,0) kernel /vmlinuz-2.6.9-42.ELsmp ro root=LABEL=/ rhgb quiet enforcing=0 initrd /initrd-2.6.9-42.ELsmp.img
サーバーを再起動します。
# shutdown -r now
モード変更時の強制再起動
selinux モードの変更時に強制的に再起動できます:
# setsebool secure_mode_policyload on