Blame SOURCES/0013-libsemanage-always-write-kernel-policy-when-check_ex.patch

146e30
From 330b6efa010b3dac732beb49c98894a99dab0545 Mon Sep 17 00:00:00 2001
146e30
From: Ondrej Mosnacek <omosnace@redhat.com>
146e30
Date: Wed, 8 Jun 2022 19:09:53 +0200
146e30
Subject: [PATCH] libsemanage: always write kernel policy when
146e30
 check_ext_changes is specified
146e30
146e30
For the use case of rebuilding the policy after package updates, we need
146e30
the check_ext_changes operation to always do at least the do_write_kernel
146e30
step, because the various semanage dbs may have also changed content
146e30
relative to the current binary policy. As this step is itself relatively
146e30
fast, we can do it unconditionally.
146e30
146e30
Fixes: 286a679fadc4 ("libsemanage: optionally rebuild policy when modules are changed externally")
146e30
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
146e30
Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>
146e30
---
146e30
 libsemanage/include/semanage/handle.h | 2 +-
146e30
 libsemanage/src/direct_api.c          | 8 +++++---
146e30
 2 files changed, 6 insertions(+), 4 deletions(-)
146e30
146e30
diff --git a/libsemanage/include/semanage/handle.h b/libsemanage/include/semanage/handle.h
146e30
index 7f298a49..df919a14 100644
146e30
--- a/libsemanage/include/semanage/handle.h
146e30
+++ b/libsemanage/include/semanage/handle.h
146e30
@@ -67,7 +67,7 @@ void semanage_set_reload(semanage_handle_t * handle, int do_reload);
146e30
 void semanage_set_rebuild(semanage_handle_t * handle, int do_rebuild);
146e30
 
146e30
 /* set whether to rebuild the policy on commit when potential changes
146e30
- * to module files since last rebuild are detected,
146e30
+ * to store files since last rebuild are detected,
146e30
  * 1 for yes (default), 0 for no */
146e30
 extern void semanage_set_check_ext_changes(semanage_handle_t * handle, int do_check);
146e30
 
146e30
diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c
146e30
index bbdca2b2..252fc5bb 100644
146e30
--- a/libsemanage/src/direct_api.c
146e30
+++ b/libsemanage/src/direct_api.c
146e30
@@ -1430,13 +1430,15 @@ static int semanage_direct_commit(semanage_handle_t * sh)
146e30
 	 * Determine what else needs to be done.
146e30
 	 * We need to write the kernel policy if we are rebuilding
146e30
 	 * or if any other policy component that lives in the kernel
146e30
-	 * policy has been modified.
146e30
+	 * policy has been modified. We also want to force it when
146e30
+	 * check_ext_changes was specified as the various dbases may have
146e30
+	 * changes as well.
146e30
 	 * We need to install the policy files if any of the managed files
146e30
 	 * that live under /etc/selinux (kernel policy, seusers, file contexts)
146e30
 	 * will be modified.
146e30
 	 */
146e30
-	do_write_kernel = do_rebuild | ports_modified | ibpkeys_modified |
146e30
-		ibendports_modified |
146e30
+	do_write_kernel = do_rebuild | sh->check_ext_changes |
146e30
+		ports_modified | ibpkeys_modified | ibendports_modified |
146e30
 		bools->dtable->is_modified(bools->dbase) |
146e30
 		ifaces->dtable->is_modified(ifaces->dbase) |
146e30
 		nodes->dtable->is_modified(nodes->dbase) |
146e30
-- 
146e30
2.37.3
146e30