Skip to content

Commit 838e1e2

Browse files
yujincheng08topjohnwu
authored andcommitted
Move devpts mount to magiskinit
1 parent 554eda8 commit 838e1e2

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

native/src/core/daemon.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,6 @@ static void daemon_entry() {
392392
ssprintf(path, sizeof(path), "%s/" ROOTOVL, tmp);
393393
rm_rf(path);
394394

395-
// Use isolated devpts if kernel support
396-
if (access("/dev/pts/ptmx", F_OK) == 0) {
397-
ssprintf(path, sizeof(path), "%s/" SHELLPTS, tmp);
398-
if (access(path, F_OK)) {
399-
xmkdirs(path, 0755);
400-
xmount("devpts", path, "devpts", MS_NOSUID | MS_NOEXEC, "newinstance");
401-
char ptmx[64];
402-
ssprintf(ptmx, sizeof(ptmx), "%s/ptmx", path);
403-
if (access(ptmx, F_OK)) {
404-
xumount(path);
405-
rmdir(path);
406-
}
407-
}
408-
}
409-
410395
fd = xsocket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
411396
sockaddr_un addr = {.sun_family = AF_LOCAL};
412397
ssprintf(addr.sun_path, sizeof(addr.sun_path), "%s/" MAIN_SOCKET, tmp);

native/src/init/mount.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,18 @@ void MagiskInit::setup_tmp(const char *path) {
249249

250250
xmount(".", path, nullptr, MS_BIND, nullptr);
251251

252+
chdir(path);
253+
254+
// Use isolated devpts if kernel support
255+
if (access("/dev/pts/ptmx", F_OK) == 0) {
256+
xmkdirs(SHELLPTS, 0755);
257+
xmount("devpts", SHELLPTS, "devpts", MS_NOSUID | MS_NOEXEC, "newinstance");
258+
xmount(nullptr, SHELLPTS, nullptr, MS_PRIVATE, nullptr);
259+
if (access(SHELLPTS "/ptmx", F_OK)) {
260+
umount2(SHELLPTS, MNT_DETACH);
261+
rmdir(SHELLPTS);
262+
}
263+
}
264+
252265
chdir("/");
253266
}

0 commit comments

Comments
 (0)