]> git.ozlabs.org Git - ppp.git/commitdiff
Add support for radius Class attribute. Possibly broken if chap is set to
authorFrank Cusack <fcusack@fcusack.com>
Thu, 12 Sep 2002 05:41:49 +0000 (05:41 +0000)
committerFrank Cusack <fcusack@fcusack.com>
Thu, 12 Sep 2002 05:41:49 +0000 (05:41 +0000)
re-authenticate and the radius server decides to change or add the Class
attribute on a subsequent (non-initial) authentication, but no more broken
than not handling it at all.

pppd/plugins/radius/radius.c
pppd/plugins/radius/radiusclient/etc/dictionary

index 73f2b943e04a1f90bc92253fb0a3785d3b0f9477..27243b15b7c155f55973c5968d44a237004e105d 100644 (file)
@@ -24,7 +24,7 @@
 *
 ***********************************************************************/
 static char const RCSID[] =
-"$Id: radius.c,v 1.14 2002/09/01 08:56:01 kad Exp $";
+"$Id: radius.c,v 1.15 2002/09/12 05:41:49 fcusack Exp $";
 
 #include "pppd.h"
 #include "chap.h"
@@ -40,6 +40,7 @@ static char const RCSID[] =
 #include <syslog.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#include <string.h>
 
 #define BUF_LEN 1024
 
@@ -81,6 +82,10 @@ static int radius_setmppekeys2(VALUE_PAIR *vp, REQUEST_INFO *req_info);
 #define MAXSESSIONID 32
 #endif
 
+#ifndef MAXCLASSLEN
+#define MAXCLASSLEN 500
+#endif
+
 struct radius_state {
     int accounting_started;
     int initialized;
@@ -96,6 +101,8 @@ struct radius_state {
     int acct_interim_interval;
     SERVER *authserver;                /* Authentication server to use */
     SERVER *acctserver;                /* Accounting server to use */
+    int class_len;
+    char class[MAXCLASSLEN];
 };
 
 void (*radius_attributes_hook)(VALUE_PAIR *) = NULL;
@@ -544,7 +551,16 @@ radius_setparams(chap_state *cstate, VALUE_PAIR *vp, char *msg,
                    rstate.ip_addr = remote;
                }
                break;
+           case PW_CLASS:
+               /* Save Class attribute to pass it in accounting request */
+               if (vp->lvalue <= MAXCLASSLEN) {
+                   rstate.class_len=vp->lvalue;
+                   memcpy(rstate.class, vp->strvalue, rstate.class_len);
+               } /* else too big for our buffer - ignore it */
+               break;
            }
+
+
 #ifdef CHAPMS
        } else if (vp->vendorcode == VENDOR_MICROSOFT) {
            switch (vp->attribute) {
@@ -756,6 +772,10 @@ radius_acct_start(void)
     rc_avpair_add(&send, PW_USER_NAME,
                   rstate.user, 0, VENDOR_NONE);
 
+    if (rstate.class_len > 0)
+       rc_avpair_add(&send, PW_CLASS,
+                     rstate.class, rstate.class_len, VENDOR_NONE);
+
     av_type = PW_STATUS_START;
     rc_avpair_add(&send, PW_ACCT_STATUS_TYPE, &av_type, 0, VENDOR_NONE);
 
index 48c7e0e201bca5ad19042f50b441fba659603801..903824dbfcce1678f7974c0307dd165d2a4ee65e 100644 (file)
@@ -65,6 +65,7 @@ ATTRIBUTE     Callback-Id             20      string
 ATTRIBUTE      Framed-Route            22      string
 ATTRIBUTE      Framed-IPX-Network      23      ipaddr
 ATTRIBUTE      State                   24      string
+ATTRIBUTE      Class                   25      string
 ATTRIBUTE      Session-Timeout         27      integer
 ATTRIBUTE      Idle-Timeout            28      integer
 ATTRIBUTE      Termination-Action      29      integer