From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jun 2025 11:38:29 +0000 (+0200) Subject: test: drop ProtectHostnameEx, add one test for ProtectHostnameEx X-Git-Tag: v258-rc1~183^2~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9228d67dc8baf2cade5b9afc3f3b2a14dea72994;p=thirdparty%2Fsystemd.git test: drop ProtectHostnameEx, add one test for ProtectHostnameEx This is a separate commit because the parent commit is supposed to be backward compatible, i.e. the tests must pass with both the bogus ProtectHostnameEx name and ProtectHostname. A test is added for ProtectHostnameEx to verify that it is still accepted for backward compat. --- diff --git a/test/units/TEST-07-PID1.delegate-namespaces.sh b/test/units/TEST-07-PID1.delegate-namespaces.sh index 6d8d51caffe..3fd1287fb23 100755 --- a/test/units/TEST-07-PID1.delegate-namespaces.sh +++ b/test/units/TEST-07-PID1.delegate-namespaces.sh @@ -45,8 +45,8 @@ testcase_pid() { } testcase_uts() { - (! systemd-run -p PrivateUsersEx=self -p ProtectHostnameEx=private --wait --pipe -- hostname abc) - systemd-run -p PrivateUsersEx=self -p ProtectHostnameEx=private -p DelegateNamespaces=uts --wait --pipe -- hostname abc + (! systemd-run -p PrivateUsersEx=self -p ProtectHostname=private --wait --pipe -- hostname abc) + systemd-run -p PrivateUsersEx=self -p ProtectHostname=private -p DelegateNamespaces=uts --wait --pipe -- hostname abc } testcase_implied_private_users_self() { diff --git a/test/units/TEST-07-PID1.protect-hostname.sh b/test/units/TEST-07-PID1.protect-hostname.sh index 4633dab57ba..4a18fe5e217 100755 --- a/test/units/TEST-07-PID1.protect-hostname.sh +++ b/test/units/TEST-07-PID1.protect-hostname.sh @@ -22,7 +22,7 @@ testcase_yes() { (! systemd-run --wait -p ProtectHostname=yes hostname foo) # ProtectHostname=yes can optionally take a hostname. - systemd-run --wait -p ProtectHostnameEx=yes:hoge \ + systemd-run --wait -p ProtectHostname=yes:hoge \ -P bash -xec ' test "$(hostname)" = "hoge" (! hostname foo) @@ -50,10 +50,18 @@ EOF systemd-run --wait -p ProtectHostname=yes -p PrivateMounts=yes \ findmnt --mountpoint /proc/sys/kernel/hostname + + # Check that ProtectHostnameEx=… also works. + systemd-run --wait -p ProtectHostnameEx=yes:hoge \ + -P bash -xec ' + test "$(hostname)" = "hoge" + (! hostname foo) + test "$(hostname)" = "hoge" + ' } testcase_private() { - systemd-run --wait -p ProtectHostnameEx=private \ + systemd-run --wait -p ProtectHostname=private \ -P bash -xec ' hostname foo test "$(hostname)" = "foo" @@ -64,7 +72,7 @@ testcase_private() { test "$(hostnamectl hostname)" = "$HOSTNAME_FROM_SYSTEMD" # ProtectHostname=private can optionally take a hostname. - systemd-run --wait -p ProtectHostnameEx=private:hoge \ + systemd-run --wait -p ProtectHostname=private:hoge \ -P bash -xec ' test "$(hostname)" = "hoge" hostname foo @@ -91,7 +99,7 @@ EOF test "$(hostnamectl hostname)" = "$HOSTNAME_FROM_SYSTEMD" # Verify /proc/sys/kernel/hostname is not bind mounted from host read-only. - (! systemd-run --wait -p ProtectHostnameEx=private -p PrivateMounts=yes \ + (! systemd-run --wait -p ProtectHostname=private -p PrivateMounts=yes \ findmnt --mountpoint /proc/sys/kernel/hostname) } diff --git a/test/units/TEST-07-PID1.transient-unit-container.sh b/test/units/TEST-07-PID1.transient-unit-container.sh index f18e9ff112c..60316bf2fa6 100755 --- a/test/units/TEST-07-PID1.transient-unit-container.sh +++ b/test/units/TEST-07-PID1.transient-unit-container.sh @@ -157,7 +157,7 @@ testcase_transient_unit_container_file_write() { -p RootDirectory="$CONTAINER_ROOT_FS" \ -p PrivatePIDs=yes \ -p PrivateUsersEx=full \ - -p ProtectHostnameEx=private \ + -p ProtectHostname=private \ -p ProtectControlGroupsEx=private \ -p PrivateMounts=yes \ -p PrivateNetwork=yes \