~ubuntu-branches/ubuntu/natty/freeradius/natty-updates

« back to all changes in this revision

Viewing changes to src/include/radiusd.h

  • Committer: Bazaar Package Importer
  • Author(s): Josip Rodin
  • Date: 2009-11-23 03:57:37 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20091123035737-zsgtzhfych8hir68
Tags: 2.1.7+dfsg-1
* Adopting the package, closes: #536623.
* New upstream version, closes: #513484.
  + Fixes the blooper in unlang evaluation logic, closes: #526175.
* Used quilt (and added README.source), and moved upstream file patching
  into debian/patches/. The source is no longer in collab-maint git
  (to make it simpler for me to finally get this out the door), but
  kept the .gitignore should we need that again.
* Dropped the dialup_admin/bin/backup_radacct patch (integrated upstream).
* Dropped the raddb/Makefile patch (problem no longer exists upstream).
* Dropped the lib/packet.c lib/radius.c main/listen.c patches (was from
  upstream 2.0.5 anyway).
* Dropped references to otp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Dropped references to snmp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Ship /etc/freeradius/modules/* in the freeradius package.
* Stop shipping sites-enabled symlinks in the package and instead create
  them only on initial install, thanks to Matej Vela, closes: #533396.
* Add export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" to the init script
  at the request of John Morrissey, closes: #550143.
* Stop installing /var/run/freeradius in the package to silence Lintian.
  The init script already recreates it at will.
* Remove executable bit from example.pl to silence Lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * radiusd.h    Structures, prototypes and global variables
5
5
 *              for the FreeRADIUS server.
6
6
 *
7
 
 * Version:     $Id: radiusd.h,v 1.263 2008/04/30 10:00:53 aland Exp $
 
7
 * Version:     $Id$
8
8
 *
9
9
 *   This program is free software; you can redistribute it and/or modify
10
10
 *   it under the terms of the GNU General Public License as published by
25
25
 */
26
26
 
27
27
#include <freeradius-devel/ident.h>
28
 
RCSIDH(radiusd_h, "$Id: radiusd.h,v 1.263 2008/04/30 10:00:53 aland Exp $")
 
28
RCSIDH(radiusd_h, "$Id$")
29
29
 
30
30
#include <freeradius-devel/libradius.h>
31
31
#include <freeradius-devel/radpaths.h>
35
35
 
36
36
typedef struct auth_req REQUEST;
37
37
 
38
 
#include <freeradius-devel/realms.h>
39
 
 
40
38
#ifdef HAVE_PTHREAD_H
41
39
#include        <pthread.h>
42
 
typedef pthread_t child_pid_t;
43
 
#define child_kill pthread_kill
44
 
#else
45
 
typedef pid_t child_pid_t;
46
 
#define child_kill kill
47
40
#endif
48
41
 
49
 
#define NO_SUCH_CHILD_PID (child_pid_t) (0)
50
 
 
51
42
#ifndef NDEBUG
52
43
#define REQUEST_MAGIC (0xdeadbeef)
53
44
#endif
54
45
 
55
46
/*
 
47
 *      New defines for minimizing the size of the server, to strip
 
48
 *      out functionality.  In order to ensure that people don't have
 
49
 *      to re-run "configure", after "cvs update", we play some
 
50
 *      special games with the defines.  i.e. any top-level "configure"
 
51
 *      option should set both WITH_FOO and WITHOUT_FOO.  After a few
 
52
 *      weeks, the WITHOUT_FOO can be deleted from the configure script.
 
53
 */
 
54
#ifndef WITHOUT_PROXY
 
55
#define WITH_PROXY (1)
 
56
#endif
 
57
 
 
58
#ifndef WITHOUT_DETAIL
 
59
#define WITH_DETAIL (1)
 
60
#endif
 
61
 
 
62
#ifndef WITHOUT_SESSION_MGMT
 
63
#define WITH_SESSION_MGMT (1)
 
64
#endif
 
65
 
 
66
#ifndef WITHOUT_UNLANG
 
67
#define WITH_UNLANG (1)
 
68
#endif
 
69
 
 
70
#ifndef WITHOUT_ACCOUNTING
 
71
#define WITH_ACCOUNTING (1)
 
72
#else
 
73
#ifdef WITH_SESSION_MGMT
 
74
#error WITH_SESSION_MGMT is defined, but WITH_ACCOUNTING is not.  Session management requires accounting.
 
75
#endif
 
76
#ifdef WITH_DETAIL
 
77
#error WITH_DETAIL is defined, but WITH_ACCOUNTING is not.  Detail file reading requires accounting.
 
78
#endif
 
79
#endif
 
80
 
 
81
#ifndef WITHOUT_DYNAMIC_CLIENTS
 
82
#define WITH_DYNAMIC_CLIENTS (1)
 
83
#endif
 
