Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 56407 - portage ought to add /sbin /usr/sbin/ to PATH when the user is sudo'ing
Summary: portage ought to add /sbin /usr/sbin/ to PATH when the user is sudo'ing
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All All
: High normal with 1 vote (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
: 118847 136697 146691 165804 182955 188641 198764 201995 210099 211597 215039 288760 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-07 21:38 UTC by Brian Harring (RETIRED)
Modified: 2011-12-23 17:57 UTC (History)
16 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Harring (RETIRED) gentoo-dev 2004-07-07 21:38:08 UTC
It's popped up on occasion; portage should be mangling the path so sbin ends up in it.
Easy way to see this, sudo emerge ntp and watch if fail in enewuser since useradd can't be found.
Comment 1 Rune Schjellerup 2005-05-16 03:41:34 UTC
The above description isn't that readable.
But it really is anoying that sudo doesn't look in sbin dirs.

Debian has that functionality as default, so should gentoo.
Comment 2 Darren Dale 2005-06-08 10:42:55 UTC
Someone on the forums pointed out that the 1.6.8_p8 ebuilds are removing
/usr/local/bin from the secure path, but secure path seems to include
/usr/local/bin if ROOTPATH is not set.
Comment 3 Alec Warner (RETIRED) archtester gentoo-dev Security 2005-08-11 18:27:36 UTC
Clarification, do you want portage to mangle the path JUST for sudo, or always?  
The former is not really feasable, and the latter is just silly, IMHO.
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-08-11 18:40:11 UTC
according to the sudo documention:
       To prevent command spoofing, sudo checks "." and "" (both denoting 
current directory) last when searching for a com-
       mand in the user's PATH (if one or both are in the PATH).  Note, 
however, that the actual PATH environment variable
       is not modified and is passed unchanged to the program that sudo 
executes.

I've tested 1.6.8p9, and found it does comply with the documentation.
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2005-08-12 00:46:52 UTC
Indeed; sudo deliberately doesn't set the ROOT's PATH when using sudo. This is
both documented in the sudo documentation and the various resources on the
Internet (including Gentoo's sudo guide at
http://www.gentoo.org/doc/en/sudo-guide.xml).
Comment 6 SpanKY gentoo-dev 2006-01-13 16:00:13 UTC
*** Bug 118847 has been marked as a duplicate of this bug. ***
Comment 7 SpanKY gentoo-dev 2006-01-13 17:41:09 UTC
*** Bug 118847 has been marked as a duplicate of this bug. ***
Comment 8 Stefan Schweizer (RETIRED) gentoo-dev 2006-05-19 01:59:17 UTC
*** Bug 133747 has been marked as a duplicate of this bug. ***
Comment 9 Jakub Moc (RETIRED) gentoo-dev 2006-06-13 12:22:18 UTC
*** Bug 136697 has been marked as a duplicate of this bug. ***
Comment 10 Jakub Moc (RETIRED) gentoo-dev 2006-09-07 07:00:25 UTC
*** Bug 146691 has been marked as a duplicate of this bug. ***
Comment 11 Paul Winkler 2006-09-07 08:07:28 UTC
in case it's not clear from the discussion so far, it's not just $PATH that needs sanitizing. Summary of duplicate bug 146991 - this fails:

export Z=foo
emerge --oneshot tk
Comment 12 Jakub Moc (RETIRED) gentoo-dev 2007-06-23 08:06:53 UTC
*** Bug 182955 has been marked as a duplicate of this bug. ***
Comment 13 Jakub Moc (RETIRED) gentoo-dev 2007-08-12 20:57:54 UTC
*** Bug 188641 has been marked as a duplicate of this bug. ***
Comment 14 Zac Medico gentoo-dev 2007-10-06 17:00:31 UTC
*** Bug 189417 has been marked as a duplicate of this bug. ***
Comment 15 Jakub Moc (RETIRED) gentoo-dev 2007-11-11 08:34:32 UTC
*** Bug 198764 has been marked as a duplicate of this bug. ***
Comment 16 Arthur Hagen 2007-11-11 20:47:51 UTC
(In reply to comment #15)
> *** Bug 198764 has been marked as a duplicate of this bug. ***
> 

I don't believe bug #198764 is a duplicate of bug #56407.  In bug #198764, the INCLUDE variable *is* sanitized and sane, and set to exactly what it should be set to, and should *not* be removed by portage, due to it being used when compiling with icc.
It's the exim package that incorrectly expects INCLUDE to be of the compiler specific form "-I/some/path".  This can be fixed by the exim maintainer by explicitly setting INCLUDE= in Local/Makefile (until upstreams stops using all caps variable names for private variables).
Can someone with access to do so reinstate bug #198764?
Comment 17 Jakub Moc (RETIRED) gentoo-dev 2007-12-12 08:15:58 UTC
*** Bug 201995 has been marked as a duplicate of this bug. ***
Comment 18 Jakub Moc (RETIRED) gentoo-dev 2008-01-12 22:00:11 UTC
*** Bug 204485 has been marked as a duplicate of this bug. ***
Comment 19 Jakub Moc (RETIRED) gentoo-dev 2008-02-14 09:43:01 UTC
*** Bug 210099 has been marked as a duplicate of this bug. ***
Comment 20 Jakub Moc (RETIRED) gentoo-dev 2008-02-14 10:04:09 UTC
*** Bug 210099 has been marked as a duplicate of this bug. ***
Comment 21 Jakub Moc (RETIRED) gentoo-dev 2008-02-27 08:41:15 UTC
*** Bug 211597 has been marked as a duplicate of this bug. ***
Comment 22 Jakub Moc (RETIRED) gentoo-dev 2008-02-29 15:10:52 UTC
*** Bug 211882 has been marked as a duplicate of this bug. ***
Comment 23 Jakub Moc (RETIRED) gentoo-dev 2008-03-27 12:34:23 UTC
*** Bug 215039 has been marked as a duplicate of this bug. ***
Comment 24 Peter Volkov (RETIRED) gentoo-dev 2008-06-20 18:35:43 UTC
*** Bug 165804 has been marked as a duplicate of this bug. ***
Comment 25 DEMAINE Benoît-Pierre, aka DoubleHP 2008-08-18 12:48:28 UTC
Does su behave a different way than sudo ? 

In bug #165804 (it was long time ago, but IIRC ... ) i was logged in as user under X env in Debian, then compiling Gentoo from there. Thus, I logged in first as user, then did su or sudo, then did chroot. In comment #4, Peter Volkov  advises me to try this:

> BTW, for chroot personally I found solution to enter it with the following
> command:
> env -i chroot ${path} /bin/bash --login
> this will recreate environment on entering chroot... HTH.

After reading this bug, I think this workaround may help many people. I think he is right in saying the fix should be at the emerge level: emerge needs to read some env vars for various reasons, but, I wonder if it really should let them accessible for ebuild execution. In present case, I wish it did not; but long time ago, I remember I had to export LD_PRELOAD from user's .bashrc (and could not do that from the system wide /etc/bashrc for various reasons) to use a Socks Proxy (Microsoft gateway in the network I was using on these days) ... a case where I would wish emerge to keep env vars to let wget know about socks proxy ... so the solution is not as much trivial as I thought. an other example of variable to keep is USE.

Still, all people attached to this bug could try this small WA, and report if it helps, or not, for their respective bugs. Mine was a specific cross-install stage problem; cant reproduce before I need to reinstall :)
Comment 26 Zac Medico gentoo-dev 2009-10-14 08:27:58 UTC
*** Bug 288760 has been marked as a duplicate of this bug. ***
Comment 27 5p4md00d 2010-04-28 16:34:21 UTC
I just found out that emerging media-libs/sdl-mixer after having sourced icc's iccvars.sh fails, because that script sets INCLUDE to icc's own include path(s), and this breaks the configuration and compilation of sdl-mixer:

...
configure: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)
configure: WARNING: *** Unable to find FLAC library (http://flac.sourceforge.net/)
configure: WARNING: *** Unable to find MAD library (http://www.underbit.com/products/mad/)
...
i686-pc-linux-gnu-gcc: /opt/intel/Compiler/11.1/069/ipp/ia32/include:/opt/intel/Compiler/11.1/069/mkl/include:/opt/intel/Compiler/11.1/069/ipp/ia32/include:/opt/intel/Compiler/11.1/069/mkl/include: No such file or directory
...

Had portage sanitized the environment, this wouldn't have happened. Maybe this is how the sdl-mixer .ebuild is supposed to work, but still I decided to let you guys know about this.
Comment 28 Faustus 2011-12-19 15:35:58 UTC
app-emulation/open-vm-tool-kmod fails to emerge when VERSION environment variable is set:

Using 2.6.x kernel build system.
make: *** No rule to make target `auto-build'.  Stop.
Comment 29 Zac Medico gentoo-dev 2011-12-19 18:18:58 UTC
(In reply to comment #0)
> It's popped up on occasion; portage should be mangling the path so sbin ends up
> in it.
> Easy way to see this, sudo emerge ntp and watch if fail in enewuser since
> useradd can't be found.

It seems that /sbin has been added to PATH since 2001 or so:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/portage/files/1.5/bin/ebuild.sh?hideattic=0&view=log#rev1.22

I'm closing this bug, since it doesn't seem to server any useful purpose.

(In reply to comment #28)
> app-emulation/open-vm-tool-kmod fails to emerge when VERSION environment
> variable is set:

For cases like this, the ebuild should filter the problematic environment variable itself, since there's no way for the package manager to know the difference between "desirable" and "undesirable" variables, and the definition of "desirable" and "undesirable" variables can vary from one package to another.
Comment 30 DEMAINE Benoît-Pierre, aka DoubleHP 2011-12-23 16:38:07 UTC
If the PATH was fixed in 2001, how come Brian had to create this bug  3 years later ? the issue is not fixed. If Brian had the issue 3 years after the introduction of /sbin in the PATH, is means that /sbin had been removed from the PATH somewhere between 2001 and 2004. Or that Brian met a special case where the PATH is not set properly.

Why are you refusing to add VERSION to the sanitasation list ? I have asked many times to start builds in a pure clean and empty environment; this have been refused several times, and more new comes come to occur because of non-sanitised env.

I have reported many variables that are known to break builds (from memory, A and/or S); why do you refuse to add VERSION to the list of purged vars ?
Comment 31 Zac Medico gentoo-dev 2011-12-23 17:57:45 UTC
(In reply to comment #30)
> If the PATH was fixed in 2001, how come Brian had to create this bug  3 years
> later ? the issue is not fixed. If Brian had the issue 3 years after the
> introduction of /sbin in the PATH, is means that /sbin had been removed from
> the PATH somewhere between 2001 and 2004. Or that Brian met a special case
> where the PATH is not set properly.

Anyway, it seems that /sbin has been added to PATH automatically for years.

> Why are you refusing to add VERSION to the sanitasation list ? I have asked
> many times to start builds in a pure clean and empty environment; this have
> been refused several times, and more new comes come to occur because of
> non-sanitised env.

As explained in comment #29, there's no way for the package manager to know the
difference between "desirable" and "undesirable" variables, and the definition
of "desirable" and "undesirable" variables can vary from one package to
another.

> I have reported many variables that are known to break builds (from memory, A
> and/or S); why do you refuse to add VERSION to the list of purged vars ?

The ${A} and ${S} variables are variables that have special meaning in the context of the PMS specification. The ${VERSION} variable has no special meaning.