* The VRFY and EXPN commands have been removed from this implementation
* because nobody uses these commands anymore, except for spammers.
*
- * Copyright (c) 1998-2015 by the citadel.org team
+ * Copyright (c) 1998-2018 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3.
#include "ctdl_module.h"
#include "smtp_util.h"
+
enum { /* Command states for login authentication */
smtp_command,
smtp_user,
int EnableSMTPLog = 0;
-#define SMTPLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (EnableSMTPLog != 0))
-
-#define SMTP_syslog(LEVEL, FORMAT, ...) \
- SMTPLOG(LEVEL) syslog(LEVEL, \
- "%s CC[%d]: " FORMAT, IOSTR, CCCID, __VA_ARGS__)
-
-#define SMTPM_syslog(LEVEL, FORMAT) \
- SMTPLOG(LEVEL) syslog(LEVEL, \
- "%s CC[%d]: " FORMAT, IOSTR, CCCID);
-
HashList *SMTPCmds = NULL;
#define MaxSMTPCmdLen 10
smtp_handler_hook *h;
if (FLen >= MaxSMTPCmdLen)
- cit_panic_backtrace (0);
+ {
+ abort();
+ }
h = (smtp_handler_hook*) malloc(sizeof(smtp_handler_hook));
memset(h, 0, sizeof(smtp_handler_hook));
Put(SMTPCmds, First, FLen, h, NULL);
}
+
void smtp_cleanup(void)
{
DeleteHash(&SMTPCmds);
* addresses immediately instead of after they execute a RCPT
*/
if ( (CtdlGetConfigInt("c_rbl_at_greeting")) && (sSMTP->is_msa == 0) ) {
- if (rbl_check(message_to_spammer)) {
+ if (rbl_check(CC->cs_addr, message_to_spammer)) {
if (server_shutting_down)
cprintf("421 %s\r\n", message_to_spammer);
else
void smtp_auth_greeting(long offset, long Flags) {
struct CitContext *CCC = CC;
cprintf("235 Hello, %s\r\n", CCC->user.fullname);
- SMTP_syslog(LOG_NOTICE, "SMTP authenticated %s", CCC->user.fullname);
+ syslog(LOG_NOTICE, "SMTP authenticated %s", CCC->user.fullname);
CCC->internal_pgm = 0;
CCC->cs_flags &= ~CS_STEALTH;
}
StrBufDecodeBase64(sSMTP->Cmd);
- if (CtdlLoginExistingUser(NULL, ChrPtr(sSMTP->Cmd)) == login_ok) {
+ if (CtdlLoginExistingUser(ChrPtr(sSMTP->Cmd)) == login_ok) {
size_t len = CtdlEncodeBase64(buf, "Password:", 9, 0);
if (buf[len - 1] == '\n') {
*/
void smtp_get_pass(long offset, long Flags)
{
- struct CitContext *CCC = CC;
citsmtp *sSMTP = SMTP;
char password[SIZ];
memset(password, 0, sizeof(password));
StrBufDecodeBase64(sSMTP->Cmd);
- SMTP_syslog(LOG_DEBUG, "Trying <%s>", password);
+ syslog(LOG_DEBUG, "Trying <%s>", password);
if (CtdlTryPassword(SKEY(sSMTP->Cmd)) == pass_ok) {
smtp_auth_greeting(offset, Flags);
}
sSMTP->command_state = smtp_command;
if (!IsEmptyStr(ident)) {
- result = CtdlLoginExistingUser(user, ident);
+ result = CtdlLoginExistingUser(ident);
}
else {
- result = CtdlLoginExistingUser(NULL, user);
+ result = CtdlLoginExistingUser(user);
}
if (result == login_ok) {
*/
else if (CtdlGetConfigInt("c_allow_spoofing") == 0) {
process_rfc822_addr(ChrPtr(sSMTP->from), user, node, name);
- SMTP_syslog(LOG_DEBUG, "Claimed envelope sender is '%s' == '%s' @ '%s' ('%s')",
+ syslog(LOG_DEBUG, "Claimed envelope sender is '%s' == '%s' @ '%s' ('%s')",
ChrPtr(sSMTP->from), user, node, name
);
if (CtdlHostAlias(node) != hostalias_nomatch) {
cprintf("550 You must log in to send mail from %s\r\n", node);
FlushStrBuf(sSMTP->from);
- SMTP_syslog(LOG_DEBUG, "Rejecting unauthenticated mail from %s", node);
+ syslog(LOG_DEBUG, "Rejecting unauthenticated mail from %s", node);
return;
}
}
if ( (!CCC->logged_in) /* Don't RBL authenticated users */
&& (!sSMTP->is_lmtp) ) { /* Don't RBL LMTP clients */
if (CtdlGetConfigInt("c_rbl_at_greeting") == 0) { /* Don't RBL again if we already did it */
- if (rbl_check(message_to_spammer)) {
+ if (rbl_check(CC->cs_addr, message_to_spammer)) {
if (server_shutting_down)
cprintf("421 %s\r\n", message_to_spammer);
else
nowstamp);
}
}
- body = CtdlReadMessageBodyBuf(HKEY("."), CtdlGetConfigLong("c_maxmsglen"), defbody, 1, NULL);
+ body = CtdlReadMessageBodyBuf(HKEY("."), CtdlGetConfigLong("c_maxmsglen"), defbody, 1);
FreeStrBuf(&defbody);
if (body == NULL) {
cprintf("550 Unable to save message: internal error.\r\n");
return;
}
- SMTPM_syslog(LOG_DEBUG, "Converting message...");
+ syslog(LOG_DEBUG, "Converting message...");
msg = convert_internet_message_buf(&body);
/* If the user is locally authenticated, FORCE the From: header to
}
if (!validemail && (CtdlGetConfigInt("c_rfc822_strict_from") == CFG_SMTP_FROM_REJECT)) {
- SMTP_syslog(LOG_ERR, "invalid sender '%s' - rejecting this message", msg->cm_fields[erFc822Addr]);
+ syslog(LOG_ERR, "invalid sender '%s' - rejecting this message", msg->cm_fields[erFc822Addr]);
cprintf("550 Invalid sender '%s' - rejecting this message.\r\n", msg->cm_fields[erFc822Addr]);
return;
}
- CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
- CM_SetField(msg, eHumanNode, CtdlGetConfigStr("c_humannode"), strlen(CtdlGetConfigStr("c_humannode")));
CM_SetField(msg, eOriginalRoom, HKEY(MAILROOM));
if (sSMTP->preferred_sender_name != NULL)
CM_SetField(msg, eAuthor, SKEY(sSMTP->preferred_sender_name));
/* Write something to the syslog(which may or may not be where the
* rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
*/
- SMTP_syslog((LOG_MAIL | LOG_INFO),
+ syslog((LOG_MAIL | LOG_INFO),
"%ld: from=<%s>, nrcpts=%d, relay=%s [%s], stat=%s",
msgnum,
ChrPtr(sSMTP->from),
char CMD[MaxSMTPCmdLen + 1];
if (sSMTP == NULL) {
- SMTPM_syslog(LOG_EMERG, "Session SMTP data is null. WTF? We will crash now.");
- return cit_panic_backtrace (0);
+ syslog(LOG_EMERG, "Session SMTP data is null. WTF? We will crash now.");
+ abort();
}
time(&CCC->lastcmd);
if (CtdlClientGetLine(sSMTP->Cmd) < 1) {
- SMTPM_syslog(LOG_CRIT, "SMTP: client disconnected: ending session.");
+ syslog(LOG_CRIT, "SMTP: client disconnected: ending session.");
CC->kill_me = KILLME_CLIENT_DISCONNECTED;
return;
}
- SMTP_syslog(LOG_DEBUG, "SMTP server: %s", ChrPtr(sSMTP->Cmd));
+ syslog(LOG_DEBUG, "SMTP server: %s", ChrPtr(sSMTP->Cmd));
if (sSMTP->command_state == smtp_user) {
if (!strncmp(ChrPtr(sSMTP->Cmd), AuthPlainStr.Key, AuthPlainStr.len))
/* Don't do this stuff if this is not an SMTP session! */
if (CCC->h_command_function != smtp_command_loop) return;
- SMTPM_syslog(LOG_DEBUG, "Performing SMTP cleanup hook");
+ syslog(LOG_DEBUG, "Performing SMTP cleanup hook");
FreeStrBuf(&sSMTP->Cmd);
FreeStrBuf(&sSMTP->helo_node);
const char *CitadelServiceSMTP_LMTP="LMTP";
const char *CitadelServiceSMTP_LMTP_UNF="LMTP-UnF";
-void DebugSMTPEnable(const int n)
-{
- EnableSMTPLog = n;
-}
CTDL_MODULE_INIT(smtp)
{
if (!threading)
{
- CtdlRegisterDebugFlagHook(HKEY("SMTP"), DebugSMTPEnable, &EnableSMTPLog);
-
SMTPCmds = NewHash(1, NULL);
RegisterSmtpCMD("AUTH", smtp_auth, 0);