SELinuxその1 - 使い方

SELinuxの使い方の例。

概要

SELinuxの使い方その1。

使い方

セキュリティコンテキストの見方 兼 ユーザのセキュリティコンテキストを確認する

SELinuxが有効な状態で、id -Zを実行するとユーザのセキュリティコンテキストが確認出来る。

$ id -Z
user_u:system_r:initrc_t:s0

それぞれ左から順番に、ユーザ識別子、ロール識別子、タイプ識別子、MLS識別子を表す。

user_u   ユーザ識別子
system_r ロール識別子
initrc_t タイプ識別子
s0       MLS識別子

プロセスのセキュリティコンテキストを確認する

$ ps -Z
LABEL                             PID TTY          TIME CMD
user_u:system_r:initrc_t:s0       987 pts/1    00:00:00 ps
user_u:system_r:initrc_t:s0     32623 pts/1    00:00:00 bash

ファイルのセキュリティコンテキストを確認する

$ ls -Z
drwxr-xr-x  owner owner system_u:object_r:file_t:s0      Desktop
drwx------  owner owner system_u:object_r:file_t:s0      mail

SELinuxの動作状態を確認する

$ /usr/sbin/getenforce
Enforcing

SELinuxの動作状態を変更する

# setenforce Permissive
# getenforce
Permissive
# setenforce Enforcing
# getenforce
Enforcing

SELinuxを有効/無効にする

/etc/sysconfig/selinuxファイル内のSELINUX=の行を直接編集。変更後はOS再起動。

(有効時の記述1)
SELINUX=enforcing

(有効時の記述2)
SELINUX=permissive

(無効時の記述)
SELINUX=disable

以上



コメント