star
star
utility does not retain extended attributes by default. Since SELinux contexts are stored in extended attributes, contexts can be lost when archiving files. Use the star -xattr -H=exustar
command to create archives that retain contexts. The star package is not installed by default. To install star
, run the yum install star
command as the root user.
star
archive that retains SELinux contexts:
Procedure 10.23. Creating a star
Archive
file1
, file2
, and file3
) in the /var/www/html/
. These files inherit the httpd_sys_content_t
type from /var/www/html/
:
~]#
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
/var/www/html/
directory. Once in this directory, as root, run the following command to create a star
archive named test.star
:
~]$
cd /var/www/html
html]#
star -xattr -H=exustar -c -f=test.star file{1,2,3}
star: 1 blocks + 0 bytes (total of 10240 bytes = 10.00k).
/test/
, and then allow all users full access to it:
~]#
mkdir /test
~]#
chmod 777 /test/
test.star
file into /test/
:
~]$
cp /var/www/html/test.star /test/
/test/
. Once in this directory, run the following command to extract the star
archive:
~]$
cd /test/
test]$
star -x -f=test.star
star: 1 blocks + 0 bytes (total of 10240 bytes = 10.00k).
httpd_sys_content_t
type has been retained, rather than being changed to default_t
, which would have happened had the -xattr -H=exustar
option not been used:
~]$
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/
directory is no longer required, as root, run the following command to remove it, as well as all files in it:
~]#
rm -ri /test/
star
is no longer required, as root, remove the package:
~]#
yum remove star
star
.