daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
5d2ee9
From 05e184dea3f0182e5787812adfd52b68cff9418d Mon Sep 17 00:00:00 2001
5d2ee9
From: Jan Janssen <medhefgo@web.de>
5d2ee9
Date: Mon, 25 Jun 2018 20:33:31 +0200
5d2ee9
Subject: [PATCH] crypt-util: Translate libcryptsetup log level instead of
5d2ee9
 using log_debug()
5d2ee9
5d2ee9
This makes sure that errors reported by libcryptsetup are shown to the
5d2ee9
user instead of getting swallowed up by log_debug().
5d2ee9
5d2ee9
(cherry picked from commit aa2cc005d77890b07e8c579f25e1333ff8ba8dac)
5d2ee9
5d2ee9
Resolves: #1776408
5d2ee9
---
5d2ee9
 src/basic/crypt-util.c | 20 +++++++++++++++++++-
5d2ee9
 1 file changed, 19 insertions(+), 1 deletion(-)
5d2ee9
5d2ee9
diff --git a/src/basic/crypt-util.c b/src/basic/crypt-util.c
5d2ee9
index b181ba3ba0..20bdc5489e 100644
5d2ee9
--- a/src/basic/crypt-util.c
5d2ee9
+++ b/src/basic/crypt-util.c
5d2ee9
@@ -5,6 +5,24 @@
5d2ee9
 #include "log.h"
5d2ee9
 
5d2ee9
 void cryptsetup_log_glue(int level, const char *msg, void *usrptr) {
5d2ee9
-        log_debug("%s", msg);
5d2ee9
+        switch (level) {
5d2ee9
+        case CRYPT_LOG_NORMAL:
5d2ee9
+                level = LOG_NOTICE;
5d2ee9
+                break;
5d2ee9
+        case CRYPT_LOG_ERROR:
5d2ee9
+                level = LOG_ERR;
5d2ee9
+                break;
5d2ee9
+        case CRYPT_LOG_VERBOSE:
5d2ee9
+                level = LOG_INFO;
5d2ee9
+                break;
5d2ee9
+        case CRYPT_LOG_DEBUG:
5d2ee9
+                level = LOG_DEBUG;
5d2ee9
+                break;
5d2ee9
+        default:
5d2ee9
+                log_error("Unknown libcryptsetup log level: %d", level);
5d2ee9
+                level = LOG_ERR;
5d2ee9
+        }
5d2ee9
+
5d2ee9
+        log_full(level, "%s", msg);
5d2ee9
 }
5d2ee9
 #endif