]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
selinux: early exit in mac_selinux_maybe_reload if not initialized
authorChristian Göttsche <cgzones@googlemail.com>
Sat, 5 Sep 2020 15:49:48 +0000 (17:49 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 5 Sep 2020 19:39:12 +0000 (21:39 +0200)
Binaries might not initialize SELinux, e.g. when they normally do not
create files with the SELinux default context.
If they, via an internal libary function, call a _label() function,
mac_selinux_maybe_reload() gets called. Since the SELinux status page
has not been opened, selinux_status_updated() will fail with EINVAL.

This affects particularly test binaries.

Just exit early and avoid confusing debug logs.

src/basic/selinux-util.c

index 2876b718bf8e21d4a9cc431c8569ed3a4ef6e8d1..9b3b15d387d452e6387ae619bf1840f659465f54 100644 (file)
@@ -153,6 +153,9 @@ void mac_selinux_maybe_reload(void) {
 #if HAVE_SELINUX
         int r;
 
+        if (!initialized)
+                return;
+
         r = selinux_status_updated();
         if (r < 0)
                 log_debug_errno(errno, "Failed to update SELinux from status page: %m");