User Tools

Site Tools


модуль_selinux

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
модуль_selinux [2020/06/22 13:09]
val [Конфигурация]
модуль_selinux [2020/07/16 14:51]
val [Добавление сетевых портов к типу (домену) контекста безопасности]
Line 4: Line 4:
  
   * [[https://​defcon.ru/​os-security/​1264/​|Знакомимся с SELINUX и пытаемся понять,​ почему Дэн Уолш плачет]]   * [[https://​defcon.ru/​os-security/​1264/​|Знакомимся с SELINUX и пытаемся понять,​ почему Дэн Уолш плачет]]
 +  * [[https://​max-ko.ru/​14-upravlenie-selinux.html|Управление SELinux]]
  
   * [[http://​itstickers.besthw.net/​selinux-%D0%B1%D0%BB%D0%BE%D0%BA%D0%B8%D1%80%D1%83%D0%B5%D1%82-zabbix-%D0%B0%D0%B3%D0%B5%D0%BD%D1%82/​|SELinux блокирует Zabbix-агент]]   * [[http://​itstickers.besthw.net/​selinux-%D0%B1%D0%BB%D0%BE%D0%BA%D0%B8%D1%80%D1%83%D0%B5%D1%82-zabbix-%D0%B0%D0%B3%D0%B5%D0%BD%D1%82/​|SELinux блокирует Zabbix-агент]]
Line 18: Line 19:
 # sestatus # sestatus
  
-yum install policycoreutils-python-utils +id -Z
- +
-# man semanage +
-</​code><​code>​ +
-... +
-semanage {import,​export,​login,​user,​port,​interface,​module,​node,​fcontext,​boolean,​permissive,​dontaudit} +
-</​code><​code>​ +
-# semanage fcontext -l+
 </​code>​ </​code>​
 +
 +===== Установка типов (доменов) контекста безопасности для файловой системы =====
  
   * [[Сервис HTTP#​Установка и запуск сервера Apache]]   * [[Сервис HTTP#​Установка и запуск сервера Apache]]
Line 39: Line 35:
  
 # chcon -v -t httpd_sys_content_t /​var/​www/​html/​index.html # chcon -v -t httpd_sys_content_t /​var/​www/​html/​index.html
 +
 +  или более правильно
  
 # yum install setroubleshoot # yum install setroubleshoot
 # sealert -a /​var/​log/​audit/​audit.log # sealert -a /​var/​log/​audit/​audit.log
-/sbin/restorecon -v /​var/​www/​html/​index.html+ 
 +# yum install policycoreutils-python-utils 
 +# semanage fcontext -l | grep '/var/www' 
 + 
 +restorecon -v /​var/​www/​html/​index.html
 </​code>​ </​code>​
  
-  ​* [[Сервис Firewall#​CentOS]] firewalld+===== Добавление сетевых портов к типу (домену) контекста безопасности ===== 
 + 
 +  ​* [[Сервис Firewall#​CentOS]] firewalld ​(для демонстрации темы можно отключить) 
 +  * [[https://​blog.tinned-software.net/​change-ssh-port-in-centos-with-selinux/​|Change SSH port in CentOS with SELinux]]
  
 <​code>​ <​code>​
 # ps axZ | grep ssh # ps axZ | grep ssh
-yum install setools-console + 
-sesearch ​--allow | grep sshd_t | grep port+ss -tupanZ | grep ssh 
 + 
 +runcon ​-t sshd_t ​-r system_r -u system_u /​usr/​sbin/​sshd -p 2222 -d 
 + 
 +# semanage port -l | grep ssh
  
 # semanage port -a -t ssh_port_t -p tcp 2222 # semanage port -a -t ssh_port_t -p tcp 2222
-# yum install policycoreutils-devel +
-# sepolicy network -a /​usr/​sbin/​sshd+
 # semanage port -d -t ssh_port_t -p tcp 22 # semanage port -d -t ssh_port_t -p tcp 22
 </​code>​ </​code>​
  
-  * [[Сервис XINETD]] +===== Управление разрешениями с использованием boolean =====
-  * [[Средства программирования shell#Web сервер на shell]]+
  
 <​code>​ <​code>​
-# runcon -t inetd_child_t -r system_r -u system_u cat /etc/passwd 
-# runcon -t httpd_t -r system_r -u system_u cat /etc/passwd 
-</​code><​code>​ 
 # semanage boolean -l # semanage boolean -l
 ... ...
модуль_selinux.txt · Last modified: 2024/04/26 14:33 by val