]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-74-AUX-UTILS: Skip run0 test if pam snippet is not installed
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 3 May 2024 12:09:27 +0000 (14:09 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 6 May 2024 09:57:09 +0000 (11:57 +0200)
test/units/testsuite-74.run.sh

index 4f3c967e2cf249617f1b5b6d995e1f1f3c6bf00f..b4ff72e440da5a5cbfc462287bd56f68875a4c40 100755 (executable)
@@ -231,15 +231,17 @@ assert_eq "$KVER" "$UNIT_KVER"
 umount /proc/version
 rm -f "$TMP_KVER"
 
-# Check that invoking the tool under the run0 alias name works
-run0 ls /
-assert_eq "$(run0 echo foo)" "foo"
-# Check if we set some expected environment variables
-for arg in "" "--user=root" "--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")"
-done
-# Let's chain a couple of run0 calls together, for fun
-readarray -t cmdline < <(printf "%.0srun0\n" {0..31})
-assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"
+if [[ -e /usr/lib/pam.d/systemd-run0 ]] || [[ -e /etc/pam.d/systemd-run0 ]]; then
+    # Check that invoking the tool under the run0 alias name works
+    run0 ls /
+    assert_eq "$(run0 echo foo)" "foo"
+    # Check if we set some expected environment variables
+    for arg in "" "--user=root" "--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")"
+    done
+    # Let's chain a couple of run0 calls together, for fun
+    readarray -t cmdline < <(printf "%.0srun0\n" {0..31})
+    assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"
+fi