[__ssh_authorized_keys] Better path checks
This commit is contained in:
parent
95ab68a272
commit
259aa13b6a
2 changed files with 41 additions and 23 deletions
|
@ -32,7 +32,8 @@ else
|
||||||
if command -v getent >/dev/null
|
if command -v getent >/dev/null
|
||||||
then
|
then
|
||||||
owner_line=$(getent passwd "$owner")
|
owner_line=$(getent passwd "$owner")
|
||||||
else
|
elif [ -f /etc/passwd ]
|
||||||
|
then
|
||||||
case $owner
|
case $owner
|
||||||
in
|
in
|
||||||
[0-9][0-9]*)
|
[0-9][0-9]*)
|
||||||
|
@ -44,6 +45,17 @@ else
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$owner_line" ]
|
||||||
|
then
|
||||||
home=$(echo "$owner_line" | cut -d':' -f6)
|
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
|
fi
|
||||||
|
|
|
@ -23,6 +23,12 @@ owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")"
|
||||||
state="$(cat "$__object/parameter/state" 2>/dev/null)"
|
state="$(cat "$__object/parameter/state" 2>/dev/null)"
|
||||||
file="$(cat "$__object/explorer/file")"
|
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
|
if [ ! -f "$__object/parameter/noparent" ] || [ ! -f "$__object/parameter/nofile" ]; then
|
||||||
group="$(cut -d':' -f 1 "$__object/explorer/group")"
|
group="$(cut -d':' -f 1 "$__object/explorer/group")"
|
||||||
if [ -z "$group" ]; then
|
if [ -z "$group" ]; then
|
||||||
|
|
Loading…
Reference in a new issue