]> git.gsnw.org Git - m0n0chwall.git/commitdiff
Add username to accounting requests, change Framed-IP-Address from string to addr...
authorjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Fri, 10 Feb 2006 14:11:48 +0000 (14:11 +0000)
committerjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Fri, 10 Feb 2006 14:11:48 +0000 (14:11 +0000)
git-svn-id: https://svn.m0n0.ch/wall/trunk@78 e36fee2c-cc09-0410-a7cc-ebac5c6737de

captiveportal/index.php
captiveportal/radius_accounting.inc
captiveportal/radius_authentication.inc
phpconf/inc/captiveportal.inc
phpconf/inc/radius.inc

index fb83d7e318480ca974f011b080cccd9c7988b76a..490d97331c134e37a062db6b1ce8d340472d2ab0 100755 (executable)
@@ -30,8 +30,6 @@
 */
 
 require_once("functions.inc");
-require_once("radius_authentication.inc");
-require_once("radius_accounting.inc");
 
 header("Expires: 0");
 header("Cache-Control: no-store, no-cache, must-revalidate");
index 92eb78868689a72205727cfa9b196bf7797bc66f..3325f8a7373f5602fa1c61093e2ada5e1444c38c 100644 (file)
@@ -38,7 +38,7 @@
 
 */
 
-/*
+/*tm0664rr
 RADIUS ACCOUNTING START 
 -----------------------
 */
@@ -112,7 +112,7 @@ function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusip,$radiusp
     $racct->putAttribute(RADIUS_ACCT_SESSION_ID, $sessionid);
 
     // Extra data to identify the client and nas
-    $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip);
+    $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip, addr);
     $racct->putAttribute(RADIUS_CALLING_STATION_ID, $callingstationid);
     $racct->putAttribute(RADIUS_CALLED_STATION_ID, $calledstationid);
 
@@ -220,12 +220,11 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
     $racct->putAttribute(RADIUS_NAS_PORT, $nas_port);
     $racct->putAttribute(RADIUS_ACCT_SESSION_ID, $sessionid);
 
-    // We have 2 ways to set the session-time, we will see which one to use in a later version
-    // $racct->session_time = $session_time;
-    $racct->putAttribute(RADIUS_ACCT_SESSION_TIME, $session_time);
+    // We have 2 ways to set the session-time, We are setting it through a var, reason see method putAuthAttributes()
+    $racct->session_time = $session_time;
 
     // Extra data to identify the client and nas
-    $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip);
+    $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip, addr);
     $racct->putAttribute(RADIUS_CALLING_STATION_ID, $callingstationid);
     $racct->putAttribute(RADIUS_CALLED_STATION_ID, $calledstationid);
 
index 09f262e0fac22544a292a21f898b1b3ae755d592..f84f8b879edc3b66bb9b9e5365bdca80a00fc26a 100644 (file)
@@ -101,7 +101,7 @@ function RADIUS_AUTHENTICATION($username,$password,$radiusservers,$clientip,$cli
     $rauth->putAttribute(RADIUS_NAS_PORT, $nas_port);
 
     // Extra data to identify the client and nas
-    $rauth->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip);
+    $rauth->putAttribute(RADIUS_FRAMED_IP_ADDRESS, $clientip, addr);
     $rauth->putAttribute(RADIUS_CALLING_STATION_ID, $callingstationid);
     $rauth->putAttribute(RADIUS_CALLED_STATION_ID, $calledstationid);
 
index 47920d4566fd84aae51bc0024ac8645c3f6de245..592d318e6c6d6a3cb0f69f2c6733c66b3870f7bd 100644 (file)
@@ -37,8 +37,6 @@
 /* include all configuration functions */
 require_once("functions.inc");
 require_once("radius.inc");
-require_once("radius_authentication.inc");
-require_once("radius_accounting.inc");
 
 $lockfile = "{$g['varrun_path']}/captiveportal.lock";
 
