From d98a10f67f9d0cdaeb5c23fea37cca8f85ec037a Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Mon, 17 Feb 2025 14:07:16 +0100 Subject: [PATCH] zkey-cryptsetup: Fix logging of libcryptsetup debug messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Messages from libcryptsetup for logging level CRYPT_LOG_DEBUG may or may not include an EOL, dependent on the cryptsetup version: Between libcryptsetup version 2.1 and 2.2 debug messages do not include an EOL character, but since 2.2 they do. Append an EOL only if the message does not already end with EOL. Signed-off-by: Ingo Franzki Reviewed-by: Jorg Schmidbauer Signed-off-by: Jan Höppner --- zkey/zkey-cryptsetup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zkey/zkey-cryptsetup.c b/zkey/zkey-cryptsetup.c index 65716f3b..784c574f 100644 --- a/zkey/zkey-cryptsetup.c +++ b/zkey/zkey-cryptsetup.c @@ -455,7 +455,8 @@ static void cryptsetup_log(int level, const char *msg, fprintf(stderr, "%s: %s", program_invocation_short_name, msg); break; case CRYPT_LOG_DEBUG: - fprintf(stderr, "%s: # %s\n", program_invocation_short_name, msg); + fprintf(stderr, "%s: # %s%s", program_invocation_short_name, + msg, msg[strlen(msg) - 1] == '\n' ? "" : "\n"); break; #ifdef CRYPT_DEBUG_JSON case CRYPT_DEBUG_JSON: