[BUG] Error setting SELinux mode due to case sensitivity. #64318
Labels
Bug
broken, incorrect, or confusing behavior
Execution-Module
security
issues and PRs for the Security Working Group
Milestone
Description
There is a bug in Salt's code where it returns SELinux mode values in capital letters ("Enforcing", "Permissive", and "Disabled") in two functions: _refine_mode in salt/states/selinux.py and another function in salt/modules/selinux.py. However, SELinux is case sensitive and expects these values in all lowercase ("enforcing", "permissive", "disabled"). This error may be elsewhere in the code, these are just some specific locations I found.
Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Please be as specific as possible and give set-up details.
Steps to Reproduce the behavior
When using the selinux state to try to set a system to any specific mode, the /etc/selinux/config file is set incorrectly.
for instance, SELINUX=Enforcing is incorrect:
since selinux is case sensitive, this causes an error during state runs.
Expected behavior
the SELINUX variable should be all lowercase:
Screenshots
If applicable, add screenshots to help explain your problem.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)(This system is running 3006.1 despite the report saying 3006.0)
Additional context
The bug is located in these two functions (and possibly more):
_refine_mode in salt/states/selinux.py:
salt/salt/states/selinux.py
Line 37 in b897734
Function in salt/modules/selinux.py:
salt/salt/modules/selinux.py
Lines 79 to 100 in b897734
The expected return values according to SELinux's case sensitivity requirements are "enforcing", "permissive", and "disabled", but the current return values are "Enforcing", "Permissive", and "Disabled".
The text was updated successfully, but these errors were encountered: