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:54] ingo_wichmann [HTML Datei außerhalb des DocumentRoot anlegen] |
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 | ||
| - | |||
| - | |||
| - | ====== PHP Anwendung: Rechte testen ====== | ||
| - | yum install php | ||
| - | service httpd restart | ||
| - | cd /var/www/html/ | ||
| - | id -Z | ||
| - | ls -dZ . | ||
| - | matchpathcon . | ||
| - | -> Type: ''httpd_sys_content_t'' | ||
| - | |||
| - | PHP-Shell((https://github.com/flozz/p0wny-shell)) installieren: (**niemals auf produktiven Systemen**) | ||
| - | 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 | ||
| ====== HTML Datei außerhalb des DocumentRoot anlegen ====== | ====== HTML Datei außerhalb des DocumentRoot anlegen ====== | ||
| <file txt /etc/httpd/conf.d/srv.conf> | <file txt /etc/httpd/conf.d/srv.conf> | ||
| - | Alias /srv /srv/www/html | + | Alias /srv /srv/test |
| - | <Directory /srv/www/html> | + | <Directory /srv/test> |
| Require all granted | Require all granted | ||
| </Directory> | </Directory> | ||
| Zeile 94: | Zeile 79: | ||
| apachectl graceful | apachectl graceful | ||
| - | mkdir -p /srv/www/html/ | + | mkdir -p /srv/test |
| - | chcon --reference /var/www/html /srv/www/html/ | + | ls -dZ /srv/test/ |
| - | matchpathcon /srv/www/html | + | -> Type: ''var_t'' |
| + | chcon --reference /var/www/html /srv/test | ||
| + | ls -dZ /srv/test/ | ||
| -> 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 110: | 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 | ||
| - | |||