summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-03-10 10:29:21 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-03-10 10:29:21 -0700
commite88c653016a1f0c5a115c762d9f727fcdfc59d43 (patch)
treea16e2cedcae497c0054efdb199e2dc8c433063de
parent4b0f63b90cc72365fccd3f4f2e07721de7af80e6 (diff)
parent13d257e967c42822106c99ebdacf0b5514cdb2f0 (diff)
downloadchef-e88c653016a1f0c5a115c762d9f727fcdfc59d43.tar.gz
Merge pull request #3050 from chef/jdm/osx
Fix dscl issues for osx
-rw-r--r--lib/chef/provider/user/dscl.rb6
-rw-r--r--spec/functional/resource/user/dscl_spec.rb1
-rw-r--r--spec/functional/resource/user/useradd_spec.rb1
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/support/platform_helpers.rb14
5 files changed, 21 insertions, 2 deletions
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 0726b08ded..0c0c85e18b 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -652,7 +652,11 @@ user password using shadow hash.")
def run_plutil(*args)
result = shell_out("plutil -#{args.join(' ')}")
raise(Chef::Exceptions::PlistUtilCommandFailed,"plutil error: #{result.inspect}") unless result.exitstatus == 0
- result.stdout
+ if result.stdout.encoding == Encoding::ASCII_8BIT
+ result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => '?')
+ else
+ result.stdout
+ end
end
def convert_binary_plist_to_xml(binary_plist_string)
diff --git a/spec/functional/resource/user/dscl_spec.rb b/spec/functional/resource/user/dscl_spec.rb
index 45b6754453..f091a0ebac 100644
--- a/spec/functional/resource/user/dscl_spec.rb
+++ b/spec/functional/resource/user/dscl_spec.rb
@@ -21,7 +21,6 @@ require 'chef/mixin/shell_out'
metadata = {
:unix_only => true,
:requires_root => true,
- :provider => {:user => Chef::Provider::User::Dscl},
:not_supported_on_mac_osx_106 => true,
}
diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb
index 9ac88d7b60..852f2eb083 100644
--- a/spec/functional/resource/user/useradd_spec.rb
+++ b/spec/functional/resource/user/useradd_spec.rb
@@ -32,6 +32,7 @@ end
metadata = { :unix_only => true,
:requires_root => true,
+ :not_supported_on_mac_osx => true,
:provider => {:user => user_provider_for_platform}
}
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 8888efc424..12b7db55da 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -114,6 +114,7 @@ RSpec.configure do |config|
# Add jruby filters here
config.filter_run_excluding :windows_only => true unless windows?
config.filter_run_excluding :not_supported_on_mac_osx_106 => true if mac_osx_106?
+ config.filter_run_excluding :not_supported_on_mac_osx=> true if mac_osx?
config.filter_run_excluding :not_supported_on_win2k3 => true if windows_win2k3?
config.filter_run_excluding :not_supported_on_solaris => true if solaris?
config.filter_run_excluding :win2k3_only => true unless windows_win2k3?
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index a412fe38e1..da0313758b 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -88,6 +88,20 @@ def mac_osx_106?
false
end
+def mac_osx?
+ if File.exists? "/usr/bin/sw_vers"
+ result = ShellHelpers.shell_out("/usr/bin/sw_vers")
+ result.stdout.each_line do |line|
+ if line =~ /^ProductName:\sMac OS X.*$/
+ return true
+ end
+ end
+ end
+
+ false
+end
+
+
# detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system)
def windows64?
windows? && ( ENV['PROCESSOR_ARCHITECTURE'] == 'AMD64' || ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64' )