summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenda Xu <heroxbd@gentoo.org>2016-06-14 10:59:53 +0900
committerBenda Xu <heroxbd@gentoo.org>2016-06-14 10:59:53 +0900
commit476e3eade829ef401bcc2eaf8ae7d0262f3d121f (patch)
tree94ba2877c032634c2896746f1ee62a9cc1ec6716
parentsys-devel/gcc-config: should use http for bootstrap. (diff)
downloadheroxbd-476e3eade829ef401bcc2eaf8ae7d0262f3d121f.tar.gz
heroxbd-476e3eade829ef401bcc2eaf8ae7d0262f3d121f.tar.bz2
heroxbd-476e3eade829ef401bcc2eaf8ae7d0262f3d121f.zip
user.eclass: gracefully return early on for enewgroup and enewuser.
-rw-r--r--eclass/user.eclass12
1 files changed, 10 insertions, 2 deletions
diff --git a/eclass/user.eclass b/eclass/user.eclass
index 860aba0..9fddbbb 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -107,6 +107,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 "Donot have enough privilege to execute ${FUNCNAME[0]}"
+ return 0
+ fi
_assert_pkg_ebuild_phase ${FUNCNAME}
# get the username
@@ -247,7 +251,7 @@ enewuser() {
;;
*)
- useradd -r "${opts[@]}" "${euser}" || use prefix || die
+ useradd -r "${opts[@]}" "${euser}" || die
;;
esac
@@ -267,6 +271,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 "Donot have enough privilege to execute ${FUNCNAME[0]}"
+ return 0
+ fi
_assert_pkg_ebuild_phase ${FUNCNAME}
# get the group
@@ -340,7 +348,7 @@ enewgroup() {
opts="-g ${egid}"
fi
# We specify -r so that we get a GID in the system range from login.defs
- groupadd -r ${opts} "${egroup}" || use prefix || die
+ groupadd -r ${opts} "${egroup}" || die
;;
esac
}