Skip to content

Commit

Permalink
For #18: First idea of a generic hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
fetzerms committed Aug 2, 2018
1 parent caaf9c8 commit b0a3069
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion server/retrieve_crypto_key
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
#!/bin/bash
macAddr="${SSH_ORIGINAL_COMMAND^^}"

keyfileName="PLACEHOLDER_FOR_KEYFILE"

if [ ! -z "$macAddr" ]; then
hMacAddr=$( echo $macAddr | sha1sum | awk '{ print $1 }' )
checkHash="PLACEHOLDER_FOR_MAC_ADDRESS"

if [ "$hMacAddr" == "$checkHash" ]; then
cat ~/crypt-keys/PLACEHOLDER_FOR_KEYFILE.keyfile
cat ~/crypt-keys/PLACEHOLDER_FOR_KEYFILE.keyfile
success=1
else
echo "nope!"
success=0
fi

# If hooks exist (and are executable), execute them.
if [ -d "./hooks/" ]; then
for hook in "./hooks/*" ; do
if [ -x "$hook" ]; then
# execute hook, pass keyfile name, success status and ssh client.
# surpress all output, as we expect either "nope!" or the keyfile
# as the only output.
$hook "$keyfileName" "$success" "$SSH_CLIENT" > /dev/null 2>&1

This comment has been minimized.

Copy link
@459below

459below Aug 3, 2018

Collaborator

Maybe prepending sh here? It wouldn't be too clean, but as I don't know how else we would satisfy Android requirements regarding the shebang I reckon it would be an acceptable trade-off.

This comment has been minimized.

Copy link
@fetzerms

fetzerms Aug 5, 2018

Author Owner

Hm... I was thinking of having the possibility to run other (non bash/sh) hooks as well. Such as binaries, python scripts, perl scripts... Tho I agreee - those would be very platform specific. A syslog-script might need to be implemented twice. Once for android, once for debian.

fi
done
fi
fi

0 comments on commit b0a3069

Please sign in to comment.