dryang / rpms / systemd

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