Linux-SELinux

under construction




SELinux

commands:

getenforce
SELinux Status abfragen

setenforce [0|1]
0 = Permissive (es wird nur geloggt, nix verboten)
1 = Enforcing
rebootfest eintragen in /etc/selinux/config

ls -lZ
-Z print selinux security context der Dateien
(SELinuxuser:SELinuxRolle:SELinuxType:MLS-Securitylevel)

ps -efZ
-Z print selinux security context der Prozesse
(SELinuxuser:SELinuxRolle:SELinuxType:MLS-Securitylevel)

ss -lntpZ
-Z print security context

ausearch -m avc -ts recent
audit daemon logs tool
-m avc = access vector cache
-ts recent = letzte 10 minuten
-x /usr/sbin/httpd = nur für httpd anzeigen

chcon -R -t /pfad/zu/dir
setzt den security types von dirs und files


restorecon -Rv *
restore file(s) default SELinux security contexts.
chcon änderungen werden rückgängig gemacht (siehe semanage für bootfest)
-R recursive

semanage - SELinux Policy Management tool
z.B.
semanage fcontext -l
alle selinux datenbankeinträge vom Typ file context anzeigen

semanage port -l
alle selinux datenbankeinträge vom Typ network port anzeigen

semanage fcontext -a -t "/pfad/zu/dir_or_file"
fügt eintrag zur SELinux datenbank hinzu (pfad kann regex enthalten)
-a = add
-m = modifizieren eines vorhandenen eintrages
-d = delete

semanage port -a -t ssh_port_t -p tcp 23
fügt port 23/tcp zu type ssh_port_t hinzu
ssh könnte nun auch auf port 23 laufen
-a = add
-m = modifizieren eines vorhandenen eintrages
-d = delete