]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/service: ignore SELinux label errors in permissive mode
authorMichal Sekletar <msekleta@redhat.com>
Tue, 1 Apr 2025 08:38:14 +0000 (10:38 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 31 Jul 2026 02:30:32 +0000 (11:30 +0900)
Return -ENODATA instead of the raw error when SELinux is permissive, so
the caller falls back to the default label. This is needed to allow
relabeling service to start on systems where file contexts maybe
invalid.

src/core/service.c

index 012336b47a0bac23498613e213c09a0b4eb07891..8950eed5396c4a1b12f91755a82abe6112718414 100644 (file)
@@ -6307,9 +6307,13 @@ int service_determine_exec_selinux_label(Service *s, char **ret) {
                 log_unit_debug_errno(UNIT(s), r, "Can't read SELinux label off binary '%s', due to privileges, ignoring.", path);
                 return -ENODATA;
         }
-        if (r < 0)
-                return log_unit_debug_errno(UNIT(s), r, "Failed to read SELinux label off binary '%s': %m", path);
+        if (r < 0) {
+                if (mac_selinux_enforcing())
+                        return log_unit_debug_errno(UNIT(s), r, "Failed to read SELinux label off binary '%s': %m", path);
 
+                log_unit_debug_errno(UNIT(s), r, "Failed to read SELinux label off binary '%s', SELinux in permissive mode, ignoring: %m", path);
+                return -ENODATA;
+        }
         return 0;
 }