summaryrefslogtreecommitdiffstats
path: root/test/units/testsuite-43.sh
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2022-03-09 03:07:34 +0100
committerLuca Boccassi <bluca@debian.org>2022-03-10 11:21:03 +0100
commitea63a260d43c27a6b5b5ae471a8d4617bb7be447 (patch)
treee6295e1c86974caabcf656b2bd2a9d30f69e47e6 /test/units/testsuite-43.sh
parenttest: set log level of user manager in TEST-43 to debug (diff)
downloadsystemd-ea63a260d43c27a6b5b5ae471a8d4617bb7be447.tar.xz
systemd-ea63a260d43c27a6b5b5ae471a8d4617bb7be447.zip
core: support MountAPIVFS and RootDirectory in user manager
The only piece missing was to somehow make /proc appear in the new user+mount namespace. It is not possible to mount a new /proc instance, not even with hidepid=invisible,subset=pid, in a user namespace unless a PID namespace is created too (and also at the same time as the other namespaces, it is not possible to mount a new /proc in a child process that creates a PID namespace forked from a parent that created a user+mount namespace, it has to happen at the same time). Use the host's /proc with a bind-mount as a fallback for this case. User session services would already run with it, so nothing is lost.
Diffstat (limited to '')
-rwxr-xr-xtest/units/testsuite-43.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/units/testsuite-43.sh b/test/units/testsuite-43.sh
index 3efe419377..cda1fe1fda 100755
--- a/test/units/testsuite-43.sh
+++ b/test/units/testsuite-43.sh
@@ -68,6 +68,24 @@ runas testuser systemd-run --wait --user --unit=test-group-fail \
-P true \
&& { echo 'unexpected success'; exit 1; }
+# Check that with a new user namespace we can bind mount
+# files and use a different root directory
+runas testuser systemd-run --wait --user --unit=test-bind-mount \
+ -p PrivateUsers=yes -p BindPaths=/dev/null:/etc/os-release \
+ test ! -s /etc/os-release
+
+unsquashfs -no-xattrs -d /tmp/img /usr/share/minimal_0.raw
+runas testuser systemd-run --wait --user --unit=test-root-dir \
+ -p PrivateUsers=yes -p RootDirectory=/tmp/img \
+ grep MARKER=1 /etc/os-release
+
+mkdir /tmp/img_bind
+mount --bind /tmp/img /tmp/img_bind
+runas testuser systemd-run --wait --user --unit=test-root-dir-bind \
+ -p PrivateUsers=yes -p RootDirectory=/tmp/img_bind \
+ grep MARKER=1 /etc/os-release
+umount /tmp/img_bind
+
systemd-analyze log-level info
echo OK >/testok