From 910a36fdc19eab87cf545ec513af54f4d0d9212d Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 20 Jul 2022 19:28:38 -0700 Subject: [PATCH] Make sepolicy.rules relative if possible --- native/jni/init/mount.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/native/jni/init/mount.cpp b/native/jni/init/mount.cpp index cd86b930d..b82f7d530 100644 --- a/native/jni/init/mount.cpp +++ b/native/jni/init/mount.cpp @@ -202,7 +202,15 @@ persist: success: // Create symlinks so we don't need to go through this logic again strcpy(p, "/sepolicy.rules"); - xsymlink(custom_rules_dir.data(), path); + if (char *rel = strstr(custom_rules_dir.data(), MIRRDIR)) { + // Create symlink with relative path + char s[128]; + s[0] = '.'; + strlcpy(s + 1, rel + sizeof(MIRRDIR) - 1, sizeof(s) - 1); + xsymlink(s, path); + } else { + xsymlink(custom_rules_dir.data(), path); + } } bool LegacySARInit::mount_system_root() {