From 2ea5b824587e782a39d2776dc6779b5480ba3bcf Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 10 Mar 2000 21:40:06 +0000 Subject: [PATCH] * Changes to message base and networker to support Internet-style message ID's instead of the conventional Citadel style. --- citadel/ChangeLog | 5 ++++ citadel/citadel.h | 33 +--------------------- citadel/internet_addressing.c | 35 +++++++++++++++++++++++ citadel/msgbase.c | 32 ++++++++++++--------- citadel/msgbase.h | 4 +-- citadel/netproc.c | 52 ++++++++++++++++++++++++----------- citadel/network/mail.sysinfo | 18 ++++++------ citadel/serv_smtp.c | 15 +++++----- citadel/serv_vcard.c | 2 +- 9 files changed, 115 insertions(+), 81 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 158d33f41..ee7185ab0 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 1.481 2000/03/10 21:40:04 ajc +* Changes to message base and networker to support Internet-style message + ID's instead of the conventional Citadel style. + Revision 1.480 2000/03/08 03:36:37 ajc * Shut off hostname resolution when dealing with Unix domain sockets * Cleaned up the 'citmail' MDA tool @@ -1707,3 +1711,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.h b/citadel/citadel.h index a4d264ae8..575a5ebcd 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -180,14 +180,7 @@ struct quickroom { /****************************************************************************/ -struct recentmsg { - char RMnodename[10]; - long RMnum; /* Number or time of message */ - }; - - -/**************************************************************************** - * +/* * Floor record. The floor number is implicit in its location in the file. */ struct floor { @@ -246,28 +239,4 @@ struct floor { #define SPOOLMIME "application/x-citadel-delivery-list" #define INTERNETCFG "application/x-citadel-internet-config" -/* - * This structure is used to hold all of the fields of a message - * during conversion, processing, or whatever. - */ -struct minfo { - char A[512]; - char B[512]; - char C[512]; - char D[512]; - char E[512]; - char G[512]; - char H[512]; - long I; - char N[512]; - char O[512]; - char P[512]; - char R[512]; - char S[512]; - long T; - char U[512]; - char Z[512]; - char nexthop[512]; - }; - #define TRACE lprintf(9, "Checkpoint: %s, %d\n", __FILE__, __LINE__) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 91648a86e..32114261d 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -458,6 +458,38 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { processed = 1; } + else if (!strcasecmp(key, "Message-ID")) { + if (msg->cm_fields['I'] != NULL) { + lprintf(5, "duplicate message id\n"); + } + + if (msg->cm_fields['I'] == NULL) { + msg->cm_fields['I'] = strdoop(value); + + /* Strip angle brackets */ + if ((haschar(msg->cm_fields['I'], '<') == 1) + && (haschar(msg->cm_fields['I'], '>') == 1)) { + while ((strlen(msg->cm_fields['I']) > 0) + && (msg->cm_fields['I'][0] != '<')) { + strcpy(&msg->cm_fields['I'][0], + &msg->cm_fields['I'][1]); + } + strcpy(&msg->cm_fields['I'][0], + &msg->cm_fields['I'][1]); + for (i = 0; icm_fields['I']); ++i) + if (msg->cm_fields['I'][i] == '>') + msg->cm_fields['I'][i] = 0; + } + } + + if (msg->cm_fields['I'] != NULL) { + TRACE; + lprintf(9, "Converted message id <%s>\n", + msg->cm_fields['I'] ); + } + processed = 1; + } + /* Clean up and move on. */ phree(key); /* Don't free 'value', it's actually the same buffer */ return(processed); @@ -490,6 +522,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { while (!done) { + TRACE; lprintf(9, "I field is %s\n", msg->cm_fields['I']); /* Locate beginning and end of field, keeping in mind that * some fields might be multiline */ @@ -523,6 +556,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { } /* Follow-up sanity checks... */ + TRACE; lprintf(9, "I field is %s\n", msg->cm_fields['I']); /* If there's no timestamp on this message, set it to now. */ if (msg->cm_fields['T'] == NULL) { @@ -530,6 +564,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { msg->cm_fields['T'] = strdoop(buf); } + TRACE; lprintf(9, "I field is %s\n", msg->cm_fields['I']); lprintf(9, "RFC822 length remaining after conversion = %d\n", strlen(rfc822)); return msg; diff --git a/citadel/msgbase.c b/citadel/msgbase.c index c5213d12b..88d1484df 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -963,7 +963,14 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ if (!strcasecmp(snode, NODENAME)) { strcpy(snode, FQDN); } - cprintf("Message-ID: <%s@%s>%s", mid, snode, nl); + + /* Construct a fun message id */ + cprintf("Message-ID: <%s", mid); + if (strchr(mid, '@')==NULL) { + cprintf("@%s", snode); + } + cprintf(">%s", nl); + PerformUserHooks(luser, (-1L), EVT_OUTPUTMSG); if (strlen(fuser) > 0) { @@ -1304,19 +1311,19 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { * */ long send_message(struct CtdlMessage *msg, /* pointer to buffer */ - int generate_id, /* generate 'I' field? */ FILE *save_a_copy) /* save a copy to disk? */ { long newmsgid; long retval; - char msgidbuf[32]; + char msgidbuf[256]; struct ser_ret smr; /* Get a new message number */ newmsgid = get_new_message_number(); - sprintf(msgidbuf, "%ld", newmsgid); + sprintf(msgidbuf, "%ld@%s", newmsgid, config.c_fqdn); - if (generate_id) { + /* Generate an ID if we don't have one already */ + if (msg->cm_fields['I']==NULL) { msg->cm_fields['I'] = strdoop(msgidbuf); } @@ -1479,8 +1486,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 supplied_mailtype, /* local or remote type */ - int generate_id) /* 1 = generate 'I' field */ + int supplied_mailtype) /* local or remote type */ { char aaa[100]; char hold_rm[ROOMNAMELEN]; @@ -1639,7 +1645,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ /* Save it to disk */ lprintf(9, "Saving to disk\n"); - newmsgid = send_message(msg, generate_id, network_fp); + newmsgid = send_message(msg, network_fp); if (network_fp != NULL) { fclose(network_fp); system("exec nohup ./netproc -i >/dev/null 2>&1 &"); @@ -1729,7 +1735,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */ imsg->cm_format_type = FMT_RFC822; imsg->cm_fields['A'] = strdoop("Citadel"); imsg->cm_fields['M'] = instr; - CtdlSaveMsg(imsg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL, 1); + CtdlSaveMsg(imsg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL); CtdlFreeMessage(imsg); } @@ -1757,7 +1763,7 @@ void quickie_message(char *from, char *to, char *room, char *text) msg->cm_fields['R'] = strdoop(to); msg->cm_fields['M'] = strdoop(text); - CtdlSaveMsg(msg, "", room, MES_LOCAL, 1); + CtdlSaveMsg(msg, "", room, MES_LOCAL); CtdlFreeMessage(msg); syslog(LOG_NOTICE, text); } @@ -2055,7 +2061,7 @@ SKFALL: b = MES_NORMAL; CC->quickroom.QRname, b, e, format_type, ""); if (msg != NULL) - CtdlSaveMsg(msg, buf, (mtsflag ? AIDEROOM : ""), e, 1); + CtdlSaveMsg(msg, buf, (mtsflag ? AIDEROOM : ""), e); CtdlFreeMessage(msg); CC->fake_postname[0] = '\0'; return; @@ -2160,7 +2166,7 @@ void cmd_ent3(char *entargs) } msg->cm_flags = CM_SKIP_HOOKS; - if (valid_msg) CtdlSaveMsg(msg, recp, "", e, 0); + if (valid_msg) CtdlSaveMsg(msg, recp, "", e); CtdlFreeMessage(msg); phree(tempbuf); } @@ -2501,7 +2507,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ CtdlDeleteMessages(roomname, 0L, content_type)); } /* Now write the data */ - CtdlSaveMsg(msg, "", roomname, MES_LOCAL, 1); + CtdlSaveMsg(msg, "", roomname, MES_LOCAL); CtdlFreeMessage(msg); } diff --git a/citadel/msgbase.h b/citadel/msgbase.h index 466e18803..5db18749a 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -55,9 +55,9 @@ void cmd_msg2 (char *cmdbuf); void cmd_msg3 (char *cmdbuf); void cmd_msg4 (char *cmdbuf); void cmd_opna (char *cmdbuf); -long send_message (struct CtdlMessage *, int, FILE *); +long send_message (struct CtdlMessage *, FILE *); void loadtroom (void); -long CtdlSaveMsg(struct CtdlMessage *, char *, char *, int, int); +long CtdlSaveMsg(struct CtdlMessage *, char *, char *, int); void quickie_message (char *, char *, char *, char *); struct CtdlMessage *make_message (struct usersupp *, char *, char *, int, int, int, char *); diff --git a/citadel/netproc.c b/citadel/netproc.c index 48ea0c01a..d6ace99fd 100644 --- a/citadel/netproc.c +++ b/citadel/netproc.c @@ -83,6 +83,33 @@ struct syslist { }; + +/* + * This structure is used to hold all of the fields of a message + * during conversion, processing, or whatever. + */ +struct minfo { + char A[512]; + char B[512]; + char C[512]; + char D[512]; + char E[512]; + char G[512]; + char H[512]; + char I[512]; + char N[512]; + char O[512]; + char P[512]; + char R[512]; + char S[512]; + long T; + char U[512]; + char Z[512]; + char nexthop[512]; + }; + + + void attach_to_server(int argc, char **argv); void serv_read(char *buf, int bytes); void serv_write(char *buf, int nbytes); @@ -539,7 +566,7 @@ BONFGM: b = getc(fp); if (b == 'T') buffer->T = atol(bbb); if (b == 'I') - buffer->I = atol(bbb); + strcpy(buffer->I, bbb); if (b == 'H') strcpy(buffer->H, bbb); if (b == 'B') @@ -554,14 +581,6 @@ BONFGM: b = getc(fp); END: - /* NOTE: we used to use the following two lines of code to assign - * the timestamp as a message-ID if there was no message-ID already - * in the message. We don't do this anymore because it screws up - * the loopzapper. - * - if (buffer->I == 0L) - buffer->I = buffer->T; - */ } @@ -726,7 +745,12 @@ void bounce(struct minfo *bminfo) void strmsgid(char *buf, struct minfo *msginfo) { int i; - sprintf(buf, "%ld@%s", msginfo->I, msginfo->N); + strcpy(buf, msginfo->I); + if (strchr(buf, '@') == NULL) { + strcat(buf, "@"); + strcat(buf, msginfo->N); + } + for (i=0; iI)==0L) { + if (strlen(msginfo->I)==0) { return 0; } @@ -825,7 +849,6 @@ void inprocess(void) { FILE *fp, *message, *testfp, *ls, *duplist; static struct minfo minfo; - struct recentmsg recentmsg; char tname[128], aaa[1024], iname[256], sfilename[256], pfilename[256]; int a, b; int FieldID; @@ -931,9 +954,6 @@ NXMSG: /* Seek to the beginning of the next message */ /* process the individual mesage */ msgfind(tname, &minfo); - strncpy(recentmsg.RMnodename, minfo.N, 9); - recentmsg.RMnodename[9] = 0; - recentmsg.RMnum = minfo.I; syslog(LOG_NOTICE, "#%ld fm <%s> in <%s> @ <%s>", minfo.I, minfo.A, minfo.O, minfo.N); if (strlen(minfo.R) > 0) { @@ -991,7 +1011,7 @@ NXMSG: /* Seek to the beginning of the next message */ /* Check the use table; reject message if it's been here before */ if (already_received(use_table, &minfo)) { syslog(LOG_NOTICE, "rejected duplicate message"); - fprintf(duplist, "#%ld fm <%s> in <%s> @ <%s>\n", + fprintf(duplist, "#<%s> fm <%s> in <%s> @ <%s>\n", minfo.I, minfo.A, minfo.O, minfo.N); } diff --git a/citadel/network/mail.sysinfo b/citadel/network/mail.sysinfo index 2e0172179..07aa686c7 100644 --- a/citadel/network/mail.sysinfo +++ b/citadel/network/mail.sysinfo @@ -24,14 +24,14 @@ use uncnsrd phonenum US6093461224 gdom NJ humannode JACS -lastcontact 952138912 Fri Mar 3 22:01:52 2000 +lastcontact 952634224 Thu Mar 9 15:37:04 2000 dogpound2 use uncnsrd phonenum netproc[4026]: Adding non-neighbor system to map gdom or system to map humannode Dog Pound BBS II -lastcontact 952349824 Mon Mar 6 08:37:04 2000 +lastcontact 952724225 Fri Mar 10 16:37:05 2000 sbn use uncnsrd @@ -66,7 +66,7 @@ use uncnsrd phonenum US (609) 953 8159 gdom NJ humannode The Amiga Zone -lastcontact 952138913 Fri Mar 3 22:01:53 2000 +lastcontact 952720625 Fri Mar 10 15:37:05 2000 cbbs use uncnsrd @@ -101,13 +101,13 @@ use uncnsrd phonenum netproc[4026]: Adding non-neighbor system to map gdom or system to map humannode PixelBBS -lastcontact 952573025 Wed Mar 8 22:37:05 2000 +lastcontact 952706223 Fri Mar 10 11:37:03 2000 tesseract bin Mail phonenum US 800 555 1212 humannode Tesseract Project -lastcontact 952573026 Wed Mar 8 22:37:06 2000 +lastcontact 952724226 Fri Mar 10 16:37:06 2000 tux bin Mail @@ -122,24 +122,24 @@ uncnsrd bin Mail phonenum US 914 244 3252 humannode Uncensored -lastcontact 952565824 Wed Mar 8 20:37:04 2000 +lastcontact 952720625 Fri Mar 10 15:37:05 2000 internet uum %s humannode Internet Gateway -lastcontact 952573026 Wed Mar 8 22:37:06 2000 +lastcontact 952724225 Fri Mar 10 16:37:05 2000 bccs use uncnsrd phonenum netproc[7145]: Adding non-neighbor system to map gdom or system to map humannode BCCS -lastcontact 952569423 Wed Mar 8 21:37:03 2000 +lastcontact 952648629 Thu Mar 9 19:37:09 2000 ctestsys use uncnsrd phonenum US 612 470 9635 gdom MN humannode C-86 Test System -lastcontact 952375033 Mon Mar 6 15:37:13 2000 +lastcontact 952673825 Fri Mar 10 02:37:05 2000 diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 99504c584..e75ec50e3 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -513,8 +513,7 @@ int smtp_message_delivery(struct CtdlMessage *msg) { msgid = CtdlSaveMsg(msg, "", SMTP_SPOOLOUT_ROOM, - MES_LOCAL, - 1); + MES_LOCAL); ++successful_saves; instr = mallok(1024); @@ -576,7 +575,7 @@ int smtp_message_delivery(struct CtdlMessage *msg) { imsg->cm_anon_type = MES_NORMAL; imsg->cm_format_type = FMT_RFC822; imsg->cm_fields['M'] = instr; - CtdlSaveMsg(imsg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL, 1); + CtdlSaveMsg(imsg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL); CtdlFreeMessage(imsg); } @@ -1161,14 +1160,14 @@ void smtp_do_bounce(char *instr) { else { bounce_msgid = CtdlSaveMsg(bmsg, bounceto, - "", mes_type, 1); + "", mes_type); } /* Otherwise, go to the Aide> room */ lprintf(9, "bounce to room?\n"); if (bounce_msgid < 0L) bounce_msgid = CtdlSaveMsg(bmsg, "", AIDEROOM, - MES_LOCAL, 1); + MES_LOCAL); } CtdlFreeMessage(bmsg); @@ -1377,7 +1376,7 @@ void smtp_do_procmsg(long msgnum) { "Content-type: %s\n\n%s\nattempted|%ld\n", SPOOLMIME, instr, time(NULL) ); phree(instr); - CtdlSaveMsg(msg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL, 1); + CtdlSaveMsg(msg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL); CtdlFreeMessage(msg); } @@ -1405,7 +1404,7 @@ void smtp_do_queue(void) { /* * Go ahead and run the queue */ - lprintf(5, "SMTP: processing outbound queue\n"); + lprintf(7, "SMTP: processing outbound queue\n"); if (getroom(&CC->quickroom, SMTP_SPOOLOUT_ROOM) != 0) { lprintf(3, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM); @@ -1413,7 +1412,7 @@ void smtp_do_queue(void) { } CtdlForEachMessage(MSGS_ALL, 0L, SPOOLMIME, NULL, smtp_do_procmsg); - lprintf(5, "SMTP: queue run completed\n"); + lprintf(7, "SMTP: queue run completed\n"); doing_queue = 0; } diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index 5ecffedf0..707cdb7b0 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -411,7 +411,7 @@ void vcard_purge(char *username, long usernum) { msg->cm_fields['S'] = strdoop("CANCEL"); - CtdlSaveMsg(msg, "", ADDRESS_BOOK_ROOM, MES_LOCAL, 1); + CtdlSaveMsg(msg, "", ADDRESS_BOOK_ROOM, MES_LOCAL); CtdlFreeMessage(msg); /* Start a netproc run in the background, so the "purge" message -- 2.30.2