From cb16d391637c26c4391b88830f949e56a534bd14 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 26 Feb 2025 17:59:42 +0100 Subject: [PATCH] unit: return a better error state for unit_get_unit_file_preset() if we have no fragment path 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index 21d57f73bcd..ae977536b8b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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; -- 2.47.3