bugzilla #380: rlm_dbm_parser refuses to create record if both check and reply items are empty

Gabriel L. Somlo gsomlo at gmail.com
Mon Jul 31 00:16:12 CEST 2006

rlm_dbm_parser refuses to create a users.dbm file where
both the list of check items *and* the list of reply-items
are empty (this is perfectly legal and allowed when one
uses the files module).

To reproduce: feed the following file to rlm_dbm_parser:

#---begin users.dbm.src
dummy_user	;


#---begin users.dbm.src

Then, attempt to create users.dbm:

	rlm_dbm_parser -c -i users.dbm.src -o users.dbm

Notice how it says 'Records loaded: 0'

Desired behavior is 'Record loaded: 1'

A desired users.dbm file *can* be created by calling libdbm
create/insert routines from a custom C program, by providing
the username as key and the string "\n\n" as content (each
'\n' denotes an empty list of check, and respectively, reply
items). Once created, the users.dbm works fine with the actual
freeradius server (radiusd).

The problem is that, before inserting a record, rlm_dbm_parser
checks the length of the content field, and skips insertion if
length is less than 3 bytes. To be able to create a list of
users w/o check and reply items, the minimum content length
should be reduced to 2 bytes (for the two '\n' characters as
described above).

The following one-liner patch (against snapshot-20060730)
fixes the bug (also submitted via bugzilla as #380):

diff -NarU5 freeradius-snapshot-20060730.orig/src/modules/rlm_dbm/rlm_dbm_parser.c freeradius-snapshot-20060730.rlmfix/src/modules/rlm_dbm/rlm_dbm_parser.c
--- freeradius-snapshot-20060730.orig/src/modules/rlm_dbm/rlm_dbm_parser.c      2006-03-16 11:47:43.000000000 -0500
+++ freeradius-snapshot-20060730.rlmfix/src/modules/rlm_dbm/rlm_dbm_parser.c    2006-07-30 17:14:00.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;


         d.dptr = content;
         d.dsize = concntr + 1;

More information about the Freeradius-Devel mailing list