Skip to content

Commit

Permalink
Don't unshare after entering global namespace (tiann#2373)
Browse files Browse the repository at this point in the history
Global namespace is usually used to publicly apply mounts so calling
unshare after entering root namespace is not desired bahavior. This also
keeps -M option same as Magisk.
  • Loading branch information
aviraxp authored and rsuntk committed Jan 24, 2025
1 parent 5df886a commit 9a4e15e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 9 deletions.
1 change: 0 additions & 1 deletion userspace/ksud/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ pub fn run() -> Result<()> {
#[cfg(any(target_os = "linux", target_os = "android"))]
{
utils::switch_mnt_ns(1)?;
utils::unshare_mnt_ns()?;
}
match command {
Module::Install { zip } => module::install_module(&zip),
Expand Down
2 changes: 0 additions & 2 deletions userspace/ksud/src/su.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn grant_root(global_mnt: bool) -> Result<()> {
command.pre_exec(move || {
if global_mnt {
let _ = utils::switch_mnt_ns(1);
let _ = utils::unshare_mnt_ns();
}
Result::Ok(())
})
Expand Down Expand Up @@ -261,7 +260,6 @@ pub fn root_shell() -> Result<()> {
#[cfg(any(target_os = "linux", target_os = "android"))]
if mount_master {
let _ = utils::switch_mnt_ns(1);
let _ = utils::unshare_mnt_ns();
}

set_identity(uid, gid, &groups);
Expand Down
6 changes: 0 additions & 6 deletions userspace/ksud/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ pub fn switch_mnt_ns(pid: i32) -> Result<()> {
Ok(())
}

#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn unshare_mnt_ns() -> Result<()> {
unshare(UnshareFlags::NEWNS)?;
Ok(())
}

fn switch_cgroup(grp: &str, pid: u32) {
let path = Path::new(grp).join("cgroup.procs");
if !path.exists() {
Expand Down

0 comments on commit 9a4e15e

Please sign in to comment.