Print out helpful error if a realm regex can't be parsed
authorAlan T. DeKok <aland@freeradius.org>
Wed, 21 Apr 2010 06:52:56 +0000 (08:52 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 26 Apr 2010 14:02:49 +0000 (16:02 +0200)
src/main/realms.c

index 46446fc..7300e62 100644 (file)
@@ -1572,15 +1572,22 @@ static int realm_add(realm_config_t *rc, CONF_SECTION *cs)
 
 #ifdef HAVE_REGEX_H
        if (name2[0] == '~') {
+               int rcode;
                regex_t reg;
                
                /*
                 *      Include substring matches.
                 */
-               if (regcomp(&reg, name2 + 1,
-                           REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) {
+               rcode = regcomp(&reg, name2 + 1,
+                               REG_EXTENDED | REG_NOSUB | REG_ICASE);
+               if (rcode != 0) {
+                       char buffer[256];
+
+                       regerror(rcode, &reg, buffer, sizeof(buffer));
+
                        cf_log_err(cf_sectiontoitem(cs),
-                                  "Invalid regex in realm \"%s\"", name2);
+                                  "Invalid regex \"%s\": %s",
+                                  name2 + 1, buffer);
                        goto error;
                }
                regfree(&reg);