From b7a300a0589711d6a9e4995064447bb73248ffcd Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 13 Jan 2000 03:32:36 +0000 Subject: [PATCH] * techdoc/delivery-list.txt: added (syntax for delivery lists) * domain.*: added (will contain MX lookup code) * internet_addressing.c, logging.c: fixed some buffer overflow bugs --- citadel/ChangeLog | 6 ++- citadel/Makefile.in | 18 +++++---- citadel/domain.c | 42 +++++++++++++++++++++ citadel/domain.h | 1 + citadel/internet_addressing.c | 6 +-- citadel/logging.c | 6 ++- citadel/techdoc/delivery-list.txt | 63 +++++++++++++++++++++++++++++++ 7 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 citadel/domain.c create mode 100644 citadel/domain.h create mode 100644 citadel/techdoc/delivery-list.txt diff --git a/citadel/ChangeLog b/citadel/ChangeLog index e96322839..dbd4887a8 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ +Revision 1.440 2000/01/13 03:32:36 ajc +* techdoc/delivery-list.txt: added (syntax for delivery lists) +* domain.*: added (will contain MX lookup code) +* internet_addressing.c, logging.c: fixed some buffer overflow bugs + Revision 1.439 2000/01/12 03:56:27 ajc * sysdep.c: start the housekeeping thread *after* dropping root perms. @@ -1535,4 +1540,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/Makefile.in b/citadel/Makefile.in index bc76559e9..9f8d3537c 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -72,7 +72,8 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c commands.c \ support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \ whobbs.c sendcommand.c mime_parser.c base64.c qpdecode.c getutline.c \ auth.c chkpwd.c client_icq.c html.c vcard.c serv_upgrade.c \ - serv_smtp.c serv_pop3.c internet_addressing.c parsedate.c genstamp.c + serv_smtp.c serv_pop3.c internet_addressing.c parsedate.c genstamp.c \ + domain.c DEP_FILES=$(SOURCES:.c=.d) @@ -133,12 +134,6 @@ modules/serv_test.so: serv_test.mo modules/serv_test.mo: serv_test.mo ln -f serv_test.mo modules -modules/serv_smtp.so: serv_smtp.mo - $(LINK_SHARED) -o modules/serv_smtp.so serv_smtp.mo - -modules/serv_smtp.mo: serv_smtp.mo - ln -f serv_smtp.mo modules - modules/serv_pop3.so: serv_pop3.mo $(LINK_SHARED) -o modules/serv_pop3.so serv_pop3.mo @@ -172,6 +167,15 @@ modules/serv_vcard.mo: serv_vcard.mo modules/vcard.mo: vcard.mo ln -f vcard.mo modules +modules/serv_smtp.so: serv_smtp.mo domain.mo + $(LINK_SHARED) -o modules/serv_smtp.so serv_smtp.mo domain.mo + +modules/serv_smtp.mo: serv_smtp.mo + ln -f serv_smtp.mo modules + +modules/domain.mo: domain.mo + ln -f domain.mo modules + aidepost: aidepost.o config.o $(LIBOBJS) $(CC) aidepost.o config.o $(LIBOBJS) $(LDFLAGS) -o aidepost diff --git a/citadel/domain.c b/citadel/domain.c new file mode 100644 index 000000000..3efb74fef --- /dev/null +++ b/citadel/domain.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include +#include "domain.h" + +#define SMART_HOST "gatekeeper.wdcs.com" + +/* + * getmx() + * + * Return one or more MX's for a mail destination. + * + * Upon success, it fills 'mxbuf' with one or more MX hosts, separated by + * vertical bar characters, and returns the number of hosts as its return + * value. If no MX's are found, it returns 0. + * + */ +int getmx(char *mxbuf, char *dest) { + char answer[1024]; + int ret; + int i; + + + /* If we're configured to send all mail to a smart-host, then our + * job here is really easy. + */ + if (1) { /* FIX */ + strcpy(mxbuf, SMART_HOST); + return(1); + } + + /* No smart-host? Look up the best MX for a site. + */ + ret = res_query( + dest, + C_IN, T_MX, answer, sizeof(answer) ); + + lprintf(9, "res_query() returned %d\n", ret); + return(0); /* FIX not yet working!! */ +} diff --git a/citadel/domain.h b/citadel/domain.h new file mode 100644 index 000000000..10d17be0f --- /dev/null +++ b/citadel/domain.h @@ -0,0 +1 @@ +int getmx(char *mxbuf, char *dest); diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index f6e39e374..24b088ec0 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -333,9 +333,9 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { } else if (!strcasecmp(key, "From")) { - user = mallok(strlen(value)); - node = mallok(strlen(value)); - name = mallok(strlen(value)); + user = mallok(1024); + node = mallok(1024); + name = mallok(1024); process_rfc822_addr(value, user, node, name); lprintf(9, "Converted to <%s@%s> (%s)\n", user, node, name); if (msg->cm_fields['A'] == NULL) diff --git a/citadel/logging.c b/citadel/logging.c index 0f5eef211..39a66c147 100644 --- a/citadel/logging.c +++ b/citadel/logging.c @@ -25,6 +25,8 @@ void rec_log(unsigned int lrtype, char *name) { time(&now); fp = fopen("citadel.log", "a"); - fprintf(fp, "%ld|%u|%s\n", (long)now, lrtype, name); - fclose(fp); + if (fp != NULL) { + fprintf(fp, "%ld|%u|%s\n", (long)now, lrtype, name); + fclose(fp); } +} diff --git a/citadel/techdoc/delivery-list.txt b/citadel/techdoc/delivery-list.txt new file mode 100644 index 000000000..fa13b64ed --- /dev/null +++ b/citadel/techdoc/delivery-list.txt @@ -0,0 +1,63 @@ +Description of the custom MIME type "application/x-citadel-delivery-list" + + This MIME type may be found in the outbound queue room on Citadel systems, +which is typically called "__CitadelSMTPspoolout__". The room is flagged as +private, but we will eventually hide it even to Aides. + + Messages in this format contain delivery instructions. Therefore, for each +message in the queue to be delivered to one or more recipients, there will be +*two* messages in the room: one containing the actual message, and the other +containing delivery instructions. It is expected that the instructions +message may be replaced at any time (using an Extended ID field) if delivery +to only some of the recipients has been accomplished. + + Citadel keeps reference counts of each message on disk. Therefore if a +message contains a mixture of local and remote recipients, there may be two +or more references to the message itself, one of them being the one in the +queue. + + A delivery list contains one or more lines of text, each line containing +a single instruction (usually a recipient). Fields are separated by the +vertical bar character ("|") and there will always be at least one field on +each line. + + + + INSTRUCTION: msgid + SYNTAX: msgid|0000000 + DESCRIPTION: + Defines the actual message for which we are providing delivery + instructions. This instruction must precede all the others. When + all deliveries have either succeeded or failed, both the instructions and + the copy of the message itself in the queue room should be deleted. The + second parameter specifies the message ID in the local database. + + + INSTRUCTION: local + SYNTAX: local|Friko Mumjiboolean|0 + DESCRIPTION: + Indicates the name of a recipient on the local system to which the + message must be delivered. Almost never seen because most code delivers + directly. + + + INSTRUCTION: room + SYNTAX: room|Lobby|0 + DESCRIPTION: + Indicates the name of a room on the local system to which the message + must be copied. Same implications as 'local'. + + + INSTRUCTION: remote + SYNTAX: remote|billg@microsoft.com|0 + DESCRIPTION: + Names a recipient on a remote system to which the message should be + delivered. (FIX ... this is where we have to keep track of multiple + delivery attempts and transient errors) + + + INSTRUCTION: ignet + SYNTAX: ignet|uncnsrd|Lobby|0 + DESCRIPTION: + Names a room on another Citadel node to which this message needs to be + spooled over the network. -- 2.30.2