core/unit: do not use unit path cache in unit_need_daemon_reload()
authorNick Rosbrook <enr0n@ubuntu.com>
Wed, 7 Aug 2024 22:18:06 +0000 (18:18 -0400)
committerLuca Boccassi <bluca@debian.org>
Thu, 15 Aug 2024 13:04:41 +0000 (14:04 +0100)
commit6f57f9b8aa4084179c82c98ec654315a63532fe9
treeca0de61b420a0dc4cc3cf2aa5650680795636929
parent195124fd1cbe26723c9170a0676d5d372e9ea729
core/unit: do not use unit path cache in unit_need_daemon_reload()

When unit_need_daemon_reload() calls unit_find_dropin_paths() to check
for new drop-in configs, the manager's unit path cache is used to limit
which directories are considered. If a new drop-in directory is created,
it may not be in the unit path cache, and hence unit_need_daemon_reload()
may return false, despite a new drop-in being present. However, if a
unit path cache is not given to unit_file_find_dropin_paths() at all,
then it behaves as if the target path was found in the unit path cache.

So, to fix this, adapt unit_find_dropin_paths() to take a boolean
argument indicating whether or not to pass along the unit path cache.
Set this to false in unit_need_daemon_reload().

Fixes #31752

(cherry picked from commit 82c482d573c9d2f3ab36f7be8d32772f90f2c335)
src/core/load-dropin.c
src/core/load-dropin.h
src/core/unit.c
test/units/TEST-07-PID1.issue-31752.sh [new file with mode: 0755]