Initial version of global alias table is in place. But it seems to have a Heisenbug.
authorArt Cancro <ajc@citadel.org>
Tue, 3 Aug 2021 19:19:17 +0000 (15:19 -0400)
committerArt Cancro <ajc@citadel.org>
Tue, 3 Aug 2021 19:19:17 +0000 (15:19 -0400)
citadel/internet_addressing.c
libcitadel/lib/libcitadel.h

index a38601d957903e5d46c7adb34dbe592ad9b15048..1da58751440e0842b8176cff7f69f02e088d60e5 100644 (file)
@@ -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);
 
index 67183fcfe59f90e6664e49b15339d6250fa2ce04..71bd0445415f64ea440ac0d5005fd3f326355861 100644 (file)
@@ -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__"