From: nekral-guest Date: Sat, 28 Aug 2010 19:55:31 +0000 (+0000) Subject: * src/su.c: Fix handling of environment variables when X-Git-Tag: 4.1.5~243 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=991ce97170df895b09aa52e24845a1b381e34904;p=shadow * src/su.c: Fix handling of environment variables when the environment is not changed. In particular, this makes su behave as documented regarding PATH and IFS (i.e. they are reset) when -p is provided. --- diff --git a/ChangeLog b/ChangeLog index ebda9801..9d8adf86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-08-28 Nicolas François + + * src/su.c: Fix handling of environment variables when + the environment is not changed. In particular, this makes su + behave as documented regarding PATH and IFS (i.e. they are reset) + when -p is provided. + 2010-08-28 Nicolas François * man/su.1.xml: Fix typo. diff --git a/src/su.c b/src/su.c index e45702f9..bd4e9432 100644 --- a/src/su.c +++ b/src/su.c @@ -933,13 +933,13 @@ int main (int argc, char **argv) exit (1); } - if (change_environment) { - /* we need to setup the environment *after* pam_open_session(), - * else the UID is changed before stuff like pam_xauth could - * run, and we cannot access /etc/shadow and co - */ - environ = newenvp; /* make new environment active */ + /* we need to setup the environment *after* pam_open_session(), + * else the UID is changed before stuff like pam_xauth could + * run, and we cannot access /etc/shadow and co + */ + environ = newenvp; /* make new environment active */ + if (change_environment) { /* update environment with all pam set variables */ envcp = pam_getenvlist (pamh); if (NULL != envcp) {