From 2f09f3e995a45c409f82e28bf1fb41f71fb0a37f Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 14 Jun 2018 20:00:01 -0600 Subject: [PATCH] Fix a couple rare bugs around SSH sessions --- core/bbs.js | 5 ++++- core/servers/login/ssh.js | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/bbs.js b/core/bbs.js index 883e1a87..a352c555 100644 --- a/core/bbs.js +++ b/core/bbs.js @@ -119,7 +119,10 @@ function shutdownSystem() { const activeConnections = ClientConns.getActiveConnections(); let i = activeConnections.length; while(i--) { - activeConnections[i].term.write('\n\nServer is shutting down NOW! Disconnecting...\n\n'); + const activeTerm = activeConnections[i].term; + if(activeTerm) { + activeTerm.write('\n\nServer is shutting down NOW! Disconnecting...\n\n'); + } ClientConns.removeClient(activeConnections[i]); } callback(null); diff --git a/core/servers/login/ssh.js b/core/servers/login/ssh.js index 4ec57d2f..c50a7d70 100644 --- a/core/servers/login/ssh.js +++ b/core/servers/login/ssh.js @@ -184,7 +184,7 @@ function SSHClient(clientConn) { if(self.input) { // do we have I/O? self.updateTermInfo(info); } else { - self.cachedPtyInfo = info; + self.cachedTermInfo = info; } }); @@ -197,9 +197,9 @@ function SSHClient(clientConn) { channel.stdin.on('data', self.dataHandler); - if(self.cachedPtyInfo) { - self.updateTermInfo(self.cachedPtyInfo); - delete self.cachedPtyInfo; + if(self.cachedTermInfo) { + self.updateTermInfo(self.cachedTermInfo); + delete self.cachedTermInfo; } // we're ready! @@ -210,7 +210,11 @@ function SSHClient(clientConn) { session.on('window-change', (accept, reject, info) => { self.log.debug(info, 'SSH window-change event'); - self.updateTermInfo(info); + if(self.input) { + self.updateTermInfo(info); + } else { + self.cachedTermInfo = info; + } }); });