summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-07-30 16:43:37 +0545
committerPhil Davis <phil.davis@inf.org>2015-07-30 16:43:37 +0545
commitede370319de55269185103954f106ea9a0596b70 (patch)
tree58c308aaedb926398849f48e6e834441c683b0bb
parentf688185c9fd30b65fcd550d5346cdf514f051801 (diff)
downloadpfsense-ede370319de55269185103954f106ea9a0596b70.zip
pfsense-ede370319de55269185103954f106ea9a0596b70.tar.gz
Allow to create empty bogons on nanoBSD
If for some reason the bogons file/s do not exist then this code creates empty ones before making any use of them in the rule set. On nanoBSD this can fail if the file system is mount RO. Protect against this possibility by use conf_mount_rw and conf_mount_ro
-rw-r--r--etc/inc/filter.inc14
1 files changed, 9 insertions, 5 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 73614f8..b121499 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -738,11 +738,15 @@ function filter_generate_aliases() {
$aliases .= "#Snort tables\n";
$aliases .= "table <snort2c>\n";
$aliases .= "table <virusprot>\n";
- if (!file_exists("/etc/bogons")) {
- @file_put_contents("/etc/bogons", "");
- }
- if (!file_exists("/etc/bogonsv6")) {
- @file_put_contents("/etc/bogonsv6", "");
+ if (!file_exists("/etc/bogons") || !file_exists("/etc/bogonsv6")) {
+ conf_mount_rw();
+ if (!file_exists("/etc/bogons")) {
+ @file_put_contents("/etc/bogons", "");
+ }
+ if (!file_exists("/etc/bogonsv6")) {
+ @file_put_contents("/etc/bogonsv6", "");
+ }
+ conf_mount_ro();
}
$aliases .= "table <bogons> persist file \"/etc/bogons\"\n";
if (is_bogonsv6_used()) {
OpenPOWER on IntegriCloud