SELinux
開発環境なので筆者は設定をオフにしています。
設定を反映するにはリブートが必要です。
現状確認
[root@momonga ~]# getenforce
Permissive
設定変更
[root@momonga ~]# vi /etc/selinux/config
変更内容
22c22
< SELINUX=enforcing
---
> SELINUX=disabled
設定反映
OS再起動で反映します
[root@momonga ~]# reboot
設定確認
[root@momonga ~]# getenforce
Disabled
とはいえ、運用で知識が必要になることもあるかもなので
SELinuxとは
Security-Enhanced Linux (SELinux) は、アメリカ国家安全保障局 (NSA) がGPL下で提供している、Linuxのカーネルに強制アクセス制御 (MAC) 機能を付加するモジュールの名称。
Wikipedia
監査ログ
[root@momonga ~]# ausearch -m avc
lsコマンドでファイルのポリシーを表示
ls コマンドの Z オプション(--context)で各ファイルのSELinuxセキュリティコンテキストを表示
[root@momonga ~]# ls -laZ /var/www/html/
total 16
drwxr-xr-x. 2 momonga wheel unconfined_u:object_r:usr_t:s0 77 Jun 20 23:41 .
drwxr-xr-x. 12 momonga wheel unconfined_u:object_r:usr_t:s0 4096 Jul 6 18:00 ..
-rw-r--r--. 1 momonga wheel unconfined_u:object_r:usr_t:s0 0 Jun 20 23:41 favicon.ico
-rw-r--r--. 1 momonga wheel unconfined_u:object_r:usr_t:s0 603 Jun 20 23:41 .htaccess
-rw-r--r--. 1 momonga wheel unconfined_u:object_r:usr_t:s0 468 Jun 20 23:41 index.php
-rw-r--r--. 1 momonga wheel unconfined_u:object_r:usr_t:s0 24 Jun 20 23:41 robots.txt
/var/www/ 以下のセキュリティポリシー?を確認
[root@momonga ~]# grep -R '/var/www' /etc/selinux/targeted/
/etc/selinux/targeted/contexts/files/file_contexts:/var/www(/.*)? system_u:object_r:httpd_sys_content_t:s0
ファイル・フォルダのセキュリティコンテキストの是正
とりあえず、コマンドの紹介だけ
個別に実行する場合: chcon
まとめて実行する場合: restorecon