Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 686756 - Portage warning message when running as unprivileged user - Directory initialization failed: '/var/lib/portage'
Summary: Portage warning message when running as unprivileged user - Directory initial...
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: 2019-05-25 20:07 UTC by Francesco Turco
Modified: 2019-05-26 09:09 UTC (History)
0 users

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


Attachments
info.txt (info.txt,16.45 KB, text/plain)
2019-05-25 20:08 UTC, Francesco Turco
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Francesco Turco 2019-05-25 20:07:34 UTC
Portage shows the following error messages when running as from an unprivileged user (fturco): 

$ emerge -p gcc 
!!! Directory initialization failed: '/var/lib/portage' 
!!! chown('/var/lib/portage', -1, 1000) 
!!! Directory initialization failed: '/var/cache/edb' 
!!! chown('/var/cache/edb', -1, 1000) 

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

Calculating dependencies... done! 
[ebuild   R    ] sys-devel/gcc-9.1.0

Some other info from my system: 

$ id fturco 
uid=1000(fturco) gid=1000(fturco) groups=1000(fturco),18(audio),19(cdrom),249(input),7(lp),106(lpadmin),105(plugdev),250(portage),101(scanner),85(usb),100(users),27(video),10(wheel)

$ id portage 
uid=250(portage) gid=250(portage) groups=250(portage)

The emerge --info -v command returns the following variables: 

PORTAGE_GID="1000" 
PORTAGE_INST_GID="1000" 
PORTAGE_INST_UID="1000" 
PORTAGE_USERNAME="fturco"

I haven't explicitely set any of the previous portage variables in any file under the /etc/portage directory.

The following commands display nothing: 

grep PORTAGE_USERNAME -r /var/db/repos /etc/portage 
grep PORTAGE_GID -r /var/db/repos /etc/portage 
grep PORTAGE_INST_GID -r /var/db/repos /etc/portage 
grep PORTAGE_INST_UID -r /var/db/repos /etc/portage

I found a Funtoo bug report with a similar problem, but I can't understand how to apply their solution to my situation.

https://bugs.funtoo.org/browse/FL-3120

I also reported this problem on the Gentoo Forums before filing this bug:

https://forums.gentoo.org/viewtopic-p-8336808.html

The following command doesn't fix the problem:

chown -R portage:portage /var/cache/distfiles /var/cache/binpkgs /var/db/repos

I have sys-apps/portage-2.3.66-r1.

Reproducible: Always
Comment 1 Francesco Turco 2019-05-25 20:08:32 UTC
Created attachment 577798 [details]
info.txt

emerge --info -v
Comment 2 Zac Medico gentoo-dev 2019-05-25 20:20:45 UTC
I looks like your user has write access to the root directory /, so you're triggering unprivileged mode (bug 433453):

> # If the current user is not root, but has write access to the
> # EROOT directory (not due to the 0002 bit), then use "unprivileged"
> # mode which sets secpass = 2 and uses the UID and GID of the EROOT
> # directory to generate default PORTAGE_INST_GID, PORTAGE_INST_UID,
> # PORTAGE_USERNAME, and PORTAGE_GRPNAME settings.
> def _unprivileged_mode(eroot, eroot_st):
> 	return os.getuid() != 0 and os.access(eroot, os.W_OK) and \
> 		not eroot_st.st_mode & 0o0002
Comment 3 Francesco Turco 2019-05-26 09:09:18 UTC
You're right. My root directory (/) had fturco:fturco user and group permissions. 

I fixed that with:

# chown root:root /

Thank you! I feel I can now close this bug.