]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/vpnmain.cgi
Hardcode theme to ipfire
[ipfire-2.x.git] / html / cgi-bin / vpnmain.cgi
index 1cd7cb84b3c81e44fc3dbd609acae2b358bf17e6..f200f1002d20b12db6c2f9aa71ae17c3df9014f2 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2019  IPFire Team  info@ipfire.org                       #
+# Copyright (C) 2007-2020  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -54,7 +54,7 @@ my $errormessage = '';
 my %color = ();
 my %mainsettings = ();
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
 
 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
 
@@ -604,7 +604,7 @@ END
                }
        }
 
-       if (ref ($cgiparams{'FH'}) ne 'Fh') {
+       unless (ref ($cgiparams{'FH'})) {
                $errormessage = $Lang::tr{'there was no file upload'};
                goto UPLOADCA_ERROR;
        }
@@ -689,12 +689,12 @@ END
                        my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/$cahash{$cgiparams{'KEY'}}[0]cert.pem ${General::swroot}/certs/$confighash{$key}[1]cert.pem`;
                        if ($test =~ /: OK/) {
                                # Delete connection
-                               system('/usr/local/bin/ipsecctrl', 'D', $key) if (&vpnenabled);
                                unlink ("${General::swroot}/certs/$confighash{$key}[1]cert.pem");
                                unlink ("${General::swroot}/certs/$confighash{$key}[1].p12");
                                delete $confighash{$key};
                                &General::writehasharray("${General::swroot}/vpn/config", \%confighash);
                                &writeipsecfiles();
+                               system('/usr/local/bin/ipsecctrl', 'D', $key) if (&vpnenabled);
                        }
                }
                unlink ("${General::swroot}/ca/$cahash{$cgiparams{'KEY'}}[0]cert.pem");
@@ -822,15 +822,17 @@ END
                        close IPADDR;
                        chomp ($ipaddr);
                        $cgiparams{'ROOTCERT_HOSTNAME'} = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0];
+                       $cgiparams{'SUBJECTALTNAME'} = "DNS:" . $cgiparams{'ROOTCERT_HOSTNAME'};
                        if ($cgiparams{'ROOTCERT_HOSTNAME'} eq '') {
                                $cgiparams{'ROOTCERT_HOSTNAME'} = $ipaddr;
+                               $cgiparams{'SUBJECTALTNAME'} = "IP:" . $cgiparams{'ROOTCERT_HOSTNAME'};
                        }
                }
                $cgiparams{'ROOTCERT_COUNTRY'} = $vpnsettings{'ROOTCERT_COUNTRY'} if (!$cgiparams{'ROOTCERT_COUNTRY'});
        } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'upload p12 file'}) {
                &General::log("ipsec", "Importing from p12...");
 
-               if (ref ($cgiparams{'FH'}) ne 'Fh') {
+               unless (ref ($cgiparams{'FH'})) {
                        $errormessage = $Lang::tr{'there was no file upload'};
                        goto ROOTCERT_ERROR;
                }
@@ -975,6 +977,11 @@ END
                #       IP: an IP address
                # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
 
+               if ($cgiparams{'SUBJECTALTNAME'} eq '') {
+                       $errormessage = $Lang::tr{'vpn subjectaltname missing'};
+                       goto ROOTCERT_ERROR;
+               }
+
                if ($cgiparams{'SUBJECTALTNAME'} ne '' && $cgiparams{'SUBJECTALTNAME'} !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/,\.\-_@]*$/) {
                        $errormessage = $Lang::tr{'vpn altname syntax'};
                        goto VPNCONF_ERROR;
@@ -1129,7 +1136,7 @@ END
        }
        print <<END
                </select></td></tr>
-       <tr><td class='base'>$Lang::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)</td>
+       <tr><td class='base'>$Lang::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)&nbsp;<img src='/blob.gif' alt='*' /></td>
        <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value='$cgiparams{'SUBJECTALTNAME'}' size='32' /></td></tr>
        <tr><td>&nbsp;</td>
                <td><br /><input type='submit' name='ACTION' value='$Lang::tr{'generate root/host certificates'}' /><br /><br /></td></tr>
@@ -1220,10 +1227,10 @@ END
                        &writeipsecfiles();
                        system('/usr/local/bin/ipsecctrl', 'S', $cgiparams{'KEY'}) if (&vpnenabled);
                } else {
-                       system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'}) if (&vpnenabled);
                        $confighash{$cgiparams{'KEY'}}[0] = 'off';
                        &General::writehasharray("${General::swroot}/vpn/config", \%confighash);
                        &writeipsecfiles();
+                       system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'}) if (&vpnenabled);
                }
                sleep $sleepDelay;
        } else {
@@ -1254,12 +1261,12 @@ END
        &General::readhasharray("${General::swroot}/vpn/config", \%confighash);
 
        if ($confighash{$cgiparams{'KEY'}}) {
-               system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'}) if (&vpnenabled);
                unlink ("${General::swroot}/certs/$confighash{$cgiparams{'KEY'}}[1]cert.pem");
                unlink ("${General::swroot}/certs/$confighash{$cgiparams{'KEY'}}[1].p12");
                delete $confighash{$cgiparams{'KEY'}};
                &General::writehasharray("${General::swroot}/vpn/config", \%confighash);
                &writeipsecfiles();
+               system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'}) if (&vpnenabled);
        } else {
                $errormessage = $Lang::tr{'invalid key'};
        }
@@ -1531,7 +1538,7 @@ END
                        $errormessage = $Lang::tr{'cant change certificates'};
                        goto VPNCONF_ERROR;
                }
-               if (ref ($cgiparams{'FH'}) ne 'Fh') {
+               unless (ref ($cgiparams{'FH'})) {
                        $errormessage = $Lang::tr{'there was no file upload'};
                        goto VPNCONF_ERROR;
                }
@@ -1568,7 +1575,7 @@ END
        } elsif ($cgiparams{'AUTH'} eq 'pkcs12') {
                &General::log("ipsec", "Importing from p12...");
 
-               if (ref ($cgiparams{'FH'}) ne 'Fh') {
+               unless (ref ($cgiparams{'FH'})) {
                        $errormessage = $Lang::tr{'there was no file upload'};
                        goto ROOTCERT_ERROR;
                }
@@ -1658,7 +1665,7 @@ END
                        $errormessage = $Lang::tr{'cant change certificates'};
                        goto VPNCONF_ERROR;
                }
-               if (ref ($cgiparams{'FH'}) ne 'Fh') {
+               unless (ref ($cgiparams{'FH'})) {
                        $errormessage = $Lang::tr{'there was no file upload'};
                        goto VPNCONF_ERROR;
                }
@@ -2377,8 +2384,8 @@ if(($cgiparams{'ACTION'} eq $Lang::tr{'advanced'}) ||
                        $errormessage = $Lang::tr{'invalid input for ike lifetime'};
                        goto ADVANCED_ERROR;
                }
-               if ($cgiparams{'IKE_LIFETIME'} < 1 || $cgiparams{'IKE_LIFETIME'} > 8) {
-                       $errormessage = $Lang::tr{'ike lifetime should be between 1 and 8 hours'};
+               if ($cgiparams{'IKE_LIFETIME'} < 1 || $cgiparams{'IKE_LIFETIME'} > 24) {
+                       $errormessage = $Lang::tr{'ike lifetime should be between 1 and 24 hours'};
                        goto ADVANCED_ERROR;
                }
                @temp = split('\|', $cgiparams{'ESP_ENCRYPTION'});
@@ -3012,6 +3019,7 @@ END
                ($line =~ /$confighash{$key}[1]\{.*INSTALLED/)) {
                        $col1="bgcolor='${Header::colourgreen}'";
                        $active = "<b><font color='#FFFFFF'>$Lang::tr{'capsopen'}</font></b>";
+                       last;
                } elsif ($line =~ /$confighash{$key}[1]\[.*CONNECTING/) {
                        $col1="bgcolor='${Header::colourorange}'";
                        $active = "<b><font color='#FFFFFF'>$Lang::tr{'vpn connecting'}</font></b>";