diff options
| author | Martin Ridgers <[email protected]> | 2022-02-01 12:37:41 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2022-02-01 12:37:41 +0100 |
| commit | 88216099733425dbd73879a9830cae136d0ba5f7 (patch) | |
| tree | c9d9801ce3f0080cf759ce4905efbb17a651c194 /scripts | |
| parent | Disable remote_build.py's ANSI codes if the terminal doesn't support them (diff) | |
| download | zen-88216099733425dbd73879a9830cae136d0ba5f7.tar.xz zen-88216099733425dbd73879a9830cae136d0ba5f7.zip | |
Validate remote_build.py key file for required tailing EOL
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/remote_build.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/scripts/remote_build.py b/scripts/remote_build.py index 756748853..6f18c734b 100644 --- a/scripts/remote_build.py +++ b/scripts/remote_build.py @@ -104,6 +104,17 @@ def _local(args): else: raise EnvironmentError("Unable to find '.git/' directory") + # Validate key file. OpenSSL needs a trailing EOL, LibreSSL doesn't + if args.keyfile: + with open(args.keyfile, "rt") as key_file: + lines = [x for x in key_file] + if not lines[-1].endswith("\n"): + print("!! ERROR: key file must end with a new line") + return 1 + identity = ("-i", args.keyfile) + else: + identity = () + # Start a git daemon to use as a transfer mechanism _header("Starting a git daemon") print("Port: 4493") @@ -136,13 +147,11 @@ def _local(args): print(f"Using zen '~/{remote_zen_dir}'") print(f"Running {__file__} remotely") - ssh_args = ("-tA",) - if args.keyfile: - ssh_args = (*ssh_args, "-i", args.keyfile) with open(__file__, "rt") as self_file: _run_checked( ssh_bin, - *ssh_args, + *identity, + "-tA", host, f"python3 -u - !remote {_get_ip()} '{remote_zen_dir}' main '{args.action}'", stdin=self_file) @@ -151,9 +160,7 @@ def _local(args): if args.action == "bundle": build_dir = zen_dir / "build" build_dir.mkdir(exist_ok=True) - scp_args = (host + f":zen/{remote_zen_dir}/build/*.zip", build_dir) - if args.keyfile: - scp_args = ("-i", args.keyfile, *scp_args) + scp_args = (*identity, host + f":zen/{remote_zen_dir}/build/*.zip", build_dir) _run_checked("scp", *scp_args) |