diff --git a/cdist/conf/type/__user/explorer/group b/cdist/conf/type/__user/explorer/group index 2aae2973..0fd1471a 100755 --- a/cdist/conf/type/__user/explorer/group +++ b/cdist/conf/type/__user/explorer/group @@ -23,11 +23,9 @@ if [ -f "$__object/parameter/gid" ]; then gid=$(cat "$__object/parameter/gid") - getent=$(command -v getent) - if [ X != X"${getent}" ]; then - "${getent}" group "$gid" || true + if command -v getent >/dev/null; then + getent group "$gid" || true elif [ -f /etc/group ]; then grep -E "^(${gid}|([^:]+:){2}${gid}):" /etc/group || true fi fi - diff --git a/cdist/conf/type/__user/explorer/passwd b/cdist/conf/type/__user/explorer/passwd index 677e3ff0..b8391a6f 100755 --- a/cdist/conf/type/__user/explorer/passwd +++ b/cdist/conf/type/__user/explorer/passwd @@ -23,9 +23,8 @@ name=$__object_id -getent=$(command -v getent) -if [ X != X"${getent}" ]; then - "${getent}" passwd "$name" || true +if command -v getent >/dev/null; then + getent passwd "$name" || true elif [ -f /etc/passwd ]; then grep "^${name}:" /etc/passwd || true fi diff --git a/cdist/conf/type/__user/explorer/shadow b/cdist/conf/type/__user/explorer/shadow index c49992d5..73ce0e29 100755 --- a/cdist/conf/type/__user/explorer/shadow +++ b/cdist/conf/type/__user/explorer/shadow @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -22,18 +22,19 @@ # name=$__object_id -os="$("$__explorer/os")" -# Default to using shadow passwords -database="shadow" -case "$os" in - "freebsd"|"netbsd"|"openbsd") database="passwd";; +case $("$__explorer/os") in + 'freebsd'|'netbsd'|'openbsd') + database='passwd' + ;; + # Default to using shadow passwords + *) + database='shadow' + ;; esac - -getent=$(command -v getent) -if [ X != X"${getent}" ]; then - "${getent}" "$database" "$name" || true +if command -v getent >/dev/null; then + getent "$database" "$name" || true elif [ -f /etc/shadow ]; then grep "^${name}:" /etc/shadow || true fi