mirror of
https://github.com/systemd/systemd.git
synced 2025-03-09 12:58:26 +03:00
test: move runas() to the shared utility library
This commit is contained in:
parent
e71bac7222
commit
7c6fa5bf16
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 "$@"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user