summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-11-03 15:29:39 +0000
committerMike Frysinger <vapier@gentoo.org>2011-11-03 15:29:39 +0000
commit7f9fa49bf0c93ecf2fab99431246bb2d558b6711 (patch)
treea5a1c24960fbbdec2cf59731c2524e675143e1f8 /eclass/user.eclass
parentUse bash-completion-r1.eclass, remove the symlink fixing hack and use DOCS in... (diff)
downloadgentoo-2-7f9fa49bf0c93ecf2fab99431246bb2d558b6711.tar.gz
gentoo-2-7f9fa49bf0c93ecf2fab99431246bb2d558b6711.tar.bz2
gentoo-2-7f9fa49bf0c93ecf2fab99431246bb2d558b6711.zip
clean up enew{user,group} and drop the [extra] argument as no one is using it
Diffstat (limited to 'eclass/user.eclass')
-rw-r--r--eclass/user.eclass122
1 files changed, 43 insertions, 79 deletions
diff --git a/eclass/user.eclass b/eclass/user.eclass
index 1d555872fdbb..553161139749 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/user.eclass,v 1.8 2011/11/03 00:59:16 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/user.eclass,v 1.9 2011/11/03 15:29:39 vapier Exp $
# @ECLASS: user.eclass
# @MAINTAINER:
@@ -95,13 +95,12 @@ egetent() {
}
# @FUNCTION: enewuser
-# @USAGE: <user> [uid] [shell] [homedir] [groups] [params]
+# @USAGE: <user> [uid] [shell] [homedir] [groups]
# @DESCRIPTION:
# Same as enewgroup, you are not required to understand how to properly add
# a user to the system. The only required parameter is the username.
# Default uid is (pass -1 for this) next available, default shell is
-# /bin/false, default homedir is /dev/null, there are no default groups,
-# and default params sets the comment as 'added by portage for ${PN}'.
+# /bin/false, default homedir is /dev/null, and there are no default groups.
enewuser() {
_assert_pkg_ebuild_phase enewuser
@@ -140,7 +139,7 @@ enewuser() {
[[ -z $(egetent passwd ${euid}) ]] && break
done
fi
- opts="${opts} -u ${euid}"
+ opts+=" -u ${euid}"
einfo " - Userid: ${euid}"
# handle shell
@@ -172,7 +171,7 @@ enewuser() {
eshell=${shell}
fi
einfo " - Shell: ${eshell}"
- opts="${opts} -s ${eshell}"
+ opts+=" -s ${eshell}"
# handle homedir
local ehome=$1; shift
@@ -180,7 +179,7 @@ enewuser() {
ehome="/dev/null"
fi
einfo " - Home: ${ehome}"
- opts="${opts} -d ${ehome}"
+ opts+=" -d ${ehome}"
# handle groups
local egroups=$1; shift
@@ -204,86 +203,58 @@ enewuser() {
done
export IFS=${oldifs}
- opts="${opts} -g ${defgroup}"
+ opts+=" -g ${defgroup}"
if [[ ! -z ${exgroups} ]] ; then
- opts="${opts} -G ${exgroups:1}"
+ opts+=" -G ${exgroups:1}"
fi
else
egroups="(none)"
fi
einfo " - Groups: ${egroups}"
- # handle extra and add the user
+ # handle extra args
+ if [[ $# -gt 0 ]] ; then
+ die "extra arguments no longer supported; please file a bug"
+ else
+ set -- -c "added by portage for ${PN}"
+ einfo " - Extra: $@"
+ fi
+
+ # add the user
local oldsandbox=${SANDBOX_ON}
export SANDBOX_ON="0"
case ${CHOST} in
*-darwin*)
### Make the user
- if [[ -z $@ ]] ; then
- dscl . create /users/${euser} uid ${euid}
- dscl . create /users/${euser} shell ${eshell}
- dscl . create /users/${euser} home ${ehome}
- dscl . create /users/${euser} realname "added by portage for ${PN}"
- ### Add the user to the groups specified
- local oldifs=${IFS}
- export IFS=","
- for g in ${egroups} ; do
- dscl . merge /groups/${g} users ${euser}
- done
- export IFS=${oldifs}
- else
- einfo "Extra options are not supported on Darwin yet"
- einfo "Please report the ebuild along with the info below"
- einfo "eextra: $@"
- die "Required function missing"
- fi
+ dscl . create /users/${euser} uid ${euid}
+ dscl . create /users/${euser} shell ${eshell}
+ dscl . create /users/${euser} home ${ehome}
+ dscl . create /users/${euser} realname "added by portage for ${PN}"
+ ### Add the user to the groups specified
+ local oldifs=${IFS}
+ export IFS=","
+ for g in ${egroups} ; do
+ dscl . merge /groups/${g} users ${euser}
+ done
+ export IFS=${oldifs}
;;
+
*-freebsd*|*-dragonfly*)
- if [[ -z $@ ]] ; then
- pw useradd ${euser} ${opts} \
- -c "added by portage for ${PN}" \
- die "enewuser failed"
- else
- einfo " - Extra: $@"
- pw useradd ${euser} ${opts} \
- "$@" || die "enewuser failed"
- fi
+ pw useradd ${euser} ${opts} "$@" || die
;;
*-netbsd*)
- if [[ -z $@ ]] ; then
- useradd ${opts} ${euser} || die "enewuser failed"
- else
- einfo " - Extra: $@"
- useradd ${opts} ${euser} "$@" || die "enewuser failed"
- fi
+ useradd ${opts} ${euser} "$@" || die
;;
*-openbsd*)
- if [[ -z $@ ]] ; then
- useradd -u ${euid} -s ${eshell} \
- -d ${ehome} -c "Added by portage for ${PN}" \
- -g ${egroups} ${euser} || die "enewuser failed"
- else
- einfo " - Extra: $@"
- useradd -u ${euid} -s ${eshell} \
- -d ${ehome} -c "Added by portage for ${PN}" \
- -g ${egroups} ${euser} "$@" || die "enewuser failed"
- fi
+ # all ops the same, except the -g vs -g/-G ...
+ useradd -u ${euid} -s ${eshell} \
+ -d ${ehome} -g ${egroups} "$@" ${euser} || die
;;
*)
- if [[ -z $@ ]] ; then
- useradd -r ${opts} \
- -c "added by portage for ${PN}" \
- ${euser} \
- || die "enewuser failed"
- else
- einfo " - Extra: $@"
- useradd -r ${opts} "$@" \
- ${euser} \
- || die "enewuser failed"
- fi
+ useradd -r ${opts} "$@" ${euser} || die
;;
esac
@@ -333,9 +304,9 @@ enewgroup() {
if [ -z "`egetent group ${egid}`" ]
then
if [[ "${CHOST}" == *-darwin* ]]; then
- opts="${opts} ${egid}"
+ opts+=" ${egid}"
else
- opts="${opts} -g ${egid}"
+ opts+=" -g ${egid}"
fi
else
egid="next available; requested gid taken"
@@ -350,22 +321,15 @@ enewgroup() {
einfo " - Groupid: ${egid}"
# handle extra
- local eextra="$@"
- opts="${opts} ${eextra}"
+ if [ $# -gt 0 ] ; then
+ die "extra arguments no longer supported; please file a bug"
+ fi
# add the group
local oldsandbox="${SANDBOX_ON}"
export SANDBOX_ON="0"
case ${CHOST} in
*-darwin*)
- if [ ! -z "${eextra}" ];
- then
- einfo "Extra options are not supported on Darwin/OS X yet"
- einfo "Please report the ebuild along with the info below"
- einfo "eextra: ${eextra}"
- die "Required function missing"
- fi
-
# If we need the next available
case ${egid} in
*[!0-9]*) # Non numeric
@@ -384,7 +348,7 @@ enewgroup() {
[[ -z $(egetent group ${egid}) ]] && break
done
esac
- pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
+ pw groupadd ${egroup} -g ${egid} || die
;;
*-netbsd*)
@@ -394,12 +358,12 @@ enewgroup() {
[[ -z $(egetent group ${egid}) ]] && break
done
esac
- groupadd -g ${egid} ${egroup} || die "enewgroup failed"
+ groupadd -g ${egid} ${egroup} || die
;;
*)
# We specify -r so that we get a GID in the system range from login.defs
- groupadd -r ${opts} ${egroup} || die "enewgroup failed"
+ groupadd -r ${opts} ${egroup} || die
;;
esac
export SANDBOX_ON="${oldsandbox}"