From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0PilBIME4V+FdAAA0tVLHw (envelope-from ) for ; Mon, 21 Dec 2020 20:24:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id mFh4AIME4V+NTAAA1q6Kng (envelope-from ) for ; Mon, 21 Dec 2020 20:24:35 +0000 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 6C28C9404FE for ; Mon, 21 Dec 2020 20:24:34 +0000 (UTC) Received: from localhost ([::1]:35570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1krRjM-0004Oz-Pv for larch@yhetil.org; Mon, 21 Dec 2020 15:24:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krRis-0004Gh-96 for bug-guix@gnu.org; Mon, 21 Dec 2020 15:24:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:36814) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1krRis-00085g-1z for bug-guix@gnu.org; Mon, 21 Dec 2020 15:24:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1krRir-0003hH-V9 for bug-guix@gnu.org; Mon, 21 Dec 2020 15:24:01 -0500 Subject: bug#25305: bug#37851: bug#25305: bug#37851: Grub installation only checks for encrypted /boot folder Resent-From: Miguel =?UTF-8?Q?=C3=81ngel?= Arruga Vivas Original-Sender: "Debbugs-submit" Resent-To: bug-guix@gnu.org Resent-Date: Mon, 21 Dec 2020 20:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 25305 X-GNU-PR-Package: guix X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Mail-Followup-To: 25305@debbugs.gnu.org, rosen644835@gmail.com, ludo@gnu.org Received: via spool by 25305-done@debbugs.gnu.org id=D25305.160858222714179 (code D ref 25305); Mon, 21 Dec 2020 20:24:01 +0000 Received: (at 25305-done) by debbugs.gnu.org; 21 Dec 2020 20:23:47 +0000 Received: from localhost ([127.0.0.1]:48358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1krRid-0003gX-BZ for submit@debbugs.gnu.org; Mon, 21 Dec 2020 15:23:47 -0500 Received: from mail-wr1-f47.google.com ([209.85.221.47]:37226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1krRic-0003gG-5K; Mon, 21 Dec 2020 15:23:46 -0500 Received: by mail-wr1-f47.google.com with SMTP id i9so12418651wrc.4; Mon, 21 Dec 2020 12:23:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=QmRmRHDQDwoqQTiRARizkcIvve6sHhuASkndbXJes10=; b=DmRi8K63KiF03IF4uxMsLMMWh+RGB7U4Sil9tZ787+IOMUTWfV5O2obvaiXn8V0wLv UmY88fRUd7YdLvEdw3yGsUNESQbwzQuTDSegEZKupaLn7/+yodaf4XUckvP2uDElMuCo jWrjecMAsLgk95Vsy8ev1hgDyhou7wclHUvw6jcPIShuTfYeqG8LmYunLEUVGHZKD4+z wYDj77HWsUbiWWVo3p4ryaHrgO7Sxj7ePplfJhWwNePl4i2y/gJsC+QLd0ANZGoN3Gbg Ze2b99RJJIN/zt4Y0VymKHsNXvtx0xQtOQIa+EKah1axSvObdGKIvi1aI1mIxBV2k+Ck acKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=QmRmRHDQDwoqQTiRARizkcIvve6sHhuASkndbXJes10=; b=UGlI1dbYiOPnLdYGcX5Z6C4OujrCTIHH+xbg04/tC8B4+RVbXqTx/g7/tHrViHyX5/ RG/tA/xo/Z5kkk1WqfLqyilRcFu1bDdoNMnqMwoVRlr7NrBdWeq8xtuV6htcn9CIg13G IBR0tY3AxIfP59YGbjnIw6MXzjJX4kHIPOCyL8llCPa6YpFKQr4z8a1VldG00iRCOxrC DZpl0edeDAcUV7T8LqFB7jf63yD8L2O7MWeYiqJUCI1fP/NdmNoar7yP7RvbE1au6X/H VmvY9idJvBMxQuu77ZurUYHWjCxTf8/0LEd3U5aYTbMGP0KA7EffkzdsJDLxiaTGJ/0b wOFA== X-Gm-Message-State: AOAM5324QqBja+IDyLvycwDT7BwIMlSzQzBs3AhqT4pUWhZZBD2OdSV1 pHpZdudvcs0lsriYOfZLRbla7fQgVEc= X-Google-Smtp-Source: ABdhPJyfwapYtZbXywZ+0SvYWI3Qacthm49dcKI4QjhJQPqzGiHL1nhrYm1J4AG4v3u12lmRmwV0Bg== X-Received: by 2002:adf:c18d:: with SMTP id x13mr20103880wre.128.1608582219824; Mon, 21 Dec 2020 12:23:39 -0800 (PST) Received: from unfall (36.193.158.146.dynamic.jazztel.es. [146.158.193.36]) by smtp.gmail.com with ESMTPSA id z15sm29876363wrv.67.2020.12.21.12.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Dec 2020 12:23:39 -0800 (PST) From: Miguel =?UTF-8?Q?=C3=81ngel?= Arruga Vivas References: <20191021130709.21d6ac20@gmail.com> <20191021144758.3d8cfe95@gmail.com> <87lftc27j2.fsf@gnu.org> <87r1pkocrc.fsf@gmail.com> <87ft5ym3ic.fsf@gmail.com> <87k0tksfau.fsf@gnu.org> Date: Mon, 21 Dec 2020 21:23:36 +0100 In-Reply-To: <87k0tksfau.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Mon, 14 Dec 2020 14:11:37 +0100") Message-ID: <87k0tazz5j.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 25305-done@debbugs.gnu.org, Mathieu Othacehe , 37851-done@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.22 Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=gmail.com header.s=20161025 header.b=DmRi8K63; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 6C28C9404FE X-Spam-Score: -1.22 X-Migadu-Scanner: scn0.migadu.com X-TUID: Lm/XGCeashQ7 Hi Ludo, First of all, thanks for your review. :-) Ludovic Court=C3=A8s writes: > Hi Miguel, > > Miguel =C3=81ngel Arruga Vivas skribis: >> + (define (crypto-devices) >> + (define (crypto-device->cryptomount dev) >> + (if (uuid? dev) >> + #~(format port "cryptomount -u ~a~%" >> + ;; cryptomount only accepts UUID without the hypen. >> + #$(string-delete #\- (uuid->string dev))) >> + ;; Other type of devices aren't implemented. >> + #~())) >> + (let ((devices (map crypto-device->cryptomount store-crypto-devices= )) >> + ;; XXX: Add luks2 when grub 2.06 is packaged. >> + (modules #~(format port "insmod luks~%"))) >> + (if (null? devices) >> + devices >> + (cons modules devices)))) > > What I don=E2=80=99t get is why we=E2=80=99re able to use an encrypted ro= ot right now > without emitting =E2=80=9Ccryptomount=E2=80=9D GRUB commands? The grub boot process goes more or less like this: 1. Firmware loads the initial image. 1.1. If that image is not the final one, it contains a "pointer" to the final one, which is loaded by it; this chain can be viewed as part of the firmware loading for this purpose. 2. The image code reads an initial configuration file, which is usually generated by grub-install/grub-mkstandalone. Here Grub is placing the needed the cryptomount lines for the devices needed to mount target in order to read grub.cfg and other modules. 3. grub.cfg is read (a.k.a. normal mode) and the usual boot process follows. The first configuration file is generated automatically by grub-install, which physically scans the target location (still /boot in our case) and inserts the needed insmod and cryptomount calls. When the target and the store don't share the device, the calls leading to the store must be inserted manually into grub.cfg. It could be easier to remove completely /boot and use a directory from the store, but that leads to more writes of the image, as each reconfiguration involving a change on the devices used for the store must end up returning a different store file name too. Nonetheless, that would leave /boot untouched if anybody wants to install their version of grub there for other purposes... >> + (_ >> + ;; No crypto-devices found >> + '()))) >> + (_ >> + ;; No store found, old format. >> + '()))) > > s/No store found/No crypto devices found/ ? The first comment is reached when crypto-devices isn't found in a (boot-parameters ... (store ...) ...) form. The second one is reached when (boot-parameters ...) form doesn't even contain a tag store in it. It follows the same pattern as store-device, as the old format didn't have a store element. On the other hand, I added a period to the first sentence as it was missing. 0:) >> +(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." >> + (map mapped-device-source >> + (filter (match-lambda >> + ((and (=3D mapped-device-type type) >> + (=3D mapped-device-source source)) >> + (and (eq? luks-device-mapping type) >> + (or (uuid? source) >> + (begin >> + (warning (G_ "\ >> +mapped-device '~a' won't be mounted by the bootloader.~%") >> + source) >> + #f))))) >> + ;; XXX: Ordering is important, we trust the returned one. >> + (operating-system-boot-mapped-devices os)))) > > You can use =E2=80=98filter-map=E2=80=99 here. Thanks for the pointer! I've modified a bit tests/boot-parameters.scm to be extra-sure that I was doing that change OK, as I moved the or to a internal function for readability too. > The rest LGTM! Make sure the =E2=80=9Cinstalled-os=E2=80=9D and =E2=80= =9Cencrypted-root-os=E2=80=9D > system tests are still fine, and if they are, I guess you can go ahead. Pushed to master as f00e68ace0 with these changes, after running the tests and booting up my system. Happy hacking! Miguel