Skip to content

Commit

Permalink
Don't skip empty lines...
Browse files Browse the repository at this point in the history
For some tricky cases we cannot skip empty line. For example when
getting a key from varstored with ssh we can have within the key a
sequence of two 0x0a bytes. The issue is that readline will split it
with an empty line. If we skip it we basically remove one 0x0a from the
key and then of course the checksum will failed.

Signed-off-by: Guillaume <[email protected]>
  • Loading branch information
gthvn1 committed Mar 1, 2024
1 parent b59e7ad commit 7181c3d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ def _ssh(hostname_or_ip, cmd, check=True, simple_output=True, suppress_fingerpri
stdout = []
for line in iter(process.stdout.readline, b''):
readable_line = line.decode(errors='replace').strip()
if readable_line != '':
stdout.append(line)
OUPUT_LOGGER.debug(readable_line)
stdout.append(line)
OUPUT_LOGGER.debug(readable_line)
_, stderr = process.communicate()
res = subprocess.CompletedProcess(ssh_cmd, process.returncode, b''.join(stdout), stderr)

Expand Down

0 comments on commit 7181c3d

Please sign in to comment.