diff mbox series

[RFC,2/2] libsemanage: Set new restorecon handle before doing restorecon

Message ID 20250122155828.151233-3-jwcart2@gmail.com (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series Possible solution to possible regression | expand

Commit Message

James Carter Jan. 22, 2025, 3:58 p.m. UTC
In semanage_setfiles(), need to reset the restorecon handle to make
sure restorecon is not operating on old selabel data.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsemanage/src/semanage_store.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
index 2ca2e900..cf9aa809 100644
--- a/libsemanage/src/semanage_store.c
+++ b/libsemanage/src/semanage_store.c
@@ -3012,9 +3012,14 @@  log_callback_mute(__attribute__((unused)) int type, __attribute__((unused)) cons
 void semanage_setfiles(semanage_handle_t * sh, const char *path){
 	struct stat sb;
 	int fd;
+	struct selabel_handle *sehandle;
+
 	union selinux_callback cb_orig = selinux_get_callback(SELINUX_CB_LOG);
 	union selinux_callback cb = { .func_log = log_callback_mute };
 
+	sehandle = selinux_restorecon_default_handle();
+	selinux_restorecon_set_sehandle(sehandle);
+
 	/* Mute all logs */
 	selinux_set_callback(SELINUX_CB_LOG, cb);