[Service]
Type=notify
-ExecStart=bash -c 'sleep infinity'
+ExecStart=sleep infinity
Description=Hello World
[Service]
-ExecStart=/bin/echo "Hello World"
+ExecStart=echo "Hello World"
OnFailure=restart-on-failure.service
[Service]
-ExecStart=/bin/sleep infinity
+ExecStart=sleep infinity
Restart=on-failure
RestartMode=direct
OnFailure=restart-on-failure.service
[Service]
-ExecStart=/bin/sleep infinity
+ExecStart=sleep infinity
Restart=on-failure
RestartMode=normal
[Service]
Type=simple
-ExecStart=/bin/sleep infinity
+ExecStart=sleep infinity
[Service]
Type=oneshot
-ExecStart=/bin/sleep 60
+ExecStart=sleep 60
[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
# 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
[Service]
ExecStart=/usr/lib/systemd/tests/testdata/TEST-07-PID1.units/%N.sh
-ExecStopPost=/bin/true
+ExecStopPost=true
KillMode=mixed
[Service]
Type=simple
Restart=on-abnormal
-ExecCondition=/bin/false
+ExecCondition=false
ExecStart=sleep 100
RestartSec=1
[Service]
Type=simple
Restart=on-failure
-ExecCondition=/bin/false
+ExecCondition=false
ExecStart=sleep 100
RestartSec=1
[Service]
Type=simple
Restart=always
-ExecCondition=/bin/false
+ExecCondition=false
ExecStart=sleep 100
RestartSec=1
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'
[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
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
Type=oneshot
-ExecStart=bash -c 'sleep infinity'
+ExecStart=sleep infinity
[Service]
Type=oneshot
-ExecStart=bash -c 'sleep infinity'
+ExecStart=sleep infinity
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"
# 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
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 "*"
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
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
# 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)
cat >"$unit_path" <<EOF
[Service]
Type=simple
-ExecStart=/bin/sleep 5
+ExecStart=sleep 5
EOF
systemctl daemon-reload
cat >"$unit_path" <<EOF
[Service]
Type=simple
-ExecStart=/bin/sleep 5
+ExecStart=sleep 5
ExecStart=bash -c "echo foo >>$log_file"
EOF
systemctl daemon-reload
cat > /run/systemd/system/"$UNIT" <<EOF
[Service]
-ExecStart=/usr/bin/true
+ExecStart=true
RemainAfterExit=yes
EOF
cat > /run/systemd/system/"$UNIT" <<EOF
[Service]
-ExecStart=/usr/bin/true
+ExecStart=true
EOF
mkdir /run/systemd/system/"$UNIT".d
disown
# Start a test process outside of our own cgroup
-systemd-run -p DynamicUser=1 --unit=test-sleep.service /bin/sleep infinity
+systemd-run -p DynamicUser=1 --unit=test-sleep.service sleep infinity
EXTERNALPID="$(systemctl show -P MainPID test-sleep.service)"
# Update our own main PID to the external test PID, this should work
test "$(systemctl show -P Result test-mainpidsh3.service)" = timeout
# Test that scope units work
-systemd-run --scope --unit test-true.scope /bin/true
+systemd-run --scope --unit test-true.scope true
test "$(systemctl show -P Result test-true.scope)" = success
# Test that user scope units work as well
systemctl start user@4711.service
-runas testuser systemd-run --scope --user --unit test-true.scope /bin/true
+runas testuser systemd-run --scope --user --unit test-true.scope true
test "$(systemctl show -P Result test-true.scope)" = success
Description=Dummy service for the socket unit
Requires=%N.socket
[Service]
-ExecStart=/usr/bin/true
+ExecStart=true
Type=oneshot
EOF
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
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; \
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); \
[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]
# 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
# 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
# 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
# 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}'
# Create a simple "entrypoint" script that validates that the container
# is created correctly according to the OCI config
cat >"$OCI/rootfs/entrypoint.sh" <<EOF
-#!/usr/bin/bash -e
+#!/usr/bin/env bash
+set -e
# Mounts
mountpoint /root
# "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
:
Port=udp:60:61
EOF
cat >"$root/entrypoint.sh" <<\EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
env
# "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
:
--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
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
cat >"$service_path" <<EOF
[Service]
Type=notify
-ExecStart=systemd-nspawn --directory="$root" --notify-ready=no /usr/bin/bash -xec "$cmd"
+ExecStart=systemd-nspawn --directory="$root" --notify-ready=no bash -xec "$cmd"
EOF
systemctl daemon-reload
# 1) Have no IP addresses assigned
create_dummy_container /var/lib/machines/nss-mymachines-noip
cat >/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
# 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
# 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
create_dummy_container /home/testuser/.local/state/machines/zurps
cat >/home/testuser/.local/state/machines/zurps/sbin/init <<EOF
-#!/bin/sh
+#!/usr/bin/env bash
echo "I am living in a container"
exec sleep infinity
EOF
echo "*** test service.d/ top level drop-in"
create_services test15-a test15-b
- check_ko test15-a ExecCondition "/bin/echo a"
- check_ko test15-b ExecCondition "/bin/echo b"
+ check_ko test15-a ExecCondition "echo a"
+ check_ko test15-b ExecCondition "echo b"
mkdir -p /run/systemd/system/service.d
cat >/run/systemd/system/service.d/override.conf <<EOF
[Service]
-ExecCondition=/bin/echo %n
+ExecCondition=echo %n
EOF
systemctl daemon-reload
- check_ok test15-a ExecCondition "/bin/echo test15-a"
- check_ok test15-b ExecCondition "/bin/echo test15-b"
+ check_ok test15-a ExecCondition "echo test15-a"
+ check_ok test15-b ExecCondition "echo test15-b"
rm -rf /run/systemd/system/service.d
clear_units test15-{a,b,c,c1}.service
systemd-run \
--property=RuntimeMaxSec=${runtime_max_sec}s \
-u runtime-max-sec-test-1.service \
- /usr/bin/sh -c "while true; do sleep 1; done"
+ sh -c "while true; do sleep 1; done"
wait_for_timeout runtime-max-sec-test-1.service $((runtime_max_sec + 2))
systemd-run \
--property=RuntimeMaxSec=${runtime_max_sec}s \
--scope \
-u runtime-max-sec-test-2.scope \
- /usr/bin/sh -c "while true; do sleep 1; done" &
+ sh -c "while true; do sleep 1; done" &
wait_for_timeout runtime-max-sec-test-2.scope $((runtime_max_sec + 2))
# These ensure that RuntimeMaxSec is honored for scope and service
# units if the value is changed and then the manager is reloaded.
systemd-run \
-u runtime-max-sec-test-3.service \
- /usr/bin/sh -c "while true; do sleep 1; done"
+ sh -c "while true; do sleep 1; done"
mkdir -p /etc/systemd/system/runtime-max-sec-test-3.service.d/
cat > /etc/systemd/system/runtime-max-sec-test-3.service.d/override.conf << EOF
[Service]
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
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -ex
set -o pipefail
cat >/run/udev/rules.d/50-testsuite.rules <<EOF
SUBSYSTEM=="mem", KERNEL=="null", OPTIONS="log_level=debug"
-ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", IMPORT{program}="/bin/echo -e HOGE=aa\\\\x20\\\\x20\\\\x20bb\nFOO=\\\\x20aaa\\\\x20\n\n\n"
+ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", IMPORT{program}="/usr/bin/echo -e HOGE=aa\\\\x20\\\\x20\\\\x20bb\nFOO=\\\\x20aaa\\\\x20\n\n\n"
EOF
udevadm control --reload
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -ex
set -o pipefail
KERNEL!="null", GOTO="test_end"
OPTIONS="log_level=debug"
-PROGRAM=="/bin/touch /tmp/test-udev-marker"
-PROGRAM!="/bin/sleep 60", ENV{PROGRAM_RESULT}="KILLED"
+PROGRAM=="/usr/bin/touch /tmp/test-udev-marker"
+PROGRAM!="/usr/bin/sleep 60", ENV{PROGRAM_RESULT}="KILLED"
LABEL="test_end"
EOF
ACTION=="remove", GOTO="end"
IMPORT{db}="INVOCATIONS"
-IMPORT{program}="/bin/bash -c 'systemctl show --property=InvocationID systemd-udevd.service'"
+IMPORT{program}="/usr/bin/bash -c 'systemctl show --property=InvocationID systemd-udevd.service'"
ENV{INVOCATIONS}+="%E{ACTION}_%E{SEQNUM}_%E{InvocationID}"
-ACTION=="add", RUN+="/bin/bash -c ':> /tmp/marker'", RUN+="/usr/bin/sleep 10"
+ACTION=="add", RUN+="/usr/bin/bash -c ':> /tmp/marker'", RUN+="/usr/bin/sleep 10"
LABEL="end"
EOF
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}" <<EOF
$(pwd)/${rules}:1 Line is too long, ignored.
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -ex
set -o pipefail
testcase_iodevice_unitfile () {
cat >/run/systemd/system/test1.service <<EOF
[Service]
-ExecStart=/usr/bin/sleep inf
+ExecStart=sleep inf
IOReadBandwidthMax=/dev/sda1 1M
IOReadBandwidthMax=/dev/sda2 2M
IOReadBandwidthMax=/dev/sda3 4M
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# With "e" don't attempt to set permissions when file doesn't exist, see
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Basic tests for types creating directories
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Basic tests for types creating/writing files
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Basic tests for types creating fifos
-#! /bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Inspired by https://github.com/systemd/systemd/issues/9508
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Verifies the issues described by https://github.com/systemd/systemd/issues/10191
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Verify tmpfiles can run in a root directory under a path prefix that contains
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for configuration directory and file precedences
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for the ":" uid/gid/mode modifier
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Check specifier expansion in L lines.
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Test for conditionalized execute bit ('X' bit)
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Test for C-style escapes in file names and contents
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for the --purge switch
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for character and block device creation
cat >"$SERVICE_PATH" <<EOF
[Service]
ExecStart=sleep infinity
-ExecReload=/bin/false
+ExecReload=false
EOF
systemctl daemon-reload
cat >"$SERVICE_PATH" <<EOF
[Service]
ExecStart=sleep infinity
-ExecReload=/bin/true
-ExecReload=/bin/false
-ExecReload=/bin/true
+ExecReload=true
+ExecReload=false
+ExecReload=true
EOF
systemctl daemon-reload
cat >"$SERVICE_PATH" <<EOF
[Service]
ExecStart=sleep infinity
-ExecReload=-/bin/false
+ExecReload=-false
EOF
systemctl daemon-reload
systemd-analyze log-level debug
systemd-run --unit=simple1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple \
- -p ExecStopPost='/bin/touch /run/simple1' true
+ -p ExecStopPost='touch /run/simple1' true
test -f /run/simple1
(! systemd-run --unit=simple2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple \
- -p ExecStopPost='/bin/touch /run/simple2' false)
+ -p ExecStopPost='touch /run/simple2' false)
test -f /run/simple2
systemd-run --unit=exec1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec \
- -p ExecStopPost='/bin/touch /run/exec1' sleep 1
+ -p ExecStopPost='touch /run/exec1' sleep 1
test -f /run/exec1
(! systemd-run --unit=exec2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec \
- -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false')
+ -p ExecStopPost='touch /run/exec2' sh -c 'sleep 1; false')
test -f /run/exec2
cat >/tmp/forking1.sh <<EOF
chmod +x /tmp/forking1.sh
systemd-run --unit=forking1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec \
- -p ExecStopPost='/bin/touch /run/forking1' /tmp/forking1.sh
+ -p ExecStopPost='touch /run/forking1' /tmp/forking1.sh
test -f /run/forking1
cat >/tmp/forking2.sh <<EOF
chmod +x /tmp/forking2.sh
(! systemd-run --unit=forking2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec \
- -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh)
+ -p ExecStopPost='touch /run/forking2' /tmp/forking2.sh)
test -f /run/forking2
systemd-run --unit=oneshot1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot \
- -p ExecStopPost='/bin/touch /run/oneshot1' true
+ -p ExecStopPost='touch /run/oneshot1' true
test -f /run/oneshot1
(! systemd-run --unit=oneshot2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot \
- -p ExecStopPost='/bin/touch /run/oneshot2' false)
+ -p ExecStopPost='touch /run/oneshot2' false)
test -f /run/oneshot2
systemd-run --unit=dbus1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost \
- -p ExecStopPost='/bin/touch /run/dbus1' \
+ -p ExecStopPost='touch /run/dbus1' \
busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus RequestName su systemd.test.ExecStopPost 4 || :
test -f /run/dbus1
systemd-run --unit=dbus2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost \
- -p ExecStopPost='/bin/touch /run/dbus2' true
+ -p ExecStopPost='touch /run/dbus2' true
test -f /run/dbus2
# https://github.com/systemd/systemd/issues/19920
(! systemd-run --unit=dbus3.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus \
- -p ExecStopPost='/bin/touch /run/dbus3' true)
+ -p ExecStopPost='touch /run/dbus3' true)
cat >/tmp/notify1.sh <<EOF
#!/usr/bin/env bash
chmod +x /tmp/notify1.sh
systemd-run --unit=notify1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify \
- -p ExecStopPost='/bin/touch /run/notify1' /tmp/notify1.sh
+ -p ExecStopPost='touch /run/notify1' /tmp/notify1.sh
test -f /run/notify1
(! systemd-run --unit=notify2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify \
- -p ExecStopPost='/bin/touch /run/notify2' true)
+ -p ExecStopPost='touch /run/notify2' true)
test -f /run/notify2
-systemd-run --unit=idle1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle1' true
+systemd-run --unit=idle1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle \
+ -p ExecStopPost='touch /run/idle1' true
test -f /run/idle1
(! systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle \
- -p ExecStopPost='/bin/touch /run/idle2' false)
+ -p ExecStopPost='touch /run/idle2' false)
test -f /run/idle2
systemd-analyze log-level info
# These should all get upgraded to the corresponding Ex property as the non-Ex variant
# does not support the ":" prefix (no-env-expand).
for c in "${!property[@]}"; do
- systemd-run --unit="$c" -r -p "Type=oneshot" -p "${property[$c]}=:/bin/echo \${$c}" true
- systemctl show -p "${property[$c]}" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; ignore_errors=no"
- systemctl show -p "${property[$c]}Ex" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; flags=no-env-expand"
+ systemd-run --unit="$c" -r -p "Type=oneshot" -p "${property[$c]}=:echo \${$c}" true
+ systemctl show -p "${property[$c]}" "$c" | grep -F "path=echo ; argv[]=echo \${$c} ; ignore_errors=no"
+ systemctl show -p "${property[$c]}Ex" "$c" | grep -F "path=echo ; argv[]=echo \${$c} ; flags=no-env-expand"
done
# Ex names on the commandline are supported for backward compat.
for c in "${!property[@]}"; do
- systemd-run --unit="${c}_ex" -r -p "Type=oneshot" -p "${property[$c]}Ex=:/bin/echo \${$c}" true
- systemctl show -p "${property[$c]}" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; ignore_errors=no"
- systemctl show -p "${property[$c]}Ex" "$c" | grep -F "path=/bin/echo ; argv[]=/bin/echo \${$c} ; flags=no-env-expand"
+ systemd-run --unit="${c}_ex" -r -p "Type=oneshot" -p "${property[$c]}Ex=:echo \${$c}" true
+ systemctl show -p "${property[$c]}" "$c" | grep -F "path=echo ; argv[]=echo \${$c} ; ignore_errors=no"
+ systemctl show -p "${property[$c]}Ex" "$c" | grep -F "path=echo ; argv[]=echo \${$c} ; flags=no-env-expand"
done
systemd-analyze log-level info
systemctl log-level debug
# test one: Restart=on-failure should restart the service
-(! systemd-run --unit=oneshot-restart-one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1")
+(! systemd-run --unit=oneshot-restart-one -p Type=oneshot -p Restart=on-failure bash -c "exit 1")
for ((secs = 0; secs < MAX_SECS; secs++)); do
[[ "$(systemctl show oneshot-restart-one.service -P NRestarts)" -le 0 ]] || break
-p StartLimitBurst=3 \
-p Type=oneshot \
-p Restart=on-failure \
- -p ExecStart="/bin/bash -c 'printf a >>$TMP_FILE'" /bin/bash -c "exit 1")
+ -p ExecStart="bash -c 'printf a >>$TMP_FILE'" bash -c "exit 1")
# wait for at least 3 restarts
for ((secs = 0; secs < MAX_SECS; secs++)); do
( ! test -d "$HOME"/.local/state/foo)
( ! test -d "$HOME"/.config/foo)
-systemd-run --user -p StateDirectory=foo --wait /bin/true
+systemd-run --user -p StateDirectory=foo --wait true
test -d "$HOME"/.local/state/foo
( ! test -L "$HOME"/.local/state/foo)
( ! test -d "$HOME"/.config/foo)
-systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
+systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait true
test -d "$HOME"/.local/state/foo
( ! test -L "$HOME"/.local/state/foo)
rmdir "$HOME"/.local/state/foo "$HOME"/.config/foo
-systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
+systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait true
test -d "$HOME"/.local/state/foo
( ! test -L "$HOME"/.local/state/foo)
rmdir "$HOME"/.local/state/foo "$HOME"/.config/foo
# Now trigger an update scenario by creating a config dir first
-systemd-run --user -p ConfigurationDirectory=foo --wait /bin/true
+systemd-run --user -p ConfigurationDirectory=foo --wait true
( ! test -d "$HOME"/.local/state/foo)
test -d "$HOME"/.config/foo
# This will look like an update and result in a symlink
-systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
+systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait true
test -d "$HOME"/.local/state/foo
test -L "$HOME"/.local/state/foo
test "$(readlink "$HOME"/.local/state/foo)" = ../../.config/foo
# Check that this will work safely a second time
-systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait /bin/true
+systemd-run --user -p StateDirectory=foo -p ConfigurationDirectory=foo --wait true
( ! systemd-run --user -p StateDirectory=foo::ro --wait sh -c "echo foo > $HOME/.local/state/foo/baz")
( ! systemd-run --user -p StateDirectory=foo:bar:ro --wait sh -c "echo foo > $HOME/.local/state/foo/baz")
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
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
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
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
(! 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
# invalid dependency
cat >"${SYSVINIT_PATH:?}/issue-24990" <<\EOF
-#!/bin/bash
+#!/usr/bin/env bash
### BEGIN INIT INFO
# Provides:test1 test2
# valid dependency
cat >"$SYSVINIT_PATH/issue-24990" <<\EOF
-#!/bin/bash
+#!/usr/bin/env bash
### BEGIN INIT INFO
# Provides:test1 test2
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; \
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; \
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
}
[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
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:]')"
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"
# 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 \
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
cat >/run/systemd/system/mysshserver@.service <<EOF
[Service]
-ExecStart=-/usr/sbin/sshd -i -d -e
+ExecStart=-sshd -i -d -e
StandardInput=socket
StandardOutput=socket
StandardError=journal
set -eux
set -o pipefail
-# Check that the /sbin/mount.ddi helper works
+# Check that the /usr/sbin/mount.ddi helper works
dir="/tmp/mounthelper.$RANDOM"
mount -t ddi "$MINIMAL_IMAGE.gpt" "$dir" -o ro,X-mount.mkdir,discard
umount -R "$dir"
systemd-dissect --list "$MINIMAL_IMAGE.raw" | grep -q '^etc/os-release$'
systemd-dissect --mtree "$MINIMAL_IMAGE.raw" --mtree-hash yes | \
- grep -qe "^./usr/bin/cat type=file mode=0755 uid=0 gid=0 size=[0-9]* sha256sum=[a-z0-9]*$"
+ grep -qE "^.(/usr|)/bin/cat type=file mode=0755 uid=0 gid=0 size=[0-9]* sha256sum=[a-z0-9]*$"
systemd-dissect --mtree "$MINIMAL_IMAGE.raw" --mtree-hash no | \
- grep -qe "^./usr/bin/cat type=file mode=0755 uid=0 gid=0 size=[0-9]*$"
+ grep -qE "^.(/usr|)/bin/cat type=file mode=0755 uid=0 gid=0 size=[0-9]*$"
read -r SHA256SUM1 _ < <(systemd-dissect --copy-from "$MINIMAL_IMAGE.raw" etc/os-release | sha256sum)
test "$SHA256SUM1" != ""
echo "ARCHITECTURE=_any" >>/run/confexts/test/etc/extension-release.d/extension-release.test
echo "MARKER_CONFEXT_123" >/run/confexts/test/etc/testfile
cat <<EOF >/run/confexts/test/etc/testscript
-#!/bin/bash
+#!/usr/bin/env bash
echo "This should not happen"
EOF
chmod +x /run/confexts/test/etc/testscript
)
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")
EOF
# Set up test mount type
- cat >/usr/sbin/mount.thisisatest <<EOF
+ mount_path="$(command -v mount 2>/dev/null)"
+ mount_test="${mount_path/\/bin/\/sbin}.thisisatest"
+ cat >"$mount_test" <<EOF
#!/usr/bin/env bash
# Mount after verifying credential file content
if [ \$(cat \${CREDENTIALS_DIRECTORY}/loadcred) = "foo" ]; then
mount -t tmpfs \$1 \$2
fi
EOF
- chmod +x /usr/sbin/mount.thisisatest
+ chmod +x "$mount_test"
# Verify mount succeeds
systemctl daemon-reload
# Stop unit and delete files
systemctl stop "$unit"
- rm -f "$credfile" /run/systemd/system/"$unit" /usr/sbin/mount.thisisatest
+ rm -f "$credfile" /run/systemd/system/"$unit" "$mount_test"
rm -rf "$tmpdir"
}
else
# Ensure that we can start services even with a very low hard memory cap without oom-kills, but skip
# under sanitizers as they balloon memory usage.
- systemd-run -t -p MemoryMax=10M -p MemorySwapMax=0 -p MemoryZSwapMax=0 /bin/true
+ systemd-run -t -p MemoryMax=10M -p MemorySwapMax=0 -p MemoryZSwapMax=0 true
fi
test_basic() {
testcase_kernel_oom() {
cat >/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
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
mount_path="$(command -v mount 2>/dev/null)"
mount_mytmpfs="${mount_path/\/bin/\/sbin}.mytmpfs"
cat >"$mount_mytmpfs" <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
sleep ".\$RANDOM"
exec -- $mount_path -t tmpfs tmpfs "\$2"
EOF
[Service]
Type=notify
NotifyAccess=all
-ExecStart=/bin/sh -c "echo 'Hello from test unit' >/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
# 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
# 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
-#!/usr/bin/python3
+#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1-or-later
# pylint: disable=broad-except
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\""
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
# 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
# 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
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"
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" || :
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"
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"
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)
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")
# 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
# 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
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)
} >/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
SCRIPT="/tmp/mempress-$RANDOM.sh"
cat >"$SCRIPT" <<'EOF'
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
"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"
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"
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"
survive_sigterm="/dev/shm/survive-sigterm-$RANDOM.sh"
cat >"$survive_sigterm" <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
trap "" TERM
systemd-notify --ready
rm "$survive_sigterm"
survive_argv="/dev/shm/survive-argv-$RANDOM.sh"
cat >"$survive_argv" <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
systemd-notify --ready
rm "$survive_argv"
exec -a @sleep sleep infinity
# Simple script that spawns given "fake" binary and then kills it with
# given signal
cat >"${MAKE_DUMP_SCRIPT:?}" <<\EOF
-#!/bin/bash -ex
+#!/usr/bin/env bash
+set -ex
bin="${1:?}"
sig="${2:?}"
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"
if pkgconf --atleast-version 0.192 libdw ; then
# dwfl_set_sysroot() is supported only in libdw-0.192 or newer.
cat >"$MAKE_STACKTRACE_DUMP" <<END
-#!/bin/bash
+#!/usr/bin/env bash
mount -t tmpfs tmpfs /tmp
gcc -xc -O0 -g -o $CORE_STACKTRACE_TEST_BIN - <<EOF
void baz(void) { int *x = 0; *x = 42; }
mkdir -p /run/systemd/coredump.conf.d/
printf '[Coredump]\nEnterNamespace=no' >/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"
RuntimeDirectory=app0
EOF
cat >"$initdir/opt/script0.sh" <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -e
test -e /usr/lib/os-release
echo bar >\${STATE_DIRECTORY}/foo
RuntimeDirectory=app1
EOF
cat >"$initdir/opt/script1.sh" <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -e
test -e /usr/lib/os-release
echo baz >\${STATE_DIRECTORY}/foo