Gentoo Archives: gentoo-dev

From: heroxbd@g.o
To: gentoo-dev@l.g.o
Cc: Benda Xu <heroxbd@g.o>
Subject: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged
Date: Mon, 20 Nov 2017 04:09:57
Message-Id: 20171120040941.28140-1-heroxbd@gentoo.org
In Reply to: Re: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged by "M. J. Everitt"
1 From: Benda Xu <heroxbd@g.o>
2
3 Thanks again. I will take your original suggestion.
4
5 enewgroup and enewuser does not apply when executed as a normal
6 user, e.g. under Gentoo Prefix.
7 ---
8 eclass/user.eclass | 8 ++++++++
9 1 file changed, 8 insertions(+)
10
11 diff --git a/eclass/user.eclass b/eclass/user.eclass
12 index 86bcd282479..76a622df698 100644
13 --- a/eclass/user.eclass
14 +++ b/eclass/user.eclass
15 @@ -103,6 +103,10 @@ egetent() {
16 # Default uid is (pass -1 for this) next available, default shell is
17 # /bin/false, default homedir is /dev/null, and there are no default groups.
18 enewuser() {
19 + if [[ ${EUID} != 0 ]] ; then
20 + einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
21 + return 0
22 + fi
23 _assert_pkg_ebuild_phase ${FUNCNAME}
24
25 # get the username
26 @@ -262,6 +266,10 @@ enewuser() {
27 # do the rest. You may specify the gid for the group or allow the group to
28 # allocate the next available one.
29 enewgroup() {
30 + if [[ ${EUID} != 0 ]] ; then
31 + einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
32 + return 0
33 + fi
34 _assert_pkg_ebuild_phase ${FUNCNAME}
35
36 # get the group
37 --
38 2.15.0

Replies

Subject Author
Re: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged Francesco Riosa <vivo75@×××××.com>