Module: Chef::Mixin::Securable

Defined Under Namespace

Modules: WindowsMacros, WindowsSecurableAttributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WindowsSecurableAttributes

#inherits

Class Method Details

.included(including_class) ⇒ Object

Callback that fires when included; will extend the including class with WindowsMacros and define #rights and #deny_rights on it.



181
182
183
184
185
186
187
188
# File 'lib/chef/mixin/securable.rb', line 181

def self.included(including_class)
  if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
    including_class.extend(WindowsMacros)
    # create a default 'rights' attribute
    including_class.rights_attribute(:rights)
    including_class.rights_attribute(:deny_rights)
  end
end

Instance Method Details

#group(arg = nil) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/chef/mixin/securable.rb', line 33

def group(arg = nil)
  set_or_return(
    :group,
    arg,
    regex: Chef::Config[:group_valid_regex]
  )
end

#mode(arg = nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/chef/mixin/securable.rb', line 41

def mode(arg = nil)
  set_or_return(
    :mode,
    arg,
    callbacks: {
      "not in valid numeric range" => lambda do |m|
        if m.is_a?(String)
          m =~ /^0/ || m = "0#{m}"
        end

        # Windows does not support the sticky or setuid bits
        if ChefUtils.windows?
          Integer(m) <= 0777 && Integer(m) >= 0
        else
          Integer(m) <= 07777 && Integer(m) >= 0
        end
      end,
    }
  )
end

#owner(arg = nil) ⇒ Object Also known as: user



23
24
25
26
27
28
29
# File 'lib/chef/mixin/securable.rb', line 23

def owner(arg = nil)
  set_or_return(
    :owner,
    arg,
    regex: Chef::Config[:user_valid_regex]
  )
end