]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_spam.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_spam.c
index 317dd7da8642289bac7cfddb703b8b9772f8a3b6..64ad1f5cba100bdd7d9703c176e19f2422d2c8d9 100644 (file)
 #include <sys/socket.h>
 #include "citadel.h"
 #include "server.h"
-#include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
 #include "control.h"
-#include "serv_extensions.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
 #include "clientsocket.h"
 
 
-
-/* 
- * This is a scanner I had started writing before deciding to just farm the
- * job out to SpamAssassin.  It *does* work but it's not in use.  We've
- * commented it out so it doesn't even compile.
- */
-#ifdef ___NOT_CURRENTLY_IN_USE___
-/* Scan a message for spam */
-int spam_filter(struct CtdlMessage *msg) {
-       int spam_strings_found = 0;
-       struct spamstrings_t *sptr;
-       char *ptr;
-
-       /* Bail out if there's no message text */
-       if (msg->cm_fields['M'] == NULL) return(0);
-
-
-       /* Scan! */
-       ptr = msg->cm_fields['M'];
-       while (ptr++[0] != 0) {
-               for (sptr = spamstrings; sptr != NULL; sptr = sptr->next) {
-                       if (!strncasecmp(ptr, sptr->string,
-                          strlen(sptr->string))) {
-                               ++spam_strings_found;
-                       }
-               }
-       }
-
-       if (spam_strings_found) {
-               if (msg->cm_fields['0'] != NULL) {
-                       free(msg->cm_fields['0']);
-               }
-               msg->cm_fields['0'] = strdup("Unsolicited spam rejected");
-               return(spam_strings_found);
-       }
-
-       return(0);
-}
-#endif
+#include "ctdl_module.h"
 
 
 
@@ -119,7 +79,7 @@ int spam_assassin(struct CtdlMessage *msg) {
 
        /* Try them one by one until we get a working one */
         for (sa=0; sa<num_sahosts; ++sa) {
-                extract(buf, sahosts, sa);
+                extract_token(buf, sahosts, sa, '|', sizeof buf);
                 lprintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
                 sock = sock_connect(buf, SPAMASSASSIN_PORT, "tcp");
                 if (sock >= 0) lprintf(CTDL_DEBUG, "Connected!\n");
@@ -141,7 +101,7 @@ int spam_assassin(struct CtdlMessage *msg) {
        CC->redirect_buffer = malloc(SIZ);
        CC->redirect_len = 0;
        CC->redirect_alloc = SIZ;
-       CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
+       CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1);
        msgtext = CC->redirect_buffer;
        msglen = CC->redirect_len;
        CC->redirect_buffer = NULL;
@@ -177,8 +137,7 @@ int spam_assassin(struct CtdlMessage *msg) {
                if (msg->cm_fields['0'] != NULL) {
                        free(msg->cm_fields['0']);
                }
-               msg->cm_fields['0'] = strdup(
-                       "5.7.1 Message rejected by SpamAssassin");
+               msg->cm_fields['0'] = strdup("5.7.1 message rejected by spam filter");
        }
 
 bail:  close(sock);
@@ -187,14 +146,10 @@ bail:     close(sock);
 
 
 
-char *serv_spam_init(void)
+CTDL_MODULE_INIT(spam)
 {
-
-/* (disabled built-in scanner, see above)
-       CtdlRegisterMessageHook(spam_filter, EVT_SMTPSCAN);
- */
-
        CtdlRegisterMessageHook(spam_assassin, EVT_SMTPSCAN);
 
+       /* return our Subversion id for the Log */
         return "$Id$";
 }