]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: use proper service type of TEST-07-PID.user-namespace-path.sh
authorQuentin Deslandes <qde@naccy.de>
Tue, 4 Nov 2025 13:45:15 +0000 (14:45 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 4 Nov 2025 15:54:06 +0000 (15:54 +0000)
TEST-07-PID.user-namespace-path.sh is flaky as Type=simple is used
(implicitly), explicitly use Type=exec instead to ensure the namespaces
are created before starting another service reusing the same namespaces.

Fixes #39546.

test/units/TEST-07-PID1.user-namespace-path.sh

index ebc8f00baf94f64cdd965edf9ef5f5d255015a10..437968e8c25315178fbf36f54ab3b52b6ba958ec 100755 (executable)
@@ -16,12 +16,10 @@ if [ -f /usr/lib/systemd/systemd-asan-env ]; then
 fi
 
 # Only reuse the user namespace
-systemd-run --unit=oldservice --property=PrivateUsers=true sleep 3600
-sleep .2
+systemd-run --unit=oldservice --property=Type=exec --property=PrivateUsers=true sleep 3600
 OLD_PID=$(systemctl show oldservice -p MainPID | awk -F= '{print $2}')
 
-systemd-run --unit=newservice --property=UserNamespacePath=/proc/"$OLD_PID"/ns/user --property=PrivateNetwork=true sleep 3600
-sleep .2
+systemd-run --unit=newservice --property=Type=exec --property=UserNamespacePath=/proc/"$OLD_PID"/ns/user --property=PrivateNetwork=true sleep 3600
 NEW_PID=$(systemctl show newservice -p MainPID | awk -F= '{print $2}')
 
 assert_neq "$(lsns -p "$OLD_PID" -o NS -t net -n)" "$(lsns -p "$NEW_PID" -o NS -t net -n)"
@@ -30,12 +28,10 @@ assert_eq "$(lsns -p "$OLD_PID" -o NS -t user -n)" "$(lsns -p "$NEW_PID" -o NS -
 systemctl stop oldservice newservice
 
 # Reuse the user and network namespaces
-systemd-run --unit=oldservice --property=PrivateUsers=true --property=PrivateNetwork=true sleep 3600
-sleep .2
+systemd-run --unit=oldservice --property=Type=exec --property=PrivateUsers=true --property=PrivateNetwork=true sleep 3600
 OLD_PID=$(systemctl show oldservice -p MainPID | awk -F= '{print $2}')
 
-systemd-run --unit=newservice --property=UserNamespacePath=/proc/"$OLD_PID"/ns/user --property=NetworkNamespacePath=/proc/"$OLD_PID"/ns/net sleep 3600
-sleep .2
+systemd-run --unit=newservice --property=Type=exec --property=UserNamespacePath=/proc/"$OLD_PID"/ns/user --property=NetworkNamespacePath=/proc/"$OLD_PID"/ns/net sleep 3600
 NEW_PID=$(systemctl show newservice -p MainPID | awk -F= '{print $2}')
 
 assert_eq "$(lsns -p "$OLD_PID" -o NS -t net -n)" "$(lsns -p "$NEW_PID" -o NS -t net -n)"
@@ -44,12 +40,10 @@ assert_eq "$(lsns -p "$OLD_PID" -o NS -t user -n)" "$(lsns -p "$NEW_PID" -o NS -
 systemctl stop oldservice newservice
 
 # Delegate the network namespace
-systemd-run --unit=oldservice --property=PrivateUsers=true sleep 3600
-sleep .2
+systemd-run --unit=oldservice --property=Type=exec --property=PrivateUsers=true sleep 3600
 OLD_PID=$(systemctl show oldservice -p MainPID | awk -F= '{print $2}')
 
-systemd-run --unit=newservice --property=UserNamespacePath=/proc/"$OLD_PID"/ns/user --property=DelegateNamespaces=net --property=PrivateNetwork=true sleep 3600
-sleep .2
+systemd-run --unit=newservice --property=Type=exec --property=UserNamespacePath=/proc/"$OLD_PID"/ns/user --property=DelegateNamespaces=net --property=PrivateNetwork=true sleep 3600
 NEW_PID=$(systemctl show newservice -p MainPID | awk -F= '{print $2}')
 
 assert_neq "$(lsns -p "$OLD_PID" -o NS -t net -n)" "$(lsns -p "$NEW_PID" -o NS -t net -n)"