- else {
- const pcre *regex_islookupmod = regex_must_compile(
- US"\\." DYNLIB_FN_EXT "$", FALSE, TRUE);
-
- DEBUG(D_lookup) debug_printf("Loading lookup modules from %s\n", LOOKUP_MODULE_DIR);
- while ((ent = readdir(dd)) != NULL) {
- char *name = ent->d_name;
- int len = (int)strlen(name);
- if (pcre_exec(regex_islookupmod, NULL, name, len, 0, PCRE_EOPT, NULL, 0) >= 0) {
- int pathnamelen = len + (int)strlen(LOOKUP_MODULE_DIR) + 2;
- void *dl;
- struct lookup_module_info *info;
- const char *errormsg;
-
- /* SRH: am I being paranoid here or what? */
- if (pathnamelen > big_buffer_size) {
- fprintf(stderr, "Loading lookup modules: %s/%s: name too long\n", LOOKUP_MODULE_DIR, name);
- log_write(0, LOG_MAIN|LOG_PANIC, "%s/%s: name too long\n", LOOKUP_MODULE_DIR, name);
- continue;
- }
-
- /* SRH: snprintf here? */
- sprintf(CS big_buffer, "%s/%s", LOOKUP_MODULE_DIR, name);
-
- dl = dlopen(CS big_buffer, RTLD_NOW);// TJ was LAZY
- if (dl == NULL) {
- fprintf(stderr, "Error loading %s: %s\n", name, dlerror());
- moduleerrors++;
- log_write(0, LOG_MAIN|LOG_PANIC, "Error loading lookup module %s: %s\n", name, dlerror());
- continue;
- }
-
- /* FreeBSD nsdispatch() can trigger dlerror() errors about
- * _nss_cache_cycle_prevention_function; we need to clear the dlerror()
- * state before calling dlsym(), so that any error afterwards only
- * comes from dlsym().
- */
- errormsg = dlerror();
-
- info = (struct lookup_module_info*) dlsym(dl, "_lookup_module_info");
- if ((errormsg = dlerror()) != NULL) {
- fprintf(stderr, "%s does not appear to be a lookup module (%s)\n", name, errormsg);
- dlclose(dl);
- moduleerrors++;
- log_write(0, LOG_MAIN|LOG_PANIC, "%s does not appear to be a lookup module (%s)\n", name, errormsg);
- continue;
- }
- if (info->magic != LOOKUP_MODULE_INFO_MAGIC) {
- fprintf(stderr, "Lookup module %s is not compatible with this version of Exim\n", name);
- dlclose(dl);
- moduleerrors++;
- log_write(0, LOG_MAIN|LOG_PANIC, "Lookup module %s is not compatible with this version of Exim\n", name);
- continue;
- }
-
- addlookupmodule(dl, info);
- DEBUG(D_lookup) debug_printf("Loaded \"%s\" (%d lookup types)\n", name, info->lookupcount);
- countmodules++;
+else
+ {
+ const pcre2_code * regex_islookupmod = regex_must_compile(
+ US"\\." DYNLIB_FN_EXT "$", MCS_NOFLAGS, TRUE);
+
+ DEBUG(D_lookup) debug_printf("Loading lookup modules from %s\n", LOOKUP_MODULE_DIR);
+ while ((ent = readdir(dd)))
+ {
+ char * name = ent->d_name;
+ int len = (int)strlen(name);
+ if (regex_match(regex_islookupmod, US name, len, NULL))
+ {
+ int pathnamelen = len + (int)strlen(LOOKUP_MODULE_DIR) + 2;
+ void *dl;
+ struct lookup_module_info *info;
+ const char *errormsg;
+
+ /* SRH: am I being paranoid here or what? */
+ if (pathnamelen > big_buffer_size)
+ {
+ fprintf(stderr, "Loading lookup modules: %s/%s: name too long\n", LOOKUP_MODULE_DIR, name);
+ log_write(0, LOG_MAIN|LOG_PANIC, "%s/%s: name too long\n", LOOKUP_MODULE_DIR, name);
+ continue;
+ }
+
+ /* SRH: snprintf here? */
+ sprintf(CS big_buffer, "%s/%s", LOOKUP_MODULE_DIR, name);
+
+ if (!(dl = dlopen(CS big_buffer, RTLD_NOW)))
+ {
+ errormsg = dlerror();
+ fprintf(stderr, "Error loading %s: %s\n", name, errormsg);
+ log_write(0, LOG_MAIN|LOG_PANIC, "Error loading lookup module %s: %s\n", name, errormsg);
+ moduleerrors++;
+ continue;
+ }
+
+ /* FreeBSD nsdispatch() can trigger dlerror() errors about
+ _nss_cache_cycle_prevention_function; we need to clear the dlerror()
+ state before calling dlsym(), so that any error afterwards only comes
+ from dlsym(). */
+
+ errormsg = dlerror();
+
+ info = (struct lookup_module_info*) dlsym(dl, "_lookup_module_info");
+ if ((errormsg = dlerror()))
+ {
+ fprintf(stderr, "%s does not appear to be a lookup module (%s)\n", name, errormsg);
+ log_write(0, LOG_MAIN|LOG_PANIC, "%s does not appear to be a lookup module (%s)\n", name, errormsg);
+ dlclose(dl);
+ moduleerrors++;
+ continue;
+ }
+ if (info->magic != LOOKUP_MODULE_INFO_MAGIC)
+ {
+ fprintf(stderr, "Lookup module %s is not compatible with this version of Exim\n", name);
+ log_write(0, LOG_MAIN|LOG_PANIC, "Lookup module %s is not compatible with this version of Exim\n", name);
+ dlclose(dl);
+ moduleerrors++;
+ continue;
+ }
+
+ addlookupmodule(dl, info);
+ DEBUG(D_lookup) debug_printf("Loaded \"%s\" (%d lookup types)\n", name, info->lookupcount);
+ countmodules++;