diff options
| author | Martin Ridgers <[email protected]> | 2022-02-01 12:39:30 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2022-02-01 12:39:30 +0100 |
| commit | 2440fa14f3288e088ea6396319c5a734dcc7a1cc (patch) | |
| tree | 9a422e073fcb3d89b27103347a1086af44b72fd5 /scripts | |
| parent | Validate remote_build.py key file for required tailing EOL (diff) | |
| download | zen-2440fa14f3288e088ea6396319c5a734dcc7a1cc.tar.xz zen-2440fa14f3288e088ea6396319c5a734dcc7a1cc.zip | |
Partial remote host validation for remote_build.py
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/remote_build.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/scripts/remote_build.py b/scripts/remote_build.py index 6f18c734b..27e9f93de 100644 --- a/scripts/remote_build.py +++ b/scripts/remote_build.py @@ -71,7 +71,7 @@ def _local(args): # Parse arguments desc = "Build Zen on a remote host" parser = argparse.ArgumentParser(description=desc) - parser.add_argument("host", help="") + parser.add_argument("remotehost", help="") parser.add_argument("action", default="build", nargs="?", help="") parser.add_argument("--keyfile", default=None, help="SSH key file") args = parser.parse_args(args) @@ -104,6 +104,8 @@ def _local(args): else: raise EnvironmentError("Unable to find '.git/' directory") + _header("Validating remote host and credentials") + # Validate key file. OpenSSL needs a trailing EOL, LibreSSL doesn't if args.keyfile: with open(args.keyfile, "rt") as key_file: @@ -115,6 +117,23 @@ def _local(args): else: identity = () + # Validate remote host + host = args.remotehost + if host == "linux": host = os.getenv("ZEN_REMOTE_HOST_LINUX", "arn-lin-12345") + if host == "mac": host = os.getenv("ZEN_REMOTE_HOST_MAC", "imacpro-arn.local") + """ + keygen_bin = find_git_tool(git_bin, "ssh-keygen") + print(f"Using '{keygen_bin.name}' from '{keygen_bin.parent}'") + known_host = subprocess.run((keygen_bin, "-F", host)).returncode + if not known_host: + print("Adding", host, "as a known host") + print("ANSWER 'yes'") + known_host = subprocess.run((ssh_bin, *identity, "zenbuild@" + host, "uname -a")).returncode + raise IndexError + """ + host = "zenbuild@" + host + print(f"Using host '{host}'") + # Start a git daemon to use as a transfer mechanism _header("Starting a git daemon") print("Port: 4493") @@ -138,12 +157,6 @@ def _local(args): _header("Running SSH") remote_zen_dir = "%s_%s" % (os.getlogin(), _get_ip()) - - host = args.host - if host == "linux": host = os.getenv("ZEN_REMOTE_HOST_LINUX", "arn-lin-12345") - if host == "mac": host = os.getenv("ZEN_REMOTE_HOST_MAC", "imacpro-arn.local") - host = "zenbuild@" + host - print(f"Using host '{host}'") print(f"Using zen '~/{remote_zen_dir}'") print(f"Running {__file__} remotely") |