84
 
 
85
#ifndef WITHOUT_STATS
 
86
#define WITH_STATS
 
87
#endif
 
88
 
 
89
#ifndef WITHOUT_COMMAND_SOCKET
 
90
#ifdef HAVE_SYS_UN_H
 
91
#define WITH_COMMAND_SOCKET (1)
 
92
#endif
 
93
#endif
 
94
 
 
95
#ifndef WITHOUT_COA
 
96
#define WITH_COA (1)
 
97
#ifndef WITH_PROXY
 
98
#error WITH_COA requires WITH_PROXY
 
99
#endif
 
100
#endif
 
101
 
 
102
#include <freeradius-devel/stats.h>
 
103
#include <freeradius-devel/realms.h>
 
104
 
 
105
 
 
106
/*
56
107
 *      See util.c
57
108
 */
58
109
typedef struct request_data_t request_data_t;
59
110
 
60
 
typedef struct rad_snmp_client_entry_t rad_snmp_client_entry_t;
61
 
 
62
111
typedef struct radclient {
63
112
        fr_ipaddr_t             ipaddr;
64
113
        int                     prefix;
72
121
        char                    *server;
73
122
        int                     number; /* internal use only */
74
123
        const CONF_SECTION      *cs;
75
 
#ifdef WITH_SNMP
76
 
        rad_snmp_client_entry_t *auth, *acct;
 
124
#ifdef WITH_STATS
 
125
        fr_stats_t              *auth;
 
126
#ifdef WITH_ACCOUNTING
 
127
        fr_stats_t              *acct;
 
128
#endif
 
129
#endif
 
130
 
 
131
#ifdef WITH_DYNAMIC_CLIENTS
 
132
        int                     lifetime;
 
133
        int                     dynamic; /* was dynamically defined */
 
134
        time_t                  created;
 
135
        time_t                  last_new_client;
 
136
        char                    *client_server;
 
137
#endif
 
138
 
 
139
#ifdef WITH_COA
 
140
        char                    *coa_name;
 
141
        home_server             *coa_server;
 
142
        home_pool_t             *coa_pool;
77
143
#endif
78
144
} RADCLIENT;
79
145
 
84
150
 */
85
151
typedef enum RAD_LISTEN_TYPE {
86
152
        RAD_LISTEN_NONE = 0,
 
153
#ifdef WITH_PROXY
87
154
        RAD_LISTEN_PROXY,
 
155
#endif
88
156
        RAD_LISTEN_AUTH,
 
157
#ifdef WITH_ACCOUNTING
89
158
        RAD_LISTEN_ACCT,
 
159
#endif
 
160
#ifdef WITH_DETAIL
90
161
        RAD_LISTEN_DETAIL,
 
162
#endif
 
163
#ifdef WITH_VMPS
91
164
        RAD_LISTEN_VQP,
 
165
#endif
 
166
#ifdef WITH_DHCP
92
167
        RAD_LISTEN_DHCP,
93
 
        RAD_LISTEN_SNMP,
 
168
#endif
 
169
#ifdef WITH_COMMAND_SOCKET
 
170
        RAD_LISTEN_COMMAND,
 
171
#endif
 
172
#ifdef WITH_COA
 
173
        RAD_LISTEN_COA,
 
174
#endif
94
175
        RAD_LISTEN_MAX
95
176
} RAD_LISTEN_TYPE;
96
177
 
99
180
 *      For listening on multiple IP's and ports.
100
181
 */
101
182
typedef struct rad_listen_t rad_listen_t;
 
183
typedef         void (*radlog_func_t)(int, int, REQUEST *, const char *, ...);
102
184
 
103
185
#define REQUEST_DATA_REGEX (0xadbeef00)
104
186
#define REQUEST_MAX_REGEX (8)
108
190
        uint32_t                magic; /* for debugging only */
109
191
#endif
110
192
        RADIUS_PACKET           *packet;
 
193
#ifdef WITH_PROXY
111
194
        RADIUS_PACKET           *proxy;
 
195
#endif
112
196
        RADIUS_PACKET           *reply;
 
197
#ifdef WITH_PROXY
113
198
        RADIUS_PACKET           *proxy_reply;
 
199
#endif
114
200
        VALUE_PAIR              *config_items;
115
201
        VALUE_PAIR              *username;
116
202
        VALUE_PAIR              *password;
119
205
 
120
206
        request_data_t          *data;
121
207
        RADCLIENT               *client;
122
 
        child_pid_t             child_pid;
 
208
#ifdef HAVE_PTHREAD_H
 
209
        pthread_t               child_pid;
 
210
#endif
123
211
        time_t                  timestamp;
124
212
        int                     number; /* internal server number */
125
213
 
126
214
        rad_listen_t            *listener;
 
215
#ifdef WITH_PROXY
127
216
        rad_listen_t            *proxy_listener;
