From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 22 09:13:29 2022 Received: (at 57983) by debbugs.gnu.org; 22 Sep 2022 13:13:29 +0000 Received: from localhost ([127.0.0.1]:36663 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obM1A-0003xs-JU for submit@debbugs.gnu.org; Thu, 22 Sep 2022 09:13:29 -0400 Received: from jpoiret.xyz ([206.189.101.64]:47102) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obM16-0003xF-40 for 57983@debbugs.gnu.org; Thu, 22 Sep 2022 09:13:26 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id DAC15185310; Thu, 22 Sep 2022 13:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1663852403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3GiqGi2LUhd0IyqbH14wmH4Dq059uSd90gr5jJFKDBk=; b=w4r/0FL02yDzT0OAFys+sEe53GS9jD7bNK9XtlTfPl7EMAt1kO7LP5fi9W4bwo2uVXDasS R6h7vvvsBn6Vkv1hD5cq3b2MK3PAT6ayI9Dkzw7wKeryHxid5pdXM2kaNN389Rl2Pux7oX O+NbTdSiSQN3JtT9hybWrC4Eo809lF/SdwMTkfl4zevs/7pFVfzBmM6e4PUxm+yTHuA884 g83ZUbcB2EOaYyJb/CYuaA1Jca+VeQqx8sQKMOc0gbd4jcQkJxcmAyzDIz5NfwMSb3hJwY rdNUCclEpCIfR6YGv7grIlKfpUb6jqFHY2m4nnY+rRMUXAuS/FblExo57JRfog== From: Josselin Poiret To: Mathieu Othacehe , Dan Finlay Subject: [PATCH 1/4] installer: Move to utils and use it for crypt passwords. Date: Thu, 22 Sep 2022 15:12:44 +0200 Message-Id: <136dd86c030223934f2cadfc47c57bb2949ccfbd.1663852053.git.dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/installer/user.scm (, secret?, make-secret, secret-content): Move to utils.scm. * gnu/installer/utils.scm (, secret?, make-secret, secret-content): Moved from user.scm. * gnu/ins [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 57983 Cc: Josselin Poiret , 57983@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) * gnu/installer/user.scm (, secret?, make-secret, secret-content): Move to utils.scm. * gnu/installer/utils.scm (, secret?, make-secret, secret-content): Moved from user.scm. * gnu/installer/newt/partition.scm (prompt-luks-passwords): Make password a . * gnu/installer/parted.scm (luks-format-and-open): Unwrap secret. --- gnu/installer/newt/partition.scm | 2 +- gnu/installer/parted.scm | 4 ++-- gnu/installer/user.scm | 18 ++---------------- gnu/installer/utils.scm | 19 ++++++++++++++++++- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/gnu/installer/newt/partition.scm b/gnu/installer/newt/partition.scm index e7a97810ac..eda34e0461 100644 --- a/gnu/installer/newt/partition.scm +++ b/gnu/installer/newt/partition.scm @@ -188,7 +188,7 @@ (define (prompt-luks-passwords user-partitions) (if (string=? password confirmation) (user-partition (inherit user-part) - (crypt-password password)) + (crypt-password (make-secret password))) (begin (run-error-page (G_ "Password mismatch, please try again.") diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index 84fdbe24fb..51ba2bebd6 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -148,7 +148,7 @@ (define-record-type* (default #f)) (crypt-label user-partition-crypt-label (default #f)) - (crypt-password user-partition-crypt-password + (crypt-password user-partition-crypt-password ; (default #f)) (fs-type user-partition-fs-type (default 'ext4)) @@ -1183,7 +1183,7 @@ (define (luks-format-and-open user-partition) "Format and open the encrypted partition pointed by USER-PARTITION." (let* ((file-name (user-partition-file-name 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 password (lambda (key-file) diff --git a/gnu/installer/user.scm b/gnu/installer/user.scm index 224040530c..2866e4520f 100644 --- a/gnu/installer/user.scm +++ b/gnu/installer/user.scm @@ -17,17 +17,13 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu installer user) + #:use-module (gnu installer utils) #:use-module (guix records) #:use-module (guix read-print) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) - #:export ( - secret? - make-secret - secret-content - - + #:export ( user make-user user-name @@ -38,16 +34,6 @@ (define-module (gnu installer user) users->configuration)) -(define-record-type - (make-secret content) - secret? - (content secret-content)) - -(set-record-type-printer! - - (lambda (secret port) - (format port ""))) - (define-record-type* user make-user user? diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm index fb62fb8896..5fd2e2d425 100644 --- a/gnu/installer/utils.scm +++ b/gnu/installer/utils.scm @@ -23,6 +23,8 @@ (define-module (gnu installer utils) #:use-module (guix build utils) #:use-module (guix i18n) #: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-34) #:use-module (srfi srfi-35) @@ -33,7 +35,12 @@ (define-module (gnu installer utils) #:use-module (ice-9 regex) #:use-module (ice-9 format) #:use-module (ice-9 textual-ports) - #:export (read-lines + #:export ( + secret? + make-secret + secret-content + + read-lines read-all nearest-exact-integer read-percentage @@ -58,6 +65,16 @@ (define-module (gnu installer utils) with-silent-shepherd)) +(define-record-type + (make-secret content) + secret? + (content secret-content)) + +(set-record-type-printer! + + (lambda (secret port) + (format port ""))) + (define* (read-lines #:optional (port (current-input-port))) "Read lines from PORT and return them as a list." (let loop ((line (read-line port)) -- 2.37.2