From debbugs-submit-bounces@debbugs.gnu.org Sat May 14 02:05:52 2022 Received: (at submit) by debbugs.gnu.org; 14 May 2022 06:05:52 +0000 Received: from localhost ([127.0.0.1]:45580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npkuW-0001bS-Gi for submit@debbugs.gnu.org; Sat, 14 May 2022 02:05:52 -0400 Received: from lists.gnu.org ([209.51.188.17]:56974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1npkuS-0001bE-2i for submit@debbugs.gnu.org; Sat, 14 May 2022 02:05:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npkuM-0005uT-0x for guix-patches@gnu.org; Sat, 14 May 2022 02:05:47 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:36542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npkuJ-0007Dp-0E for guix-patches@gnu.org; Sat, 14 May 2022 02:05:40 -0400 Received: by mail-qt1-x82d.google.com with SMTP id v14so7604874qtc.3 for ; Fri, 13 May 2022 23:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Et6KGkarKqbelUod9AZhAePCxLxcXkKuc3NzZyP+ElQ=; b=dC8RXhGMpdKbqdKsxQ7dVJ3Zgp+glduFrMstJHoOVpBDr7JvYGK7Lzlx9Wxi1+ewCn r9OjuNZC6FnV0HJVSwwyvai//X7BmidrBg/WkffU5i7xDvIQVBWB0Mp2YfRnlm8VIdrv nlNQH1eEgcEYtT9G1W7N+JeWitytuHBSfbM6D+q7buD/S3lhqutVP3KPczAbnDneRxdG 9e9lJEm0JZZPHTdz2g4yQeTPD3bvU1hW/mAhlQILm+RYo5Okx2MEtL0/BsHdhf0Z81hq LPgFszb+d4sMecTQmuLWrX0uJuEazmhSe/PR7ozIKd4VCq9rwPg00P6h166PhlqmxtnY K7mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Et6KGkarKqbelUod9AZhAePCxLxcXkKuc3NzZyP+ElQ=; b=he230viZg6zCRqy6cznYMcrfUu1KVFsFZxSItjNIgeNOM9aNmB/fgw7U1NMARidxoZ l4VfBs4fDXxaNCa8liVcAAEdkf0EDKBdbwQpVHL/vRrNJ7q05032xIwEsu/ALtsf42Qq dk3x4EWX7tf0adQ82ALY9xM10f+CmEovDTQl3kh8JK173Ct2Mw1gWF+LNJhU/sz4rZOJ S+Cqvyisb3XhlAzyc04JtUAM3ogfXc2fn5VddMKzcStmxakKWjbQtCm55aBNBeLmSJ+A 2ll+0G1A2fuASXgW1Pz7BBJYIF88+a+jVhzLvsRzNncaVJjHuU7h9YLnUBy9uHIRsB7P SwtQ== X-Gm-Message-State: AOAM530q8bQXzxocPM0sSOvLNBRAhO97VHJN+1lDc34beTfyzQ/l4n0k ovXlig8n+v9X614n5sbxlCvZBWWnwSGPfw== X-Google-Smtp-Source: ABdhPJxoJs3YvQMakAgdzyW496wG1O2hPTLVAAwHEnj0DpUdR2LMlBp3ERG4gIMsPTQAdRPEDNjI5g== X-Received: by 2002:a05:622a:13cf:b0:2f3:d843:1a4d with SMTP id p15-20020a05622a13cf00b002f3d8431a4dmr7573921qtk.609.1652508337872; Fri, 13 May 2022 23:05:37 -0700 (PDT) Received: from localhost.localdomain (dsl-149-239.b2b2c.ca. [66.158.149.239]) by smtp.gmail.com with ESMTPSA id h26-20020ac8777a000000b002f39b99f68csm2604675qtu.38.2022.05.13.23.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 23:05:37 -0700 (PDT) From: Maxim Cournoyer To: guix-patches@gnu.org Subject: [PATCH] system: Improve warning when using LUKS mapped devices without UUIDs. Date: Sat, 14 May 2022 02:05:32 -0400 Message-Id: <20220514060532.1011-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x82d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: Maxim Cournoyer 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: -2.3 (--) This corrects two problems with the previous mapped devices warning: 1. It wasn't clear how to correct the situation. 2. The output would be repeated twice, as the procedure is called twice during a system reconfigure. * gnu/system.scm (operating-system-bootloader-crypto-devices): Memoize procedure. Produce a single message for the combined problematic devices. Add a hint to help users fix the warning. --- gnu/system.scm | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index c3810cbeeb..b090eeae01 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -33,6 +33,7 @@ (define-module (gnu system) #:use-module (guix inferior) #:use-module (guix store) + #:use-module (guix memoization) #:use-module (guix monads) #:use-module (guix gexp) #:use-module (guix records) @@ -78,7 +79,9 @@ (define-module (gnu system) #:use-module (gnu system uuid) #:use-module (gnu system file-systems) #:use-module (gnu system mapped-devices) + #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 receive) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -600,25 +603,26 @@ (define (operating-system-boot-mapped-devices os) (any file-system-needed-for-boot? users))) devices))) -(define (operating-system-bootloader-crypto-devices os) - "Return the subset of mapped devices that the bootloader must open. -Only devices specified by uuid are supported." - (define (valid-crypto-device? dev) - (or (uuid? dev) - (begin - (warning (G_ "\ -mapped-device '~a' may not be mounted by the bootloader.~%") - dev) - #f))) - (filter-map (match-lambda - ((and (= mapped-device-type type) - (= mapped-device-source source)) - (and (eq? luks-device-mapping type) - (valid-crypto-device? source) - source)) - (_ #f)) - ;; XXX: Ordering is important, we trust the returned one. - (operating-system-boot-mapped-devices os))) +(define operating-system-bootloader-crypto-devices + (mlambda (os) ;to avoid duplicated output + "Return the sources of the LUKS mapped devices specified by UUID." + ;; XXX: Device ordering is important, we trust the returned one. + (let ((luks-devices (filter (lambda (m) + (eq? luks-device-mapping + (mapped-device-type m))) + (operating-system-boot-mapped-devices os)))) + (receive (uuid-crypto-devices non-uuid-crypto-devices) + (partition (compose uuid? mapped-device-source) luks-devices) + (when (not (null? non-uuid-crypto-devices)) + (warning (N_ "\ +the following mapped device may not be mounted by the bootloader: ~s +hint: specify the mapped device source via its LUKS UUID.~%" + "\ +the following mapped devices may not be mounted by the bootloader: ~s +hint: specify the mapped device sources via their LUKS UUID.~%" + (length non-uuid-crypto-devices)) + (map mapped-device-source non-uuid-crypto-devices))) + (map mapped-device-source uuid-crypto-devices))))) (define (device-mapping-services os) "Return the list of device-mapping services for OS as a list." -- 2.36.0