]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-74-AUX-UTILS: add tests for 'run0 -D' 34771/head
authorJohn A. Leuenhagen <john@zlima12.com>
Tue, 15 Oct 2024 06:00:18 +0000 (02:00 -0400)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Oct 2024 09:59:44 +0000 (18:59 +0900)
test/test-functions
test/units/TEST-74-AUX-UTILS.run.sh

index 269cd8812bfe588dde23d9641324f43537b4d407..8a4cc55626119b2baa155591a3a596f718b5c461 100644 (file)
@@ -211,6 +211,7 @@ BASICTOOLS=(
     ping
     pkill
     ps
+    pwd
     readlink
     realpath
     rev
index 9e0a429e414b60c5d272f9f53232562ae904aad1..5b46e11409b814308e521e99d2b625d044c7ddb1 100755 (executable)
@@ -246,4 +246,16 @@ if [[ -e /usr/lib/pam.d/systemd-run0 ]] || [[ -e /etc/pam.d/systemd-run0 ]]; the
     # 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"
+
+    # Tests for working directory, especially for specifying "/" (see PR #34771).
+    cd /
+    assert_eq "$(run0 pwd)" "/"
+    assert_eq "$(run0 -D /tmp pwd)" "/tmp"
+    assert_eq "$(run0 --user=testuser pwd)" "/home/testuser"
+    assert_eq "$(run0 -D /tmp --user=testuser pwd)" "/tmp"
+    cd /tmp
+    assert_eq "$(run0 pwd)" "/tmp"
+    assert_eq "$(run0 -D / pwd)" "/"
+    assert_eq "$(run0 --user=testuser pwd)" "/home/testuser"
+    assert_eq "$(run0 -D / --user=testuser pwd)" "/"
 fi