luksmeta: backport upstream bugfix patches

luksmeta: backport upstream bugfix patches

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
This commit is contained in:
Zhiqiang Liu 2020-07-13 15:14:26 +08:00
parent 14897de708
commit 6dfc8c0a5c
4 changed files with 210 additions and 8 deletions

View File

@ -0,0 +1,151 @@
From 666ad5914ea677c5c15eb9b81a5d8e1d47ccb134 Mon Sep 17 00:00:00 2001
From: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Date: Mon, 10 Dec 2018 14:25:33 +0100
Subject: [PATCH 1/3] Relax content tests in test suite
Starting with version 2.0.5, cryptsetup wipes the full LUKS header
and fills unused sections with random data, this was introduced
in commit
commit c2bce3e93ecee41f661b589ee28f112eb538259e
Author: Milan Broz <gmazyland@gmail.com>
Date: Sun Oct 14 13:11:50 2018 +0200
Wipe full header areas (including unused) during LUKS format.
While this is the right thing to do, it breaks luksmeta tests. So
relax them.
Bug-Debian: https://bugs.debian.org/915256
Resolves: https://github.com/latchset/luksmeta/issues/6
---
test-lm-assumptions.c | 3 ++-
test-lm-big.c | 4 ++--
test-lm-init.c | 4 ++--
test-lm-one.c | 4 ++--
test-lm-two.c | 8 ++++----
5 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/test-lm-assumptions.c b/test-lm-assumptions.c
index d9ff20b..b4f293f 100644
--- a/test-lm-assumptions.c
+++ b/test-lm-assumptions.c
@@ -28,7 +28,8 @@ main(int argc, char *argv[])
/* Test the layout state. */
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- END(1024), /* Rest of the file */
+ { 1024, 3072, true }, /* Keyslot Area */
+ { 0, 0 },
}));
unlink(filename);
diff --git a/test-lm-big.c b/test-lm-big.c
index 6098e59..eb94d3b 100644
--- a/test-lm-big.c
+++ b/test-lm-big.c
@@ -111,7 +111,7 @@ main(int argc, char *argv[])
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
{ offset + 4096, 4096 }, /* luksmeta slot 0 */
{ offset + 8192, 4096 }, /* luksmeta slot 0 (cont) */
@@ -127,7 +127,7 @@ main(int argc, char *argv[])
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
END(offset + 4096), /* Rest of the file */
}));
diff --git a/test-lm-init.c b/test-lm-init.c
index 2a6cb45..b16d597 100644
--- a/test-lm-init.c
+++ b/test-lm-init.c
@@ -57,7 +57,7 @@ main(int argc, char *argv[])
/* Test the layout state. */
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
END(offset + 4096), /* Rest of the file */
}));
@@ -106,7 +106,7 @@ main(int argc, char *argv[])
assert(luksmeta_test(cd) == -ENOENT);
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
END(offset), /* Rest of the file */
}));
diff --git a/test-lm-one.c b/test-lm-one.c
index 8deb70a..18613e0 100644
--- a/test-lm-one.c
+++ b/test-lm-one.c
@@ -49,7 +49,7 @@ main(int argc, char *argv[])
/* Test the layout state. */
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
{ offset + 4096, 4096 }, /* luksmeta slot 0 */
END(offset + 8192), /* Rest of the file */
@@ -68,7 +68,7 @@ main(int argc, char *argv[])
/* Test the layout state. */
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
END(offset + 4096), /* Rest of the file */
}));
diff --git a/test-lm-two.c b/test-lm-two.c
index 78fea5b..9f0b1c5 100644
--- a/test-lm-two.c
+++ b/test-lm-two.c
@@ -53,7 +53,7 @@ main(int argc, char *argv[])
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
{ offset + 4096, 4096 }, /* luksmeta slot 0 */
END(offset + 8192), /* Rest of the file */
@@ -70,7 +70,7 @@ main(int argc, char *argv[])
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
{ offset + 4096, 4096 }, /* luksmeta slot 0 */
{ offset + 8192, 4096 }, /* luksmeta slot 1 */
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
assert(luksmeta_wipe(cd, 0, UUID0) == 0);
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
{ offset + 4096, 4096, true }, /* luksmeta slot 0 */
{ offset + 8192, 4096 }, /* luksmeta slot 1 */
@@ -99,7 +99,7 @@ main(int argc, char *argv[])
assert(luksmeta_wipe(cd, 1, UUID1) == 0);
assert(test_layout((range_t[]) {
{ 0, 1024 }, /* LUKS header */
- { 1024, offset - 1024, true }, /* Keyslot Area */
+ { 1024, 3072, true }, /* Keyslot Area */
{ offset, 4096 }, /* luksmeta header */
END(offset + 4096), /* Rest of the file */
}));
--
1.8.3.1

