Gentoo Archives: gentoo-dev

From: Jaco Kroon <jaco@××××××.za>
To: gentoo-dev@l.g.o, "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-dev] [PATCH] acct-*.eclass: Allow dynamic UID/GID assignment via -1
Date: Mon, 19 Aug 2019 09:47:38
Message-Id: 766d0740-f10b-8479-4cec-e90769fe7b1e@uls.co.za
In Reply to: Re: [gentoo-dev] [PATCH] acct-*.eclass: Allow dynamic UID/GID assignment via -1 by "Michał Górny"
1 Thank you.
2
3
4 Kind Regards,
5 Jaco
6
7
8 On 2019/08/17 22:37, Michał Górny wrote:
9
10 > On Wed, 2019-08-07 at 19:10 +0200, Michał Górny wrote:
11 >> Allow a special value of '-1' to dynamically assign UID/GID for the user
12 >> or group. This is intended to be used in overlays where proper
13 >> assignment does not take place but whose owners wish to switch to acct-*
14 >> packages.
15 >>
16 >> While technically it is possible to choose a free UID/GID, it could be
17 >> taken afterwards by some Gentoo package and unnecessarily introduce
18 >> a conflict. Using '999' was also suggested (as the first dynamic
19 >> UID/GID) but it would cause issues for people enabling
20 >> ACCT_*_ENFORCE_ID. To avoid this, '-1' does not trigger collision
21 >> checks.
22 >>
23 >> Signed-off-by: Michał Górny <mgorny@g.o>
24 >> ---
25 >> eclass/acct-group.eclass | 4 ++++
26 >> eclass/acct-user.eclass | 4 ++++
27 >> 2 files changed, 8 insertions(+)
28 >>
29 >> diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass
30 >> index 9eab00db690f..d5ccd209c9e3 100644
31 >> --- a/eclass/acct-group.eclass
32 >> +++ b/eclass/acct-group.eclass
33 >> @@ -59,6 +59,9 @@ readonly ACCT_GROUP_NAME
34 >> # @DESCRIPTION:
35 >> # Preferred GID for the new group. This variable is obligatory, and its
36 >> # value must be unique across all group packages.
37 >> +#
38 >> +# Overlays should set this to -1 to dynamically allocate GID. Using -1
39 >> +# in ::gentoo is prohibited by policy.
40 >>
41 >> # @ECLASS-VARIABLE: ACCT_GROUP_ENFORCE_ID
42 >> # @DESCRIPTION:
43 >> @@ -87,6 +90,7 @@ acct-group_pkg_pretend() {
44 >>
45 >> # verify ACCT_GROUP_ID
46 >> [[ -n ${ACCT_GROUP_ID} ]] || die "Ebuild error: ACCT_GROUP_ID must be set!"
47 >> + [[ ${ACCT_GROUP_ID} -eq -1 ]] && return
48 >> [[ ${ACCT_GROUP_ID} -ge 0 ]] || die "Ebuild errors: ACCT_GROUP_ID=${ACCT_GROUP_ID} invalid!"
49 >>
50 >> # check for ACCT_GROUP_ID collisions early
51 >> diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
52 >> index 60009643c144..17a58e9126e4 100644
53 >> --- a/eclass/acct-user.eclass
54 >> +++ b/eclass/acct-user.eclass
55 >> @@ -67,6 +67,9 @@ readonly ACCT_USER_NAME
56 >> # @DESCRIPTION:
57 >> # Preferred UID for the new user. This variable is obligatory, and its
58 >> # value must be unique across all user packages.
59 >> +#
60 >> +# Overlays should set this to -1 to dynamically allocate GID. Using -1
61 >> +# in ::gentoo is prohibited by policy.
62 >>
63 >> # @ECLASS-VARIABLE: ACCT_USER_ENFORCE_ID
64 >> # @DESCRIPTION:
65 >> @@ -279,6 +282,7 @@ acct-user_pkg_pretend() {
66 >>
67 >> # verify ACCT_USER_ID
68 >> [[ -n ${ACCT_USER_ID} ]] || die "Ebuild error: ACCT_USER_ID must be set!"
69 >> + [[ ${ACCT_USER_ID} -eq -1 ]] && return
70 >> [[ ${ACCT_USER_ID} -ge 0 ]] || die "Ebuild errors: ACCT_USER_ID=${ACCT_USER_ID} invalid!"
71 >>
72 >> # check for ACCT_USER_ID collisions early
73 > Pushed now.