From 351113e21eecd730b33a2d73c1bb74eff9fcb845 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 29 Aug 2025 11:40:06 +0100 Subject: [PATCH] ovpnmain.cgi: Initialize some checkboxes when storing settiings This should hopefully resolve this problem: https://lists.ipfire.org/development/118761f0-24cd-4a62-b064-8d87dffc6b89@ipfire.org/ Signed-off-by: Michael Tremer --- html/cgi-bin/ovpnmain.cgi | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 6261e9968..0b2513174 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -211,6 +211,21 @@ sub deletebackupcert } } +# Writes the OpenVPN RW server settings and ensures that some values are set +sub writesettings() { + # Initialize TLSAUTH + if ($vpnsettings{"TLSAUTH"} eq "") { + $vpnsettings{"TLSAUTH"} = "off"; + } + + # Initialize MSSFIX + if ($vpnsettings{"MSSFIX"} eq "") { + $vpnsettings{"MSSFIX"} = "off"; + } + + &General::writehash("${General::swroot}/ovpn/settings", \%vpnsettings); +} + sub writeserverconf { # Do we require the OpenSSL Legacy Provider? my $requires_legacy_provider = 0; @@ -1067,7 +1082,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save-adv-options'}) { } if ($cgiparams{'MSSFIX'} ne 'on') { - delete $vpnsettings{'MSSFIX'}; + $vpnsettings{'MSSFIX'} = "off"; } else { $vpnsettings{'MSSFIX'} = $cgiparams{'MSSFIX'}; } @@ -1124,7 +1139,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save-adv-options'}) { } # Store our configuration - &General::writehash("${General::swroot}/ovpn/settings", \%vpnsettings); + &writesettings(); # Write the server configuration &writeserverconf(); @@ -1419,7 +1434,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save'} && $cgiparams{'TYPE'} eq '' && $cg $vpnsettings{'DOVPN_SUBNET'} = $cgiparams{'DOVPN_SUBNET'}; # Store our configuration - &General::writehash("${General::swroot}/ovpn/settings", \%vpnsettings); + &writesettings(); # Write the OpenVPN server configuration &writeserverconf(); @@ -1969,7 +1984,7 @@ END $vpnsettings{'ROOTCERT_CITY'} = $cgiparams{'ROOTCERT_CITY'}; $vpnsettings{'ROOTCERT_STATE'} = $cgiparams{'ROOTCERT_STATE'}; $vpnsettings{'ROOTCERT_COUNTRY'} = $cgiparams{'ROOTCERT_COUNTRY'}; - &General::writehash("${General::swroot}/ovpn/settings", \%vpnsettings); + &writesettings(); # Replace empty strings with a . (my $ou = $cgiparams{'ROOTCERT_OU'}) =~ s/^\s*$/\./; -- 2.47.3