[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

This is expected behaviour, but

[23:28|root at gbjh:~]# sudo --login -u test
[23:28|test at gbjh:~]$ echo $PATH
^^^^^ 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

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