From 6602e0ddebac7386f1f00caea7b89a249ab5ae2a Mon Sep 17 00:00:00 2001 From: Wei Gao Date: Tue, 17 Dec 2024 05:59:40 -0500 Subject: [PATCH] ipsecbase.pm: check firewall status before stop firewall --- lib/ipsecbase.pm | 8 -------- lib/utils.pm | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/ipsecbase.pm b/lib/ipsecbase.pm index 8b441ffac497..151602ee77c2 100644 --- a/lib/ipsecbase.pm +++ b/lib/ipsecbase.pm @@ -112,12 +112,4 @@ sub pre_run_hook { $self->SUPER::pre_run_hook; } -sub ensure_service_disabled { - my ($service) = @_; - unless (systemctl "is-active " . $service, ignore_failure => 1) { # 0 if active, unless to revert - systemctl "disable --now " . $service; - record_info $service, "disabled"; - } -} - 1; diff --git a/lib/utils.pm b/lib/utils.pm index 11e0be8a894c..6046a7afffda 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -97,6 +97,7 @@ our @EXPORT = qw( is_efi_boot install_patterns common_service_action + ensure_service_disabled script_output_retry validate_script_output_retry get_secureboot_status @@ -2546,6 +2547,21 @@ sub common_service_action { } } +=head2 ensure_service_disabled + ensure_service_disabled(); + +Make sure service is disabled before test. + +=cut + +sub ensure_service_disabled { + my ($service) = @_; + unless (systemctl "is-active " . $service, ignore_failure => 1) { # 0 if active, unless to revert + systemctl "disable --now " . $service; + record_info $service, "disabled"; + } +} + sub get_secureboot_status { my $sbvar = '8be4df61-93ca-11d2-aa0d-00e098032b8c-SecureBoot'; my $ret;