第8章 SELinux の有効化
Red Hat Gluster Storage 3.x にアップグレードした後に、以下で SELinux サポートについて説明されている手順に従います。この手順は必須ではなく、SELinux サポートが必要な場合にのみ必要になります。
この手順は、selinux-policy-targeted、selinux-policy、libselinux、Red Hat Enterprise Linux 8(RHEL 8)のpython3-libselinuxパッケージが提供するlibselinux-python、libselinux-utils、policycoreutils、RHEL8のpolicycoreutils-python-utils および python3-policycoreutilsに置き換えられるpolicycoreutils-python、setroubleshoot、setroubleshoot-server、setroubleshoot-pluginsパッケージがインストールされます。パッケージがインストールされていることを確認するには、以下のコマンドを使用します。
# rpm -q package_name
重要
システムが最初に SELinux(とくに selinux-policy パッケージ) なしでインストールされている場合は、SELinux を有効にするために追加の手順が必要になります。システムの起動時に SELinux が初期化されるようにするには、
dracut
ユーティリティーを実行して、SELinux を initramfs
ファイルシステムに認識させる必要があります。そうしない場合には、SELinux はシステムの起動時に起動しません。
- SELinux を有効にする前に、ファイルシステムの各ファイルに SELinux コンテキストでラベル付けする必要があります。その前に、制限のあるドメインではアクセスが拒否され、システムが正常に起動しなくなる可能性があります。これを防ぐには、
/etc/selinux/config
でSELINUX=permissive
を設定します。# 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=permissive # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection SELINUXTYPE=targeted
- Linux の root ユーザーとして、システムを再起動します。次回の起動時に、ファイルシステムにラベルが付けられます。ラベルプロセスでは、各ファイルに SELinux コンテキストのラベルを付けます。
*** Warning -- SELinux targeted policy relabel is required. *** Relabeling could take a very long time, depending on file *** system size and speed of hard drives. ****
一番下の行にある * (アスタリスク)文字は、ラベル付けされている 1000 ファイルを表します。上記の例では、4 つの * 文字は 4000 ファイルにラベルが付けられていることを表します。すべてのファイルにラベルを付けるのにかかる時間は、システムのファイル数とハードドライブの速度によって異なります。最新のシステムでは、このプロセスに 10 分程度かかる場合があります。 - Permissive モードでは、SELinux ポリシーは実行されませんが、Enforcing モードで拒否された可能性のあるアクションについての拒否メッセージがログに記録されます。Linux の root ユーザーとして Enforcing モードに切り換える前に、以下のコマンドを実行して、SELinux が最後の起動時にアクションを拒否していないことを確認します。
# grep "SELinux is preventing" /var/log/messages
SELinux が最後の起動時にアクションを拒否しなかった場合、このコマンドは出力を返しません。 - /var/log/messages に拒否メッセージがない場合は、/etc/selinux/config に SELINUX=enforcing を設定します。
# 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
- システムを再起動します。再起動後に、getenforce が Enforcing を返すことを確認します。
~]$ getenforce Enforcing
REHL 7 での SELINUX の状態およびモードの変更についての詳細は、『『SELinux User's and Adminstrator's Guide』』の「『Permanent Changes in SELINUX States and Modes』」を参照してください。
REHL 8 での SELINUX のステータスおよびモードの変更に関する詳細は、『『Using SELinux』』の「『Permanent Changes in SELINUX States and Modes』」を参照してください。