Sameer,

I've taken the qmail-queue-custom-error patch and modified it so it patches 
cleanly and compiles against qmail-ldap-1.03-20050401a with no other patches 
installed.

Note I didn't say "runs."  I haven't tried to run it yet.  But it at least 
patches and compiles. ;-)

Please let me know if this works with simscan.

--Ed

On Thursday 30 June 2005 06:53, you wrote:
> Hi All,
> I am wondering if there is some functionality like one provided by
> qmail-queue-custom-error.patch
> in qmail-ldap. Or do I have to use this patch?
>
> I have qmail-ldap running patched with qmail-ldap-1.03-20050401a.patch
>
> I want to send some custom error messages and using simscan, clamav and
> spamassassin.
> I tried to pach the qmail-ldap source with this patch but it failed.
>
> Thank you.
--- qmail.c.old	2005-07-02 11:11:29.000000000 -0500
+++ qmail.c	2005-07-02 11:11:34.000000000 -0500
@@ -32,6 +32,7 @@
 {
   int pim[2];
   int pie[2];
+  int pierr[2];
 
 #ifdef ALTQUEUE
   setup_qqargs();
@@ -39,17 +40,26 @@
 
   if (pipe(pim) == -1) return -1;
   if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; }
+  if (pipe(pierr) == -1) {
+    close(pim[0]); close(pim[1]);
+    close(pie[0]); close(pie[1]);
+    close(pierr[0]); close(pierr[1]);
+    return -1;
+  }
  
   switch(qq->pid = vfork()) {
     case -1:
+      close(pierr[0]); close(pierr[1]);
       close(pim[0]); close(pim[1]);
       close(pie[0]); close(pie[1]);
       return -1;
     case 0:
       close(pim[1]);
       close(pie[1]);
+      close(pierr[0]); /* we want to receive data */
       if (fd_move(0,pim[0]) == -1) _exit(120);
       if (fd_move(1,pie[0]) == -1) _exit(120);
+      if (fd_move(4,pierr[1]) == -1) _exit(120);
       if (chdir(auto_qmail) == -1) _exit(61);
       execv(*binqqargs,binqqargs);
       _exit(120);
@@ -57,6 +67,7 @@
 
   qq->fdm = pim[1]; close(pim[0]);
   qq->fde = pie[1]; close(pie[0]);
+  qq->fderr = pierr[0]; close(pierr[1]);
   substdio_fdbuf(&qq->ss,subwrite,qq->fdm,qq->buf,sizeof(qq->buf));
   qq->flagerr = 0;
   return 0;
@@ -141,10 +152,21 @@
 {
   int wstat;
   int exitcode;
+  int match;
+  char ch;
+  static char errstr[256];
+  int len = 0;
 
   qmail_put(qq,"",1);
   if (!qq->flagerr) if (substdio_flush(&qq->ss) == -1) qq->flagerr = 1;
   close(qq->fde);
+  substdio_fdbuf(&qq->ss,read,qq->fderr,qq->buf,sizeof(qq->buf));
+  while( substdio_bget(&qq->ss,&ch,1) && len < 255){
+    errstr[len]=ch;
+    len++;
+  }
+  if (len > 0) errstr[len]='\0'; /* add str-term */
+  close(qq->fderr);
 
   if ((unsigned long)wait_pid(&wstat,qq->pid) != qq->pid)
     return "Zqq waitpid surprise (#4.3.0)";
--- qmail.h.old	2005-07-02 11:10:19.000000000 -0500
+++ qmail.h	2005-07-02 11:10:00.000000000 -0500
@@ -8,6 +8,7 @@
   unsigned long pid;
   int fdm;
   int fde;
+  int fderr;
   substdio ss;
   char buf[1024];
 } ;

Reply via email to