diff options
| author | Carson Fleming <cflems@cflems.net> | 2023-01-13 04:22:43 -0800 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2023-01-13 04:22:43 -0800 |
| commit | 352a8d94986f4387ecb1e81abfa0eb2f0c7bb543 (patch) | |
| tree | b531160fb654342d1f0d3d6b3f3d86a04b23c4e3 | |
| parent | 9a9c7ff09bbcf3ff5a7d8913ff00a25a2b7e0dc4 (diff) | |
| download | pk-352a8d94986f4387ecb1e81abfa0eb2f0c7bb543.tar.gz | |
Fix client crashing bug on pty exit
| -rw-r--r-- | pkcli_stub.py | 1 | ||||
| -rw-r--r-- | pkd_stub.py | 18 |
2 files changed, 8 insertions, 11 deletions
diff --git a/pkcli_stub.py b/pkcli_stub.py index 1644718..8494f1a 100644 --- a/pkcli_stub.py +++ b/pkcli_stub.py @@ -192,7 +192,6 @@ def work(h_addr, port, privkey, bits): if not run_pty(sock, screen_is, screen_os): return True screen_os.send(b'\xc0\xdenpty') - assert(screen_is.recv() == b'\xc0\xdeflush') # TODO: this comes on time but the process zombifies after for some reason continue else: diff --git a/pkd_stub.py b/pkd_stub.py index e51299b..1d33ddf 100644 --- a/pkd_stub.py +++ b/pkd_stub.py @@ -1,4 +1,4 @@ -import os, sys, socket, threading, signal, json, traceback +import os, sys, socket, threading, signal, json from concurrent.futures import ThreadPoolExecutor # initial crypto config @@ -310,10 +310,6 @@ def unpty(client): if not alive: tcpc_lock.release() return - try: - client['pty_os'].send(b'\xc0\xdeflush') - except: - client['alive'] = False client['pty'] = False del client['pty_is'] del client['pty_os'] @@ -367,13 +363,15 @@ def run_pty(screen, cn): return False except: data = b'\xde\xad' + # TODO: problem is here: we wake up and suddenly not in pty mode if not data or data == b'\xde\xad': unpty(client) return False - try: - pty_os.send(data) - except: - client['alive'] = False + elif alive and client['alive'] and client['pty'] == screen: + try: + pty_os.send(data) + except: + client['alive'] = False def screen_reader(screen): global alive, screens, screens_lock, cmdq, cmdq_lock, tcp_clients, tcpc_lock @@ -540,7 +538,7 @@ def cleanup(*args): if 'screen' in sockets: sockets['screen'].close() try: - ws = socket.socket(socket.AF_UNIX, sockte.SOCK_STREAM) + ws = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) ws.connect(socket_file) ws.close() except: |
