|
|
e76f14 |
From 2a0fc9580c0b169f3c1d884e300d8b3d59678431 Mon Sep 17 00:00:00 2001
|
|
|
e76f14 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
e76f14 |
Date: Thu, 23 Jun 2016 11:19:37 +0100
|
|
|
e76f14 |
Subject: [PATCH] p2v: Force bash as the remote shell.
|
|
|
e76f14 |
|
|
|
e76f14 |
As described in the comment, this solves a number of problems with
|
|
|
e76f14 |
non-standard remote configurations.
|
|
|
e76f14 |
|
|
|
e76f14 |
I tested this with:
|
|
|
e76f14 |
|
|
|
e76f14 |
- tcsh
|
|
|
e76f14 |
- zsh
|
|
|
e76f14 |
- ksh
|
|
|
e76f14 |
|
|
|
e76f14 |
and all behaved correctly.
|
|
|
e76f14 |
|
|
|
e76f14 |
(cherry picked from commit d41cf142e1eb285eca798889d3b6a955afffbe32)
|
|
|
e76f14 |
---
|
|
|
e76f14 |
p2v/ssh.c | 21 ++++++++++++++++++---
|
|
|
e76f14 |
1 file changed, 18 insertions(+), 3 deletions(-)
|
|
|
e76f14 |
|
|
|
e76f14 |
diff --git a/p2v/ssh.c b/p2v/ssh.c
|
|
|
e76f14 |
index f2c849f..d2c8035 100644
|
|
|
e76f14 |
--- a/p2v/ssh.c
|
|
|
e76f14 |
+++ b/p2v/ssh.c
|
|
|
e76f14 |
@@ -416,13 +416,28 @@ start_ssh (struct config *config, char **extra_args, int wait_prompt)
|
|
|
e76f14 |
if (!wait_prompt)
|
|
|
e76f14 |
return h;
|
|
|
e76f14 |
|
|
|
e76f14 |
- /* Synchronize with the command prompt and set it to a known string. */
|
|
|
e76f14 |
-
|
|
|
e76f14 |
- /* Note that we cannot control the initial prompt. It would involve
|
|
|
e76f14 |
+ /* Ensure we are running bash, set environment variables, and
|
|
|
e76f14 |
+ * synchronize with the command prompt and set it to a known
|
|
|
e76f14 |
+ * string. There are multiple issues being solved here:
|
|
|
e76f14 |
+ *
|
|
|
e76f14 |
+ * We cannot control the initial shell prompt. It would involve
|
|
|
e76f14 |
* changing the remote SSH configuration (AcceptEnv). However what
|
|
|
e76f14 |
* we can do is to repeatedly send 'export PS1=<magic>' commands
|
|
|
e76f14 |
* until we synchronize with the remote shell.
|
|
|
e76f14 |
+ *
|
|
|
e76f14 |
+ * We don't know if the user is using a Bourne-like shell (eg sh,
|
|
|
e76f14 |
+ * bash) or csh/tcsh. Setting environment variables works
|
|
|
e76f14 |
+ * differently.
|
|
|
e76f14 |
+ *
|
|
|
e76f14 |
+ * We don't know how command line editing is set up
|
|
|
e76f14 |
+ * (https://bugzilla.redhat.com/1314244#c9).
|
|
|
e76f14 |
*/
|
|
|
e76f14 |
+ if (mexp_printf (h, "exec bash --noediting --noprofile\n") == -1) {
|
|
|
e76f14 |
+ set_ssh_error ("setting bash as remote shell: %m");
|
|
|
e76f14 |
+ mexp_close (h);
|
|
|
e76f14 |
+ return NULL;
|
|
|
e76f14 |
+ }
|
|
|
e76f14 |
+
|
|
|
e76f14 |
saved_timeout = mexp_get_timeout_ms (h);
|
|
|
e76f14 |
mexp_set_timeout (h, 2);
|
|
|
e76f14 |
|
|
|
e76f14 |
--
|
|
|
e76f14 |
1.8.3.1
|
|
|
e76f14 |
|