diff options
author | NOYB <Al_Stu@Frontier.com> | 2016-05-24 13:39:09 -0700 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2016-05-25 08:30:36 -0400 |
commit | f0f471f7c278e1795679cef63e1bc1d8581ac1ee (patch) | |
tree | 00e5e2f2595d570e9cb02fa422c096c76e4f51c5 /src | |
parent | e139a2050953daa312795bfe548830bde117884d (diff) | |
download | pfsense-f0f471f7c278e1795679cef63e1bc1d8581ac1ee.zip pfsense-f0f471f7c278e1795679cef63e1bc1d8581ac1ee.tar.gz |
Firewall / Aliases / Edit - New URL Table Alias Type
Need to pass alias type to process_alias_urltable() function when creating a new url table alias because it is not yet set/available from config. So the alias_get_type() function can't be successfully used yet.
(cherry picked from commit 3b07f4feaf35e70700082240ef03966f74f5df97)
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/pfsense-utils.inc | 5 | ||||
-rwxr-xr-x | src/etc/rc.update_urltables | 2 | ||||
-rwxr-xr-x | src/usr/local/www/firewall_aliases_edit.php | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 71219fb..86f4a51 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -2150,7 +2150,7 @@ function pfs_version_compare($cur_time, $cur_text, $remote) { } return $v; } -function process_alias_urltable($name, $url, $freq, $forceupdate=false, $validateonly=false) { +function process_alias_urltable($name, $type, $url, $freq, $forceupdate=false, $validateonly=false) { global $g, $config; $urltable_prefix = "/var/db/aliastables/"; @@ -2177,7 +2177,8 @@ function process_alias_urltable($name, $url, $freq, $forceupdate=false, $validat if (download_file($url, $tmp_urltable_filename, $verify_ssl)) { // Convert lines that begin with '$' or ';' to comments '#' instead of deleting them. mwexec("/usr/bin/sed -i \"\" -E 's/^[[:space:]]*($|#|;)/#/g; /^#/!s/\;.*//g;' ". escapeshellarg($tmp_urltable_filename)); - if (alias_get_type($name) == "urltable_ports") { + $type = ($type) ? $type : alias_get_type($name); // If empty type passed, try to get it from config. + if ($type == "urltable_ports") { $ports = parse_aliases_file($tmp_urltable_filename, "url_ports", "-1", true); $ports = group_ports($ports, true); file_put_contents($urltable_filename, implode("\n", $ports)); diff --git a/src/etc/rc.update_urltables b/src/etc/rc.update_urltables index 887dfac..8a2c00b 100755 --- a/src/etc/rc.update_urltables +++ b/src/etc/rc.update_urltables @@ -49,7 +49,7 @@ if (count($todo) > 0) { continue; } - $r = process_alias_urltable($t['name'], $t['url'], $t['freq'], $forceupdate); + $r = process_alias_urltable($t['name'], $t['type'], $t['url'], $t['freq'], $forceupdate); if ($r == 1) { $result = ""; // TODO: Change it when pf supports tables with ports diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php index f762fe8..ea60a73 100755 --- a/src/usr/local/www/firewall_aliases_edit.php +++ b/src/usr/local/www/firewall_aliases_edit.php @@ -206,6 +206,7 @@ if ($_POST) { $address = array(); $final_address_details = array(); $alias['name'] = $_POST['name']; + $alias['type'] = $_POST['type']; if (preg_match("/urltable/i", $_POST['type'])) { $address = ""; @@ -219,7 +220,7 @@ if ($_POST) { $alias['updatefreq'] = $_POST['address_subnet0'] ? $_POST['address_subnet0'] : 7; if (!is_URL($alias['url']) || empty($alias['url'])) { $input_errors[] = gettext("A valid URL must be provided."); - } elseif (!process_alias_urltable($alias['name'], $alias['url'], 0, true, true)) { + } elseif (!process_alias_urltable($alias['name'], $alias['type'], $alias['url'], 0, true, true)) { $input_errors[] = gettext("Unable to fetch usable data from URL") . " " . htmlspecialchars($alias['url']); } if ($_POST["detail0"] <> "") { |