[gentoo-user] Re: Where does sudo get the PATH ?
Nicolas Richard theonewiththeevill...@yahoo.fr writes: I don't understand where sudo finds the value for the PATH env variable. Finally, I found where the problem lied. Recall that my problem was the following : I had a path in `sudo env | grep ^PATH' which did not seem to originate from any config file in /etc or /root (the path pointing to texlive/2011). And indeed, it was set at compile time, using --with-secure-path : $ sudo sudo -V | head -2 Sudo version 1.8.5p2 Configure options: --prefix=/usr --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-zlib=system --with-secure-path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux --with-editor=/usr/libexec/editor --with-env-editor --without-insults --without-all-insults --with-ldap_conf_file=/etc/ldap.conf.sudo --with-ldap --enable-nls --with-pam --without-skey --without-selinux --without-opie --without-linux-audit --with-timedir=/var/db/sudo --with-plugindir=/usr/lib/sudo --docdir=/usr/share/doc/sudo-1.8.5_p2 In the ebuild, I find the following comment : # FIXME: secure_path is a compile time setting. using ROOTPATH # is not perfect, env-update may invalidate this, but until it # is available as a sudoers setting this will have to do. I'm not sure I understand this comment because adding the following line in /etc/sudoers : Defaults secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin does what I expect it to do : override the PATH variable. Maybe the comment is simply outdated ? Thanks to those who tried to help me here and also to Nicolas George who pointed me in the direction of `secure_path' which I had somehow overlooked in the manpages. -- Nicolas.
[gentoo-user] Re: Where does sudo get the PATH ?
Pandu Poluan pa...@poluan.info writes: Maybe it's building the PATH not explicitly... something like : PATH=$PATH;/usr/local/texlive/$SOME_VARIABLE/and/so/forth Try grepping for texlive/\$ I tried, but the results are always pointing to the (correct) 2012 version. I paste the result hereunder just in case, but I'm pretty sure there's nothing interesting in there. (btw, there are errors because of missing targets for some symlinks, hence the redirection) youngfrog@geodiff-mac3 /etc $ sudo grep -R 'texlive' * 2 /dev/null csh.env:setenv INFOPATH '/usr/share/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.5.4/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.22/info:/usr/share/info/emacs-24:/usr/local/texlive/2012/texmf/doc/info' csh.env:setenv MANPATH '/usr/local/share/man:/usr/share/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.5.4/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.22/man:/etc/java-config/system-vm/man/:/usr/local/texlive/2012/texmf/doc/man' csh.env:setenv PATH '/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux' csh.env:setenv ROOTPATH '/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/local/texlive/2012/bin/i386-linux' env.d/99texlive:PATH=/usr/local/texlive/2012/bin/i386-linux env.d/99texlive:ROOTPATH=/usr/local/texlive/2012/bin/i386-linux env.d/99texlive:MANPATH=/usr/local/texlive/2012/texmf/doc/man env.d/99texlive:INFOPATH=/usr/local/texlive/2012/texmf/doc/info environment:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/local/texlive/2012/bin/i386-linux:/root/bin portage/profile/package.provided:app-text/texlive-core-2011-r5 portage/profile/package.provided:dev-texlive/texlive-basic-2011-r1 portage/profile/package.provided:dev-texlive/texlive-documentation-base-2011 portage/profile/package.provided:dev-texlive/texlive-fontsextra-2011 portage/profile/package.provided:dev-texlive/texlive-fontsrecommended-2011 portage/profile/package.provided:dev-texlive/texlive-fontutils-2011 portage/profile/package.provided:dev-texlive/texlive-genericextra-2011 portage/profile/package.provided:dev-texlive/texlive-genericrecommanded-2011 portage/profile/package.provided:dev-texlive/texlive-genericrecommended-2011 portage/profile/package.provided:dev-texlive/texlive-latex-2011 portage/profile/package.provided:dev-texlive/texlive-latexextra-2011-r2 portage/profile/package.provided:dev-texlive/texlive-latexrecommended-2011 portage/profile/package.provided:dev-texlive/texlive-pictures-2011 portage/profile/package.provided:dev-texlive/texlive-pstricks-2011 portage/profile/package.provided:dev-texlive/texlive-science-2011 portage/profile/package.provided:dev-texlive/texlive-texinfo-2011 portage/profile/package.provided:# dev-texlive/texlive-latex3-2011 portage/profile/package.provided:# dev-texlive/texlive-fontsextra-2011 portage/profile/package.provided:# dev-texlive/texlive-latexextra-2011 portage/profile/package.provided:# dev-texlive/texlive-pictures-2011 portage/profile/package.provided:# dev-texlive/texlive-science-2011 portage/profile/package.provided:# dev-texlive/texlive-xetex-2011 portage/profile/package.provided:# dev-texlive/texlive-luatex-2011 prelink.conf:-h /usr/local/texlive/2012/bin/i386-linux/ profile.env:export INFOPATH='/usr/share/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.5.4/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.22/info:/usr/share/info/emacs-24:/usr/local/texlive/2012/texmf/doc/info' profile.env:export MANPATH='/usr/local/share/man:/usr/share/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.5.4/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.22/man:/etc/java-config/system-vm/man/:/usr/local/texlive/2012/texmf/doc/man' profile.env:export PATH='/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux' profile.env:export ROOTPATH='/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/local/texlive/2012/bin/i386-linux' -- N.
[gentoo-user] Re: Where does sudo get the PATH ?
Joost Roeleveld jo...@antarean.org writes: On Wednesday, October 10, 2012 04:57:50 PM Nicolas Richard wrote: In my homedir: .bash_profile loads .bashrc .bashrc says export PATH=~/bin/overrideglobal:${PATH}:~/bin (and defines some aliases) Does it load any global default? No. Here are the full files, omitting comments and empty lines : youngfrog@geodiff-mac3 ~ $ grep -vH '^#\|^$' .bashrc .bash_profile .bashrc:export PATH=~/bin/overrideglobal:${PATH}:~/bin .bashrc:if [[ $- != *i* ]] ; then .bashrc:# Shell is non-interactive. Be done now! .bashrc:return .bashrc:fi .bashrc:UPDATEGITREPO=~/TeX/ ~/BSSM/2011/notes-de-conf/ ~/org/ ~/BSSM/2012 .bashrc:export UPDATEGITREPO .bashrc:alias ll=ls -lA .bashrc:alias l=ls -CF .bashrc:alias cp=cp -i .bashrc:alias rm=rm -i .bashrc:alias mv=mv -i .bash_profile:[[ -f ~/.bashrc ]] . ~/.bashrc In other words, what is in the environment when you are normally logged in? Ok, I thought my original post contained it. In fact that was part of my original post : youngfrog@geodiff-mac3 ~ $ bash -c 'echo $PATH' ~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin and I forgot to mention that it was the same as : youngfrog@geodiff-mac3 ~ $ env | grep ^PATH PATH=~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin and yet the same as : youngfrog@geodiff-mac3 ~ $ echo $PATH ~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin Thanks for trying btw. I certainly did something really stupid to set the path the first time, but can't see where. N.
Re: [gentoo-user] Re: Where does sudo get the PATH ?
On Oct 11, 2012 9:29 PM, Nicolas Richard theonewiththeevill...@yahoo.fr wrote: Joost Roeleveld jo...@antarean.org writes: On Wednesday, October 10, 2012 04:57:50 PM Nicolas Richard wrote: In my homedir: .bash_profile loads .bashrc .bashrc says export PATH=~/bin/overrideglobal:${PATH}:~/bin (and defines some aliases) Does it load any global default? No. Here are the full files, omitting comments and empty lines : youngfrog@geodiff-mac3 ~ $ grep -vH '^#\|^$' .bashrc .bash_profile .bashrc:export PATH=~/bin/overrideglobal:${PATH}:~/bin .bashrc:if [[ $- != *i* ]] ; then .bashrc:# Shell is non-interactive. Be done now! .bashrc:return .bashrc:fi .bashrc:UPDATEGITREPO=~/TeX/ ~/BSSM/2011/notes-de-conf/ ~/org/ ~/BSSM/2012 .bashrc:export UPDATEGITREPO .bashrc:alias ll=ls -lA .bashrc:alias l=ls -CF .bashrc:alias cp=cp -i .bashrc:alias rm=rm -i .bashrc:alias mv=mv -i .bash_profile:[[ -f ~/.bashrc ]] . ~/.bashrc In other words, what is in the environment when you are normally logged in? Ok, I thought my original post contained it. In fact that was part of my original post : youngfrog@geodiff-mac3 ~ $ bash -c 'echo $PATH' ~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin and I forgot to mention that it was the same as : youngfrog@geodiff-mac3 ~ $ env | grep ^PATH PATH=~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin and yet the same as : youngfrog@geodiff-mac3 ~ $ echo $PATH ~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin Thanks for trying btw. I certainly did something really stupid to set the path the first time, but can't see where. A bit desperate, but try : grep -R texlive/2011 /etc/* Rgds,
[gentoo-user] Re: Where does sudo get the PATH ?
Pandu Poluan pa...@poluan.info writes: A bit desperate, but try : grep -R texlive/2011 /etc/* I tried that already youngfrog@geodiff-mac3 ~ $ sudo grep -r texlive/2011 /etc youngfrog@geodiff-mac3 ~ $ sudo grep -r texlive/2011 ~root /root/.bash_history:cd /usr/local/texlive/2011 /root/.bash_history:grep texlive/2011 * -r /root/.bash_history:grep texlive/2011 . -r /root/.bash_history:grep texlive/2011 .* -r -- N.
Re: [gentoo-user] Re: Where does sudo get the PATH ?
On Oct 11, 2012 11:54 PM, Nicolas Richard theonewiththeevill...@yahoo.fr wrote: Pandu Poluan pa...@poluan.info writes: A bit desperate, but try : grep -R texlive/2011 /etc/* I tried that already youngfrog@geodiff-mac3 ~ $ sudo grep -r texlive/2011 /etc youngfrog@geodiff-mac3 ~ $ sudo grep -r texlive/2011 ~root /root/.bash_history:cd /usr/local/texlive/2011 /root/.bash_history:grep texlive/2011 * -r /root/.bash_history:grep texlive/2011 . -r /root/.bash_history:grep texlive/2011 .* -r -- N. Hmm Maybe it's building the PATH not explicitly... something like : PATH=$PATH;/usr/local/texlive/$SOME_VARIABLE/and/so/forth Try grepping for texlive/\$ Rgds,
Re: [gentoo-user] Re: Where does sudo get the PATH ?
On Tue, October 9, 2012 5:03 pm, Nicolas Richard wrote: Joost == J Roeleveld jo...@antarean.org writes: Joost Nicolas Richard theonewiththeevill...@yahoo.fr wrote: Here is the output of the relevant (at least I thought they were) commands. Can somebody explain to me why I still have /usr/local/texlive/*2011*/bin/i386-linux in the first sudo output youngfrog@geodiff-mac3 ~ $ sudo bash -c 'echo $PATH' /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux youngfrog@geodiff-mac3 ~ $ grep -v '^#\|^$' /etc/environment PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/local/texlive/2012/bin/i386-linux:/root/bin Joost I can see several /usr/local/... paths in your Joost /etc/environment. Hello Joost, Yes, I see them too, but they are pointing to the more recent 2012 release of texlive, not the older 2011 one. What I don't understand is where /sudo/ finds the environment when called without the -i option (and in particular, that entry for texlive 2011). The manpage seems to say that it simply uses the current environment (quoting the manpage : Note, however, that the actual PATH environment variable is not modified and is passed unchanged to the program that sudo executes.) but that does not seem right. -- N. What do you get with echo $PATH when not using sudo? -- Joost
Re: [gentoo-user] Re: Where does sudo get the PATH ?
On Tue, October 9, 2012 5:03 pm, Nicolas Richard wrote: Joost == J Roeleveld jo...@antarean.org writes: Joost Nicolas Richard theonewiththeevill...@yahoo.fr wrote: Here is the output of the relevant (at least I thought they were) commands. Can somebody explain to me why I still have /usr/local/texlive/*2011*/bin/i386-linux in the first sudo output youngfrog@geodiff-mac3 ~ $ sudo bash -c 'echo $PATH' /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux youngfrog@geodiff-mac3 ~ $ grep -v '^#\|^$' /etc/environment PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/local/texlive/2012/bin/i386-linux:/root/bin Joost I can see several /usr/local/... paths in your Joost /etc/environment. Hello Joost, Yes, I see them too, but they are pointing to the more recent 2012 release of texlive, not the older 2011 one. What I don't understand is where /sudo/ finds the environment when called without the -i option (and in particular, that entry for texlive 2011). The manpage seems to say that it simply uses the current environment (quoting the manpage : Note, however, that the actual PATH environment variable is not modified and is passed unchanged to the program that sudo executes.) but that does not seem right. And, what is in the .bash_profile and .bashrc files in your homedir and in root's homedir? -- Joost
[gentoo-user] Re: Where does sudo get the PATH ?
Joost == J Roeleveld jo...@antarean.org writes: Joost And, what is in the .bash_profile and .bashrc files in your Joost homedir and in root's homedir? In my homedir: .bash_profile loads .bashrc .bashrc says export PATH=~/bin/overrideglobal:${PATH}:~/bin (and defines some aliases) In root's: I have no such files. Maybe it would be less distracting if I don't use a shell at all : youngfrog@geodiff-mac3 ~ $ sudo -i env | grep ^PATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/local/texlive/2012/bin/i386-linux:/root/bin youngfrog@geodiff-mac3 ~ $ sudo env | grep ^PATH PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux Joost What do you get with echo $PATH when not using sudo? You mean, when I'm logged in as root ? Then it's the same as when using sudo -i. N.
Re: [gentoo-user] Re: Where does sudo get the PATH ?
On Wednesday, October 10, 2012 04:57:50 PM Nicolas Richard wrote: Joost == J Roeleveld jo...@antarean.org writes: Joost And, what is in the .bash_profile and .bashrc files in your Joost homedir and in root's homedir? In my homedir: .bash_profile loads .bashrc .bashrc says export PATH=~/bin/overrideglobal:${PATH}:~/bin (and defines some aliases) Does it load any global default? In root's: I have no such files. Maybe it would be less distracting if I don't use a shell at all : youngfrog@geodiff-mac3 ~ $ sudo -i env | grep ^PATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/ usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/local/texlive/2012/bin/i386-linux:/ root/bin youngfrog@geodiff-mac3 ~ $ sudo env | grep ^PATH PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/ usr/local/texlive/2011/bin/i386-linux Joost What do you get with echo $PATH when not using sudo? You mean, when I'm logged in as root ? Then it's the same as when using sudo -i. No, when you're logged in as your normal user. In other words, what is in the environment when you are normally logged in? -- Joost
[gentoo-user] Re: Where does sudo get the PATH ?
Joost == J Roeleveld jo...@antarean.org writes: Joost Nicolas Richard theonewiththeevill...@yahoo.fr wrote: Here is the output of the relevant (at least I thought they were) commands. Can somebody explain to me why I still have /usr/local/texlive/*2011*/bin/i386-linux in the first sudo output youngfrog@geodiff-mac3 ~ $ sudo bash -c 'echo $PATH' /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux youngfrog@geodiff-mac3 ~ $ grep -v '^#\|^$' /etc/environment PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/local/texlive/2012/bin/i386-linux:/root/bin Joost I can see several /usr/local/... paths in your Joost /etc/environment. Hello Joost, Yes, I see them too, but they are pointing to the more recent 2012 release of texlive, not the older 2011 one. What I don't understand is where /sudo/ finds the environment when called without the -i option (and in particular, that entry for texlive 2011). The manpage seems to say that it simply uses the current environment (quoting the manpage : Note, however, that the actual PATH environment variable is not modified and is passed unchanged to the program that sudo executes.) but that does not seem right. -- N.