# File lib/chef/file_access_control/unix.rb, line 82 def current_gid gid_from_resource(current_resource) end
# File lib/chef/file_access_control/unix.rb, line 134 def current_mode mode_from_resource(current_resource) end
# File lib/chef/file_access_control/unix.rb, line 58 def current_uid uid_from_resource(current_resource) end
# File lib/chef/file_access_control/unix.rb, line 46 def describe_changes changes = [] changes << "change mode from '#{mode_to_s(current_mode)}' to '#{mode_to_s(target_mode)}'" if should_update_mode? changes << "change owner from '#{current_resource.owner}' to '#{resource.owner}'" if should_update_owner? changes << "change group from '#{current_resource.group}' to '#{resource.group}'" if should_update_group? changes end
# File lib/chef/file_access_control/unix.rb, line 86 def gid_from_resource(resource) return nil if resource == nil or resource.group.nil? if resource.group.kind_of?(String) diminished_radix_complement( Etc.getgrnam(resource.group).gid ) elsif resource.group.kind_of?(Integer) resource.group else Chef::Log.error("The `group` parameter of the #@resource resource is set to an invalid value (#{resource.owner.inspect})") raise ArgumentError, "cannot resolve #{resource.group.inspect} to gid, group must be a string or integer" end rescue ArgumentError provider.requirements.assert(:create, :create_if_missing, :touch) do |a| a.assertion { false } a.failure_message(Chef::Exceptions::GroupIDNotFound, "cannot determine group id for '#{resource.group}', does the group exist on this system?") a.whyrun("Assuming group #{resource.group} would have been created") end return nil end
# File lib/chef/file_access_control/unix.rb, line 121 def mode_from_resource(res) return nil if res == nil or res.mode.nil? (res.mode.respond_to?(:oct) ? res.mode.oct : res.mode.to_i) & 007777 end
# File lib/chef/file_access_control/unix.rb, line 130 def mode_to_s(mode) mode.nil? ? "" : "0#{mode.to_s(8)}" end
TODO factor this up
# File lib/chef/file_access_control/unix.rb, line 42 def requires_changes? should_update_mode? || should_update_owner? || should_update_group? end
# File lib/chef/file_access_control/unix.rb, line 35 def set_all set_owner set_group set_mode end
# File lib/chef/file_access_control/unix.rb, line 29 def set_all! set_owner! set_group! set_mode! end
# File lib/chef/file_access_control/unix.rb, line 117 def set_group set_group! if should_update_group? end
# File lib/chef/file_access_control/unix.rb, line 109 def set_group! unless target_gid.nil? chown(nil, target_gid, file) Chef::Log.info("#{log_string} group changed to #{target_gid}") modified end end
# File lib/chef/file_access_control/unix.rb, line 150 def set_mode set_mode! if should_update_mode? end
# File lib/chef/file_access_control/unix.rb, line 142 def set_mode! unless target_mode.nil? chmod(target_mode, file) Chef::Log.info("#{log_string} mode changed to #{target_mode.to_s(8)}") modified end end
# File lib/chef/file_access_control/unix.rb, line 74 def set_owner set_owner! if should_update_owner? end
# File lib/chef/file_access_control/unix.rb, line 66 def set_owner! unless target_uid.nil? chown(target_uid, nil, file) Chef::Log.info("#{log_string} owner changed to #{target_uid}") modified end end
# File lib/chef/file_access_control/unix.rb, line 105 def should_update_group? !target_gid.nil? && target_gid != current_gid end
# File lib/chef/file_access_control/unix.rb, line 138 def should_update_mode? !target_mode.nil? && current_mode != target_mode end
# File lib/chef/file_access_control/unix.rb, line 62 def should_update_owner? !target_uid.nil? && target_uid != current_uid end
# File lib/chef/file_access_control/unix.rb, line 154 def stat if File.symlink?(file) @stat ||= File.lstat(file) else @stat ||= File.stat(file) end end
# File lib/chef/file_access_control/unix.rb, line 78 def target_gid gid_from_resource(resource) end
Generated with the Darkfish Rdoc Generator 2.