aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/pfblockerng/geoipupdate.sh28
-rw-r--r--config/pfblockerng/pfblockerng.inc3
-rw-r--r--config/pfblockerng/pfblockerng.php34
-rwxr-xr-xconfig/snort/snort.inc49
-rwxr-xr-xconfig/snort/snort.xml2
-rw-r--r--config/snort/snort_migrate_config.php2
-rw-r--r--config/snort/snort_post_install.php25
-rw-r--r--config/tinc/tinc.inc2
-rw-r--r--config/vnstat2/vnstat2.inc96
-rw-r--r--config/vnstat2/vnstat2.xml2
-rw-r--r--config/vnstat2/www/vnstat2_img.php4
11 files changed, 159 insertions, 88 deletions
diff --git a/config/pfblockerng/geoipupdate.sh b/config/pfblockerng/geoipupdate.sh
index 4b8fbb63..302f81f5 100644
--- a/config/pfblockerng/geoipupdate.sh
+++ b/config/pfblockerng/geoipupdate.sh
@@ -23,19 +23,23 @@
# may be met by including the following in all advertising and documentation
# mentioning features of or use of this database.
-# Folder Locations
+mtype=$(/usr/bin/uname -m);
+
+# Application Locations
pathfetch=/usr/bin/fetch
pathtar=/usr/bin/tar
pathgunzip=/usr/bin/gunzip
-# File Locations
+# Folder Locations
pathdb=/var/db/pfblockerng
+pathpbi=/usr/pbi/pfblockerng-$mtype/share/GeoIP
pathlog=/var/log/pfblockerng
+
+# File Locations
errorlog=$pathlog/geoip.log
-pathgeoipdatgz=$pathdb/GeoIP.dat.gz
-pathgeoipdatgzv6=$pathdb/GeoIPv6.dat.gz
-pathgeoipdat=$pathdb/GeoIP.dat
-pathgeoipdatv6=$pathdb/GeoIPv6.dat
+geoipdat=/GeoIP.dat
+geoipdatv6=/GeoIPv6.dat
+
pathgeoipcc=$pathdb/country_continent.csv
pathgeoipcsv4=$pathdb/GeoIPCountryCSV.zip
pathgeoipcsvfinal4=$pathdb/GeoIPCountryWhois.csv
@@ -56,12 +60,12 @@ binaryupdate() {
echo " ** Downloading MaxMind GeoLite IPv4 Binary Database (For Reputation/Alerts Processes) **"; echo
URL="http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
-$pathfetch -v -o $pathgeoipdatgz -T 20 $URL
+$pathfetch -v -o $pathpbi$geoipdat.gz -T 20 $URL
if [ "$?" -eq "0" ]; then
- $pathgunzip -f $pathgeoipdatgz
+ $pathgunzip -f $pathpbi$geoipdat.gz
echo; echo " ( MaxMind IPv4 GeoIP.dat has been updated )"; echo
echo "Current Date/Timestamp:"
- /bin/ls -alh $pathgeoipdat
+ /bin/ls -alh $pathpbi$geoipdat
echo
else
echo; echo " => MaxMind IPv4 GeoIP.dat Update [ FAILED ]"; echo
@@ -72,12 +76,12 @@ fi
echo; echo " ** Downloading MaxMind GeoLite IPv6 Binary Database (For Reputation/Alerts Processes) **"; echo
URL="http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz"
-$pathfetch -v -o $pathgeoipdatgzv6 -T 20 $URL
+$pathfetch -v -o $pathpbi$geoipdatv6.gz -T 20 $URL
if [ "$?" -eq "0" ]; then
- $pathgunzip -f $pathgeoipdatgzv6
+ $pathgunzip -f $pathpbi$geoipdatv6.gz
echo; echo " ( MaxMind IPv6 GeoIPv6.dat has been updated )"; echo
echo "Current Date/Timestamp:"
- /bin/ls -alh $pathgeoipdatv6
+ /bin/ls -alh $pathpbi$geoipdatv6
echo
else
echo; echo " => MaxMind IPv6 GeoIPv6.dat Update [ FAILED ]"; echo
diff --git a/config/pfblockerng/pfblockerng.inc b/config/pfblockerng/pfblockerng.inc
index d612dbf1..66b5a313 100644
--- a/config/pfblockerng/pfblockerng.inc
+++ b/config/pfblockerng/pfblockerng.inc
@@ -2341,9 +2341,6 @@ function pfblockerng_php_install_command() {
update_output_window(gettext("Downloading MaxMind Country Databases. This may take a minute..."));
exec("/bin/sh /usr/local/pkg/pfblockerng/geoipupdate.sh all >> {$pfb['geolog']} 2>&1");
- @rename("{$pfb['dbdir']}/GeoIP.dat", "{$pfb['ccdir']}/GeoIP.dat");
- @rename("{$pfb['dbdir']}/GeoIPv6.dat", "{$pfb['ccdir']}/GeoIPv6.dat");
-
update_output_window(gettext("MaxMind Country Database downloads completed..."));
update_output_window(gettext("Converting MaxMind Country Databases for pfBlockerNG. This may take a few minutes..."));
pfblockerng_uc_countries();
diff --git a/config/pfblockerng/pfblockerng.php b/config/pfblockerng/pfblockerng.php
index 1db36334..ca8a23a9 100644
--- a/config/pfblockerng/pfblockerng.php
+++ b/config/pfblockerng/pfblockerng.php
@@ -44,9 +44,13 @@ require_once("functions.inc");
require_once("pkg-utils.inc");
require_once("globals.inc");
require_once("services.inc");
-require_once("/usr/local/pkg/pfblockerng/pfblockerng.inc");
-pfb_global();
+// Call Include File and Collect updated Global Settings
+if (in_array($argv[1], array( 'update','dc','uc','gc','cron' ))) {
+ require_once("/usr/local/pkg/pfblockerng/pfblockerng.inc");
+ pfb_global();
+}
+
// IPv6 Range to CIDR function used courtesey from:
// https://github.com/stilez/pfsense-leases/blob/50cc0fa81dba5fe91bcddaea016c245d1b8479cc/etc/inc/util.inc
@@ -147,7 +151,7 @@ $uname = posix_uname();
if ($uname['machine'] == "amd64")
ini_set('memory_limit', '256M');
-function pfb_update_check($header_url, $list_url, $url_format) {
+function pfb_update_check($header_url, $list_url, $url_format, $pfbfolder) {
global $pfb;
$pfb['cron_update'] = FALSE;
@@ -230,6 +234,12 @@ if ($argv[1] == 'dc') {
}
pfblockerng_uc_countries();
pfblockerng_get_countries();
+
+ // Remove Original Maxmind Database Files
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryCSV.zip");
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryWhois.csv");
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPv6.csv");
+ @unlink_if_exists("{$pfb['dbdir']}/country_continent.csv");
}
if ($argv[1] == 'uc') {
@@ -425,7 +435,6 @@ if ($argv[1] == 'cron') {
// Function to process the downloaded Maxmind Database and format into Continent txt files.
function pfblockerng_uc_countries() {
global $g,$pfb;
- pfb_global();
$maxmind_cont = "{$pfb['dbdir']}/country_continent.csv";
$maxmind_cc4 = "{$pfb['dbdir']}/GeoIPCountryWhois.csv";
@@ -584,7 +593,6 @@ function pfblockerng_uc_countries() {
// Function to process Continent txt files and create Country ISO files and to Generate GUI XML files.
function pfblockerng_get_countries() {
global $g,$pfb;
- pfb_global();
$files = array ( "Africa" => "{$pfb['ccdir']}/Africa_v4.txt",
"Asia" => "{$pfb['ccdir']}/Asia_v4.txt",
@@ -622,7 +630,9 @@ function pfblockerng_get_countries() {
if (preg_match("/#/",$line)) {
if ($pfb['complete']) {
${'coptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
- ${'roptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
+ // Only collect IPv4 for Reputation Tab
+ if ($type == "4")
+ $roptions4[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
// Save ISO data
@file_put_contents($pfb['ccdir'] . '/' . $isocode . '_v' . $type . '.txt', $xml_data, LOCK_EX);
@@ -646,7 +656,8 @@ function pfblockerng_get_countries() {
if ($keycount == $lastkey) {
if (preg_match("/Total Networks: 0/", $line)) { continue;} // Dont Display Countries with Null Data
${'coptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
- ${'roptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
+ if ($type == "4")
+ $roptions4[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
@file_put_contents($pfb['ccdir'] . '/' . $isocode . '_v' . $type . '.txt', $xml_data, LOCK_EX);
unset($total, $xml_data);
}
@@ -962,13 +973,12 @@ EOF;
// Sort Countries IPv4 Alphabetically and Build XML <option> Data for Reputation Tab (IPv6 not used by ET IQRisk)
- $type = "4";
- sort(${'roptions' . $type}, SORT_STRING);
- $eoa = count(${'roptions' . $type});
+ sort($roptions4, SORT_STRING);
+ $eoa = count($roptions4);
$count = 1;
$etoptions = "";
- foreach (${'roptions' . $type} as $option4) {
+ foreach ($roptions4 as $option4) {
if ($count == 1) { $et_options .= "\t" . '<option><name>' . $option4 . "\n"; $count++; continue; }
if ($eoa == $count) {
$et_options .= "\t\t\t\t" . '<option><name>' . $option4;
@@ -1470,6 +1480,6 @@ EOF;
pfb_logger("{$log}","3");
// Unset Arrays
- unset ($et_options, $xmlrep);
+ unset ($roptions4, $et_options, $xmlrep);
}
?> \ No newline at end of file
diff --git a/config/snort/snort.inc b/config/snort/snort.inc
index bec163d7..b9a022fd 100755
--- a/config/snort/snort.inc
+++ b/config/snort/snort.inc
@@ -324,10 +324,11 @@ function snort_build_list($snortcfg, $listname = "", $whitelist = false, $extern
if (($externallist && $localnet == 'yes') || (!$externallist && (!$whitelist || $localnet == 'yes' || empty($localnet)))) {
if (is_ipaddr($snortip)) {
if ($snortcfg['interface'] <> "wan") {
- $sn = get_interface_subnet($snortcfg['interface']);
- $ip = gen_subnet($snortip, $sn) . "/{$sn}";
- if (!in_array($ip, $home_net))
- $home_net[] = $ip;
+ if ($sn = get_interface_subnet($snortcfg['interface'])) {
+ $ip = gen_subnet($snortip, $sn) . "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
}
}
}
@@ -346,10 +347,11 @@ function snort_build_list($snortcfg, $listname = "", $whitelist = false, $extern
if (($externallist && $localnet == 'yes') || (!$externallist && (!$whitelist || $localnet == 'yes' || empty($localnet)))) {
if (is_ipaddrv6($snortip)) {
if ($snortcfg['interface'] <> "wan") {
- $sn = get_interface_subnetv6($snortcfg['interface']);
- $ip = gen_subnetv6($snortip, $sn). "/{$sn}";
- if (!in_array($ip, $home_net))
- $home_net[] = $ip;
+ if ($sn = get_interface_subnetv6($snortcfg['interface'])) {
+ $ip = gen_subnetv6($snortip, $sn). "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
}
}
}
@@ -383,10 +385,11 @@ function snort_build_list($snortcfg, $listname = "", $whitelist = false, $extern
continue;
$subnet = get_interface_ip($int);
if (is_ipaddrv4($subnet)) {
- $sn = get_interface_subnet($int);
- $ip = gen_subnet($subnet, $sn) . "/{$sn}";
- if (!in_array($ip, $home_net))
- $home_net[] = $ip;
+ if ($sn = get_interface_subnet($int)) {
+ $ip = gen_subnet($subnet, $sn) . "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
}
$subnet = get_interface_ipv6($int);
@@ -394,10 +397,11 @@ function snort_build_list($snortcfg, $listname = "", $whitelist = false, $extern
if (strpos($subnet, "%") !== FALSE)
$subnet = substr($subnet, 0, strpos($subnet, "%"));
if (is_ipaddrv6($subnet)) {
- $sn = get_interface_subnetv6($int);
- $ip = gen_subnetv6($subnet, $sn). "/{$sn}";
- if (!in_array($ip, $home_net))
- $home_net[] = $ip;
+ if ($sn = get_interface_subnetv6($int)) {
+ $ip = gen_subnetv6($subnet, $sn). "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
}
// Add link-local address
@@ -814,7 +818,9 @@ function snort_snortloglimit_install_cron($should_install=TRUE) {
if ($should_install && snort_cron_job_exists("/usr/local/pkg/snort/snort_check_cron_misc.inc", TRUE, "*/5"))
return;
- // Else install the new or updated cron job
+ // Else install the new or updated cron job by removing the
+ // existing job first, then installing the new or updated job.
+ install_cron_job("snort_check_cron_misc.inc", false);
install_cron_job("/usr/bin/nice -n20 /usr/local/bin/php -f /usr/local/pkg/snort/snort_check_cron_misc.inc", $should_install, "*/5");
}
@@ -921,7 +927,9 @@ function snort_rm_blocked_install_cron($should_install) {
// Else install the new or updated cron job
if ($should_install) {
- install_cron_job($command, $should_install, $snort_rm_blocked_min, $snort_rm_blocked_hr, $snort_rm_blocked_mday, $snort_rm_blocked_month, $snort_rm_blocked_wday, "root");
+ // Remove the existing job first, then install the new or updated job
+ install_cron_job("snort2c", false);
+ install_cron_job($command, true, $snort_rm_blocked_min, $snort_rm_blocked_hr, $snort_rm_blocked_mday, $snort_rm_blocked_month, $snort_rm_blocked_wday, "root");
}
}
@@ -1009,8 +1017,11 @@ function snort_rules_up_install_cron($should_install) {
return;
// Else install the new or updated cron job
- if ($should_install)
+ if ($should_install) {
+ // Remove the existing job first, then install the new or updated job
+ install_cron_job("snort_check_for_rule_updates.php", false);
install_cron_job($command, $should_install, $snort_rules_up_min, $snort_rules_up_hr, $snort_rules_up_mday, $snort_rules_up_month, $snort_rules_up_wday, "root");
+ }
}
/* Only run when all ifaces needed to sync. Expects filesystem rw */
diff --git a/config/snort/snort.xml b/config/snort/snort.xml
index fb23997c..60573130 100755
--- a/config/snort/snort.xml
+++ b/config/snort/snort.xml
@@ -47,7 +47,7 @@
<faq>Currently there are no FAQ items provided.</faq>
<name>Snort</name>
<version>2.9.7.0</version>
- <title>Services:2.9.7.0 pkg v3.2.2</title>
+ <title>Services:2.9.7.0 pkg v3.2.3</title>
<include_file>/usr/local/pkg/snort/snort.inc</include_file>
<menu>
<name>Snort</name>
diff --git a/config/snort/snort_migrate_config.php b/config/snort/snort_migrate_config.php
index 12ae5d19..de8ac308 100644
--- a/config/snort/snort_migrate_config.php
+++ b/config/snort/snort_migrate_config.php
@@ -533,7 +533,7 @@ unset($r);
// Log a message if we changed anything
if ($updated_cfg) {
- $config['installedpackages']['snortglobal']['snort_config_ver'] = "3.2";
+ $config['installedpackages']['snortglobal']['snort_config_ver'] = "3.2.3";
log_error("[Snort] Settings successfully migrated to new configuration format...");
}
else
diff --git a/config/snort/snort_post_install.php b/config/snort/snort_post_install.php
index 57e92ce5..7ab8b3db 100644
--- a/config/snort/snort_post_install.php
+++ b/config/snort/snort_post_install.php
@@ -115,6 +115,27 @@ if ($pkgid >= 0) {
/* Define a default Dashboard Widget Container for Snort */
$snort_widget_container = "snort_alerts-container:col2:close";
+/*********************************************************/
+/* START OF BUG FIX CODE */
+/* */
+/* Remove any Snort cron tasks that may have been left */
+/* from a previous uninstall due to a bug that saved */
+/* edited cron tasks as new ones while still leaving */
+/* the original task. Correct cron task entries will */
+/* be recreated below if saved settings are detected. */
+/*********************************************************/
+$cron_count = 0;
+while (snort_cron_job_exists("snort2c", FALSE)) {
+ install_cron_job("snort2c", false);
+ $cron_count++;
+}
+if ($cron_count > 0)
+ log_error(gettext("[Snort] Removed {$cron_count} duplicate 'remove_blocked_hosts' cron task(s)."));
+
+/*********************************************************/
+/* END OF BUG FIX CODE */
+/*********************************************************/
+
/* remake saved settings */
if ($config['installedpackages']['snortglobal']['forcekeepsettings'] == 'on') {
log_error(gettext("[Snort] Saved settings detected... rebuilding installation with saved settings..."));
@@ -242,8 +263,8 @@ if (stristr($config['widgets']['sequence'], "snort_alerts-container") === FALSE)
$config['widgets']['sequence'] .= ",{$snort_widget_container}";
/* Update Snort package version in configuration */
-$config['installedpackages']['snortglobal']['snort_config_ver'] = "3.2";
-write_config("Snort pkg v3.2: post-install configuration saved.");
+$config['installedpackages']['snortglobal']['snort_config_ver'] = "3.2.3";
+write_config("Snort pkg v3.2.3: post-install configuration saved.");
/* Done with post-install, so clear flag */
unset($g['snort_postinstall']);
diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc
index bf4101d7..8b2b671c 100644
--- a/config/tinc/tinc.inc
+++ b/config/tinc/tinc.inc
@@ -1,5 +1,7 @@
<?php
+include_once('guiconfig.inc'); // needed for clear_log_file() during package installation while booting
+
function tinc_save() {
global $config;
conf_mount_rw();
diff --git a/config/vnstat2/vnstat2.inc b/config/vnstat2/vnstat2.inc
index 7418530f..f248083e 100644
--- a/config/vnstat2/vnstat2.inc
+++ b/config/vnstat2/vnstat2.inc
@@ -1,4 +1,5 @@
<?php
+require_once("util.inc");
function vnstat_install_deinstall() {
conf_mount_rw();
global $config;
@@ -113,18 +114,22 @@ EOF;
}
fwrite($hf2, $vnstat_conf_file);
fclose($hf2);
+ vnstat_link_config();
+ vnstat_create_nic_dbs();
}
function create_vnstati_image() {
conf_mount_rw();
global $config;
+ $vnstat_tmp = "/tmp/vnstat";
$iface = $_POST['vnstat_interface'];
$ifaces_final = convert_friendly_interface_to_real_interface_name($iface);
$config['installedpackages']['vnstat2']['config'][0]['vnstat_interface'] = $ifaces_final;
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -vs -o /tmp/newpicture1.png");
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -m -o /tmp/newpicture2.png");
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -d -o /tmp/newpicture3.png");
- exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -t -o /tmp/newpicture4.png");
+ @mkdir($vnstat_tmp);
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -vs -o {$vnstat_tmp}/newpicture1.png");
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -m -o {$vnstat_tmp}/newpicture2.png");
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -d -o {$vnstat_tmp}/newpicture3.png");
+ exec("/usr/local/bin/vnstati -i ". escapeshellarg($ifaces_final) ." -t -o {$vnstat_tmp}/newpicture4.png");
write_config();
conf_mount_ro();
}
@@ -139,50 +144,71 @@ function create_vnstat_output() {
conf_mount_ro();
}
+function vnstat_link_config() {
+// Check for pbi install and arch type then create symlinks
+ if (file_exists('/usr/pbi/vnstat-' . php_uname("m"))) {
+ $conf_path = "/usr/local/etc/vnstat.conf";
+ $pbi_conf_path = "/usr/pbi/vnstat-" . php_uname("m") . "/etc/vnstat.conf";
+ unlink_if_exists($pbi_conf_path);
+ symlink($conf_path, $pbi_conf_path);
+ }
+}
+
+function vnstat_create_nic_dbs() {
+ global $config;
+ conf_mount_rw();
+ $vnstat_db_prefix = "/conf/vnstat";
+ @mkdir($vnstat_db_prefix);
+
+ // Locate NICs and create associated databases
+ $array_of_real_nic_names = array();
+ $array_of_custom_nic_names = array();
+ $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
+ $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
+ }
+ foreach ($ifdescrs as $ifdescr => $ifname) {
+ $real_nic_names = convert_friendly_interface_to_real_interface_name($ifdescr);
+ array_push($array_of_real_nic_names, $real_nic_names);
+ }
+ $vnstat_nic = array_map('basename', glob($vnstat_db_prefix . '/*', GLOB_ONLYDIR));
+
+ // Compare real NICs with NICs assigned to vnstat
+ $leftovers = array_diff($array_of_real_nic_names, $vnstat_nic);
+ // Create database for each NIC
+ foreach ($leftovers as $nic) {
+ exec("/usr/local/bin/vnstat -u -i ". escapeshellarg($nic));
+ }
+
+ conf_mount_ro();
+}
+
function vnstat_install_config() {
- global $config;
+ $vnstat_db_prefix = "/conf/vnstat";
conf_mount_rw();
// Create vnstat database dir where it also will work for nanobsd
-// exec("[ -d /var/db/vnstat ] && mv /var/db/vnstat /conf/vnstat");
- exec("[ -d /usr/local/pkg/vnstat2/vnstat ] && mv /usr/local/pkg/vnstat2/vnstat /conf/vnstat");
- exec("[ ! -d /conf/vnstat ] && mkdir /conf/vnstat");
-// Check for pbi install and arch type then create symlinks
- if (file_exists('/usr/pbi/vnstat-i386')) { exec("ln -s /usr/local/etc/vnstat.conf /usr/pbi/vnstat-i386/etc/vnstat.conf"); }
- if (file_exists('/usr/pbi/vnstat-amd64')) { exec("ln -s /usr/local/etc/vnstat.conf /usr/pbi/vnstat-amd64/etc/vnstat.conf"); }
+ if (is_dir("/usr/local/pkg/vnstat2/vnstat")) {
+ @rename("/usr/local/pkg/vnstat2/vnstat", $vnstat_db_prefix);
+ }
+ if (!is_dir($vnstat_db_prefix)) {
+ @mkdir($vnstat_db_prefix);
+ }
+ vnstat_link_config();
// Add MonthRotate value to config.xml and write /usr/local/etc/vnstat.conf
$no_monthrotate = $config['installedpackages']['vnstat2']['config'][0]['monthrotate'];
if ($no_monthrotate == ""){
$config['installedpackages']['vnstat2']['config'][0]['monthrotate'] = "1";
}
$no_vnstat_phpfrontend = $config['installedpackages']['vnstat2']['config'][0]['vnstat_phpfrontend'];
- if ($no_vnstat_phpfrontend == "on"){
- vnstat_php_frontend();
+ if ($no_vnstat_phpfrontend == "on"){
+ vnstat_php_frontend();
}
write_conf_f();
// Add cron job to config.xml
vnstat2_install_cron(true);
-// get system nic's and create a database for them
- $array_of_real_nic_names = array();
- $array_of_custom_nic_names = array();
- $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
- }
- foreach ($ifdescrs as $ifdescr => $ifname):
- $real_nic_names = convert_friendly_interface_to_real_interface_name($ifdescr);
- array_push($array_of_real_nic_names, $real_nic_names);
- endforeach;
- // Get already nic's assigned to vnstat
- exec("ls /conf/vnstat/ | grep -v '\.'", $vnstat_nic);
- // Compare real nic's with nic's assigned to vnstat
- $result = array_diff($array_of_real_nic_names, $vnstat_nic);
- // Create database for each nic
- foreach ($result as $result2)
- {
- exec("/usr/local/bin/vnstat -u -i ". $result2);
- }
- write_config();
- conf_mount_ro();
+ vnstat_create_nic_dbs();
+ write_config();
+ conf_mount_ro();
}
function vnstat_php_frontend(){
diff --git a/config/vnstat2/vnstat2.xml b/config/vnstat2/vnstat2.xml
index ab07f004..94b7cfc1 100644
--- a/config/vnstat2/vnstat2.xml
+++ b/config/vnstat2/vnstat2.xml
@@ -7,7 +7,7 @@
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>vnstat2</name>
- <version>1.0</version>
+ <version>11.2,3</version>
<title>Vnstat2</title>
<aftersaveredirect>/pkg_edit.php?xml=vnstat2.xml&amp;id=0</aftersaveredirect>
<include_file>/usr/local/pkg/vnstat2/vnstat2.inc</include_file>
diff --git a/config/vnstat2/www/vnstat2_img.php b/config/vnstat2/www/vnstat2_img.php
index 85644309..a83c3b06 100644
--- a/config/vnstat2/www/vnstat2_img.php
+++ b/config/vnstat2/www/vnstat2_img.php
@@ -1,6 +1,6 @@
<?php
require_once("guiconfig.inc");
-$image = $_GET['image'];
+$image = basename($_GET['image']);
header("Content-type: image/png");
-readfile("/tmp/$image");
+readfile("/tmp/vnstat/{$image}");
?>