Migrate selinux.cpp to selinux.rs

This commit is contained in:
topjohnwu
2025-04-28 17:22:14 -07:00
committed by John Wu
parent c7d1af9805
commit 73840f8721
19 changed files with 172 additions and 181 deletions
+10 -3
View File
@@ -8,7 +8,6 @@
#include <consts.hpp>
#include <base.hpp>
#include <core.hpp>
#include <selinux.hpp>
#include <flags.h>
using namespace std;
@@ -339,6 +338,16 @@ static void switch_cgroup(const char *cgroup, int pid) {
close(fd);
}
static int setcon(const char *con) {
int fd = open("/proc/self/attr/current", O_WRONLY | O_CLOEXEC);
if (fd < 0)
return fd;
size_t len = strlen(con) + 1;
int rc = write(fd, con, len);
close(fd);
return rc != len;
}
static void daemon_entry() {
android_logging();
@@ -383,8 +392,6 @@ static void daemon_entry() {
set_prop("ro.vendor.mtk_model", "0");
}
restore_tmpcon();
// Cleanups
const char *tmp = get_magisk_tmp();
char path[64];