diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-07-15 16:26:04 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-07-15 16:33:52 +0200 |
commit | d6ac8e57453040d9f6523098fe3f969cecf32e9d (patch) | |
tree | bbb1f8a89d61a3d4787968bfcfcc64f99f9fcec3 /tests | |
parent | 0660f4ca87c4c978589f923e0e2d0eca856be6b4 (diff) | |
download | alpine-conf-d6ac8e57453040d9f6523098fe3f969cecf32e9d.zip |
setup-alpine: ensure unintentional ssh diconnect
Avoid restart network when running over ssh. hostname is now a
dependency of networking so openrc will restart networking together with
hostname, which may lead to disconnection when running over ssh.
Solve this by only restart hostname if SSH_CONNECTION is empty.
fixes https://gitlab.alpinelinux.org/alpine/aports/-/issues/14018
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/setup_alpine_test | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/setup_alpine_test b/tests/setup_alpine_test index 1bde901..903d220 100755 --- a/tests/setup_alpine_test +++ b/tests/setup_alpine_test @@ -5,7 +5,8 @@ init_tests \ setup_alpine_usage \ setup_alpine_quick \ setup_alpine_create_answerfile \ - setup_alpine_kvm_clock + setup_alpine_kvm_clock \ + setup_alpine_restart_network setup_alpine_usage_body() { test_usage setup-alpine @@ -23,6 +24,11 @@ setup_alpine_quick_body() { -o match:"openrc default" \ -e empty \ setup-alpine -q + + atf_check -s exit:0 \ + rc-service --quiet hostname status + atf_check -s exit:0 \ + rc-service --quiet networking status } setup_alpine_create_answerfile_body() { @@ -84,3 +90,21 @@ setup_alpine_kvm_clock_body() { -o not-match:"Which NTP client to run" \ setup-alpine -e < answers } + +setup_alpine_restart_network_body() { + init_env + mkdir -p sys/class/net/lo sys/class/net/eth0 + echo 1 >sys/class/net/lo/ifindex + echo 2 >sys/class/net/eth0/ifindex + echo down >sys/class/net/lo/operstate + echo down >sys/class/net/eth0/operstate + + SSH_CONNECTION="::1 54984 ::1 22" atf_check -s exit:0 \ + -o match:"openrc boot" \ + -e empty \ + setup-alpine -q + atf_check -s exit:3 \ + rc-service --quiet hostname status + atf_check -s exit:3 \ + rc-service --quiet networking status +} |