summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-07-15 23:07:52 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-07-16 09:42:17 +0200
commit5ac0dc70ff330a531539a92552fbeb0f542edfb5 (patch)
tree187f4f87c05801a9d822d14bfb91cf4b79c52f5b
parentmkosi: Disable unique debug source names (diff)
downloadsystemd-5ac0dc70ff330a531539a92552fbeb0f542edfb5.tar.xz
systemd-5ac0dc70ff330a531539a92552fbeb0f542edfb5.zip
TEST-13-NSPAWN: make sure we don't load libnss_systemd
Let's make sure we don't load libnss_systemd.so from bash as the necessary environment variables aren't set to make that work when we're running with sanitizers enabled. We can't add a sanitizer wrapper for bash as the wrapper runs using bash so you end up in a loop.
-rwxr-xr-xtest/units/TEST-13-NSPAWN.nspawn.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/units/TEST-13-NSPAWN.nspawn.sh b/test/units/TEST-13-NSPAWN.nspawn.sh
index c73b49b1a5..ee0fef8d06 100755
--- a/test/units/TEST-13-NSPAWN.nspawn.sh
+++ b/test/units/TEST-13-NSPAWN.nspawn.sh
@@ -179,6 +179,10 @@ elif [[ $1 == initgroups ]]; then
fi
EOF
chmod +x "$root/bin/getent"
+ # The useradd is important here so the user is added to /etc/passwd. If the user is not in /etc/passwd,
+ # bash will end up loading libnss_systemd.so which breaks when libnss_systemd.so is built with sanitizers
+ # as bash isn't invoked with the necessary environment variables for that.
+ useradd --root="$root" --uid 1000 --user-group --create-home testuser
systemd-nspawn --directory="$root" bash -xec '[[ $USER == root ]]'
systemd-nspawn --directory="$root" --user=testuser bash -xec '[[ $USER == testuser ]]'
@@ -672,8 +676,10 @@ fi
EOF
chmod +x "$root/bin/getent"
- mkdir -p "$root/home/testuser"
- chown 1010:1010 "$root/home/testuser"
+ # The useradd is important here so the user is added to /etc/passwd. If the user is not in /etc/passwd,
+ # bash will end up loading libnss_systemd.so which breaks when libnss_systemd.so is built with sanitizers
+ # as bash isn't invoked with the necessary environment variables for that.
+ useradd --root="$root" --uid 1010 --user-group --create-home testuser
cmd='PERMISSIONS=$(stat -c "%u:%g" /home/testuser/file); if [[ $PERMISSIONS != "1010:1010" ]]; then echo "*** wrong permissions: $PERMISSIONS"; return 1; fi; touch /home/testuser/other_file'
if ! SYSTEMD_LOG_TARGET=console \