Hello!
> > reading NASes from an SQL nas table. In that case you wouldn't need the
> > clients.conf file any more. Problem is, if there is no client in this
> > file (or the file is not included), the server will not start up and
> > silently exit.
>
> As always, patches are welcome.
>
> Alan DEKok.
Please find attached a patch that enables this functionality:
- when parsing the main config, it checks whether clients could be read via
client{} clauses.
- If not, it puts out a warning (L_INFO|L_CONS) that this only makes sense in
conjunction with a nas table
- after modules have been loaded, a check is performed to see if the clients
list is empty (which would be the case if no client clauses were in place and
no clients were loaded from nas table), in which case an error message is
given and FreeRADIUS exits.
Patch should apply cleanly against 1.0.1.
For the legal side of things: GPLv2 licensing is perfectly okay for this
contribution. However, copyright is not at me personally, but the company I
work with:
Fondation RESTENA, 6, rue Richard Coudenhove-Kalergi, L-1359 Luxembourg
Greetings,
Stefan Winter
--
Stefan WINTER
Fondation RESTENA - R�seau T�l�informatique de l'Education Nationale et de
la Recherche
Ing�nieur r�seau et syst�me
6, rue Richard Coudenhove-Kalergi
L-1359 Luxembourg
email: [EMAIL PROTECTED] � � t�l.: � � �+352 424409-33
http://www.restena.lu � � � � � � � � � � fax: � � �+352 422473
--
Stefan WINTER
Fondation RESTENA - R�seau T�l�informatique de l'Education Nationale et de
la Recherche
Ing�nieur r�seau et syst�me
6, rue Richard Coudenhove-Kalergi
L-1359 Luxembourg
email: [EMAIL PROTECTED] � � t�l.: � � �+352 424409-33
http://www.restena.lu � � � � � � � � � � fax: � � �+352 422473
diff -ur freeradius-1.0.1/src/main/mainconfig.c freeradius-1.0.1-patched/src/main/mainconfig.c
--- freeradius-1.0.1/src/main/mainconfig.c 2004-06-08 17:09:40.000000000 +0200
+++ freeradius-1.0.1-patched/src/main/mainconfig.c 2005-01-06 09:04:14.369396698 +0100
@@ -1210,18 +1210,27 @@
snprintf(buffer, sizeof(buffer), "%.200s/%.50s", radius_dir, RADIUS_CONFIG);
c = generate_clients(buffer, mainconfig.config);
if (!c) {
- return -1;
+ radlog(L_INFO|L_CONS,"No clients could be loaded from the config file. This only makes sense if they are to be read via the SQL nas table!");
+
}
/*
- * The new list of clients takes precedence over the old one.
+ * The new list of clients takes precedence over the old one
+ * if a new list exists.
*/
- for (tail = c; tail->next != NULL; tail = tail->next) {
- /* do nothing */
- }
- tail->next = mainconfig.clients;
- mainconfig.clients = c;
+ if (c) {
+ for (tail = c; tail->next != NULL; tail = tail->next) {
+ /* do nothing */
+ }
+ tail->next = mainconfig.clients;
+
+ mainconfig.clients = c;
+ }
+
+ /* don't forget: mainconfig.clients could be NULL, gotta check that after SQL
+ module is instantiated */
+
/* old-style realms file */
snprintf(buffer, sizeof(buffer), "%.200s/%.50s", radius_dir, RADIUS_REALMS);
DEBUG2("read_config_files: reading realms");
diff -ur freeradius-1.0.1/src/main/radiusd.c freeradius-1.0.1-patched/src/main/radiusd.c
--- freeradius-1.0.1/src/main/radiusd.c 2004-07-05 17:36:08.000000000 +0200
+++ freeradius-1.0.1-patched/src/main/radiusd.c 2005-01-06 08:38:23.000000000 +0100
@@ -967,6 +967,14 @@
exit(1);
}
+ /* ensure that the clients list is not empty. At this point,
+ this fatal! */
+
+ if (mainconfig.clients == NULL) {
+ radlog(L_ERR|L_CONS, "The list of clients is empty. FreeRADIUS will now exit.");
+ exit(1);
+ }
+
#ifdef HAVE_SYSLOG_H
/*
* If they asked for syslog, then give it to them.