From: Yu Watanabe Date: Sun, 21 Sep 2025 13:10:21 +0000 (+0900) Subject: test: use relative paths to executables X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2c5e9c0116f410a87958c9eeb361cd47fdc34b0;p=thirdparty%2Fsystemd.git test: use relative paths to executables This also makes shebang always use env command, and drops unnecessary 'bash -c' or 'sh -c' when a signle command is invoked in the shell, like sleep or echo. --- diff --git a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/always-activating.service b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/always-activating.service index 93ddb85c75f..e2714a57ade 100644 --- a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/always-activating.service +++ b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/always-activating.service @@ -5,4 +5,4 @@ After=always-activating.socket [Service] Type=notify -ExecStart=bash -c 'sleep infinity' +ExecStart=sleep infinity diff --git a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/hello.service b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/hello.service index 0c3f2f817d9..b3c8199d1b4 100644 --- a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/hello.service +++ b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/hello.service @@ -3,4 +3,4 @@ Description=Hello World [Service] -ExecStart=/bin/echo "Hello World" +ExecStart=echo "Hello World" diff --git a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-direct.service b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-direct.service index 00316db1f1a..bc898bd7ed6 100644 --- a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-direct.service +++ b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-direct.service @@ -3,6 +3,6 @@ OnFailure=restart-on-failure.service [Service] -ExecStart=/bin/sleep infinity +ExecStart=sleep infinity Restart=on-failure RestartMode=direct diff --git a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-normal.service b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-normal.service index dabba4c4f02..0ec9c7ff5ff 100644 --- a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-normal.service +++ b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-restart-normal.service @@ -3,6 +3,6 @@ OnFailure=restart-on-failure.service [Service] -ExecStart=/bin/sleep infinity +ExecStart=sleep infinity Restart=on-failure RestartMode=normal diff --git a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-simple.service b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-simple.service index 211346d7c00..043e2503bdc 100644 --- a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-simple.service +++ b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep-infinity-simple.service @@ -4,4 +4,4 @@ Description=Sleep infinitely [Service] Type=simple -ExecStart=/bin/sleep infinity +ExecStart=sleep infinity diff --git a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep.service b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep.service index 32c2037a094..b071c94e253 100644 --- a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep.service +++ b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/sleep.service @@ -4,4 +4,4 @@ Description=Sleep for 1 minute [Service] Type=oneshot -ExecStart=/bin/sleep 60 +ExecStart=sleep 60 diff --git a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/unstoppable.service b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/unstoppable.service index 6eb7c19eab3..9d3e732e451 100644 --- a/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/unstoppable.service +++ b/test/integration-tests/TEST-03-JOBS/TEST-03-JOBS.units/unstoppable.service @@ -2,5 +2,5 @@ [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/bin/echo "I'm unstoppable!" -ExecStop=/bin/systemctl start --no-block unstoppable.service +ExecStart=echo "I'm unstoppable!" +ExecStop=systemctl start --no-block unstoppable.service diff --git a/test/integration-tests/TEST-06-SELINUX/TEST-06-SELINUX.units/hola.service b/test/integration-tests/TEST-06-SELINUX/TEST-06-SELINUX.units/hola.service index 94f9b47b722..0acf808480b 100644 --- a/test/integration-tests/TEST-06-SELINUX/TEST-06-SELINUX.units/hola.service +++ b/test/integration-tests/TEST-06-SELINUX/TEST-06-SELINUX.units/hola.service @@ -1,7 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later [Service] Type=oneshot -ExecStart=/bin/echo Start Hola -ExecReload=/bin/echo Reload Hola -ExecStop=/bin/echo Stop Hola +ExecStart=echo Start Hola +ExecReload=echo Reload Hola +ExecStop=echo Stop Hola RemainAfterExit=yes diff --git a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service index 757f978101e..4fd77160813 100644 --- a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service +++ b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service @@ -4,5 +4,5 @@ Description=Issue 14566 Repro [Service] ExecStart=/usr/lib/systemd/tests/testdata/TEST-07-PID1.units/%N.sh -ExecStopPost=/bin/true +ExecStopPost=true KillMode=mixed diff --git a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service index 90252b388ad..b841777c846 100644 --- a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service +++ b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service @@ -5,6 +5,6 @@ Description=Issue 16115 Repro with on-abnormal [Service] Type=simple Restart=on-abnormal -ExecCondition=/bin/false +ExecCondition=false ExecStart=sleep 100 RestartSec=1 diff --git a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service index 7c65691029d..e41a968e164 100644 --- a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service +++ b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service @@ -5,6 +5,6 @@ Description=Issue 16115 Repro with on-failure [Service] Type=simple Restart=on-failure -ExecCondition=/bin/false +ExecCondition=false ExecStart=sleep 100 RestartSec=1 diff --git a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service index c68f93d11d7..c1942dbd40a 100644 --- a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service +++ b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service @@ -5,6 +5,6 @@ Description=Issue 22257 Repro with Restart=always [Service] Type=simple Restart=always -ExecCondition=/bin/false +ExecCondition=false ExecStart=sleep 100 RestartSec=1 diff --git a/test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.units/fail-stop.service b/test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.units/fail-stop.service index 6d66731f858..e3b374cc710 100644 --- a/test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.units/fail-stop.service +++ b/test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.units/fail-stop.service @@ -13,4 +13,4 @@ Environment=SERVICE=fail_stop extend_timeout_interval=5 sleep_interval=7 start_i ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh # Due to 6041a7ee2c1bbff6301082f192fc1b0882400d42 SIGTERM isn't sent as the service shuts down with STOPPING=1 # This file makes the test assess.sh quicker by notifying it that this test has finished. -ExecStopPost=/bin/bash -c '[[ $SERVICE_RESULT == timeout && $EXIT_CODE == killed ]] && touch /fail_runtime.terminated' +ExecStopPost=bash -c '[[ $SERVICE_RESULT == timeout && $EXIT_CODE == killed ]] && touch /fail_runtime.terminated' diff --git a/test/integration-tests/TEST-62-RESTRICT-IFACES/TEST-62-RESTRICT-IFACES.units/TEST-62-RESTRICT-IFACES-6.service b/test/integration-tests/TEST-62-RESTRICT-IFACES/TEST-62-RESTRICT-IFACES.units/TEST-62-RESTRICT-IFACES-6.service index 876d8f36e77..b7e91f7e682 100644 --- a/test/integration-tests/TEST-62-RESTRICT-IFACES/TEST-62-RESTRICT-IFACES.units/TEST-62-RESTRICT-IFACES-6.service +++ b/test/integration-tests/TEST-62-RESTRICT-IFACES/TEST-62-RESTRICT-IFACES.units/TEST-62-RESTRICT-IFACES-6.service @@ -2,9 +2,9 @@ [Unit] Description=TEST-62-RESTRICT-IFACES-altname [Service] -ExecStart=/bin/sh -c 'ping -c 1 -W 0.2 192.168.113.1' -ExecStart=/bin/sh -c 'ping -c 1 -W 0.2 192.168.113.5' -ExecStart=/bin/sh -c '! ping -c 1 -W 0.2 192.168.113.9' +ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.1' +ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.5' +ExecStart=sh -c '! ping -c 1 -W 0.2 192.168.113.9' RestrictNetworkInterfaces=veth0-altname-with-more-than-15-chars RestrictNetworkInterfaces=veth1-altname-with-more-than-15-chars Type=oneshot diff --git a/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577-dep.service b/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577-dep.service index e332ea474e7..92de94993da 100644 --- a/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577-dep.service +++ b/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577-dep.service @@ -1,4 +1,4 @@ # SPDX-License-Identifier: LGPL-2.1-or-later [Service] Type=oneshot -ExecStart=bash -c 'sleep infinity' +ExecStart=sleep infinity diff --git a/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577.service b/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577.service index 568518bbf60..7664ed0c114 100644 --- a/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577.service +++ b/test/integration-tests/TEST-63-PATH/TEST-63-PATH.units/test63-issue-24577.service @@ -5,4 +5,4 @@ After=test63-issue-24577-dep.service [Service] Type=oneshot -ExecStart=bash -c 'sleep infinity' +ExecStart=sleep infinity diff --git a/test/units/TEST-04-JOURNAL.SYSTEMD_JOURNAL_COMPRESS.sh b/test/units/TEST-04-JOURNAL.SYSTEMD_JOURNAL_COMPRESS.sh index 6da9f5e4205..1561ed971eb 100755 --- a/test/units/TEST-04-JOURNAL.SYSTEMD_JOURNAL_COMPRESS.sh +++ b/test/units/TEST-04-JOURNAL.SYSTEMD_JOURNAL_COMPRESS.sh @@ -26,7 +26,7 @@ EOF journalctl --rotate ID="$(systemd-id128 new)" - systemd-cat -t "$ID" /bin/bash -c "for ((i=0;i<100;i++)); do echo -n hoge with ${c}; done; echo" + systemd-cat -t "$ID" bash -c "for ((i=0;i<100;i++)); do echo -n hoge with ${c}; done; echo" journalctl --sync timeout 10 bash -c "until SYSTEMD_LOG_LEVEL=debug journalctl --verify --quiet --file /var/log/journal/$MACHINE_ID/system.journal 2>&1 | grep -q -F 'compress=${c}'; do sleep .5; done" diff --git a/test/units/TEST-04-JOURNAL.journal.sh b/test/units/TEST-04-JOURNAL.journal.sh index 8834d5ae592..14892120eb4 100755 --- a/test/units/TEST-04-JOURNAL.journal.sh +++ b/test/units/TEST-04-JOURNAL.journal.sh @@ -93,7 +93,7 @@ grep -vq "^_PID=$PID" /tmp/output # https://github.com/systemd/systemd/issues/15654 ID=$(systemd-id128 new) printf "This will\nusually fail\nand be truncated\n" >/tmp/expected -systemd-cat -t "$ID" /bin/sh -c 'env echo -n "This will";echo;env echo -n "usually fail";echo;env echo -n "and be truncated";echo;' +systemd-cat -t "$ID" sh -c 'env echo -n "This will";echo;env echo -n "usually fail";echo;env echo -n "and be truncated";echo;' journalctl --sync journalctl -b -o cat -t "$ID" >/tmp/output diff /tmp/expected /tmp/output @@ -120,7 +120,7 @@ journalctl -b -n 1 /bin/true /bin/false journalctl -b -n 1 /bin/true + /bin/false journalctl -b -n 1 -r --unit "systemd*" -systemd-run --user -M "testuser@.host" /bin/echo hello +systemd-run --user -M "testuser@.host" echo hello journalctl --sync journalctl -b -n 1 -r --user-unit "*" @@ -158,7 +158,7 @@ journalctl --header | grep system.journal journalctl --field _EXE | grep . >/dev/null journalctl --no-hostname --utc --catalog | grep . >/dev/null # Exercise executable_is_script() and the related code, e.g. `journalctl -b /path/to/a/script.sh` should turn -# into ((_EXE=/bin/bash AND _COMM=script.sh) AND _BOOT_ID=c002e3683ba14fa8b6c1e12878386514) +# into ((_EXE=/usr/bin/bash AND _COMM=script.sh) AND _BOOT_ID=c002e3683ba14fa8b6c1e12878386514) journalctl -b "$(readlink -f "$0")" | grep . >/dev/null journalctl -b "$(systemd-id128 boot-id)" | grep . >/dev/null journalctl --since yesterday --reverse | grep . >/dev/null @@ -219,7 +219,7 @@ journalctl --follow --merge | head -n1 | grep . rm -f /tmp/issue-26746-log /tmp/issue-26746-cursor ID="$(systemd-id128 new)" journalctl -t "$ID" --follow --cursor-file=/tmp/issue-26746-cursor | tee /tmp/issue-26746-log & -systemd-cat -t "$ID" /bin/sh -c 'echo hogehoge' +systemd-cat -t "$ID" sh -c 'echo hogehoge' # shellcheck disable=SC2016 timeout 10 bash -c 'until [[ -f /tmp/issue-26746-log && "$(cat /tmp/issue-26746-log)" =~ hogehoge ]]; do sleep .5; done' pkill -TERM journalctl diff --git a/test/units/TEST-07-PID1.exec-context.sh b/test/units/TEST-07-PID1.exec-context.sh index 592c64ca4ce..2ec7f018e85 100755 --- a/test/units/TEST-07-PID1.exec-context.sh +++ b/test/units/TEST-07-PID1.exec-context.sh @@ -405,7 +405,7 @@ if [[ ! -v ASAN_OPTIONS ]]; then # Here, -p EnvironmentFile=-/usr/lib/systemd/systemd-asan-env does not work, # as sd-executor loads NSS module and fails before applying the environment: # (true)[660]: test-dynamicuser-fail.service: Changing to the requested working directory failed: No such file or directory - # (true)[660]: test-dynamicuser-fail.service: Failed at step CHDIR spawning /usr/bin/true: No such file or directory + # (true)[660]: test-dynamicuser-fail.service: Failed at step CHDIR spawning true: No such file or directory # TEST-07-PID1.sh[660]: ==660==LeakSanitizer has encountered a fatal error. # TEST-07-PID1.sh[660]: ==660==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1 # TEST-07-PID1.sh[660]: ==660==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc) diff --git a/test/units/TEST-07-PID1.exec-deserialization.sh b/test/units/TEST-07-PID1.exec-deserialization.sh index 04f17c88e9d..580fa090f64 100755 --- a/test/units/TEST-07-PID1.exec-deserialization.sh +++ b/test/units/TEST-07-PID1.exec-deserialization.sh @@ -193,7 +193,7 @@ testcase_issue_6533() { cat >"$unit_path" <"$unit_path" <>$log_file" EOF systemctl daemon-reload diff --git a/test/units/TEST-07-PID1.issue-31752.sh b/test/units/TEST-07-PID1.issue-31752.sh index 89ec07e46bf..73b6cc69ee6 100755 --- a/test/units/TEST-07-PID1.issue-31752.sh +++ b/test/units/TEST-07-PID1.issue-31752.sh @@ -23,7 +23,7 @@ trap cleanup EXIT cat > /run/systemd/system/"$UNIT" < /run/systemd/system/"$UNIT" < /run/systemd/system/mqueue-ownership.service Description=Dummy service for the socket unit Requires=%N.socket [Service] -ExecStart=/usr/bin/true +ExecStart=true Type=oneshot EOF diff --git a/test/units/TEST-07-PID1.private-network.sh b/test/units/TEST-07-PID1.private-network.sh index 37658f7d1cd..9b39733546e 100755 --- a/test/units/TEST-07-PID1.private-network.sh +++ b/test/units/TEST-07-PID1.private-network.sh @@ -4,4 +4,4 @@ set -eux set -o pipefail # For issue https://github.com/systemd/systemd/issues/29526 -systemd-run -p PrivateNetwork=yes --wait /bin/true +systemd-run -p PrivateNetwork=yes --wait true diff --git a/test/units/TEST-07-PID1.quota.sh b/test/units/TEST-07-PID1.quota.sh index 748b5ee6589..a68d9dd53d4 100755 --- a/test/units/TEST-07-PID1.quota.sh +++ b/test/units/TEST-07-PID1.quota.sh @@ -41,7 +41,7 @@ PrivateUsers=yes TemporaryFileSystem=/run /var/opt /var/lib /vol ${exec_directory_directive} ${exec_quota_directive} -ExecStart=/bin/bash -c ' \ +ExecStart=bash -c ' \ set -eux; \ set -o pipefail; \ touch ${directory}/quotadir/testfile; \ @@ -77,7 +77,7 @@ PrivateUsers=yes TemporaryFileSystem=/run /var/opt /var/lib /vol ${exec_directory_directive} ${exec_quota_directive} -ExecStart=/bin/bash -c ' \ +ExecStart=bash -c ' \ set -eux; \ set -o pipefail; \ (! fallocate -l 10000G ${directory}/quotadir/largefile); \ diff --git a/test/units/TEST-07-PID1.transient-unit-container.sh b/test/units/TEST-07-PID1.transient-unit-container.sh index 60316bf2fa6..a17f08bd51f 100755 --- a/test/units/TEST-07-PID1.transient-unit-container.sh +++ b/test/units/TEST-07-PID1.transient-unit-container.sh @@ -121,8 +121,8 @@ After=basic.target [Service] Type=oneshot -ExecStart=/bin/sh -c 'echo "$EXPECTED_OUTPUT" > "$guest_output"' -ExecStartPost=/usr/bin/systemctl --no-block exit 0 +ExecStart=sh -c 'echo "$EXPECTED_OUTPUT" > "$guest_output"' +ExecStartPost=systemctl --no-block exit 0 TimeoutStopSec=15s [Install] diff --git a/test/units/TEST-07-PID1.type-exec-parallel.sh b/test/units/TEST-07-PID1.type-exec-parallel.sh index 30f80c539b5..23c4c9e4d4f 100755 --- a/test/units/TEST-07-PID1.type-exec-parallel.sh +++ b/test/units/TEST-07-PID1.type-exec-parallel.sh @@ -6,4 +6,4 @@ set -o pipefail # Make sure that we never mistake a process starting but failing quickly for a process failing to start, with Type=exec. # See https://github.com/systemd/systemd/pull/30799 -seq 25 | xargs -n 1 -P 0 systemd-run -p Type=exec /bin/false +seq 25 | xargs -n 1 -P 0 systemd-run -p Type=exec false diff --git a/test/units/TEST-13-NSPAWN.machined.sh b/test/units/TEST-13-NSPAWN.machined.sh index 76db239f916..d93b3f0441f 100755 --- a/test/units/TEST-13-NSPAWN.machined.sh +++ b/test/units/TEST-13-NSPAWN.machined.sh @@ -40,7 +40,7 @@ done # Create one "long running" container with some basic signal handling create_dummy_container /var/lib/machines/long-running cat >/var/lib/machines/long-running/sbin/init <<\EOF -#!/usr/bin/bash +#!/usr/bin/env bash set -x @@ -316,7 +316,7 @@ varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Unreg # test io.systemd.Machine.List with addresses, OSRelease, and UIDShift fields create_dummy_container "/var/lib/machines/container-without-os-release" cat >>/var/lib/machines/container-without-os-release/sbin/init <<\EOF -#!/usr/bin/bash +#!/usr/bin/env bash set -x @@ -397,13 +397,13 @@ rm -f /tmp/none-existent-file # server side, to not generate early SIGHUP. Hence, let's just invoke "sleep # infinity" client side, once we acquired the fd (passing it to it), and kill # it once we verified everything worked. -PID=$(systemd-notify --fork -- varlinkctl --exec call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": "shell", "user": "root", "path": "/bin/bash", "args": ["/bin/bash", "-c", "echo $FOO > /tmp/none-existent-file"], "environment": ["FOO=BAR"]}' -- sleep infinity) +PID=$(systemd-notify --fork -- varlinkctl --exec call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": "shell", "user": "root", "path": "/usr/bin/bash", "args": ["bash", "-c", "echo $FOO > /tmp/none-existent-file"], "environment": ["FOO=BAR"]}' -- sleep infinity) timeout 30 bash -c "until test -e /tmp/none-existent-file; do sleep .5; done" grep -q "BAR" /tmp/none-existent-file kill "$PID" # Test varlinkctl's --exec fd passing logic properly -assert_eq "$(varlinkctl --exec call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": "shell", "user": "root", "path": "/bin/bash", "args": ["/bin/bash", "-c", "echo $((7 + 8))"], "environment": ["TERM=dumb"]}' -- bash -c 'read -r -N 2 x <&3 ; echo "$x"')" 15 +assert_eq "$(varlinkctl --exec call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": "shell", "user": "root", "path": "/usr/bin/bash", "args": ["bash", "-c", "echo $((7 + 8))"], "environment": ["TERM=dumb"]}' -- bash -c 'read -r -N 2 x <&3 ; echo "$x"')" 15 # test io.systemd.Machine.MapFrom varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapFrom '{"name": "long-running", "uid":0, "gid": 0}' diff --git a/test/units/TEST-13-NSPAWN.nspawn-oci.sh b/test/units/TEST-13-NSPAWN.nspawn-oci.sh index 65dcc96b594..bae3e2e085c 100755 --- a/test/units/TEST-13-NSPAWN.nspawn-oci.sh +++ b/test/units/TEST-13-NSPAWN.nspawn-oci.sh @@ -351,7 +351,8 @@ EOF # Create a simple "entrypoint" script that validates that the container # is created correctly according to the OCI config cat >"$OCI/rootfs/entrypoint.sh" <"$root/bin/getent" <<\EOF -#!/bin/bash +#!/usr/bin/env bash if [[ $# -eq 0 ]]; then : @@ -456,7 +456,7 @@ Port=tcp:60 Port=udp:60:61 EOF cat >"$root/entrypoint.sh" <<\EOF -#!/bin/bash +#!/usr/bin/env bash set -ex env @@ -844,7 +844,7 @@ testcase_owneridmap() { # "Fake" getent passwd's bare minimum, so we don't have to pull it in # with all the DSO shenanigans cat >"$root/bin/getent" <<\EOF -#!/bin/bash +#!/usr/bin/env bash if [[ $# -eq 0 ]]; then : @@ -869,7 +869,7 @@ EOF --user=testuser \ --bind=/tmp/owneridmap/bind:/home/testuser:owneridmap \ ${COVERAGE_BUILD_DIR:+--bind="$COVERAGE_BUILD_DIR"} \ - /usr/bin/bash -c "$cmd" |& tee nspawn.out; then + bash -c "$cmd" |& tee nspawn.out; then if grep -q "Failed to map ids for bind mount.*: Function not implemented" nspawn.out; then echo "idmapped mounts are not supported, skipping the test..." return 0 @@ -906,7 +906,8 @@ testcase_os_release() { create_dummy_container "$root" entrypoint="$root/entrypoint.sh" cat >"$entrypoint" <<\EOF -#!/usr/bin/bash -ex +#!/usr/bin/env bash +set -ex . /tmp/os-release [[ -n "${ID:-}" && "$ID" != "$container_host_id" ]] && exit 1 @@ -953,7 +954,7 @@ testcase_machinectl_bind() { cat >"$service_path" </var/lib/machines/nss-mymachines-noip/sbin/init <<\EOF -#!/usr/bin/bash -ex +#!/usr/bin/env bash +set -ex ip addr show dev ve-noip touch /initialized @@ -38,7 +39,8 @@ EOF # 2) Have one IP address assigned (IPv4 only) create_dummy_container /var/lib/machines/nss-mymachines-singleip cat >/var/lib/machines/nss-mymachines-singleip/sbin/init <<\EOF -#!/usr/bin/bash -ex +#!/usr/bin/env bash +set -ex ip addr add 10.1.0.2/24 dev ve-singleip ip addr show dev ve-singleip @@ -51,7 +53,8 @@ EOF # 3) Have bunch of IP addresses assigned (both IPv4 and IPv6) create_dummy_container /var/lib/machines/nss-mymachines-manyips cat >/var/lib/machines/nss-mymachines-manyips/sbin/init <<\EOF -#!/usr/bin/bash -ex +#!/usr/bin/env bash +set -ex ip addr add 10.2.0.2/24 dev ve-manyips for i in {100..120}; do diff --git a/test/units/TEST-13-NSPAWN.unpriv.sh b/test/units/TEST-13-NSPAWN.unpriv.sh index 17ccb19c8eb..b9ac5d903b7 100755 --- a/test/units/TEST-13-NSPAWN.unpriv.sh +++ b/test/units/TEST-13-NSPAWN.unpriv.sh @@ -24,7 +24,7 @@ run0 -u testuser mkdir -p .local/state/machines create_dummy_container /home/testuser/.local/state/machines/zurps cat >/home/testuser/.local/state/machines/zurps/sbin/init </run/systemd/system/service.d/override.conf < /etc/systemd/system/runtime-max-sec-test-3.service.d/override.conf << EOF [Service] @@ -96,7 +96,7 @@ wait_for_timeout runtime-max-sec-test-3.service $((runtime_max_sec + 2)) systemd-run \ --scope \ -u runtime-max-sec-test-4.scope \ - /usr/bin/sh -c "while true; do sleep 1; done" & + sh -c "while true; do sleep 1; done" & # Wait until the unit is running to avoid race with creating the override. until systemctl is-active runtime-max-sec-test-4.scope; do diff --git a/test/units/TEST-17-UDEV.IMPORT.sh b/test/units/TEST-17-UDEV.IMPORT.sh index 60be31a126c..d960ddd9811 100755 --- a/test/units/TEST-17-UDEV.IMPORT.sh +++ b/test/units/TEST-17-UDEV.IMPORT.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later set -ex set -o pipefail @@ -7,7 +7,7 @@ mkdir -p /run/udev/rules.d/ cat >/run/udev/rules.d/50-testsuite.rules <"$ assert_1 "${rules}" { - printf 'RUN+="/bin/true",%8174s\\\n' ' ' - printf 'RUN+="/bin/false"%8174s\\\n' ' ' + printf 'RUN+="/usr/bin/true",%8170s\\\n' ' ' + printf 'RUN+="/usr/bin/false"%8170s\\\n' ' ' echo } >"${rules}" assert_0 "${rules}" -printf 'RUN+="/bin/true"%8176s\\\n #\n' ' ' ' ' >"${rules}" +printf 'RUN+="/usr/bin/true"%8176s\\\n #\n' ' ' ' ' >"${rules}" echo >>"${rules}" cat >"${exp}" </run/systemd/system/test1.service <"$SERVICE_PATH" <"$SERVICE_PATH" <"$SERVICE_PATH" </tmp/forking1.sh </tmp/forking2.sh </tmp/notify1.sh < $HOME/.local/state/foo/baz") ( ! systemd-run --user -p StateDirectory=foo:bar:ro --wait sh -c "echo foo > $HOME/.local/state/foo/baz") diff --git a/test/units/TEST-23-UNIT-FILE.type-exec.sh b/test/units/TEST-23-UNIT-FILE.type-exec.sh index 87f32ccb586..d5497efff2a 100755 --- a/test/units/TEST-23-UNIT-FILE.type-exec.sh +++ b/test/units/TEST-23-UNIT-FILE.type-exec.sh @@ -12,16 +12,16 @@ touch /tmp/brokenbinary chmod +x /tmp/brokenbinary # These three commands should succeed. -systemd-run --unit=exec-one -p Type=simple /bin/sleep infinity -systemd-run --unit=exec-two -p Type=simple -p User=idontexist /bin/sleep infinity +systemd-run --unit=exec-one -p Type=simple sleep infinity +systemd-run --unit=exec-two -p Type=simple -p User=idontexist sleep infinity systemd-run --unit=exec-three -p Type=simple /tmp/brokenbinary # And now, do the same with Type=exec, where the latter two should fail -systemd-run --unit=exec-four -p Type=exec /bin/sleep infinity -(! systemd-run --unit=exec-five -p Type=exec -p User=idontexist /bin/sleep infinity) +systemd-run --unit=exec-four -p Type=exec sleep infinity +(! systemd-run --unit=exec-five -p Type=exec -p User=idontexist sleep infinity) (! systemd-run --unit=exec-six -p Type=exec /tmp/brokenbinary) -systemd-run --unit=exec-seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity +systemd-run --unit=exec-seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec sleep infinity # Both TERM and SIGINT happen to have the same number on all architectures test "$(systemctl show --value -p KillSignal exec-seven.service)" -eq 15 test "$(systemctl show --value -p RestartKillSignal exec-seven.service)" -eq 2 @@ -37,7 +37,7 @@ busctl call \ org.freedesktop.systemd1.Manager StartTransientUnit \ "ssa(sv)a(sa(sv))" test-20933-ok.service replace 1 \ ExecStart "a(sasb)" 1 \ - /usr/bin/sleep 2 /usr/bin/sleep 1 true \ + sleep 2 sleep 1 true \ 0 # DBus call should fail but not crash systemd @@ -46,7 +46,7 @@ busctl call \ org.freedesktop.systemd1.Manager StartTransientUnit \ "ssa(sv)a(sa(sv))" test-20933-bad.service replace 1 \ ExecStart "a(sasb)" 1 \ - /usr/bin/sleep 0 true \ + sleep 0 true \ 0) # Same but with the empty argv in the middle @@ -55,9 +55,9 @@ busctl call \ org.freedesktop.systemd1.Manager StartTransientUnit \ "ssa(sv)a(sa(sv))" test-20933-bad-middle.service replace 1 \ ExecStart "a(sasb)" 3 \ - /usr/bin/sleep 2 /usr/bin/sleep 1 true \ - /usr/bin/sleep 0 true \ - /usr/bin/sleep 2 /usr/bin/sleep 1 true \ + sleep 2 sleep 1 true \ + sleep 0 true \ + sleep 2 sleep 1 true \ 0) systemd-analyze log-level info diff --git a/test/units/TEST-26-SYSTEMCTL.sh b/test/units/TEST-26-SYSTEMCTL.sh index cc6b8449895..d5f9c02a03c 100755 --- a/test/units/TEST-26-SYSTEMCTL.sh +++ b/test/units/TEST-26-SYSTEMCTL.sh @@ -258,7 +258,7 @@ systemctl revert "$UNIT_NAME" (! grep -r "CPUQuota=" "/run/systemd/system.control/${UNIT_NAME}.d/") # Failed-unit related tests -(! systemd-run --wait --unit "failed.service" /bin/false) +(! systemd-run --wait --unit "failed.service" false) systemctl is-failed failed.service systemctl --state=failed | grep failed.service systemctl --failed | grep failed.service @@ -405,7 +405,7 @@ if [[ -x /usr/lib/systemd/system-generators/systemd-sysv-generator ]]; then # invalid dependency cat >"${SYSVINIT_PATH:?}/issue-24990" <<\EOF -#!/bin/bash +#!/usr/bin/env bash ### BEGIN INIT INFO # Provides:test1 test2 @@ -459,7 +459,7 @@ EOF # valid dependency cat >"$SYSVINIT_PATH/issue-24990" <<\EOF -#!/bin/bash +#!/usr/bin/env bash ### BEGIN INIT INFO # Provides:test1 test2 diff --git a/test/units/TEST-34-DYNAMICUSERMIGRATE.sh b/test/units/TEST-34-DYNAMICUSERMIGRATE.sh index e5aee475af7..05d645c35ef 100755 --- a/test/units/TEST-34-DYNAMICUSERMIGRATE.sh +++ b/test/units/TEST-34-DYNAMICUSERMIGRATE.sh @@ -180,7 +180,7 @@ PrivateUsers=yes TemporaryFileSystem=/run /var/opt /var/lib /vol UMask=0000 StateDirectory=testidmapped:sampleservice -ExecStart=/bin/bash -c ' \ +ExecStart=bash -c ' \ set -eux; \ set -o pipefail; \ touch /var/lib/sampleservice/testfile; \ @@ -213,7 +213,7 @@ PrivateUsers=no TemporaryFileSystem=/run /var/opt /var/lib /vol UMask=0000 StateDirectory=testidmapped:sampleservice -ExecStart=/bin/bash -c ' \ +ExecStart=bash -c ' \ set -eux; \ set -o pipefail; \ touch /var/lib/sampleservice/testfile; \ diff --git a/test/units/TEST-35-LOGIN.sh b/test/units/TEST-35-LOGIN.sh index 49ce59d5b9a..b714fce67aa 100755 --- a/test/units/TEST-35-LOGIN.sh +++ b/test/units/TEST-35-LOGIN.sh @@ -21,7 +21,7 @@ cleanup_test_user() ( setup_test_user() { mkdir -p /var/spool/cron /var/spool/mail - useradd -m -s /bin/bash logind-test-user + useradd -m -s /usr/bin/bash logind-test-user trap cleanup_test_user EXIT } @@ -351,7 +351,7 @@ create_session() { [Service] Type=simple ExecStart= -ExecStart=-/usr/sbin/agetty --autologin logind-test-user --noclear %I $TERM +ExecStart=-agetty --autologin logind-test-user --noclear %I $TERM Restart=no EOF systemctl daemon-reload @@ -679,7 +679,7 @@ session required pam_unix.so EOF cat > "$SCRIPT" <<'EOF' -#!/bin/bash +#!/usr/bin/env bash set -ex typeset -i AMB MASK AMB="0x$(grep 'CapAmb:' /proc/self/status | cut -d: -f2 | tr -d '[:space:]')" diff --git a/test/units/TEST-38-FREEZER.sh b/test/units/TEST-38-FREEZER.sh index 5ce073d045c..31f28c9ef12 100755 --- a/test/units/TEST-38-FREEZER.sh +++ b/test/units/TEST-38-FREEZER.sh @@ -339,7 +339,7 @@ testcase_watchdog() { local unit="wd.service" systemd-run --collect --unit "$unit" --property WatchdogSec=4s --property Type=notify \ - /bin/bash -c 'systemd-notify --ready; while true; do systemd-notify WATCHDOG=1; sleep 1; done' + bash -c 'systemd-notify --ready; while true; do systemd-notify WATCHDOG=1; sleep 1; done' systemctl freeze "$unit" check_freezer_state "$unit" "frozen" diff --git a/test/units/TEST-43-PRIVATEUSER-UNPRIV.sh b/test/units/TEST-43-PRIVATEUSER-UNPRIV.sh index f8a2a624676..0805a5caf94 100755 --- a/test/units/TEST-43-PRIVATEUSER-UNPRIV.sh +++ b/test/units/TEST-43-PRIVATEUSER-UNPRIV.sh @@ -93,7 +93,7 @@ runas testuser systemd-run --wait --user --unit=test-devices \ # Same check as test/test-execute/exec-privatenetwork-yes.service runas testuser systemd-run --wait --user --unit=test-network \ -p PrivateNetwork=yes \ - /bin/sh -x -c '! ip link | grep -E "^[0-9]+: " | grep -Ev ": (lo|(erspan|gre|gretap|ip_vti|ip6_vti|ip6gre|ip6tnl|sit|tunl)0@.*):"' + sh -x -c '! ip link | grep -E "^[0-9]+: " | grep -Ev ": (lo|(erspan|gre|gretap|ip_vti|ip6_vti|ip6gre|ip6tnl|sit|tunl)0@.*):"' (! runas testuser systemd-run --wait --user --unit=test-hostname \ -p ProtectHostname=yes \ diff --git a/test/units/TEST-46-HOMED.sh b/test/units/TEST-46-HOMED.sh index 8a6aa54fa19..b18a6c11f87 100755 --- a/test/units/TEST-46-HOMED.sh +++ b/test/units/TEST-46-HOMED.sh @@ -519,14 +519,14 @@ userdbctl ssh-authorized-keys dropinuser | tee /tmp/authorized-keys grep "ssh-ed25519" /tmp/authorized-keys grep "ecdsa-sha2-nistp256" /tmp/authorized-keys echo "my-top-secret-key 🐱" >/tmp/my-top-secret-key -userdbctl ssh-authorized-keys dropinuser --chain /bin/cat /tmp/my-top-secret-key | tee /tmp/authorized-keys +userdbctl ssh-authorized-keys dropinuser --chain /usr/bin/cat /tmp/my-top-secret-key | tee /tmp/authorized-keys grep "ssh-ed25519" /tmp/authorized-keys grep "ecdsa-sha2-nistp256" /tmp/authorized-keys grep "my-top-secret-key 🐱" /tmp/authorized-keys (! userdbctl ssh-authorized-keys 🐱) (! userdbctl ssh-authorized-keys dropin-user --chain) (! userdbctl ssh-authorized-keys dropin-user --chain '') -(! SYSTEMD_LOG_LEVEL=debug userdbctl ssh-authorized-keys dropin-user --chain /bin/false) +(! SYSTEMD_LOG_LEVEL=debug userdbctl ssh-authorized-keys dropin-user --chain /usr/bin/false) (! userdbctl '') for opt in json multiplexer output synthesize with-dropin with-nss with-varlink; do @@ -611,7 +611,7 @@ EOF cat >/run/systemd/system/mysshserver@.service </run/confexts/test/etc/extension-release.d/extension-release.tes echo "ARCHITECTURE=_any" >>/run/confexts/test/etc/extension-release.d/extension-release.test echo "MARKER_CONFEXT_123" >/run/confexts/test/etc/testfile cat </run/confexts/test/etc/testscript -#!/bin/bash +#!/usr/bin/env bash echo "This should not happen" EOF chmod +x /run/confexts/test/etc/testscript diff --git a/test/units/TEST-54-CREDS.sh b/test/units/TEST-54-CREDS.sh index 7016aee85a3..d349b0f3e45 100755 --- a/test/units/TEST-54-CREDS.sh +++ b/test/units/TEST-54-CREDS.sh @@ -24,7 +24,7 @@ run_with_cred_compare() ( ) test_mount_with_credential() { - local credfile tmpdir unit + local credfile tmpdir unit mount_path mount_test credfile="/tmp/mount-cred" tmpdir="/tmp/test-54-mount" unit=$(systemd-escape --suffix mount --path "$tmpdir") @@ -42,14 +42,16 @@ LoadCredential=loadcred:$credfile EOF # Set up test mount type - cat >/usr/sbin/mount.thisisatest <"$mount_test" </tmp/script.sh <<"EOF" -#!/bin/bash +#!/usr/bin/env bash choom --adjust '+1000' -- bash -c 'echo f >/proc/sysrq-trigger && exec sleep infinity' choom --adjust '+1000' -p $$ echo f >/proc/sysrq-trigger @@ -325,7 +325,7 @@ EOF systemctl reset-failed cat >/tmp/script.sh <<"EOF" -#!/bin/bash +#!/usr/bin/env bash echo '+memory' >/sys/fs/cgroup/system.slice/oom-kill.service/cgroup.subtree_control mkdir /sys/fs/cgroup/system.slice/oom-kill.service/sub echo 1 >/sys/fs/cgroup/system.slice/oom-kill.service/sub/memory.oom.group diff --git a/test/units/TEST-60-MOUNT-RATELIMIT.sh b/test/units/TEST-60-MOUNT-RATELIMIT.sh index 028ad7e3a21..d91e22225e1 100755 --- a/test/units/TEST-60-MOUNT-RATELIMIT.sh +++ b/test/units/TEST-60-MOUNT-RATELIMIT.sh @@ -68,7 +68,7 @@ testcase_issue_23796() { mount_path="$(command -v mount 2>/dev/null)" mount_mytmpfs="${mount_path/\/bin/\/sbin}.mytmpfs" cat >"$mount_mytmpfs" </tmp/testfile; systemd-notify --ready; sleep infinity" +ExecStart=sh -c "echo 'Hello from test unit' >/tmp/testfile; systemd-notify --ready; sleep infinity" PrivateTmp=disconnected EOF # Start the service diff --git a/test/units/TEST-68-PROPAGATE-EXIT-STATUS.sh b/test/units/TEST-68-PROPAGATE-EXIT-STATUS.sh index d717ce5a557..70743b78df1 100755 --- a/test/units/TEST-68-PROPAGATE-EXIT-STATUS.sh +++ b/test/units/TEST-68-PROPAGATE-EXIT-STATUS.sh @@ -69,7 +69,7 @@ EOF # Script to check that when an OnSuccess= dependency fires, the correct # MONITOR* env variables are passed. cat >/tmp/check_on_success.sh <<"EOF" -#!/bin/sh +#!/usr/bin/env bash set -ex env | sort @@ -126,7 +126,7 @@ EOF # Script to check that when an OnFailure= dependency fires, the correct # MONITOR* env variables are passed. cat >/tmp/check_on_failure.sh <<"EOF" -#!/bin/sh +#!/usr/bin/env bash set -ex env | sort diff --git a/test/units/TEST-69-SHUTDOWN.py b/test/units/TEST-69-SHUTDOWN.py index 4e554702abb..51569bf51ef 100755 --- a/test/units/TEST-69-SHUTDOWN.py +++ b/test/units/TEST-69-SHUTDOWN.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # SPDX-License-Identifier: LGPL-2.1-or-later # pylint: disable=broad-except diff --git a/test/units/TEST-74-AUX-UTILS.ask-password.sh b/test/units/TEST-74-AUX-UTILS.ask-password.sh index 1ae1df1142e..421ebb74b78 100755 --- a/test/units/TEST-74-AUX-UTILS.ask-password.sh +++ b/test/units/TEST-74-AUX-UTILS.ask-password.sh @@ -19,6 +19,6 @@ systemd-tty-ask-password-agent --list varlinkctl introspect /run/systemd/io.systemd.AskPassword # Spawn an agent that always replies all ask password requests with "waldo" -systemd-run -u waldo-ask-pw-agent.service -p Environment=SYSTEMD_ASK_PASSWORD_AGENT_PASSWORD=waldo -p Type=notify /usr/bin/systemd-tty-ask-password-agent --watch --console=/dev/console +systemd-run -u waldo-ask-pw-agent.service -p Environment=SYSTEMD_ASK_PASSWORD_AGENT_PASSWORD=waldo -p Type=notify systemd-tty-ask-password-agent --watch --console=/dev/console assert_eq "$(systemd-ask-password --no-tty)" "waldo" assert_eq "$(varlinkctl call /usr/bin/systemd-ask-password io.systemd.AskPassword.Ask '{"message":"foobar"}' | jq '.passwords[0]')" "\"waldo\"" diff --git a/test/units/TEST-74-AUX-UTILS.capsule.sh b/test/units/TEST-74-AUX-UTILS.capsule.sh index e7b5c877470..06f6a1ca6e2 100755 --- a/test/units/TEST-74-AUX-UTILS.capsule.sh +++ b/test/units/TEST-74-AUX-UTILS.capsule.sh @@ -36,7 +36,7 @@ busctl -C foobar systemctl -C foobar -systemd-run -C foobar -u sleepinfinity /bin/sleep infinity +systemd-run -C foobar -u sleepinfinity sleep infinity systemctl -C foobar status sleepinfinity diff --git a/test/units/TEST-74-AUX-UTILS.delta.sh b/test/units/TEST-74-AUX-UTILS.delta.sh index dabe2347093..15f5df05572 100755 --- a/test/units/TEST-74-AUX-UTILS.delta.sh +++ b/test/units/TEST-74-AUX-UTILS.delta.sh @@ -29,7 +29,7 @@ systemctl mask delta-test-unit-masked.service # Overridden unit cp -fv /run/systemd/system/delta-test-unit-extended.service /run/systemd/system/delta-test-unit-overridden.service cp -fv /run/systemd/system/delta-test-unit-overridden.service /etc/systemd/system/delta-test-unit-overridden.service -echo "ExecStartPost=/bin/true" >>/etc/systemd/system/delta-test-unit-overridden.service +echo "ExecStartPost=true" >>/etc/systemd/system/delta-test-unit-overridden.service # Overridden but equivalent unit ln -srfv /run/systemd/system/delta-test-unit-extended.service /run/systemd/system/delta-test-unit-equivalent.service ln -sfv /run/systemd/system/delta-test-unit-extended.service /etc/systemd/system/delta-test-unit-equivalent.service diff --git a/test/units/TEST-74-AUX-UTILS.pty-forward.sh b/test/units/TEST-74-AUX-UTILS.pty-forward.sh index deb49352628..6d35802ee3f 100755 --- a/test/units/TEST-74-AUX-UTILS.pty-forward.sh +++ b/test/units/TEST-74-AUX-UTILS.pty-forward.sh @@ -7,7 +7,7 @@ systemd-pty-forward --background 41 --title test echo foobar # Test that signals are forwarded to the systemd-pty-forward child process. cat >/tmp/child <<\EOF -#!/usr/bin/bash +#!/usr/bin/env bash set -x trap 'touch /tmp/int' INT diff --git a/test/units/TEST-74-AUX-UTILS.run.sh b/test/units/TEST-74-AUX-UTILS.run.sh index 19b4f113bb4..c7ca8ce6153 100755 --- a/test/units/TEST-74-AUX-UTILS.run.sh +++ b/test/units/TEST-74-AUX-UTILS.run.sh @@ -126,7 +126,7 @@ systemd-run --remain-after-exit \ true systemctl cat "$UNIT.service" "$UNIT.timer" grep -q "^OnUnitInactiveSec=16h$" "/run/systemd/transient/$UNIT.timer" -grep -qE "^ExecStart=.*/bin/true.*$" "/run/systemd/transient/$UNIT.service" +grep -qE "^ExecStart=.*true.*$" "/run/systemd/transient/$UNIT.service" systemctl stop "$UNIT.timer" "$UNIT.service" || : UNIT="timer-1-$RANDOM" @@ -162,7 +162,7 @@ grep -q "^OnTimezoneChange=yes$" "/run/systemd/transient/$UNIT.timer" grep -q "^After=systemd-journald.service$" "/run/systemd/transient/$UNIT.timer" grep -q "^Description=My Fancy Timer$" "/run/systemd/transient/$UNIT.service" grep -q "^RemainAfterExit=yes$" "/run/systemd/transient/$UNIT.service" -grep -qE "^ExecStart=.*/bin/true.*$" "/run/systemd/transient/$UNIT.service" +grep -qE "^ExecStart=.*true.*$" "/run/systemd/transient/$UNIT.service" (! grep -q "^After=systemd-journald.service$" "/run/systemd/transient/$UNIT.service") systemctl stop "$UNIT.timer" "$UNIT.service" || : @@ -180,7 +180,7 @@ systemd-analyze verify --recursive-errors=no "/run/systemd/transient/$UNIT.path" grep -q "^PathExists=/tmp$" "/run/systemd/transient/$UNIT.path" grep -q "^PathExists=/tmp/foo$" "/run/systemd/transient/$UNIT.path" grep -q "^PathChanged=/root/bar$" "/run/systemd/transient/$UNIT.path" -grep -qE "^ExecStart=.*/bin/true.*$" "/run/systemd/transient/$UNIT.service" +grep -qE "^ExecStart=.*true.*$" "/run/systemd/transient/$UNIT.service" systemctl stop "$UNIT.path" "$UNIT.service" || : : "Transient socket unit" @@ -197,7 +197,7 @@ systemd-analyze verify --recursive-errors=no "/run/systemd/transient/$UNIT.socke grep -q "^ListenFIFO=/tmp/socket.fifo$" "/run/systemd/transient/$UNIT.socket" grep -q "^SocketMode=0666$" "/run/systemd/transient/$UNIT.socket" grep -q "^SocketMode=0644$" "/run/systemd/transient/$UNIT.socket" -grep -qE "^ExecStart=.*/bin/true.*$" "/run/systemd/transient/$UNIT.service" +grep -qE "^ExecStart=.*true.*$" "/run/systemd/transient/$UNIT.service" systemctl stop "$UNIT.socket" "$UNIT.service" || : : "Job mode" @@ -215,8 +215,8 @@ SHELL=/bin/true systemd-run --shell SHELL=/bin/true systemd-run --scope --shell systemd-run --wait --pty true systemd-run --wait --machine=.host --pty true -systemd-run --json=short /bin/true | jq . >/dev/null -systemd-run --json=pretty /bin/true | jq . >/dev/null +systemd-run --json=short true | jq . >/dev/null +systemd-run --json=pretty true | jq . >/dev/null (! SHELL=/bin/false systemd-run --quiet --shell) (! systemd-run) diff --git a/test/units/TEST-74-AUX-UTILS.varlinkctl.sh b/test/units/TEST-74-AUX-UTILS.varlinkctl.sh index d00d2e65d83..49d0a171e50 100755 --- a/test/units/TEST-74-AUX-UTILS.varlinkctl.sh +++ b/test/units/TEST-74-AUX-UTILS.varlinkctl.sh @@ -53,7 +53,6 @@ fi IDL_FILE="$(mktemp)" varlinkctl introspect /run/systemd/journal/io.systemd.journal io.systemd.Journal | tee "${IDL_FILE:?}" varlinkctl validate-idl "$IDL_FILE" -varlinkctl validate-idl "$IDL_FILE" cat /bin/sh >"$IDL_FILE" (! varlinkctl validate-idl "$IDL_FILE") @@ -91,7 +90,7 @@ trap rm_rf_sshbindir EXIT # Create a fake "ssh" binary that validates everything works as expected if invoked for the "ssh-unix:" Varlink transport cat > "$SSHBINDIR"/ssh <<'EOF' -#!/bin/sh +#!/usr/bin/env bash set -xe @@ -107,7 +106,7 @@ SYSTEMD_SSH="$SSHBINDIR/ssh" varlinkctl info ssh-unix:foobar:/run/systemd/journa # Now build another fake "ssh" binary that does the same for "ssh-exec:" cat > "$SSHBINDIR"/ssh <<'EOF' -#!/bin/sh +#!/usr/bin/env bash set -xe diff --git a/test/units/TEST-74-AUX-UTILS.vpick.sh b/test/units/TEST-74-AUX-UTILS.vpick.sh index 400097ffeb7..4c78b91002c 100755 --- a/test/units/TEST-74-AUX-UTILS.vpick.sh +++ b/test/units/TEST-74-AUX-UTILS.vpick.sh @@ -98,19 +98,19 @@ ls -l /var/lib/machines/testroot.v test "$(systemd-vpick /var/lib/machines/testroot.v)" = /var/lib/machines/testroot.v/testroot_34/ test "$(systemd-vpick --resolve=yes /var/lib/machines/testroot.v)" = /var/lib/machines/testroot.v/testroot_34/ -(! systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v /bin/true) +(! systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v true) find /var/lib/machines/testroot.v/testroot_34 rm -rf /var/lib/machines/testroot.v/testroot_34 test "$(systemd-vpick /var/lib/machines/testroot.v)" = /var/lib/machines/testroot.v/testroot_33/ test "$(systemd-vpick --resolve=yes /var/lib/machines/testroot.v)" = /tmp/dotvroot/ -systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v /bin/true +systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v true rm /var/lib/machines/testroot.v/testroot_33 test "$(systemd-vpick /var/lib/machines/testroot.v)" = /var/lib/machines/testroot.v/testroot_32/ test "$(systemd-vpick --resolve=yes /var/lib/machines/testroot.v)" = /var/lib/machines/testroot.v/testroot_32/ -(! systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v /bin/true) +(! systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v true) rm -rf /var/lib/machines/testroot.v/testroot_32 (! systemd-vpick /var/lib/machines/testroot.v) -(! systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v /bin/true) +(! systemd-run --wait -p RootDirectory=/var/lib/machines/testroot.v true) diff --git a/test/units/TEST-75-RESOLVED.sh b/test/units/TEST-75-RESOLVED.sh index 39cd4c717d5..5e4fa064716 100755 --- a/test/units/TEST-75-RESOLVED.sh +++ b/test/units/TEST-75-RESOLVED.sh @@ -970,7 +970,7 @@ testcase_11_nft() { } >/run/systemd/system/test-nft.socket { echo "[Service]" - echo "ExecStart=/usr/bin/sleep 10000" + echo "ExecStart=sleep 10000" } >/run/systemd/system/test-nft.service systemctl daemon-reload systemctl start test-nft.socket diff --git a/test/units/TEST-79-MEMPRESS.sh b/test/units/TEST-79-MEMPRESS.sh index 2b1de204f7b..0cf5c37416e 100755 --- a/test/units/TEST-79-MEMPRESS.sh +++ b/test/units/TEST-79-MEMPRESS.sh @@ -28,7 +28,7 @@ UNIT="test-mempress-$RANDOM.service" SCRIPT="/tmp/mempress-$RANDOM.sh" cat >"$SCRIPT" <<'EOF' -#!/bin/bash +#!/usr/bin/env bash set -ex diff --git a/test/units/TEST-81-GENERATORS.run-generator.sh b/test/units/TEST-81-GENERATORS.run-generator.sh index 9bd74efbaff..314c1fe7a79 100755 --- a/test/units/TEST-81-GENERATORS.run-generator.sh +++ b/test/units/TEST-81-GENERATORS.run-generator.sh @@ -54,9 +54,9 @@ ARGS=( "systemd.run_success_action=" "systemd.run_failure_action=" - "systemd.run=/bin/false" + "systemd.run=false" "systemd.run=" - "systemd.run=/bin/true" + "systemd.run=true" "systemd.run='echo this is a long string'" "systemd.run_success_action=reboot" @@ -70,7 +70,7 @@ cat "$UNIT" systemd-analyze verify --man=no --recursive-errors=no "$UNIT" grep -qE "^SuccessAction=reboot$" "$UNIT" grep -qE "^FailureAction=poweroff-force$" "$UNIT" -grep -qE "^ExecStart=/bin/false$" "$UNIT" +grep -qE "^ExecStart=false$" "$UNIT" grep -qE "^ExecStart=$" "$UNIT" -grep -qE "^ExecStart=/bin/true$" "$UNIT" +grep -qE "^ExecStart=true$" "$UNIT" grep -qE "^ExecStart=echo this is a long string$" "$UNIT" diff --git a/test/units/TEST-82-SOFTREBOOT.sh b/test/units/TEST-82-SOFTREBOOT.sh index 65d0e030b86..9d6a93f8e8e 100755 --- a/test/units/TEST-82-SOFTREBOOT.sh +++ b/test/units/TEST-82-SOFTREBOOT.sh @@ -32,7 +32,7 @@ KERNEL!="null", GOTO="end" ACTION=="remove", GOTO="end" IMPORT{db}="HISTORY" -IMPORT{program}="/bin/bash -c 'systemctl show --property=SoftRebootsCount'" +IMPORT{program}="/usr/bin/systemctl show --property=SoftRebootsCount" ENV{HISTORY}+="%E{ACTION}_%E{SEQNUM}_%E{SoftRebootsCount}" LABEL="end" @@ -242,7 +242,7 @@ else survive_sigterm="/dev/shm/survive-sigterm-$RANDOM.sh" cat >"$survive_sigterm" <"$survive_argv" <"${MAKE_DUMP_SCRIPT:?}" <<\EOF -#!/bin/bash -ex +#!/usr/bin/env bash +set -ex bin="${1:?}" sig="${2:?}" @@ -98,12 +99,12 @@ EOF machinectl start "$CONTAINER" timeout "$TIMEOUT" bash -xec "until systemd-run -M '$CONTAINER' -q --wait --pipe true; do sleep .5; done" - [[ "$(systemd-run -M "$CONTAINER" -q --wait --pipe coredumpctl list -q --no-legend /usr/bin/sleep | wc -l)" -eq 0 ]] + [[ "$(systemd-run -M "$CONTAINER" -q --wait --pipe coredumpctl list -q --no-legend sleep | wc -l)" -eq 0 ]] machinectl copy-to "$CONTAINER" "$MAKE_DUMP_SCRIPT" - systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "/usr/bin/sleep" "SIGABRT" - systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "/usr/bin/sleep" "SIGTRAP" + systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "sleep" "SIGABRT" + systemd-run -M "$CONTAINER" -q --wait --pipe "$MAKE_DUMP_SCRIPT" "sleep" "SIGTRAP" # Wait a bit for the coredumps to get processed - timeout 30 bash -c "while [[ \$(systemd-run -M $CONTAINER -q --wait --pipe coredumpctl list -q --no-legend /usr/bin/sleep | wc -l) -lt 2 ]]; do sleep 1; done" + timeout 30 bash -c "while [[ \$(systemd-run -M $CONTAINER -q --wait --pipe coredumpctl list -q --no-legend sleep | wc -l) -lt 2 ]]; do sleep 1; done" machinectl stop "$CONTAINER" rm -rf "/var/lib/machines/$CONTAINER" @@ -253,7 +254,7 @@ systemd-run -t --property CoredumpFilter=default ls /tmp if pkgconf --atleast-version 0.192 libdw ; then # dwfl_set_sysroot() is supported only in libdw-0.192 or newer. cat >"$MAKE_STACKTRACE_DUMP" </run/systemd/coredump.conf.d/99-enter-namespace.conf - unshare --pid --fork --mount-proc --mount --uts --ipc --net /bin/bash -c "$MAKE_STACKTRACE_DUMP" || : + unshare --pid --fork --mount-proc --mount --uts --ipc --net bash -c "$MAKE_STACKTRACE_DUMP" || : timeout 30 bash -c "until coredumpctl -1 info $CORE_STACKTRACE_TEST_BIN | grep -zvqE 'baz.*bar.*foo'; do sleep .2; done" printf '[Coredump]\nEnterNamespace=yes' >/run/systemd/coredump.conf.d/99-enter-namespace.conf - unshare --pid --fork --mount-proc --mount --uts --ipc --net /bin/bash -c "$MAKE_STACKTRACE_DUMP" || : + unshare --pid --fork --mount-proc --mount --uts --ipc --net bash -c "$MAKE_STACKTRACE_DUMP" || : timeout 30 bash -c "until coredumpctl -1 info $CORE_STACKTRACE_TEST_BIN | grep -zqE 'baz.*bar.*foo'; do sleep .2; done" else echo "libdw doesn't not support setting sysroot, skipping EnterNamespace= test" diff --git a/test/units/util.sh b/test/units/util.sh index 65f2d0b2e31..ea60abb92ee 100755 --- a/test/units/util.sh +++ b/test/units/util.sh @@ -304,7 +304,7 @@ StateDirectory=app0 RuntimeDirectory=app0 EOF cat >"$initdir/opt/script0.sh" <\${STATE_DIRECTORY}/foo @@ -347,7 +347,7 @@ StateDirectory=app1 RuntimeDirectory=app1 EOF cat >"$initdir/opt/script1.sh" <\${STATE_DIRECTORY}/foo