installer: Move <secret> to utils and use it for crypt passwords.

* gnu/installer/user.scm (<secret>, secret?, make-secret, secret-content): Move
to utils.scm.
* gnu/installer/utils.scm (<secret>, secret?, make-secret, secret-content):
Moved from user.scm.
* gnu/installer/newt/partition.scm (prompt-luks-passwords): Make password a
<secret>.
* gnu/installer/parted.scm (luks-format-and-open): Unwrap secret.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
This commit is contained in:
Josselin Poiret 2022-09-22 15:12:44 +02:00 committed by Mathieu Othacehe
parent 3c4024e9f5
commit 4814ec284f
No known key found for this signature in database
GPG key ID: 8354763531769CA6
4 changed files with 23 additions and 20 deletions

View file

@ -188,7 +188,7 @@ (define (prompt-luks-passwords user-partitions)
(if (string=? password confirmation) (if (string=? password confirmation)
(user-partition (user-partition
(inherit user-part) (inherit user-part)
(crypt-password password)) (crypt-password (make-secret password)))
(begin (begin
(run-error-page (run-error-page
(G_ "Password mismatch, please try again.") (G_ "Password mismatch, please try again.")

View file

@ -148,7 +148,7 @@ (define-record-type* <user-partition>
(default #f)) (default #f))
(crypt-label user-partition-crypt-label (crypt-label user-partition-crypt-label
(default #f)) (default #f))
(crypt-password user-partition-crypt-password (crypt-password user-partition-crypt-password ; <secret>
(default #f)) (default #f))
(fs-type user-partition-fs-type (fs-type user-partition-fs-type
(default 'ext4)) (default 'ext4))
@ -1183,7 +1183,7 @@ (define (luks-format-and-open user-partition)
"Format and open the encrypted partition pointed by USER-PARTITION." "Format and open the encrypted partition pointed by USER-PARTITION."
(let* ((file-name (user-partition-file-name user-partition)) (let* ((file-name (user-partition-file-name user-partition))
(label (user-partition-crypt-label user-partition)) (label (user-partition-crypt-label user-partition))
(password (user-partition-crypt-password user-partition))) (password (secret-content (user-partition-crypt-password user-partition))))
(call-with-luks-key-file (call-with-luks-key-file
password password
(lambda (key-file) (lambda (key-file)

View file

@ -17,17 +17,13 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu installer user) (define-module (gnu installer user)
#:use-module (gnu installer utils)
#:use-module (guix records) #:use-module (guix records)
#:use-module (guix read-print) #:use-module (guix read-print)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-9) #:use-module (srfi srfi-9)
#:use-module (srfi srfi-9 gnu) #:use-module (srfi srfi-9 gnu)
#:export (<secret> #:export (<user>
secret?
make-secret
secret-content
<user>
user user
make-user make-user
user-name user-name
@ -38,16 +34,6 @@ (define-module (gnu installer user)
users->configuration)) users->configuration))
(define-record-type <secret>
(make-secret content)
secret?
(content secret-content))
(set-record-type-printer!
<secret>
(lambda (secret port)
(format port "<secret>")))
(define-record-type* <user> (define-record-type* <user>
user make-user user make-user
user? user?

View file

@ -23,6 +23,8 @@ (define-module (gnu installer utils)
#:use-module (guix build utils) #:use-module (guix build utils)
#:use-module (guix i18n) #:use-module (guix i18n)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-9 gnu)
#:use-module (srfi srfi-19) #:use-module (srfi srfi-19)
#:use-module (srfi srfi-34) #:use-module (srfi srfi-34)
#:use-module (srfi srfi-35) #:use-module (srfi srfi-35)
@ -33,7 +35,12 @@ (define-module (gnu installer utils)
#:use-module (ice-9 regex) #:use-module (ice-9 regex)
#:use-module (ice-9 format) #:use-module (ice-9 format)
#:use-module (ice-9 textual-ports) #:use-module (ice-9 textual-ports)
#:export (read-lines #:export (<secret>
secret?
make-secret
secret-content
read-lines
read-all read-all
nearest-exact-integer nearest-exact-integer
read-percentage read-percentage
@ -58,6 +65,16 @@ (define-module (gnu installer utils)
with-silent-shepherd)) with-silent-shepherd))
(define-record-type <secret>
(make-secret content)
secret?
(content secret-content))
(set-record-type-printer!
<secret>
(lambda (secret port)
(format port "<secret>")))
(define* (read-lines #:optional (port (current-input-port))) (define* (read-lines #:optional (port (current-input-port)))
"Read lines from PORT and return them as a list." "Read lines from PORT and return them as a list."
(let loop ((line (read-line port)) (let loop ((line (read-line port))