summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2012-03-12 15:53:37 +0000
committerErmal <eri@pfsense.org>2012-03-12 15:53:37 +0000
commitad218b1d99a78b814834fa56aac97e85a1f16ea4 (patch)
treeefaa56264f78a177031db5ec8af6e107317fdbd7
parent9b79809efb7a70e139aa770d695697c1baa40d10 (diff)
downloadpfsense-ad218b1d99a78b814834fa56aac97e85a1f16ea4.zip
pfsense-ad218b1d99a78b814834fa56aac97e85a1f16ea4.tar.gz
Prevent ruleset breaking from grep putting garbage on urltable files and as a result creating unparsable files breaking rulesets
-rw-r--r--etc/inc/pfsense-utils.inc7
1 files changed, 5 insertions, 2 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index a4e0771..b2f4d1b 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -1833,8 +1833,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 -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;
OpenPOWER on IntegriCloud