Do not support systems without SELinux

This commit is contained in:
topjohnwu
2023-09-25 15:10:54 -07:00
parent ec115cd7e3
commit 5d07d0b964
6 changed files with 3 additions and 31 deletions

View File

@@ -251,7 +251,7 @@ static void handle_request(pollfd *pfd) {
}
break;
case MainRequest::ZYGISK:
if (!is_zygote && selinux_enabled()) {
if (!is_zygote) {
// Invalid client context
write_int(client, MainResponse::ACCESS_DENIED);
goto done;

View File

@@ -64,8 +64,6 @@ static void restore_syscon(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,8 +74,6 @@ void restorecon() {
}
void restore_tmpcon() {
if (!selinux_enabled())
return;
if (MAGISKTMP == "/sbin")
setfilecon(MAGISKTMP.data(), ROOT_CON);
else

View File

@@ -458,7 +458,7 @@ void su_daemon_handler(int client, const sock_cred *cred) {
sigset_t block_set;
sigemptyset(&block_set);
sigprocmask(SIG_SETMASK, &block_set, nullptr);
if (!ctx.req.context.empty() && selinux_enabled()) {
if (!ctx.req.context.empty()) {
auto f = xopen_file("/proc/self/attr/exec", "we");
if (f) fprintf(f.get(), "%s", ctx.req.context.data());
}