Merge pull request #26214 from YHNdnzj/sd-notify-change-notifyaccess

core: support overriding NOTIFYACCESS= through sd-notify during runtime
This commit is contained in:
Mike Yuan
2023-03-24 00:11:29 +08:00
committed by GitHub
13 changed files with 165 additions and 12 deletions
+8
View File
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-80-NOTIFYACCESS
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# shellcheck disable=SC2016
set -eux
set -o pipefail
# shellcheck source=test/units/assert.sh
. "$(dirname "$0")"/assert.sh
: >/failed
systemctl --no-block start notify.service
sleep 2
assert_eq "$(systemctl show notify.service -p StatusText --value)" "Test starts, waiting for 5 seconds"
assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "all"
sleep 5
assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "main"
assert_eq "$(systemctl show notify.service -p StatusText --value)" "Sending READY=1 in an unpriviledged process"
assert_rc 3 systemctl --quiet is-active notify.service
sleep 10
systemctl --quiet is-active notify.service
assert_eq "$(systemctl show notify.service -p StatusText --value)" "OK"
assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "none"
systemctl stop notify.service
assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "all"
touch /testok
rm /failed