Class: Puppet::SELFileContext
- Inherits:
-
Property
- Object
- Property
- Puppet::SELFileContext
show all
- Includes:
- Util::SELinux
- Defined in:
- lib/puppet/type/file/selcontext.rb
Constant Summary
Util::SELinux::S_IFDIR, Util::SELinux::S_IFLNK, Util::SELinux::S_IFREG
Instance Method Summary
collapse
#get_selinux_current_context, #get_selinux_default_context, #get_selinux_default_context_with_handle, #parse_selinux_context, #selinux_category_to_label, selinux_support?, #selinux_support?, #set_selinux_context, #set_selinux_default_context
Instance Method Details
#insync?(value) ⇒ Boolean
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/puppet/type/file/selcontext.rb', line 58
def insync?(value)
if !selinux_support?
debug("SELinux bindings not found. Ignoring parameter.")
true
elsif !selinux_label_support?(@resource[:path])
debug("SELinux not available for this filesystem. Ignoring parameter.")
true
else
super
end
end
|
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/puppet/type/file/selcontext.rb', line 30
def retrieve
return :absent unless @resource.stat
context = get_selinux_current_context(@resource[:path])
is = parse_selinux_context(name, context)
if name == :selrange and selinux_support?
selinux_category_to_label(is)
else
is
end
end
|
#retrieve_default_context(property) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/puppet/type/file/selcontext.rb', line 42
def retrieve_default_context(property)
return nil if Puppet::Util::Platform.windows?
if @resource[:selinux_ignore_defaults] == :true
return nil
end
context = get_selinux_default_context_with_handle(@resource[:path], provider.class.selinux_handle, @resource[:ensure])
unless context
return nil
end
property_default = parse_selinux_context(property, context)
debug "Found #{property} default '#{property_default}' for #{@resource[:path]}" unless property_default.nil?
property_default
end
|
82
83
84
85
|
# File 'lib/puppet/type/file/selcontext.rb', line 82
def sync
set_selinux_context(@resource[:path], @should, name)
:file_changed
end
|
#unsafe_munge(should) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/puppet/type/file/selcontext.rb', line 70
def unsafe_munge(should)
unless selinux_support?
return should
end
if name == :selrange
selinux_category_to_label(should)
else
should
end
end
|