Note that "hashsize=0" is a bad idea
authorAlan T. DeKok <aland@freeradius.org>
Tue, 20 Dec 2011 13:14:40 +0000 (08:14 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 20 Dec 2011 13:34:41 +0000 (08:34 -0500)
raddb/modules/passwd
src/modules/rlm_passwd/rlm_passwd.c

index b7ac2a9..92496bf 100644 (file)
 #            Attributes marked as '=' are added to reply_items instead
 #            of default configure_itmes
 #
-#           Attributse marked as '~' are added to request_items
+#           Attributes marked as '~' are added to request_items
 #
 #            Field marked as ',' may contain a comma separated list
 #            of attributes.
 #
-#   hashsize - hashtable size. If 0 or not specified records are not
-#            stored in memory and file is read on every request.
-#           This configuration is *not* recommended, as it can be
-#           very slow.  The "passwd" module reloads its configuration
-#           on HUP, so setting "hashsize = 0" is unnecessary.
+#   hashsize - hashtable size.  Setting it to 0 is no longer permitted
+#              A future version of the server will have the module
+#              automatically determine the hash size.  Having it set
+#              manually should not be necessary.
 #
 #   allowmultiplekeys - if many records for a key are allowed
 #
index 806e5cd..be6f064 100644 (file)
@@ -403,12 +403,21 @@ static int passwd_instantiate(CONF_SECTION *conf, void **instance)
                return -1;
        }
        if(!inst->filename || *inst->filename == '\0' || !inst->format || *inst->format == '\0') {
-               radlog(L_ERR, "rlm_passwd: cann't find passwd file and/or format in configuration");
+               radlog(L_ERR, "rlm_passwd: can't find passwd file and/or format in configuration");
+               free(inst);
                return -1;
        }
+
+       if (inst->hashsize == 0) {
+               radlog(L_ERR, "rlm_passwd: hashsize=0 is no longer permitted as it will break the server.");
+               free(inst);
+               return -1;
+       }
+
        lf=strdup(inst->format);
        if ( lf == NULL) {
                radlog(L_ERR, "rlm_passwd: memory allocation failed for lf");
+               free(inst);
                return -1;
        }
        memset(lf, 0, strlen(inst->format));