From 9174d7e8878fda46768f860e794e12687bf053e7 Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Mon, 25 May 2026 23:04:36 -0400 Subject: [PATCH 1/4] Warn about long guest commands on console --- guest_cmd.py | 8 +++++++- src/main.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/guest_cmd.py b/guest_cmd.py index bb86306..f06288f 100644 --- a/guest_cmd.py +++ b/guest_cmd.py @@ -5,6 +5,12 @@ import os +def prepare_command(command): + if "PATH=" not in command: + command = f"export PATH=/igloo/utils:$PATH; {command}" + return command + + def run_guest(unix_socket, port, command, use_stdio=True): try: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) @@ -17,7 +23,7 @@ def run_guest(unix_socket, port, command, use_stdio=True): response = s.recv(4096).decode('utf-8') assert f"OK {port}" in response, "OK not received from vsock unix socket" - s.sendall(command.encode('utf-8')) + s.sendall(prepare_command(command).encode('utf-8')) output = b"" while True: diff --git a/src/main.rs b/src/main.rs index a1e945f..25998dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,9 @@ use structopt::StructOpt; use log::{info,warn,error}; use env_logger; use std::error::Error; +use std::io::Write; use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; use serde::{Serialize, Deserialize}; use serde_json; use shlex; @@ -18,6 +20,8 @@ use portalcall::{URegSize, RegSize}; const BUF_SIZE: usize = 65536; const CMD_TIMEOUT: Duration = Duration::from_secs(10); const INDIV_DEBUG_PORTALCALL_MAGIC: URegSize = 0xfeedbeef; +const LONG_COMMAND_THRESHOLD: usize = 2048; +static LONG_COMMAND_WARNED: AtomicBool = AtomicBool::new(false); #[derive(Serialize, Deserialize, Debug)] struct CmdResult { @@ -81,6 +85,7 @@ async fn process_request(mut vsock: VsockStream, addr: VsockAddr, shell: Arc { + let _ = tty.write_all(warning.as_bytes()); + } + Err(_) => { + warn!("{}", warning.trim_end()); + } + } +} From b095a28047f7033426f928b04dfa0e56868a7fce Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Mon, 25 May 2026 23:08:19 -0400 Subject: [PATCH 2/4] Harden guest command client errors --- guest_cmd.py | 155 +++++++++++++++++++++++++++------------- tests/test_guest_cmd.py | 86 ++++++++++++++++++++++ 2 files changed, 193 insertions(+), 48 deletions(-) create mode 100644 tests/test_guest_cmd.py diff --git a/guest_cmd.py b/guest_cmd.py index f06288f..224e524 100644 --- a/guest_cmd.py +++ b/guest_cmd.py @@ -5,57 +5,112 @@ import os +class GuestCommandError(RuntimeError): + pass + + def prepare_command(command): - if "PATH=" not in command: - command = f"export PATH=/igloo/utils:$PATH; {command}" - return command + return f"export PATH=/igloo/utils:$PATH; {command}" -def run_guest(unix_socket, port, command, use_stdio=True): - try: - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.connect(unix_socket) - s.settimeout(None) # Disable timeout for long-running commands +def find_vsocket(search_root="/tmp"): + matches = [] + for root, _dirs, files in os.walk(search_root): + for filename in files: + if "vsocket" in filename: + matches.append(os.path.join(root, filename)) - # Send CONNECT PORTNUM (for vsock) followed by the actual command - connect_command = f"CONNECT {port}\n" - s.sendall(connect_command.encode('utf-8')) - response = s.recv(4096).decode('utf-8') - assert f"OK {port}" in response, "OK not received from vsock unix socket" + if not matches: + raise GuestCommandError(f"No vsocket found under {search_root}") - s.sendall(prepare_command(command).encode('utf-8')) + matches.sort() + return matches[0] - output = b"" - while True: - chunk = s.recv(4096) - if not chunk: + +def recv_all(sock): + output = bytearray() + while True: + chunk = sock.recv(4096) + if not chunk: break - output += chunk + output.extend(chunk) + return bytes(output) + - received_json = output.decode('utf-8') +def decode_response(payload): + if not payload: + raise GuestCommandError("No response received from guest command server") + + try: + received_json = payload.decode("utf-8") + except UnicodeDecodeError as e: + raise GuestCommandError(f"Guest command response was not valid UTF-8: {e}") from e + + try: result = json.loads(received_json) + except json.JSONDecodeError as e: + raise GuestCommandError(f"Guest command response was not valid JSON: {e}") from e + + if not isinstance(result, dict): + raise GuestCommandError("Guest command response was not a JSON object") + + for key in ("stdout", "stderr", "exit_code"): + if key not in result: + raise GuestCommandError(f"Guest command response missing {key!r}") + + if not isinstance(result["stdout"], str): + raise GuestCommandError("Guest command response field 'stdout' was not a string") + if not isinstance(result["stderr"], str): + raise GuestCommandError("Guest command response field 'stderr' was not a string") + if not isinstance(result["exit_code"], int): + raise GuestCommandError("Guest command response field 'exit_code' was not an integer") + + return result + + +def run_guest(unix_socket, port, command, use_stdio=True): + try: + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock: + sock.connect(unix_socket) + # Disable timeout for long-running commands. + sock.settimeout(None) + + result = run_guest_with_socket(sock, port, command) + except OSError as e: + raise GuestCommandError(f"Socket error while talking to {unix_socket}: {e}") from e + + if not use_stdio: + return result["stdout"] - if not use_stdio: - return result["stdout"] - print(result["stdout"], end='') - # Propagate stderr to stderr - if result["stderr"]: - print(result["stderr"], file=sys.stderr, end='') - sys.exit(result["exit_code"]) + print(result["stdout"], end="") + if result["stderr"]: + print(result["stderr"], file=sys.stderr, end="") + sys.exit(result["exit_code"]) + +def run_guest_with_socket(sock, port, command): + # Send CONNECT PORTNUM (for vsock) followed by the actual command. + try: + connect_command = f"CONNECT {port}\n" + sock.sendall(connect_command.encode("utf-8")) + response = sock.recv(4096).decode("utf-8", errors="replace").strip() except OSError as e: - if s.error: - print(f"Socket error: {e}", file=sys.stderr) - else: - print(e, file=sys.stderr) - except SystemExit as e: - # A little janky, but does the trick - sys.exit(e.code) - finally: - s.close() + raise GuestCommandError(f"Failed to connect to vsock port {port}: {e}") from e + expected = f"OK {port}" + if response != expected: + raise GuestCommandError( + f"Unexpected response from vsock unix socket: expected {expected!r}, got {response!r}" + ) -if __name__ == "__main__": + try: + sock.sendall(prepare_command(command).encode("utf-8")) + return decode_response(recv_all(sock)) + except OSError as e: + raise GuestCommandError(f"Failed while running guest command: {e}") from e + + +def main(argv=None): parser = argparse.ArgumentParser(description="Run a command in a rehosted guest") parser.add_argument("--socket", @@ -72,17 +127,21 @@ def run_guest(unix_socket, port, command, use_stdio=True): nargs=argparse.REMAINDER, help="The command to run on the server.") - args = parser.parse_args() + args = parser.parse_args(argv) - if args.socket is None: - for root, dirs, files in os.walk('/tmp'): - for file in files: - if 'vsocket' in file: - unix_socket = os.path.join(root, file) - break - else: - unix_socket = args.socket + if not args.command: + parser.error("command is required") - command = ' '.join(args.command) + try: + unix_socket = args.socket if args.socket is not None else find_vsocket() + command = " ".join(args.command) + run_guest(unix_socket, args.port, command) + except GuestCommandError as e: + print(f"guest_cmd: {e}", file=sys.stderr) + return 1 + + return 0 - run_guest(unix_socket, args.port, command) + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_guest_cmd.py b/tests/test_guest_cmd.py new file mode 100644 index 0000000..2fc313d --- /dev/null +++ b/tests/test_guest_cmd.py @@ -0,0 +1,86 @@ +import json +import os +import sys +import tempfile +import unittest + +sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + +import guest_cmd + + +class FakeSocket: + def __init__(self, responses): + self.responses = list(responses) + self.sent = [] + + def sendall(self, data): + self.sent.append(data) + + def recv(self, _size): + if self.responses: + return self.responses.pop(0) + return b"" + + +class GuestCmdTests(unittest.TestCase): + def test_find_vsocket_returns_first_sorted_match(self): + with tempfile.TemporaryDirectory() as tmpdir: + os.makedirs(os.path.join(tmpdir, "b")) + os.makedirs(os.path.join(tmpdir, "a")) + open(os.path.join(tmpdir, "b", "vsocket-2"), "w").close() + open(os.path.join(tmpdir, "a", "vsocket-1"), "w").close() + + expected = os.path.join(tmpdir, "a", "vsocket-1") + self.assertEqual(guest_cmd.find_vsocket(tmpdir), expected) + + def test_find_vsocket_errors_when_missing(self): + with tempfile.TemporaryDirectory() as tmpdir: + with self.assertRaisesRegex(guest_cmd.GuestCommandError, "No vsocket"): + guest_cmd.find_vsocket(tmpdir) + + def test_prepare_command_exports_path(self): + self.assertEqual( + guest_cmd.prepare_command("echo hi"), + "export PATH=/igloo/utils:$PATH; echo hi", + ) + self.assertEqual( + guest_cmd.prepare_command("PATH=/bin echo hi"), + "export PATH=/igloo/utils:$PATH; PATH=/bin echo hi", + ) + + def test_run_guest_with_socket_validates_connect_response(self): + sock = FakeSocket([b"ERR 123\n"]) + + with self.assertRaisesRegex(guest_cmd.GuestCommandError, "Unexpected response"): + guest_cmd.run_guest_with_socket(sock, 123, "true") + + def test_run_guest_with_socket_decodes_result(self): + payload = json.dumps({"stdout": "out", "stderr": "", "exit_code": 0}).encode() + sock = FakeSocket([b"OK 123\n", payload]) + + result = guest_cmd.run_guest_with_socket(sock, 123, "echo out") + + self.assertEqual(result["stdout"], "out") + self.assertEqual(sock.sent[0], b"CONNECT 123\n") + self.assertEqual(sock.sent[1], b"export PATH=/igloo/utils:$PATH; echo out") + + def test_decode_response_rejects_invalid_json(self): + with self.assertRaisesRegex(guest_cmd.GuestCommandError, "valid JSON"): + guest_cmd.decode_response(b"not json") + + def test_decode_response_requires_expected_keys(self): + with self.assertRaisesRegex(guest_cmd.GuestCommandError, "missing 'exit_code'"): + guest_cmd.decode_response(b'{"stdout": "", "stderr": ""}') + + def test_decode_response_requires_object(self): + with self.assertRaisesRegex(guest_cmd.GuestCommandError, "JSON object"): + guest_cmd.decode_response(b"[]") + + def test_decode_response_requires_expected_types(self): + with self.assertRaisesRegex(guest_cmd.GuestCommandError, "exit_code"): + guest_cmd.decode_response(b'{"stdout": "", "stderr": "", "exit_code": "0"}') + + +if __name__ == "__main__": + unittest.main() From dd1a91285d8de37998e9c170fba0accad2170bc1 Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Mon, 25 May 2026 23:10:10 -0400 Subject: [PATCH 3/4] Run guest command client tests in CI --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11c4cba..09e8e10 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Test Python client + run: python3 -m unittest discover -s tests + - name: Build run: | docker run --rm -v $PWD:/app -w /app ghcr.io/rehosting/embedded-toolchains_rust:latest /app/package.sh - From 5c31a930669a3f729fe05a1404b5ff8ee570aca5 Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Mon, 25 May 2026 23:14:21 -0400 Subject: [PATCH 4/4] Pin Rust dependencies for CI toolchain --- .github/workflows/build.yml | 2 +- .github/workflows/test.yml | 2 +- Cargo.lock | 838 ++++++++++++++++++++++++++++++++++++ build_with_docker.sh | 2 +- src/main.rs | 3 +- 5 files changed, 842 insertions(+), 5 deletions(-) create mode 100644 Cargo.lock diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e181f50..988bb98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - name: Build run: | - docker run --rm -v $PWD:/app -w /app ghcr.io/rehosting/embedded-toolchains_rust:latest /app/package.sh + docker run --rm -v $PWD:/app -w /app rehosting/embedded-toolchains_rust:latest /app/package.sh - name: Save package uses: actions/upload-artifact@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09e8e10..3c737e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,4 +18,4 @@ jobs: - name: Build run: | - docker run --rm -v $PWD:/app -w /app ghcr.io/rehosting/embedded-toolchains_rust:latest /app/package.sh + docker run --rm -v $PWD:/app -w /app rehosting/embedded-toolchains_rust:latest /app/package.sh diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..abc26db --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,838 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "env_filter" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e90c2accc4b07a8456ea0debdc2e7587bdd890680d71173a15d4ae604f6eef" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0621c04f2196ac3f488dd583365b9c09be011a4ab8b9f37248ffcc8f6198b56a" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "guesthopper" +version = "0.0.1" +dependencies = [ + "anyhow", + "env_logger", + "lazy_static", + "libc", + "log", + "serde", + "serde_json", + "shlex", + "structopt", + "thiserror", + "tokio", + "tokio-vsock", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jiff" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6835eea34fb6321b9b3aa7b685c2b433948c09447e389dc017fdf687d5d11e65" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c22e04db9c58f5136eb1757f3d5c49a7b187f49e52185228cbd2f5acdfcc08c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mio" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.11.1", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.11.1", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "serde_json" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tokio" +version = "1.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tokio-vsock" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b319ef9394889dab2e1b4f0085b45ba11d0c79dc9d1a9d1afc057d009d0f1c7" +dependencies = [ + "bytes", + "futures", + "libc", + "tokio", + "vsock", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vsock" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8b4d00e672f147fc86a09738fadb1445bd1c0a40542378dfb82909deeee688" +dependencies = [ + "libc", + "nix", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/build_with_docker.sh b/build_with_docker.sh index 2d2c020..4a06484 100755 --- a/build_with_docker.sh +++ b/build_with_docker.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker run -it --rm -v $PWD:/app -w /app ghcr.io/rehosting/embedded-toolchains_rust:latest /app/package.sh +docker run -it --rm -v $PWD:/app -w /app rehosting/embedded-toolchains_rust:latest /app/package.sh diff --git a/src/main.rs b/src/main.rs index 25998dc..b469c56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,6 @@ use structopt::StructOpt; use log::{info,warn,error}; use env_logger; use std::error::Error; -use std::io::Write; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use serde::{Serialize, Deserialize}; @@ -148,7 +147,7 @@ fn warn_long_command_to_console(command: &str) { ); match std::fs::OpenOptions::new().write(true).open("/dev/ttyS0") { Ok(mut tty) => { - let _ = tty.write_all(warning.as_bytes()); + let _ = std::io::Write::write_all(&mut tty, warning.as_bytes()); } Err(_) => { warn!("{}", warning.trim_end());