summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenda Xu <heroxbd@gentoo.org>2017-11-20 12:34:53 +0900
committerBenda Xu <heroxbd@gentoo.org>2017-11-26 10:05:41 +0900
commit4524dea9689c94b7b6250d64f4917f7fc9b3a879 (patch)
tree5099d2e1c68e66c765a2a7dc710c7eeb477f747e /eclass/user.eclass
parentapp-arch/unzip: Rev bump to add -DUSE_ICONV_MAPPING on USE=unicode (diff)
downloadgentoo-4524dea9689c94b7b6250d64f4917f7fc9b3a879.tar.gz
gentoo-4524dea9689c94b7b6250d64f4917f7fc9b3a879.tar.bz2
gentoo-4524dea9689c94b7b6250d64f4917f7fc9b3a879.zip
user.eclass: gracefully return when unprivileged
enewgroup and enewuser does not apply when executed as a normal user, e.g. under Gentoo Prefix.
Diffstat (limited to 'eclass/user.eclass')
-rw-r--r--eclass/user.eclass10
1 files changed, 9 insertions, 1 deletions
diff --git a/eclass/user.eclass b/eclass/user.eclass
index 86bcd282479f..97e417a7be9d 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: user.eclass
@@ -103,6 +103,10 @@ egetent() {
# Default uid is (pass -1 for this) next available, default shell is
# /bin/false, default homedir is /dev/null, and there are no default groups.
enewuser() {
+ if [[ ${EUID} != 0 ]] ; then
+ einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
+ return 0
+ fi
_assert_pkg_ebuild_phase ${FUNCNAME}
# get the username
@@ -262,6 +266,10 @@ enewuser() {
# do the rest. You may specify the gid for the group or allow the group to
# allocate the next available one.
enewgroup() {
+ if [[ ${EUID} != 0 ]] ; then
+ einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
+ return 0
+ fi
_assert_pkg_ebuild_phase ${FUNCNAME}
# get the group