]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit: return a better error state for unit_get_unit_file_preset() if we have no fragm... 36504/head
authorLennart Poettering <lennart@poettering.net>
Wed, 26 Feb 2025 16:59:42 +0000 (17:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Apr 2025 14:47:41 +0000 (16:47 +0200)
We'd previously return what was already set. Let's instead return a
clear ENOEXEC in this case, to make clear what is going on: preset logic
doesn't apply to units which lag a fragment path.

src/core/unit.c

index 21d57f73bcdea5263f58bd5251b645e6998df232..ae977536b8b27f06ff1e9da8f8d0045f3c6bcc07 100644 (file)
@@ -4173,12 +4173,12 @@ PresetAction unit_get_unit_file_preset(Unit *u) {
 
         assert(u);
 
-        if (u->unit_file_preset >= 0 || !u->fragment_path)
+        if (u->unit_file_preset >= 0)
                 return u->unit_file_preset;
 
         /* If this is a transient or perpetual unit file it doesn't make much sense to ask the preset
          * database about this, because enabling/disabling makes no sense for either. Hence don't. */
-        if (u->transient || u->perpetual)
+        if (!u->fragment_path || u->transient || u->perpetual)
                 return (u->unit_file_preset = -ENOEXEC);
 
         _cleanup_free_ char *bn = NULL;