Gentoo Archives: gentoo-dev

From: Farid BENAMROUCHE <fariouche@×××××.fr>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Modification proposal for user/group creation when ROOT!="/"
Date: Tue, 24 May 2016 19:00:39
Message-Id: 1187243158.3442649.1464116425074.JavaMail.yahoo@mail.yahoo.com
1 Hi all,
2
3 Currently there is an old known limitation when using ROOT= option to install a package in a folder: user/groups are created in the host filesystem, not the target root filesystem.
4
5 So I've pushed some modifications to the upstream shadow repo.
6 Basically, I've added a --prefix option to user{add,mod,del} and group{add,mod,del}
7 This option does the same as --root option, but whithout a chroot (so compatible when cross compiling)
8 You can see more details (and the limitation of my implementation) in the shadow github repo:
9 https://github.com/shadow-maint/shadow/issues/18
10
11
12 Now, for the gentoo part, I do have a working solution that I've pushed in the following bugzilla:
13 https://bugs.gentoo.org/show_bug.cgi?id=541406
14
15 A new user.eclass file with modified enewuser,enewgroup and egetent that all supports ${ROOT} option via --prefix in shadow utilities.
16 For now I've only added this option for linux.
17
18 However, I've encountered some unexpected issues: some ebuilds are using direct calls to chown and fowners. Both are not compatible with ${ROOT}...
19
20 To solve this, I've created 2 new calls in user.eclass: echown and efowners.
21 The only thing the new functions are doing is to get the uid/gid from the correct passwd/group files from ${ROOT} using the modified egetent function and pass that to the native chown/fowners...
22
23 For example, in sys-power/nut we can find:
24 chown nut:nut ${ROOT}/var/lib/nut
25
26 This should be changed to
27 echown nut:nut ${ROOT}/var/lib/nut
28
29 Same to fowners.
30 If the modification is not done, either the ebuild will fail because the nut user does not exists in the host, or the incorrect uid will be user in ${ROOT}
31
32 The solution is not perfect, but at least better than what we have today, and totally usable I believe.
33
34 I've uploaded the patches for lighttpd and nut, plus my patch for user.eclass for review in this bug... we do have time until upstream shadow team reviews and commits my modifications (at least).
35
36 Side note: it's a bit complicated to know when to add ${ROOT} and when not in a ebuild... For example, chown needs ${ROOT} but fowners must not!...
37 Side note 2: maybe I should add a verification to check if useradd/groupadd supports my new --prefix solution, and fallback to original behavior if not?
38
39 Tests: I've compiled a full working system with my above solution, and it works. (cross compilation in a dedicated target root path)
40
41 Regards,
42 Farid

Replies