aboutsummaryrefslogtreecommitdiffstats
path: root/packages/nut/nut.inc
diff options
context:
space:
mode:
authorRyan Wagoner <rsw686@pfsense.org>2007-02-16 15:58:56 +0000
committerRyan Wagoner <rsw686@pfsense.org>2007-02-16 15:58:56 +0000
commita00c9bef6c042f15c59b29c55d7cd537c9f032ae (patch)
tree551bc258525a61978df7c7bbc79f97820c56184b /packages/nut/nut.inc
parent8c75b002bedbd391647d7ccb0070e5893d129e23 (diff)
downloadpfsense-packages-a00c9bef6c042f15c59b29c55d7cd537c9f032ae.tar.gz
pfsense-packages-a00c9bef6c042f15c59b29c55d7cd537c9f032ae.tar.bz2
pfsense-packages-a00c9bef6c042f15c59b29c55d7cd537c9f032ae.zip
-check for valid cdir range in ip address
-fix ups type and cable selections according to man pages for drivers
Diffstat (limited to 'packages/nut/nut.inc')
-rw-r--r--packages/nut/nut.inc27
1 files changed, 21 insertions, 6 deletions
diff --git a/packages/nut/nut.inc b/packages/nut/nut.inc
index defc8807..32af50cf 100644
--- a/packages/nut/nut.inc
+++ b/packages/nut/nut.inc
@@ -70,11 +70,24 @@
if($uid) chown($file, $uid);
}
- function nut_validate_ip($ip) {
- if(!eregi("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $ip))
- return false;
- foreach(explode('.', $ip) as $sub)
- if($sub < 0 || $sub > 256)
+ function nut_validate_ip($ip,$check_cdir) {
+ /* validate cdir */
+ if($check_cdir) {
+ $ip_array = explode("/",$ip);
+ if(count($ip_array) == 2) {
+ if($ip_array[1] < 1 || $ip_array[1] > 32)
+ return false;
+ } else
+ if(count($ip_array) != 1)
+ return false;
+ } else
+ $ip_array[] = $ip;
+
+ /* validate ip */
+ if(!eregi("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $ip_array[0]))
+ return false;
+ foreach(explode(".", $ip_array[0]) as $sub)
+ if($sub < 0 || $sub > 256)
return false;
return true;
}
@@ -117,7 +130,7 @@
if($post['monitor'] == 'remote') {
if(!$post['remotename'])
$input_errors[] = 'You must specify a name in the \'Remote Name\' field';
- if(!$post['remoteaddr'] || !nut_validate_ip($post['remoteaddr']))
+ if(!$post['remoteaddr'] || !nut_validate_ip($post['remoteaddr'],false))
$input_errors[] = 'You must specify a valid address \'Remote Address\' field';
if(!$post['remoteuser'])
$input_errors[] = 'You must specify a name in the \'Remote User\' field';
@@ -133,6 +146,8 @@
$input_errors[] = 'You must select a driver in the \'Driver\' field';
if(!$post['port'])
$input_errors[] = 'You must select a port in the \'Port\' field';
+ if($post['allowaddr'] && !nut_validate_ip($post['allowaddr'],true))
+ $input_errors[] = 'You must specify a valid address \'Local Remote Access Address\' field';
}
/* this is run before the config file changed */