Module: Chef::Util::Selinux
- Includes:
- Mixin::ShellOut, Mixin::Which
- Included in:
- Provider::File
- Defined in:
- lib/chef/util/selinux.rb
Overview
IMPORTANT: We assume that selinux utilities are installed on an selinux enabled server. Provisioning an selinux enabled server without selinux utilities is not supported.
Constant Summary collapse
- @@selinux_enabled =
We want to initialize below variables once during a chef-client run therefore they are class variables.
nil
- @@restorecon_path =
nil
- @@selinuxenabled_path =
nil
Instance Method Summary collapse
Instance Method Details
#restore_security_context(file_path, recursive = false) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/chef/util/selinux.rb', line 49 def restore_security_context(file_path, recursive = false) if restorecon_path restorecon_flags = [ "-R" ] restorecon_flags << "-r" if recursive restorecon_flags << file_path Chef::Log.trace("Restoring selinux security content with #{restorecon_path}") shell_out!(restorecon_path, restorecon_flags) else Chef::Log.warn "Can not find 'restorecon' on the system. Skipping selinux security context restore." end end |
#selinux_enabled? ⇒ Boolean
44 45 46 47 |
# File 'lib/chef/util/selinux.rb', line 44 def selinux_enabled? @@selinux_enabled = check_selinux_enabled? if @@selinux_enabled.nil? @@selinux_enabled end |