#!/usr/bin/env python3 """A fake `ssh`: like sshd with a forced command — the remote command becomes SSH_ORIGINAL_COMMAND of tgit-runner.""" import os import sys args = sys.argv[1:] with_value = {"-F", "-p", "-o", "-i"} i = 0 while i < len(args) and args[i].startswith("-"): i += 2 if args[i] in with_value else 1 remote = " ".join(args[i + 1 :]) os.environ["SSH_ORIGINAL_COMMAND"] = remote os.execvp("bash", ["bash", os.environ["FAKE_RUNNER"]])