<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: vpopmail - maildrop - SqWebMail mailfilter patch</title>
	<atom:link href="http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/feed/" rel="self" type="application/rss+xml" />
	<link>http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/</link>
	<description>Chaotic solutions and random thoughts from the restless mind of a notorious problem solver (TM), by Andre Beckedorf</description>
	<pubDate>Wed, 07 Jan 2009 02:10:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andre</title>
		<link>http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/comment-page-1/#comment-1001</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Fri, 03 Nov 2006 20:37:01 +0000</pubDate>
		<guid isPermaLink="false">http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/#comment-1001</guid>
		<description>Hi Jerome,
thanks for your patch. I'll check it out one of these days.
As for the domain wide filtering problem and .qmail being bypassed, I need to look into that.</description>
		<content:encoded><![CDATA[<p>Hi Jerome,<br />
thanks for your patch. I&#8217;ll check it out one of these days.<br />
As for the domain wide filtering problem and .qmail being bypassed, I need to look into that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerome MOLLIER-PIERRET</title>
		<link>http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/comment-page-1/#comment-905</link>
		<dc:creator>Jerome MOLLIER-PIERRET</dc:creator>
		<pubDate>Wed, 25 Oct 2006 15:40:17 +0000</pubDate>
		<guid isPermaLink="false">http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/#comment-905</guid>
		<description>Re Andre,

As precised in our last comment, we wanted the delivery from vdelivermail to go through maildrop.

But we wanted to keep the behavior of vdelivermail on all delivering cases (like bouncing, defrals ...). This is particularly important on the way that vdelivermail handle quota, and the users notifications.

We also wanted the granularity of a using a mailfilter configuration file for domains (ie /home/vpopmail/domains/onedomain/mailfilter), all domains (ie /home/vpopmail/domains/mailfilter) ... and indeed a default one in /etc/mailfilter.
If no mailfilter file is present, the we would like that vdelivermail deliver the mail as it does naturally.

So we rewritted a patch from scratch, witch is working fine in ours many tests ...

Regards,

Here it is :

--- vpopmail-5.4.17/vdelivermail.c	2006-06-29 21:36:43.000000000  0200
    vpopmail-5.4.17.patchmaildrop_actinux/vdelivermail.c	2006-10-25 16:59:17.000000000  0200
@@ -22,6  22,13 @@
  *
  */
 
 /* Patch insertion for using maildrop delivery program October 2006
  * by Actinux Team 
  * Jerome MOLLIER-PIERRET , 
  * Brian PASSANTE  
  *
  */
 
 /* include files */
 #include 
 #include 
@@ -81,6  88,9 @@
 /* from qmail's wait.h for run_command() */
 #define wait_exitcode(w) ((w) &#62;&#62; 8)
 
 /* Maildrop binary path */
 #define MAILDROP "/usr/local/bin/maildrop"
 
 /* Forward declarations */
 int process_valias(void);
 void get_arguments(int argc, char **argv);
@@ -93,6  103,7 @@
 void usernotfound(void);
 int is_loop_match( const char *dt, const char *address);
 int deliver_quota_warning(const char *dir, const char *q);
 int launchmaildrop(void);
 
 
 /* print an error string and then exit
@@ -610,7  621,7 @@
                 maildir_to_email(address));
         }
     
-        switch (deliver_to_maildir (address, DeliveredTo, 0, message_size)) {
         switch (launchmaildrop()) {
             case -1:
                 vexiterr (EXIT_OVERQUOTA, "user is over quota");
                 break;
@@ -620,6  631,22 @@
             case -3:
                 vexiterr (EXIT_BOUNCE, "mail is looping");
                 break;
             case -200:
 		/*start the old launch */
 		printf ("trying_normal_delivery: ");
 		switch (deliver_to_maildir (address, DeliveredTo, 0, message_size)) {
            		 case -1:
                 		vexiterr (EXIT_OVERQUOTA, "user is over quota");
                 		break;
             		case -2:
 		                vexiterr (EXIT_DEFER, "system error");
 		                break;
             		case -3:
                 		vexiterr (EXIT_BOUNCE, "mail is looping");
                 		break;
             		default:
                 		return;
 		        }
             default:
                 return;
         }
@@ -1042,6  1069,7 @@
             maildir_to_email(newdir), date_header());
     }
 
 
     err = deliver_to_maildir (dir, DeliveredTo, read_fd, sb.st_size);
 
     close (read_fd);
