summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-09-15 14:30:52 -0400
committerAndrew Cady <d@jerkface.net>2020-09-15 14:30:52 -0400
commit44ee7c0f5ad0e48b30d8cda9b5a00aa65f7a36f9 (patch)
treec669ffc618c4a46c52a41f233402d09d8868c975
parent0c5876c62571161ba7fc4032db4628891863ef9a (diff)
new name format
-rwxr-xr-xbin/cryptonomic-dyndns-command18
-rwxr-xr-xbin/samizdat-ssh-uid23
2 files changed, 28 insertions, 13 deletions
diff --git a/bin/cryptonomic-dyndns-command b/bin/cryptonomic-dyndns-command
index dc420d7..8e1cbce 100755
--- a/bin/cryptonomic-dyndns-command
+++ b/bin/cryptonomic-dyndns-command
@@ -9,7 +9,9 @@ sql_string()
9 9
10powerdns_sqlite_add_replace_record() 10powerdns_sqlite_add_replace_record()
11{ 11{
12 local sql_new_domain="$(sql_string "$1.$3")" 12 local fqdn="$1.$3"
13 fqdn=${fqdn: -64 : 64}
14 local sql_new_domain="$(sql_string "$fqdn")"
13 local sql_ip_address="$(sql_string "$2")" 15 local sql_ip_address="$(sql_string "$2")"
14 local sql_domain="$(sql_string "$3")" 16 local sql_domain="$(sql_string "$3")"
15 local record_type="$(sql_string "$4")" 17 local record_type="$(sql_string "$4")"
@@ -46,6 +48,10 @@ BEGIN;
46 WHERE name=$sql_domain; 48 WHERE name=$sql_domain;
47COMMIT; 49COMMIT;
48END 50END
51 r=$?
52 [ $r = 0 ] || return $r
53
54 printf '%s %s\n' "$fqdn" "$2"
49} 55}
50 56
51add() 57add()
@@ -57,8 +63,7 @@ add()
57 *) exit 1 ;; 63 *) exit 1 ;;
58 esac 64 esac
59 65
60 powerdns_sqlite_add_replace_record "$1" "$2" "$domain" "$record_type" \ 66 powerdns_sqlite_add_replace_record "$1" "$2" "$domain" "$record_type"
61 && printf '%s %s\n' "$1.$domain $2"
62} 67}
63 68
64main() 69main()
@@ -66,16 +71,15 @@ main()
66 add "$subdomain" "$ip_address" 71 add "$subdomain" "$ip_address"
67 72
68 set -- $SSH_ORIGINAL_COMMAND 73 set -- $SSH_ORIGINAL_COMMAND
69 while [ $# -ge 2 ]; do 74 while [ $# -ge 1 ]; do
70 d=$1 75 d=$1
71 ip=$2 76 shift
72 shift 2
73 77
74 case "$d" in 78 case "$d" in
75 *.*) continue;; 79 *.*) continue;;
76 esac 80 esac
77 81
78 add "$d.$subdomain" "$ip" 82 add "$d.$subdomain" "$ip_address"
79 done 83 done
80} 84}
81 85
diff --git a/bin/samizdat-ssh-uid b/bin/samizdat-ssh-uid
index 94d8f8c..33cb2b4 100755
--- a/bin/samizdat-ssh-uid
+++ b/bin/samizdat-ssh-uid
@@ -19,12 +19,23 @@ SSH_CLIENT_FINGERPRINT=$(ssh-keygen -r . -f "${PEMFILE}" | sed -ne 's/^. IN SSHF
19SSH_CLIENT_FINGERPRINT_B32=$(b16_to_b32 "$SSH_CLIENT_FINGERPRINT") 19SSH_CLIENT_FINGERPRINT_B32=$(b16_to_b32 "$SSH_CLIENT_FINGERPRINT")
20 20
21read keytype keydata < "${PEMFILE}" || die "reading from PEMFILE=$PEMFILE" 21read keytype keydata < "${PEMFILE}" || die "reading from PEMFILE=$PEMFILE"
22case "$keytype" in 22
23 ssh-rsa|ssh-dss|ecdsa-sha2-nistp256|ssh-ed25519) 23ssh_keytag_to_path_fragment()
24 domain=$keytype.cryptonomic.net ;; 24{
25 *) 25 case "$1" in
26 die "Unsupported key type: $keytype" ;; 26 ssh-dss) echo dsa ;;
27esac 27 ecdsa-sha2-nistp256) echo ecdsa ;;
28 ssh-rsa|ssh-ed25519) echo ${1#ssh-} ;;
29 *) return 1 ;;
30 esac
31}
32
33if keyfrag=$(ssh_keytag_to_path_fragment "$keytype")
34then
35 domain=${keyfrag}.cryptonomic.net
36else
37 die "Unsupported key type: $keytype"
38fi
28 39
29if [ "$1" = '--copy-pem' -a "$2" ] 40if [ "$1" = '--copy-pem' -a "$2" ]
30then 41then