Introduction:
If you are a system-administrator, 100% that you faced with at least one issue with SELinux. In short: SELinux is a security mechanism which allow / prevent processes to reach stored files in paths. If you are using default processes with default paths SELinux will allow access as it was defined on it. But if you changed for example the default logging path, SELinux without your declaration will not know that this access is expected, or it is a trojan-modified process.
Detect that SELinux blocks your task:
The simplest way to know, SELinux is the reason or not: Temporary disable SELinux.
If your task works, enable again SELinux & check audit log-file.
Logging of denied actions is in /var/log/audit/audit.log. If you found “denied” string on it means that SELinux prevent something (the action is defined after deny as {} ) for some process. For example:
If you not found any related message on audit.log, maybe you faced with Silent denial. So please disable temporary do-not-audit with the following command:
Hint:To read time-stamp in audit.log use this online epoch-converter.
After you found denied message, please enable it again. This option filter out a lot of unneeded message.
Create your custom policy to solve it.
Grep to the command which was denied (defined as comm=””) on audit.log
- If you have more denied message it is better if you copy messages form audit.log to an separated file & grep to it (not to audit.log).
- If you want, now you can edit created *.te file.
Create module & policy from it:
Install created, custom local policy module:
Test & correct it if needed:
Some cases created local policy not solve (for first time) your problem. This is not a problem as your created policy work. Please verify again audit.log as the created policy solved one problem but a new access problem can be appeared. It is a common case as the denied process in a lot cases need more right to the same task (open; write; read) & SELinux log always just the first problem. If you found the next problem, just create the next module and install it. If every denied message was disappeared at the end you can create ONE local policy which contain all definition (edit *.te file and follow the described process).