Gentoo Archives: gentoo-dev

From: Joonas Niilola <juippis@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] A script to pick next free UID/GID for your acct-* packages
Date: Tue, 09 Feb 2021 17:44:15
Message-Id: 6628c8ea-9317-e4ee-12db-5cc7bccff8f2@gentoo.org
1 Hey all,
2
3 Summary:
4 There's a script by jkroon in data/api.git
5 (https://gitweb.gentoo.org/data/api.git/) that prints the next available
6 UID/GID pair for new acct-* packages. You can use it by:
7   cd ~/git/gentoo/data/api
8   git pull
9   sh bin/used_free_uidgids.sh
10  
11   The outcome looks like this for those curious:
12   https://dev.gentoo.org/~juippis/pics/free_uid_gid_by_jkroon.png
13  
14 Check the Author e-mail from the script to report bugs, and please open
15 pull requests here:
16   https://github.com/gentoo/api-gentoo-org
17
18 Story:
19 As someone who's pushed a few new UID/GID packages lately it was
20 becoming more and more tedious trying to find the next free number. And
21 I was personally becoming worried when we're going to run out of
22 available IDs.
23
24 Now a while back I asked half-jokingly someone to write a script that
25 finds the next free UID, GID and UID/GID, and also prints the current
26 number of free IDs <500 in #gentoo-dev IRC channel. Lucky for us all,
27 jkroon was up to the task.
28
29 I wanted the implementation to be "open for inspection" and available in
30 every system syncing data/api.git. So in my eyes the viable options were
31 using bash or python, and the current script is written in bash. We've
32 heard enough about using bash for this so please leave such comments out
33 from this thread. It is well documented and should be maintainable for
34 the time being, but if someone is up to re-writing it using some other
35 viable language (python), please go ahead! In its current state the
36 script works and is very useful!
37
38 Script's output looks like this:
39   #ID               UID       GID
40 ...
41   317..320         FREE      FREE
42   321              USED      USED
43   322..326         FREE      FREE
44   327..330         USED      USED
45   331..332         USED      FREE
46   333..372         USED      USED
47   373              USED      FREE
48 ...
49
50   Recommended GID only: 460
51   Recommended UID only: 458
52   Recommended UID+GID both: 326
53   Free UIDs: 200
54   Free GIDs: 177
55
56 (note that FREE/USED are colourcoded for your convenience, check the
57 screenshot above!)
58
59 It is not forbidden to mix and mash UID/GID between different packages,
60 but I'd still suggest to find a new "pair" even if you push just an UID
61 or GID. Since we don't seem to be in danger of running out any time soon.
62
63 Please report bugs to Author (e-mail in the script), and for any fixes
64 open pull requests at https://github.com/gentoo/api-gentoo-org/
65
66 Not to any proxied maintainers (reading this far), a free UID/GID pair
67 will be given to you when your acct-* packages are merged, so you don't
68 have to reserve an ID beforehand. But it'd be great if you picked one
69 that is free when making your new acct-* packages so at least during
70 merge the next free one will be close to your chosen one.
71
72 Enjoy everyone, and huge thanks to jkroon!
73
74 -- juippis

Attachments

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

Replies

Subject Author
Re: [gentoo-dev] A script to pick next free UID/GID for your acct-* packages Peter Stuge <peter@×××××.se>