summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-03-09 17:09:00 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-03-09 17:09:00 -0700
commit573999f631c662c9bb111d1a6ce61c7f61d6c85c (patch)
tree2cfd7bc74050632481c78415b3701d818461b2fd
parentb57ede8e5d829f623aceb7d7b77631f9c63d539f (diff)
downloadchef-573999f631c662c9bb111d1a6ce61c7f61d6c85c.tar.gz
Sometimes plutil returns an invalid utf-8 string, which gets interpreted as ascii
This causes plist gem to crash
-rw-r--r--lib/chef/provider/user/dscl.rb6
1 files changed, 5 insertions, 1 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)