* IGnet delivery is broken
authorArt Cancro <ajc@citadel.org>
Tue, 29 Feb 2000 05:00:14 +0000 (05:00 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 29 Feb 2000 05:00:14 +0000 (05:00 +0000)
citadel/Makefile.in
citadel/ignet.c [deleted file]
citadel/ignet.h [deleted file]
citadel/internet_addressing.c
citadel/internet_addressing.h
citadel/msgbase.c
citadel/serv_smtp.c

index 5dde47ce7e85f4c5dcac5fb2fc4c91b01c8b2f32..7daefb1d81139b51f1bb752813172ddb63252001 100644 (file)
@@ -76,7 +76,7 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c commands.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 \
-       domain.c clientsocket.c serv_inetcfg.c serv_rwho.c ignet.c
+       domain.c clientsocket.c serv_inetcfg.c serv_rwho.c
 
 DEP_FILES=$(SOURCES:.c=.d)
 
@@ -113,7 +113,7 @@ SERV_OBJS = citserver.ro user_ops.ro support.ro room_ops.ro file_ops.ro \
        msgbase.ro config.ro sysdep.ro locate_host.ro housekeeping.ro \
        database.ro control.ro logging.ro policy.ro dynloader.ro tools.ro \
        mime_parser.ro html.ro internet_addressing.ro \
-       parsedate.ro genstamp.ro clientsocket.ro ignet.ro \
+       parsedate.ro genstamp.ro clientsocket.ro \
        $(AUTH) $(LIBOBJS:.o=.ro)
 
 citserver: $(SERV_OBJS)
diff --git a/citadel/ignet.c b/citadel/ignet.c
deleted file mode 100644 (file)
index bc4a09f..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * $Id$
- *
- */
-
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <signal.h>
-#include <pwd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <string.h>
-#include <limits.h>
-#include "citadel.h"
-#include "server.h"
-#include <time.h>
-#include "sysdep_decls.h"
-#include "citserver.h"
-#include "support.h"
-#include "config.h"
-#include "tools.h"
-#include "msgbase.h"
-#include "internet_addressing.h"
-#include "ignet.h"
-#include "user_ops.h"
-#include "room_ops.h"
-#include "parsedate.h"
-
-
-
-/*
- * Returns nonzero if the specified nodename is on the Citadel network
- */
-
-int is_ignet(char *node) {
-       char filename[256];
-
-       /* First, check to see if the specified node is a neighbor */
-       sprintf(filename, "./network/systems/%s", node);
-       if (!access(filename, F_OK)) return(1);
-
-       /* If not, see if it's a non-neighbor node */
-       /* FIXME add this */
-
-       /* Nope */
-       return 0;
-
-}
-
-
-int ignet_spool_to(char *node, long msgnum) {
-
-       return 1;               /* FIXME */
-
-}
-
-
-
-
-
diff --git a/citadel/ignet.h b/citadel/ignet.h
deleted file mode 100644 (file)
index b371d86..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * $Id$
- */
-
-
-
-int is_ignet(char *node);
-int ignet_spool_to(char *node, long msgnum);
-
-
-
index e82d63a7c4aebc230105d0eefa98f4ec29e2f751..f6859292806884784f45f79976c777e6c0fa072d 100644 (file)
@@ -315,6 +315,7 @@ int convert_internet_address(char *destuser, char *desthost, char *source)
        char buf[256];
        int passes = 0;
        char sourcealias[1024];
+       int msgtype = 0;
 
        safestrncpy(sourcealias, source, sizeof(sourcealias) );
 
@@ -347,7 +348,8 @@ REALIAS:
                 * a few times, in case we accidentally hit an alias loop
                 */
                strcpy(sourcealias, user);
-               alias(user);
+               msgtype = alias(user);
+               lprintf(9, "msgtype for <%s> is %d\n", msgtype, user);
                if ( (strcasecmp(user, sourcealias)) && (++passes < 3) )
                        goto REALIAS;
 
@@ -376,7 +378,8 @@ REALIAS:
 
        strcpy(destuser, user);
        strcpy(desthost, node);
-       return(rfc822_address_invalid); /* unknown error */
+       if (msgtype == MES_BINARY) return(rfc822_address_on_citadel_network);
+       return(rfc822_address_nonlocal);
 }
 
 
index 7f08de119753d190546e99c4d0cf0e794fe639d1..98e7979b2416f1dc0c5896ad8909291595a39ef8 100644 (file)
@@ -7,7 +7,7 @@ enum {
        rfc822_address_locally_validated,
        rfc822_no_such_user,
        rfc822_address_on_citadel_network,
-       rfc822_address_invalid,
+       rfc822_address_nonlocal,
        rfc822_room_delivery
 };
 
