From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CC76B138334 for ; Thu, 20 Jun 2019 08:17:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B5FFAE0A83; Thu, 20 Jun 2019 08:17:17 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9C390E0A83 for ; Thu, 20 Jun 2019 08:17:17 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C33E6346540 for ; Thu, 20 Jun 2019 08:17:16 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 34317626 for ; Thu, 20 Jun 2019 08:17:13 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1561018603.95ec6aaf25cb32bded8ff48282f19468dc89a297.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/user.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 95ec6aaf25cb32bded8ff48282f19468dc89a297 X-VCS-Branch: master Date: Thu, 20 Jun 2019 08:17:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2f101b28-b9a9-4be1-bb61-59251ed3a9b3 X-Archives-Hash: 29b1cb7e1b3abecb152b574ab611e2d2 commit: 95ec6aaf25cb32bded8ff48282f19468dc89a297 Author: Michał Górny gentoo org> AuthorDate: Thu Jun 6 14:21:28 2019 +0000 Commit: Michał Górny gentoo org> CommitDate: Thu Jun 20 08:16:43 2019 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95ec6aaf user.eclass: Factor out finding nologin into separate function Signed-off-by: Michał Górny gentoo.org> eclass/user.eclass | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/eclass/user.eclass b/eclass/user.eclass index 8afbc101fac..54d7a3fdbe2 100644 --- a/eclass/user.eclass +++ b/eclass/user.eclass @@ -70,6 +70,31 @@ egetent() { esac } +# @FUNCTION: user_get_nologin +# @INTERNAL +# @DESCRIPTION: +# Find an appropriate 'nologin' shell for the platform, and output +# its path. +user_get_nologin() { + local eshell + + for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null ; do + [[ -x ${ROOT}${eshell} ]] && break + done + + if [[ ${eshell} == "/dev/null" ]] ; then + ewarn "Unable to identify the shell to use, proceeding with userland default." + case ${USERLAND} in + GNU) eshell="/bin/false" ;; + BSD) eshell="/sbin/nologin" ;; + Darwin) eshell="/usr/sbin/nologin" ;; + *) die "Unable to identify the default shell for userland ${USERLAND}" + esac + fi + + echo "${eshell}" +} + # @FUNCTION: enewuser # @USAGE: [-F] [-M] [uid] [shell] [homedir] [groups] # @DESCRIPTION: @@ -152,19 +177,7 @@ enewuser() { die "Pass '-1' as the shell parameter" fi else - for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null ; do - [[ -x ${ROOT}${eshell} ]] && break - done - - if [[ ${eshell} == "/dev/null" ]] ; then - eerror "Unable to identify the shell to use, proceeding with userland default." - case ${USERLAND} in - GNU) eshell="/bin/false" ;; - BSD) eshell="/sbin/nologin" ;; - Darwin) eshell="/usr/sbin/nologin" ;; - *) die "Unable to identify the default shell for userland ${USERLAND}" - esac - fi + eshell=$(user_get_nologin) fi einfo " - Shell: ${eshell}" opts+=( -s "${eshell}" )