Mail processing KNOWN ISSUES has been added;

This commit is contained in:
Alexander Vdolainen 2026-10-15 01:36:53 +03:00
parent b7dfef0a55
commit b2c80f0b61
2 changed files with 18 additions and 9 deletions

7
KNOWN_ISSUES Normal file
View File

@ -0,0 +1,7 @@
Mail processing engine:
1. It trusts 'From' header, probably the better way should be used (IMAP envelope data?)
2. If SMTP fails, message will be lost
3. It checks only 'To:' header, but users might 'Cc:' to mail list
4. Check up for failures in pending pool (extremely rare case, but anyway)
5. Allocation checks
6. Missing logging of different events

View File

@ -551,7 +551,8 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg)
return imap_expunge_message(mp->cfg, msg->uid); return imap_expunge_message(mp->cfg, msg->uid);
} }
char sender[256], recipient[256]; /* IMPROVE: more checking up for email addresses */
char sender[EMAILLEN_MAX], recipient[EMAILLEN_MAX];
extract_email_address(raw_from, sender, sizeof(sender)); extract_email_address(raw_from, sender, sizeof(sender));
extract_email_address(raw_to, recipient, sizeof(recipient)); extract_email_address(raw_to, recipient, sizeof(recipient));
@ -559,8 +560,9 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg)
free(raw_to); free(raw_to);
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* UC 4.3: Subscription Initiation (maillist+subscribe@domain.tld) */ /* UC 4.3: Subscription case (to is maillist+subscribe@domaintld) */
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* IMPROVE: extract before at sign and compare */
if (strcasecmp(recipient, "subscribe") == 0 || strstr(recipient, "+subscribe@")) { if (strcasecmp(recipient, "subscribe") == 0 || strstr(recipient, "+subscribe@")) {
if (!subscriber_exists(mp->subscribers, sender)) { if (!subscriber_exists(mp->subscribers, sender)) {
char token[32]; char token[32];
@ -591,7 +593,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg)
{ "SUBSCRIBER_ADDR", sender } { "SUBSCRIBER_ADDR", sender }
}; };
char tpath[1024]; char tpath[PATHLEN_MAX];
snprintf(tpath, sizeof(tpath), "%s/subscribe.txt", mp->cfg->template_path); snprintf(tpath, sizeof(tpath), "%s/subscribe.txt", mp->cfg->template_path);
char *body = template_render_file(tpath, vars, 4); char *body = template_render_file(tpath, vars, 4);
@ -630,7 +632,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg)
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* UC 4.5: Unsubscribe (maillist+unsubscribe@domain.tld) */ /* UC 4.5: Unsubscribe (to is maillist+unsubscribe@domain.tld) */
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
if (strcasecmp(recipient, "unsubscribe") == 0 || strstr(recipient, "+unsubscribe@")) { if (strcasecmp(recipient, "unsubscribe") == 0 || strstr(recipient, "+unsubscribe@")) {
if (subscriber_exists(mp->subscribers, sender)) { if (subscriber_exists(mp->subscribers, sender)) {
@ -640,9 +642,9 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg)
return imap_expunge_message(mp->cfg, msg->uid); return imap_expunge_message(mp->cfg, msg->uid);
} }
/* ---------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* UC 4.4: Subscription Confirmation (maillist+<unique_id>@domain.tld) */ /* UC 4.4: Subscription confirmation (to is maillist+<unique_id>@domain.tld) */
/* ---------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
char *plus = strchr(recipient, '+'); char *plus = strchr(recipient, '+');
char *at = strchr(recipient, '@'); char *at = strchr(recipient, '@');
if (plus && at && at > plus) { if (plus && at && at > plus) {
@ -668,7 +670,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg)
{ "SUBSCRIBER_ADDR", sender } { "SUBSCRIBER_ADDR", sender }
}; };
char tpath[1024]; char tpath[PATHLEN_MAX];
snprintf(tpath, sizeof(tpath), "%s/welcome.txt", mp->cfg->template_path); snprintf(tpath, sizeof(tpath), "%s/welcome.txt", mp->cfg->template_path);
char *body = template_render_file(tpath, vars, 3); char *body = template_render_file(tpath, vars, 3);
@ -683,7 +685,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg)
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* UC 4.2: Normal Broadcast Operation (maillist@domain.tld) */ /* UC 4.2: Broadcast (maillist@domain.tld) */
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
if (!subscriber_exists(mp->subscribers, sender)) { if (!subscriber_exists(mp->subscribers, sender)) {
/* Drop unauthorized message from non-subscriber */ /* Drop unauthorized message from non-subscriber */