Now we have a nice mechanism for setting the login debug level, I'd like to
make a minor request: that the 'Connection' and 'Disconnected' messages be
filterable as debug messages.

The reason for this is simple: I have Courier sitting behind a pair of
Foundry serverirons for load balancing and failover, and they poll every
couple of seconds to check the server is still alive, so I get loads of logs
like this:

Nov  5 14:35:12 10.0.0.1 imapd: Connection, ip=[192.0.2.1]
Nov  5 14:35:12 10.0.0.1 pop3d: Connection, ip=[192.0.2.1]
Nov  5 14:35:12 10.0.0.1 pop3d: LOGIN: DEBUG: ip=[192.0.2.1], command=QUIT
Nov  5 14:35:12 10.0.0.1 pop3d: Disconnected, ip=[192.0.2.1]

The third message I can remove (since I currently have DEBUG turned on for
other reasons, and it will be turned off shortly) but that leaves the other
three.

Actually, I think there's another issue here. Shouldn't it be "DEBUG:
LOGIN:" instead of "LOGIN: DEBUG: "? Then courierlogger can be modified to
check for a "DEBUG:" prefix and log at LOG_DEBUG, which seems like it was
the intention but didn't get coded.

In fact, if that were done, then pop3login/imaplogin can simply log
"DEBUG: Connection" instead of "INFO: Connection" and then syslogd can
filter it out.

So basically what I am suggesting is either as attached (note the little
bugfix for ALERT: in logger.c), or else to have
                auth_debug_login( 1, "Connection, ip=[%s]\n", ip );
instead of
                fprintf(stderr, "DEBUG: Connection, ip=[%s]\n", ip);
...etc

since that would be less work to do for syslogd to through them away.

There's also an inconsistency in the logged messages for disconnection in
pop3login.c / imaplogin.c ("Disconnected" versus "LOGOUT"). The attached
patch makes them both say "Disconnected", but could be "QUIT"/"LOGOUT"
instead.

Cheers,

Brian.
diff -uNr courier-imap-1.6.0.20021025.orig/tcpd/logger.c 
courier-imap-1.6.0.20021025/tcpd/logger.c
--- courier-imap-1.6.0.20021025.orig/tcpd/logger.c      Thu Aug 16 02:38:43 2001
+++ courier-imap-1.6.0.20021025/tcpd/logger.c   Tue Nov  5 14:46:53 2002
@@ -67,13 +67,18 @@
                        c=LOG_WARNING;
                        p=buf+5;
                }
-               else if (strncmp(buf, "ALERT:", 5) == 0)
+               else if (strncmp(buf, "ALERT:", 6) == 0)
                {
                        c=LOG_ALERT;
                        p=buf+6;
                }
                else if (strncmp(buf, "INFO:", 5) == 0)
                        p=buf+5;
+               else if (strncmp(buf, "DEBUG:", 6) == 0)
+               {
+                       c=LOG_DEBUG;
+                       p=buf+6;
+               }
                else    p=buf;
 
                while (*p == ' ')
diff -uNr courier-imap-1.6.0.20021025.orig/authlib/debug.c 
courier-imap-1.6.0.20021025/authlib/debug.c
--- courier-imap-1.6.0.20021025.orig/authlib/debug.c    Mon Oct 21 12:27:35 2002
+++ courier-imap-1.6.0.20021025/authlib/debug.c Tue Nov  5 14:47:13 2002
@@ -50,7 +50,7 @@
        if( level > auth_debug_login_level )
                return;
 
-       fprintf( stderr, "LOGIN: DEBUG: ip=[%s], ", getenv("TCPREMOTEIP") );
+       fprintf( stderr, "DEBUG: LOGIN: ip=[%s], ", getenv("TCPREMOTEIP") );
        va_start( ap, fmt );
        auth_debug( fmt, ap );
        va_end( ap );
diff -uNr courier-imap-1.6.0.20021025.orig/imap/pop3login.c 
courier-imap-1.6.0.20021025/imap/pop3login.c
--- courier-imap-1.6.0.20021025.orig/imap/pop3login.c   Tue Oct  1 04:00:15 2002
+++ courier-imap-1.6.0.20021025/imap/pop3login.c        Tue Nov  5 14:47:57 2002
@@ -143,7 +143,7 @@
 
        if (authmoduser(argc, argv, 60, 5))
        {
-               fprintf(stderr, "INFO: Connection, ip=[%s]\n", ip);
+               fprintf(stderr, "DEBUG: Connection, ip=[%s]\n", ip);
                printf("+OK Hello there.\r\n");
        }
        else
@@ -178,7 +178,7 @@
 
                        if ( strcmp(p, "QUIT") == 0)
                        {
-                               fprintf(stderr, "INFO: Disconnected, ip=[%s]\n",
+                               fprintf(stderr, "DEBUG: Disconnected, ip=[%s]\n",
                                        ip);
                                fflush(stderr);
                                printf("+OK Better luck next time.\r\n");
diff -uNr courier-imap-1.6.0.20021025.orig/imap/imaplogin.c 
courier-imap-1.6.0.20021025/imap/imaplogin.c
--- courier-imap-1.6.0.20021025.orig/imap/imaplogin.c   Tue Oct  1 04:00:14 2002
+++ courier-imap-1.6.0.20021025/imap/imaplogin.c        Tue Nov  5 14:49:40 2002
@@ -141,7 +141,7 @@
                writes(tag);
                writes(" OK LOGOUT completed\r\n");
                writeflush();
-               fprintf(stderr, "INFO: LOGOUT, ip=[%s]\n",
+               fprintf(stderr, "DEBUG: Disconnected, ip=[%s]\n",
                        getenv("TCPREMOTEIP"));
                exit(0);
        }
@@ -283,7 +283,7 @@
        if (authmoduser(argc, argv, 60, 5))
        {
                writes("* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, 
Inc.  See COPYING for distribution information.\r\n");
-               fprintf(stderr, "INFO: Connection, ip=[%s]\n", ip);
+               fprintf(stderr, "DEBUG: Connection, ip=[%s]\n", ip);
        }
        else
        {

Reply via email to