Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for BSD stat #502

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/chef/provisioning/machine/unix_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ def delete_file(action_handler, path)

def is_directory?(path)
result = transport.execute("stat -c '%F' #{path}", :read_only => true)
unless result.exitstatus == 0
result = transport.execute("stat -f '%HT' #{path}", :read_only => true)
end
return nil if result.exitstatus != 0
result.stdout.chomp == 'directory'
result.stdout.chomp.downcase == 'directory'
end

# Return true or false depending on whether file exists
Expand Down Expand Up @@ -96,6 +99,9 @@ def set_attributes(action_handler, path, attributes)
# Get file attributes { :mode, :owner, :group }
def get_attributes(path)
result = transport.execute("stat -c '%a %U %G %n' #{path}", :read_only => true)
unless result.exitstatus == 0
result = transport.execute("stat -f '%OLp %Sg %Su %N' #{path}", :read_only => true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space stat -f and switch positions of %Sg %Su => %Su %Sg to be consistent with %U %G

end
return nil if result.exitstatus != 0
file_info = result.stdout.split(/\s+/)
if file_info.size <= 1
Expand Down