From a01c0ddf1f5bee4876ca2336eff33efeae0e0d8b Mon Sep 17 00:00:00 2001 From: Luuk van den Broek Date: Wed, 10 Feb 2016 00:17:24 +0000 Subject: [PATCH] Add fix for BSD stat --- lib/chef/provisioning/machine/unix_machine.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/chef/provisioning/machine/unix_machine.rb b/lib/chef/provisioning/machine/unix_machine.rb index 9c985446..2dfa05d9 100644 --- a/lib/chef/provisioning/machine/unix_machine.rb +++ b/lib/chef/provisioning/machine/unix_machine.rb @@ -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 @@ -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) + end return nil if result.exitstatus != 0 file_info = result.stdout.split(/\s+/) if file_info.size <= 1