4.4. 権限のない SELinux ユーザーの非標準共有ディレクトリーへのアクセスを管理する
対応する SELinux ファイルタイプを見つけてマッピングすることで、汎用の権限のない SELinux ユーザー user_u
の非標準共有ディレクトリーへのアクセスを設定できます。user_u
ユーザーには、デフォルトのロール user_r
とデフォルトのドメイン user_t
が付与されています。
前提条件
-
selinux-policy-doc
およびsetools-console
パッケージがシステムにインストールされている。
手順
ターミナルで
user_selinux(8)
man ページを開きます。man user_selinux
$ man user_selinux
Copy to Clipboard Copied! MANAGED FILES
セクションで、お客様の状況に合った属性またはタイプを見つけます。たとえば、user_home_type
属性です。オプション: 属性に割り当てられているすべてのタイプをリスト表示するには、
-x
および-a
オプションを指定したseinfo
コマンドを使用します。次に例を示します。seinfo -x -a user_home_type
$ seinfo -x -a user_home_type Type Attributes: 1 attribute user_home_type; … chrome_sandbox_home_t config_home_t cvs_home_t data_home_t dbus_home_t fetchmail_home_t gconf_home_t git_user_content_t …
Copy to Clipboard Copied! 対応するタイプの候補 (この例では
data_home_t
タイプ) を特定したら、その SELinux マッピングを確認します。semanage fcontext -l | grep data_home_t
$ semanage fcontext -l | grep data_home_t … /root/\.local/share(/.*)? all files system_u:object_r:data_home_t:s0 …
Copy to Clipboard Copied! 対応するタイプを、
user_u
からアクセス可能にするディレクトリー (例:/shared-data
) にマップします。semanage fcontext -a -t data_home_t '/shared-data(/.*)?'
$ semanage fcontext -a -t data_home_t '/shared-data(/.*)?'
Copy to Clipboard Copied!
検証
設定したディレクトリーのマッピングを確認します。
semanage fcontext -l | grep "shared-data"
# semanage fcontext -l | grep "shared-data" /shared-data(/.*)? all files system_u:object_r:data_home_t:s0
Copy to Clipboard Copied! -
user_u
SELinux ユーザーにマップされた Linux ユーザーとしてログインし、ディレクトリーにアクセスできることを確認します。