1 |
commit: 970abc63ba7144c45208acf3f727d8a559caaa43 |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Jul 27 08:37:53 2019 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jul 29 09:21:48 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=970abc63 |
7 |
|
8 |
user.eclass: Allocate next free UID or GID from 999 downwards. |
9 |
|
10 |
Fixed UIDs and GIDs are mostly located in the low range, therefore |
11 |
going downwards from 999 to 101 will minimise collisions between fixed |
12 |
and dynamically allocated IDs. |
13 |
|
14 |
Note that on Linux and other targets using "groupadd -r" from |
15 |
sys-apps/shadow, GIDs are already allocated that way implicitly. |
16 |
|
17 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
18 |
|
19 |
eclass/user.eclass | 8 ++++---- |
20 |
1 file changed, 4 insertions(+), 4 deletions(-) |
21 |
|
22 |
diff --git a/eclass/user.eclass b/eclass/user.eclass |
23 |
index 9dc15fa75d2..a3cacb6d5f1 100644 |
24 |
--- a/eclass/user.eclass |
25 |
+++ b/eclass/user.eclass |
26 |
@@ -157,10 +157,10 @@ enewuser() { |
27 |
euid="next" |
28 |
fi |
29 |
if [[ ${euid} == "next" ]] ; then |
30 |
- for ((euid = 101; euid <= 999; euid++)); do |
31 |
+ for ((euid = 999; euid >= 101; euid--)); do |
32 |
[[ -z $(egetent passwd ${euid}) ]] && break |
33 |
done |
34 |
- [[ ${euid} -le 999 ]] || die "${FUNCNAME}: no free UID found" |
35 |
+ [[ ${euid} -ge 101 ]] || die "${FUNCNAME}: no free UID found" |
36 |
fi |
37 |
opts+=( -u ${euid} ) |
38 |
einfo " - Userid: ${euid}" |
39 |
@@ -318,10 +318,10 @@ enewgroup() { |
40 |
_enewgroup_next_gid() { |
41 |
if [[ ${egid} == *[!0-9]* ]] ; then |
42 |
# Non numeric |
43 |
- for ((egid = 101; egid <= 999; egid++)) ; do |
44 |
+ for ((egid = 999; egid >= 101; egid--)) ; do |
45 |
[[ -z $(egetent group ${egid}) ]] && break |
46 |
done |
47 |
- [[ ${egid} -le 999 ]] || die "${FUNCNAME}: no free GID found" |
48 |
+ [[ ${egid} -ge 101 ]] || die "${FUNCNAME}: no free GID found" |
49 |
fi |
50 |
} |