diff options
author | Andrew Cady <d@cryptonomic.net> | 2021-10-30 09:04:46 -0400 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2021-10-30 09:04:46 -0400 |
commit | c0115a43369a9489bb2abe98119af86911ca0710 (patch) | |
tree | 62f82352429b0586ce93abcd83e05a4f294aeffa /EndoForge/src | |
parent | 6d6afb40c72253784149c80fb3851970ef4f0305 (diff) |
cleaned up "authline_to_sshfp" function.
Diffstat (limited to 'EndoForge/src')
-rwxr-xr-x | EndoForge/src/AnonymousAccessCommand | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/EndoForge/src/AnonymousAccessCommand b/EndoForge/src/AnonymousAccessCommand index 082f185..e000811 100755 --- a/EndoForge/src/AnonymousAccessCommand +++ b/EndoForge/src/AnonymousAccessCommand | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | default_msg() | 2 | default_msg() |
3 | { | 3 | { |
4 | sshfpline="$(get_sshfp_authline ${SSH_CLIENT%% *})" | 4 | sshfpline="$(authline_to_sshfp "$authline" "${SSH_CLIENT%% *}")" |
5 | cat <<EOF >&2 | 5 | cat <<EOF >&2 |
6 | 6 | ||
7 | You are: | 7 | You are: |
@@ -26,42 +26,31 @@ Error: access denied. The specified directory is not a self-forge. | |||
26 | EOF | 26 | EOF |
27 | } | 27 | } |
28 | 28 | ||
29 | get_sshfp_authline() | 29 | authline_to_sshfp() |
30 | { | 30 | { |
31 | ( | 31 | ( |
32 | r=${1:-.} | 32 | authline=$1 |
33 | key=$(mktemp) || exit | 33 | dnsname=${2:-.} |
34 | trap 'rm -rf "$key"' EXIT | 34 | |
35 | echo "$authline" > "$key" | 35 | authfile=$(mktemp) || exit |
36 | get_sshfp "$key" "$r" | 36 | trap 'rm -f "$authfile"' EXIT |
37 | ) | 37 | echo "$authline" > "$authfile" |
38 | } | 38 | ssh-keygen -f "$authfile" -r "$dnsname" | |
39 | 39 | while read line | |
40 | get_sshfp() | 40 | do |
41 | { | 41 | set -- $line |
42 | ( | 42 | if [ "$3 $5" = "SSHFP 2" ] |
43 | key="$1" | 43 | then |
44 | r="${2:-.}" | 44 | echo "$line" |
45 | dns=$(mktemp) || exit | 45 | break |
46 | trap 'rm -rf "$dns"' EXIT | 46 | fi |
47 | 47 | done | |
48 | ssh-keygen -r "$r" -f "$key" > "$dns" | ||
49 | exec < "$dns" | ||
50 | while read line | ||
51 | do | ||
52 | set -- $line | ||
53 | if [ "$3 $5" = "SSHFP 2" ] | ||
54 | then | ||
55 | echo "$line" | ||
56 | break | ||
57 | fi | ||
58 | done | ||
59 | ) | 48 | ) |
60 | } | 49 | } |
61 | 50 | ||
62 | ssh_client_fingerprint_base16() | 51 | ssh_client_fingerprint_base16() |
63 | { | 52 | { |
64 | set -- $(get_sshfp_authline) | 53 | set -- $(authline_to_sshfp "$authline") |
65 | [ "$6" ] | 54 | [ "$6" ] |
66 | echo $6 | 55 | echo $6 |
67 | } | 56 | } |