rlm_dbm with empty check and reply items

Gabriel L. Somlo somlo at cmu.edu
Fri Jul 28 16:42:13 CEST 2006


Alan & all,

I want to use rlm_dbm for authorization with no check or reply items.
A user is authorized if he is listed in the dbm database, and not
authorized if not present:

modules {
	...
	dbm {
		usersfile = ${confdir}/users.dbm
	}
	...
}
...
authorize {
	...
	dbm {
		notfound = reject
	}
}

So, what I need is a dbm file which has "empty" content associated with
each username key. "Empty" actually means a "\n\n" string (first '\n'
for no check items, second one for no reply items).

I can create such a database by calling dbm routines from my own C code,
and it works fine with the radiusd.conf excerpt above.

HOWEVER, I would like to use the rlm_dbm_parser binary included with the
freeradius package. The trouble is, this code checks for the length of
each content record before inserting into the dbm file, and refuses to
do so unless the record is more than 3 characters long (rlm_dbm_parser.c,
line 158, inside function 'static int storecontent' as per
freeradius-snapshot-20060728):

static int storecontent (const char * username) {

	 datum d,k;
	 int res;

	if ( pdb == NULL || concntr < 3 ) return 1;
/*                        ^^^^^^^^^^^^^^            */

	DOUT2("store:\n%s\ncontent:\n%s",username,content);

	d.dptr = content;

...

Is there a known good reason why this code wants length >=3, or why it
prevents check items and reply items from being empty at the same time ?

If yes, inquiring minds want to know :)

If not, please apply the attached patch, which modifies the check from < 3
to < 2, allowing "empty" keys to be stored in the dbm.

Thanks much,
Gabriel


-------------- next part --------------
diff -NarU5 freeradius.orig/src/modules/rlm_dbm/rlm_dbm_parser.c freeradius/src/modules/rlm_dbm/rlm_dbm_parser.c
--- freeradius.orig/src/modules/rlm_dbm/rlm_dbm_parser.c	2004-02-26 14:04:28.000000000 -0500
+++ freeradius/src/modules/rlm_dbm/rlm_dbm_parser.c	2006-07-27 15:49:27.000000000 -0400
@@ -153,11 +153,11 @@
 static int storecontent (const char * username) {
 
 	 datum d,k;
 	 int res;
 
-	if ( pdb == NULL || concntr < 3 ) return 1;
+	if ( pdb == NULL || concntr < 2 ) return 1;
 
 	DOUT2("store:\n%s\ncontent:\n%s",username,content);
 
 	d.dptr = content;
 	d.dsize = concntr + 1;


More information about the Freeradius-Devel mailing list