pub fn host_login_environment() -> Result<Vec<(OsString, OsString)>>Expand description
The logged-in user’s environment, as a fresh login would see it.
Unix has no API that reconstructs a login environment, so this is rebuilt
from the user’s identity rather than copied from this process: getpwuid_r
supplies USER/LOGNAME/HOME/SHELL, PATH gets this host’s login
default, and the session-describing variables are carried over.
A user with no resolvable passwd entry – a uid absent from NSS – has no identity to rebuild from, so the current process environment is returned instead. That is a worse answer than a real login environment and a much better one than nothing.