* The VRFY and EXPN commands have been removed from this implementation
* because nobody uses these commands anymore, except for spammers.
*
- * Copyright (c) 1998-2012 by the citadel.org team
+ * Copyright (c) 1998-2013 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.
+ * 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.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*/
#include "sysdep.h"
#include "config.h"
#include "control.h"
#include "user_ops.h"
+#include "room_ops.h"
#include "database.h"
#include "msgbase.h"
#include "internet_addressing.h"
sSMTP->from = NewStrBufPlain(NULL, SIZ);
sSMTP->recipients = NewStrBufPlain(NULL, SIZ);
sSMTP->OneRcpt = NewStrBufPlain(NULL, SIZ);
+ sSMTP->preferred_sender_email = NULL;
+ sSMTP->preferred_sender_name = NULL;
/* If this config option is set, reject connections from problem
* addresses immediately instead of after they execute a RCPT
*webcit_conf = (char *)msg->cm_fields[eMesageText];
msg->cm_fields[eMesageText] = NULL;
}
- CtdlFreeMessage(msg);
+ CM_Free(msg);
}
void smtp_webcit_preferences_hack(void) {
char config_roomname[ROOMNAMELEN];
char *webcit_conf = NULL;
+ citsmtp *sSMTP = SMTP;
snprintf(config_roomname, sizeof config_roomname, "%010ld.%s", CC->user.usernum, USERCONFIGROOM);
if (CtdlGetRoom(&CC->room, config_roomname) != 0) {
return;
}
- /* FIXME : now do something with this data */
+ /* Parse the webcit configuration and attempt to do something useful with it */
+ char *str = webcit_conf;
+ char *saveptr = str;
+ char *this_line = NULL;
+ while (this_line = strtok_r(str, "\n", &saveptr), this_line != NULL) {
+ str = NULL;
+ if (!strncasecmp(this_line, "defaultfrom|", 12)) {
+ sSMTP->preferred_sender_email = NewStrBufPlain(&this_line[12], -1);
+ }
+ if (!strncasecmp(this_line, "defaultname|", 12)) {
+ sSMTP->preferred_sender_name = NewStrBufPlain(&this_line[12], -1);
+ }
+ if ((!strncasecmp(this_line, "defaultname|", 12)) && (sSMTP->preferred_sender_name == NULL)) {
+ sSMTP->preferred_sender_name = NewStrBufPlain(&this_line[12], -1);
+ }
+ }
free(webcit_conf);
- abort();
}
void smtp_try_plain(long offset, long Flags)
{
citsmtp *sSMTP = SMTP;
- char decoded_authstring[1024];
- char ident[256];
- char user[256];
- char pass[256];
+ const char*decoded_authstring;
+ char ident[256] = "";
+ char user[256] = "";
+ char pass[256] = "";
int result;
- long len;
- CtdlDecodeBase64(decoded_authstring, ChrPtr(sSMTP->Cmd), StrLength(sSMTP->Cmd));
- safestrncpy(ident, decoded_authstring, sizeof ident);
- safestrncpy(user, &decoded_authstring[strlen(ident) + 1], sizeof user);
- len = safestrncpy(pass, &decoded_authstring[strlen(ident) + strlen(user) + 2], sizeof pass);
- if (len == -1)
- len = sizeof(pass) - 1;
+ long decoded_len;
+ long len = 0;
+
+ memset(pass, 0, sizeof(pass));
+ decoded_len = StrBufDecodeBase64(sSMTP->Cmd);
+
+ if (decoded_len > 0)
+ {
+ decoded_authstring = ChrPtr(sSMTP->Cmd);
+
+ len = safestrncpy(ident, decoded_authstring, sizeof ident);
+
+ decoded_len -= len - 1;
+ decoded_authstring += len + 1;
+
+ if (decoded_len > 0)
+ {
+ len = safestrncpy(user, decoded_authstring, sizeof user);
+
+ decoded_authstring += len + 1;
+ decoded_len -= len - 1;
+ }
+
+ if (decoded_len > 0)
+ {
+ len = safestrncpy(pass, decoded_authstring, sizeof pass);
+
+ if (len < 0)
+ len = sizeof(pass) - 1;
+ }
+ }
sSMTP->command_state = smtp_command;
if (result == login_ok) {
if (CtdlTryPassword(pass, len) == pass_ok) {
-//// smtp_webcit_preferences_hack();
+ smtp_webcit_preferences_hack();
smtp_auth_greeting(offset, Flags);
return;
}
* address so we don't have to contend with the empty string causing
* other code to fail when it's expecting something there.
*/
- if (StrLength(sSMTP->from)) {
+ if (StrLength(sSMTP->from) == 0) {
StrBufPlain(sSMTP->from, HKEY("someone@example.com"));
}
{
struct CitContext *CCC = CC;
char message_to_spammer[SIZ];
- struct recptypes *valid = NULL;
+ recptypes *valid = NULL;
citsmtp *sSMTP = SMTP;
if (StrLength(sSMTP->from) == 0) {
struct CtdlMessage *msg = NULL;
long msgnum = (-1L);
char nowstamp[SIZ];
- struct recptypes *valid;
+ recptypes *valid;
int scan_errors;
int i;
citsmtp *sSMTP = SMTP;
return;
}
- CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
- CM_SetField(msg, eNodeName, config.c_nodename, strlen(config.c_nodename));
- CM_SetField(msg, eHumanNode, config.c_humannode, strlen(config.c_humannode));
+ CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+ CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
CM_SetField(msg, eOriginalRoom, HKEY(MAILROOM));
+ if (sSMTP->preferred_sender_name != NULL)
+ CM_SetField(msg, eAuthor, SKEY(sSMTP->preferred_sender_name));
+ else
+ CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
if (!validemail) {
- CM_SetField(msg, erFc822Addr, CCC->cs_inet_email, strlen(CCC->cs_inet_email));
+ if (sSMTP->preferred_sender_email != NULL)
+ CM_SetField(msg, erFc822Addr, SKEY(sSMTP->preferred_sender_email));
+ else
+ CM_SetField(msg, erFc822Addr, CCC->cs_inet_email, strlen(CCC->cs_inet_email));
}
}
scan_errors = 0;
}
else {
- scan_errors = PerformMessageHooks(msg, EVT_SMTPSCAN);
+ scan_errors = PerformMessageHooks(msg, valid, EVT_SMTPSCAN);
}
if (scan_errors > 0) { /* We don't want this message! */
);
/* Clean up */
- CtdlFreeMessage(msg);
+ CM_Free(msg);
free_recipients(valid);
smtp_data_clear(0, 0); /* clear out the buffers now */
}
if (sSMTP->command_state == smtp_user) {
smtp_get_user(0);
+ return;
}
else if (sSMTP->command_state == smtp_password) {
smtp_get_pass(0, 0);
+ return;
}
else if (sSMTP->command_state == smtp_plain) {
smtp_try_plain(0, 0);
+ return;
}
pchs = pch = ChrPtr(sSMTP->Cmd);
FreeStrBuf(&sSMTP->from);
FreeStrBuf(&sSMTP->recipients);
FreeStrBuf(&sSMTP->OneRcpt);
+ FreeStrBuf(&sSMTP->preferred_sender_email);
+ FreeStrBuf(&sSMTP->preferred_sender_name);
free(sSMTP);
}