1 |
commit: c871b87b56208684b0a1fedeaf24fe10943748e2 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Aug 7 17:07:45 2019 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 17 20:36:31 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c871b87b |
7 |
|
8 |
acct-*.eclass: Allow dynamic UID/GID assignment via -1 |
9 |
|
10 |
Allow a special value of '-1' to dynamically assign UID/GID for the user |
11 |
or group. This is intended to be used in overlays where proper |
12 |
assignment does not take place but whose owners wish to switch to acct-* |
13 |
packages. |
14 |
|
15 |
While technically it is possible to choose a free UID/GID, it could be |
16 |
taken afterwards by some Gentoo package and unnecessarily introduce |
17 |
a conflict. Using '999' was also suggested (as the first dynamic |
18 |
UID/GID) but it would cause issues for people enabling |
19 |
ACCT_*_ENFORCE_ID. To avoid this, '-1' does not trigger collision |
20 |
checks. |
21 |
|
22 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
23 |
|
24 |
eclass/acct-group.eclass | 4 ++++ |
25 |
eclass/acct-user.eclass | 4 ++++ |
26 |
2 files changed, 8 insertions(+) |
27 |
|
28 |
diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass |
29 |
index 9eab00db690..d5ccd209c9e 100644 |
30 |
--- a/eclass/acct-group.eclass |
31 |
+++ b/eclass/acct-group.eclass |
32 |
@@ -59,6 +59,9 @@ readonly ACCT_GROUP_NAME |
33 |
# @DESCRIPTION: |
34 |
# Preferred GID for the new group. This variable is obligatory, and its |
35 |
# value must be unique across all group packages. |
36 |
+# |
37 |
+# Overlays should set this to -1 to dynamically allocate GID. Using -1 |
38 |
+# in ::gentoo is prohibited by policy. |
39 |
|
40 |
# @ECLASS-VARIABLE: ACCT_GROUP_ENFORCE_ID |
41 |
# @DESCRIPTION: |
42 |
@@ -87,6 +90,7 @@ acct-group_pkg_pretend() { |
43 |
|
44 |
# verify ACCT_GROUP_ID |
45 |
[[ -n ${ACCT_GROUP_ID} ]] || die "Ebuild error: ACCT_GROUP_ID must be set!" |
46 |
+ [[ ${ACCT_GROUP_ID} -eq -1 ]] && return |
47 |
[[ ${ACCT_GROUP_ID} -ge 0 ]] || die "Ebuild errors: ACCT_GROUP_ID=${ACCT_GROUP_ID} invalid!" |
48 |
|
49 |
# check for ACCT_GROUP_ID collisions early |
50 |
|
51 |
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass |
52 |
index 008dc6bb7d6..fa4f9daef8f 100644 |
53 |
--- a/eclass/acct-user.eclass |
54 |
+++ b/eclass/acct-user.eclass |
55 |
@@ -67,6 +67,9 @@ readonly ACCT_USER_NAME |
56 |
# @DESCRIPTION: |
57 |
# Preferred UID for the new user. This variable is obligatory, and its |
58 |
# value must be unique across all user packages. |
59 |
+# |
60 |
+# Overlays should set this to -1 to dynamically allocate UID. Using -1 |
61 |
+# in ::gentoo is prohibited by policy. |
62 |
|
63 |
# @ECLASS-VARIABLE: ACCT_USER_ENFORCE_ID |
64 |
# @DESCRIPTION: |
65 |
@@ -279,6 +282,7 @@ acct-user_pkg_pretend() { |
66 |
|
67 |
# verify ACCT_USER_ID |
68 |
[[ -n ${ACCT_USER_ID} ]] || die "Ebuild error: ACCT_USER_ID must be set!" |
69 |
+ [[ ${ACCT_USER_ID} -eq -1 ]] && return |
70 |
[[ ${ACCT_USER_ID} -ge 0 ]] || die "Ebuild errors: ACCT_USER_ID=${ACCT_USER_ID} invalid!" |
71 |
|
72 |
# check for ACCT_USER_ID collisions early |