| Server IP : 77.68.64.21 / Your IP : 216.73.217.105 Web Server : Apache System : Linux hp3-wp-1011378.hostingp3.local 3.10.0-1160.144.1.el7.tuxcare.els9.x86_64 #1 SMP Fri Jul 10 17:06:31 UTC 2026 x86_64 User : csh2668128 ( 2112425) PHP Version : 8.1.34 Disable Function : shell_exec,exec,system,popen,set_time_limit MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/ruby/vendor_ruby/puppet/util/windows/ |
Upload File : |
require 'puppet/util/windows'
module Puppet::Util::Windows
module Registry
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
KEY64 = 0x100
KEY32 = 0x200
KEY_READ = 0x20019
KEY_WRITE = 0x20006
KEY_ALL_ACCESS = 0x2003f
def root(name)
Win32::Registry.const_get(name)
rescue NameError
raise Puppet::Error, "Invalid registry key '#{name}'", $!.backtrace
end
def open(name, path, mode = KEY_READ | KEY64, &block)
hkey = root(name)
begin
hkey.open(path, mode) do |subkey|
return yield subkey
end
rescue Win32::Registry::Error => error
raise Puppet::Util::Windows::Error.new("Failed to open registry key '#{hkey.keyname}\\#{path}'", error.code, error)
end
end
def values(subkey)
values = {}
subkey.each_value do |name, type, data|
case type
when Win32::Registry::REG_MULTI_SZ
data.each { |str| force_encoding(str) }
when Win32::Registry::REG_SZ, Win32::Registry::REG_EXPAND_SZ
force_encoding(data)
end
values[name] = data
end
values
end
if defined?(Encoding)
def force_encoding(str)
if @encoding.nil?
# See https://bugs.ruby-lang.org/issues/8943
# Ruby uses ANSI versions of Win32 APIs to read values from the
# registry. The encoding of these strings depends on the active
# code page. However, ruby incorrectly sets the string
# encoding to US-ASCII. So we must force the encoding to the
# correct value.
require 'windows/national'
begin
cp = Windows::National::GetACP.call
@encoding = Encoding.const_get("CP#{cp}")
rescue
@encoding = Encoding.default_external
end
end
str.force_encoding(@encoding)
end
else
def force_encoding(str, enc)
end
end
private :force_encoding
end
end