Show Table of Contents
5.9.2. デフォルトコンテキストの変更
「file_t および default_t タイプ」 の説明にあるように、拡張属性をサポートするファイルシステムでは、ディスク上に SELinux コンテキストがないファイルにアクセスがあった場合、SELinux ポリシーが定義するデフォルトのコンテキストを持っているものとして扱われます。共通ポリシーでは、このデフォルトのコンテキストは
file_t タイプを使います。別のデフォルトコンテキストが望ましい場合は、defcontext オプションでファイルシステムをマウントします。
以下の例は、(
/dev/sda2 上の) 新規作成ファイルを新規作成の /test/ ディレクトリーにマウントします。ここでは、/test/ ディレクトリーを定義するルールが /etc/selinux/targeted/contexts/files/ にないことを前提としています。
~]# mount /dev/sda2 /test/ -o defcontext="system_u:object_r:samba_share_t:s0"
この例では、
- マウントされると、ファイルシステムの root ディレクトリー (
/test/) は、defcontextが指定するコンテキストでラベル付けされたかのように扱われます (このラベルはディスク上で保存されない)。これは、/test/下で作成されたファイルのラベリングに影響します。新規作成ファイルはsamba_share_tタイプを継承し、これらのラベルはディスク上で保存されます。 defcontextオプションでファイルシステムがマウントされる間に/test/下で作成されたファイルは、そのラベルを保持します。
[10]
Morris, James. "Filesystem Labeling in SELinux". Published 1 October 2004. Accessed 14 October 2008: http://www.linuxjournal.com/article/7426.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.