Merge pull request #6475 from nikelmwann/linux-host-use-xfreerdp

Prefer xfreerdp for RDP connections on Linux hosts.
This commit is contained in:
Mitchell Hashimoto 2015-11-18 15:12:47 -08:00
commit 9e1a119a4b
3 changed files with 33 additions and 14 deletions

View File

@ -404,8 +404,8 @@ module Vagrant
error_key(:linux_nfs_mount_failed) error_key(:linux_nfs_mount_failed)
end end
class LinuxRDesktopNotFound < VagrantError class LinuxRDPClientNotFound < VagrantError
error_key(:linux_rdesktop_not_found) error_key(:linux_rdp_client_not_found)
end end
class LocalDataDirectoryNotAccessible < VagrantError class LocalDataDirectoryNotAccessible < VagrantError

View File

@ -5,17 +5,35 @@ module VagrantPlugins
module Cap module Cap
class RDP class RDP
def self.rdp_client(env, rdp_info) def self.rdp_client(env, rdp_info)
if !Vagrant::Util::Which.which("rdesktop") # Detect if an RDP client is available.
raise Vagrant::Errors::LinuxRDesktopNotFound # Prefer xfreerdp as it supports newer versions of RDP.
end rdp_client =
if Vagrant::Util::Which.which("xfreerdp")
"xfreerdp"
elsif Vagrant::Util::Which.which("rdesktop")
"rdesktop"
else
raise Vagrant::Errors::LinuxRDPClientNotFound
end
args = [] args = []
args << "-u" << rdp_info[:username]
args << "-p" << rdp_info[:password] if rdp_info[:password]
args += rdp_info[:extra_args] if rdp_info[:extra_args]
args << "#{rdp_info[:host]}:#{rdp_info[:port]}"
Vagrant::Util::Subprocess.execute("rdesktop", *args) # Build appropriate arguments for the RDP client.
case rdp_client
when "xfreerdp"
args << "/u:#{rdp_info[:username]}"
args << "/p:#{rdp_info[:password]}" if rdp_info[:password]
args << "/v:#{rdp_info[:host]}:#{rdp_info[:port]}"
args += rdp_info[:extra_args] if rdp_info[:extra_args]
when "rdesktop"
args << "-u" << rdp_info[:username]
args << "-p" << rdp_info[:password] if rdp_info[:password]
args += rdp_info[:extra_args] if rdp_info[:extra_args]
args << "#{rdp_info[:host]}:#{rdp_info[:port]}"
end
# Finally, run the client.
Vagrant::Util::Subprocess.execute(rdp_client, *args)
end end
end end
end end

View File

@ -823,10 +823,11 @@ en:
that the NFS client software is properly installed, and consult any resources that the NFS client software is properly installed, and consult any resources
specific to the linux distro you're using for more information on how to specific to the linux distro you're using for more information on how to
do this. do this.
linux_rdesktop_not_found: |- linux_rdp_client_not_found: |-
The `rdesktop` application was not found. Vagrant requires this An appropriate RDP client was not found. Vagrant requires either
in order to connect via RDP to the Vagrant environment. Please ensure `xfreerdp` or `rdesktop` in order to connect via RDP to the Vagrant
this application is installed and available on the path and try again. environment. Please ensure one of these applications is installed and
available on the path and try again.
machine_action_locked: |- machine_action_locked: |-
An action '%{action}' was attempted on the machine '%{name}', An action '%{action}' was attempted on the machine '%{name}',
but another process is already executing an action on the machine. but another process is already executing an action on the machine.