Skip to content

Commit

Permalink
ensure we pass the registry redirection flag into reg.open
Browse files Browse the repository at this point in the history
  • Loading branch information
schisamo committed Oct 28, 2011
1 parent 23389f1 commit f217996
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions windows/providers/feature_dism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
include Windows::Helper

def install_feature(name)
shell_out!("#{dism} /online /enable-feature /featurename:#{@new_resource.feature_name} /norestart", {:returns => [0,42]})
shell_out!("#{dism} /online /enable-feature /featurename:#{@new_resource.feature_name} /norestart", {:returns => [0,42,127]})
end

def remove_feature(name)
shell_out!("#{dism} /online /disable-feature /featurename:#{@new_resource.feature_name} /norestart", {:returns => [0,42]})
shell_out!("#{dism} /online /disable-feature /featurename:#{@new_resource.feature_name} /norestart", {:returns => [0,42,127]})
end

def installed?
@installed ||= begin
cmd = shell_out("#{dism} /online /Get-Features", {:returns => [0,42]})
cmd = shell_out("#{dism} /online /Get-Features", {:returns => [0,42,127]})
cmd.stderr.empty? && (cmd.stdout =~ /^Feature Name : #{@new_resource.feature_name}$\n^State : Enabled$/i)
end
end
Expand Down
6 changes: 3 additions & 3 deletions windows/providers/feature_servermanagercmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
include Windows::Helper

def install_feature(name)
shell_out!("#{servermanagercmd} -install #{@new_resource.feature_name}", {:returns => [0,42]})
shell_out!("#{servermanagercmd} -install #{@new_resource.feature_name}", {:returns => [0,42,127]})
end

def remove_feature(name)
shell_out!("#{servermanagercmd} -remove #{@new_resource.feature_name}", {:returns => [0,42]})
shell_out!("#{servermanagercmd} -remove #{@new_resource.feature_name}", {:returns => [0,42,127]})
end

def installed?
@installed ||= begin
cmd = shell_out("#{servermanagercmd} -query", {:returns => [0,42]})
cmd = shell_out("#{servermanagercmd} -query", {:returns => [0,42,127]})
cmd.stderr.empty? && (cmd.stdout =~ /^\s*?\[X\]\s.+?\s\[#{@new_resource.feature_name}\]$/i)
end
end
Expand Down
30 changes: 15 additions & 15 deletions windows/providers/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
include Chef::Mixin::ShellOut
include Windows::Helper

# the logic in all action methods mirror that of
# the logic in all action methods mirror that of
# the Chef::Provider::Package which will make
# refactoring into core chef easy

Expand Down Expand Up @@ -86,8 +86,8 @@ def expand_options(options)
options ? " #{options}" : ""
end

# these methods are the required overrides of
# a provider that extends from Chef::Provider::Package
# these methods are the required overrides of
# a provider that extends from Chef::Provider::Package
# so refactoring into core Chef should be easy

def load_current_resource
Expand Down Expand Up @@ -163,7 +163,7 @@ def unattended_installation_flags
case installer_type
when :msi
"/qb /i"
when :installshield
when :installshield
"/s /sms"
when :nsis
"/S /NCRC"
Expand All @@ -189,8 +189,6 @@ def installed_packages
installed_packages.merge!(extract_installed_packages_from_key(Win32::Registry::HKEY_LOCAL_MACHINE, (Win32::Registry::Constants::KEY_READ | 0x0200))) #rescue nil
# Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
installed_packages.merge!(extract_installed_packages_from_key(Win32::Registry::HKEY_CURRENT_USER)) #rescue nil
# require 'pp'
# pp installed_packages
installed_packages
end
end
Expand All @@ -201,15 +199,17 @@ def extract_installed_packages_from_key(hkey = Win32::Registry::HKEY_LOCAL_MACHI
begin
Win32::Registry.open(hkey, uninstall_subkey, desired) do |reg|
reg.each_key do |key, wtime|
k = reg.open(key)
display_name = k["DisplayName"] rescue nil
version = k["DisplayVersion"] rescue "NO VERSION"
uninstall_string = k["UninstallString"] rescue nil

if display_name
packages[display_name] = {:name => display_name,
:version => version,
:uninstall_string => uninstall_string}
begin
k = reg.open(key, desired)
display_name = k["DisplayName"] rescue nil
version = k["DisplayVersion"] rescue "NO VERSION"
uninstall_string = k["UninstallString"] rescue nil
if display_name
packages[display_name] = {:name => display_name,
:version => version,
:uninstall_string => uninstall_string}
end
rescue Win32::Registry::Error
end
end
end
Expand Down

0 comments on commit f217996

Please sign in to comment.