mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
core/unit: ignore dropins for masked units completely when checking need_reload
Follow-up for 19a44dfe45
If a drop-in is set from upper level, e.g. global unit_type.d/,
even if a unit is masked, its dropin_paths would still be partially
populated. However, unit_need_daemon_reload() would always
compare u->dropin_paths with empty strv in case of masked units,
resulting in it always returning true. Instead, let's ignore
dropins entirely here.
Fixes #33672
This commit is contained in:
parent
8b6de9e638
commit
11b3775f51
@ -3796,8 +3796,6 @@ static bool fragment_mtime_newer(const char *path, usec_t mtime, bool path_maske
|
||||
}
|
||||
|
||||
bool unit_need_daemon_reload(Unit *u) {
|
||||
_cleanup_strv_free_ char **dropins = NULL;
|
||||
|
||||
assert(u);
|
||||
assert(u->manager);
|
||||
|
||||
@ -3813,16 +3811,20 @@ bool unit_need_daemon_reload(Unit *u) {
|
||||
if (fragment_mtime_newer(u->source_path, u->source_mtime, false))
|
||||
return true;
|
||||
|
||||
if (u->load_state == UNIT_LOADED)
|
||||
(void) unit_find_dropin_paths(u, &dropins);
|
||||
if (!strv_equal(u->dropin_paths, dropins))
|
||||
return true;
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
_cleanup_strv_free_ char **dropins = NULL;
|
||||
|
||||
/* … any drop-ins that are masked are simply omitted from the list. */
|
||||
STRV_FOREACH(path, u->dropin_paths)
|
||||
if (fragment_mtime_newer(*path, u->dropin_mtime, false))
|
||||
(void) unit_find_dropin_paths(u, &dropins);
|
||||
|
||||
if (!strv_equal(u->dropin_paths, dropins))
|
||||
return true;
|
||||
|
||||
/* … any drop-ins that are masked are simply omitted from the list. */
|
||||
STRV_FOREACH(path, u->dropin_paths)
|
||||
if (fragment_mtime_newer(*path, u->dropin_mtime, false))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -37,5 +37,4 @@ systemctl unmask "$UNIT"
|
||||
assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" no
|
||||
|
||||
systemctl mask "$UNIT"
|
||||
# FIXME: should be "no"
|
||||
assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" yes
|
||||
assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" no
|
||||
|
Loading…
Reference in New Issue
Block a user