X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtp.c;fp=citadel%2Fmodules%2Fsmtp%2Fserv_smtp.c;h=a4e7d75afb00d2a131631eeb304950a881a85071;hp=2ebcc4bc12440a88e14dd1a3927376a1fb25a606;hb=b094c568dfdab8c614b7deeb03db65f1b951e715;hpb=4119052e142985e46a6b9cb656ab49c1f9d9f81d diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index 2ebcc4bc1..a4e7d75af 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -690,43 +690,48 @@ void smtp_data(void) { * to something ugly like "0000058008.Sent Items>" when the message * is read with a Citadel client. */ - if ( (CC->logged_in) && (config.c_rfc822_strict_from == 0) ) { - -#ifdef SMTP_REJECT_INVALID_SENDER + if ( (CC->logged_in) && (config.c_rfc822_strict_from != CFG_SMTP_FROM_NOFILTER) ) { int validemail = 0; - - if (!IsEmptyStr(CC->cs_inet_email) && - !IsEmptyStr(msg->cm_fields['F'])) - validemail = strcmp(CC->cs_inet_email, msg->cm_fields['F']) == 0; - if ((!validemail) && - (!IsEmptyStr(CC->cs_inet_other_emails))) + + if (!IsEmptyStr(msg->cm_fields['F']) && + ((config.c_rfc822_strict_from == CFG_SMTP_FROM_CORRECT) || + (config.c_rfc822_strict_from == CFG_SMTP_FROM_REJECT) ) ) { - int num_secondary_emails = 0; - int i; - num_secondary_emails = num_tokens(CC->cs_inet_other_emails, '|'); - for (i=0; ics_inet_other_emails,i,'|',sizeof CC->cs_inet_other_emails); - validemail = strcmp(buf, msg->cm_fields['F']) == 0; + if (!IsEmptyStr(CC->cs_inet_email)) + validemail = strcmp(CC->cs_inet_email, msg->cm_fields['F']) == 0; + if ((!validemail) && + (!IsEmptyStr(CC->cs_inet_other_emails))) + { + int num_secondary_emails = 0; + int i; + num_secondary_emails = num_tokens(CC->cs_inet_other_emails, '|'); + for (i=0; i < num_secondary_emails && !validemail; ++i) { + char buf[256]; + extract_token(buf, CC->cs_inet_other_emails,i,'|',sizeof CC->cs_inet_other_emails); + validemail = strcmp(buf, msg->cm_fields['F']) == 0; + } } } - if (!validemail) { + + if (!validemail && (config.c_rfc822_strict_from == CFG_SMTP_FROM_REJECT)) { syslog(LOG_ERR, "invalid sender '%s' - rejecting this message", msg->cm_fields['F']); cprintf("550 Invalid sender '%s' - rejecting this message.\r\n", msg->cm_fields['F']); return; } -#endif /* SMTP_REJECT_INVALID_SENDER */ if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']); if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']); if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']); - if (msg->cm_fields['F'] != NULL) free(msg->cm_fields['F']); if (msg->cm_fields['O'] != NULL) free(msg->cm_fields['O']); msg->cm_fields['A'] = strdup(CC->user.fullname); msg->cm_fields['N'] = strdup(config.c_nodename); msg->cm_fields['H'] = strdup(config.c_humannode); - msg->cm_fields['F'] = strdup(CC->cs_inet_email); msg->cm_fields['O'] = strdup(MAILROOM); + + if (!validemail) { + if (msg->cm_fields['F'] != NULL) free(msg->cm_fields['F']); + msg->cm_fields['F'] = strdup(CC->cs_inet_email); + } } /* Set the "envelope from" address */