Relabeling a File or Directory
755
-rw-rw-r-- auser auser user_u:object_r:user_home_t 3.html
-rw-rw-r-- auser auser user_u:object_r:user_home_t 4.html
-rw-rw-r-- auser auser user_u:object_r:user_home_t 5.html
-rw-rw-r-- auser auser user_u:object_r:user_home_t index.html
To make these files viewable from a special user public HTML folder, they need to have a type that
httpd
has permissions to read, presuming the Apache HTTP Server is configured for UserDir and the
Boolean value
httpd_enable_homedirs
is enabled.
chcon -R -t httpd_user_content_t public_html/
ls -Z public_html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t 1.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t 2.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t 3.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t 4.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t 5.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t index.html
ls -Z public_html/ -d
drwxrwxr-x auser auser user_u:object_r:httpd_user_content_t public_html/
Tip
If the file has no label, such as a file created while SELinux was disabled in the kernel,
you need to give it a full label with
chcon system_u:object_r:shlib_t foo.so
.
Otherwise, you will receive an error about applying a partial context to an unlabeled file.
Use the
restorecon
command to restore files to the default values according to the policy. There
are two other methods for performing this operation that work on the entire file system:
fixfiles
or
a policy relabeling operation. Each of these methods requires superuser privileges. Cautions against
both of these methods appear in
Section 45.2.2, “Relabeling a File System”
.
The following example demonstrates restoring the default user home directory context to a set of files
that have different types. The first two sets of files have different types, and are being moved into a
directory for archiving. Their contexts are different from each other, and are incorrect for a standard
user's home directory:
ls -Z /tmp/
-rw-rw-r-- auser auser user_u:object_r:tmp_t /tmp/file1
-rw-rw-r-- auser auser user_u:object_r:tmp_t /tmp/file2
-rw-rw-r-- auser auser user_u:object_r:tmp_t /tmp/file3
mv /tmp/{1,2,3} archives/
mv public_html/* archives/
ls -Z archives/
-rw-rw-r-- auser auser user_u:object_r:tmp_t file1
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t file1.html
-rw-rw-r-- auser auser user_u:object_r:tmp_t file2
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t file2.html
-rw-rw-r-- auser auser user_u:object_r:tmp_t file3
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t file3.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t file4.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t file5.html
-rw-rw-r-- auser auser user_u:object_r:httpd_user_content_t index.html
Содержание ENTERPRISE LINUX 5 - VIRTUAL SERVER ADMINISTRATION
Страница 22: ...xxii ...
Страница 28: ......
Страница 36: ...10 ...
Страница 40: ...14 ...
Страница 96: ...70 ...
Страница 116: ...90 ...
Страница 144: ...118 ...
Страница 146: ......
Страница 158: ...132 ...
Страница 165: ...Installing and Removing Packages 139 Figure 11 7 Installing and removing packages simultaneously ...
Страница 166: ...140 ...
Страница 172: ...146 ...
Страница 178: ......
Страница 228: ...202 ...
Страница 264: ...238 ...
Страница 318: ...292 ...
Страница 330: ...304 ...
Страница 388: ...362 ...
Страница 428: ...402 ...
Страница 452: ......
Страница 458: ...432 ...
Страница 476: ...450 ...
Страница 478: ...452 ...
Страница 494: ...468 ...
Страница 498: ...472 ...
Страница 530: ...504 ...
Страница 536: ...510 ...
Страница 544: ...Chapter 36 Log Files 518 Figure 36 7 Log file contents after five seconds ...
Страница 546: ......
Страница 550: ...524 ...
Страница 576: ......
Страница 584: ...558 ...
Страница 608: ......
Страница 776: ...750 ...
Страница 796: ...770 ...
Страница 800: ...774 ...
Страница 804: ......
Страница 806: ...780 ...
Страница 808: ...782 ...
Страница 816: ...790 ...
Страница 820: ...794 ...
Страница 822: ...796 ...
Страница 830: ...804 ...
Страница 836: ...810 ...
Страница 844: ...818 ...
Страница 848: ...822 ...