From 2dac1c701cba8c79a3ca6b3c5491e044a5fb1167 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:19:27 +0800 Subject: [PATCH 1/7] build(deps): bump the crates group across 1 directory with 22 updates (#1979) --- userspace/ksud/Cargo.lock | 119 ++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 64 deletions(-) diff --git a/userspace/ksud/Cargo.lock b/userspace/ksud/Cargo.lock index d262204ba46f..262a61a495d0 100644 --- a/userspace/ksud/Cargo.lock +++ b/userspace/ksud/Cargo.lock @@ -32,7 +32,7 @@ dependencies = [ "cfg-if 1.0.0", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -216,9 +216,12 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.7" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "5fb8dd288a69fc53a1996d7ecfbf4a20d59065bff137ce7e56bbd620de191189" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -248,9 +251,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" dependencies = [ "clap_builder", "clap_derive", @@ -258,9 +261,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -314,9 +317,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core2" @@ -329,9 +332,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -574,9 +577,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -725,9 +728,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown", @@ -766,9 +769,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -959,9 +962,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.2" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ "memchr", ] @@ -986,11 +989,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy 0.6.6", + "zerocopy", ] [[package]] @@ -1239,18 +1242,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" dependencies = [ "proc-macro2", "quote", @@ -1259,11 +1262,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1303,6 +1307,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "simd-adler32" version = "0.3.7" @@ -1317,9 +1327,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.72" +version = "2.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" dependencies = [ "proc-macro2", "quote", @@ -1440,19 +1450,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if 1.0.0", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -1465,9 +1476,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1475,9 +1486,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -1488,9 +1499,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "which" @@ -1522,9 +1533,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ "windows-sys", ] @@ -1623,34 +1634,14 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "byteorder", + "zerocopy-derive", ] [[package]] From bbc31bdbcafc5e0718031a1b65862024f49cccb3 Mon Sep 17 00:00:00 2001 From: LoveSy <shana@zju.edu.cn> Date: Thu, 15 Aug 2024 16:28:05 +0800 Subject: [PATCH 2/7] Use tempfile (#1980) --- userspace/ksud/Cargo.lock | 102 +++++++++++-------------------- userspace/ksud/Cargo.toml | 32 +++++----- userspace/ksud/src/boot_patch.rs | 10 ++- userspace/ksud/src/utils.rs | 2 +- 4 files changed, 59 insertions(+), 87 deletions(-) diff --git a/userspace/ksud/Cargo.lock b/userspace/ksud/Cargo.lock index 262a61a495d0..369e1e421423 100644 --- a/userspace/ksud/Cargo.lock +++ b/userspace/ksud/Cargo.lock @@ -115,7 +115,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -125,7 +125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -551,7 +551,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -575,6 +575,12 @@ dependencies = [ "libc", ] +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + [[package]] name = "flate2" version = "1.0.31" @@ -585,12 +591,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "generic-array" version = "0.14.7" @@ -668,7 +668,7 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -819,7 +819,7 @@ dependencies = [ "serde_json", "sha1", "sha256", - "tempdir", + "tempfile", "which", "zip", "zip-extensions", @@ -1040,19 +1040,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - [[package]] name = "rand" version = "0.8.5" @@ -1061,7 +1048,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1071,24 +1058,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -1118,37 +1090,19 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "regex-lite" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "retry" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9166d72162de3575f950507683fac47e30f6f2c3836b71b7fbc61aa517c9c5f4" dependencies = [ - "rand 0.8.5", + "rand", ] [[package]] @@ -1208,7 +1162,7 @@ dependencies = [ "errno 0.3.9", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1222,7 +1176,7 @@ dependencies = [ "libc", "linux-raw-sys", "once_cell", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1337,13 +1291,16 @@ dependencies = [ ] [[package]] -name = "tempdir" -version = "0.3.7" +name = "tempfile" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ - "rand 0.4.6", - "remove_dir_all", + "cfg-if 1.0.0", + "fastrand", + "once_cell", + "rustix 0.38.34 (registry+https://github.com/rust-lang/crates.io-index)", + "windows-sys 0.59.0", ] [[package]] @@ -1537,7 +1494,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -1564,6 +1521,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.52.6" diff --git a/userspace/ksud/Cargo.toml b/userspace/ksud/Cargo.toml index 3e6545dd38fd..5a4068a5c00c 100644 --- a/userspace/ksud/Cargo.toml +++ b/userspace/ksud/Cargo.toml @@ -2,16 +2,15 @@ name = "ksud" version = "0.1.0" edition = "2021" -rust-version = "1.77.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1" -clap = { version = "4", features = ["derive"] } +anyhow = "1.0" +clap = { version = "4.5", features = ["derive"] } const_format = "0.2" -zip = { version = "2.1.6", default-features = false } -zip-extensions = { version = "0.8.1", features = [ +zip = { version = "2.1", default-features = false } +zip-extensions = { version = "0.8", features = [ "deflate", "deflate64", "time", @@ -21,29 +20,29 @@ zip-extensions = { version = "0.8.1", features = [ java-properties = { git = "https://github.com/Kernel-SU/java-properties.git", branch = "master", default-features = false } log = "0.4" env_logger = { version = "0.11", default-features = false } -serde = { version = "1" } -serde_json = "1" +serde = { version = "1.0" } +serde_json = "1.0" encoding_rs = "0.8" -retry = "2" -humansize = "2" +retry = "2.0" +humansize = "2.1" libc = "0.2" -extattr = "1" +extattr = "1.0" jwalk = "0.8" -is_executable = "1" -nom = "7" +is_executable = "1.0" +nom = "7.1" derive-new = "0.6" -rust-embed = { version = "8", features = [ +rust-embed = { version = "8.5", features = [ "debug-embed", "compression", # must clean build after updating binaries ] } -which = "6" +which = "6.0" getopts = "0.2" sha256 = "1" sha1 = "0.10" -tempdir = "0.3" +tempfile = "3.12" chrono = "0.4" hole-punch = { git = "https://github.com/tiann/hole-punch" } -regex-lite = "0.1.6" +regex-lite = "0.1" [target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies] rustix = { git = "https://github.com/Kernel-SU/rustix.git", branch = "main", features = [ @@ -61,3 +60,4 @@ android_logger = { version = "0.14", default-features = false } strip = true opt-level = "z" lto = true +codegen-units = 1 diff --git a/userspace/ksud/src/boot_patch.rs b/userspace/ksud/src/boot_patch.rs index a303e03091e4..8ce6ee73a186 100644 --- a/userspace/ksud/src/boot_patch.rs +++ b/userspace/ksud/src/boot_patch.rs @@ -211,7 +211,10 @@ pub fn restore( magiskboot_path: Option<PathBuf>, flash: bool, ) -> Result<()> { - let tmpdir = tempdir::TempDir::new("KernelSU").context("create temp dir failed")?; + let tmpdir = tempfile::Builder::new() + .prefix("KernelSU") + .tempdir() + .context("create temp dir failed")?; let workdir = tmpdir.path(); let magiskboot = find_magiskboot(magiskboot_path, workdir)?; @@ -366,7 +369,10 @@ fn do_patch( ); } - let tmpdir = tempdir::TempDir::new("KernelSU").context("create temp dir failed")?; + let tmpdir = tempfile::Builder::new() + .prefix("KernelSU") + .tempdir() + .context("create temp dir failed")?; let workdir = tmpdir.path(); // extract magiskboot diff --git a/userspace/ksud/src/utils.rs b/userspace/ksud/src/utils.rs index 9bacfa366496..f7e695507be1 100644 --- a/userspace/ksud/src/utils.rs +++ b/userspace/ksud/src/utils.rs @@ -206,7 +206,7 @@ fn find_temp_path() -> String { } // Try to create a random directory in /dev/ - let r = tempdir::TempDir::new_in("/dev/", ""); + let r = tempfile::tempdir_in("/dev/"); match r { Ok(tmp_dir) => { if let Some(path) = tmp_dir.into_path().to_str() { From fd09ccfc2906ad119f7158f9518810e06a73a919 Mon Sep 17 00:00:00 2001 From: LoveSy <shana@zju.edu.cn> Date: Thu, 15 Aug 2024 17:04:02 +0800 Subject: [PATCH 3/7] Drop some legacy codes (#1981) --- userspace/ksud/src/defs.rs | 2 - userspace/ksud/src/init_event.rs | 2 +- userspace/ksud/src/mount.rs | 87 ++++++++++++-------------------- userspace/ksud/src/utils.rs | 66 +----------------------- 4 files changed, 35 insertions(+), 122 deletions(-) diff --git a/userspace/ksud/src/defs.rs b/userspace/ksud/src/defs.rs index c4b9fc3f989b..dd71a0f63e82 100644 --- a/userspace/ksud/src/defs.rs +++ b/userspace/ksud/src/defs.rs @@ -29,8 +29,6 @@ pub const MODULE_UPDATE_TMP_DIR: &str = concatcp!(ADB_DIR, "modules_update/"); pub const SYSTEM_RW_DIR: &str = concatcp!(MODULE_DIR, ".rw/"); pub const TEMP_DIR: &str = "/debug_ramdisk"; -pub const TEMP_DIR_LEGACY: &str = "/sbin"; - pub const MODULE_WEB_DIR: &str = "webroot"; pub const DISABLE_FILE_NAME: &str = "disable"; pub const UPDATE_FILE_NAME: &str = "update"; diff --git a/userspace/ksud/src/init_event.rs b/userspace/ksud/src/init_event.rs index 7107ff74225d..5839c1957fa4 100644 --- a/userspace/ksud/src/init_event.rs +++ b/userspace/ksud/src/init_event.rs @@ -191,7 +191,7 @@ pub fn on_post_data_fs() -> Result<()> { } // mount temp dir - if let Err(e) = mount::mount_tmpfs(utils::get_tmp_path()) { + if let Err(e) = mount::mount_tmpfs(defs::TEMP_DIR) { warn!("do temp dir mount failed: {}", e); } diff --git a/userspace/ksud/src/mount.rs b/userspace/ksud/src/mount.rs index 11be898bbeb7..a15deb976092 100644 --- a/userspace/ksud/src/mount.rs +++ b/userspace/ksud/src/mount.rs @@ -63,21 +63,18 @@ pub fn mount_ext4(source: impl AsRef<Path>, target: impl AsRef<Path>) -> Result< .attach(source) .with_context(|| "Failed to attach loop")?; let lo = new_loopback.path().ok_or(anyhow!("no loop"))?; - if let Result::Ok(fs) = fsopen("ext4", FsOpenFlags::FSOPEN_CLOEXEC) { - let fs = fs.as_fd(); - fsconfig_set_string(fs, "source", lo)?; - fsconfig_create(fs)?; - let mount = fsmount(fs, FsMountFlags::FSMOUNT_CLOEXEC, MountAttrFlags::empty())?; - move_mount( - mount.as_fd(), - "", - CWD, - target.as_ref(), - MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, - )?; - } else { - mount(lo, target.as_ref(), "ext4", MountFlags::empty(), "")?; - } + let fs = fsopen("ext4", FsOpenFlags::FSOPEN_CLOEXEC)?; + let fs = fs.as_fd(); + fsconfig_set_string(fs, "source", lo)?; + fsconfig_create(fs)?; + let mount = fsmount(fs, FsMountFlags::FSMOUNT_CLOEXEC, MountAttrFlags::empty())?; + move_mount( + mount.as_fd(), + "", + CWD, + target.as_ref(), + MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, + )?; Ok(()) } @@ -157,27 +154,18 @@ pub fn mount_overlayfs( #[cfg(any(target_os = "linux", target_os = "android"))] pub fn mount_tmpfs(dest: impl AsRef<Path>) -> Result<()> { info!("mount tmpfs on {}", dest.as_ref().display()); - if let Result::Ok(fs) = fsopen("tmpfs", FsOpenFlags::FSOPEN_CLOEXEC) { - let fs = fs.as_fd(); - fsconfig_set_string(fs, "source", KSU_OVERLAY_SOURCE)?; - fsconfig_create(fs)?; - let mount = fsmount(fs, FsMountFlags::FSMOUNT_CLOEXEC, MountAttrFlags::empty())?; - move_mount( - mount.as_fd(), - "", - CWD, - dest.as_ref(), - MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, - )?; - } else { - mount( - KSU_OVERLAY_SOURCE, - dest.as_ref(), - "tmpfs", - MountFlags::empty(), - "", - )?; - } + let fs = fsopen("tmpfs", FsOpenFlags::FSOPEN_CLOEXEC)?; + let fs = fs.as_fd(); + fsconfig_set_string(fs, "source", KSU_OVERLAY_SOURCE)?; + fsconfig_create(fs)?; + let mount = fsmount(fs, FsMountFlags::FSMOUNT_CLOEXEC, MountAttrFlags::empty())?; + move_mount( + mount.as_fd(), + "", + CWD, + dest.as_ref(), + MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, + )?; Ok(()) } @@ -188,29 +176,20 @@ pub fn bind_mount(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> { from.as_ref().display(), to.as_ref().display() ); - if let Result::Ok(tree) = open_tree( + let tree = open_tree( CWD, from.as_ref(), OpenTreeFlags::OPEN_TREE_CLOEXEC | OpenTreeFlags::OPEN_TREE_CLONE | OpenTreeFlags::AT_RECURSIVE, - ) { - move_mount( - tree.as_fd(), - "", - CWD, - to.as_ref(), - MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, - )?; - } else { - mount( - from.as_ref(), - to.as_ref(), - "", - MountFlags::BIND | MountFlags::REC, - "", - )?; - } + )?; + move_mount( + tree.as_fd(), + "", + CWD, + to.as_ref(), + MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, + )?; Ok(()) } diff --git a/userspace/ksud/src/utils.rs b/userspace/ksud/src/utils.rs index f7e695507be1..c08fdeee26c4 100644 --- a/userspace/ksud/src/utils.rs +++ b/userspace/ksud/src/utils.rs @@ -1,17 +1,15 @@ use anyhow::{bail, Context, Error, Ok, Result}; use std::{ - fs::{self, create_dir_all, remove_file, write, File, OpenOptions}, + fs::{create_dir_all, remove_file, write, File, OpenOptions}, io::{ ErrorKind::{AlreadyExists, NotFound}, Write, }, path::Path, process::Command, - sync::OnceLock, }; use crate::{assets, boot_patch, defs, ksucalls, module, restorecon}; -use std::fs::metadata; #[allow(unused_imports)] use std::fs::{set_permissions, Permissions}; #[cfg(unix)] @@ -189,68 +187,6 @@ pub fn has_magisk() -> bool { which::which("magisk").is_ok() } -fn is_ok_empty(dir: &str) -> bool { - use std::result::Result::Ok; - - match fs::read_dir(dir) { - Ok(mut entries) => entries.next().is_none(), - Err(_) => false, - } -} - -fn find_temp_path() -> String { - use std::result::Result::Ok; - - if is_ok_empty(defs::TEMP_DIR) { - return defs::TEMP_DIR.to_string(); - } - - // Try to create a random directory in /dev/ - let r = tempfile::tempdir_in("/dev/"); - match r { - Ok(tmp_dir) => { - if let Some(path) = tmp_dir.into_path().to_str() { - return path.to_string(); - } - } - Err(_e) => {} - } - - let dirs = [ - defs::TEMP_DIR, - "/patch_hw", - "/oem", - "/root", - defs::TEMP_DIR_LEGACY, - ]; - - // find empty directory - for dir in dirs { - if is_ok_empty(dir) { - return dir.to_string(); - } - } - - // Fallback to non-empty directory - for dir in dirs { - if metadata(dir).is_ok() { - return dir.to_string(); - } - } - - "".to_string() -} - -pub fn get_tmp_path() -> &'static str { - static CHOSEN_TMP_PATH: OnceLock<String> = OnceLock::new(); - - CHOSEN_TMP_PATH.get_or_init(|| { - let r = find_temp_path(); - log::info!("Chosen temp_path: {}", r); - r - }) -} - #[cfg(target_os = "android")] fn link_ksud_to_bin() -> Result<()> { let ksu_bin = PathBuf::from(defs::DAEMON_PATH); From 421371f496bd931043dce29ce5b801f01a00c510 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:05:03 +0800 Subject: [PATCH 4/7] build(deps): bump the maven group across 1 directory with 5 updates (#1962) --- manager/gradle/libs.versions.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manager/gradle/libs.versions.toml b/manager/gradle/libs.versions.toml index e3b68aa73b66..daf6c7a99ba5 100644 --- a/manager/gradle/libs.versions.toml +++ b/manager/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] -agp = "8.5.1" -kotlin = "2.0.0" -ksp = "2.0.0-1.0.24" +agp = "8.5.2" +kotlin = "2.0.10" +ksp = "2.0.10-1.0.24" compose-bom = "2024.06.00" lifecycle = "2.8.4" accompanist = "0.34.0" From b032ce7445851be5529aecf6c82f5281cef2a5ea Mon Sep 17 00:00:00 2001 From: LoveSy <shana@zju.edu.cn> Date: Fri, 16 Aug 2024 23:45:04 +0800 Subject: [PATCH 5/7] Try add android15-6.6-2024-07 support (#1987) --- .github/workflows/build-kernel-a15.yml | 121 +++++++++++++++++++++++++ .github/workflows/release.yml | 3 + 2 files changed, 124 insertions(+) create mode 100644 .github/workflows/build-kernel-a15.yml diff --git a/.github/workflows/build-kernel-a15.yml b/.github/workflows/build-kernel-a15.yml new file mode 100644 index 000000000000..eedc9807aa3f --- /dev/null +++ b/.github/workflows/build-kernel-a15.yml @@ -0,0 +1,121 @@ +name: Build Kernel - Android 15 +on: + push: + branches: ["main", "ci", "checkci"] + paths: + - ".github/workflows/build-kernel-a15.yml" + - ".github/workflows/gki-kernel.yml" + - ".github/scripts/build_a13.sh" + - "kernel/**" + pull_request: + branches: ["main"] + paths: + - ".github/workflows/build-kernel-a15.yml" + - ".github/workflows/gki-kernel.yml" + - ".github/scripts/build-a13.sh" + - "kernel/**" + workflow_call: +jobs: + build-kernel: + if: github.event_name != 'pull_request' && github.ref != 'refs/heads/checkci' + strategy: + matrix: + include: + - version: "6.6" + sub_level: 30 + os_patch_level: 2024-07 + uses: ./.github/workflows/gki-kernel.yml + secrets: inherit + with: + version: android15-${{ matrix.version }} + version_name: android15-${{ matrix.version }}.${{ matrix.sub_level }} + tag: android15-${{ matrix.version }}-${{ matrix.os_patch_level }} + os_patch_level: ${{ matrix.os_patch_level }} + patch_path: ${{ matrix.version }} + + upload-artifacts: + needs: build-kernel + runs-on: ubuntu-latest + if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' || github.ref == 'refs/heads/ci' }} + env: + CHAT_ID: ${{ secrets.CHAT_ID }} + BOT_TOKEN: ${{ secrets.BOT_TOKEN }} + MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + COMMIT_URL: ${{ github.event.head_commit.url }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + + - uses: actions/checkout@v4 + with: + path: KernelSU + fetch-depth: 0 + + - name: List artifacts + run: | + tree + + - name: Download prebuilt toolchain + run: | + AOSP_MIRROR=https://android.googlesource.com + BRANCH=main-kernel-build-2024 + git clone $AOSP_MIRROR/platform/prebuilts/build-tools -b $BRANCH --depth 1 build-tools + git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools + git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 + pip3 install telethon + + - name: Set boot sign key + env: + BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }} + run: | + if [ ! -z "$BOOT_SIGN_KEY" ]; then + echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem + fi + + - name: Bot session cache + id: bot_session_cache + uses: actions/cache@v4 + if: false + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session + + - name: Build boot images + run: | + export AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool + export GZIP=$GITHUB_WORKSPACE/build-tools/path/linux-x86/gzip + export LZ4=$GITHUB_WORKSPACE/build-tools/path/linux-x86/lz4 + export MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py + export UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py + cd $GITHUB_WORKSPACE/KernelSU + export VERSION=$(($(git rev-list --count HEAD) + 10200)) + echo "VERSION: $VERSION" + cd - + bash $GITHUB_WORKSPACE/KernelSU/.github/scripts/build_a13.sh + + - name: Display structure of boot files + run: ls -R + + - name: Upload images artifact + uses: actions/upload-artifact@v4 + with: + name: boot-images-android15 + path: Image-android15*/*.img.gz + + check-build-kernel: + if: (github.event_name == 'pull_request' && !github.event.pull_request.draft) || github.ref == 'refs/heads/checkci' + strategy: + matrix: + include: + - version: "6.6" + sub_level: 30 + os_patch_level: 2024-07 + uses: ./.github/workflows/gki-kernel.yml + with: + version: android15-${{ matrix.version }} + version_name: android15-${{ matrix.version }}.${{ matrix.sub_level }} + tag: android15-${{ matrix.version }}-${{ matrix.os_patch_level }} + os_patch_level: ${{ matrix.os_patch_level }} + patch_path: ${{ matrix.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26b3171c8e68..dcc0fca8856c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,9 @@ jobs: build-a14-kernel: uses: ./.github/workflows/build-kernel-a14.yml secrets: inherit + build-a15-kernel: + uses: ./.github/workflows/build-kernel-a15.yml + secrets: inherit build-wsa-kernel: uses: ./.github/workflows/build-kernel-wsa.yml secrets: inherit From 221c834a9f8183675cbda6ee200ac7a84a0fddad Mon Sep 17 00:00:00 2001 From: LoveSy <shana@zju.edu.cn> Date: Sat, 17 Aug 2024 12:42:22 +0800 Subject: [PATCH 6/7] Try add android15-6.6-2024-07 for LKM (#1988) --- .github/workflows/build-lkm.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-lkm.yml b/.github/workflows/build-lkm.yml index 5a14ce1b4826..7755a514f30c 100644 --- a/.github/workflows/build-lkm.yml +++ b/.github/workflows/build-lkm.yml @@ -29,10 +29,13 @@ jobs: - version: "android14-6.1" sub_level: 75 os_patch_level: 2024-05 + - version: "android15-6.6" + sub_level: 30 + os_patch_level: 2024-07 uses: ./.github/workflows/gki-kernel.yml with: version: ${{ matrix.version }} version_name: ${{ matrix.version }}.${{ matrix.sub_level }} tag: ${{ matrix.version }}-${{ matrix.os_patch_level }} os_patch_level: ${{ matrix.os_patch_level }} - build_lkm: true \ No newline at end of file + build_lkm: true From b2dbaa9bc85c53c75a6fbcf5131d1e7d109c404f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 00:14:28 +0800 Subject: [PATCH 7/7] build(deps): bump the crates group across 1 directory with 6 updates (#1984) --- userspace/ksud/Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/userspace/ksud/Cargo.lock b/userspace/ksud/Cargo.lock index 369e1e421423..3bb563592a11 100644 --- a/userspace/ksud/Cargo.lock +++ b/userspace/ksud/Cargo.lock @@ -216,9 +216,9 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.11" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb8dd288a69fc53a1996d7ecfbf4a20d59065bff137ce7e56bbd620de191189" +checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" dependencies = [ "shlex", ] @@ -251,9 +251,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.15" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", "clap_derive", @@ -833,9 +833,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a" [[package]] name = "libflate" @@ -1196,18 +1196,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.207" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.207" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", @@ -1216,9 +1216,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ "itoa", "memchr",