diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c5cf3661..4406ba6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,8 @@ IMPROVEMENTS / BUG FIXES: copy issues. [GH-1199] - Vagrant works properly in folders with strange characters. [GH-1223] - Vagrant properly handles "paused" VirtualBox machines. [GH-1184] + - Better behavior around permissions issues when copying insecure + private key. [GH-580] ## 1.0.6 (December 21, 2012) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index f64ae84f3..fb6881594 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -592,8 +592,17 @@ module Vagrant def copy_insecure_private_key if !@default_private_key_path.exist? @logger.info("Copying private key to home directory") - FileUtils.cp(File.expand_path("keys/vagrant", Vagrant.source_root), - @default_private_key_path) + + source = File.expand_path("keys/vagrant", Vagrant.source_root) + destination = @default_private_key_path + + begin + FileUtils.cp(source, destination) + rescue Errno::EACCES + raise Errors::CopyPrivateKeyFailed, + :source => source, + :destination => destination + end end if !Util::Platform.windows? diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 85952de94..14b7274e6 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -143,6 +143,10 @@ module Vagrant error_key(:config_upgrade_errors) end + class CopyPrivateKeyFailed < VagrantError + error_key(:copy_private_key_failed) + end + class DestroyRequiresForce < VagrantError error_key(:destroy_requires_force) end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index a7a5a3298..3f04c3195 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -80,6 +80,14 @@ en: config_upgrade_errors: |- Because there were errors upgrading your Vagrantfiles, Vagrant can no longer continue. Please fix the errors above and try again. + copy_private_key_failed: |- + Vagrant failed to copy the default insecure private key into your + home directory. This is usually caused by a permissions error. + Please make sure the permissions of the source is readable and + the destination is writable. + + Source: %{source} + Destination: %{destination} destroy_requires_force: |- Destroy doesn't have a TTY to ask for confirmation. Please pass the `--force` flag to force a destroy, otherwise attach a TTY so that