diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-02 12:19:23 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-06 12:23:51 -0700 |
commit | 0cc223cebb652f8c0d4c918298a16a90c86c321d (patch) | |
tree | bf55d81b5552f12330b255857985d15a35e25c61 /src | |
parent | ed3558c213df1255944f5e3a9094d2d0bc27692f (diff) | |
download | consfigurator-0cc223cebb652f8c0d4c918298a16a90c86c321d.tar.gz |
implement obtaining LUKS passphrases as prerequisite data
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r-- | src/package.lisp | 2 | ||||
-rw-r--r-- | src/property/disk.lisp | 35 |
2 files changed, 35 insertions, 2 deletions
diff --git a/src/package.lisp b/src/package.lisp index 61f2aa5..5dd7420 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -373,7 +373,9 @@ #:volume-contents #:volume-size #:subvolumes-of-type + #:all-subvolumes #:copy-volume-and-contents + #:require-volumes-data #:physical-disk #:disk-image diff --git a/src/property/disk.lisp b/src/property/disk.lisp index 3beb73b..c8aab69 100644 --- a/src/property/disk.lisp +++ b/src/property/disk.lisp @@ -92,6 +92,13 @@ volumes encountered whose type is a subtype of TYPE.") (cons volume contents) contents)))) (walk volume)))) +(defgeneric all-subvolumes (volume) + (:documentation + "Recursively examine VOLUME and its VOLUME-CONTENTS and return a list of all +volumes encountered.") + (:method ((volume volume)) + (subvolumes-of-type 'volume volume))) + (defgeneric volume-contents-minimum-size (volume) (:documentation "Return the minimum size required to accommodate the VOLUME-CONTENTS of VOLUME.") @@ -129,6 +136,23 @@ accommodate its contents, whichever is larger.") of VOLUME where that makes sense, and explicitly nil otherwise. Return values, if any, should be ignored.")) +(defgeneric volume-required-data (volume) + (:documentation + "Return (IDEN1 . IDEN2) pairs for each item of prerequisite data opening +and/or creating the volume requires.") + (:method ((volume volume)) + "Default implementation: nothing required." + nil)) + +(defun require-volumes-data (volumes) + "Call REQUIRE-DATA on each item of prerequisite data requires for opening +and/or creating each of VOLUMES. + +Called by property :HOSTATTRS subroutines." + (dolist (pair (mapcan #'volume-required-data + (mapcan #'all-subvolumes volumes))) + (require-data (car pair) (cdr pair)))) + ;;;; Opened volumes @@ -489,6 +513,10 @@ specify \"luks1\" if this is needed."))) (defclass-opened-volume opened-luks-container (luks-container)) +(defmethod volume-required-data ((volume luks-container)) + (with-slots (luks-passphrase-iden1 volume-label) volume + (list (cons luks-passphrase-iden1 volume-label)))) + (defmethod open-volume ((volume luks-container) (file pathname)) (with-slots (luks-passphrase-iden1 volume-label) volume (unless (and (stringp volume-label) (plusp (length volume-label))) @@ -614,7 +642,10 @@ must not be modified." (volumes propapp &key (mount-below nil mount-below-supplied-p)) (:retprop :type (propapptype propapp) - :hostattrs (get (car propapp) 'hostattrs) + :hostattrs (lambda (&rest ignore) + (declare (ignore ignore)) + (require-volumes-data volumes) + (propappattrs propapp)) :apply (lambda (&rest ignore) (declare (ignore ignore)) @@ -684,7 +715,7 @@ the LVM physical volumes corresponding to those volume groups." (:desc (declare (ignore volumes chroot rebuild)) #?"Created raw disk image & other volumes") (:hostattrs - (declare (ignore volumes chroot rebuild)) + (require-volumes-data volumes) ;; We require GNU du(1). (os:required 'os:linux)) (:check |