summaryrefslogtreecommitdiff
path: root/lib/chef/win32/unicode.rb
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2014-07-09 16:05:27 -0700
committersersut <serdar@opscode.com>2014-07-14 13:18:31 -0700
commit04612158ac256ce46faad599e141ff7d1161fd66 (patch)
tree5d6ff018c0173c2ec0282bf9e68357964a06e578 /lib/chef/win32/unicode.rb
parent3ec42a522a5b40d1ef217f23831b7417bda65761 (diff)
downloadchef-04612158ac256ce46faad599e141ff7d1161fd66.tar.gz
Automatically find out the sid for Administrators so that the specs can run on boxes for which the administrators account is renamed.
Diffstat (limited to 'lib/chef/win32/unicode.rb')
-rw-r--r--lib/chef/win32/unicode.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/chef/win32/unicode.rb b/lib/chef/win32/unicode.rb
index 1002a4d58f..e7399d5255 100644
--- a/lib/chef/win32/unicode.rb
+++ b/lib/chef/win32/unicode.rb
@@ -30,7 +30,19 @@ end
module FFI
class Pointer
- def read_wstring(num_wchars)
+ def read_wstring(num_wchars = nil)
+ if num_wchars.nil?
+ # Find the length of the string
+ length = 0
+ last_char = nil
+ while last_char != "\000\000" do
+ length += 1
+ last_char = self.get_bytes(0,length * 2)[-2..-1]
+ end
+
+ num_wchars = length
+ end
+
Chef::ReservedNames::Win32::Unicode.wide_to_utf8(self.get_bytes(0, num_wchars*2))
end
end