* When logging to syslog is enabled, SMTP transactions are now logged to
authorArt Cancro <ajc@citadel.org>
Mon, 31 Oct 2005 04:07:10 +0000 (04:07 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 31 Oct 2005 04:07:10 +0000 (04:07 +0000)
  LOG_MAIL as well as whatever the normal facility is, in a format
  similar to what conventional MTA's use.  Resolves bugzilla issue #153.

citadel/ChangeLog
citadel/serv_smtp.c
citadel/server_main.c
citadel/sysdep.c

index 0e07dd32c26578a0351bd01ccc365f3395289354..0d48eadd8d4c1a9ac82e8dd88f654aaa2a09c130 100644 (file)
@@ -1,5 +1,10 @@
 $Id$
 
+Sun Oct 30 23:03:49 EST 2005 ajc
+* When logging to syslog is enabled, SMTP transactions are now logged to
+  LOG_MAIL as well as whatever the normal facility is, in a format
+  similar to what conventional MTA's use.  Resolves bugzilla issue #153.
+
 Sun Oct 30 22:22:00 EST 2005 ajc
 * syslog messages are now sent to the desired facility rather than always
   going to LOG_DAEMON.  There was a command line parsing bug.
index d460ba611e90729131a253bceca90ea9c7b7c7a4..6d1d3ec0ed4f849d5478f60f87cfe6f5f1f89e8a 100644 (file)
@@ -31,6 +31,7 @@
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
+#include <syslog.h>
 
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>
@@ -780,6 +781,22 @@ void smtp_data(void) {
                cprintf("%s", result);
        }
 
+       /* Write something to the syslog (which may or may not be where the
+        * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
+        */
+       if (enable_syslog) {
+               syslog((LOG_MAIL | LOG_INFO),
+                       "%ld: from=<%s>, nrcpts=%d, relay=%s [%s], stat=%s",
+                       msgnum,
+                       SMTP->from,
+                       SMTP->number_of_recipients,
+                       CC->cs_host,
+                       CC->cs_addr,
+                       result
+               );
+       }
+
+       /* Clean up */
        CtdlFreeMessage(msg);
        free(valid);
        smtp_data_clear();      /* clear out the buffers now */
@@ -1179,6 +1196,20 @@ void smtp_try(const char *key, const char *addr, int *status,
 
 bail:  free(msgtext);
        sock_close(sock);
+
+       /* Write something to the syslog (which may or may not be where the
+        * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
+        */
+       if (enable_syslog) {
+               syslog((LOG_MAIL | LOG_INFO),
+                       "%ld: to=<%s>, relay=%s, stat=%s",
+                       msgnum,
+                       addr,
+                       mx_host,
+                       dsn
+               );
+       }
+
        return;
 }
 
index 6ee7f9b806efdff4b7be05cd102d5a0258096247..a87787f886993b705656a44e588ec606ac1fd8da 100644 (file)
@@ -136,14 +136,17 @@ int main(int argc, char **argv)
                drop_root_perms = 1;
        }
 
-       /* initialize the syslog facility */
+       /* Initialize the syslogger.  Yes, we are really using 0 as the
+        * facility, because we are going to bitwise-OR the facility to
+        * the severity of each message, allowing us to write to other
+        * facilities when we need to...
+        */
        if (enable_syslog) {
                if (running_as_daemon) {
-                       openlog("citadel", LOG_NDELAY, syslog_facility);
+                       openlog("citadel", LOG_NDELAY, 0);
                }
                else {
-                       openlog("citadel", LOG_PERROR|LOG_NDELAY,
-                               syslog_facility);
+                       openlog("citadel", LOG_PERROR|LOG_NDELAY, 0);
                }
                setlogmask(LOG_UPTO(verbosity));
        }
index f2e1c5db913379f84b2e5533743e5a0ee65951a2..77a7d852a9473f50913ce13532de44cb2d09f011 100644 (file)
@@ -109,7 +109,7 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) {
 
        if (enable_syslog) {
                va_start(arg_ptr, format);
-                       vsyslog(loglevel, format, arg_ptr);
+                       vsyslog((syslog_facility | loglevel), format, arg_ptr);
                va_end(arg_ptr);
        }