2 # SPDX-License-Identifier: LGPL-2.1-or-later
8 systemd-analyze log-level debug
10 # Create a binary for which execve() will fail
11 touch /tmp
/brokenbinary
12 chmod +x
/tmp
/brokenbinary
14 # These three commands should succeed.
15 systemd-run
--unit=exec-one
-p Type
=simple
/bin
/sleep infinity
16 systemd-run
--unit=exec-two
-p Type
=simple
-p User
=idontexist
/bin
/sleep infinity
17 systemd-run
--unit=exec-three
-p Type
=simple
/tmp
/brokenbinary
19 # And now, do the same with Type=exec, where the latter two should fail
20 systemd-run
--unit=exec-four
-p Type
=exec /bin
/sleep infinity
21 (! systemd-run
--unit=exec-five
-p Type
=exec -p User
=idontexist
/bin
/sleep infinity
)
22 (! systemd-run
--unit=exec-six
-p Type
=exec /tmp
/brokenbinary
)
24 systemd-run
--unit=exec-seven
-p KillSignal
=SIGTERM
-p RestartKillSignal
=SIGINT
-p Type
=exec /bin
/sleep infinity
25 # Both TERM and SIGINT happen to have the same number on all architectures
26 test "$(systemctl show --value -p KillSignal exec-seven.service)" -eq 15
27 test "$(systemctl show --value -p RestartKillSignal exec-seven.service)" -eq 2
29 systemctl restart exec-seven.service
30 systemctl stop exec-seven.service
34 # Should work normally
36 org.freedesktop.systemd1
/org
/freedesktop
/systemd1 \
37 org.freedesktop.systemd1.Manager StartTransientUnit \
38 "ssa(sv)a(sa(sv))" test-20933-ok.service replace
1 \
39 ExecStart
"a(sasb)" 1 \
40 /usr
/bin
/sleep 2 /usr
/bin
/sleep 1 true \
43 # DBus call should fail but not crash systemd
45 org.freedesktop.systemd1
/org
/freedesktop
/systemd1 \
46 org.freedesktop.systemd1.Manager StartTransientUnit \
47 "ssa(sv)a(sa(sv))" test-20933-bad.service replace
1 \
48 ExecStart
"a(sasb)" 1 \
49 /usr
/bin
/sleep 0 true \
52 # Same but with the empty argv in the middle
54 org.freedesktop.systemd1
/org
/freedesktop
/systemd1 \
55 org.freedesktop.systemd1.Manager StartTransientUnit \
56 "ssa(sv)a(sa(sv))" test-20933-bad-middle.service replace
1 \
57 ExecStart
"a(sasb)" 3 \
58 /usr
/bin
/sleep 2 /usr
/bin
/sleep 1 true \
59 /usr
/bin
/sleep 0 true \
60 /usr
/bin
/sleep 2 /usr
/bin
/sleep 1 true \
63 systemd-analyze log-level info