summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2011-03-11 10:42:41 +1100
committerJames Turnbull <james@lovedthanlost.net>2011-03-11 10:42:41 +1100
commitdea6f78ace56df3459dd182300cc9618df712317 (patch)
tree501efa88ae46a93667519ecf740c87f3c5f36fe0 /lib
parent7c05312d844b05465b6f2a05de456dff1ddf2cd9 (diff)
downloadfacter-dea6f78ace56df3459dd182300cc9618df712317.tar.gz
facter-dea6f78ace56df3459dd182300cc9618df712317.tar.xz
facter-dea6f78ace56df3459dd182300cc9618df712317.zip
Further fix to #5485 - SELinux facts
1. Added new facts for all values returned by the sestatus command 2. Updated legacy selinux_mode fact with former value 3. Added note and ticket #6677 to remove legacy fact at Facter 2.0.0 4. Added tests for new facts and legacy fact
Diffstat (limited to 'lib')
-rw-r--r--lib/facter/selinux.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/facter/selinux.rb b/lib/facter/selinux.rb
index 73e3239..9fab427 100644
--- a/lib/facter/selinux.rb
+++ b/lib/facter/selinux.rb
@@ -36,7 +36,7 @@ Facter.add("selinux_policyversion") do
end
end
-Facter.add("selinux_mode") do
+Facter.add("selinux_current_mode") do
confine :selinux => :true
setcode do
result = 'unknown'
@@ -45,3 +45,34 @@ Facter.add("selinux_mode") do
result.chomp
end
end
+
+Facter.add("selinux_config_mode") do
+ confine :selinux => :true
+ setcode do
+ result = 'unknown'
+ mode = Facter::Util::Resolution.exec('/usr/sbin/sestatus')
+ mode.each_line { |l| result = $1 if l =~ /^Mode from config file\:\s+(\w+)$/i }
+ result.chomp
+ end
+end
+
+Facter.add("selinux_config_policy") do
+ confine :selinux => :true
+ setcode do
+ result = 'unknown'
+ mode = Facter::Util::Resolution.exec('/usr/sbin/sestatus')
+ mode.each_line { |l| result = $1 if l =~ /^Policy from config file\:\s+(\w+)$/i }
+ result.chomp
+ end
+end
+
+# This is a legacy fact which returns the old selinux_mode fact value to prevent
+# breakages of existing manifests. It should be removed at the next major release.
+# See ticket #6677.
+
+Facter.add("selinux_mode") do
+ confine :selinux => :true
+ setcode do
+ Facter.value(:selinux_config_policy)
+ end
+end