Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 68928 - Portage 2.0.51-r2 fails when a file named "tee" is in the directory emerge is run
Summary: Portage 2.0.51-r2 fails when a file named "tee" is in the directory emerge is...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 108082
  Show dependency tree
 
Reported: 2004-10-25 22:47 UTC by Robert McGinley
Modified: 2005-10-16 01:42 UTC (History)
2 users (show)

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


Attachments
portage-2.0.51.22-spawn-path_lookup.patch (portage-2.0.51.22-spawn-path_lookup.patch,519 bytes, patch)
2005-07-31 12:43 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert McGinley 2004-10-25 22:47:33 UTC
Portage 2.0.51-r2 fails when a file named "tee" is in the directory emerge is run.
Error message:

Traceback (most recent call last):
File "/usr/bin/emerge", line 2991, in ?
mydepgraph.merge(mydepgraph.altlist())
File "/usr/bin/emerge", line 1809, in merge
retval=portage.doebuild(y,"package",myroot,self.pkgsettings,edebug)
File "/usr/lib/portage/pym/portage.py", line 2550, in doebuild
return spawnebuild(mydo,actionmap,mysettings,debug,logfile=logfile)
File "/usr/lib/portage/pym/portage.py", line 2177, in spawnebuild
retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
File "/usr/lib/portage/pym/portage.py", line 2177, in spawnebuild retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
File "/usr/lib/portage/pym/portage.py", line 2177, in spawnebuild
retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
File "/usr/lib/portage/pym/portage.py", line 2177, in spawnebuild retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
File "/usr/lib/portage/pym/portage.py", line 2177, in spawnebuild retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
File "/usr/lib/portage/pym/portage.py", line 2193, in spawnebuild     droppriv=actionmap[mydo]["args"][1],logfile=logfile)
File "/usr/lib/portage/pym/portage.py", line 1507, in spawn return portage_exec.spawn_bash(mystring,env=env,**keywords)
File "/usr/lib/portage/pym/portage_exec.py", line 44, in spawn_bash
  return spawn(args,env=env,opt_name=opt_name,**keywords)
File "/usr/lib/portage/pym/portage_exec.py", line 86, in spawn mypid.extend(spawn(('tee','-i','-a',logfile),returnpid=True,fd_pipes={0:pr,1:1,2:2}))
File "/usr/lib/portage/pym/portage_exec.py", line 167, in spawn
  raise str(e)+":\n   "+myc+" "+string.join(myargs)
[Errno 13] Permission denied:
  tee tee -i -a /var/log/portage/2161-genkernel-3.1.0a.log

Reproducible: Always
Steps to Reproduce:
1. Upgrade portage to latest (2.0.51-r2)
2. Create a file in the working directory named "tee" (touch tee)
3. Attempt to emerge anything (emerge -U world)

Actual Results:  
Emerge produced the error log above, most notably the following:
[Errno 13] Permission denied:
  tee tee -i -a /var/log/portage/(package being merged)



Expected Results:  
Ignored the file in the current directory and executed /bin/tee

Portage 2.0.51-r2 (default-x86-2004.0, gcc-3.3.4, glibc-2.3.4.20040808-r1, 2.4.26-
gentoo-r9 i686)
=================================================================
System uname: 2.4.26-gentoo-r9 i686 Mobile AMD Athlon(tm) XP 1500+
Gentoo Base System version 1.4.16
Autoconf: sys-devel/autoconf-2.59-r5
Automake: sys-devel/automake-1.8.5-r1
Binutils: sys-devel/binutils-2.14.90.0.8-r1
Headers:  sys-kernel/linux-headers-2.4.21-r1
Libtools: sys-devel/libtool-1.5.2-r5
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-mcpu=athlon-xp -O3 -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config
/usr/kde/3.2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config
/usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-mcpu=athlon-xp -O3 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs buildpkg ccache distcc distlocks notitles sandbox userpriv
usersandbox"
GENTOO_MIRRORS="ftp://gentoo.ccccom.com http://gentoo.ccccom.com
http://mirrors.tds.net/gentoo ftp://mirrors.tds.net/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext X acpi apm arts avi berkdb bitmap-fonts cdr crypt dvd encode
esd f77 foomaticdb gdbm gif gtk2 imlib jpeg kde libg++ libwww mad mikmod mmx
motifmpeg ncurses nls oggvorbis opengl oss pam pcmcia pdflib perl png python qt
quicktime readline sdl slang spell sse ssl svga tcpd truetype x86 xml2 xmms
xprint xv zlib"
Comment 1 Emil Beinroth 2004-10-30 09:36:12 UTC
I got the same error on my box.
Please note that it not just fails, but tries to execute the file with root-permissions. I think this bug is also a security-issue.

PS: Shouldn't the "Hardware"-field of this bug be changed from x86 to all?
Comment 2 Jason Stubbs (RETIRED) gentoo-dev 2005-07-31 00:51:43 UTC
Do either of you have PATH="." ? 
Comment 3 Emil Beinroth 2005-07-31 03:40:29 UTC
No, '.' is not in PATH.
Comment 4 Zac Medico gentoo-dev 2005-07-31 12:12:23 UTC
With portage-2.0.51.22-r2 I have to "chmod +x tee" in order to reproduce this
error.  There must be a subtle bug in portage_exec.find_binary().
Comment 5 Zac Medico gentoo-dev 2005-07-31 12:43:28 UTC
Created attachment 64810 [details, diff]
portage-2.0.51.22-spawn-path_lookup.patch

This patch adds a test to see if myc is an absolute path or not.

The problem is in this section at the beginning of portage_exec.spawn() where
it can skip the path lookup if there is an executable file with the same name
in the current directory.

if not os.access(myc, os.X_OK):
	if not path_lookup:
		return None
	myc = find_binary(myc)
	if myc == None:
		return None
Comment 6 Jason Stubbs (RETIRED) gentoo-dev 2005-10-16 01:42:46 UTC
Fixed in 2.0.53