diff options
author | Ermal <eri@pfsense.org> | 2012-03-12 15:53:37 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2012-03-12 15:53:53 +0000 |
commit | 4aa0979fbc3a860c8182a14da6a1d218f55cf336 (patch) | |
tree | c6cecc5491d864f62c21fbf1932dcfca0482e99a /etc/inc/pfsense-utils.inc | |
parent | 973b2663e42e27e0a98c09cdee9c7e978266f709 (diff) | |
download | pfsense-4aa0979fbc3a860c8182a14da6a1d218f55cf336.zip pfsense-4aa0979fbc3a860c8182a14da6a1d218f55cf336.tar.gz |
Prevent ruleset breaking from grep putting garbage on urltable files and as a result creating unparsable files breaking rulesets
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index b4a41d0..b25b3fd 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1846,8 +1846,11 @@ function process_alias_urltable($name, $url, $freq, $forceupdate=false) { // Use fetch to grab data since these may be large files, we don't want to process them through PHP if we can help it. mwexec("/usr/bin/fetch -T 5 -q -o " . escapeshellarg($urltable_filename . ".tmp") . " " . escapeshellarg($url)); // Remove comments. Might need some grep-fu to only allow lines that look like IPs/subnets - mwexec("/usr/bin/grep -v '^#' " . escapeshellarg($urltable_filename . ".tmp") . " > " . escapeshellarg($urltable_filename)); - unlink_if_exists($urltable_filename . ".tmp"); + if (file_exists($urltable_filename . ".tmp")) { + mwexec("/usr/bin/grep -v '^#' " . escapeshellarg($urltable_filename . ".tmp") . " > " . escapeshellarg($urltable_filename)); + unlink_if_exists($urltable_filename . ".tmp"); + } else + mwexec("/usr/bin/touch {$urltable_filename}"); conf_mount_ro(); if (filesize($urltable_filename)) { return true; |