packages: djbdns/add-sshfp.sh (NEW), djbdns/add-sshfp.pl (REMOVED) - slower...
glen
glen at pld-linux.org
Fri Aug 6 10:36:05 CEST 2010
Author: glen Date: Fri Aug 6 08:36:05 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- slower, but without perl dependency
---- Files affected:
packages/djbdns:
add-sshfp.sh (NONE -> 1.1) (NEW), add-sshfp.pl (1.1 -> NONE) (REMOVED)
---- Diffs:
================================================================
Index: packages/djbdns/add-sshfp.sh
diff -u /dev/null packages/djbdns/add-sshfp.sh:1.1
--- /dev/null Fri Aug 6 10:36:05 2010
+++ packages/djbdns/add-sshfp.sh Fri Aug 6 10:35:59 2010
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Script to convert SSHFP Bind format records to djbdns tinydns.
+#
+# Author: Elan Ruusamäe <glen at pld-linux.org>
+#
+# Inspired from Perl version
+# http://dank.qemfd.net/dankwiki/index.php/SSHFP
+
+# convert decimal to octal
+dec2oct() {
+ echo "ibase=10; obase=8; $1" | bc -l
+}
+
+# convert hex to octal
+hex2oct() {
+ # bc wants uppercase hex
+ local i=$(echo "$1" | tr [a-f] [A-F])
+ echo "ibase=16; obase=8; $i" | bc -l
+}
+
+hostalias=$1
+ssh-keygen -f /etc/ssh/ssh_host_rsa_key.pub -r $hostalias | \
+while read host in sshfp alg fptype fp; do
+ out="\\"$(printf "%03d" $(dec2oct $alg))
+ out=$out"\\"$(printf "%03d" $(dec2oct $fptype))
+
+ while [ "$fp" ]; do
+ # temp chop off two bytes
+ t=${fp#??}
+ # take the bytes
+ ch=${fp%$t}
+ out=$out"\\"$(printf "%03d" $(hex2oct $ch))
+ # continue fp
+ fp=$t
+ done
+ printf ":%s:44:%s:\n" $host $out
+done
================================================================
More information about the pld-cvs-commit
mailing list