Facter/Puppet: Could not retrieve selinux: Invalid argument – /proc/self/attr/current

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, July 31, 2012

Follow me on Twitter as @mattiasgeniar

I recently ran into the following issue on a CentOS 5 server.

$ facter
Could not retrieve selinux: Invalid argument - /proc/self/attr/current
Could not retrieve selinux: Invalid argument - /proc/self/attr/current
Could not retrieve selinux: Invalid argument - /proc/self/attr/current
Could not retrieve selinux: Invalid argument - /proc/self/attr/current
...

After checking the sestatus, it should have been disabled.

$ sestatus
SELinux status:                 disabled

Yet the /selinux directory on the server contained content that would contradict that.

$ ls -alh /selinux/
total 20K
drwxr-xr-x  2 root root 4.0K May 11  2011 .
drwxr-xr-x 23 root root 4.0K Jul 31 11:27 ..
-rw-r--r--  1 root root    2 Oct  6  2010 enforce

That file should not be there if the selinux is in fact disabled. If all selinux related configurations have been disabled (as verified by sestatus and the selinux config file at /etc/selinux/config) you can safely remove that file.

$ rm -f /selinux/enforce

The Puppet/Facter code would check if that file exists in the /selinux directory – if that does not fully match your selinux config, you can get funky messages as the ones shown above.

  • Update: this can also be bug #18429 known to Puppetlabs.


Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.