selinux: early exit in mac_selinux_maybe_reload if not initialized

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.
This commit is contained in:
Christian Göttsche 2020-09-05 17:49:48 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 22c2f841db
commit 1006038cf1

View 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");