mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-16 09:52:31 +00:00
@@ -156,6 +156,8 @@ static void daemon_entry(int ppid) {
|
||||
setsid();
|
||||
setcon("u:r:" SEPOL_PROC_DOMAIN ":s0");
|
||||
|
||||
LOGI(NAME_WITH_VER(Magisk) " daemon started\n");
|
||||
|
||||
// Make sure ppid is not in acct
|
||||
char src[64], dest[64];
|
||||
sprintf(src, "/acct/uid_0/pid_%d", ppid);
|
||||
@@ -167,20 +169,6 @@ static void daemon_entry(int ppid) {
|
||||
MAGISKTMP = dirname(src);
|
||||
xstat("/proc/self/exe", &self_st);
|
||||
|
||||
restore_tmpcon();
|
||||
|
||||
// SAR cleanups
|
||||
auto mount_list = MAGISKTMP + "/" ROOTMNT;
|
||||
if (access(mount_list.data(), F_OK) == 0) {
|
||||
file_readline(true, mount_list.data(), [](string_view line) -> bool {
|
||||
umount2(line.data(), MNT_DETACH);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
unlink("/dev/.se");
|
||||
|
||||
LOGI(NAME_WITH_VER(Magisk) " daemon started\n");
|
||||
|
||||
// Get API level
|
||||
parse_prop_file("/system/build.prop", [](auto key, auto val) -> bool {
|
||||
if (key == "ro.build.version.sdk") {
|
||||
@@ -198,6 +186,18 @@ static void daemon_entry(int ppid) {
|
||||
}
|
||||
LOGI("* Device API level: %d\n", SDK_INT);
|
||||
|
||||
restore_tmpcon();
|
||||
|
||||
// SAR cleanups
|
||||
auto mount_list = MAGISKTMP + "/" ROOTMNT;
|
||||
if (access(mount_list.data(), F_OK) == 0) {
|
||||
file_readline(true, mount_list.data(), [](string_view line) -> bool {
|
||||
umount2(line.data(), MNT_DETACH);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
unlink("/dev/.se");
|
||||
|
||||
// Load config status
|
||||
auto config = MAGISKTMP + "/" INTLROOT "/config";
|
||||
parse_prop_file(config.data(), [](auto key, auto val) -> bool {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include <string_view>
|
||||
|
||||
#include <magisk.hpp>
|
||||
#include <daemon.hpp>
|
||||
#include <selinux.hpp>
|
||||
#include <utils.hpp>
|
||||
|
||||
@@ -87,7 +88,7 @@ void restore_tmpcon() {
|
||||
int dfd = dirfd(dir.get());
|
||||
|
||||
for (dirent *entry; (entry = xreaddir(dir.get()));) {
|
||||
if (entry->d_name == "magisk"sv)
|
||||
if (SDK_INT >= 26 && entry->d_name == "magisk"sv)
|
||||
setfilecon_at(dfd, entry->d_name, EXEC_CON);
|
||||
else
|
||||
setfilecon_at(dfd, entry->d_name, SYSTEM_CON);
|
||||
|
Reference in New Issue
Block a user