summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <claire@chef.io>2015-09-01 15:27:48 -0700
committerClaire McQuin <claire@chef.io>2015-09-03 11:18:22 -0700
commit55a6507b98b69652d9b5c74f4209c6472e356834 (patch)
treeb35cc82a0b5f5ff6488980197c910f7b2b6d1119
parent8143bf6010cfcef180a8bc85a5e71dc3eb1a8f81 (diff)
downloadchef-55a6507b98b69652d9b5c74f4209c6472e356834.tar.gz
Monkey-patch Win32::Registry::API::DeleteValue for Win32::Registry#delete_value.
-rw-r--r--lib/chef/monkey_patches/win32/registry.rb23
-rw-r--r--lib/chef/win32/api/registry.rb6
-rw-r--r--lib/chef/win32/registry.rb4
3 files changed, 33 insertions, 0 deletions
diff --git a/lib/chef/monkey_patches/win32/registry.rb b/lib/chef/monkey_patches/win32/registry.rb
new file mode 100644
index 0000000000..c7279ced92
--- /dev/null
+++ b/lib/chef/monkey_patches/win32/registry.rb
@@ -0,0 +1,23 @@
+
+require 'chef/win32/api/registry'
+require 'chef/win32/unicode'
+require 'win32/registry'
+
+module Win32
+ class Registry
+ module API
+
+ extend Chef::ReservedNames::Win32::API::Registry
+
+ 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)
+ end
+
+ end
+ end
+end \ No newline at end of file
diff --git a/lib/chef/win32/api/registry.rb b/lib/chef/win32/api/registry.rb
index 45b91d7d32..cbbf6b66bb 100644
--- a/lib/chef/win32/api/registry.rb
+++ b/lib/chef/win32/api/registry.rb
@@ -39,6 +39,12 @@ class Chef
safe_attach_function :RegDeleteKeyExW, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG
safe_attach_function :RegDeleteKeyExA, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG
+ # LONG WINAPI RegDeleteValue(
+ # _In_ HKEY hKey,
+ # _In_opt_ LPCTSTR lpValueName
+ # );
+ safe_attach_function :RegDeleteValueW, [ :HKEY, :LPCTSTR ], :LONG
+
end
end
end
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index b25ce7937e..877c2ebff3 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -21,6 +21,10 @@ 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/win32/api/registry'
require 'win32/registry'
require 'win32/api'