Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
selinux [2019/02/09 22:20] – [Configure non-standard ports] admin | selinux [2024/11/30 11:28] (current) – [Creation of selinux module] admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== SELinux ====== | ====== SELinux ====== | ||
+ | This document applies to Fedora 29. But, all should work on CentOS/REL 7. | ||
===== General ===== | ===== General ===== | ||
+ | Before you can work with all the selinux tools, you must install the following packages first: | ||
+ | <code bash> | ||
+ | dnf -y install python3-policycoreutils policycoreutils-python-utils policycoreutils setroubleshoot-server setools-console libselinux-utils coreutils | ||
+ | </ | ||
==== File contexts ==== | ==== File contexts ==== | ||
Line 230: | Line 234: | ||
</ | </ | ||
- | ===== Proxy ===== | + | ===== Example applications |
+ | |||
+ | ==== Nginx Proxy ==== | ||
* Per default, '' | * Per default, '' | ||
Line 291: | Line 298: | ||
</ | </ | ||
- | ===== HTTP ===== | + | ==== HTTP ==== |
For example the Bolt CMS requires to write files in the in '' | For example the Bolt CMS requires to write files in the in '' | ||
Line 332: | Line 339: | ||
restorecon -R /www | restorecon -R /www | ||
</ | </ | ||
- | |||
- | ==== Configure non-standard ports ==== | ||
- | |||
- | * Example for configuring port 8888 for httpd service:< | ||
- | semanage port -a -t httpd_port_t -p tcp 8888 | ||
- | </ | ||
- | |||
- | ===== Applications ===== | ||
==== Icinga ==== | ==== Icinga ==== | ||
If the icinga service does not start after configuring API, you should check the following: | If the icinga service does not start after configuring API, you should check the following: | ||
- | + | * Check, if port 5665 is allowed:<code bash> | |
- | <code bash> | + | |
semanage port -l | grep 5665 | semanage port -l | grep 5665 | ||
</ | </ | ||
- | + | * If empty, you have to configure it:<code bash> | |
- | If empty, you have to configure it: | + | |
- | + | ||
- | <code bash> | + | |
semanage port -a -t icinga2_port_t -p tcp 5665 | semanage port -a -t icinga2_port_t -p tcp 5665 | ||
</ | </ | ||
- | + | * Check, if port 5665 is allowed:<code bash> | |
- | <code bash> | + | |
semanage port -l | grep 5665 | semanage port -l | grep 5665 | ||
</ | </ | ||
Line 361: | Line 355: | ||
==== Piwik (Matomo) ==== | ==== Piwik (Matomo) ==== | ||
Not yet done ... | Not yet done ... | ||
+ | |||
+ | ==== Configure non-standard ports ==== | ||
+ | If you have an application which has not a standart port definition, you can also define a port for a service. | ||
+ | |||
+ | * Example for configuring port 8888 for httpd service:< | ||
+ | semanage port -a -t httpd_port_t -p tcp 8888 | ||
+ | </ | ||
===== Problems during boot ===== | ===== Problems during boot ===== | ||
Line 381: | Line 382: | ||
* **autorelabel=1** \\ This parameter will force the system to relabel. It does the same thing as “touch / | * **autorelabel=1** \\ This parameter will force the system to relabel. It does the same thing as “touch / | ||
+ | ===== Creation of selinux module ===== | ||
+ | Sometimes not all rules apply to a application. Then, you need to create your own '' | ||
+ | - Get information from ''/ | ||
+ | p=rrdtool; grep ' | ||
+ | module local_rrdtool 1.0; | ||
+ | |||
+ | require { | ||
+ | type httpd_t; | ||
+ | type nagios_var_lib_t; | ||
+ | class file map; | ||
+ | } | ||
+ | |||
+ | # | ||
+ | # src=" | ||
+ | # comm=" | ||
+ | #!!!! This avc can be allowed using the boolean ' | ||
+ | allow httpd_t nagios_var_lib_t: | ||
+ | </ | ||
+ | - Create now the module configuration file *.te:< | ||
+ | p=rrdtool; grep ' | ||
+ | </ | ||
+ | - Check now the syntax of the config file:< | ||
+ | checkmodule -M -m -o local_$p.mod local_$p.te | ||
+ | </ | ||
+ | - Create now the module for selinux:< | ||
+ | semodule_package -o local_$p.pp -m local_$p.mod | ||
+ | </ | ||
+ | - Activate the module and copy it to ''/ | ||
+ | semodule -v -i local_$p.pp | ||
+ | Attempting to install module ' | ||
+ | Ok: return value of 0. | ||
+ | Committing changes: | ||
+ | Ok: transaction number 21. | ||
+ | |||
+ | cp local_$p.pp / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | It's a good idea to use a prefix for the module name (in my case: '' | ||
+ | </ | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | If you want to create a module for more than one binary (because they are part of an application), | ||
+ | </ | ||
+ | |||
+ | ===== States of selinux ===== | ||
+ | |||
+ | * State of '' | ||
+ | sestatus | ||
+ | SELinux status: | ||
+ | SELinuxfs mount: | ||
+ | SELinux root directory: | ||
+ | Loaded policy name: | ||
+ | Current mode: | ||
+ | Mode from config file: permissive | ||
+ | Policy MLS status: | ||
+ | Policy deny_unknown status: | ||
+ | Memory protection checking: | ||
+ | Max kernel policy version: | ||
+ | </ | ||
+ | * List all loaded '' | ||
+ | semodule -l | ||
+ | </ |