ksud: fmt & tidy
This commit is contained in:
@@ -5,7 +5,7 @@ use std::{
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use crate::defs;
|
||||
use crate::{assets, defs, ksucalls, restorecon};
|
||||
use std::fs::metadata;
|
||||
#[allow(unused_imports)]
|
||||
use std::fs::{set_permissions, Permissions};
|
||||
@@ -16,6 +16,7 @@ use hole_punch::*;
|
||||
use std::io::{Read, Seek, SeekFrom};
|
||||
|
||||
use jwalk::WalkDir;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use rustix::{
|
||||
@@ -108,7 +109,7 @@ pub fn is_safe_mode() -> bool {
|
||||
if safemode {
|
||||
return true;
|
||||
}
|
||||
let safemode = crate::ksu::check_kernel_safemode();
|
||||
let safemode = ksucalls::check_kernel_safemode();
|
||||
log::info!("kernel_safemode: {}", safemode);
|
||||
safemode
|
||||
}
|
||||
@@ -193,6 +194,29 @@ pub fn get_tmp_path() -> &'static str {
|
||||
""
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn link_ksud_to_bin() -> Result<()> {
|
||||
let ksu_bin = PathBuf::from(defs::DAEMON_PATH);
|
||||
let ksu_bin_link = PathBuf::from(defs::DAEMON_LINK_PATH);
|
||||
if ksu_bin.exists() && !ksu_bin_link.exists() {
|
||||
std::os::unix::fs::symlink(&ksu_bin, &ksu_bin_link)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn install() -> Result<()> {
|
||||
ensure_dir_exists(defs::ADB_DIR)?;
|
||||
std::fs::copy("/proc/self/exe", defs::DAEMON_PATH)?;
|
||||
restorecon::lsetfilecon(defs::DAEMON_PATH, restorecon::ADB_CON)?;
|
||||
// install binary assets
|
||||
assets::ensure_binaries(false).with_context(|| "Failed to extract assets")?;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
link_ksud_to_bin()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// TODO: use libxcp to improve the speed if cross's MSRV is 1.70
|
||||
pub fn copy_sparse_file<P: AsRef<Path>, Q: AsRef<Path>>(
|
||||
src: P,
|
||||
|
||||
Reference in New Issue
Block a user