X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fnetwork%2Fserv_netmail.c;h=820c2fe9f6f8448b9b469ff55b2a914a57355b18;hb=0387f48886a9395d89eaca01cd40ab751610426f;hp=ddd3ba19d9182b009dd55ced4198015b46e97f9d;hpb=5c39ca8a3c875df98163fed8923c258f21bb3f66;p=citadel.git diff --git a/citadel/modules/network/serv_netmail.c b/citadel/modules/network/serv_netmail.c index ddd3ba19d..820c2fe9f 100644 --- a/citadel/modules/network/serv_netmail.c +++ b/citadel/modules/network/serv_netmail.c @@ -1,8 +1,7 @@ /* - * This module handles shared rooms, inter-Citadel mail, and outbound - * mailing list processing. + * This module handles network mail and mailing list processing. * - * Copyright (c) 2000-2016 by the citadel.org team + * Copyright (c) 2000-2020 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 3. @@ -222,7 +221,7 @@ void network_deliver_digest(SpoolControl *sc) if (valid != NULL) { valid->bounce_to = strdup(bounce_to); valid->envelope_from = strdup(bounce_to); - CtdlSubmitMsg(msg, valid, NULL, 0); + CtdlSubmitMsg(msg, valid, NULL); } CM_Free(msg); free_recipients(valid); @@ -270,11 +269,6 @@ void network_process_digest(SpoolControl *sc, struct CtdlMessage *omsg, long *de "<%s> ", msg->cm_fields[erFc822Addr]); } - else if (!CM_IsEmpty(msg, eNodeName)) { - fprintf(sc->digestfp, - "@%s ", - msg->cm_fields[eNodeName]); - } fprintf(sc->digestfp, "\n"); if (!CM_IsEmpty(msg, eMsgSubject)) { fprintf(sc->digestfp, @@ -371,7 +365,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc, const char valid->bounce_to = strdup(bounce_to); valid->envelope_from = strdup(bounce_to); valid->sending_room = strdup(RoomName); - CtdlSubmitMsg(msg, valid, NULL, 0); + CtdlSubmitMsg(msg, valid, NULL); free_recipients(valid); } /* Do not call CM_Free(msg) here; the caller will free it. */ @@ -382,7 +376,6 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon { struct CtdlMessage *msg = NULL; int ok_to_participate = 0; - StrBuf *Buf = NULL; recptypes *valid; /* @@ -399,22 +392,11 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon * is rude... */ ok_to_participate = 0; - if (!CM_IsEmpty(msg, eNodeName)) { - if (!strcasecmp(msg->cm_fields[eNodeName], CtdlGetConfigStr("c_nodename"))) - { - ok_to_participate = 1; - } - - Buf = NewStrBufPlain(CM_KEY(msg, eNodeName)); - if (CtdlIsValidNode(NULL, - NULL, - Buf, - sc->working_ignetcfg, - sc->the_netmap) == 0) - { - ok_to_participate = 1; - } - } + + // FIXME -- After we removed CitaNet/IGnet support , we now need a new heuristic to determine + // whether a message originated locally. This means the "participate" mode no longer works. + // We'll definitely need to refactor this when we do other federated stuff later. + if (ok_to_participate) { /* Replace the Internet email address of the @@ -427,141 +409,9 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon valid = validate_recipients(ChrPtr(sc->Users[participate]) , NULL, 0); CM_SetField(msg, eRecipient, SKEY(sc->Users[roommailalias])); - CtdlSubmitMsg(msg, valid, "", 0); + CtdlSubmitMsg(msg, valid, ""); free_recipients(valid); } - FreeStrBuf(&Buf); - CM_Free(msg); -} - -void network_process_ignetpush(SpoolControl *sc, struct CtdlMessage *omsg, long *delete_after_send) -{ - StrBuf *Recipient; - StrBuf *RemoteRoom; - const char *Pos = NULL; - struct CtdlMessage *msg = NULL; - struct CitContext *CCC = CC; - struct ser_ret sermsg; - char buf[SIZ]; - char filename[PATH_MAX]; - FILE *fp; - StrBuf *Buf = NULL; - int i; - int bang = 0; - int send = 1; - - if (sc->Users[ignet_push_share] == NULL) - return; - - /* - * Process IGnet push shares - */ - msg = CM_Duplicate(omsg); - - /* Prepend our node name to the Path field whenever - * sending a message to another IGnet node - */ - Netmap_AddMe(msg, HKEY("username")); - - /* - * Determine if this message is set to be deleted - * after sending out on the network - */ - if (!CM_IsEmpty(msg, eSpecialField)) { - if (!strcasecmp(msg->cm_fields[eSpecialField], "CANCEL")) { - *delete_after_send = 1; - } - } - - /* Now send it to every node */ - Recipient = NewStrBufPlain(NULL, StrLength(sc->Users[ignet_push_share])); - RemoteRoom = NewStrBufPlain(NULL, StrLength(sc->Users[ignet_push_share])); - while ((Pos != StrBufNOTNULL) && - StrBufExtract_NextToken(Recipient, sc->Users[ignet_push_share], &Pos, ',')) - { - StrBufExtract_NextToken(RemoteRoom, sc->Users[ignet_push_share], &Pos, ','); - send = 1; - NewStrBufDupAppendFlush(&Buf, Recipient, NULL, 1); - - /* Check for valid node name */ - if (CtdlIsValidNode(NULL, - NULL, - Buf, - sc->working_ignetcfg, - sc->the_netmap) != 0) - { - syslog(LOG_ERR, "netmail: invalid node <%s>", ChrPtr(Recipient)); - send = 0; - } - - /* Check for split horizon */ - syslog(LOG_DEBUG, "netmail: path is %s", msg->cm_fields[eMessagePath]); - bang = num_tokens(msg->cm_fields[eMessagePath], '!'); - if (bang > 1) { - for (i=0; i<(bang-1); ++i) { - extract_token(buf, - msg->cm_fields[eMessagePath], - i, '!', - sizeof buf); - - syslog(LOG_DEBUG, "netmail: compare <%s> to <%s>", buf, ChrPtr(Recipient)) ; - if (!strcasecmp(buf, ChrPtr(Recipient))) { - send = 0; - break; - } - } - - syslog(LOG_INFO, "netmail: %ssending to %s", (send)?"":"not ", ChrPtr(Recipient)); - } - - /* Send the message */ - if (send == 1) - { - /* - * Force the message to appear in the correct - * room on the far end by setting the C field - * correctly - */ - if (StrLength(RemoteRoom) > 0) { - CM_SetField(msg, eRemoteRoom, SKEY(RemoteRoom)); - } - else { - CM_SetField(msg, eRemoteRoom, CCC->room.QRname, strlen(CCC->room.QRname)); - } - - /* serialize it for transmission */ - CtdlSerializeMessage(&sermsg, msg); - if (sermsg.len > 0) { - - /* write it to a spool file */ - snprintf(filename, - sizeof(filename), - "%s/%s@%lx%x", - ctdl_netout_dir, - ChrPtr(Recipient), - time(NULL), - rand() - ); - - syslog(LOG_DEBUG, "netmail: appending to %s", filename); - - fp = fopen(filename, "ab"); - if (fp != NULL) { - fwrite(sermsg.ser, sermsg.len, 1, fp); - fclose(fp); - } - else { - syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno)); - } - - /* free the serialized version */ - free(sermsg.ser); - } - } - } - FreeStrBuf(&Buf); - FreeStrBuf(&Recipient); - FreeStrBuf(&RemoteRoom); CM_Free(msg); } @@ -576,7 +426,7 @@ void network_spool_msg(long msgnum, void *userdata) SpoolControl *sc; sc = (SpoolControl *)userdata; - msg = CtdlFetchMessage(msgnum, 1, 1); + msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) { @@ -586,7 +436,6 @@ void network_spool_msg(long msgnum, void *userdata) network_process_list(sc, msg, &delete_after_send); network_process_digest(sc, msg, &delete_after_send); network_process_participate(sc, msg, &delete_after_send); - network_process_ignetpush(sc, msg, &delete_after_send); CM_Free(msg);