Gentoo Archives: gentoo-dev

From: Alec Warner <antarus@g.o>
To: Gentoo Dev <gentoo-dev@l.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 18:35:09
Message-Id: CAAr7Pr-=gBKLbX=zMT1QSUDACLGJhBijwrEy36zrSYP_JyaYyg@mail.gmail.com
In Reply to: Re: [gentoo-dev] [PATCH] user.eclass: die if hard coded UID or GID is already in use by Mike Gilbert
1 On Tue, May 28, 2019 at 11:05 AM Mike Gilbert <floppym@g.o> wrote:
2
3 > On Tue, May 28, 2019 at 10:43 AM William Hubbs <williamh@g.o>
4 > wrote:
5 > >
6 > > On Tue, May 28, 2019 at 02:21:23AM -0400, Mike Gilbert wrote:
7 > > > On Tue, May 28, 2019 at 1:41 AM Robin H. Johnson <robbat2@g.o>
8 > wrote:
9 > > > >
10 > > > > On Mon, May 27, 2019 at 08:44:09PM -0400, Mike Gilbert wrote:
11 > > > > > On Mon, May 27, 2019 at 11:45 AM William Hubbs <
12 > williamh@g.o> wrote:
13 > > > > > >
14 > > > > > > If a package hard codes the UID or GID when adding a user or
15 > group to
16 > > > > > > the system and that UID/GID already exists, we should abort
17 > rather than
18 > > > > > > changing the UID/GID.
19 > > > > > These functions have behaved this way for a long time.
20 > > > > Yes, I recall this breakage being raised even prior to GLEP27.
21 > > > >
22 > > > > Some coverage of prior work firstly.
23 > > > > 2003/May: eid_database [1]
24 > > > > 2004/May: GLEP27 [2]
25 > > > > 2006/Summer: GSOC Project for GLEP27 implementation [3]
26 > > > > Later: Creandus [4][5]
27 > > > >
28 > > > > [1]
29 > https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-src/eid_database/
30 > > > > [2] https://www.gentoo.org/glep/glep-0027.html
31 > > > > [3]
32 > https://github.com/creandus/creandus.github.com/blob/master/glep27-proposal.txt
33 > > > > [4] https://github.com/creandus/
34 > > > > [5] http://creandus.github.io/
35 > > > >
36 > > > > > What problem are you trying to solve here?
37 > > > > Specifically:
38 > > > > 1. Package A is emerged, and the ebuild specifies enewuser/enewgroup
39 > > > > with -1 as the numeric input, and some user or group is created with
40 > > > > value X.
41 > > > > 2. Package B is emerged, and the ebuild specifies enewuser/enewgroup
42 > > > > with a fixed UID/GID value Y && explicitly depends on having that
43 > > > > specific value.
44 > > >
45 > > > Could you provide some examples of packages that require a specific
46 > > > numeric UID/GID to function properly? That seems like a significant
47 > > > design flaw.
48 > >
49 > > The example I specifically found was kubernetes security contexts -- to
50 > > set one of these up, you need numeric uids/gids [1].
51 > >
52 > > [1]
53 > https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
54 > >
55 > > I agree this could be possibly seen as a flaw, but I don't know enough
56 > > about kubernetes to know if symbolic uids/gids could be used.
57 > >
58 > > I am speculating here, but I'm guessing that if the pod spans
59 > > multiple hosts, the uids/gids might need to be the same, which would
60 > > require fixed UIDs/GIDs.
61 >
62 > Your kubernetes example is not a very compelling one. Firstly, none of
63 > the kubernetes-related ebuilds in the gentoo repo actually call
64 > enewuser or enewgroup with a static id. Secondly, I would expect the
65 > sysadmin of a kubernetes cluster to allocate a UID/GID range outside
66 > the "system range" defined in /etc/login.defs.
67 >
68 > > > As mgorny suggests, I suspect the static UID/GID that is sometimes
69 > > > passed to enewuser/enewgroup is more of a preference/suggestion than a
70 > > > requirement.
71 > > >
72 > > > I do not believe William's patch should be merged without some very
73 > > > good reason for the change in behavior.
74 > >
75 > > Consider this situation:
76 > >
77 > > in package-a.ebuild:
78 > > enewuser usera 300 ...
79 > > enewgroup groupa 300 ...
80 > >
81 > > in package-b.ebuild:
82 > > enewuser userb 300 ...
83 > > enewgroup groupb 300 ...
84 > >
85 > > Ok, cool, if I need a security context for package b, the uid/gid is 300
86 > > correct? Yes, unless package a gets installed on some host where package
87 > > b is without me knowing about it.
88 > >
89 > > I see no way around this other than to make uids/gids fixed when
90 > > packages request specific ones.
91 >
92 > If you are running a cluster system that requires static ids, you
93 > should really create these ids yourself as part of the cluster node
94 > setup process.
95 >
96
97 Pretty much +1 to this. I agree this is a problem as many services use
98 shared uid / gid to handle authorization. I'm not convinced solving this
99 problem at the package manager level is correct, so every time its proposed
100 I vote no.
101
102 If you need to share UID / GID, across hosts, there are many solutions
103 available.
104 - lib_nssldap
105 - lib_nsscache
106 - lib_nssfiles with configuration management on top.
107
108 These are all strictly better than trying to do this in ebuilds.
109
110 -A