Merge branch 'nogetent-dotssh' into 'master'

[__ssh_dot_ssh] Fall back to /etc files if getent(1) is not available

See merge request ungleich-public/cdist!796
This commit is contained in:
poljakowski 2019-10-01 13:16:25 +02:00
commit 69e5e538ac
2 changed files with 23 additions and 3 deletions

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# 2014 Steven Armstrong (steven-cdist at armstrong.cc) # 2014 Steven Armstrong (steven-cdist at armstrong.cc)
# 2019 Dennis Camera (dennis.camera at ssrq-sds-fds.ch)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -18,5 +19,11 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
gid="$("$__type_explorer/passwd" | cut -d':' -f 4)" gid=$("$__type_explorer/passwd" | cut -d':' -f4)
getent group "$gid" || true
if command -v getent >/dev/null
then
getent group "$gid" || true
else
awk -F: "\$3 == \"$gid\" { print }" /etc/group
fi

View file

@ -2,6 +2,7 @@
# #
# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # 2012 Steven Armstrong (steven-cdist at armstrong.cc)
# 2014 Nico Schottelius (nico-cdist at schottelius.org) # 2014 Nico Schottelius (nico-cdist at schottelius.org)
# 2019 Dennis Camera (dennis.camera at ssrq-sds-fds.ch)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -21,4 +22,16 @@
owner="$__object_id" owner="$__object_id"
getent passwd "$owner" || true if command -v getent >/dev/null
then
getent passwd "$owner" || true
else
case $owner in
[0-9][0-9]*)
awk -F: "\$3 == \"$owner\" { print }" /etc/passwd
;;
*)
grep "^$owner:" /etc/passwd || true
;;
esac
fi