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.
This commit is contained in:
Wang Han 2025-06-16 21:29:17 +08:00 committed by John Wu
parent 1460317ebd
commit 39f2940bd1

View File

@ -83,8 +83,10 @@ pub(crate) fn restore_tmpcon() -> LoggedResult<()> {
let mut path = cstr::buf::default(); let mut path = cstr::buf::default();
let mut dir = Directory::open(tmp)?; let mut dir = Directory::open(tmp)?;
while let Some(ref e) = dir.read()? { while let Some(ref e) = dir.read()? {
e.resolve_path(&mut path)?; if !e.is_symlink() {
path.set_secontext(SYSTEM_CON)?; e.resolve_path(&mut path)?;
path.set_secontext(SYSTEM_CON)?;
}
} }
path.clear(); path.clear();