You've already forked KernelSU
mirror of
https://github.com/tiann/KernelSU.git
synced 2025-08-27 23:46:34 +00:00
ksud: make clippy happy (#2683)
e1be06240d/clippy_lints/src/format_args.rs (L168)
This commit is contained in:
53
userspace/ksud/Cargo.lock
generated
53
userspace/ksud/Cargo.lock
generated
@@ -483,17 +483,6 @@ dependencies = [
|
|||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "displaydoc"
|
|
||||||
version = "0.2.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.15.0"
|
version = "1.15.0"
|
||||||
@@ -595,6 +584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
|
checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
|
"libz-rs-sys",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -682,7 +672,7 @@ dependencies = [
|
|||||||
"errno 0.2.8",
|
"errno 0.2.8",
|
||||||
"libc",
|
"libc",
|
||||||
"memmap",
|
"memmap",
|
||||||
"thiserror 1.0.69",
|
"thiserror",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -883,6 +873,15 @@ version = "0.2.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libz-rs-sys"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "172a788537a2221661b480fee8dc5f96c580eb34fa88764d3205dc356c7e4221"
|
||||||
|
dependencies = [
|
||||||
|
"zlib-rs",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.15"
|
version = "0.4.15"
|
||||||
@@ -1311,16 +1310,7 @@ version = "1.0.69"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl 1.0.69",
|
"thiserror-impl",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror"
|
|
||||||
version = "2.0.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
|
|
||||||
dependencies = [
|
|
||||||
"thiserror-impl 2.0.11",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1334,17 +1324,6 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror-impl"
|
|
||||||
version = "2.0.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.41"
|
version = "0.3.41"
|
||||||
@@ -1725,12 +1704,10 @@ dependencies = [
|
|||||||
"arbitrary",
|
"arbitrary",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"deflate64",
|
"deflate64",
|
||||||
"displaydoc",
|
|
||||||
"flate2",
|
"flate2",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"lzma-rs",
|
"lzma-rs",
|
||||||
"memchr",
|
"memchr",
|
||||||
"thiserror 2.0.11",
|
|
||||||
"time",
|
"time",
|
||||||
"xz2",
|
"xz2",
|
||||||
"zopfli",
|
"zopfli",
|
||||||
@@ -1745,6 +1722,12 @@ dependencies = [
|
|||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zlib-rs"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "626bd9fa9734751fc50d6060752170984d7053f5a39061f524cda68023d4db8a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zopfli"
|
name = "zopfli"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ fn get_git_version() -> Result<(u32, String), std::io::Error> {
|
|||||||
let version_code: u32 = version_code
|
let version_code: u32 = version_code
|
||||||
.trim()
|
.trim()
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Failed to parse git count"))?;
|
.map_err(|_| std::io::Error::other("Failed to parse git count"))?;
|
||||||
let version_code = 10000 + 200 + version_code; // For historical reasons
|
let version_code = 10000 + 200 + version_code; // For historical reasons
|
||||||
|
|
||||||
let version_name = String::from_utf8(
|
let version_name = String::from_utf8(
|
||||||
@@ -23,12 +23,7 @@ fn get_git_version() -> Result<(u32, String), std::io::Error> {
|
|||||||
.output()?
|
.output()?
|
||||||
.stdout,
|
.stdout,
|
||||||
)
|
)
|
||||||
.map_err(|_| {
|
.map_err(|_| std::io::Error::other("Failed to read git describe stdout"))?;
|
||||||
std::io::Error::new(
|
|
||||||
std::io::ErrorKind::Other,
|
|
||||||
"Failed to read git describe stdout",
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
let version_name = version_name.trim_start_matches('v').to_string();
|
let version_name = version_name.trim_start_matches('v').to_string();
|
||||||
Ok((version_code, version_name))
|
Ok((version_code, version_name))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ pub fn restore(
|
|||||||
do_cpio_cmd(
|
do_cpio_cmd(
|
||||||
&magiskboot,
|
&magiskboot,
|
||||||
workdir,
|
workdir,
|
||||||
&format!("extract {0} {0}", BACKUP_FILENAME),
|
&format!("extract {BACKUP_FILENAME} {BACKUP_FILENAME}"),
|
||||||
)?;
|
)?;
|
||||||
let sha = std::fs::read(workdir.join(BACKUP_FILENAME))?;
|
let sha = std::fs::read(workdir.join(BACKUP_FILENAME))?;
|
||||||
let sha = String::from_utf8(sha)?;
|
let sha = String::from_utf8(sha)?;
|
||||||
@@ -384,7 +384,7 @@ fn do_patch(
|
|||||||
match get_current_kmi() {
|
match get_current_kmi() {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("- {}", e);
|
println!("- {e}");
|
||||||
if let Some(image_path) = &image {
|
if let Some(image_path) = &image {
|
||||||
println!(
|
println!(
|
||||||
"- Trying to auto detect KMI version for {}",
|
"- Trying to auto detect KMI version for {}",
|
||||||
@@ -542,7 +542,7 @@ fn calculate_sha1(file_path: impl AsRef<Path>) -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let result = hasher.finalize();
|
let result = hasher.finalize();
|
||||||
Ok(format!("{:x}", result))
|
Ok(format!("{result:x}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
@@ -558,7 +558,7 @@ fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
|||||||
do_cpio_cmd(
|
do_cpio_cmd(
|
||||||
magiskboot,
|
magiskboot,
|
||||||
workdir,
|
workdir,
|
||||||
&format!("add 0755 {0} {0}", BACKUP_FILENAME),
|
&format!("add 0755 {BACKUP_FILENAME} {BACKUP_FILENAME}"),
|
||||||
)?;
|
)?;
|
||||||
println!("- Stock image has been backup to");
|
println!("- Stock image has been backup to");
|
||||||
println!("- {target}");
|
println!("- {target}");
|
||||||
@@ -568,7 +568,7 @@ fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
|||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
fn clean_backup(sha1: &str) -> Result<()> {
|
fn clean_backup(sha1: &str) -> Result<()> {
|
||||||
println!("- Clean up backup");
|
println!("- Clean up backup");
|
||||||
let backup_name = format!("{}{}", KSU_BACKUP_FILE_PREFIX, sha1);
|
let backup_name = format!("{KSU_BACKUP_FILE_PREFIX}{sha1}");
|
||||||
let dir = std::fs::read_dir(defs::KSU_BACKUP_DIR)?;
|
let dir = std::fs::read_dir(defs::KSU_BACKUP_DIR)?;
|
||||||
for entry in dir.flatten() {
|
for entry in dir.flatten() {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|||||||
@@ -374,13 +374,13 @@ pub fn run() -> Result<()> {
|
|||||||
Commands::BootInfo { command } => match command {
|
Commands::BootInfo { command } => match command {
|
||||||
BootInfo::CurrentKmi => {
|
BootInfo::CurrentKmi => {
|
||||||
let kmi = crate::boot_patch::get_current_kmi()?;
|
let kmi = crate::boot_patch::get_current_kmi()?;
|
||||||
println!("{}", kmi);
|
println!("{kmi}");
|
||||||
// return here to avoid printing the error message
|
// return here to avoid printing the error message
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
BootInfo::SupportedKmi => {
|
BootInfo::SupportedKmi => {
|
||||||
let kmi = crate::assets::list_supported_kmi()?;
|
let kmi = crate::assets::list_supported_kmi()?;
|
||||||
kmi.iter().for_each(|kmi| println!("{}", kmi));
|
kmi.iter().for_each(|kmi| println!("{kmi}"));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -392,7 +392,7 @@ pub fn run() -> Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = &result {
|
if let Err(e) = &result {
|
||||||
log::error!("Error: {:?}", e);
|
log::error!("Error: {e:?}");
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ fn set_kernel_param(uid: u32) -> Result<()> {
|
|||||||
fn get_pkg_uid(pkg: &str) -> Result<u32> {
|
fn get_pkg_uid(pkg: &str) -> Result<u32> {
|
||||||
// stat /data/data/<pkg>
|
// stat /data/data/<pkg>
|
||||||
let uid = rustix::fs::stat(format!("/data/data/{pkg}"))
|
let uid = rustix::fs::stat(format!("/data/data/{pkg}"))
|
||||||
.with_context(|| format!("stat /data/data/{}", pkg))?
|
.with_context(|| format!("stat /data/data/{pkg}"))?
|
||||||
.st_uid;
|
.st_uid;
|
||||||
Ok(uid)
|
Ok(uid)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ pub fn mount_modules_systemlessly(module_dir: &str) -> Result<()> {
|
|||||||
|
|
||||||
// mount /system first
|
// mount /system first
|
||||||
if let Err(e) = mount_partition("system", &system_lowerdir) {
|
if let Err(e) = mount_partition("system", &system_lowerdir) {
|
||||||
warn!("mount system failed: {:#}", e);
|
warn!("mount system failed: {e:#}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount other partitions
|
// mount other partitions
|
||||||
for (k, v) in partition_lowerdir {
|
for (k, v) in partition_lowerdir {
|
||||||
if let Err(e) = mount_partition(&k, &v) {
|
if let Err(e) = mount_partition(&k, &v) {
|
||||||
warn!("mount {k} failed: {:#}", e);
|
warn!("mount {k} failed: {e:#}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ pub fn on_post_data_fs() -> Result<()> {
|
|||||||
} else {
|
} else {
|
||||||
// Then exec common post-fs-data scripts
|
// Then exec common post-fs-data scripts
|
||||||
if let Err(e) = crate::module::exec_common_scripts("post-fs-data.d", true) {
|
if let Err(e) = crate::module::exec_common_scripts("post-fs-data.d", true) {
|
||||||
warn!("exec common post-fs-data scripts failed: {}", e);
|
warn!("exec common post-fs-data scripts failed: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,17 +168,17 @@ pub fn on_post_data_fs() -> Result<()> {
|
|||||||
if safe_mode {
|
if safe_mode {
|
||||||
warn!("safe mode, skip post-fs-data scripts and disable all modules!");
|
warn!("safe mode, skip post-fs-data scripts and disable all modules!");
|
||||||
if let Err(e) = crate::module::disable_all_modules() {
|
if let Err(e) = crate::module::disable_all_modules() {
|
||||||
warn!("disable all modules failed: {}", e);
|
warn!("disable all modules failed: {e}");
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = prune_modules() {
|
if let Err(e) = prune_modules() {
|
||||||
warn!("prune modules failed: {}", e);
|
warn!("prune modules failed: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = restorecon::restorecon() {
|
if let Err(e) = restorecon::restorecon() {
|
||||||
warn!("restorecon failed: {}", e);
|
warn!("restorecon failed: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// load sepolicy.rule
|
// load sepolicy.rule
|
||||||
@@ -187,28 +187,28 @@ pub fn on_post_data_fs() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = crate::profile::apply_sepolies() {
|
if let Err(e) = crate::profile::apply_sepolies() {
|
||||||
warn!("apply root profile sepolicy failed: {}", e);
|
warn!("apply root profile sepolicy failed: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount temp dir
|
// mount temp dir
|
||||||
if let Err(e) = mount::mount_tmpfs(defs::TEMP_DIR) {
|
if let Err(e) = mount::mount_tmpfs(defs::TEMP_DIR) {
|
||||||
warn!("do temp dir mount failed: {}", e);
|
warn!("do temp dir mount failed: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec modules post-fs-data scripts
|
// exec modules post-fs-data scripts
|
||||||
// TODO: Add timeout
|
// TODO: Add timeout
|
||||||
if let Err(e) = crate::module::exec_stage_script("post-fs-data", true) {
|
if let Err(e) = crate::module::exec_stage_script("post-fs-data", true) {
|
||||||
warn!("exec post-fs-data scripts failed: {}", e);
|
warn!("exec post-fs-data scripts failed: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// load system.prop
|
// load system.prop
|
||||||
if let Err(e) = crate::module::load_system_prop() {
|
if let Err(e) = crate::module::load_system_prop() {
|
||||||
warn!("load system.prop failed: {}", e);
|
warn!("load system.prop failed: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount module systemlessly by overlay
|
// mount module systemlessly by overlay
|
||||||
if let Err(e) = mount_modules_systemlessly(module_dir) {
|
if let Err(e) = mount_modules_systemlessly(module_dir) {
|
||||||
warn!("do systemless mount failed: {}", e);
|
warn!("do systemless mount failed: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
run_stage("post-mount", true);
|
run_stage("post-mount", true);
|
||||||
@@ -298,7 +298,7 @@ fn catch_bootlog(logname: &str, command: Vec<&str>) -> Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
warn!("Failed to start logcat: {:#}", e);
|
warn!("Failed to start logcat: {e:#}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ pub fn prune_modules() -> Result<()> {
|
|||||||
let uninstaller = module.join("uninstall.sh");
|
let uninstaller = module.join("uninstall.sh");
|
||||||
if uninstaller.exists() {
|
if uninstaller.exists() {
|
||||||
if let Err(e) = exec_script(uninstaller, true) {
|
if let Err(e) = exec_script(uninstaller, true) {
|
||||||
warn!("Failed to exec uninstaller: {}", e);
|
warn!("Failed to exec uninstaller: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ fn _install_module(zip: &str) -> Result<()> {
|
|||||||
module_prop.insert(k, v);
|
module_prop.insert(k, v);
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
info!("module prop: {:?}", module_prop);
|
info!("module prop: {module_prop:?}");
|
||||||
|
|
||||||
let Some(module_id) = module_prop.get("id") else {
|
let Some(module_id) = module_prop.get("id") else {
|
||||||
bail!("module id not found in module.prop!");
|
bail!("module id not found in module.prop!");
|
||||||
@@ -440,13 +440,13 @@ fn _install_module(zip: &str) -> Result<()> {
|
|||||||
|
|
||||||
let _dontdrop = mount::AutoMountExt4::try_new(tmp_module_img, module_update_tmp_dir, true)?;
|
let _dontdrop = mount::AutoMountExt4::try_new(tmp_module_img, module_update_tmp_dir, true)?;
|
||||||
|
|
||||||
info!("mounted {} to {}", tmp_module_img, module_update_tmp_dir);
|
info!("mounted {tmp_module_img} to {module_update_tmp_dir}");
|
||||||
|
|
||||||
setsyscon(module_update_tmp_dir)?;
|
setsyscon(module_update_tmp_dir)?;
|
||||||
|
|
||||||
let module_dir = format!("{module_update_tmp_dir}/{module_id}");
|
let module_dir = format!("{module_update_tmp_dir}/{module_id}");
|
||||||
ensure_clean_dir(&module_dir)?;
|
ensure_clean_dir(&module_dir)?;
|
||||||
info!("module dir: {}", module_dir);
|
info!("module dir: {module_dir}");
|
||||||
|
|
||||||
// unzip the image and move it to modules_update/<id> dir
|
// unzip the image and move it to modules_update/<id> dir
|
||||||
let file = File::open(zip)?;
|
let file = File::open(zip)?;
|
||||||
@@ -584,7 +584,7 @@ pub fn uninstall_module(id: &str) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_action(id: &str) -> Result<()> {
|
pub fn run_action(id: &str) -> Result<()> {
|
||||||
let action_script_path = format!("/data/adb/modules/{}/action.sh", id);
|
let action_script_path = format!("/data/adb/modules/{id}/action.sh");
|
||||||
exec_script(&action_script_path, true)
|
exec_script(&action_script_path, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,11 +674,11 @@ fn _list_modules(path: &str) -> Vec<HashMap<String, String>> {
|
|||||||
if !module_prop_map.contains_key("id") || module_prop_map["id"].is_empty() {
|
if !module_prop_map.contains_key("id") || module_prop_map["id"].is_empty() {
|
||||||
match entry.file_name().to_str() {
|
match entry.file_name().to_str() {
|
||||||
Some(id) => {
|
Some(id) => {
|
||||||
info!("Use dir name as module id: {}", id);
|
info!("Use dir name as module id: {id}");
|
||||||
module_prop_map.insert("id".to_owned(), id.to_owned());
|
module_prop_map.insert("id".to_owned(), id.to_owned());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
info!("Failed to get module id: {:?}", module_prop);
|
info!("Failed to get module id: {module_prop:?}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ pub fn mount_overlayfs(
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
warn!("fsopen mount failed: {:#}, fallback to mount", e);
|
warn!("fsopen mount failed: {e:#}, fallback to mount");
|
||||||
let mut data = format!("lowerdir={lowerdir_config}");
|
let mut data = format!("lowerdir={lowerdir_config}");
|
||||||
if let (Some(upperdir), Some(workdir)) = (upperdir, workdir) {
|
if let (Some(upperdir), Some(workdir)) = (upperdir, workdir) {
|
||||||
data = format!("{data},upperdir={upperdir},workdir={workdir}");
|
data = format!("{data},upperdir={upperdir},workdir={workdir}");
|
||||||
@@ -225,7 +225,7 @@ fn mount_overlay_child(
|
|||||||
}
|
}
|
||||||
// merge modules and stock
|
// merge modules and stock
|
||||||
if let Err(e) = mount_overlayfs(&lower_dirs, stock_root, None, None, mount_point) {
|
if let Err(e) = mount_overlayfs(&lower_dirs, stock_root, None, None, mount_point) {
|
||||||
warn!("failed: {:#}, fallback to bind mount", e);
|
warn!("failed: {e:#}, fallback to bind mount");
|
||||||
bind_mount(stock_root, mount_point)?;
|
bind_mount(stock_root, mount_point)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -238,7 +238,7 @@ pub fn mount_overlay(
|
|||||||
workdir: Option<PathBuf>,
|
workdir: Option<PathBuf>,
|
||||||
upperdir: Option<PathBuf>,
|
upperdir: Option<PathBuf>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
info!("mount overlay for {}", root);
|
info!("mount overlay for {root}");
|
||||||
std::env::set_current_dir(root).with_context(|| format!("failed to chdir to {root}"))?;
|
std::env::set_current_dir(root).with_context(|| format!("failed to chdir to {root}"))?;
|
||||||
let stock_root = ".";
|
let stock_root = ".";
|
||||||
|
|
||||||
@@ -269,10 +269,7 @@ pub fn mount_overlay(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Err(e) = mount_overlay_child(mount_point, &relative, module_roots, &stock_root) {
|
if let Err(e) = mount_overlay_child(mount_point, &relative, module_roots, &stock_root) {
|
||||||
warn!(
|
warn!("failed to mount overlay for child {mount_point}: {e:#}, revert");
|
||||||
"failed to mount overlay for child {}: {:#}, revert",
|
|
||||||
mount_point, e
|
|
||||||
);
|
|
||||||
umount_dir(root).with_context(|| format!("failed to revert {root}"))?;
|
umount_dir(root).with_context(|| format!("failed to revert {root}"))?;
|
||||||
bail!(e);
|
bail!(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ pub fn apply_sepolies() -> Result<()> {
|
|||||||
};
|
};
|
||||||
let sepolicy = sepolicy.path();
|
let sepolicy = sepolicy.path();
|
||||||
if sepolicy::apply_file(&sepolicy).is_ok() {
|
if sepolicy::apply_file(&sepolicy).is_ok() {
|
||||||
log::info!("profile sepolicy applied: {:?}", sepolicy);
|
log::info!("profile sepolicy applied: {sepolicy:?}");
|
||||||
} else {
|
} else {
|
||||||
log::info!("profile sepolicy apply failed: {:?}", sepolicy);
|
log::info!("profile sepolicy apply failed: {sepolicy:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -697,7 +697,7 @@ fn apply_one_rule<'a>(statement: &'a PolicyStatement<'a>, strict: bool) -> Resul
|
|||||||
|
|
||||||
for policy in policies {
|
for policy in policies {
|
||||||
if !rustix::process::ksu_set_policy(&FfiPolicy::from(policy)) {
|
if !rustix::process::ksu_set_policy(&FfiPolicy::from(policy)) {
|
||||||
log::warn!("apply rule: {:?} failed.", statement);
|
log::warn!("apply rule: {statement:?} failed.");
|
||||||
if strict {
|
if strict {
|
||||||
return Err(anyhow::anyhow!("apply rule {:?} failed.", statement));
|
return Err(anyhow::anyhow!("apply rule {:?} failed.", statement));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ pub fn is_safe_mode() -> bool {
|
|||||||
|| getprop("ro.sys.safemode")
|
|| getprop("ro.sys.safemode")
|
||||||
.filter(|prop| prop == "1")
|
.filter(|prop| prop == "1")
|
||||||
.is_some();
|
.is_some();
|
||||||
log::info!("safemode: {}", safemode);
|
log::info!("safemode: {safemode}");
|
||||||
if safemode {
|
if safemode {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let safemode = ksucalls::check_kernel_safemode();
|
let safemode = ksucalls::check_kernel_safemode();
|
||||||
log::info!("kernel_safemode: {}", safemode);
|
log::info!("kernel_safemode: {safemode}");
|
||||||
safemode
|
safemode
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ fn copy_xattrs(src_path: impl AsRef<Path>, dest_path: impl AsRef<Path>) -> Resul
|
|||||||
if let Err(e) =
|
if let Err(e) =
|
||||||
extattr::lsetxattr(dest_path.as_ref(), &xattr, &value, extattr::Flags::empty())
|
extattr::lsetxattr(dest_path.as_ref(), &xattr, &value, extattr::Flags::empty())
|
||||||
{
|
{
|
||||||
log::warn!("Failed to set xattr: {}", e);
|
log::warn!("Failed to set xattr: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -336,7 +336,7 @@ pub fn copy_module_files(source: impl AsRef<Path>, destination: impl AsRef<Path>
|
|||||||
std::fs::remove_file(&dest_path).context("Failed to remove file")?;
|
std::fs::remove_file(&dest_path).context("Failed to remove file")?;
|
||||||
}
|
}
|
||||||
let target = std::fs::read_link(entry.path()).context("Failed to read symlink")?;
|
let target = std::fs::read_link(entry.path()).context("Failed to read symlink")?;
|
||||||
log::info!("Symlink: {:?} -> {:?}", dest_path, target);
|
log::info!("Symlink: {dest_path:?} -> {target:?}");
|
||||||
std::os::unix::fs::symlink(target, &dest_path).context("Failed to create symlink")?;
|
std::os::unix::fs::symlink(target, &dest_path).context("Failed to create symlink")?;
|
||||||
copy_xattrs(&source_path, &dest_path)?;
|
copy_xattrs(&source_path, &dest_path)?;
|
||||||
} else if entry.file_type().is_dir() {
|
} else if entry.file_type().is_dir() {
|
||||||
|
|||||||
Reference in New Issue
Block a user