]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
ovpnmain.cgi: Drop newcleanssldatabase()
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 Mar 2024 15:32:33 +0000 (16:32 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 23 Sep 2024 11:07:15 +0000 (13:07 +0200)
I have no idea why this was added when there is a function that does the
same already. The remove function also had typos in the path which
probably resulted in it not working very well.

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

index f56b56909a5622d9358d11407158beb764a66ec1..d9e456756ccc303454b28209b2fdb8805190c838 100755 (executable)
@@ -147,42 +147,26 @@ sub iscertlegacy
        return 0;
 }
 
-sub cleanssldatabase
-{
-    if (open(FILE, ">${General::swroot}/ovpn/certs/serial")) {
-       print FILE "01";
-       close FILE;
-    }
-    if (open(FILE, ">${General::swroot}/ovpn/certs/index.txt")) {
-       print FILE "";
-       close FILE;
-    }
-    if (open(FILE, ">${General::swroot}/ovpn/certs/index.txt.attr")) {
-      print FILE "";
-      close FILE;
-    }
-    unlink ("${General::swroot}/ovpn/certs/index.txt.old");
-    unlink ("${General::swroot}/ovpn/certs/index.txt.attr.old");
-    unlink ("${General::swroot}/ovpn/certs/serial.old");
-    unlink ("${General::swroot}/ovpn/certs/01.pem");
-}
+sub cleanssldatabase() {
+       if (open(FILE, ">${General::swroot}/ovpn/certs/serial")) {
+               print FILE "01";
+               close FILE;
+       }
 
-sub newcleanssldatabase
-{
-    if (! -s "${General::swroot}/ovpn/certs/serial" )  {
-        open(FILE, ">${General::swroot}(ovpn/certs/serial");
-       print FILE "01";
-       close FILE;
-    }
-    if (! -s ">${General::swroot}/ovpn/certs/index.txt") {
-       &General::system("touch", "${General::swroot}/ovpn/certs/index.txt");
-    }
-    if (! -s ">${General::swroot}/ovpn/certs/index.txt.attr") {
-       &General::system("touch", "${General::swroot}/ovpn/certs/index.txt.attr");
-    }
-    unlink ("${General::swroot}/ovpn/certs/index.txt.old");
-    unlink ("${General::swroot}/ovpn/certs/index.txt.attr.old");
-    unlink ("${General::swroot}/ovpn/certs/serial.old");
+       if (open(FILE, ">${General::swroot}/ovpn/certs/index.txt")) {
+               print FILE "";
+               close FILE;
+       }
+
+       if (open(FILE, ">${General::swroot}/ovpn/certs/index.txt.attr")) {
+               print FILE "";
+               close FILE;
+       }
+
+       unlink("${General::swroot}/ovpn/certs/index.txt.old");
+       unlink("${General::swroot}/ovpn/certs/index.txt.attr.old");
+       unlink("${General::swroot}/ovpn/certs/serial.old");
+       unlink("${General::swroot}/ovpn/certs/01.pem");
 }
 
 sub deletebackupcert
@@ -1801,7 +1785,7 @@ END
            unlink ("${General::swroot}/ovpn/serverkey.pem");
            unlink ("${General::swroot}/ovpn/certs/serverreq.pem");
            unlink ("${General::swroot}/ovpn/certs/servercert.pem");
-           &newcleanssldatabase();
+           &cleanssldatabase();
            goto ROOTCERT_ERROR;
        } else {
            unlink ("${General::swroot}/ovpn/certs/serverreq.pem");
@@ -3963,7 +3947,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
                $errormessage = "$Lang::tr{'openssl produced an error'}: $?";
                unlink ($filename);
                unlink ("${General::swroot}/ovpn/certs/$cgiparams{'NAME'}cert.pem");
-               &newcleanssldatabase();
+               &cleanssldatabase();
                goto VPNCONF_ERROR;
            } else {
                unlink ($filename);
@@ -4191,7 +4175,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
                unlink ("${General::swroot}/ovpn/certs/$cgiparams{'NAME'}key.pem");
                unlink ("${General::swroot}/ovpn/certs/$cgiparams{'NAME'}req.pem");
                unlink ("${General::swroot}/ovpn/certs/$cgiparams{'NAME'}cert.pem");
-               &newcleanssldatabase();
+               &cleanssldatabase();
                goto VPNCONF_ERROR;
            } else {
                unlink ("${General::swroot}/ovpn/certs/$cgiparams{'NAME'}req.pem");