mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-02 14:35:29 +00:00
parent
6e5df1f06b
commit
4e2ecdb920
@ -415,14 +415,13 @@ void su_daemon_handler(int client, const sock_cred *cred) {
|
|||||||
if (realpath(path, cwd))
|
if (realpath(path, cwd))
|
||||||
chdir(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 };
|
auto env = full_read(path);
|
||||||
int fd = xopen(path, O_RDONLY);
|
|
||||||
read(fd, buf, sizeof(buf));
|
|
||||||
close(fd);
|
|
||||||
clearenv();
|
clearenv();
|
||||||
for (size_t pos = 0; buf[pos];) {
|
for (size_t pos = 0; pos < env.size(); ++pos) {
|
||||||
putenv(buf + pos);
|
putenv(env.data() + pos);
|
||||||
pos += strlen(buf + pos) + 1;
|
pos = env.find_first_of('\0', pos);
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!ctx.req.keepenv) {
|
if (!ctx.req.keepenv) {
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
Loading…
Reference in New Issue
Block a user