9b9f54
From a04a9acd5d399b700da17f90430c7efbf6719c25 Mon Sep 17 00:00:00 2001
9b9f54
From: Nikos Mavrogiannopoulos <nmav@redhat.com>
9b9f54
Date: Mon, 26 Jun 2017 13:11:40 +0200
9b9f54
Subject: [PATCH] use warning messages for failing to enumerate store
9b9f54
9b9f54
In systems which use p11-kit to register all available PKCS#11
9b9f54
modules, an unconfigured softhsm will always fail to load and
9b9f54
print the following to syslog:
9b9f54
Jun 26 13:29:05 host wget[6407]: ObjectStore.cpp(59): Failed to enumerate object in /var/lib/softhsm/tokens
9b9f54
Jun 26 13:29:05 host wget[6407]: SoftHSM.cpp(476): Could not load the object store
9b9f54
9b9f54
That can be output to any command utilizing p11-kit (e.g., applications
9b9f54
using gnutls or engine_pkcs11 applications).
9b9f54
9b9f54
To avoid that unnecessary print, I decreased the log level of
9b9f54
the message to warning and set the default configuration to
9b9f54
print only error messages to syslog.
9b9f54
9b9f54
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
9b9f54
---
9b9f54
 src/lib/SoftHSM.cpp                  | 2 +-
9b9f54
 src/lib/common/softhsm2.conf.in      | 2 +-
9b9f54
 src/lib/object_store/ObjectStore.cpp | 2 +-
9b9f54
 3 files changed, 3 insertions(+), 3 deletions(-)
9b9f54
9b9f54
diff --git a/src/lib/SoftHSM.cpp b/src/lib/SoftHSM.cpp
9b9f54
index 26dd6e5..bed5aa6 100644
9b9f54
--- a/src/lib/SoftHSM.cpp
9b9f54
+++ b/src/lib/SoftHSM.cpp
9b9f54
@@ -473,7 +473,7 @@ CK_RV SoftHSM::C_Initialize(CK_VOID_PTR pInitArgs)
9b9f54
 	objectStore = new ObjectStore(Configuration::i()->getString("directories.tokendir", DEFAULT_TOKENDIR));
9b9f54
 	if (!objectStore->isValid())
9b9f54
 	{
9b9f54
-		ERROR_MSG("Could not load the object store");
9b9f54
+		WARNING_MSG("Could not load the object store");
9b9f54
 		delete objectStore;
9b9f54
 		objectStore = NULL;
9b9f54
 		delete sessionObjectStore;
9b9f54
diff --git a/src/lib/common/softhsm2.conf.in b/src/lib/common/softhsm2.conf.in
9b9f54
index b208cb6..bd0a60b 100644
9b9f54
--- a/src/lib/common/softhsm2.conf.in
9b9f54
+++ b/src/lib/common/softhsm2.conf.in
9b9f54
@@ -4,4 +4,4 @@ directories.tokendir = @softhsmtokendir@
9b9f54
 objectstore.backend = file
9b9f54
 
9b9f54
 # ERROR, WARNING, INFO, DEBUG
9b9f54
-log.level = INFO
9b9f54
+log.level = ERROR
9b9f54
diff --git a/src/lib/object_store/ObjectStore.cpp b/src/lib/object_store/ObjectStore.cpp
9b9f54
index 171cede..3cde15f 100644
9b9f54
--- a/src/lib/object_store/ObjectStore.cpp
9b9f54
+++ b/src/lib/object_store/ObjectStore.cpp
9b9f54
@@ -56,7 +56,7 @@ ObjectStore::ObjectStore(std::string inStorePath)
9b9f54
 
9b9f54
 	if (!storeDir.isValid())
9b9f54
 	{
9b9f54
-		ERROR_MSG("Failed to enumerate object store in %s", storePath.c_str());
9b9f54
+		WARNING_MSG("Failed to enumerate object store in %s", storePath.c_str());
9b9f54
 
9b9f54
 		return;
9b9f54
 	}
9b9f54
-- 
9b9f54
2.13.6
9b9f54