I'm trying to run a program in Rust using libc as another user.
nix::unistd::setuid(uid).unwrap();
If I fork
and exec
a process which runs printenv
, the environment does not change. How can I reset the environment to the default for a user?
With nix::unistd::execve()
's third argument env
, you have full control over the next processes environment. Also see exec(3)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.