>   Can someone help me to find logging alternatives to qmail-pop3d and
   >   checkpassword?
   >
   >   Jörgen


On my system, I've added some code to qmail-pop3d.c to make it log
the clients username and IP address to syslog every time a user quits.
Here is the extra code:


/* Add syslog logging
 */
static void log_summary()
{
    #include <syslog.h>

    extern char **environ;
    char **p;
    char *user, *ip;

    /* TCPREMOTEIP is inherited from tcpserver.
     */
    for (p = environ; *p && strncmp(*p, "TCPREMOTEIP=", 12) != 0; ++p);
    ip = (*p) ? (*p + 12) : "0.0.0.0";

    /* USER is inherited from checkpassword.
     * Make sure that USER is not already set when tcpserver starts.
     */
    for (p = environ; *p && strncmp(*p, "USER=", 5) != 0; ++p);
    user = (*p) ? (*p + 5) : "unknown";

    openlog("qmail-pop3d", 0, LOG_MAIL);
    syslog(LOG_INFO, "%s   %s", ip, user);
    closelog();
}

static void log_and_die() { log_summary(); die(); }


....Then substitute log_and_die() for die() in the pop3_quit() function.

-- 
Gjermund Sorseth

Reply via email to