Prefer xfreerdp for RDP connections on Linux hosts.
Rather than only using rdesktop (which does not work properly with newer versions of RDP), use xfreerdp if available and fall back to rdesktop if not.
This commit is contained in:
parent
73edde7356
commit
879977832c
|
@ -5,17 +5,35 @@ module VagrantPlugins
|
|||
module Cap
|
||||
class RDP
|
||||
def self.rdp_client(env, rdp_info)
|
||||
if !Vagrant::Util::Which.which("rdesktop")
|
||||
raise Vagrant::Errors::LinuxRDesktopNotFound
|
||||
end
|
||||
# Detect if an RDP client is available.
|
||||
# Prefer xfreerdp as it supports newer versions of RDP.
|
||||
rdp_client =
|
||||
if Vagrant::Util::Which.which("xfreerdp")
|
||||
"xfreerdp"
|
||||
elsif Vagrant::Util::Which.which("rdesktop")
|
||||
"rdesktop"
|
||||
else
|
||||
raise Vagrant::Errors::LinuxRDesktopNotFound
|
||||
end
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue