tech:notes_selinux
Ceci est une ancienne révision du document !
Table des matières
Notes SELinux
Voir :
- ausearch
- SEtroubleshoot
Autoriser avec audit2allow
sudo cat /var/log/audit/audit.log | grep AVC | grep denied | audit2why > audit2why.txt sudo cat /var/log/audit/audit.log | grep AVC | grep denied | audit2allow > audit2allow.txt
/usr/bin/audit2allow -a -M plop
Restaurer les autorisations SELinux
# Voir les différences restorecon -nv /etc/passwd # Les remettre restorecon -v /etc/passwd # Exemple restorecon -v /usr/sbin/httpd restorecon -v /etc/ld.so.cache restorecon -v /etc/hosts
Au démarrage du système
touch /.autorelabel
Réétiquetés les fichiers lors du prochain redémarrage
Cela crée le fichier /.autorelabel contenant l'option -F
fixfiles -F onboot
Passez toujours en mode permissif avant d'entrer dans la commande fixfiles -F onboot. Cela permet d'éviter que le système ne démarre pas s'il contient des fichiers non étiquetés. Pour plus d'informations, voir RHBZ#2021835.
Voir aussi /etc/selinux/restorecond.conf qui contient les chemins des fichiers à restaurer
En vrac
ls -z ps -eZ sestatus setenforce 0 getenforce semanage login -l chcon seinfo audit2allow
semodule --list-modules=full chcon system_u:object_r:bin_t /opt/nagios/agent/nrpe chcon -t sudo_exec_t /usr/bin/sudo
grep -w 'denied.*insights-client.*permissive=0' /var/log/audit/audit.log
Serveur Web
setsebool -P httpd_can_network_connect 1
Pb Exemple
Err Permission denied
Before:
# ls -lZ /opt/plop/plop/plop.jar -rwxrwxrwx. 1 app_plop appgrp unconfined_u:object_r:unlabeled_t:s0 61558236 Feb 26 2023 /opt/plop/plop/plop.jar
After:
# ls -lZ /opt/plop/plop/plop.jar -rwxrwxrwx. 1 app_plop appgrp unconfined_u:object_r:bin_t:s0 61558236 Feb 26 2023 /opt/plop/plop/plop.jar
Service SystemD
chmod 640 /usr/local/lib/systemd/system/plop.service restorecon -v /usr/local/lib/systemd/system/plop.service systemctl daemon-reload chcon system_u:object_r:bin_t:s0 /tools/list/plop/ctmagt/ctm/scripts/start-ag chcon system_u:object_r:bin_t:s0 /tools/list/plop/ctmagt/ctm/scripts/shut-ag
Containers
DEFAULT_CONTAINER_RUN_OPTIONS = ['--network', 'slirp4netns:enable_ipv6=true', '--security-opt', 'label=disable']
Voir : https://ansible.readthedocs.io/projects/awx/en/24.6.1/administration/instances.html
Autres
Voir :
- sealert
tech/notes_selinux.1758920520.txt.gz · Dernière modification : de Jean-Baptiste
