* Fortified the message base and SMTP code so that misdirected bounce messages
authorArt Cancro <ajc@citadel.org>
Sat, 26 Feb 2000 05:15:39 +0000 (05:15 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 26 Feb 2000 05:15:39 +0000 (05:15 +0000)
  end up in the Aide> room instead of getting dereferenced
* Started writing a message reference count verifier ('fsck' for message base)

citadel/ChangeLog
citadel/msgbase.c
citadel/network/mail.sysinfo
citadel/room_ops.c
citadel/serv_expire.c
citadel/serv_smtp.c
citadel/sysdep.c

index 10957e74db96e1c80e16b65c5299d05f56f32d9d..b349384b6be73e76d309013e7c2edd047698125e 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index df17f3c4f975b63f1a1af650aa0a4d113e9f69c1..320c2cb4fb76498b58ceb086e7ecc7c8ae444a67 100644 (file)
@@ -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 */
index ae363a4f64dc049f810008dc61822f37f30845d6..6e72af00852fb3fb52f48342894f721682c1ca7f 100644 (file)
@@ -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
+
index 2fadd7f18a5436a4939469c3d48efd21a3b32383..cf88f1841b12df3ebb3889b376284ee3b8b020d8 100644 (file)
@@ -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);
 }
 
 
index e70117a384480af9bf1e410b2b70ff663e3f4263..3f3cc05aa33f982ebcc29f0668cd89b15df64333 100644 (file)
@@ -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$";
 }
index b08f2d23a9082c38bc0dfe7c26730c9a7afc228c..9a2b03179a9f452028c998c1f9b90b487a8b25be 100644 (file)
@@ -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");
index 904528aa7149042995bb4c2a708aa44336a5067c..d7eee1f7358a7c7cbffa01953a21e0edae6baeda 100644 (file)
@@ -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]);
 }