From e2bc3d8b7adcc83c8a1f616453d9e6958ba88818 Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Tue, 14 May 2024 10:45:54 +0900 Subject: [PATCH 1/8] Update howto build statically-linked binary --- README.md | 156 +++++++++++++++++++++++++++--------------------- static_build.sh | 4 -- 2 files changed, 88 insertions(+), 72 deletions(-) delete mode 100755 static_build.sh diff --git a/README.md b/README.md index 29cb71b..ba6a054 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,43 @@ # orca + Sandbox version control system ## Summary + Orca creates sandboxes from + 1. host's filesystem 2. container (DockerHub) -and version control both host and container environment (by versioning entire filesystem with OverlayFS) + and version control both host and container environment (by versioning entire filesystem with OverlayFS) Read [mechanism](docs/mechanism.md) for more information. ## Install orca + Download orca from [release page](https://github.com/miyake13000/orca/releases/latest). Or execute below command to download command-line. + ```bash $ wget https://github.com/miyake13000/orca/releases/latest/download/orca $ chmod +x ./orca ``` ### Optional + Orca needs root priviledge, so make orca available with sudo. + ```bash $ sudo mv ./orca /usr/bin/ ``` + Or, setuid to orca + ```bash $ sudo chmod 6755 ./orca ``` ## How to use + 1. Initialize (once) ```bash $ orca init # Use host envrionment @@ -37,85 +47,95 @@ $ sudo chmod 6755 ./orca $ orca init --image ubuntu:22.04 --name ubuntu-test ``` 2. Run orca - ```bash - # current files: example.c - $ orca run # Enter sandbox - $ apt update && apt install -y clang - $ clang -o example example.c - # current files: example example.c - $ ./example - $ exit # Exit from sandbox - # current files: example.c - ``` - Or, you can use container image created orca init - ```bash - $ orca --name ubuntu-test run - $ apt update && apt install -y clang - $ clang -o example example.c - ``` + ```bash + # current files: example.c + $ orca run # Enter sandbox + $ apt update && apt install -y clang + $ clang -o example example.c + # current files: example example.c + $ ./example + $ exit # Exit from sandbox + # current files: example.c + ``` + Or, you can use container image created orca init + ```bash + $ orca --name ubuntu-test run + $ apt update && apt install -y clang + $ clang -o example example.c + ``` 3. Commit environment - ```bash - $ orca commit --message "Install clang" - $ orca log - commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 - date: 2024-05-03 10:46:11.868560348 +09:00 - message: Install clang - ``` + ```bash + $ orca commit --message "Install clang" + $ orca log + commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 + date: 2024-05-03 10:46:11.868560348 +09:00 + message: Install clang + ``` 4. Create branch - ```bash - $ orca branch libc - $ orca checkout libc - $ orca run bash -c "apt update && apt install -y 2.35-0ubuntu3" - $ orca run gcc -o example example.com - $ orca log - commit: 408dfdc46bb489eafbf6e38acbeae7656d0c31ec - date: 2024-05-03 10:49:25.145348653 +09:00 - message: Downgrade libc - - commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 - date: 2024-05-03 10:46:11.868560348 +09:00 - message: Install clang - ``` -6. Merge branch - ```bash - $ orca checkout main - $ orca merge libc - $ orca log - commit: 408dfdc46bb489eafbf6e38acbeae7656d0c31ec - date: 2024-05-03 10:49:25.145348653 +09:00 - message: Downgrade libc - - commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 - date: 2024-05-03 10:46:11.868560348 +09:00 - message: Install clang - ``` -7. Reset commit - ```bash - $ orca reset 8dfb0a - $ orca log - commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 - date: 2024-05-03 10:46:11.868560348 +09:00 - message: Install clang - ``` + + ```bash + $ orca branch libc + $ orca checkout libc + $ orca run bash -c "apt update && apt install -y 2.35-0ubuntu3" + $ orca run gcc -o example example.com + $ orca log + commit: 408dfdc46bb489eafbf6e38acbeae7656d0c31ec + date: 2024-05-03 10:49:25.145348653 +09:00 + message: Downgrade libc + + commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 + date: 2024-05-03 10:46:11.868560348 +09:00 + message: Install clang + ``` + +5. Merge branch + + ```bash + $ orca checkout main + $ orca merge libc + $ orca log + commit: 408dfdc46bb489eafbf6e38acbeae7656d0c31ec + date: 2024-05-03 10:49:25.145348653 +09:00 + message: Downgrade libc + + commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 + date: 2024-05-03 10:46:11.868560348 +09:00 + message: Install clang + ``` + +6. Reset commit + ```bash + $ orca reset 8dfb0a + $ orca log + commit: 8dfb0a6c3c943d14ab4cf745d1c761cc6f386219 + date: 2024-05-03 10:46:11.868560348 +09:00 + message: Install clang + ``` ## Uninstall + 1. `sudo rm $(which orca)` 2. `sudo rm -rf $HOME/.local/share/orca` ## Build from source + ### normal build + 1. Install [Rust](https://www.rust-lang.org/tools/install) 2. Build orca - ```bash - $ cargo build --release - ``` -3. orca is placed 'target/release/orca' + ```bash + $ cargo build --release + ``` +3. Orca is placed 'target/release/orca' ### staticaly linked build -1. Install [docker](https://docs.docker.com/engine/install/) + +1. Install 'x86_64-unknown-linux-musl' target + ```bash + $ rustup target add x86_64-unknown-linux-musl + ``` 2. Build orca ```bash - $ ./static_build.sh - ``` -3. orca is placed 'target/x86_64-unknown-linux-musl/release/orca' - + $ cargo build --release --target x86_64-unknown-linux-musl + ``` +3. Orca is placed 'target/x86_64-unknown-linux-musl/release/orca' diff --git a/static_build.sh b/static_build.sh deleted file mode 100755 index 7ee5087..0000000 --- a/static_build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cd "$(dirname $0)" -docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder cargo build --target=x86_64-unknown-linux-musl --release From 996992362049545a2cd55134a7eaf3b9042d9fd0 Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Sun, 19 May 2024 13:21:51 +0900 Subject: [PATCH 2/8] Update Cargo.lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 79a7977..240359a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -701,7 +701,7 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "orca" -version = "0.4.0" +version = "0.5.0" dependencies = [ "anyhow", "chrono", From 63f0b523e7b5391fdf11e5b4134eca4d784dbb17 Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Mon, 20 May 2024 14:36:16 +0900 Subject: [PATCH 3/8] Update LICENSE --- LICENSE.txt => LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename LICENSE.txt => LICENSE (96%) diff --git a/LICENSE.txt b/LICENSE similarity index 96% rename from LICENSE.txt rename to LICENSE index d3839da..bcc6740 100644 --- a/LICENSE.txt +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018-2019 Nomura Laboratory +Copyright (c) 2020-2024 Nomura Laboratory Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From c398ac92b4c1690777a1a2bda51d8f98d6afe097 Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Mon, 30 Jun 2025 12:14:02 +0900 Subject: [PATCH 4/8] Bump dependencies --- Cargo.lock | 236 ++++++++++++++++++++++++++++++++++++----------------- Cargo.toml | 10 +-- 2 files changed, 164 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 240359a..8a81239 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -103,7 +109,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.2", "object", "rustc-demangle", ] @@ -122,9 +128,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "block-buffer" @@ -155,15 +161,15 @@ checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "cfg_aliases" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" @@ -176,7 +182,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -262,9 +268,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -319,12 +325,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.30" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.9", ] [[package]] @@ -410,7 +416,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -605,9 +623,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.154" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "linux-raw-sys" @@ -642,6 +660,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "0.8.11" @@ -649,17 +676,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] [[package]] name = "nix" -version = "0.28.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.9.1", "cfg-if", "cfg_aliases", "libc", @@ -724,12 +751,12 @@ dependencies = [ [[package]] name = "os_pipe" -version = "1.1.5" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57119c3b893986491ec9aa85056780d3a0f3cf4da7cc09dd3650dbd6c6738fb9" +checksum = "db335f4760b14ead6290116f2427bf33a14d4f0617d49f78a246de10c1831224" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -772,15 +799,18 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -796,29 +826,34 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "rand" -version = "0.8.5" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ - "libc", "rand_chacha", "rand_core", ] [[package]] name = "rand_chacha" -version = "0.3.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", "rand_core", @@ -826,11 +861,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom", + "getrandom 0.3.3", ] [[package]] @@ -886,9 +921,9 @@ dependencies = [ [[package]] name = "retry" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9166d72162de3575f950507683fac47e30f6f2c3836b71b7fbc61aa517c9c5f4" +checksum = "a1e211f878258887b3e65dd3c8ff9f530fe109f441a117ee0cdc27f341355032" dependencies = [ "rand", ] @@ -901,7 +936,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "spin", "untrusted", @@ -929,7 +964,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys", @@ -1113,9 +1148,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.63" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -1141,18 +1176,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -1303,9 +1338,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-normalization" @@ -1376,6 +1411,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.92" @@ -1498,7 +1542,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1516,7 +1560,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -1536,18 +1589,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1558,9 +1611,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -1570,9 +1623,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -1582,15 +1635,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -1600,9 +1653,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -1612,9 +1665,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -1624,9 +1677,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -1636,9 +1689,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -1659,6 +1712,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.1", +] + [[package]] name = "xattr" version = "1.3.1" @@ -1670,6 +1732,26 @@ dependencies = [ "rustix", ] +[[package]] +name = "zerocopy" +version = "0.8.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/Cargo.toml b/Cargo.toml index 2b136d9..912f7c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,20 +8,20 @@ description = "Lightweight Container Management Tool written by Rust" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nix = { version = "0.28", features = ["sched", "term", "ioctl", "mount", "fs", "user"] } +nix = { version = "0.30", features = ["sched", "term", "ioctl", "mount", "fs", "user"] } clap = { version = "4.5", features = ["derive", "string"] } reqwest = { version = "0.12", features = ["blocking", "json", "rustls-tls"], default-features = false } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -retry = "2.0" +retry = "2.1" tar = "0.4" -flate2 = "1.0" +flate2 = "1.1" anyhow = "1.0" rm_rf = "0.6" walkdir = "2.5" toml = "0.8" chrono = "0.4" sha1 = "0.10" -thiserror = "1.0" -os_pipe = "1.1" +thiserror = "2.0" +os_pipe = "1.2" const_format = "0.2" From 0eb1a857f1be762cbc482e3a824bd1163db185cf Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Mon, 30 Jun 2025 14:12:33 +0900 Subject: [PATCH 5/8] Update license --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index bcc6740..d1bb9f5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020-2024 Nomura Laboratory +Copyright (c) 2020-2025 Nomura Laboratory Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 063bd009606fd585e39c1a4e191fb62ecb576098 Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Mon, 30 Jun 2025 14:12:48 +0900 Subject: [PATCH 6/8] Bump rust version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 912f7c4..10b0128 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "orca" version = "0.5.0" authors = ["nomlab "] -edition = "2021" +edition = "2024" description = "Lightweight Container Management Tool written by Rust" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 5b54ba8fe7e15ee7360740b91846881db0a73b30 Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Tue, 1 Jul 2025 10:48:56 +0900 Subject: [PATCH 7/8] Update io-connector and its argument (stdin, stderr, stdout) to address Fd, OwnedFD changes of Rust --- src/container.rs | 3 --- src/container/child.rs | 16 ++++++++-------- src/container/parent.rs | 12 +++++++----- src/container/parent/io_connector.rs | 6 +++--- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/container.rs b/src/container.rs index f6daa3a..869a6e6 100644 --- a/src/container.rs +++ b/src/container.rs @@ -16,8 +16,6 @@ use os_pipe::PipeWriter; use parent::io_connector::IoConnector; use std::io::stdin; use std::io::{Read, Write}; -use std::os::fd::FromRawFd; -use std::os::fd::OwnedFd; use std::path::Path; use terminal::Terminal; @@ -92,7 +90,6 @@ fn get_pty_slave() -> Result { nix::sys::stat::Mode::empty(), ) .context("Failed to open /dev/pts/0")?; - let pty_slave = unsafe { OwnedFd::from_raw_fd(pty_slave) }; Terminal::new(pty_slave).context("Failed to open pty_slave") } diff --git a/src/container/child.rs b/src/container/child.rs index 53ee059..65c2bc2 100644 --- a/src/container/child.rs +++ b/src/container/child.rs @@ -6,8 +6,8 @@ use nix::unistd; use std::ffi::CString; use std::fs::{self, copy, create_dir_all}; use std::io::{stderr, stdin, stdout}; +use std::os::fd::{AsRawFd, FromRawFd, OwnedFd}; use std::os::unix::fs::symlink; -use std::os::unix::io::AsRawFd; use std::path::{Path, PathBuf}; pub struct Initializer; @@ -161,14 +161,14 @@ impl Initializer { ) .context("Failed to open /dev/pts/0")?; - let pty_slave_fd = pty_slave.as_raw_fd(); - let stdout = stdout().as_raw_fd(); - let stderr = stderr().as_raw_fd(); - let stdin = stdin().as_raw_fd(); + let pty_slave_fd = pty_slave; + let mut stdout = unsafe { OwnedFd::from_raw_fd(stdout().as_raw_fd()) }; + let mut stderr = unsafe { OwnedFd::from_raw_fd(stderr().as_raw_fd()) }; + let mut stdin = unsafe { OwnedFd::from_raw_fd(stdin().as_raw_fd()) }; - let _ = unistd::dup2(pty_slave_fd, stdout)?; - let _ = unistd::dup2(pty_slave_fd, stderr)?; - let _ = unistd::dup2(pty_slave_fd, stdin)?; + let _ = unistd::dup2(&pty_slave_fd, &mut stdout)?; + let _ = unistd::dup2(&pty_slave_fd, &mut stderr)?; + let _ = unistd::dup2(&pty_slave_fd, &mut stdin)?; Mount::new("/dev/console", FileType::File) .src(concatcp!("/", OLDROOT_NAME, "/dev/console")) diff --git a/src/container/parent.rs b/src/container/parent.rs index 54419b5..8f2df4e 100644 --- a/src/container/parent.rs +++ b/src/container/parent.rs @@ -2,7 +2,7 @@ pub mod io_connector; use anyhow::{anyhow, Context, Result}; use io_connector::IoConnector; -use nix::libc::{grantpt, unlockpt}; +use nix::pty::{grantpt, unlockpt, PtyMaster}; use nix::sched::{self, CloneFlags}; use nix::unistd::Pid; use std::fs::File; @@ -42,17 +42,19 @@ impl Initilizer { ) .context("Child process has not connected tty yet")?; - if unsafe { grantpt(pty_master) } < 0 { + let pty_master = unsafe { PtyMaster::from_owned_fd(pty_master) }; + if grantpt(&pty_master).is_err() { return Err(anyhow!("Failed to grantpt('{}')", pty_master_path)); } - if unsafe { unlockpt(pty_master) } < 0 { + if unlockpt(&pty_master).is_err() { return Err(anyhow!("Failed to unlockpt('{}')", pty_master_path)); } let stdout = unsafe { OwnedFd::from_raw_fd(stdout().as_raw_fd()) }; let stdin = unsafe { OwnedFd::from_raw_fd(stdin().as_raw_fd()) }; - let child_stdout = unsafe { OwnedFd::from_raw_fd(pty_master) }; - let child_stdin = unsafe { OwnedFd::from_raw_fd(pty_master) }; + let pty_master: OwnedFd = pty_master.into(); + let child_stdout = pty_master.try_clone().unwrap(); + let child_stdin = pty_master; Ok(IoConnector::new(stdout, stdin, child_stdout, child_stdin)) } diff --git a/src/container/parent/io_connector.rs b/src/container/parent/io_connector.rs index a4d5b47..7b2b9d2 100644 --- a/src/container/parent/io_connector.rs +++ b/src/container/parent/io_connector.rs @@ -1,6 +1,6 @@ use anyhow::Result; use nix::unistd::{read, write}; -use std::os::fd::{AsRawFd, OwnedFd}; +use std::os::fd::{AsFd, OwnedFd}; use std::thread; pub struct IoConnector; @@ -14,7 +14,7 @@ impl IoConnector { ) -> Self { thread::spawn(move || { let mut s: [u8; 1] = [0; 1]; - let child_stdout_fd = child_stdout.as_raw_fd(); + let child_stdout_fd = child_stdout.as_fd(); loop { if read(child_stdout_fd, &mut s).is_err() { return; @@ -27,7 +27,7 @@ impl IoConnector { thread::spawn(move || { let mut s: [u8; 1] = [0; 1]; - let parent_stdin_fd = parent_stdin.as_raw_fd(); + let parent_stdin_fd = parent_stdin.as_fd(); loop { if read(parent_stdin_fd, &mut s).is_err() { return; From e3d14bf3e31603ca7f576f152906b3752f567ea1 Mon Sep 17 00:00:00 2001 From: miyake13000 Date: Tue, 1 Jul 2025 16:08:29 +0900 Subject: [PATCH 8/8] Fix a bug that the container IO is not connected to host --- src/container.rs | 6 +++--- src/container/child.rs | 11 +++-------- src/container/parent.rs | 23 ++++++----------------- src/container/parent/io_connector.rs | 8 +++----- 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/container.rs b/src/container.rs index 869a6e6..d342aae 100644 --- a/src/container.rs +++ b/src/container.rs @@ -130,11 +130,11 @@ where Initializer::mount_mandatory_files() .context(error_message) .or_exit(); - writer.write_all(SIGNAL_MOUNTED_DEVPTS).unwrap(); - Initializer::copy_resolv_conf(work_dir) + Initializer::create_ptmx_link() .context(error_message) .or_exit(); - Initializer::create_ptmx_link() + writer.write_all(SIGNAL_MOUNTED_DEVPTS).unwrap(); + Initializer::copy_resolv_conf(work_dir) .context(error_message) .or_exit(); reader.read_exact(&mut signal_buf).unwrap(); diff --git a/src/container/child.rs b/src/container/child.rs index 65c2bc2..0487870 100644 --- a/src/container/child.rs +++ b/src/container/child.rs @@ -5,8 +5,6 @@ use core::convert::Infallible; use nix::unistd; use std::ffi::CString; use std::fs::{self, copy, create_dir_all}; -use std::io::{stderr, stdin, stdout}; -use std::os::fd::{AsRawFd, FromRawFd, OwnedFd}; use std::os::unix::fs::symlink; use std::path::{Path, PathBuf}; @@ -162,13 +160,10 @@ impl Initializer { .context("Failed to open /dev/pts/0")?; let pty_slave_fd = pty_slave; - let mut stdout = unsafe { OwnedFd::from_raw_fd(stdout().as_raw_fd()) }; - let mut stderr = unsafe { OwnedFd::from_raw_fd(stderr().as_raw_fd()) }; - let mut stdin = unsafe { OwnedFd::from_raw_fd(stdin().as_raw_fd()) }; - let _ = unistd::dup2(&pty_slave_fd, &mut stdout)?; - let _ = unistd::dup2(&pty_slave_fd, &mut stderr)?; - let _ = unistd::dup2(&pty_slave_fd, &mut stdin)?; + unistd::dup2_stdin(&pty_slave_fd)?; + unistd::dup2_stdout(&pty_slave_fd)?; + unistd::dup2_stderr(&pty_slave_fd)?; Mount::new("/dev/console", FileType::File) .src(concatcp!("/", OLDROOT_NAME, "/dev/console")) diff --git a/src/container/parent.rs b/src/container/parent.rs index 8f2df4e..61bce18 100644 --- a/src/container/parent.rs +++ b/src/container/parent.rs @@ -1,8 +1,8 @@ pub mod io_connector; -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result}; use io_connector::IoConnector; -use nix::pty::{grantpt, unlockpt, PtyMaster}; +use nix::pty::{grantpt, posix_openpt, unlockpt}; use nix::sched::{self, CloneFlags}; use nix::unistd::Pid; use std::fs::File; @@ -34,21 +34,10 @@ impl Initilizer { } pub fn connect_tty() -> Result { - let pty_master_path = "/dev/pts/ptmx"; - let pty_master = nix::fcntl::open( - pty_master_path, - nix::fcntl::OFlag::O_RDWR, - nix::sys::stat::Mode::all(), - ) - .context("Child process has not connected tty yet")?; - - let pty_master = unsafe { PtyMaster::from_owned_fd(pty_master) }; - if grantpt(&pty_master).is_err() { - return Err(anyhow!("Failed to grantpt('{}')", pty_master_path)); - } - if unlockpt(&pty_master).is_err() { - return Err(anyhow!("Failed to unlockpt('{}')", pty_master_path)); - } + let pty_master = posix_openpt(nix::fcntl::OFlag::O_RDWR) + .context("Child process has not connected tty yet")?; + grantpt(&pty_master).context("Failed to grantpt")?; + unlockpt(&pty_master).context("Failed to unlockpt")?; let stdout = unsafe { OwnedFd::from_raw_fd(stdout().as_raw_fd()) }; let stdin = unsafe { OwnedFd::from_raw_fd(stdin().as_raw_fd()) }; diff --git a/src/container/parent/io_connector.rs b/src/container/parent/io_connector.rs index 7b2b9d2..eb75200 100644 --- a/src/container/parent/io_connector.rs +++ b/src/container/parent/io_connector.rs @@ -1,6 +1,6 @@ use anyhow::Result; use nix::unistd::{read, write}; -use std::os::fd::{AsFd, OwnedFd}; +use std::os::fd::OwnedFd; use std::thread; pub struct IoConnector; @@ -14,9 +14,8 @@ impl IoConnector { ) -> Self { thread::spawn(move || { let mut s: [u8; 1] = [0; 1]; - let child_stdout_fd = child_stdout.as_fd(); loop { - if read(child_stdout_fd, &mut s).is_err() { + if read(&child_stdout, &mut s).is_err() { return; }; if write(&parent_stdout, &s).is_err() { @@ -27,9 +26,8 @@ impl IoConnector { thread::spawn(move || { let mut s: [u8; 1] = [0; 1]; - let parent_stdin_fd = parent_stdin.as_fd(); loop { - if read(parent_stdin_fd, &mut s).is_err() { + if read(&parent_stdin, &mut s).is_err() { return; } if write(&child_stdin, &s).is_err() {