Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: William Hubbs <williamh@g.o>
Subject: Re: [gentoo-dev] [PATCH] user.eclass: die if hard coded UID or GID is already in use
Date: Tue, 28 May 2019 05:10:24
Message-Id: 6c7375c1a8dcb287a30bf4609d00bdbacffa8d8b.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH] user.eclass: die if hard coded UID or GID is already in use by William Hubbs
1 On Mon, 2019-05-27 at 10:45 -0500, William Hubbs wrote:
2 > If a package hard codes the UID or GID when adding a user or group to
3 > the system and that UID/GID already exists, we should abort rather than
4 > changing the UID/GID.
5
6 I think the major usage of this argument is not to enforce a specific
7 UID/GID but to specify a 'preferred' UID/GID, i.e. somewhat attempt
8 to build Gentoo systems with stable UID/GIDs. That's why it's non-
9 fatal.
10
11 I don't have a strong opinion on changing it. I don't know if we have
12 any actual use cases where UID/GID needs to be enforced.
13
14 > ---
15 > eclass/user.eclass | 6 ++++--
16 > 1 file changed, 4 insertions(+), 2 deletions(-)
17 >
18 > diff --git a/eclass/user.eclass b/eclass/user.eclass
19 > index f6a10a6bee2..0d0f9d9eb89 100644
20 > --- a/eclass/user.eclass
21 > +++ b/eclass/user.eclass
22 > @@ -130,7 +130,8 @@ enewuser() {
23 > if [[ -n ${euid} && ${euid} != -1 ]] ; then
24 > if [[ ${euid} -gt 0 ]] ; then
25 > if [[ -n $(egetent passwd ${euid}) ]] ; then
26 > - euid="next"
27 > + eerror "UID is already taken"
28 > + die "user ${euser} needs a new UID"
29 > fi
30 > else
31 > eerror "Userid given but is not greater than 0 !"
32 > @@ -290,7 +291,8 @@ enewgroup() {
33 > if [[ ! -z ${egid} ]] ; then
34 > if [[ ${egid} -gt 0 ]] ; then
35 > if [[ -n $(egetent group ${egid}) ]] ; then
36 > - egid="next available; requested gid taken"
37 > + eerror "GID is already taken"
38 > + die "group ${egroup} needs a new GID"
39 > fi
40 > else
41 > eerror "Groupid given but is not greater than 0 !"
42
43 --
44 Best regards,
45 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature