From 70d8a1059c0489df5c1c09cc5510d6b7a3214d8c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 24 Feb 2023 15:47:20 -0500 Subject: [PATCH] Consistently treat bytes as bytes in ssh In Python3 systems, there would be confusion about bytes versus str. Fix this so that ssh can work more consistently. --- confluent_server/confluent/plugins/shell/ssh.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/confluent_server/confluent/plugins/shell/ssh.py b/confluent_server/confluent/plugins/shell/ssh.py index db9f8097..d88ca9b2 100644 --- a/confluent_server/confluent/plugins/shell/ssh.py +++ b/confluent_server/confluent/plugins/shell/ssh.py @@ -146,7 +146,7 @@ class SshShell(conapi.Console): return except cexc.PubkeyInvalid as pi: self.ssh.close() - self.keyaction = '' + self.keyaction = b'' self.candidatefprint = pi.fingerprint self.datacallback(pi.message) self.keyattrname = pi.attrname @@ -197,18 +197,18 @@ class SshShell(conapi.Console): delidx = data.index(b'\x7f') data = data[:delidx - 1] + data[delidx + 1:] self.keyaction += data - if '\r' in self.keyaction: - action = self.keyaction.split('\r')[0] - if action.lower() == 'accept': + if b'\r' in self.keyaction: + action = self.keyaction.split(b'\r')[0] + if action.lower() == b'accept': self.nodeconfig.set_node_attributes( {self.node: {self.keyattrname: self.candidatefprint}}) self.datacallback('\r\n') self.logon() - elif action.lower() == 'disconnect': + elif action.lower() == b'disconnect': self.datacallback(conapi.ConsoleEvent.Disconnect) else: - self.keyaction = '' + self.keyaction = b'' self.datacallback('\r\nEnter "disconnect" or "accept": ') elif len(data) > 0: self.datacallback(data)