/[gentoo-x86]/eclass/user.eclass
Gentoo

Diff of /eclass/user.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.15 Revision 1.16
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/user.eclass,v 1.15 2011/11/29 19:01:28 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/user.eclass,v 1.16 2011/11/29 19:31:20 vapier Exp $
4 4
5# @ECLASS: user.eclass 5# @ECLASS: user.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org (Linux) 7# base-system@gentoo.org (Linux)
8# Joe Jezak <josejx@gmail.com> (OS X) 8# Joe Jezak <josejx@gmail.com> (OS X)
181 einfo " - Home: ${ehome}" 181 einfo " - Home: ${ehome}"
182 opts+=( -d "${ehome}" ) 182 opts+=( -d "${ehome}" )
183 183
184 # handle groups 184 # handle groups
185 local egroups=$1; shift 185 local egroups=$1; shift
186 if [[ ! -z ${egroups} ]] ; then 186 local g egroups_arr
187 local oldifs=${IFS} 187 IFS="," read -r -a egroups_arr <<<"${egroups}"
188 shift
189 if [[ ${#egroups_arr[@]} -gt 0 ]] ; then
188 local defgroup="" exgroups="" 190 local defgroup exgroups
189
190 export IFS=","
191 for g in ${egroups} ; do 191 for g in "${egroups_arr[@]}" ; do
192 export IFS=${oldifs}
193 if [[ -z $(egetent group "${g}") ]] ; then 192 if [[ -z $(egetent group "${g}") ]] ; then
194 eerror "You must add group ${g} to the system first" 193 eerror "You must add group ${g} to the system first"
195 die "${g} is not a valid GID" 194 die "${g} is not a valid GID"
196 fi 195 fi
197 if [[ -z ${defgroup} ]] ; then 196 if [[ -z ${defgroup} ]] ; then
198 defgroup=${g} 197 defgroup=${g}
199 else 198 else
200 exgroups="${exgroups},${g}" 199 exgroups+=",${g}"
201 fi 200 fi
202 export IFS=","
203 done 201 done
204 export IFS=${oldifs}
205
206 opts+=( -g "${defgroup}" ) 202 opts+=( -g "${defgroup}" )
207 if [[ ! -z ${exgroups} ]] ; then 203 if [[ ! -z ${exgroups} ]] ; then
208 opts+=( -G "${exgroups:1}" ) 204 opts+=( -G "${exgroups:1}" )
209 fi 205 fi
210 else
211 egroups="(none)"
212 fi 206 fi
213 einfo " - Groups: ${egroups}" 207 einfo " - Groups: ${egroups:-(none)}"
214 208
215 # handle extra args 209 # handle extra args
216 if [[ $# -gt 0 ]] ; then 210 if [[ $# -gt 0 ]] ; then
217 die "extra arguments no longer supported; please file a bug" 211 die "extra arguments no longer supported; please file a bug"
218 else 212 else
228 dscl . create "/users/${euser}" uid ${euid} 222 dscl . create "/users/${euser}" uid ${euid}
229 dscl . create "/users/${euser}" shell "${eshell}" 223 dscl . create "/users/${euser}" shell "${eshell}"
230 dscl . create "/users/${euser}" home "${ehome}" 224 dscl . create "/users/${euser}" home "${ehome}"
231 dscl . create "/users/${euser}" realname "added by portage for ${PN}" 225 dscl . create "/users/${euser}" realname "added by portage for ${PN}"
232 ### Add the user to the groups specified 226 ### Add the user to the groups specified
233 local g oldifs=${IFS}
234 export IFS=","
235 for g in ${egroups} ; do 227 for g in "${egroups_arr[@]}" ; do
236 dscl . merge "/groups/${g}" users "${euser}" 228 dscl . merge "/groups/${g}" users "${euser}"
237 done 229 done
238 export IFS=${oldifs}
239 ;; 230 ;;
240 231
241 *-freebsd*|*-dragonfly*) 232 *-freebsd*|*-dragonfly*)
242 pw useradd "${euser}" "${opts[@]}" || die 233 pw useradd "${euser}" "${opts[@]}" || die
243 ;; 234 ;;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20