/[radius]/radius/radiusd/acct.c
ViewVC logotype

Diff of /radius/radiusd/acct.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.52 by gray, Fri Aug 2 11:18:43 2002 UTC revision 1.53 by gray, Fri Apr 18 05:27:10 2003 UTC
# Line 1  Line 1 
1  /* This file is part of GNU RADIUS.  /* This file is part of GNU Radius.
2     Copyright (C) 2000,2001, Sergey Poznyakoff     Copyright (C) 2000,2001, Sergey Poznyakoff
3    
4     This program is free software; you can redistribute it and/or modify     GNU Radius is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.     (at your option) any later version.
8    
9     This program is distributed in the hope that it will be useful,     GNU Radius is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.     GNU General Public License for more details.
13    
14     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software Foundation,     along with GNU Radius; if not, write to the Free Software Foundation,
16     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17    
18  #define RADIUS_MODULE_ACCT_C  #define RADIUS_MODULE_ACCT_C
19    
 #ifndef lint  
 static char rcsid[] =  
 "@(#) $Id$";  
 #endif  
20  #define LOG_EMPTY_USERNAME  #define LOG_EMPTY_USERNAME
21    
22  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
# Line 64  int rad_acct_ext(RADIUS_REQ *radreq); Line 60  int rad_acct_ext(RADIUS_REQ *radreq);
60    
61  /* Zap a user, or all users on a NAS, from the radutmp file. */  /* Zap a user, or all users on a NAS, from the radutmp file. */
62  int  int
63  radzap(nasaddr, port, user, t)  radzap(UINT4 nasaddr, int port, char *user, time_t t)
         UINT4 nasaddr;  
         int port;  
         char *user;  
         time_t t;  
64  {  {
65          struct radutmp  *up;          struct radutmp  *up;
66          radut_file_t    file;          radut_file_t    file;
# Line 99  radzap(nasaddr, port, user, t) Line 91  radzap(nasaddr, port, user, t)
91  }  }
92    
93  static void  static void
94  store_session_id(buffer, len, id, idlen)  store_session_id(char *buffer, int len, char *id, int idlen)
         char *buffer;  
         int len;  
         char *id;  
         int idlen;  
95  {  {
96          int off = idlen - len;          int off = idlen - len;
97          if (off < 0)          if (off < 0)
# Line 113  store_session_id(buffer, len, id, idlen) Line 101  store_session_id(buffer, len, id, idlen)
101  }  }
102    
103  int  int
104  write_wtmp(ut)  write_wtmp(struct radutmp *ut)
         struct radutmp *ut;  
105  {  {
106          return radwtmp_putent(radwtmp_path, ut);          return radwtmp_putent(radwtmp_path, ut);
107  }  }
108    
109  void  void
110  backslashify(dst, src, len)  backslashify(char *dst, char *src, int len)
         char *dst;  
         char *src;  
         int len;  
111  {  {
112  #define CHECK(l,m) \  #define CHECK(l,m) \
113   if (l <= m) goto end; else l -= m   if (l <= m) goto end; else l -= m
# Line 168  end: Line 152  end:
152  }  }
153    
154  int  int
155  check_attribute(check_pairs, pair_attr, pair_value, def)  check_attribute(VALUE_PAIR *check_pairs, int pair_attr,
156          VALUE_PAIR *check_pairs;                  int pair_value, int def)
         int pair_attr;  
         int pair_value;  
         int def;  
