From 604ae6caa3c69203d16982844a541d88b205252f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 1 May 2014 21:35:02 -0700 Subject: [PATCH] communicators/ssh: detect if config.ssh.shell is non-functional [GH-3040] --- CHANGELOG.md | 1 + lib/vagrant/errors.rb | 4 ++++ plugins/communicators/ssh/communicator.rb | 7 +++++++ templates/locales/en.yml | 6 ++++++ 4 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c47928b0..f261d2c58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ BUG FIXES: source, use that. [GH-3610] - commands/rsync-auto: Interrupt exits properly. [GH-3552] - commands/rsync-auto: Run properly on Windows. [GH-3547] + - communicators/ssh: Detect if `config.ssh.shell` is invalid. [GH-3040] - providers/virtualbox: VirtalBox detection works properly again on Windows when the `VBOX_INSTALL_PATH` has multiple elements. [GH-3549] - providers/virtualbox: Forcing MAC address on private network works diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 8afa60fbc..eb0f78d0b 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -592,6 +592,10 @@ module Vagrant error_key(:ssh_host_down) end + class SSHInvalidShell< VagrantError + error_key(:ssh_invalid_shell) + end + class SSHIsPuttyLink < VagrantError error_key(:ssh_is_putty_link) end diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index eb0686648..37d38ebb9 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -78,6 +78,8 @@ module VagrantPlugins message = "Host appears down." rescue Vagrant::Errors::SSHNoRoute message = "Host unreachable." + rescue Vagrant::Errors::SSHInvalidShell + raise rescue Vagrant::Errors::SSHKeyTypeNotSupported raise rescue Vagrant::Errors::VagrantError => e @@ -120,6 +122,11 @@ module VagrantPlugins return false end + # Verify the shell is valid + if execute("", error_check: false) != 0 + raise Vagrant::Errors::SSHInvalidShell + end + # If we're already attempting to switch out the SSH key, then # just return that we're ready (for Machine#guest). @lock.synchronize do diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 967e720e0..a666fcbce 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -995,6 +995,12 @@ en: While attempting to connect with SSH, a "host is down" (EHOSTDOWN) error was received. Please verify your SSH settings are correct and try again. + ssh_invalid_shell: |- + The configured shell (config.ssh.shell) is invalid and unable + to properly execute commands. The most common cause for this is + using a shell that is unavailable on the system. Please verify + you're using the full path to the shell and that the shell is + executable by the SSH user. ssh_is_putty_link: |- The `ssh` executable found in the PATH is a PuTTY Link SSH client. Vagrant is only compatible with OpenSSH SSH clients. Please install