From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MApDHg1oiGLYEwEAbAwnHQ (envelope-from ) for ; Sat, 21 May 2022 06:18:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iF9pHQ1oiGLSPgAAG6o9tA (envelope-from ) for ; Sat, 21 May 2022 06:18:21 +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 ED4D6389F8 for ; Sat, 21 May 2022 06:18:20 +0200 (CEST) Received: from localhost ([::1]:54850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nsGZH-0005kv-SP for larch@yhetil.org; Sat, 21 May 2022 00:18:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nsGZ0-0005kL-U2 for guix-patches@gnu.org; Sat, 21 May 2022 00:18:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nsGZ0-0003sc-JG for guix-patches@gnu.org; Sat, 21 May 2022 00:18:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nsGZ0-0000t0-FA for guix-patches@gnu.org; Sat, 21 May 2022 00:18:02 -0400 Subject: bug#55407: [PATCH] system: Improve warning when using LUKS mapped devices without UUIDs. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Sat, 21 May 2022 04:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 55407 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 55407-done@debbugs.gnu.org Mail-Followup-To: 55407@debbugs.gnu.org, maxim.cournoyer@gmail.com, maxim.cournoyer@gmail.com Received: via spool by 55407-done@debbugs.gnu.org id=D55407.16531066543362 (code D ref 55407); Sat, 21 May 2022 04:18:02 +0000 Received: (at 55407-done) by debbugs.gnu.org; 21 May 2022 04:17:34 +0000 Received: from localhost ([127.0.0.1]:40481 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nsGYX-0000sA-Rr for submit@debbugs.gnu.org; Sat, 21 May 2022 00:17:34 -0400 Received: from mail-qk1-f170.google.com ([209.85.222.170]:40953) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nsGYW-0000rv-4Z for 55407-done@debbugs.gnu.org; Sat, 21 May 2022 00:17:32 -0400 Received: by mail-qk1-f170.google.com with SMTP id b200so274795qkc.7 for <55407-done@debbugs.gnu.org>; Fri, 20 May 2022 21:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=RVqaRMtFtsI4IdS1IxJ/HRr021H4xdGlOqxl/0KQ4UM=; b=pQlBIXmE23mmKgTM3CZwMU+j46p0+qDqO44BHX7g6Slu5epvwd8nJIQm1mH5YGkIXE Q/2q+5U2ihERNmQFJKXc+0Nv8wF7q2bS2GHRESW6yaEIAbAXpP5rH05X1Bstbrb/cLtQ C2U+BM+BcoS6jzIARSflCLRE3jm9r/pJEHFE+aV0J5yqWWezyK94cE11VCKAnSYaizXB bLyGImPyKBEZFfqEVJsjK7yOWF3jciUj67Xd/sKwQURKDip5jZFx0Vshgh6QbS3Y3qct zvvLh5FXAMZe7zJSDogVP8JCknkf+xG/mWdqSV2YvcoG68rXoDUVS8HTwKDqBu0HTKAk 5oOA== 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:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=RVqaRMtFtsI4IdS1IxJ/HRr021H4xdGlOqxl/0KQ4UM=; b=4wZveZr4husNReJgjlgX7TFi/X7myzyU7CnglsYeVlRD7rju7aWQssqs/pd0uZ84TH Y0A5Me3YCvT5NcBJWFbmh0Qa3TeF380Guw6Y0qckGBO6uGqVg9hsVtc1t71FaefvxNkN rvecLBP5A5Ed8ymVVuIUWTEa/ISPdd0CGPKm9V10lh4jnC8/x/kjHRfJGzsjwzsCPdw0 UdqF2kirukIDotkOd4A3E5dRgk/w0KdxwN9nDVUFzVa67KJko+81Bk78scsxe2Z9UUAS RDgDLV9WObe1Ot+IG2I6bfMTCo+Cwf+d0jCTXKQ2OzS35lU+E0VjpOb+QUaDthsPiPoD 98xQ== X-Gm-Message-State: AOAM531krHR3LUdU2b4AOqHkem9dfZDOacnBr09Nv4tK5ENv4etRwwb+ +UUG4OgcP42qdC7Ma18rfOD/7iJ5Ntl56A== X-Google-Smtp-Source: ABdhPJzqUltjnguWfBq8rBeqJNgMrjk8KgqWCZgS2GgX5UnIzcR9zkSdWFhyvAJ8ssc5bgnD+mufRw== X-Received: by 2002:a05:620a:400b:b0:6a0:fe03:8053 with SMTP id h11-20020a05620a400b00b006a0fe038053mr8429633qko.674.1653106646326; Fri, 20 May 2022 21:17:26 -0700 (PDT) Received: from hurd (dsl-10-148-238.b2b2c.ca. [72.10.148.238]) by smtp.gmail.com with ESMTPSA id f194-20020a379ccb000000b006a349bfcb02sm846682qke.41.2022.05.20.21.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 21:17:25 -0700 (PDT) From: Maxim Cournoyer References: <20220514060532.1011-1-maxim.cournoyer@gmail.com> <87ee0q1sfq.fsf@gnu.org> Date: Sat, 21 May 2022 00:17:25 -0400 In-Reply-To: <87ee0q1sfq.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 18 May 2022 22:44:57 +0200") Message-ID: <87o7zrbju2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=1653106701; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-to: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=RVqaRMtFtsI4IdS1IxJ/HRr021H4xdGlOqxl/0KQ4UM=; b=qV7jKyDvofhrL/UC0OFZHeveSwsekMNmsfwxWgvlB580xPb7m7a/+zWvSEXgVK6b6fPoHO tK9KTmaJPUz5iCFhs9eDL72GjUL/8BoL5oSwdRvZv8TOCB1MWv6R5egGRf8i3KL7afCAvb Y9sCYHMTdPd01f/+F/BDvVuAkLgPHWLbjYYZRXnfxPCFII/l7lchAlyEE4Q3gTltYGjvyb FcsS6yk9n7EglzvTLY4fRiivWsbM1h4nC6Z4K55NnHtINJ9IwwIzwuLjCEfVFTYo3YN8GJ 5PRib4cvX/owlGAWJwICZENOaD6fL7zdTG/J2LJccvdXmq8G0p5QVpiR4dtjkw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653106701; a=rsa-sha256; cv=none; b=YiFmg65k+7exSOlb3r7MV2AumAvEJwgk7D/bAyBVSQ5rQjoTWYpHEbNj9qFVCo8i0tEn8a JRgEF4Vh1xoY5F8jyPDS/bxgZzTZOPTuKPVsY+O9NQ0HZumFtIAq+SuAYoB828z9DqfG3I VjuXjzZIV+w2EdXH8mAbsML7TvwuV8bVndMxY2Edj1uy0DnLR7DoES9WILSIqn5aEmGjjb S5t5SqrX7f53QDir+J8+aLtjp8I4YrKNKGeoUoY2l8CYgUF6QR62dCPjxGDeSoDqLg3HRr 3W9yfu4ZZnSb52dDuy969Jm3+st2Jq5o4+YulKgjX+wJs/mGJ8FUx9Q5JaQFIA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=pQlBIXmE; 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: 4.66 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=pQlBIXmE; 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: ED4D6389F8 X-Spam-Score: 4.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: dgGwD+Vtlrnl Hi, Ludovic Court=C3=A8s writes: > Hi! > > Maxim Cournoyer skribis: > >> 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 device= s. >> Add a hint to help users fix the warning. > > [...] > >> +(define operating-system-bootloader-crypto-devices >> + (mlambda (os) ;to avoid duplicated output > > Should be =E2=80=98mlambdaq=E2=80=99 so that OS is compared with =E2=80= =98eq?=E2=80=99, which is cheaper > and better corresponds to what we want to achieve here. Done. >> + (receive (uuid-crypto-devices non-uuid-crypto-devices) >> + (partition (compose uuid? mapped-device-source) luks-devices) > > I suggest using =E2=80=98let=E2=80=99 from (srfi srfi-71) for consistency. Done. >> + (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))) > > By convention, warnings should fit on a single line and not be full > sentences. This is a Guix-specific convention, right? I couldn't find a reference to it in the GNU Standards (info standards) document. I'd be more of the thinking that warnings directed at *users* should be as human readable as possible; the motivation for my fix was because that for more than a year, I read that warning without having clue about what it really meant and had to review the source to get the answer. > If we emit one warning per mapped device, we can report the source > location using: > > (warning (mapped-device-location dev) (G_ "mapped device =E2=80=A6")) > > Given that we have location info, it might be better to report one > warning per device? Done! > Last, hints should be reported either with =E2=80=98display-hint=E2=80=99= or with a > =E2=80=98&fix-hint=E2=80=99 exception. The hint itself can be one or two= paragraphs > using Texinfo markup. > > All this should ensure consistent diagnostic reporting. > > I hope this makes sense! It does. I didn't know about warning accepting the location like that, and I thought hints were only usable via conditions, so I've learned a couple new things here. With the following changes: --8<---------------cut here---------------start------------->8--- modified gnu/system.scm @@ -43,6 +43,7 @@ (define-module (gnu system) #:use-module ((guix utils) #:select (substitute-keyword-arguments)) #:use-module (guix i18n) #:use-module (guix diagnostics) + #:use-module (guix ui) #:use-module (gnu packages admin) #:use-module (gnu packages base) #:use-module (gnu packages bash) @@ -81,11 +82,11 @@ (define-module (gnu system) #: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) #:use-module (srfi srfi-35) + #:use-module (srfi srfi-71) #:use-module (rnrs bytevectors) #:export (operating-system operating-system? @@ -604,25 +605,25 @@ (define (operating-system-boot-mapped-devices os) devices))) (define operating-system-bootloader-crypto-devices - (mlambda (os) ;to avoid duplicated output + (mlambdaq (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))))) + (let* ((luks-devices (filter (lambda (m) + (eq? luks-device-mapping + (mapped-device-type m))) + (operating-system-boot-mapped-devices os)= )) + (uuid-crypto-devices non-uuid-crypto-devices + (partition (compose uuid? mapped-device-so= urce) + luks-devices))) + (when (not (null? non-uuid-crypto-devices)) + (for-each (lambda (dev) + (warning + (source-properties->location (mapped-device-location = dev)) + (G_ "mapped device '~a' may be ignored by bootloader~= %") + (mapped-device-source dev))) + non-uuid-crypto-devices) + (display-hint "Specify mapped device sources via their LUKS UUID."= )) + (map mapped-device-source uuid-crypto-devices)))) (define (device-mapping-services os) "Return the list of device-mapping services for OS as a list." --8<---------------cut here---------------end--------------->8--- It produced this output: --8<---------------cut here---------------start------------->8--- /home/maxim/stow/guix/hurd.scm:109:8: warning: mapped device '/dev/sda2' ma= y be ignored by bootloader /home/maxim/stow/guix/hurd.scm:113:8: warning: mapped device '/dev/sdb2' ma= y be ignored by bootloader /home/maxim/stow/guix/hurd.scm:117:8: warning: mapped device '/dev/sdc2' ma= y be ignored by bootloader hint: Specify mapped device sources via their LUKS UUID. updating checkout of 'file:///home/maxim/src/mcron'... retrieved commit a233aab1b6770bece7538cda8381df824b7560b6 --8<---------------cut here---------------end--------------->8--- which compares favorably to before the change: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix system reconfigure ~/stow/guix/hurd.scm guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. updating checkout of 'file:///home/maxim/src/mcron'... retrieved commit a233aab1b6770bece7538cda8381df824b7560b6 guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. updating checkout of 'file:///home/maxim/src/mcron'... retrieved commit a233aab1b6770bece7538cda8381df824b7560b6 substitute: updating substitutes from 'http://127.0.0.1:8181'... 100.0% [...] activating system... guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. [...] --8<---------------cut here---------------end--------------->8--- Pushed as 39a9404c99. Thanks for the useful comments! Maxim