Check for permission denied when using SCP to upload [GH-924]

This commit is contained in:
Mitchell Hashimoto 2012-06-22 21:04:21 -07:00
parent 76f7da0618
commit fa99eb7e54
4 changed files with 22 additions and 0 deletions

View File

@ -34,6 +34,8 @@
process to 100%. [GH-832] process to 100%. [GH-832]
- Fix issue where shell provisioner would sometimes never end. [GH-968] - Fix issue where shell provisioner would sometimes never end. [GH-968]
- FIx issue where puppet would reorder module paths. [GH-964] - 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) ## 1.0.3 (May 1, 2012)

View File

@ -85,6 +85,15 @@ module Vagrant
scp_connect do |scp| scp_connect do |scp|
scp.upload!(from, to) scp.upload!(from, to)
end 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 end
protected protected

View File

@ -303,6 +303,11 @@ module Vagrant
error_key(:plugin_load_error) error_key(:plugin_load_error)
end end
class SCPPermissionDenied < VagrantError
status_code(82)
error_key(:scp_permission_denied)
end
class SCPUnavailable < VagrantError class SCPUnavailable < VagrantError
status_code(56) status_code(56)
error_key(:scp_unavailable) error_key(:scp_unavailable)

View File

@ -92,6 +92,12 @@ en:
for you but VirtualBox only allows forwarded ports to change if the VM is 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 powered off. Therefore, please reload your VM or halt the other running
VMs to continue. 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: |- scp_unavailable: |-
SSH server on the guest doesn't support SCP. Please install the necessary SSH server on the guest doesn't support SCP. Please install the necessary
software to enable SCP on your guest operating system. software to enable SCP on your guest operating system.