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
модуль_selinux [2020/04/09 11:13]
val [Отключение]
модуль_selinux [2024/04/26 14:33] (current)
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-агент]] +  * [[https://habr.com/ru/companies/otus/articles/460387/|Руководство для начинающих ​по SELinux]]
- +
-  ​* [[https://docs.fedoraproject.org/ru-RU/Fedora/13/html/Security-Enhanced_Linux/index.html|Security-Enhanced Linux. Linux с улучшенной безопасностью]]+
   * [[https://​www.opennet.ru/​base/​sec/​selinux_setup.txt.html|Настройка и использование SELinux (selinux limit security linux mac acl)]]   * [[https://​www.opennet.ru/​base/​sec/​selinux_setup.txt.html|Настройка и использование SELinux (selinux limit security linux mac acl)]]
   * [[https://​www.ibm.com/​developerworks/​ru/​library/​l-se_linux_01/​index.html|Часть 1. SELinux - история появления,​ архитектура и принципы работы]]   * [[https://​www.ibm.com/​developerworks/​ru/​library/​l-se_linux_01/​index.html|Часть 1. SELinux - история появления,​ архитектура и принципы работы]]
-  * [[https://​wiki.centos.org/​TipsAndTricks/​SelinuxBooleans|SELinux Booleans]]+
   * [[https://​www.server-world.info/​en/​note?​os=CentOS_7&​p=selinux&​f=11|SELinux : Use sesearch]]   * [[https://​www.server-world.info/​en/​note?​os=CentOS_7&​p=selinux&​f=11|SELinux : Use sesearch]]
-  * [[http://​hansenroy.com/​selinux-run-a-command-or-script-in-a-specific-context/​|SELinux:​ Run a command or script in a specific context]] 
  
  
-<​code>​ 
-# sestatus 
  
-yum install policycoreutils-python+<​code>​ 
 +sestatus ​-v
  
-man semanage +id -Z
-</​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 37: Line 31:
 # mv /​root/​index.html /​var/​www/​html/​index.html # mv /​root/​index.html /​var/​www/​html/​index.html
 # ls -Za /​var/​www/​html/​ # ls -Za /​var/​www/​html/​
 +
 # 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
 +# sealert -a /​var/​log/​audit/​audit.log
 +
 +# 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://​access.redhat.com/​documentation/​ru-ru/​red_hat_enterprise_linux/​5/​html/​deployment_guide/​rhlcommon-section-0085|50.2.11. Running a Command in a Specific Security Context]] 
 +  * [[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]]+ 
 +  * [[https://​wiki.centos.org/​TipsAndTricks/​SelinuxBooleans|SELinux Booleans]] 
 +  * [[https://​serverfault.com/​questions/​666045/​zabbix-server-selinux-policy|Zabbix server SELinux policy]]
  
 <​code>​ <​code>​
-# runcon -t inetd_child_t -r system_r -u system_u cat /​etc/​passwd +# semanage boolean -l | grep zabbix
-# runcon -t httpd_t -r system_r -u system_u cat /​etc/​passwd +
-</​code><​code>​ +
-# semanage boolean -l+
 ... ...
-httpd_can_connect_ldap+ 
 +или 
 + 
 +# getsebool -a | grep zabbix
 ... ...
 +
 +# setsebool -P httpd_can_connect_zabbix on
 </​code>​ </​code>​
 +
 +===== Аудит SELinux Policy утилитой sesearch =====
 +
 +  * [[https://​www.lisenet.com/​2019/​auditing-the-selinux-policy-with-sesearch/​|Auditing the SELinux Policy with sesearch]]
 +
 +<​code>​
 +# yum install -y setools-console
 +
 +# sesearch --allow | tee se_allow.txt
 +...
 +allow sshd_t ssh_port_t:​tcp_socket name_bind;
 +...
 +allow httpd_t zabbix_port_t:​tcp_socket name_connect;​ [ httpd_can_connect_zabbix ]:True
 +...
 +</​code>​
 +
 ===== Разработка модулей ===== ===== Разработка модулей =====
  
модуль_selinux.1586420012.txt.gz · Last modified: 2020/04/09 11:13 by val