26 lines
367 B
Text
26 lines
367 B
Text
|
#!/bin/bash
|
||
|
# ^^^^ Because we need Bash arrays.
|
||
|
|
||
|
set -e
|
||
|
|
||
|
UNKNOWN=3
|
||
|
|
||
|
unset command
|
||
|
declare -A command
|
||
|
. /etc/sshmon.cfg
|
||
|
|
||
|
if [[ -z "$SSH_ORIGINAL_COMMAND" ]]
|
||
|
then
|
||
|
echo "No command given" >&2
|
||
|
exit $UNKNOWN
|
||
|
fi
|
||
|
|
||
|
execute=${command["$SSH_ORIGINAL_COMMAND"]}
|
||
|
if [[ -z "$execute" ]]
|
||
|
then
|
||
|
echo "Unknown command" >&2
|
||
|
exit $UNKNOWN
|
||
|
fi
|
||
|
|
||
|
exec sh -c "$execute"
|