Sha256: d4a62f929e7e3cdf74dd6d0912eb85de167e3bb2b5c751fa3d2a21bdea8b000b

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class Chef
  module SELinux
    module CommonHelpers
      def selinux_disabled?
        selinux_state.eql?(:disabled)
      end

      def selinux_enforcing?
        selinux_state.eql?(:enforcing)
      end

      def selinux_permissive?
        selinux_state.eql?(:permissive)
      end

      def state_change_reboot_required?
        (selinux_disabled? && %i{enforcing permissive}.include?(action)) || ((selinux_enforcing? || selinux_permissive?) && action == :disabled)
      end

      def selinux_state
        state = shell_out!("getenforce").stdout.strip.downcase.to_sym
        raise "Got unknown SELinux state #{state}" unless %i{disabled enforcing permissive}.include?(state)

        state
      end

      def selinux_activate_required?
        return false unless platform_family?("debian")

        !File.read("/etc/default/grub").match?("security=selinux")
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
chef-18.5.0-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.4.12-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.4.12 lib/chef/resource/selinux/common_helpers.rb
chef-18.4.2-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.4.2 lib/chef/resource/selinux/common_helpers.rb
chef-18.3.0-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.3.0 lib/chef/resource/selinux/common_helpers.rb
chef-18.2.7-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.2.7 lib/chef/resource/selinux/common_helpers.rb
chef-18.1.29 lib/chef/resource/selinux/common_helpers.rb
chef-18.1.29-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.1.0-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.1.0 lib/chef/resource/selinux/common_helpers.rb
chef-18.0.185-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.0.185 lib/chef/resource/selinux/common_helpers.rb
chef-18.0.169-x64-mingw-ucrt lib/chef/resource/selinux/common_helpers.rb
chef-18.0.169 lib/chef/resource/selinux/common_helpers.rb