From 993d83d05304da06680a5c731533c6944f3d6fe9 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 3 Aug 2021 15:19:17 -0400 Subject: [PATCH] Initial version of global alias table is in place. But it seems to have a Heisenbug. --- citadel/internet_addressing.c | 39 +++++++++++++++++++---------------- libcitadel/lib/libcitadel.h | 4 +++- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index a38601d95..1da587514 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -398,35 +398,38 @@ char *killo[] = { // FIXME remove this when diags are complete }; -/* - * Aliasing for network mail. - */ -int expand_aliases(char *name) { /* process alias and routing info for mail */ +// Process alias and routing info for email addresses +int expand_aliases(char *name) { int a; char aaa[SIZ]; int at = 0; char node[64]; + char *t; + char *aliases = CtdlGetSysConfig(GLOBAL_ALIASES); // First hit the Global Alias Table + if (aliases) { + char *aptr = aliases; + while ((t = strtok_r(aptr, "\n", &aptr))) { + char *bar = strchr(t, '|'); + if (bar) { + bar[0] = 0; + ++bar; + if (!strcasecmp(name, t)) { + syslog(LOG_DEBUG, "\033[36mAliasing <%s> to <%s>\033[0m", name, bar); + strcpy(name, bar); + } + } + } - - - // FIXME write a "real" alias table here - - - // temporary test of expansion - if (!strcasecmp(name, "root")) { - strcpy(name, "root"); - return(EA_MULTIPLE); - } - if (!strcasecmp(name, "qux")) { - strcpy(name, "eggroll,blat,fun@eek.boop"); - return(EA_MULTIPLE); + free(aliases); + if (strchr(name, ',')) { + return(EA_MULTIPLE); + } } - char original_name[256]; safestrncpy(original_name, name, sizeof original_name); diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 67183fcfe..71bd04454 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -673,8 +673,9 @@ extern "C" { #define CFG_SMTP_FROM_NOFILTER 1 #define CFG_SMTP_FROM_CORRECT 2 #define CFG_SMTP_FROM_REJECT 3 + /* - * MIME types used in Citadel for configuration stuff + * object types used in Citadel for configuration stuff (some of these are obsolete) */ #define SPOOLMIME "application/x-citadel-delivery-list" #define INTERNETCFG "application/x-citadel-internet-config" @@ -683,6 +684,7 @@ extern "C" { #define FILTERLIST "application/x-citadel-filter-list" #define SIEVECONFIG "application/x-citadel-sieve-config" #define XMPPMORTUARY "application/x-citadel-xmpp-mortuary" +#define GLOBAL_ALIASES "global_alias_table" #define FILE_MAILALIAS "__MAIL_ALIAS__" -- 2.30.2