Sha256: 9466b9853cfa0c18255e3a2864786fd3eccb8f531b80d53af39c51dd51bbfa95

Contents?: true

Size: 1.21 KB

Versions: 94

Compression:

Stored size: 1.21 KB

Contents

class Specinfra::Command::Linux::Base::Selinux < Specinfra::Command::Base::Selinux
  class << self
    def check_has_mode(mode, policy = nil)

      cmd =  ""

      # If disabled, then the absence of /etc/selinux/config is sufficient
      cmd += "test ! -f /etc/selinux/config || " if mode == "disabled"

      # If disabled, wrap the rest of the test in parentheses
      # i.e. only test this stuff if /etc/selinux/config exists
      cmd += "( ( " if mode == "disabled"

      # Does getenforce return the same value as we are checking for?
      cmd += "(getenforce | grep -i -- #{escape(mode)})"

      # If disabled, then permissive is considered a pass
      cmd += " || (getenforce | grep -i -- #{escape('permissive')}) )" if mode == "disabled"

      # Ensure that /etc/selinux/config contains the mode we specify
      cmd += %Q{ && grep -iE -- '^\\s*SELINUX=#{escape(mode)}\\>' /etc/selinux/config}

      # If we have specified a policy, ensure that is included in /etc/selinux/config
      cmd += %Q{ && grep -iE -- '^\\s*SELINUXTYPE=#{escape(policy)}\\>' /etc/selinux/config} if policy != nil

      # End parenthesis for tests when /etc/selinux/config exists
      cmd += ")" if mode == "disabled"

      cmd
    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
specinfra-2.82.25 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.24 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.23 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.22 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.21 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.20 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.19 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.18 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.17 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.16 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.15 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.14 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.13 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.12 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.11 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.10 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.9 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.8 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.7 lib/specinfra/command/linux/base/selinux.rb
specinfra-2.82.6 lib/specinfra/command/linux/base/selinux.rb