Give a unique, prefixed name to all tempfiles
This commit basically grepped the code base for all uses of Dir.mktmpdir and Tempfile.new/open and ensures the value is unique within the code base and also prefixed with `vagrant-`. Previously, most invocations of these commands simply used "vagrant", thus making them indistinguishable when trying to identify leaks.
This commit is contained in:
parent
fb7c4033a9
commit
3d2390fc94
|
@ -56,7 +56,7 @@ module Vagrant
|
|||
|
||||
# Setup the "local" Bundler configuration. We need to set BUNDLE_PATH
|
||||
# because the existence of this actually suppresses `sudo`.
|
||||
@appconfigpath = Dir.mktmpdir
|
||||
@appconfigpath = Dir.mktmpdir("vagrant-bundle-app-config")
|
||||
File.open(File.join(@appconfigpath, "config"), "w+") do |f|
|
||||
f.write("BUNDLE_PATH: \"#{bundle_path}\"")
|
||||
end
|
||||
|
@ -254,14 +254,13 @@ module Vagrant
|
|||
def with_isolated_gem
|
||||
raise Errors::BundlerDisabled if !@enabled
|
||||
|
||||
tmp_gemfile = tempfile("vagrant-gemfile")
|
||||
tmp_gemfile.close
|
||||
tmp_gemfile = Dir::Tmpname.create("vagrant-gemfile") {}
|
||||
|
||||
# Remove bundler settings so that Bundler isn't loaded when building
|
||||
# native extensions because it causes all sorts of problems.
|
||||
old_rubyopt = ENV["RUBYOPT"]
|
||||
old_gemfile = ENV["BUNDLE_GEMFILE"]
|
||||
ENV["BUNDLE_GEMFILE"] = tmp_gemfile.path
|
||||
ENV["BUNDLE_GEMFILE"] = tmp_gemfile
|
||||
ENV["RUBYOPT"] = (ENV["RUBYOPT"] || "").gsub(/-rbundler\/setup\s*/, "")
|
||||
|
||||
# Set the GEM_HOME so gems are installed only to our local gem dir
|
||||
|
@ -291,7 +290,7 @@ module Vagrant
|
|||
return yield
|
||||
end
|
||||
ensure
|
||||
tmp_gemfile.unlink rescue nil
|
||||
File.unlink(tmp_gemfile) if File.file?(tmp_gemfile)
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] = old_gemfile
|
||||
ENV["GEM_HOME"] = @gem_home
|
||||
|
|
|
@ -125,7 +125,7 @@ module Vagrant
|
|||
# directory runs a different filesystem than the root directory.
|
||||
# However, this works in many cases.
|
||||
def fs_case_sensitive?
|
||||
Dir.mktmpdir("vagrant") do |tmp_dir|
|
||||
Dir.mktmpdir("vagrant-fs-case-sensitive") do |tmp_dir|
|
||||
tmp_file = File.join(tmp_dir, "FILE")
|
||||
File.open(tmp_file, "w") do |f|
|
||||
f.write("foo")
|
||||
|
|
|
@ -16,8 +16,7 @@ module VagrantPlugins
|
|||
SHA256SUM = "62f933115498e51ddf5f2dab47dc1eebb42eb78ea1a7665cb91c53edacc847c6".freeze
|
||||
|
||||
def self.provider_install_virtualbox(env)
|
||||
tf = Tempfile.new("vagrant")
|
||||
tf.close
|
||||
path = Dir::Tmpname.create("vagrant-provider-install-virtualbox") {}
|
||||
|
||||
# Prefixed UI for prettiness
|
||||
ui = Vagrant::UI::Prefixed.new(env.ui, "")
|
||||
|
@ -28,11 +27,11 @@ module VagrantPlugins
|
|||
version: VERSION))
|
||||
ui.detail(I18n.t(
|
||||
"vagrant.hosts.darwin.virtualbox_install_detail"))
|
||||
dl = Vagrant::Util::Downloader.new(URL, tf.path, ui: ui)
|
||||
dl = Vagrant::Util::Downloader.new(URL, path, ui: ui)
|
||||
dl.download!
|
||||
|
||||
# Validate that the file checksum matches
|
||||
actual = FileChecksum.new(tf.path, Digest::SHA2).checksum
|
||||
actual = FileChecksum.new(path, Digest::SHA2).checksum
|
||||
if actual != SHA256SUM
|
||||
raise Vagrant::Errors::ProviderChecksumMismatch,
|
||||
provider: "virtualbox",
|
||||
|
@ -46,7 +45,7 @@ module VagrantPlugins
|
|||
ui.detail(I18n.t(
|
||||
"vagrant.hosts.darwin.virtualbox_install_install_detail"))
|
||||
script = File.expand_path("../../scripts/install_virtualbox.sh", __FILE__)
|
||||
result = Vagrant::Util::Subprocess.execute("bash", script, tf.path)
|
||||
result = Vagrant::Util::Subprocess.execute("bash", script, path)
|
||||
if result.exit_code != 0
|
||||
raise Vagrant::Errors::ProviderInstallFailed,
|
||||
provider: "virtualbox",
|
||||
|
|
|
@ -17,8 +17,7 @@ module VagrantPlugins
|
|||
SHA256SUM = "3e5ed8fe4ada6eef8dfb4fe6fd79fcab4b242acf799f7d3ab4a17b43838b1e04".freeze
|
||||
|
||||
def self.provider_install_virtualbox(env)
|
||||
tf = Tempfile.new("vagrant")
|
||||
tf.close
|
||||
path = Dir::Tmpname.create("vagrant-provider-install-virtualbox") {}
|
||||
|
||||
# Prefixed UI for prettiness
|
||||
ui = Vagrant::UI::Prefixed.new(env.ui, "")
|
||||
|
@ -29,11 +28,11 @@ module VagrantPlugins
|
|||
version: VERSION))
|
||||
ui.detail(I18n.t(
|
||||
"vagrant.hosts.windows.virtualbox_install_detail"))
|
||||
dl = Vagrant::Util::Downloader.new(URL, tf.path, ui: ui)
|
||||
dl = Vagrant::Util::Downloader.new(URL, path, ui: ui)
|
||||
dl.download!
|
||||
|
||||
# Validate that the file checksum matches
|
||||
actual = FileChecksum.new(tf.path, Digest::SHA2).checksum
|
||||
actual = FileChecksum.new(path, Digest::SHA2).checksum
|
||||
if actual != SHA256SUM
|
||||
raise Vagrant::Errors::ProviderChecksumMismatch,
|
||||
provider: "virtualbox",
|
||||
|
@ -47,7 +46,7 @@ module VagrantPlugins
|
|||
ui.detail(I18n.t(
|
||||
"vagrant.hosts.windows.virtualbox_install_install_detail"))
|
||||
script = File.expand_path("../../scripts/install_virtualbox.ps1", __FILE__)
|
||||
result = Vagrant::Util::PowerShell.execute(script, tf.path)
|
||||
result = Vagrant::Util::PowerShell.execute(script, path)
|
||||
if result.exit_code != 0
|
||||
raise Vagrant::Errors::ProviderInstallFailed,
|
||||
provider: "virtualbox",
|
||||
|
|
|
@ -14,7 +14,7 @@ module VagrantPlugins
|
|||
|
||||
def call(env)
|
||||
env["package.output"] ||= "package.box"
|
||||
env["package.directory"] ||= Dir.mktmpdir("package-", env[:tmp_path])
|
||||
env["package.directory"] ||= Dir.mktmpdir("vagrant-package-", env[:tmp_path])
|
||||
|
||||
# Match up a couple environmental variables so that the other parts of
|
||||
# Vagrant will do the right thing.
|
||||
|
|
Loading…
Reference in New Issue