summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-12-24 10:45:45 +0000
committerErmal <eri@pfsense.org>2013-12-24 10:45:45 +0000
commit1f965b69a89df2671b49033153c063e8ca8672ed (patch)
tree97f9e12f9cb1b27606fe0dcab68369c1f7f762b4 /etc
parenta2a42c72f45091d19046d65239c1edf7f377f7f0 (diff)
downloadpfsense-1f965b69a89df2671b49033153c063e8ca8672ed.zip
pfsense-1f965b69a89df2671b49033153c063e8ca8672ed.tar.gz
Merge manually 4fd85b115e2550969ddeadd43a2bc6dafff21779 3f2ae9d58f5ea3d9de175e8daa9c8902b3f23440 and e049c5e74f009430e22e446f149a552d00846d7a
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/captiveportal.inc91
1 files changed, 56 insertions, 35 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 211bcf3..51d8d92 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -1383,15 +1383,19 @@ function captiveportal_free_dnrules($rulenos_start = 2000, $rulenos_range_max =
$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++) {
+ $ridx = $rulenos_start;
+ while ($ridx < $rulenos_range_max) {
if ($rules[$ridx] == $cpzone) {
$rules[$ridx] = false;
$ridx++;
$rules[$ridx] = false;
- }
+ $ridx++;
+ } else
+ $ridx += 2;
}
+ file_put_contents("{$g['vardb_path']}/captiveportaldn.rules", serialize($rules));
+ unset($rules);
}
- file_put_contents("{$g['vardb_path']}/captiveportaldn.rules", serialize($rules));
unlock($cpruleslck);
}
@@ -1402,24 +1406,28 @@ function captiveportal_get_next_dn_ruleno($rulenos_start = 2000, $rulenos_range_
$ruleno = 0;
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]) {
+ $ridx = $rulenos_start;
+ while ($ridx < $rulenos_range_max) {
+ if ($rules[$ridx] === false) {
+ $ridx += 2;
+ } else {
+ $ruleno = $ridx;
+ $rules[$ridx] = $cpzone;
$ridx++;
- continue;
+ $rules[$ridx] = $cpzone;
+ break;
}
- $ruleno = $ridx;
- $rules[$ridx] = $cpzone;
- $rules[++$ridx] = $cpzone;
- break;
}
} else {
$rules = array_pad(array(), $rulenos_range_max, false);
$ruleno = $rulenos_start;
$rules[$rulenos_start] = $cpzone;
- $rules[++$rulenos_start] = $cpzone;
+ $rulenos_start++;
+ $rules[$rulenos_start] = $cpzone;
}
file_put_contents("{$g['vardb_path']}/captiveportaldn.rules", serialize($rules));
unlock($cpruleslck);
+ unset($rules);
return $ruleno;
}
@@ -1434,6 +1442,7 @@ function captiveportal_free_dn_ruleno($ruleno) {
$ruleno++;
$rules[$ruleno] = false;
file_put_contents("{$g['vardb_path']}/captiveportaldn.rules", serialize($rules));
+ unset($rules);
}
unlock($cpruleslck);
}
@@ -1446,17 +1455,19 @@ function captiveportal_get_dn_passthru_ruleno($value) {
return NULL;
$cpruleslck = lock("captiveportalrulesdn", LOCK_EX);
+ $ruleno = NULL;
if (file_exists("{$g['vardb_path']}/captiveportaldn.rules")) {
$rules = unserialize(file_get_contents("{$g['vardb_path']}/captiveportaldn.rules"));
- $ruleno = intval(`/sbin/ipfw -x {$cpzoneid} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d " " -f 5 | /usr/bin/head -n 1`);
- if ($rules[$ruleno]) {
- unlock($cpruleslck);
- return $ruleno;
- }
+ unset($output);
+ $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d \" \" -f 5 | /usr/bin/head -n 1", $output);
+ $ruleno = intval($output[0]);
+ if (!$rules[$ruleno])
+ $ruleno = NULL;
+ unset($rules);
}
-
unlock($cpruleslck);
- return NULL;
+
+ return $ruleno;
}
/*
@@ -1475,28 +1486,33 @@ function captiveportal_get_next_ipfw_ruleno($rulenos_start = 2, $rulenos_range_m
$ruleno = 0;
if (file_exists("{$g['vardb_path']}/captiveportal_{$cpzone}.rules")) {
$rules = unserialize(file_get_contents("{$g['vardb_path']}/captiveportal_{$cpzone}.rules"));
- for ($ridx = 2; $ridx < ($rulenos_range_max - $rulenos_start); $ridx++) {
+ $ridx = $rulenos_start;
+ while ($ridx < $rulenos_range_max) {
if ($rules[$ridx]) {
/*
* This allows our traffic shaping pipes to be the in pipe the same as ruleno
* and the out pipe ruleno + 1.
*/
+ $ridx += 2;
+ } else {
+ $ruleno = $ridx;
+ $rules[$ridx] = $cpzone;
$ridx++;
- continue;
+ $rules[$ridx] = $cpzone;
+ break;
}
- $ruleno = $ridx;
- $rules[$ridx] = "used";
- $rules[++$ridx] = "used";
- break;
}
} else {
$rules = array_pad(array(), $rulenos_range_max, false);
- $rules[$rulenos_start] = "used";
- $rules[++$rulenos_start] = "used";
- $ruleno = 2;
+ $ruleno = $rulenos_start;
+ $rules[$rulenos_start] = $cpzone;
+ $rulenos_start++;
+ $rules[$rulenos_start] = $cpzone;
}
file_put_contents("{$g['vardb_path']}/captiveportal_{$cpzone}.rules", serialize($rules));
unlock($cpruleslck);
+ unset($rules);
+
return $ruleno;
}
@@ -1511,8 +1527,10 @@ function captiveportal_free_ipfw_ruleno($ruleno) {
if (file_exists("{$g['vardb_path']}/captiveportal_{$cpzone}.rules")) {
$rules = unserialize(file_get_contents("{$g['vardb_path']}/captiveportal_{$cpzone}.rules"));
$rules[$ruleno] = false;
- $rules[++$ruleno] = false;
+ $ruleno++;
+ $rules[$ruleno] = false;
file_put_contents("{$g['vardb_path']}/captiveportal_{$cpzone}.rules", serialize($rules));
+ unset($rules);
}
unlock($cpruleslck);
}
@@ -1525,17 +1543,19 @@ function captiveportal_get_ipfw_passthru_ruleno($value) {
return NULL;
$cpruleslck = lock("captiveportalrules{$cpzone}", LOCK_EX);
+ $ruleno = NULL;
if (file_exists("{$g['vardb_path']}/captiveportal_{$cpzone}.rules")) {
$rules = unserialize(file_get_contents("{$g['vardb_path']}/captiveportal_{$cpzone}.rules"));
- $ruleno = intval(`/sbin/ipfw -x {$cpzoneid} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d " " -f 1 | /usr/bin/head -n 1`);
- if ($rules[$ruleno]) {
- unlock($cpruleslck);
- return $ruleno;
- }
+ unset($output);
+ $_gb = exec("/sbin/ipfw -x {$cpzone} show | /usr/bin/grep {$value} | /usr/bin/grep -v grep | /usr/bin/cut -d \" \" -f 5 | /usr/bin/head -n 1", $output);
+ $ruleno = intval($output[0]);
+ if (!$rules[$ruleno])
+ $ruleno = NULL;
+ unset($rules);
}
-
unlock($cpruleslck);
- return NULL;
+
+ return $ruleno;
}
/**
@@ -1960,6 +1980,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut
/* store information to database */
captiveportal_write_db($insertquery);
unlock($cpdblck);
+ unset($insertquery, $bpassword);
if (isset($config['captiveportal'][$cpzone]['radacct_enable']) && !empty($radiusservers[$radiusctx])) {
$acct_val = RADIUS_ACCOUNTING_START($pipeno, $username, $sessionid, $radiusservers[$radiusctx], $clientip, $clientmac);
OpenPOWER on IntegriCloud