-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #18: First idea of a generic hook.
- Loading branch information
Showing
1 changed file
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fetzerms
Author
Owner
|
||
fi | ||
done | ||
fi | ||
fi |
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.