Merge pull request #6612 from reedloden/virtualbox-checksum
Add checksum validation for the VirtualBox installs on Windows and OS X
This commit is contained in:
commit
739d29e8fa
|
@ -524,6 +524,10 @@ module Vagrant
|
||||||
error_key(:provider_cant_install)
|
error_key(:provider_cant_install)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class ProviderChecksumMismatch < VagrantError
|
||||||
|
error_key(:provider_checksum_mismatch)
|
||||||
|
end
|
||||||
|
|
||||||
class ProviderInstallFailed < VagrantError
|
class ProviderInstallFailed < VagrantError
|
||||||
error_key(:provider_install_failed)
|
error_key(:provider_install_failed)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ require "pathname"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
|
||||||
require "vagrant/util/downloader"
|
require "vagrant/util/downloader"
|
||||||
|
require "vagrant/util/file_checksum"
|
||||||
require "vagrant/util/subprocess"
|
require "vagrant/util/subprocess"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
|
@ -12,6 +13,7 @@ module VagrantPlugins
|
||||||
# known-good version to download.
|
# known-good version to download.
|
||||||
URL = "http://download.virtualbox.org/virtualbox/5.0.10/VirtualBox-5.0.10-104061-OSX.dmg".freeze
|
URL = "http://download.virtualbox.org/virtualbox/5.0.10/VirtualBox-5.0.10-104061-OSX.dmg".freeze
|
||||||
VERSION = "5.0.10".freeze
|
VERSION = "5.0.10".freeze
|
||||||
|
SHA256SUM = "62f933115498e51ddf5f2dab47dc1eebb42eb78ea1a7665cb91c53edacc847c6".freeze
|
||||||
|
|
||||||
def self.provider_install_virtualbox(env)
|
def self.provider_install_virtualbox(env)
|
||||||
tf = Tempfile.new("vagrant")
|
tf = Tempfile.new("vagrant")
|
||||||
|
@ -29,6 +31,15 @@ module VagrantPlugins
|
||||||
dl = Vagrant::Util::Downloader.new(URL, tf.path, ui: ui)
|
dl = Vagrant::Util::Downloader.new(URL, tf.path, ui: ui)
|
||||||
dl.download!
|
dl.download!
|
||||||
|
|
||||||
|
# Validate that the file checksum matches
|
||||||
|
actual = Vagrant::Util::FileChecksum.new(tf.path, Digest::SHA2).checksum
|
||||||
|
if actual != SHA256SUM
|
||||||
|
raise Vagrant::Errors::ProviderChecksumMismatch,
|
||||||
|
provider: "virtualbox",
|
||||||
|
actual: actual,
|
||||||
|
expected: SHA256SUM
|
||||||
|
end
|
||||||
|
|
||||||
# Launch it
|
# Launch it
|
||||||
ui.output(I18n.t(
|
ui.output(I18n.t(
|
||||||
"vagrant.hosts.darwin.virtualbox_install_install"))
|
"vagrant.hosts.darwin.virtualbox_install_install"))
|
||||||
|
|
|
@ -2,6 +2,7 @@ require "pathname"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
|
||||||
require "vagrant/util/downloader"
|
require "vagrant/util/downloader"
|
||||||
|
require "vagrant/util/file_checksum"
|
||||||
require "vagrant/util/powershell"
|
require "vagrant/util/powershell"
|
||||||
require "vagrant/util/subprocess"
|
require "vagrant/util/subprocess"
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ module VagrantPlugins
|
||||||
# known-good version to download.
|
# known-good version to download.
|
||||||
URL = "http://download.virtualbox.org/virtualbox/5.0.10/VirtualBox-5.0.10-104061-Win.exe".freeze
|
URL = "http://download.virtualbox.org/virtualbox/5.0.10/VirtualBox-5.0.10-104061-Win.exe".freeze
|
||||||
VERSION = "5.0.10".freeze
|
VERSION = "5.0.10".freeze
|
||||||
|
SHA256SUM = "3e5ed8fe4ada6eef8dfb4fe6fd79fcab4b242acf799f7d3ab4a17b43838b1e04".freeze
|
||||||
|
|
||||||
def self.provider_install_virtualbox(env)
|
def self.provider_install_virtualbox(env)
|
||||||
tf = Tempfile.new("vagrant")
|
tf = Tempfile.new("vagrant")
|
||||||
|
@ -30,6 +32,15 @@ module VagrantPlugins
|
||||||
dl = Vagrant::Util::Downloader.new(URL, tf.path, ui: ui)
|
dl = Vagrant::Util::Downloader.new(URL, tf.path, ui: ui)
|
||||||
dl.download!
|
dl.download!
|
||||||
|
|
||||||
|
# Validate that the file checksum matches
|
||||||
|
actual = Vagrant::Util::FileChecksum.new(tf.path, Digest::SHA2).checksum
|
||||||
|
if actual != SHA256SUM
|
||||||
|
raise Vagrant::Errors::ProviderChecksumMismatch,
|
||||||
|
provider: "virtualbox",
|
||||||
|
actual: actual,
|
||||||
|
expected: SHA256SUM
|
||||||
|
end
|
||||||
|
|
||||||
# Launch it
|
# Launch it
|
||||||
ui.output(I18n.t(
|
ui.output(I18n.t(
|
||||||
"vagrant.hosts.windows.virtualbox_install_install"))
|
"vagrant.hosts.windows.virtualbox_install_install"))
|
||||||
|
|
|
@ -1015,6 +1015,13 @@ en:
|
||||||
This is a limitation of this provider. Please report this as a feature
|
This is a limitation of this provider. Please report this as a feature
|
||||||
request to the provider in question. To install this provider, you'll
|
request to the provider in question. To install this provider, you'll
|
||||||
have to do so manually.
|
have to do so manually.
|
||||||
|
provider_checksum_mismatch: |-
|
||||||
|
The checksum of the downloaded provider '%{provider}' did not match the
|
||||||
|
expected value. If the problem persists, please install the provider
|
||||||
|
manually.
|
||||||
|
|
||||||
|
Expected: %{expected}
|
||||||
|
Received: %{actual}
|
||||||
provider_install_failed: |-
|
provider_install_failed: |-
|
||||||
Installation of the provider '%{provider}' failed! The stdout
|
Installation of the provider '%{provider}' failed! The stdout
|
||||||
and stderr are shown below. Please read the error output, resolve it,
|
and stderr are shown below. Please read the error output, resolve it,
|
||||||
|
|
Loading…
Reference in New Issue