File: TEST-07-PID1.attach_processes.sh

package info (click to toggle)
systemd-udeb 260-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 114,360 kB
  • sloc: ansic: 741,727; xml: 122,306; python: 35,714; sh: 35,154; cpp: 947; awk: 126; makefile: 89; lisp: 13; sed: 1
file content (34 lines) | stat: -rwxr-xr-x 808 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux

# Assert when calling AttachProcesses on a unit without ref_uid set

at_exit() {
    set +e

    systemctl stop attach_and_barf.service
    rm -f /run/systemd/system/attach_and_barf.service
    systemctl daemon-reload
}

trap at_exit EXIT

mkdir -p /run/systemd/system

cat >/run/systemd/system/attach_and_barf.service <<EOF
[Service]
Type=simple
Delegate=yes
ExecStart=sleep infinity
EOF

systemctl daemon-reload
systemctl start attach_and_barf.service
run0 -u testuser \
    busctl --system call \
        org.freedesktop.systemd1 \
        /org/freedesktop/systemd1 \
        org.freedesktop.systemd1.Manager \
        AttachProcessesToUnit \
        "ssau" "attach_and_barf.service" "" 1 0 |& grep -F "Access denied" &>/dev/null