summaryrefslogtreecommitdiff
path: root/lib/chef/provider/execute.rb
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2017-06-13 15:41:45 -0700
committerThom May <thom@chef.io>2018-03-22 11:10:50 +0000
commit7354ffb870dbc39cda29f8caed3211491323899f (patch)
tree24944fce7dd1d79880bb470f2409e4a7cacf407c /lib/chef/provider/execute.rb
parent87247ca010af724763efb8e1817f5d67009c6608 (diff)
downloadchef-7354ffb870dbc39cda29f8caed3211491323899f.tar.gz
Use a better (read: working) technique because I was totally wrong about $!.pr-6203
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'lib/chef/provider/execute.rb')
-rw-r--r--lib/chef/provider/execute.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index 11c84eaf9e..0e9acb4028 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -58,9 +58,12 @@ class Chef
shell_out_with_systems_locale!(command, opts)
rescue Mixlib::ShellOut::ShellCommandFailed
if sensitive?
- $! = nil
- raise Mixlib::ShellOut::ShellCommandFailed,
- "Command execution failed. STDOUT/STDERR suppressed for sensitive resource"
+ ex = Mixlib::ShellOut::ShellCommandFailed.new("Command execution failed. STDOUT/STDERR suppressed for sensitive resource")
+ # Forcibly hide the exception cause chain here so we don't log the unredacted version
+ def ex.cause
+ nil
+ end
+ raise ex
else
raise
end