index 320c2cb4fb76498b58ceb086e7ecc7c8ae444a67..4c91cd80777c0c39adb78dbc72e9177f0705805b 100644 (file)
@@ -187,6 +187,7 @@ GETSN:              do {
                        while (bbb[strlen(bbb) - 1] == '_')
                                bbb[strlen(bbb) - 1] = 0;
                        sprintf(name, &aaa[4], bbb);
+                       lprintf(9, "returning MES_INTERNET\n");
                        return (MES_INTERNET);
                }
                if (!strncmp(aaa, "bin", 3)) {
@@ -203,10 +204,12 @@ GETSN:            do {
                        while (bbb[0] == ' ')
                                strcpy(bbb, &bbb[1]);
                        sprintf(name, "%s @%s", aaa, bbb);
+                       lprintf(9, "returning MES_BINARY\n");
                        return (MES_BINARY);
                }
                return (MES_ERROR);
        }
+       lprintf(9, "returning MES_LOCAL\n");
        return (MES_LOCAL);
 }
 
index 8dd3b6554ed52ff263d4466fbfb336f350a501e2..55e8e026434ea06cfaab2adb79687564ec694c59 100644 (file)
@@ -30,7 +30,6 @@
 #include "msgbase.h"
 #include "tools.h"
 #include "internet_addressing.h"
-#include "ignet.h"
 #include "genstamp.h"
 #include "domain.h"
 #include "clientsocket.h"
@@ -373,6 +372,7 @@ void smtp_rcpt(char *argbuf) {
 
        cvt = convert_internet_address(user, node, recp);
        sprintf(recp, "%s@%s", user, node);
+       lprintf(9, "cvt=%d, citaddr=<%s@%s>\n", cvt, user, node);
 
        switch(cvt) {
                case rfc822_address_locally_validated:
@@ -399,7 +399,19 @@ void smtp_rcpt(char *argbuf) {
                        cprintf("550 %s: no such user\r\n", recp);
                        return;
 
-               case rfc822_address_invalid:
+               case rfc822_address_on_citadel_network:
+                       cprintf("250 %s is on the local network\r\n", recp);
+                       ++SMTP->number_of_recipients;
+                       CtdlReallocUserData(SYM_SMTP_RECP,
+                               strlen(SMTP_RECP) + 1024 );
+                       strcat(SMTP_RECP, "ignet|");
+                       strcat(SMTP_RECP, user);
+                       strcat(SMTP_RECP, "|");
+                       strcat(SMTP_RECP, node);
+                       strcat(SMTP_RECP, "|0|\n");
+                       return;
+
+               case rfc822_address_nonlocal:
                        if (is_spam) {
                                cprintf("551 Away with thee, spammer!\r\n");
                        }
@@ -421,6 +433,37 @@ void smtp_rcpt(char *argbuf) {
 
 
 
+/*
+ * Send a message out through the local network
+ * (This is kind of ugly.  IGnet should be done using clean server-to-server
+ * code instead of the old style spool.)
+ */
+void smtp_deliver_ignet(struct CtdlMessage *msg, char *user, char *room) {
+       struct ser_ret smr;
+       char *hold_R, *hold_D;
+       FILE *fp;
+
+       hold_R = msg->cm_fields['R'];
+       hold_D = msg->cm_fields['D'];
+       msg->cm_fields['R'] = user;
+       msg->cm_fields['D'] = room;
+
+       serialize_message(&smr, msg);
+
+       msg->cm_fields['R'] = hold_R;
+       msg->cm_fields['D'] = hold_D;
+
+       if (smr.len != 0) {
+               fp = fopen(tmpnam("./network/spoolin/"), "wb");
+               if (fp != NULL) {
+                       fwrite(smr.ser, smr.len, 1, fp);
+                       fclose(fp);
+               }
+               phree(smr.ser);
+       }
+
+}
+
 
 
 /*
@@ -489,6 +532,11 @@ int smtp_message_delivery(struct CtdlMessage *msg) {
                        ++successful_saves;
                }
 
+               /* Delivery over the local Citadel network (IGnet) */
+               if (!strcasecmp(dtype, "ignet")) {
+                       smtp_deliver_ignet(msg, user, room);
+               }
+
                /* Remote delivery */
                if (!strcasecmp(dtype, "remote")) {
                        extract(user, buf, 1);
@@ -706,18 +754,6 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
        /* Parse out the host portion of the recipient address */
        process_rfc822_addr(addr, user, node, name);
 
-       if (is_ignet(node)) {
-               if (ignet_spool_to(node, msgnum) == 0) {
-                       strcpy(dsn, "Delivery via Citadel network successful");
-                       *status = 2;
-               }
-               else {
-                       strcpy(dsn, "Delivery via Citadel network failed");
-                       *status = 5;
-               }
-               return;
-       }
-
        lprintf(9, "Attempting SMTP delivery to <%s> @ <%s> (%s)\n",
                user, node, name);