1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-26 17:27:41 +03:00

test: move runas() to the shared utility library

This commit is contained in:
Frantisek Sumsal 2023-05-16 22:41:03 +02:00
parent e71bac7222
commit 7c6fa5bf16
4 changed files with 14 additions and 17 deletions

View File

@ -5,6 +5,9 @@ set -o pipefail
# Test changing the main PID
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
systemd-analyze log-level debug
# The main service PID should be the parent bash process
@ -166,12 +169,6 @@ test "$(systemctl show -P Result test-true.scope)" = success
# Test that user scope units work as well
runas() {
declare userid=$1
shift
XDG_RUNTIME_DIR=/run/user/"$(id -u "$userid")" setpriv --reuid="$userid" --init-groups "$@"
}
systemctl start user@4711.service
runas testuser systemd-run --scope --user --unit test-true.scope /bin/true
test "$(systemctl show -P Result test-true.scope)" = success

View File

@ -3,13 +3,10 @@
set -eux
set -o pipefail
systemd-analyze log-level debug
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
runas() {
declare userid=$1
shift
XDG_RUNTIME_DIR=/run/user/"$(id -u "$userid")" setpriv --reuid="$userid" --init-groups "$@"
}
systemd-analyze log-level debug
runas testuser systemd-run --wait --user --unit=test-private-users \
-p PrivateUsers=yes -P echo hello

View File

@ -3,11 +3,8 @@
set -eux
set -o pipefail
runas() {
declare userid=$1
shift
XDG_RUNTIME_DIR=/run/user/"$(id -u "$userid")" setpriv --reuid="$userid" --init-groups "$@"
}
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
if ! command -v systemd-repart &>/dev/null; then
echo "no systemd-repart" >/skipped

View File

@ -74,3 +74,9 @@ get_cgroup_hierarchy() {
exit 1
esac
}
runas() {
local userid="${1:?}"
shift
XDG_RUNTIME_DIR=/run/user/"$(id -u "$userid")" setpriv --reuid="$userid" --init-groups "$@"
}