There's a difference in the handling of environment variables between
the two implementations.

su provided by login/src:shadow resets
HOME
LOGNAME
PATH
SHELL
USER

su provided by util-linux resets
HOME
SHELL


I changed:

th's PATH to "/usr/sbin:/usr/bin:/sbin:/bin"
root's PATH to "/root/bin:/usr/sbin:/usr/bin:/sbin:/bin"
root's shell to "/bin/mksh"


Output:


Debian 9

th@localhost ~ $ echo $HOME $LOGNAME $PATH $SHELL $USER
/home/th th /usr/sbin:/usr/bin:/sbin:/bin /bin/bash th

th@localhost ~ $ su

root@localhost /home/th # echo $HOME $LOGNAME $PATH $SHELL $USER
/root root /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/bin/mksh root

root@localhost /home/th # grep SUPATH /etc/login.defs
# Three items must be defined:  MAIL_DIR, ENV_SUPATH, and ENV_PATH.
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

root@localhost /home/th # grep PATH= .profile
PATH="/root/bin:/usr/sbin:/usr/bin:/sbin:/bin"


RHEL 7

th@localhost ~ $ echo $HOME $LOGNAME $PATH $SHELL $USER
/home/th th /usr/sbin:/usr/bin:/sbin:/bin /bin/bash th

th@localhost ~ $ su

root@localhost /home/th # echo $HOME $LOGNAME $PATH $SHELL $USER
/root th /usr/sbin:/usr/bin:/sbin:/bin /bin/mksh th

root@localhost /home/th # grep PATH= .profile
PATH="/root/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Reply via email to