Я хотел бы начать с того, что не будет никакой реальной проблемы, и все работает так, как я ожидал, однако я испытываю странное поведение, которое я не могу объяснить, поэтому, чтобы получить представление о более опытных инженерах ,SELinux fcontext после svn checkout
Нечетное поведение наблюдается с тем, как SELinux применяет определения отображения контекста.
Позволь мне начать печать fcontext политики SELinux, которая относится к моему делу:
[[email protected] wp-content]# semanage fcontext -l | grep "^/var/www.*httpd_sys_rw_content_t:s0\s$"
/var/www/svn(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/html(/.*)?/uploads(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/html(/.*)?/wp-content(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/html(/.*)?/sites/default/files(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/html(/.*)?/sites/default/settings\.php regular file system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/moodledata(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/moodle/data(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/gallery/albums(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/html/owncloud/data(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/html/configuration\.php all files system_u:object_r:httpd_sys_rw_content_t:s0
Как вы можете видеть из команды, я заинтересован в fcontext политики, позволяющей HTTPD писать внутри /вар/WWW ,
Я настройка WordPress установки, так что мои глаза запирать на этой политике:
/var/www/html(/.*)?/uploads(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/var/www/html(/.*)?/wp-content(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
С RegExp политики я могу desifer, что структура директорий мне нужно иметь. Давайте создадим каталог для проекта и checkout.
[[email protected] /]# mkdir -p /var/www/html/sun
[[email protected] /]# cd /var/www/html/sun
[[email protected] sun]# svn co http://server/ .
Давайте посмотрим, если мы правы fcontext применяются:
[[email protected] sun]# cd /var/www/html/sun/public/wp-content
[[email protected] wp-content]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 index.php
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 languages
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 mu-plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 themes
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 uploads
Отлично! Просто для интереса и перепроверить, давайте попробуем восстановить fcontext и посмотреть, что происходит:
[[email protected] wp-content]# restorecon -Rv /var/www/html/sun/
[[email protected] wp-content]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 index.php
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 languages
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 mu-plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 themes
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 uploads
Отлично! Работает так, как ожидалось.
Чтобы закончить тест, давайте моделируем ожидаемый сбой. Давайте создадим каталог проекта за пределами /html/, как здесь: /var/www/sun и выписка.
[[email protected] wp-content]# mkdir -p /var/www/sun
[[email protected] wp-content]# cd /var/www/sun/
[[email protected] sun]# svn co http://server/ .
Давайте посмотрим, если мы правы fcontext применяются:
[[email protected] sun]# cd /var/www/sun/public/wp-content/
[[email protected] wp-content]# ls –Z
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.php
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 languages
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 mu-plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 themes
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 uploads
Странно, я ожидал увидеть httpd_sys_content_t (по умолчанию fcontext), давайте попробуем восстановить по умолчанию:
[[email protected] wp-content]# restorecon -Rv /var/www/sun
...Output omitted
[[email protected] wp-content]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.php
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 languages
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 mu-plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 plugins
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 themes
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 uploads
Использование restorecon для /var/www/sun работает, как и ожидалось, однако ... головоломка:
Почему svn co inside/var/www/sun использовали не существующие политики? Матч политика fcontext, но не место для этого:
/var/www/html(/.*)?/wp-content(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
Как индекс.PHP имеет differect fcontext, но каталоги имеют то же самое: httpd_sys_rw_content_t