RHEL9 での SELINUX の無効化方法について

◆ Live配信スケジュール ◆
サイオステクノロジーでは、Microsoft MVPの武井による「わかりみの深いシリーズ」など、定期的なLive配信を行っています。
⇒ 詳細スケジュールはこちらから
⇒ 見逃してしまった方はYoutubeチャンネルをご覧ください
【4/18開催】VSCode Dev Containersで楽々開発環境構築祭り〜Python/Reactなどなど〜
Visual Studio Codeの拡張機能であるDev Containersを使ってReactとかPythonとかSpring Bootとかの開発環境をラクチンで構築する方法を紹介するイベントです。
https://tech-lab.connpass.com/event/311864/

こんにちは。サイオステクノロジーの橋本です。

前回 RHEL9 OS をインストールしたのでいろいろ試してみましょう。

RHEL 9 から SELinux の無効化方法が変更となりました。
※そもそも無効化自体安易にするべきではありませんが

具体的に無効化方法がどのように変わったのか見てみましょう。

RHEL 8 での無効化方法

SELINUX を disabled とすることで無効化することが可能です。

ファイル : /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=enforcing
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

RHEL 9 での無効化方法

実機を確認してみて驚いたのですが、設定ファイルは RHEL 9 でもあり。
RHEL 8 同様に設定項目「SELINUX」が存在します。

ファイル : /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.
# See also:
# https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-selinux/#getting-started-with-selinux-selinux-states-and-modes
#
# NOTE: In earlier Fedora kernel builds, SELINUX=disabled would also
# fully disable SELinux during boot. If you need a system with SELinux
# fully disabled instead of SELinux running with no policy loaded, you
# need to pass selinux=0 to the kernel command line. You can use grubby
# to persistently set the bootloader to boot with selinux=0:
#
# grubby --update-kernel ALL --args selinux=0
#
# To revert back to SELinux enabled:
#
# grubby --update-kernel ALL --remove-args selinux
#
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

何も考えずに構築をするとうっかり「SELINUX=disabled」と設定しそうです。

英語で注意書きがしっかり書かれています。
SELINUX の無効化はコメントで書かれているように grubby コマンドで行います。

# grubby --update-kernel ALL --args selinux=0
#
# shutdown -r now

・再起動後

# getenforce
Disabled
#

うっかり /etc/selinux/config を書き換えると OS が起動しなくなる可能性があります。
あくまで可能性であり OS が起動しなくなる可能性は 10~20% 程度なので、
思い出したときになぜか OS が起動しないという事象が発生しえます…

そもそも SELinux の無効化自体が推奨されていませんが、
無効化するときは気を付けてください。

アバター画像
About 橋本 8 Articles
OSS サポートエンジニア。前職ではインフラエンジニアとしてサーバ運用なんかもしていました。現在は検証のため日々サーバを作っては壊す日々です。
ご覧いただきありがとうございます! この投稿はお役に立ちましたか?

役に立った 役に立たなかった

2人がこの投稿は役に立ったと言っています。


ご覧いただきありがとうございます。
ブログの最新情報はSNSでも発信しております。
ぜひTwitterのフォロー&Facebookページにいいねをお願い致します!



>> 雑誌等の執筆依頼を受付しております。
   ご希望の方はお気軽にお問い合わせください!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


質問はこちら 閉じる