aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--packages/nut/nut.inc27
-rw-r--r--packages/nut/nut.xml68
2 files changed, 36 insertions, 59 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 */
diff --git a/packages/nut/nut.xml b/packages/nut/nut.xml
index f7a826d9..9cdbec04 100644
--- a/packages/nut/nut.xml
+++ b/packages/nut/nut.xml
@@ -68,13 +68,15 @@
<fielddescr>Local UPS Model</fielddescr>
<fieldname>driver</fieldname>
<type>select</type>
+ <description>If generic or cable specified in parenthesis you need
+ to select the appropriate option below.</description>
<options>
<option>
- <name>APC Back-UPS (Generic/Cable)</name>
+ <name>APC Back-UPS (Generic)</name>
<value>genericups00</value>
</option>
<option>
- <name>APC Back-UPS RS (Generic/Cable)</name>
+ <name>APC Back-UPS RS (Generic)</name>
<value>genericups02</value>
</option>
<option>
@@ -90,7 +92,7 @@
<value>apcsmart02</value>
</option>
<option>
- <name>APC Masterswitch (Generic/Cable)</name>
+ <name>APC Masterswitch (Generic)</name>
<value>genericups01</value>
</option>
<option>
@@ -369,23 +371,23 @@
</option>
<option>
<value>1 00</value>
- <name>1 (APC Back-UPS)</name>
+ <name>1 (APC Back-UPS using 940-0095A/C cables)</name>
</option>
<option>
<value>2 00</value>
- <name>2 (APC Back-UPS)</name>
+ <name>2 (APC Back-UPS using 940-0020B/C cables)</name>
</option>
<option>
<value>9 00</value>
- <name>9 (APC Back-UPS)</name>
+ <name>9 (APC Back-UPS using 940-0023A cable)</name>
</option>
<option>
<value>12 00</value>
- <name>12 (APC Back-UPS Office)</name>
+ <name>12 (APC Back-UPS Office using 940-0119A cable)</name>
</option>
<option>
<value>12 01</value>
- <name>12 (APC Masterswitch)</name>
+ <name>12 (APC Masterswitch using 940-0020 cable)</name>
</option>
<option>
<value>20 00</value>
@@ -393,7 +395,7 @@
</option>
<option>
<value>6 00</value>
- <name>6 (Best Power Patriot)</name>
+ <name>6 (Best Power Patriot using INT51 cable)</name>
</option>
</options>
</field>
@@ -405,55 +407,15 @@
<option>
<value></value>
<name></name>
- </option>
- <option>
- <value>940-0020B 00</value>
- <name>940-0020B (APC Back-Ups - Simple Signalling - Gray Cable)</name>
- </option>
- <option>
- <value>940-0020C 00</value>
- <name>940-0020C (APC Back-Ups - Simple Signalling)</name>
- </option>
- <option>
- <value>940-0023A 00</value>
- <name>940-0023A (APC Back-Ups - Simple Signalling)</name>
- </option>
- <option>
- <value>940-0119A 00</value>
- <name>940-0119A (APC Back-Ups Office - Simple Signalling - Phone Jack Cable)</name>
- </option>
- <option>
- <value>940-0095A 00</value>
- <name>940-0095A (APC Back-Ups Pro - Smart Signalling)</name>
- </option>
- <option>
- <value>940-0095B 00</value>
- <name>940-0095B (APC Back-Ups Pro - Smart Signalling - Gray Cable)</name>
</option>
<option>
- <value>940-0095C 00</value>
- <name>940-0095C (APC Back-Ups Pro - Smart Signalling)</name>
+ <value>940-0095B 00</value>
+ <name>940-0095B (Gray Cable)</name>
</option>
<option>
- <value>940-0024B 00</value>
- <name>940-0024B (APC Smart-Ups - Smart Signalling)</name>
- </option>
- <option>
<value>940-0024C 00</value>
- <name>940-0024C (APC Smart-Ups - Smart Signalling - Black Cable)</name>
- </option>
- <option>
- <value>940-0024G 00</value>
- <name>940-0024G (APC Smart-Ups - Smart Signalling)</name>
- </option>
- <option>
- <value>940-0020 00</value>
- <name>940-0020 (APC Masterswitch - Simple Signalling - Gray Cable)</name>
- </option>
- <option>
- <value>INT51 00</value>
- <name>INT51 (Best Power Patriot)</name>
- </option>
+ <name>940-0024C (Black Cable)</name>
+ </option>
</options>
</field>
<field>