From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SetMf-0008Tj-A1 for garchives@archives.gentoo.org; Wed, 13 Jun 2012 19:36:25 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 69652E06B4; Wed, 13 Jun 2012 19:36:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 41165E058F for ; Wed, 13 Jun 2012 19:35:26 +0000 (UTC) Received: from [192.168.1.145] (CPE002401f30b73-CM001cea3ddad8.cpe.net.cable.rogers.com [99.240.69.152]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: axs) by smtp.gentoo.org (Postfix) with ESMTPSA id 9654D1B400E for ; Wed, 13 Jun 2012 19:35:25 +0000 (UTC) Message-ID: <4FD8EB8C.90701@gentoo.org> Date: Wed, 13 Jun 2012 15:35:40 -0400 From: Ian Stakenvicius User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120511 Thunderbird/10.0.4 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] RFC: esethome References: <4FD8B910.3090606@gentoo.org> <201206131504.07384.vapier@gentoo.org> <4FD8E5D7.3000402@gentoo.org> <201206131514.51074.vapier@gentoo.org> In-Reply-To: <201206131514.51074.vapier@gentoo.org> X-Enigmail-Version: 1.3.5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Archives-Salt: 7c60ab6d-ab9f-41f4-8e9d-ad062b960fa4 X-Archives-Hash: df9f5f143e40f358a0d993c7cbece5e0 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 13/06/12 03:14 PM, Mike Frysinger wrote: > > eset{home,shell} don't exist today, so you should implement them > :) -mike RFC - heavily based on enewuser. - --- user.eclass [some timestamp] +++ user.eclass.esethome [some other timestamp] @@ -388,3 +388,63 @@ } fi + +# @FUNCTION: esethome +# @USAGE: +# @DESCRIPTION: +# Update the home directory in a platform-agnostic way. +# Required parameters is the username and the new home directory. +# Specify -1 if you want to set home to the enewuser default +# of /dev/null. +# If the new home directory does not exist, it is created. +# Any previously existing home directory is NOT moved. +esethome() { + _assert_pkg_ebuild_phase ${FUNCNAME} + + # get the username + local euser=$1; shift + if [[ -z ${euser} ]] ; then + eerror "No username specified !" + die "Cannot call esethome without a username" + fi + + # lets see if the username already exists + if [[ ! -n $(egetent passwd "${euser}") ]] ; then + ewarn "User does not exist, cannot set home. skipping." + return 1 + fi + + # handle homedir + local ehome=$1; shift + if [[ -z ${ehome} ]] ; then + eerror "No home directory specified !" + die "Cannot call esethome without a home directory" + fi + + if [[ ${ehome} == "-1" ]] ; then + ehome="/dev/null" + fi + einfo " - Home: ${ehome}" + + # update the home directory + case ${CHOST} in + *-darwin*) + dscl . change "/users/${euser}" home "${ehome}" + ;; + + *-freebsd*|*-dragonfly*) + pw usermod "${euser}" -d "${ehome}" || die + ;; + + *) + usermod -d "${ehome}" "${euser}" || die + ;; + esac + + if [[ ! -e ${ROOT}/${ehome} ]] ; then + einfo " - Creating ${ehome} in ${ROOT}" + mkdir -p "${ROOT}/${ehome}" + chown "${euser}" "${ROOT}/${ehome}" + chmod 755 "${ROOT}/${ehome}" + fi +} -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iF4EAREIAAYFAk/Y64wACgkQ2ugaI38ACPBZYQD9EzzmBDUon1YUNxaev5ONluAX 2GA32hOyvwGs2ylZPy8A/3RN8VNsa6XI++eHRdwjpsSZLw4sTVpa+fY2LZHSnWsh =gLrd -----END PGP SIGNATURE-----