Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Cc: "Ulrich Müller" <ulm@g.o>
Subject: [gentoo-dev] [PATCH 9/9] acct-user.eclass: Refuse to lock out the superuser
Date: Sun, 27 Mar 2022 07:30:48
Message-Id: 20220327072735.9719-10-ulm@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/9] eclass: Use UID 0 instead of root and other fixes by "Ulrich Müller"
1 Signed-off-by: Ulrich Müller <ulm@g.o>
2 ---
3 eclass/acct-user.eclass | 5 +++++
4 1 file changed, 5 insertions(+)
5
6 diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
7 index 2e2e1152f9ad..f2aaefc2ee39 100644
8 --- a/eclass/acct-user.eclass
9 +++ b/eclass/acct-user.eclass
10 @@ -473,6 +473,11 @@ acct-user_pkg_prerm() {
11 return 0
12 fi
13
14 + if [[ ${ACCT_USER_ID} -eq 0 ]]; then
15 + elog "Refusing to lock out the superuser (UID 0)"
16 + return 0
17 + fi
18 +
19 if [[ -z ${REPLACED_BY_VERSION} ]]; then
20 if [[ -z $(egetent passwd "${ACCT_USER_NAME}") ]]; then
21 ewarn "User account not found: ${ACCT_USER_NAME}"
22 --
23 2.35.1