summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2019-06-06 16:21:28 +0200
committerMichał Górny <mgorny@gentoo.org>2019-06-20 10:16:43 +0200
commit95ec6aaf25cb32bded8ff48282f19468dc89a297 (patch)
tree1b52b526d5ed9ad4dd83a58d36f7e6b89d9f6ac0 /eclass
parentuser.eclass: Die if no free UID/GID is found (diff)
downloadgentoo-95ec6aaf25cb32bded8ff48282f19468dc89a297.tar.gz
gentoo-95ec6aaf25cb32bded8ff48282f19468dc89a297.tar.bz2
gentoo-95ec6aaf25cb32bded8ff48282f19468dc89a297.zip
user.eclass: Factor out finding nologin into separate function
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/user.eclass39
1 files changed, 26 insertions, 13 deletions
diff --git a/eclass/user.eclass b/eclass/user.eclass
index 8afbc101fac3..54d7a3fdbe28 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: <user> [-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}" )