[sudo-users] handling of PATH, between "su - user" and "sudo --login -u user"

Cobrin Steve (ext) GBJH steve.cobrin at syngenta.com
Tue Jun 2 16:57:39 MDT 2020


This is CentOS 7 (equivalent of RHEL 7), it does not have any rc scripts. The account "oracle" (maybe it was a bad example) had no additional configuration in its .bashrc,  .bash_profile or /etc/profile.d/*.sh files

I can reproduce the issue with another account, testing from root

[23:27|root at gbjh:~]# su - test
[23:28|test at gbjh:~]$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/test/.local/bin:/home/test/bin

This is expected behaviour, but

[23:28|root at gbjh:~]# sudo --login -u test
[23:28|test at gbjh:~]$ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/home/test/.local/bin:/home/test/bin
^^^^^ This is should be /usr/local/bin

My only alternative is something like
[23:37|root at gbjh:~]# sudo su - test
[23:37|scobrin at gbjh:~]$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/test/.local/bin:/home/test/bin

But that would require a less safe configuration in the sudoers, the creation of more processes, and the --login option should not mess with the PATH, what am I missing?

-- Steve 

This message may contain confidential information. If you are not the designated recipient, please notify the sender immediately, and delete the original and any copies. Any use of the message by you is prohibited.



More information about the sudo-users mailing list