* [gentoo-dev] A script to pick next free UID/GID for your acct-* packages
@ 2021-02-09 17:43 Joonas Niilola
2021-02-09 17:51 ` Peter Stuge
0 siblings, 1 reply; 6+ messages in thread
From: Joonas Niilola @ 2021-02-09 17:43 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 3009 bytes --]
Hey all,
Summary:
There's a script by jkroon in data/api.git
(https://gitweb.gentoo.org/data/api.git/) that prints the next available
UID/GID pair for new acct-* packages. You can use it by:
cd ~/git/gentoo/data/api
git pull
sh bin/used_free_uidgids.sh
The outcome looks like this for those curious:
https://dev.gentoo.org/~juippis/pics/free_uid_gid_by_jkroon.png
Check the Author e-mail from the script to report bugs, and please open
pull requests here:
https://github.com/gentoo/api-gentoo-org
Story:
As someone who's pushed a few new UID/GID packages lately it was
becoming more and more tedious trying to find the next free number. And
I was personally becoming worried when we're going to run out of
available IDs.
Now a while back I asked half-jokingly someone to write a script that
finds the next free UID, GID and UID/GID, and also prints the current
number of free IDs <500 in #gentoo-dev IRC channel. Lucky for us all,
jkroon was up to the task.
I wanted the implementation to be "open for inspection" and available in
every system syncing data/api.git. So in my eyes the viable options were
using bash or python, and the current script is written in bash. We've
heard enough about using bash for this so please leave such comments out
from this thread. It is well documented and should be maintainable for
the time being, but if someone is up to re-writing it using some other
viable language (python), please go ahead! In its current state the
script works and is very useful!
Script's output looks like this:
#ID UID GID
...
317..320 FREE FREE
321 USED USED
322..326 FREE FREE
327..330 USED USED
331..332 USED FREE
333..372 USED USED
373 USED FREE
...
Recommended GID only: 460
Recommended UID only: 458
Recommended UID+GID both: 326
Free UIDs: 200
Free GIDs: 177
(note that FREE/USED are colourcoded for your convenience, check the
screenshot above!)
It is not forbidden to mix and mash UID/GID between different packages,
but I'd still suggest to find a new "pair" even if you push just an UID
or GID. Since we don't seem to be in danger of running out any time soon.
Please report bugs to Author (e-mail in the script), and for any fixes
open pull requests at https://github.com/gentoo/api-gentoo-org/
Not to any proxied maintainers (reading this far), a free UID/GID pair
will be given to you when your acct-* packages are merged, so you don't
have to reserve an ID beforehand. But it'd be great if you picked one
that is free when making your new acct-* packages so at least during
merge the next free one will be close to your chosen one.
Enjoy everyone, and huge thanks to jkroon!
-- juippis
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 618 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] A script to pick next free UID/GID for your acct-* packages
2021-02-09 17:43 [gentoo-dev] A script to pick next free UID/GID for your acct-* packages Joonas Niilola
@ 2021-02-09 17:51 ` Peter Stuge
2021-02-09 18:11 ` Mike Gilbert
2021-02-10 8:00 ` Jaco Kroon
0 siblings, 2 replies; 6+ messages in thread
From: Peter Stuge @ 2021-02-09 17:51 UTC (permalink / raw
To: gentoo-dev
Joonas Niilola wrote:
> There's a script by jkroon in data/api.git
> (https://gitweb.gentoo.org/data/api.git/) that prints the next available
> UID/GID pair for new acct-* packages.
This is super nice! Thanks a lot jkroon!
> It is not forbidden to mix and mash UID/GID between different packages,
> but I'd still suggest to find a new "pair" even if you push just an UID
> or GID. Since we don't seem to be in danger of running out any time soon.
Mh - so the obvious first feature request for the script is to also output
Free UID+GID pairs. Counting them manually in your screenshot I get 36.
That's not a whole lot; just 7% of 500.
//Peter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] A script to pick next free UID/GID for your acct-* packages
2021-02-09 17:51 ` Peter Stuge
@ 2021-02-09 18:11 ` Mike Gilbert
2021-02-09 19:23 ` Ulrich Mueller
2021-02-10 8:00 ` Jaco Kroon
1 sibling, 1 reply; 6+ messages in thread
From: Mike Gilbert @ 2021-02-09 18:11 UTC (permalink / raw
To: Gentoo Dev
On Tue, Feb 9, 2021 at 12:51 PM Peter Stuge <peter@stuge.se> wrote:
>
> Joonas Niilola wrote:
> > There's a script by jkroon in data/api.git
> > (https://gitweb.gentoo.org/data/api.git/) that prints the next available
> > UID/GID pair for new acct-* packages.
>
> This is super nice! Thanks a lot jkroon!
>
>
> > It is not forbidden to mix and mash UID/GID between different packages,
> > but I'd still suggest to find a new "pair" even if you push just an UID
> > or GID. Since we don't seem to be in danger of running out any time soon.
>
> Mh - so the obvious first feature request for the script is to also output
> Free UID+GID pairs. Counting them manually in your screenshot I get 36.
>
> That's not a whole lot; just 7% of 500.
The output was abbreviated. Here is the full output for entries where
both ids are FREE.
% bin/used_free_uidgids.sh | grep "FREE FREE"
23..24 FREE FREE
29..30 FREE FREE
34 FREE FREE
37..39 FREE FREE
41..42 FREE FREE
44 FREE FREE
49..52 FREE FREE
54..58 FREE FREE
67 FREE FREE
71..73 FREE FREE
83 FREE FREE
86..87 FREE FREE
90 FREE FREE
92..94 FREE FREE
96 FREE FREE
98 FREE FREE
104..105 FREE FREE
107..110 FREE FREE
112 FREE FREE
116 FREE FREE
118..121 FREE FREE
125..132 FREE FREE
134..138 FREE FREE
140..149 FREE FREE
151..152 FREE FREE
154..155 FREE FREE
159..166 FREE FREE
168 FREE FREE
170 FREE FREE
173..176 FREE FREE
179..182 FREE FREE
185 FREE FREE
187 FREE FREE
189 FREE FREE
210..211 FREE FREE
213..218 FREE FREE
224..229 FREE FREE
231 FREE FREE
233..234 FREE FREE
238 FREE FREE
244 FREE FREE
246..249 FREE FREE
251 FREE FREE
253..264 FREE FREE
266 FREE FREE
279..289 FREE FREE
293..298 FREE FREE
311..314 FREE FREE
317..320 FREE FREE
322..326 FREE FREE
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] A script to pick next free UID/GID for your acct-* packages
2021-02-09 18:11 ` Mike Gilbert
@ 2021-02-09 19:23 ` Ulrich Mueller
2021-02-09 23:37 ` Mike Gilbert
0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Mueller @ 2021-02-09 19:23 UTC (permalink / raw
To: Mike Gilbert; +Cc: Gentoo Dev
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
>>>>> On Tue, 09 Feb 2021, Mike Gilbert wrote:
>> Mh - so the obvious first feature request for the script is to also
>> output Free UID+GID pairs. Counting them manually in your screenshot
>> I get 36.
>>
>> That's not a whole lot; just 7% of 500.
> The output was abbreviated. Here is the full output for entries where
> both ids are FREE.
Still, it's not an infinite resource, and maybe we shouldn't waste a
pair if only one of UID or GID is needed?
Ulrich
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] A script to pick next free UID/GID for your acct-* packages
2021-02-09 19:23 ` Ulrich Mueller
@ 2021-02-09 23:37 ` Mike Gilbert
0 siblings, 0 replies; 6+ messages in thread
From: Mike Gilbert @ 2021-02-09 23:37 UTC (permalink / raw
To: Gentoo Dev
On Tue, Feb 9, 2021 at 2:23 PM Ulrich Mueller <ulm@gentoo.org> wrote:
>
> >>>>> On Tue, 09 Feb 2021, Mike Gilbert wrote:
>
> >> Mh - so the obvious first feature request for the script is to also
> >> output Free UID+GID pairs. Counting them manually in your screenshot
> >> I get 36.
> >>
> >> That's not a whole lot; just 7% of 500.
>
> > The output was abbreviated. Here is the full output for entries where
> > both ids are FREE.
>
> Still, it's not an infinite resource, and maybe we shouldn't waste a
> pair if only one of UID or GID is needed?
It's possible that a package might require both a UID and a GID at
some point in the future.
If we actually start running out of low-numbered ids, we could start
mixing them at that point; having them match is really just a cosmetic
thing.
Or we could always just expand the permissible range.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] A script to pick next free UID/GID for your acct-* packages
2021-02-09 17:51 ` Peter Stuge
2021-02-09 18:11 ` Mike Gilbert
@ 2021-02-10 8:00 ` Jaco Kroon
1 sibling, 0 replies; 6+ messages in thread
From: Jaco Kroon @ 2021-02-10 8:00 UTC (permalink / raw
To: Peter Stuge; +Cc: gentoo development
Hi Peter,
On 2021/02/09 19:51, Peter Stuge wrote:
> Joonas Niilola wrote:
>> There's a script by jkroon in data/api.git
>> (https://gitweb.gentoo.org/data/api.git/) that prints the next available
>> UID/GID pair for new acct-* packages.
> This is super nice! Thanks a lot jkroon!
You're most welcome.
>> It is not forbidden to mix and mash UID/GID between different packages,
>> but I'd still suggest to find a new "pair" even if you push just an UID
>> or GID. Since we don't seem to be in danger of running out any time soon.
> Mh - so the obvious first feature request for the script is to also output
> Free UID+GID pairs. Counting them manually in your screenshot I get 36.
https://github.com/gentoo/api-gentoo-org/pull/367
>
> That's not a whole lot; just 7% of 500.
Recommended GID only: 460
Recommended UID only: 458
Recommended UID+GID both: 326
Free UIDs: 200
Free GIDs: 177
Free UID+GID pairs: 160
Full count of 32% looks a tad better than 7%.
Re always picking a pair (raised in original email), my recommedation
would be:
Pick a pair if there is any chance that you might want the other
eventually too, else pick free uid/gid.
The problem with that is, if you don't take BOTH right now, someone else
might take the other, so perhaps the strategy of always picking a pair
is better ...
Then again, there are packages that need one UID and multiple GIDs, and
probably the other way around too, so not always picking pairs in such
cases makes a lot of sense too.
Kind Regards,
Jaco
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-10 8:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-09 17:43 [gentoo-dev] A script to pick next free UID/GID for your acct-* packages Joonas Niilola
2021-02-09 17:51 ` Peter Stuge
2021-02-09 18:11 ` Mike Gilbert
2021-02-09 19:23 ` Ulrich Mueller
2021-02-09 23:37 ` Mike Gilbert
2021-02-10 8:00 ` Jaco Kroon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox