Blob Blame History Raw
From 7c2726e8d9c3aa5f8f6710a7ea147bf99877e1a5 Mon Sep 17 00:00:00 2001
From: Radovan Sroka <rsroka@redhat.com>
Date: Tue, 16 Mar 2021 12:49:48 +0100
Subject: [PATCH] Fixed problem with startup failed on unlink() (#120)

- introduced in 128e22d0c638aed81337a6dbbfa664e5bfc9ea06

- daemon does not start when unlinking non existing db
- fapolicyd-cli returned error when there is no db to unlink

Signed-off-by: Radovan Sroka <rsroka@redhat.com>
---
 src/library/database.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/library/database.c b/src/library/database.c
index a010923..59816cb 100644
--- a/src/library/database.c
+++ b/src/library/database.c
@@ -718,13 +718,13 @@ int unlink_db(void)
 
 	snprintf(path, sizeof(path), "%s/data.mdb", data_dir);
 	rc = unlink(path);
-	if (rc) {
+	if (rc == -1 && errno != ENOENT) {
 		msg(LOG_ERR, "Could not unlink %s (%s)", path, strerror(errno));
 		ret_val = 1;
 	}
 	snprintf(path, sizeof(path), "%s/lock.mdb", data_dir);
 	rc = unlink(path);
-	if (rc) {
+	if (rc == -1 && errno != ENOENT) {
 		msg(LOG_ERR, "Could not unlink %s (%s)", path, strerror(errno));
 		ret_val = 1;
 	}