SELinux: getenforce says 'Disabled' but config file says 'permissive'

Latest response

I've got one server which, according to the /etc/selinux/config file, the mode is set to "permissive" but when I run getenforce, it reports the it is disabled. Yes, the server has been restarted, so I would think it should be in permissive mode.

I thought I had seen information about setting SELinux mode during boot. I can't remember if it was something in inittab or grub.conf, but I've checked both of those areas and there is no reference to SELinux in either place. So, at this point, it is unclear why this server showing that it's disabled.

Any ideas?

Responses

I'm not sure how this would impact a system, but... can you look at:

[root@cypher ~]# ls -l /etc/selinux/config
-rw-r--r--. 1 root root 547 Apr 30 09:43 /etc/selinux/config
[root@cypher ~]# ls -l /etc/sysconfig/selinux
lrwxrwxrwx. 1 root root 17 Apr 30 09:43 /etc/sysconfig/selinux -> ../selinux/config

[root@cypher ~]# ls -lZ /etc/selinux/config
-rw-r--r--. root root system_u:object_r:selinux_config_t:s0 /etc/selinux/config

And make sure the file in /etc/sysconfig is still a symlink. Also - I wonder if the context is changed on a file which is neccsarry for SElinux to start, if it would just disable the whole stack (i.e. if someone did an mv of config file, or if someone did a chmod 777 to the config file, or changed the owner - and SElinux saw that when it started, it would disable the whole stack.)

do you see SElinux initializing in /var/log/messages?

@James

I do see an entry from the last system boot (7/17) that shows:

kernel: SELinux: Initializing.

When looking at the context for /etc/selinux/config, it shows "unlabeled" though I assume this is due to the fact the SELinux is disabled.

The ownership/permissions as well as the symlink at /etc/sysconfig/selinux are the same as shown in your example.

Thanks for the feedback!!

I believe the label should still be 'selinux_config_t' (even though SElinux is currently disabled) like in the following example:

[root@rhel6 ~] # grep ^SELINUX= /etc/selinux/config
SELINUX=disabled
[root@rhel6 ~] # ls -lZ /etc/selinux/config 
-rw-r--r--. root root system_u:object_r:selinux_config_t:s0 /etc/selinux/config

It almost seems as though at one point SELinux was not enabled then re-enabled (possibly)? Which shoudl have relabeled the entire file systems after the reboot.

I'm sure support could get this sorted in no time ;-) But, if I was in this situation, I would want to test a few things. I would first try to relabel the entire system, which can take quite a while.
DISCLAIMER: I have heard of systems being so out of compliance that the person first needed to set SElinux to PERMISSIVE, then relabel, the set to ENFORCING. (i.e. could not simply go to ENFORCING).

Check out the following doc (and the Note at the bootom)
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Working_with_SELinux-Enabling_and_Disabling_SELinux.html

And.. this is part of the reason I love helping out at the Portal - I just discovered a justification why you should use PERMISSIVE rather than DISABLED (from the Sec Doc above)
"Also, files created while SELinux is disabled are not labeled."

James,

Sounds like it's worth a try. I figured it should have SOME label on it, as well. I will create the /.autorelabel and see if the file system is able to apply SELinux labels and then set the mode to "permissive" as is specified in the config file.

Thanks, again, for the thoughts. I'll see when I can get this system restarted and I'll be sure to post the results to let you know if it worked or not.

My pleasure - I wish I knew the "silver bullet" but.. I think you'll get this resolved.

This thread made me also wonder about something else (when you mentioned grub.conf) - I guess I had not considered that to be the culprit. For the benefit of others that happen upon this thread, grub.conf could actually have been playing a role in this as well (though Dan said he checked there)

https://access.redhat.com/solutions/3176

Make sure SELinux is not disabled using Grub boot loader. 
Search /boot/grub/grub.conf for selinux
# egrep -i 'selinux|enforcing' /boot/grub/grub.conf
(/boot/efi/EFI/fedora/grub.cfg) for Fedora, with EFI.

Check out this link, I wonder if you have to enable the "policycoreutils".
See this Red Hat documentation.

*I have no idea why my reply turned into a zero. Fixed.

Hi Samantha, I noticed you mentioned:

(### quoted)
Check out this link, I wonder if you have to enable the "policycoreutils".
See this Red Hat documentation.
(### end quoted)

Dan, perhaps in addition to what James wrote, check out this bit Samantha found...

In Section 5.4.1 on that document, it lists packages that are assumed to be installed. I found that the selinux-policy-targeted package was not installed on my server. Not sure how the heck that would have happened, but then that's what I get for inheriting servers. :-)

At this point, I think I still need to restart the server to initialize everything, but I do have the appropriate packages installed, so I'll see what happens at the next scheduled reboot.

Thanks for the tip!!

Good find!
BTW - If you use Satellite (or RHN probably allows this also) you can create a profile of a "known good" system and then compare your other systems to see what the package differential is. Otherwise, you might want to run a rpm -ql | sort on both systems and run an sdiff against the 2 outputs.

After looking at the file list of selinux-policy-targeted - I guess that makes sense. I thought the contexts were acquired by looking at the rpm manifest. I need to do some learning ;-)

[root@apoc files]# grep \/etc\/selinux /etc/selinux/targeted/contexts/files/file_contexts
/etc/selinux(/.*)?  system_u:object_r:selinux_config_t:s0
/etc/selinux/([^/]*/)?seusers   --  system_u:object_r:selinux_config_t:s0
/etc/selinux/([^/]*/)?users(/.*)?   --  system_u:object_r:selinux_config_t:s0
/etc/selinux/([^/]*/)?logins(/.*)?  system_u:object_r:selinux_login_config_t:s0
/etc/selinux/([^/]*/)?policy(/.*)?  system_u:object_r:semanage_store_t:s0
/etc/selinux/([^/]*/)?setrans\.conf --  system_u:object_r:selinux_config_t:s0
/etc/selinux/([^/]*/)?contexts(/.*)?    system_u:object_r:default_context_t:s0
/etc/selinux/([^/]*/)?contexts/files(/.*)?  system_u:object_r:file_context_t:s0
/etc/selinux/([^/]*/)?modules/semanage\.read\.LOCK  --  system_u:object_r:semanage_read_lock_t:s0
/etc/selinux/([^/]*/)?modules/semanage\.trans\.LOCK --  system_u:object_r:semanage_trans_lock_t:s0
/etc/selinux/([^/]*/)?modules/(active|tmp|previous)(/.*)?   system_u:object_r:semanage_store_t:s0

Another curiosity thing again - I wonder what would have happened had you run a restorecon -Fv /etc/selinux/config before you installed the missing package. Crazy!

Glad it helped Dan,

Hey Samantha - nice find!!!

It seems from step 3, the file system will be relabeled. ->By the way, is SAN attached? Or a big giant raid??

If the server is virtual (vmware), perhaps snapshot it first. or clone it and test it on the clone.

Dan you are using Targeted SELinux, not MLS SELinux, right? If MLS SELinux, remember to check this Red Hat article, particularly the grub boot directive or the system will panic guaranteed upon reboot (ask me how I know, at least it used to when changing to MLS SELinux under RHEL 5).

This server was P2V'd about a year ago or so. So it's a VM now. Yes, we are using Targeted policy. There is no currently SAN attached storage on this system.

James, I need to get more familiar with the Satellite profiles. I've seen references to it, but that is an area of Satellite I have yet to delve into. We've got a couple of other Satellite-related initiatives going on at the moment, but perhaps after that, I can look into using profiles. That might help give me more flexability between kickstart profiles, activation keys and such. Thanks for the tip!

Just to let you know - working with profiles is one of the easier areas to get familiar with. (which is one thing I like about Satellite, you can pick-and-chose which features to use and go at your own pace when you want to utilize them). I mostly use them for reporting and comparing hosts - but you can also use them to sync systems to a known-good profile - or when we do significant upgrades, we first create a profile that we can roll back to.

Over the past year I developed our use of activation keys - mostly to manage which parent/child channels the host will subscribe to, in addition to the config channels. Working on that was reasonably complicated (for me anyhow ;-)

Latest update:

After installing the selinux-policy-targeted package and restarting the server last night, 'getenforce' now shows (accurately) that the system is in Permissive mode.

Thanks to everyone for your help and to Samantha, specifically, for pointing out the document that led to the resolution!

Also, James, I'll definitely be checking into some of the currently unused features / functions of Satellite. Thanks so much for pointing them out!

Nice work Samantha!

Glad it worked out for you Dan

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.