diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 46f037d..ea79cdc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,6 +14,12 @@ jobs: matrix: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] os: [ubuntu-latest, windows-latest] + include: + - os: ubuntu-22.04 + python-version: "3.7" + exclude: + - os: ubuntu-latest + python-version: "3.7" steps: - uses: actions/checkout@v1 diff --git a/mockssh/server.py b/mockssh/server.py index 9bb157e..930c64f 100644 --- a/mockssh/server.py +++ b/mockssh/server.py @@ -39,15 +39,13 @@ def run(self): channel = self.transport.accept() if channel is None: break - if channel.chanid not in self.command_queues: - self.command_queues[channel.chanid] = Queue() t = threading.Thread(target=self.handle_client, args=(channel,)) t.daemon = True t.start() def handle_client(self, channel): try: - command = self.command_queues[channel.chanid].get(block=True) + command = self.command_queues[channel.get_id()].get(block=True) self.log.debug("Executing %s", command) with subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, @@ -77,11 +75,12 @@ def check_auth_publickey(self, username, key): return paramiko.AUTH_FAILED def check_channel_exec_request(self, channel, command): - self.command_queues.setdefault(channel.get_id(), Queue()).put(command) + self.command_queues[channel.get_id()].put(command) return True def check_channel_request(self, kind, chanid): if kind == "session": + self.command_queues.setdefault(chanid, Queue()) return paramiko.OPEN_SUCCEEDED return paramiko.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED