Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 388755 - portage use two different uid to create distfiles
Summary: portage use two different uid to create distfiles
Status: RESOLVED INVALID
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-28 09:34 UTC by nobody
Modified: 2011-10-29 02:31 UTC (History)
0 users

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 nobody 2011-10-28 09:34:52 UTC
Portage use two different uid to create its files, it use the root uid and portage uid, while creating them both in portage gid

emerge -1 gperf

 * IMPORTANT: 3 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

 * Last emerge --sync was Tue Sep 27 20:05:01 2011.
Calculating dependencies... done!
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) dev-util/gperf-3.0.4
>>> Jobs: 0 of 1 complete, 1 running                Load avg: 0.31, 0.10, 0.07^C

Exiting on signal 2

!!! select error: (4, 'Interrupted system call')
>>> Failed to emerge dev-util/gperf-3.0.4, Log file:
>>>  '/var/tmp/portage/dev-util/gperf-3.0.4/temp/build.log'
>>> Jobs: 0 of 1 complete, 1 failed                 Load avg: 0.31, 0.10, 0.07

ls -l gperf*
-rw-rw-r-- 1 portage portage 983500 28 oct.  11:24 gperf-3.0.4.tar.gz
ls -l .gperf*
-rw-rw---- 1 root portage 0 28 oct.  11:24 .gperf-3.0.4.tar.gz.portage_lockfile


It will of course cause issues on an export distfiles with strict user rules set.

Reproducible: Always
Comment 1 nobody 2011-10-28 09:37:44 UTC
emerge --info
Portage 2.1.10.11 (default/linux/x86/10.0/server, gcc-4.4.3, glibc-2.11.3-r0, 2.6.38.7 i686)
=================================================================
System uname: Linux-2.6.38.7-i686-Intel-R-_Core-TM-2_CPU_4300_@_1.80GHz-with-gentoo-2.0.3
Timestamp of tree: Tue, 27 Sep 2011 18:30:01 +0000
distcc 3.1 i686-pc-linux-gnu [enabled]
app-shells/bash:          4.1_p9
dev-lang/python:          2.7.1-r1, 3.1.3-r1
dev-util/cmake:           2.8.4-r1
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.8.3-r1
sys-apps/sandbox:         2.4
sys-devel/autoconf:       2.68
sys-devel/automake:       1.9.6-r2, 1.11.1
sys-devel/binutils:       2.20.1-r1
sys-devel/gcc:            4.4.3-r3
sys-devel/gcc-config:     1.4.1-r1
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 2.6.36.1 (virtual/os-headers)
sys-libs/glibc:           2.11.3
Repositories: gentoo x-portage
ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="* -@EULA"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=core2 -O2 -pipe -mfpmath=sse"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=core2 -O2 -pipe -mfpmath=sse"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--buildpkg --jobs=2"
FEATURES="assume-digests binpkg-logs distcc distlocks ebuild-locks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="ftp://ftp.free.fr/mirrors/ftp.gentoo.org ftp://mirror.ovh.net/gentoo-distfiles http://gentoo.mirror.sdv.fr/  http://gentoo.oregonstate.edu/ http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LANG="fr_FR.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="fr fr_FR"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl berkdb bzip2 cli cracklib crypt cxx dri fortran gdbm gpm iconv modules mudflap ncurses nls nptl nptlonly openmp pam pcre pppd readline session snmp ssl sysfs tcpd truetype unicode x86 xml xorg zlib" ALSA_CARDS="intel8x0" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="fr fr_FR" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="vesa nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Zac Medico gentoo-dev 2011-10-28 19:17:25 UTC
(In reply to comment #0)
> ls -l gperf*
> -rw-rw-r-- 1 portage portage 983500 28 oct.  11:24 gperf-3.0.4.tar.gz

FEATURES=userfetch is enabled by default, which causes the fetcher to run as the portage user. This safer than running the fetcher with superuser privileges, since the fetcher might have some vulnerability that can be exploited. IIRC, there was a recent GLSA issued for wget.

> ls -l .gperf*
> -rw-rw---- 1 root portage 0 28 oct.  11:24 .gperf-3.0.4.tar.gz.portage_lockfile

The lock file is created by the parent process, which runs as root. It gives write permission to the portage group, so that anyone in the portage group can open the lock in write mode, for purposes of cooperation.

> It will of course cause issues on an export distfiles with strict user rules
> set.

You'll have to be more specific about the "issues", because the current behavior is fine as far as I know.
Comment 3 nobody 2011-10-28 23:39:44 UTC
if you use root squash, portage lost ability to handle the lock file.

I'm not really sure what this will do except the manpage say :
"Portage uses  lockfiles  to  ensure  competing  instances
                     don't clobber each other's files."

if portage drop also priviledges to handle its lock files, it won't get squash and the feature won't get lost.
Comment 4 Zac Medico gentoo-dev 2011-10-29 00:10:40 UTC
(In reply to comment #3)
> if you use root squash, portage lost ability to handle the lock file.

What are the specifics of the actual error? Does creation of the lock file fail because it tries to create it with the root uid? Or does it fail to change the uid or permissions of the lock file after it's created?

> I'm not really sure what this will do except the manpage say :
> "Portage uses  lockfiles  to  ensure  competing  instances
>                      don't clobber each other's files."

For example, you have two different emerge instances trying to fetch the same file, one will wait for the other one to fetch the file. That prevents them from interfering with each other.

> if portage drop also priviledges to handle its lock files, it won't get squash
> and the feature won't get lost.

I'd prefer not to drop privileges for this unless it's absolutely necessary.
Comment 5 nobody 2011-10-29 02:31:56 UTC
no issue finally, portage then fail to set root and just leave the lock file as portage user
ls -l .*
-rw-rw---- 1 portage portage    0 29 oct.  04:27 .OOo_3.3.0_Linux_x86_install-rpm_en-US.tar.gz.portage_lockfile

so it works, sorry for your time lost.