ovpnmain.cgi: Fix remote IP address validation.

This commit is contained in:
Michael Tremer
2013-08-19 17:33:23 +02:00
parent 3765eb6179
commit 86228a56ef

View File

@@ -3604,36 +3604,34 @@ if ($cgiparams{'TYPE'} eq 'net') {
} }
# Check if a remote host/IP has been set for the client. # Check if a remote host/IP has been set for the client.
if ($cgiparams{'REMOTE'} eq '' && $cgiparams{'SIDE'} ne 'server') { if ($cgiparams{'TYPE'} eq 'net') {
if ($cgiparams{'SIDE'} ne 'server' && $cgiparams{'REMOTE'} eq '') {
$errormessage = $Lang::tr{'invalid input for remote host/ip'}; $errormessage = $Lang::tr{'invalid input for remote host/ip'};
# Check if this is a N2N connection and drop temporary config. # Check if this is a N2N connection and drop temporary config.
if ($cgiparams{'TYPE'} eq 'net') {
unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!"; unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!"; rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
}
goto VPNCONF_ERROR; goto VPNCONF_ERROR;
} }
# Check if a remote host/IP has been configured - the field can be empty on the server side. # Check if a remote host/IP has been configured - the field can be empty on the server side.
if ($cgiparams{'REMOTE'} ne '') { if ($cgiparams{'REMOTE'} ne '') {
# Check if the given IP is valid - otherwise check if it is a valid domain. # Check if the given IP is valid - otherwise check if it is a valid domain.
if (! &General::validip($cgiparams{'REMOTE'})) { if (! &General::validip($cgiparams{'REMOTE'})) {
# Check for a valid domain. # Check for a valid domain.
if (! &General::validfqdn ($cgiparams{'REMOTE'})) { if (! &General::validfqdn ($cgiparams{'REMOTE'})) {
$errormessage = $Lang::tr{'invalid input for remote host/ip'}; $errormessage = $Lang::tr{'invalid input for remote host/ip'};
# Check if this is a N2N connection and drop temporary config. # Check if this is a N2N connection and drop temporary config.
if ($cgiparams{'TYPE'} eq 'net') {
unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!"; unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!"; rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
}
goto VPNCONF_ERROR; goto VPNCONF_ERROR;
} }
} }
} }
}
if ($cgiparams{'TYPE'} ne 'host') { if ($cgiparams{'TYPE'} ne 'host') {
unless (&General::validipandmask($cgiparams{'LOCAL_SUBNET'})) { unless (&General::validipandmask($cgiparams{'LOCAL_SUBNET'})) {