Support SELinux disabled on debug builds

This commit is contained in:
topjohnwu
2022-05-31 22:24:13 -07:00
parent d7776f6597
commit d4fe8632ec
6 changed files with 40 additions and 8 deletions

View File

@@ -66,6 +66,8 @@ static void restore_magiskcon(int dirfd) {
}
void restorecon() {
if (!selinux_enabled())
return;
int fd = xopen(SELINUX_CONTEXT, O_WRONLY | O_CLOEXEC);
if (write(fd, ADB_CON, sizeof(ADB_CON)) >= 0)
lsetfilecon(SECURE_DIR, ADB_CON);
@@ -76,6 +78,8 @@ void restorecon() {
}
void restore_tmpcon() {
if (!selinux_enabled())
return;
if (MAGISKTMP == "/sbin")
setfilecon(MAGISKTMP.data(), ROOT_CON);
else