Class: Chef::FileAccessControl

Inherits:
Object
  • Object
show all
Includes:
FileAccessControl::Unix, FileAccessControl::Windows
Defined in:
lib/chef/file_access_control.rb,
lib/chef/file_access_control/unix.rb,
lib/chef/file_access_control/windows.rb

Overview

Chef::FileAccessControl

FileAccessControl objects set the owner, group and mode of file to the values specified by a value object, usually a Chef::Resource.

Defined Under Namespace

Modules: Unix, Windows

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_resource, new_resource, provider) ⇒ FileAccessControl

FileAccessControl objects set the owner, group and mode of file to the values specified by resource. file is completely independent of any file or path attribute on resource, so it is possible to set access control settings on a tempfile (for example).

Arguments:

resource: probably a Chef::Resource::File object (or subclass), but this is not required. Must respond to owner, group, and mode file: The file whose access control settings you wish to modify, given as a String.

TODO requiring current_resource will break cookbook_file template_file



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/chef/file_access_control.rb', line 56

def initialize(current_resource, new_resource, provider)
  @current_resource, @resource, @provider = current_resource, new_resource, provider
  @file = @current_resource.path
  @modified = false

  # When running on Windows in target mode the remote host is a Unix
  # system managed via SSH.  Extend this instance with the Unix access
  # control module so that permissions are applied via TargetIO
  # (chmod/chown over SSH) rather than Win32 security APIs against a
  # path that does not exist on the local Windows filesystem.
  if RUBY_PLATFORM.match?(/mswin|mingw|windows/) && ChefConfig::Config.target_mode?
    extend FileAccessControl::Unix
  end
end

Instance Attribute Details

#current_resourceObject (readonly)

Returns the value of attribute current_resource.



39
40
41
# File 'lib/chef/file_access_control.rb', line 39

def current_resource
  @current_resource
end

#fileObject (readonly)

Returns the value of attribute file.



42
43
44
# File 'lib/chef/file_access_control.rb', line 42

def file
  @file
end

#providerObject (readonly)

Returns the value of attribute provider.



41
42
43
# File 'lib/chef/file_access_control.rb', line 41

def provider
  @provider
end

#resourceObject (readonly)

Returns the value of attribute resource.



40
41
42
# File 'lib/chef/file_access_control.rb', line 40

def resource
  @resource
end

Instance Method Details

#modified?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/chef/file_access_control.rb', line 71

def modified?
  @modified
end