selinux: Disable selinux logging in mac_init() as well

We currently only disable selinux logging in mac_selinux_setup(),
but not in mac_init(). We don't want libraries we use to log unless
we tell them to, so disable selinux's logging in mac_init() as well.
This commit is contained in:
Daan De Meyer
2025-04-25 06:17:28 +09:00
committed by Yu Watanabe
parent 3a4aa7f5b2
commit d04f6fe446
3 changed files with 19 additions and 9 deletions
+1 -9
View File
@@ -19,21 +19,13 @@
#include "string-util.h"
#include "time-util.h"
#if HAVE_SELINUX
_printf_(2,3)
static int null_log(int type, const char *fmt, ...) {
return 0;
}
#endif
int mac_selinux_setup(bool *loaded_policy) {
assert(loaded_policy);
#if HAVE_SELINUX
int r;
/* Turn off all of SELinux' own logging, we want to do that ourselves */
selinux_set_callback(SELINUX_CB_LOG, (const union selinux_callback) { .func_log = null_log });
mac_selinux_disable_logging();
/* Don't load policy in the initrd if we don't appear to have it. For the real root, we check below
* if we've already loaded policy, and return gracefully. */