From 70247ce7e47963bfbd6c4cdc584f35ca38ccf66d Mon Sep 17 00:00:00 2001 From: Sergio Correia Date: Mon, 11 Nov 2019 18:06:13 -0500 Subject: [PATCH] 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", -- 2.23.0