aboutsummaryrefslogtreecommitdiff
path: root/src/data
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-02-21 10:42:10 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-02-21 10:42:24 -0700
commit3d3b0526657556cb986be202b3143c27dc9b319c (patch)
tree2fe72262bf3e3841bac055546aeef757f7a599c8 /src/data
parent1b14862d157c6ef8b2fa97b4cfa7fc9ef479a3ff (diff)
downloadconsfigurator-3d3b0526657556cb986be202b3143c27dc9b319c.tar.gz
have PGP data source signal MISSING-DATA-SOURCE
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/data')
-rw-r--r--src/data/pgp.lisp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/data/pgp.lisp b/src/data/pgp.lisp
index 22cfed2..cff64ac 100644
--- a/src/data/pgp.lisp
+++ b/src/data/pgp.lisp
@@ -23,11 +23,14 @@
;; user to call at the REPL to add pieces of data, see what's there, etc. (a
;; prerequisite data source which was some sort of external file-generating or
;; secrets storage database might not provide any functions for the REPL).
+;;
+;; You will need to touch(1) the file you wish to use before trying to
+;; register it.
(defmethod register-data-source ((type (eql :pgp)) &key location)
(unless (file-exists-p location)
- (with-open-file (s location :direction :output)
- (print "" s)))
+ (error 'missing-data-source
+ :text (format nil "Could not open ~A" location)))
(let ((mod (file-write-date location))
(cache (read-store location)))
(labels ((update-cache ()
@@ -43,12 +46,15 @@
(cons #'check #'extract))))
(defun read-store (location)
- (unless (file-exists-p location)
- (error "~A does not exist!" location))
- (read-from-string
- (run-program
- (escape-sh-command (list "gpg" "--decrypt" (unix-namestring location)))
- :output :string)))
+ (handler-case
+ (read-from-string
+ (run-program
+ (escape-sh-command (list "gpg" "--decrypt" (unix-namestring location)))
+ :output :string))
+ (subprocess-error (error)
+ (error 'missing-data-source
+ :text (format nil "While attempt to decrypt, gpg exited with ~A"
+ (uiop:subprocess-error-code error))))))
(defun put-store (location data)
(run-program (list "gpg" "--encrypt")