X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/b1c673ddfac7f322a62786cd4aae8b5b30ba69e8..a85c067ba6c6940512cf57ec213277a370d87e70:/src/src/drtables.c diff --git a/src/src/drtables.c b/src/src/drtables.c index 558359032..a6cbede89 100644 --- a/src/src/drtables.c +++ b/src/src/drtables.c @@ -2,8 +2,10 @@ * Exim - an Internet mail transport agent * *************************************************/ +/* Copyright (c) The Exim Maintainers 2020 - 2022 */ /* Copyright (c) University of Cambridge 1995 - 2018 */ /* See the file NOTICE for conditions of use and distribution. */ +/* SPDX-License-Identifier: GPL-2.0-only */ #include "exim.h" @@ -201,15 +203,6 @@ auth_info auths_available[] = { { .driver_name = US"" } /* end marker */ }; -void -auth_show_supported(FILE * f) -{ -fprintf(f, "Authenticators:"); -for (auth_info * ai = auths_available; ai->driver_name[0]; ai++) - fprintf(f, " %s", ai->driver_name); -fprintf(f, "\n"); -} - /* Tables of information about which routers and transports are included in the exim binary. */ @@ -369,17 +362,6 @@ router_info routers_available[] = { }; -void -route_show_supported(FILE * f) -{ -fprintf(f, "Routers:"); -for (router_info * rr = routers_available; rr->driver_name[0]; rr++) - fprintf(f, " %s", rr->driver_name); -fprintf(f, "\n"); -} - - - transport_info transports_available[] = { #ifdef TRANSPORT_APPENDFILE @@ -469,42 +451,61 @@ transport_info transports_available[] = { { US"" } }; -void -transport_show_supported(FILE * f) +#ifndef MACRO_PREDEF + +gstring * +auth_show_supported(gstring * g) { -fprintf(f, "Transports:"); +g = string_cat(g, US"Authenticators:"); +for (auth_info * ai = auths_available; ai->driver_name[0]; ai++) + g = string_fmt_append(g, " %s", ai->driver_name); +return string_cat(g, US"\n"); +} + +gstring * +route_show_supported(gstring * g) +{ +g = string_cat(g, US"Routers:"); +for (router_info * rr = routers_available; rr->driver_name[0]; rr++) + g = string_fmt_append(g, " %s", rr->driver_name); +return string_cat(g, US"\n"); +} + +gstring * +transport_show_supported(gstring * g) +{ +g = string_cat(g, US"Transports:"); #ifdef TRANSPORT_APPENDFILE - fprintf(f, " appendfile"); + g = string_cat(g, US" appendfile"); #ifdef SUPPORT_MAILDIR - fprintf(f, "/maildir"); /* damn these subclasses */ + g = string_cat(g, US"/maildir"); /* damn these subclasses */ #endif #ifdef SUPPORT_MAILSTORE - fprintf(f, "/mailstore"); + g = string_cat(g, US"/mailstore"); #endif #ifdef SUPPORT_MBX - fprintf(f, "/mbx"); + g = string_cat(g, US"/mbx"); #endif #endif #ifdef TRANSPORT_AUTOREPLY - fprintf(f, " autoreply"); + g = string_cat(g, US" autoreply"); #endif #ifdef TRANSPORT_LMTP - fprintf(f, " lmtp"); + g = string_cat(g, US" lmtp"); #endif #ifdef TRANSPORT_PIPE - fprintf(f, " pipe"); + g = string_cat(g, US" pipe"); #endif #ifdef EXPERIMENTAL_QUEUEFILE - fprintf(f, " queuefile"); + g = string_cat(g, US" queuefile"); #endif #ifdef TRANSPORT_SMTP - fprintf(f, " smtp"); + g = string_cat(g, US" smtp"); #endif -fprintf(f, "\n"); +return string_cat(g, US"\n"); } -#ifndef MACRO_PREDEF struct lookupmodulestr { @@ -518,7 +519,7 @@ static struct lookupmodulestr *lookupmodules = NULL; static void addlookupmodule(void *dl, struct lookup_module_info *info) { -struct lookupmodulestr *p = store_get(sizeof(struct lookupmodulestr), FALSE); +struct lookupmodulestr *p = store_get(sizeof(struct lookupmodulestr), GET_UNTAINTED); p->dl = dl; p->info = info; @@ -546,8 +547,7 @@ if (lookup_list[pos]) /* need to insert it, so move all the other items up (last slot is still empty, of course) */ - memmove(&lookup_list[pos+1], - &lookup_list[pos], + memmove(&lookup_list[pos+1], &lookup_list[pos], sizeof(lookup_info *) * (lookup_list_count-pos-1)); } lookup_list[pos] = info; @@ -603,7 +603,7 @@ extern lookup_module_info pgsql_lookup_module_info; #if defined(LOOKUP_REDIS) && LOOKUP_REDIS!=2 extern lookup_module_info redis_lookup_module_info; #endif -#if defined(EXPERIMENTAL_LMDB) +#if defined(LOOKUP_LMDB) extern lookup_module_info lmdb_lookup_module_info; #endif #if defined(SUPPORT_SPF) @@ -619,6 +619,8 @@ extern lookup_module_info testdb_lookup_module_info; extern lookup_module_info whoson_lookup_module_info; #endif +extern lookup_module_info readsock_lookup_module_info; + void init_lookup_list(void) @@ -697,7 +699,7 @@ addlookupmodule(NULL, &pgsql_lookup_module_info); addlookupmodule(NULL, &redis_lookup_module_info); #endif -#ifdef EXPERIMENTAL_LMDB +#ifdef LOOKUP_LMDB addlookupmodule(NULL, &lmdb_lookup_module_info); #endif @@ -717,23 +719,25 @@ addlookupmodule(NULL, &testdb_lookup_module_info); addlookupmodule(NULL, &whoson_lookup_module_info); #endif +addlookupmodule(NULL, &readsock_lookup_module_info); + #ifdef LOOKUP_MODULE_DIR -if (!(dd = opendir(LOOKUP_MODULE_DIR))) +if (!(dd = exim_opendir(LOOKUP_MODULE_DIR))) { DEBUG(D_lookup) debug_printf("Couldn't open %s: not loading lookup modules\n", LOOKUP_MODULE_DIR); log_write(0, LOG_MAIN, "Couldn't open %s: not loading lookup modules\n", LOOKUP_MODULE_DIR); } else { - const pcre *regex_islookupmod = regex_must_compile( - US"\\." DYNLIB_FN_EXT "$", FALSE, TRUE); + 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; + char * name = ent->d_name; int len = (int)strlen(name); - if (pcre_exec(regex_islookupmod, NULL, name, len, 0, PCRE_EOPT, NULL, 0) >= 0) + if (regex_match(regex_islookupmod, US name, len, NULL)) { int pathnamelen = len + (int)strlen(LOOKUP_MODULE_DIR) + 2; void *dl; @@ -753,35 +757,35 @@ else if (!(dl = dlopen(CS big_buffer, RTLD_NOW))) { - errormessage = dlerror(); - fprintf(stderr, "Error loading %s: %s\n", name, errormessage); + 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++; - log_write(0, LOG_MAIN|LOG_PANIC, "Error loading lookup module %s: %s\n", name, errormessage); 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(). - */ + _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++; - 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); + log_write(0, LOG_MAIN|LOG_PANIC, "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; }