From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1o16tV-0005u0-Gp for mharc-grub-devel@gnu.org; Tue, 14 Jun 2022 09:47:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o16tP-0005qg-5q for grub-devel@gnu.org; Tue, 14 Jun 2022 09:47:39 -0400 Received: from jpoiret.xyz ([206.189.101.64]:35072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o16tM-0008Sp-Ul for grub-devel@gnu.org; Tue, 14 Jun 2022 09:47:38 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 2D41A1851E1; Tue, 14 Jun 2022 13:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1655214455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=StKGluE4B/zS+HIzEHMVQdOG1GTifHoqF6vJEGwDXpM=; b=QibtIntnYG2OwGjM5eVXotI+YraBcyI4jr30GF77VWGFnqaTLqsUAcBAdXLHuheYzKpJOE Yomx3ynCtYJGenxjkTJeVPuCGa/6hJejHClWWClqQTFdtugwHox2JRpsI6bIr02AjuYFMt NYs3fpVaX2R/pWIECskOLVzkPkOxBZhh11w9M2SyQiSqKpWoicrR5ryObGFz/4yJgvpmAJ yTAWjvCV9d//j9+07KPkKM/Ti1BzNZtea6ktr+lvI1oslSh4DZ6kuLgumXTiKsfg2Wg8f4 ZmHGYk6sYmQtsftTFgbro7LN6/7Pww6mAE9IhKMbp+VvH+7oOWhQ0PTGids6XQ== From: Josselin Poiret To: Glenn Washburn Cc: grub-devel@gnu.org, Josselin Poiret Subject: [PATCH v4 1/2] devmapper/getroot: Have devmapper recognize LUKS2 Date: Tue, 14 Jun 2022 15:47:29 +0200 Message-Id: <20220614134730.7439-2-dev@jpoiret.xyz> In-Reply-To: <20220614134730.7439-1-dev@jpoiret.xyz> References: <20220520192035.313b5ede@crass-HP-ZBook-15-G2> <20220614134730.7439-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / Received-SPF: pass client-ip=206.189.101.64; envelope-from=dev@jpoiret.xyz; helo=jpoiret.xyz X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 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, FROM_SUSPICIOUS_NTLD=0.499, PDS_OTHER_BAD_TLD=1.997, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: Tue, 14 Jun 2022 13:47:39 -0000 Changes UUID comparisons so that LUKS1 and LUKS2 are both recognized as being LUKS cryptodisks. --- 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 9ba5c9865..2bf4264cf 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.36.1