ssh: Fix redacting SSH password in errors
IIUC this is supposed to redact the password from exception messages,
but 'pass_string' is not set to the password so nothing is
altered. Fix that.
diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py
index 89613bd..5470367 100644
--- a/devlib/utils/ssh.py
+++ b/devlib/utils/ssh.py
@@ -284,16 +284,17 @@
port_string = '-P {}'.format(self.port) if (self.port and self.port != 22) else ''
keyfile_string = '-i {}'.format(self.keyfile) if self.keyfile else ''
command = '{} -r {} {} {} {}'.format(scp, keyfile_string, port_string, source, dest)
- pass_string = ''
+ command_redacted = command
logger.debug(command)
if self.password:
command = _give_password(self.password, command)
+ command_redacted = command.replace(self.password, '<redacted>')
try:
check_output(command, timeout=timeout, shell=True)
except subprocess.CalledProcessError as e:
- raise subprocess.CalledProcessError(e.returncode, e.cmd.replace(pass_string, ''), e.output)
+ raise subprocess.CalledProcessError(e.returncode, command_redacted e.output)
except TimeoutError as e:
- raise TimeoutError(e.command.replace(pass_string, ''), e.output)
+ raise TimeoutError(command_redacted, e.output)
class TelnetConnection(SshConnection):