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

@@ -4,6 +4,7 @@
#include <base.hpp>
#include <selinux.hpp>
#include <flags.h>
using namespace std;
@@ -101,7 +102,23 @@ void setfilecon_at(int dirfd, const char *name, const char *con) {
lsetfilecon(path, con);
}
#if MAGISK_DEBUG
static bool se_state = false;
bool selinux_enabled() {
return se_state;
}
#else
bool selinux_enabled() {
return true;
}
#endif
void enable_selinux() {
#if MAGISK_DEBUG
if (access(SELINUX_MNT, F_OK) != 0)
return;
se_state = true;
#endif
setcon = __setcon;
getfilecon = __getfilecon;
lgetfilecon = __lgetfilecon;