1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 10:10:46 +00:00

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.
This commit is contained in:
Brendan Jackman 2017-08-09 15:59:24 +01:00
parent 70d755d75b
commit 93b39a7f47

View File

@ -284,16 +284,17 @@ class SshConnection(object):
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):