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

@@ -6,6 +6,7 @@
#include <base.hpp>
#include <socket.hpp>
#include <daemon.hpp>
#include <selinux.hpp>
#include "zygisk.hpp"
@@ -17,7 +18,14 @@ int app_process_main(int argc, char *argv[]) {
char buf[PATH_MAX];
bool zygote = false;
if (auto fp = open_file("/proc/self/attr/current", "r")) {
if (!selinux_enabled()) {
for (int i = 0; i < argc; ++i) {
if (argv[i] == "--zygote"sv) {
zygote = true;
break;
}
}
} else if (auto fp = open_file("/proc/self/attr/current", "r")) {
fscanf(fp.get(), "%s", buf);
zygote = (buf == "u:r:zygote:s0"sv);
}