mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
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.
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user