summaryrefslogtreecommitdiffstats
path: root/etc/inc/captiveportal.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-07-10 15:26:26 +0000
committerErmal <eri@pfsense.org>2013-07-10 15:26:26 +0000
commit7fb233997df32e5f3a50da815b6778ed0bdd0345 (patch)
tree2c2bd5504629781215066e4ca2d043c95b8c16eb /etc/inc/captiveportal.inc
parent0f50d70d30bdb969a0f8db7a2de752d37ec7aad2 (diff)
downloadpfsense-7fb233997df32e5f3a50da815b6778ed0bdd0345.zip
pfsense-7fb233997df32e5f3a50da815b6778ed0bdd0345.tar.gz
Implement proper releasing of pipes allocated based on CPzone. Keep track of which zone a pipe is and release those pipes during disabling/deleting of zone. Ticket #3062, Pull request #698
Diffstat (limited to 'etc/inc/captiveportal.inc')
-rw-r--r--etc/inc/captiveportal.inc30
1 files changed, 25 insertions, 5 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 59a6eb4..ecc4c4c 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -363,6 +363,8 @@ EOD;
unlink_if_exists("{$g['vardb_path']}/captiveportal{$cpzone}.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_radius_{$cpzone}.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_{$cpzone}.rules");
+ /* Release allocated pipes for this zone */
+ captiveportal_free_dnrules();
mwexec("/usr/local/sbin/ipfw_context -d {$cpzone}", true);
@@ -1341,8 +1343,26 @@ function captiveportal_write_elements() {
return 0;
}
+function captiveportal_free_dnrules($rulenos_start = 2000, $rulenos_range_max = 64500) {
+ global $cpzone;
+
+ $cpruleslck = lock("captiveportalrulesdn", LOCK_EX);
+ if (file_exists("{$g['vardb_path']}/captiveportaldn.rules")) {
+ $rules = unserialize(file_get_contents("{$g['vardb_path']}/captiveportaldn.rules"));
+ for ($ridx = $rulenos_start; $ridx < $rulenos_range_max; $ridx++) {
+ if ($rules[$ridx] == $cpzone) {
+ $rules[$ruleno] = false;
+ $ridx++;
+ $rules[$ruleno] = false;
+ }
+ }
+ }
+ file_put_contents("{$g['vardb_path']}/captiveportaldn.rules", serialize($rules));
+ unlock($cpruleslck);
+}
+
function captiveportal_get_next_dn_ruleno($rulenos_start = 2000, $rulenos_range_max = 64500) {
- global $config, $g;
+ global $config, $g, $cpzone;
$cpruleslck = lock("captiveportalrulesdn", LOCK_EX);
$ruleno = 0;
@@ -1354,15 +1374,15 @@ function captiveportal_get_next_dn_ruleno($rulenos_start = 2000, $rulenos_range_
continue;
}
$ruleno = $ridx;
- $rules[$ridx] = "used";
- $rules[++$ridx] = "used";
+ $rules[$ridx] = $cpzone;
+ $rules[++$ridx] = $cpzone;
break;
}
} else {
$rules = array_pad(array(), $rulenos_range_max, false);
$ruleno = $rulenos_start;
- $rules[$rulenos_start] = "used";
- $rules[++$rulenos_start] = "used";
+ $rules[$rulenos_start] = $cpzone;
+ $rules[++$rulenos_start] = $cpzone;
}
file_put_contents("{$g['vardb_path']}/captiveportaldn.rules", serialize($rules));
unlock($cpruleslck);
OpenPOWER on IntegriCloud