diff --git a/config/default.rb b/config/default.rb index faa7f5e08..99a58a4d6 100644 --- a/config/default.rb +++ b/config/default.rb @@ -12,6 +12,7 @@ Vagrant::Config.run do |config| config.ssh.timeout = 30 config.ssh.private_key_path = File.expand_path("keys/vagrant", Vagrant.source_root) config.ssh.forward_agent = false + config.ssh.forward_x11 = false config.vm.auto_port_range = (2200..2250) config.vm.box_ovf = "box.ovf" diff --git a/lib/vagrant/config/ssh.rb b/lib/vagrant/config/ssh.rb index ca15c2cd4..de4347ce5 100644 --- a/lib/vagrant/config/ssh.rb +++ b/lib/vagrant/config/ssh.rb @@ -11,6 +11,7 @@ module Vagrant attr_accessor :timeout attr_writer :private_key_path attr_accessor :forward_agent + attr_accessor :forward_x11 def private_key_path File.expand_path(@private_key_path, env.root_path) diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 8b8ce2223..16e305502 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -42,6 +42,7 @@ module Vagrant "-o StrictHostKeyChecking=no", "-o IdentitiesOnly=yes", "-i #{options[:private_key_path]}"] command_options << "-o ForwardAgent=yes" if env.config.ssh.forward_agent + command_options << "-o ForwardX11=yes" if env.config.ssh.forward_x11 # Some hackery going on here. On Mac OS X Leopard (10.5), exec fails # (GH-51). As a workaround, we fork and wait. On all other platforms, diff --git a/test/vagrant/ssh_test.rb b/test/vagrant/ssh_test.rb index 0acb81e62..0e96c4e1b 100644 --- a/test/vagrant/ssh_test.rb +++ b/test/vagrant/ssh_test.rb @@ -69,6 +69,17 @@ class SshTest < Test::Unit::TestCase @ssh.connect end + should "add forward X11 option if enabled" do + @env.config.ssh.forward_x11 = true + ssh_exec_expect(@ssh.port, + @env.config.ssh.private_key_path, + @env.config.ssh.username, + @env.config.ssh.host) do |args| + assert args =~ /-o ForwardX11=yes/ + end + @ssh.connect + end + context "on leopard" do setup do Vagrant::Util::Platform.stubs(:leopard?).returns(true)