X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtp.c;h=d2c7b1e95f6ca4896187885c199dca25e28485ae;hb=3faf301cf0711139536f237f6cf69a22a71ee370;hp=960e105d0816164602b6a3182c861439a5179105;hpb=0e211d73471e57a1ac1bf20fad04e9866a5142c3;p=citadel.git diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index 960e105d0..d2c7b1e95 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -55,6 +55,7 @@ #include #include #include +#include #include "citadel.h" #include "server.h" #include "citserver.h" @@ -66,7 +67,6 @@ #include "policy.h" #include "database.h" #include "msgbase.h" -#include "tools.h" #include "internet_addressing.h" #include "genstamp.h" #include "domain.h" @@ -105,7 +105,7 @@ enum { /* Command states for login authentication */ smtp_plain }; -#define SMTP CC->SMTP +#define SMTP ((struct citsmtp *)CC->session_specific_data) int run_queue_now = 0; /* Set to 1 to ignore SMTP send retry times */ @@ -127,7 +127,7 @@ void smtp_greeting(int is_msa) strcpy(CC->cs_clientname, "SMTP session"); CC->internal_pgm = 1; CC->cs_flags |= CS_STEALTH; - SMTP = malloc(sizeof(struct citsmtp)); + CC->session_specific_data = malloc(sizeof(struct citsmtp)); memset(SMTP, 0, sizeof(struct citsmtp)); SMTP->is_msa = is_msa; @@ -166,7 +166,9 @@ void smtp_greeting(int is_msa) */ void smtps_greeting(void) { CtdlModuleStartCryptoMsgs(NULL, NULL, NULL); +#ifdef HAVE_OPENSSL if (!CC->redirect_ssl) CC->kill_me = 1; /* kill session if no crypto */ +#endif smtp_greeting(0); } @@ -314,7 +316,7 @@ void smtp_get_user(char *argbuf) { CtdlDecodeBase64(username, argbuf, SIZ); /* lprintf(CTDL_DEBUG, "Trying <%s>\n", username); */ if (CtdlLoginExistingUser(NULL, username) == login_ok) { - CtdlEncodeBase64(buf, "Password:", 9); + CtdlEncodeBase64(buf, "Password:", 9, 0); cprintf("334 %s\r\n", buf); SMTP->command_state = smtp_password; } @@ -397,7 +399,7 @@ void smtp_auth(char *argbuf) { smtp_get_user(&argbuf[6]); } else { - CtdlEncodeBase64(username_prompt, "Username:", 9); + CtdlEncodeBase64(username_prompt, "Username:", 9, 0); cprintf("334 %s\r\n", username_prompt); SMTP->command_state = smtp_user; } @@ -596,7 +598,8 @@ void smtp_rcpt(char *argbuf) { } } - valid = validate_recipients(recp); + valid = validate_recipients(recp, + (CC->logged_in)? POST_LOGGED_IN:POST_EXTERNAL); if (valid->num_error != 0) { cprintf("599 5.1.1 Error: %s\r\n", valid->errormsg); free_recipients(valid); @@ -673,7 +676,7 @@ void smtp_data(void) { config.c_fqdn, nowstamp); - body = CtdlReadMessageBody(".", config.c_maxmsglen, body, 1); + body = CtdlReadMessageBody(".", config.c_maxmsglen, body, 1, 0); if (body == NULL) { cprintf("550 5.6.5 " "Unable to save message: internal error.\r\n"); @@ -719,7 +722,8 @@ void smtp_data(void) { msg->cm_fields['V'] = strdup(SMTP->recipients); /* Submit the message into the Citadel system. */ - valid = validate_recipients(SMTP->recipients); + valid = validate_recipients(SMTP->recipients, + (CC->logged_in)? POST_LOGGED_IN:POST_EXTERNAL); /* If there are modules that want to scan this message before final * submission (such as virus checkers or spam filters), call them now @@ -1109,7 +1113,7 @@ void smtp_try(const char *key, const char *addr, int *status, if (!IsEmptyStr(mx_user)) { char encoded[1024]; sprintf(buf, "%s%c%s%c%s", mx_user, '\0', mx_user, '\0', mx_pass); - CtdlEncodeBase64(encoded, buf, strlen(mx_user) + strlen(mx_user) + strlen(mx_pass) + 2); + CtdlEncodeBase64(encoded, buf, strlen(mx_user) + strlen(mx_user) + strlen(mx_pass) + 2, 0); snprintf(buf, sizeof buf, "AUTH PLAIN %s\r\n", encoded); lprintf(CTDL_DEBUG, ">%s", buf); sock_write(sock, buf, strlen(buf)); @@ -1435,7 +1439,7 @@ void smtp_do_bounce(char *instr) { } /* Can we deliver the bounce to the original sender? */ - valid = validate_recipients(bounceto); + valid = validate_recipients(bounceto, 0); if (valid != NULL) { if (valid->num_error == 0) { CtdlSubmitMsg(bmsg, valid, ""); @@ -1812,48 +1816,51 @@ const char *CitadelServiceSMTP_LMTP_UNF="LMTP-UnF"; CTDL_MODULE_INIT(smtp) { - CtdlRegisterServiceHook(config.c_smtp_port, /* SMTP MTA */ - NULL, - smtp_mta_greeting, - smtp_command_loop, - NULL, - CitadelServiceSMTP_MTA); + if (!threading) + { + CtdlRegisterServiceHook(config.c_smtp_port, /* SMTP MTA */ + NULL, + smtp_mta_greeting, + smtp_command_loop, + NULL, + CitadelServiceSMTP_MTA); #ifdef HAVE_OPENSSL - CtdlRegisterServiceHook(config.c_smtps_port, - NULL, - smtps_greeting, - smtp_command_loop, - NULL, - CitadelServiceSMTPS_MTA); + CtdlRegisterServiceHook(config.c_smtps_port, + NULL, + smtps_greeting, + smtp_command_loop, + NULL, + CitadelServiceSMTPS_MTA); #endif - CtdlRegisterServiceHook(config.c_msa_port, /* SMTP MSA */ - NULL, - smtp_msa_greeting, - smtp_command_loop, - NULL, - CitadelServiceSMTP_MSA); - - CtdlRegisterServiceHook(0, /* local LMTP */ - file_lmtp_socket, - lmtp_greeting, - smtp_command_loop, - NULL, - CitadelServiceSMTP_LMTP); - - CtdlRegisterServiceHook(0, /* local LMTP */ - file_lmtp_unfiltered_socket, - lmtp_unfiltered_greeting, - smtp_command_loop, - NULL, - CitadelServiceSMTP_LMTP_UNF); - - smtp_init_spoolout(); - CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER); - CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP); - CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands"); - + CtdlRegisterServiceHook(config.c_msa_port, /* SMTP MSA */ + NULL, + smtp_msa_greeting, + smtp_command_loop, + NULL, + CitadelServiceSMTP_MSA); + + CtdlRegisterServiceHook(0, /* local LMTP */ + file_lmtp_socket, + lmtp_greeting, + smtp_command_loop, + NULL, + CitadelServiceSMTP_LMTP); + + CtdlRegisterServiceHook(0, /* local LMTP */ + file_lmtp_unfiltered_socket, + lmtp_unfiltered_greeting, + smtp_command_loop, + NULL, + CitadelServiceSMTP_LMTP_UNF); + + smtp_init_spoolout(); + CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER); + CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP); + CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands"); + } + /* return our Subversion id for the Log */ return "$Id$"; }