diff options
author | Claire McQuin <claire@chef.io> | 2015-09-02 09:11:26 -0700 |
---|---|---|
committer | Claire McQuin <claire@chef.io> | 2015-09-03 11:18:23 -0700 |
commit | 30b588f7035c2a219bc96a0b055f1d0eb8e16d3c (patch) | |
tree | 720c02e509a8bb3bc3a42daecfef46b5e67edff2 /lib | |
parent | 55a6507b98b69652d9b5c74f4209c6472e356834 (diff) | |
download | chef-30b588f7035c2a219bc96a0b055f1d0eb8e16d3c.tar.gz |
Monkey-patch Win32::Registry::API::DeleteKey for Win32::Registry#delete_key
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/monkey_patches/win32/registry.rb | 19 | ||||
-rw-r--r-- | lib/chef/win32/registry.rb | 5 |
2 files changed, 15 insertions, 9 deletions
diff --git a/lib/chef/monkey_patches/win32/registry.rb b/lib/chef/monkey_patches/win32/registry.rb index c7279ced92..a754949ca0 100644 --- a/lib/chef/monkey_patches/win32/registry.rb +++ b/lib/chef/monkey_patches/win32/registry.rb @@ -11,11 +11,20 @@ module Win32 module_function - # ::Win32::Registry#delete_value is broken in Ruby 2.1 (up to Ruby 2.1.6p336). - # This should be resolved a later release (see note #9 in link below). - # https://bugs.ruby-lang.org/issues/10820 - def DeleteValue(hkey, name) - check RegDeleteValueW(hkey, name.to_wstring) + if RUBY_VERSION =~ /^2\.1/ + # ::Win32::Registry#delete_value is broken in Ruby 2.1 (up to Ruby 2.1.6). + # This should be resolved in a later release (see note #9 in link below). + # https://bugs.ruby-lang.org/issues/10820 + def DeleteValue(hkey, name) + check RegDeleteValueW(hkey, name.to_wstring) + end + end + + # ::Win32::Registry#delete_key uses RegDeleteKeyW. We need to use + # RegDeleteKeyExW to properly support WOW64 systems. + def DeleteKey(hkey, name) + arch_mask = win64? ? 0x0100 : 0x0200 + check RegDeleteKeyExW(hkey, name.to_wstring, KEY_WRITE | arch_mask, 0) end end diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb index 877c2ebff3..3a01553445 100644 --- a/lib/chef/win32/registry.rb +++ b/lib/chef/win32/registry.rb @@ -21,10 +21,7 @@ require 'chef/win32/api' require 'chef/mixin/wide_string' if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - if RUBY_VERSION =~ /^2\.1/ - require 'chef/monkey_patches/win32/registry' - end - + require 'chef/monkey_patches/win32/registry' require 'chef/win32/api/registry' require 'win32/registry' require 'win32/api' |