@@ -1063,3  1091,67 @@
 
     return (strcasecmp (compare, (dt 14)) == 0);
 }
 
 int launchmaildrop(void)
 {
  char *prog;
  int child;
  char *(args[4]);
  int wstat;
  char mailfilter_file[256];
  FILE *fs;
 
  printf("trying_through_maildrop: ");
 
  sprintf(mailfilter_file, "%s/mailfilter",TheDomainDir);
  if ( (fs=fopen(mailfilter_file, "r")) == NULL ) {
   /* if no mailfilter in domain then check in vpopmail dir */
   sprintf(mailfilter_file, "%s/%s/mailfilter",VPOPMAILDIR,DOMAINS_DIR);
   if ( (fs=fopen(mailfilter_file, "r")) == NULL ) {
    /* if no mailfilter in vpopmail dir check in /etc/ */
    sprintf(mailfilter_file, "/etc/mailfilter");
    if ( (fs=fopen(mailfilter_file, "r")) == NULL ) {
    /* no mailfilter file present */
    printf("Ouups,_no_mailfilter_file: ");
    return -200;
    }
   }
  }
 
 snprintf(prog, AUTH_SIZE, "&#124; /usr/bin/env HOME=%s VDOMAINDIR=%s VUSERDIR=%s VUSER=%s VDOMAIN=%s preline \"%s\" %s", TheDomainDir, TheDomainDir, vpw-&#62;pw_dir, TheUser, TheDomain, MAILDROP, mailfilter_file);
 
 /*to put maildrop in debug mode uncomment theses line
 snprintf(prog, AUTH_SIZE, "&#124; /usr/bin/env HOME=%s VDOMAINDIR=%s VUSERDIR=%s VUSER=%s VDOMAIN=%s preline \"%s\" %s -V 2", TheDomainDir, TheDomainDir, vpw-&#62;pw_dir, TheUser, TheDomain, MAILDROP, mailfilter_file);
 printf(prog);
 */
 
 
  while ((*prog == ' ') &#124;&#124; (*prog == '&#124;'))   prog;
 
  switch(child = fork())
   {
    case -1:
      printf("Unable to fork: %d.", errno); 
      vexit(EXIT_DEFER);
    case 0:
      args[0] = "/bin/sh"; args[1] = "-c"; args[2] = prog; args[3] = 0;
      sig_catch(SIGPIPE,SIG_DFL);
      execv(*args,args);
      printf("Unable to run /bin/sh: %d.", errno);
      exit(EXIT_DEFER);    /* the child's exit code will get caught below */
   }
 
   wait(&#38;wstat);
   waitpid(wstat,&#38;child,0);
 
  switch(wait_exitcode(wstat))
    {
     case 77: return -1; /* Overquota return code of maildrop */
     case 0: return 0;
     default: return -2; /* All other case */
    }
 
 
 }</description>
		<content:encoded><![CDATA[<p>Re Andre,</p>
<p>As precised in our last comment, we wanted the delivery from vdelivermail to go through maildrop.</p>
<p>But we wanted to keep the behavior of vdelivermail on all delivering cases (like bouncing, defrals &#8230;). This is particularly important on the way that vdelivermail handle quota, and the users notifications.</p>
<p>We also wanted the granularity of a using a mailfilter configuration file for domains (ie /home/vpopmail/domains/onedomain/mailfilter), all domains (ie /home/vpopmail/domains/mailfilter) &#8230; and indeed a default one in /etc/mailfilter.<br />
If no mailfilter file is present, the we would like that vdelivermail deliver the mail as it does naturally.</p>
<p>So we rewritted a patch from scratch, witch is working fine in ours many tests &#8230;</p>
<p>Regards,</p>
<p>Here it is :</p>
<p>&#8212; vpopmail-5.4.17/vdelivermail.c	2006-06-29 21:36:43.000000000  0200<br />
    vpopmail-5.4.17.patchmaildrop_actinux/vdelivermail.c	2006-10-25 16:59:17.000000000  0200<br />
@@ -22,6  22,13 @@<br />
  *<br />
  */</p>
<p> /* Patch insertion for using maildrop delivery program October 2006<br />
  * by Actinux Team<br />
  * Jerome MOLLIER-PIERRET ,<br />
  * Brian PASSANTE<br />
  *<br />
  */</p>
<p> /* include files */<br />
 #include<br />
 #include<br />
@@ -81,6  88,9 @@<br />
 /* from qmail&#8217;s wait.h for run_command() */<br />
 #define wait_exitcode(w) ((w) &gt;&gt; 8)</p>
<p> /* Maildrop binary path */<br />
 #define MAILDROP &#8220;/usr/local/bin/maildrop&#8221;</p>
<p> /* Forward declarations */<br />
 int process_valias(void);<br />
 void get_arguments(int argc, char **argv);<br />
@@ -93,6  103,7 @@<br />
 void usernotfound(void);<br />
 int is_loop_match( const char *dt, const char *address);<br />
 int deliver_quota_warning(const char *dir, const char *q);<br />
 int launchmaildrop(void);</p>
<p> /* print an error string and then exit<br />
@@ -610,7  621,7 @@<br />
                 maildir_to_email(address));<br />
         }</p>
<p>-        switch (deliver_to_maildir (address, DeliveredTo, 0, message_size)) {<br />
         switch (launchmaildrop()) {<br />
             case -1:<br />
                 vexiterr (EXIT_OVERQUOTA, &#8220;user is over quota&#8221;);<br />
                 break;<br />
@@ -620,6  631,22 @@<br />
             case -3:<br />
                 vexiterr (EXIT_BOUNCE, &#8220;mail is looping&#8221;);<br />
                 break;<br />
             case -200:<br />
 		/*start the old launch */<br />
 		printf (&#8221;trying_normal_delivery: &#8220;);<br />
 		switch (deliver_to_maildir (address, DeliveredTo, 0, message_size)) {<br />
            		 case -1:<br />
                 		vexiterr (EXIT_OVERQUOTA, &#8220;user is over quota&#8221;);<br />
                 		break;<br />
             		case -2:<br />
 		                vexiterr (EXIT_DEFER, &#8220;system error&#8221;);<br />
 		                break;<br />
             		case -3:<br />
                 		vexiterr (EXIT_BOUNCE, &#8220;mail is looping&#8221;);<br />
                 		break;<br />
             		default:<br />
                 		return;<br />
 		        }<br />
             default:<br />
                 return;<br />
         }<br />
@@ -1042,6  1069,7 @@<br />
             maildir_to_email(newdir), date_header());<br />
     }</p>
<p>     err = deliver_to_maildir (dir, DeliveredTo, read_fd, sb.st_size);</p>
<p>     close (read_fd);<br />
@@ -1063,3  1091,67 @@</p>
<p>     return (strcasecmp (compare, (dt 14)) == 0);<br />
 }</p>
<p> int launchmaildrop(void)<br />
 {<br />
  char *prog;<br />
  int child;<br />
  char *(args[4]);<br />
  int wstat;<br />
  char mailfilter_file[256];<br />
  FILE *fs;</p>
<p>  printf(&#8221;trying_through_maildrop: &#8220;);</p>
<p>  sprintf(mailfilter_file, &#8220;%s/mailfilter&#8221;,TheDomainDir);<br />
  if ( (fs=fopen(mailfilter_file, &#8220;r&#8221;)) == NULL ) {<br />
   /* if no mailfilter in domain then check in vpopmail dir */<br />
   sprintf(mailfilter_file, &#8220;%s/%s/mailfilter&#8221;,VPOPMAILDIR,DOMAINS_DIR);<br />
   if ( (fs=fopen(mailfilter_file, &#8220;r&#8221;)) == NULL ) {<br />
    /* if no mailfilter in vpopmail dir check in /etc/ */<br />
    sprintf(mailfilter_file, &#8220;/etc/mailfilter&#8221;);<br />
    if ( (fs=fopen(mailfilter_file, &#8220;r&#8221;)) == NULL ) {<br />
    /* no mailfilter file present */<br />
    printf(&#8221;Ouups,_no_mailfilter_file: &#8220;);<br />
    return -200;<br />
    }<br />
   }<br />
  }</p>
<p> snprintf(prog, AUTH_SIZE, &#8220;| /usr/bin/env HOME=%s VDOMAINDIR=%s VUSERDIR=%s VUSER=%s VDOMAIN=%s preline \&#8221;%s\&#8221; %s&#8221;, TheDomainDir, TheDomainDir, vpw-&gt;pw_dir, TheUser, TheDomain, MAILDROP, mailfilter_file);</p>
<p> /*to put maildrop in debug mode uncomment theses line<br />
 snprintf(prog, AUTH_SIZE, &#8220;| /usr/bin/env HOME=%s VDOMAINDIR=%s VUSERDIR=%s VUSER=%s VDOMAIN=%s preline \&#8221;%s\&#8221; %s -V 2&#8243;, TheDomainDir, TheDomainDir, vpw-&gt;pw_dir, TheUser, TheDomain, MAILDROP, mailfilter_file);<br />
 printf(prog);<br />
 */</p>
<p>  while ((*prog == &#8216; &#8216;) || (*prog == &#8216;|&#8217;))   prog;</p>
<p>  switch(child = fork())<br />
   {<br />
    case -1:<br />
      printf(&#8221;Unable to fork: %d.&#8221;, errno);<br />
      vexit(EXIT_DEFER);<br />
    case 0:<br />
      args[0] = &#8220;/bin/sh&#8221;; args[1] = &#8220;-c&#8221;; args[2] = prog; args[3] = 0;<br />
      sig_catch(SIGPIPE,SIG_DFL);<br />
      execv(*args,args);<br />
      printf(&#8221;Unable to run /bin/sh: %d.&#8221;, errno);<br />
      exit(EXIT_DEFER);    /* the child&#8217;s exit code will get caught below */<br />
   }</p>
<p>   wait(&amp;wstat);<br />
   waitpid(wstat,&amp;child,0);</p>
<p>  switch(wait_exitcode(wstat))<br />
    {<br />
     case 77: return -1; /* Overquota return code of maildrop */<br />
     case 0: return 0;<br />
     default: return -2; /* All other case */<br />
    }</p>
<p> }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerome MOLLIER-PIERRET</title>
		<link>http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/comment-page-1/#comment-892</link>
		<dc:creator>Jerome MOLLIER-PIERRET</dc:creator>
		<pubDate>Tue, 24 Oct 2006 14:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/#comment-892</guid>
		<description>Hi Andre,

You are right about the QMAIL-EXT option.

This kind of implementation using maildrop for filtering purpose seems to be the cleanest for us in our mind, because we do not have to change .qmail-default behavior in many ways (ie like qmailadmin stuff...). And therefore, using vdelivermail make us sure to do many more check regarding vpopmail, like for sample 'bouncing over-quota mails over full mailboxes'.  

But regarding deeper in the code and testing more your filtering solution... We encountred anothers questions : the big issue we founded is is that .qmail checks are completly bypassed if the mailfilter file is present for the domain.

Do you aggreed with our conclusion ?

Regards,</description>
		<content:encoded><![CDATA[<p>Hi Andre,</p>
<p>You are right about the QMAIL-EXT option.</p>
<p>This kind of implementation using maildrop for filtering purpose seems to be the cleanest for us in our mind, because we do not have to change .qmail-default behavior in many ways (ie like qmailadmin stuff&#8230;). And therefore, using vdelivermail make us sure to do many more check regarding vpopmail, like for sample &#8216;bouncing over-quota mails over full mailboxes&#8217;.  </p>
<p>But regarding deeper in the code and testing more your filtering solution&#8230; We encountred anothers questions : the big issue we founded is is that .qmail checks are completly bypassed if the mailfilter file is present for the domain.</p>
<p>Do you aggreed with our conclusion ?</p>
<p>Regards,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/comment-page-1/#comment-860</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Fri, 20 Oct 2006 18:53:03 +0000</pubDate>
		<guid isPermaLink="false">http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/#comment-860</guid>
		<description>Jerome, thanks for the comment. Indeed there was a problem when you're using the QMAIL_EXT option. We don't use QMAIL_EXT over here, so that's why I missed that one. Sorry for the trouble!
Anyway, I've updated the patch and the vdelivermail.c above. Thanks again!</description>
		<content:encoded><![CDATA[<p>Jerome, thanks for the comment. Indeed there was a problem when you&#8217;re using the QMAIL_EXT option. We don&#8217;t use QMAIL_EXT over here, so that&#8217;s why I missed that one. Sorry for the trouble!<br />
Anyway, I&#8217;ve updated the patch and the vdelivermail.c above. Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerome MOLLIER-PIERRET</title>
		<link>http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/comment-page-1/#comment-859</link>
		<dc:creator>Jerome MOLLIER-PIERRET</dc:creator>
		<pubDate>Fri, 20 Oct 2006 15:34:32 +0000</pubDate>
		<guid isPermaLink="false">http://katastrophos.net/andre/blog/2006/10/03/vpopmail-maildrop-sqwebmail-mailfilter-patch/#comment-859</guid>
		<description>Well, trying to test the patch we encountred some trouble to compile vdelivermail ... and patch posted here seem to be broken.

here is our added patch solution :

--- vpopmail-5.4.17/vdelivermail.c      2006-10-20 17:15:13.000000000  0200
    vpopmail-5.4.17-patchmaildrop/vdelivermail.c        2006-10-20 17:12:24.000000000  0200
@@ -187,7  187,7 @@
 void get_arguments(int argc, char **argv)
 {
 #ifdef QMAIL_EXT
- int i;
 // int i;
 #endif
  char *tmpstr;

@@ -214,6  214,11 @@

 void postprocess(void)
 {
 #ifdef QMAIL_EXT
  int i;
 #endif
 
 
     lowerit(TheUser);
     lowerit(TheDomain);</description>
		<content:encoded><![CDATA[<p>Well, trying to test the patch we encountred some trouble to compile vdelivermail &#8230; and patch posted here seem to be broken.</p>
<p>here is our added patch solution :</p>
<p>&#8212; vpopmail-5.4.17/vdelivermail.c      2006-10-20 17:15:13.000000000  0200<br />
    vpopmail-5.4.17-patchmaildrop/vdelivermail.c        2006-10-20 17:12:24.000000000  0200<br />
@@ -187,7  187,7 @@<br />
 void get_arguments(int argc, char **argv)<br />
 {<br />
 #ifdef QMAIL_EXT<br />
- int i;<br />
 // int i;<br />
 #endif<br />
  char *tmpstr;</p>
<p>@@ -214,6  214,11 @@</p>
<p> void postprocess(void)<br />
 {<br />
 #ifdef QMAIL_EXT<br />
  int i;<br />
 #endif</p>
<p>     lowerit(TheUser);<br />
     lowerit(TheDomain);</p>
]]></content:encoded>
	</item>
</channel>
</rss>
