Fix env parsing off by one - #35
serpilliere wants to merge 3 commits into
Conversation
|
This PR fixes the off by one described in #34 Note: Line 170 in 1bc5a7e self.set_env("HOME", user.home_dir().to_str().unwrap())?;
self.set_env("PWD", user.home_dir().to_str().unwrap())?;
self.set_env("SHELL", user.shell().to_str().unwrap())?;But the PAM environment can set important other variables: for example in a kerberos environement, you have the So if you are ok with this, maybe we could modify this code to inherit every environment variable positioned by the PAM to the process, instead of just arbitrary one. Or if you are not ok with this principle, maybe we could expose an API for get all pam variable to the use api, something in the client.rs like: /// Retreive environement variable set by pam
pub fn get_env_list(&mut self) -> Vec<(String, String)> {
let pam_env = getenvlist(self.handle);
let mut env = vec![];
for (name, value) in pam_env {
env.push((name, value));
}
env
}So the end user could do this on its own Note: I think in an old version of your code, you forwarded every environment variables if I remember correctly. |
|
Hi @1wilkens |
Squashed commit of the following: commit a65741d Author: Antonio Gurgel <antonio@goorzhel.com> Date: Mon Aug 22 17:30:24 2022 -0700 Portably refer to C char type commit 56a3e24 Author: Fabrice Desclaux <fabrice.desclaux@cea.fr> Date: Thu Jul 21 11:17:00 2022 +0200 Set environement retrived by pam module commit be06986 Author: Fabrice Desclaux <fabrice.desclaux@cea.fr> Date: Fri Jul 8 11:47:59 2022 +0200 Fix env parsing off by one 1wilkens#35 Co-authored-by: Fabrice Desclaux <fabrice.desclaux@cea.fr> Co-authored-by: Antonio Gurgel <antonio@goorzhel.com>
Fix issue #34