salt icon indicating copy to clipboard operation
salt copied to clipboard

SELinux module is still not available after installing policycoreutils and policycoreutils-python

Open travispaul opened this issue 13 years ago • 8 comments

CentOS 6.4, salt 0.17.1 from EPEL.

What's weird is that some minions have not had this is issue, some did have the issue and it went away after a while, not sure if I'm doing something wrong or this is a bug. response from the minion is:

----------
    State: - pkg
    Name:      policycoreutils
    Function:  installed
        Result:    True
        Comment:   Package policycoreutils is already installed
        Changes:   
----------
    State: - pkg
    Name:      policycoreutils-python
    Function:  installed
        Result:    True
        Comment:   Package policycoreutils-python is already installed
        Changes:   
----------
    State: - selinux
    Name:      enforcing
    Function:  mode
        Result:    False
        Comment:   State selinux.mode found in sls selinux is unavailable

        Changes:
----------

state:

policycoreutils:
    pkg.installed
 
policycoreutils-python:
    pkg.installed
 
enforcing:
    selinux.mode

travispaul avatar Nov 19 '13 17:11 travispaul

You can see here what the requirements are for the selinux module (and through it, the state): https://github.com/saltstack/salt/blob/develop/salt/modules/selinux.py#L24-L60

Can you verify that those requirements are met? semanage and setsebool should be available on your path, and the paths defined in selinux_fs_path should be available as well.

basepi avatar Nov 19 '13 21:11 basepi

Thanks for the response @basepi,

semanage and setsebool are available, however /selinux/enforce is not available and it is only present if SELinux is already being enforced. So it appears that the SELinux module's 'enforcing' state will only check that it in 'enforcing' mode. My expectation was that salt would enforce SELinux if it was not being enforced.

I can confirm the following:

Manually enable SELinux, reboot:

/selinux/enforce is present and value is 1

Comment:   SELinux is already in Enforcing mode
Manually disable SELinux, reboot:

/selinux/enforce is not present

Comment:   State selinux.mode found in sls selinux is unavailable

travispaul avatar Nov 19 '13 21:11 travispaul

Yes, I think this state is fairly new, we need to extend the functionality.

basepi avatar Nov 20 '13 17:11 basepi

Hit this today. Not sure why /selinux/enforce is needed. It would be nice to be able to ensure a given mode even if selinux is disabled.

fbretel avatar Oct 27 '15 17:10 fbretel

I assume some of the functionality requires /selinux/enforce. However, I haven't gone through the code to see exactly when/where it is needed.

basepi avatar Oct 28 '15 20:10 basepi

/sbin/getenforce references /sys/fs/enforce to determine the level of the system, but "disabled" is a perfectly valid mode to be in, and want to transition from. The logic there is "1" = enforcing, "0" = permissive, no such file = disabled.

Maybe adopting the same logic would be wise for salt to enable the module? We're already checking if the tools from policycoreutils are available, and it looks like those require the other selinux dependencies.
If that approach is acceptable I'd be willing to submit a PR.

shpsec-david avatar Dec 23 '15 22:12 shpsec-david

This seems like a reasonable approach, feel free to submit a PR!

basepi avatar Jan 04 '16 20:01 basepi

Looking for some group input here.

SELinux can be: Disabled Enabled - Permissive Enabled - Enforcing

Changing between Enabled/Disabled requires writing to /etc/selinux/config (as best as I can determine this file location is consistent in any environment which can run selinux) and rebooting the system.

Changing between Enforcing/Permissive being the active state is currently accomplished by writing to the 'enforce' file, which changes the currently active state, but does not persist through reboots.

My thought is to add a write to /etc/selinux/config for all state changes, in addition to the current write to the enforce file. This is a little bit presumptuous, as a change in state now becomes "change the state and persist it", but I think that's very likely what people intend, even if they don't know it. I'm having a difficult time coming up with scenarios in which changing between Enforcing/Permissive and not persisting it is a useful thing to have available.

Thoughts?

shpsec-david avatar Jan 13 '16 17:01 shpsec-david