From ebdd4d59b4021b59571652e8bf2fff9843ae23b1 Mon Sep 17 00:00:00 2001 From: Vincent Li Date: Mon, 1 Jul 2024 00:16:30 +0000 Subject: [PATCH] keepalived UI: remove @nosaved item remove @nosaved item from form submission before writehash to each setting file because it could interfere with each other. for example, when change keepalived configuration for green or red interface from the UI, without removing @nosaved which has 'ENABLE_HA' before writehash, 'ENABLE_HA=off' would be saved in '/var/ipfire/keepalived/settings', this would trigger the UI to show keepalived being "STOPPED" or it could actually stopoped keepalived. Signed-off-by: Vincent Li --- html/cgi-bin/keepalived.cgi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/html/cgi-bin/keepalived.cgi b/html/cgi-bin/keepalived.cgi index 434e2b6a6..82fcaaec4 100644 --- a/html/cgi-bin/keepalived.cgi +++ b/html/cgi-bin/keepalived.cgi @@ -43,7 +43,8 @@ my $runsetting = "${General::swroot}/keepalived/runsettings"; my $loxilbipfile = "${General::swroot}/loxilb/ipconfig"; # because we need commas in the some data my $errormessage = ''; -my @nosaved=(); +#remove 'ENABLE_HA' from '/var/ipfire/keepalived/settings' as it could affect keepalived running state +my @nosaved=('ENABLE_HA'); my %color = (); $hasettings{'ENABLE_HA'} = 'off'; @@ -82,6 +83,11 @@ foreach my $itf (@ITFs) { if ($hasettings{'ACTION'} eq $Lang::tr{'enable'}) { + #remove @nosaved from $hasettings before writehash to 'runsettings' file since 'runsetting' is only for keepalived running state + foreach my $itf (@ITFs) { + my @nosaved = ("virtual_router_id_${itf}", "priority_${itf}", "unicast_peer_${itf}", "auth_pass_${itf}", "garp_master_delay_${itf}", "advert_int_${itf}", "virtual_ipaddress_${itf}", "state_${itf}", "ENABLE_${itf}"); + map (delete ($hasettings{$_}) ,(@nosaved)); + } &General::writehash("$runsetting", \%hasettings); if ($hasettings{'ENABLE_HA'} eq 'on') { &General::system('/usr/bin/touch', "${General::swroot}/keepalived/enable_ha");