From ec57a286cd8fd3aeeff50a03ab71387c1bde5866 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 20 Apr 2014 21:06:07 -0700 Subject: [PATCH] hosts/darwin: use a temp dir since Tempfile is deleted right away --- plugins/hosts/darwin/cap/rdp.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/hosts/darwin/cap/rdp.rb b/plugins/hosts/darwin/cap/rdp.rb index a33ba008f..93ff71c31 100644 --- a/plugins/hosts/darwin/cap/rdp.rb +++ b/plugins/hosts/darwin/cap/rdp.rb @@ -1,4 +1,5 @@ -require "tempfile" +require "pathname" +require "tmpdir" require "vagrant/util/subprocess" @@ -7,7 +8,6 @@ module VagrantPlugins module Cap class RDP def self.rdp_client(env, rdp_info) - config = nil opts = { "drivestoredirect:s" => "*", "full address:s" => "#{rdp_info[:host]}:#{rdp_info[:port]}", @@ -16,16 +16,16 @@ module VagrantPlugins } # Create the ".rdp" file - config = Tempfile.new(["vagrant-rdp", ".rdp"]) - opts.each do |k, v| - config.puts("#{k}:#{v}") + config_path = Pathname.new(Dir.tmpdir).join( + "vagrant-rdp-#{Time.now.to_i}-#{rand(10000)}.rdp") + config_path.open("w+") do |f| + opts.each do |k, v| + f.puts("#{k}:#{v}") + end end - config.close # Launch it - Vagrant::Util::Subprocess.execute("open", config.path) - ensure - config.close if config + Vagrant::Util::Subprocess.execute("open", config_path.to_s) end end end