View File

@ -1,9 +1,10 @@
From 052c5d53d56f52cba95a569b3f2648b7cd647f1e Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccallum@redhat.com>
Date: Thu, 9 Aug 2018 15:07:17 -0400
Subject: [PATCH] Specify LUKSv1 during luksFormat
From 768e926ac640f422f81cf5e7578015188751b028 Mon Sep 17 00:00:00 2001
From: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Date: Sat, 28 Sep 2019 13:24:11 +0200
Subject: [PATCH 2/3] Force creation of LUKS1 containers in test suite
This fixes tests on builds of cryptsetup which default to LUKSv2.
Cryptsetup defaults to LUKS2 since version 2.1, make sure to create
LUKS1 containers instead by using the "--type luks1" argument.
---
test-luksmeta | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@ -22,5 +23,5 @@ index fd17ead..f1e8b2e 100755
! ./luksmeta test -d $tmp
--
2.17.1
1.8.3.1

View File

@ -0,0 +1,45 @@
From f108d57745f83e1fb7217beea356221c155f5d80 Mon Sep 17 00:00:00 2001
From: Sergio Correia <scorreia@redhat.com>
Date: Mon, 11 Nov 2019 18:06:13 -0500
Subject: [PATCH 3/3] Define log callback function to use with libcryptsetup
Logs from libcryptsetup now go to stderr and this prevents issues like
the one reported in https://bugzilla.redhat.com/show_bug.cgi?id=1770395
---
luksmeta.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/luksmeta.c b/luksmeta.c
index a79da82..1c72787 100644
--- a/luksmeta.c
+++ b/luksmeta.c
@@ -45,6 +45,17 @@ struct options {
int slot;
};
+#define LUKSMETA_LIBCRYPTSETUP_LOG_LEVEL CRYPT_LOG_ERROR
+
+static void
+luksmeta_libcryptsetup_log(int level, const char *msg, void *usrptr)
+{
+ if (level != LUKSMETA_LIBCRYPTSETUP_LOG_LEVEL) {
+ return;
+ }
+ fprintf(stderr, "%s", msg);
+}
+
static int
cmd_test(const struct options *opts, struct crypt_device *cd)
{
@@ -485,6 +496,8 @@ main(int argc, char *argv[])
return EX_IOERR;
}
+ crypt_set_log_callback(cd, luksmeta_libcryptsetup_log, NULL);
+
r = crypt_load(cd, NULL, NULL);
if (r != 0) {
fprintf(stderr, "Unable to read LUKSv1 header (%s): %s\n",
--
1.8.3.1

View File

@ -1,12 +1,14 @@
Name: luksmeta
Version: 9
Release: 3
Release: 4
Summary: LUKSMeta is a simple library for storing metadata in the LUKSv1 header
License: LGPLv2+
URL: https://github.com/latchset/%{name}
Source0: https://github.com/latchset/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.bz2
Patch0: 0000-luksmeta-9-tests.patch
Patch1: 0001-Relax-content-tests-in-test-suite.patch
Patch2: 0002-Force-creation-of-LUKS1-containers-in-test-suite.patch
Patch3: 0003-Define-log-callback-function-to-use-with-libcryptset.patch
BuildRequires: gcc asciidoc pkgconfig
BuildRequires: cryptsetup-devel git
@ -70,5 +72,8 @@ make %{?_smp_mflags} check
%changelog
* Mon Jul 13 2020 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 9-4
- backport upstream bugfix patches
* Fri Aug 30 2019 guiyao<guiyao@huawei.com> - 9-3
- Package init