Blame SOURCES/fapolicyd-trust.patch

2ceba8
From c7d409cebf86b1c71192fd79ec5f5582f4f00f30 Mon Sep 17 00:00:00 2001
2ceba8
From: Radovan Sroka <rsroka@redhat.com>
2ceba8
Date: Tue, 2 Jun 2020 21:24:28 +0200
2ceba8
Subject: [PATCH] Ignore db errors from check_trust_database() (#70)
2ceba8
2ceba8
- mark every subject and object as not trusted
2ceba8
  when it is not possible to do a query
2ceba8
2ceba8
- previously, when error occurred then subject or
2ceba8
  object was actually considered to be trusted
2ceba8
2ceba8
Signed-off-by: Radovan Sroka <rsroka@redhat.com>
2ceba8
---
2ceba8
 src/library/event.c | 23 +++++++++++++++++------
2ceba8
 1 file changed, 17 insertions(+), 6 deletions(-)
2ceba8
2ceba8
diff --git a/src/library/event.c b/src/library/event.c
2ceba8
index 564c120..2a4083b 100644
2ceba8
--- a/src/library/event.c
2ceba8
+++ b/src/library/event.c
2ceba8
@@ -339,9 +339,15 @@ subject_attr_t *get_subj_attr(event_t *e, subject_type_t t)
2ceba8
 
2ceba8
 			subj.val = 0;
2ceba8
 			if (exe) {
2ceba8
-				if (exe->str && check_trust_database(exe->str,
2ceba8
-								     NULL, 0))
2ceba8
-					subj.val = 1;
2ceba8
+				if (exe->str) {
2ceba8
+					int res = check_trust_database(exe->str, NULL, 0);
2ceba8
+
2ceba8
+					// ignore -1
2ceba8
+					if (res == 1)
2ceba8
+						subj.val = 1;
2ceba8
+					else
2ceba8
+						subj.val = 0;
2ceba8
+				}
2ceba8
 			}
2ceba8
 			}
2ceba8
 			break;
2ceba8
@@ -422,10 +428,15 @@ object_attr_t *get_obj_attr(event_t *e, object_type_t t)
2ceba8
 		case OBJ_TRUST: {
2ceba8
 			object_attr_t *path =  get_obj_attr(e, PATH);
2ceba8
 
2ceba8
-			if (path && path->o && check_trust_database(path->o,
2ceba8
-							    o->info, e->fd))
2ceba8
-			obj.val = 1;
2ceba8
+			if (path && path->o) {
2ceba8
+				int res = check_trust_database(path->o, o->info, e->fd);
2ceba8
 
2ceba8
+				// ignore -1
2ceba8
+				if (res == 1)
2ceba8
+					obj.val = 1;
2ceba8
+				else
2ceba8
+					obj.val = 0;
2ceba8
+			}
2ceba8
 			}
2ceba8
 			break;
2ceba8
 		case FMODE: