#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. */
if (!force && initialized != LAZY_INITIALIZED)
return 1;
+ mac_selinux_disable_logging();
+
r = selinux_status_open(/* netlink fallback= */ 1);
if (r < 0) {
if (!ERRNO_IS_PRIVILEGE(errno))
#endif
}
+#if HAVE_SELINUX
+_printf_(2,3)
+static int selinux_log_glue(int type, const char *fmt, ...) {
+ return 0;
+}
+#endif
+
+void mac_selinux_disable_logging(void) {
+#if HAVE_SELINUX
+ /* 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 = selinux_log_glue });
+#endif
+}
+
#if HAVE_SELINUX
static int selinux_fix_fd(
int fd,
void mac_selinux_maybe_reload(void);
void mac_selinux_finish(void);
+void mac_selinux_disable_logging(void);
+
int mac_selinux_fix_full(int atfd, const char *inode_path, const char *label_path, LabelFixFlags flags);
int mac_selinux_apply(const char *path, const char *label);