~ubuntu-branches/ubuntu/dapper/freeradius/dapper-updates

« back to all changes in this revision

Viewing changes to src/main/acct.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Hampson
  • Date: 2006-01-15 13:34:13 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060115133413-92geefww41y7hqi8
Tags: 1.1.0-1
* ReDebianise upstream tarball:
  - Deleted RFCs: 2243 2289 2433 2548 2618 2619 2620 2621 2716 2759 2809 2865
                  2866 2867 2868 2869 2882 2924 3162 3575 3576 3579 3580
                  draft-kamath-pppext-eap-mschapv2-00

* New FreeRADIUS modules marked stable by new upstream release
  - rlm_perl
  - rlm_sqlcounter
  - rlm_sql_log + radsqlrelay
  - rlm_otp (formerly rlm_x99_token, not built as it depends on OpenSSL)

* Remove upstream-integrated patches:
  - 02_EAP-SIM_doesnt_need_openssl
  - 03_X99_is_not_stable
  - 07_manpage_fixups
  - 09_use_crypth_if_we_have_it
  - 10_escape_entire_ldap_string
  - 11_dont_xlat_possibly_bad_usernames_in_bad_accounting_packets
  - 12_dialup_admin_various_fixes

* More dialup-admin fixes from Arve Seljebu
  - Fix redirects in dialup-admin pages on servers with
    register_globals turned off.
    Closes: #333704
  - HTTP form fields will always fail is_int, use in_numeric instead
    Closes: #335149
  - Created 12_more_dialup_admin_various_fixes

* Update to Policy 3.6.2.0
* Upgrade Debhelper support to V5
* Don't install the .in files with the examples
* Prefer libmysqlclient15-dev
  Closes: #343779
* Shared secrets can only be 31 characters long, note this in clients.conf
  - Created 02_document_actual_shared_secret_maximum_length
  Closes: 344606
* Added support for lsb-init functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * acct.c       Accounting routines.
3
3
 *
4
 
 * Version:     $Id: acct.c,v 1.30.2.2 2005/07/11 13:47:45 nbk Exp $
 
4
 * Version:     $Id: acct.c,v 1.30.2.4 2005/10/31 17:34:04 nbk Exp $
5
5
 *
6
6
 *   This program is free software; you can redistribute it and/or modify
7
7
 *   it under the terms of the GNU General Public License as published by
23
23
 * Copyright 2000  Alan Curry <pacman@world.std.com>
24
24
 */
25
25
 
26
 
static const char rcsid[] = "$Id: acct.c,v 1.30.2.2 2005/07/11 13:47:45 nbk Exp $";
 
26
static const char rcsid[] = "$Id: acct.c,v 1.30.2.4 2005/10/31 17:34:04 nbk Exp $";
27
27
 
28
28
#include "autoconf.h"
29
 
#include "libradius.h"
30
29
 
31
30
#include <stdlib.h>
32
 
#include <string.h>
33
31
 
34
32
#include "radiusd.h"
35
33
#include "modules.h"
36
34
 
37
 
 
38
35
/*
39
36
 *      rad_accounting: call modules.
40
37
 *
43
40
 */
