Move devpts mount to magiskinit

This commit is contained in:
LoveSy 2024-08-13 21:34:32 +08:00 committed by John Wu
parent 554eda8fe1
commit 838e1e254d
2 changed files with 13 additions and 15 deletions

View File

@ -392,21 +392,6 @@ static void daemon_entry() {
ssprintf(path, sizeof(path), "%s/" ROOTOVL, tmp);
rm_rf(path);
// Use isolated devpts if kernel support
if (access("/dev/pts/ptmx", F_OK) == 0) {
ssprintf(path, sizeof(path), "%s/" SHELLPTS, tmp);
if (access(path, F_OK)) {
xmkdirs(path, 0755);
xmount("devpts", path, "devpts", MS_NOSUID | MS_NOEXEC, "newinstance");
char ptmx[64];
ssprintf(ptmx, sizeof(ptmx), "%s/ptmx", path);
if (access(ptmx, F_OK)) {
xumount(path);
rmdir(path);
}
}
}
fd = xsocket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
sockaddr_un addr = {.sun_family = AF_LOCAL};
ssprintf(addr.sun_path, sizeof(addr.sun_path), "%s/" MAIN_SOCKET, tmp);

View File

@ -249,5 +249,18 @@ void MagiskInit::setup_tmp(const char *path) {
xmount(".", path, nullptr, MS_BIND, nullptr);
chdir(path);
// Use isolated devpts if kernel support
if (access("/dev/pts/ptmx", F_OK) == 0) {
xmkdirs(SHELLPTS, 0755);
xmount("devpts", SHELLPTS, "devpts", MS_NOSUID | MS_NOEXEC, "newinstance");
xmount(nullptr, SHELLPTS, nullptr, MS_PRIVATE, nullptr);
if (access(SHELLPTS "/ptmx", F_OK)) {
umount2(SHELLPTS, MNT_DETACH);
rmdir(SHELLPTS);
}
}
chdir("/");
}