diff options
author | Ermal <eri@pfsense.org> | 2013-11-21 21:18:00 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2013-11-21 21:18:00 +0000 |
commit | baec2b007fa963f9c047ef08b16abc92c571c407 (patch) | |
tree | 94d4ecc36df550dbcbade2518b33fc5211a3f3f8 /usr | |
parent | fc5a4f3c22bc0cfc44a8d0e74a1a5fda12ba9f8b (diff) | |
download | pfsense-baec2b007fa963f9c047ef08b16abc92c571c407.zip pfsense-baec2b007fa963f9c047ef08b16abc92c571c407.tar.gz |
Properly create zones for the CP with the new command arguments and properly invoke ipfw for applying rules and other configuration options.
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/captiveportal/index.php | 4 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal.php | 14 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal_hostname_edit.php | 3 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal_ip_edit.php | 5 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal_mac.php | 9 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal_mac_edit.php | 7 | ||||
-rw-r--r-- | usr/local/www/services_captiveportal_zones.php | 4 | ||||
-rwxr-xr-x | usr/local/www/status.php | 8 |
8 files changed, 40 insertions, 14 deletions
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php index a97c33b..e8bcee3 100755 --- a/usr/local/captiveportal/index.php +++ b/usr/local/captiveportal/index.php @@ -44,7 +44,7 @@ header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Connection: close"); -global $cpzone; +global $cpzone, $cpzoneid; $cpzone = $_REQUEST['zone']; $cpcfg = $config['captiveportal'][$cpzone]; @@ -55,6 +55,8 @@ if (empty($cpcfg)) { return; } +$cpzoneid = $cpcfg['zoneid']; + $orig_host = $_ENV['HTTP_HOST']; /* NOTE: IE 8/9 is buggy and that is why this is needed */ $orig_request = trim($_REQUEST['redirurl'], " /"); diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php index 8d7b211..ced841c 100755 --- a/usr/local/www/services_captiveportal.php +++ b/usr/local/www/services_captiveportal.php @@ -44,6 +44,10 @@ require_once("filter.inc"); require_once("shaper.inc"); require_once("captiveportal.inc"); +global $cpzone; +global $cpzoneid; + +$cpzoneid = 1; /* Just a default */ $cpzone = $_GET['zone']; if (isset($_POST['zone'])) $cpzone = $_POST['zone']; @@ -85,7 +89,7 @@ if (!is_array($config['cert'])) $a_cert =& $config['cert']; if ($a_cp[$cpzone]) { - $pconfig['zoneid'] = $a_cp[$cpzone]['zoneid']; + $cpzoneid = $pconfig['zoneid'] = $a_cp[$cpzone]['zoneid']; $pconfig['cinterface'] = $a_cp[$cpzone]['interface']; $pconfig['maxproc'] = $a_cp[$cpzone]['maxproc']; $pconfig['maxprocperip'] = $a_cp[$cpzone]['maxprocperip']; @@ -248,10 +252,12 @@ if ($_POST) { $newcp =& $a_cp[$cpzone]; //$newcp['zoneid'] = $a_cp[$cpzone]['zoneid']; if (empty($newcp['zoneid'])) { - $newcp['zoneid'] = 8000; - foreach ($a_cp as $keycpzone => $cp) + $newcp['zoneid'] = 1; + foreach ($a_cp as $keycpzone => $cp) { if ($cp['zoneid'] == $newcp['zoneid'] && $keycpzone != $cpzone) $newcp['zoneid'] += 2; /* Resreve space for SSL config if needed */ + } + $cpzoneid = $newcp['zoneid']; } $oldifaces = explode(",", $newcp['interface']); if (is_array($_POST['cinterface'])) @@ -344,7 +350,7 @@ if ($_POST) { if (!empty($toremove)) { foreach ($toremove as $removeif) { $removeif = get_real_interface($removeif); - mwexec("/usr/local/sbin/ipfw_context -d {$cpzone} -x {$removeif}"); + mwexec("/usr/local/sbin/ipfw zone {$cpzone} mdel {$removeif}"); } } captiveportal_configure_zone($newcp); diff --git a/usr/local/www/services_captiveportal_hostname_edit.php b/usr/local/www/services_captiveportal_hostname_edit.php index b42aa78..cf01f18 100755 --- a/usr/local/www/services_captiveportal_hostname_edit.php +++ b/usr/local/www/services_captiveportal_hostname_edit.php @@ -140,7 +140,8 @@ if ($_POST) { $rules = captiveportal_allowedhostname_configure(); @file_put_contents("{$g['tmp_path']}/hostname_rules", $rules); - mwexec("/sbin/ipfw -x {$cpzone} {$g['tmp_path']}/hostname_rules"); + $cpzoneid = $a_cp[$cpzone]['zoneid']; + mwexec("/sbin/ipfw -x {$cpzoneid} {$g['tmp_path']}/hostname_rules"); unset($rules); header("Location: services_captiveportal_hostname.php?zone={$cpzone}"); diff --git a/usr/local/www/services_captiveportal_ip_edit.php b/usr/local/www/services_captiveportal_ip_edit.php index a700e9b..f91d680 100755 --- a/usr/local/www/services_captiveportal_ip_edit.php +++ b/usr/local/www/services_captiveportal_ip_edit.php @@ -147,9 +147,10 @@ if ($_POST) { if (isset($a_cp[$cpzone]['enable']) && is_module_loaded("ipfw.ko")) { $rules = ""; + $cpzoneid = $a_cp[$cpzone]['zoneid']; unset($ipfw); if (isset($oldip) && isset($oldmask)) { - $ipfw = pfSense_ipfw_getTablestats($cpzone, 3, $oldip, $oldmask); + $ipfw = pfSense_ipfw_getTablestats($cpzoneid, 3, $oldip, $oldmask); $rules .= "table 3 delete {$oldip}/{$oldmask}\n"; $rules .= "table 4 delete {$oldip}/{$oldmask}\n"; if (is_array($ipfw)) { @@ -163,7 +164,7 @@ if ($_POST) { } $uniqid = uniqid("{$cpzone}_allowed"); @file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules); - mwexec("/sbin/ipfw -x {$cpzone} -q {$g['tmp_path']}/{$uniqid}_tmp"); + mwexec("/sbin/ipfw -x {$cpzoneid} -q {$g['tmp_path']}/{$uniqid}_tmp"); @unlink("{$g['tmp_path']}/{$uniqid}_tmp"); } diff --git a/usr/local/www/services_captiveportal_mac.php b/usr/local/www/services_captiveportal_mac.php index b0a8492..e636f7b 100755 --- a/usr/local/www/services_captiveportal_mac.php +++ b/usr/local/www/services_captiveportal_mac.php @@ -44,6 +44,9 @@ require_once("filter.inc"); require("shaper.inc"); require("captiveportal.inc"); +global $cpzone; +global $cpzoneid; + $cpzone = $_GET['zone']; if (isset($_POST['zone'])) $cpzone = $_POST['zone']; @@ -102,10 +105,11 @@ if ($_POST) { } } if ($found == true) { + $cpzoneid = $a_cp[$cpzone]['zoneid']; $rules = captiveportal_passthrumac_delete_entry($a_passthrumacs[$idx]); $uniqid = uniqid("{$cpzone}_mac"); file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules); - mwexec("/sbin/ipfw -x {$cpzone} -q {$g['tmp_path']}/{$uniqid}_tmp"); + mwexec("/sbin/ipfw -x {$cpzoneid} -q {$g['tmp_path']}/{$uniqid}_tmp"); @unlink("{$g['tmp_path']}/{$uniqid}_tmp"); unset($a_passthrumacs[$idx]); write_config(); @@ -120,10 +124,11 @@ if ($_POST) { if ($_GET['act'] == "del") { $a_passthrumacs =& $a_cp[$cpzone]['passthrumac']; if ($a_passthrumacs[$_GET['id']]) { + $cpzoneid = $a_cp[$cpzone]['zoneid']; $rules = captiveportal_passthrumac_delete_entry($a_passthrumacs[$_GET['id']]); $uniqid = uniqid("{$cpzone}_mac"); file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules); - mwexec("/sbin/ipfw -x {$cpzone} -q {$g['tmp_path']}/{$uniqid}_tmp"); + mwexec("/sbin/ipfw -x {$cpzoneid} -q {$g['tmp_path']}/{$uniqid}_tmp"); @unlink("{$g['tmp_path']}/{$uniqid}_tmp"); unset($a_passthrumacs[$_GET['id']]); write_config(); diff --git a/usr/local/www/services_captiveportal_mac_edit.php b/usr/local/www/services_captiveportal_mac_edit.php index ef70c45..e03454d 100755 --- a/usr/local/www/services_captiveportal_mac_edit.php +++ b/usr/local/www/services_captiveportal_mac_edit.php @@ -54,6 +54,9 @@ require_once("filter.inc"); require("shaper.inc"); require("captiveportal.inc"); +global $cpzone; +global $cpzoneid; + $pgtitle = array(gettext("Services"),gettext("Captive portal"),gettext("Edit MAC address rules")); $shortcut_section = "captiveportal"; @@ -153,12 +156,14 @@ if ($_POST) { write_config(); if (isset($config['captiveportal'][$cpzone]['enable'])) { + $cpzoneid = $config['captiveportal'][$cpzone]['zoneid']; $rules = captiveportal_passthrumac_delete_entry($oldmac); $rules .= captiveportal_passthrumac_configure_entry($mac); $uniqid = uniqid("{$cpzone}_macedit"); file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules); - mwexec("/sbin/ipfw -x {$cpzone} -q {$g['tmp_path']}/{$uniqid}_tmp"); + mwexec("/sbin/ipfw -x {$cpzoneid} -q {$g['tmp_path']}/{$uniqid}_tmp"); @unlink("{$g['tmp_path']}/{$uniqid}_tmp"); + unset($cpzoneid); } header("Location: services_captiveportal_mac.php?zone={$cpzone}"); diff --git a/usr/local/www/services_captiveportal_zones.php b/usr/local/www/services_captiveportal_zones.php index 58fc3d8..454b36e 100644 --- a/usr/local/www/services_captiveportal_zones.php +++ b/usr/local/www/services_captiveportal_zones.php @@ -16,6 +16,9 @@ require_once("filter.inc"); require("shaper.inc"); require("captiveportal.inc"); +global $cpzone; +global $cpzoneid; + if (!is_array($config['captiveportal'])) $config['captiveportal'] = array(); $a_cp = &$config['captiveportal']; @@ -23,6 +26,7 @@ $a_cp = &$config['captiveportal']; if ($_GET['act'] == "del" && !empty($_GET['zone'])) { $cpzone = $_GET['zone']; if ($a_cp[$cpzone]) { + $cpzoneid = $a_cp[$cpzone]['zoneid']; unset($a_cp[$cpzone]['enable']); captiveportal_configure_zone($a_cp[$cpzone]); unset($a_cp[$cpzone]); diff --git a/usr/local/www/status.php b/usr/local/www/status.php index a4906cf..4459207 100755 --- a/usr/local/www/status.php +++ b/usr/local/www/status.php @@ -138,10 +138,12 @@ defCmdT("top | head -n5", "/usr/bin/top | /usr/bin/head -n5"); defCmdT("sysctl hw.physmem","/sbin/sysctl hw.physmem"); -if (isset($config['captiveportal']) && is_array($config['captiveportal'])) - foreach ($config['captiveportal'] as $cpZone => $cpdata) +if (isset($config['captiveportal']) && is_array($config['captiveportal'])) { + foreach ($config['captiveportal'] as $cpZone => $cpdata) { if (isset($cpdata['enable'])) - defCmdT("ipfw -x {$cpZone} show", "/sbin/ipfw -x {$cpZone} show"); + defCmdT("ipfw -x {$cpdata['zoneid']} show", "/sbin/ipfw -x {$cpdata['zoneid']} show"); + } +} defCmdT("pfctl -sn", "/sbin/pfctl -sn"); defCmdT("pfctl -sr", "/sbin/pfctl -sr"); |