Report crypto lib version only once (and add kernel version).
diff --git a/TODO b/TODO
index 17d0680..b5a66e1 100644
--- a/TODO
+++ b/TODO
@@ -4,6 +4,5 @@
- TRIM for keyslots
- Do we need crypt_data_path() - path to data device (if differs)?
- Resync ETA time is not accurate, calculate it better (last minute window?).
-- crypto backend should initialise itself only once (debug log)
- Extend existing LUKS header to use another KDF? (https://password-hashing.net/)
- Fix all crazy automake warnings (or switch to Cmake).
diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c
index dcc54fd..8dc3599 100644
--- a/lib/libdevmapper.c
+++ b/lib/libdevmapper.c
@@ -28,7 +28,6 @@
#include <fcntl.h>
#include <linux/fs.h>
#include <uuid/uuid.h>
-#include <sys/utsname.h>
#include "internal.h"
@@ -159,16 +158,6 @@
verity_maj, verity_min, verity_patch);
}
-static void _dm_kernel_info(void)
-{
- struct utsname uts;
-
- if (!uname(&uts))
- log_dbg("Detected kernel %s %s %s.",
- uts.sysname, uts.release, uts.machine);
-
-}
-
static int _dm_check_versions(void)
{
struct dm_task *dmt;
@@ -179,8 +168,6 @@
if (_dm_crypt_checked)
return 1;
- _dm_kernel_info();
-
/* Shut up DM while checking */
_quiet_log = 1;
diff --git a/lib/setup.c b/lib/setup.c
index e18cb89..8261445 100644
--- a/lib/setup.c
+++ b/lib/setup.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <sys/utsname.h>
#include <fcntl.h>
#include <errno.h>
@@ -99,6 +100,9 @@
char error[MAX_ERROR_LENGTH];
};
+/* Just to suppress redundant messages about crypto backend */
+static int _crypto_logged = 0;
+
/* Global error */
/* FIXME: not thread safe, remove this later */
static char global_error[MAX_ERROR_LENGTH] = {0};
@@ -188,6 +192,7 @@
int init_crypto(struct crypt_device *ctx)
{
+ struct utsname uts;
int r;
r = crypt_random_init(ctx);
@@ -200,7 +205,14 @@
if (r < 0)
log_err(ctx, _("Cannot initialize crypto backend.\n"));
- log_dbg("Crypto backend (%s) initialized.", crypt_backend_version());
+ if (!r && !_crypto_logged) {
+ log_dbg("Crypto backend (%s) initialized.", crypt_backend_version());
+ if (!uname(&uts))
+ log_dbg("Detected kernel %s %s %s.",
+ uts.sysname, uts.release, uts.machine);
+ _crypto_logged = 1;
+ }
+
return r;
}