]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/sieve/serv_sieve.c
* give the flag to the CtdlDoIHavePermissionToPostInThisRoom in through the parameter...
[citadel.git] / citadel / modules / sieve / serv_sieve.c
index 226b4825562344c30a3fcd988e10f01d8c7c669a..39827f36588c3ae3f3cdbb5b507a69fd33170b28 100644 (file)
@@ -31,6 +31,7 @@
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
@@ -41,7 +42,6 @@
 #include "database.h"
 #include "msgbase.h"
 #include "internet_addressing.h"
-#include "tools.h"
 
 
 #include "ctdl_module.h"
@@ -104,7 +104,7 @@ int ctdl_redirect(sieve2_context_t *s, void *my)
 
        lprintf(CTDL_DEBUG, "Action is REDIRECT, recipient <%s>\n", recp);
 
-       valid = validate_recipients(recp);
+       valid = validate_recipients(recp, 0);
        if (valid == NULL) {
                lprintf(CTDL_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
                return SIEVE2_ERROR_BADARGS;
@@ -386,7 +386,8 @@ int ctdl_getenvelope(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       lprintf(CTDL_DEBUG, "Action is GETENVELOPE\n");
+       lprintf(CTDL_DEBUG, "Action is GETENVELOPE\nEnvFrom: %s\n  EnvTo: %s\n",
+               cs->envelope_from, cs->envelope_to);
 
        if (cs->envelope_from != NULL) {
                if ((cs->envelope_from[0] != '@')&&(cs->envelope_from[strlen(cs->envelope_from)-1] != '@')) {
@@ -513,6 +514,12 @@ void sieve_do_msg(long msgnum, void *userdata) {
        size_t headers_len = 0;
        int len = 0;
 
+       if (userdata == NULL)
+       {
+               lprintf(CTDL_EMERG, "Cant process Message <%ld>without Userdata!\n", msgnum);
+               return;
+       }
+
        lprintf(CTDL_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum);
 
        msg = CtdlFetchMessage(msgnum, 0);
@@ -576,9 +583,11 @@ void sieve_do_msg(long msgnum, void *userdata) {
        /* Keep track of the envelope-from address (use body-from if not found) */
        if (msg->cm_fields['P'] != NULL) {
                safestrncpy(my.envelope_from, msg->cm_fields['P'], sizeof my.envelope_from);
+               stripallbut(my.envelope_from, '<', '>');
        }
        else if (msg->cm_fields['F'] != NULL) {
                safestrncpy(my.envelope_from, msg->cm_fields['F'], sizeof my.envelope_from);
+               stripallbut(my.envelope_from, '<', '>');
        }
        else {
                strcpy(my.envelope_from, "");
@@ -596,6 +605,7 @@ void sieve_do_msg(long msgnum, void *userdata) {
        /* Keep track of the envelope-to address (use body-to if not found) */
        if (msg->cm_fields['V'] != NULL) {
                safestrncpy(my.envelope_to, msg->cm_fields['V'], sizeof my.envelope_to);
+               stripallbut(my.envelope_to, '<', '>');
        }
        else if (msg->cm_fields['R'] != NULL) {
                safestrncpy(my.envelope_to, msg->cm_fields['R'], sizeof my.envelope_to);
@@ -603,6 +613,7 @@ void sieve_do_msg(long msgnum, void *userdata) {
                        strcat(my.envelope_to, "@");
                        strcat(my.envelope_to, msg->cm_fields['D']);
                }
+               stripallbut(my.envelope_to, '<', '>');
        }
        else {
                strcpy(my.envelope_to, "");
@@ -1281,22 +1292,24 @@ int serv_sieve_room(struct ctdlroom *room)
 
 CTDL_MODULE_INIT(sieve)
 {
-
+       if (!threading)
+       {
 #ifdef HAVE_LIBSIEVE
 
-       ctdl_sieve_init();
-       CtdlRegisterProtoHook(cmd_msiv, "MSIV", "Manage Sieve scripts");
+               ctdl_sieve_init();
+               CtdlRegisterProtoHook(cmd_msiv, "MSIV", "Manage Sieve scripts");
 
-        CtdlRegisterRoomHook(serv_sieve_room);
+               CtdlRegisterRoomHook(serv_sieve_room);
 
-        CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE);
+               CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE);
 
 #else  /* HAVE_LIBSIEVE */
 
-       lprintf(CTDL_INFO, "This server is missing libsieve.  Mailbox filtering will be disabled.\n");
+               lprintf(CTDL_INFO, "This server is missing libsieve.  Mailbox filtering will be disabled.\n");
 
 #endif /* HAVE_LIBSIEVE */
-
+       }
+       
         /* return our Subversion id for the Log */
        return "$Id$";
 }