From 39f2940bd1561e8384f1435b791271d1c988543a Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Mon, 16 Jun 2025 21:29:17 +0800 Subject: [PATCH] Skip symlink in restore_tmpcon() If magisktmp is /sbin, there may exist files which is symlink to files in root dir. As root is RO, setcontext will fail and break iterating loop. --- native/src/core/selinux.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/native/src/core/selinux.rs b/native/src/core/selinux.rs index 58a7ae326..feeeabd64 100644 --- a/native/src/core/selinux.rs +++ b/native/src/core/selinux.rs @@ -83,8 +83,10 @@ pub(crate) fn restore_tmpcon() -> LoggedResult<()> { let mut path = cstr::buf::default(); let mut dir = Directory::open(tmp)?; while let Some(ref e) = dir.read()? { - e.resolve_path(&mut path)?; - path.set_secontext(SYSTEM_CON)?; + if !e.is_symlink() { + e.resolve_path(&mut path)?; + path.set_secontext(SYSTEM_CON)?; + } } path.clear();