mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
82c482d573
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
45 lines
1.1 KiB
Bash
Executable File
45 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
|
set -eux
|
|
set -o pipefail
|
|
|
|
# shellcheck source=test/units/util.sh
|
|
. "$(dirname "$0")"/util.sh
|
|
|
|
# Make sure NeedDaemonReload= considers newly created drop-ins.
|
|
# Issue: https://github.com/systemd/systemd/issues/31752
|
|
|
|
UNIT=test-issue-31752.service
|
|
|
|
cleanup() {
|
|
rm -rf /run/systemd/system/"$UNIT" /run/systemd/system/"$UNIT".d
|
|
systemctl daemon-reload
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
cat > /run/systemd/system/"$UNIT" <<EOF
|
|
[Service]
|
|
ExecStart=/usr/bin/true
|
|
RemainAfterExit=yes
|
|
EOF
|
|
|
|
systemctl daemon-reload
|
|
systemctl start "$UNIT"
|
|
assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" no
|
|
|
|
mkdir /run/systemd/system/"$UNIT".d
|
|
cat > /run/systemd/system/"$UNIT".d/desc.conf <<EOF
|
|
[Unit]
|
|
Description=Test NeedDaemonReload status after creating drop-in
|
|
EOF
|
|
|
|
assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" yes
|
|
|
|
rm /run/systemd/system/"$UNIT".d/desc.conf
|
|
|
|
assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" no
|