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

Bug 517712

Summary: user.eclass: enewgroup() does not respect ROOT=
Product: Gentoo Linux Reporter: Joakim Tjernlund <joakim.tjernlund>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Severity: normal CC: devurandom
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---

Description Joakim Tjernlund 2014-07-21 18:20:17 UTC
Trying to cross build sys-fs/udev as normal user fails with:

 * Adding group 'input' to your system ...
 *  - Groupid: next available
groupadd: Permission denied.
groupadd: cannot lock /etc/group; try again later.
 * ERROR: sys-fs/udev-215::gentoo failed (postinst phase):
 *   (no error message)
 * Call stack:
 *, line   93:  Called pkg_postinst
 *   environment, line 4350:  Called enewgroup 'input'
 *   environment, line 1802:  Called die
 * The specific snippet of code:
 *               groupadd -r ${opts} "${egroup}" || die
 * If you need support, post the output of `emerge --info '=sys-fs/udev-215::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-fs/udev-215::gentoo'`.
 * The complete build log is located at '/usr/x86_64-tm-linux-gnu/tmp/portage/sys-fs/udev-215/temp/build.log'.
 * The ebuild environment file is located at '/usr/x86_64-tm-linux-gnu/tmp/portage/sys-fs/udev-215/temp/environment'.
 * Working directory: '/usr/local/src/portage/pym'
 * S: '/usr/x86_64-tm-linux-gnu/tmp/portage/sys-fs/udev-215/work/systemd-215'
!!! FAILED postinst: 1

This could probably be resolved  by adding --root $ROOT to groupadd in
Comment 1 Joakim Tjernlund 2014-07-21 19:00:02 UTC
The same goes for useradd which also has a --root option
Comment 2 Joakim Tjernlund 2014-07-21 19:19:58 UTC
hmm, just did a test with --root option and it turns out that groupadd really
tries to do a chroot so it will fail again.
Comment 3 Joakim Tjernlund 2014-07-23 09:21:35 UTC
Got an idea, use sys-apps/proot to bind mount $ROOT/etc over /etc and
then run group add:
 proot -0 --bind=${ROOT}/etc:/etc /usr/sbin/groupadd -r ${opts} "${egroup}" || die

This actually works!
Should be usable for all group/user related tasks.

What do you think of using proot in user.eclass?
Comment 4 Joakim Tjernlund 2014-07-24 15:02:35 UTC
proot is only avaliaable on x86/amd64 so that won't work well.

Wrapping the groupadd call in:
if [[ ${ROOT} == / ]] ; then
would be apropiate though, with some msg that groupadd has been skipped.

same for enewuser etc.

No comment so far, anyone home ?
Comment 5 SpanKY gentoo-dev 2014-07-31 13:32:44 UTC

*** This bug has been marked as a duplicate of bug 53269 ***