chiark / gitweb /
Build .ssh/authorized_keys using our sshsvc machinery.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 4 Apr 2015 11:50:17 +0000 (12:50 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 4 Apr 2015 23:38:52 +0000 (00:38 +0100)
.gitignore
.ssh/.gitignore [new file with mode: 0644]
.ssh/Makefile [new file with mode: 0644]
.ssh/sshsvc.conf [new file with mode: 0644]
bin/update

index aa88922..bd8ebae 100644 (file)
@@ -1,2 +1 @@
-.ssh/
 dyndns.conf
diff --git a/.ssh/.gitignore b/.ssh/.gitignore
new file mode 100644 (file)
index 0000000..80702e3
--- /dev/null
@@ -0,0 +1,3 @@
+authorized_keys
+domains.conf
+keys/
diff --git a/.ssh/Makefile b/.ssh/Makefile
new file mode 100644 (file)
index 0000000..a5d51e0
--- /dev/null
@@ -0,0 +1,4 @@
+### -*-makefile-*-
+
+authorized_keys: sshsvc.conf domains.conf keys $(wildcard keys/*.pub)
+       sshsvc-mkauthkeys
diff --git a/.ssh/sshsvc.conf b/.ssh/sshsvc.conf
new file mode 100644 (file)
index 0000000..5099cdd
--- /dev/null
@@ -0,0 +1,22 @@
+### -*-sh-*-
+
+make_key_line () {
+  user=$1
+  hosts=""
+  zone=""
+  while read u hh; do
+    case $u in "" | \#*) continue ;; esac
+    case $user in $u) ;; *) continue ;; esac
+    for h in $hh; do
+      case $h in
+       zone=*) zone=${h#*=} ;;
+       *) hosts=${hosts:+$hosts }$h ;;
+      esac
+    done
+  done <domains.conf
+  case ${hosts+t} in t) ;; *) continue ;; esac
+  line="environment=\"DYNDNS_HOST=$hosts\""
+  line="$line${zone:+,environment=\"DYNDNS_ZONE=$zone\"}"
+  line="$line,command=\"bin/update\""
+  echo "$line"
+}
index 957df07..60cbea0 100755 (executable)
@@ -68,7 +68,7 @@ case "$cmd" in
       0,t,*) fail_usage ;;
       *,nil,"$client" | *,t,*) addr=$1; shift ;;
       *)
-       echo >&2 "$0: incorrect address (wanted = $2; found = $addr)"
+       echo >&2 "$0: incorrect address (wanted = $client; found = $1)"
        exit 3
        ;;
     esac