From 1670ccdbbd82f875d58fd9758775223d6d843fcf Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Fri, 23 Jun 2017 15:58:12 -0700 Subject: [PATCH] Avoid double-encoding to bytes Both the 'container_user' used within the 'cmd' variable and the container path padding added to the 'out_file' variable in the connection plugin should be strings since they're later encoded to bytes by the inherited class. Change-Id: I8874c439fc9c006125bb39ff6a2cd386bfc8f561 --- connection/ssh.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/connection/ssh.py b/connection/ssh.py index 735c920..016dd34 100644 --- a/connection/ssh.py +++ b/connection/ssh.py @@ -82,8 +82,7 @@ class Connection(SSH.Connection): # Remote user is normally set, but if it isn't, then default to 'root' container_user = 'root' if self._play_context.remote_user: - container_user = SSH.to_bytes(self._play_context.remote_user, - errors='surrogate_or_strict') + container_user = self._play_context.remote_user # NOTE(hwoarang) It is important to connect to the container # without inheriting the host environment as that would interfere # with running commands and services inside the container. However, @@ -151,7 +150,7 @@ class Connection(SSH.Connection): ) if returncode == 0: pad = os.path.join( - '/proc/%s/root' % stdout.strip(), + '/proc/%s/root' % SSH.to_text(stdout.strip()), path.lstrip(os.sep) ) SSH.display.vvv(