diff --git a/userspace/ksud/Cargo.toml b/userspace/ksud/Cargo.toml index 9c5dff68..fc9320ca 100644 --- a/userspace/ksud/Cargo.toml +++ b/userspace/ksud/Cargo.toml @@ -46,4 +46,4 @@ android_logger = "0.13" [profile.release] strip = true opt-level = "z" -lto = true +# lto = true diff --git a/userspace/ksud/src/ksu.rs b/userspace/ksud/src/ksu.rs index e386f5ba..6045a611 100644 --- a/userspace/ksud/src/ksu.rs +++ b/userspace/ksud/src/ksu.rs @@ -161,22 +161,14 @@ pub fn root_shell() -> Result<()> { let preserve_env = matches.opt_present("p"); let mount_master = matches.opt_present("M"); + // we've make sure that -c is the last option and it already contains the whole command, no need to construct it again + let args = matches + .opt_str("c") + .map(|cmd| vec!["-c".to_string(), cmd]) + .unwrap_or_default(); + let mut free_idx = 0; - let command = matches.opt_str("c").map(|cmd| { - free_idx = matches.free.len(); - let mut cmds = vec![]; - cmds.push(cmd); - cmds.extend(matches.free.clone()); - cmds - }); - - let mut args = vec![]; - if let Some(cmd) = command { - args.push("-c".to_string()); - args.push(cmd.join(" ")); - }; - - if free_idx < matches.free.len() && matches.free[free_idx] == "-" { + if !matches.free.is_empty() && matches.free[free_idx] == "-" { is_login = true; free_idx += 1; }