Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


admin_grundlagen:selinux_-_webserver_inhalte_freigeben

Dies ist eine alte Version des Dokuments!


Voraussetzungen

HTML Datei im Zielverzeichnis anlegen

cd /var/www/html/
id -Z
ls -dZ .
matchpathcon .

→ Type: httpd_sys_content_t

test.html
<html>
  <head>
    <title>Hello SELinux!</title>
  </head>
  <body>
    Hello SELinux
  </body>
</html>
ls -Z test.html

→ Type: httpd_sys_content_t, Webserver kann darauf zugreifen

HTML Datei im Heimatverzeichnis anlegen

als root:

cd
id -Z
ls -dZ .
matchpathcon .

→ Type: admin_home_t

test.html
<html>
  <head>
    <title>Hello SELinux!</title>
  </head>
  <body>
    Hello SELinux
  </body>
</html>
ls -Z test.html

→ Type: admin_home_t

mv test.html /var/www/html

→ Webserver kann nicht darauf zugreifen

SELinux file type korrigieren

setroubleshootd

Wenn zum Zeitpunkt des Zugriffs setroubleshootd aktiviert ist, gibt es hier Hilfe:

journalctl -f _COMM=setroubleshootd

SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/test.html

auditd

Wenn zum Zeitpunkt des Zugriffs der auditd läuft:

ausearch -m avc -c httpd

denied { getattr } … comm=„httpd“ path=„/var/www/html/test.html“ … tcontext=…admin_home_t

chcon

chcon -t httpd_sys_content_t /var/www/html/test.html

oder

chcon --reference /var/www/html /var/www/html/test.html

restorecon

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-Shell1) 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

admin_grundlagen/selinux_-_webserver_inhalte_freigeben.1542065830.txt.gz · Zuletzt geändert: 2018/11/12 23:37 von ingo_wichmann