Gentoo Archives: gentoo-dev

From: heroxbd@g.o
To: gentoo-dev@l.g.o
Cc: Benda Xu <heroxbd@g.o>
Subject: [gentoo-dev] [PATCH] eclass/acct-user.eclass: disable pkg_* on Prefix.
Date: Tue, 18 Feb 2020 13:03:20
Message-Id: 20200218130239.22957-1-heroxbd@gentoo.org
1 From: Benda Xu <heroxbd@g.o>
2
3 Gentoo Prefix runs with a normal user and cannot manage any other user.
4 Exit gracefully with a message.
5
6 Closes: https://bugs.gentoo.org/709570
7 Signed-off-by: Benda Xu <heroxbd@g.o>
8 ---
9 eclass/acct-user.eclass | 10 ++++++++++
10 1 file changed, 10 insertions(+)
11
12 diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
13 index be6b3dd3e600..e3ec3966035d 100644
14 --- a/eclass/acct-user.eclass
15 +++ b/eclass/acct-user.eclass
16 @@ -360,6 +360,11 @@ acct-user_pkg_preinst() {
17 acct-user_pkg_postinst() {
18 debug-print-function ${FUNCNAME} "${@}"
19
20 + if [[ ${EUID} != 0 ]] ; then
21 + einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
22 + return 0
23 + fi
24 +
25 # NB: eset* functions check current value
26 esethome "${ACCT_USER_NAME}" "${ACCT_USER_HOME}"
27 esetshell "${ACCT_USER_NAME}" "${ACCT_USER_SHELL}"
28 @@ -376,6 +381,11 @@ acct-user_pkg_postinst() {
29 acct-user_pkg_prerm() {
30 debug-print-function ${FUNCNAME} "${@}"
31
32 + if [[ ${EUID} != 0 ]] ; then
33 + einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
34 + return 0
35 + fi
36 +
37 if [[ -z ${REPLACED_BY_VERSION} ]]; then
38 if [[ -z $(egetent passwd "${ACCT_USER_NAME}") ]]; then
39 ewarn "User account not found: ${ACCT_USER_NAME}"
40 --
41 2.25.0

Replies

Subject Author
Re: [gentoo-dev] [PATCH] eclass/acct-user.eclass: disable pkg_* on Prefix. Michael 'veremitz' Everitt <gentoo@×××××××.xyz>