]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ovpnmain.cgi: Initialize some checkboxes when storing settiings
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Aug 2025 10:40:06 +0000 (11:40 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Aug 2025 10:40:06 +0000 (11:40 +0100)
This should hopefully resolve this problem:

  https://lists.ipfire.org/development/118761f0-24cd-4a62-b064-8d87dffc6b89@ipfire.org/

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/ovpnmain.cgi

index 6261e9968d6c87b10b0f7cf6a78cff6ca86bdf9f..0b2513174d9ea45c40aed3d2ef746916f6c1151b 100644 (file)
@@ -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*$/\./;