From 3a37e8c9c5342da54e1a19e2585989129f52da2f Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Sun, 8 Jun 2025 00:44:44 +0800 Subject: [PATCH] Don't clone attributes for magisk symlinks This avoids use existing attributes for su, which will obviously break magisk functions. --- native/src/core/module.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/native/src/core/module.rs b/native/src/core/module.rs index 53e27ef00..05eafa209 100644 --- a/native/src/core/module.rs +++ b/native/src/core/module.rs @@ -92,7 +92,7 @@ impl Drop for PathTracker<'_> { enum FsNode { Directory { children: FsNodeMap }, File { src: Utf8CString }, - Symlink { target: Utf8CString }, + Symlink { target: Utf8CString, is_magisk_bin: bool }, Whiteout, } @@ -125,6 +125,7 @@ impl FsNode { .entry(entry.name().to_string()) .or_insert_with(|| FsNode::Symlink { target: link.to_owned(), + is_magisk_bin: false, }); } else { if entry.is_char_device() { @@ -277,6 +278,7 @@ impl FsNode { entry.name().to_string(), FsNode::Symlink { target: link.to_owned(), + is_magisk_bin: false, }, ); } else { @@ -297,10 +299,11 @@ impl FsNode { } mount_dummy("mount", src, path.tmp, false)?; } - FsNode::Symlink { target } => { + FsNode::Symlink { target, is_magisk_bin } => { module_log!("mklink", path.tmp, target); path.tmp.create_symlink_to(target)?; - if path.real.exists() { + // Avoid cloneing existing su attributes to our su + if !*is_magisk_bin && path.real.exists() { clone_attr(path.real, path.tmp)?; } } @@ -348,18 +351,21 @@ fn inject_magisk_bins(system: &mut FsNode) { "su".to_string(), FsNode::Symlink { target: Utf8CString::from("./magisk"), + is_magisk_bin: true, }, ); children.insert( "resetprop".to_string(), FsNode::Symlink { target: Utf8CString::from("./magisk"), + is_magisk_bin: true, }, ); children.insert( "supolicy".to_string(), FsNode::Symlink { target: Utf8CString::from("./magiskpolicy"), + is_magisk_bin: true, }, ); }