Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 729178

Summary: linux-info.eclass: linux_info_pkg_setup M="${S}" setting creates ${S} with root ownership which breaks builds with FEATURES=userpriv
Product: Portage Development Reporter: Tobias Klausmann (RETIRED) <klausman>
Component: UnclassifiedAssignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers <kernel>
Status: RESOLVED FIXED    
Severity: normal CC: dev-portage, fedora.dm0, kernel, mbartoszkiewicz, mceier, ulm
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=469210
Whiteboard:
Package list:
Runtime testing required: ---

Description Tobias Klausmann (RETIRED) gentoo-dev 2020-06-22 13:44:29 UTC
# emerge -av1 portage

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] sys-apps/portage-2.3.101-r2::gentoo [2.3.99-r2::gentoo] USE="(ipc) native-extensions rsync-verify xattr -apidoc -build -doc -gentoo-dev (-selinux)" PYTHON_TARGETS="python3_7 -pypy3 -python3_6 -python3_8 -python3_9%" 0 KiB

Total: 1 package (1 upgrade), Size of downloads: 0 KiB

Would you like to merge these packages? [Yes/No] 

>>> Verifying ebuild manifests
>>> Running pre-merge checks for sys-apps/portage-2.3.101-r2
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     5.8.0-rc2
 * Checking for suitable kernel configuration options...                                                                                                                                                                               [ ok ]

>>> Emerging (1 of 1) sys-apps/portage-2.3.101-r2::gentoo
 * portage-2.3.101.tar.bz2 BLAKE2B SHA512 size ;-) ...                                                                                                                                                                                 [ ok ]
 * portage-2.3.101-revert2-bug-709746.patch BLAKE2B SHA512 size ;-) ...                                                                                                                                                                [ ok ]
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     5.8.0-rc2
>>> Unpacking source...
>>> Unpacking portage-2.3.101.tar.bz2 to /var/tmp/portage/sys-apps/portage-2.3.101-r2/work
tar: portage-2.3.101/PKG-INFO: Cannot open: Permission denied
tar: portage-2.3.101/setup.py: Cannot open: Permission denied
tar: portage-2.3.101/TEST-NOTES: Cannot open: Permission denied
tar: portage-2.3.101/RELEASE-NOTES: Cannot open: Permission denied
tar: portage-2.3.101/README: Cannot open: Permission denied
tar: portage-2.3.101/NEWS: Cannot open: Permission denied


# emerge --info
Portage 2.3.99 (python 3.7.7-final-0, default/linux/amd64/17.1, gcc-10.1.0, glibc-2.31-r5, 5.7.0-rc5 x86_64)
=================================================================
System uname: Linux-5.7.0-rc5-x86_64-AMD_Ryzen_7_1700X_Eight-Core_Processor-with-gentoo-2.7
KiB Mem:    32879264 total,  18736964 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Mon, 22 Jun 2020 12:05:24 +0000
Head commit of repository gentoo: d2c54a4200c881868025430587613969bbe7a8b2

Head commit of repository steam-overlay: ae3e928b83b722ae6197fc1bc78859b592b819e5

sh bash 5.0_p17
ld GNU ld (Gentoo 2.34 p4) 2.34.0
app-shells/bash:          5.0_p17::gentoo
dev-lang/perl:            5.30.3-r1::gentoo
dev-lang/python:          2.7.18::gentoo, 3.6.10-r2::gentoo, 3.7.7-r2::gentoo, 3.8.3::gentoo
dev-util/cmake:           3.17.2::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.2::gentoo
sys-devel/binutils:       2.34-r1::gentoo
sys-devel/gcc:            10.1.0-r1::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.7::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r5::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo
    priority: -1000

local
    location: /usr/local/portage
    masters: gentoo
    priority: 0

klausman-tinkerforge
    location: /var/lib/layman/klausman-tinkerforge
    masters: gentoo
    priority: 50

steam-overlay
    location: /usr/local/portage/steam-overlay
    sync-type: git
    sync-uri: https://github.com/anyc/steam-overlay.git
    masters: gentoo
    priority: 50

