From d0e8faea77715e9468be5b8a44f7380cadb70da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=9F=E4=BA=8E=E7=94=9F=E6=97=B6=20=E4=BA=A1=E4=BA=8E?= =?UTF-8?q?=E4=BA=A1=E5=88=BB?= <127004703+Tools-cx-app@users.noreply.github.com> Date: Sat, 22 Nov 2025 06:09:45 +0800 Subject: [PATCH] chore(ksud): enable clippy::all, clippy::pedantic && make clippy happy (#617) * Revert "chore(ksud): bump ksud's deps (#585)" * Because it may cause compilation errors. This reverts commit c8020b2066ac3f6355929070d7dacf11b3cb3d87. * chore(ksud): remove unused Result Signed-off-by: Tools-app * chore(ksud): enable clippy::all, clippy::pedantic && make clippy happy https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args https://rust-lang.github.io/rust-clippy/master/index.html#used_underscore_items https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate ... and use some #![allow(...)] or #[allow(...)] Signed-off-by: Tools-app --------- Signed-off-by: Tools-app --- userspace/ksud/Cargo.lock | 872 ++++++++++++++------------- userspace/ksud/Cargo.toml | 10 +- userspace/ksud/src/apk_sign.rs | 2 +- userspace/ksud/src/assets.rs | 10 +- userspace/ksud/src/boot_patch.rs | 42 +- userspace/ksud/src/cli.rs | 44 +- userspace/ksud/src/debug.rs | 14 +- userspace/ksud/src/feature.rs | 128 ++-- userspace/ksud/src/init_event.rs | 16 +- userspace/ksud/src/kpm.rs | 21 +- userspace/ksud/src/ksucalls.rs | 33 +- userspace/ksud/src/main.rs | 12 + userspace/ksud/src/metamodule.rs | 101 ++-- userspace/ksud/src/module.rs | 114 ++-- userspace/ksud/src/module_config.rs | 100 +-- userspace/ksud/src/profile.rs | 6 +- userspace/ksud/src/sepolicy.rs | 14 +- userspace/ksud/src/su.rs | 32 +- userspace/ksud/src/uid_scanner.rs | 18 +- userspace/ksud/src/umount_manager.rs | 24 +- 20 files changed, 829 insertions(+), 784 deletions(-) diff --git a/userspace/ksud/Cargo.lock b/userspace/ksud/Cargo.lock index aab55b79..83061a4d 100644 --- a/userspace/ksud/Cargo.lock +++ b/userspace/ksud/Cargo.lock @@ -3,10 +3,19 @@ version = 4 [[package]] -name = "adler2" -version = "2.0.1" +name = "addr2line" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "adler32" @@ -14,6 +23,18 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "allocator-api2" version = "0.2.21" @@ -26,6 +47,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_log-sys" version = "0.3.2" @@ -34,9 +61,9 @@ checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" [[package]] name = "android_logger" -version = "0.15.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb4e440d04be07da1f1bf44fb4495ebd58669372fe0cffa6e48595ac5bd88a3" +checksum = "05b07e8e73d720a1f2e4b6014766e6039fd2e96a4fa44e2a78d0e1fa2ff49826" dependencies = [ "android_log-sys", "env_filter", @@ -54,9 +81,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.21" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -69,70 +96,85 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.13" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.7" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.11" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", - "once_cell_polyfill", - "windows-sys 0.61.2", + "once_cell", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.100" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "arbitrary" -version = "1.4.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" dependencies = [ "derive_arbitrary", ] [[package]] name = "async-trait" -version = "0.1.89" +version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn", ] [[package]] name = "autocfg" -version = "1.5.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] [[package]] name = "bitflags" @@ -142,9 +184,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.10.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "block-buffer" @@ -157,9 +199,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.19.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "byteorder" @@ -169,34 +211,32 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.11.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.46" +version = "1.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" +checksum = "32db95edf998450acc7881c932f94cd9b05c87b4b2599e8bab064753da4acfd1" dependencies = [ - "find-msvc-tools", - "jobserver", - "libc", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.4" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.42" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", "num-traits", @@ -206,9 +246,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.51" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" +checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" dependencies = [ "clap_builder", "clap_derive", @@ -216,9 +256,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.51" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" +checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" dependencies = [ "anstream", "anstyle", @@ -228,33 +268,33 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.49" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.110", + "syn", ] [[package]] name = "clap_lex" -version = "0.7.6" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" -version = "1.0.4" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "const_format" -version = "0.2.35" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" dependencies = [ "const_format_proc_macros", ] @@ -311,9 +351,9 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" -version = "1.5.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -376,9 +416,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crypto-common" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", @@ -386,21 +426,21 @@ dependencies = [ [[package]] name = "dary_heap" -version = "0.3.8" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d2e3287df1c007e74221c49ca10a95d557349e54b3a75dc2fb14712c751f04" +checksum = "04d2cd9c18b9f454ed67da600630b021a8a80bf33f8c95896ab33aaf1c26b728" [[package]] name = "deflate64" -version = "0.1.10" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26bf8fc351c5ed29b5c2f0cbbac1b209b74f60ecd62e675a998df72c49af5204" +checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b" [[package]] name = "deranged" -version = "0.5.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", ] @@ -413,18 +453,18 @@ checksum = "2cdc8d50f426189eef89dac62fabfa0abb27d5cc008f25bf4156a0203325becc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn", ] [[package]] name = "derive_arbitrary" -version = "1.4.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn", ] [[package]] @@ -454,9 +494,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", ] @@ -496,12 +536,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.14" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -532,28 +572,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] -name = "find-msvc-tools" -version = "0.1.5" +name = "filetime" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" +checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.60.2", +] [[package]] name = "flate2" -version = "1.1.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "libz-rs-sys", "miniz_oxide", ] -[[package]] -name = "foldhash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - [[package]] name = "fsevent-sys" version = "4.1.0" @@ -575,35 +615,46 @@ dependencies = [ [[package]] name = "getopts" -version = "0.2.24" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" dependencies = [ "unicode-width", ] [[package]] name = "getrandom" -version = "0.3.4" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "libc", "r-efi", - "wasip2", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", ] [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash", -] +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -628,9 +679,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.64" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -652,58 +703,44 @@ dependencies = [ [[package]] name = "include-flate" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01b7cb6ca682a621e7cda1c358c9724b53a7b4409be9be1dd443b7f3a26f998" +checksum = "df49c16750695486c1f34de05da5b7438096156466e7f76c38fcdf285cf0113e" dependencies = [ "include-flate-codegen", - "include-flate-compress", + "lazy_static", "libflate", - "zstd", ] [[package]] name = "include-flate-codegen" -version = "0.3.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f49bf5274aebe468d6e6eba14a977eaf1efa481dc173f361020de70c1c48050" +checksum = "8c5b246c6261be723b85c61ecf87804e8ea4a35cb68be0ff282ed84b95ffe7d7" dependencies = [ - "include-flate-compress", "libflate", - "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.110", - "zstd", -] - -[[package]] -name = "include-flate-compress" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae6a40e716bcd5931f5dbb79cd921512a4f647e2e9413fded3171fca3824dbc" -dependencies = [ - "libflate", - "zstd", + "syn", ] [[package]] name = "indexmap" -version = "2.12.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.2", ] [[package]] name = "inotify" -version = "0.11.0" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" +checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" dependencies = [ - "bitflags 2.10.0", + "bitflags 1.3.2", "inotify-sys", "libc", ] @@ -719,18 +756,18 @@ dependencies = [ [[package]] name = "is_executable" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baabb8b4867b26294d818bf3f651a454b6901431711abb96e296245888d6e8c4" +checksum = "d4a1b5bad6f9072935961dfbf1cced2f3d129963d091b6f69f007fe04e758ae2" dependencies = [ - "windows-sys 0.60.2", + "winapi", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.2" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" @@ -748,21 +785,11 @@ dependencies = [ "regex-lite", ] -[[package]] -name = "jobserver" -version = "0.1.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" -dependencies = [ - "getrandom", - "libc", -] - [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -830,7 +857,7 @@ dependencies = [ "sha256", "tempfile", "which", - "zip 6.0.0", + "zip", "zip-extensions", ] @@ -842,15 +869,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.177" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libflate" -version = "2.2.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3248b8d211bd23a104a42d81b4fa8bb8ac4a3b75e7a43d85d2c9ccb6179cd74" +checksum = "45d9dfdc14ea4ef0900c1cddbc8dcd553fbaacd8a4a282cf4018ae9dd04fb21e" dependencies = [ "adler32", "core2", @@ -861,12 +888,12 @@ dependencies = [ [[package]] name = "libflate_lz77" -version = "2.2.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a599cb10a9cd92b1300debcef28da8f70b935ec937f44fcd1b70a7c986a11c5c" +checksum = "e6e0d73b369f386f1c44abd9c570d5318f55ccde816ff4b562fa452e5182863d" dependencies = [ "core2", - "hashbrown", + "hashbrown 0.14.5", "rle-decode-fast", ] @@ -876,6 +903,17 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +[[package]] +name = "libredox" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" +dependencies = [ + "bitflags 2.8.0", + "libc", + "redox_syscall", +] + [[package]] name = "libz-rs-sys" version = "0.5.2" @@ -893,15 +931,15 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "log" -version = "0.4.28" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lzma-rs" @@ -913,16 +951,6 @@ dependencies = [ "crc", ] -[[package]] -name = "lzma-rust2" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c60a23ffb90d527e23192f1246b14746e2f7f071cb84476dd879071696c18a4a" -dependencies = [ - "crc", - "sha2", -] - [[package]] name = "lzma-sys" version = "0.1.20" @@ -936,30 +964,29 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.6" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.8.9" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", - "simd-adler32", ] [[package]] name = "mio" -version = "1.1.0" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi", - "windows-sys 0.61.2", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.48.0", ] [[package]] @@ -973,28 +1000,23 @@ dependencies = [ [[package]] name = "notify" -version = "8.2.0" +version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3" +checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.10.0", + "bitflags 2.8.0", + "crossbeam-channel", + "filetime", "fsevent-sys", "inotify", "kqueue", "libc", "log", "mio", - "notify-types", "walkdir", - "windows-sys 0.60.2", + "windows-sys 0.48.0", ] -[[package]] -name = "notify-types" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" - [[package]] name = "num-conv" version = "0.1.0" @@ -1010,18 +1032,21 @@ dependencies = [ "autocfg", ] +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "once_cell_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" - [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1040,59 +1065,35 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" -version = "1.0.103" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.42" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" -version = "5.3.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "rayon" -version = "1.11.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -1100,19 +1101,28 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.13.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", ] [[package]] -name = "regex-lite" -version = "0.1.8" +name = "redox_syscall" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d942b98df5e658f56f20d592c7f868833fe38115e65c33003d8cd224b0155da" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +dependencies = [ + "bitflags 2.8.0", +] + +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "rle-decode-fast" @@ -1122,9 +1132,9 @@ checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" [[package]] name = "rust-embed" -version = "8.9.0" +version = "8.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "947d7f3fad52b283d261c4c99a084937e2fe492248cb9a68a8435a861b8798ca" +checksum = "025908b8682a26ba8d12f6f2d66b987584a4a87bc024abc5bbc12553a8cd178a" dependencies = [ "include-flate", "rust-embed-impl", @@ -1134,34 +1144,40 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "8.9.0" +version = "8.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fa2c8c9e8711e10f9c4fd2d64317ef13feaab820a4c51541f1a8c8e2e851ab2" +checksum = "6065f1a4392b71819ec1ea1df1120673418bf386f50de1d6f54204d836d4349c" dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.110", + "syn", "walkdir", ] [[package]] name = "rust-embed-utils" -version = "8.9.0" +version = "8.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b161f275cb337fe0a44d924a5f4df0ed69c2c39519858f931ce61c779d3475" +checksum = "f6cc0c81648b20b70c491ff8cce00c1c3b223bb8ed2b5d41f0e54c6c4c0a3594" dependencies = [ "sha2", "walkdir", ] +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustix" version = "0.38.34" -source = "git+https://github.com/Kernel-SU/rustix.git?rev=4a53fbc7cb7a07cabe87125cc21dbc27db316259#4a53fbc7cb7a07cabe87125cc21dbc27db316259" +source = "git+https://github.com/Kernel-SU/rustix.git?branch=main#4a53fbc7cb7a07cabe87125cc21dbc27db316259" dependencies = [ - "bitflags 2.10.0", - "errno 0.3.14", + "bitflags 2.8.0", + "errno 0.3.10", "itoa", "libc", "linux-raw-sys 0.4.15", @@ -1171,22 +1187,22 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.2" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.10.0", - "errno 0.3.14", + "bitflags 2.8.0", + "errno 0.3.10", "libc", - "linux-raw-sys 0.11.0", - "windows-sys 0.61.2", + "linux-raw-sys 0.9.4", + "windows-sys 0.59.0", ] [[package]] name = "rustversion" -version = "1.0.22" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "ryu" @@ -1205,45 +1221,34 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.228" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" -dependencies = [ - "serde_core", - "serde_derive", -] - -[[package]] -name = "serde_core" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn", ] [[package]] name = "serde_json" -version = "1.0.145" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", "ryu", "serde", - "serde_core", ] [[package]] @@ -1301,19 +1306,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.110" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -1322,22 +1317,22 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.23.0" +version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", "getrandom", "once_cell", - "rustix 1.1.2", - "windows-sys 0.61.2", + "rustix 1.0.7", + "windows-sys 0.59.0", ] [[package]] name = "time" -version = "0.3.44" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "num-conv", @@ -1348,37 +1343,38 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.6" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "tokio" -version = "1.48.0" +version = "1.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" dependencies = [ + "backtrace", "bytes", "pin-project-lite", ] [[package]] name = "typenum" -version = "1.19.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-width" -version = "0.2.2" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" @@ -1415,32 +1411,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "wasip2" -version = "1.0.1+wasi-0.2.4" +name = "wasi" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ - "wit-bindgen", + "wit-bindgen-rt", ] [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1448,34 +1457,35 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ - "bumpalo", "proc-macro2", "quote", - "syn 2.0.110", + "syn", + "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" dependencies = [ "unicode-ident", ] [[package]] name = "which" -version = "8.0.0" +version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fabb953106c3c8eea8306e4393700d7657561cb43122571b172bbfb7c7ba1d" +checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762" dependencies = [ + "either", "env_home", - "rustix 1.1.2", + "rustix 1.0.7", "winsafe", ] @@ -1497,11 +1507,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.11" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -1512,9 +1522,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.62.2" +version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" dependencies = [ "windows-implement", "windows-interface", @@ -1525,50 +1535,59 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.60.2" +version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn", ] [[package]] name = "windows-interface" -version = "0.59.3" +version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn", ] [[package]] name = "windows-link" -version = "0.2.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] name = "windows-result" -version = "0.4.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" -version = "0.5.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" dependencies = [ "windows-link", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -1580,20 +1599,35 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.60.2" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.53.5", + "windows-targets 0.52.6", ] [[package]] name = "windows-sys" -version = "0.61.2" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-link", + "windows-targets 0.53.3", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1614,21 +1648,27 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.5" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -1637,9 +1677,15 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" @@ -1649,9 +1695,15 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" @@ -1661,9 +1713,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" [[package]] name = "windows_i686_gnullvm" @@ -1673,9 +1725,15 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" @@ -1685,9 +1743,15 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" @@ -1697,9 +1761,15 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" @@ -1709,9 +1779,15 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" @@ -1721,9 +1797,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.1" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winsafe" @@ -1732,10 +1808,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" [[package]] -name = "wit-bindgen" -version = "0.46.0" +name = "wit-bindgen-rt" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.8.0", +] [[package]] name = "xz2" @@ -1746,6 +1825,26 @@ dependencies = [ "lzma-sys", ] +[[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 = "zip" version = "3.0.0" @@ -1754,28 +1853,13 @@ checksum = "12598812502ed0105f607f941c386f43d441e00148fce9dec3ca5ffb0bde9308" dependencies = [ "arbitrary", "crc32fast", + "deflate64", "flate2", "indexmap", "lzma-rs", "memchr", - "xz2", - "zopfli", -] - -[[package]] -name = "zip" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2a05c7c36fde6c09b08576c9f7fb4cda705990f73b58fe011abf7dfb24168b" -dependencies = [ - "arbitrary", - "crc32fast", - "deflate64", - "flate2", - "indexmap", - "lzma-rust2", - "memchr", "time", + "xz2", "zopfli", ] @@ -1785,7 +1869,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f105becb0a5da773e655775dd05fee454ca1475bcc980ec9d940a02f42cee40" dependencies = [ - "zip 3.0.0", + "zip", ] [[package]] @@ -1796,40 +1880,12 @@ checksum = "2f06ae92f42f5e5c42443fd094f245eb656abf56dd7cce9b8b263236565e00f2" [[package]] name = "zopfli" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249" +checksum = "edfc5ee405f504cd4984ecc6f14d02d55cfda60fa4b689434ef4102aae150cd7" dependencies = [ "bumpalo", "crc32fast", "log", "simd-adler32", ] - -[[package]] -name = "zstd" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "7.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" -dependencies = [ - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.16+zstd.1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/userspace/ksud/Cargo.toml b/userspace/ksud/Cargo.toml index ec562751..d0567206 100644 --- a/userspace/ksud/Cargo.toml +++ b/userspace/ksud/Cargo.toml @@ -6,11 +6,11 @@ edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -notify = "8.2" +notify = "6.1" anyhow = "1" clap = { version = "4", features = ["derive"] } const_format = "0.2" -zip = { version = "6", features = [ +zip = { version = "3", features = [ "deflate", "deflate64", "time", @@ -38,7 +38,7 @@ rust-embed = { version = "8", features = [ "debug-embed", "compression", # must clean build after updating binaries ] } -which = "8" +which = "7" getopts = "0.2" sha256 = "1" sha1 = "0.10" @@ -48,14 +48,14 @@ regex-lite = "0.1" serde = { version = "1.0", features = ["derive"] } [target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies] -rustix = { git = "https://github.com/Kernel-SU/rustix.git", rev = "4a53fbc7cb7a07cabe87125cc21dbc27db316259", features = [ +rustix = { git = "https://github.com/Kernel-SU/rustix.git", branch = "main", features = [ "all-apis", ] } # some android specific dependencies which compiles under unix are also listed here for convenience of coding android-properties = { version = "0.2", features = ["bionic-deprecated"] } [target.'cfg(target_os = "android")'.dependencies] -android_logger = { version = "0.15", default-features = false } +android_logger = { version = "0.14", default-features = false } [profile.release] overflow-checks = false diff --git a/userspace/ksud/src/apk_sign.rs b/userspace/ksud/src/apk_sign.rs index 4b2c4a98..27d5c50e 100644 --- a/userspace/ksud/src/apk_sign.rs +++ b/userspace/ksud/src/apk_sign.rs @@ -84,7 +84,7 @@ pub fn get_apk_signature(apk: &str) -> Result<(u32, String)> { return Err(anyhow::anyhow!("Unexpected v3 signature found!",)); } - v2_signing.ok_or(anyhow::anyhow!("No signature found!")) + v2_signing.ok_or_else(|| anyhow::anyhow!("No signature found!")) } fn calc_cert_sha256( diff --git a/userspace/ksud/src/assets.rs b/userspace/ksud/src/assets.rs index e722cd67..24e7aef0 100644 --- a/userspace/ksud/src/assets.rs +++ b/userspace/ksud/src/assets.rs @@ -31,19 +31,19 @@ pub fn ensure_binaries(ignore_if_exist: bool) -> Result<()> { // don't extract ksuinit and kernel modules continue; } - let asset = Asset::get(&file).ok_or(anyhow::anyhow!("asset not found: {}", file))?; - utils::ensure_binary(format!("{BINARY_DIR}{file}"), &asset.data, ignore_if_exist)? + let asset = Asset::get(&file).ok_or_else(|| anyhow::anyhow!("asset not found: {file}"))?; + utils::ensure_binary(format!("{BINARY_DIR}{file}"), &asset.data, ignore_if_exist)?; } Ok(()) } pub fn copy_assets_to_file(name: &str, dst: impl AsRef) -> Result<()> { - let asset = Asset::get(name).ok_or(anyhow::anyhow!("asset not found: {}", name))?; + let asset = Asset::get(name).ok_or_else(|| anyhow::anyhow!("asset not found: {name}"))?; std::fs::write(dst, asset.data)?; Ok(()) } -pub fn list_supported_kmi() -> Result> { +pub fn list_supported_kmi() -> std::vec::Vec { let mut list = Vec::new(); for file in Asset::iter() { // kmi_name = "xxx_kernelsu.ko" @@ -51,5 +51,5 @@ pub fn list_supported_kmi() -> Result> { list.push(kmi.to_string()); } } - Ok(list) + list } diff --git a/userspace/ksud/src/boot_patch.rs b/userspace/ksud/src/boot_patch.rs index 531b4229..2d6e05cb 100644 --- a/userspace/ksud/src/boot_patch.rs +++ b/userspace/ksud/src/boot_patch.rs @@ -1,3 +1,4 @@ +#![allow(clippy::ref_option, clippy::needless_pass_by_value)] #[cfg(unix)] use std::{ os::unix::fs::PermissionsExt, @@ -217,7 +218,7 @@ pub fn restore( let workdir = tmpdir.path(); let magiskboot = find_magiskboot(magiskboot_path, workdir)?; - let kmi = get_current_kmi().unwrap_or_else(|_| String::from("")); + let kmi = get_current_kmi().unwrap_or_default(); let (bootimage, bootdevice) = find_boot_image(&image, &kmi, false, false, workdir, &None)?; @@ -233,7 +234,7 @@ pub fn restore( let mut ramdisk = workdir.join("ramdisk.cpio"); if !ramdisk.exists() { - ramdisk = workdir.join("vendor_ramdisk").join("init_boot.cpio") + ramdisk = workdir.join("vendor_ramdisk").join("init_boot.cpio"); } if !ramdisk.exists() { ramdisk = workdir.join("vendor_ramdisk").join("ramdisk.cpio"); @@ -272,7 +273,7 @@ pub fn restore( new_boot = Some(backup_path); from_backup = true; } else { - println!("- Warning: no backup {backup_path:?} found!"); + println!("- Warning: no backup {} found!", backup_path.display()); } if let Err(e) = clean_backup(sha) { @@ -355,7 +356,7 @@ pub fn patch( result } -#[allow(clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments, clippy::needless_pass_by_value)] fn do_patch( image: Option, kernel: Option, @@ -415,7 +416,7 @@ fn do_patch( ); parse_kmi_from_kernel(kernel_path, tmpdir.path())? } else { - "".to_string() + String::new() } } } @@ -444,7 +445,7 @@ fn do_patch( let name = format!("{kmi}_kernelsu.ko"); assets::copy_assets_to_file(&name, kmod_file) .with_context(|| format!("Failed to copy {name}"))?; - }; + } let init_file = workdir.join("init"); if let Some(init) = init { @@ -465,7 +466,7 @@ fn do_patch( let mut ramdisk = workdir.join("ramdisk.cpio"); if !ramdisk.exists() { - ramdisk = workdir.join("vendor_ramdisk").join("init_boot.cpio") + ramdisk = workdir.join("vendor_ramdisk").join("init_boot.cpio"); } if !ramdisk.exists() { ramdisk = workdir.join("vendor_ramdisk").join("ramdisk.cpio"); @@ -481,15 +482,16 @@ fn do_patch( println!("- Adding KernelSU LKM"); let is_kernelsu_patched = is_kernelsu_patched(&magiskboot, workdir, ramdisk)?; - let mut need_backup = false; - if !is_kernelsu_patched { + let need_backup = if is_kernelsu_patched { + false + } else { // kernelsu.ko is not exist, backup init if necessary let status = do_cpio_cmd(&magiskboot, workdir, ramdisk, "exists init"); if status.is_ok() { do_cpio_cmd(&magiskboot, workdir, ramdisk, "mv init init.real")?; } - need_backup = flash; - } + flash + }; do_cpio_cmd(&magiskboot, workdir, ramdisk, "add 0755 init init")?; do_cpio_cmd( @@ -678,7 +680,7 @@ fn find_boot_image( bootimage = tmp_boot_path; bootdevice = Some(boot_partition); - }; + } Ok((bootimage, bootdevice)) } @@ -719,12 +721,12 @@ pub fn choose_boot_partition( #[cfg(target_os = "android")] pub fn get_slot_suffix(ota: bool) -> String { - let mut slot_suffix = utils::getprop("ro.boot.slot_suffix").unwrap_or_else(|| String::from("")); + let mut slot_suffix = utils::getprop("ro.boot.slot_suffix").unwrap_or_default(); if !slot_suffix.is_empty() && ota { if slot_suffix == "_a" { - slot_suffix = "_b".to_string() + slot_suffix = "_b".to_string(); } else { - slot_suffix = "_a".to_string() + slot_suffix = "_a".to_string(); } } slot_suffix @@ -741,8 +743,8 @@ pub fn list_available_partitions() -> Vec { let candidates = vec!["boot", "init_boot", "vendor_boot"]; candidates .into_iter() - .filter(|name| Path::new(&format!("/dev/block/by-name/{}{}", name, slot_suffix)).exists()) - .map(|s| s.to_string()) + .filter(|name| Path::new(&format!("/dev/block/by-name/{name}{slot_suffix}")).exists()) + .map(std::string::ToString::to_string) .collect() } @@ -765,7 +767,7 @@ fn post_ota() -> Result<()> { .stdout; let current_slot = String::from_utf8(current_slot)?; let current_slot = current_slot.trim(); - let target_slot = if current_slot == "0" { 1 } else { 0 }; + let target_slot = i32::from(current_slot == "0"); Command::new(BOOTCTL_PATH) .arg(format!("set-active-boot-slot {target_slot}")) @@ -776,11 +778,11 @@ fn post_ota() -> Result<()> { let post_ota_sh = post_fs_data.join("post_ota.sh"); let sh_content = format!( - r###" + r" {BOOTCTL_PATH} mark-boot-successful rm -f {BOOTCTL_PATH} rm -f /data/adb/post-fs-data.d/post_ota.sh -"### +" ); std::fs::write(&post_ota_sh, sh_content)?; diff --git a/userspace/ksud/src/cli.rs b/userspace/ksud/src/cli.rs index 7afbe99f..e0877ffc 100644 --- a/userspace/ksud/src/cli.rs +++ b/userspace/ksud/src/cli.rs @@ -7,7 +7,7 @@ use android_logger::Config; #[cfg(target_os = "android")] use log::LevelFilter; -use crate::{apk_sign, assets, debug, defs, init_event, ksucalls, module, utils}; +use crate::{apk_sign, assets, debug, defs, init_event, ksucalls, module, module_config, utils}; /// KernelSU userspace cli #[derive(Parser, Debug)] @@ -540,7 +540,10 @@ pub fn run() -> Result<()> { let result = match cli.command { Commands::PostFsData => init_event::on_post_data_fs(), - Commands::BootCompleted => init_event::on_boot_completed(), + Commands::BootCompleted => { + init_event::on_boot_completed(); + Ok(()) + } Commands::Module { command } => { #[cfg(any(target_os = "linux", target_os = "android"))] @@ -561,17 +564,16 @@ pub fn run() -> Result<()> { anyhow::anyhow!("This command must be run in the context of a module") })?; - use crate::module_config; match command { ModuleConfigCmd::Get { key } => { // Use merge_configs to respect priority (temp overrides persist) let config = module_config::merge_configs(&module_id)?; match config.get(&key) { Some(value) => { - println!("{}", value); + println!("{value}"); Ok(()) } - None => anyhow::bail!("Key '{}' not found", key), + None => anyhow::bail!("Key '{key}' not found"), } } ModuleConfigCmd::Set { key, value, temp } => { @@ -592,7 +594,7 @@ pub fn run() -> Result<()> { println!("No config entries found"); } else { for (key, value) in config { - println!("{}={}", key, value); + println!("{key}={value}"); } } Ok(()) @@ -624,7 +626,10 @@ pub fn run() -> Result<()> { Sepolicy::Apply { file } => crate::sepolicy::apply_file(file), Sepolicy::Check { sepolicy } => crate::sepolicy::check_rule(&sepolicy), }, - Commands::Services => init_event::on_services(), + Commands::Services => { + init_event::on_services(); + Ok(()) + } Commands::Profile { command } => match command { Profile::GetSepolicy { package } => crate::profile::get_sepolicy(package), Profile::SetSepolicy { package, policy } => { @@ -637,10 +642,13 @@ pub fn run() -> Result<()> { }, Commands::Feature { command } => match command { - Feature::Get { id } => crate::feature::get_feature(id), - Feature::Set { id, value } => crate::feature::set_feature(id, value), - Feature::List => crate::feature::list_features(), - Feature::Check { id } => crate::feature::check_feature(id), + Feature::Get { id } => crate::feature::get_feature(&id), + Feature::Set { id, value } => crate::feature::set_feature(&id, value), + Feature::List => { + crate::feature::list_features(); + Ok(()) + } + Feature::Check { id } => crate::feature::check_feature(&id), Feature::Load => crate::feature::load_config_and_apply(), Feature::Save => crate::feature::save_config(), }, @@ -689,8 +697,10 @@ pub fn run() -> Result<()> { return Ok(()); } BootInfo::SupportedKmis => { - let kmi = crate::assets::list_supported_kmi()?; - kmi.iter().for_each(|kmi| println!("{kmi}")); + let kmi = crate::assets::list_supported_kmi(); + for kmi in &kmi { + println!("{kmi}"); + } return Ok(()); } BootInfo::IsAbDevice => { @@ -701,7 +711,7 @@ pub fn run() -> Result<()> { return Ok(()); } BootInfo::DefaultPartition => { - let kmi = crate::boot_patch::get_current_kmi().unwrap_or_else(|_| String::from("")); + let kmi = crate::boot_patch::get_current_kmi().unwrap_or_else(|_| String::new()); let name = crate::boot_patch::choose_boot_partition(&kmi, false, &None); println!("{name}"); return Ok(()); @@ -713,7 +723,9 @@ pub fn run() -> Result<()> { } BootInfo::AvailablePartitions => { let parts = crate::boot_patch::list_available_partitions(); - parts.iter().for_each(|p| println!("{p}")); + for p in &parts { + println!("{p}"); + } return Ok(()); } }, @@ -747,7 +759,7 @@ pub fn run() -> Result<()> { Kpm::Info { name } => crate::kpm::kpm_info(&name), Kpm::Control { name, args } => { let ret = crate::kpm::kpm_control(&name, &args)?; - println!("{}", ret); + println!("{ret}"); Ok(()) } Kpm::Version => crate::kpm::kpm_version_loader(), diff --git a/userspace/ksud/src/debug.rs b/userspace/ksud/src/debug.rs index fa996883..d26cd231 100644 --- a/userspace/ksud/src/debug.rs +++ b/userspace/ksud/src/debug.rs @@ -58,13 +58,11 @@ pub fn mark_get(pid: i32) -> Result<()> { let result = ksucalls::mark_get(pid)?; if pid == 0 { bail!("Please specify a pid to get its mark status"); - } else { - println!( - "Process {} mark status: {}", - pid, - if result != 0 { "marked" } else { "unmarked" } - ); } + println!( + "Process {pid} mark status: {}", + if result != 0 { "marked" } else { "unmarked" } + ); Ok(()) } @@ -74,7 +72,7 @@ pub fn mark_set(pid: i32) -> Result<()> { if pid == 0 { println!("All processes marked successfully"); } else { - println!("Process {} marked successfully", pid); + println!("Process {pid} marked successfully"); } Ok(()) } @@ -85,7 +83,7 @@ pub fn mark_unset(pid: i32) -> Result<()> { if pid == 0 { println!("All processes unmarked successfully"); } else { - println!("Process {} unmarked successfully", pid); + println!("Process {pid} unmarked successfully"); } Ok(()) } diff --git a/userspace/ksud/src/feature.rs b/userspace/ksud/src/feature.rs index 626828d1..99c54745 100644 --- a/userspace/ksud/src/feature.rs +++ b/userspace/ksud/src/feature.rs @@ -8,6 +8,7 @@ use std::path::Path; use crate::defs; const FEATURE_CONFIG_PATH: &str = concatcp!(defs::WORKING_DIR, ".feature_config"); +#[allow(clippy::unreadable_literal)] const FEATURE_MAGIC: u32 = 0x7f4b5355; const FEATURE_VERSION: u32 = 1; @@ -21,37 +22,37 @@ pub enum FeatureId { } impl FeatureId { - pub fn from_u32(id: u32) -> Option { + pub const fn from_u32(id: u32) -> Option { match id { - 0 => Some(FeatureId::SuCompat), - 1 => Some(FeatureId::KernelUmount), - 2 => Some(FeatureId::EnhancedSecurity), - 3 => Some(FeatureId::SuLog), + 0 => Some(Self::SuCompat), + 1 => Some(Self::KernelUmount), + 2 => Some(Self::EnhancedSecurity), + 3 => Some(Self::SuLog), _ => None, } } - pub fn name(&self) -> &'static str { + pub const fn name(self) -> &'static str { match self { - FeatureId::SuCompat => "su_compat", - FeatureId::KernelUmount => "kernel_umount", - FeatureId::EnhancedSecurity => "enhanced_security", - FeatureId::SuLog => "sulog", + Self::SuCompat => "su_compat", + Self::KernelUmount => "kernel_umount", + Self::EnhancedSecurity => "enhanced_security", + Self::SuLog => "sulog", } } - pub fn description(&self) -> &'static str { + pub const fn description(self) -> &'static str { match self { - FeatureId::SuCompat => { + Self::SuCompat => { "SU Compatibility Mode - allows authorized apps to gain root via traditional 'su' command" } - FeatureId::KernelUmount => { + Self::KernelUmount => { "Kernel Umount - controls whether kernel automatically unmounts modules when not needed" } - FeatureId::EnhancedSecurity => { + Self::EnhancedSecurity => { "Enhanced Security - disable non‑KSU root elevation and unauthorized UID downgrades" } - FeatureId::SuLog => { + Self::SuLog => { "SU Log - enables logging of SU command usage to kernel log for auditing purposes" } } @@ -64,7 +65,7 @@ fn parse_feature_id(name: &str) -> Result { "kernel_umount" | "1" => Ok(FeatureId::KernelUmount), "enhanced_security" | "2" => Ok(FeatureId::EnhancedSecurity), "sulog" | "3" => Ok(FeatureId::SuLog), - _ => bail!("Unknown feature: {}", name), + _ => bail!("Unknown feature: {name}"), } } @@ -83,11 +84,7 @@ pub fn load_binary_config() -> Result> { let magic = u32::from_le_bytes(magic_buf); if magic != FEATURE_MAGIC { - bail!( - "Invalid feature config magic: expected 0x{:08x}, got 0x{:08x}", - FEATURE_MAGIC, - magic - ); + bail!("Invalid feature config magic: expected 0x{FEATURE_MAGIC:08x}, got 0x{magic:08x}",); } let mut version_buf = [0u8; 4]; @@ -97,9 +94,8 @@ pub fn load_binary_config() -> Result> { if version != FEATURE_VERSION { log::warn!( - "Feature config version mismatch: expected {}, got {}", - FEATURE_VERSION, - version + "Feature config version mismatch: expected {FEATURE_VERSION}, got {version + }", ); } @@ -144,11 +140,11 @@ pub fn save_binary_config(features: &HashMap) -> Result<()> { file.write_all(&count.to_le_bytes()) .with_context(|| "Failed to write count")?; - for (&id, &value) in features.iter() { + for (&id, &value) in features { file.write_all(&id.to_le_bytes()) - .with_context(|| format!("Failed to write feature id {}", id))?; + .with_context(|| format!("Failed to write feature id {id}"))?; file.write_all(&value.to_le_bytes()) - .with_context(|| format!("Failed to write feature value for id {}", id))?; + .with_context(|| format!("Failed to write feature value for id {id}"))?; } file.sync_all() @@ -158,43 +154,42 @@ pub fn save_binary_config(features: &HashMap) -> Result<()> { Ok(()) } -pub fn apply_config(features: &HashMap) -> Result<()> { +pub fn apply_config(features: &HashMap) { log::info!("Applying feature configuration to kernel..."); let mut applied = 0; - for (&id, &value) in features.iter() { + for (&id, &value) in features { match crate::ksucalls::set_feature(id, value) { - Ok(_) => { + Ok(()) => { if let Some(feature_id) = FeatureId::from_u32(id) { - log::info!("Set feature {} to {}", feature_id.name(), value); + log::info!("Set feature {} to {value}", feature_id.name()); } else { - log::info!("Set feature {} to {}", id, value); + log::info!("Set feature {id} to {value}"); } applied += 1; } Err(e) => { - log::warn!("Failed to set feature {}: {}", id, e); + log::warn!("Failed to set feature {id}: {e}"); } } } - log::info!("Applied {} features successfully", applied); - Ok(()) + log::info!("Applied {applied} features successfully"); } -pub fn get_feature(id: String) -> Result<()> { - let feature_id = parse_feature_id(&id)?; +pub fn get_feature(id: &str) -> Result<()> { + let feature_id = parse_feature_id(id)?; let (value, supported) = crate::ksucalls::get_feature(feature_id as u32) - .with_context(|| format!("Failed to get feature {}", id))?; + .with_context(|| format!("Failed to get feature {id}"))?; if !supported { - println!("Feature '{}' is not supported by kernel", id); + println!("Feature '{id}' is not supported by kernel"); return Ok(()); } println!("Feature: {} ({})", feature_id.name(), feature_id as u32); println!("Description: {}", feature_id.description()); - println!("Value: {}", value); + println!("Value: {value}"); println!( "Status: {}", if value != 0 { "enabled" } else { "disabled" } @@ -203,8 +198,8 @@ pub fn get_feature(id: String) -> Result<()> { Ok(()) } -pub fn set_feature(id: String, value: u64) -> Result<()> { - let feature_id = parse_feature_id(&id)?; +pub fn set_feature(id: &str, value: u64) -> Result<()> { + let feature_id = parse_feature_id(id)?; // Check if this feature is managed by any module if let Ok(managed_features_map) = crate::module::get_managed_features() { @@ -232,27 +227,25 @@ pub fn set_feature(id: String, value: u64) -> Result<()> { } log::info!( - "Module '{}' is setting managed feature '{}'", - caller_module, + "Module '{caller_module}' is setting managed feature '{}'", feature_id.name() ); } } crate::ksucalls::set_feature(feature_id as u32, value) - .with_context(|| format!("Failed to set feature {} to {}", id, value))?; + .with_context(|| format!("Failed to set feature {id} to {value}"))?; println!( - "Feature '{}' set to {} ({})", + "Feature '{}' set to {value} ({})", feature_id.name(), - value, if value != 0 { "enabled" } else { "disabled" } ); Ok(()) } -pub fn list_features() -> Result<()> { +pub fn list_features() { println!("Available Features:"); println!("{}", "=".repeat(80)); @@ -261,7 +254,7 @@ pub fn list_features() -> Result<()> { // Build a reverse map: feature_name -> Vec let mut feature_to_modules: HashMap> = HashMap::new(); - for (module_id, feature_list) in managed_features_map.iter() { + for (module_id, feature_list) in &managed_features_map { for feature_name in feature_list { feature_to_modules .entry(feature_name.clone()) @@ -277,14 +270,14 @@ pub fn list_features() -> Result<()> { FeatureId::SuLog, ]; - for feature_id in all_features.iter() { + for feature_id in &all_features { let id = *feature_id as u32; let (value, supported) = crate::ksucalls::get_feature(id).unwrap_or((0, false)); let status = if !supported { "NOT_SUPPORTED".to_string() } else if value != 0 { - format!("ENABLED ({})", value) + format!("ENABLED ({value})") } else { "DISABLED".to_string() }; @@ -314,8 +307,6 @@ pub fn list_features() -> Result<()> { println!(); } - - Ok(()) } pub fn load_config_and_apply() -> Result<()> { @@ -326,7 +317,7 @@ pub fn load_config_and_apply() -> Result<()> { return Ok(()); } - apply_config(&features)?; + apply_config(&features); println!("Feature configuration loaded and applied"); Ok(()) } @@ -341,13 +332,13 @@ pub fn save_config() -> Result<()> { FeatureId::SuLog, ]; - for feature_id in all_features.iter() { + for feature_id in &all_features { let id = *feature_id as u32; if let Ok((value, supported)) = crate::ksucalls::get_feature(id) && supported { features.insert(id, value); - log::info!("Saved feature {} = {}", feature_id.name(), value); + log::info!("Saved feature {} = {value}", feature_id.name()); } } @@ -359,8 +350,8 @@ pub fn save_config() -> Result<()> { Ok(()) } -pub fn check_feature(id: String) -> Result<()> { - let feature_id = parse_feature_id(&id)?; +pub fn check_feature(id: &str) -> Result<()> { + let feature_id = parse_feature_id(id)?; // Check if this feature is managed by any module let managed_features_map = crate::module::get_managed_features().unwrap_or_default(); @@ -375,7 +366,7 @@ pub fn check_feature(id: String) -> Result<()> { // Check if the feature is supported by kernel let (_value, supported) = crate::ksucalls::get_feature(feature_id as u32) - .with_context(|| format!("Failed to get feature {}", id))?; + .with_context(|| format!("Failed to get feature {id}"))?; if supported { println!("supported"); @@ -400,10 +391,9 @@ pub fn init_features() -> Result<()> { ); // Build a set of all managed feature IDs to skip - for (module_id, feature_list) in managed_features_map.iter() { + for (module_id, feature_list) in &managed_features_map { log::info!( - "Module '{}' manages {} feature(s)", - module_id, + "Module '{module_id}' manages {} feature(s)", feature_list.len() ); for feature_name in feature_list { @@ -412,22 +402,16 @@ pub fn init_features() -> Result<()> { // Remove managed features from config, let modules control them if features.remove(&feature_id_u32).is_some() { log::info!( - " - Skipping managed feature '{}' (controlled by module: {})", - feature_name, - module_id + " - Skipping managed feature '{feature_name}' (controlled by module: {module_id})", ); } else { log::info!( - " - Feature '{}' is managed by module '{}', skipping", - feature_name, - module_id + " - Feature '{feature_name}' is managed by module '{module_id}', skipping", ); } } else { log::warn!( - " - Unknown managed feature '{}' from module '{}', ignoring", - feature_name, - module_id + " - Unknown managed feature '{feature_name}' from module '{module_id}', ignoring", ); } } @@ -444,7 +428,7 @@ pub fn init_features() -> Result<()> { return Ok(()); } - apply_config(&features)?; + apply_config(&features); // Save the configuration (excluding managed features) save_binary_config(&features)?; diff --git a/userspace/ksud/src/init_event.rs b/userspace/ksud/src/init_event.rs index be467c56..f305fcfd 100644 --- a/userspace/ksud/src/init_event.rs +++ b/userspace/ksud/src/init_event.rs @@ -21,9 +21,9 @@ pub fn on_post_data_fs() -> Result<()> { } #[cfg(unix)] - let _ = catch_bootlog("logcat", vec!["logcat"]); + let _ = catch_bootlog("logcat", &["logcat"]); #[cfg(unix)] - let _ = catch_bootlog("dmesg", vec!["dmesg", "-w"]); + let _ = catch_bootlog("dmesg", &["dmesg", "-w"]); if utils::has_magisk() { warn!("Magisk detected, skip post-fs-data!"); @@ -159,24 +159,20 @@ fn run_stage(stage: &str, block: bool) { } } -pub fn on_services() -> Result<()> { +pub fn on_services() { info!("on_services triggered!"); run_stage("service", false); - - Ok(()) } -pub fn on_boot_completed() -> Result<()> { +pub fn on_boot_completed() { ksucalls::report_boot_complete(); info!("on_boot_completed triggered!"); run_stage("boot-completed", false); - - Ok(()) } #[cfg(unix)] -fn catch_bootlog(logname: &str, command: Vec<&str>) -> Result<()> { +fn catch_bootlog(logname: &str, command: &[&str]) -> Result<()> { use std::os::unix::process::CommandExt; use std::process::Stdio; @@ -192,7 +188,7 @@ fn catch_bootlog(logname: &str, command: Vec<&str>) -> Result<()> { let bootlog = std::fs::File::create(bootlog)?; let mut args = vec!["-s", "9", "30s"]; - args.extend_from_slice(&command); + args.extend_from_slice(command); // timeout -s 9 30s logcat > boot.log let result = unsafe { std::process::Command::new("timeout") diff --git a/userspace/ksud/src/kpm.rs b/userspace/ksud/src/kpm.rs index f4dad199..7488dba1 100644 --- a/userspace/ksud/src/kpm.rs +++ b/userspace/ksud/src/kpm.rs @@ -20,6 +20,7 @@ const KPM_INFO: u64 = 5; const KPM_CONTROL: u64 = 6; const KPM_VERSION: u64 = 7; +#[allow(clippy::unreadable_literal)] const KSU_IOCTL_KPM: u32 = 0xc0004bc8; // _IOC(_IOC_READ|_IOC_WRITE, 'K', 200, 0) #[repr(C)] @@ -32,7 +33,7 @@ struct KsuKpmCmd { } fn kpm_ioctl(cmd: &mut KsuKpmCmd) -> std::io::Result<()> { - ksuctl(KSU_IOCTL_KPM, cmd as *mut _)?; + ksuctl(KSU_IOCTL_KPM, std::ptr::from_mut(cmd))?; Ok(()) } @@ -57,7 +58,7 @@ where control_code: KPM_LOAD, arg1: path_c.as_ptr() as u64, arg2: args_c.as_ref().map_or(0, |s| s.as_ptr() as u64), - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -75,7 +76,7 @@ pub fn kpm_unload(name: &str) -> Result<()> { control_code: KPM_UNLOAD, arg1: name_c.as_ptr() as u64, arg2: 0, - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -90,7 +91,7 @@ pub fn kpm_num() -> Result { control_code: KPM_NUM, arg1: 0, arg2: 0, - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -108,7 +109,7 @@ pub fn kpm_list() -> Result<()> { control_code: KPM_LIST, arg1: buf.as_mut_ptr() as u64, arg2: buf.len() as u64, - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -127,7 +128,7 @@ pub fn kpm_info(name: &str) -> Result<()> { control_code: KPM_INFO, arg1: name_c.as_ptr() as u64, arg2: buf.as_mut_ptr() as u64, - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -146,7 +147,7 @@ pub fn kpm_control(name: &str, args: &str) -> Result { control_code: KPM_CONTROL, arg1: name_c.as_ptr() as u64, arg2: args_c.as_ptr() as u64, - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -162,7 +163,7 @@ pub fn kpm_version_loader() -> Result<()> { control_code: KPM_VERSION, arg1: buf.as_mut_ptr() as u64, arg2: buf.len() as u64, - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -180,7 +181,7 @@ pub fn check_kpm_version() -> Result { control_code: KPM_VERSION, arg1: buf.as_mut_ptr() as u64, arg2: buf.len() as u64, - result_code: &mut result as *mut i32 as u64, + result_code: &raw mut result as u64, }; kpm_ioctl(&mut cmd)?; @@ -308,7 +309,7 @@ pub fn load_kpm_modules() -> Result<()> { && ex == OsStr::new("kpm") { match kpm_load(&p, None) { - Ok(_) => ok += 1, + Ok(()) => ok += 1, Err(e) => { log::warn!("KPM: load {} failed: {e}", p.display()); ng += 1; diff --git a/userspace/ksud/src/ksucalls.rs b/userspace/ksud/src/ksucalls.rs index 4a814d2a..25553e46 100644 --- a/userspace/ksud/src/ksucalls.rs +++ b/userspace/ksud/src/ksucalls.rs @@ -1,3 +1,4 @@ +#![allow(clippy::unreadable_literal)] use std::fs; #[cfg(any(target_os = "linux", target_os = "android"))] use std::os::fd::RawFd; @@ -115,7 +116,7 @@ fn scan_driver_fd() -> Option { for entry in fd_dir.flatten() { if let Ok(fd_num) = entry.file_name().to_string_lossy().parse::() { - let link_path = format!("/proc/self/fd/{}", fd_num); + let link_path = format!("/proc/self/fd/{fd_num}"); if let Ok(target) = fs::read_link(&link_path) { let target_str = target.to_string_lossy(); if target_str.contains("[ksu_driver]") { @@ -181,7 +182,7 @@ fn get_info() -> GetInfoCmd { version: 0, flags: 0, }; - let _ = ksuctl(KSU_IOCTL_GET_INFO, &mut cmd as *mut _); + let _ = ksuctl(KSU_IOCTL_GET_INFO, &raw mut cmd); cmd }) } @@ -210,7 +211,7 @@ pub fn grant_root() -> std::io::Result<()> { #[cfg(any(target_os = "linux", target_os = "android"))] fn report_event(event: u32) { let mut cmd = ReportEventCmd { event }; - let _ = ksuctl(KSU_IOCTL_REPORT_EVENT, &mut cmd as *mut _); + let _ = ksuctl(KSU_IOCTL_REPORT_EVENT, &raw mut cmd); } #[cfg(not(any(target_os = "linux", target_os = "android")))] @@ -231,7 +232,7 @@ pub fn report_module_mounted() { #[cfg(any(target_os = "linux", target_os = "android"))] pub fn check_kernel_safemode() -> bool { let mut cmd = CheckSafemodeCmd { in_safe_mode: 0 }; - let _ = ksuctl(KSU_IOCTL_CHECK_SAFEMODE, &mut cmd as *mut _); + let _ = ksuctl(KSU_IOCTL_CHECK_SAFEMODE, &raw mut cmd); cmd.in_safe_mode != 0 } @@ -242,7 +243,7 @@ pub fn check_kernel_safemode() -> bool { pub fn set_sepolicy(cmd: &SetSepolicyCmd) -> std::io::Result<()> { let mut ioctl_cmd = *cmd; - ksuctl(KSU_IOCTL_SET_SEPOLICY, &mut ioctl_cmd as *mut _)?; + ksuctl(KSU_IOCTL_SET_SEPOLICY, &raw mut ioctl_cmd)?; Ok(()) } @@ -254,21 +255,21 @@ pub fn get_feature(feature_id: u32) -> std::io::Result<(u64, bool)> { value: 0, supported: 0, }; - ksuctl(KSU_IOCTL_GET_FEATURE, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_GET_FEATURE, &raw mut cmd)?; Ok((cmd.value, cmd.supported != 0)) } /// Set feature value in kernel pub fn set_feature(feature_id: u32, value: u64) -> std::io::Result<()> { let mut cmd = SetFeatureCmd { feature_id, value }; - ksuctl(KSU_IOCTL_SET_FEATURE, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_SET_FEATURE, &raw mut cmd)?; Ok(()) } #[cfg(any(target_os = "linux", target_os = "android"))] pub fn get_wrapped_fd(fd: RawFd) -> std::io::Result { let mut cmd = GetWrapperFdCmd { fd, flags: 0 }; - let result = ksuctl(KSU_IOCTL_GET_WRAPPER_FD, &mut cmd as *mut _)?; + let result = ksuctl(KSU_IOCTL_GET_WRAPPER_FD, &raw mut cmd)?; Ok(result) } @@ -279,7 +280,7 @@ pub fn mark_get(pid: i32) -> std::io::Result { pid, result: 0, }; - ksuctl(KSU_IOCTL_MANAGE_MARK, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_MANAGE_MARK, &raw mut cmd)?; Ok(cmd.result) } @@ -290,7 +291,7 @@ pub fn mark_set(pid: i32) -> std::io::Result<()> { pid, result: 0, }; - ksuctl(KSU_IOCTL_MANAGE_MARK, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_MANAGE_MARK, &raw mut cmd)?; Ok(()) } @@ -301,7 +302,7 @@ pub fn mark_unset(pid: i32) -> std::io::Result<()> { pid, result: 0, }; - ksuctl(KSU_IOCTL_MANAGE_MARK, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_MANAGE_MARK, &raw mut cmd)?; Ok(()) } @@ -312,7 +313,7 @@ pub fn mark_refresh() -> std::io::Result<()> { pid: 0, result: 0, }; - ksuctl(KSU_IOCTL_MANAGE_MARK, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_MANAGE_MARK, &raw mut cmd)?; Ok(()) } @@ -321,7 +322,7 @@ pub fn nuke_ext4_sysfs(mnt: &str) -> anyhow::Result<()> { let mut ioctl_cmd = NukeExt4SysfsCmd { arg: c_mnt.as_ptr() as u64, }; - ksuctl(KSU_IOCTL_NUKE_EXT4_SYSFS, &mut ioctl_cmd as *mut _)?; + ksuctl(KSU_IOCTL_NUKE_EXT4_SYSFS, &raw mut ioctl_cmd)?; Ok(()) } @@ -332,7 +333,7 @@ pub fn umount_list_wipe() -> std::io::Result<()> { flags: 0, mode: KSU_UMOUNT_WIPE, }; - ksuctl(KSU_IOCTL_ADD_TRY_UMOUNT, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_ADD_TRY_UMOUNT, &raw mut cmd)?; Ok(()) } @@ -344,7 +345,7 @@ pub fn umount_list_add(path: &str, flags: u32) -> anyhow::Result<()> { flags, mode: KSU_UMOUNT_ADD, }; - ksuctl(KSU_IOCTL_ADD_TRY_UMOUNT, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_ADD_TRY_UMOUNT, &raw mut cmd)?; Ok(()) } @@ -356,6 +357,6 @@ pub fn umount_list_del(path: &str) -> anyhow::Result<()> { flags: 0, mode: KSU_UMOUNT_DEL, }; - ksuctl(KSU_IOCTL_ADD_TRY_UMOUNT, &mut cmd as *mut _)?; + ksuctl(KSU_IOCTL_ADD_TRY_UMOUNT, &raw mut cmd)?; Ok(()) } diff --git a/userspace/ksud/src/main.rs b/userspace/ksud/src/main.rs index 945aeaef..a77c4080 100644 --- a/userspace/ksud/src/main.rs +++ b/userspace/ksud/src/main.rs @@ -1,3 +1,15 @@ +#![deny(clippy::all, clippy::pedantic)] +#![warn(clippy::nursery)] +#![allow( + clippy::module_name_repetitions, + clippy::cast_possible_truncation, + clippy::cast_sign_loss, + clippy::cast_precision_loss, + clippy::doc_markdown, + clippy::too_many_lines, + clippy::cast_possible_wrap +)] + mod apk_sign; mod assets; mod boot_patch; diff --git a/userspace/ksud/src/metamodule.rs b/userspace/ksud/src/metamodule.rs index a49a9b61..7daafcb7 100644 --- a/userspace/ksud/src/metamodule.rs +++ b/userspace/ksud/src/metamodule.rs @@ -17,13 +17,10 @@ use crate::{assets, defs}; /// Determine whether the provided module properties mark it as a metamodule pub fn is_metamodule(props: &HashMap) -> bool { - props - .get("metamodule") - .map(|s| { - let trimmed = s.trim(); - trimmed == "1" || trimmed.eq_ignore_ascii_case("true") - }) - .unwrap_or(false) + props.get("metamodule").is_some_and(|s| { + let trimmed = s.trim(); + trimmed == "1" || trimmed.eq_ignore_ascii_case("true") + }) } /// Get metamodule path if it exists @@ -44,12 +41,11 @@ pub fn get_metamodule_path() -> Option { if resolved.exists() && resolved.is_dir() { return Some(resolved); - } else { - warn!( - "Metamodule symlink points to non-existent path: {:?}", - resolved - ); } + warn!( + "Metamodule symlink points to non-existent path: {}", + resolved.display() + ); } // Fallback: search for metamodule=1 in modules directory @@ -58,7 +54,10 @@ pub fn get_metamodule_path() -> Option { if let Ok(props) = crate::module::read_module_prop(module_path) && is_metamodule(&props) { - info!("Found metamodule in modules directory: {:?}", module_path); + info!( + "Found metamodule in modules directory: {}", + module_path.display() + ); result = Some(module_path.to_path_buf()); } Ok(()) @@ -113,13 +112,14 @@ pub fn check_install_safety() -> Result<(), bool> { /// Create or update the metamodule symlink /// Points /data/adb/metamodule -> /data/adb/modules/{module_id} -pub(crate) fn ensure_symlink(module_path: &Path) -> Result<()> { +pub fn ensure_symlink(module_path: &Path) -> Result<()> { // METAMODULE_DIR might have trailing slash, so we need to trim it let symlink_path = Path::new(defs::METAMODULE_DIR.trim_end_matches('/')); info!( - "Creating metamodule symlink: {:?} -> {:?}", - symlink_path, module_path + "Creating metamodule symlink: {} -> {}", + symlink_path.display(), + module_path.display() ); // Remove existing symlink if it exists @@ -137,14 +137,14 @@ pub(crate) fn ensure_symlink(module_path: &Path) -> Result<()> { // Create symlink #[cfg(unix)] std::os::unix::fs::symlink(module_path, symlink_path) - .with_context(|| format!("Failed to create symlink to {:?}", module_path))?; + .with_context(|| format!("Failed to create symlink to {}", module_path.display()))?; info!("Metamodule symlink created successfully"); Ok(()) } /// Remove the metamodule symlink -pub(crate) fn remove_symlink() -> Result<()> { +pub fn remove_symlink() -> Result<()> { let symlink_path = Path::new(defs::METAMODULE_DIR.trim_end_matches('/')); if symlink_path.is_symlink() { @@ -158,37 +158,35 @@ pub(crate) fn remove_symlink() -> Result<()> { /// Get the install script content, using metainstall.sh from metamodule if available /// Returns the script content to be executed -pub(crate) fn get_install_script( +pub fn get_install_script( is_metamodule: bool, installer_content: &str, install_module_script: &str, ) -> Result { // Check if there's a metamodule with metainstall.sh // Only apply this logic for regular modules (not when installing metamodule itself) - let install_script = if !is_metamodule { - if let Some(metamodule_path) = get_metamodule_path() { - if metamodule_path.join(defs::DISABLE_FILE_NAME).exists() { - info!("Metamodule is disabled, using default installer"); - install_module_script.to_string() - } else { - let metainstall_path = metamodule_path.join(defs::METAMODULE_METAINSTALL_SCRIPT); - - if metainstall_path.exists() { - info!("Using metainstall.sh from metamodule"); - let metamodule_content = std::fs::read_to_string(&metainstall_path) - .with_context(|| "Failed to read metamodule metainstall.sh")?; - format!("{}\n{}\nexit 0\n", installer_content, metamodule_content) - } else { - info!("Metamodule exists but has no metainstall.sh, using default installer"); - install_module_script.to_string() - } - } - } else { - info!("No metamodule found, using default installer"); + let install_script = if is_metamodule { + info!("Installing metamodule, using default installer"); + install_module_script.to_string() + } else if let Some(metamodule_path) = get_metamodule_path() { + if metamodule_path.join(defs::DISABLE_FILE_NAME).exists() { + info!("Metamodule is disabled, using default installer"); install_module_script.to_string() + } else { + let metainstall_path = metamodule_path.join(defs::METAMODULE_METAINSTALL_SCRIPT); + + if metainstall_path.exists() { + info!("Using metainstall.sh from metamodule"); + let metamodule_content = std::fs::read_to_string(&metainstall_path) + .with_context(|| "Failed to read metamodule metainstall.sh")?; + format!("{installer_content}\n{metamodule_content}\nexit 0\n") + } else { + info!("Metamodule exists but has no metainstall.sh, using default installer"); + install_module_script.to_string() + } } } else { - info!("Installing metamodule, using default installer"); + info!("No metamodule found, using default installer"); install_module_script.to_string() }; @@ -204,7 +202,7 @@ fn check_metamodule_script(script_name: &str) -> Option { // Check if metamodule is disabled if metamodule_path.join(defs::DISABLE_FILE_NAME).exists() { - info!("Metamodule is disabled, skipping {}", script_name); + info!("Metamodule is disabled, skipping {script_name}"); return None; } @@ -218,16 +216,13 @@ fn check_metamodule_script(script_name: &str) -> Option { } /// Execute metamodule's metauninstall.sh for a specific module -pub(crate) fn exec_metauninstall_script(module_id: &str) -> Result<()> { +pub fn exec_metauninstall_script(module_id: &str) -> Result<()> { let Some(metauninstall_path) = check_metamodule_script(defs::METAMODULE_METAUNINSTALL_SCRIPT) else { return Ok(()); }; - info!( - "Executing metamodule metauninstall.sh for module: {}", - module_id - ); + info!("Executing metamodule metauninstall.sh for module: {module_id}",); let result = Command::new(assets::BUSYBOX_PATH) .args(["sh", metauninstall_path.to_str().unwrap()]) @@ -238,15 +233,11 @@ pub(crate) fn exec_metauninstall_script(module_id: &str) -> Result<()> { ensure!( result.success(), - "Metamodule metauninstall.sh failed for module {}: {:?}", - module_id, + "Metamodule metauninstall.sh failed for module {module_id}: {:?}", result ); - info!( - "Metamodule metauninstall.sh executed successfully for {}", - module_id - ); + info!("Metamodule metauninstall.sh executed successfully for {module_id}",); Ok(()) } @@ -276,12 +267,12 @@ pub fn exec_mount_script(module_dir: &str) -> Result<()> { /// Execute metamodule script for a specific stage pub fn exec_stage_script(stage: &str, block: bool) -> Result<()> { - let Some(script_path) = check_metamodule_script(&format!("{}.sh", stage)) else { + let Some(script_path) = check_metamodule_script(&format!("{stage}.sh")) else { return Ok(()); }; - info!("Executing metamodule {}.sh", stage); + info!("Executing metamodule {stage}.sh"); crate::module::exec_script(&script_path, block)?; - info!("Metamodule {}.sh executed successfully", stage); + info!("Metamodule {stage}.sh executed successfully"); Ok(()) } diff --git a/userspace/ksud/src/module.rs b/userspace/ksud/src/module.rs index bb8467a1..b27c171a 100644 --- a/userspace/ksud/src/module.rs +++ b/userspace/ksud/src/module.rs @@ -58,7 +58,7 @@ pub fn validate_module_id(module_id: &str) -> Result<()> { } /// Get common environment variables for script execution -pub(crate) fn get_common_script_envs() -> Vec<(&'static str, String)> { +pub fn get_common_script_envs() -> Vec<(&'static str, String)> { vec![ ("ASH_STANDALONE", "1".to_string()), ("KSU", "true".to_string()), @@ -104,13 +104,14 @@ fn ensure_boot_completed() -> Result<()> { } #[derive(PartialEq, Eq)] -pub(crate) enum ModuleType { +pub enum ModuleType { All, Active, Updated, } -pub(crate) fn foreach_module( +#[allow(clippy::needless_pass_by_value)] +pub fn foreach_module( module_type: ModuleType, mut f: impl FnMut(&Path) -> Result<()>, ) -> Result<()> { @@ -172,22 +173,20 @@ pub fn exec_script>(path: T, wait: bool) -> Result<()> { .ok() .and_then(|p| p.components().next()) .and_then(|c| c.as_os_str().to_str()) - .map(|s| s.to_string()); + .map(std::string::ToString::to_string); // Validate and log module_id extraction let validated_module_id = module_id .as_ref() .and_then(|id| match validate_module_id(id) { - Ok(_) => { - debug!("Module ID extracted from script path: '{}'", id); + Ok(()) => { + debug!("Module ID extracted from script path: '{id}'"); Some(id.as_str()) } Err(e) => { warn!( - "Invalid module ID '{}' extracted from script path '{}': {}", - id, + "Invalid module ID '{id}' extracted from script path '{}': {e}", path.as_ref().display(), - e ); None } @@ -228,7 +227,7 @@ pub fn exec_script>(path: T, wait: bool) -> Result<()> { } else { command.spawn().map(|_| ()) }; - result.map_err(|err| anyhow!("Failed to exec {}: {}", path.as_ref().display(), err)) + result.map_err(|e| anyhow!("Failed to exec {}: {e}", path.as_ref().display())) } pub fn exec_stage_script(stage: &str, block: bool) -> Result<()> { @@ -317,13 +316,10 @@ pub fn prune_modules() -> Result<()> { if is_metamodule { info!("Removing metamodule symlink"); if let Err(e) = metamodule::remove_symlink() { - warn!("Failed to remove metamodule symlink: {}", e); + warn!("Failed to remove metamodule symlink: {e}"); } } else if let Err(e) = metamodule::exec_metauninstall_script(module_id) { - warn!( - "Failed to exec metamodule uninstall for {}: {}", - module_id, e - ); + warn!("Failed to exec metamodule uninstall for {module_id}: {e}",); } // Then execute module's own uninstall.sh @@ -336,12 +332,12 @@ pub fn prune_modules() -> Result<()> { // Clear module configs before removing module directory if let Err(e) = crate::module_config::clear_module_configs(module_id) { - warn!("Failed to clear configs for {}: {}", module_id, e); + warn!("Failed to clear configs for {module_id}: {e}"); } // Finally remove the module directory if let Err(e) = remove_dir_all(module) { - warn!("Failed to remove {}: {}", module.display(), e); + warn!("Failed to remove {}: {e}", module.display()); } Ok(()) @@ -349,7 +345,7 @@ pub fn prune_modules() -> Result<()> { // collect remaining modules, if none, clean up metamodule record let remaining_modules: Vec<_> = std::fs::read_dir(defs::MODULE_DIR)? - .filter_map(|entry| entry.ok()) + .filter_map(std::result::Result::ok) .filter(|entry| entry.path().join("module.prop").exists()) .collect(); @@ -381,12 +377,12 @@ pub fn handle_updated_modules() -> Result<()> { if removed { let path = module_dir.join(defs::REMOVE_FILE_NAME); if let Err(e) = ensure_file_exists(&path) { - warn!("Failed to create {}: {}", path.display(), e); + warn!("Failed to create {}: {e}", path.display()); } } else if disabled { let path = module_dir.join(defs::DISABLE_FILE_NAME); if let Err(e) = ensure_file_exists(&path) { - warn!("Failed to create {}: {}", path.display(), e); + warn!("Failed to create {}: {e}", path.display()); } } } @@ -395,7 +391,7 @@ pub fn handle_updated_modules() -> Result<()> { Ok(()) } -fn _install_module(zip: &str) -> Result<()> { +fn install_module_to_system(zip: &str) -> Result<()> { ensure_boot_completed()?; // print banner @@ -429,7 +425,7 @@ fn _install_module(zip: &str) -> Result<()> { // Validate module_id format validate_module_id(module_id) - .with_context(|| format!("Invalid module ID in module.prop: '{}'", module_id))?; + .with_context(|| format!("Invalid module ID in module.prop: '{module_id}'"))?; // Check if this module is a metamodule let is_metamodule = metamodule::is_metamodule(&module_prop); @@ -455,7 +451,7 @@ fn _install_module(zip: &str) -> Result<()> { let updated_dir = Path::new(defs::MODULE_UPDATE_DIR).join(module_id); if is_metamodule { - info!("Installing metamodule: {}", module_id); + info!("Installing metamodule: {module_id}"); // Check if there's already a metamodule installed if metamodule::has_metamodule() @@ -470,7 +466,7 @@ fn _install_module(zip: &str) -> Result<()> { println!("\n❌ Installation Failed"); println!("┌────────────────────────────────"); println!("│ A metamodule is already installed"); - println!("│ Current metamodule: {}", existing_id); + println!("│ Current metamodule: {existing_id}"); println!("│"); println!("│ Only one metamodule can be active at a time."); println!("│"); @@ -536,13 +532,13 @@ fn _install_module(zip: &str) -> Result<()> { } println!("- Module installed successfully!"); - info!("Module {} installed successfully!", module_id); + info!("Module {module_id} installed successfully!"); Ok(()) } pub fn install_module(zip: &str) -> Result<()> { - let result = _install_module(zip); + let result = install_module_to_system(zip); if let Err(ref e) = result { println!("- Error: {e}"); } @@ -553,14 +549,14 @@ pub fn undo_uninstall_module(id: &str) -> Result<()> { validate_module_id(id)?; let module_path = Path::new(defs::MODULE_DIR).join(id); - ensure!(module_path.exists(), "Module {} not found", id); + ensure!(module_path.exists(), "Module {id} not found"); // Remove the remove mark let remove_file = module_path.join(defs::REMOVE_FILE_NAME); if remove_file.exists() { std::fs::remove_file(&remove_file) - .with_context(|| format!("Failed to delete remove file for module '{}'", id))?; - info!("Removed the remove mark for module {}", id); + .with_context(|| format!("Failed to delete remove file for module '{id}'"))?; + info!("Removed the remove mark for module {id}"); } Ok(()) @@ -570,13 +566,13 @@ pub fn uninstall_module(id: &str) -> Result<()> { validate_module_id(id)?; let module_path = Path::new(defs::MODULE_DIR).join(id); - ensure!(module_path.exists(), "Module {} not found", id); + ensure!(module_path.exists(), "Module {id} not found"); // Mark for removal let remove_file = module_path.join(defs::REMOVE_FILE_NAME); File::create(remove_file).with_context(|| "Failed to create remove file")?; - info!("Module {} marked for removal", id); + info!("Module {id} marked for removal"); Ok(()) } @@ -592,14 +588,14 @@ pub fn enable_module(id: &str) -> Result<()> { validate_module_id(id)?; let module_path = Path::new(defs::MODULE_DIR).join(id); - ensure!(module_path.exists(), "Module {} not found", id); + ensure!(module_path.exists(), "Module {id} not found"); let disable_path = module_path.join(defs::DISABLE_FILE_NAME); if disable_path.exists() { std::fs::remove_file(&disable_path).with_context(|| { format!("Failed to remove disable file: {}", disable_path.display()) })?; - info!("Module {} enabled", id); + info!("Module {id} enabled"); } Ok(()) @@ -607,12 +603,12 @@ pub fn enable_module(id: &str) -> Result<()> { pub fn disable_module(id: &str) -> Result<()> { let module_path = Path::new(defs::MODULE_DIR).join(id); - ensure!(module_path.exists(), "Module {} not found", id); + ensure!(module_path.exists(), "Module {id} not found"); let disable_path = module_path.join(defs::DISABLE_FILE_NAME); ensure_file_exists(disable_path)?; - info!("Module {} disabled", id); + info!("Module {id} disabled"); Ok(()) } @@ -633,7 +629,7 @@ fn mark_all_modules(flag_file: &str) -> Result<()> { let path = entry.path(); let flag = path.join(flag_file); if let Err(e) = ensure_file_exists(flag) { - warn!("Failed to mark module: {}: {}", path.display(), e); + warn!("Failed to mark module: {}: {e}", path.display()); } } @@ -662,12 +658,12 @@ pub fn read_module_prop(module_path: &Path) -> Result> { Ok(prop_map) } -fn _list_modules(path: &str) -> Vec> { +fn list_module(path: &str) -> Vec> { // Load all module configs once to minimize I/O overhead let all_configs = match crate::module_config::get_all_module_configs() { Ok(configs) => configs, Err(e) => { - warn!("Failed to load module configs: {}", e); + warn!("Failed to load module configs: {e}"); HashMap::new() } }; @@ -691,22 +687,19 @@ fn _list_modules(path: &str) -> Vec> { let mut module_prop_map = match read_module_prop(&path) { Ok(prop) => prop, Err(e) => { - warn!("Failed to read module.prop for {}: {}", path.display(), e); + warn!("Failed to read module.prop for {}: {e}", path.display()); continue; } }; // If id is missing or empty, use directory name as fallback if !module_prop_map.contains_key("id") || module_prop_map["id"].is_empty() { - match entry.file_name().to_str() { - Some(id) => { - info!("Use dir name as module id: {id}"); - module_prop_map.insert("id".to_owned(), id.to_owned()); - } - _ => { - info!("Failed to get module id from dir name"); - continue; - } + if let Some(id) = entry.file_name().to_str() { + info!("Use dir name as module id: {id}"); + module_prop_map.insert("id".to_owned(), id.to_owned()); + } else { + info!("Failed to get module id from dir name"); + continue; } } @@ -739,7 +732,8 @@ fn _list_modules(path: &str) -> Vec> { .iter() .filter_map(|(k, v)| { if k.starts_with("manage.") && crate::module_config::parse_bool_config(v) { - k.strip_prefix("manage.").map(|f| f.to_string()) + k.strip_prefix("manage.") + .map(std::string::ToString::to_string) } else { None } @@ -758,7 +752,7 @@ fn _list_modules(path: &str) -> Vec> { } pub fn list_modules() -> Result<()> { - let modules = _list_modules(defs::MODULE_DIR); + let modules = list_module(defs::MODULE_DIR); println!("{}", serde_json::to_string_pretty(&modules)?); Ok(()) } @@ -771,35 +765,31 @@ pub fn get_managed_features() -> Result>> { foreach_active_module(|module_path| { // Get module ID - let module_id = match module_path.file_name().and_then(|n| n.to_str()) { - Some(id) => id, - None => { - warn!( - "Failed to get module id from path: {}", - module_path.display() - ); - return Ok(()); - } + let Some(module_id) = module_path.file_name().and_then(|n| n.to_str()) else { + warn!( + "Failed to get module id from path: {}", + module_path.display() + ); + return Ok(()); }; // Read module config let config = match crate::module_config::merge_configs(module_id) { Ok(c) => c, Err(e) => { - warn!("Failed to merge configs for module '{}': {}", module_id, e); + warn!("Failed to merge configs for module '{module_id}': {e}"); return Ok(()); // Skip this module } }; // Extract manage.* config entries let mut feature_list = Vec::new(); - for (key, value) in config.iter() { + for (key, value) in &config { if key.starts_with("manage.") { // Parse feature name if let Some(feature_name) = key.strip_prefix("manage.") && crate::module_config::parse_bool_config(value) { - info!("Module {} manages feature: {}", module_id, feature_name); feature_list.push(feature_name.to_string()); } } diff --git a/userspace/ksud/src/module_config.rs b/userspace/ksud/src/module_config.rs index 90518a39..2b3c70a2 100644 --- a/userspace/ksud/src/module_config.rs +++ b/userspace/ksud/src/module_config.rs @@ -8,6 +8,7 @@ use std::path::{Path, PathBuf}; use crate::defs; use crate::utils::ensure_dir_exists; +#[allow(clippy::unreadable_literal)] const MODULE_CONFIG_MAGIC: u32 = 0x4b53554d; // "KSUM" const MODULE_CONFIG_VERSION: u32 = 1; @@ -23,10 +24,10 @@ pub enum ConfigType { } impl ConfigType { - fn filename(&self) -> &'static str { + const fn filename(self) -> &'static str { match self { - ConfigType::Persist => defs::PERSIST_CONFIG_NAME, - ConfigType::Temp => defs::TEMP_CONFIG_NAME, + Self::Persist => defs::PERSIST_CONFIG_NAME, + Self::Temp => defs::TEMP_CONFIG_NAME, } } } @@ -133,12 +134,12 @@ pub fn load_config(module_id: &str, config_type: ConfigType) -> Result Result Result {:?}", - temp_path, config_path + "Failed to rename config file: {} -> {}", + temp_path.display(), + config_path.display() ) })?; - debug!("Saved {} entries to {:?}", config.len(), config_path); + debug!( + "Saved {} entries to {}", + config.len(), + config_path.display() + ); Ok(()) } @@ -323,7 +329,7 @@ pub fn delete_config_value(module_id: &str, key: &str, config_type: ConfigType) let mut config = load_config(module_id, config_type)?; if config.remove(key).is_none() { - bail!("Key '{}' not found in config", key); + bail!("Key '{key}' not found in config"); } save_config(module_id, config_type, &config)?; @@ -336,8 +342,8 @@ pub fn clear_config(module_id: &str, config_type: ConfigType) -> Result<()> { if config_path.exists() { fs::remove_file(&config_path) - .with_context(|| format!("Failed to remove config file: {:?}", config_path))?; - debug!("Cleared config: {:?}", config_path); + .with_context(|| format!("Failed to remove config file: {}", config_path.display()))?; + debug!("Cleared config: {}", config_path.display()); } Ok(()) @@ -350,10 +356,7 @@ pub fn merge_configs(module_id: &str) -> Result> { let mut merged = match load_config(module_id, ConfigType::Persist) { Ok(config) => config, Err(e) => { - warn!( - "Failed to load persist config for module '{}': {}", - module_id, e - ); + warn!("Failed to load persist config for module '{module_id}': {e}"); HashMap::new() } }; @@ -361,10 +364,7 @@ pub fn merge_configs(module_id: &str) -> Result> { let temp = match load_config(module_id, ConfigType::Temp) { Ok(config) => config, Err(e) => { - warn!( - "Failed to load temp config for module '{}': {}", - module_id, e - ); + warn!("Failed to load temp config for module '{module_id}': {e}"); HashMap::new() } }; @@ -389,7 +389,7 @@ pub fn get_all_module_configs() -> Result Result { - warn!("Failed to load config for module '{}': {}", module_id, e); + warn!("Failed to load config for module '{module_id}': {e}"); // Continue processing other modules } } @@ -428,7 +428,7 @@ pub fn clear_all_temp_configs() -> Result<()> { let mut cleared_count = 0; for entry in fs::read_dir(config_root) - .with_context(|| format!("Failed to read config directory: {:?}", config_root))? + .with_context(|| format!("Failed to read config directory: {}", config_root.display()))? { let entry = entry?; let path = entry.path(); @@ -440,19 +440,19 @@ pub fn clear_all_temp_configs() -> Result<()> { let temp_config = path.join(defs::TEMP_CONFIG_NAME); if temp_config.exists() { match fs::remove_file(&temp_config) { - Ok(_) => { - debug!("Cleared temp config: {:?}", temp_config); + Ok(()) => { + debug!("Cleared temp config: {}", temp_config.display()); cleared_count += 1; } Err(e) => { - warn!("Failed to clear temp config {:?}: {}", temp_config, e); + warn!("Failed to clear temp config {}: {e}", temp_config.display()); } } } } if cleared_count > 0 { - debug!("Cleared {} temp config file(s)", cleared_count); + debug!("Cleared {cleared_count} temp config file(s)"); } Ok(()) @@ -465,9 +465,13 @@ pub fn clear_module_configs(module_id: &str) -> Result<()> { let config_dir = get_config_dir(module_id); if config_dir.exists() { - fs::remove_dir_all(&config_dir) - .with_context(|| format!("Failed to remove config directory: {:?}", config_dir))?; - debug!("Cleared all configs for module: {}", module_id); + fs::remove_dir_all(&config_dir).with_context(|| { + format!( + "Failed to remove config directory: {}", + config_dir.display() + ) + })?; + debug!("Cleared all configs for module: {module_id}"); } Ok(()) diff --git a/userspace/ksud/src/profile.rs b/userspace/ksud/src/profile.rs index 0584f948..94fb8b2e 100644 --- a/userspace/ksud/src/profile.rs +++ b/userspace/ksud/src/profile.rs @@ -50,7 +50,7 @@ pub fn list_templates() -> Result<()> { let template = template.file_name(); if let Some(template) = template.to_str() { println!("{template}"); - }; + } } Ok(()) } @@ -71,9 +71,9 @@ pub fn apply_sepolies() -> Result<()> { }; let sepolicy = sepolicy.path(); if sepolicy::apply_file(&sepolicy).is_ok() { - log::info!("profile sepolicy applied: {sepolicy:?}"); + log::info!("profile sepolicy applied: {}", sepolicy.display()); } else { - log::info!("profile sepolicy apply failed: {sepolicy:?}"); + log::info!("profile sepolicy apply failed: {}", sepolicy.display()); } } Ok(()) diff --git a/userspace/ksud/src/sepolicy.rs b/userspace/ksud/src/sepolicy.rs index 5c4d35f8..f25de52d 100644 --- a/userspace/ksud/src/sepolicy.rs +++ b/userspace/ksud/src/sepolicy.rs @@ -390,11 +390,11 @@ impl TryFrom<&str> for PolicyObject { fn try_from(s: &str) -> Result { anyhow::ensure!(s.len() <= SEPOLICY_MAX_LEN, "policy object too long"); if s == "*" { - return Ok(PolicyObject::All); + return Ok(Self::All); } let mut buf = [0u8; SEPOLICY_MAX_LEN]; buf[..s.len()].copy_from_slice(s.as_bytes()); - Ok(PolicyObject::One(buf)) + Ok(Self::One(buf)) } } @@ -669,7 +669,7 @@ struct FfiPolicy { sepol7: *const ffi::c_char, } -fn to_c_ptr(pol: &PolicyObject) -> *const ffi::c_char { +const fn to_c_ptr(pol: &PolicyObject) -> *const ffi::c_char { match pol { PolicyObject::None | PolicyObject::All => std::ptr::null(), PolicyObject::One(s) => s.as_ptr().cast::(), @@ -677,8 +677,8 @@ fn to_c_ptr(pol: &PolicyObject) -> *const ffi::c_char { } impl From for FfiPolicy { - fn from(policy: AtomicStatement) -> FfiPolicy { - FfiPolicy { + fn from(policy: AtomicStatement) -> Self { + Self { cmd: policy.cmd, subcmd: policy.subcmd, sepol1: to_c_ptr(&policy.sepol1), @@ -700,10 +700,10 @@ fn apply_one_rule<'a>(statement: &'a PolicyStatement<'a>, strict: bool) -> Resul let ffi_policy = FfiPolicy::from(policy); let cmd = crate::ksucalls::SetSepolicyCmd { cmd: 0, - arg: &ffi_policy as *const _ as u64, + arg: &raw const ffi_policy as u64, }; if let Err(e) = crate::ksucalls::set_sepolicy(&cmd) { - log::warn!("apply rule {:?} failed: {}", statement, e); + log::warn!("apply rule {statement:?} failed: {e}"); if strict { return Err(anyhow::anyhow!("apply rule {:?} failed: {}", statement, e)); } diff --git a/userspace/ksud/src/su.rs b/userspace/ksud/src/su.rs index 60a09677..d4f2756e 100644 --- a/userspace/ksud/src/su.rs +++ b/userspace/ksud/src/su.rs @@ -43,7 +43,7 @@ pub fn grant_root(_global_mnt: bool) -> Result<()> { unimplemented!("grant_root is only available on android"); } -fn print_usage(program: &str, opts: Options) { +fn print_usage(program: &str, opts: &Options) { let brief = format!("KernelSU\n\nUsage: {program} [options] [-] [user [argument...]]"); print!("{}", opts.usage(&brief)); } @@ -78,10 +78,9 @@ fn wrap_tty(fd: c_int) { bail!("dup {new_fd} -> {fd} errno: {}", unsafe { *libc::__errno() }); - } else { - unsafe { libc::close(new_fd) }; - Ok(()) } + unsafe { libc::close(new_fd) }; + Ok(()) }; if let Err(e) = inner_fn() { @@ -95,16 +94,16 @@ pub fn root_shell() -> Result<()> { } #[cfg(any(target_os = "linux", target_os = "android"))] +#[allow(clippy::similar_names)] pub fn root_shell() -> Result<()> { // we are root now, this was set in kernel! use anyhow::anyhow; let env_args: Vec = env::args().collect(); let program = env_args[0].clone(); - let args = env_args - .iter() - .position(|arg| arg == "-c") - .map(|i| { + let args = env_args.iter().position(|arg| arg == "-c").map_or_else( + || env_args.clone(), + |i| { let rest = env_args[i + 1..].to_vec(); let mut new_args = env_args[..i].to_vec(); new_args.push("-c".to_string()); @@ -112,8 +111,8 @@ pub fn root_shell() -> Result<()> { new_args.push(rest.join(" ")); } new_args - }) - .unwrap_or_else(|| env_args.clone()); + }, + ); let mut opts = Options::new(); opts.optopt( @@ -169,13 +168,13 @@ pub fn root_shell() -> Result<()> { Result::Ok(m) => m, Err(f) => { println!("{f}"); - print_usage(&program, opts); + print_usage(&program, &opts); std::process::exit(-1); } }; if matches.opt_present("h") { - print_usage(&program, opts); + print_usage(&program, &opts); return Ok(()); } @@ -189,7 +188,9 @@ pub fn root_shell() -> Result<()> { return Ok(()); } - let shell = matches.opt_str("s").unwrap_or("/system/bin/sh".to_string()); + let shell = matches + .opt_str("s") + .unwrap_or_else(|| "/system/bin/sh".to_string()); let mut is_login = matches.opt_present("l"); let preserve_env = matches.opt_present("p"); let mount_master = matches.opt_present("M"); @@ -234,10 +235,7 @@ pub fn root_shell() -> Result<()> { #[cfg(target_arch = "x86_64")] let pw = libc::getpwnam(name.as_ptr() as *const i8).as_ref(); - match pw { - Some(pw) => pw.pw_uid, - None => name.parse::().unwrap_or(0), - } + pw.map_or_else(|| name.parse::().unwrap_or(0), |pw| pw.pw_uid) } } diff --git a/userspace/ksud/src/uid_scanner.rs b/userspace/ksud/src/uid_scanner.rs index 64be9d99..ce1c1ac9 100644 --- a/userspace/ksud/src/uid_scanner.rs +++ b/userspace/ksud/src/uid_scanner.rs @@ -19,28 +19,28 @@ const SERVICE_PATH: &str = "/data/adb/service.d/uid_scanner.sh"; pub fn start_uid_scanner_daemon() -> Result<()> { if !fs::exists(SCANNER_PATH)? { - warn!("uid scanner binary not found at {}", SCANNER_PATH); + warn!("uid scanner binary not found at {SCANNER_PATH}"); return Ok(()); } if let Err(e) = fs::set_permissions(SCANNER_PATH, fs::Permissions::from_mode(0o755)) { - warn!("failed to set permissions for {}: {}", SCANNER_PATH, e); + warn!("failed to set permissions for {SCANNER_PATH}: {e}"); } #[cfg(unix)] { if let Err(e) = fs::create_dir_all(LINK_DIR) { - warn!("failed to create {}: {}", LINK_DIR, e); + warn!("failed to create {LINK_DIR}: {e}"); } else if !fs::exists(LINK_PATH)? { match symlink(SCANNER_PATH, LINK_PATH) { - Ok(_) => info!("created symlink {} -> {}", SCANNER_PATH, LINK_PATH), - Err(e) => warn!("failed to create symlink: {}", e), + Ok(()) => info!("created symlink {SCANNER_PATH} -> {LINK_PATH}"), + Err(e) => warn!("failed to create symlink: {e}"), } } } if let Err(e) = fs::create_dir_all(SERVICE_DIR) { - warn!("failed to create {}: {}", SERVICE_DIR, e); + warn!("failed to create {SERVICE_DIR}: {e}"); } if !fs::exists(SERVICE_PATH)? { @@ -55,8 +55,8 @@ pub fn start_uid_scanner_daemon() -> Result<()> { f.sync_all()?; fs::set_permissions(SERVICE_PATH, fs::Permissions::from_mode(0o755)) }) { - Ok(_) => info!("created service script {}", SERVICE_PATH), - Err(e) => warn!("failed to write {}: {}", SERVICE_PATH, e), + Ok(()) => info!("created service script {SERVICE_PATH}"), + Err(e) => warn!("failed to write {SERVICE_PATH}: {e}"), } } @@ -81,7 +81,7 @@ pub fn start_uid_scanner_daemon() -> Result<()> { info!("uid scanner daemon started with pid: {}", child.id()); std::mem::drop(child); } - Err(e) => warn!("failed to start uid scanner daemon: {}", e), + Err(e) => warn!("failed to start uid scanner daemon: {e}"), } Ok(()) diff --git a/userspace/ksud/src/umount_manager.rs b/userspace/ksud/src/umount_manager.rs index c6711194..3c680c95 100644 --- a/userspace/ksud/src/umount_manager.rs +++ b/userspace/ksud/src/umount_manager.rs @@ -8,6 +8,7 @@ use crate::ksucalls::ksuctl; const MAGIC_NUMBER_HEADER: &[u8; 4] = b"KUMT"; const MAGIC_VERSION: u32 = 1; const CONFIG_FILE: &str = "/data/adb/ksu/.umount"; +#[allow(clippy::unreadable_literal)] const KSU_IOCTL_UMOUNT_MANAGER: u32 = 0xc0004b6b; // _IOC(_IOC_READ|_IOC_WRITE, 'K', 107, 0) #[derive(Clone, Serialize, Deserialize, Debug)] @@ -39,7 +40,7 @@ struct UmountManagerCmd { impl Default for UmountManagerCmd { fn default() -> Self { - UmountManagerCmd { + Self { operation: 0, path: [0; 256], flags: 0, @@ -61,7 +62,7 @@ impl UmountManager { } }; - Ok(UmountManager { + Ok(Self { config, config_path: path, }) @@ -81,7 +82,7 @@ impl UmountManager { let version = u32::from_le_bytes([data[4], data[5], data[6], data[7]]); if version != MAGIC_VERSION { - return Err(anyhow!("Unsupported config version: {}", version)); + return Err(anyhow!("Unsupported config version: {version}")); } let json_data = &data[8..]; @@ -110,7 +111,7 @@ impl UmountManager { pub fn add_entry(&mut self, path: &str, flags: i32) -> Result<()> { let exists = self.config.entries.iter().any(|e| e.path == path); if exists { - return Err(anyhow!("Entry already exists: {}", path)); + return Err(anyhow!("Entry already exists: {path}")); } let entry = UmountEntry { @@ -128,7 +129,7 @@ impl UmountManager { self.config.entries.retain(|e| e.path != path); if before == self.config.entries.len() { - return Err(anyhow!("Entry not found: {}", path)); + return Err(anyhow!("Entry not found: {path}")); } Ok(()) } @@ -137,9 +138,8 @@ impl UmountManager { self.config.entries.clone() } - pub fn clear_custom_entries(&mut self) -> Result<()> { + pub fn clear_custom_entries(&mut self) { self.config.entries.retain(|e| e.is_default); - Ok(()) } pub fn apply_to_kernel(&self) -> Result<()> { @@ -183,7 +183,7 @@ pub fn add_umount_path(path: &str, flags: i32) -> Result<()> { let mut manager = init_umount_manager()?; manager.add_entry(path, flags)?; manager.save_config()?; - println!("✓ Added umount path: {}", path); + println!("✓ Added umount path: {path}"); Ok(()) } @@ -191,7 +191,7 @@ pub fn remove_umount_path(path: &str) -> Result<()> { let mut manager = init_umount_manager()?; manager.remove_entry(path)?; manager.save_config()?; - println!("✓ Removed umount path: {}", path); + println!("✓ Removed umount path: {path}"); Ok(()) } @@ -222,7 +222,7 @@ pub fn list_umount_paths() -> Result<()> { #[cfg(any(target_os = "linux", target_os = "android"))] fn umount_manager_ioctl(cmd: &UmountManagerCmd) -> std::io::Result<()> { let mut ioctl_cmd = *cmd; - ksuctl(KSU_IOCTL_UMOUNT_MANAGER, &mut ioctl_cmd as *mut _)?; + ksuctl(KSU_IOCTL_UMOUNT_MANAGER, &raw mut ioctl_cmd)?; Ok(()) } @@ -233,7 +233,7 @@ pub fn umount_manager_ioctl(_cmd: &UmountManagerCmd) -> std::io::Result<()> { pub fn clear_custom_paths() -> Result<()> { let mut manager = init_umount_manager()?; - manager.clear_custom_entries()?; + manager.clear_custom_entries(); manager.save_config()?; println!("✓ Cleared all custom paths"); Ok(()) @@ -242,7 +242,7 @@ pub fn clear_custom_paths() -> Result<()> { pub fn save_umount_config() -> Result<()> { let manager = init_umount_manager()?; manager.save_config()?; - println!("✓ Configuration saved to: {}", CONFIG_FILE); + println!("✓ Configuration saved to: {CONFIG_FILE}"); Ok(()) }