Re: Can't log POP3

Bruno Negrão <[email protected]>
Newsgroups gmane.comp.djb.syslog
Message-ID <008b01c45303$250be3c0$5100a8c0@egp>
Hi Mario,

I had some qmail installations with qmail-pop3d logging things. It was
needed to apply a patch over qmail-pop3d. The patch is called
qmail-1.03-poplogging.patch.txt and it's attached to this e-mail.

A tigh warmful hug,
bruno.

----- Original Message ----- 
From: "Mario Gamito" <[email protected]>
To: "ML log qmail" <[email protected]>
Sent: Tuesday, June 15, 2004 1:09 PM
Subject: Can't log POP3


> Hi,
>
> In my life i've installed more (q)mail servers than i can count.
> However, i was never able to get POP3 logging. Shame on me :(
>
> qmail-send logs ok, qmail-smtpd logs ok, qmail-pop3ds logs ok,
> qmail-pop3d don't.
>
> The file /var/log/qmail/qmail-pop3d/current *exists*, but is always
> empty :(
>
> I have no explanation for this.
> I use the same method for all, the permissions are ok, but... nothing :(
>
> I wonder if someone is kind enough to help me here:
>
> ------------------------------------------------
> Here is my /var/qmail/supervise/qmail-pop3d/run:
>
> #!/bin/sh
> env - PATH="/usr/local/bin:/var/qmail/bin" \
> tcpserver -v -l 0 -P -H -Q -R 0 pop3 \
> qmail-popup foo.netual.com \
> /home/vpopmail/bin/vchkpw \
> qmail-pop3d Maildir 2>&1
> -------------------------------------------------
>
> ----------------------------------------------------------------
> Here is my /var/qmail/supervise/qmail-pop3d/log/run:
>
> #!/bin/sh
> env - PATH="/usr/local/bin" \
> setuidgid qmaill multilog t s2500000 /var/log/qmail/qmail-pop3d
> ----------------------------------------------------------------
>
> -----------------------------------------------------
> The pop3d logger is running:
>
> [root@foo log]# svstat /service/*/log
> /service/qmail-pop3d/log: up (pid 1706) 1282 seconds
> /service/qmail-pop3ds/log: up (pid 1700) 1282 seconds
> /service/qmail-send/log: up (pid 1705) 1282 seconds
> /service/qmail-smtpd/log: up (pid 1703) 1283 seconds
> [root@foo log]#
> --------------------------------------------------------------
>
> My ownership throught /var/log/qmail is qmaill.qmail
> as in "chown -R qmaill.qmail /var/log/qmail/"
>
> Also my permissions for the same directory are 2700 as in "chmod 2700
> /var/log/qmail/*"
> ---------------------------------------------------------------
>
> ---------------------------------------------------------------
> One thing: i use vpopmail with authentication through MySQL and
> compiled with --enable-auth-logging=y (not through MySQL)
> and --enable-logging=v
>
> The authentication logs are going to /var/log/maillog
> The rest, i don't have a clue :(
>
> My configure:
>
> ./configure --enable-qmaildir=/var/qmail
> --enable-qmail-newu=/var/qmail/bin/qmail-newu
> --enable-qmail-inject=/var/qmail/bin/qmail-inject
> --enable-qmail-newmrh=/var/qmail/bin/qmail-newmrh
> --enable-vpopuser=vpopmail
> --enable-vpopgroup=vchkpw
> --enable-roaming-users=n
> --enable-tcprules-prog=/usr/local/bin/tcprules
> --enable-tcpserver-file=/var/qmail/control/tcp.smtp
> --enable-logging=v --enable-md5-passwords=y --enable-log-name=vpopmail
> --enable-valias=y --enable-qmail-ext=y --enable-ip-alias-domain=n
> --enable-many-domains=y --enable-learn-passwords=y --enable-auth-logging=y
> --enable-auth-module=mysql --disable-mysql-limits
> --------------------------------------------------------------------------
>
> Would someone give me a hand on this ?
> I'd really appreciate it and be forever grateful.
>
> Warm Regards,
> Mário Gamito
>
>
>
qmail-1.03-poplogging.patch.txt (text/plain, 3.7 KB)
diff -Naur qmail-1.03.orig/qmail-pop3d.c qmail-1.03/qmail-pop3d.c
--- qmail-1.03.orig/qmail-pop3d.c	Sat Feb 24 14:26:54 2001
+++ qmail-1.03/qmail-pop3d.c	Sat Feb 24 22:52:55 2001
@@ -41,6 +41,9 @@
 char ssinbuf[128];
 substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
 
+char sserrbuf[128];
+substdio sserr = SUBSTDIO_FDBUF(safewrite,2,sserrbuf,sizeof sserrbuf);
+
 void put(buf,len) char *buf; int len;
 {
   substdio_put(&ssout,buf,len);
@@ -53,8 +56,25 @@
 {
   substdio_flush(&ssout);
 }
+void writelog(char *x1, char *x2, char *x3, char *x4)
+{
+  char strnum[FMT_ULONG];
+  
+  strnum[fmt_ulong(strnum,getpid())] = 0;
+    
+  substdio_puts(&sserr,"pop3d: pid ");
+  substdio_puts(&sserr,strnum);
+  substdio_puts(&sserr," ");
+  if (x1) substdio_puts(&sserr,x1);
+  if (x2) substdio_puts(&sserr,x2);
+  if (x3) substdio_puts(&sserr,x3);
+  if (x4) substdio_puts(&sserr,x4);
+  substdio_puts(&sserr,"\n");
+  substdio_flush(&sserr);
+}
 void err(s) char *s;
 {
+  writelog("-ERR ", s, 0, 0);
   puts("-ERR ");
   puts(s);
   puts("\r\n");
@@ -193,6 +213,7 @@
 	rename(m[i].fn,line.s); /* if it fails, bummer */
       }
   okay();
+  writelog("QUIT", 0, 0, 0);
   die();
 }
 
@@ -257,6 +278,7 @@
   int i;
   unsigned long limit;
   int fd;
+  char strnum[FMT_ULONG];
  
   i = msgno(arg);
   if (i == -1) return;
@@ -271,6 +293,8 @@
   substdio_fdbuf(&ssmsg,read,fd,ssmsgbuf,sizeof(ssmsgbuf));
   blast(&ssmsg,limit);
   close(fd);
+  strnum[fmt_ulong(strnum,m[i].size)] = 0;
+  writelog("RETR: ", "msglen: ", strnum, 0);
 }
 
 struct commands pop3commands[] = {
diff -Naur qmail-1.03.orig/qmail-popup.c qmail-1.03/qmail-popup.c
--- qmail-1.03.orig/qmail-popup.c	Mon Jun 15 12:53:16 1998
+++ qmail-1.03/qmail-popup.c	Sat Feb 24 22:52:55 2001
@@ -38,6 +38,9 @@
 char ssinbuf[128];
 substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
 
+char sserrbuf[128];
+substdio sserr = SUBSTDIO_FDBUF(safewrite,2,sserrbuf,sizeof sserrbuf);
+
 void puts(s) char *s;
 {
   substdio_puts(&ssout,s);
@@ -46,8 +49,25 @@
 {
   substdio_flush(&ssout);
 }
+void writelog(char *x1, char *x2, char *x3, char *x4)
+{
+  char strnum[FMT_ULONG];
+  
+  strnum[fmt_ulong(strnum,getpid())] = 0;
+  
+  substdio_puts(&sserr,"popup: pid ");
+  substdio_puts(&sserr,strnum);
+  substdio_puts(&sserr," ");
+  if (x1) substdio_puts(&sserr,x1);
+  if (x2) substdio_puts(&sserr,x2);
+  if (x3) substdio_puts(&sserr,x3);
+  if (x4) substdio_puts(&sserr,x4);
+  substdio_puts(&sserr,"\n");
+  substdio_flush(&sserr);
+}
 void err(s) char *s;
 {
+  writelog("-ERR ", s, 0, 0);
   puts("-ERR ");
   puts(s);
   puts("\r\n");
@@ -67,7 +87,7 @@
 void err_authoriz() { err("authorization first"); }
 
 void okay() { puts("+OK \r\n"); flush(); }
-void pop3_quit() { okay(); die(); }
+void pop3_quit() { okay(); writelog("QUIT", 0, 0, 0); die(); }
 
 
 char unique[FMT_ULONG + FMT_ULONG + 3];
@@ -88,7 +108,14 @@
   int wstat;
   int pi[2];
  
-  if (fd_copy(2,1) == -1) die_pipe();
+  /* Don't know why this is needed has no effect when removed
+     it stands in the way of good logging with multilog
+     checked qmail-pop3d it does not use the fd 2
+     it only writes to stdout not stderr not even for errors
+     Willy De la Court <[email protected]>
+   */
+  
+  /* if (fd_copy(2,1) == -1) die_pipe();*/
   close(3);
   if (pipe(pi) == -1) die_pipe();
   if (pi[0] != 3) die_pipe();
@@ -140,6 +167,7 @@
   seenuser = 1;
   if (!stralloc_copys(&username,arg)) die_nomem(); 
   if (!stralloc_0(&username)) die_nomem(); 
+  writelog("USER: ", arg, 0, 0);
 }
 void pop3_pass(arg) char *arg;
 {
@@ -153,6 +181,7 @@
   space = arg + str_chr(arg,' ');
   if (!*space) { err_syntax(); return; }
   *space++ = 0;
+  writelog("APOP: ", arg, 0, 0);
   doanddie(arg,space - arg,space);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.