dovecot-2.1: imapc: Added imapc_rawlog_dir setting.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Sep 21 15:58:45 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/87662d9ceff8
changeset: 13535:87662d9ceff8
user: Timo Sirainen <tss at iki.fi>
date: Wed Sep 21 15:58:26 2011 +0300
description:
imapc: Added imapc_rawlog_dir setting.
diffstat:
src/lib-storage/index/imapc/imapc-client.c | 1 +
src/lib-storage/index/imapc/imapc-client.h | 1 +
src/lib-storage/index/imapc/imapc-connection.c | 35 ++++++++++++++++++++++---
src/lib-storage/index/imapc/imapc-settings.c | 6 +++-
src/lib-storage/index/imapc/imapc-settings.h | 2 +
src/lib-storage/index/imapc/imapc-storage.c | 2 +
6 files changed, 41 insertions(+), 6 deletions(-)
diffs (144 lines):
diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-client.c
--- a/src/lib-storage/index/imapc/imapc-client.c Wed Sep 21 15:57:57 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-client.c Wed Sep 21 15:58:26 2011 +0300
@@ -54,6 +54,7 @@
p_strdup(pool, set->dns_client_socket_path);
client->set.temp_path_prefix =
p_strdup(pool, set->temp_path_prefix);
+ client->set.rawlog_dir = p_strdup(pool, set->rawlog_dir);
if (set->ssl_mode != IMAPC_CLIENT_SSL_MODE_NONE) {
client->set.ssl_mode = set->ssl_mode;
diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-client.h
--- a/src/lib-storage/index/imapc/imapc-client.h Wed Sep 21 15:57:57 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-client.h Wed Sep 21 15:58:26 2011 +0300
@@ -45,6 +45,7 @@
enum imapc_client_ssl_mode ssl_mode;
const char *ssl_ca_dir;
+ const char *rawlog_dir;
bool debug;
};
diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-connection.c
--- a/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 21 15:57:57 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 21 15:58:26 2011 +0300
@@ -9,6 +9,7 @@
#include "write-full.h"
#include "str.h"
#include "dns-lookup.h"
+#include "iostream-rawlog.h"
#include "iostream-ssl.h"
#include "imap-quote.h"
#include "imap-util.h"
@@ -70,8 +71,8 @@
int fd;
struct io *io;
- struct istream *input;
- struct ostream *output;
+ struct istream *input, *raw_input;
+ struct ostream *output, *raw_output;
struct imap_parser *parser;
struct timeout *to;
struct timeout *to_output;
@@ -1026,6 +1027,16 @@
if (conn->client->set.debug)
i_debug("imapc(%s): Starting SSL handshake", conn->name);
+ if (conn->raw_input != conn->input) {
+ /* recreate rawlog after STARTTLS */
+ i_stream_ref(conn->raw_input);
+ o_stream_ref(conn->raw_output);
+ i_stream_destroy(&conn->input);
+ o_stream_destroy(&conn->output);
+ conn->input = conn->raw_input;
+ conn->output = conn->raw_output;
+ }
+
source = t_strdup_printf("imapc(%s): ", conn->name);
if (io_stream_create_ssl(conn->client->ssl_ctx, source, &ssl_set,
&conn->input, &conn->output,
@@ -1038,9 +1049,16 @@
imapc_connection_ssl_handshaked,
conn);
if (ssl_iostream_handshake(conn->ssl_iostream) < 0) {
- i_error("imapc(%s): SSL handshake failed", conn->name);
+ i_error("imapc(%s): SSL handshake failed: %s", conn->name,
+ ssl_iostream_get_last_error(conn->ssl_iostream));
return -1;
}
+
+ if (*conn->client->set.rawlog_dir != '\0') {
+ (void)iostream_rawlog_create(conn->client->set.rawlog_dir,
+ &conn->input, &conn->output);
+ }
+
imap_parser_set_streams(conn->parser, conn->input, NULL);
return 0;
}
@@ -1120,8 +1138,15 @@
return;
}
conn->fd = fd;
- conn->input = i_stream_create_fd(fd, (size_t)-1, FALSE);
- conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
+ conn->input = conn->raw_input = i_stream_create_fd(fd, (size_t)-1, FALSE);
+ conn->output = conn->raw_output = o_stream_create_fd(fd, (size_t)-1, FALSE);
+
+ if (*conn->client->set.rawlog_dir != '\0' &&
+ conn->client->set.ssl_mode != IMAPC_CLIENT_SSL_MODE_IMMEDIATE) {
+ (void)iostream_rawlog_create(conn->client->set.rawlog_dir,
+ &conn->input, &conn->output);
+ }
+
o_stream_set_flush_callback(conn->output, imapc_connection_output,
conn);
conn->io = io_add(fd, IO_WRITE, imapc_connection_connected, conn);
diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-settings.c
--- a/src/lib-storage/index/imapc/imapc-settings.c Wed Sep 21 15:57:57 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-settings.c Wed Sep 21 15:58:26 2011 +0300
@@ -23,6 +23,8 @@
DEF(SET_ENUM, imapc_ssl),
DEF(SET_STR, imapc_ssl_ca_dir),
+ DEF(SET_STR, imapc_rawlog_dir),
+
SETTING_DEFINE_LIST_END
};
@@ -34,7 +36,9 @@
.imapc_password = "",
.imapc_ssl = "no:imaps:starttls",
- .imapc_ssl_ca_dir = ""
+ .imapc_ssl_ca_dir = "",
+
+ .imapc_rawlog_dir = ""
};
static const struct setting_parser_info imapc_setting_parser_info = {
diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-settings.h
--- a/src/lib-storage/index/imapc/imapc-settings.h Wed Sep 21 15:57:57 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-settings.h Wed Sep 21 15:58:26 2011 +0300
@@ -10,6 +10,8 @@
const char *imapc_ssl;
const char *imapc_ssl_ca_dir;
+
+ const char *imapc_rawlog_dir;
};
const struct setting_parser_info *imapc_get_setting_parser_info(void);
diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 21 15:57:57 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 21 15:58:26 2011 +0300
@@ -257,6 +257,8 @@
t_strconcat(_storage->user->set->base_dir, "/",
DNS_CLIENT_SOCKET_NAME, NULL);
set.debug = _storage->set->mail_debug;
+ set.rawlog_dir = mail_user_home_expand(_storage->user,
+ storage->set->imapc_rawlog_dir);
str = t_str_new(128);
mail_user_set_get_temp_prefix(str, _storage->user->set);
More information about the dovecot-cvs
mailing list