]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/cryptsetup-util.c
selinux/systemctl: create unit file with default context on edit
[thirdparty/systemd.git] / src / shared / cryptsetup-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #if HAVE_LIBCRYPTSETUP
4 #include "cryptsetup-util.h"
5 #include "log.h"
6
7 static void cryptsetup_log_glue(int level, const char *msg, void *usrptr) {
8 switch (level) {
9 case CRYPT_LOG_NORMAL:
10 level = LOG_NOTICE;
11 break;
12 case CRYPT_LOG_ERROR:
13 level = LOG_ERR;
14 break;
15 case CRYPT_LOG_VERBOSE:
16 level = LOG_INFO;
17 break;
18 case CRYPT_LOG_DEBUG:
19 level = LOG_DEBUG;
20 break;
21 default:
22 log_error("Unknown libcryptsetup log level: %d", level);
23 level = LOG_ERR;
24 }
25
26 log_full(level, "%s", msg);
27 }
28
29 void cryptsetup_enable_logging(struct crypt_device *cd) {
30 crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
31 crypt_set_debug_level(DEBUG_LOGGING ? CRYPT_DEBUG_ALL : CRYPT_DEBUG_NONE);
32 }
33
34 #endif