Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 329289 - eutils.eclass - enewuser/enewgroup adds users/groups to the build machine instead of the build target designed by $ROOT
Summary: eutils.eclass - enewuser/enewgroup adds users/groups to the build machine ins...
Status: RESOLVED DUPLICATE of bug 266246
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-21 15:13 UTC by Hugo Chargois
Modified: 2010-07-25 18:42 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 Hugo Chargois 2010-07-21 15:13:47 UTC
Functions enewuser and enewgroup of eclass eutils adds the new users and groups to the /etc/passwd and /etc/group of the host/build machine, regardless of $ROOT.
If using $ROOT to specify a target system to build, the expected behaviour would be to modify $ROOT/etc/passwd and $ROOT/etc/group.

Reproducible: Always

Steps to Reproduce:
1. Set ROOT variable to a target system, other than /
2. Install a package that uses enewuser or enewgroup (apache, trac, openssh, dhcp...)

Actual Results:  
/etc/passwd, /etc/shadow and /etc/group are modified with the new users/groups, $ROOT/etc/passwd, $ROOT/etc/shadow and $ROOT/etc/group are untouched.

Expected Results:  
/etc/{passwd,shadow,group} left untouched, $ROOT/etc/{passwd,shadow,group} modified with the new users/groups added.

Proposed fix:
enewuser and enewgroup defers user and group creation to useradd and groupadd. chroot to $ROOT when calling these programs.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2010-07-21 16:28:45 UTC
Ebuild developers should take care to only add these users/groups to the build host when the build system (configure/compile/install phases) fail without them, and equally that the users/groups are added to the target system too.

For the first purpose we have the pkg_setup() phase. The pkg_preinst() and pkg_postinst phases are there to introduce new users/groups to the target system.

However, there is nothing wrong with the concepts of enewuser and enewgroup themselves - what you could provide instead are examples of where the use of these functions goes wrong, and file separate bugs for separate cat-egory/pkg's.
Comment 2 Hugo Chargois 2010-07-21 17:22:23 UTC
(In reply to comment #1)
You are right about making the distinction between the build-time and run-time, where new users/groups need to be added to the build system and to the target system, respectively.

Yet, even compliant ebuilds (eg. net-misc/dhcp/dhcp-3.1.2_p1.ebuild) where enewuser/enewgroup are used in an install function (pkg_preinst in the case of dhcp) do not work properly. The group and user 'dhcp' get added on the build system.

That is understandable and expected from the code of enew{user,group} since it doesn't check for the $EBUILD_PHASE if it is setup or preinst or postinst, and it just calls useradd and groupadd without any reference to $ROOT.

btw, it checks if $EBUILD_PHASE is unpack|compile|test|install but not prepare which is a sandboxed function too, isn't that a mistake?

Proposed fix:
replace useradd (groupadd) with a wrapper that would check $EBUILD_PHASE and run useradd (groupadd) directly if it is setup, and run chroot $ROOT useradd (groupadd) if it is preinst or postinst.
Comment 3 SpanKY gentoo-dev 2010-07-25 18:42:25 UTC

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