Gentoo Archives: gentoo-dev

From: "M. J. Everitt" <m.j.everitt@×××.org>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged
Date: Mon, 20 Nov 2017 03:43:29
Message-Id: aab98801-8688-e440-d574-5390f778b6bc@iee.org
In Reply to: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged by heroxbd@gentoo.org
1 On 20/11/17 03:38, heroxbd@g.o wrote:
2 > From: Benda Xu <heroxbd@g.o>
3 >
4 > Thanks MJ, how about "Unprivileged to execute"? Less bytes.
5 >
6 > enewgroup and enewuser does not apply when executed as a normal
7 > user, e.g. under Gentoo Prefix.
8 > ---
9 > eclass/user.eclass | 8 ++++++++
10 > 1 file changed, 8 insertions(+)
11 >
12 > diff --git a/eclass/user.eclass b/eclass/user.eclass
13 > index 86bcd282479..8ff06935277 100644
14 > --- a/eclass/user.eclass
15 > +++ b/eclass/user.eclass
16 > @@ -103,6 +103,10 @@ egetent() {
17 > # Default uid is (pass -1 for this) next available, default shell is
18 > # /bin/false, default homedir is /dev/null, and there are no default groups.
19 > enewuser() {
20 > + if [[ ${EUID} != 0 ]] ; then
21 > + einfo "Unprivileged to execute ${FUNCNAME[0]}"
22 > + return 0
23 > + fi
24 > _assert_pkg_ebuild_phase ${FUNCNAME}
25 >
26 > # get the username
27 > @@ -262,6 +266,10 @@ enewuser() {
28 > # do the rest. You may specify the gid for the group or allow the group to
29 > # allocate the next available one.
30 > enewgroup() {
31 > + if [[ ${EUID} != 0 ]] ; then
32 > + einfo "Unprivileged to execute ${FUNCNAME[0]}"
33 > + return 0
34 > + fi
35 > _assert_pkg_ebuild_phase ${FUNCNAME}
36 >
37 > # get the group
38 That's rather strange English .. perhaps "Unprivileged: cannot execute..."
39
40 MJE

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies