diff options
author | Phil Davis <phil.davis@inf.org> | 2015-07-30 16:43:37 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-07-30 16:43:37 +0545 |
commit | ede370319de55269185103954f106ea9a0596b70 (patch) | |
tree | 58c308aaedb926398849f48e6e834441c683b0bb /etc/inc | |
parent | f688185c9fd30b65fcd550d5346cdf514f051801 (diff) | |
download | pfsense-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
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/filter.inc | 14 |
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()) { |