[__user] Fall back to /etc files if getent(1) is not available
On systems without getent(1) the script would fail because "command -v getent" exits with 1 which terminates the script due to it being called by sh -e.
This commit is contained in:
parent
97bcfcc23c
commit
2d751443a4
3 changed files with 15 additions and 17 deletions
|
@ -23,11 +23,9 @@
|
||||||
|
|
||||||
if [ -f "$__object/parameter/gid" ]; then
|
if [ -f "$__object/parameter/gid" ]; then
|
||||||
gid=$(cat "$__object/parameter/gid")
|
gid=$(cat "$__object/parameter/gid")
|
||||||
getent=$(command -v getent)
|
if command -v getent >/dev/null; then
|
||||||
if [ X != X"${getent}" ]; then
|
getent group "$gid" || true
|
||||||
"${getent}" group "$gid" || true
|
|
||||||
elif [ -f /etc/group ]; then
|
elif [ -f /etc/group ]; then
|
||||||
grep -E "^(${gid}|([^:]+:){2}${gid}):" /etc/group || true
|
grep -E "^(${gid}|([^:]+:){2}${gid}):" /etc/group || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,8 @@
|
||||||
|
|
||||||
name=$__object_id
|
name=$__object_id
|
||||||
|
|
||||||
getent=$(command -v getent)
|
if command -v getent >/dev/null; then
|
||||||
if [ X != X"${getent}" ]; then
|
getent passwd "$name" || true
|
||||||
"${getent}" passwd "$name" || true
|
|
||||||
elif [ -f /etc/passwd ]; then
|
elif [ -f /etc/passwd ]; then
|
||||||
grep "^${name}:" /etc/passwd || true
|
grep "^${name}:" /etc/passwd || true
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh -e
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
#
|
#
|
||||||
|
@ -22,18 +22,19 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
name=$__object_id
|
name=$__object_id
|
||||||
os="$("$__explorer/os")"
|
|
||||||
# Default to using shadow passwords
|
|
||||||
database="shadow"
|
|
||||||
|
|
||||||
case "$os" in
|
case $("$__explorer/os") in
|
||||||
"freebsd"|"netbsd"|"openbsd") database="passwd";;
|
'freebsd'|'netbsd'|'openbsd')
|
||||||
|
database='passwd'
|
||||||
|
;;
|
||||||
|
# Default to using shadow passwords
|
||||||
|
*)
|
||||||
|
database='shadow'
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
getent=$(command -v getent)
|
if command -v getent >/dev/null; then
|
||||||
if [ X != X"${getent}" ]; then
|
getent "$database" "$name" || true
|
||||||
"${getent}" "$database" "$name" || true
|
|
||||||
elif [ -f /etc/shadow ]; then
|
elif [ -f /etc/shadow ]; then
|
||||||
grep "^${name}:" /etc/shadow || true
|
grep "^${name}:" /etc/shadow || true
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue