Blame SOURCES/shadow-4.9-semanage-close-the-selabel-handle.patch

9746fa
From 234af5cf67fc1a3ba99fc246ba65869a3c416545 Mon Sep 17 00:00:00 2001
9746fa
From: Iker Pedrosa <ipedrosa@redhat.com>
9746fa
Date: Fri, 8 Oct 2021 13:13:13 +0200
9746fa
Subject: [PATCH] semanage: close the selabel handle
9746fa
9746fa
Close the selabel handle to update the file_context. This means that the
9746fa
file_context will be remmaped and used by selabel_lookup() to return
9746fa
the appropriate context to label the home folder.
9746fa
9746fa
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1993081
9746fa
9746fa
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
9746fa
---
9746fa
 lib/prototypes.h | 1 +
9746fa
 lib/selinux.c    | 5 +++++
9746fa
 lib/semanage.c   | 1 +
9746fa
 3 files changed, 7 insertions(+)
9746fa
9746fa
diff --git a/lib/prototypes.h b/lib/prototypes.h
9746fa
index 1d1586d4..b697e0ec 100644
9746fa
--- a/lib/prototypes.h
9746fa
+++ b/lib/prototypes.h
9746fa
@@ -392,6 +392,7 @@ extern /*@observer@*/const char *crypt_make_salt (/*@null@*//*@observer@*/const
9746fa
 /* selinux.c */
9746fa
 #ifdef WITH_SELINUX
9746fa
 extern int set_selinux_file_context (const char *dst_name, mode_t mode);
9746fa
+extern void reset_selinux_handle (void);
9746fa
 extern int reset_selinux_file_context (void);
9746fa
 extern int check_selinux_permit (const char *perm_name);
9746fa
 #endif
9746fa
diff --git a/lib/selinux.c b/lib/selinux.c
9746fa
index c83545f9..b075d4c0 100644
9746fa
--- a/lib/selinux.c
9746fa
+++ b/lib/selinux.c
9746fa
@@ -50,6 +50,11 @@ static void cleanup(void)
9746fa
 	}
9746fa
 }
9746fa
 
9746fa
+void reset_selinux_handle (void)
9746fa
+{
9746fa
+    cleanup();
9746fa
+}
9746fa
+
9746fa
 /*
9746fa
  * set_selinux_file_context - Set the security context before any file or
9746fa
  *                            directory creation.
9746fa
diff --git a/lib/semanage.c b/lib/semanage.c
9746fa
index 0d30456a..a5bf9218 100644
9746fa
--- a/lib/semanage.c
9746fa
+++ b/lib/semanage.c
9746fa
@@ -293,6 +293,7 @@ int set_seuser (const char *login_name, const char *seuser_name)
9746fa
 	}
9746fa
 
9746fa
 	ret = 0;
9746fa
+	reset_selinux_handle();
9746fa
 
9746fa
 done:
9746fa
 	semanage_seuser_key_free (key);
9746fa
-- 
9746fa
2.31.1
9746fa