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

"Cobrin Steve (ext) GBJH" <[email protected]> Tue, 2 Jun 2020 12:22:29 +0000
Newsgroups gmane.comp.tools.sudo.user
Message-ID <AM6PR05MB48054703D9694FBA469965F0EC8B0@AM6PR05MB4805.eurprd05.prod.outlook.com>
Hi there,

I have a user "oscar" on a CentOS 7 system (sudo-1.8.23 unchanged /etc/sudoers), who I want to allow to "su" to user "oracle", so I created an alias for him in his .bashrc

	alias become="sudo --login -u"

I've created a sudoers.d/gbjh entry

	oscar	ALL=(oracle)	NOPASSWD: ALL

Now, when I log into his machine as root, and type "su - oracle" my PATH is (correctly)

	[13:01|root@gbjh:/etc]# su - oracle
	[13:01|oracle@gbjh:~]$ echo $PATH
	/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/.local/bin:/home/oracle/bin

But, when he logs in and types "become oracle", his PATH afterwards is 

	[13:00|oscar@gbjh:~]$ become oracle
	[13:00|oracle@gbjh:~]$ echo $PATH
	/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/home/oracle/.local/bin:/home/oracle/bin

So, /usr/local/bin has been removed from his path and replaced with /sbin

What is the best way to make sure oracle's PATH is the same however we get to it?

Cheers
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.

____________________________________________________________
sudo-users mailing list <[email protected]>
For list information, options, or to unsubscribe, visit:
https://www.sudo.ws/mailman/listinfo/sudo-users