Hello to everyone.
I believe I found a bug in the implementation of the sieve engine. I
include a program that demonstrates the faulty behaviour. My program
opens a mailbox and for each message it creates a new sieve machine,
compiles the same sieve file, calls sieve_message() and destroys the
machine.
The program is called as
./sieve_eng_test mbox:test.mbox filters.sieve
From: Smara Frementiti <[EMAIL PROTECTED]>
Subject: SE THELO TORA
Sieve flag: 0
filters.sieve:21: recursive inclusion
Error compile sieve script: Operation not permitted
The sieve engine produces the error "recursive inclusion". I believe I
have traced the error and has to do with the variables
char *sieve_filename;
int sieve_line_num;
ino_t sieve_source_inode;
in sieve.l that are not initialized. However, I hate to admit, my
lex/yacc skills are quite rusty (I definetely should go through the
dragon book again).
I include my program, the makefile, the sieve file and the test
mailbox. All tests are against snapshot 20050929 (with a patch of mine
that has to do with the reject action, already sent to the list).
Let me know if you need anything else to trace the problem.
Kostas
--
Kostas Zorbadelos
Systems Designer/Developer, Otenet SA
[EMAIL PROTECTED] contact: kzorba (at) otenet.gr
Out there in the darkness, out there in the night
out there in the starlight, one soul burns brighter
than a thousand suns.
/*------------------------------------------------------------------
* sieve_eng_test.c
* This program tests the sieve engine.
*
* The program expects as input a mailbox location and a file containing
* a sieve script. For each message in the mailbox, it creates a new
* instance of a sieve machine, compiles the script and passes the message
* in the engine.
------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "mailutils/mailutils.h"
#define MU_DEBUG_LEVEL (MU_DEBUG_ERROR|MU_DEBUG_TRACE|MU_DEBUG_PROT|MU_SIEVE_DEBUG_TRACE)
#define SIEVE_DEBUG_LEVEL 0
int main(int argc, char* argv[]) {
char *from;
char *subject;
mu_mailbox_t mbox;
size_t msgno, total = 0;
int status;
mu_sieve_machine_t mach;
mu_debug_t debug = NULL;
/* Register the formats. */
/* This supports mbox, maildir and mh */
mu_register_local_mbox_formats();
/* mu_register_all_mbox_formats (); */
/* Register the mailer formats */
mu_register_all_mailer_formats();
status = mu_mailbox_create(&mbox, argv[1]);
if (status != 0) {
mu_error ("mailbox_create: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
status = mu_mailbox_open(mbox, MU_STREAM_READ);
if (status != 0) {
mu_error ("mailbox_open: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
mu_mailbox_messages_count (mbox, &total);
for (msgno = 1; msgno <= total; msgno++) {
mu_message_t msg;
mu_header_t hdr;
mu_attribute_t attr;
if ((status = mu_mailbox_get_message (mbox, msgno, &msg)) != 0
|| (status = mu_message_get_header (msg, &hdr)) != 0) {
mu_error ("Error message: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
mu_message_get_attribute (msg, &attr);
mu_attribute_unset_deleted (attr);
if (mu_header_aget_value (hdr, MU_HEADER_FROM, &from))
from = strdup ("(NO FROM)");
if (mu_header_aget_value (hdr, MU_HEADER_SUBJECT, &subject))
subject = strdup ("(NO SUBJECT)");
/* Create the instance of the sieve machine */
status = mu_sieve_machine_init(&mach,NULL);
if (status !=0) {
mu_error ("Cannot initialize sieve machine: %s", mu_strerror (status));
exit (EXIT_FAILURE);;
}
if (getenv ("MU_DEBUG"))
{
if ((status = mu_debug_create (&debug, mach)))
{
mu_error ("mu_debug_create: %s", mu_strerror (status));
abort ();
}
if ((status = mu_debug_set_level (debug, MU_DEBUG_LEVEL)))
{
mu_error ("mu_debug_set_level: %s", mu_strerror (status));
abort ();
}
mu_sieve_set_debug_level (mach, debug, SIEVE_DEBUG_LEVEL);
}
status = mu_sieve_compile(mach,argv[2]);
if (status !=0) {
mu_error ("Error compile sieve script: %s", mu_strerror (status));
exit (EXIT_FAILURE);;
}
status = mu_sieve_message(mach,msg);
if (status != 0)
mu_error ("Error sieve_message: %s", mu_strerror (status));
else
status = mu_attribute_is_deleted (attr) == 0;
mu_sieve_machine_destroy(&mach);
printf ("\nFrom: %s\n Subject: %s\n Sieve flag: %d\n", from, subject,status);
free (from);
free (subject);
}
status = mu_mailbox_close (mbox);
if (status != 0) {
mu_error ("mailbox_close: %s", mu_strerror (status));
exit (EXIT_FAILURE);
}
mu_mailbox_destroy (&mbox);
return 0;
}
>From [EMAIL PROTECTED] Fri Jun 3 18:36:03 2005
Return-Path: <[EMAIL PROTECTED]>
X-Original-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: from localhost (enigma.otenet.gr [127.0.0.1])
by enigma.otenet.gr (Postfix) with ESMTP id A2939AA60C
for <[EMAIL PROTECTED]>; Fri, 3 Jun 2005 18:36:03 +0300 (EEST)
Received: from noc.otenet.gr [195.170.0.29]
by localhost with POP3 (fetchmail-6.2.5)
for [EMAIL PROTECTED] (single-drop); Fri, 03 Jun 2005 18:36:03 +0300
(EEST)
Received: from pinky.otenet.gr (pinky.otenet.gr [195.170.0.24])
by noc.otenet.gr (8.13.4/8.13.4) with ESMTP id j53FXp3W015958
for <[EMAIL PROTECTED]>; Fri, 3 Jun 2005 18:33:51 +0300 (EEST)
Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206])
by pinky.otenet.gr (8.13.4/8.13.4/Debian-1) with ESMTP id j53FW1td018887
for <[EMAIL PROTECTED]>; Fri, 3 Jun 2005 18:32:01 +0300
Received: by wproxy.gmail.com with SMTP id 57so975720wri
for <[EMAIL PROTECTED]>; Fri, 03 Jun 2005 08:33:48 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=beta; d=gmail.com;
h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
b=VxABdWZPJFzSzBgjKdCVDAwp5As3r+FxvlJDeKJ3W/rY/LE+H00vTxgZgbuD6U87pxGkvjLV3rXX4TzuG1WjGupwvDr9q5/fRwAjQwDqmTGIE99gVdVDYj+pMOSSOxfCTL/3TcZWzot8ntVR4YSdX3Qa9PEcGyJTcidFbpMR4SU=
Received: by 10.54.78.16 with SMTP id a16mr1195422wrb;
Fri, 03 Jun 2005 08:33:48 -0700 (PDT)
Received: by 10.54.67.6 with HTTP; Fri, 3 Jun 2005 08:33:48 -0700 (PDT)
Message-ID: <[EMAIL PROTECTED]>
Date: Fri, 3 Jun 2005 18:33:48 +0300
From: Smara Frementiti <[EMAIL PROTECTED]>
Reply-To: Smara Frementiti <[EMAIL PROTECTED]>
To: Kostas Zorbadelos <[EMAIL PROTECTED]>
Subject: SE THELO TORA
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Disposition: inline
X-Spam-Status: No, score=0.4 required=4.5 tests=RCVD_BY_IP,SUBJ_ALL_CAPS
autolearn=no version=3.0.3
X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on bilbo.otenet.gr
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by noc.otenet.gr id
j53FXp3W015958
X-UIDL: iW#"!i`N"!OaJ!!9c0"!
Status: RO
X-Status: A
Content-Length: 83
Lines: 3
ELA NA PIOYME KAFE MORO,EXEI TOSO ORAIA MERA KAI ISE KLEISMENOS EKEIIIIIIIIIIII!
>From [EMAIL PROTECTED] Thu Jun 30 12:33:25 2005
Return-Path: <[EMAIL PROTECTED]>
X-Original-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: from localhost (enigma.otenet.gr [127.0.0.1])
by enigma.otenet.gr (Postfix) with ESMTP id 4AE80AA708
for <[EMAIL PROTECTED]>; Thu, 30 Jun 2005 12:33:25 +0300 (EEST)
Received: from noc.otenet.gr [195.170.0.29]
by localhost with POP3 (fetchmail-6.2.5)
for [EMAIL PROTECTED] (single-drop); Thu, 30 Jun 2005 12:33:25 +0300
(EEST)
Received: from diablo.otenet.gr (diablo.otenet.gr [195.170.0.33])
by noc.otenet.gr (8.13.4/8.13.4) with ESMTP id j5U9VMWs004593
for <[EMAIL PROTECTED]>; Thu, 30 Jun 2005 12:31:22 +0300 (EEST)
Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206])
by diablo.otenet.gr (8.13.4/8.13.4/Debian-1) with ESMTP id
j5U9UnUt020379
for <[EMAIL PROTECTED]>; Thu, 30 Jun 2005 12:30:49 +0300
Received: by wproxy.gmail.com with SMTP id 71so57637wra
for <[EMAIL PROTECTED]>; Thu, 30 Jun 2005 02:31:21 -0700 (PDT)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=beta; d=gmail.com;
h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
b=Xq5cabjB0mAK4xR6qXZmy3OEBaKWvhfun/7JU/vjyDU6tj4h7auC89Fp6cxGJRW/IdbmCMcM5uPz5usrEgnrMwP/10oRrvmLbEcO557A2+9uCLnXNzWBq24SlH41RL8c4XAhD5HIeUveroTnwGQ+l+XC8p20uG33XK5gEeKa7yc=
Received: by 10.54.115.4 with SMTP id n4mr263578wrc;
Thu, 30 Jun 2005 02:31:20 -0700 (PDT)
Received: by 10.54.22.29 with HTTP; Thu, 30 Jun 2005 02:31:20 -0700 (PDT)
Message-ID: <[EMAIL PROTECTED]>
Date: Thu, 30 Jun 2005 12:31:20 +0300
From: Kostas Zorbadelos <[EMAIL PROTECTED]>
Reply-To: Kostas Zorbadelos <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Test from gmail
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Disposition: inline
X-Spam-Status: No, score=0.0 required=4.5 tests=RCVD_BY_IP autolearn=failed
version=3.0.3
X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on bilbo.otenet.gr
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by noc.otenet.gr id
j5U9VMWs004593
X-UIDL: bKn"!;ej"!H7-"!pL>!!
Status: RO
Content-Length: 10
Lines: 3
Test it
>From [EMAIL PROTECTED] Tue Jul 5 16:21:27 2005
Return-Path: <[EMAIL PROTECTED]>
X-Original-To: kzorba
Delivered-To: [EMAIL PROTECTED]
Received: by enigma.otenet.gr (Postfix, from userid 1000)
id 01539AA708; Tue, 5 Jul 2005 16:21:27 +0300 (EEST)
Date: Tue, 5 Jul 2005 16:21:26 +0300
From: Kostas Zorbadelos <[EMAIL PROTECTED]>
To: Kostas Zorbadelos <[EMAIL PROTECTED]>
Subject: Test
Message-ID: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.9i
Status: RO
Content-Length: 242
Lines: 10
Test
--
Kostas Zorbadelos
Systems Designer/Developer, Otenet SA
[EMAIL PROTECTED] contact: kzorba (at) otenet.gr
Out there in the darkness, out there in the night
out there in the starlight, one soul burns brighter
than a thousand suns.
#searchpath "/usr/local/mailutils/lib/mailutils"
require ["vacation","fileinto","redirect","reject"];
#vacation :subject "I am on vacation" "I am on vacation. Yahoo!!";
if header :contains "from" "[EMAIL PROTECTED]"
{
fileinto "xxx";
}
elsif header :contains "from" "[EMAIL PROTECTED]"
{
reject "I do not accept mails from you...";
}
elsif header :contains "from" "smaraf"
{
discard;
}
else
{
keep;
}
CC = gcc
CCOPTS = -Wall -pedantic -g -ggdb
MAILUTILSPATH = /usr/local/mailutils
TESTLINKOPTS = -Wl,-R $(MAILUTILSPATH)/lib -Wl,-R /usr/local/lib
-L/usr/local/lib `$(MAILUTILSPATH)/bin/mailutils-config --link mbox maildir mh`
-lsieve
TESTCOMPILEOPTS = `$(MAILUTILSPATH)/bin/mailutils-config --compile`
default: all
all: sieve_eng_test
sieve_eng_test: sieve_eng_test.c Makefile
$(CC) $(CCOPTS) $(TESTCOMPILEOPTS) $(TESTLINKOPTS) -o sieve_eng_test
sieve_eng_test.c
_______________________________________________
Bug-mailutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-mailutils