Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
|
admin_grundlagen:selinux_-_webserver_inhalte_freigeben [2018/11/12 23:50] ingo_wichmann |
admin_grundlagen:selinux_-_webserver_inhalte_freigeben [2019/08/14 09:03] (aktuell) dhoppe |
||
|---|---|---|---|
| Zeile 45: | Zeile 45: | ||
| -> Type: ''admin_home_t'' | -> Type: ''admin_home_t'' | ||
| mv test.html /var/www/html | mv test.html /var/www/html | ||
| - | -> Webserver kann //nicht// darauf zugreifen | + | -> Webserver kann //nicht// darauf zugreifen ((Security Context: //mv// verhält sich anders als //cp//. //mv// behält den Security Context der Quelle, während //cp// den Security Context des Ziels übernimmt.)) |
| ===== SELinux file type korrigieren ===== | ===== SELinux file type korrigieren ===== | ||
| Zeile 62: | Zeile 62: | ||
| oder | oder | ||
| chcon --reference /var/www/html /var/www/html/test.html | chcon --reference /var/www/html /var/www/html/test.html | ||
| + | |||
| + | ((Change Security Context: Bei dem Befehl //chcon// handelt es sich um eine temporäre Lösung, die durch ein Relabling des Filesystem überschrieben wird. Eine dauerhafte Lösung wird mit Hilfe von //semanage// erzielt.)) | ||
| ==== restorecon ==== | ==== restorecon ==== | ||
| restorecon /var/www/html/test.html | restorecon /var/www/html/test.html | ||
| + | ====== HTML Datei außerhalb des DocumentRoot anlegen ====== | ||
| + | <file txt /etc/httpd/conf.d/srv.conf> | ||
| + | Alias /srv /srv/test | ||
| - | ====== PHP Anwendung: Rechte testen ====== | + | <Directory /srv/test> |
| - | yum install php | + | Require all granted |
| - | service httpd restart | + | </Directory> |
| - | cd /var/www/html/ | + | </file> |
| - | id -Z | + | |
| - | ls -dZ . | + | |
| - | matchpathcon . | + | |
| - | -> Type: ''httpd_sys_content_t'' | + | |
| - | PHP-Shell((https://github.com/flozz/p0wny-shell)) installieren: (**niemals auf produktiven Systemen**) | + | apachectl graceful |
| - | wget https://github.com/flozz/p0wny-shell/raw/master/shell.php | + | |
| - | ls -Z shell.html | + | |
| - | -> Type: ''httpd_sys_content_t'', Webserver kann darauf zugreifen | + | |
| - | -> http://localhost/shell.php | + | mkdir -p /srv/test |
| - | + | ls -dZ /srv/test/ | |
| - | ====== HTML Datei außerhalb des DocumentRoot anlegen ====== | + | -> Type: ''var_t'' |
| - | mkdir -p /srv/www/html/ | + | chcon --reference /var/www/html /srv/test |
| - | chcon --reference /var/www/html /srv/www/html/ | + | ls -dZ /srv/test/ |
| - | matchpathcon /srv/www/html | + | |
| -> Type: ''httpd_sys_content_t'' | -> Type: ''httpd_sys_content_t'' | ||
| + | matchpathcon /srv/test/ | ||
| + | -> Type: ''var_t'' (**Achtung!**) | ||
| <file html test.html> | <file html test.html> | ||
| Zeile 100: | Zeile 99: | ||
| </file> | </file> | ||
| - | ls -Z /srv/www/html/test.html | + | ls -Z /srv/test/test.html |
| + | -> Type: ''var_t'', Webserver kann **nicht** darauf zugreifen | ||
| + | chcon --reference /var/www/html /srv/test/test.html | ||
| + | ls -Z /srv/test/test.html | ||
| + | -> Type: ''httpd_sys_content_t'', Webserver kann darauf zugreifen | ||
| + | restorecon -RF /srv/test/ | ||
| + | ls -Z /srv/test/test.html | ||
| + | -> Type: ''var_t'', Webserver kann **nicht** darauf zugreifen | ||
| + | semanage fcontext --add -t httpd_sys_content_t '/srv/test(/.*)?' | ||
| + | restorecon -RF /srv/test/ | ||
| -> Type: ''httpd_sys_content_t'', Webserver kann darauf zugreifen | -> Type: ''httpd_sys_content_t'', Webserver kann darauf zugreifen | ||
| - | |||