@@ -936,7 +934,7 @@ function getVolume($ruleno) {
 
 function getNasID()
 {
-    exec("/bin/hostname", $_nasId);
+    exec("/bin/hostname", $nasId);
     if(!$nasId[0])
         $nasId[0] = "m0n0wall";
     return $nasId[0];
index 19339d910289b0bae6e6aa0661e95977e4c9c199..73f6644a03cad0ff4a56ba858b6e5f2d40d04db6 100644 (file)
@@ -1,56 +1,58 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
 /*
-$Id$
-
-Copyright (c) 2003, Michael Bretterklieber <michael@bretterklieber.com>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without 
-modification, are permitted provided that the following conditions 
-are met:
-
-1. Redistributions of source code must retain the above copyright 
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright 
-   notice, this list of conditions and the following disclaimer in the 
-   documentation and/or other materials provided with the distribution.
-3. The names of the authors may not be used to endorse or promote products 
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
-IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
-EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-This code cannot simply be copied and put under the GNU Public License or 
-any other GPL-like (LGPL, GPL2) License.
-
-    This version of RADIUS.php has been modified by
-    Jonathan De Graeve <jonathan@imelda.be> to integrate with M0n0wall <http://www.m0n0.ch/wall>
-
-    Changes made include:
-    * StandardAttributes for M0n0wall use
-    * Removed internal Session-Id creation
-    * Adding of ReplyMessage to getAttributes()
-    * Adding of listAttributes()
-    * Adding of VENDOR Bay Networks (Nortel)
-    * Adding of VENDOR Nomadix
-    * Adding of VENDOR WISPr (Wi-Fi Alliance)
-    
+    $Id$
+
+    Copyright (c) 2003, Michael Bretterklieber <michael@bretterklieber.com>
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without 
+    modification, are permitted provided that the following conditions 
+    are met:
+
+    1. Redistributions of source code must retain the above copyright 
+       notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright 
+       notice, this list of conditions and the following disclaimer in the 
+       documentation and/or other materials provided with the distribution.
+    3. The names of the authors may not be used to endorse or promote products 
+       derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
+    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
+    IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
+    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
+    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
+    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    This code cannot simply be copied and put under the GNU Public License or 
+    any other GPL-like (LGPL, GPL2) License.
+
+        This version of RADIUS.php has been modified by
+        Jonathan De Graeve <jonathan@imelda.be> to integrate with M0n0wall <http://www.m0n0.ch/wall>
+
+        Changes made include:
+        * StandardAttributes for M0n0wall use
+        * Removed internal Session-Id creation
+        * Adding of ReplyMessage to getAttributes()
+        * Adding of listAttributes()
+        * Adding of VENDOR Bay Networks (Nortel)
+        * Adding of VENDOR Nomadix
+        * Adding of VENDOR WISPr (Wi-Fi Alliance)
+
 */
 
 require_once("pear.inc");
+require_once("radius_authentication.inc");
+require_once("radius_accounting.inc");
 
 /**
 * Client implementation of RADIUS. This are wrapper classes for
-* the RADIUS PECL
+* the RADIUS PECL
 * Provides RADIUS Authentication (RFC2865) and RADIUS Accounting (RFC2866).
 *
 * @package Auth_RADIUS
@@ -76,21 +78,21 @@ class Auth_RADIUS extends PEAR {
      * @see  addServer(), putServer()
      */
     var $_servers  = array();
-    
+
     /**
      * Path to the configuration-file.
      * @var  string
      * @see  setConfigFile()
      */
     var $_configfile = null;
-    
+
     /**
      * Resource.
      * @var  resource
      * @see  open(), close()
      */
     var $res = null;
-    
+
     /**
      * Username for authentication and accounting requests.
      * @var  string
@@ -109,7 +111,7 @@ class Auth_RADIUS extends PEAR {
      * @see  dumpAttributes(), getAttributes()
      */
     var $attributes = array();
-    
+
     /**
      * List of raw attributes.
      * @var  array
@@ -122,8 +124,8 @@ class Auth_RADIUS extends PEAR {
      * @var  array
      * @see  dumpAttributes(), getAttributes()
      */
-    var $rawVendorAttributes = array();    
-    
+    var $rawVendorAttributes = array();
+
     /**
      * Constructor
      *
@@ -135,11 +137,11 @@ class Auth_RADIUS extends PEAR {
     {
         $this->PEAR();
     }
-    
+
     /**
      * Adds a RADIUS server to the list of servers for requests.
      *
-     * At most 10 servers may be specified.    When multiple servers 
+     * At most 10 servers may be specified.    When multiple servers 
      * are given, they are tried in round-robin fashion until a 
      * valid response is received
      *
@@ -148,12 +150,12 @@ class Auth_RADIUS extends PEAR {
      * @param  integer $port         Portnumber
      * @param  string  $sharedSecret Shared secret
      * @param  integer $timeout      Timeout for each request
-     * @param  integer $maxtries     Max. retries for each request          
+     * @param  integer $maxtries     Max. retries for each request
      * @return void
      */
     function addServer($servername = 'localhost', $port = 0, $sharedSecret = 'testing123', $timeout = 5, $maxtries = 3) 
     {
-        $this->_servers[] = array($servername, $port, $sharedSecret, $timeout, $maxtries);    
+        $this->_servers[] = array($servername, $port, $sharedSecret, $timeout, $maxtries);
     }
 
     /**
@@ -171,9 +173,9 @@ class Auth_RADIUS extends PEAR {
      * Sets the configuration-file.
      *
      * @access public
-     * @param  string  $file Path to the configuration file    
+     * @param  string  $file Path to the configuration file
      * @return void
-     */    
+     */
     function setConfigfile($file) 
     {
         $this->_configfile = $file;
@@ -187,7 +189,7 @@ class Auth_RADIUS extends PEAR {
      * @param  mixed   $port         Attribute-value
      * @param  type    $type         Attribute-type
      * @return bool  true on success, false on error
-     */    
+     */
     function putAttribute($attrib, $value, $type = null) 
     {
         if ($type == null) {
@@ -207,7 +209,7 @@ class Auth_RADIUS extends PEAR {
         }
 
     }
-    
+
     /**
      * Puts a vendor-specific attribute.
      *
@@ -220,30 +222,30 @@ class Auth_RADIUS extends PEAR {
      */ 
     function putVendorAttribute($vendor, $attrib, $value, $type = null) 
     {
-        
+
         if ($type == null) {
             $type = gettype($value);
         }
-        
+
         switch ($type) {
         case 'integer':
             return radius_put_vendor_int($this->res, $vendor, $attrib, $value);
-        
+
         case 'addr':
             return radius_put_vendor_addr($this->res, $vendor,$attrib, $value);
-            
+
         case 'string':
         default:
             return radius_put_vendor_attr($this->res, $vendor, $attrib, $value);
         }
-        
-    }    
+
+    }
 
     /**
      * Prints known attributes received from the server.
      *
      * @access public
-     */     
+     */
     function dumpAttributes()
     {
         foreach ($this->attributes as $name => $data) {
@@ -265,7 +267,7 @@ class Auth_RADIUS extends PEAR {
      * Overwrite this. 
      *
      * @access public
-     */         
+     */
     function open() 
     {
     }
@@ -274,23 +276,20 @@ class Auth_RADIUS extends PEAR {
      * Overwrite this.
      *
      * @access public
-     */         
+     */
     function createRequest()
     {
     }
-    
+
     /**
      * Puts standard attributes.
      *
      * These attributes will always be present in a radius request
      *
      * @access public
-     */ 
+     */
     function putStandardAttributes()
     {
-        // Not sure if these need to be in here but for the moment its ok
-        $this->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET);
-        $this->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_LOGIN);
 
         // Add support for sending NAS-IP-Address, set this explicitly as an ip_addr
         $this->putAttribute(RADIUS_NAS_IP_ADDRESS, getNasIP(), addr);
@@ -299,19 +298,19 @@ class Auth_RADIUS extends PEAR {
         $this->putAttribute(RADIUS_NAS_IDENTIFIER, getNasID());
 
     }
-    
+
     /**
      * Puts custom attributes.
      *
      * @access public
-     */ 
+     */
     function putAuthAttributes()
     {
         if (isset($this->username)) {
-            $this->putAttribute(RADIUS_USER_NAME, $this->username);        
+            $this->putAttribute(RADIUS_USER_NAME, $this->username);
         }
     }
-    
+
     /**
      * Configures the radius library.
      *
@@ -320,10 +319,10 @@ class Auth_RADIUS extends PEAR {
      * @param  integer $port         Portnumber
      * @param  string  $sharedSecret Shared secret
      * @param  integer $timeout      Timeout for each request
-     * @param  integer $maxtries     Max. retries for each request          
+     * @param  integer $maxtries     Max. retries for each request
      * @return bool  true on success, false on error
      * @see addServer()
-     */      
+     */
     function putServer($servername, $port = 0, $sharedsecret = 'testing123', $timeout = 3, $maxtries = 3) 
     {
         if (!radius_add_server($this->res, $servername, $port, $sharedsecret, $timeout, $maxtries)) {
@@ -331,22 +330,22 @@ class Auth_RADIUS extends PEAR {
         }
         return true;
     }
-    
+
     /**
      * Configures the radius library via external configurationfile
      *
      * @access public
      * @param  string  $servername   Servername or IP-Address
      * @return bool  true on success, false on error
-     */      
+     */
     function putConfigfile($file) 
     {
         if (!radius_config($this->res, $file)) {
             return false;
         }
         return true;
-    }    
-        
+    }
+
     /**
      * Initiates a RADIUS request. 
      *
@@ -358,32 +357,32 @@ class Auth_RADIUS extends PEAR {
         if (!$this->open()) {
             return false;
         }
-        
+
         foreach ($this->_servers as $s) {
-               // Servername, port, sharedsecret, timeout, retries
+            // Servername, port, sharedsecret, timeout, retries
             if (!$this->putServer($s[0], $s[1], $s[2], $s[3], $s[4])) {
                 return false;
             }
         }
-        
+
         if (!empty($this->_configfile)) {
             if (!$this->putConfigfile($this->_configfile)) {
                 return false;
             }
         }
-        
+
         $this->createRequest();
         $this->putStandardAttributes();
         $this->putAuthAttributes();
         return true;
     }
-    
+
     /**
      * Sends a prepared RADIUS request and waits for a response
      *
      * @access public
      * @return mixed  true on success, false on reject, PEAR_Error on error
-     */ 
+     */
     function send()
     {
         $req = radius_send_request($this->res);
@@ -400,7 +399,7 @@ class Auth_RADIUS extends PEAR {
 
         case RADIUS_ACCESS_REJECT:
             return false;
-            
+
         case RADIUS_ACCOUNTING_RESPONSE:
             if (is_subclass_of($this, 'auth_radius_pap')) {
                 return $this->raiseError('RADIUS_ACCOUNTING_RESPONSE is unexpected for authentication');
@@ -410,21 +409,21 @@ class Auth_RADIUS extends PEAR {
         default:
             return $this->raiseError("Unexpected return value: $req");
         }
-        
+
     }
 
     /**
      * Reads all received attributes after sending the request.
      *
-     * This methos stores know attributes in the property attributes, 
-     * all attributes (including known attibutes) are stored in rawAttributes 
+     * This methos stores know attributes in the property attributes,
+     * all attributes (including known attibutes) are stored in rawAttributes
      * or rawVendorAttributes.
-     * NOTE: call this functio also even if the request was rejected, because the 
+     * NOTE: call this functio also even if the request was rejected, because the
      * Server returns usualy an errormessage
      *
      * @access public
      * @return bool   true on success, false on error
-     */     
+     */
     function getAttributes()
     {
 
@@ -493,11 +492,11 @@ class Auth_RADIUS extends PEAR {
                 if (!is_array($attribv)) {
                     return false;
                 }
-                    
+
                 $vendor = $attribv['vendor'];
                 $attrv = $attribv['attr'];
                 $datav = $attribv['data'];
-                
+
                 $this->rawVendorAttributes[$vendor][$attrv] = $datav;
 
                 if ($vendor == RADIUS_VENDOR_MICROSOFT) {
@@ -552,7 +551,7 @@ class Auth_RADIUS extends PEAR {
                     }
                 }
 
-                if ($vendor == 3309) { /* RADIUS_VENDOR_NOMADIX */
+                if ($vendor == 3309) {    /* RADIUS_VENDOR_NOMADIX */
 
                     switch ($attrv) {
                     case 1: /* RADIUS_NOMADIX_BW_UP */
@@ -579,53 +578,53 @@ class Auth_RADIUS extends PEAR {
                     }
                 } 
 
-               if ($vendor == 14122) { /* RADIUS_VENDOR_WISPr Wi-Fi Alliance */
-
-                   switch ($attrv) {
-                   case 1: /* WISPr-Location-ID */
-                       $this->attributes['location_id'] = radius_cvt_string($datav);
-                       break;
-                   case 2: /* WISPr-Location-Name */
-                       $this->attributes['location_name'] = radius_cvt_string($datav);
-                       break;
-                   case 3: /* WISPr-Logoff-URL */
-                       $this->attributes['url_logoff'] = radius_cvt_string($datav);
-                       break;
-                   case 4: /* WISPr-Redirection-URL */
-                       $this->attributes['url_redirection'] = radius_cvt_string($datav);
-                       break;
-                   case 5: /* WISPr-Bandwidth-Min-Up */
-                       $this->attributes['bw_minbytesup'] = radius_cvt_int($datav);
-                       break;
-                   case 6: /* WISPr-Bandwidth-Min-Down */
-                       $this->attributes['bw_minbytesdown'] = radius_cvt_int($datav);
-                       break;
-                   case 7: /* WIPSr-Bandwidth-Max-Up */
-                       $this->attributes['bw_maxbytesup'] = radius_cvt_int($datav);
-                       break;
-                   case 8: /* WISPr-Bandwidth-Max-Down */
-                       $this->attributes['bw_maxbytesdown'] = radius_cvt_int($datav);
-                       break;
-                   case 9: /* WISPr-Session-Terminate-Time */
-                       $this->attributes['session_terminate_time'] = radius_cvt_string($datav);
-                       break;
-                   case 10: /* WISPr-Session-Terminate-End-Of-Day */
-                       $this->attributes['session_terminate_endofday'] = radius_cvt_int($datav);
-                       break;
-                   case 11: /* WISPr-Billing-Class-Of-Service */
-                       $this->attributes['billing_class_of_service'] = radius_cvt_string($datav);
-                       break;
-                  }
-               }
+        if ($vendor == 14122) { /* RADIUS_VENDOR_WISPr Wi-Fi Alliance */
+
+            switch ($attrv) {
+            case 1: /* WISPr-Location-ID */
+            $this->attributes['location_id'] = radius_cvt_string($datav);
+            break;
+            case 2: /* WISPr-Location-Name */
+            $this->attributes['location_name'] = radius_cvt_string($datav);
+            break;
+            case 3: /* WISPr-Logoff-URL */
+            $this->attributes['url_logoff'] = radius_cvt_string($datav);
+            break;
+            case 4: /* WISPr-Redirection-URL */
+            $this->attributes['url_redirection'] = radius_cvt_string($datav);
+            break;
+            case 5: /* WISPr-Bandwidth-Min-Up */
+            $this->attributes['bw_minbytesup'] = radius_cvt_int($datav);
+            break;
+            case 6: /* WISPr-Bandwidth-Min-Down */
+            $this->attributes['bw_minbytesdown'] = radius_cvt_int($datav);
+            break;
+            case 7: /* WIPSr-Bandwidth-Max-Up */
+            $this->attributes['bw_maxbytesup'] = radius_cvt_int($datav);
+            break;
+            case 8: /* WISPr-Bandwidth-Max-Down */
+            $this->attributes['bw_maxbytesdown'] = radius_cvt_int($datav);
+            break;
+            case 9: /* WISPr-Session-Terminate-Time */
+            $this->attributes['session_terminate_time'] = radius_cvt_string($datav);
+            break;
+            case 10: /* WISPr-Session-Terminate-End-Of-Day */
+            $this->attributes['session_terminate_endofday'] = radius_cvt_int($datav);
+            break;
+            case 11: /* WISPr-Billing-Class-Of-Service */
+            $this->attributes['billing_class_of_service'] = radius_cvt_string($datav);
+            break;
+           }
+        }
 
                 break;
-                
+
             }
-        }    
+        }
 
         return true;
     }
-    
+
     /**
      * Frees resources.
      *
@@ -633,7 +632,7 @@ class Auth_RADIUS extends PEAR {
      * attributes are filled with Nullbytes to leave nothing in the mem.
      *
      * @access public
-     */   
+     */
     function close()
     {
         if ($this->res != null) {
@@ -643,14 +642,14 @@ class Auth_RADIUS extends PEAR {
         $this->username = str_repeat("\0", strlen($this->username));
         $this->password = str_repeat("\0", strlen($this->password));
     }
-    
+
 }
 
 /**
  * class Auth_RADIUS_PAP
  *
  * Class for authenticating using PAP (Plaintext)
- * 
+ *
  * @package Auth_RADIUS 
  */
 class Auth_RADIUS_PAP extends Auth_RADIUS 
@@ -669,7 +668,7 @@ class Auth_RADIUS_PAP extends Auth_RADIUS
         $this->username = $username;
         $this->password = $password;
     }
-    
+
     /**
      * Creates a RADIUS resource
      *
@@ -686,7 +685,7 @@ class Auth_RADIUS_PAP extends Auth_RADIUS
         }
         return true;
     }
-    
+
     /**
      * Creates an authentication request 
      *
@@ -711,7 +710,7 @@ class Auth_RADIUS_PAP extends Auth_RADIUS
     function putAuthAttributes()
     {
         if (isset($this->username)) {
-            $this->putAttribute(RADIUS_USER_NAME, $this->username);        
+            $this->putAttribute(RADIUS_USER_NAME, $this->username);
         }
         if (isset($this->password)) {
             $this->putAttribute(RADIUS_USER_PASSWORD, $this->password);
@@ -726,7 +725,7 @@ class Auth_RADIUS_PAP extends Auth_RADIUS
  * Class for authenticating using CHAP-MD5 see RFC1994.
  * Instead og the plaintext password the challenge and 
  * the response are needed.
- * 
+ *
  * @package Auth_RADIUS 
  */
 class Auth_RADIUS_CHAP_MD5 extends Auth_RADIUS_PAP
@@ -742,13 +741,13 @@ class Auth_RADIUS_CHAP_MD5 extends Auth_RADIUS_PAP
      * @var  string
      */
     var $response = null;
-    
+
     /**
      * Id of the authentication request. Should incremented after every request.
      * @var  integer
      */
     var $chapid = 1;
-    
+
     /**
      * Constructor
      *
@@ -764,7 +763,7 @@ class Auth_RADIUS_CHAP_MD5 extends Auth_RADIUS_PAP
         $this->challenge = $challenge;
         $this->chapid = $chapid;
     }
-    
+
     /**
      * Put CHAP-MD5 specific attributes
      *
@@ -786,7 +785,7 @@ class Auth_RADIUS_CHAP_MD5 extends Auth_RADIUS_PAP
             $this->putAttribute(RADIUS_CHAP_CHALLENGE, $this->challenge);
         }
     }
-    
+
     /**
      * Frees resources.
      *
@@ -794,21 +793,21 @@ class Auth_RADIUS_CHAP_MD5 extends Auth_RADIUS_PAP
      * attributes are filled with Nullbytes to leave nothing in the mem.
      *
      * @access public
-     */   
+     */
     function close()
     {
         Auth_RADIUS_PAP::close();
         $this->challenge =  str_repeat("\0", strlen($this->challenge));
         $this->response =  str_repeat("\0", strlen($this->response));
-    }    
-    
+    }
+
 }
 
 /**
  * class Auth_RADIUS_MSCHAPv1
  *
  * Class for authenticating using MS-CHAPv1 see RFC2433
- * 
+ *
  * @package Auth_RADIUS 
  */
 class Auth_RADIUS_MSCHAPv1 extends Auth_RADIUS_CHAP_MD5 
@@ -825,7 +824,7 @@ class Auth_RADIUS_MSCHAPv1 extends Auth_RADIUS_CHAP_MD5
      * @var  bool
      */
     var $flags = 1;
-    
+
     /**
      * Put MS-CHAPv1 specific attributes 
      *
@@ -837,13 +836,13 @@ class Auth_RADIUS_MSCHAPv1 extends Auth_RADIUS_CHAP_MD5
      *   u_char lm_response[24];
      *   u_char response[24];
      * };
-     * 
+     *
      * @return void
      */
     function putAuthAttributes()
     {
         if (isset($this->username)) {
-            $this->putAttribute(RADIUS_USER_NAME, $this->username);        
+            $this->putAttribute(RADIUS_USER_NAME, $this->username);
         }
         if (isset($this->response) || isset($this->lmResponse)) {
             $lmResp = isset($this->lmResponse) ? $this->lmResponse : str_repeat ("\0", 24);
@@ -851,17 +850,17 @@ class Auth_RADIUS_MSCHAPv1 extends Auth_RADIUS_CHAP_MD5
             $resp = pack('CC', $this->chapid, $this->flags) . $lmResp . $ntResp;
             $this->putVendorAttribute(RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_RESPONSE, $resp);
         }
-        if (isset($this->challenge)) {        
+        if (isset($this->challenge)) {
             $this->putVendorAttribute(RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_CHALLENGE, $this->challenge);
         }
-    }    
+    }
 }
 
 /**
  * class Auth_RADIUS_MSCHAPv2
  *
  * Class for authenticating using MS-CHAPv2 see RFC2759
- * 
+ *
  * @package Auth_RADIUS 
  */
 class Auth_RADIUS_MSCHAPv2 extends Auth_RADIUS_MSCHAPv1 
@@ -871,7 +870,7 @@ class Auth_RADIUS_MSCHAPv2 extends Auth_RADIUS_MSCHAPv1
      * @var  string
      */
     var $challenge = null;
-    
+
     /**
      * 16 Bytes binary Peer Challenge
      * @var  string
@@ -892,7 +891,7 @@ class Auth_RADIUS_MSCHAPv2 extends Auth_RADIUS_MSCHAPv1
      * };
      * where pchallenge is the peer challenge. Like for MS-CHAPv1 we set the flags field to 1.
      * @return void
-     */    
+     */
     function putAuthAttributes()
     {
         if (isset($this->username)) {
@@ -906,8 +905,8 @@ class Auth_RADIUS_MSCHAPv2 extends Auth_RADIUS_MSCHAPv1
         if (isset($this->challenge)) {
             $this->putVendorAttribute(RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_CHALLENGE, $this->challenge);
         }
-    }    
-    
+    }
+
     /**
      * Frees resources.
      *
@@ -920,7 +919,7 @@ class Auth_RADIUS_MSCHAPv2 extends Auth_RADIUS_MSCHAPv1
     {
         Auth_RADIUS_MSCHAPv1::close();
         $this->peerChallenge = str_repeat("\0", strlen($this->peerChallenge));
-    }       
+    }
 }
 
 /**
@@ -957,7 +956,7 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
      * @var  string
      */    
     var $session_id = null;
-    
+
     /**
      * Constructor
      *
@@ -969,7 +968,7 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
     function Auth_RADIUS_Acct()
     {
         $this->Auth_RADIUS();
-        
+
         if (isset($_SERVER)) {
             $var = &$_SERVER;
         } else {
@@ -1021,8 +1020,8 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
             return false;
         }
         return true;
-    }   
-   
+    }
+
   /**
      * Put attributes for accounting.
      *
@@ -1032,9 +1031,9 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
      */ 
     function putAuthAttributes()
     {
-        /* Remove the internal ACCT_SESSION_ID function since we are going to set it manually
-        $this->putAttribute(RADIUS_ACCT_SESSION_ID, $this->session_id);
-        */
+        if (isset($this->username)) {
+            $this->putAttribute(RADIUS_USER_NAME, $this->username);
+        }
         $this->putAttribute(RADIUS_ACCT_STATUS_TYPE, $this->status_type);
         if (isset($this->session_time) && $this->status_type == RADIUS_STOP) {
             $this->putAttribute(RADIUS_ACCT_SESSION_TIME, $this->session_time);
@@ -1042,9 +1041,9 @@ class Auth_RADIUS_Acct extends Auth_RADIUS
         if (isset($this->authentic)) {
             $this->putAttribute(RADIUS_ACCT_AUTHENTIC, $this->authentic);
         }
-        
-    }    
-    
+
+    }
+
 }
 
 /**
@@ -1060,7 +1059,7 @@ class Auth_RADIUS_Acct_Start extends Auth_RADIUS_Acct
      * Defines the type of the accounting request.
      * It is set to RADIUS_START by default in this class.
      * @var  integer
-     */    
+     */
     var $status_type = RADIUS_START;
 }