Commit 06f5db67 authored by Ad Schellevis's avatar Ad Schellevis

(Auth, radius) suppress accounting messages when not enabled

parent 3cfac591
...@@ -48,7 +48,7 @@ class Radius implements IAuthConnector ...@@ -48,7 +48,7 @@ class Radius implements IAuthConnector
/** /**
* @var null port to use for accounting * @var null port to use for accounting
*/ */
private $acctPort = "1813"; private $acctPort = null;
/** /**
* @var null shared secret to use for this server * @var null shared secret to use for this server
...@@ -120,6 +120,8 @@ class Radius implements IAuthConnector ...@@ -120,6 +120,8 @@ class Radius implements IAuthConnector
*/ */
public function startAccounting($username, $sessionid) public function startAccounting($username, $sessionid)
{ {
// only send messages if target port specified
if ($this->acctPort != null) {
$radius = radius_auth_open(); $radius = radius_auth_open();
$error = null; $error = null;
...@@ -130,7 +132,8 @@ class Radius implements IAuthConnector ...@@ -130,7 +132,8 @@ class Radius implements IAuthConnector
$this->sharedSecret, $this->sharedSecret,
$this->timeout, $this->timeout,
$this->maxRetries $this->maxRetries
)) { )
) {
$error = radius_strerror($radius); $error = radius_strerror($radius);
} elseif (!radius_create_request($radius, RADIUS_ACCOUNTING_REQUEST)) { } elseif (!radius_create_request($radius, RADIUS_ACCOUNTING_REQUEST)) {
$error = radius_strerror($radius); $error = radius_strerror($radius);
...@@ -162,7 +165,7 @@ class Radius implements IAuthConnector ...@@ -162,7 +165,7 @@ class Radius implements IAuthConnector
syslog(LOG_ERR, 'RadiusError:' . radius_strerror($error)); syslog(LOG_ERR, 'RadiusError:' . radius_strerror($error));
exit; exit;
} }
switch($req) { switch ($req) {
case RADIUS_ACCOUNTING_RESPONSE: case RADIUS_ACCOUNTING_RESPONSE:
break; break;
default: default:
...@@ -172,6 +175,7 @@ class Radius implements IAuthConnector ...@@ -172,6 +175,7 @@ class Radius implements IAuthConnector
radius_close($radius); radius_close($radius);
} }
} }
}
/** /**
* stop radius accounting * stop radius accounting
...@@ -181,6 +185,8 @@ class Radius implements IAuthConnector ...@@ -181,6 +185,8 @@ class Radius implements IAuthConnector
*/ */
public function stopAccounting($username, $sessionid, $session_time) public function stopAccounting($username, $sessionid, $session_time)
{ {
// only send messages if target port specified
if ($this->acctPort != null) {
$radius = radius_auth_open(); $radius = radius_auth_open();
$error = null; $error = null;
...@@ -191,7 +197,8 @@ class Radius implements IAuthConnector ...@@ -191,7 +197,8 @@ class Radius implements IAuthConnector
$this->sharedSecret, $this->sharedSecret,
$this->timeout, $this->timeout,
$this->maxRetries $this->maxRetries
)) { )
) {
$error = radius_strerror($radius); $error = radius_strerror($radius);
} elseif (!radius_create_request($radius, RADIUS_ACCOUNTING_REQUEST)) { } elseif (!radius_create_request($radius, RADIUS_ACCOUNTING_REQUEST)) {
$error = radius_strerror($radius); $error = radius_strerror($radius);
...@@ -227,7 +234,7 @@ class Radius implements IAuthConnector ...@@ -227,7 +234,7 @@ class Radius implements IAuthConnector
syslog(LOG_ERR, 'RadiusError:' . radius_strerror($error)); syslog(LOG_ERR, 'RadiusError:' . radius_strerror($error));
exit; exit;
} }
switch($req) { switch ($req) {
case RADIUS_ACCOUNTING_RESPONSE: case RADIUS_ACCOUNTING_RESPONSE:
break; break;
default: default:
...@@ -237,6 +244,7 @@ class Radius implements IAuthConnector ...@@ -237,6 +244,7 @@ class Radius implements IAuthConnector
radius_close($radius); radius_close($radius);
} }
} }
}
/** /**
* update radius accounting (interim update) * update radius accounting (interim update)
...@@ -246,6 +254,8 @@ class Radius implements IAuthConnector ...@@ -246,6 +254,8 @@ class Radius implements IAuthConnector
*/ */
public function updateAccounting($username, $sessionid, $session_time) public function updateAccounting($username, $sessionid, $session_time)
{ {
// only send messages if target port specified
if ($this->acctPort != null) {
$radius = radius_auth_open(); $radius = radius_auth_open();
if (!defined('RADIUS_UPDATE')) { if (!defined('RADIUS_UPDATE')) {
define('RADIUS_UPDATE', 3); define('RADIUS_UPDATE', 3);
...@@ -259,7 +269,8 @@ class Radius implements IAuthConnector ...@@ -259,7 +269,8 @@ class Radius implements IAuthConnector
$this->sharedSecret, $this->sharedSecret,
$this->timeout, $this->timeout,
$this->maxRetries $this->maxRetries
)) { )
) {
$error = radius_strerror($radius); $error = radius_strerror($radius);
} elseif (!radius_create_request($radius, RADIUS_ACCOUNTING_REQUEST)) { } elseif (!radius_create_request($radius, RADIUS_ACCOUNTING_REQUEST)) {
$error = radius_strerror($radius); $error = radius_strerror($radius);
...@@ -293,7 +304,7 @@ class Radius implements IAuthConnector ...@@ -293,7 +304,7 @@ class Radius implements IAuthConnector
syslog(LOG_ERR, 'RadiusError:' . radius_strerror($error)); syslog(LOG_ERR, 'RadiusError:' . radius_strerror($error));
exit; exit;
} }
switch($req) { switch ($req) {
case RADIUS_ACCOUNTING_RESPONSE: case RADIUS_ACCOUNTING_RESPONSE:
break; break;
default: default:
...@@ -303,6 +314,7 @@ class Radius implements IAuthConnector ...@@ -303,6 +314,7 @@ class Radius implements IAuthConnector
radius_close($radius); radius_close($radius);
} }
} }
}
/** /**
* authenticate user against radius * authenticate user against radius
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment