Print a better error message when the non-root user on the conversion server requires a password to use sudo, and p2v is told to use sudo. See also RHZ#1340809. --- p2v/ssh.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/p2v/ssh.c b/p2v/ssh.c index 76a6827..97d76ae 100644 --- a/p2v/ssh.c +++ b/p2v/ssh.c @@ -97,6 +97,7 @@ static void free_regexps (void) __attribute__((destructor)); static pcre *password_re; static pcre *ssh_message_re; +static pcre *sudo_password_re; static pcre *prompt_re; static pcre *version_re; static pcre *feature_libguestfs_rewrite_re; @@ -140,6 +141,7 @@ compile_regexps (void) COMPILE (password_re, "password:", 0); COMPILE (ssh_message_re, "(ssh: .*)", 0); + COMPILE (sudo_password_re, "sudo: a password is required", 0); /* The magic synchronization strings all match this expression. See * start_ssh function below. */ @@ -160,6 +162,7 @@ free_regexps (void) { pcre_free (password_re); pcre_free (ssh_message_re); + pcre_free (sudo_password_re); pcre_free (prompt_re); pcre_free (version_re); pcre_free (feature_libguestfs_rewrite_re); @@ -532,6 +535,7 @@ test_connection (struct config *config) (mexp_regexp[]) { { 100, .re = version_re }, { 101, .re = prompt_re }, + { 102, .re = sudo_password_re }, { 0 } }, ovector, ovecsize)) { case 100: /* Got version string. */ @@ -546,6 +550,11 @@ test_connection (struct config *config) case 101: /* Got the prompt. */ goto end_of_version; + case 102: + mexp_close (h); + set_ssh_error ("sudo for user '%s' requires a password", config->username); + return -1; + case MEXP_EOF: mexp_close (h); set_ssh_error ("unexpected end of file waiting virt-v2v --version output"); -- 2.5.5