From 71940c60ba541e8c5dc69d0380dfca3febd2d389 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 6 Jul 2015 18:13:59 -0600 Subject: [PATCH] providers/virtualbox: error if uid mismatch --- lib/vagrant/errors.rb | 4 ++++ plugins/providers/virtualbox/provider.rb | 7 +++++++ templates/locales/en.yml | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 02804b5b0..b705b362e 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -764,6 +764,10 @@ module Vagrant error_key(:virtualbox_name_exists) end + class VirtualBoxUserMismatch < VagrantError + error_key(:virtualbox_user_mismatch) + end + class VirtualBoxVersionEmpty < VagrantError error_key(:virtualbox_version_empty) end diff --git a/plugins/providers/virtualbox/provider.rb b/plugins/providers/virtualbox/provider.rb index 9428fe6d7..270286341 100644 --- a/plugins/providers/virtualbox/provider.rb +++ b/plugins/providers/virtualbox/provider.rb @@ -73,6 +73,13 @@ module VagrantPlugins # # @return [Symbol] def state + # We have to check if the UID matches to avoid issues with + # VirtualBox. + uid = @machine.uid + if uid && uid.to_s == Process.uid.to_s + raise Vagrant::Errors::VirtualBoxUserMismatch, uid: uid.to_s + end + # Determine the ID of the state here. state_id = nil state_id = :not_created if !@driver.uuid diff --git a/templates/locales/en.yml b/templates/locales/en.yml index a6abe138c..285960f39 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1317,6 +1317,13 @@ en: Vagrant uses the `VBoxManage` binary that ships with VirtualBox, and requires this to be available on the PATH. If VirtualBox is installed, please find the `VBoxManage` binary and add it to the PATH environmental variable. + virtualbox_user_mismatch: |- + The VirtualBox VM was created with a user that doesn't match the + current user running Vagrant. VirtualBox requires that the same user + be used to manage the VM that was created. Please re-run Vagrant with + that user. + + The UID used to create the VM was: %{uid} virtualbox_version_empty: |- Vagrant detected that VirtualBox appears installed on your system, but calls to detect the version are returning empty. This is often