zkey-cryptsetup: Fix logging of libcryptsetup debug messages

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 <ifranzki@linux.ibm.com>
Reviewed-by: Jorg Schmidbauer <jschmidb@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2025-02-17 14:07:16 +01:00
committed by Jan Höppner
parent fb6e7e70c6
commit d98a10f67f

View File

@@ -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: