[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Environment Variables for sudo




On 6 Mar 2006, at 22:02, Star King of the Grape Trees wrote:

(First, is that as typo? (spurious space in PATH))

I would assume that sudo merely executes the program, and does not start a new shell (unless you ask it to), thus my assumption is that it's your env, merely executed with root's privilages.

Hmm... a fair assumption, but 'env' from my user account gives this, including the variables missing from 'sudo env':

TERM=vt100
SHELL=/bin/bash
CATALINA_HOME=/usr/local/java/apache-tomcat
SSH_CLIENT=81.158.253.147 38636 22
SSH_TTY=/dev/pts/1
USER=tim
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40 ; 33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01; 31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*. bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:* .gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:* .xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35: *.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:* .xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:
MAIL=/var/mail/tim
PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:usr/local/:/ usr/local/java/j2sdk/bin
PWD=/etc/pam.d
JAVA_HOME=/usr/local/java/j2sdk
PS1=${debian_chroot:+($debian_chroot)}\u@\h:\w\$
SHLVL=1
HOME=/home/tim
LOGNAME=tim
SSH_CONNECTION=81.158.253.147 38636 87.117.194.123 22
_=/usr/bin/env
OLDPWD=/home/tim

As for su, from the man page:
OPTIONS
      -      make this a login shell
So, if you want to be root, AND have settings associated with root's login, use:
su -
As opposed to just:
su

su already takes the environment variables just fine, although i had disabled in in the PAM configuration (switched it back on only to test this) as would rather use sudo, really. This should also negate the typo theory, as it isn't a problem with the root accout, but rather with sudo itself.


thanks all the same!



tim



Reply to: