Class: Puppet::SELFileContext

Inherits:
Property show all
Includes:
Util::SELinux
Defined in:
lib/vendor/puppet/type/file/selcontext.rb

Constant Summary

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows

Instance Attribute Summary

Attributes inherited from Property

#noop, #shadow, #shouldorig

Attributes inherited from Parameter

#parent, #resource

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods included from Util::SELinux

#get_selinux_current_context, #get_selinux_default_context, #parse_selinux_context, #selinux_support?, #set_selinux_context, #set_selinux_default_context

Methods inherited from Property

array_matching, array_matching=, #call_provider, #call_valuemethod, #change_to_s, #event, #event_name, #initialize, #is_to_s, #log, #match_all?, method_added, #munge, #name, newvalue, #property_matches?, #safe_insync?, #set, #setup_shadow, #should, #should=, #should_to_s, #unsafe_validate, #validate_features_per_value, #value, #value=, value_name, value_option

Methods inherited from Parameter

aliasvalue, defaultto, desc, #devfail, doc, #fail, format_value_for_display, #initialize, initvars, isnamevar, isnamevar?, isrequired, #log, #metaparam?, #munge, munge, #name, newvalues, nodefault, #noop, #pathbuilder, #provider, proxymethods, #remove, required?, #tags, #to_s, unmunge, #unmunge, #unsafe_munge, #unsafe_validate, validate, #validate, #value, #value=

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Methods included from Util

absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Logging

#clear_deprecation_warnings, #deprecation_warning, #send_log

Methods included from Util::LogPaths

#path, #source_descriptors

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

This class inherits a constructor from Puppet::Property

Instance Method Details

#insync?(value) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vendor/puppet/type/file/selcontext.rb', line 48

def insync?(value)
  if not selinux_support?
    debug("SELinux bindings not found. Ignoring parameter.")
    true
  elsif not selinux_label_support?(@resource[:path])
    debug("SELinux not available for this filesystem. Ignoring parameter.")
    true
  else
    super
  end
end

#retrieveObject



28
29
30
31
32
# File 'lib/vendor/puppet/type/file/selcontext.rb', line 28

def retrieve
  return :absent unless @resource.stat
  context = self.get_selinux_current_context(@resource[:path])
  parse_selinux_context(name, context)
end

#retrieve_default_context(property) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vendor/puppet/type/file/selcontext.rb', line 34

def retrieve_default_context(property)
  if @resource[:selinux_ignore_defaults] == :true
    return nil
  end

  unless context = self.get_selinux_default_context(@resource[:path])
    return nil
  end

  property_default = self.parse_selinux_context(property, context)
  self.debug "Found #{property} default '#{property_default}' for #{@resource[:path]}" if not property_default.nil?
  property_default
end

#syncObject



60
61
62
63
# File 'lib/vendor/puppet/type/file/selcontext.rb', line 60

def sync
  self.set_selinux_context(@resource[:path], @should, name)
  :file_changed
end