* techdoc/delivery-list.txt: added (syntax for delivery lists)
authorArt Cancro <ajc@citadel.org>
Thu, 13 Jan 2000 03:32:36 +0000 (03:32 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 13 Jan 2000 03:32:36 +0000 (03:32 +0000)
* domain.*: added (will contain MX lookup code)
* internet_addressing.c, logging.c: fixed some buffer overflow bugs

citadel/ChangeLog
citadel/Makefile.in
citadel/domain.c [new file with mode: 0644]
citadel/domain.h [new file with mode: 0644]
citadel/internet_addressing.c
citadel/logging.c
citadel/techdoc/delivery-list.txt [new file with mode: 0644]

index e9632283989abcd58acff9c7692d95f4fddb5c40..dbd4887a87c8db2cf8a3c5ab84e4b788d349ed0a 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index bc76559e9159f78c72bfd54853f9e9099ca91e0a..9f8d3537c5ae689d0f69d22c21e921dbb4ed9e25 100644 (file)
@@ -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 (file)
index 0000000..3efb74f
--- /dev/null
@@ -0,0 +1,42 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+#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 (file)
index 0000000..10d17be
--- /dev/null
@@ -0,0 +1 @@
+int getmx(char *mxbuf, char *dest);
index f6e39e374ecf2c9f82b0e636c3bc190d05b3e54e..24b088ec0b7fd8073dd11a7eb13cd1f3c5776c08 100644 (file)
@@ -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)
index 0f5eef2116fd2f6fe7e4c60521225d9e172eb9af..39a66c147f38ca688b0c83a6a45f6189bc7b5f71 100644 (file)
@@ -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 (file)
index 0000000..fa13b64
--- /dev/null
@@ -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.