From 6e0ed2865e344e18765c6a3d69c4646015f2a143 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 3 Jan 2020 18:25:51 +0100 Subject: test: hardcode shell to use let's make sure we always invoke our commands through /bin/sh, since on some distros su will use /bin/nologin (or whatever is listed in /etc/passwd) as shell otherwise and we don#t want that. --- test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh index cd61dc95c9..158889888e 100755 --- a/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh +++ b/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh @@ -7,7 +7,7 @@ systemd-analyze log-level debug runas() { declare userid=$1 shift - su "$userid" -c 'XDG_RUNTIME_DIR=/run/user/$UID "$@"' -- sh "$@" + su "$userid" -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh "$@" } runas nobody systemctl --user --wait is-system-running -- cgit v1.2.1 From e9786a5c016477c37905e4a5538f753643c672fd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 3 Jan 2020 18:27:14 +0100 Subject: test: don't rely on "nobody" user for TEST-43 The name is not as universal as we want, still, hence let's use our own user we create with sysusers.d/. That should yield same behaviour everywhere (and also test sysusers a bit as side effect). --- test/TEST-43-PRIVATEUSER-UNPRIV/test.sh | 17 +++++++++------- test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh | 30 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh index 49d61c6a7f..fe20114756 100755 --- a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh +++ b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh @@ -15,20 +15,23 @@ test_setup() { mask_supporting_services - usermod --root $initdir -d /home/nobody -s /bin/bash nobody - mkdir $initdir/home $initdir/home/nobody - # Ubuntu's equivalent is nogroup - chown nobody:nobody $initdir/home/nobody || chown nobody:nogroup $initdir/home/nobody + # Allocate user for running test case under + mkdir -p $initdir/etc/sysusers.d + cat >$initdir/etc/sysusers.d/testuser.conf <$initdir/etc/systemd/system/testsuite.service < Date: Mon, 6 Jan 2020 13:40:36 +0100 Subject: testsuite: drop "systemctl is-system-running --wait" invocation We wait for "basic.target" being reached in the user instance anyway before allowing the user's session to start, hence doing such a wait is unnecessary, since that would just mean we'd wait for "default.target" on top of "basic.target", but we shouldn#t need anything of that... Hence, let's simplify this, reduce explicit sync points. --- test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh | 2 -- 1 file changed, 2 deletions(-) (limited to 'test') diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh index 837d5dbfa8..fa5da2ec7d 100755 --- a/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh +++ b/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh @@ -10,8 +10,6 @@ runas() { su "$userid" -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh "$@" } -runas testuser systemctl --user --wait is-system-running - runas testuser systemd-run --user --unit=test-private-users \ -p PrivateUsers=yes -P echo hello -- cgit v1.2.1