summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Powell <powell@progress.com>2022-08-11 15:34:44 -0400
committerThomas Powell <powell@progress.com>2022-08-11 15:34:44 -0400
commitb9dc7284e9d7ef11d0808a4b81b32591036a5e04 (patch)
treeb4ab57b3a4a61c61397dc97c374d59112315ac69
parentea7002d361647f3f315feb35085943e88196c8ef (diff)
downloadchef-b9dc7284e9d7ef11d0808a4b81b32591036a5e04.tar.gz
Trapping and more debugging for shimtp-INFC-218
Signed-off-by: Thomas Powell <powell@progress.com>
-rw-r--r--Gemfile13
-rw-r--r--lib/chef/http/authenticator.rb10
-rw-r--r--post-bundle-install.rb28
3 files changed, 37 insertions, 14 deletions
diff --git a/Gemfile b/Gemfile
index 5827d92e69..0dc2f77526 100644
--- a/Gemfile
+++ b/Gemfile
@@ -36,12 +36,6 @@ end
# proxifier gem is busted on ruby 3.1 and seems abandoned so use git fork of gem
gem "proxifier", git: "https://github.com/chef/ruby-proxifier", branch: "lcg/ruby-3"
-# Everything except AIX and Windows
-group(:ruby_shadow) do
- # if ruby-shadow does a release that supports ruby-3.0 this can be removed
- gem "ruby-shadow", git: "https://github.com/chef/ruby-shadow", branch: "lcg/ruby-3.0", platforms: :ruby
-end
-
# deps that cannot be put in the knife gem because they require a compiler and fail on windows nodes
group(:knife_windows_deps) do
gem "ed25519", "~> 1.2" # ed25519 ssh key support
@@ -54,11 +48,6 @@ group(:development, :test) do
gem "fauxhai-ng" # for chef-utils gem
end
-group(:chefstyle) do
- # for testing new chefstyle rules
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "main"
-end
-
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
# If you want to load debugging tools into the bundle exec sandbox,
@@ -76,6 +65,8 @@ eval_gemfile("./Gemfile.local") if File.exist?("./Gemfile.local")
# We copy (and overwrite) these files every time "bundle <exec|install>" is
# executed, just in case they have changed.
if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
+ gem "chef-powershell", git: "https://github.com/chef/chef-powershell-shim.git", branch: "neha-p6/rescue_ffi_parsing", glob: "chef-powershell/*.gemspec"
+
instance_eval do
ruby_exe_dir = RbConfig::CONFIG["bindir"]
assemblies = Dir.glob(File.expand_path("distro/ruby_bin_folder/#{ENV["PROCESSOR_ARCHITECTURE"]}", __dir__) + "**/*")
diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb
index 820a789934..59fa0112b1 100644
--- a/lib/chef/http/authenticator.rb
+++ b/lib/chef/http/authenticator.rb
@@ -212,10 +212,18 @@ class Chef
def self.decrypt_pfx_pass(password)
powershell_code = <<~CODE
$secure_string = "#{password}" | ConvertTo-SecureString
+ $secure_string | Out-File -FilePath C:\\secure_string.txt
$string = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR((($secure_string))))
+ $string | Out-File -FilePath C:\\decrypted_string.txt
return $string
CODE
- powershell_exec!(powershell_code).result
+ begin
+ powershell_exec!(powershell_code).result
+ rescue StandardError => error
+ p error
+ end
+ puts "======== secure string " + File.read("C:/secure_string.txt")
+ puts "======== descrypted " + File.read("C:/decrypted_string.txt")
end
def self.retrieve_certificate_key(client_name)
diff --git a/post-bundle-install.rb b/post-bundle-install.rb
index 86a530bffd..201033e098 100644
--- a/post-bundle-install.rb
+++ b/post-bundle-install.rb
@@ -1,5 +1,7 @@
#!/usr/bin/env ruby
+require 'fileutils'
+
gem_home = Gem.paths.home
puts "fixing bundle installed gems in #{gem_home}"
@@ -9,10 +11,28 @@ puts "fixing bundle installed gems in #{gem_home}"
# rake install since we need --conservative --minimal-deps in order to not install duplicate gems.
#
Dir["#{gem_home}/bundler/gems/*"].each do |gempath|
+ puts "===Gempath: #{gempath.inspect}"
matches = File.basename(gempath).match(/.*-[A-Fa-f0-9]{12}/)
next unless matches
- gem_name = File.basename(Dir["#{gempath}/*.gemspec"].first, ".gemspec")
+ if gempath.match("chef-powershell")
+ path = "#{gempath}/chef-powershell"
+
+ #For now copy the windowspowershell dlls at chef/chef to gem here
+ dll_files = Dir.glob(File.expand_path("distro/ruby_bin_folder/#{ENV["PROCESSOR_ARCHITECTURE"]}", __dir__) + "**/*")
+ puts "=== dll files #{dll_files.inspect}"
+ bin_path = "#{path}/bin/ruby_bin_folder/#{ENV["PROCESSOR_ARCHITECTURE"]}"
+ puts "==== bin_path:#{bin_path}"
+
+ FileUtils.mkdir_p "#{bin_path}"
+ FileUtils.cp_r dll_files, bin_path
+
+ puts "=== bin_path contents after copying: #{Dir[bin_path + '/*']}}"
+ else
+ path = "#{gempath}"
+ end
+
+ gem_name = File.basename(Dir["#{path}/*.gemspec"].first, ".gemspec")
# FIXME: should strip any valid ruby platform off of the gem_name if it matches
next unless gem_name
@@ -22,7 +42,11 @@ Dir["#{gem_home}/bundler/gems/*"].each do |gempath|
puts "re-installing #{gem_name}..."
- Dir.chdir(gempath) do
+ Dir.chdir(path) do
+ if gem_name == "chef-powershell"
+ File.delete("#{gem_name}.gemspec") if File.exist?("#{gem_name}.gemspec")
+ File.rename("template.txt", "chef-powershell.gemspec")
+ end
system("gem build #{gem_name}.gemspec") or raise "gem build failed"
system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise "gem install failed"
end