after going through some articles I understand that sudo's environment and the commands that it can use are influenced by /etc/sudoers
file.
this sudoers
manual - https://www.sudo.ws/man/1.8.13/sudoers.man.html - specifies that users in the group specified by exempt_group option are not affected by secure_path
which basically alters the sudo's PATH
This is how defaults are set in my /etc/sudoers
file
Defaults always_set_home
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
#
# Adding HOME to env_keep may enable a user to run unrestricted
# commands via sudo.
#
# Defaults env_keep += "HOME"
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
Defaults exempt_group=exempt
exempt
is the group on the system that the user is added to.
instead of the group
on the system, I have also tried using the group
created by User_Alias
in /etc/sudoers
file. this didnt help either.
sudo ruby -v
- returns 2.0.0
ruby -v
- returns 2.3.3
how can sudo
pick rvm ruby
without modifying secure_path?
sudo -i
works but in my case the command is a remote ssh command and we dont have access to change that code which triggers the command. please help