SELinux

Last-modified: 2013-10-21 (月) 12:02:18

概要

SELinuxはファイルやプロセスに対して「コンテキスト」と呼ばれる属性を付している
SELinuxはコンテキストを利用してアクセス制御を行っている
制御は「Targeted ポリシー」というルールに基づいて設定されている。
ポリシーを自作することもできる
  1. confrim SELinux enable
    /usr/sbin/getenforce
Enforcing
  1. confirm context ※-Z オプションで確認
    ls -IZ ~
drwxr-xr-x. user user unconfined_u:object_r:user_home_t:s0 Desktop
drwxrwxr-x. user user unconfined_u:object_r:user_home_t:s0 dev
drwxr-xr-x. user user unconfined_u:object_r:user_home_t:s0 Documents
drwxr-xr-x. user user unconfined_u:object_r:user_home_t:s0 Downloads
drwxr-xr-x. user user unconfined_u:object_r:audio_home_t:s0 Music
drwxr-xr-x. user user unconfined_u:object_r:user_home_t:s0 Pictures
drwxr-xr-x. user user unconfined_u:object_r:user_home_t:s0 Public
                      ユーザ      :ロール  :タイプ      :MLS レベル
※タイプはプロセスの場合「ドメイン」とも言う
※MLS (Multi Level Security)

ツール

  1. install policycoreutils-python (For CUI)
    SELinux の制御を設定できるsemanageをインストール 
    policycoreutils-python package に含まれるためインストール
sudo yum -y install policy-python
Dependency Installed:
audit-libs-python.x86_64 0:2.2-2.el6               libcgroup.x86_64 0:0.37-7.2.el6_4
libsemanage-python.x86_64 0:2.0.43-4.2.el6         setools-libs.x86_64 0:3.3.7-4.el6
setools-libs-python.x86_64 0:3.3.7-4.el6
Complete!
semanage --help
  1. install policycoreutils-gui (For GUI)
    SELinuxManagement はpolicycoreutils-gui packageに含まれるためインストール
sudo yum -y install policy-python
Dependency Installed:
gnome-python2-gtkhtml2.x86_64 0:2.25.3-20.el6         gtkhtml2.x86_64 0:2.11.1-7.el6
setools-console.x86_64 0:3.3.7-4.el6
Complete!
システム>管理>SELinuxManagement

調整

  1. boolean
    セキュリティ項目毎にenable disableを切り替える
  1. Process Domain
    CentOS6 からはプロセスタイプ(プロセスドメイン)毎にSELinuxの有効・無効を制御できる

SELinuxによるトラブルシューティング

  1. SELinuxのenable disable
    SELinux をinstallしてアプリケーションが正常動作しなくなった場合の
    SELinuxの正常無効化
sudo vi /etc/selinux/config
6 #     disabled - No SELinux policy is loaded.
7 SELINUX=enforcing
     ↓
7 SELINUX=disable
reboot OS
  1. SELinux のポリシー

実例