Allow sudo wrapping but default to no-op

This commit is contained in:
Chris Roberts 2017-04-16 07:59:29 -07:00
parent c56acfab94
commit b35c68eacc
2 changed files with 7 additions and 2 deletions

View File

@ -20,7 +20,7 @@ module VagrantPlugins
sudo = opts[:sudo] sudo = opts[:sudo]
@logger.info("Execute: #{command}") @logger.info("Execute: #{command} (sudo=#{sudo.inspect})")
exit_status = nil exit_status = nil
# Open the channel so we can execute or command # Open the channel so we can execute or command
@ -56,6 +56,9 @@ SCRIPT
upload(tfile.path, remote_name) upload(tfile.path, remote_name)
tfile.delete tfile.delete
base_cmd = shell_cmd(opts.merge(shell: base_cmd))
@logger.debug("Base SSH exec command: #{base_cmd}")
ch.exec(base_cmd) do |ch2, _| ch.exec(base_cmd) do |ch2, _|
# Setup the channel callbacks so we can get data and exit status # Setup the channel callbacks so we can get data and exit status
ch2.on_data do |ch3, data| ch2.on_data do |ch3, data|

View File

@ -1,12 +1,14 @@
require File.expand_path("../../../kernel_v2/config/ssh", __FILE__) require File.expand_path("../../../kernel_v2/config/ssh", __FILE__)
# forward_x11 pty sudo_command
module VagrantPlugins module VagrantPlugins
module CommunicatorWinSSH module CommunicatorWinSSH
class Config < VagrantPlugins::Kernel_V2::SSHConfig class Config < VagrantPlugins::Kernel_V2::SSHConfig
def finalize! def finalize!
@shell = "cmd" if @shell == UNSET_VALUE @shell = "cmd" if @shell == UNSET_VALUE
@sudo_command = "cmd" if @sudo_command == UNSET_VALUE @sudo_command = "%c" if @sudo_command == UNSET_VALUE
if @export_command_template == UNSET_VALUE if @export_command_template == UNSET_VALUE
if @shell == "cmd" if @shell == "cmd"
@export_command_template = 'set %ENV_KEY%="%ENV_VALUE%"' @export_command_template = 'set %ENV_KEY%="%ENV_VALUE%"'