From 2cf33d635d8247fd67e71ac54d8ea27f481f36d2 Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Sat, 26 Jan 2019 04:34:29 +0800 Subject: [PATCH] Setuid after read proc --- native/jni/su/su_daemon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/jni/su/su_daemon.cpp b/native/jni/su/su_daemon.cpp index e05c35138..cde625b36 100644 --- a/native/jni/su/su_daemon.cpp +++ b/native/jni/su/su_daemon.cpp @@ -335,7 +335,6 @@ void su_daemon_handler(int client, struct ucred *credential) { // Setup environment umask(022); - set_identity(ctx.req.uid); char path[32], buf[4096]; snprintf(path, sizeof(path), "/proc/%d/cwd", ctx.pid); xreadlink(path, buf, sizeof(buf)); @@ -363,6 +362,7 @@ void su_daemon_handler(int client, struct ucred *credential) { } } + set_identity(ctx.req.uid); execvp(ctx.req.shell, (char **) argv); fprintf(stderr, "Cannot execute %s: %s\n", ctx.req.shell, strerror(errno)); PLOGE("exec");