[dev] ingo procmail script driver

Tyler Colbert tyler-hordeml at colberts.us
Mon Aug 18 18:22:54 PDT 2003


Quoting Michael M Slusarz <slusarz at bigworm.colorado.edu>:

> Quoting ben at chavet.net:
>
> | I extended the procmail script driver in ingo to allow user-defined
> | filters.
> | I'll be the first to admit that it's kind of an ugly patch, but it works
> | (ugly,
> | meaning there is a lot of duplicate code).

Funny thing, I just changed from procmail because of a lack of support for
user defined filters in the driver... :).. oh well...

Exim has some basic support for sieve filters, so I might as well share what
I've done on supporting that as Im unlikely to get much further for a while
:)...  The basic functionality works fine.

I've attached a small patch that just puts a comment in the top of the sieve
script that is required by exim ("# sieve filter") Aside from that, there were
some things that I had just started researching but hadn't implimented:

If using sieve with exim:
1) Remove INGO_STORAGE_ACTION_REJECT from sieve.php as Exim doesnt support
rejection.  Probably, REJECT and MOVE should be configurable in backends.php as
they are optional parts of RFC3028.  REJECT will probably never be supported by
exim.
2) Turn off message status flags (read, answered, important, etc) as per
procmail for much the same reasons.
3) Shut off all the comparisons except "is" "contains" and "matches".  Sounds
like the exim people responsible plan on correcting this difficiency, but their
sieve support is still in its infancy.
4) make sieve filter header configurable.

I've attached a diff for ingo/config/backends.php.dist that has an example of
uploading for exim.  Since it uses 'procmailrc' to update the '.forward' file
with a sieve script, it seems that the name 'procmailrc' is rather
inappropriate :)...

I should note that you need a small change to exim as well which should be in
the next release of exim.  Otherwise, "stop;" is broken. For archival reasons,
I've attached that patch as well.  Of course, its a patch against exim..  FYI,
Its against V 4.21 and applies to src/sieve.c

Tyler Colbert
--
Tyler Colbert
-------------- next part --------------
--- sieve.php   12 Aug 2003 16:13:41 -0000      1.48
+++ sieve.php   18 Aug 2003 23:54:28 -0000
@@ -79,7 +79,7 @@
      */
     function toCode()
     {
-        $code = '';
+        $code = '# sieve filter' . "\n" . '# generated by ingo' . "\n\n";
         $requires = $this->requires();

         if (count($requires) > 1) {
-------------- next part --------------
--- backends.php.dist   29 Jul 2003 16:52:26 -0000      1.11
+++ backends.php.dist   19 Aug 2003 00:11:53 -0000
@@ -75,6 +75,25 @@
     )
 );

+/* Sieve using Exim example */
+$backends['eximsieve'] = array(
+    'driver' => 'vfs',
+    'preferred' => 'example.com',
+    'hordeauth' => true,
+    'params' => array(
+        // Hostname of the VFS server
+        'hostspec' => 'ftp.example.com',
+        // Name of the procmail config file to write
+        'procmailrc' => '.forward',
+        // Port of the VFS server
+        'port' => 21,
+        // The VFS driver to use
+        'vfstype' => 'ftp'
+    ),
+    'script' => 'sieve',
+    'scriptparams' => array()
+);
+
 /* IMAP Example */
 $backends['imap'] = array(
     'driver' => 'null',
-------------- next part --------------
--- sieve.c.orig        2003-08-18 19:08:07.000000000 +0200
+++ sieve.c     2003-08-18 19:18:32.000000000 +0200
@@ -1781,6 +1781,7 @@
   generated   where to hang newly-generated addresses
 
 Returns:      1                success
+              2                success by stop
               0                no block command found
               -1               syntax or execution error
 */
@@ -1788,11 +1789,13 @@
 static int parse_block(struct Sieve *filter, int exec,
   address_item **generated)
 {
+int r;
+
 if (parse_white(filter)==-1) return -1;
 if (*filter->pc=='{')
   {
   ++filter->pc;
-  if (parse_commands(filter,exec,generated)==-1) return -1;
+  if ((r=parse_commands(filter,exec,generated))==-1 || r==2) return r;
   if (*filter->pc=='}')
     {
     ++filter->pc;
@@ -1847,6 +1850,7 @@
   generated   where to hang newly-generated addresses
 
 Returns:      1                success
+              2                success by stop
               -1               syntax or execution error
 */
 static int parse_commands(struct Sieve *filter, int exec,
@@ -1854,6 +1858,8 @@
 {
 while (*filter->pc)
   {
+  int r;
+
   if (parse_white(filter)==-1) return -1;
   if (parse_identifier(filter,CUS "if"))
     {
@@ -1872,7 +1878,7 @@
       return -1;
       }
     m=parse_block(filter,exec ? cond : 0, generated);
-    if (m==-1) return -1;
+    if (m==-1 || m==2) return r;
     if (m==0)
       {
       filter->errmsg=CUS "missing block";
@@ -1893,7 +1899,7 @@
           return -1;
           }
         m=parse_block(filter,exec && unsuccessful ? cond : 0, generated);
-        if (m==-1) return -1;
+        if (m==-1 || m==2) return m;
         if (m==0)
           {
           filter->errmsg=CUS "missing block";
@@ -1908,7 +1914,7 @@
     if (parse_identifier(filter,CUS "else"))
       {
       m=parse_block(filter,exec && unsuccessful, generated);
-      if (m==-1) return -1;
+      if (m==-1 || m==2) return m;
       if (m==0)
         {
         filter->errmsg=CUS "missing block";
@@ -1926,7 +1932,7 @@
     if (exec)
       {
       filter->pc+=Ustrlen(filter->pc);
-      return 1;
+      return 2;
       }
     }
   else if (parse_identifier(filter,CUS "keep"))


More information about the dev mailing list