isolate: ensure calling chdir('/') after chroot

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
This commit is contained in:
Nikos Mavrogiannopoulos
2026-01-02 16:58:18 +01:00
parent 8ddc9b6abd
commit da61847df9
+8
View File
@@ -69,6 +69,14 @@ void drop_privileges(struct worker_st *ws, main_server_st *s)
GETPCONFIG(s)->chroot_dir, strerror(e)); GETPCONFIG(s)->chroot_dir, strerror(e));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = chdir("/");
if (ret != 0) {
e = errno;
oclog(ws, LOG_ERR, "cannot chdir to '/': %s",
strerror(e));
exit(EXIT_FAILURE);
}
} }
if (GETPCONFIG(s)->gid != -1 && (getgid() == 0 || getegid() == 0)) { if (GETPCONFIG(s)->gid != -1 && (getgid() == 0 || getegid() == 0)) {