[Dovecot] pop3 logging patches

Jens Laas jens.laas at data.slu.se
Tue Jun 3 11:14:22 EEST 2003


Following patches will fulfill my need for pop3 logging.

It aint pretty, but it works!

Would you consider including this until you have made this more to your
liking ?

Cheers
Jens Låås

--- pop3/commands.c.orig	2003-05-30 10:34:33.000000000 +0200
+++ pop3/commands.c	2003-06-03 10:05:53.000000000 +0200
@@ -1,5 +1,6 @@
 /* Copyright (C) 2002 Timo Sirainen */

+#include <sys/stat.h>
 #include "common.h"
 #include "istream.h"
 #include "ostream.h"
@@ -139,14 +140,29 @@
 	return TRUE;
 }

+static uoff_t inbox_size(struct client *client)
+{
+  struct stat sb;
+  if(stat(client->mailbox->storage->inbox_file, &sb))
+    return 0;
+  return sb.st_size;
+}
+
 static int cmd_quit(struct client *client, const char *args __attr_unused__)
 {
 	unsigned int first, last, msgnum, max, i, j;
 	struct mail_full_flags flags;
 	string_t *set;
+	uoff_t orig_size;

+	orig_size = inbox_size(client);
+
 	if (!client->deleted) {
 		client_send_line(client, "+OK Logging out.");
+		/* FIXME uoff_t printing */
+		i_info("Logout: del 0/0 left %u/%llu",
+		       client->messages_count,
+		       orig_size);
 		client_disconnect(client);
 		return TRUE;
 	}
@@ -200,6 +216,22 @@
 	else
 		client_send_storage_error(client);

+	{
+	  uoff_t cur_size;
+	  struct mailbox_status status;
+
+	if (client->mailbox->get_status(client->mailbox,
+					 STATUS_MESSAGES | STATUS_UIDVALIDITY,
+					 &status))
+	  {
+	    cur_size = inbox_size(client);
+	    i_info("Logout: del %u/%llu left %u/%llu",
+		   client->messages_count - status.messages,
+		   orig_size - cur_size,
+		   status.messages,
+		   cur_size);
+	  }
+	}
 	client_disconnect(client);
 	return TRUE;
 }


--- pop3-login/client-authenticate.c.orig	2003-05-30 10:32:19.000000000 +0200
+++ pop3-login/client-authenticate.c	2003-05-30 10:33:26.000000000 +0200
@@ -91,7 +91,8 @@
 	const char *reason = NULL;

 	if (success) {
-		reason = t_strconcat("Login: ", client->common.virtual_user,
+		reason = t_strconcat(client->tls?"Login [TLS]:":"Login: ",
+				     client->common.virtual_user,
 				     NULL);
 	} else {
 		reason = t_strconcat("Internal login failure: ",


-----------------------------------------------------------------------
    'This mail automatically becomes portable when carried.'
-----------------------------------------------------------------------
    Jens Låås                              Email: jens.laas at data.slu.se
    Department of Computer Services, SLU   Phone: +46 18 67 35 15
    Vindbrovägen 1
    P.O. Box 7079
    S-750 07 Uppsala
    SWEDEN
-----------------------------------------------------------------------


More information about the dovecot mailing list