Re: pop3 loggin.
Stefan Paletta <stefanp <at> cabal1.com>
2004-07-01 12:24:38 GMT
Cesar,
find attached a modification to qmail-pop3d I am using. This will
make qmail-pop3d report the initial number of messages in mailbox,
number of messages remaining, size of all messages, size of messages
remaining, and bytes transferred to client.
> warnings (error authentications) dont report associated pid.(may)?
> ip reports in pop3 accounting will separate tcpserver pop3 loggin from
> pop3 accounting loggin and you can then associate ip connections with a
> pop3 accounting pid.
I did not quite understand the other features you mentioned, so if
you could explain once more ...
Btw. there seems to be a quirk with the 'login' accouning -- I some-
times see these lines run together with the next line from another
process.
-Stefan
--
junior guru SP666-RIPE JID:stefanp <at> jabber.de.cw.net SMP <at> IRC
Index: qmail-pop3d.c
===================================================================
--- qmail-pop3d.c (revision 10)
+++ qmail-pop3d.c (revision 14)
<at> <at> -25,6 +25,13 <at> <at>
#include "qmail-ldap.h"
int qfd;
+
+struct message {
+ int flagdeleted;
+ unsigned long size;
+ char *fn;
+} *m;
+unsigned int numm;
/* level 0 = no logging
1 = fatal errors
<at> <at> -50,13 +57,38 <at> <at>
void log_quit(void)
{
+ unsigned int i;
+ unsigned long before;
+ unsigned long after;
+ unsigned int remain;
char strnum[FMT_ULONG];
logit(2, "acct:");
logit(2, logs_pidhostinfo.s);
logit(2, "logout ");
+
+ before = after = 0;
+ remain = 0;
+ for (i = 0;i < numm;++i) {
+ before += m[i].size;
+ if (!m[i].flagdeleted) {
+ after += m[i].size;
+ remain++;
+ }
+ }
+
+ strnum[fmt_uint(strnum,numm)] = 0;
+ logit(2, strnum); logit(2, ":");
+ strnum[fmt_uint(strnum,remain)] = 0;
+ logit(2, strnum); logit(2, " ");
+
+ strnum[fmt_ulong(strnum,before)] = 0;
+ logit(2, strnum); logit(2, ":");
+ strnum[fmt_ulong(strnum,after)] = 0;
+ logit(2, strnum); logit(2, " ");
+
strnum[fmt_ulong(strnum,log_bytes)] = 0;
- logit(2, strnum); logitf(2, " bytes transferred");
+ logitf(2, strnum);
}
void die(void) { log_quit(); _exit(0); }
<at> <at> -112,11 +144,11 <at> <at>
void err_syntax(void) { err("syntax error"); logitf(3, "error: syntax error"); }
void err_unimpl(void) { err("unimplemented"); logitf(3, "error: unimplemented"); }
-void err_deleted(void) { err("already deleted"); logitf(3, "already deleted"); }
-void err_nozero(void) { err("messages are counted from 1"); logitf(3, "messages are counted from 1"); }
-void err_toobig(void) { err("not that many messages"); logitf(3, "not that many messages"); }
-void err_nosuch(void) { err("unable to open that message"); logitf(3, "unable to open that message"); }
-void err_nounlink(void) { err("unable to unlink all deleted messages"); logitf(3, "unable to unlink
all deleted messages"); }
+void err_deleted(void) { err("already deleted"); logitf(3, "error: already deleted"); }
+void err_nozero(void) { err("messages are counted from 1"); logitf(3, "error: messages are counted
from 1"); }
+void err_toobig(void) { err("not that many messages"); logitf(3, "error: not that many messages"); }
+void err_nosuch(void) { err("unable to open that message"); logitf(3, "error: unable to open that
message"); }
+void err_nounlink(void) { err("unable to unlink all deleted messages"); logitf(3, "error: unable to
unlink all deleted messages"); }
void okay(void) { putstr("+OK \r\n"); flush(); }
<at> <at> -142,7 +174,7 <at> <at>
remoteip = env_get("TCPREMOTEIP");
if (!remoteip) remoteip = "unknown";
remotehost = env_get("TCPREMOTEHOST");
- if (!remotehost) remotehost = "unknown";
+ if (!remotehost) remotehost = "";
remoteinfo = env_get("TCPREMOTEINFO");
if (!remoteinfo) remoteinfo = "";
user = env_get("USER");
<at> <at> -151,7 +183,7 <at> <at>
if (!stralloc_copys(&logs_pidhostinfo, " pid ")) die_nomem();
strnum[fmt_ulong(strnum,getpid())] = 0;
if (!stralloc_cats(&logs_pidhostinfo, strnum)) die_nomem();
- if (!stralloc_cats(&logs_pidhostinfo, ": ")) die_nomem();
+ if (!stralloc_cats(&logs_pidhostinfo, " ")) die_nomem();
if (!stralloc_cats(&logs_pidhostinfo, remotehost)) die_nomem();
if (!stralloc_cats(&logs_pidhostinfo, ":")) die_nomem();
<at> <at> -197,13 +229,6 <at> <at>
stralloc filenames = {0};
prioq pq = {0};
-struct message {
- int flagdeleted;
- unsigned long size;
- char *fn;
-} *m;
-unsigned int numm;
-
unsigned int last = 0;
void getlist(void)