nas-list from db vs. vserver
Michael Bretterklieber
mbretterklieber at upcbroadband.com
Mon Apr 28 09:46:41 CEST 2008
Hi,
we found a small issue, when reading the naslist/client-list from a
sql-db, it's not possible to get the vserver-name like in the clients.conf.
Here's small patch whitch solves the problem:
--- rlm_sql.c.orig 2008-04-28 11:49:06.000000000 +0200
+++ rlm_sql.c 2008-04-28 11:49:11.000000000 +0200
@@ -221,6 +221,7 @@
RADCLIENT *c;
char *prefix_ptr = NULL;
unsigned int i = 0;
+ int numf = 0;
DEBUG("rlm_sql (%s): Processing generate_sql_clients",
inst->config->xlat_name);
@@ -254,6 +255,7 @@
* 2. Shortname
* 3. Type
* 4. Secret
+ * 5. Virtual Server (optional)
*/
if (!row[0]){
radlog(L_ERR, "rlm_sql (%s): No row id found on
pass %d",inst->config->xlat_name,i);
@@ -322,16 +324,21 @@
}
/*
- * Other values (secret, shortname, nastype)
+ * Other values (secret, shortname, nastype,
virtual_server)
*/
c->secret = strdup(row[4]);
c->shortname = strdup(row[2]);
if(row[3] != NULL)
c->nastype = strdup(row[3]);
- DEBUG("rlm_sql (%s): Adding client %s (%s) to clients list",
+ numf = (inst->module->sql_num_fields)(sqlsocket,
inst->config);
+ if (numf > 5)
+ if (row[5] != NULL)
+ c->server = strdup(row[5]);
+
+ DEBUG("rlm_sql (%s): Adding client %s (%s, server=%s) to
clients list",
inst->config->xlat_name,
- c->longname,c->shortname);
+ c->longname,c->shortname, c->server ? c->server :
"<none>");
if (!client_add(NULL, c)) {
DEBUG("rlm_sql (%s): Failed to add client %s
(%s) to clients list. Maybe there's a duplicate?",
inst->config->xlat_name,
the NASquery could then look like:
nas_query = "SELECT id, nasname, shortname, type, secret,
virtual_server FROM ${nas_table}"
The additional vserver field is optional, so it's backwards-compatible.
any chance to get it commited?
thanx,
bye,
Michi
More information about the Freeradius-Devel
mailing list