Louis,

> This can be fixed without any patching.  The problem is with the way
> qmail-popup sets up the file descriptors.  Here's my run file for pop3
> service:
> 
>   #!/bin/sh
>   PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/bin/qtools
>   # this is ugly, but qmail-popup breaks things a bit. --L
>   exec 8>&1 
>   exec env -  PATH=$PATH softlimit -m 2000000 \
>     tcpserver -Rlyossarian.americas.nokia.com yossarian.americas.nokia.com 110 \
>     qmail-popup yossarian.americas.nokia.com stderrto /dev/fd/8 ckpw qmail-pop3d 
>./Maildir 2>&1

Thanks for the tip.  I wish I got your note earlier.

In the past two hours, I was reading qmail-popup.c and thus found out
the underlined line below was doing something unusual:

     void doanddie(user,userlen,pass)
     char *user;
     unsigned int userlen; /* including 0 byte */
     char *pass;
     {
       int child;
       int wstat;
       int pi[2];
 
       if (fd_copy(2,1) == -1) die_pipe();
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Once deleted, I could get *some* :( stuff written by qmail-pop3d to
STDERR logged via multilog, rather than spitted out to POP clients.
The reason I said *some* is because I am stuck again.  The 2nd
strerr_warn1 in the attached patch below (WARNING! unfinished) simply
stays silent. The first one prints its msg correctly.  I have been
looking up and down the src to see what I did wrong, but so far can't
spot anything (yet).

> 
> where stderrto is a small program that opens its first argument for
> writing on fd 2 and execs the rest of its arguments[1].  In
> retrospect, patching qmail-popup might have been a better idea.
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Please see above.  I don't know whether it's the right thing to do or
not at this moment.  Somehow it just "partially" works - for the first
strerr_warn1 anyways.

Regards,

Chin Fang
[EMAIL PROTECTED]

> 
> 
> ^L
> 
> [1] Incidentally, there's a program in an old daemontools distribution
> that does exactly the same thing, which I only realized after I wrote
> mine.  You can get the same effect with something like:
> 
>   sh -c 'exec ckpw qmail-pop3d 8>&2'
> 
> (untested)
---------------- unfinished qmail-pop3d download logging patch -----------

*** qmail-pop3d.c.orig  Sat May 20 14:47:32 2000
--- qmail-pop3d.c       Sat May 20 14:36:16 2000
***************
*** 16,22 ****
--- 16,25 ----
  #include "readwrite.h"
  #include "timeoutread.h"
  #include "timeoutwrite.h"
+ #include "strerr.h"
  
+ unsigned long bytesread = 0;
+ 
  void die() { _exit(0); }
  
  int saferead(fd,buf,len) int fd; char *buf; int len;
***************
*** 99,111 ****
      if (!line.len)
        inheaders = 0;
      else
!       if (line.s[0] == '.')
          put(".",1);
      put(line.s,line.len);
      put("\r\n",2);
      if (!match) break;
    }
    put("\r\n.\r\n",5);
    flush();
  }
  
--- 102,119 ----
      if (!line.len)
        inheaders = 0;
      else
!       if (line.s[0] == '.') {
          put(".",1);
+       bytesread++; /* even one byte counts :> */
+       }
      put(line.s,line.len);
      put("\r\n",2);
+     bytesread += line.len;
+     bytesread += 2;
      if (!match) break;
    }
    put("\r\n.\r\n",5);
+   bytesread += 5;
    flush();
  }
  
***************
*** 298,305 ****
    if (chdir(argv[1]) == -1) die_nomaildir();
   
    getlist();
! 
    okay();
    commands(&ssin,pop3commands);
    die();
  }
--- 306,314 ----
    if (chdir(argv[1]) == -1) die_nomaildir();
   
    getlist();
!   strerr_warn1("getlist done",0);
    okay();
    commands(&ssin,pop3commands);
+   strerr_warn1("Ready to exit",0);
    die();
  }

Reply via email to