128
 
 
129
 
        int                     simul_max;
 
217
#endif
 
218
 
 
219
 
 
220
        int                     simul_max; /* see modcall.c && xlat.c */
 
221
#ifdef WITH_SESSION_MGMT
130
222
        int                     simul_count;
131
223
        int                     simul_mpp; /* WEIRD: 1 is false, 2 is true */
 
224
#endif
132
225
 
133
226
        int                     options; /* miscellanous options */
134
227
        const char              *module; /* for debugging unresponsive children */
147
240
        fr_event_callback_t     next_callback;
148
241
 
149
242
        int                     in_request_hash;
 
243
#ifdef WITH_PROXY
150
244
        int                     in_proxy_hash;
151
245
 
152
246
        home_server             *home_server;
156
250
 
157
251
        int                     num_proxied_requests;
158
252
        int                     num_proxied_responses;
 
253
#endif
159
254
 
160
255
        const char              *server;
161
256
        REQUEST                 *parent;
 
257
        radlog_func_t           radlog; /* logging function, if set */
 
258
#ifdef WITH_COA
 
259
        REQUEST                 *coa;
 
260
        int                     num_coa_requests;
 
261
#endif
162
262
};                              /* REQUEST typedef */
163
263
 
164
264
#define RAD_REQUEST_OPTION_NONE            (0)
 
265
#define RAD_REQUEST_OPTION_DEBUG           (1)
 
266
#define RAD_REQUEST_OPTION_DEBUG2          (2)
 
267
#define RAD_REQUEST_OPTION_DEBUG3          (3)
 
268
#define RAD_REQUEST_OPTION_DEBUG4          (4)
165
269
 
166
270
#define REQUEST_ACTIVE          (1)
167
271
#define REQUEST_STOP_PROCESSING (2)
207
311
        RAD_LISTEN_TYPE type;
208
312
        int             fd;
209
313
        const char      *server;
 
314
        int             status;
210
315
 
211
316
        rad_listen_recv_t recv;
212
317
        rad_listen_send_t send;
215
320
        rad_listen_print_t print;
216
321
 
217
322
        void            *data;
 
323
 
 
324
#ifdef WITH_STATS
 
325
        fr_stats_t      stats;
 
326
#endif
218
327
};
219
328
 
 
329
#define RAD_LISTEN_STATUS_INIT   (0)
 
330
#define RAD_LISTEN_STATUS_KNOWN  (1)
 
331
#define RAD_LISTEN_STATUS_CLOSED (2)
 
332
#define RAD_LISTEN_STATUS_FINISH (3)
220
333
 
221
334
typedef enum radlog_dest_t {
222
335
  RADLOG_STDOUT = 0,
255
368
        radlog_dest_t   radlog_dest;
256
369
        CONF_SECTION    *config;
257
370
        const char      *name;
258
 
        int             do_snmp;
 
371
        const char      *auth_badpass_msg;
 
372
        const char      *auth_goodpass_msg;
259
373
} MAIN_CONFIG_T;
260
374
 
261
375
#define DEBUG   if(debug_flag)log_debug
262
376
#define DEBUG2  if (debug_flag > 1)log_debug
263
377
#define DEBUG3  if (debug_flag > 2)log_debug
 
378
#define DEBUG4  if (debug_flag > 3)log_debug
 
379
 
 
380
#if __GNUC__ >= 3
 
381
#define RDEBUG(fmt, ...)   if(request && request->radlog) request->radlog(L_DBG, 1, request, fmt, ## __VA_ARGS__)
 
382
#define RDEBUG2(fmt, ...)  if(request && request->radlog) request->radlog(L_DBG, 2, request, fmt, ## __VA_ARGS__)
 
383
#define RDEBUG3(fmt, ...)  if(request && request->radlog) request->radlog(L_DBG, 3, request, fmt, ## __VA_ARGS__)
 
384
#define RDEBUG4(fmt, ...)  if(request && request->radlog) request->radlog(L_DBG, 4, request, fmt, ## __VA_ARGS__)
 
385
#else
 
386
#define RDEBUG  DEBUG
 
387
#define RDEBUG2 DEBUG2
 
388
#define RDEBUG3 DEBUG3
 
389
#define RDEBUG4 DEBUG4
 
390
#endif
264
391
 
265
392
#define SECONDS_PER_DAY         86400
266
393
#define MAX_REQUEST_TIME        30
363
490
void            *rad_malloc(size_t size); /* calls exit(1) on error! */
364
491
REQUEST         *request_alloc(void);
365
492
REQUEST         *request_alloc_fake(REQUEST *oldreq);
 
493
REQUEST         *request_alloc_coa(REQUEST *request);
366
494
int             request_data_add(REQUEST *request,
367
495
                                 void *unique_ptr, int unique_int,
368
496
                                 void *opaque, void (*free_opaque)(void *));
