From b5751fc945bd8dc8b94bf2f77170c26d308def1b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 26 Feb 2000 05:15:39 +0000 Subject: [PATCH] * Fortified the message base and SMTP code so that misdirected bounce messages end up in the Aide> room instead of getting dereferenced * Started writing a message reference count verifier ('fsck' for message base) --- citadel/ChangeLog | 6 +++++- citadel/msgbase.c | 15 +++++++++++++-- citadel/network/mail.sysinfo | 8 +++++++- citadel/room_ops.c | 6 ++++-- citadel/serv_expire.c | 35 +++++++++++++++++++++++++++++++++++ citadel/serv_smtp.c | 36 +++++++++++++++++++++--------------- citadel/sysdep.c | 2 ++ 7 files changed, 87 insertions(+), 21 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 10957e74d..b349384b6 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ +Revision 1.470 2000/02/26 05:15:38 ajc +* Fortified the message base and SMTP code so that misdirected bounce messages + end up in the Aide> room instead of getting dereferenced +* Started writing a message reference count verifier ('fsck' for message base) + Revision 1.469 2000/02/25 06:14:05 ajc * Modularized the RWHO (Read WHO is online) command, basically as a pilot for modularizing all "non-API" functionality. @@ -1662,4 +1667,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/msgbase.c b/citadel/msgbase.c index df17f3c4f..320c2cb4f 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1476,7 +1476,7 @@ int ReplicationChecks(struct CtdlMessage *msg) { long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ char *rec, /* Recipient (mail) */ char *force, /* force a particular room? */ - int mailtype, /* local or remote type */ + int supplied_mailtype, /* local or remote type */ int generate_id) /* 1 = generate 'I' field */ { char aaa[100]; @@ -1494,9 +1494,11 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ static int seqnum = 1; struct CtdlMessage *imsg; char *instr; + int mailtype; lprintf(9, "CtdlSaveMsg() called\n"); if (is_valid_message(msg) == 0) return(-1); /* self check */ + mailtype = supplied_mailtype; /* If this message has no timestamp, we take the liberty of * giving it one, right now. @@ -1540,6 +1542,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ == hostalias_localhost) { recipient[a] = 0; lprintf(7, "Changed to <%s>\n", recipient); + mailtype = MES_LOCAL; } } } @@ -1660,7 +1663,10 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ * is no local sender; it would otherwise go to the Trashcan). */ if ((!CC->internal_pgm) || (strlen(recipient) == 0)) { - CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0); + if (CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0) != 0) { + lprintf(3, "ERROR saving message pointer!\n"); + CtdlSaveMsgPointerInRoom(AIDEROOM, newmsgid, 0); + } } /* For internet mail, drop a copy in the outbound queue room */ @@ -1683,6 +1689,11 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ MailboxName(actual_rm, &userbuf, MAILROOM); CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0); } + else { + lprintf(9, "No user <%s>, saving in %s> instead\n", + recipient, AIDEROOM); + CtdlSaveMsgPointerInRoom(AIDEROOM, newmsgid, 0); + } } /* Perform "after save" hooks */ diff --git a/citadel/network/mail.sysinfo b/citadel/network/mail.sysinfo index ae363a4f6..6e72af008 100644 --- a/citadel/network/mail.sysinfo +++ b/citadel/network/mail.sysinfo @@ -1,7 +1,7 @@ internet uum %s humannode Internet Gateway -lastcontact 951189557 Mon Feb 21 22:19:17 2000 +lastcontact 951540103 Fri Feb 25 23:41:43 2000 uncnsrd bin Mail @@ -12,3 +12,9 @@ lastcontact 951189558 Mon Feb 21 22:19:18 2000 test bin Mail +tux +bin Mail +phonenum US 800 555 1212 +humannode My System +lastcontact 951540103 Fri Feb 25 23:41:43 2000 + diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 2fadd7f18..cf88f1841 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -171,8 +171,10 @@ int getroom(struct quickroom *qrbuf, char *room_name) */ int lgetroom(struct quickroom *qrbuf, char *room_name) { - begin_critical_section(S_QUICKROOM); - return (getroom(qrbuf, room_name)); + register int retval; + retval = getroom(qrbuf, room_name); + if (retval == 0) begin_critical_section(S_QUICKROOM); + return(retval); } diff --git a/citadel/serv_expire.c b/citadel/serv_expire.c index e70117a38..3f3cc05aa 100644 --- a/citadel/serv_expire.c +++ b/citadel/serv_expire.c @@ -531,10 +531,45 @@ void cmd_expi(char *argbuf) { } } +/*****************************************************************************/ +/* + * Check message reference counts (FIXME ... not yet finished) +void cmd_fsck(char *argbuf) { + long msgnum; + struct cdbdata *cdbmsg; + struct SuppMsgInfo smi; + + cprintf("%d This is not done yet.\n", LISTING_FOLLOWS); + + get_control(); + for (msgnum = 0L; msgnum <= CitControl.MMhighest; ++msgnum) { + + cdbmsg = cdb_fetch(CDB_MSGMAIN, &msgnum, sizeof(long)); + if (cdbmsg != NULL) { + cdb_free(cdbmsg); + cprintf("Message %7ld ", msgnum); + + GetSuppMsgInfo(&smi, msgnum); + cprintf("refcount=%-2d \n", smi.smi_refcount); + } + + } + + cprintf("000\n"); + +} + */ + + + + +/*****************************************************************************/ + char *Dynamic_Module_Init(void) { CtdlRegisterProtoHook(cmd_expi, "EXPI", "Expire old system objects"); +/* CtdlRegisterProtoHook(cmd_fsck, "FSCK", "Check message ref counts"); */ return "$Id$"; } diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index b08f2d23a..9a2b03179 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -21,6 +21,7 @@ #include "citserver.h" #include "support.h" #include "config.h" +#include "control.h" #include "dynloader.h" #include "room_ops.h" #include "user_ops.h" @@ -979,6 +980,7 @@ void smtp_do_bounce(char *instr) { time_t submitted = 0L; struct CtdlMessage *bmsg = NULL; int give_up = 0; + int mes_type = 0; lprintf(9, "smtp_do_bounce() called\n"); strcpy(bounceto, ""); @@ -1010,25 +1012,20 @@ void smtp_do_bounce(char *instr) { bmsg->cm_anon_type = MES_NORMAL; bmsg->cm_format_type = 1; bmsg->cm_fields['A'] = strdoop("Citadel"); + bmsg->cm_fields['O'] = strdoop(MAILROOM); bmsg->cm_fields['N'] = strdoop(config.c_nodename); if (give_up) bmsg->cm_fields['M'] = strdoop( -"BOUNCE! BOUNCE!! BOUNCE!!!\n\n" -"FIXME ... this message should be made to look nice and stuff.\n" -"In the meantime, you should be aware that we're giving up on the\n" -"following deliveries because their mail servers are fux0red and\n" -"would not accept the message for a very, very long time:\n\n" +"A message you sent could not be delivered to some or all of its recipients.\n" +"The following addresses were undeliverable:\n\n" ); else bmsg->cm_fields['M'] = strdoop( -"BOUNCE! BOUNCE!! BOUNCE!!!\n\n" -"FIXME ... this message should be made to look nice and stuff.\n" -"In the meantime, you should be aware that the following\n" -"recipient addresses had permanent fatal errors:\n\n" +"A message you sent could not be delivered to some or all of its recipients\n" +"due to prolonged unavailability of its destination(s).\n" +"Giving up on the following addresses:\n\n" ); - - /* * Now go through the instructions checking for stuff. */ @@ -1085,10 +1082,19 @@ void smtp_do_bounce(char *instr) { /* First try the user who sent the message */ lprintf(9, "bounce to user? <%s>\n", bounceto); - if (strlen(bounceto) == 0) bounce_msgid = (-1L); - else bounce_msgid = CtdlSaveMsg(bmsg, - bounceto, - "", MES_LOCAL, 1); + if (strlen(bounceto) == 0) { + lprintf(7, "No bounce address specified\n"); + bounce_msgid = (-1L); + } + else if (mes_type = alias(bounceto), mes_type == MES_ERROR) { + lprintf(7, "Invalid bounce address <%s>\n", bounceto); + bounce_msgid = (-1L); + } + else { + bounce_msgid = CtdlSaveMsg(bmsg, + bounceto, + "", mes_type, 1); + } /* Otherwise, go to the Aide> room */ lprintf(9, "bounce to room?\n"); diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 904528aa7..d7eee1f73 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -241,6 +241,7 @@ void init_sysdep(void) { */ void begin_critical_section(int which_one) { + /* lprintf(9, "begin_critical_section(%d)\n", which_one); */ pthread_mutex_lock(&Critters[which_one]); } @@ -249,6 +250,7 @@ void begin_critical_section(int which_one) */ void end_critical_section(int which_one) { + /* lprintf(9, "end_critical_section(%d)\n", which_one); */ pthread_mutex_unlock(&Critters[which_one]); } -- 2.39.2