Class: Chef::ReservedNames::Win32::Security::ACL

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/chef/win32/security/acl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pointer, owner = nil) ⇒ ACL

Returns a new instance of ACL.



29
30
31
32
33
34
# File 'lib/chef/win32/security/acl.rb', line 29

def initialize(pointer, owner = nil)
  @struct = Chef::ReservedNames::Win32::API::Security::ACLStruct.new pointer
  # Keep a reference to the actual owner of this memory so that it isn't freed out from under us
  # TODO this could be avoided if we could mark a pointer's parent manually
  @owner = owner
end

Instance Attribute Details

#structObject (readonly)

Returns the value of attribute struct.



44
45
46
# File 'lib/chef/win32/security/acl.rb', line 44

def struct
  @struct
end

Class Method Details

.create(aces) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/chef/win32/security/acl.rb', line 36

def self.create(aces)
  aces_size = aces.inject(0) { |sum, ace| sum + ace.size }
  acl_size = align_dword(Chef::ReservedNames::Win32::API::Security::ACLStruct.size + aces_size) # What the heck is 94???
  acl = Chef::ReservedNames::Win32::Security.initialize_acl(acl_size)
  aces.each { |ace| Chef::ReservedNames::Win32::Security.add_ace(acl, ace) }
  acl
end

Instance Method Details

#==(other) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/chef/win32/security/acl.rb', line 46

def ==(other)
  return false if length != other.length

  0.upto(length - 1) do |i|
    return false if self[i] != other[i]
  end
  true
end

#[](index) ⇒ Object



59
60
61
# File 'lib/chef/win32/security/acl.rb', line 59

def [](index)
  Chef::ReservedNames::Win32::Security.get_ace(self, index)
end

#delete_at(index) ⇒ Object



63
64
65
# File 'lib/chef/win32/security/acl.rb', line 63

def delete_at(index)
  Chef::ReservedNames::Win32::Security.delete_ace(self, index)
end

#eachObject



67
68
69
# File 'lib/chef/win32/security/acl.rb', line 67

def each
  0.upto(length - 1) { |i| yield self[i] }
end

#insert(index, *aces) ⇒ Object



71
72
73
# File 'lib/chef/win32/security/acl.rb', line 71

def insert(index, *aces)
  aces.reverse_each { |ace| add_ace(self, ace, index) }
end

#lengthObject



75
76
77
# File 'lib/chef/win32/security/acl.rb', line 75

def length
  struct[:AceCount]
end

#pointerObject



55
56
57
# File 'lib/chef/win32/security/acl.rb', line 55

def pointer
  struct.pointer
end

#push(*aces) ⇒ Object



79
80
81
# File 'lib/chef/win32/security/acl.rb', line 79

def push(*aces)
  aces.each { |ace| Chef::ReservedNames::Win32::Security.add_ace(self, ace) }
end

#to_sObject



91
92
93
# File 'lib/chef/win32/security/acl.rb', line 91

def to_s
  "[#{collect(&:to_s).join(", ")}]"
end

#unshift(*aces) ⇒ Object



83
84
85
# File 'lib/chef/win32/security/acl.rb', line 83

def unshift(*aces)
  aces.each { |ace| Chef::ReservedNames::Win32::Security.add_ace(self, ace, 0) }
end

#valid?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/chef/win32/security/acl.rb', line 87

def valid?
  Chef::ReservedNames::Win32::Security.is_valid_acl(self)
end