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:45] – 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 348: | Line 352: | ||
semanage port -l | grep 5665 | semanage port -l | grep 5665 | ||
</ | </ | ||
+ | |||
+ | ==== Piwik (Matomo) ==== | ||
+ | Not yet done ... | ||
==== Configure non-standard ports ==== | ==== 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:< | * Example for configuring port 8888 for httpd service:< | ||
semanage port -a -t httpd_port_t -p tcp 8888 | semanage port -a -t httpd_port_t -p tcp 8888 | ||
</ | </ | ||
- | |||
- | ==== Piwik (Matomo) ==== | ||
- | Not yet done ... | ||
===== Problems during boot ===== | ===== Problems during boot ===== | ||
Line 377: | 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 | ||
+ | </ |