aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2013-12-30 00:08:15 -0800
committerErmal Luçi <eri@pfsense.org>2013-12-30 00:08:15 -0800
commite0207e7d7d9b82d1317de41e4a1779825a677d8f (patch)
tree4d78cec82fa6077aea77235e6849b94bf5f576e8
parent34e530837f376a936e5d11b745dfa5c575fdc33a (diff)
parent38203725d2ab99140c42c10b9e6a9313eb5e962a (diff)
downloadpfsense-packages-e0207e7d7d9b82d1317de41e4a1779825a677d8f.tar.gz
pfsense-packages-e0207e7d7d9b82d1317de41e4a1779825a677d8f.tar.bz2
pfsense-packages-e0207e7d7d9b82d1317de41e4a1779825a677d8f.zip
Merge pull request #565 from phildd/master
bandwidthd belts and braces checks when generating conf
-rw-r--r--config/bandwidthd/bandwidthd.inc36
-rw-r--r--config/bandwidthd/bandwidthd.xml2
-rw-r--r--pkg_config.8.xml2
-rw-r--r--pkg_config.8.xml.amd642
4 files changed, 31 insertions, 11 deletions
diff --git a/config/bandwidthd/bandwidthd.inc b/config/bandwidthd/bandwidthd.inc
index 1220e033..7cdc8006 100644
--- a/config/bandwidthd/bandwidthd.inc
+++ b/config/bandwidthd/bandwidthd.inc
@@ -40,6 +40,10 @@ switch ($pfs_version) {
}
// End: Check pfSense version
+function is_blank($value) {
+ return empty($value) && !is_numeric($value);
+}
+
function bandwidthd_install_deinstall() {
conf_mount_rw();
config_lock();
@@ -66,8 +70,11 @@ function bandwidthd_install_config() {
/* user defined values */
$bandwidthd_config = $config['installedpackages']['bandwidthd']['config'][0];
$meta_refresh = $bandwidthd_config['meta_refresh'];
- if ($meta_refresh)
+ if (is_numeric($meta_refresh))
$meta_refresh = "meta_refresh $meta_refresh\n";
+ else
+ $meta_refresh = "";
+
$graph = $bandwidthd_config['drawgraphs'];
if ($graph)
$graph = "graph true\n";
@@ -75,11 +82,17 @@ function bandwidthd_install_config() {
$graph = "graph false\n";
$filter_text = $bandwidthd_config['filter'];
- if ($filter_text)
+ if (!is_blank($filter_text))
$filter_text = "filter $filter_text\n";
+ else
+ $filter_text = "";
+
$recover_cdf = $bandwidthd_config['recovercdf'];
if ($recover_cdf)
$recover_cdf = "recover_cdf true\n";
+ else
+ $recover_cdf = "";
+
$output_cdf = $bandwidthd_config['outputcdf'];
if ($output_cdf)
$output_cdf_string = "output_cdf true\n";
@@ -93,15 +106,15 @@ function bandwidthd_install_config() {
$postgresql_password = $bandwidthd_config['postgresqlpassword'];
$postgresql_string = "";
if ($output_postgresql) {
- if ($postgresql_host && $postgresql_username && $postgresql_database && $postgresql_password)
+ if (!is_blank($postgresql_host) && !is_blank($postgresql_username) && !is_blank($postgresql_database) && !is_blank($postgresql_password))
$postgresql_string = "pgsql_connect_string \"user = $postgresql_username dbname = $postgresql_database password = $postgresql_password host = $postgresql_host\"\n";
else
- log_error("You have to specify the postgreSQL Host, Database, Username and Password. Exiting.");
+ log_error("bandwidthd: You have to specify the postgreSQL Host, Database, Username and Password. postgreSQL details have been ignored.");
}
$sensor_id = $bandwidthd_config['sensorid'];
- if ($sensor_id)
+ if (!is_blank($sensor_id))
$sensor_id_string = "sensor_id \"$sensor_id\"";
else
$sensor_id_string = "";
@@ -113,13 +126,20 @@ function bandwidthd_install_config() {
$promiscuous = "promiscuous false\n";
$graph_cutoff = $bandwidthd_config['graphcutoff'];
- if ($graph_cutoff)
+ if (!is_blank($graph_cutoff))
$graph_cutoff = "graph_cutoff $graph_cutoff\n";
+ else
+ $graph_cutoff = "";
+
$skip_intervals = $bandwidthd_config['skipintervals'];
- if ($skip_intervals)
+ if ($skip_intervals) {
$skip_intervals = "skip_intervals $skip_intervals\n";
+ } else {
+ /* Includes the case where 0 is explicitly specified, which is the default anyway. */
+ $skip_intervals = "";
+ }
- if ($bandwidthd_config['active_interface']){
+ if (!is_blank($bandwidthd_config['active_interface'])){
$ifdescrs = array($bandwidthd_config['active_interface']);
} else {
log_error("You should specify an interface for bandwidthd to listen on. Exiting.");
diff --git a/config/bandwidthd/bandwidthd.xml b/config/bandwidthd/bandwidthd.xml
index 672b5367..44a33bac 100644
--- a/config/bandwidthd/bandwidthd.xml
+++ b/config/bandwidthd/bandwidthd.xml
@@ -46,7 +46,7 @@
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>bandwidthd</name>
- <version>2.0.1_5 pkg v.0.2</version>
+ <version>2.0.1_5 pkg v.0.3</version>
<title>Bandwidthd</title>
<aftersaveredirect>/pkg_edit.php?xml=bandwidthd.xml&amp;id=0</aftersaveredirect>
<include_file>/usr/local/pkg/bandwidthd.inc</include_file>
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index 27d6f21f..ea32993a 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -1133,7 +1133,7 @@
<website>http://bandwidthd.sourceforge.net/</website>
<descr>BandwidthD tracks usage of TCP/IP network subnets and builds html files with graphs to display utilization. Charts are built by individual IPs, and by default display utilization over 2 day, 8 day, 40 day, and 400 day periods. Furthermore, each ip address's utilization can be logged out at intervals of 3.3 minutes, 10 minutes, 1 hour or 12 hours in cdf format, or to a backend database server. HTTP, TCP, UDP, ICMP, VPN, and P2P traffic are color coded.</descr>
<category>System</category>
- <version>2.0.1_5 pkg v.0.2</version>
+ <version>2.0.1_5 pkg v.0.3</version>
<status>BETA</status>
<required_version>1.2.1</required_version>
<depends_on_package_base_url>http://files.pfsense.org/packages/8/All/</depends_on_package_base_url>
diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64
index 1f43a074..fdff8ea1 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -1120,7 +1120,7 @@
<website>http://bandwidthd.sourceforge.net/</website>
<descr>BandwidthD tracks usage of TCP/IP network subnets and builds html files with graphs to display utilization. Charts are built by individual IPs, and by default display utilization over 2 day, 8 day, 40 day, and 400 day periods. Furthermore, each ip address's utilization can be logged out at intervals of 3.3 minutes, 10 minutes, 1 hour or 12 hours in cdf format, or to a backend database server. HTTP, TCP, UDP, ICMP, VPN, and P2P traffic are color coded.</descr>
<category>System</category>
- <version>2.0.1_5 pkg v.0.2</version>
+ <version>2.0.1_5 pkg v.0.3</version>
<status>BETA</status>
<required_version>1.2.1</required_version>
<depends_on_package_base_url>http://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url>