379
507
RADCLIENT_LIST  *clients_parse_section(CONF_SECTION *section);
380
508
void            client_free(RADCLIENT *client);
381
509
int             client_add(RADCLIENT_LIST *clients, RADCLIENT *client);
 
510
#ifdef WITH_DYNAMIC_CLIENTS
 
511
void            client_delete(RADCLIENT_LIST *clients, RADCLIENT *client);
 
512
RADCLIENT       *client_create(RADCLIENT_LIST *clients, REQUEST *request);
 
513
#endif
382
514
RADCLIENT       *client_find(const RADCLIENT_LIST *clients,
383
515
                             const fr_ipaddr_t *ipaddr);
384
516
RADCLIENT       *client_findbynumber(const RADCLIENT_LIST *clients,
385
517
                                     int number);
386
518
RADCLIENT       *client_find_old(const fr_ipaddr_t *ipaddr);
 
519
int             client_validate(RADCLIENT_LIST *clients, RADCLIENT *master,
 
520
                                RADCLIENT *c);
 
521
RADCLIENT       *client_read(const char *filename, int in_server, int flag);
 
522
 
387
523
 
388
524
/* files.c */
389
525
int             pairlist_read(const char *file, PAIR_LIST **list, int complain);
405
541
#endif
406
542
;
407
543
void            vp_listdebug(VALUE_PAIR *vp);
 
544
void radlog_request(int lvl, int priority, REQUEST *request, const char *msg, ...)
 
545
#ifdef __GNUC__
 
546
                __attribute__ ((format (printf, 4, 5)))
 
547
#endif
 
548
;
408
549
 
409
550
/* auth.c */
410
551
char    *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli);
433
574
int radius_callback_compare(REQUEST *req, VALUE_PAIR *request,
434
575
                            VALUE_PAIR *check, VALUE_PAIR *check_pairs,
435
576
                            VALUE_PAIR **reply_pairs);
 
577
int radius_find_compare(int attribute);
436
578
VALUE_PAIR      *radius_paircreate(REQUEST *request, VALUE_PAIR **vps,
437
579
                                  int attribute, int type);
438
580
VALUE_PAIR *radius_pairmake(REQUEST *request, VALUE_PAIR **vps,
451
593
void            xlat_free(void);
452
594
 
453
595
/* threads.c */
454
 
extern          int thread_pool_init(CONF_SECTION *cs, int spawn_flag);
 
596
extern          int thread_pool_init(CONF_SECTION *cs, int *spawn_flag);
455
597
extern          int thread_pool_addrequest(REQUEST *, RAD_REQUEST_FUNP);
456
598
extern          pid_t rad_fork(void);
457
599
extern          pid_t rad_waitpid(pid_t pid, int *status);
458
600
extern          int total_active_threads(void);
459
601
extern          void thread_pool_lock(void);
460
602
extern          void thread_pool_unlock(void);
 
603
extern          void thread_pool_queue_stats(int *array);
461
604
 
462
605
#ifndef HAVE_PTHREAD_H
463
606
#define rad_fork(n) fork()
470
613
 
471
614
int read_mainconfig(int reload);
472
615
int free_mainconfig(void);
 
616
void hup_mainconfig(void);
 
617
void fr_suid_down(void);
 
618
void fr_suid_up(void);
 
619
void fr_suid_down_permanent(void);
473
620
 
474
621
/* listen.c */
475
622
void listen_free(rad_listen_t **head);
476
623
int listen_init(CONF_SECTION *cs, rad_listen_t **head);
477
 
rad_listen_t *proxy_new_listener(void);
 
624
rad_listen_t *proxy_new_listener(fr_ipaddr_t *ipaddr, int exists);
478
625
RADCLIENT *client_listener_find(const rad_listen_t *listener,
479
 
                                const fr_ipaddr_t *ipaddr);
 
626
                                const fr_ipaddr_t *ipaddr, int src_port);
 
627
#ifdef WITH_STATS
 
628
RADCLIENT_LIST *listener_find_client_list(const fr_ipaddr_t *ipaddr,
 
629
                                          int port);
 
630
rad_listen_t *listener_find_byipaddr(const fr_ipaddr_t *ipaddr, int port);
 
631
#endif
480
632
 
481
633
/* event.c */
482
634
int radius_event_init(CONF_SECTION *cs, int spawn_flag);
487
639
                     RADIUS_PACKET *packet, REQUEST **prequest,
488
640
                     RADCLIENT *client);
489
641
REQUEST *received_proxy_response(RADIUS_PACKET *packet);
 
642
void event_new_fd(rad_listen_t *listener);
490
643
 
491
644
/* evaluate.c */
492
645
int radius_evaluate_condition(REQUEST *request, int modreturn, int depth,