From patchwork Sat Jan 15 13:50:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josselin Poiret X-Patchwork-Id: 36379 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 75F6627BBEA; Sat, 15 Jan 2022 13:53:15 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id F324127BBE9 for ; Sat, 15 Jan 2022 13:53:14 +0000 (GMT) Received: from localhost ([::1]:42442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8jUY-00085O-3w for patchwork@mira.cbaines.net; Sat, 15 Jan 2022 08:53:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8jTc-00067d-Jh for guix-patches@gnu.org; Sat, 15 Jan 2022 08:52:16 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8jTP-0004RN-97 for guix-patches@gnu.org; Sat, 15 Jan 2022 08:52:14 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8jTP-0001ud-9U for guix-patches@gnu.org; Sat, 15 Jan 2022 08:52:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53063] [PATCH v2 wip-harden-installer 17/18] installer: Turn passwords into opaque records. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 15 Jan 2022 13:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53063 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Mathieu Othacehe Cc: 53063@debbugs.gnu.org, ludo@gnu.org, Josselin Poiret Received: via spool by 53063-submit@debbugs.gnu.org id=B53063.16422546757245 (code B ref 53063); Sat, 15 Jan 2022 13:52:03 +0000 Received: (at 53063) by debbugs.gnu.org; 15 Jan 2022 13:51:15 +0000 Received: from localhost ([127.0.0.1]:39543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8jSd-0001sg-8t for submit@debbugs.gnu.org; Sat, 15 Jan 2022 08:51:15 -0500 Received: from jpoiret.xyz ([206.189.101.64]:49658) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8jS3-0001nw-J1 for 53063@debbugs.gnu.org; Sat, 15 Jan 2022 08:50:40 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id E1B61185148; Sat, 15 Jan 2022 13:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1642254639; 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=mgahbeW99p08uqGuUoQSrqa3yRE4WTyhH8DCGFxLk5c=; b=W/p+G0xRU+ZoDEi6PIrFpUTc503oYj18Om1eD3MsQMuodjZP3LICSgR1GsWrkwCdVya6nN y61eces6/kDQhld9SZlVo6/atIchs2FH7ceAXg7pTW6SephK2MrVlJzcZ8RITKAj/QmaAl vDz4VL4WTJr+HTfS2s1iGMCW+XTkjMktmWww4HUx/JWFMLMlzo5+J5C9XazhRcaSFBCpod UfKrpmaMI1dQ1c7+wB9OQv9cj6hos20Sic7Mtitxwn6AaNxNX3xMD/7O5sRsqKAhzsnNP+ DCR4jHS/A3lunSxrZ159qYBhHhrBZ04SPW9xzymJYyCptNrXVxUiHiGhR5LjhQ== Date: Sat, 15 Jan 2022 14:50:10 +0100 Message-Id: <20220115135011.5817-18-dev@jpoiret.xyz> In-Reply-To: <20220115135011.5817-1-dev@jpoiret.xyz> References: <8735lz4xsv.fsf@gnu.org> <20220115135011.5817-1-dev@jpoiret.xyz> MIME-Version: 1.0 X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches X-Patchwork-Original-From: Josselin Poiret via Guix-patches via From: Josselin Poiret X-getmail-retrieved-from-mailbox: Patches * gnu/installer/user.scm (, secret?, make-secret, secret-content): Add opaque record that boxes its contents, with a custom printer that doesn't display anything. * gnu/installer/newt/user.scm (run-user-add-page, run-user-page): Box it. * gnu/installer/final.scm (create-user-database): Unbox it. --- gnu/installer/final.scm | 5 +++-- gnu/installer/newt/user.scm | 6 +++--- gnu/installer/user.scm | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm index 63e5073ff4..2087536502 100644 --- a/gnu/installer/final.scm +++ b/gnu/installer/final.scm @@ -85,8 +85,9 @@ (define root? (uid (if root? 0 #f)) (home-directory (user-home-directory user)) - (password (crypt (user-password user) - (salt))) + (password (crypt + (secret-content (user-password user)) + (salt))) ;; We need a string here, not a file-like, hence ;; this choice. diff --git a/gnu/installer/newt/user.scm b/gnu/installer/newt/user.scm index 97141cfe64..7c1cc2249d 100644 --- a/gnu/installer/newt/user.scm +++ b/gnu/installer/newt/user.scm @@ -143,7 +143,7 @@ (define (pad-label label) (name name) (real-name real-name) (home-directory home-directory) - (password password)) + (password (make-secret password))) (run-user-add-page #:name name #:real-name real-name #:home-directory @@ -266,7 +266,7 @@ (define (run users) (map (lambda (name real-name home password) (user (name name) (real-name real-name) (home-directory home) - (password password))) + (password (make-secret password)))) names real-names homes passwords)))))) (lambda () (destroy-form-and-pop form)))))) @@ -274,5 +274,5 @@ (define (run users) ;; Add a "root" user simply to convey the root password. (cons (user (name "root") (home-directory "/root") - (password (run-root-password-page))) + (password (make-secret (run-root-password-page)))) (run '()))) diff --git a/gnu/installer/user.scm b/gnu/installer/user.scm index 4e701e64ce..13114e9832 100644 --- a/gnu/installer/user.scm +++ b/gnu/installer/user.scm @@ -19,7 +19,14 @@ (define-module (gnu installer user) #:use-module (guix records) #:use-module (srfi srfi-1) - #:export ( + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) + #:export ( + secret? + make-secret + secret-content + + user make-user user-name @@ -30,6 +37,15 @@ (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?