changeset 20731:5b1f69b37089

imap, pop3: Added rawlog_dir setting to store IMAP/POP3 traffic logs. This at least partially replaces the "rawlog" post-login binary. For now the "rawlog" binary supports some parameters, which aren't configurable for rawlog_dir.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 13 Sep 2016 07:22:03 +0300
parents a21e038e54c7
children a34a58d690d4
files src/imap/imap-client.c src/imap/imap-settings.c src/imap/imap-settings.h src/pop3/pop3-client.c src/pop3/pop3-settings.c src/pop3/pop3-settings.h
diffstat 6 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-client.c	Fri Sep 09 15:51:43 2016 +0300
+++ b/src/imap/imap-client.c	Tue Sep 13 07:22:03 2016 +0300
@@ -7,6 +7,7 @@
 #include "hostpid.h"
 #include "net.h"
 #include "iostream.h"
+#include "iostream-rawlog.h"
 #include "istream.h"
 #include "ostream.h"
 #include "time-util.h"
@@ -123,6 +124,11 @@
 	client->notify_count_changes = TRUE;
 	client->notify_flag_changes = TRUE;
 
+	if (set->rawlog_dir[0] != '\0') {
+		(void)iostream_rawlog_create(set->rawlog_dir, &client->input,
+					     &client->output);
+	}
+
 	mail_namespaces_set_storage_callbacks(user->namespaces,
 					      &mail_storage_callbacks, client);
 
--- a/src/imap/imap-settings.c	Fri Sep 09 15:51:43 2016 +0300
+++ b/src/imap/imap-settings.c	Tue Sep 13 07:22:03 2016 +0300
@@ -63,6 +63,7 @@
 
 static const struct setting_define imap_setting_defines[] = {
 	DEF(SET_BOOL, verbose_proctitle),
+	DEF(SET_STR_VARS, rawlog_dir),
 
 	DEF(SET_SIZE, imap_max_line_length),
 	DEF(SET_TIME, imap_idle_notify_interval),
@@ -82,6 +83,7 @@
 
 static const struct imap_settings imap_default_settings = {
 	.verbose_proctitle = FALSE,
+	.rawlog_dir = "",
 
 	/* RFC-2683 recommends at least 8000 bytes. Some clients however don't
 	   break large message sets to multiple commands, so we're pretty
--- a/src/imap/imap-settings.h	Fri Sep 09 15:51:43 2016 +0300
+++ b/src/imap/imap-settings.h	Tue Sep 13 07:22:03 2016 +0300
@@ -15,6 +15,7 @@
 
 struct imap_settings {
 	bool verbose_proctitle;
+	const char *rawlog_dir;
 
 	/* imap: */
 	uoff_t imap_max_line_length;
--- a/src/pop3/pop3-client.c	Fri Sep 09 15:51:43 2016 +0300
+++ b/src/pop3/pop3-client.c	Tue Sep 13 07:22:03 2016 +0300
@@ -7,6 +7,7 @@
 #include "iostream.h"
 #include "istream.h"
 #include "ostream.h"
+#include "iostream-rawlog.h"
 #include "crc32.h"
 #include "str.h"
 #include "llist.h"
@@ -400,6 +401,11 @@
 	o_stream_set_no_error_handling(client->output, TRUE);
 	o_stream_set_flush_callback(client->output, client_output, client);
 
+	if (set->rawlog_dir[0] != '\0') {
+		(void)iostream_rawlog_create(set->rawlog_dir, &client->input,
+					     &client->output);
+	}
+
 	p_array_init(&client->module_contexts, client->pool, 5);
 	client->io = io_add_istream(client->input, client_input, client);
         client->last_input = ioloop_time;
--- a/src/pop3/pop3-settings.c	Fri Sep 09 15:51:43 2016 +0300
+++ b/src/pop3/pop3-settings.c	Tue Sep 13 07:22:03 2016 +0300
@@ -60,6 +60,7 @@
 
 static const struct setting_define pop3_setting_defines[] = {
 	DEF(SET_BOOL, verbose_proctitle),
+	DEF(SET_STR_VARS, rawlog_dir),
 
 	DEF(SET_BOOL, pop3_no_flag_updates),
 	DEF(SET_BOOL, pop3_enable_last),
@@ -78,6 +79,7 @@
 
 static const struct pop3_settings pop3_default_settings = {
 	.verbose_proctitle = FALSE,
+	.rawlog_dir = "",
 
 	.pop3_no_flag_updates = FALSE,
 	.pop3_enable_last = FALSE,
--- a/src/pop3/pop3-settings.h	Fri Sep 09 15:51:43 2016 +0300
+++ b/src/pop3/pop3-settings.h	Tue Sep 13 07:22:03 2016 +0300
@@ -16,6 +16,7 @@
 
 struct pop3_settings {
 	bool verbose_proctitle;
+	const char *rawlog_dir;
 
 	/* pop3: */
 	bool pop3_no_flag_updates;