aboutsummaryrefslogtreecommitdiffstats
path: root/config
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 /config
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
Diffstat (limited to 'config')
-rw-r--r--config/bandwidthd/bandwidthd.inc36
-rw-r--r--config/bandwidthd/bandwidthd.xml2
2 files changed, 29 insertions, 9 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>