Skip to content

Commit

Permalink
Fix verify step for sudo to be more robust to outside config changes.
Browse files Browse the repository at this point in the history
test-kitchen was setting sudo_command to "sudo -E" which conflicts
with us trying to run `sudo -v`. This bypasses `run` entirely and just
runs `sudo -v` as-is. It would be nice if we could use `sudo_command`,
but we'd have to sanitize it if that were the case.

Signed-off-by: Ryan Davis <[email protected]>
  • Loading branch information
zenspider committed Jan 17, 2020
1 parent efadf53 commit d4a7788
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/train/extras/command_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def initialize(backend, options)
def verify
cmd = if @sudo
# Wrap it up. It needs /dev/null on the outside to disable stdin
"bash -c '(#{run("-v")}) < /dev/null'"
# NOTE: can't use @sudo_command because -v conflicts with -E.
# See test-kitchen's use of this variable for conflict.
"sh -c '(sudo -v) < /dev/null'"
else
run("echo")
end
Expand Down

0 comments on commit d4a7788

Please sign in to comment.