SHA256
Compare commits
27
Commits
c758c68f23
..
v0.1.6
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
c132ca3ffa | ||
|
|
0ea1a9bb3f | ||
|
|
b4127f2fe8 | ||
|
|
1bf3ef0e15 | ||
|
|
b90544bac5 | ||
|
|
62a9e244a6 | ||
|
|
32a1491537 | ||
|
|
56d181864a | ||
|
|
ba4cca635b | ||
|
|
92cb61dccc | ||
|
|
f15fa368ac | ||
|
|
70246f0d97 | ||
|
|
856a759315 | ||
|
|
4d01705527 | ||
|
|
e6a3425109 | ||
|
|
81a0f4f8a2 | ||
|
|
0b4291b97e | ||
|
|
f74461f6fb | ||
|
|
4396c5011b | ||
|
|
acdf923ce0 | ||
|
|
68c19d84cf | ||
|
|
33cabc86c9 | ||
|
|
379a992421 | ||
|
|
ab7ba83428 | ||
|
|
75c043b652 | ||
|
|
212fa7ed44 | ||
|
|
76a04b7d3e |
Generated
+97
-54
@@ -34,9 +34,9 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.13.0"
|
version = "2.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "by_address"
|
name = "by_address"
|
||||||
@@ -59,6 +59,12 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg_aliases"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "compact_str"
|
name = "compact_str"
|
||||||
version = "0.9.1"
|
version = "0.9.1"
|
||||||
@@ -93,7 +99,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"strsim",
|
"strsim",
|
||||||
"syn",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -104,7 +110,7 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -115,9 +121,9 @@ checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.16.0"
|
version = "1.17.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
@@ -190,7 +196,7 @@ dependencies = [
|
|||||||
"indoc",
|
"indoc",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -221,9 +227,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.186"
|
version = "0.2.189"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libm"
|
name = "libm"
|
||||||
@@ -242,18 +248,30 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lru"
|
name = "lru"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9"
|
checksum = "0b6180140927ee907000b0aa540091f6ea512ead4447c92b8fc35bc72788a5a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.17.1",
|
"hashbrown 0.17.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.8.2"
|
version = "2.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4"
|
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nix"
|
||||||
|
version = "0.31.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if",
|
||||||
|
"cfg_aliases",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-conv"
|
name = "num-conv"
|
||||||
@@ -287,9 +305,11 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nyanit"
|
name = "nyanit"
|
||||||
version = "0.1.0"
|
version = "0.1.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"nix",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
|
"ratatui-textarea",
|
||||||
"regex",
|
"regex",
|
||||||
"termion",
|
"termion",
|
||||||
]
|
]
|
||||||
@@ -315,14 +335,14 @@ dependencies = [
|
|||||||
"by_address",
|
"by_address",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "portable-atomic"
|
name = "portable-atomic"
|
||||||
version = "1.13.1"
|
version = "1.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powerfmt"
|
name = "powerfmt"
|
||||||
@@ -332,27 +352,27 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.106"
|
version = "1.0.107"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.45"
|
version = "1.0.47"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ratatui"
|
name = "ratatui"
|
||||||
version = "0.30.1"
|
version = "0.30.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1695748e3a735b34968c887ceea5a380b43545903868ae8f5b666593100f6b68"
|
checksum = "3274ba0a2c5e1bcad2a2005d20f4dc59dad26b2eb0940fb094500dba4099d57d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"instability",
|
"instability",
|
||||||
"ratatui-core",
|
"ratatui-core",
|
||||||
@@ -363,14 +383,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ratatui-core"
|
name = "ratatui-core"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "42d3603f354bba8c595fa47860e60142d7372b7210c27044c6a7d0e1a4336b44"
|
checksum = "cbb175c433c8e28a809d1f5773a2ae96e68c0ce40db865cbab1020bf33ae479c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"compact_str",
|
"compact_str",
|
||||||
"hashbrown 0.17.1",
|
"hashbrown 0.17.1",
|
||||||
"indoc",
|
|
||||||
"itertools",
|
"itertools",
|
||||||
"kasuari",
|
"kasuari",
|
||||||
"lru",
|
"lru",
|
||||||
@@ -385,9 +404,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ratatui-termion"
|
name = "ratatui-termion"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c16cc35a9d9114e0b2bb4b22018b96ae7f5fe60e2595dc73e622b4e78624835"
|
checksum = "87c732202fa5a71a9da0991013f0853e53f87048f45198e3a1ca3ee722accc2f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"instability",
|
"instability",
|
||||||
"ratatui-core",
|
"ratatui-core",
|
||||||
@@ -395,10 +414,23 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ratatui-widgets"
|
name = "ratatui-textarea"
|
||||||
version = "0.3.1"
|
version = "0.9.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ef4f17dd7ac3abf5adc2b920a03c61eee4bfe6a88fa5191936895525371d79c"
|
checksum = "3c78d5ba0f26f97baed69a4c479f268a31c7b5b89d68ab939842152e383d6e73"
|
||||||
|
dependencies = [
|
||||||
|
"ratatui-core",
|
||||||
|
"ratatui-termion",
|
||||||
|
"ratatui-widgets",
|
||||||
|
"unicode-segmentation",
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ratatui-widgets"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "66e3d19bcc9130ca376277d93b60767ff121ace3be06f5f95f81dd68956407d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"hashbrown 0.17.1",
|
"hashbrown 0.17.1",
|
||||||
@@ -416,9 +448,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.12.4"
|
version = "1.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba"
|
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -428,9 +460,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.14"
|
version = "0.4.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
|
checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -445,9 +477,9 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.22"
|
version = "1.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
@@ -457,9 +489,9 @@ checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.228"
|
version = "1.0.229"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
@@ -467,22 +499,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_core"
|
name = "serde_core"
|
||||||
version = "1.0.228"
|
version = "1.0.229"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.228"
|
version = "1.0.229"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 3.0.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -515,14 +547,25 @@ dependencies = [
|
|||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.117"
|
version = "2.0.119"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "3.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -541,29 +584,29 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.18"
|
version = "2.0.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
|
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.18"
|
version = "2.0.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
|
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 3.0.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.49"
|
version = "0.3.54"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "711a53c2d47bbd818258c498c8dbfe186a2526c631495cfe7e078567f86b8469"
|
checksum = "3e1d5e639ff6bab73cb6885cc7e7b1de96c3f32c68ec55f3952614bec1092244"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
"libc",
|
"libc",
|
||||||
|
|||||||
+5
-4
@@ -1,18 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nyanit"
|
name = "nyanit"
|
||||||
version = "0.1.0"
|
version = "0.1.6"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
nix = { version = "0.31", features = ["mount"] }
|
||||||
ratatui = { version = "0.30", default-features = false, features = ["termion"] }
|
ratatui = { version = "0.30", default-features = false, features = ["termion"] }
|
||||||
regex = "1.12.4"
|
ratatui-textarea = { version = "0.9", default-features = false, features = ["termion"] }
|
||||||
|
regex = "1.1"
|
||||||
termion = "4"
|
termion = "4"
|
||||||
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
debug = false
|
debug = false
|
||||||
incremental = false
|
incremental = false
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
opt-level = 3
|
opt-level = 2
|
||||||
strip = true
|
strip = true
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
# nyanit
|
# nyanit
|
||||||
|
|
||||||
Init program for initrd
|
Kira-Linux init program for initrd
|
||||||
|
|
||||||
|
|
||||||
|
1. It looks for partitoin with GPT labelve **bee-root** what will shown in dev tree as **/dev/disk/by-partlabel/bee-root**
|
||||||
|
And this partition should be formated to bcachefs.
|
||||||
|
|
||||||
|
2. Nyanit checks if bcachefs is encrypted, and asks for unlock password if it is.
|
||||||
|
|
||||||
|
3. Then it mounts it to **/mnt/bee-root**.
|
||||||
|
|
||||||
|
4. And looks for snapshots with name pattern **/mnt/bee-root/bzz_snaps/bzz-yyyy-mm-ddTHH-MM-SS**
|
||||||
|
|
||||||
|
5. If no snapshots are found it calls **switch_root** for **/mnt/bee-root**
|
||||||
|
|
||||||
|
6. Othervise vait for F2 for few seconds.
|
||||||
|
And if F2 pressed provides list of snapshoots to boot from.
|
||||||
|
|
||||||
|
7. After some snapshoot or just **/mnt/bee-root** is selected, Nyanit doing **switch_root** to it.
|
||||||
|
|
||||||
|
|||||||
+155
-61
@@ -14,30 +14,32 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use ratatui::widgets::Borders;
|
use ratatui::{Frame, Terminal, backend::TermionBackend};
|
||||||
use ratatui::{Frame, Terminal, backend::TermionBackend, widgets::Paragraph};
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Constraint, Layout},
|
layout::{Constraint, Layout},
|
||||||
style::{Style, Stylize},
|
style::{Color, Style, Stylize},
|
||||||
text::{Line},
|
text::Line,
|
||||||
widgets::{Block, List, ListState},
|
widgets::{Block, Borders, List, ListState, Paragraph},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use ratatui_textarea::TextArea;
|
||||||
|
|
||||||
use std::io::{self, Read, stdout};
|
use std::io::{self, Read, stdout};
|
||||||
use std::process::ExitCode;
|
use std::process::ExitCode;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use termion::event::{Event, Key};
|
use termion::event::{self, Event};
|
||||||
use termion::raw::IntoRawMode;
|
use termion::raw::IntoRawMode;
|
||||||
|
|
||||||
mod nyan_system;
|
mod nyan_system;
|
||||||
|
|
||||||
use nyan_system::{ExecCommandError};
|
use nyan_system::ExecCommandError;
|
||||||
|
|
||||||
const BEE_CAT: &str = include_str!("bee_cat.txt");
|
const BEE_CAT: &str = include_str!("bee_cat.txt");
|
||||||
|
|
||||||
//const ROOT_PARTLABEL: &str = "bee-root";
|
//const ROOT_PARTLABEL: &str = "bee-root";
|
||||||
const ROOT_DEV: &str = "/dev/disk/by-partlabel/bee-root";
|
const ROOT_PARTLABEL: &str = "bee-root";
|
||||||
const TMP_ROOT: &str = "/mnt/bee_root";
|
const TMP_ROOT: &str = "/mnt/bee_root";
|
||||||
const TMP_ROOT_SNAPS: &str = "/mnt/bee-root/bzz_snaps";
|
const TMP_ROOT_SNAPS: &str = "/mnt/bee-root/bzz_snaps";
|
||||||
const SYS_INIT: &str = "/sbin/init";
|
const SYS_INIT: &str = "/sbin/init";
|
||||||
@@ -71,19 +73,10 @@ enum NyanitState {
|
|||||||
HandOff(String),
|
HandOff(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_stage() -> Result<NyanitState, ExecCommandError> {
|
/// Mounting bee-root and chiking if there any snapshots
|
||||||
// mount sysfss
|
fn mount_and_check_snaps(bee_root_dev: &str) -> Result<NyanitState, ExecCommandError> {
|
||||||
nyan_system::prepare_env()?;
|
|
||||||
|
|
||||||
// check if device is encrypted
|
|
||||||
if nyan_system::bzzpss_dev_encrypted(ROOT_DEV)? {
|
|
||||||
// if encrypted return EnterPassword so used get promted for pass
|
|
||||||
return Ok(NyanitState::EnterPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if unencrypted
|
|
||||||
// mount bee-root
|
// mount bee-root
|
||||||
nyan_system::mount_bee_root(TMP_ROOT, ROOT_DEV)?;
|
nyan_system::mount_bee_root(TMP_ROOT, bee_root_dev)?;
|
||||||
|
|
||||||
// list snaps if any
|
// list snaps if any
|
||||||
let mut snaps_list = nyan_system::list_bzzpss_snaps(TMP_ROOT_SNAPS)?;
|
let mut snaps_list = nyan_system::list_bzzpss_snaps(TMP_ROOT_SNAPS)?;
|
||||||
@@ -93,53 +86,89 @@ fn init_stage() -> Result<NyanitState, ExecCommandError> {
|
|||||||
return Ok(NyanitState::WaitForF2(snaps_list));
|
return Ok(NyanitState::WaitForF2(snaps_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
// tell to finish boot
|
// else tell to finish boot
|
||||||
Ok(NyanitState::HandOff(TMP_ROOT.into()))
|
Ok(NyanitState::HandOff(TMP_ROOT.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NyanitTUI {
|
fn init_stage() -> Result<(String, NyanitState), ExecCommandError> {
|
||||||
exit: bool,
|
// mount sysfss
|
||||||
state: NyanitState,
|
nyan_system::prepare_env().map_err(|ex| format!("prepare_env error: {}", ex))?;
|
||||||
list_state: ListState,
|
|
||||||
time_counter: u32,
|
// get bee-root device name aka /dev/sda1
|
||||||
|
let bee_root_dev = nyan_system::find_partlabel(ROOT_PARTLABEL)?;
|
||||||
|
// check if device is encrypted
|
||||||
|
if nyan_system::bzzpss_dev_encrypted(&bee_root_dev).map_err(|ex| format!("Error checking if device is encrypted: {}", ex))? {
|
||||||
|
// if encrypted return EnterPassword so used get promted for pass
|
||||||
|
return Ok((bee_root_dev, NyanitState::EnterPassword));
|
||||||
|
}
|
||||||
|
|
||||||
|
// if unencrypted
|
||||||
|
let check_res = mount_and_check_snaps(&bee_root_dev)?;
|
||||||
|
Ok((bee_root_dev, check_res))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NyanitTUI {
|
struct NyanitTUI<'a> {
|
||||||
|
exit: bool,
|
||||||
|
state: NyanitState,
|
||||||
|
bee_root_dev: String,
|
||||||
|
list_state: ListState,
|
||||||
|
time_counter: u32,
|
||||||
|
textarea: Option<TextArea<'a>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NyanitTUI<'_> {
|
||||||
pub fn new() -> io::Result<Self> {
|
pub fn new() -> io::Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
exit: false,
|
exit: false,
|
||||||
state: NyanitState::Init,
|
state: NyanitState::Init,
|
||||||
|
bee_root_dev: String::new(),
|
||||||
list_state: ListState::default().with_selected(Some(0)),
|
list_state: ListState::default().with_selected(Some(0)),
|
||||||
time_counter: 0,
|
time_counter: 0,
|
||||||
|
textarea: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn bzz_unwrap<T,E>(&mut self, val: Result<T,E>) -> T {
|
|
||||||
// match val {
|
|
||||||
// Ok(v) => v,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
/// runs the application's main loop until the user quits
|
/// runs the application's main loop until the user quits
|
||||||
pub fn run(&mut self) -> io::Result<()> {
|
pub fn run(&mut self) -> io::Result<()> {
|
||||||
self.state = match init_stage() {
|
self.state = match init_stage() {
|
||||||
Ok(st) => st,
|
Ok(res) => {
|
||||||
Err(ex) => NyanitState::Error(format!("Error while trying to bzzz-pss things: {}", ex)),
|
self.bee_root_dev = res.0;
|
||||||
|
res.1
|
||||||
|
},
|
||||||
|
Err(ex) => {
|
||||||
|
NyanitState::Error(format!("Error while trying to bzzz-pss things:\n{}", ex))
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// if drive unencrypted and there is no root snapshots finish boot
|
// if drive unencrypted and there is no root snapshots finish boot
|
||||||
if let NyanitState::HandOff(root_mnt) = &self.state {
|
match &self.state {
|
||||||
if let Err(ex) = nyan_system::hand_off_control(root_mnt, SYS_INIT) {
|
// if drive unencrypted and there is no root snapshots finish boot
|
||||||
self.state = NyanitState::Error(ex.to_string())
|
NyanitState::HandOff(root_mnt) => {
|
||||||
|
if let Err(ex) = nyan_system::hand_off_control(root_mnt, SYS_INIT) {
|
||||||
|
self.state = NyanitState::Error(ex.to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// init password input
|
||||||
|
NyanitState::EnterPassword => {
|
||||||
|
let mut textarea: TextArea<'_> = TextArea::default();
|
||||||
|
textarea.set_cursor_line_style(Style::default());
|
||||||
|
textarea.set_mask_char('\u{1F41D}'); //U+2022 BULLET (•)
|
||||||
|
textarea.set_placeholder_text("Please enter your password");
|
||||||
|
textarea.set_style(Style::default().fg(Color::LightYellow));
|
||||||
|
textarea.set_block(Block::default().borders(Borders::ALL).title("Password"));
|
||||||
|
self.textarea = Some(textarea);
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init terminal
|
||||||
// 1. Enable raw mode
|
// 1. Enable raw mode
|
||||||
let stdout = stdout().into_raw_mode()?;
|
let stdout = stdout().into_raw_mode()?;
|
||||||
// 2. Setup Terminal
|
// 2. Setup Terminal
|
||||||
let backend = TermionBackend::new(stdout);
|
let backend = TermionBackend::new(stdout);
|
||||||
let mut terminal = Terminal::new(backend)?;
|
let mut terminal = Terminal::new(backend)?;
|
||||||
|
|
||||||
// init tty input and start actually drawing things now!
|
// init tty async input and start actually drawing things now!
|
||||||
let mut tty_input_async = termion::async_stdin().bytes();
|
let mut tty_input_async = termion::async_stdin().bytes();
|
||||||
|
|
||||||
self.time_counter = 0;
|
self.time_counter = 0;
|
||||||
@@ -207,51 +236,116 @@ impl NyanitTUI {
|
|||||||
&mut self.list_state,
|
&mut self.list_state,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
NyanitState::EnterPassword => {
|
||||||
|
frame.render_widget(self.textarea.as_ref().unwrap(), vertical_chunks[1]);
|
||||||
|
}
|
||||||
|
NyanitState::HandOff(_) => {
|
||||||
|
let ok_text = Paragraph::new("Booting\nKira Linux\n \u{1F41D} \u{1F41D} :3")
|
||||||
|
.block(Block::bordered().light_green())
|
||||||
|
.light_green();
|
||||||
|
frame.render_widget(ok_text, vertical_chunks[1]);
|
||||||
|
// just some time to look at message
|
||||||
|
thread::sleep(Duration::from_millis(1000))
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_events(&mut self, tty_input: &mut io::Bytes<termion::AsyncReader>) -> io::Result<()> {
|
fn handle_events(&mut self, tty_input: &mut io::Bytes<termion::AsyncReader>) -> io::Result<()> {
|
||||||
|
|
||||||
// cheking if there is any input to read
|
// cheking if there is any input to read
|
||||||
if let Some(item) = tty_input.next() {
|
if let Some(item) = tty_input.next() {
|
||||||
let read_byte = item?;
|
let read_byte = item?;
|
||||||
|
|
||||||
let e = termion::event::parse_event(read_byte, tty_input)?;
|
let e = event::parse_event(read_byte, tty_input)?;
|
||||||
match &self.state {
|
match &self.state {
|
||||||
NyanitState::WaitForF2(vol_list) => {
|
// finishing boot
|
||||||
if e == Event::Key(Key::F(2)) {
|
NyanitState::HandOff(root_mnt) => {
|
||||||
self.state = NyanitState::ChooseSnapshot(vol_list.clone());
|
if let Err(ex) = nyan_system::hand_off_control(root_mnt, SYS_INIT) {
|
||||||
}
|
self.state = NyanitState::Error(ex.to_string())
|
||||||
},
|
|
||||||
NyanitState::ChooseSnapshot(vol_list) => {
|
|
||||||
match e {
|
|
||||||
Event::Key(Key::Down) => self.list_state.select_next(),
|
|
||||||
Event::Key(Key::Up) => self.list_state.select_previous(),
|
|
||||||
Event::Key(Key::Char('\n')) => if let Some(idx) = self.list_state.selected() {
|
|
||||||
self.state = NyanitState::HandOff(vol_list[idx].clone());
|
|
||||||
},
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
NyanitState::WaitForF2(vol_list) => {
|
||||||
|
if e == Event::Key(event::Key::F(2)) {
|
||||||
|
self.state = NyanitState::ChooseSnapshot(vol_list.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NyanitState::ChooseSnapshot(vol_list) => match e {
|
||||||
|
Event::Key(event::Key::Down) => self.list_state.select_next(),
|
||||||
|
Event::Key(event::Key::Up) => self.list_state.select_previous(),
|
||||||
|
Event::Key(event::Key::Char('\n')) => {
|
||||||
|
if let Some(idx) = self.list_state.selected() {
|
||||||
|
self.state = NyanitState::HandOff(vol_list[idx].clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
},
|
},
|
||||||
_ => ()
|
NyanitState::EnterPassword => {
|
||||||
|
match e {
|
||||||
|
// try to unlock if enter pressed
|
||||||
|
Event::Key(event::Key::Char('\n')) => {
|
||||||
|
let password = self.textarea.as_ref().unwrap().lines()[0].clone();
|
||||||
|
match nyan_system::bcachefs_unlock(password, &self.bee_root_dev) {
|
||||||
|
Ok(unlocked) => {
|
||||||
|
if unlocked {
|
||||||
|
// need to check for subvolumes and stuff
|
||||||
|
self.state = match mount_and_check_snaps(&self.bee_root_dev) {
|
||||||
|
Ok(st) => {
|
||||||
|
self.time_counter = 0;
|
||||||
|
st
|
||||||
|
}
|
||||||
|
Err(ex) => NyanitState::Error(ex.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ask to enter password again
|
||||||
|
else {
|
||||||
|
self.textarea
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.set_placeholder_text("Wrong password, try again");
|
||||||
|
self.textarea
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.set_style(Style::default().fg(Color::LightRed));
|
||||||
|
self.textarea.as_mut().unwrap().clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(ex) => {
|
||||||
|
self.state = NyanitState::Error(ex.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
self.textarea
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.set_style(Style::default().fg(Color::LightYellow));
|
||||||
|
self.textarea.as_mut().unwrap().input(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Tick time
|
// Tick time
|
||||||
thread::sleep(Duration::from_millis(500));
|
thread::sleep(Duration::from_millis(500));
|
||||||
self.time_counter = self.time_counter.wrapping_add(1u32);
|
|
||||||
// 2.5 sec wait
|
if let NyanitState::WaitForF2(_) = self.state {
|
||||||
if self.time_counter > 5 {
|
self.time_counter = self.time_counter.wrapping_add(1u32);
|
||||||
// boot from root
|
// 2.5 sec wait
|
||||||
self.state = NyanitState::HandOff(TMP_ROOT.into());
|
if self.time_counter > 5 {
|
||||||
|
// boot from root
|
||||||
|
self.state = NyanitState::HandOff(TMP_ROOT.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
|
// nyan_system::set_env_vars_unsafe();
|
||||||
let mut app = NyanitTUI::new().unwrap();
|
let mut app = NyanitTUI::new().unwrap();
|
||||||
app.run().unwrap();
|
app.run().unwrap();
|
||||||
// Terminal restores automatically when `stdout` (RawTerminal) is dropped
|
// Terminal restores automatically when `stdout` (RawTerminal) is dropped
|
||||||
|
|||||||
+161
-22
@@ -18,6 +18,7 @@
|
|||||||
Functions fot system interaction
|
Functions fot system interaction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use nix;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
@@ -109,35 +110,116 @@ pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// exec given command with arguments, returning stdout parsed to UTF-8 string
|
/// Gets device node aka /dev/sda1 from gpr partition label
|
||||||
/// capturing stderr in case or failure
|
/// blkid -s PARTLABEL --match-token "PARTLABEL=primary"
|
||||||
pub fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result<String, ExecCommandError> {
|
pub fn find_partlabel(partlabel: &str) -> Result<String, ExecCommandError> {
|
||||||
let out = Command::new(cmd).args(args).output()?;
|
let out = Command::new("/usr/bin/blkid")
|
||||||
|
.args([
|
||||||
|
"-s",
|
||||||
|
"PARTLABEL",
|
||||||
|
"--match-token",
|
||||||
|
format!("\"PARTLABEL={}\"", partlabel).as_str(),
|
||||||
|
])
|
||||||
|
.output()?;
|
||||||
if out.status.success() {
|
if out.status.success() {
|
||||||
Ok(String::from_utf8(out.stdout)?)
|
let out_text = String::from_utf8(out.stdout)?;
|
||||||
|
|
||||||
|
let split_res = out_text.split_once(':').ok_or_else(|| {
|
||||||
|
ExecCommandError::Other(format!("Unexpected blkid output format: \"{}\"", out_text))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(split_res.0.to_string())
|
||||||
} else {
|
} else {
|
||||||
Err(CommandFailed::new(cmd, args, out.stderr).into())
|
Err(ExecCommandError::Other(format!(
|
||||||
|
"Connot find device with partlabel={} or something other is wrong: \"{}\"",
|
||||||
|
partlabel,
|
||||||
|
String::from_utf8(out.stderr).unwrap_or_else(|_| String::new())
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// exec given command with arguments, returning stdout parsed to UTF-8 string
|
||||||
|
/// capturing stderr in case or failure
|
||||||
|
// pub fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result<String, ExecCommandError> {
|
||||||
|
// let out = Command::new(cmd).args(args).output()?;
|
||||||
|
// if out.status.success() {
|
||||||
|
// Ok(String::from_utf8(out.stdout)?)
|
||||||
|
// } else {
|
||||||
|
// Err(CommandFailed::new(cmd, args, out.stderr).into())
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// ls /dev/disk/by-partlabel/
|
// ls /dev/disk/by-partlabel/
|
||||||
// here we can find gpt part labels
|
// here we can find gpt part labels
|
||||||
pub fn list_gpt_labeled_devs() -> Result<Vec<String>, ExecCommandError> {
|
// pub fn list_gpt_labeled_devs() -> Result<Vec<String>, ExecCommandError> {
|
||||||
use std::os::unix::fs::FileTypeExt;
|
// use std::os::unix::fs::FileTypeExt;
|
||||||
let mut res: Vec<String> = Vec::new();
|
// let mut res: Vec<String> = Vec::new();
|
||||||
for maybe_entry in fs::read_dir("/dev/disk/by-partlabel/")? {
|
// for maybe_entry in fs::read_dir("/dev/disk/by-partlabel/")? {
|
||||||
let entry = maybe_entry?;
|
// let entry = maybe_entry?;
|
||||||
if entry.file_type()?.is_block_device() {
|
// if entry.file_type()?.is_block_device() {
|
||||||
res.push(entry.path().to_str().unwrap().to_string());
|
// res.push(entry.path().to_str().unwrap().to_string());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Ok(res)
|
||||||
|
// }
|
||||||
|
|
||||||
|
/// bcachefs unlock --file=/tmp/bzzpsspass.txt /dev/loop0somedev
|
||||||
|
/// Ok so. It is stupid, because bcacheutils far from ideal.
|
||||||
|
/// But if we provide wrong password from file or stdin this stuff plays stupid and asks for right password.
|
||||||
|
/// Sooo.. In order to know if unlock was sucessfull we need to check if program exited with Ok status,
|
||||||
|
/// or it shits to STDERR still waiting for stdin
|
||||||
|
/// Returns true if unlock successful, and false otherwise
|
||||||
|
pub fn bcachefs_unlock(pass: String, dev: &str) -> Result<bool, ExecCommandError> {
|
||||||
|
use std::io::Read;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::process::Stdio;
|
||||||
|
// "-k", "session" is important as it stores key in sessyin keyring what allows
|
||||||
|
// system to mount filesystem after switch_root
|
||||||
|
let mut child = Command::new("/usr/bin/bcachefs")
|
||||||
|
.args(&vec!["unlock", "-k", "session", dev])
|
||||||
|
.stdin(Stdio::piped())
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
|
.spawn()?;
|
||||||
|
|
||||||
|
let mut c_stderr = child
|
||||||
|
.stderr
|
||||||
|
.take()
|
||||||
|
.ok_or_else(|| "Unable to get child process STDERR".to_string())?;
|
||||||
|
|
||||||
|
// Write password to STDIN in a limited scope
|
||||||
|
{
|
||||||
|
let mut c_stdin = child
|
||||||
|
.stdin
|
||||||
|
.take()
|
||||||
|
.ok_or_else(|| "Unable to get child process STDIN".to_string())?;
|
||||||
|
// neccessery to use thread or we may be deadlocking
|
||||||
|
c_stdin.write_all(pass.as_bytes())?;
|
||||||
|
let bytes_written = c_stdin.write(b"\n")?;
|
||||||
|
println!("bytes_written: {}", bytes_written);
|
||||||
|
// stdin is dropped here automatically when the block ends
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(res)
|
let mut buffer = [0u8; 10];
|
||||||
|
// This blocks.
|
||||||
|
// if unlok fails it reads 10 bytes (piece of err message)
|
||||||
|
// if sucess it reads 0 bytes and exit
|
||||||
|
let read_b = c_stderr.read(&mut buffer)?;
|
||||||
|
if read_b > 0 {
|
||||||
|
println!("STDERR error not empty, password incorrect! Try to kill a child.");
|
||||||
|
child.kill()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Safe to wait now; child will see EOF
|
||||||
|
let exit_status = child.wait()?;
|
||||||
|
// if exit status is SUCCESS - unloking is successful
|
||||||
|
Ok(exit_status.success())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cheking if device is encripted
|
/// Cheking if device is encripted
|
||||||
pub fn bzzpss_dev_encrypted(dev_name: &str) -> Result<bool, ExecCommandError> {
|
pub fn bzzpss_dev_encrypted(dev_name: &str) -> Result<bool, ExecCommandError> {
|
||||||
match exec_command("bcachefs", &vec!["unlock", "--check"]) {
|
match exec_command("/usr/bin/bcachefs", &vec!["unlock", "--check", dev_name]) {
|
||||||
Ok(_) => Ok(true), // if status OK - dev encrypted
|
Ok(_) => Ok(true), // if status OK - dev encrypted
|
||||||
Err(ExecCommandError::CommandFailed(_)) => Ok(false), // if bcachefs returned error - unencrypted
|
Err(ExecCommandError::CommandFailed(_)) => Ok(false), // if bcachefs returned error - unencrypted
|
||||||
Err(ex) => Err(ex), // othervice its error
|
Err(ex) => Err(ex), // othervice its error
|
||||||
@@ -169,20 +251,77 @@ pub fn list_bzzpss_snaps(snaps_dir: &str) -> Result<Vec<String>, ExecCommandErro
|
|||||||
// mount -t proc none /proc
|
// mount -t proc none /proc
|
||||||
// mount -t sysfs none /sys
|
// mount -t sysfs none /sys
|
||||||
// modprobe bcachefs
|
// modprobe bcachefs
|
||||||
pub fn prepare_env() -> Result<(), ExecCommandError> {
|
pub fn prepare_env() -> Result<(), String> {
|
||||||
|
use nix::mount::{MsFlags, mount};
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
// Mount proc filesystem
|
||||||
// mount -t proc none /proc
|
// mount -t proc none /proc
|
||||||
exec_command("mount", &vec!["-t", "proc", "none", "/proc"])?;
|
mount(
|
||||||
|
Some("proc"),
|
||||||
|
Path::new("/proc"),
|
||||||
|
Some("proc"),
|
||||||
|
MsFlags::empty(),
|
||||||
|
None::<&str>,
|
||||||
|
)
|
||||||
|
.map_err(|ex| format!("Error mounting /proc: {}", ex.to_string()))?;
|
||||||
|
|
||||||
// mount -t sysfs none /sys
|
// mount -t sysfs none /sys
|
||||||
exec_command("mount", &vec!["-t", "sysfs", "none", "/sys"])?;
|
mount(
|
||||||
|
Some("sysfs"),
|
||||||
|
Path::new("/sys"),
|
||||||
|
Some("sysfs"),
|
||||||
|
MsFlags::empty(),
|
||||||
|
None::<&str>,
|
||||||
|
)
|
||||||
|
.map_err(|ex| format!("Error mounting /sys: {}", ex.to_string()))?;
|
||||||
|
|
||||||
|
mount(
|
||||||
|
Some("devtmpfs"),
|
||||||
|
"/dev",
|
||||||
|
Some("devtmpfs"),
|
||||||
|
MsFlags::empty(),
|
||||||
|
None::<&str>,
|
||||||
|
)
|
||||||
|
.map_err(|ex| format!("Error mounting /dev: {}", ex.to_string()))?;
|
||||||
|
|
||||||
// modprobe bcachefs
|
// modprobe bcachefs
|
||||||
exec_command("modprobe", &vec!["bcachefs"])?;
|
// exec_command("modprobe", &vec!["bcachefs"])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// MUST be done before spawning any threads or async runtimes
|
||||||
|
pub fn set_env_vars_unsafe() -> () {
|
||||||
|
use std::env;
|
||||||
|
// 1. Define your custom paths
|
||||||
|
let custom_bin = "/usr/bin";
|
||||||
|
let custom_lib = "/usr/lib";
|
||||||
|
|
||||||
|
// 2. Retrieve existing paths to append/prepend (optional but recommended)
|
||||||
|
// 3. Construct new path strings
|
||||||
|
let new_path = match env::var("PATH") {
|
||||||
|
Err(_) => custom_bin.to_string(),
|
||||||
|
Ok(v) => format!("{}:{}", custom_bin, v),
|
||||||
|
};
|
||||||
|
|
||||||
|
let new_ld_path = match env::var("LD_LIBRARY_PATH") {
|
||||||
|
Err(_) => custom_lib.to_string(),
|
||||||
|
Ok(v) => format!("{}:{}", custom_lib, v),
|
||||||
|
};
|
||||||
|
|
||||||
|
// 4. Set environment variables (UNSAFE in Rust 2024+)
|
||||||
|
// MUST be done before spawning any threads or async runtimes
|
||||||
|
unsafe {
|
||||||
|
env::set_var("PATH", new_path);
|
||||||
|
env::set_var("LD_LIBRARY_PATH", new_ld_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// # Mount the real root filesystem
|
// # Mount the real root filesystem
|
||||||
pub fn mount_bee_root(mount_point: &str, dev_name: &str) -> Result<(), ExecCommandError> {
|
pub fn mount_bee_root(mount_point: &str, dev_name: &str) -> Result<(), ExecCommandError> {
|
||||||
exec_command("mount", &vec!["-o", "ro", dev_name, mount_point])?;
|
exec_command("/usr/bin/mount", &vec!["-o", "ro", dev_name, mount_point])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +343,7 @@ pub fn hand_off_control(mnt_root: &str, init_path: &str) -> Result<(), ExecComma
|
|||||||
// 3. Execute switch_root.
|
// 3. Execute switch_root.
|
||||||
// This call replaces the current Rust process.
|
// This call replaces the current Rust process.
|
||||||
// It only returns if an error occurs.
|
// It only returns if an error occurs.
|
||||||
let err = Command::new("switch_root")
|
let err = Command::new("/usr/bin/switch_root")
|
||||||
.arg(mnt_root)
|
.arg(mnt_root)
|
||||||
.arg(init_path)
|
.arg(init_path)
|
||||||
.exec();
|
.exec();
|
||||||
|
|||||||
Reference in New Issue
Block a user