ksud: fix post-fs-data.sh and service.sh may be not executed

This commit is contained in:
tiann 2023-02-01 20:28:17 +08:00
parent 85bf01eb65
commit d8042a36c3
No known key found for this signature in database
GPG Key ID: 6D3F65FFD9559C06
2 changed files with 10 additions and 4 deletions

View File

@ -155,7 +155,9 @@ pub fn on_post_data_fs() -> Result<()> {
pub fn on_services() -> Result<()> {
// exec modules service.sh scripts
if !crate::utils::is_safe_mode() {
let _ = crate::module::exec_services();
if let Err(e) = crate::module::exec_services() {
warn!("exec service scripts failed: {}", e);
}
} else {
warn!("safe mode, skip module service scripts");
}

View File

@ -9,7 +9,7 @@ use crate::{
use const_format::concatcp;
use java_properties::PropertiesIter;
use log::{info, warn};
use log::{info, warn, debug};
use std::{
collections::HashMap,
env::var as env_var,
@ -216,10 +216,12 @@ pub fn exec_post_fs_data() -> Result<()> {
let mut command_new;
let mut command;
if is_executable(&post_fs_data) {
if !is_executable(&post_fs_data) {
debug!("{} is not executable, use /system/bin/sh!", post_fs_data.display());
command_new = Command::new("sh");
command = command_new.arg(&post_fs_data);
} else {
debug!("{} is executable, exec directly!", post_fs_data.display());
command_new = Command::new(&post_fs_data);
command = &mut command_new;
};
@ -267,10 +269,12 @@ pub fn exec_services() -> Result<()> {
let mut command_new;
let mut command;
if is_executable(&service) {
if !is_executable(&service) {
debug!("{} is not executable, use /system/bin/sh!", service.display());
command_new = Command::new("sh");
command = command_new.arg(&service);
} else {
debug!("{} is executable, exec directly!", service.display());
command_new = Command::new(&service);
command = &mut command_new;
};