From ede370319de55269185103954f106ea9a0596b70 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 30 Jul 2015 16:43:37 +0545 Subject: 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 --- etc/inc/filter.inc | 14 +++++++++----- 1 file 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 \n"; $aliases .= "table \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 persist file \"/etc/bogons\"\n"; if (is_bogonsv6_used()) { -- cgit v1.1