luksmeta/0003-Define-log-callback-function-to-use-with-libcryptset.patch
Zhiqiang Liu 6dfc8c0a5c luksmeta: backport upstream bugfix patches
luksmeta: backport upstream bugfix patches

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
2020-07-13 15:14:29 +08:00

46 lines
1.2 KiB
Diff

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