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

« back to all changes in this revision

Viewing changes to src/main/client.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Hampson
  • Date: 2004-12-29 20:19:42 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041229201942-uj2e95la965uthc7
Tags: 1.0.1-2
* freeradius-dialupadmin Suggests php4-mysql | php4-pgsql
   Closes: #279419
* Added a two-second pause to restart in init.d script
   Closes: #262635
* FreeRADIUS module packages now depend on the same source
  version of the main FreeRADIUS package.
   Closes: #284353
* FreeRADIUS-dialupadmin's default paths in admin.conf are
  now correct.
   Closes: #280942
* FreeRADIUS-dialupadmin's help.php3 can now find README.
   Closes: #280941
* Fixes stolen from 1.0.2 CVS:
  - Bug fix to make udpfromto code work
  - radrelay shouldn't dump core if it can't read a VP from the
    detail file.
  - Only initialize the random pool once.
  - In rlm_sql, don't escape characters twice.
  - In rlm_ldap, only claim Auth-Type if a plain text password is present.
  - Locking fixes in threading code
  - Fix building on gcc-4.0 by not trying to access static auth_port from
    other files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * files.c      Read config files into memory.
3
3
 *
4
 
 * Version:     $Id: client.c,v 1.22 2003/06/15 14:09:32 hartwick Exp $
 
4
 * Version:     $Id: client.c,v 1.27 2004/04/07 16:02:05 aland 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
22
22
 * Copyright 2000  Alan DeKok <aland@ox.org>
23
23
 */
24
24
 
25
 
static const char rcsid[] = "$Id: client.c,v 1.22 2003/06/15 14:09:32 hartwick Exp $";
 
25
static const char rcsid[] = "$Id: client.c,v 1.27 2004/04/07 16:02:05 aland Exp $";
26
26
 
27
27
#include "autoconf.h"
28
28
#include "libradius.h"
29
29
 
30
30
#include <sys/stat.h>
31
31
 
32
 
#if HAVE_NETINET_IN_H
 
32
#ifdef HAVE_NETINET_IN_H
33
33
#       include <netinet/in.h>
34
34
#endif
35
35
 
71
71
        uint32_t mask;
72
72
        int lineno = 0;
73
73
        char *p;
 
74
        int got_clients = FALSE;
74
75
 
75
76
        clients_free(mainconfig.clients);
76
77
        mainconfig.clients = NULL;
82
83
                   done. */
83
84
                return 0;
84
85
        }
85
 
        radlog(L_INFO, "Using deprecated clients file.  Support for this will go away soon.");
86
86
 
87
87
        while(fgets(buffer, 256, fp) != NULL) {
88
88
                lineno++;
96
96
                 */
97
97
                p = buffer;
98
98
                while (*p &&
99
 
                                ((*p == ' ') || (*p == '\t'))) 
 
99
                                ((*p == ' ') || (*p == '\t')))
100
100
                        p++;
101
101
 
102
102
                /*
121
121
                mask = ~0;
122
122
 
123
123
                if (p) {
124
 
                        int i, mask_length;
 
124
                        int mask_length;
125
125
 
126
126
                        *p = '\0';
127
127
                        p++;
129
129
                        mask_length = atoi(p);
130
130
                        if ((mask_length < 0) || (mask_length > 32)) {
131
131
                                radlog(L_ERR, "%s[%d]: Invalid value '%s' for IP network mask.",
132
 
                                                file, lineno, p);
 
132
                                       file, lineno, p);
133
133
                                return -1;
134
134
                        }
135
135
 
136
 
                        mask = (1 << 31);
137
 
                        for (i = 1; i < mask_length; i++) {
138
 
                                mask |= (mask >> 1);
 
136
                        if (mask_length == 0) {
 
137
                                mask = 0;
 
138
                        } else {
 
139
                                mask = ~0 << (32 - mask_length);
139
140
                        }
140
141
                }
141
142
 
144
145
                 */
145
146
                if (strlen(hostnm) >= sizeof(c->longname)) {
146
147
                        radlog(L_ERR, "%s[%d]: host name of length %d is greater than the allowed maximum of %d.",
147
 
                                        file, lineno,
148
 
                                        strlen(hostnm), sizeof(c->longname) - 1);
 
148
                               file, lineno,
 
149
                               (int) strlen(hostnm),
 
150
                               (int) sizeof(c->longname) - 1);
149
151
                        return -1;
150
152
                }
151
153
                if (strlen(secret) >= sizeof(c->secret)) {
152
154
                        radlog(L_ERR, "%s[%d]: secret of length %d is greater than the allowed maximum of %d.",
153
 
                                        file, lineno,
154
 
                                        strlen(secret), sizeof(c->secret) - 1);
 
155
                               file, lineno,
 
156
                               (int) strlen(secret),
 
157
                               (int) sizeof(c->secret) - 1);
155
158
                        return -1;
156
159
                }
157
160
                if (strlen(shortnm) > sizeof(c->shortname)) {
158
161
                        radlog(L_ERR, "%s[%d]: short name of length %d is greater than the allowed maximum of %d.",
159
 
                                        file, lineno,
160
 
                                        strlen(shortnm), sizeof(c->shortname) - 1);
 
162
                               file, lineno,
 
163
                               (int) strlen(shortnm),
 
164
                               (int) sizeof(c->shortname) - 1);
161
165
                        return -1;
162
166
                }
163
 
                
 
167
 
164
168
                /*
165
169
                 *      It should be OK now, let's create the buffer.
166
170
                 */
 
171
                got_clients = TRUE;
167
172
                c = rad_malloc(sizeof(RADCLIENT));
168
173
                memset(c, 0, sizeof(*c));
169
174
 
216
221
        }
217
222
        fclose(fp);
218
223
 
 
224
        if (got_clients) {
 
225
                radlog(L_INFO, "Using deprecated clients file.  Support for this will go away soon.");
 
226
        }
 
227
 
219
228
        return 0;
220
229
}
221
230
 
244
253
 *      Walk the RADCLIENT list displaying the clients.  This function
245
254
 *      is for debugging purposes.
246
255
 */
247
 
void client_walk(void) 
 
256
void client_walk(void)
248
257
{
249
258
        RADCLIENT *cl;
250
259
        char host_ipaddr[16];
269
278
                else
270
279
                        return cl->longname;
271
280
        }
272
 
        
273
 
        /* 
274
 
         * this isn't normally reachable, but if a loggable event happens just 
275
 
         * after a client list change and a HUP, then we may not know this 
 
281
 
 
282
        /*
 
283
         * this isn't normally reachable, but if a loggable event happens just
 
284
         * after a client list change and a HUP, then we may not know this
276
285
         * information any more.
277
286
         *
278
287
         * If you see lots of these, then there's something wrong.
279
288
         */
280
 
        radlog(L_ERR, "Trying to look up name of unknown client %s.\n", ip_ntoa(host_ipaddr, ipaddr));
 
289
        radlog(L_ERR, "Trying to look up name of unknown client %s.\n",
 
290
               ip_ntoa(host_ipaddr, ipaddr));
281
291
 
282
292
        return "UNKNOWN-CLIENT";
283
293
}