summaryrefslogtreecommitdiffstats
path: root/etc/inc/captiveportal.inc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-05-13 18:09:37 +0000
committerErmal Luçi <eri@pfsense.org>2009-05-13 18:09:37 +0000
commit2f70eac786b462e058edf8ffcd7bbbae637ecc62 (patch)
tree5d00728e4fbde12d8dded589de18ff001f079498 /etc/inc/captiveportal.inc
parentd853e5dbf623528ecd52b9c2ae0f8dadb3952c12 (diff)
downloadpfsense-2f70eac786b462e058edf8ffcd7bbbae637ecc62.zip
pfsense-2f70eac786b462e058edf8ffcd7bbbae637ecc62.tar.gz
* Use file_get_contents its better and process the contents of the file after reading the file.
* Release the lock before authenticating against radius to allow another request to come in. This allows more parallellism in the authentication and speedups the CP login page displaying.
Diffstat (limited to 'etc/inc/captiveportal.inc')
-rw-r--r--etc/inc/captiveportal.inc32
1 files changed, 19 insertions, 13 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 201ddf5..86c394f 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -790,21 +790,19 @@ function captiveportal_get_radius_servers() {
global $g;
if (file_exists("{$g['vardb_path']}/captiveportal_radius.db")) {
- $fd = @fopen("{$g['vardb_path']}/captiveportal_radius.db","r");
- if ($fd) {
- $radiusservers = array();
- while (!feof($fd)) {
- $line = trim(fgets($fd));
- if ($line) {
- $radsrv = array();
- list($radsrv['ipaddr'],$radsrv['port'],$radsrv['acctport'],$radsrv['key']) = explode(",",$line);
- $radiusservers[] = $radsrv;
- }
+ $radiusservers = array();
+ $cpradiusdb = file_get_contents("{$g['vardb_path']}/captiveportal_radius.db");
+ $cpradiusdb = explode("\n", $cpradiusdb);
+ foreach($cpradiusdb as $cpradiusentry) {
+ $line = trim($cpradiusentry);
+ if ($line) {
+ $radsrv = array();
+ list($radsrv['ipaddr'],$radsrv['port'],$radsrv['acctport'],$radsrv['key']) = explode(",",$line);
+ $radiusservers[] = $radsrv;
}
- fclose($fd);
+ }
- return $radiusservers;
- }
+ return $radiusservers;
}
return false;
@@ -850,6 +848,12 @@ function radius($username,$password,$clientip,$clientmac,$type) {
return $auth_list;
}
+ /*
+ * Drop the lock since radius takes some time to finish.
+ * The implementation is reentrant so we gain speed with this.
+ */
+ unlock($captiveportallck);
+
$radiusservers = captiveportal_get_radius_servers();
$auth_list = RADIUS_AUTHENTICATION($username,
@@ -859,6 +863,8 @@ function radius($username,$password,$clientip,$clientmac,$type) {
$clientmac,
$ruleno);
+ $captiveportallck = lock('captiveportal');
+
if ($auth_list['auth_val'] == 2) {
captiveportal_logportalauth($username,$clientmac,$clientip,$type);
$sessionid = portal_allow($clientip,
OpenPOWER on IntegriCloud