Installed sets: @steam
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=native -fno-omit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=native -fno-omit-frame-pointer"
DISTDIR="/mnt/moep/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="https://mirror.init7.net/gentoo"
LANG="en_US.utf8"
LC_ALL="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--exclude lost+found"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X acl alsa amd64 audiofile bash-completion berkdb bmp bzip2 caps cdparanoia cdr cli crypt dri encode exif ffmpeg fftw fortran gdbm gif glamor gtk iconv idn ipv6 jpeg lame lcms libass libtirpc lua mad matroska mmap mng mp3 mpeg multilib ncurses nls nptl ogg opengl openmp pam pcre png ppds pulseaudio python qt4 qt5 readline recode seccomp split-usr ssl svg tcpd theora unicode usb v4l vaapi vdpau vim vim-pager vim-syntax vlm vorbis wmf xattr xcb xinerama xosd xpm xrandr xscreensaver xvid xvmc zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="emu10k1 ice1724" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd 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="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7" QEMU_SOFTMMU_TARGETS="i386 x86_64 alpha aarch64" QEMU_USER_TARGETS="i386 x86_64 alpha aarch64" RUBY_TARGETS="ruby25" SANE_BACKENDS="canon microtek microtek2 mustek mustek_usb nec plustek" USERLAND="GNU" VIDEO_CARDS="vesa amdgpu r300 r600 radeonsi" 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:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS


