mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-07 13:40:48 +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:
parent
70d755d75b
commit
93b39a7f47
@ -284,16 +284,17 @@ class SshConnection(object):
|
|||||||
port_string = '-P {}'.format(self.port) if (self.port and self.port != 22) else ''
|
port_string = '-P {}'.format(self.port) if (self.port and self.port != 22) else ''
|
||||||
keyfile_string = '-i {}'.format(self.keyfile) if self.keyfile else ''
|
keyfile_string = '-i {}'.format(self.keyfile) if self.keyfile else ''
|
||||||
command = '{} -r {} {} {} {}'.format(scp, keyfile_string, port_string, source, dest)
|
command = '{} -r {} {} {} {}'.format(scp, keyfile_string, port_string, source, dest)
|
||||||
pass_string = ''
|
command_redacted = command
|
||||||
logger.debug(command)
|
logger.debug(command)
|
||||||
if self.password:
|
if self.password:
|
||||||
command = _give_password(self.password, command)
|
command = _give_password(self.password, command)
|
||||||
|
command_redacted = command.replace(self.password, '<redacted>')
|
||||||
try:
|
try:
|
||||||
check_output(command, timeout=timeout, shell=True)
|
check_output(command, timeout=timeout, shell=True)
|
||||||
except subprocess.CalledProcessError as e:
|
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:
|
except TimeoutError as e:
|
||||||
raise TimeoutError(e.command.replace(pass_string, ''), e.output)
|
raise TimeoutError(command_redacted, e.output)
|
||||||
|
|
||||||
|
|
||||||
class TelnetConnection(SshConnection):
|
class TelnetConnection(SshConnection):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user