From a55a53e6a46438d5093487f83248f01ddece4534 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 13 Dec 2013 21:02:00 -0800 Subject: [PATCH] core: execute SSH commands in context of login shell [GH-2636] --- CHANGELOG.md | 2 ++ lib/vagrant/action/builtin/ssh_run.rb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2f0b1cee..94183c187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ IMPROVEMENTS: BUG FIXES: - core: box removal of a V1 box works + - core: `vagrant ssh -c` commands are now executed in the context of + a login shell (regression). [GH-2636] - guests/debian: fix `use_dhcp_assigned_default_route` to work properly. [GH-2648] - guests/debian,ubuntu: fix change\_host\_name for FQDNs with trailing diff --git a/lib/vagrant/action/builtin/ssh_run.rb b/lib/vagrant/action/builtin/ssh_run.rb index 1b155178d..afa8253ec 100644 --- a/lib/vagrant/action/builtin/ssh_run.rb +++ b/lib/vagrant/action/builtin/ssh_run.rb @@ -32,8 +32,14 @@ module Vagrant end end - # Execute! + # Get the command and wrap it in a login shell command = env[:ssh_run_command] + command = command.gsub(/'/) do |m| + "#{m}\\#{m}#{m}" + end + command = "#{env[:machine].config.ssh.shell} -c '#{command}'" + + # Execute! opts = env[:ssh_opts] || {} opts[:extra_args] = ["-t", command] opts[:subprocess] = true