summaryrefslogtreecommitdiffstats
path: root/etc/inc/voucher.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2011-06-07 17:25:24 +0000
committerErmal <eri@pfsense.org>2011-06-07 17:25:24 +0000
commit2c85b316b83c74fc3e26f8cc55a5ffeb67ce18f4 (patch)
tree80c8594103c5718928a26476811224b42386acdf /etc/inc/voucher.inc
parente64c894f56b32e603c5e5b1d72bdee40b4876755 (diff)
downloadpfsense-2c85b316b83c74fc3e26f8cc55a5ffeb67ce18f4.zip
pfsense-2c85b316b83c74fc3e26f8cc55a5ffeb67ce18f4.tar.gz
Disconnect any voucher forced to expire if there are active sessions with it.
Diffstat (limited to 'etc/inc/voucher.inc')
-rw-r--r--etc/inc/voucher.inc16
1 files changed, 16 insertions, 0 deletions
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index e6a44c4..ad96914 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -213,6 +213,9 @@ function voucher_expire($voucher_received) {
$a_vouchers_received = split("[\t\n\r ]+",$voucher_received);
$active_dirty = false;
+ $cpdb = captiveportal_read_db(false, 4); /* Indexed by Voucher */
+ $unsetindexes[] = array();
+
// go through all received vouchers, check their valid and extract
// Roll# and Ticket# using the external readvoucher binary
foreach ($a_vouchers_received as $voucher) {
@@ -242,6 +245,15 @@ function voucher_expire($voucher_received) {
if (!(ord($bitstring[$roll][$pos]) & $mask))
$bitstring[$roll][$pos] = chr(ord($bitstring[$roll][$pos]) | $mask);
captiveportal_syslog("{$voucher} ({$roll}/{$nr}) forced to expire");
+
+ /* Check if this voucher has any active sessions */
+ if (isset($cpdb[$voucher])) {
+ $cpentry = $cpdb[$voucher];
+ captiveportal_disconnect($cpentry,null,13);
+ captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"FORCLY TERMINATING VOUCHER {$voucher} SESSION");
+ unset($cpdb[$voucher]);
+ $unsetindexes[] = $cpentry[5];
+ }
} else
captiveportal_syslog("$voucher ($roll/$nr): not found on any registererd Roll");
} else
@@ -269,6 +281,10 @@ function voucher_expire($voucher_received) {
unlock($voucherlck);
+ /* Write database */
+ if (!empty($unsetindexes))
+ captiveportal_write_db($cpdb, false, $unsetindexes);
+
return true;
}
OpenPOWER on IntegriCloud