providers/virtualbox: error if uid mismatch

This commit is contained in:
Mitchell Hashimoto 2015-07-06 18:13:59 -06:00
parent 1330244fef
commit 71940c60ba
3 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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