zone.lisp: Apply pathname templates to DKIM and SSHFP files.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 15 Apr 2014 14:02:31 +0000 (15:02 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 15 Apr 2014 15:47:05 +0000 (16:47 +0100)
Makes zone files nicer.  Alas, not compatible; sorry.

zone.lisp

index a6c4944..f03b9dd 100644 (file)
--- a/zone.lisp
+++ b/zone.lisp
   ":txt TEXT"
   (rec :data data))
 
+(export '*dkim-pathname-defaults*)
+(defvar *dkim-pathname-defaults*
+  (make-pathname :directory '(:relative "keys")
+                :type "dkim"))
+
 (defzoneparse :dkim (name data rec)
   ":dkim (KEYFILE {:TAG VALUE}*)"
   (destructuring-bind (file &rest plist) (listify data)
        (emit (with-output-to-string (out)
                (write-string "p=" out)
                (when file
-                 (with-open-file (in file :direction :input)
+                 (with-open-file
+                     (in (merge-pathnames file *dkim-pathname-defaults*))
                    (loop
                      (when (string= (read-line in)
                                     "-----BEGIN PUBLIC KEY-----")
       (setf (get sym prop) val)
       (export sym))))
 
+(export '*sshfp-pathname-defaults*)
+(defvar *sshfp-pathname-defaults*
+  (make-pathname :directory '(:relative "keys")
+                :type "sshfp"))
+
 (defzoneparse :sshfp (name data rec)
   ":sshfp { FILENAME | ((FPR :alg ALG :type HASH)*) }"
   (if (stringp data)
-      (with-open-file (in data)
+      (with-open-file (in (merge-pathnames data *sshfp-pathname-defaults*))
        (loop (let ((line (read-line in nil)))
                (unless line (return))
                (let ((words (str-split-words line)))