1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-21 02:50:18 +03:00

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.
This commit is contained in:
Lennart Poettering 2025-02-26 17:59:42 +01:00
parent 80a9d4f92c
commit 01881ff12a

View File

@ -4186,12 +4186,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;