157  {  {
158          VALUE_PAIR *pair;          VALUE_PAIR *pair;
159    
# Line 195  check_attribute(check_pairs, pair_attr, Line 176  check_attribute(check_pairs, pair_attr,
176    
177  /*  Store logins in the RADIUS utmp file. */  /*  Store logins in the RADIUS utmp file. */
178  int  int
179  rad_acct_system(radreq, dowtmp)  rad_acct_system(RADIUS_REQ *radreq, int dowtmp)
         RADIUS_REQ *radreq;  
         int dowtmp;  
180  {  {
181          struct radutmp  ut;          struct radutmp  ut;
182          VALUE_PAIR *vp;          VALUE_PAIR *vp;
# Line 453  check_acct_dir() Line 432  check_acct_dir()
432  }  }
433    
434  int  int
435  write_detail(radreq, authtype, f)  write_detail(RADIUS_REQ *radreq, int authtype, char *f)
         RADIUS_REQ *radreq;  
         int authtype;  
         char *f;  
436  {  {
437          FILE            *outfd;          FILE            *outfd;
438          char            nasname[MAX_LONGNAME];          char            nasname[MAX_LONGNAME];
# Line 570  write_detail(radreq, authtype, f) Line 546  write_detail(radreq, authtype, f)
546  }  }
547    
548  int  int
549  rad_acct_db(radreq, authtype)  rad_acct_db(RADIUS_REQ *radreq, int authtype)
         RADIUS_REQ *radreq;  
         int authtype;  
550  {  {
551          int rc = 0;          int rc = 0;
552    
# Line 586  rad_acct_db(radreq, authtype) Line 560  rad_acct_db(radreq, authtype)
560  }  }
561    
562  int  int
563  rad_acct_ext(radreq)  rad_acct_ext(RADIUS_REQ *radreq)
         RADIUS_REQ *radreq;  
564  {  {
565          VALUE_PAIR *p;          VALUE_PAIR *p;
566    
# Line 614  rad_acct_ext(radreq) Line 587  rad_acct_ext(radreq)
587    
588  /* run accounting modules */  /* run accounting modules */
589  int  int
590  rad_accounting(radreq, activefd)  rad_accounting(RADIUS_REQ *radreq, int activefd, int verified)
         RADIUS_REQ *radreq;  
         int activefd;  
591  {  {
         int auth;  
   
592          log_open(L_ACCT);          log_open(L_ACCT);
         /* See if we know this client, then check the request authenticator. */  
         auth = calc_acctdigest(radreq);  
         if (auth == REQ_AUTH_BAD)  
                 stat_inc(acct, radreq->ipaddr, num_bad_sign);  
593    
594          huntgroup_access(radreq);          huntgroup_access(radreq);
595    
596  #if defined(RT_ASCEND_EVENT_REQUEST) && defined(RT_ASCEND_EVENT_RESPONSE)  #if defined(RT_ASCEND_EVENT_REQUEST) && defined(RT_ASCEND_EVENT_RESPONSE)
597          /* Special handling for Ascend-Event-Request */          /* Special handling for Ascend-Event-Request */
598          if (radreq->code == RT_ASCEND_EVENT_REQUEST) {          if (radreq->code == RT_ASCEND_EVENT_REQUEST) {
599                  write_detail(radreq, auth, "detail");                  write_detail(radreq, verified, "detail");
600                  rad_send_reply(RT_ASCEND_EVENT_RESPONSE,                  radius_send_reply(RT_ASCEND_EVENT_RESPONSE,
601                                 radreq, NULL, NULL, activefd);                                    radreq, NULL, NULL, activefd);
602                  stat_inc(acct, radreq->ipaddr, num_resp);                  stat_inc(acct, radreq->ipaddr, num_resp);
603                  return 0;                  return 0;
604          }          }
605  #endif  #endif
606                    
607          if (rad_acct_system(radreq, doradwtmp) == 0 &&          if (rad_acct_system(radreq, doradwtmp) == 0 &&
608              rad_acct_db(radreq, auth) == 0 &&              rad_acct_db(radreq, verified) == 0 &&
609              rad_acct_ext(radreq) == 0) {              rad_acct_ext(radreq) == 0) {
610                  /* Now send back an ACK to the NAS. */                  /* Now send back an ACK to the NAS. */
611                  rad_send_reply(RT_ACCOUNTING_RESPONSE,                  radius_send_reply(RT_ACCOUNTING_RESPONSE,
612                                 radreq, NULL, NULL, activefd);                                 radreq, NULL, NULL, activefd);
613                  stat_inc(acct, radreq->ipaddr, num_resp);                  stat_inc(acct, radreq->ipaddr, num_resp);
614                  return 0;                  return 0;
# Line 658  rad_accounting(radreq, activefd) Line 623  rad_accounting(radreq, activefd)
623          0 if user is not logged in */          0 if user is not logged in */
624    
625  static int  static int
626  rad_check_ts(ut)  rad_check_ts(struct radutmp *ut)
         struct radutmp *ut;  
627  {  {
628          int result;          int result;
629                    
# Line 685  rad_check_ts(ut) Line 649  rad_check_ts(ut)
649  /* Return value: that of CHECKRAD process, i.e. 1 means true (user FOUND)  /* Return value: that of CHECKRAD process, i.e. 1 means true (user FOUND)
650     0 means false (user NOT found) */     0 means false (user NOT found) */
651  static int  static int
652  check_ts(ut)  check_ts(struct radutmp *ut)
         struct radutmp *ut;  
653  {  {
654          NAS     *nas;          NAS     *nas;
655    
# Line 706  check_ts(ut) Line 669  check_ts(ut)
669  }  }
670    
671  int  int
672  rad_check_realm(realm)  rad_check_realm(REALM *realm)
         REALM *realm;  
673  {  {
674          int count;          int count;
675          struct radutmp *up;          struct radutmp *up;
# Line 766  rad_check_realm(realm) Line 728  rad_check_realm(realm)
728        0 == OK,        0 == OK,
729        1 == user exceeds its simultaneous-use parameter */        1 == user exceeds its simultaneous-use parameter */
730  int  int
731  rad_check_multi(name, request, maxsimul, pcount)  rad_check_multi(char *name, VALUE_PAIR *request, int maxsimul, int *pcount)
         char *name;  
         VALUE_PAIR *request;  
         int maxsimul;  
         int *pcount;  
732  {  {
733          radut_file_t file;          radut_file_t file;
734          int             count;          int             count;
# Line 838  rad_check_multi(name, request, maxsimul, Line 796  rad_check_multi(name, request, maxsimul,
796  }  }
797    
798  int  int
799  write_nas_restart(status, addr)  write_nas_restart(int status, UINT4 addr)
         int status;  
         UINT4 addr;  
800  {  {
801          struct radutmp ut;          struct radutmp ut;
802    

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26