Class: Specinfra::Command::Linux::Base::Selinux

Inherits:
Base::Selinux show all
Defined in:
lib/specinfra/command/linux/base/selinux.rb

Class Method Summary collapse

Methods inherited from Base

create, escape

Class Method Details

.check_has_mode(mode, policy = nil) ⇒ Object


3
4
5
6
7
8
9
10
11
# File 'lib/specinfra/command/linux/base/selinux.rb', line 3

def check_has_mode(mode, policy = nil)
  cmd =  ""
  cmd += "test ! -f /etc/selinux/config || (" if mode == "disabled"
  cmd += "getenforce | grep -i -- #{escape(mode)}"
  cmd += %Q{ && grep -iE -- '^\\s*SELINUX=#{escape(mode)}\\>' /etc/selinux/config}
  cmd += %Q{ && grep -iE -- '^\\s*SELINUXTYPE=#{escape(policy)}\\>' /etc/selinux/config} if policy != nil
  cmd += ")" if mode == "disabled"
  cmd
end