X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtp.c;h=15110cdd68f2296b5434fefaaffc1f97d21d2ac1;hb=882ff5a53c3b4e440520a073cf07dc60b2671876;hp=756116637a41fdc546810b98b1aafc05eb38ede3;hpb=ea0ec5b4c8801733d437a329829e0847bcca5993;p=citadel.git diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index 756116637..15110cdd6 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -20,7 +20,7 @@ * 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-2021 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. @@ -42,18 +42,7 @@ #include #include #include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - +#include #include #include #include @@ -81,6 +70,7 @@ #include "ctdl_module.h" #include "smtp_util.h" + enum { /* Command states for login authentication */ smtp_command, smtp_user, @@ -115,7 +105,9 @@ void registerSmtpCMD(const char *First, long FLen, 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)); @@ -125,10 +117,6 @@ void registerSmtpCMD(const char *First, long FLen, Put(SMTPCmds, First, FLen, h, NULL); } -void smtp_cleanup(void) -{ - DeleteHash(&SMTPCmds); -} /* * Here's where our SMTP session begins its happy day. @@ -157,7 +145,7 @@ void smtp_greeting(int is_msa) * 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 @@ -322,7 +310,7 @@ void smtp_webcit_preferences_hack_backend(long msgnum, void *userdata) { return; // already got it } - msg = CtdlFetchMessage(msgnum, 1, 1); + msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) { return; } @@ -403,7 +391,7 @@ void smtp_get_user(long offset) 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') { @@ -488,10 +476,10 @@ void smtp_try_plain(long offset, long 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) { @@ -705,7 +693,7 @@ void smtp_rcpt(long offset, long flags) { struct CitContext *CCC = CC; char message_to_spammer[SIZ]; - recptypes *valid = NULL; + struct recptypes *valid = NULL; citsmtp *sSMTP = SMTP; if (StrLength(sSMTP->from) == 0) { @@ -737,7 +725,7 @@ void smtp_rcpt(long offset, long flags) 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 @@ -804,7 +792,7 @@ void smtp_data(long offset, long flags) struct CtdlMessage *msg = NULL; long msgnum = (-1L); char nowstamp[SIZ]; - recptypes *valid; + struct recptypes *valid; int scan_errors; int i; citsmtp *sSMTP = SMTP; @@ -847,7 +835,7 @@ void smtp_data(long offset, long flags) 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"); @@ -896,8 +884,6 @@ void smtp_data(long offset, long flags) 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)); @@ -946,7 +932,7 @@ void smtp_data(long offset, long flags) } else { /* Ok, we'll accept this message. */ - msgnum = CtdlSubmitMsg(msg, valid, "", 0); + msgnum = CtdlSubmitMsg(msg, valid, ""); if (msgnum > 0L) { StrBufPrintf(sSMTP->OneRcpt, "250 Message accepted.\r\n"); } @@ -1021,7 +1007,7 @@ void smtp_command_loop(void) if (sSMTP == NULL) { syslog(LOG_EMERG, "Session SMTP data is null. WTF? We will crash now."); - return cit_panic_backtrace (0); + abort(); } time(&CCC->lastcmd); @@ -1188,7 +1174,6 @@ CTDL_MODULE_INIT(smtp) NULL, CitadelServiceSMTP_LMTP_UNF); - CtdlRegisterCleanupHook(smtp_cleanup); CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP, PRIO_STOP + 250); }