Merge branch 'fix/type/__user/openbsd-shadow' into 'master'

__user: Fix shadow explorer for OpenBSD

See merge request ungleich-public/cdist!902
This commit is contained in:
poljakowski 2020-06-30 22:55:33 +02:00
commit 727f3dbb03
1 changed files with 14 additions and 7 deletions

View File

@ -23,18 +23,25 @@
name=$__object_id name=$__object_id
case $("$__explorer/os") in case $("${__explorer}/os") in
'freebsd'|'netbsd'|'openbsd'|'alpine') freebsd|netbsd)
database='passwd' database='passwd'
;; ;;
# Default to using shadow passwords openbsd)
database='master.passwd'
;;
*) *)
# Default to using shadow passwords
database='shadow' database='shadow'
;; ;;
esac esac
if command -v getent >/dev/null; then if command -v getent >/dev/null 2>&1
getent "$database" "$name" || true then
elif [ -f /etc/shadow ]; then # shellcheck disable=SC2015
grep "^${name}:" /etc/shadow || true getent "${database}" "${name}" 2>/dev/null && exit || true # fallback to file
fi
if test -n "${database}" -a -f "/etc/${database}"
then
grep -e "^${name}:" "/etc/${database}" || true # ignore failure
fi fi