Note that most tarballs work fine (so it's not a mount options problem). So far I have found that besides portage mentioned above, media-libs/mesa-20.1.1 also fails in the same way.
Comment 1 jospezial 2020-06-22 19:44:05 UTC
* Fetching https://anongit.gentoo.org/git/proj/portage.git ...
git fetch https://anongit.gentoo.org/git/proj/portage.git +HEAD:refs/git-r3/HEAD
git symbolic-ref refs/git-r3/sys-apps/portage/0/__main__ refs/git-r3/HEAD
 * Checking out https://anongit.gentoo.org/git/proj/portage.git to /var/tmp/portage/sys-apps/portage-9999/work/portage-9999 ...
/var/tmp/portage/sys-apps/portage-9999/work/portage-9999/.git: Permission denied
 * ERROR: sys-apps/portage-9999::gentoo failed (unpack phase):
 *   (no error message)
Comment 2 Mariusz Ceier 2020-06-23 11:12:25 UTC
I have the same issue with sys-apps/portage-2.3.101-r2 and in order to merge some packages (tested with mesa, portage, qemu) I have to remove userpriv from the FEATURES.

Downgrading to sys-apps/portage-2.3.100-r1 doesn't help, so I guess it's some eclass bug.
Comment 3 Michał Bartoszkiewicz 2020-06-23 14:49:06 UTC
It seems that ${S} is created as root:root before src_unpack.
I think it is related to linux-info.eclass running the kernel Makefile with M=${S} to check the config.

The problem form me only occurs on one of three similar hosts – one with Linux 5.8-rc2 in /usr/src/linux.
Comment 4 Michał Bartoszkiewicz 2020-06-23 14:57:34 UTC
It seems that the kernel Makefile from Linux v5.8-rc2 always creates ${M}, while earlier didn't:

$ git reset --hard v5.8-rc1; rm -r foo; echo -e 'e: \ninclude Makefile' | make -f - M=$PWD/foo; ls -ld foo
HEAD is now at b3a9e3b9622a Linux 5.8-rc1
arch/x86/Makefile:147: CONFIG_X86_X32 enabled but no binutils support
arch/x86/Makefile:168: Disabling CONFIG_CC_OPTIMIZE_FOR_SIZE.  Your compiler does not have -mfentry so you cannot optimize for size with CONFIG_FUNCTION_GRAPH_TRACER.
make: Nothing to be done for 'e'.
ls: cannot access 'foo': No such file or directory
$ git reset --hard v5.8-rc2; rm -r foo; echo -e 'e: \ninclude Makefile' | make -f - M=$PWD/foo; ls -ld foo
HEAD is now at 48778464bb7d Linux 5.8-rc2
rm: cannot remove 'foo': No such file or directory
make: Nothing to be done for 'e'.
drwxr-xr-x 1 embe embe 0 06-23 16:53 foo

which causes linux-info.eclass to create ${S} as root before src_unpack, causing permission errors.
Comment 5 Mariusz Ceier 2020-06-23 15:16:48 UTC
(In reply to Michał Bartoszkiewicz from comment #4)
> It seems that the kernel Makefile from Linux v5.8-rc2 always creates ${M},
> while earlier didn't:
> 

I confirm that I also have v5.8-rc2.
Comment 6 Zac Medico gentoo-dev 2020-06-23 16:58:29 UTC
Please test this eclass fix:

> diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
> index 405ef5571e1..d043b2c4492 100644
> --- a/eclass/linux-info.eclass
> +++ b/eclass/linux-info.eclass
> @@ -187,3 +187,3 @@ getfilevar() {
>                 case ${EBUILD_PHASE_FUNC} in
> -                       pkg_info|pkg_nofetch|pkg_pretend) M="${T}" ;;
> +                       pkg_info|pkg_nofetch|pkg_pretend|pkg_setup) M="${T}" ;;
>                 esac
Comment 7 Michał Bartoszkiewicz 2020-06-23 17:01:34 UTC
(In reply to Zac Medico from comment #6)
> Please test this eclass fix:
> 
> > diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
> > index 405ef5571e1..d043b2c4492 100644
> > --- a/eclass/linux-info.eclass
> > +++ b/eclass/linux-info.eclass
> > @@ -187,3 +187,3 @@ getfilevar() {
> >                 case ${EBUILD_PHASE_FUNC} in
> > -                       pkg_info|pkg_nofetch|pkg_pretend) M="${T}" ;;
> > +                       pkg_info|pkg_nofetch|pkg_pretend|pkg_setup) M="${T}" ;;
> >                 esac

This fixes the problem for me.
Comment 8 Ulrich Müller gentoo-dev 2020-06-23 17:08:45 UTC
Also note that S is only valid in src_* phases.

PMS reference: https://projects.gentoo.org/pms/7/pms.html#x1-109002
Comment 9 Mariusz Ceier 2020-06-23 17:09:37 UTC
(In reply to Zac Medico from comment #6)
> Please test this eclass fix:
> 
> > diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
> > index 405ef5571e1..d043b2c4492 100644
> > --- a/eclass/linux-info.eclass
> > +++ b/eclass/linux-info.eclass
> > @@ -187,3 +187,3 @@ getfilevar() {
> >                 case ${EBUILD_PHASE_FUNC} in
> > -                       pkg_info|pkg_nofetch|pkg_pretend) M="${T}" ;;
> > +                       pkg_info|pkg_nofetch|pkg_pretend|pkg_setup) M="${T}" ;;
> >                 esac

This fixes the issue for me.
Comment 10 Ulrich Müller gentoo-dev 2020-06-24 15:35:50 UTC
(In reply to Zac Medico from comment #6)
> Please test this eclass fix:
> 
> > diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
> > index 405ef5571e1..d043b2c4492 100644
> > --- a/eclass/linux-info.eclass
> > +++ b/eclass/linux-info.eclass
> > @@ -187,3 +187,3 @@ getfilevar() {
> >                 case ${EBUILD_PHASE_FUNC} in
> > -                       pkg_info|pkg_nofetch|pkg_pretend) M="${T}" ;;
> > +                       pkg_info|pkg_nofetch|pkg_pretend|pkg_setup) M="${T}" ;;
> >                 esac

Looking at the fix again, I wonder if the eclass couldn't just use M="${T}" unconditionally.

M is the object output dir used by the Linux Makefile. It was added in this commit: https://gitweb.gentoo.org/repo/gentoo/historical.git/commit/?id=bba72b7037d567f5d9147be6c6998c1e90c4b9d4
Comment 11 Larry the Git Cow gentoo-dev 2020-06-26 20:12:16 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5a3acd443c3347568d14d000776f46177317744a

commit 5a3acd443c3347568d14d000776f46177317744a
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2020-06-24 16:00:10 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2020-06-26 20:11:12 +0000

    linux-info.eclass: Pass M=${T} to the Linux Makefile unconditionally.
    
    Using M="${S}" breaks in the pkg_setup phase where the S variable is
    not valid. Previous commit messages don't give any rationale why some
    phases would need the dir pointing to ${S}. Therefore, use ${T} in all
    phases unconditionally.
    
    Closes: https://bugs.gentoo.org/729178
    Bug: https://bugs.gentoo.org/469210
    Acked-by: Thomas Deutschmann <whissi@gentoo.org>
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 eclass/linux-info.eclass | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)