mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone
Blob Blame History Raw
From 5ca9876f652f093230ed8c4f50463a64b76dce62 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 23 Jun 2016 11:27:01 +0100
Subject: [PATCH] p2v: Set LANG=C in the remote shell so we can match on error
 messages.

Since commit 5b6a8e086264c85fb048c0eadff6c34351663133 we are now
matching on error messages, and therefore we must set LANG=C.

(cherry picked from commit 5e794b86072cfaa1d2017d93bd3a24be72636c02)
---
 p2v/ssh.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/p2v/ssh.c b/p2v/ssh.c
index d2c8035..aa070d5 100644
--- a/p2v/ssh.c
+++ b/p2v/ssh.c
@@ -425,6 +425,8 @@ start_ssh (struct config *config, char **extra_args, int wait_prompt)
    * we can do is to repeatedly send 'export PS1=<magic>' commands
    * until we synchronize with the remote shell.
    *
+   * Since we parse error messages, we must set LANG=C.
+   *
    * We don't know if the user is using a Bourne-like shell (eg sh,
    * bash) or csh/tcsh.  Setting environment variables works
    * differently.
@@ -455,7 +457,7 @@ start_ssh (struct config *config, char **extra_args, int wait_prompt)
     /* The purpose of the '' inside the string is to ensure we don't
      * mistake the command echo for the prompt.
      */
-    if (mexp_printf (h, "export PS1='###''%s''### '\n", magic) == -1) {
+    if (mexp_printf (h, "export LANG=C PS1='###''%s''### '\n", magic) == -1) {
       set_ssh_error ("random_string: %m");
       mexp_close (h);
       return NULL;
-- 
1.8.3.1