Commit b2f152e6 authored by vvb2060's avatar vvb2060 Committed by John Wu

realpath /proc/pid/cwd

prevent cross mount namespace
parent 6c5b2618
...@@ -314,7 +314,9 @@ void su_daemon_handler(int client, const sock_cred *cred) { ...@@ -314,7 +314,9 @@ void su_daemon_handler(int client, const sock_cred *cred) {
umask(022); umask(022);
char path[32]; char path[32];
snprintf(path, sizeof(path), "/proc/%d/cwd", ctx.pid); snprintf(path, sizeof(path), "/proc/%d/cwd", ctx.pid);
chdir(path); char cwd[PATH_MAX];
if (realpath(path, cwd))
chdir(cwd);
snprintf(path, sizeof(path), "/proc/%d/environ", ctx.pid); snprintf(path, sizeof(path), "/proc/%d/environ", ctx.pid);
char buf[4096] = { 0 }; char buf[4096] = { 0 };
int fd = xopen(path, O_RDONLY); int fd = xopen(path, O_RDONLY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment