northox / 2sshfp

Build SSHFP DNS records - xmss, ecdsa & ed25519 support
40 stars 4 forks source link

echo -> printf lost newline #7

Closed dtucny closed 7 years ago

dtucny commented 7 years ago

The recent commit to change echo to printf, 6f58718fa60690e17a9b12532d5a5c1fc5808ca6, appears to have had the unintended consequence of losing newlines. echo adding them by default, printf not so.

Simply adding a newline fixes this.

--- bin/2sshfp.orig     2017-05-12 17:55:17.504030010 +0800
+++ bin/2sshfp  2017-05-12 17:55:49.780881219 +0800
@@ -1,7 +1,7 @@
 #!/bin/sh
 # A secure way to create SSHFP records (local) | Danny Fullerton - mantor.org | license: public domain
 if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
-  printf "Usage:\t$0 <hostname>\n\t$0 galvatron.mantor.org." >&2
+  printf "Usage:\t$0 <hostname>\n\t$0 galvatron.mantor.org.\n" >&2
   exit 1
 fi
 name=$1
@@ -13,7 +13,7 @@
     if [ -f $key_path ]; then
       eval "h=\${hash${j}}"
       sshfp=`awk '{print $2}' $key_path | openssl base64 -d -A | openssl dgst -${h} | sed 's/^.* //' | awk '{print $1}' | tr '[a-z]' '[A-Z]'`
-      printf "${name} IN SSHFP ${i} ${j} ${sshfp}"
+      printf "${name} IN SSHFP ${i} ${j} ${sshfp}\n"
     fi
   done
 done
northox commented 7 years ago

I should remember to avoid direct github edits ;). Thanks.