44
41
int rad_accounting(REQUEST *request)
45
42
{
46
 
        int             reply = RLM_MODULE_OK;
 
43
        int result = RLM_MODULE_OK;
47
44
 
48
 
        if (!request->proxy) { /* Only need to do this once, before proxying */
 
45
        /*
 
46
         *      Run the modules only once, before proxying.
 
47
         */
 
48
        if (!request->proxy) {
49
49
                char            *exec_program;
50
50
                int             exec_wait;
51
51
                VALUE_PAIR      *vp;
52
52
                int             rcode;
53
53
                int             acct_type = 0;
54
54
 
55
 
                reply = module_preacct(request);
56
 
                if (reply != RLM_MODULE_NOOP &&
57
 
                    reply != RLM_MODULE_OK &&
58
 
                    reply != RLM_MODULE_UPDATED)
59
 
                        return reply;
 
55
                result = module_preacct(request);
 
56
                switch (result) {
 
57
                        /*
 
58
                         *      The module has a number of OK return codes.
 
59
                         */
 
60
                        case RLM_MODULE_NOOP:
 
61
                        case RLM_MODULE_OK:
 
62
                        case RLM_MODULE_UPDATED:
 
63
                                break;
 
64
                        /*
 
65
                         *      The module handled the request, stop here.
 
66
                         */
 
67
                        case RLM_MODULE_HANDLED:
 
68
                                return result;
 
69
                        /*
 
70
                         *      The module failed, or said the request is
 
71
                         *      invalid, therefore we stop here.
 
72
                         */
 
73
                        case RLM_MODULE_FAIL:
 
74
                        case RLM_MODULE_INVALID:
 
75
                        case RLM_MODULE_NOTFOUND:
 
76
                        case RLM_MODULE_REJECT:
 
77
                        case RLM_MODULE_USERLOCK:
 
78
                        default:
 
79
                                return result;
 
80
                }
60
81
 
61
82
                /*
62
 
                 *      Do accounting, ONLY the first time through.
63
 
                 *      This is to ensure that we log the packet
64
 
                 *      immediately, even if the proxy never does.
 
83
                 *      Do the data storage before proxying. This is to ensure
 
84
                 *      that we log the packet, even if the proxy never does.
65
85
                 */
66
86
                vp = pairfind(request->config_items, PW_ACCT_TYPE);
67
 
                if (vp)
 
87
                if (vp) {
 
88
                        DEBUG2("  Found Acct-Type %s", vp->strvalue);
68
89
                        acct_type = vp->lvalue;
69
 
                reply = module_accounting(acct_type,request);
 
90
                }
 
91
                result = module_accounting(acct_type, request);
 
92
                switch (result) {
 
93
                        /*
 
94
                         *      In case the accounting module returns FAIL,
 
95
                         *      it's still useful to send the data to the
 
96
                         *      proxy.
 
97
                         */
 
98
                        case RLM_MODULE_FAIL:
 
99
                        case RLM_MODULE_NOOP:
 
100
                        case RLM_MODULE_OK:
 
101
                        case RLM_MODULE_UPDATED:
 
102
                                break;
 
103
                        /*
 
104
                         *      The module handled the request, don't reply.
 
105
                         */
 
106
                        case RLM_MODULE_HANDLED:
 
107
                                return result;
 
108
                        /*
 
109
                         *      Neither proxy, nor reply to invalid requests.
 
110
                         */
 
111
                        case RLM_MODULE_INVALID:
 
112
                        case RLM_MODULE_NOTFOUND:
 
113
                        case RLM_MODULE_REJECT:
 
114
                        case RLM_MODULE_USERLOCK:
 
115
                        default:
 
116
                                return result;
 
117
                }
70
118
 
71
119
                /*
72
120
                 *      See if we need to execute a program.
118
166
 
119
167
                        if (exec_wait) {
120
168
                                if (rcode != 0) {
121
 
                                        return reply;
 
169
                                        return result;
122
170
                                }
123
171
                        }
124
172
                }
142
190
                        } else {
143
191
                                /*
144
192
                                 *      Don't reply to the NAS now because
145
 
                                 *      we have to send the proxied packet.
 
193
                                 *      we have to send the proxied packet
 
194
                                 *      before that.
146
195
                                 */
147
 
                                return reply;
 
196
                                return result;
148
197
                        }
149
198
                }
150
199
        }
157
206
         *      storage did not succeed, so radiusd should not send
158
207
         *      Accounting-Response.
159
208
         */
160
 
        if (reply == RLM_MODULE_OK ||
161
 
            reply == RLM_MODULE_UPDATED) {
162
 
 
163
 
                /*
164
 
                 *      Now send back an ACK to the NAS.
165
 
                 */
166
 
                request->reply->code = PW_ACCOUNTING_RESPONSE;
 
209
        switch (result) {
 
210
                /*
 
211
                 *      Send back an ACK to the NAS.
 
212
                 */
 
213
                case RLM_MODULE_OK:
 
214
                case RLM_MODULE_UPDATED:
 
215
                        request->reply->code = PW_ACCOUNTING_RESPONSE;
 
216
                        break;
 
217
                /*
 
218
                 *      The module handled the request, don't reply.
 
219
                 */
 
220
                case RLM_MODULE_HANDLED:
 
221
                        break;
 
222
                /*
 
223
                 *      Failed to log or to proxy the accounting data,
 
224
                 *      therefore don't reply to the NAS.
 
225
                 */
 
226
                case RLM_MODULE_FAIL:
 
227
                case RLM_MODULE_INVALID:
 
228
                case RLM_MODULE_NOOP:
 
229
                case RLM_MODULE_NOTFOUND:
 
230
                case RLM_MODULE_REJECT:
 
231
                case RLM_MODULE_USERLOCK:
 
232
                default:
 
233
                        break;
167
234
        }
168
 
 
169
 
        return reply;
 
235
        return result;
170
236
}