Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set standard RADIUS attributes ouside of the RADIUS class #534

Merged
merged 3 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net/pear-Auth_RADIUS/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

PORTNAME= Auth_RADIUS
PORTVERSION= 1.1.0
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= net security pear

MAINTAINER= bofh@FreeBSD.org
Expand Down
70 changes: 16 additions & 54 deletions net/pear-Auth_RADIUS/files/patch-Auth_RADIUS.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,20 @@
/**
* Puts standard attributes.
*/
@@ -300,6 +305,45 @@ class Auth_RADIUS {
$this->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_FRAMED);
$this->putAttribute(RADIUS_FRAMED_PROTOCOL, RADIUS_PPP);
$this->putAttribute(RADIUS_CALLING_STATION_ID, isset($var['REMOTE_HOST']) ? $var['REMOTE_HOST'] : '127.0.0.1');
+
+ if (!function_exists("getNasIp")) {
+ $ipaddr = "0.0.0.0";
+ } else {
+ $ipaddr = getNasIP();
+ }
+
+ /*
+ * Add support for sending NAS-IP-Address, set this explicitly
+ * as an ip_addr
+ */
+ $this->putAttribute(RADIUS_NAS_IP_ADDRESS, $ipaddr, "addr");
+
+ /* Add support for sending NAS-Identifier */
+ if (function_exists("getNasID")) {
+ $nasId = getNasID();
+ } else if (!empty($cpzone) &&
+ empty($config["captiveportal"][$cpzone]["radiusnasid"])) {
+ $nasId = php_uname("n");
+ } else {
+ $nasId =
+ $config["captiveportal"][$cpzone]["radiusnasid"];
+ }
+ $this->putAttribute(RADIUS_NAS_IDENTIFIER, $nasId);
+
+ if (function_exists("getNasPortType")) {
+ $this->putAttribute(RADIUS_NAS_PORT_TYPE,
+ getNasPortType());
+ }
+
+ if (function_exists("getNasPort")) {
+ $this->putAttribute(RADIUS_NAS_PORT, getNasPort(),
+ 'integer');
+ }
+
+ if (function_exists("getCalledStationId")) {
+ $this->putAttribute(RADIUS_CALLED_STATION_ID,
+ getCalledStationId());
+ }
@@ -295,11 +300,7 @@ class Auth_RADIUS {
$var = $GLOBALS['HTTP_SERVER_VARS'];
}

- $this->putAttribute(RADIUS_NAS_IDENTIFIER, isset($var['HTTP_HOST']) ? $var['HTTP_HOST'] : 'localhost');
- $this->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_VIRTUAL);
- $this->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_FRAMED);
- $this->putAttribute(RADIUS_FRAMED_PROTOCOL, RADIUS_PPP);
- $this->putAttribute(RADIUS_CALLING_STATION_ID, isset($var['REMOTE_HOST']) ? $var['REMOTE_HOST'] : '127.0.0.1');
+ $this->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_LOGIN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing attributes that are assigned by the original port? Less changes we need to carry on it are better.

Copy link
Contributor Author

@Augustin-FL Augustin-FL Jul 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • For Service-Type and Framed-Protocol attributes : because these 2 attributes are wrong : they indicate that pfSense is querying Radius server in order to make a PPP connection(which is false...). These two attributes were also not assigned in old RADIUS.inc.
  • For Calling-Station-ID : Because I suggested in Redmine # 5112: Captive Portal - Use User Manager as Authentication source pfsense#3640 to set this attribute here in auth.inc (for user manager authentication) and here in captiveportal.inc (for captiveportal accounting), so i am removing it from the RADIUS class. Also, the new RADIUS port broke this attribute : it is currently unconditionally set to 127.0.0.1....

}

/**
@@ -384,13 +428,13 @@ class Auth_RADIUS {
@@ -384,13 +385,13 @@ class Auth_RADIUS {
{
$req = radius_send_request($this->res);
if (!$req) {
Expand All @@ -74,7 +41,7 @@
}
return true;

@@ -399,12 +443,12 @@ class Auth_RADIUS {
@@ -399,12 +400,12 @@ class Auth_RADIUS {

case RADIUS_ACCOUNTING_RESPONSE:
if (is_subclass_of($this, 'auth_radius_pap')) {
Expand All @@ -89,7 +56,7 @@
}

}
@@ -464,7 +508,10 @@ class Auth_RADIUS {
@@ -464,7 +465,10 @@ class Auth_RADIUS {
break;

case RADIUS_CLASS:
Expand All @@ -101,7 +68,7 @@
break;

case RADIUS_FRAMED_PROTOCOL:
@@ -536,9 +583,179 @@ class Auth_RADIUS {
@@ -536,9 +540,179 @@ class Auth_RADIUS {
$this->attributes['ms_primary_dns_server'] = radius_cvt_string($datav);
break;
}
Expand Down Expand Up @@ -282,7 +249,7 @@
}
}

@@ -935,14 +1152,21 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
@@ -935,11 +1109,16 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
*/
function putAuthAttributes()
{
Expand All @@ -301,12 +268,7 @@ function putAuthAttributes()
if (isset($this->authentic)) {
$this->putAttribute(RADIUS_ACCT_AUTHENTIC, $this->authentic);
}
+
+ $this->putStandardAttributes();

}

@@ -1003,4 +1227,22 @@ class Auth_RADIUS_Acct_Update extends Auth_RADIUS_Acct
@@ -1003,4 +1182,22 @@ class Auth_RADIUS_Acct_Update extends Auth_RADIUS_Acct
var $status_type = RADIUS_UPDATE;
}

Expand Down