diff --git a/CHANGELOG.md b/CHANGELOG.md index 093a6cd75..a42708bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ process to 100%. [GH-832] - Fix issue where shell provisioner would sometimes never end. [GH-968] - FIx issue where puppet would reorder module paths. [GH-964] + - Human-friendly error is raised if there are permission issues when + using SCP to upload files. [GH-924] ## 1.0.3 (May 1, 2012) diff --git a/lib/vagrant/communication/ssh.rb b/lib/vagrant/communication/ssh.rb index 44f1ade97..92d6e5a32 100644 --- a/lib/vagrant/communication/ssh.rb +++ b/lib/vagrant/communication/ssh.rb @@ -85,6 +85,15 @@ module Vagrant scp_connect do |scp| scp.upload!(from, to) end + rescue RuntimeError => e + # Net::SCP raises a runtime error for this so the only way we have + # to really catch this exception is to check the message to see if + # it is something we care about. If it isn't, we re-raise. + raise if e.message !~ /Permission denied/ + + # Otherwise, it is a permission denied, so let's raise a proper + # exception + raise Errors::SCPPermissionDenied, :path => from end protected diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 9a192386a..778872d57 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -303,6 +303,11 @@ module Vagrant error_key(:plugin_load_error) end + class SCPPermissionDenied < VagrantError + status_code(82) + error_key(:scp_permission_denied) + end + class SCPUnavailable < VagrantError status_code(56) error_key(:scp_unavailable) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index deac589cb..8e809fd80 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -92,6 +92,12 @@ en: for you but VirtualBox only allows forwarded ports to change if the VM is powered off. Therefore, please reload your VM or halt the other running VMs to continue. + scp_permission_denied: |- + Failed to upload a file to the guest VM via SCP due to a permissions + error. This is normally because the user running Vagrant doesn't have + read permission on the file. Please set proper permissions on the file: + + %{path} scp_unavailable: |- SSH server on the guest doesn't support SCP. Please install the necessary software to enable SCP on your guest operating system.