Class: Chef::ChefFS::FileSystem::Repository::NodesDir

Inherits:
Directory
  • Object
show all
Defined in:
lib/chef/chef_fs/file_system/repository/nodes_dir.rb

Instance Attribute Summary

Attributes inherited from Directory

#file_path, #name, #parent, #path

Instance Method Summary collapse

Methods inherited from Directory

#can_have_child?, #child, #children, #create, #delete, #dir?, #dir_ls, #empty?, #exists?, #fs_entry_valid?, #initialize, #name_valid?, #path_for_printing, #root

Constructor Details

This class inherits a constructor from Chef::ChefFS::FileSystem::Repository::Directory

Instance Method Details

#create_child(child_name, file_contents = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/chef/chef_fs/file_system/repository/nodes_dir.rb', line 35

def create_child(child_name, file_contents = nil)
  child = super
  File.chmod(0600, child.file_path)
  if ChefUtils.windows?
    read_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_READ
    write_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE
    administrators = Chef::ReservedNames::Win32::Security::SID.Administrators
    owner = Chef::ReservedNames::Win32::Security::SID.default_security_object_owner
    dacl = Chef::ReservedNames::Win32::Security::ACL.create([
      Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, read_mask),
      Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, write_mask),
      Chef::ReservedNames::Win32::Security::ACE.access_allowed(administrators, read_mask),
      Chef::ReservedNames::Win32::Security::ACE.access_allowed(administrators, write_mask),
    ])
    so = Chef::ReservedNames::Win32::Security::SecurableObject.new(child.file_path)
    so.owner = owner
    so.set_dacl(dacl, false)
  end
  child
end

#make_child_entry(child_name) ⇒ Object



31
32
33
# File 'lib/chef/chef_fs/file_system/repository/nodes_dir.rb', line 31

def make_child_entry(child_name)
  Node.new(child_name, self)
end