Human-friendly error if error copying private key [GH-580]

This commit is contained in:
Mitchell Hashimoto 2013-03-01 13:51:11 -08:00
parent 27af5ab408
commit ade5d8a579
4 changed files with 25 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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