Show Table of Contents
5.10.5. star を使ったファイルのアーカイビング
star は、デフォルトでは拡張属性を維持しません。SELinux コンテキストは拡張属性に保存されるので、ファイルをアーカイビングするとコンテキストは失われます。star -xattr -H=exustar を使ってコンテキストを維持するアーカイブを作成します。star パッケージはデフォルトではインストールされません。star をインストールするには、yum install star コマンドを Linux root ユーザーで実行します。
以下の例では、SELinux コンテキストを保持する Star アーカイブの作成方法を説明します。
- Linux root ユーザーで
touch /var/www/html/file{1,2,3}コマンドを実行し、3 つのファイルを作成します (file1、file2、file3)。これらのファイルは、/var/www/html/ディレクトリーからのhttpd_sys_content_tタイプを継承します。~]#
touch /var/www/html/file{1,2,3}~]#ls -Z /var/www/html/-rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 file1 -rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 file2 -rw-r--r-- root root unconfined_u:object_r:httpd_sys_content_t:s0 file3 cd /var/www/html/コマンドで/var/www/html/ディレクトリーに移動します。その後、Linux root ユーザーでstar -xattr -H=exustar -c -f=test.star file{1,2,3}コマンドを実行し、test.starという名前の Star アーカイブを作成します。~]#
star -xattr -H=exustar -c -f=test.star file{1,2,3}star: 1 blocks + 0 bytes (total of 10240 bytes = 10.00k).- Linux root ユーザーで
mkdir /testコマンドを実行し、新規ディレクトリーを作成します。そしてchmod 777 /test/コマンドを実行し、全ユーザーに/test/ディレクトリーへの完全アクセスを可能にします。 cp /var/www/html/test.star /test/コマンドを実行し、test.starファイルを/test/ディレクトリーにコピーします。cd /test/コマンドを実行し、/test/ディレクトリーに切り替え、このディレクトリー内でstar -x -f=test.starコマンドを実行して Star アーカイブを抽出します。~]$
star -x -f=test.starstar: 1 blocks + 0 bytes (total of 10240 bytes = 10.00k).ls -lZ /test/コマンドで SELinux コンテキストを表示させます。httpd_sys_content_tタイプが維持されます。-xattr -H=exustarが使われていなければ、default_tに変更されます。~]$
ls -lZ /test/-rw-r--r-- user1 group1 unconfined_u:object_r:httpd_sys_content_t:s0 file1 -rw-r--r-- user1 group1 unconfined_u:object_r:httpd_sys_content_t:s0 file2 -rw-r--r-- user1 group1 unconfined_u:object_r:httpd_sys_content_t:s0 file3 -rw-r--r-- user1 group1 unconfined_u:object_r:default_t:s0 test.star/test/ディレクトリーが不要であれば、Linux root ユーザーでrm -ri /test/コマンドを実行し、ディレクトリーとその中の全ファイルをを削除します。starが不要であれば、Linux root ユーザーでyum remove starコマンドを実行し、パッケージを削除します。
star についての詳細は、star(1) の man ページを参照してください。

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.