]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add quick test to verify the PAM stack really ran in all run0 modes of operation
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Oct 2024 20:51:49 +0000 (22:51 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 13 Nov 2024 19:48:10 +0000 (19:48 +0000)
(cherry picked from commit f515ea1cd4981ceb1a2c85d676f279db2972283f)

test/units/TEST-74-AUX-UTILS.run.sh

index 2c2a9f47e890cec388796ad4ba3447ba84af73d4..107c17e35223c6734b5b0c25ea3495e8073e283b 100755 (executable)
@@ -236,10 +236,13 @@ if [[ -e /usr/lib/pam.d/systemd-run0 ]] || [[ -e /etc/pam.d/systemd-run0 ]]; the
     run0 ls /
     assert_eq "$(run0 echo foo)" "foo"
     # Check if we set some expected environment variables
-    for arg in "" "--user=root" "--user=testuser"; do
+    for arg in "" "--user=root" "--user=0" "--user=testuser"; do
         assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_USER')" "$USER"
         assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_UID')" "$(id -u "$USER")"
         assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $SUDO_GID')" "$(id -u "$USER")"
+
+        # Validate that we actually went properly through PAM (XDG_SESSION_TYPE is set by pam_systemd)
+        assert_eq "$(run0 ${arg:+"$arg"} bash -c 'echo $XDG_SESSION_TYPE')" "unspecified"
     done
     # Let's chain a couple of run0 calls together, for fun
     readarray -t cmdline < <(printf "%.0srun0\n" {0..31})