From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id IGFdKxRIf2L/TgAAbAwnHQ (envelope-from ) for ; Sat, 14 May 2022 08:11:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id qHtHKxRIf2I0/AAA9RJhRA (envelope-from ) for ; Sat, 14 May 2022 08:11:32 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 30FCEAE90 for ; Sat, 14 May 2022 08:11:32 +0200 (CEST) Received: from localhost ([::1]:51948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npkzz-0001K0-9y for larch@yhetil.org; Sat, 14 May 2022 02:11:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npkuh-0005ww-7z for guix-patches@gnu.org; Sat, 14 May 2022 02:06:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npkug-0007Ih-IV for guix-patches@gnu.org; Sat, 14 May 2022 02:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1npkug-0001bt-CF for guix-patches@gnu.org; Sat, 14 May 2022 02:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55407] [PATCH] system: Improve warning when using LUKS mapped devices without UUIDs. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 14 May 2022 06:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55407 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55407@debbugs.gnu.org Cc: Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16525083526170 (code B ref -1); Sat, 14 May 2022 06:06:02 +0000 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 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-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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652508692; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Et6KGkarKqbelUod9AZhAePCxLxcXkKuc3NzZyP+ElQ=; b=uB8ZZw03kyYhAI1OzE+b3FnZFS1PI1Xptj9SmIgr6XDWdcfSCSLXhuzTy9ogIZY/K7RF2P +AZlvTYmTw25UUmE6HOrLdfKespbrMkHk5Nm/8+BcabMS57qrg91yUPfPNVtVAud+mFpns K6Wv/HPJtTWfAxNFOOU9vAS9ik6VNjK74c6qrVuB2b8C7HjAdI19V2vrPtAYRPf27HpY9n MFX5cmbyRbC8/+ezRgSzjmhdR77BBhNWWA7XkbJbCLiq6lvblPVZjcGY5z63N7sTM/upqy kyiIZcRQ9oX+B0NrNUyotTsEIX4E67y5W/R5ZZPeHZYYG+Mfh/TWBM+lqp0nMw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652508692; a=rsa-sha256; cv=none; b=EO2KknP3RwnzMAq4XQHTfBlcfoFI4qTpjHlb00YBPcCIgFh+U4gi9Qo4ewV9ikfvWcHY7q EMt33+ro/cG1a+O5do1ONhY6vYMsPC+4Q9ANi5mvYmxGivMKrLGiEP2NQFa7/NJq/Q8W+i xxroUTfYZ/m3nROC1noWup+DSD6zUZWsTK6ZSW32eSp4HshQBKV825PW3BYMBMk3QGuzX5 Msu3FHSVhW+gdYGqzSNaFltYOw37N3jWqI9r24V4pbx3D2tB6GwDLDDk4eGpt/I5im9+2p uhc2RApz1sHMy+iw1cLZtEwNX5BZc86dmrPwr/832F4QetWmUt4by5/pkhXoBA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=dC8RXhGM; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.27 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=dC8RXhGM; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 30FCEAE90 X-Spam-Score: 6.27 X-Migadu-Scanner: scn1.migadu.com X-TUID: UiSA8xnqsm+A 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