mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
vpnmain.cgi - Replace spaces with tab characters and fix indentation
Replaced spaces with tab characters. Fixed indentation. This is based on http://patchwork.ipfire.org/patch/88/ so that patch must be applied before. Signed-off-by: Lars Schuhmacher <larsen007@web.de> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
committed by
Michael Tremer
parent
ed1d0fbdbe
commit
624615ee07
@@ -40,8 +40,7 @@ undef (@dummy);
|
||||
###
|
||||
### Initialize variables
|
||||
###
|
||||
my $sleepDelay = 4; # after a call to ipsecctrl S or R, wait this delay (seconds) before reading status
|
||||
# (let the ipsec do its job)
|
||||
my $sleepDelay = 4; # after a call to ipsecctrl S or R, wait this delay (seconds) before reading status (let the ipsec do its job)
|
||||
my %netsettings=();
|
||||
our %cgiparams=();
|
||||
our %vpnsettings=();
|
||||
@@ -136,10 +135,9 @@ sub vpnenabled {
|
||||
}
|
||||
###
|
||||
### old version: maintain serial number to one, without explication.
|
||||
### this : let the counter go, so that each cert is numbered.
|
||||
### this: let the counter go, so that each cert is numbered.
|
||||
###
|
||||
sub cleanssldatabase
|
||||
{
|
||||
sub cleanssldatabase {
|
||||
if (open(FILE, ">${General::swroot}/certs/serial")) {
|
||||
print FILE "01";
|
||||
close FILE;
|
||||
@@ -152,8 +150,7 @@ sub cleanssldatabase
|
||||
unlink ("${General::swroot}/certs/serial.old");
|
||||
unlink ("${General::swroot}/certs/01.pem");
|
||||
}
|
||||
sub newcleanssldatabase
|
||||
{
|
||||
sub newcleanssldatabase {
|
||||
if (! -s "${General::swroot}/certs/serial" ) {
|
||||
open(FILE, ">${General::swroot}/certs/serial");
|
||||
print FILE "01";
|
||||
@@ -288,8 +285,8 @@ sub writeipsecfiles {
|
||||
print CONF "\tleftsubnet=$cidr_net\n";
|
||||
print CONF "\tleftfirewall=yes\n";
|
||||
print CONF "\tlefthostaccess=yes\n";
|
||||
|
||||
print CONF "\tright=$lconfighash{$key}[10]\n";
|
||||
|
||||
if ($lconfighash{$key}[3] eq 'net') {
|
||||
my $cidr_net=&General::ipcidr($lconfighash{$key}[11]);
|
||||
print CONF "\trightsubnet=$cidr_net\n";
|
||||
@@ -349,6 +346,7 @@ sub writeipsecfiles {
|
||||
if (! $lconfighash{$key}[29]) {
|
||||
$lconfighash{$key}[29] = "ikev1";
|
||||
}
|
||||
|
||||
print CONF "\tkeyexchange=$lconfighash{$key}[29]\n";
|
||||
|
||||
# Lifetimes
|
||||
@@ -417,7 +415,7 @@ sub writeipsecfiles {
|
||||
print CONF "\tfragmentation=yes\n";
|
||||
|
||||
print CONF "\n";
|
||||
}#foreach key
|
||||
} #foreach key
|
||||
|
||||
# Add post user includes to config file
|
||||
# After the GUI-connections allows to patch connections.
|
||||
@@ -442,6 +440,7 @@ if ($ENV{"REMOTE_ADDR"} eq "") {
|
||||
###
|
||||
if ($cgiparams{'ACTION'} eq $Lang::tr{'save'} && $cgiparams{'TYPE'} eq '' && $cgiparams{'KEY'} eq '') {
|
||||
&General::readhash("${General::swroot}/vpn/settings", \%vpnsettings);
|
||||
|
||||
unless (&General::validfqdn($cgiparams{'VPN_IP'}) || &General::validip($cgiparams{'VPN_IP'})
|
||||
|| $cgiparams{'VPN_IP'} eq '%defaultroute' ) {
|
||||
$errormessage = $Lang::tr{'invalid input for hostname'};
|
||||
@@ -509,8 +508,8 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save'} && $cgiparams{'TYPE'} eq '' && $cg
|
||||
<tr>
|
||||
<td align='center'>
|
||||
<input type='hidden' name='AREUSURE' value='yes' />
|
||||
<b><font color='${Header::colourred}'>$Lang::tr{'capswarning'}</font></b>:
|
||||
$Lang::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
|
||||
<b><font color='${Header::colourred}'>$Lang::tr{'capswarning'}</font></b>: $Lang::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td align='center'>
|
||||
<input type='submit' name='ACTION' value='$Lang::tr{'remove x509'}' />
|
||||
@@ -519,7 +518,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save'} && $cgiparams{'TYPE'} eq '' && $cg
|
||||
</table>
|
||||
</form>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
@@ -684,8 +683,7 @@ END
|
||||
<input type='hidden' name='AREUSURE' value='yes' /></td>
|
||||
</tr><tr>
|
||||
<td align='center'>
|
||||
<b><font color='${Header::colourred}'>$Lang::tr{'capswarning'}</font></b>
|
||||
$Lang::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}</td>
|
||||
<b><font color='${Header::colourred}'>$Lang::tr{'capswarning'}</font></b> $Lang::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}</td>
|
||||
</tr><tr>
|
||||
<td align='center'>
|
||||
<input type='submit' name='ACTION' value='$Lang::tr{'remove ca certificate'}' />
|
||||
@@ -694,7 +692,7 @@ END
|
||||
</table>
|
||||
</form>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
@@ -1070,7 +1068,7 @@ END
|
||||
<tr><td class='base'>$Lang::tr{'country'}:</td>
|
||||
<td class='base'><select name='ROOTCERT_COUNTRY'>
|
||||
END
|
||||
;
|
||||
;
|
||||
foreach my $country (sort keys %{Countries::countries}) {
|
||||
print "<option value='$Countries::countries{$country}'";
|
||||
if ( $Countries::countries{$country} eq $cgiparams{'ROOTCERT_COUNTRY'} ) {
|
||||
@@ -1099,7 +1097,7 @@ END
|
||||
<img src='/blob.gif' alt='*' /> $Lang::tr{'required field'}</td></tr>
|
||||
</table></form>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
@@ -1237,7 +1235,7 @@ END
|
||||
</tr>
|
||||
</table></form>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
@@ -1797,7 +1795,7 @@ END
|
||||
$confighash{$key}[27] = $cgiparams{'DPD_ACTION'};
|
||||
$confighash{$key}[29] = $cgiparams{'IKE_VERSION'};
|
||||
|
||||
#dont forget advanced value
|
||||
# don't forget advanced value
|
||||
$confighash{$key}[18] = $cgiparams{'IKE_ENCRYPTION'};
|
||||
$confighash{$key}[19] = $cgiparams{'IKE_INTEGRITY'};
|
||||
$confighash{$key}[20] = $cgiparams{'IKE_GROUPTYPE'};
|
||||
@@ -1814,7 +1812,7 @@ END
|
||||
$confighash{$key}[31] = $cgiparams{'DPD_DELAY'};
|
||||
$confighash{$key}[32] = $cgiparams{'FORCE_MOBIKE'};
|
||||
|
||||
#free unused fields!
|
||||
# free unused fields!
|
||||
$confighash{$key}[6] = 'off';
|
||||
$confighash{$key}[15] = 'off';
|
||||
|
||||
@@ -1829,7 +1827,7 @@ END
|
||||
$cgiparams{'ACTION'} = $Lang::tr{'advanced'};
|
||||
}
|
||||
goto VPNCONF_END;
|
||||
} else { # add new connection
|
||||
} else { # add new connection
|
||||
$cgiparams{'ENABLED'} = 'on';
|
||||
if ( ! -f "${General::swroot}/private/cakey.pem" ) {
|
||||
$cgiparams{'AUTH'} = 'psk';
|
||||
@@ -1838,7 +1836,7 @@ END
|
||||
} else {
|
||||
$cgiparams{'AUTH'} = 'certgen';
|
||||
}
|
||||
$cgiparams{'LOCAL_SUBNET'} ="$netsettings{'GREEN_NETADDRESS'}/$netsettings{'GREEN_NETMASK'}";
|
||||
$cgiparams{'LOCAL_SUBNET'} = "$netsettings{'GREEN_NETADDRESS'}/$netsettings{'GREEN_NETMASK'}";
|
||||
$cgiparams{'CERT_EMAIL'} = $vpnsettings{'ROOTCERT_EMAIL'};
|
||||
$cgiparams{'CERT_OU'} = $vpnsettings{'ROOTCERT_OU'};
|
||||
$cgiparams{'CERT_ORGANIZATION'} = $vpnsettings{'ROOTCERT_ORGANIZATION'};
|
||||
@@ -1886,9 +1884,9 @@ END
|
||||
$cgiparams{'COMPRESSION'} = 'on'; #[13];
|
||||
$cgiparams{'ONLY_PROPOSED'} = 'off'; #[24];
|
||||
$cgiparams{'PFS'} = 'on'; #[28];
|
||||
}
|
||||
}
|
||||
|
||||
VPNCONF_ERROR:
|
||||
VPNCONF_ERROR:
|
||||
$checked{'ENABLED'}{'off'} = '';
|
||||
$checked{'ENABLED'}{'on'} = '';
|
||||
$checked{'ENABLED'}{$cgiparams{'ENABLED'}} = "checked='checked'";
|
||||
@@ -1942,7 +1940,7 @@ END
|
||||
<input type='hidden' name='DPD_TIMEOUT' value='$cgiparams{'DPD_TIMEOUT'}' />
|
||||
<input type='hidden' name='FORCE_MOBIKE' value='$cgiparams{'FORCE_MOBIKE'}' />
|
||||
END
|
||||
;
|
||||
;
|
||||
if ($cgiparams{'KEY'}) {
|
||||
print "<input type='hidden' name='KEY' value='$cgiparams{'KEY'}' />";
|
||||
print "<input type='hidden' name='NAME' value='$cgiparams{'NAME'}' />";
|
||||
@@ -2010,7 +2008,7 @@ EOF
|
||||
</td>
|
||||
</tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
if (!$cgiparams{'KEY'}) {
|
||||
print "<tr><td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked{'EDIT_ADVANCED'}{'on'} /> $Lang::tr{'edit advanced settings when done'}</td></tr>";
|
||||
}
|
||||
@@ -2026,7 +2024,7 @@ END
|
||||
</tr>
|
||||
</table>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
} elsif (! $cgiparams{'KEY'}) {
|
||||
my $cakeydisabled = ( ! -f "${General::swroot}/private/cakey.pem" ) ? "disabled='disabled'" : '';
|
||||
@@ -2074,7 +2072,7 @@ END
|
||||
<td class='base'>$Lang::tr{'country'}:</td>
|
||||
<td class='base'><select name='CERT_COUNTRY' $cakeydisabled>
|
||||
END
|
||||
;
|
||||
;
|
||||
foreach my $country (sort keys %{Countries::countries}) {
|
||||
print "\t\t\t<option value='$Countries::countries{$country}'";
|
||||
if ( $Countries::countries{$country} eq $cgiparams{'CERT_COUNTRY'} ) {
|
||||
@@ -2094,7 +2092,7 @@ END
|
||||
<td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value='$cgiparams{'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
|
||||
</table>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
}
|
||||
|
||||
@@ -2206,12 +2204,10 @@ if(($cgiparams{'ACTION'} eq $Lang::tr{'advanced'}) ||
|
||||
goto ADVANCED_ERROR;
|
||||
}
|
||||
|
||||
if (
|
||||
($cgiparams{'COMPRESSION'} !~ /^(|on|off)$/) ||
|
||||
if (($cgiparams{'COMPRESSION'} !~ /^(|on|off)$/) ||
|
||||
($cgiparams{'FORCE_MOBIKE'} !~ /^(|on|off)$/) ||
|
||||
($cgiparams{'ONLY_PROPOSED'} !~ /^(|on|off)$/) ||
|
||||
($cgiparams{'PFS'} !~ /^(|on|off)$/)
|
||||
){
|
||||
($cgiparams{'PFS'} !~ /^(|on|off)$/)) {
|
||||
$errormessage = $Lang::tr{'invalid input'};
|
||||
goto ADVANCED_ERROR;
|
||||
}
|
||||
@@ -2278,7 +2274,6 @@ if(($cgiparams{'ACTION'} eq $Lang::tr{'advanced'}) ||
|
||||
if (!$cgiparams{'DPD_TIMEOUT'}) {
|
||||
$cgiparams{'DPD_TIMEOUT'} = 120;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ADVANCED_ERROR:
|
||||
@@ -2613,7 +2608,7 @@ if(($cgiparams{'ACTION'} eq $Lang::tr{'advanced'}) ||
|
||||
</td>
|
||||
</tr>
|
||||
EOF
|
||||
;
|
||||
;
|
||||
|
||||
print <<EOF;
|
||||
<tr>
|
||||
@@ -2696,7 +2691,7 @@ EOF
|
||||
<td width='20%' class='base'>$Lang::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked{'ENABLED'} /></td>
|
||||
</tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
print <<END
|
||||
<tr>
|
||||
<td class='base' nowrap='nowrap'>$Lang::tr{'vpn delayed start'}: <img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /></td>
|
||||
@@ -2737,7 +2732,7 @@ END
|
||||
<th class='boldbase' align='center' colspan='6'><b>$Lang::tr{'action'}</b></th>
|
||||
</tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
my $id = 0;
|
||||
my $gif;
|
||||
foreach my $key (sort { ncmp ($confighash{$a}[1],$confighash{$b}[1]) } keys %confighash) {
|
||||
@@ -2765,13 +2760,12 @@ END
|
||||
my $active = "<b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b>";
|
||||
foreach my $line (@status) {
|
||||
if (($line =~ /\"$confighash{$key}[1]\".*IPsec SA established/) ||
|
||||
($line =~ /$confighash{$key}[1]\{.*INSTALLED/))
|
||||
{
|
||||
($line =~ /$confighash{$key}[1]\{.*INSTALLED/)) {
|
||||
$col1="bgcolor='${Header::colourgreen}'";
|
||||
$active = "<b><font color='#FFFFFF'>$Lang::tr{'capsopen'}</font></b>";
|
||||
}
|
||||
}
|
||||
# move to blueif really down
|
||||
# move to blue if really down
|
||||
if ($confighash{$key}[0] eq 'off' && $col1 =~ /${Header::colourred}/ ) {
|
||||
$col1="bgcolor='${Header::colourblue}'";
|
||||
$active = "<b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b>";
|
||||
@@ -2786,7 +2780,7 @@ END
|
||||
</form>
|
||||
</td>
|
||||
END
|
||||
;
|
||||
;
|
||||
if (($confighash{$key}[4] eq 'cert') && ($confighash{$key}[2] ne '%auth-dn')) {
|
||||
print <<END
|
||||
<td align='center' $col>
|
||||
@@ -2797,7 +2791,8 @@ END
|
||||
</form>
|
||||
</td>
|
||||
END
|
||||
; } else {
|
||||
;
|
||||
} else {
|
||||
print "<td width='2%' $col> </td>";
|
||||
}
|
||||
if ($confighash{$key}[4] eq 'cert' && -f "${General::swroot}/certs/$confighash{$key}[1].p12") {
|
||||
@@ -2810,7 +2805,8 @@ END
|
||||
</form>
|
||||
</td>
|
||||
END
|
||||
; } elsif (($confighash{$key}[4] eq 'cert') && ($confighash{$key}[2] ne '%auth-dn')) {
|
||||
;
|
||||
} elsif (($confighash{$key}[4] eq 'cert') && ($confighash{$key}[2] ne '%auth-dn')) {
|
||||
print <<END
|
||||
<td align='center' $col>
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
@@ -2820,7 +2816,8 @@ END
|
||||
</form>
|
||||
</td>
|
||||
END
|
||||
; } else {
|
||||
;
|
||||
} else {
|
||||
print "<td width='2%' $col> </td>";
|
||||
}
|
||||
print <<END
|
||||
@@ -2848,7 +2845,7 @@ END
|
||||
</td>
|
||||
</tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
$id++;
|
||||
}
|
||||
print "</table>";
|
||||
@@ -2879,7 +2876,7 @@ END
|
||||
</tr>
|
||||
</table>
|
||||
END
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
print <<END
|
||||
@@ -2891,7 +2888,7 @@ END
|
||||
</td></tr>
|
||||
</table>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
|
||||
&Header::openbox('100%', 'left', "$Lang::tr{'certificate authorities'}");
|
||||
@@ -2903,7 +2900,7 @@ END
|
||||
<th width='10%' class='boldbase' colspan='3' align='center'><b>$Lang::tr{'action'}</b></th>
|
||||
</tr>
|
||||
EOF
|
||||
;
|
||||
;
|
||||
my $col1="bgcolor='$color{'color22'}'";
|
||||
my $col2="bgcolor='$color{'color20'}'";
|
||||
if (-f "${General::swroot}/ca/cacert.pem") {
|
||||
@@ -2926,7 +2923,7 @@ EOF
|
||||
</td>
|
||||
<td width='4%' $col1> </td></tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
} else {
|
||||
# display rootcert generation buttons
|
||||
print <<END
|
||||
@@ -2935,7 +2932,7 @@ END
|
||||
<td class='base' $col1>$Lang::tr{'not present'}</td>
|
||||
<td colspan='3' $col1> </td></tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
if (-f "${General::swroot}/certs/hostcert.pem") {
|
||||
@@ -2959,7 +2956,7 @@ END
|
||||
</td>
|
||||
<td width='4%' $col2> </td></tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
} else {
|
||||
# Nothing
|
||||
print <<END
|
||||
@@ -2968,7 +2965,7 @@ END
|
||||
<td class='base' $col2>$Lang::tr{'not present'}</td>
|
||||
<td colspan='3' $col2> </td></tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
my $rowcolor = 0;
|
||||
@@ -3007,7 +3004,7 @@ END
|
||||
</td>
|
||||
</tr>
|
||||
END
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
print "</table>";
|
||||
@@ -3023,7 +3020,7 @@ END
|
||||
<td class='base'>$Lang::tr{'download certificate'}</td>
|
||||
</tr></table>
|
||||
END
|
||||
;
|
||||
;
|
||||
}
|
||||
my $createCA = -f "${General::swroot}/ca/cacert.pem" ? '' : "<tr><td colspan='3'></td><td><input type='submit' name='ACTION' value='$Lang::tr{'generate root/host certificates'}' /></td></tr>";
|
||||
print <<END
|
||||
@@ -3045,7 +3042,7 @@ END
|
||||
</table>
|
||||
</form>
|
||||
END
|
||||
;
|
||||
;
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
|
||||
Reference in New Issue
Block a user