[__ssh_authorized_keys] Better path checks

This commit is contained in:
Dennis Camera 2019-10-01 11:06:02 +02:00
parent 95ab68a272
commit 259aa13b6a
2 changed files with 41 additions and 23 deletions

View file

@ -32,7 +32,8 @@ else
if command -v getent >/dev/null
then
owner_line=$(getent passwd "$owner")
else
elif [ -f /etc/passwd ]
then
case $owner
in
[0-9][0-9]*)
@ -44,6 +45,17 @@ else
esac
fi
if [ "$owner_line" ]
then
home=$(echo "$owner_line" | cut -d':' -f6)
echo "$home/.ssh/authorized_keys"
fi
if [ ! -d "$home" ]
then
# Don't know how to determine user's home directory, fall back to ~
home="~$owner"
command -v realpath >/dev/null && home=$(realpath "$home")
fi
[ -d "$home" ] && echo "$home/.ssh/authorized_keys"
fi

View file

@ -23,6 +23,12 @@ owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")"
state="$(cat "$__object/parameter/state" 2>/dev/null)"
file="$(cat "$__object/explorer/file")"
if [ ! -f "$__object/parameter/nofile" ] && [ -z "$file" ]
then
echo "Cannot determine path of authorized_keys file" >&2
exit 1
fi
if [ ! -f "$__object/parameter/noparent" ] || [ ! -f "$__object/parameter/nofile" ]; then
group="$(cut -d':' -f 1 "$__object/explorer/group")"
if [ -z "$group" ]; then