From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pG6dh-0000wZ-2O for mharc-grub-devel@gnu.org; Thu, 12 Jan 2023 18:05:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pG6dc-0000w0-1Q for grub-devel@gnu.org; Thu, 12 Jan 2023 18:05:37 -0500 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pG6da-00054v-Eb for grub-devel@gnu.org; Thu, 12 Jan 2023 18:05:35 -0500 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-4d0f843c417so147739627b3.7 for ; Thu, 12 Jan 2023 15:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nZbAgecFuH6vLpvUz/WKOofO8Igpq9AZgL57e5OGWq8=; b=iOv45lNmbtc8B8OHaK/q/nrEjkl+MOK++FCaact0sXumISSEA/jn/Io3BXhL7TupMn /JIXyStYtJG8QzH2+XXhTqBjpmajWrwAdsN99ADob/1bpOQvoLZVbBUNg/su2vCEOgde PErEanunOp8Q2DwGs6vUn19isJtmKoFZZ2VNF7w0r51rAphlcQiis7i23hFjxhTIaznf yETv7SnchTPX//eeM/iqBHFPIt3WGGMWAkOZX0c6XInErwgd624Xr311TzYbFMKj/D1D w5gpDJrLp/vx9flpTW/A8sR7hlubXeZUy0BcyIRk8szZuHxyQc6Bs270ekX2BMoDfcZx sCCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nZbAgecFuH6vLpvUz/WKOofO8Igpq9AZgL57e5OGWq8=; b=tEuF+rUSnGEPyUrKW/oUnWJH5pVz5UXyXL7b5zUtfUsWQdyl/yFSxX4L7WCotetSTK 7EzF/L3yB4Uh8s9PR42VcA4XcL9Rgyjau+DZxfIzhjW6Hx/0RiS/4nc0R+xzQxE1v7hI SNvCYyF9CaRCL7qORI3x50PVez5hcCd2EVAlVNwqm94axqbsjzgCvEUCJlg5Q75zienl zZ6MyeMlVwVDB99fejw5WNSo0Xs5U1l37I4wKIZg4jfjVCFr8jot1INg0JhFbKrvD+UB H5P8iqZhf5j5eZEa5B54k1DYtd7wkhVZaVSt43HEViiUp4YzhrI+/539gOzuaTOSG6Mb cC0Q== X-Gm-Message-State: AFqh2kpfikUYtOsdiUcPhQ66x7yBPpcbptHzXJshmXg3/er7mf+ypKg/ O8/1hS3HOOgD1VihuCdpyn4S+EHxTYSbtYA5 X-Google-Smtp-Source: AMrXdXtVZhceg/Q79xpNw4Y8B+WhHsrZNQhOEn7CfdRvFdyKKoi1oLK0FT6P264YQutHDaTWExq3PA== X-Received: by 2002:a0d:fc42:0:b0:4bd:eacd:e1e8 with SMTP id m63-20020a0dfc42000000b004bdeacde1e8mr24478292ywf.44.1673564732772; Thu, 12 Jan 2023 15:05:32 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id bq35-20020a05620a46a300b00704c9015e68sm11704446qkb.116.2023.01.12.15.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 15:05:31 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Patrick Steinhardt , Pierre-Louis Bonicoli , Josselin Poiret , Fabian Vogt , Glenn Washburn Subject: [PATCH 2/4] devmapper/getroot: Have devmapper recognize LUKS2 Date: Thu, 12 Jan 2023 17:05:08 -0600 Message-Id: <20230112230510.1319896-3-development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112230510.1319896-1-development@efficientek.com> References: <20230112230510.1319896-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::112d; envelope-from=development@efficientek.com; helo=mail-yw1-x112d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2023 23:05:37 -0000 From: Josselin Poiret Changes UUID comparisons so that LUKS1 and LUKS2 are both recognized as being LUKS cryptodisks. Signed-off-by: Josselin Poiret Tested-by: Glenn Washburn --- grub-core/osdep/devmapper/getroot.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 9ba5c98655..2bf4264cf0 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -138,7 +138,8 @@ grub_util_get_dm_abstraction (const char *os_dev) grub_free (uuid); return GRUB_DEV_ABSTRACTION_LVM; } - if (strncmp (uuid, "CRYPT-LUKS1-", 12) == 0) + if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0 + || strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0) { grub_free (uuid); return GRUB_DEV_ABSTRACTION_LUKS; @@ -179,7 +180,9 @@ grub_util_pull_devmapper (const char *os_dev) grub_util_pull_device (subdev); } } - if (uuid && strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0 + if (uuid + && (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0 + || strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0) && lastsubdev) { char *grdev = grub_util_get_grub_dev (lastsubdev); @@ -253,11 +256,11 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) { char *dash; - dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-'); + dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS*-") - 1, '-'); if (dash) *dash = 0; grub_dev = grub_xasprintf ("cryptouuid/%s", - uuid + sizeof ("CRYPT-LUKS1-") - 1); + uuid + sizeof ("CRYPT-LUKS*-") - 1); grub_free (uuid); return grub_dev; } -- 2.34.1