From dovecot at dovecot.org Fri Feb 1 01:03:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 01 Feb 2013 01:03:15 +0200 Subject: dovecot-2.2: auth: first/last_valid_uid settings shouldn't have ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/18661d1d6ed0 changeset: 15709:18661d1d6ed0 user: Timo Sirainen date: Fri Feb 01 01:03:05 2013 +0200 description: auth: first/last_valid_uid settings shouldn't have had auth_ prefix. diffstat: src/auth/auth-settings.c | 10 +++++----- src/auth/auth-settings.h | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diffs (68 lines): diff -r 4a59737dd2ca -r 18661d1d6ed0 src/auth/auth-settings.c --- a/src/auth/auth-settings.c Thu Jan 31 22:59:13 2013 +0200 +++ b/src/auth/auth-settings.c Fri Feb 01 01:03:05 2013 +0200 @@ -210,8 +210,6 @@ DEF(SET_STR, winbind_helper_path), DEF(SET_STR, proxy_self), DEF(SET_TIME, failure_delay), - DEF(SET_UINT, first_valid_uid), - DEF(SET_UINT, last_valid_uid), DEF(SET_BOOL, verbose), DEF(SET_BOOL, debug), @@ -228,6 +226,8 @@ DEF_NOPREFIX(SET_STR, base_dir), DEF_NOPREFIX(SET_BOOL, verbose_proctitle), + DEF_NOPREFIX(SET_UINT, first_valid_uid), + DEF_NOPREFIX(SET_UINT, last_valid_uid), SETTING_DEFINE_LIST_END }; @@ -249,8 +249,6 @@ .winbind_helper_path = "/usr/bin/ntlm_auth", .proxy_self = "", .failure_delay = 2, - .first_valid_uid = 500, - .last_valid_uid = 0, .verbose = FALSE, .debug = FALSE, @@ -266,7 +264,9 @@ .userdbs = ARRAY_INIT, .base_dir = PKG_RUNDIR, - .verbose_proctitle = FALSE + .verbose_proctitle = FALSE, + .first_valid_uid = 500, + .last_valid_uid = 0, }; const struct setting_parser_info auth_setting_parser_info = { diff -r 4a59737dd2ca -r 18661d1d6ed0 src/auth/auth-settings.h --- a/src/auth/auth-settings.h Thu Jan 31 22:59:13 2013 +0200 +++ b/src/auth/auth-settings.h Fri Feb 01 01:03:05 2013 +0200 @@ -42,8 +42,6 @@ const char *winbind_helper_path; const char *proxy_self; unsigned int failure_delay; - unsigned int first_valid_uid; - unsigned int last_valid_uid; bool verbose, debug, debug_passwords; const char *verbose_passwords; @@ -53,11 +51,14 @@ unsigned int worker_max_count; + /* settings that don't have auth_ prefix: */ ARRAY(struct auth_passdb_settings *) passdbs; ARRAY(struct auth_userdb_settings *) userdbs; const char *base_dir; bool verbose_proctitle; + unsigned int first_valid_uid; + unsigned int last_valid_uid; /* generated: */ char username_chars_map[256]; From dovecot at dovecot.org Fri Feb 1 01:40:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 01 Feb 2013 01:40:12 +0200 Subject: dovecot-2.2: lib-http: Various bugfixes Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c5230b8ffd40 changeset: 15710:c5230b8ffd40 user: Stephan Bosch date: Fri Feb 01 01:39:41 2013 +0200 description: lib-http: Various bugfixes diffstat: src/lib-http/http-client-connection.c | 70 ++++++++++++++------ src/lib-http/http-client-host.c | 4 +- src/lib-http/http-client-peer.c | 18 ++++- src/lib-http/http-client-private.h | 7 +- src/lib-http/http-client-request.c | 113 ++++++++++++++++++++++++++++++--- src/lib-http/http-client.c | 10 +- src/lib-http/http-client.h | 8 ++ src/lib-http/test-http-client.c | 46 +++++++++++-- 8 files changed, 228 insertions(+), 48 deletions(-) diffs (truncated from 643 to 300 lines): diff -r 18661d1d6ed0 -r c5230b8ffd40 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Fri Feb 01 01:03:05 2013 +0200 +++ b/src/lib-http/http-client-connection.c Fri Feb 01 01:39:41 2013 +0200 @@ -66,6 +66,11 @@ conn->client->set.max_pipelined_requests); } +bool http_client_connection_is_idle(struct http_client_connection *conn) +{ + return (conn->to_idle != NULL); +} + static void http_client_connection_retry_requests(struct http_client_connection *conn, unsigned int status, const char *error) @@ -92,13 +97,14 @@ array_foreach_modifiable(&conn->request_wait_list, req) { http_client_request_resubmit(*req); + http_client_request_unref(req); } array_clear(&conn->request_wait_list); if (conn->client->ioloop != NULL) io_loop_stop(conn->client->ioloop); - http_client_connection_free(_conn); + http_client_connection_unref(_conn); } static void @@ -111,7 +117,7 @@ conn->closing = TRUE; http_client_connection_retry_requests(conn, status, error); - http_client_connection_free(_conn); + http_client_connection_unref(_conn); } static void @@ -128,7 +134,7 @@ http_client_request_error(*req, status, error); } array_clear(&conn->request_wait_list); - http_client_connection_free(_conn); + http_client_connection_unref(_conn); } static void @@ -136,7 +142,7 @@ { http_client_connection_debug(conn, "Idle connection timed out"); - http_client_connection_free(&conn); + http_client_connection_unref(&conn); } static void @@ -153,9 +159,6 @@ return; } - http_client_connection_debug(conn, - "No more requests queued; going idle"); - if (conn->client->ioloop != NULL) io_loop_stop(conn->client->ioloop); @@ -167,13 +170,20 @@ /* instant death for (urgent) connections above limit */ timeout = 0; } else { + unsigned int idle_count = http_client_peer_idle_connections(conn->peer); + /* kill duplicate connections quicker; linearly based on the number of connections */ - timeout = (conn->client->set.max_parallel_connections - count) * + i_assert(count >= idle_count + 1); + timeout = (conn->client->set.max_parallel_connections - idle_count) * (conn->client->set.max_idle_time_msecs / conn->client->set.max_parallel_connections); } + http_client_connection_debug(conn, + "No more requests queued; going idle (timeout = %u msecs)", + timeout); + conn->to_idle = timeout_add(timeout, http_client_connection_idle_timeout, conn); @@ -199,7 +209,6 @@ req_idx = array_idx(&conn->request_wait_list, 0); req = req_idx[0]; - // FIXME: we should mark this in the peer object for next requests conn->payload_continue = TRUE; if (http_client_request_send_more(req) < 0) { http_client_connection_abort_temp_error(&conn, @@ -236,6 +245,9 @@ array_append(&conn->request_wait_list, &req, 1); http_client_request_ref(req); + http_client_connection_debug(conn, "Claimed request %s", + http_client_request_label(req)); + if (http_client_request_send(req) < 0) { http_client_connection_abort_temp_error(&conn, HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST, @@ -255,7 +267,7 @@ period before sending the payload body. */ if (req->payload_sync) { - i_assert(req->payload_size > 0); + i_assert(req->payload_chunked || req->payload_size > 0); i_assert(conn->to_response == NULL); conn->to_response = timeout_add(HTTP_CLIENT_CONTINUE_TIMEOUT_MSECS, http_client_connection_continue_timeout, conn); @@ -284,7 +296,7 @@ break; } - http_client_connection_free(&conn); + http_client_connection_unref(&conn); } static void http_client_payload_finished(struct http_client_connection *conn) @@ -425,7 +437,7 @@ if (req == NULL) { /* server sent response without any requests in the wait list */ http_client_connection_error(conn, "Got unexpected input from server"); - http_client_connection_free(&conn); + http_client_connection_unref(&conn); return; } @@ -433,10 +445,6 @@ if (conn->to_response != NULL) timeout_remove(&conn->to_response); - /* Got some response; cancel response timeout */ - if (conn->to_response != NULL) - timeout_remove(&conn->to_response); - /* https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21 Section 7.2: @@ -459,8 +467,11 @@ /* ignore them for now */ http_client_connection_debug(conn, "Got unexpected %u response; ignoring", response->status); + /* restart timeout */ + conn->to_response = timeout_add(HTTP_CLIENT_CONTINUE_TIMEOUT_MSECS, + http_client_connection_continue_timeout, conn); continue; - } // FIXME: handle 417 Expectation Failed + } http_client_connection_debug(conn, "Got %u response for request %s", @@ -474,7 +485,13 @@ conn->close_indicated = response->connection_close; if (!aborted) { - if (response->status / 100 == 3) { + if (response->status == 417 && req->payload_sync) { + /* drop Expect: continue */ + req->payload_sync = FALSE; + conn->peer->no_payload_sync = TRUE; + http_client_request_retry(req, response->status, response->reason); + return; + } else if (response->status / 100 == 3) { /* redirect */ http_client_request_redirect(req, response->status, response->location); } else { @@ -568,7 +585,7 @@ conn->connected = TRUE; - if (*conn->client->set.rawlog_dir != '\0' && + if (conn->client->set.rawlog_dir != NULL && stat(conn->client->set.rawlog_dir, &st) == 0) { iostream_rawlog_create(conn->client->set.rawlog_dir, &conn->conn.input, &conn->conn.output); @@ -716,6 +733,7 @@ static unsigned int id = 0; conn = i_new(struct http_client_connection, 1); + conn->refcount = 1; conn->client = peer->client; conn->peer = peer; i_array_init(&conn->request_wait_list, 16); @@ -724,7 +742,7 @@ (peer->client->conn_list, &conn->conn, &peer->addr.ip, peer->addr.port); if (http_client_connection_connect(conn) < 0) { - http_client_connection_free(&conn); + http_client_connection_unref(&conn); return NULL; } @@ -737,13 +755,23 @@ return conn; } -void http_client_connection_free(struct http_client_connection **_conn) +void http_client_connection_ref(struct http_client_connection *conn) +{ + conn->refcount++; +} + +void http_client_connection_unref(struct http_client_connection **_conn) { struct http_client_connection *conn = *_conn; struct http_client_connection *const *conn_idx; struct http_client_peer *peer = conn->peer; struct http_client_request **req; + i_assert(conn->refcount > 0); + + if (--conn->refcount > 0) + return; + http_client_connection_debug(conn, "Connection destroy"); conn->connected = FALSE; diff -r 18661d1d6ed0 -r c5230b8ffd40 src/lib-http/http-client-host.c --- a/src/lib-http/http-client-host.c Fri Feb 01 01:03:05 2013 +0200 +++ b/src/lib-http/http-client-host.c Fri Feb 01 01:39:41 2013 +0200 @@ -236,7 +236,7 @@ host->ips_count = 1; host->ips = i_new(struct ip_addr, host->ips_count); host->ips[0] = ip; - } else if (*dns_set.dns_client_socket_path == '\0') { + } else if (dns_set.dns_client_socket_path == NULL) { ret = net_gethostbyname(host->name, &ips, &ips_count); if (ret != 0) { i_error("http-client: net_gethostbyname(%s) failed: %s", @@ -327,7 +327,7 @@ } http_client_host_debug(host, - "Connection %s:%u claimed request %s %s", + "Connection to peer %s:%u claimed request %s %s", net_ip2addr(&addr->ip), addr->port, http_client_request_label(req), (req->urgent ? "(urgent)" : "")); diff -r 18661d1d6ed0 -r c5230b8ffd40 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Fri Feb 01 01:03:05 2013 +0200 +++ b/src/lib-http/http-client-peer.c Fri Feb 01 01:39:41 2013 +0200 @@ -257,7 +257,7 @@ array_copy(&conns.arr, 0, &peer->conns.arr, 0, array_count(&peer->conns)); array_foreach_modifiable(&conns, conn) { - http_client_connection_free(conn); + http_client_connection_unref(conn); } i_assert(array_count(&peer->conns) == 0); @@ -343,7 +343,7 @@ if (peer->destroyed) return; - http_client_peer_debug(peer, "Lost connection (%d connections left)", + http_client_peer_debug(peer, "Lost a connection (%d connections left)", array_count(&peer->conns)); if (array_count(&peer->conns) == 0) { @@ -356,3 +356,17 @@ } } +unsigned int http_client_peer_idle_connections(struct http_client_peer *peer) +{ + struct http_client_connection *const *conn_idx; + unsigned int idle = 0; + + /* find the least busy connection */ + array_foreach(&peer->conns, conn_idx) { + if (http_client_connection_is_idle(*conn_idx)) + idle++; + } + + return idle; +} + diff -r 18661d1d6ed0 -r c5230b8ffd40 src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Fri Feb 01 01:03:05 2013 +0200 +++ b/src/lib-http/http-client-private.h Fri Feb 01 01:39:41 2013 +0200 @@ -70,6 +70,7 @@ unsigned int payload_sync:1; unsigned int payload_chunked:1; + unsigned int payload_wait:1; unsigned int ssl:1; unsigned int urgent:1; }; @@ -133,6 +134,7 @@ struct connection conn; struct http_client_peer *peer; struct http_client *client; From dovecot at dovecot.org Fri Feb 1 02:19:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 01 Feb 2013 02:19:10 +0200 Subject: dovecot-2.2: fts-solr: Free the solr_connection at exit. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e62a7ca7d1f2 changeset: 15711:e62a7ca7d1f2 user: Timo Sirainen date: Fri Feb 01 02:18:54 2013 +0200 description: fts-solr: Free the solr_connection at exit. diffstat: src/plugins/fts-solr/fts-backend-solr-old.c | 9 ++++++++- src/plugins/fts-solr/fts-backend-solr.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diffs (54 lines): diff -r c5230b8ffd40 -r e62a7ca7d1f2 src/plugins/fts-solr/fts-backend-solr-old.c --- a/src/plugins/fts-solr/fts-backend-solr-old.c Fri Feb 01 01:39:41 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr-old.c Fri Feb 01 02:18:54 2013 +0200 @@ -225,6 +225,11 @@ return &backend->backend; } +static void fts_backend_solr_connection_deinit(void) +{ + solr_connection_deinit(solr_conn); +} + static int fts_backend_solr_init(struct fts_backend *_backend, const char **error_r ATTR_UNUSED) @@ -234,8 +239,10 @@ const struct fts_solr_settings *set = &fuser->set; const char *str; - if (solr_conn == NULL) + if (solr_conn == NULL) { solr_conn = solr_connection_init(set->url, set->debug); + lib_atexit(fts_backend_solr_connection_deinit); + } str = solr_escape_id_str(_backend->ns->user->username); backend->id_username = i_strdup(str); diff -r c5230b8ffd40 -r e62a7ca7d1f2 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 01 01:39:41 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 01 02:18:54 2013 +0200 @@ -150,6 +150,11 @@ return &backend->backend; } +static void fts_backend_solr_connection_deinit(void) +{ + solr_connection_deinit(solr_conn); +} + static int fts_backend_solr_init(struct fts_backend *_backend, const char **error_r ATTR_UNUSED) @@ -157,8 +162,10 @@ struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(_backend->ns->user); const struct fts_solr_settings *set = &fuser->set; - if (solr_conn == NULL) + if (solr_conn == NULL) { solr_conn = solr_connection_init(set->url, set->debug); + lib_atexit(fts_backend_solr_connection_deinit); + } return 0; } From dovecot at dovecot.org Fri Feb 1 02:25:29 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 01 Feb 2013 02:25:29 +0200 Subject: dovecot-2.2: fts-solr: Reverted previous change, it only crashes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/78bdcb6642c7 changeset: 15712:78bdcb6642c7 user: Timo Sirainen date: Fri Feb 01 02:25:18 2013 +0200 description: fts-solr: Reverted previous change, it only crashes. The plugin is already unloaded at lib_atexit() time. diffstat: src/plugins/fts-solr/fts-backend-solr-old.c | 9 +-------- src/plugins/fts-solr/fts-backend-solr.c | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diffs (54 lines): diff -r e62a7ca7d1f2 -r 78bdcb6642c7 src/plugins/fts-solr/fts-backend-solr-old.c --- a/src/plugins/fts-solr/fts-backend-solr-old.c Fri Feb 01 02:18:54 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr-old.c Fri Feb 01 02:25:18 2013 +0200 @@ -225,11 +225,6 @@ return &backend->backend; } -static void fts_backend_solr_connection_deinit(void) -{ - solr_connection_deinit(solr_conn); -} - static int fts_backend_solr_init(struct fts_backend *_backend, const char **error_r ATTR_UNUSED) @@ -239,10 +234,8 @@ const struct fts_solr_settings *set = &fuser->set; const char *str; - if (solr_conn == NULL) { + if (solr_conn == NULL) solr_conn = solr_connection_init(set->url, set->debug); - lib_atexit(fts_backend_solr_connection_deinit); - } str = solr_escape_id_str(_backend->ns->user->username); backend->id_username = i_strdup(str); diff -r e62a7ca7d1f2 -r 78bdcb6642c7 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 01 02:18:54 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 01 02:25:18 2013 +0200 @@ -150,11 +150,6 @@ return &backend->backend; } -static void fts_backend_solr_connection_deinit(void) -{ - solr_connection_deinit(solr_conn); -} - static int fts_backend_solr_init(struct fts_backend *_backend, const char **error_r ATTR_UNUSED) @@ -162,10 +157,8 @@ struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(_backend->ns->user); const struct fts_solr_settings *set = &fuser->set; - if (solr_conn == NULL) { + if (solr_conn == NULL) solr_conn = solr_connection_init(set->url, set->debug); - lib_atexit(fts_backend_solr_connection_deinit); - } return 0; } From dovecot at dovecot.org Sat Feb 2 00:31:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 02 Feb 2013 00:31:58 +0200 Subject: dovecot-2.1: dbox: Fail if trying to create a mailbox that alrea... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/004b69090776 changeset: 14892:004b69090776 user: Timo Sirainen date: Sat Feb 02 00:31:44 2013 +0200 description: dbox: Fail if trying to create a mailbox that already exists. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (16 lines): diff -r bf80034a547d -r 004b69090776 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Thu Jan 31 18:27:22 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Sat Feb 02 00:31:44 2013 +0200 @@ -254,6 +254,12 @@ if (mailbox_open(box) < 0) return -1; + if (mail_index_get_header(box->view)->uid_validity != 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "Mailbox already exists"); + return -1; + } + /* if alt path already exists and contains files, rebuild storage so that we don't start overwriting files. */ alt_path = mailbox_list_get_path(box->list, box->name, From dovecot at dovecot.org Sat Feb 2 16:52:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 02 Feb 2013 16:52:35 +0200 Subject: dovecot-2.2: fts-solr: Deinit solr connection at plugin unload. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1b671d03474d changeset: 15713:1b671d03474d user: Timo Sirainen date: Sat Feb 02 16:52:23 2013 +0200 description: fts-solr: Deinit solr connection at plugin unload. diffstat: src/plugins/fts-solr/fts-backend-solr-old.c | 2 -- src/plugins/fts-solr/fts-backend-solr.c | 2 -- src/plugins/fts-solr/fts-solr-plugin.c | 4 ++++ src/plugins/fts-solr/fts-solr-plugin.h | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diffs (56 lines): diff -r 78bdcb6642c7 -r 1b671d03474d src/plugins/fts-solr/fts-backend-solr-old.c --- a/src/plugins/fts-solr/fts-backend-solr-old.c Fri Feb 01 02:25:18 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr-old.c Sat Feb 02 16:52:23 2013 +0200 @@ -40,8 +40,6 @@ bool documents_added; }; -static struct solr_connection *solr_conn = NULL; - static bool is_valid_xml_char(unichar_t chr) { /* Valid characters in XML: diff -r 78bdcb6642c7 -r 1b671d03474d src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 01 02:25:18 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr.c Sat Feb 02 16:52:23 2013 +0200 @@ -50,8 +50,6 @@ unsigned int expunges:1; }; -static struct solr_connection *solr_conn = NULL; - static bool is_valid_xml_char(unichar_t chr) { /* Valid characters in XML: diff -r 78bdcb6642c7 -r 1b671d03474d src/plugins/fts-solr/fts-solr-plugin.c --- a/src/plugins/fts-solr/fts-solr-plugin.c Fri Feb 01 02:25:18 2013 +0200 +++ b/src/plugins/fts-solr/fts-solr-plugin.c Sat Feb 02 16:52:23 2013 +0200 @@ -9,6 +9,7 @@ #include const char *fts_solr_plugin_version = DOVECOT_ABI_VERSION; +struct solr_connection *solr_conn = NULL; struct fts_solr_user_module fts_solr_user_module = MODULE_CONTEXT_INIT(&mail_user_module_register); @@ -82,6 +83,9 @@ fts_backend_unregister(fts_backend_solr.name); fts_backend_unregister(fts_backend_solr_old.name); mail_storage_hooks_remove(&fts_solr_mail_storage_hooks); + if (solr_conn != NULL) + solr_connection_deinit(solr_conn); + } const char *fts_solr_plugin_dependencies[] = { "fts", NULL }; diff -r 78bdcb6642c7 -r 1b671d03474d src/plugins/fts-solr/fts-solr-plugin.h --- a/src/plugins/fts-solr/fts-solr-plugin.h Fri Feb 01 02:25:18 2013 +0200 +++ b/src/plugins/fts-solr/fts-solr-plugin.h Sat Feb 02 16:52:23 2013 +0200 @@ -21,6 +21,7 @@ extern struct fts_backend fts_backend_solr; extern struct fts_backend fts_backend_solr_old; extern MODULE_CONTEXT_DEFINE(fts_solr_user_module, &mail_user_module_register); +extern struct solr_connection *solr_conn; void fts_solr_plugin_init(struct module *module); void fts_solr_plugin_deinit(void); From dovecot at dovecot.org Sat Feb 2 17:01:28 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 02 Feb 2013 17:01:28 +0200 Subject: dovecot-2.2: Updated copyright notices to include year 2013. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/90710c6c3beb changeset: 15714:90710c6c3beb user: Timo Sirainen date: Sat Feb 02 17:01:07 2013 +0200 description: Updated copyright notices to include year 2013. diffstat: src/anvil/anvil-connection.c | 2 +- src/anvil/anvil-settings.c | 2 +- src/anvil/connect-limit.c | 2 +- src/anvil/main.c | 2 +- src/anvil/penalty.c | 2 +- src/anvil/test-penalty.c | 2 +- src/auth/auth-cache.c | 2 +- src/auth/auth-client-connection.c | 2 +- src/auth/auth-fields.c | 2 +- src/auth/auth-master-connection.c | 2 +- src/auth/auth-penalty.c | 2 +- src/auth/auth-postfix-connection.c | 2 +- src/auth/auth-request-handler.c | 2 +- src/auth/auth-request.c | 2 +- src/auth/auth-settings.c | 2 +- src/auth/auth-token.c | 2 +- src/auth/auth-worker-client.c | 2 +- src/auth/auth-worker-server.c | 2 +- src/auth/auth.c | 2 +- src/auth/db-checkpassword.c | 2 +- src/auth/db-dict.c | 2 +- src/auth/db-ldap.c | 2 +- src/auth/db-passwd-file.c | 2 +- src/auth/db-sql.c | 2 +- src/auth/main.c | 2 +- src/auth/mech-anonymous.c | 2 +- src/auth/mech-cram-md5.c | 2 +- src/auth/mech-digest-md5.c | 2 +- src/auth/mech-dovecot-token.c | 2 +- src/auth/mech-external.c | 2 +- src/auth/mech-plain.c | 2 +- src/auth/mech.c | 2 +- src/auth/passdb-blocking.c | 2 +- src/auth/passdb-bsdauth.c | 2 +- src/auth/passdb-cache.c | 2 +- src/auth/passdb-checkpassword.c | 2 +- src/auth/passdb-dict.c | 2 +- src/auth/passdb-imap.c | 2 +- src/auth/passdb-ldap.c | 2 +- src/auth/passdb-passwd-file.c | 2 +- src/auth/passdb-passwd.c | 2 +- src/auth/passdb-shadow.c | 2 +- src/auth/passdb-sql.c | 2 +- src/auth/passdb-static.c | 2 +- src/auth/passdb-template.c | 2 +- src/auth/passdb-vpopmail.c | 2 +- src/auth/passdb.c | 2 +- src/auth/password-scheme-crypt.c | 2 +- src/auth/password-scheme.c | 2 +- src/auth/test-auth-cache.c | 2 +- src/auth/userdb-blocking.c | 2 +- src/auth/userdb-checkpassword.c | 2 +- src/auth/userdb-dict.c | 2 +- src/auth/userdb-ldap.c | 2 +- src/auth/userdb-nss.c | 2 +- src/auth/userdb-passwd-file.c | 2 +- src/auth/userdb-passwd.c | 2 +- src/auth/userdb-prefetch.c | 2 +- src/auth/userdb-sql.c | 2 +- src/auth/userdb-static.c | 2 +- src/auth/userdb-template.c | 2 +- src/auth/userdb-vpopmail.c | 2 +- src/auth/userdb.c | 2 +- src/config/config-connection.c | 2 +- src/config/config-filter.c | 2 +- src/config/config-parser.c | 2 +- src/config/config-request.c | 2 +- src/config/config-settings.c | 2 +- src/config/doveconf.c | 2 +- src/config/main.c | 2 +- src/config/old-set-parser.c | 2 +- src/config/sysinfo-get.c | 2 +- src/dict/dict-commands.c | 2 +- src/dict/dict-connection.c | 2 +- src/dict/dict-settings.c | 2 +- src/dict/main.c | 2 +- src/director/auth-connection.c | 2 +- src/director/director-connection.c | 2 +- src/director/director-host.c | 2 +- src/director/director-request.c | 2 +- src/director/director-settings.c | 2 +- src/director/director-test.c | 2 +- src/director/director.c | 2 +- src/director/doveadm-connection.c | 2 +- src/director/login-connection.c | 2 +- src/director/mail-host.c | 2 +- src/director/main.c | 2 +- src/director/notify-connection.c | 2 +- src/director/test-user-directory.c | 2 +- src/director/user-directory.c | 2 +- src/dns/dns-client-settings.c | 2 +- src/dns/dns-client.c | 2 +- src/doveadm/client-connection.c | 2 +- src/doveadm/doveadm-auth.c | 2 +- src/doveadm/doveadm-director.c | 2 +- src/doveadm/doveadm-dump-dbox.c | 2 +- src/doveadm/doveadm-dump-index.c | 2 +- src/doveadm/doveadm-dump-log.c | 2 +- src/doveadm/doveadm-dump-mailboxlog.c | 2 +- src/doveadm/doveadm-dump-thread.c | 2 +- src/doveadm/doveadm-dump.c | 2 +- src/doveadm/doveadm-instance.c | 2 +- src/doveadm/doveadm-kick.c | 2 +- src/doveadm/doveadm-log.c | 2 +- src/doveadm/doveadm-mail-altmove.c | 2 +- src/doveadm/doveadm-mail-copymove.c | 2 +- src/doveadm/doveadm-mail-expunge.c | 2 +- src/doveadm/doveadm-mail-fetch.c | 2 +- src/doveadm/doveadm-mail-import.c | 2 +- src/doveadm/doveadm-mail-index.c | 2 +- src/doveadm/doveadm-mail-iter.c | 2 +- src/doveadm/doveadm-mail-mailbox-status.c | 2 +- src/doveadm/doveadm-mail-mailbox.c | 2 +- src/doveadm/doveadm-mail-search.c | 2 +- src/doveadm/doveadm-mail-server.c | 2 +- src/doveadm/doveadm-mail.c | 2 +- src/doveadm/doveadm-mailbox-list-iter.c | 2 +- src/doveadm/doveadm-master.c | 2 +- src/doveadm/doveadm-mount.c | 2 +- src/doveadm/doveadm-mutf7.c | 2 +- src/doveadm/doveadm-penalty.c | 2 +- src/doveadm/doveadm-print-flow.c | 2 +- src/doveadm/doveadm-print-pager.c | 2 +- src/doveadm/doveadm-print-server.c | 2 +- src/doveadm/doveadm-print-tab.c | 2 +- src/doveadm/doveadm-print-table.c | 2 +- src/doveadm/doveadm-print.c | 2 +- src/doveadm/doveadm-proxy.c | 2 +- src/doveadm/doveadm-pw.c | 2 +- src/doveadm/doveadm-settings.c | 2 +- src/doveadm/doveadm-sis.c | 2 +- src/doveadm/doveadm-stats.c | 2 +- src/doveadm/doveadm-util.c | 2 +- src/doveadm/doveadm-who.c | 2 +- src/doveadm/doveadm-zlib.c | 2 +- src/doveadm/doveadm.c | 2 +- src/doveadm/dsync/doveadm-dsync.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox-tree.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox.c | 2 +- src/doveadm/dsync/dsync-brain-mails.c | 2 +- src/doveadm/dsync/dsync-brain.c | 2 +- src/doveadm/dsync/dsync-deserializer.c | 2 +- src/doveadm/dsync/dsync-ibc-pipe.c | 2 +- src/doveadm/dsync/dsync-ibc-stream.c | 2 +- src/doveadm/dsync/dsync-ibc.c | 2 +- src/doveadm/dsync/dsync-mail.c | 2 +- src/doveadm/dsync/dsync-mailbox-export.c | 2 +- src/doveadm/dsync/dsync-mailbox-import.c | 2 +- src/doveadm/dsync/dsync-mailbox-state.c | 2 +- src/doveadm/dsync/dsync-mailbox-tree-fill.c | 2 +- src/doveadm/dsync/dsync-mailbox-tree-sync.c | 2 +- src/doveadm/dsync/dsync-mailbox-tree.c | 2 +- src/doveadm/dsync/dsync-serializer.c | 2 +- src/doveadm/dsync/dsync-transaction-log-scan.c | 2 +- src/doveadm/dsync/test-dsync-mailbox-tree-sync.c | 2 +- src/doveadm/main.c | 2 +- src/doveadm/server-connection.c | 2 +- src/imap-login/client-authenticate.c | 2 +- src/imap-login/client.c | 2 +- src/imap-login/imap-login-settings.c | 2 +- src/imap-login/imap-proxy.c | 2 +- src/imap-urlauth/imap-urlauth-client.c | 2 +- src/imap-urlauth/imap-urlauth-login-settings.c | 2 +- src/imap-urlauth/imap-urlauth-login.c | 2 +- src/imap-urlauth/imap-urlauth-settings.c | 2 +- src/imap-urlauth/imap-urlauth-worker-settings.c | 2 +- src/imap-urlauth/imap-urlauth-worker.c | 2 +- src/imap-urlauth/imap-urlauth.c | 2 +- src/imap/cmd-append.c | 2 +- src/imap/cmd-cancelupdate.c | 2 +- src/imap/cmd-capability.c | 2 +- src/imap/cmd-check.c | 2 +- src/imap/cmd-close.c | 2 +- src/imap/cmd-copy.c | 2 +- src/imap/cmd-create.c | 2 +- src/imap/cmd-delete.c | 2 +- src/imap/cmd-enable.c | 2 +- src/imap/cmd-examine.c | 2 +- src/imap/cmd-expunge.c | 2 +- src/imap/cmd-fetch.c | 2 +- src/imap/cmd-genurlauth.c | 2 +- src/imap/cmd-id.c | 2 +- src/imap/cmd-idle.c | 2 +- src/imap/cmd-list.c | 2 +- src/imap/cmd-logout.c | 2 +- src/imap/cmd-lsub.c | 2 +- src/imap/cmd-namespace.c | 2 +- src/imap/cmd-noop.c | 2 +- src/imap/cmd-notify.c | 2 +- src/imap/cmd-rename.c | 2 +- src/imap/cmd-resetkey.c | 2 +- src/imap/cmd-search.c | 2 +- src/imap/cmd-select.c | 2 +- src/imap/cmd-sort.c | 2 +- src/imap/cmd-status.c | 2 +- src/imap/cmd-store.c | 2 +- src/imap/cmd-subscribe.c | 2 +- src/imap/cmd-thread.c | 2 +- src/imap/cmd-uid.c | 2 +- src/imap/cmd-unselect.c | 2 +- src/imap/cmd-unsubscribe.c | 2 +- src/imap/cmd-urlfetch.c | 2 +- src/imap/cmd-x-cancel.c | 2 +- src/imap/imap-client.c | 2 +- src/imap/imap-commands-util.c | 2 +- src/imap/imap-commands.c | 2 +- src/imap/imap-expunge.c | 2 +- src/imap/imap-fetch-body.c | 2 +- src/imap/imap-fetch.c | 2 +- src/imap/imap-list.c | 2 +- src/imap/imap-notify.c | 2 +- src/imap/imap-search-args.c | 2 +- src/imap/imap-search.c | 2 +- src/imap/imap-settings.c | 2 +- src/imap/imap-status.c | 2 +- src/imap/imap-sync.c | 2 +- src/imap/mail-storage-callbacks.c | 2 +- src/imap/main.c | 2 +- src/indexer/indexer-client.c | 2 +- src/indexer/indexer-queue.c | 2 +- src/indexer/indexer-settings.c | 2 +- src/indexer/indexer-worker-settings.c | 2 +- src/indexer/indexer-worker.c | 2 +- src/indexer/indexer.c | 2 +- src/indexer/master-connection.c | 2 +- src/indexer/worker-connection.c | 2 +- src/indexer/worker-pool.c | 2 +- src/ipc/client.c | 2 +- src/ipc/ipc-connection.c | 2 +- src/ipc/ipc-group.c | 2 +- src/ipc/ipc-settings.c | 2 +- src/ipc/main.c | 2 +- src/lda/main.c | 2 +- src/lib-auth/auth-client-request.c | 2 +- src/lib-auth/auth-client.c | 2 +- src/lib-auth/auth-master.c | 2 +- src/lib-auth/auth-server-connection.c | 2 +- src/lib-charset/charset-iconv.c | 2 +- src/lib-charset/charset-utf8.c | 2 +- src/lib-compression/compression.c | 2 +- src/lib-compression/istream-bzlib.c | 2 +- src/lib-compression/istream-zlib.c | 2 +- src/lib-compression/ostream-bzlib.c | 2 +- src/lib-compression/ostream-zlib.c | 2 +- src/lib-dict/dict-client.c | 2 +- src/lib-dict/dict-db.c | 2 +- src/lib-dict/dict-file.c | 2 +- src/lib-dict/dict-memcached-ascii.c | 2 +- src/lib-dict/dict-memcached.c | 2 +- src/lib-dict/dict-redis.c | 2 +- src/lib-dict/dict-sql-settings.c | 2 +- src/lib-dict/dict-sql.c | 2 +- src/lib-dict/dict-transaction-memory.c | 2 +- src/lib-dict/dict.c | 2 +- src/lib-dict/test-dict.c | 2 +- src/lib-dns/dns-lookup.c | 2 +- src/lib-fs/fs-api.c | 2 +- src/lib-fs/fs-posix.c | 2 +- src/lib-fs/fs-sis-common.c | 2 +- src/lib-fs/fs-sis-queue.c | 2 +- src/lib-fs/fs-sis.c | 2 +- src/lib-fs/fs-test.c | 2 +- src/lib-fs/istream-metawrap.c | 2 +- src/lib-fs/ostream-cmp.c | 2 +- src/lib-http/http-client-connection.c | 2 +- src/lib-http/http-client-host.c | 2 +- src/lib-http/http-client-peer.c | 2 +- src/lib-http/http-client-request.c | 2 +- src/lib-http/http-client.c | 2 +- src/lib-http/http-date.c | 2 +- src/lib-http/http-header-parser.c | 2 +- src/lib-http/http-parser.c | 2 +- src/lib-http/http-response-parser.c | 2 +- src/lib-http/http-transfer-chunked.c | 2 +- src/lib-http/http-url.c | 2 +- src/lib-http/test-http-client.c | 2 +- src/lib-http/test-http-date.c | 2 +- src/lib-http/test-http-header-parser.c | 2 +- src/lib-http/test-http-response-parser.c | 2 +- src/lib-http/test-http-transfer.c | 2 +- src/lib-http/test-http-url.c | 2 +- src/lib-imap-client/imapc-client.c | 2 +- src/lib-imap-client/imapc-connection.c | 2 +- src/lib-imap-client/imapc-msgmap.c | 2 +- src/lib-imap-storage/imap-msgpart-url.c | 2 +- src/lib-imap-storage/imap-msgpart.c | 2 +- src/lib-imap-urlauth/imap-urlauth-backend.c | 2 +- src/lib-imap-urlauth/imap-urlauth-connection.c | 2 +- src/lib-imap-urlauth/imap-urlauth-fetch.c | 2 +- src/lib-imap-urlauth/imap-urlauth.c | 2 +- src/lib-imap/imap-arg.c | 2 +- src/lib-imap/imap-base-subject.c | 2 +- src/lib-imap/imap-bodystructure.c | 2 +- src/lib-imap/imap-date.c | 2 +- src/lib-imap/imap-envelope.c | 2 +- src/lib-imap/imap-id.c | 2 +- src/lib-imap/imap-match.c | 2 +- src/lib-imap/imap-parser.c | 2 +- src/lib-imap/imap-quote.c | 2 +- src/lib-imap/imap-seqset.c | 2 +- src/lib-imap/imap-url.c | 2 +- src/lib-imap/imap-utf7.c | 2 +- src/lib-imap/imap-util.c | 2 +- src/lib-imap/test-imap-bodystructure.c | 2 +- src/lib-imap/test-imap-match.c | 2 +- src/lib-imap/test-imap-parser.c | 2 +- src/lib-imap/test-imap-url.c | 2 +- src/lib-imap/test-imap-utf7.c | 2 +- src/lib-imap/test-imap-util.c | 2 +- src/lib-index/mail-cache-compress.c | 2 +- src/lib-index/mail-cache-decisions.c | 2 +- src/lib-index/mail-cache-fields.c | 2 +- src/lib-index/mail-cache-lookup.c | 2 +- src/lib-index/mail-cache-sync-update.c | 2 +- src/lib-index/mail-cache-transaction.c | 2 +- src/lib-index/mail-cache.c | 2 +- src/lib-index/mail-index-alloc-cache.c | 2 +- src/lib-index/mail-index-dummy-view.c | 2 +- src/lib-index/mail-index-fsck.c | 2 +- src/lib-index/mail-index-lock.c | 2 +- src/lib-index/mail-index-map-hdr.c | 2 +- src/lib-index/mail-index-map-read.c | 2 +- src/lib-index/mail-index-map.c | 2 +- src/lib-index/mail-index-modseq.c | 2 +- src/lib-index/mail-index-strmap.c | 2 +- src/lib-index/mail-index-sync-ext.c | 2 +- src/lib-index/mail-index-sync-keywords.c | 2 +- src/lib-index/mail-index-sync-update.c | 2 +- src/lib-index/mail-index-sync.c | 2 +- src/lib-index/mail-index-transaction-export.c | 2 +- src/lib-index/mail-index-transaction-finish.c | 2 +- src/lib-index/mail-index-transaction-sort-appends.c | 2 +- src/lib-index/mail-index-transaction-update.c | 2 +- src/lib-index/mail-index-transaction-view.c | 2 +- src/lib-index/mail-index-transaction.c | 2 +- src/lib-index/mail-index-util.c | 2 +- src/lib-index/mail-index-view-sync.c | 2 +- src/lib-index/mail-index-view.c | 2 +- src/lib-index/mail-index-write.c | 2 +- src/lib-index/mail-index.c | 2 +- src/lib-index/mail-transaction-log-append.c | 2 +- src/lib-index/mail-transaction-log-file.c | 2 +- src/lib-index/mail-transaction-log-view.c | 2 +- src/lib-index/mail-transaction-log.c | 2 +- src/lib-index/mailbox-log.c | 2 +- src/lib-index/test-mail-index-sync-ext.c | 2 +- src/lib-index/test-mail-index-transaction-finish.c | 2 +- src/lib-index/test-mail-index-transaction-update.c | 2 +- src/lib-index/test-mail-transaction-log-append.c | 2 +- src/lib-index/test-mail-transaction-log-view.c | 2 +- src/lib-lda/duplicate.c | 2 +- src/lib-lda/lda-settings.c | 2 +- src/lib-lda/lmtp-client.c | 2 +- src/lib-lda/mail-deliver.c | 2 +- src/lib-lda/mail-send.c | 2 +- src/lib-lda/smtp-client.c | 2 +- src/lib-mail/istream-attachment-connector.c | 2 +- src/lib-mail/istream-attachment-extractor.c | 2 +- src/lib-mail/istream-binary-converter.c | 2 +- src/lib-mail/istream-dot.c | 2 +- src/lib-mail/istream-header-filter.c | 2 +- src/lib-mail/istream-nonuls.c | 2 +- src/lib-mail/istream-qp-decoder.c | 2 +- src/lib-mail/mail-user-hash.c | 2 +- src/lib-mail/mbox-from.c | 2 +- src/lib-mail/message-address.c | 2 +- src/lib-mail/message-binary-part.c | 2 +- src/lib-mail/message-date.c | 2 +- src/lib-mail/message-decoder.c | 2 +- src/lib-mail/message-header-decode.c | 2 +- src/lib-mail/message-header-encode.c | 2 +- src/lib-mail/message-header-parser.c | 2 +- src/lib-mail/message-id.c | 2 +- src/lib-mail/message-parser.c | 2 +- src/lib-mail/message-part-serialize.c | 2 +- src/lib-mail/message-search.c | 2 +- src/lib-mail/message-size.c | 2 +- src/lib-mail/quoted-printable.c | 2 +- src/lib-mail/rfc2231-parser.c | 2 +- src/lib-mail/rfc822-parser.c | 2 +- src/lib-mail/test-istream-attachment.c | 2 +- src/lib-mail/test-istream-binary-converter.c | 2 +- src/lib-mail/test-istream-dot.c | 2 +- src/lib-mail/test-istream-header-filter.c | 2 +- src/lib-mail/test-istream-qp-decoder.c | 2 +- src/lib-mail/test-mbox-from.c | 2 +- src/lib-mail/test-message-address.c | 2 +- src/lib-mail/test-message-date.c | 2 +- src/lib-mail/test-message-decoder.c | 2 +- src/lib-mail/test-message-header-decode.c | 2 +- src/lib-mail/test-message-header-encode.c | 2 +- src/lib-mail/test-message-header-parser.c | 2 +- src/lib-mail/test-message-id.c | 2 +- src/lib-mail/test-message-parser.c | 2 +- src/lib-mail/test-quoted-printable.c | 2 +- src/lib-mail/test-rfc2231-parser.c | 2 +- src/lib-master/anvil-client.c | 2 +- src/lib-master/ipc-client.c | 2 +- src/lib-master/ipc-server.c | 2 +- src/lib-master/master-auth.c | 2 +- src/lib-master/master-instance.c | 2 +- src/lib-master/master-login-auth.c | 2 +- src/lib-master/master-login.c | 2 +- src/lib-master/master-service-settings-cache.c | 2 +- src/lib-master/master-service-settings.c | 2 +- src/lib-master/master-service-ssl-settings.c | 2 +- src/lib-master/master-service-ssl.c | 2 +- src/lib-master/master-service.c | 2 +- src/lib-master/mountpoint-list.c | 2 +- src/lib-master/syslog-util.c | 2 +- src/lib-settings/settings-parser.c | 2 +- src/lib-settings/settings.c | 2 +- src/lib-sql/driver-mysql.c | 2 +- src/lib-sql/driver-pgsql.c | 2 +- src/lib-sql/driver-sqlite.c | 2 +- src/lib-sql/driver-sqlpool.c | 2 +- src/lib-sql/sql-api.c | 2 +- src/lib-sql/sql-db-cache.c | 2 +- src/lib-ssl-iostream/iostream-openssl-common.c | 2 +- src/lib-ssl-iostream/iostream-openssl-context.c | 2 +- src/lib-ssl-iostream/iostream-openssl-params.c | 2 +- src/lib-ssl-iostream/iostream-openssl.c | 2 +- src/lib-ssl-iostream/iostream-ssl-none.c | 2 +- src/lib-ssl-iostream/iostream-ssl.c | 2 +- src/lib-ssl-iostream/istream-openssl.c | 2 +- src/lib-ssl-iostream/ostream-openssl.c | 2 +- src/lib-storage/fail-mail-storage.c | 2 +- src/lib-storage/fail-mail.c | 2 +- src/lib-storage/fail-mailbox.c | 2 +- src/lib-storage/index/cydir/cydir-mail.c | 2 +- src/lib-storage/index/cydir/cydir-save.c | 2 +- src/lib-storage/index/cydir/cydir-storage.c | 2 +- src/lib-storage/index/cydir/cydir-sync.c | 2 +- src/lib-storage/index/dbox-common/dbox-attachment.c | 2 +- src/lib-storage/index/dbox-common/dbox-file-fix.c | 2 +- src/lib-storage/index/dbox-common/dbox-file.c | 2 +- src/lib-storage/index/dbox-common/dbox-mail.c | 2 +- src/lib-storage/index/dbox-common/dbox-save.c | 2 +- src/lib-storage/index/dbox-common/dbox-storage.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-file.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-mail.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-map.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-purge.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-save.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-settings.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-storage.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-sync.c | 2 +- src/lib-storage/index/dbox-single/sdbox-copy.c | 2 +- src/lib-storage/index/dbox-single/sdbox-file.c | 2 +- src/lib-storage/index/dbox-single/sdbox-mail.c | 2 +- src/lib-storage/index/dbox-single/sdbox-save.c | 2 +- src/lib-storage/index/dbox-single/sdbox-storage.c | 2 +- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +- src/lib-storage/index/dbox-single/sdbox-sync.c | 2 +- src/lib-storage/index/imapc/imapc-list.c | 2 +- src/lib-storage/index/imapc/imapc-mail-fetch.c | 2 +- src/lib-storage/index/imapc/imapc-mail.c | 2 +- src/lib-storage/index/imapc/imapc-mailbox.c | 2 +- src/lib-storage/index/imapc/imapc-save.c | 2 +- src/lib-storage/index/imapc/imapc-settings.c | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/index/imapc/imapc-sync.c | 2 +- src/lib-storage/index/index-attachment.c | 2 +- src/lib-storage/index/index-attribute.c | 2 +- src/lib-storage/index/index-mail-binary.c | 2 +- src/lib-storage/index/index-mail-headers.c | 2 +- src/lib-storage/index/index-mail.c | 2 +- src/lib-storage/index/index-mailbox-check.c | 2 +- src/lib-storage/index/index-rebuild.c | 2 +- src/lib-storage/index/index-search-result.c | 2 +- src/lib-storage/index/index-search.c | 2 +- src/lib-storage/index/index-sort-string.c | 2 +- src/lib-storage/index/index-sort.c | 2 +- src/lib-storage/index/index-status.c | 2 +- src/lib-storage/index/index-storage.c | 2 +- src/lib-storage/index/index-sync-changes.c | 2 +- src/lib-storage/index/index-sync-pvt.c | 2 +- src/lib-storage/index/index-sync-search.c | 2 +- src/lib-storage/index/index-sync.c | 2 +- src/lib-storage/index/index-thread-finish.c | 2 +- src/lib-storage/index/index-thread-links.c | 2 +- src/lib-storage/index/index-thread.c | 2 +- src/lib-storage/index/index-transaction.c | 2 +- src/lib-storage/index/istream-mail.c | 2 +- src/lib-storage/index/maildir/maildir-copy.c | 2 +- src/lib-storage/index/maildir/maildir-filename-flags.c | 2 +- src/lib-storage/index/maildir/maildir-filename.c | 2 +- src/lib-storage/index/maildir/maildir-keywords.c | 2 +- src/lib-storage/index/maildir/maildir-mail.c | 2 +- src/lib-storage/index/maildir/maildir-save.c | 2 +- src/lib-storage/index/maildir/maildir-settings.c | 2 +- src/lib-storage/index/maildir/maildir-storage.c | 2 +- src/lib-storage/index/maildir/maildir-sync-index.c | 2 +- src/lib-storage/index/maildir/maildir-sync.c | 2 +- src/lib-storage/index/maildir/maildir-uidlist.c | 2 +- src/lib-storage/index/maildir/maildir-util.c | 2 +- src/lib-storage/index/mbox/istream-raw-mbox.c | 2 +- src/lib-storage/index/mbox/mbox-file.c | 2 +- src/lib-storage/index/mbox/mbox-lock.c | 2 +- src/lib-storage/index/mbox/mbox-mail.c | 2 +- src/lib-storage/index/mbox/mbox-md5-all.c | 2 +- src/lib-storage/index/mbox/mbox-md5-apop3d.c | 2 +- src/lib-storage/index/mbox/mbox-save.c | 2 +- src/lib-storage/index/mbox/mbox-settings.c | 2 +- src/lib-storage/index/mbox/mbox-storage.c | 2 +- src/lib-storage/index/mbox/mbox-sync-parse.c | 2 +- src/lib-storage/index/mbox/mbox-sync-rewrite.c | 2 +- src/lib-storage/index/mbox/mbox-sync-update.c | 2 +- src/lib-storage/index/mbox/mbox-sync.c | 2 +- src/lib-storage/index/pop3c/pop3c-client.c | 2 +- src/lib-storage/index/pop3c/pop3c-mail.c | 2 +- src/lib-storage/index/pop3c/pop3c-settings.c | 2 +- src/lib-storage/index/pop3c/pop3c-storage.c | 2 +- src/lib-storage/index/pop3c/pop3c-sync.c | 2 +- src/lib-storage/index/raw/raw-mail.c | 2 +- src/lib-storage/index/raw/raw-storage.c | 2 +- src/lib-storage/index/raw/raw-sync.c | 2 +- src/lib-storage/index/shared/shared-list.c | 2 +- src/lib-storage/index/shared/shared-storage.c | 2 +- src/lib-storage/list/mailbox-list-delete.c | 2 +- src/lib-storage/list/mailbox-list-fs-flags.c | 2 +- src/lib-storage/list/mailbox-list-fs-iter.c | 2 +- src/lib-storage/list/mailbox-list-fs.c | 2 +- src/lib-storage/list/mailbox-list-index-backend.c | 2 +- src/lib-storage/list/mailbox-list-index-iter.c | 2 +- src/lib-storage/list/mailbox-list-index-notify.c | 2 +- src/lib-storage/list/mailbox-list-index-status.c | 2 +- src/lib-storage/list/mailbox-list-index-sync.c | 2 +- src/lib-storage/list/mailbox-list-index.c | 2 +- src/lib-storage/list/mailbox-list-iter.c | 2 +- src/lib-storage/list/mailbox-list-maildir-iter.c | 2 +- src/lib-storage/list/mailbox-list-maildir.c | 2 +- src/lib-storage/list/mailbox-list-none.c | 2 +- src/lib-storage/list/mailbox-list-notify-tree.c | 2 +- src/lib-storage/list/mailbox-list-subscriptions.c | 2 +- src/lib-storage/list/subscription-file.c | 2 +- src/lib-storage/mail-copy.c | 2 +- src/lib-storage/mail-error.c | 2 +- src/lib-storage/mail-namespace.c | 2 +- src/lib-storage/mail-search-build.c | 2 +- src/lib-storage/mail-search-parser-cmdline.c | 2 +- src/lib-storage/mail-search-parser-imap.c | 2 +- src/lib-storage/mail-search-parser.c | 2 +- src/lib-storage/mail-search-register-human.c | 2 +- src/lib-storage/mail-search-register-imap.c | 2 +- src/lib-storage/mail-search-register.c | 2 +- src/lib-storage/mail-search.c | 2 +- src/lib-storage/mail-storage-hooks.c | 2 +- src/lib-storage/mail-storage-service.c | 2 +- src/lib-storage/mail-storage-settings.c | 2 +- src/lib-storage/mail-storage.c | 2 +- src/lib-storage/mail-thread.c | 2 +- src/lib-storage/mail-user.c | 2 +- src/lib-storage/mail.c | 2 +- src/lib-storage/mailbox-get.c | 2 +- src/lib-storage/mailbox-guid-cache.c | 2 +- src/lib-storage/mailbox-header.c | 2 +- src/lib-storage/mailbox-keywords.c | 2 +- src/lib-storage/mailbox-list-notify.c | 2 +- src/lib-storage/mailbox-list.c | 2 +- src/lib-storage/mailbox-search-result.c | 2 +- src/lib-storage/mailbox-tree.c | 2 +- src/lib-storage/mailbox-uidvalidity.c | 2 +- src/lib-storage/test-mailbox-get.c | 2 +- src/lib-test/test-common.c | 2 +- src/lib/abspath.c | 2 +- src/lib/aqueue.c | 2 +- src/lib/array.c | 2 +- src/lib/askpass.c | 2 +- src/lib/backtrace-string.c | 2 +- src/lib/base64.c | 2 +- src/lib/bsearch-insert-pos.c | 2 +- src/lib/buffer.c | 2 +- src/lib/child-wait.c | 2 +- src/lib/compat.c | 2 +- src/lib/connection.c | 2 +- src/lib/crc32.c | 2 +- src/lib/data-stack.c | 2 +- src/lib/eacces-error.c | 2 +- src/lib/env-util.c | 2 +- src/lib/execv-const.c | 2 +- src/lib/failures.c | 2 +- src/lib/fd-close-on-exec.c | 2 +- src/lib/fd-set-nonblock.c | 2 +- src/lib/fdatasync-path.c | 2 +- src/lib/fdpass.c | 2 +- src/lib/file-cache.c | 2 +- src/lib/file-copy.c | 2 +- src/lib/file-dotlock.c | 2 +- src/lib/file-lock.c | 2 +- src/lib/file-set-size.c | 2 +- src/lib/guid.c | 2 +- src/lib/hash-format.c | 2 +- src/lib/hash-method.c | 2 +- src/lib/hash.c | 2 +- src/lib/hash2.c | 2 +- src/lib/hex-binary.c | 2 +- src/lib/hex-dec.c | 2 +- src/lib/home-expand.c | 2 +- src/lib/hostpid.c | 2 +- src/lib/imem.c | 2 +- src/lib/ioloop-epoll.c | 2 +- src/lib/ioloop-notify-dn.c | 2 +- src/lib/ioloop-notify-fd.c | 2 +- src/lib/ioloop-notify-inotify.c | 2 +- src/lib/ioloop-notify-none.c | 2 +- src/lib/ioloop-poll.c | 2 +- src/lib/ioloop-select.c | 2 +- src/lib/ioloop.c | 2 +- src/lib/iostream-rawlog.c | 2 +- src/lib/iostream-temp.c | 2 +- src/lib/iostream.c | 2 +- src/lib/ipwd.c | 2 +- src/lib/iso8601-date.c | 2 +- src/lib/istream-base64-decoder.c | 2 +- src/lib/istream-base64-encoder.c | 2 +- src/lib/istream-chain.c | 2 +- src/lib/istream-concat.c | 2 +- src/lib/istream-crlf.c | 2 +- src/lib/istream-data.c | 2 +- src/lib/istream-file.c | 2 +- src/lib/istream-jsonstr.c | 2 +- src/lib/istream-limit.c | 2 +- src/lib/istream-mmap.c | 2 +- src/lib/istream-rawlog.c | 2 +- src/lib/istream-seekable.c | 2 +- src/lib/istream-sized.c | 2 +- src/lib/istream-tee.c | 2 +- src/lib/istream.c | 2 +- src/lib/json-parser.c | 2 +- src/lib/lib-signals.c | 2 +- src/lib/lib.c | 2 +- src/lib/mempool-alloconly.c | 2 +- src/lib/mempool-datastack.c | 2 +- src/lib/mempool-system.c | 2 +- src/lib/mempool-unsafe-datastack.c | 2 +- src/lib/mempool.c | 2 +- src/lib/mkdir-parents.c | 2 +- src/lib/mmap-anon.c | 2 +- src/lib/mmap-util.c | 2 +- src/lib/module-dir.c | 2 +- src/lib/mountpoint.c | 2 +- src/lib/net.c | 2 +- src/lib/nfs-workarounds.c | 2 +- src/lib/numpack.c | 2 +- src/lib/ostream-buffer.c | 2 +- src/lib/ostream-file.c | 2 +- src/lib/ostream-rawlog.c | 2 +- src/lib/ostream.c | 2 +- src/lib/primes.c | 2 +- src/lib/printf-format-fix.c | 2 +- src/lib/priorityq.c | 2 +- src/lib/process-title.c | 2 +- src/lib/randgen.c | 2 +- src/lib/read-full.c | 2 +- src/lib/restrict-access.c | 2 +- src/lib/restrict-process-size.c | 2 +- src/lib/safe-memset.c | 2 +- src/lib/safe-mkdir.c | 2 +- src/lib/safe-mkstemp.c | 2 +- src/lib/sendfile-util.c | 2 +- src/lib/seq-range-array.c | 2 +- src/lib/str-find.c | 2 +- src/lib/str-sanitize.c | 2 +- src/lib/str.c | 2 +- src/lib/strescape.c | 2 +- src/lib/strfuncs.c | 2 +- src/lib/strnum.c | 2 +- src/lib/test-aqueue.c | 2 +- src/lib/test-array.c | 2 +- src/lib/test-base64.c | 2 +- src/lib/test-bsearch-insert-pos.c | 2 +- src/lib/test-buffer.c | 2 +- src/lib/test-crc32.c | 2 +- src/lib/test-hash-format.c | 2 +- src/lib/test-hex-binary.c | 2 +- src/lib/test-iso8601-date.c | 2 +- src/lib/test-istream-base64-decoder.c | 2 +- src/lib/test-istream-base64-encoder.c | 2 +- src/lib/test-istream-concat.c | 2 +- src/lib/test-istream-crlf.c | 2 +- src/lib/test-istream-seekable.c | 2 +- src/lib/test-istream-tee.c | 2 +- src/lib/test-json-parser.c | 2 +- src/lib/test-lib.c | 2 +- src/lib/test-llist.c | 2 +- src/lib/test-mempool-alloconly.c | 2 +- src/lib/test-network.c | 2 +- src/lib/test-numpack.c | 2 +- src/lib/test-ostream-file.c | 2 +- src/lib/test-primes.c | 2 +- src/lib/test-priorityq.c | 2 +- src/lib/test-seq-range-array.c | 2 +- src/lib/test-str-find.c | 2 +- src/lib/test-str-sanitize.c | 2 +- src/lib/test-strescape.c | 2 +- src/lib/test-strfuncs.c | 2 +- src/lib/test-time-util.c | 2 +- src/lib/test-unichar.c | 2 +- src/lib/test-utc-mktime.c | 2 +- src/lib/test-var-expand.c | 2 +- src/lib/time-util.c | 2 +- src/lib/unichar.c | 2 +- src/lib/unix-socket-create.c | 2 +- src/lib/unlink-directory.c | 2 +- src/lib/unlink-old-files.c | 2 +- src/lib/uri-util.c | 2 +- src/lib/utc-mktime.c | 2 +- src/lib/utc-offset.c | 2 +- src/lib/var-expand.c | 2 +- src/lib/write-full.c | 2 +- src/lmtp/client.c | 2 +- src/lmtp/commands.c | 2 +- src/lmtp/lmtp-proxy.c | 2 +- src/lmtp/lmtp-settings.c | 2 +- src/lmtp/main.c | 2 +- src/log/doveadm-connection.c | 2 +- src/log/log-connection.c | 2 +- src/log/log-error-buffer.c | 2 +- src/log/log-settings.c | 2 +- src/log/main.c | 2 +- src/login-common/access-lookup.c | 2 +- src/login-common/client-common-auth.c | 2 +- src/login-common/client-common.c | 2 +- src/login-common/login-proxy-state.c | 2 +- src/login-common/login-proxy.c | 2 +- src/login-common/login-settings.c | 2 +- src/login-common/main.c | 2 +- src/login-common/sasl-server.c | 2 +- src/login-common/ssl-proxy-gnutls.c | 2 +- src/login-common/ssl-proxy-openssl.c | 2 +- src/login-common/ssl-proxy.c | 2 +- src/master/capabilities-posix.c | 2 +- src/master/dup2-array.c | 2 +- src/master/main.c | 2 +- src/master/master-settings.c | 2 +- src/master/service-anvil.c | 2 +- src/master/service-listen.c | 2 +- src/master/service-log.c | 2 +- src/master/service-monitor.c | 2 +- src/master/service-process-notify.c | 2 +- src/master/service-process.c | 2 +- src/master/service.c | 2 +- src/plugins/acl/acl-api.c | 2 +- src/plugins/acl/acl-backend-vfile-acllist.c | 2 +- src/plugins/acl/acl-backend-vfile.c | 2 +- src/plugins/acl/acl-backend.c | 2 +- src/plugins/acl/acl-cache.c | 2 +- src/plugins/acl/acl-lookup-dict.c | 2 +- src/plugins/acl/acl-mailbox-list.c | 2 +- src/plugins/acl/acl-mailbox.c | 2 +- src/plugins/acl/acl-plugin.c | 2 +- src/plugins/acl/acl-shared-storage.c | 2 +- src/plugins/acl/acl-storage.c | 2 +- src/plugins/acl/doveadm-acl.c | 2 +- src/plugins/autocreate/autocreate-plugin.c | 2 +- src/plugins/expire/doveadm-expire.c | 2 +- src/plugins/expire/expire-plugin.c | 2 +- src/plugins/expire/expire-set.c | 2 +- src/plugins/fts-lucene/doveadm-fts-lucene.c | 2 +- src/plugins/fts-lucene/fts-backend-lucene.c | 2 +- src/plugins/fts-lucene/fts-lucene-plugin.c | 2 +- src/plugins/fts-solr/fts-backend-solr-old.c | 2 +- src/plugins/fts-solr/fts-backend-solr.c | 2 +- src/plugins/fts-solr/fts-solr-plugin.c | 2 +- src/plugins/fts-solr/solr-connection.c | 2 +- src/plugins/fts-squat/fts-backend-squat.c | 2 +- src/plugins/fts-squat/fts-squat-plugin.c | 2 +- src/plugins/fts-squat/squat-test.c | 2 +- src/plugins/fts-squat/squat-trie.c | 2 +- src/plugins/fts-squat/squat-uidlist.c | 2 +- src/plugins/fts/doveadm-dump-fts-expunge-log.c | 2 +- src/plugins/fts/doveadm-fts.c | 2 +- src/plugins/fts/fts-api.c | 2 +- src/plugins/fts/fts-build-mail.c | 2 +- src/plugins/fts/fts-expunge-log.c | 2 +- src/plugins/fts/fts-indexer.c | 2 +- src/plugins/fts/fts-parser-html.c | 2 +- src/plugins/fts/fts-parser-script.c | 2 +- src/plugins/fts/fts-parser.c | 2 +- src/plugins/fts/fts-plugin.c | 2 +- src/plugins/fts/fts-search-serialize.c | 2 +- src/plugins/fts/fts-search.c | 2 +- src/plugins/fts/fts-storage.c | 2 +- src/plugins/fts/xml2text.c | 2 +- src/plugins/imap-acl/imap-acl-plugin.c | 2 +- src/plugins/imap-quota/imap-quota-plugin.c | 2 +- src/plugins/imap-stats/imap-stats-plugin.c | 2 +- src/plugins/imap-zlib/imap-zlib-plugin.c | 2 +- src/plugins/lazy-expunge/lazy-expunge-plugin.c | 2 +- src/plugins/listescape/listescape-plugin.c | 2 +- src/plugins/mail-log/mail-log-plugin.c | 2 +- src/plugins/mailbox-alias/mailbox-alias-plugin.c | 2 +- src/plugins/notify/notify-plugin.c | 2 +- src/plugins/notify/notify-storage.c | 2 +- src/plugins/pop3-migration/pop3-migration-plugin.c | 2 +- src/plugins/quota/doveadm-quota.c | 2 +- src/plugins/quota/quota-count.c | 2 +- src/plugins/quota/quota-dict.c | 2 +- src/plugins/quota/quota-dirsize.c | 2 +- src/plugins/quota/quota-fs.c | 2 +- src/plugins/quota/quota-maildir.c | 2 +- src/plugins/quota/quota-plugin.c | 2 +- src/plugins/quota/quota-storage.c | 2 +- src/plugins/quota/quota.c | 2 +- src/plugins/replication/replication-plugin.c | 2 +- src/plugins/snarf/snarf-plugin.c | 2 +- src/plugins/stats/stats-connection.c | 2 +- src/plugins/stats/stats-plugin.c | 2 +- src/plugins/trash/trash-plugin.c | 2 +- src/plugins/virtual/virtual-config.c | 2 +- src/plugins/virtual/virtual-mail.c | 2 +- src/plugins/virtual/virtual-plugin.c | 2 +- src/plugins/virtual/virtual-save.c | 2 +- src/plugins/virtual/virtual-search.c | 2 +- src/plugins/virtual/virtual-storage.c | 2 +- src/plugins/virtual/virtual-sync.c | 2 +- src/plugins/virtual/virtual-transaction.c | 2 +- src/plugins/zlib/zlib-plugin.c | 2 +- src/pop3-login/client-authenticate.c | 2 +- src/pop3-login/client.c | 2 +- src/pop3-login/pop3-login-settings.c | 2 +- src/pop3-login/pop3-proxy.c | 2 +- src/pop3/main.c | 2 +- src/pop3/pop3-client.c | 2 +- src/pop3/pop3-commands.c | 2 +- src/pop3/pop3-settings.c | 2 +- src/replication/aggregator/aggregator-settings.c | 2 +- src/replication/aggregator/aggregator.c | 2 +- src/replication/aggregator/notify-connection.c | 2 +- src/replication/aggregator/replicator-connection.c | 2 +- src/replication/replicator/doveadm-connection.c | 2 +- src/replication/replicator/notify-connection.c | 2 +- src/replication/replicator/replicator-brain.c | 2 +- src/replication/replicator/replicator-queue.c | 2 +- src/replication/replicator/replicator-settings.c | 2 +- src/replication/replicator/replicator.c | 2 +- src/ssl-params/main.c | 2 +- src/ssl-params/ssl-params-openssl.c | 2 +- src/ssl-params/ssl-params-settings.c | 2 +- src/ssl-params/ssl-params.c | 2 +- src/stats/client-export.c | 2 +- src/stats/client.c | 2 +- src/stats/global-memory.c | 2 +- src/stats/mail-command.c | 2 +- src/stats/mail-domain.c | 2 +- src/stats/mail-ip.c | 2 +- src/stats/mail-server-connection.c | 2 +- src/stats/mail-session.c | 2 +- src/stats/mail-stats.c | 2 +- src/stats/mail-user.c | 2 +- src/stats/main.c | 2 +- src/stats/stats-settings.c | 2 +- src/util/gdbhelper.c | 2 +- src/util/maildirlock.c | 2 +- src/util/rawlog.c | 2 +- src/util/script-login.c | 2 +- src/util/script.c | 2 +- src/util/tcpwrap-settings.c | 2 +- src/util/tcpwrap.c | 2 +- 862 files changed, 862 insertions(+), 862 deletions(-) diffs (truncated from 7758 to 300 lines): diff -r 1b671d03474d -r 90710c6c3beb src/anvil/anvil-connection.c --- a/src/anvil/anvil-connection.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/anvil/anvil-connection.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "common.h" #include "llist.h" diff -r 1b671d03474d -r 90710c6c3beb src/anvil/anvil-settings.c --- a/src/anvil/anvil-settings.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/anvil/anvil-settings.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "buffer.h" diff -r 1b671d03474d -r 90710c6c3beb src/anvil/connect-limit.c --- a/src/anvil/connect-limit.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/anvil/connect-limit.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "common.h" #include "hash.h" diff -r 1b671d03474d -r 90710c6c3beb src/anvil/main.c --- a/src/anvil/main.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/anvil/main.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "common.h" #include "array.h" diff -r 1b671d03474d -r 90710c6c3beb src/anvil/penalty.c --- a/src/anvil/penalty.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/anvil/penalty.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ /* The idea behind checksums is that the same username+password doesn't increase the penalty, because it's most likely a user with a misconfigured diff -r 1b671d03474d -r 90710c6c3beb src/anvil/test-penalty.c --- a/src/anvil/test-penalty.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/anvil/test-penalty.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-cache.c --- a/src/auth/auth-cache.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-cache.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2004-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "lib-signals.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-client-connection.c --- a/src/auth/auth-client-connection.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-client-connection.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-fields.c --- a/src/auth/auth-fields.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-fields.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-master-connection.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "buffer.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-penalty.c --- a/src/auth/auth-penalty.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-penalty.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-postfix-connection.c --- a/src/auth/auth-postfix-connection.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-postfix-connection.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2011-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-request-handler.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-request.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-settings.c --- a/src/auth/auth-settings.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-settings.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "array.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-token.c --- a/src/auth/auth-token.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-token.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ /* Auth process maintains a random secret. Once a user authenticates the response to the REQUEST command from a master service is augmented with an diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-worker-client.c --- a/src/auth/auth-worker-client.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-worker-client.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "base64.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth-worker-server.c --- a/src/auth/auth-worker-server.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth-worker-server.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/auth.c --- a/src/auth/auth.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/auth.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/db-checkpassword.c --- a/src/auth/db-checkpassword.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/db-checkpassword.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2004-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/db-dict.c --- a/src/auth/db-dict.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/db-dict.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/db-ldap.c --- a/src/auth/db-ldap.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/db-ldap.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/db-passwd-file.c --- a/src/auth/db-passwd-file.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/db-passwd-file.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/db-sql.c --- a/src/auth/db-sql.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/db-sql.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/main.c --- a/src/auth/main.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/main.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/mech-anonymous.c --- a/src/auth/mech-anonymous.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/mech-anonymous.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "mech.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/mech-cram-md5.c --- a/src/auth/mech-cram-md5.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/mech-cram-md5.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ /* CRAM-MD5 SASL authentication, see RFC-2195 Joshua Goodall */ diff -r 1b671d03474d -r 90710c6c3beb src/auth/mech-digest-md5.c --- a/src/auth/mech-digest-md5.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/mech-digest-md5.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ /* Digest-MD5 SASL authentication, see RFC-2831 */ diff -r 1b671d03474d -r 90710c6c3beb src/auth/mech-dovecot-token.c --- a/src/auth/mech-dovecot-token.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/mech-dovecot-token.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ /* Used internally by Dovecot processes to authenticate against each others (e.g. imap to imap-urlauth). See auth-token.c */ diff -r 1b671d03474d -r 90710c6c3beb src/auth/mech-external.c --- a/src/auth/mech-external.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/mech-external.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "passdb.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/mech-plain.c --- a/src/auth/mech-plain.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/mech-plain.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "safe-memset.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/mech.c --- a/src/auth/mech.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/mech.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/passdb-blocking.c --- a/src/auth/passdb-blocking.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/passdb-blocking.c Sat Feb 02 17:01:07 2013 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ +* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "str.h" diff -r 1b671d03474d -r 90710c6c3beb src/auth/passdb-bsdauth.c --- a/src/auth/passdb-bsdauth.c Sat Feb 02 16:52:23 2013 +0200 +++ b/src/auth/passdb-bsdauth.c Sat Feb 02 17:01:07 2013 +0200 From dovecot at dovecot.org Sat Feb 2 17:04:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 02 Feb 2013 17:04:16 +0200 Subject: dovecot-2.2: Oops :) Update copyrights to 2013 without breaking ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/36ef72481934 changeset: 15715:36ef72481934 user: Timo Sirainen date: Sat Feb 02 17:02:55 2013 +0200 description: Oops :) Update copyrights to 2013 without breaking all .c files. diffstat: src/anvil/anvil-connection.c | 2 +- src/anvil/anvil-settings.c | 2 +- src/anvil/connect-limit.c | 2 +- src/anvil/main.c | 2 +- src/anvil/penalty.c | 2 +- src/anvil/test-penalty.c | 2 +- src/auth/auth-cache.c | 2 +- src/auth/auth-client-connection.c | 2 +- src/auth/auth-fields.c | 2 +- src/auth/auth-master-connection.c | 2 +- src/auth/auth-penalty.c | 2 +- src/auth/auth-postfix-connection.c | 2 +- src/auth/auth-request-handler.c | 2 +- src/auth/auth-request.c | 2 +- src/auth/auth-settings.c | 2 +- src/auth/auth-token.c | 2 +- src/auth/auth-worker-client.c | 2 +- src/auth/auth-worker-server.c | 2 +- src/auth/auth.c | 2 +- src/auth/db-checkpassword.c | 2 +- src/auth/db-dict.c | 2 +- src/auth/db-ldap.c | 2 +- src/auth/db-passwd-file.c | 2 +- src/auth/db-sql.c | 2 +- src/auth/main.c | 2 +- src/auth/mech-anonymous.c | 2 +- src/auth/mech-cram-md5.c | 2 +- src/auth/mech-digest-md5.c | 2 +- src/auth/mech-dovecot-token.c | 2 +- src/auth/mech-external.c | 2 +- src/auth/mech-plain.c | 2 +- src/auth/mech.c | 2 +- src/auth/passdb-blocking.c | 2 +- src/auth/passdb-bsdauth.c | 2 +- src/auth/passdb-cache.c | 2 +- src/auth/passdb-checkpassword.c | 2 +- src/auth/passdb-dict.c | 2 +- src/auth/passdb-imap.c | 2 +- src/auth/passdb-ldap.c | 2 +- src/auth/passdb-passwd-file.c | 2 +- src/auth/passdb-passwd.c | 2 +- src/auth/passdb-shadow.c | 2 +- src/auth/passdb-sql.c | 2 +- src/auth/passdb-static.c | 2 +- src/auth/passdb-template.c | 2 +- src/auth/passdb-vpopmail.c | 2 +- src/auth/passdb.c | 2 +- src/auth/password-scheme-crypt.c | 2 +- src/auth/password-scheme.c | 2 +- src/auth/test-auth-cache.c | 2 +- src/auth/userdb-blocking.c | 2 +- src/auth/userdb-checkpassword.c | 2 +- src/auth/userdb-dict.c | 2 +- src/auth/userdb-ldap.c | 2 +- src/auth/userdb-nss.c | 2 +- src/auth/userdb-passwd-file.c | 2 +- src/auth/userdb-passwd.c | 2 +- src/auth/userdb-prefetch.c | 2 +- src/auth/userdb-sql.c | 2 +- src/auth/userdb-static.c | 2 +- src/auth/userdb-template.c | 2 +- src/auth/userdb-vpopmail.c | 2 +- src/auth/userdb.c | 2 +- src/config/config-connection.c | 2 +- src/config/config-filter.c | 2 +- src/config/config-parser.c | 2 +- src/config/config-request.c | 2 +- src/config/config-settings.c | 2 +- src/config/doveconf.c | 2 +- src/config/main.c | 2 +- src/config/old-set-parser.c | 2 +- src/config/sysinfo-get.c | 2 +- src/dict/dict-commands.c | 2 +- src/dict/dict-connection.c | 2 +- src/dict/dict-settings.c | 2 +- src/dict/main.c | 2 +- src/director/auth-connection.c | 2 +- src/director/director-connection.c | 2 +- src/director/director-host.c | 2 +- src/director/director-request.c | 2 +- src/director/director-settings.c | 2 +- src/director/director-test.c | 2 +- src/director/director.c | 2 +- src/director/doveadm-connection.c | 2 +- src/director/login-connection.c | 2 +- src/director/mail-host.c | 2 +- src/director/main.c | 2 +- src/director/notify-connection.c | 2 +- src/director/test-user-directory.c | 2 +- src/director/user-directory.c | 2 +- src/dns/dns-client-settings.c | 2 +- src/dns/dns-client.c | 2 +- src/doveadm/client-connection.c | 2 +- src/doveadm/doveadm-auth.c | 2 +- src/doveadm/doveadm-director.c | 2 +- src/doveadm/doveadm-dump-dbox.c | 2 +- src/doveadm/doveadm-dump-index.c | 2 +- src/doveadm/doveadm-dump-log.c | 2 +- src/doveadm/doveadm-dump-mailboxlog.c | 2 +- src/doveadm/doveadm-dump-thread.c | 2 +- src/doveadm/doveadm-dump.c | 2 +- src/doveadm/doveadm-instance.c | 2 +- src/doveadm/doveadm-kick.c | 2 +- src/doveadm/doveadm-log.c | 2 +- src/doveadm/doveadm-mail-altmove.c | 2 +- src/doveadm/doveadm-mail-copymove.c | 2 +- src/doveadm/doveadm-mail-expunge.c | 2 +- src/doveadm/doveadm-mail-fetch.c | 2 +- src/doveadm/doveadm-mail-import.c | 2 +- src/doveadm/doveadm-mail-index.c | 2 +- src/doveadm/doveadm-mail-iter.c | 2 +- src/doveadm/doveadm-mail-mailbox-status.c | 2 +- src/doveadm/doveadm-mail-mailbox.c | 2 +- src/doveadm/doveadm-mail-search.c | 2 +- src/doveadm/doveadm-mail-server.c | 2 +- src/doveadm/doveadm-mail.c | 2 +- src/doveadm/doveadm-mailbox-list-iter.c | 2 +- src/doveadm/doveadm-master.c | 2 +- src/doveadm/doveadm-mount.c | 2 +- src/doveadm/doveadm-mutf7.c | 2 +- src/doveadm/doveadm-penalty.c | 2 +- src/doveadm/doveadm-print-flow.c | 2 +- src/doveadm/doveadm-print-pager.c | 2 +- src/doveadm/doveadm-print-server.c | 2 +- src/doveadm/doveadm-print-tab.c | 2 +- src/doveadm/doveadm-print-table.c | 2 +- src/doveadm/doveadm-print.c | 2 +- src/doveadm/doveadm-proxy.c | 2 +- src/doveadm/doveadm-pw.c | 2 +- src/doveadm/doveadm-settings.c | 2 +- src/doveadm/doveadm-sis.c | 2 +- src/doveadm/doveadm-stats.c | 2 +- src/doveadm/doveadm-util.c | 2 +- src/doveadm/doveadm-who.c | 2 +- src/doveadm/doveadm-zlib.c | 2 +- src/doveadm/doveadm.c | 2 +- src/doveadm/dsync/doveadm-dsync.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox-tree.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox.c | 2 +- src/doveadm/dsync/dsync-brain-mails.c | 2 +- src/doveadm/dsync/dsync-brain.c | 2 +- src/doveadm/dsync/dsync-deserializer.c | 2 +- src/doveadm/dsync/dsync-ibc-pipe.c | 2 +- src/doveadm/dsync/dsync-ibc-stream.c | 2 +- src/doveadm/dsync/dsync-ibc.c | 2 +- src/doveadm/dsync/dsync-mail.c | 2 +- src/doveadm/dsync/dsync-mailbox-export.c | 2 +- src/doveadm/dsync/dsync-mailbox-import.c | 2 +- src/doveadm/dsync/dsync-mailbox-state.c | 2 +- src/doveadm/dsync/dsync-mailbox-tree-fill.c | 2 +- src/doveadm/dsync/dsync-mailbox-tree-sync.c | 2 +- src/doveadm/dsync/dsync-mailbox-tree.c | 2 +- src/doveadm/dsync/dsync-serializer.c | 2 +- src/doveadm/dsync/dsync-transaction-log-scan.c | 2 +- src/doveadm/dsync/test-dsync-mailbox-tree-sync.c | 2 +- src/doveadm/main.c | 2 +- src/doveadm/server-connection.c | 2 +- src/imap-login/client-authenticate.c | 2 +- src/imap-login/client.c | 2 +- src/imap-login/imap-login-settings.c | 2 +- src/imap-login/imap-proxy.c | 2 +- src/imap-urlauth/imap-urlauth-client.c | 2 +- src/imap-urlauth/imap-urlauth-login-settings.c | 2 +- src/imap-urlauth/imap-urlauth-login.c | 2 +- src/imap-urlauth/imap-urlauth-settings.c | 2 +- src/imap-urlauth/imap-urlauth-worker-settings.c | 2 +- src/imap-urlauth/imap-urlauth-worker.c | 2 +- src/imap-urlauth/imap-urlauth.c | 2 +- src/imap/cmd-append.c | 2 +- src/imap/cmd-cancelupdate.c | 2 +- src/imap/cmd-capability.c | 2 +- src/imap/cmd-check.c | 2 +- src/imap/cmd-close.c | 2 +- src/imap/cmd-copy.c | 2 +- src/imap/cmd-create.c | 2 +- src/imap/cmd-delete.c | 2 +- src/imap/cmd-enable.c | 2 +- src/imap/cmd-examine.c | 2 +- src/imap/cmd-expunge.c | 2 +- src/imap/cmd-fetch.c | 2 +- src/imap/cmd-genurlauth.c | 2 +- src/imap/cmd-id.c | 2 +- src/imap/cmd-idle.c | 2 +- src/imap/cmd-list.c | 2 +- src/imap/cmd-logout.c | 2 +- src/imap/cmd-lsub.c | 2 +- src/imap/cmd-namespace.c | 2 +- src/imap/cmd-noop.c | 2 +- src/imap/cmd-notify.c | 2 +- src/imap/cmd-rename.c | 2 +- src/imap/cmd-resetkey.c | 2 +- src/imap/cmd-search.c | 2 +- src/imap/cmd-select.c | 2 +- src/imap/cmd-sort.c | 2 +- src/imap/cmd-status.c | 2 +- src/imap/cmd-store.c | 2 +- src/imap/cmd-subscribe.c | 2 +- src/imap/cmd-thread.c | 2 +- src/imap/cmd-uid.c | 2 +- src/imap/cmd-unselect.c | 2 +- src/imap/cmd-unsubscribe.c | 2 +- src/imap/cmd-urlfetch.c | 2 +- src/imap/cmd-x-cancel.c | 2 +- src/imap/imap-client.c | 2 +- src/imap/imap-commands-util.c | 2 +- src/imap/imap-commands.c | 2 +- src/imap/imap-expunge.c | 2 +- src/imap/imap-fetch-body.c | 2 +- src/imap/imap-fetch.c | 2 +- src/imap/imap-list.c | 2 +- src/imap/imap-notify.c | 2 +- src/imap/imap-search-args.c | 2 +- src/imap/imap-search.c | 2 +- src/imap/imap-settings.c | 2 +- src/imap/imap-status.c | 2 +- src/imap/imap-sync.c | 2 +- src/imap/mail-storage-callbacks.c | 2 +- src/imap/main.c | 2 +- src/indexer/indexer-client.c | 2 +- src/indexer/indexer-queue.c | 2 +- src/indexer/indexer-settings.c | 2 +- src/indexer/indexer-worker-settings.c | 2 +- src/indexer/indexer-worker.c | 2 +- src/indexer/indexer.c | 2 +- src/indexer/master-connection.c | 2 +- src/indexer/worker-connection.c | 2 +- src/indexer/worker-pool.c | 2 +- src/ipc/client.c | 2 +- src/ipc/ipc-connection.c | 2 +- src/ipc/ipc-group.c | 2 +- src/ipc/ipc-settings.c | 2 +- src/ipc/main.c | 2 +- src/lda/main.c | 2 +- src/lib-auth/auth-client-request.c | 2 +- src/lib-auth/auth-client.c | 2 +- src/lib-auth/auth-master.c | 2 +- src/lib-auth/auth-server-connection.c | 2 +- src/lib-charset/charset-iconv.c | 2 +- src/lib-charset/charset-utf8.c | 2 +- src/lib-compression/compression.c | 2 +- src/lib-compression/istream-bzlib.c | 2 +- src/lib-compression/istream-zlib.c | 2 +- src/lib-compression/ostream-bzlib.c | 2 +- src/lib-compression/ostream-zlib.c | 2 +- src/lib-dict/dict-client.c | 2 +- src/lib-dict/dict-db.c | 2 +- src/lib-dict/dict-file.c | 2 +- src/lib-dict/dict-memcached-ascii.c | 2 +- src/lib-dict/dict-memcached.c | 2 +- src/lib-dict/dict-redis.c | 2 +- src/lib-dict/dict-sql-settings.c | 2 +- src/lib-dict/dict-sql.c | 2 +- src/lib-dict/dict-transaction-memory.c | 2 +- src/lib-dict/dict.c | 2 +- src/lib-dict/test-dict.c | 2 +- src/lib-dns/dns-lookup.c | 2 +- src/lib-fs/fs-api.c | 2 +- src/lib-fs/fs-posix.c | 2 +- src/lib-fs/fs-sis-common.c | 2 +- src/lib-fs/fs-sis-queue.c | 2 +- src/lib-fs/fs-sis.c | 2 +- src/lib-fs/fs-test.c | 2 +- src/lib-fs/istream-metawrap.c | 2 +- src/lib-fs/ostream-cmp.c | 2 +- src/lib-http/http-client-connection.c | 2 +- src/lib-http/http-client-host.c | 2 +- src/lib-http/http-client-peer.c | 2 +- src/lib-http/http-client-request.c | 2 +- src/lib-http/http-client.c | 2 +- src/lib-http/http-date.c | 2 +- src/lib-http/http-header-parser.c | 2 +- src/lib-http/http-parser.c | 2 +- src/lib-http/http-response-parser.c | 2 +- src/lib-http/http-transfer-chunked.c | 2 +- src/lib-http/http-url.c | 2 +- src/lib-http/test-http-client.c | 2 +- src/lib-http/test-http-date.c | 2 +- src/lib-http/test-http-header-parser.c | 2 +- src/lib-http/test-http-response-parser.c | 2 +- src/lib-http/test-http-transfer.c | 2 +- src/lib-http/test-http-url.c | 2 +- src/lib-imap-client/imapc-client.c | 2 +- src/lib-imap-client/imapc-connection.c | 2 +- src/lib-imap-client/imapc-msgmap.c | 2 +- src/lib-imap-storage/imap-msgpart-url.c | 2 +- src/lib-imap-storage/imap-msgpart.c | 2 +- src/lib-imap-urlauth/imap-urlauth-backend.c | 2 +- src/lib-imap-urlauth/imap-urlauth-connection.c | 2 +- src/lib-imap-urlauth/imap-urlauth-fetch.c | 2 +- src/lib-imap-urlauth/imap-urlauth.c | 2 +- src/lib-imap/imap-arg.c | 2 +- src/lib-imap/imap-base-subject.c | 2 +- src/lib-imap/imap-bodystructure.c | 2 +- src/lib-imap/imap-date.c | 2 +- src/lib-imap/imap-envelope.c | 2 +- src/lib-imap/imap-id.c | 2 +- src/lib-imap/imap-match.c | 2 +- src/lib-imap/imap-parser.c | 2 +- src/lib-imap/imap-quote.c | 2 +- src/lib-imap/imap-seqset.c | 2 +- src/lib-imap/imap-url.c | 2 +- src/lib-imap/imap-utf7.c | 2 +- src/lib-imap/imap-util.c | 2 +- src/lib-imap/test-imap-bodystructure.c | 2 +- src/lib-imap/test-imap-match.c | 2 +- src/lib-imap/test-imap-parser.c | 2 +- src/lib-imap/test-imap-url.c | 2 +- src/lib-imap/test-imap-utf7.c | 2 +- src/lib-imap/test-imap-util.c | 2 +- src/lib-index/mail-cache-compress.c | 2 +- src/lib-index/mail-cache-decisions.c | 2 +- src/lib-index/mail-cache-fields.c | 2 +- src/lib-index/mail-cache-lookup.c | 2 +- src/lib-index/mail-cache-sync-update.c | 2 +- src/lib-index/mail-cache-transaction.c | 2 +- src/lib-index/mail-cache.c | 2 +- src/lib-index/mail-index-alloc-cache.c | 2 +- src/lib-index/mail-index-dummy-view.c | 2 +- src/lib-index/mail-index-fsck.c | 2 +- src/lib-index/mail-index-lock.c | 2 +- src/lib-index/mail-index-map-hdr.c | 2 +- src/lib-index/mail-index-map-read.c | 2 +- src/lib-index/mail-index-map.c | 2 +- src/lib-index/mail-index-modseq.c | 2 +- src/lib-index/mail-index-strmap.c | 2 +- src/lib-index/mail-index-sync-ext.c | 2 +- src/lib-index/mail-index-sync-keywords.c | 2 +- src/lib-index/mail-index-sync-update.c | 2 +- src/lib-index/mail-index-sync.c | 2 +- src/lib-index/mail-index-transaction-export.c | 2 +- src/lib-index/mail-index-transaction-finish.c | 2 +- src/lib-index/mail-index-transaction-sort-appends.c | 2 +- src/lib-index/mail-index-transaction-update.c | 2 +- src/lib-index/mail-index-transaction-view.c | 2 +- src/lib-index/mail-index-transaction.c | 2 +- src/lib-index/mail-index-util.c | 2 +- src/lib-index/mail-index-view-sync.c | 2 +- src/lib-index/mail-index-view.c | 2 +- src/lib-index/mail-index-write.c | 2 +- src/lib-index/mail-index.c | 2 +- src/lib-index/mail-transaction-log-append.c | 2 +- src/lib-index/mail-transaction-log-file.c | 2 +- src/lib-index/mail-transaction-log-view.c | 2 +- src/lib-index/mail-transaction-log.c | 2 +- src/lib-index/mailbox-log.c | 2 +- src/lib-index/test-mail-index-sync-ext.c | 2 +- src/lib-index/test-mail-index-transaction-finish.c | 2 +- src/lib-index/test-mail-index-transaction-update.c | 2 +- src/lib-index/test-mail-transaction-log-append.c | 2 +- src/lib-index/test-mail-transaction-log-view.c | 2 +- src/lib-lda/duplicate.c | 2 +- src/lib-lda/lda-settings.c | 2 +- src/lib-lda/lmtp-client.c | 2 +- src/lib-lda/mail-deliver.c | 2 +- src/lib-lda/mail-send.c | 2 +- src/lib-lda/smtp-client.c | 2 +- src/lib-mail/istream-attachment-connector.c | 2 +- src/lib-mail/istream-attachment-extractor.c | 2 +- src/lib-mail/istream-binary-converter.c | 2 +- src/lib-mail/istream-dot.c | 2 +- src/lib-mail/istream-header-filter.c | 2 +- src/lib-mail/istream-nonuls.c | 2 +- src/lib-mail/istream-qp-decoder.c | 2 +- src/lib-mail/mail-user-hash.c | 2 +- src/lib-mail/mbox-from.c | 2 +- src/lib-mail/message-address.c | 2 +- src/lib-mail/message-binary-part.c | 2 +- src/lib-mail/message-date.c | 2 +- src/lib-mail/message-decoder.c | 2 +- src/lib-mail/message-header-decode.c | 2 +- src/lib-mail/message-header-encode.c | 2 +- src/lib-mail/message-header-parser.c | 2 +- src/lib-mail/message-id.c | 2 +- src/lib-mail/message-parser.c | 2 +- src/lib-mail/message-part-serialize.c | 2 +- src/lib-mail/message-search.c | 2 +- src/lib-mail/message-size.c | 2 +- src/lib-mail/quoted-printable.c | 2 +- src/lib-mail/rfc2231-parser.c | 2 +- src/lib-mail/rfc822-parser.c | 2 +- src/lib-mail/test-istream-attachment.c | 2 +- src/lib-mail/test-istream-binary-converter.c | 2 +- src/lib-mail/test-istream-dot.c | 2 +- src/lib-mail/test-istream-header-filter.c | 2 +- src/lib-mail/test-istream-qp-decoder.c | 2 +- src/lib-mail/test-mbox-from.c | 2 +- src/lib-mail/test-message-address.c | 2 +- src/lib-mail/test-message-date.c | 2 +- src/lib-mail/test-message-decoder.c | 2 +- src/lib-mail/test-message-header-decode.c | 2 +- src/lib-mail/test-message-header-encode.c | 2 +- src/lib-mail/test-message-header-parser.c | 2 +- src/lib-mail/test-message-id.c | 2 +- src/lib-mail/test-message-parser.c | 2 +- src/lib-mail/test-quoted-printable.c | 2 +- src/lib-mail/test-rfc2231-parser.c | 2 +- src/lib-master/anvil-client.c | 2 +- src/lib-master/ipc-client.c | 2 +- src/lib-master/ipc-server.c | 2 +- src/lib-master/master-auth.c | 2 +- src/lib-master/master-instance.c | 2 +- src/lib-master/master-login-auth.c | 2 +- src/lib-master/master-login.c | 2 +- src/lib-master/master-service-settings-cache.c | 2 +- src/lib-master/master-service-settings.c | 2 +- src/lib-master/master-service-ssl-settings.c | 2 +- src/lib-master/master-service-ssl.c | 2 +- src/lib-master/master-service.c | 2 +- src/lib-master/mountpoint-list.c | 2 +- src/lib-master/syslog-util.c | 2 +- src/lib-settings/settings-parser.c | 2 +- src/lib-settings/settings.c | 2 +- src/lib-sql/driver-mysql.c | 2 +- src/lib-sql/driver-pgsql.c | 2 +- src/lib-sql/driver-sqlite.c | 2 +- src/lib-sql/driver-sqlpool.c | 2 +- src/lib-sql/sql-api.c | 2 +- src/lib-sql/sql-db-cache.c | 2 +- src/lib-ssl-iostream/iostream-openssl-common.c | 2 +- src/lib-ssl-iostream/iostream-openssl-context.c | 2 +- src/lib-ssl-iostream/iostream-openssl-params.c | 2 +- src/lib-ssl-iostream/iostream-openssl.c | 2 +- src/lib-ssl-iostream/iostream-ssl-none.c | 2 +- src/lib-ssl-iostream/iostream-ssl.c | 2 +- src/lib-ssl-iostream/istream-openssl.c | 2 +- src/lib-ssl-iostream/ostream-openssl.c | 2 +- src/lib-storage/fail-mail-storage.c | 2 +- src/lib-storage/fail-mail.c | 2 +- src/lib-storage/fail-mailbox.c | 2 +- src/lib-storage/index/cydir/cydir-mail.c | 2 +- src/lib-storage/index/cydir/cydir-save.c | 2 +- src/lib-storage/index/cydir/cydir-storage.c | 2 +- src/lib-storage/index/cydir/cydir-sync.c | 2 +- src/lib-storage/index/dbox-common/dbox-attachment.c | 2 +- src/lib-storage/index/dbox-common/dbox-file-fix.c | 2 +- src/lib-storage/index/dbox-common/dbox-file.c | 2 +- src/lib-storage/index/dbox-common/dbox-mail.c | 2 +- src/lib-storage/index/dbox-common/dbox-save.c | 2 +- src/lib-storage/index/dbox-common/dbox-storage.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-file.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-mail.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-map.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-purge.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-save.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-settings.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-storage.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-sync.c | 2 +- src/lib-storage/index/dbox-single/sdbox-copy.c | 2 +- src/lib-storage/index/dbox-single/sdbox-file.c | 2 +- src/lib-storage/index/dbox-single/sdbox-mail.c | 2 +- src/lib-storage/index/dbox-single/sdbox-save.c | 2 +- src/lib-storage/index/dbox-single/sdbox-storage.c | 2 +- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +- src/lib-storage/index/dbox-single/sdbox-sync.c | 2 +- src/lib-storage/index/imapc/imapc-list.c | 2 +- src/lib-storage/index/imapc/imapc-mail-fetch.c | 2 +- src/lib-storage/index/imapc/imapc-mail.c | 2 +- src/lib-storage/index/imapc/imapc-mailbox.c | 2 +- src/lib-storage/index/imapc/imapc-save.c | 2 +- src/lib-storage/index/imapc/imapc-settings.c | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/index/imapc/imapc-sync.c | 2 +- src/lib-storage/index/index-attachment.c | 2 +- src/lib-storage/index/index-attribute.c | 2 +- src/lib-storage/index/index-mail-binary.c | 2 +- src/lib-storage/index/index-mail-headers.c | 2 +- src/lib-storage/index/index-mail.c | 2 +- src/lib-storage/index/index-mailbox-check.c | 2 +- src/lib-storage/index/index-rebuild.c | 2 +- src/lib-storage/index/index-search-result.c | 2 +- src/lib-storage/index/index-search.c | 2 +- src/lib-storage/index/index-sort-string.c | 2 +- src/lib-storage/index/index-sort.c | 2 +- src/lib-storage/index/index-status.c | 2 +- src/lib-storage/index/index-storage.c | 2 +- src/lib-storage/index/index-sync-changes.c | 2 +- src/lib-storage/index/index-sync-pvt.c | 2 +- src/lib-storage/index/index-sync-search.c | 2 +- src/lib-storage/index/index-sync.c | 2 +- src/lib-storage/index/index-thread-finish.c | 2 +- src/lib-storage/index/index-thread-links.c | 2 +- src/lib-storage/index/index-thread.c | 2 +- src/lib-storage/index/index-transaction.c | 2 +- src/lib-storage/index/istream-mail.c | 2 +- src/lib-storage/index/maildir/maildir-copy.c | 2 +- src/lib-storage/index/maildir/maildir-filename-flags.c | 2 +- src/lib-storage/index/maildir/maildir-filename.c | 2 +- src/lib-storage/index/maildir/maildir-keywords.c | 2 +- src/lib-storage/index/maildir/maildir-mail.c | 2 +- src/lib-storage/index/maildir/maildir-save.c | 2 +- src/lib-storage/index/maildir/maildir-settings.c | 2 +- src/lib-storage/index/maildir/maildir-storage.c | 2 +- src/lib-storage/index/maildir/maildir-sync-index.c | 2 +- src/lib-storage/index/maildir/maildir-sync.c | 2 +- src/lib-storage/index/maildir/maildir-uidlist.c | 2 +- src/lib-storage/index/maildir/maildir-util.c | 2 +- src/lib-storage/index/mbox/istream-raw-mbox.c | 2 +- src/lib-storage/index/mbox/mbox-file.c | 2 +- src/lib-storage/index/mbox/mbox-lock.c | 2 +- src/lib-storage/index/mbox/mbox-mail.c | 2 +- src/lib-storage/index/mbox/mbox-md5-all.c | 2 +- src/lib-storage/index/mbox/mbox-md5-apop3d.c | 2 +- src/lib-storage/index/mbox/mbox-save.c | 2 +- src/lib-storage/index/mbox/mbox-settings.c | 2 +- src/lib-storage/index/mbox/mbox-storage.c | 2 +- src/lib-storage/index/mbox/mbox-sync-parse.c | 2 +- src/lib-storage/index/mbox/mbox-sync-rewrite.c | 2 +- src/lib-storage/index/mbox/mbox-sync-update.c | 2 +- src/lib-storage/index/mbox/mbox-sync.c | 2 +- src/lib-storage/index/pop3c/pop3c-client.c | 2 +- src/lib-storage/index/pop3c/pop3c-mail.c | 2 +- src/lib-storage/index/pop3c/pop3c-settings.c | 2 +- src/lib-storage/index/pop3c/pop3c-storage.c | 2 +- src/lib-storage/index/pop3c/pop3c-sync.c | 2 +- src/lib-storage/index/raw/raw-mail.c | 2 +- src/lib-storage/index/raw/raw-storage.c | 2 +- src/lib-storage/index/raw/raw-sync.c | 2 +- src/lib-storage/index/shared/shared-list.c | 2 +- src/lib-storage/index/shared/shared-storage.c | 2 +- src/lib-storage/list/mailbox-list-delete.c | 2 +- src/lib-storage/list/mailbox-list-fs-flags.c | 2 +- src/lib-storage/list/mailbox-list-fs-iter.c | 2 +- src/lib-storage/list/mailbox-list-fs.c | 2 +- src/lib-storage/list/mailbox-list-index-backend.c | 2 +- src/lib-storage/list/mailbox-list-index-iter.c | 2 +- src/lib-storage/list/mailbox-list-index-notify.c | 2 +- src/lib-storage/list/mailbox-list-index-status.c | 2 +- src/lib-storage/list/mailbox-list-index-sync.c | 2 +- src/lib-storage/list/mailbox-list-index.c | 2 +- src/lib-storage/list/mailbox-list-iter.c | 2 +- src/lib-storage/list/mailbox-list-maildir-iter.c | 2 +- src/lib-storage/list/mailbox-list-maildir.c | 2 +- src/lib-storage/list/mailbox-list-none.c | 2 +- src/lib-storage/list/mailbox-list-notify-tree.c | 2 +- src/lib-storage/list/mailbox-list-subscriptions.c | 2 +- src/lib-storage/list/subscription-file.c | 2 +- src/lib-storage/mail-copy.c | 2 +- src/lib-storage/mail-error.c | 2 +- src/lib-storage/mail-namespace.c | 2 +- src/lib-storage/mail-search-build.c | 2 +- src/lib-storage/mail-search-parser-cmdline.c | 2 +- src/lib-storage/mail-search-parser-imap.c | 2 +- src/lib-storage/mail-search-parser.c | 2 +- src/lib-storage/mail-search-register-human.c | 2 +- src/lib-storage/mail-search-register-imap.c | 2 +- src/lib-storage/mail-search-register.c | 2 +- src/lib-storage/mail-search.c | 2 +- src/lib-storage/mail-storage-hooks.c | 2 +- src/lib-storage/mail-storage-service.c | 2 +- src/lib-storage/mail-storage-settings.c | 2 +- src/lib-storage/mail-storage.c | 2 +- src/lib-storage/mail-thread.c | 2 +- src/lib-storage/mail-user.c | 2 +- src/lib-storage/mail.c | 2 +- src/lib-storage/mailbox-get.c | 2 +- src/lib-storage/mailbox-guid-cache.c | 2 +- src/lib-storage/mailbox-header.c | 2 +- src/lib-storage/mailbox-keywords.c | 2 +- src/lib-storage/mailbox-list-notify.c | 2 +- src/lib-storage/mailbox-list.c | 2 +- src/lib-storage/mailbox-search-result.c | 2 +- src/lib-storage/mailbox-tree.c | 2 +- src/lib-storage/mailbox-uidvalidity.c | 2 +- src/lib-storage/test-mailbox-get.c | 2 +- src/lib-test/test-common.c | 2 +- src/lib/abspath.c | 2 +- src/lib/aqueue.c | 2 +- src/lib/array.c | 2 +- src/lib/askpass.c | 2 +- src/lib/backtrace-string.c | 2 +- src/lib/base64.c | 2 +- src/lib/bsearch-insert-pos.c | 2 +- src/lib/buffer.c | 2 +- src/lib/child-wait.c | 2 +- src/lib/compat.c | 2 +- src/lib/connection.c | 2 +- src/lib/crc32.c | 2 +- src/lib/data-stack.c | 2 +- src/lib/eacces-error.c | 2 +- src/lib/env-util.c | 2 +- src/lib/execv-const.c | 2 +- src/lib/failures.c | 2 +- src/lib/fd-close-on-exec.c | 2 +- src/lib/fd-set-nonblock.c | 2 +- src/lib/fdatasync-path.c | 2 +- src/lib/fdpass.c | 2 +- src/lib/file-cache.c | 2 +- src/lib/file-copy.c | 2 +- src/lib/file-dotlock.c | 2 +- src/lib/file-lock.c | 2 +- src/lib/file-set-size.c | 2 +- src/lib/guid.c | 2 +- src/lib/hash-format.c | 2 +- src/lib/hash-method.c | 2 +- src/lib/hash.c | 2 +- src/lib/hash2.c | 2 +- src/lib/hex-binary.c | 2 +- src/lib/hex-dec.c | 2 +- src/lib/home-expand.c | 2 +- src/lib/hostpid.c | 2 +- src/lib/imem.c | 2 +- src/lib/ioloop-epoll.c | 2 +- src/lib/ioloop-notify-dn.c | 2 +- src/lib/ioloop-notify-fd.c | 2 +- src/lib/ioloop-notify-inotify.c | 2 +- src/lib/ioloop-notify-none.c | 2 +- src/lib/ioloop-poll.c | 2 +- src/lib/ioloop-select.c | 2 +- src/lib/ioloop.c | 2 +- src/lib/iostream-rawlog.c | 2 +- src/lib/iostream-temp.c | 2 +- src/lib/iostream.c | 2 +- src/lib/iso8601-date.c | 2 +- src/lib/istream-base64-decoder.c | 2 +- src/lib/istream-base64-encoder.c | 2 +- src/lib/istream-chain.c | 2 +- src/lib/istream-concat.c | 2 +- src/lib/istream-crlf.c | 2 +- src/lib/istream-data.c | 2 +- src/lib/istream-file.c | 2 +- src/lib/istream-jsonstr.c | 2 +- src/lib/istream-limit.c | 2 +- src/lib/istream-mmap.c | 2 +- src/lib/istream-rawlog.c | 2 +- src/lib/istream-seekable.c | 2 +- src/lib/istream-sized.c | 2 +- src/lib/istream-tee.c | 2 +- src/lib/istream.c | 2 +- src/lib/json-parser.c | 2 +- src/lib/lib-signals.c | 2 +- src/lib/lib.c | 2 +- src/lib/mempool-alloconly.c | 2 +- src/lib/mempool-datastack.c | 2 +- src/lib/mempool-system.c | 2 +- src/lib/mempool-unsafe-datastack.c | 2 +- src/lib/mempool.c | 2 +- src/lib/mkdir-parents.c | 2 +- src/lib/mmap-anon.c | 2 +- src/lib/mmap-util.c | 2 +- src/lib/module-dir.c | 2 +- src/lib/mountpoint.c | 2 +- src/lib/net.c | 2 +- src/lib/nfs-workarounds.c | 2 +- src/lib/numpack.c | 2 +- src/lib/ostream-buffer.c | 2 +- src/lib/ostream-file.c | 2 +- src/lib/ostream-rawlog.c | 2 +- src/lib/ostream.c | 2 +- src/lib/primes.c | 2 +- src/lib/printf-format-fix.c | 2 +- src/lib/priorityq.c | 2 +- src/lib/process-title.c | 2 +- src/lib/randgen.c | 2 +- src/lib/read-full.c | 2 +- src/lib/restrict-access.c | 2 +- src/lib/restrict-process-size.c | 2 +- src/lib/safe-memset.c | 2 +- src/lib/safe-mkdir.c | 2 +- src/lib/safe-mkstemp.c | 2 +- src/lib/sendfile-util.c | 2 +- src/lib/seq-range-array.c | 2 +- src/lib/str-find.c | 2 +- src/lib/str-sanitize.c | 2 +- src/lib/str.c | 2 +- src/lib/strescape.c | 2 +- src/lib/strfuncs.c | 2 +- src/lib/strnum.c | 2 +- src/lib/test-aqueue.c | 2 +- src/lib/test-array.c | 2 +- src/lib/test-base64.c | 2 +- src/lib/test-bsearch-insert-pos.c | 2 +- src/lib/test-buffer.c | 2 +- src/lib/test-crc32.c | 2 +- src/lib/test-hash-format.c | 2 +- src/lib/test-hex-binary.c | 2 +- src/lib/test-iso8601-date.c | 2 +- src/lib/test-istream-base64-decoder.c | 2 +- src/lib/test-istream-base64-encoder.c | 2 +- src/lib/test-istream-concat.c | 2 +- src/lib/test-istream-crlf.c | 2 +- src/lib/test-istream-seekable.c | 2 +- src/lib/test-istream-tee.c | 2 +- src/lib/test-json-parser.c | 2 +- src/lib/test-lib.c | 2 +- src/lib/test-llist.c | 2 +- src/lib/test-mempool-alloconly.c | 2 +- src/lib/test-network.c | 2 +- src/lib/test-numpack.c | 2 +- src/lib/test-ostream-file.c | 2 +- src/lib/test-primes.c | 2 +- src/lib/test-priorityq.c | 2 +- src/lib/test-seq-range-array.c | 2 +- src/lib/test-str-find.c | 2 +- src/lib/test-str-sanitize.c | 2 +- src/lib/test-strescape.c | 2 +- src/lib/test-strfuncs.c | 2 +- src/lib/test-time-util.c | 2 +- src/lib/test-unichar.c | 2 +- src/lib/test-utc-mktime.c | 2 +- src/lib/test-var-expand.c | 2 +- src/lib/time-util.c | 2 +- src/lib/unichar.c | 2 +- src/lib/unix-socket-create.c | 2 +- src/lib/unlink-directory.c | 2 +- src/lib/unlink-old-files.c | 2 +- src/lib/uri-util.c | 2 +- src/lib/utc-mktime.c | 2 +- src/lib/utc-offset.c | 2 +- src/lib/var-expand.c | 2 +- src/lib/write-full.c | 2 +- src/lmtp/client.c | 2 +- src/lmtp/commands.c | 2 +- src/lmtp/lmtp-proxy.c | 2 +- src/lmtp/lmtp-settings.c | 2 +- src/lmtp/main.c | 2 +- src/log/doveadm-connection.c | 2 +- src/log/log-connection.c | 2 +- src/log/log-error-buffer.c | 2 +- src/log/log-settings.c | 2 +- src/log/main.c | 2 +- src/login-common/access-lookup.c | 2 +- src/login-common/client-common-auth.c | 2 +- src/login-common/client-common.c | 2 +- src/login-common/login-proxy-state.c | 2 +- src/login-common/login-proxy.c | 2 +- src/login-common/login-settings.c | 2 +- src/login-common/main.c | 2 +- src/login-common/sasl-server.c | 2 +- src/login-common/ssl-proxy-gnutls.c | 2 +- src/login-common/ssl-proxy-openssl.c | 2 +- src/login-common/ssl-proxy.c | 2 +- src/master/capabilities-posix.c | 2 +- src/master/dup2-array.c | 2 +- src/master/main.c | 2 +- src/master/master-settings.c | 2 +- src/master/service-anvil.c | 2 +- src/master/service-listen.c | 2 +- src/master/service-log.c | 2 +- src/master/service-monitor.c | 2 +- src/master/service-process-notify.c | 2 +- src/master/service-process.c | 2 +- src/master/service.c | 2 +- src/plugins/acl/acl-api.c | 2 +- src/plugins/acl/acl-backend-vfile-acllist.c | 2 +- src/plugins/acl/acl-backend-vfile.c | 2 +- src/plugins/acl/acl-backend.c | 2 +- src/plugins/acl/acl-cache.c | 2 +- src/plugins/acl/acl-lookup-dict.c | 2 +- src/plugins/acl/acl-mailbox-list.c | 2 +- src/plugins/acl/acl-mailbox.c | 2 +- src/plugins/acl/acl-plugin.c | 2 +- src/plugins/acl/acl-shared-storage.c | 2 +- src/plugins/acl/acl-storage.c | 2 +- src/plugins/acl/doveadm-acl.c | 2 +- src/plugins/autocreate/autocreate-plugin.c | 2 +- src/plugins/expire/doveadm-expire.c | 2 +- src/plugins/expire/expire-plugin.c | 2 +- src/plugins/expire/expire-set.c | 2 +- src/plugins/fts-lucene/doveadm-fts-lucene.c | 2 +- src/plugins/fts-lucene/fts-backend-lucene.c | 2 +- src/plugins/fts-lucene/fts-lucene-plugin.c | 2 +- src/plugins/fts-solr/fts-backend-solr-old.c | 2 +- src/plugins/fts-solr/fts-backend-solr.c | 2 +- src/plugins/fts-solr/fts-solr-plugin.c | 2 +- src/plugins/fts-solr/solr-connection.c | 2 +- src/plugins/fts-squat/fts-backend-squat.c | 2 +- src/plugins/fts-squat/fts-squat-plugin.c | 2 +- src/plugins/fts-squat/squat-test.c | 2 +- src/plugins/fts-squat/squat-trie.c | 2 +- src/plugins/fts-squat/squat-uidlist.c | 2 +- src/plugins/fts/doveadm-dump-fts-expunge-log.c | 2 +- src/plugins/fts/doveadm-fts.c | 2 +- src/plugins/fts/fts-api.c | 2 +- src/plugins/fts/fts-build-mail.c | 2 +- src/plugins/fts/fts-expunge-log.c | 2 +- src/plugins/fts/fts-indexer.c | 2 +- src/plugins/fts/fts-parser-html.c | 2 +- src/plugins/fts/fts-parser-script.c | 2 +- src/plugins/fts/fts-parser.c | 2 +- src/plugins/fts/fts-plugin.c | 2 +- src/plugins/fts/fts-search-serialize.c | 2 +- src/plugins/fts/fts-search.c | 2 +- src/plugins/fts/fts-storage.c | 2 +- src/plugins/fts/xml2text.c | 2 +- src/plugins/imap-acl/imap-acl-plugin.c | 2 +- src/plugins/imap-quota/imap-quota-plugin.c | 2 +- src/plugins/imap-stats/imap-stats-plugin.c | 2 +- src/plugins/imap-zlib/imap-zlib-plugin.c | 2 +- src/plugins/lazy-expunge/lazy-expunge-plugin.c | 2 +- src/plugins/listescape/listescape-plugin.c | 2 +- src/plugins/mail-log/mail-log-plugin.c | 2 +- src/plugins/mailbox-alias/mailbox-alias-plugin.c | 2 +- src/plugins/notify/notify-plugin.c | 2 +- src/plugins/notify/notify-storage.c | 2 +- src/plugins/pop3-migration/pop3-migration-plugin.c | 2 +- src/plugins/quota/doveadm-quota.c | 2 +- src/plugins/quota/quota-count.c | 2 +- src/plugins/quota/quota-dict.c | 2 +- src/plugins/quota/quota-dirsize.c | 2 +- src/plugins/quota/quota-fs.c | 2 +- src/plugins/quota/quota-maildir.c | 2 +- src/plugins/quota/quota-plugin.c | 2 +- src/plugins/quota/quota-storage.c | 2 +- src/plugins/quota/quota.c | 2 +- src/plugins/replication/replication-plugin.c | 2 +- src/plugins/snarf/snarf-plugin.c | 2 +- src/plugins/stats/stats-connection.c | 2 +- src/plugins/stats/stats-plugin.c | 2 +- src/plugins/trash/trash-plugin.c | 2 +- src/plugins/virtual/virtual-config.c | 2 +- src/plugins/virtual/virtual-mail.c | 2 +- src/plugins/virtual/virtual-plugin.c | 2 +- src/plugins/virtual/virtual-save.c | 2 +- src/plugins/virtual/virtual-search.c | 2 +- src/plugins/virtual/virtual-storage.c | 2 +- src/plugins/virtual/virtual-sync.c | 2 +- src/plugins/virtual/virtual-transaction.c | 2 +- src/plugins/zlib/zlib-plugin.c | 2 +- src/pop3-login/client-authenticate.c | 2 +- src/pop3-login/client.c | 2 +- src/pop3-login/pop3-login-settings.c | 2 +- src/pop3-login/pop3-proxy.c | 2 +- src/pop3/main.c | 2 +- src/pop3/pop3-client.c | 2 +- src/pop3/pop3-commands.c | 2 +- src/pop3/pop3-settings.c | 2 +- src/replication/aggregator/aggregator-settings.c | 2 +- src/replication/aggregator/aggregator.c | 2 +- src/replication/aggregator/notify-connection.c | 2 +- src/replication/aggregator/replicator-connection.c | 2 +- src/replication/replicator/doveadm-connection.c | 2 +- src/replication/replicator/notify-connection.c | 2 +- src/replication/replicator/replicator-brain.c | 2 +- src/replication/replicator/replicator-queue.c | 2 +- src/replication/replicator/replicator-settings.c | 2 +- src/replication/replicator/replicator.c | 2 +- src/ssl-params/main.c | 2 +- src/ssl-params/ssl-params-openssl.c | 2 +- src/ssl-params/ssl-params-settings.c | 2 +- src/ssl-params/ssl-params.c | 2 +- src/stats/client-export.c | 2 +- src/stats/client.c | 2 +- src/stats/global-memory.c | 2 +- src/stats/mail-command.c | 2 +- src/stats/mail-domain.c | 2 +- src/stats/mail-ip.c | 2 +- src/stats/mail-server-connection.c | 2 +- src/stats/mail-session.c | 2 +- src/stats/mail-stats.c | 2 +- src/stats/mail-user.c | 2 +- src/stats/main.c | 2 +- src/stats/stats-settings.c | 2 +- src/util/gdbhelper.c | 2 +- src/util/maildirlock.c | 2 +- src/util/rawlog.c | 2 +- src/util/script-login.c | 2 +- src/util/script.c | 2 +- src/util/tcpwrap-settings.c | 2 +- src/util/tcpwrap.c | 2 +- 861 files changed, 861 insertions(+), 861 deletions(-) diffs (truncated from 7749 to 300 lines): diff -r 90710c6c3beb -r 36ef72481934 src/anvil/anvil-connection.c --- a/src/anvil/anvil-connection.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/anvil/anvil-connection.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "common.h" #include "llist.h" diff -r 90710c6c3beb -r 36ef72481934 src/anvil/anvil-settings.c --- a/src/anvil/anvil-settings.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/anvil/anvil-settings.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "buffer.h" diff -r 90710c6c3beb -r 36ef72481934 src/anvil/connect-limit.c --- a/src/anvil/connect-limit.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/anvil/connect-limit.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "common.h" #include "hash.h" diff -r 90710c6c3beb -r 36ef72481934 src/anvil/main.c --- a/src/anvil/main.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/anvil/main.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "common.h" #include "array.h" diff -r 90710c6c3beb -r 36ef72481934 src/anvil/penalty.c --- a/src/anvil/penalty.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/anvil/penalty.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ /* The idea behind checksums is that the same username+password doesn't increase the penalty, because it's most likely a user with a misconfigured diff -r 90710c6c3beb -r 36ef72481934 src/anvil/test-penalty.c --- a/src/anvil/test-penalty.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/anvil/test-penalty.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-cache.c --- a/src/auth/auth-cache.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-cache.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2004-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2004-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "lib-signals.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-client-connection.c --- a/src/auth/auth-client-connection.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-client-connection.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-fields.c --- a/src/auth/auth-fields.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-fields.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-master-connection.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "buffer.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-penalty.c --- a/src/auth/auth-penalty.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-penalty.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-postfix-connection.c --- a/src/auth/auth-postfix-connection.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-postfix-connection.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2011-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2011-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-request-handler.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-request.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-settings.c --- a/src/auth/auth-settings.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-settings.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "array.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-token.c --- a/src/auth/auth-token.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-token.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ /* Auth process maintains a random secret. Once a user authenticates the response to the REQUEST command from a master service is augmented with an diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-worker-client.c --- a/src/auth/auth-worker-client.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-worker-client.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "base64.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth-worker-server.c --- a/src/auth/auth-worker-server.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth-worker-server.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/auth.c --- a/src/auth/auth.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/auth.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/db-checkpassword.c --- a/src/auth/db-checkpassword.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/db-checkpassword.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2004-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2004-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/db-dict.c --- a/src/auth/db-dict.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/db-dict.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/db-ldap.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/db-passwd-file.c --- a/src/auth/db-passwd-file.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/db-passwd-file.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/db-sql.c --- a/src/auth/db-sql.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/db-sql.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/main.c --- a/src/auth/main.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/main.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/mech-anonymous.c --- a/src/auth/mech-anonymous.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/mech-anonymous.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "mech.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/mech-cram-md5.c --- a/src/auth/mech-cram-md5.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/mech-cram-md5.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ /* CRAM-MD5 SASL authentication, see RFC-2195 Joshua Goodall */ diff -r 90710c6c3beb -r 36ef72481934 src/auth/mech-digest-md5.c --- a/src/auth/mech-digest-md5.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/mech-digest-md5.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ /* Digest-MD5 SASL authentication, see RFC-2831 */ diff -r 90710c6c3beb -r 36ef72481934 src/auth/mech-dovecot-token.c --- a/src/auth/mech-dovecot-token.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/mech-dovecot-token.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ /* Used internally by Dovecot processes to authenticate against each others (e.g. imap to imap-urlauth). See auth-token.c */ diff -r 90710c6c3beb -r 36ef72481934 src/auth/mech-external.c --- a/src/auth/mech-external.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/mech-external.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "passdb.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/mech-plain.c --- a/src/auth/mech-plain.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/mech-plain.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "safe-memset.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/mech.c --- a/src/auth/mech.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/mech.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/passdb-blocking.c --- a/src/auth/passdb-blocking.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/passdb-blocking.c Sat Feb 02 17:02:55 2013 +0200 @@ -1,4 +1,4 @@ -* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "str.h" diff -r 90710c6c3beb -r 36ef72481934 src/auth/passdb-bsdauth.c --- a/src/auth/passdb-bsdauth.c Sat Feb 02 17:01:07 2013 +0200 +++ b/src/auth/passdb-bsdauth.c Sat Feb 02 17:02:55 2013 +0200 From dovecot at dovecot.org Sat Feb 2 22:21:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 02 Feb 2013 22:21:49 +0200 Subject: dovecot-2.2: fts-solr: Compile warning fix Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f4d33f3c1ab9 changeset: 15716:f4d33f3c1ab9 user: Timo Sirainen date: Sat Feb 02 22:21:36 2013 +0200 description: fts-solr: Compile warning fix diffstat: src/plugins/fts-solr/fts-solr-plugin.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 36ef72481934 -r f4d33f3c1ab9 src/plugins/fts-solr/fts-solr-plugin.c --- a/src/plugins/fts-solr/fts-solr-plugin.c Sat Feb 02 17:02:55 2013 +0200 +++ b/src/plugins/fts-solr/fts-solr-plugin.c Sat Feb 02 22:21:36 2013 +0200 @@ -4,6 +4,7 @@ #include "array.h" #include "mail-user.h" #include "mail-storage-hooks.h" +#include "solr-connection.h" #include "fts-solr-plugin.h" #include From dovecot at dovecot.org Sun Feb 3 21:53:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 03 Feb 2013 21:53:48 +0200 Subject: dovecot-2.2: lib-fs: istream-metawrap is a bit more flexible now... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/30922a3668a9 changeset: 15717:30922a3668a9 user: Timo Sirainen date: Sun Feb 03 21:48:58 2013 +0200 description: lib-fs: istream-metawrap is a bit more flexible now, allowing stat()ing and reading from fd diffstat: src/lib-fs/istream-metawrap.c | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diffs (61 lines): diff -r f4d33f3c1ab9 -r 30922a3668a9 src/lib-fs/istream-metawrap.c --- a/src/lib-fs/istream-metawrap.c Sat Feb 02 22:21:36 2013 +0200 +++ b/src/lib-fs/istream-metawrap.c Sun Feb 03 21:48:58 2013 +0200 @@ -34,6 +34,7 @@ mstream->istream.istream.eof = TRUE; return -1; } + i_assert(!mstream->istream.parent->blocking); return 0; } @@ -51,12 +52,38 @@ mstream->start_offset = stream->parent->v_offset; if (ret <= 0) return ret; + /* this stream is kind of silently skipping over the metadata */ + stream->abs_start_offset += mstream->start_offset; mstream->in_metadata = FALSE; } /* after metadata header it's all just passthrough */ return i_stream_read_copy_from_parent(&stream->istream); } +static int i_stream_metawrap_stat(struct istream_private *stream, bool exact) +{ + struct metawrap_istream *mstream = (struct metawrap_istream *)stream; + const struct stat *st; + int ret; + + if (i_stream_stat(stream->parent, exact, &st) < 0) + return -1; + stream->statbuf = *st; + + if (mstream->in_metadata) { + ret = i_stream_read(&stream->istream); + if (ret < 0) + return -1; + if (ret == 0) { + stream->statbuf.st_size = -1; + return 0; + } + } + i_assert((uoff_t)stream->statbuf.st_size >= mstream->start_offset); + stream->statbuf.st_size -= mstream->start_offset; + return 0; +} + struct istream * i_stream_create_metawrap(struct istream *input, metawrap_callback_t *callback, void *context) @@ -67,8 +94,9 @@ mstream->istream.max_buffer_size = input->real_stream->max_buffer_size; mstream->istream.read = i_stream_metawrap_read; + mstream->istream.stat = i_stream_metawrap_stat; - mstream->istream.istream.readable_fd = FALSE; + mstream->istream.istream.readable_fd = input->readable_fd; mstream->istream.istream.blocking = input->blocking; mstream->istream.istream.seekable = FALSE; mstream->in_metadata = TRUE; From dovecot at dovecot.org Sun Feb 3 21:53:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 03 Feb 2013 21:53:48 +0200 Subject: dovecot-2.2: lib-fs: fs-posix now allows reading from the same f... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1aed8e57ea1c changeset: 15718:1aed8e57ea1c user: Timo Sirainen date: Sun Feb 03 21:51:40 2013 +0200 description: lib-fs: fs-posix now allows reading from the same file that was created. diffstat: src/lib-fs/fs-posix.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 30922a3668a9 -r 1aed8e57ea1c src/lib-fs/fs-posix.c --- a/src/lib-fs/fs-posix.c Sun Feb 03 21:48:58 2013 +0200 +++ b/src/lib-fs/fs-posix.c Sun Feb 03 21:51:40 2013 +0200 @@ -404,6 +404,8 @@ i_free_and_null(file->temp_path); file->success = TRUE; file->seek_to_beginning = TRUE; + /* allow opening the file after writing to it */ + file->open_mode = FS_OPEN_MODE_READONLY; return 0; } From dovecot at dovecot.org Sun Feb 3 21:53:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 03 Feb 2013 21:53:48 +0200 Subject: dovecot-2.2: lib-fs: fs_write_stream_finish(file, NULL) is now a... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/01d238b13719 changeset: 15719:01d238b13719 user: Timo Sirainen date: Sun Feb 03 21:52:19 2013 +0200 description: lib-fs: fs_write_stream_finish(file, NULL) is now alias to fs_write_stream_finish_async(file) This makes wrapper implementations easier. diffstat: src/lib-fs/fs-api.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 1aed8e57ea1c -r 01d238b13719 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Sun Feb 03 21:51:40 2013 +0200 +++ b/src/lib-fs/fs-api.c Sun Feb 03 21:52:19 2013 +0200 @@ -314,7 +314,7 @@ int fs_write_stream_finish(struct fs_file *file, struct ostream **output) { - i_assert(*output == file->output); + i_assert(*output == file->output || *output == NULL); *output = NULL; return file->fs->v.write_stream_finish(file, TRUE); From dovecot at dovecot.org Sun Feb 3 21:53:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 03 Feb 2013 21:53:48 +0200 Subject: dovecot-2.2: i_stream_create_error() should have set eof=TRUE im... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/42e152c01ace changeset: 15720:42e152c01ace user: Timo Sirainen date: Sun Feb 03 21:52:48 2013 +0200 description: i_stream_create_error() should have set eof=TRUE immediately. diffstat: src/lib/istream.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 01d238b13719 -r 42e152c01ace src/lib/istream.c --- a/src/lib/istream.c Sun Feb 03 21:52:19 2013 +0200 +++ b/src/lib/istream.c Sun Feb 03 21:52:48 2013 +0200 @@ -707,6 +707,7 @@ stream->istream.readable_fd = FALSE; stream->istream.blocking = TRUE; stream->istream.seekable = TRUE; + stream->istream.eof = TRUE; stream->istream.stream_errno = stream_errno; i_stream_create(stream, NULL, -1); i_stream_set_name(&stream->istream, "(error)"); From dovecot at dovecot.org Sun Feb 3 21:53:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 03 Feb 2013 21:53:48 +0200 Subject: dovecot-2.2: iostream-temp: Avoid copying data if IOSTREAM_TEMP_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/50d43f04511b changeset: 15721:50d43f04511b user: Timo Sirainen date: Sun Feb 03 21:53:24 2013 +0200 description: iostream-temp: Avoid copying data if IOSTREAM_TEMP_FLAG_TRY_FD_DUP is set. diffstat: src/lib/iostream-temp.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++- src/lib/iostream-temp.h | 10 +++- 2 files changed, 114 insertions(+), 5 deletions(-) diffs (179 lines): diff -r 42e152c01ace -r 50d43f04511b src/lib/iostream-temp.c --- a/src/lib/iostream-temp.c Sun Feb 03 21:52:48 2013 +0200 +++ b/src/lib/iostream-temp.c Sun Feb 03 21:53:24 2013 +0200 @@ -5,7 +5,7 @@ #include "str.h" #include "safe-mkstemp.h" #include "write-full.h" -#include "istream.h" +#include "istream-private.h" #include "ostream-private.h" #include "iostream-temp.h" @@ -15,7 +15,13 @@ struct temp_ostream { struct ostream_private ostream; + char *temp_path_prefix; + enum iostream_temp_flags flags; + + struct istream *dupstream; + uoff_t dupstream_offset, dupstream_start_offset; + buffer_t *buf; int fd; bool fd_tried; @@ -87,6 +93,8 @@ ssize_t ret = 0; unsigned int i; + tstream->flags &= ~IOSTREAM_TEMP_FLAG_TRY_FD_DUP; + if (tstream->fd != -1) return o_stream_temp_fd_sendv(tstream, iov, iov_count); @@ -105,15 +113,91 @@ return ret; } -struct ostream *iostream_temp_create(const char *temp_path_prefix) +static int o_stream_temp_dup_cancel(struct temp_ostream *tstream) +{ + struct istream *input; + uoff_t size = tstream->dupstream_offset - + tstream->dupstream_start_offset; + off_t ret; + + i_stream_seek(tstream->dupstream, tstream->dupstream_start_offset); + + input = i_stream_create_limit(tstream->dupstream, size); + do { + ret = io_stream_copy(&tstream->ostream.ostream, + input, IO_BLOCK_SIZE); + } while (input->v_offset < tstream->dupstream_offset && ret > 0); + if (ret < 0 && tstream->ostream.ostream.stream_errno == 0) { + i_assert(input->stream_errno != 0); + tstream->ostream.ostream.stream_errno = input->stream_errno; + } + i_stream_destroy(&input); + i_stream_unref(&tstream->dupstream); + return ret < 0 ? -1 : 0; +} + +static int o_stream_temp_dup_istream(struct temp_ostream *outstream, + struct istream *instream) +{ + uoff_t in_size; + off_t ret; + + if (!instream->readable_fd || i_stream_get_fd(instream) == -1) + return 0; + + if (i_stream_get_size(instream, TRUE, &in_size) <= 0) { + if (outstream->dupstream != NULL) + return o_stream_temp_dup_cancel(outstream); + return 0; + } + + if (outstream->dupstream == NULL) { + outstream->dupstream = instream; + outstream->dupstream_start_offset = instream->v_offset; + i_stream_ref(outstream->dupstream); + } else { + if (outstream->dupstream != instream || + outstream->dupstream_offset != instream->v_offset || + outstream->dupstream_offset > in_size) + return o_stream_temp_dup_cancel(outstream); + } + ret = in_size - instream->v_offset; + i_stream_seek(instream, in_size); + outstream->dupstream_offset = instream->v_offset; + return ret; +} + +static off_t o_stream_temp_send_istream(struct ostream_private *_outstream, + struct istream *instream) +{ + struct temp_ostream *outstream = (struct temp_ostream *)_outstream; + uoff_t orig_offset; + int ret; + + if ((outstream->flags & IOSTREAM_TEMP_FLAG_TRY_FD_DUP) != 0) { + orig_offset = outstream->dupstream_offset; + if ((ret = o_stream_temp_dup_istream(outstream, instream)) > 0) + return outstream->dupstream_offset - orig_offset; + if (ret < 0) + return -1; + outstream->flags &= ~IOSTREAM_TEMP_FLAG_TRY_FD_DUP; + } + return io_stream_copy(&outstream->ostream.ostream, + instream, IO_BLOCK_SIZE); +} + +struct ostream *iostream_temp_create(const char *temp_path_prefix, + enum iostream_temp_flags flags) { struct temp_ostream *tstream; struct ostream *output; tstream = i_new(struct temp_ostream, 1); tstream->ostream.sendv = o_stream_temp_sendv; + tstream->ostream.send_istream = o_stream_temp_send_istream; tstream->ostream.iostream.close = o_stream_temp_close; tstream->temp_path_prefix = i_strdup(temp_path_prefix); + tstream->flags = flags; tstream->buf = buffer_create_dynamic(default_pool, 8192); tstream->fd = -1; @@ -132,9 +216,26 @@ { struct temp_ostream *tstream = (struct temp_ostream *)(*output)->real_stream; - struct istream *input; + struct istream *input, *input2; + uoff_t abs_offset, size; + int fd; - if (tstream->fd != -1) { + if (tstream->dupstream != NULL) { + abs_offset = tstream->dupstream->real_stream->abs_start_offset + + tstream->dupstream_start_offset; + size = tstream->dupstream_offset - + tstream->dupstream_start_offset; + fd = dup(i_stream_get_fd(tstream->dupstream)); + if (fd == -1) + input = i_stream_create_error(errno); + else { + input2 = i_stream_create_fd(fd, max_buffer_size, TRUE); + i_stream_seek(input2, abs_offset); + input = i_stream_create_limit(input2, size); + i_stream_unref(&input2); + } + i_stream_unref(&tstream->dupstream); + } else if (tstream->fd != -1) { input = i_stream_create_fd(tstream->fd, max_buffer_size, TRUE); tstream->fd = -1; } else { diff -r 42e152c01ace -r 50d43f04511b src/lib/iostream-temp.h --- a/src/lib/iostream-temp.h Sun Feb 03 21:52:48 2013 +0200 +++ b/src/lib/iostream-temp.h Sun Feb 03 21:53:24 2013 +0200 @@ -1,9 +1,17 @@ #ifndef IOSTREAM_TEMP_H #define IOSTREAM_TEMP_H +enum iostream_temp_flags { + /* if o_stream_send_istream() is called with a readable fd, don't + actually copy the input stream, just have iostream_temp_finish() + return a new iostream pointing to the fd dup()ed */ + IOSTREAM_TEMP_FLAG_TRY_FD_DUP = 0x01 +}; + /* Start writing to given output stream. The data is initially written to memory, and later to a temporary file that is immediately unlinked. */ -struct ostream *iostream_temp_create(const char *temp_path_prefix); +struct ostream *iostream_temp_create(const char *temp_path_prefix, + enum iostream_temp_flags flags); /* Finished writing to stream. Return input stream for it and free the output stream. */ struct istream *iostream_temp_finish(struct ostream **output, From dovecot at dovecot.org Mon Feb 4 16:10:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 16:10:58 +0200 Subject: dovecot-2.1: i_stream_close(): Set stream_errno to EPIPE instead... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/93633121bc9d changeset: 14893:93633121bc9d user: Timo Sirainen date: Mon Feb 04 15:59:12 2013 +0200 description: i_stream_close(): Set stream_errno to EPIPE instead of ENOENT. diffstat: src/lib/istream.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 004b69090776 -r 93633121bc9d src/lib/istream.c --- a/src/lib/istream.c Sat Feb 02 00:31:44 2013 +0200 +++ b/src/lib/istream.c Mon Feb 04 15:59:12 2013 +0200 @@ -75,7 +75,7 @@ stream->closed = TRUE; if (stream->stream_errno == 0) - stream->stream_errno = ENOENT; + stream->stream_errno = EPIPE; } void i_stream_set_init_buffer_size(struct istream *stream, size_t size) From dovecot at dovecot.org Mon Feb 4 16:10:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 16:10:58 +0200 Subject: dovecot-2.1: istream-tee: Copy the parent stream's name to child... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/eb117a619075 changeset: 14894:eb117a619075 user: Timo Sirainen date: Mon Feb 04 15:59:50 2013 +0200 description: istream-tee: Copy the parent stream's name to child streams. diffstat: src/lib/istream-tee.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 93633121bc9d -r eb117a619075 src/lib/istream-tee.c --- a/src/lib/istream-tee.c Mon Feb 04 15:59:12 2013 +0200 +++ b/src/lib/istream-tee.c Mon Feb 04 15:59:50 2013 +0200 @@ -223,6 +223,7 @@ tee->children = tstream; ret = i_stream_create(&tstream->istream, input, i_stream_get_fd(input)); + i_stream_set_name(&tstream->istream.istream, i_stream_get_name(input)); /* we keep the reference in tee stream, no need for extra references */ i_stream_unref(&input); return ret; From dovecot at dovecot.org Mon Feb 4 16:10:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 16:10:58 +0200 Subject: dovecot-2.1: imap: Set [io]stream name for imap client connections. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/23fb615c3628 changeset: 14895:23fb615c3628 user: Timo Sirainen date: Mon Feb 04 16:03:54 2013 +0200 description: imap: Set [io]stream name for imap client connections. diffstat: src/imap/imap-client.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r eb117a619075 -r 23fb615c3628 src/imap/imap-client.c --- a/src/imap/imap-client.c Mon Feb 04 15:59:50 2013 +0200 +++ b/src/imap/imap-client.c Mon Feb 04 16:03:54 2013 +0200 @@ -56,6 +56,8 @@ client->input = i_stream_create_fd(fd_in, set->imap_max_line_length, FALSE); client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE); + i_stream_set_name(client->input, ""); + o_stream_set_name(client->output, ""); o_stream_set_flush_callback(client->output, client_output, client); From dovecot at dovecot.org Mon Feb 4 16:10:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 16:10:59 +0200 Subject: dovecot-2.1: lib-storage: If message parser's input stream is cl... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b15a98fd8e15 changeset: 14896:b15a98fd8e15 user: Timo Sirainen date: Mon Feb 04 16:10:50 2013 +0200 description: lib-storage: If message parser's input stream is closed early, don't treat it as error. This seems to happen sometimes during message saving(?), although I'm not exactly sure why. In any case it shouldn't log an error about it. This behavior is probably better than failing. The caller should be the one to figure out if saving has failed or not. diffstat: src/lib-storage/index/index-mail.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diffs (29 lines): diff -r 23fb615c3628 -r b15a98fd8e15 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Mon Feb 04 16:03:54 2013 +0200 +++ b/src/lib-storage/index/index-mail.c Mon Feb 04 16:10:50 2013 +0200 @@ -762,15 +762,20 @@ i_stream_ref(parser_input); ret = message_parser_deinit(&mail->data.parser_ctx, &mail->data.parts) < 0 ? 0 : 1; - if (parser_input->stream_errno != 0) { + if (parser_input->stream_errno == 0 || + parser_input->stream_errno == EPIPE) { + /* EPIPE = input already closed. allow the caller to + decide if that is an error or not. */ + i_assert(i_stream_read(parser_input) == -1 && + !i_stream_have_bytes_left(parser_input)); + } else { errno = parser_input->stream_errno; mail_storage_set_critical(mail->mail.mail.box->storage, - "read(%s) failed: %m", - i_stream_get_name(parser_input)); + "mail parser: read(%s, box=%s) failed: %m", + i_stream_get_name(parser_input), + mail->mail.mail.box->vname); ret = -1; } - i_assert(i_stream_read(parser_input) == -1 && - !i_stream_have_bytes_left(parser_input)); i_stream_unref(&parser_input); } if (ret <= 0) { From dovecot at dovecot.org Mon Feb 4 17:06:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 17:06:48 +0200 Subject: dovecot-2.1: lib-index: Bug in cache file size verification caus... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/443ff272317f changeset: 14897:443ff272317f user: Timo Sirainen date: Mon Feb 04 17:06:40 2013 +0200 description: lib-index: Bug in cache file size verification caused the whole cache file to be mapped. diffstat: src/lib-index/mail-cache.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (23 lines): diff -r b15a98fd8e15 -r 443ff272317f src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Mon Feb 04 16:10:50 2013 +0200 +++ b/src/lib-index/mail-cache.c Mon Feb 04 17:06:40 2013 +0200 @@ -367,7 +367,8 @@ /* verify offset + size before trying to allocate a huge amount of memory due to them. note that we may be prefetching more than we actually need, so don't fail too early. */ - if (size > cache->mmap_length || offset + size > cache->mmap_length) { + if ((size > cache->mmap_length || offset + size > cache->mmap_length) && + (offset > 0 || size > sizeof(struct mail_cache_header))) { if (fstat(cache->fd, &st) < 0) { i_error("fstat(%s) failed: %m", cache->filepath); return -1; @@ -376,7 +377,8 @@ *data_r = NULL; return 0; } - size = st.st_size - offset; + if (offset + size > (uoff_t)st.st_size) + size = st.st_size - offset; } cache->remap_counter++; From dovecot at dovecot.org Mon Feb 4 18:17:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 18:17:34 +0200 Subject: dovecot-2.2: lib-http: Added http_url_escape_param() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b1a03d3c0ae7 changeset: 15722:b1a03d3c0ae7 user: Timo Sirainen date: Mon Feb 04 18:17:21 2013 +0200 description: lib-http: Added http_url_escape_param() diffstat: src/lib-http/http-url.c | 6 ++++-- src/lib-http/http-url.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diffs (23 lines): diff -r 50d43f04511b -r b1a03d3c0ae7 src/lib-http/http-url.c --- a/src/lib-http/http-url.c Sun Feb 03 21:53:24 2013 +0200 +++ b/src/lib-http/http-url.c Mon Feb 04 18:17:21 2013 +0200 @@ -283,5 +283,7 @@ return str_c(urlstr); } - - +void http_url_escape_param(string_t *out, const char *data) +{ + uri_append_query_data(out, "&;", data); +} diff -r 50d43f04511b -r b1a03d3c0ae7 src/lib-http/http-url.h --- a/src/lib-http/http-url.h Sun Feb 03 21:53:24 2013 +0200 +++ b/src/lib-http/http-url.h Mon Feb 04 18:17:21 2013 +0200 @@ -45,4 +45,6 @@ const char *http_url_create(const struct http_url *url); +void http_url_escape_param(string_t *out, const char *data); + #endif From dovecot at dovecot.org Mon Feb 4 20:11:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 20:11:06 +0200 Subject: dovecot-2.2: lib-http: Added http_client_request_set_destroy_cal... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e11b9ba8b90a changeset: 15723:e11b9ba8b90a user: Timo Sirainen date: Mon Feb 04 20:10:59 2013 +0200 description: lib-http: Added http_client_request_set_destroy_callback() This is useful for io_remove()ing the payload stream's fd at the right time. diffstat: src/lib-http/http-client-private.h | 3 +++ src/lib-http/http-client-request.c | 11 +++++++++++ src/lib-http/http-client.h | 5 +++++ 3 files changed, 19 insertions(+), 0 deletions(-) diffs (53 lines): diff -r b1a03d3c0ae7 -r e11b9ba8b90a src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Mon Feb 04 18:17:21 2013 +0200 +++ b/src/lib-http/http-client-private.h Mon Feb 04 20:10:59 2013 +0200 @@ -66,6 +66,9 @@ http_client_request_callback_t *callback; void *context; + void (*destroy_callback)(void *); + void *destroy_context; + enum http_request_state state; unsigned int payload_sync:1; diff -r b1a03d3c0ae7 -r e11b9ba8b90a src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Mon Feb 04 18:17:21 2013 +0200 +++ b/src/lib-http/http-client-request.c Mon Feb 04 20:10:59 2013 +0200 @@ -412,6 +412,9 @@ req->callback = NULL; req->state = HTTP_REQUEST_STATE_FINISHED; + if (req->destroy_callback != NULL) + req->destroy_callback(req->destroy_context); + if (req->payload_wait && req->client->ioloop != NULL) io_loop_stop(req->client->ioloop); http_client_request_unref(_req); @@ -581,3 +584,11 @@ /* resubmit */ http_client_request_resubmit(req); } + +void http_client_request_set_destroy_callback(struct http_client_request *req, + void (*callback)(void *), + void *context) +{ + req->destroy_callback = callback; + req->destroy_context = context; +} diff -r b1a03d3c0ae7 -r e11b9ba8b90a src/lib-http/http-client.h --- a/src/lib-http/http-client.h Mon Feb 04 18:17:21 2013 +0200 +++ b/src/lib-http/http-client.h Mon Feb 04 20:10:59 2013 +0200 @@ -78,6 +78,11 @@ void http_client_request_submit(struct http_client_request *req); void http_client_request_abort(struct http_client_request **req); +/* Call the specified callback when HTTP request is destroyed. */ +void http_client_request_set_destroy_callback(struct http_client_request *req, + void (*callback)(void *), + void *context); + /* submits request and blocks until provided payload is sent. Multiple calls are allowed; payload transmission is ended when data == NULL. */ int http_client_request_send_payload(struct http_client_request **req, From dovecot at dovecot.org Mon Feb 4 20:18:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 20:18:39 +0200 Subject: dovecot-2.2: istream-seekable: Fail stat() if stream_errno is set. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/595c00f289bf changeset: 15724:595c00f289bf user: Timo Sirainen date: Mon Feb 04 20:12:10 2013 +0200 description: istream-seekable: Fail stat() if stream_errno is set. diffstat: src/lib/istream-seekable.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r e11b9ba8b90a -r 595c00f289bf src/lib/istream-seekable.c --- a/src/lib/istream-seekable.c Mon Feb 04 20:10:59 2013 +0200 +++ b/src/lib/istream-seekable.c Mon Feb 04 20:12:10 2013 +0200 @@ -330,6 +330,8 @@ i_stream_seek(&stream->istream, old_offset); unref_streams(sstream); } + if (stream->istream.stream_errno != 0) + return -1; if (sstream->fd_input != NULL) { /* using a file backed buffer, we can use real fstat() */ From dovecot at dovecot.org Mon Feb 4 20:18:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 20:18:39 +0200 Subject: dovecot-2.2: istream: Fail in the default stat() implementation ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d4bf15bbf182 changeset: 15725:d4bf15bbf182 user: Timo Sirainen date: Mon Feb 04 20:13:26 2013 +0200 description: istream: Fail in the default stat() implementation if stream_errno is set. diffstat: src/lib/istream.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 595c00f289bf -r d4bf15bbf182 src/lib/istream.c --- a/src/lib/istream.c Mon Feb 04 20:12:10 2013 +0200 +++ b/src/lib/istream.c Mon Feb 04 20:13:26 2013 +0200 @@ -630,7 +630,7 @@ const struct stat *st; if (stream->parent == NULL) - return 0; + return stream->istream.stream_errno == 0 ? 0 : -1; if (i_stream_stat(stream->parent, exact, &st) < 0) return -1; From dovecot at dovecot.org Mon Feb 4 20:18:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 20:18:39 +0200 Subject: dovecot-2.2: i_stream_create(): Copy stream_errno/eof immediatel... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7d682358619 changeset: 15726:e7d682358619 user: Timo Sirainen date: Mon Feb 04 20:14:16 2013 +0200 description: i_stream_create(): Copy stream_errno/eof immediately from the parent stream. This makes wrapper istream behavior more reliable when the original istream is an istream-error. diffstat: src/lib/istream.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r d4bf15bbf182 -r e7d682358619 src/lib/istream.c --- a/src/lib/istream.c Mon Feb 04 20:13:26 2013 +0200 +++ b/src/lib/istream.c Mon Feb 04 20:14:16 2013 +0200 @@ -666,6 +666,9 @@ _stream->parent_expected_offset = parent->v_offset; _stream->abs_start_offset = parent->v_offset + parent->real_stream->abs_start_offset; + /* if parent stream is an istream-error, copy the error */ + _stream->istream.stream_errno = parent->stream_errno; + _stream->istream.eof = parent->eof; i_stream_ref(parent); } _stream->istream.real_stream = _stream; From dovecot at dovecot.org Mon Feb 4 20:18:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 20:18:39 +0200 Subject: dovecot-2.2: fs-metawrap: Error handling fixes Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/159c18c2e502 changeset: 15727:159c18c2e502 user: Timo Sirainen date: Mon Feb 04 20:15:32 2013 +0200 description: fs-metawrap: Error handling fixes diffstat: src/lib-fs/fs-metawrap.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diffs (32 lines): diff -r e7d682358619 -r 159c18c2e502 src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Mon Feb 04 20:14:16 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Mon Feb 04 20:15:32 2013 +0200 @@ -145,7 +145,11 @@ { struct metawrap_fs *fs = (struct metawrap_fs *)_fs; - return fs_wait_async(fs->super); + if (fs_wait_async(fs->super) < 0) { + fs_metawrap_copy_error(fs); + return -1; + } + return 0; } static void @@ -167,8 +171,13 @@ struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; char c; - if (!file->fs->wrap_metadata) - return fs_get_metadata(file->super, metadata_r); + if (!file->fs->wrap_metadata) { + if (fs_get_metadata(file->super, metadata_r) < 0) { + fs_metawrap_file_copy_error(file); + return -1; + } + return 0; + } if (fs_read(_file, &c, 1) < 0) return -1; From dovecot at dovecot.org Mon Feb 4 20:18:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 20:18:39 +0200 Subject: dovecot-2.2: lib-fs: Added FS_OPEN_FLAG_SEEKABLE. Globally handl... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8515223e4766 changeset: 15729:8515223e4766 user: Timo Sirainen date: Mon Feb 04 20:18:22 2013 +0200 description: lib-fs: Added FS_OPEN_FLAG_SEEKABLE. Globally handle fs_read_stream() seekability and waits. diffstat: src/lib-fs/fs-api-private.h | 2 + src/lib-fs/fs-api.c | 55 +++++++++++++++++++++++++++++++++++++++++++- src/lib-fs/fs-api.h | 4 ++- src/lib-fs/fs-metawrap.c | 5 ++++ 4 files changed, 63 insertions(+), 3 deletions(-) diffs (148 lines): diff -r 5462dbd46703 -r 8515223e4766 src/lib-fs/fs-api-private.h --- a/src/lib-fs/fs-api-private.h Mon Feb 04 20:17:14 2013 +0200 +++ b/src/lib-fs/fs-api-private.h Mon Feb 04 20:18:22 2013 +0200 @@ -55,6 +55,7 @@ struct fs { const char *name; struct fs_vfuncs v; + char *temp_path_prefix; struct fs_settings set; string_t *last_error; @@ -66,6 +67,7 @@ struct fs *fs; struct ostream *output; char *path; + enum fs_open_flags flags; struct istream *pending_read_input; bool write_pending; diff -r 5462dbd46703 -r 8515223e4766 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Mon Feb 04 20:17:14 2013 +0200 +++ b/src/lib-fs/fs-api.c Mon Feb 04 20:18:22 2013 +0200 @@ -5,6 +5,7 @@ #include "module-dir.h" #include "str.h" #include "istream.h" +#include "istream-seekable.h" #include "ostream.h" #include "fs-api-private.h" @@ -99,6 +100,7 @@ struct fs **fs_r, const char **error_r) { const struct fs *fs_class; + const char *temp_file_prefix; fs_class = fs_class_find(driver); if (fs_class == NULL) { @@ -111,7 +113,14 @@ *error_r = t_strdup_printf("Unknown fs driver: %s", driver); return -1; } - return fs_alloc(fs_class, args, set, fs_r, error_r); + if (fs_alloc(fs_class, args, set, fs_r, error_r) < 0) + return -1; + + temp_file_prefix = set->temp_file_prefix != NULL ? + set->temp_file_prefix : ".temp.dovecot"; + (*fs_r)->temp_path_prefix = i_strconcat(set->temp_dir, "/", + temp_file_prefix, NULL); + return 0; } void fs_deinit(struct fs **_fs) @@ -126,6 +135,7 @@ fs->name, fs->files_open_count); } + i_free(fs->temp_path_prefix); fs->v.deinit(fs); str_free(&last_error); } @@ -140,6 +150,7 @@ file = fs->v.file_init(fs, path, mode_flags & FS_OPEN_MODE_MASK, mode_flags & ~FS_OPEN_MODE_MASK); } T_END; + file->flags = mode_flags & ~FS_OPEN_MODE_MASK; fs->files_open_count++; return file; } @@ -262,7 +273,47 @@ struct istream *fs_read_stream(struct fs_file *file, size_t max_buffer_size) { - return file->fs->v.read_stream(file, max_buffer_size); + struct istream *input, *inputs[2]; + const unsigned char *data; + size_t size; + ssize_t ret; + bool want_seekable = FALSE; + + input = file->fs->v.read_stream(file, max_buffer_size); + if (input->stream_errno != 0) { + /* read failed already */ + return input; + } + + if ((file->flags & FS_OPEN_FLAG_SEEKABLE) != 0) + want_seekable = TRUE; + else if ((file->flags & FS_OPEN_FLAG_ASYNC) == 0 && !input->blocking) + want_seekable = TRUE; + + if (want_seekable && !input->seekable) { + /* need to make the stream seekable */ + inputs[0] = input; + inputs[1] = NULL; + input = i_stream_create_seekable_path(inputs, max_buffer_size, + file->fs->temp_path_prefix); + i_stream_set_name(input, i_stream_get_name(inputs[0])); + i_stream_unref(&inputs[0]); + } + if ((file->flags & FS_OPEN_FLAG_ASYNC) == 0 && !input->blocking) { + /* read the whole input stream before returning */ + while ((ret = i_stream_read_data(input, &data, &size, 0)) >= 0) { + i_stream_skip(input, size); + if (ret == 0) { + if (fs_wait_async(file->fs) < 0) { + input->stream_errno = errno; + input->eof = TRUE; + break; + } + } + } + i_stream_seek(input, 0); + } + return input; } int fs_write_via_stream(struct fs_file *file, const void *data, size_t size) diff -r 5462dbd46703 -r 8515223e4766 src/lib-fs/fs-api.h --- a/src/lib-fs/fs-api.h Mon Feb 04 20:17:14 2013 +0200 +++ b/src/lib-fs/fs-api.h Mon Feb 04 20:18:22 2013 +0200 @@ -49,7 +49,9 @@ Asynchronous reads: fs_read() will fail with EAGAIN if it's not finished and fs_read_stream() returns a nonblocking stream. */ - FS_OPEN_FLAG_ASYNC = 0x20 + FS_OPEN_FLAG_ASYNC = 0x20, + /* fs_read_stream() must return a seekable input stream */ + FS_OPEN_FLAG_SEEKABLE = 0x40 }; enum fs_iter_flags { diff -r 5462dbd46703 -r 8515223e4766 src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Mon Feb 04 20:17:14 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Mon Feb 04 20:18:22 2013 +0200 @@ -109,6 +109,11 @@ file->fs = fs; file->open_mode = mode; + /* avoid unnecessarily creating two seekable streams */ + flags &= ~FS_OPEN_FLAG_SEEKABLE; + if (mode == FS_OPEN_MODE_READONLY) + flags |= FS_OPEN_FLAG_ASYNC; + file->super = fs_file_init(fs->super, path, mode | flags); i_array_init(&file->file.metadata, 8); return &file->file; From dovecot at dovecot.org Mon Feb 4 20:18:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 20:18:39 +0200 Subject: dovecot-2.2: fs-metawrap: Fixed stat() to work when parent file'... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5462dbd46703 changeset: 15728:5462dbd46703 user: Timo Sirainen date: Mon Feb 04 20:17:14 2013 +0200 description: fs-metawrap: Fixed stat() to work when parent file's input stream didn't have a parent. diffstat: src/lib-fs/fs-metawrap.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diffs (45 lines): diff -r 159c18c2e502 -r 5462dbd46703 src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Mon Feb 04 20:15:32 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Mon Feb 04 20:17:14 2013 +0200 @@ -328,7 +328,7 @@ { struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; struct istream *input; - uoff_t content_offset; + uoff_t input_size; ssize_t ret; if (!file->fs->wrap_metadata) { @@ -339,21 +339,24 @@ return 0; } input = fs_read_stream(_file, IO_BLOCK_SIZE); - ret = i_stream_read(input); - content_offset = input->real_stream->parent->v_offset; - i_stream_unref(&input); - if (ret <= 0) { - if (ret == 0) - fs_set_error_async(_file->fs); + if ((ret = i_stream_get_size(input, TRUE, &input_size)) < 0) { + fs_set_error(_file->fs, "i_stream_get_size(%s) failed: %m", + fs_file_path(_file)); + i_stream_unref(&input); + return -1; + } + if (ret == 0) { + i_stream_unref(&input); + fs_set_error_async(_file->fs); return -1; } if (fs_stat(file->super, st_r) < 0) { + i_assert(errno != EAGAIN); /* read should have caught this */ fs_metawrap_copy_error(file->fs); return -1; } - i_assert((uoff_t)st_r->st_size >= content_offset); - st_r->st_size -= content_offset; + st_r->st_size = input_size; return 0; } From dovecot at dovecot.org Mon Feb 4 22:03:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 22:03:24 +0200 Subject: dovecot-2.2: fs-metawrap: Delay writing the metadata headers unt... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a1598c03c940 changeset: 15730:a1598c03c940 user: Timo Sirainen date: Mon Feb 04 22:02:42 2013 +0200 description: fs-metawrap: Delay writing the metadata headers until first data is written. Also some other read/write fixes. diffstat: src/lib-fs/Makefile.am | 2 + src/lib-fs/fs-metawrap.c | 93 +++++++++++++++++++++++++++--------------- src/lib-fs/ostream-metawrap.c | 58 ++++++++++++++++++++++++++ src/lib-fs/ostream-metawrap.h | 8 +++ 4 files changed, 127 insertions(+), 34 deletions(-) diffs (241 lines): diff -r 8515223e4766 -r a1598c03c940 src/lib-fs/Makefile.am --- a/src/lib-fs/Makefile.am Mon Feb 04 20:18:22 2013 +0200 +++ b/src/lib-fs/Makefile.am Mon Feb 04 22:02:42 2013 +0200 @@ -14,6 +14,7 @@ fs-sis-common.c \ fs-sis-queue.c \ istream-metawrap.c \ + ostream-metawrap.c \ ostream-cmp.c headers = \ @@ -21,6 +22,7 @@ fs-api-private.h \ fs-sis-common.h \ istream-metawrap.h \ + ostream-metawrap.h \ ostream-cmp.h fs_test_SOURCES = fs-test.c diff -r 8515223e4766 -r a1598c03c940 src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Mon Feb 04 20:18:22 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Mon Feb 04 22:02:42 2013 +0200 @@ -8,8 +8,11 @@ #include "istream-private.h" #include "istream-metawrap.h" #include "ostream.h" +#include "ostream-metawrap.h" #include "fs-api-private.h" +#define MAX_METADATA_LINE_LEN 8192 + struct metawrap_fs { struct fs fs; struct fs *super; @@ -21,6 +24,8 @@ struct metawrap_fs *fs; struct fs_file *super; enum fs_open_mode open_mode; + struct istream *input; + struct ostream *super_output; }; static void fs_metawrap_copy_error(struct metawrap_fs *fs) @@ -226,15 +231,21 @@ fs_metawrap_read_stream(struct fs_file *_file, size_t max_buffer_size) { struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; - struct istream *input, *input2; + struct istream *input; if (!file->fs->wrap_metadata) return fs_read_stream(file->super, max_buffer_size); - input = fs_read_stream(file->super, max_buffer_size); - input2 = i_stream_create_metawrap(input, fs_metawrap_callback, file); + if (file->input != NULL) { + i_stream_seek(file->input, 0); + return file->input; + } + + input = fs_read_stream(file->super, + I_MAX(max_buffer_size, MAX_METADATA_LINE_LEN)); + file->input = i_stream_create_metawrap(input, fs_metawrap_callback, file); i_stream_unref(&input); - return input2; + return file->input; } static int fs_metawrap_write(struct fs_file *_file, const void *data, size_t size) @@ -251,36 +262,42 @@ return fs_write_via_stream(_file, data, size); } +static void fs_metawrap_write_metadata(void *context) +{ + struct metawrap_fs_file *file = context; + const struct fs_metadata *metadata; + string_t *str = t_str_new(256); + ssize_t ret; + + /* FIXME: if fs_set_metadata() is called later the changes are + ignored. we'd need to write via temporary file then. */ + array_foreach(&file->file.metadata, metadata) { + str_append_tabescaped(str, metadata->key); + str_append_c(str, ':'); + str_append_tabescaped(str, metadata->value); + str_append_c(str, '\n'); + } + str_append_c(str, '\n'); + ret = o_stream_send(file->file.output, str_data(str), str_len(str)); + if (ret < 0) + o_stream_close(file->file.output); + else + i_assert((size_t)ret == str_len(str)); +} + static void fs_metawrap_write_stream(struct fs_file *_file) { struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; i_assert(_file->output == NULL); - _file->output = fs_write_stream(file->super); - if (file->fs->wrap_metadata) T_BEGIN { - const struct fs_metadata *metadata; - string_t *str = t_str_new(256); - ssize_t ret; - - /* FIXME: if fs_set_metadata() is called later the changes are - ignored. we'd need to write via temporary file then. */ - array_foreach(&_file->metadata, metadata) { - str_append_tabescaped(str, metadata->key); - str_append_c(str, ':'); - str_append_tabescaped(str, metadata->value); - str_append_c(str, '\n'); - } - str_append_c(str, '\n'); - ret = o_stream_send(_file->output, str_data(str), str_len(str)); - if (ret < 0) { - int err = _file->output->stream_errno; - fs_write_stream_abort(file->super, &_file->output); - _file->output = o_stream_create_error(err); - } else { - i_assert((size_t)ret == str_len(str)); - } - } T_END; + file->super_output = fs_write_stream(file->super); + if (!file->fs->wrap_metadata) + _file->output = file->super_output; + else { + _file->output = o_stream_create_metawrap(file->super_output, + fs_metawrap_write_metadata, file); + } } static int fs_metawrap_write_stream_finish(struct fs_file *_file, bool success) @@ -288,16 +305,24 @@ struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; int ret; + if (_file->output->closed) + success = FALSE; + if (!success) { - fs_write_stream_abort(file->super, &_file->output); - fs_metawrap_file_copy_error(file); - return -1; + fs_write_stream_abort(file->super, &file->super_output); + ret = -1; + } else { + ret = fs_write_stream_finish(file->super, &file->super_output); } - if ((ret = fs_write_stream_finish(file->super, &_file->output)) < 0) { + if (ret != 0) { + if (_file->output == file->super_output) + _file->output = NULL; + else + o_stream_unref(&_file->output); + } + if (ret < 0) fs_metawrap_file_copy_error(file); - return -1; - } return ret; } diff -r 8515223e4766 -r a1598c03c940 src/lib-fs/ostream-metawrap.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-fs/ostream-metawrap.c Mon Feb 04 22:02:42 2013 +0200 @@ -0,0 +1,58 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "ostream-private.h" +#include "ostream-metawrap.h" + +struct metawrap_ostream { + struct ostream_private ostream; + void (*write_callback)(void *); + void *context; +}; + +static void o_stream_metawrap_call_callback(struct metawrap_ostream *mstream) +{ + void (*write_callback)(void *) = mstream->write_callback; + + if (write_callback != NULL) { + mstream->write_callback = NULL; + write_callback(mstream->context); + } +} + +static ssize_t +o_stream_metawrap_sendv(struct ostream_private *stream, + const struct const_iovec *iov, unsigned int iov_count) +{ + struct metawrap_ostream *mstream = (struct metawrap_ostream *)stream; + + o_stream_metawrap_call_callback(mstream); + return o_stream_sendv(stream->parent, iov, iov_count); +} + +static off_t +o_stream_metawrap_send_istream(struct ostream_private *_outstream, + struct istream *instream) +{ + struct metawrap_ostream *outstream = + (struct metawrap_ostream *)_outstream; + + o_stream_metawrap_call_callback(outstream); + return o_stream_send_istream(_outstream->parent, instream); +} + +struct ostream * +o_stream_create_metawrap(struct ostream *output, + void (*write_callback)(void *), void *context) +{ + struct metawrap_ostream *mstream; + + mstream = i_new(struct metawrap_ostream, 1); + mstream->ostream.sendv = o_stream_metawrap_sendv; + mstream->ostream.send_istream = o_stream_metawrap_send_istream; + mstream->write_callback = write_callback; + mstream->context = context; + + return o_stream_create(&mstream->ostream, output, + o_stream_get_fd(output)); +} diff -r 8515223e4766 -r a1598c03c940 src/lib-fs/ostream-metawrap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-fs/ostream-metawrap.h Mon Feb 04 22:02:42 2013 +0200 @@ -0,0 +1,8 @@ +#ifndef OSTREAM_METAWRAP_H +#define OSTREAM_METAWRAP_H + +struct ostream * +o_stream_create_metawrap(struct ostream *output, + void (*write_callback)(void *), void *context); + +#endif From dovecot at dovecot.org Mon Feb 4 22:03:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 22:03:24 +0200 Subject: dovecot-2.2: iostream-temp: Don't try to dup() the stream fd if ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6a6472846181 changeset: 15731:6a6472846181 user: Timo Sirainen date: Mon Feb 04 22:03:10 2013 +0200 description: iostream-temp: Don't try to dup() the stream fd if it's already closed. diffstat: src/lib/iostream-temp.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (22 lines): diff -r a1598c03c940 -r 6a6472846181 src/lib/iostream-temp.c --- a/src/lib/iostream-temp.c Mon Feb 04 22:02:42 2013 +0200 +++ b/src/lib/iostream-temp.c Mon Feb 04 22:03:10 2013 +0200 @@ -220,7 +220,7 @@ uoff_t abs_offset, size; int fd; - if (tstream->dupstream != NULL) { + if (tstream->dupstream != NULL && !tstream->dupstream->closed) { abs_offset = tstream->dupstream->real_stream->abs_start_offset + tstream->dupstream_start_offset; size = tstream->dupstream_offset - @@ -235,6 +235,9 @@ i_stream_unref(&input2); } i_stream_unref(&tstream->dupstream); + } else if (tstream->dupstream != NULL) { + /* return the original failed stream. */ + input = tstream->dupstream; } else if (tstream->fd != -1) { input = i_stream_create_fd(tstream->fd, max_buffer_size, TRUE); tstream->fd = -1; From dovecot at dovecot.org Mon Feb 4 22:07:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 22:07:19 +0200 Subject: dovecot-2.2: lib-http: If http_client_request_set_payload() fail... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e4fbb3a834a7 changeset: 15732:e4fbb3a834a7 user: Timo Sirainen date: Mon Feb 04 22:07:14 2013 +0200 description: lib-http: If http_client_request_set_payload() fails to get stream size, log an error. diffstat: src/lib-http/http-client-request.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diffs (23 lines): diff -r 6a6472846181 -r e4fbb3a834a7 src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Mon Feb 04 22:03:10 2013 +0200 +++ b/src/lib-http/http-client-request.c Mon Feb 04 22:07:14 2013 +0200 @@ -133,12 +133,18 @@ void http_client_request_set_payload(struct http_client_request *req, struct istream *input, bool sync) { + int ret; + i_assert(req->state == HTTP_REQUEST_STATE_NEW); i_assert(req->payload_input == NULL); i_stream_ref(input); req->payload_input = input; - if (i_stream_get_size(input, TRUE, &req->payload_size) <= 0) { + if ((ret = i_stream_get_size(input, TRUE, &req->payload_size)) <= 0) { + if (ret < 0) { + i_error("i_stream_get_size(%s) failed: %m", + i_stream_get_name(input)); + } req->payload_size = 0; req->payload_chunked = TRUE; } From dovecot at dovecot.org Mon Feb 4 22:16:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 04 Feb 2013 22:16:18 +0200 Subject: dovecot-2.2: iostream-temp: Set a name for the returned istream. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b94603584655 changeset: 15733:b94603584655 user: Timo Sirainen date: Mon Feb 04 22:15:59 2013 +0200 description: iostream-temp: Set a name for the returned istream. diffstat: src/lib/iostream-temp.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (27 lines): diff -r e4fbb3a834a7 -r b94603584655 src/lib/iostream-temp.c --- a/src/lib/iostream-temp.c Mon Feb 04 22:07:14 2013 +0200 +++ b/src/lib/iostream-temp.c Mon Feb 04 22:15:59 2013 +0200 @@ -234,16 +234,23 @@ input = i_stream_create_limit(input2, size); i_stream_unref(&input2); } + i_stream_set_name(input, t_strdup_printf( + "(Temp file in %s, from %s)", tstream->temp_path_prefix, + i_stream_get_name(tstream->dupstream))); i_stream_unref(&tstream->dupstream); } else if (tstream->dupstream != NULL) { /* return the original failed stream. */ input = tstream->dupstream; } else if (tstream->fd != -1) { input = i_stream_create_fd(tstream->fd, max_buffer_size, TRUE); + i_stream_set_name(input, t_strdup_printf( + "(Temp file in %s)", tstream->temp_path_prefix)); tstream->fd = -1; } else { input = i_stream_create_from_data(tstream->buf->data, tstream->buf->used); + i_stream_set_name(input, t_strdup_printf( + "(Temp file in %s)", tstream->temp_path_prefix)); i_stream_set_destroy_callback(input, iostream_temp_buf_destroyed, tstream->buf); tstream->buf = NULL; From dovecot at dovecot.org Tue Feb 5 01:16:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 01:16:58 +0200 Subject: dovecot-2.2: fs-metawrap: Set underlying file async only for fs_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/15ad5fc0568b changeset: 15734:15ad5fc0568b user: Timo Sirainen date: Tue Feb 05 01:16:48 2013 +0200 description: fs-metawrap: Set underlying file async only for fs_read_stream() lookups. diffstat: src/lib-fs/fs-metawrap.c | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-) diffs (79 lines): diff -r b94603584655 -r 15ad5fc0568b src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Mon Feb 04 22:15:59 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Tue Feb 05 01:16:48 2013 +0200 @@ -22,7 +22,7 @@ struct metawrap_fs_file { struct fs_file file; struct metawrap_fs *fs; - struct fs_file *super; + struct fs_file *super, *super_read; enum fs_open_mode open_mode; struct istream *input; struct ostream *super_output; @@ -116,10 +116,16 @@ /* avoid unnecessarily creating two seekable streams */ flags &= ~FS_OPEN_FLAG_SEEKABLE; - if (mode == FS_OPEN_MODE_READONLY) - flags |= FS_OPEN_FLAG_ASYNC; file->super = fs_file_init(fs->super, path, mode | flags); + if (mode == FS_OPEN_MODE_READONLY && (flags & FS_OPEN_FLAG_ASYNC) == 0) { + /* use async stream for super, so fs_read_stream() won't create + another seekable stream unneededly */ + file->super_read = fs_file_init(fs->super, path, mode | flags | + FS_OPEN_FLAG_ASYNC); + } else { + file->super_read = file->super; + } i_array_init(&file->file.metadata, 8); return &file->file; } @@ -128,6 +134,8 @@ { struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; + if (file->super_read != file->super) + fs_file_deinit(&file->super_read); fs_file_deinit(&file->super); array_free(&file->file.metadata); i_free(file->file.path); @@ -241,7 +249,7 @@ return file->input; } - input = fs_read_stream(file->super, + input = fs_read_stream(file->super_read, I_MAX(max_buffer_size, MAX_METADATA_LINE_LEN)); file->input = i_stream_create_metawrap(input, fs_metawrap_callback, file); i_stream_unref(&input); @@ -305,8 +313,14 @@ struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; int ret; - if (_file->output->closed) - success = FALSE; + if (_file->output != NULL) { + if (_file->output->closed) + success = FALSE; + if (_file->output == file->super_output) + _file->output = NULL; + else + o_stream_unref(&_file->output); + } if (!success) { fs_write_stream_abort(file->super, &file->super_output); @@ -315,12 +329,6 @@ ret = fs_write_stream_finish(file->super, &file->super_output); } - if (ret != 0) { - if (_file->output == file->super_output) - _file->output = NULL; - else - o_stream_unref(&_file->output); - } if (ret < 0) fs_metawrap_file_copy_error(file); return ret; From dovecot at dovecot.org Tue Feb 5 03:24:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 03:24:58 +0200 Subject: dovecot-2.2: fs-metawrap: Memory leak fixes Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c31ee24e7255 changeset: 15736:c31ee24e7255 user: Timo Sirainen date: Tue Feb 05 03:23:46 2013 +0200 description: fs-metawrap: Memory leak fixes diffstat: src/lib-fs/fs-metawrap.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (51 lines): diff -r 275973a62419 -r c31ee24e7255 src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Tue Feb 05 03:23:30 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Tue Feb 05 03:23:46 2013 +0200 @@ -126,7 +126,7 @@ } else { file->super_read = file->super; } - i_array_init(&file->file.metadata, 8); + fs_metadata_init(&file->file); return &file->file; } @@ -134,10 +134,11 @@ { struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; + if (file->input != NULL) + i_stream_unref(&file->input); if (file->super_read != file->super) fs_file_deinit(&file->super_read); fs_file_deinit(&file->super); - array_free(&file->file.metadata); i_free(file->file.path); i_free(file); } @@ -245,6 +246,7 @@ return fs_read_stream(file->super, max_buffer_size); if (file->input != NULL) { + i_stream_ref(file->input); i_stream_seek(file->input, 0); return file->input; } @@ -253,6 +255,7 @@ I_MAX(max_buffer_size, MAX_METADATA_LINE_LEN)); file->input = i_stream_create_metawrap(input, fs_metawrap_callback, file); i_stream_unref(&input); + i_stream_ref(file->input); return file->input; } @@ -383,8 +386,8 @@ i_stream_unref(&input); return -1; } + i_stream_unref(&input); if (ret == 0) { - i_stream_unref(&input); fs_set_error_async(_file->fs); return -1; } From dovecot at dovecot.org Tue Feb 5 03:24:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 03:24:58 +0200 Subject: dovecot-2.2: lib-fs: Avoid memory leaks if file was closed befor... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/275973a62419 changeset: 15735:275973a62419 user: Timo Sirainen date: Tue Feb 05 03:23:30 2013 +0200 description: lib-fs: Avoid memory leaks if file was closed before fs_read()/fs_copy() was finished. diffstat: src/lib-fs/fs-api.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (18 lines): diff -r 15ad5fc0568b -r 275973a62419 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Tue Feb 05 01:16:48 2013 +0200 +++ b/src/lib-fs/fs-api.c Tue Feb 05 03:23:30 2013 +0200 @@ -164,6 +164,14 @@ *_file = NULL; + if (file->pending_read_input != NULL) + i_stream_unref(&file->pending_read_input); + + if (file->copy_input != NULL) { + i_stream_unref(&file->copy_input); + (void)fs_write_stream_abort(file, &file->copy_output); + } + file->fs->files_open_count--; file->fs->v.file_deinit(file); From dovecot at dovecot.org Tue Feb 5 03:24:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 03:24:58 +0200 Subject: dovecot-2.2: lib-index: Memory leak fix Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/be320a216190 changeset: 15737:be320a216190 user: Timo Sirainen date: Tue Feb 05 03:23:59 2013 +0200 description: lib-index: Memory leak fix diffstat: src/lib-index/mail-index-transaction-update.c | 4 ++++ src/lib-index/test-mail-index-transaction-update.c | 4 ++++ 2 files changed, 8 insertions(+), 0 deletions(-) diffs (42 lines): diff -r c31ee24e7255 -r be320a216190 src/lib-index/mail-index-transaction-update.c --- a/src/lib-index/mail-index-transaction-update.c Tue Feb 05 03:23:46 2013 +0200 +++ b/src/lib-index/mail-index-transaction-update.c Tue Feb 05 03:23:59 2013 +0200 @@ -1034,6 +1034,7 @@ { struct mail_index_transaction_keyword_update *u; struct mail_keywords *add_keywords = NULL, *remove_keywords = NULL; + struct mail_keywords *unref_keywords = NULL; unsigned int i; bool changed; @@ -1069,6 +1070,7 @@ if (seq < t->first_new_seq) { /* remove the ones currently in index */ remove_keywords = keyword_update_remove_existing(t, seq); + unref_keywords = remove_keywords; } /* remove from all changes we've done in this transaction */ array_foreach_modifiable(&t->keyword_updates, u) @@ -1107,6 +1109,8 @@ seq_range_array_remove(&u->remove_seq, seq); } } + if (unref_keywords != NULL) + mail_index_keywords_unref(&unref_keywords); t->log_updates = TRUE; } diff -r c31ee24e7255 -r be320a216190 src/lib-index/test-mail-index-transaction-update.c --- a/src/lib-index/test-mail-index-transaction-update.c Tue Feb 05 03:23:46 2013 +0200 +++ b/src/lib-index/test-mail-index-transaction-update.c Tue Feb 05 03:23:59 2013 +0200 @@ -57,6 +57,10 @@ return NULL; } +void mail_index_keywords_unref(struct mail_keywords **keywords ATTR_UNUSED) +{ +} + static struct mail_index_transaction * mail_index_transaction_new(void) { From dovecot at dovecot.org Tue Feb 5 03:24:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 03:24:58 +0200 Subject: dovecot-2.2: cydir, dbox, maildir: Don't leak the stream if mail... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1a6cf87eeff0 changeset: 15738:1a6cf87eeff0 user: Timo Sirainen date: Tue Feb 05 03:24:45 2013 +0200 description: cydir, dbox, maildir: Don't leak the stream if mail.istream_opened() fails diffstat: src/lib-storage/index/cydir/cydir-mail.c | 12 ++++++++---- src/lib-storage/index/dbox-common/dbox-mail.c | 6 +++++- src/lib-storage/index/maildir/maildir-mail.c | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diffs (71 lines): diff -r be320a216190 -r 1a6cf87eeff0 src/lib-storage/index/cydir/cydir-mail.c --- a/src/lib-storage/index/cydir/cydir-mail.c Tue Feb 05 03:23:59 2013 +0200 +++ b/src/lib-storage/index/cydir/cydir-mail.c Tue Feb 05 03:24:45 2013 +0200 @@ -98,6 +98,7 @@ struct istream **stream_r) { struct index_mail *mail = (struct index_mail *)_mail; + struct istream *input; const char *path; int fd; @@ -114,13 +115,16 @@ } return -1; } - mail->data.stream = i_stream_create_fd(fd, 0, TRUE); - i_stream_set_name(mail->data.stream, path); - index_mail_set_read_buffer_size(_mail, mail->data.stream); + input = i_stream_create_fd(fd, 0, TRUE); + i_stream_set_name(input, path); + index_mail_set_read_buffer_size(_mail, input); if (mail->mail.v.istream_opened != NULL) { - if (mail->mail.v.istream_opened(_mail, stream_r) < 0) + if (mail->mail.v.istream_opened(_mail, &input) < 0) { + i_stream_unref(&input); return -1; + } } + mail->data.stream = input; } return index_mail_init_stream(mail, hdr_size, body_size, stream_r); diff -r be320a216190 -r 1a6cf87eeff0 src/lib-storage/index/dbox-common/dbox-mail.c --- a/src/lib-storage/index/dbox-common/dbox-mail.c Tue Feb 05 03:23:59 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-mail.c Tue Feb 05 03:24:45 2013 +0200 @@ -220,8 +220,10 @@ struct dbox_file *file = mail->open_file; int ret; - if ((ret = dbox_file_seek(file, offset)) <= 0) + if ((ret = dbox_file_seek(file, offset)) <= 0) { + *stream_r = NULL; return ret; + } *stream_r = i_stream_create_limit(file->input, file->cur_physical_size); if (pmail->v.istream_opened != NULL) { @@ -258,6 +260,8 @@ dbox_file_set_corrupted(mail->open_file, "uid=%u points to broken data at offset=" "%"PRIuUOFF_T, _mail->uid, offset); + if (input != NULL) + i_stream_unref(&input); return -1; } data->stream = input; diff -r be320a216190 -r 1a6cf87eeff0 src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Tue Feb 05 03:23:59 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-mail.c Tue Feb 05 03:24:45 2013 +0200 @@ -584,8 +584,10 @@ } if (mail->mail.v.istream_opened != NULL) { if (mail->mail.v.istream_opened(_mail, - &data->stream) < 0) + &data->stream) < 0) { + i_stream_unref(&data->stream); return -1; + } } } From dovecot at dovecot.org Tue Feb 5 03:30:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 03:30:12 +0200 Subject: dovecot-2.2: fs-metawrap: Don't duplicate work if fs_get_metadat... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7e95d2d2b37 changeset: 15739:e7e95d2d2b37 user: Timo Sirainen date: Tue Feb 05 03:30:01 2013 +0200 description: fs-metawrap: Don't duplicate work if fs_get_metadata() is called multiple times. diffstat: src/lib-fs/fs-metawrap.c | 12 ++++++++++-- src/lib-fs/istream-metawrap.c | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diffs (51 lines): diff -r 1a6cf87eeff0 -r e7e95d2d2b37 src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Tue Feb 05 03:24:45 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Tue Feb 05 03:30:01 2013 +0200 @@ -26,6 +26,7 @@ enum fs_open_mode open_mode; struct istream *input; struct ostream *super_output; + bool metadata_read; }; static void fs_metawrap_copy_error(struct metawrap_fs *fs) @@ -198,8 +199,10 @@ return 0; } - if (fs_read(_file, &c, 1) < 0) - return -1; + if (!file->metadata_read) { + if (fs_read(_file, &c, 1) < 0) + return -1; + } *metadata_r = &_file->metadata; return 0; } @@ -229,6 +232,11 @@ { struct metawrap_fs_file *file = context; + if (key == NULL) { + file->metadata_read = TRUE; + return; + } + T_BEGIN { key = str_tabunescape(t_strdup_noconst(key)); value = str_tabunescape(t_strdup_noconst(value)); diff -r 1a6cf87eeff0 -r e7e95d2d2b37 src/lib-fs/istream-metawrap.c --- a/src/lib-fs/istream-metawrap.c Tue Feb 05 03:24:45 2013 +0200 +++ b/src/lib-fs/istream-metawrap.c Tue Feb 05 03:30:01 2013 +0200 @@ -18,8 +18,10 @@ char *line, *p; while ((line = i_stream_read_next_line(mstream->istream.parent)) != NULL) { - if (*line == '\0') + if (*line == '\0') { + mstream->callback(NULL, NULL, mstream->context); return 1; + } p = strchr(line, ':'); if (p == NULL) { mstream->istream.istream.stream_errno = EINVAL; From dovecot at dovecot.org Tue Feb 5 03:38:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 03:38:01 +0200 Subject: dovecot-2.2: lib-fs: Changed FS_OPEN_FLAG_UNIMPORTANT to a rever... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/397253f15f36 changeset: 15740:397253f15f36 user: Timo Sirainen date: Tue Feb 05 03:37:47 2013 +0200 description: lib-fs: Changed FS_OPEN_FLAG_UNIMPORTANT to a reversed FS_OPEN_FLAG_FSYNC. This explains its behavior better. diffstat: src/lib-fs/fs-api.h | 6 +++--- src/lib-fs/fs-posix.c | 2 +- src/lib-storage/index/index-attachment.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diffs (42 lines): diff -r e7e95d2d2b37 -r 397253f15f36 src/lib-fs/fs-api.h --- a/src/lib-fs/fs-api.h Tue Feb 05 03:30:01 2013 +0200 +++ b/src/lib-fs/fs-api.h Tue Feb 05 03:37:47 2013 +0200 @@ -40,9 +40,9 @@ }; enum fs_open_flags { - /* File being written isn't very important, performance is more - important than actually guaranteeing that the file gets saved */ - FS_OPEN_FLAG_UNIMPORTANT = 0x10, + /* File is important and writing must call fsync() or have equivalent + behavior. */ + FS_OPEN_FLAG_FSYNC = 0x10, /* Asynchronous writes: fs_write() will fail with EAGAIN if it needs to be called again (the retries can use size=0). For streams fs_write_stream_finish() may request retrying with 0. diff -r e7e95d2d2b37 -r 397253f15f36 src/lib-fs/fs-posix.c --- a/src/lib-fs/fs-posix.c Tue Feb 05 03:30:01 2013 +0200 +++ b/src/lib-fs/fs-posix.c Tue Feb 05 03:37:47 2013 +0200 @@ -350,7 +350,7 @@ { int ret; - if ((file->open_flags & FS_OPEN_FLAG_UNIMPORTANT) == 0) { + if ((file->open_flags & FS_OPEN_FLAG_FSYNC) != 0) { if (fdatasync(file->fd) < 0) { fs_set_error(file->file.fs, "fdatasync(%s) failed: %m", file->file.path); diff -r e7e95d2d2b37 -r 397253f15f36 src/lib-storage/index/index-attachment.c --- a/src/lib-storage/index/index-attachment.c Tue Feb 05 03:30:01 2013 +0200 +++ b/src/lib-storage/index/index-attachment.c Tue Feb 05 03:37:47 2013 +0200 @@ -87,8 +87,8 @@ i_assert(attach->cur_file == NULL); - if (storage->set->parsed_fsync_mode == FSYNC_MODE_NEVER) - flags |= FS_OPEN_FLAG_UNIMPORTANT; + if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) + flags |= FS_OPEN_FLAG_FSYNC; if (strlen(digest) < 4) { /* make sure we can access first 4 bytes without accessing From dovecot at dovecot.org Tue Feb 5 03:53:52 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 03:53:52 +0200 Subject: dovecot-2.2: lib-storage: Changed mailbox_attribute_get() to ret... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/03a0af22100d changeset: 15741:03a0af22100d user: Timo Sirainen date: Tue Feb 05 03:53:40 2013 +0200 description: lib-storage: Changed mailbox_attribute_get() to return a struct for value. This allows returning flags for the values in future. Mainly readonly-flag for internal attributes and when restricted by ACL plugin. diffstat: src/lib-imap-urlauth/imap-urlauth-backend.c | 4 +++- src/lib-storage/index/index-attribute.c | 11 ++++++----- src/lib-storage/index/index-storage.h | 4 ++-- src/lib-storage/mail-storage-private.h | 2 +- src/lib-storage/mail-storage.c | 2 +- src/lib-storage/mail-storage.h | 10 +++++++++- 6 files changed, 22 insertions(+), 11 deletions(-) diffs (127 lines): diff -r 397253f15f36 -r 03a0af22100d src/lib-imap-urlauth/imap-urlauth-backend.c --- a/src/lib-imap-urlauth/imap-urlauth-backend.c Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-imap-urlauth/imap-urlauth-backend.c Tue Feb 05 03:53:40 2013 +0200 @@ -18,6 +18,7 @@ enum mail_error *error_code_r) { struct mail_user *user = mail_storage_get_user(mailbox_get_storage(box)); + struct mail_attribute_value urlauth_key; const char *mailbox_key_hex = NULL; buffer_t key_buf; int ret; @@ -26,7 +27,7 @@ *error_code_r = MAIL_ERROR_TEMP; ret = mailbox_attribute_get(box, MAIL_ATTRIBUTE_TYPE_PRIVATE, - IMAP_URLAUTH_KEY, &mailbox_key_hex); + IMAP_URLAUTH_KEY, &urlauth_key); if (ret < 0) return -1; @@ -55,6 +56,7 @@ /* read existing key */ buffer_create_from_data(&key_buf, mailbox_key_r, IMAP_URLAUTH_KEY_LEN); + mailbox_key_hex = urlauth_key.value; if (strlen(mailbox_key_hex) != 2*IMAP_URLAUTH_KEY_LEN || hex_to_binary(mailbox_key_hex, &key_buf) < 0 || key_buf.used != IMAP_URLAUTH_KEY_LEN) { diff -r 397253f15f36 -r 03a0af22100d src/lib-storage/index/index-attribute.c --- a/src/lib-storage/index/index-attribute.c Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/index/index-attribute.c Tue Feb 05 03:53:40 2013 +0200 @@ -174,24 +174,25 @@ } int index_storage_attribute_get(struct mailbox *box, - enum mail_attribute_type type, - const char *key, const char **value_r) + enum mail_attribute_type type, const char *key, + struct mail_attribute_value *value_r) { struct dict *dict; const char *mailbox_prefix; int ret; + memset(value_r, 0, sizeof(*value_r)); + if (index_storage_get_dict(box, type, &dict, &mailbox_prefix) < 0) return -1; ret = dict_lookup(dict, pool_datastack_create(), - key_get_prefixed(type, mailbox_prefix, key), value_r); + key_get_prefixed(type, mailbox_prefix, key), + &value_r->value); if (ret < 0) { mail_storage_set_internal_error(box->storage); return -1; } - if (ret == 0) - *value_r = NULL; return ret; } diff -r 397253f15f36 -r 03a0af22100d src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/index/index-storage.h Tue Feb 05 03:53:40 2013 +0200 @@ -120,8 +120,8 @@ enum mail_attribute_type type, const char *key, const char *value); int index_storage_attribute_get(struct mailbox *box, - enum mail_attribute_type type, - const char *key, const char **value_r); + enum mail_attribute_type type, const char *key, + struct mail_attribute_value *value_r); struct mailbox_attribute_iter * index_storage_attribute_iter_init(struct mailbox *box, enum mail_attribute_type type, diff -r 397253f15f36 -r 03a0af22100d src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/mail-storage-private.h Tue Feb 05 03:53:40 2013 +0200 @@ -154,7 +154,7 @@ int (*attribute_set)(struct mailbox *box, enum mail_attribute_type type, const char *key, const char *value); int (*attribute_get)(struct mailbox *box, enum mail_attribute_type type, - const char *key, const char **value_r); + const char *key, struct mail_attribute_value *value_r); struct mailbox_attribute_iter * (*attribute_iter_init)(struct mailbox *box, enum mail_attribute_type type, diff -r 397253f15f36 -r 03a0af22100d src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/mail-storage.c Tue Feb 05 03:53:40 2013 +0200 @@ -1515,7 +1515,7 @@ } int mailbox_attribute_get(struct mailbox *box, enum mail_attribute_type type, - const char *key, const char **value_r) + const char *key, struct mail_attribute_value *value_r) { return box->v.attribute_get(box, type, key, value_r); } diff -r 397253f15f36 -r 03a0af22100d src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/mail-storage.h Tue Feb 05 03:53:40 2013 +0200 @@ -203,6 +203,14 @@ MAIL_ATTRIBUTE_TYPE_PRIVATE, MAIL_ATTRIBUTE_TYPE_SHARED }; +enum mail_attribute_value_flags { + MAIL_ATTRIBUTE_VALUE_FLAG_READONLY = 0x01 +}; + +struct mail_attribute_value { + const char *value; + enum mail_attribute_value_flags flags; +}; struct message_part; struct mail_namespace; @@ -527,7 +535,7 @@ /* Returns value for mailbox attribute key. Returns 1 if value was returned, 0 if value wasn't found (set to NULL), -1 if error */ int mailbox_attribute_get(struct mailbox *box, enum mail_attribute_type type, - const char *key, const char **value_r); + const char *key, struct mail_attribute_value *value_r); /* Iterate through mailbox attributes of the given type. The prefix can be used to restrict what attributes are returned. */ From dovecot at dovecot.org Tue Feb 5 16:48:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 05 Feb 2013 16:48:38 +0200 Subject: dovecot-2.1: lmtp: If verbose_proctitle=yes, update the process ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/63117ab893dc changeset: 14898:63117ab893dc user: Timo Sirainen date: Tue Feb 05 16:48:29 2013 +0200 description: lmtp: If verbose_proctitle=yes, update the process state in the title. diffstat: src/lmtp/client.c | 22 ++++++++++++++++++++-- src/lmtp/client.h | 2 ++ src/lmtp/commands.c | 8 ++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diffs (132 lines): diff -r 443ff272317f -r 63117ab893dc src/lmtp/client.c --- a/src/lmtp/client.c Mon Feb 04 17:06:40 2013 +0200 +++ b/src/lmtp/client.c Tue Feb 05 16:48:29 2013 +0200 @@ -8,6 +8,7 @@ #include "istream.h" #include "ostream.h" #include "hostpid.h" +#include "process-title.h" #include "var-expand.h" #include "settings-parser.h" #include "master-service.h" @@ -31,6 +32,20 @@ static struct client *clients = NULL; unsigned int clients_count = 0; +void client_state_set(struct client *client, const char *name) +{ + client->state.name = name; + + if (!client->service_set->verbose_proctitle) + return; + if (clients_count == 0) + process_title_set("[idling]"); + else if (clients_count > 1) + process_title_set(t_strdup_printf("[%u clients]", clients_count)); + else + process_title_set(t_strdup_printf("[%s]", client->state.name)); +} + static void client_idle_timeout(struct client *client) { client_destroy(client, @@ -156,6 +171,7 @@ lmtp_settings_dup(set_parser, client->pool, &lmtp_set, &lda_set); settings_var_expand(&lmtp_setting_parser_info, lmtp_set, client->pool, mail_storage_service_get_var_expand_table(storage_service, &input)); + client->service_set = master_service_settings_get(master_service); client->lmtp_set = lmtp_set; client->set = lda_set; } @@ -219,7 +235,6 @@ client_io_reset(client); client->state_pool = pool_alloconly_create("client state", 4096); client->state.mail_data_fd = -1; - client->state.name = "banner"; client_read_settings(client); client_raw_user_create(client); client_generate_session_id(client); @@ -229,6 +244,7 @@ DLLIST_PREPEND(&clients, client); clients_count++; + client_state_set(client, "banner"); client_send_line(client, "220 %s %s", client->my_domain, client->lmtp_set->login_greeting); i_info("Connect from %s", client_remote_id(client)); @@ -243,6 +259,8 @@ clients_count--; DLLIST_REMOVE(&clients, client); + client_state_set(client, "destroyed"); + if (client->raw_mail_user != NULL) mail_user_unref(&client->raw_mail_user); if (client->proxy != NULL) @@ -326,7 +344,7 @@ client->state.mail_data_fd = -1; client_generate_session_id(client); - client->state.name = "reset"; + client_state_set(client, "reset"); } void client_send_line(struct client *client, const char *fmt, ...) diff -r 443ff272317f -r 63117ab893dc src/lmtp/client.h --- a/src/lmtp/client.h Mon Feb 04 17:06:40 2013 +0200 +++ b/src/lmtp/client.h Tue Feb 05 16:48:29 2013 +0200 @@ -43,6 +43,7 @@ const struct setting_parser_info *user_set_info; const struct lda_settings *set; const struct lmtp_settings *lmtp_set; + const struct master_service_settings *service_set; int fd_in, fd_out; struct io *io; struct istream *input; @@ -76,6 +77,7 @@ const char *reason); void client_io_reset(struct client *client); void client_state_reset(struct client *client); +void client_state_set(struct client *client, const char *name); void client_input_handle(struct client *client); int client_input_read(struct client *client); diff -r 443ff272317f -r 63117ab893dc src/lmtp/commands.c --- a/src/lmtp/commands.c Mon Feb 04 17:06:40 2013 +0200 +++ b/src/lmtp/commands.c Tue Feb 05 16:48:29 2013 +0200 @@ -74,7 +74,7 @@ i_free(client->lhlo); client->lhlo = i_strdup(str_c(domain)); - client->state.name = "LHLO"; + client_state_set(client, "LHLO"); return 0; } @@ -143,7 +143,7 @@ client->state.mail_from = p_strdup(client->state_pool, addr); p_array_init(&client->state.rcpt_to, client->state_pool, 64); client_send_line(client, "250 2.1.0 OK"); - client->state.name = "MAIL FROM"; + client_state_set(client, "MAIL FROM"); return 0; } @@ -488,7 +488,7 @@ const char *error = NULL; int ret = 0; - client->state.name = "RCPT TO"; + client_state_set(client, "RCPT TO"); if (client->state.mail_from == NULL) { client_send_line(client, "503 5.5.1 MAIL needed first"); @@ -1014,7 +1014,7 @@ client_send_line(client, "354 OK"); io_remove(&client->io); - client->state.name = "DATA"; + client_state_set(client, "DATA"); client->io = io_add(client->fd_in, IO_READ, client_input_data, client); client_input_data_handle(client); return -1; From dovecot at dovecot.org Wed Feb 6 18:29:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 06 Feb 2013 18:29:35 +0200 Subject: dovecot-2.1: lib-index: Avoid assert-crashing later if mmap(dove... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a54f749f5a44 changeset: 14899:a54f749f5a44 user: Timo Sirainen date: Wed Feb 06 18:29:22 2013 +0200 description: lib-index: Avoid assert-crashing later if mmap(dovecot.index.cache) fails. diffstat: src/lib-index/mail-cache.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 63117ab893dc -r a54f749f5a44 src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Tue Feb 05 16:48:29 2013 +0200 +++ b/src/lib-index/mail-cache.c Wed Feb 06 18:29:22 2013 +0200 @@ -437,6 +437,7 @@ cache->mmap_base = mmap_ro_file(cache->fd, &cache->mmap_length); if (cache->mmap_base == MAP_FAILED) { cache->mmap_base = NULL; + cache->mmap_length = 0; mail_cache_set_syscall_error(cache, "mmap()"); return -1; } From dovecot at dovecot.org Wed Feb 6 19:01:00 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 06 Feb 2013 19:01:00 +0200 Subject: dovecot-2.1: lib-storage: Convert INBOX to uppercase also when n... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3ec0d772be49 changeset: 14900:3ec0d772be49 user: Timo Sirainen date: Wed Feb 06 19:00:52 2013 +0200 description: lib-storage: Convert INBOX to uppercase also when namespace has inbox=no. This fixes assert-crash in mailbox_check_mismatching_separators(). diffstat: src/lib-storage/mail-storage.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (19 lines): diff -r a54f749f5a44 -r 3ec0d772be49 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Feb 06 18:29:22 2013 +0200 +++ b/src/lib-storage/mail-storage.c Wed Feb 06 19:00:52 2013 +0200 @@ -627,10 +627,12 @@ i_assert(uni_utf8_str_is_valid(vname)); - if ((list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && - strncasecmp(vname, "INBOX", 5) == 0 && + if (strncasecmp(vname, "INBOX", 5) == 0 && strncmp(vname, "INBOX", 5) != 0) { - /* make sure INBOX shows up in uppercase everywhere */ + /* make sure INBOX shows up in uppercase everywhere. do this + regardless of whether we're in inbox=yes namespace, because + clients expect INBOX to be case insensitive regardless of + server's internal configuration. */ if (vname[5] == '\0') vname = "INBOX"; else if (vname[5] == mail_namespace_get_sep(list->ns)) From pigeonhole at rename-it.nl Wed Feb 6 22:27:02 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 06 Feb 2013 21:27:02 +0100 Subject: dovecot-2.1-pigeonhole: managesieve: Fixed bug in skipping of CR... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/32d178f5e1a2 changeset: 1672:32d178f5e1a2 user: Stephan Bosch date: Wed Feb 06 21:24:30 2013 +0100 description: managesieve: Fixed bug in skipping of CRLF at end of AUTHENTICATE command. Setting skip_newline is useless when the connection is transfered to another process after successful login. diffstat: src/managesieve-login/client-authenticate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r f8fad363984d -r 32d178f5e1a2 src/managesieve-login/client-authenticate.c --- a/src/managesieve-login/client-authenticate.c Sat Jan 26 09:10:26 2013 +0100 +++ b/src/managesieve-login/client-authenticate.c Wed Feb 06 21:24:30 2013 +0100 @@ -257,7 +257,7 @@ } if ( i_stream_next_line(client->input) == NULL ) - msieve_client->skip_line = TRUE; + return 0; return 1; } From dovecot at dovecot.org Fri Feb 8 15:12:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 08 Feb 2013 15:12:15 +0200 Subject: dovecot-2.1: Added tag 2.1.15 for changeset fc75811f3c08 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5fe181f1497a changeset: 14902:5fe181f1497a user: Timo Sirainen date: Fri Feb 08 15:05:37 2013 +0200 description: Added tag 2.1.15 for changeset fc75811f3c08 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r fc75811f3c08 -r 5fe181f1497a .hgtags --- a/.hgtags Fri Feb 08 15:05:36 2013 +0200 +++ b/.hgtags Fri Feb 08 15:05:37 2013 +0200 @@ -91,3 +91,4 @@ 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 2.1.12 cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 2.1.13 b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14 +fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15 From dovecot at dovecot.org Fri Feb 8 15:12:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 08 Feb 2013 15:12:15 +0200 Subject: dovecot-2.1: Released v2.1.15. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fc75811f3c08 changeset: 14901:fc75811f3c08 user: Timo Sirainen date: Fri Feb 08 15:05:36 2013 +0200 description: Released v2.1.15. diffstat: NEWS | 5 +++++ configure.in | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diffs (22 lines): diff -r 3ec0d772be49 -r fc75811f3c08 NEWS --- a/NEWS Wed Feb 06 19:00:52 2013 +0200 +++ b/NEWS Fri Feb 08 15:05:36 2013 +0200 @@ -1,3 +1,8 @@ +v2.1.15 2013-02-08 Timo Sirainen + + - v2.1.14: dovecot.index.cache fixes caused it to use more disk I/O + and memory than necessary. + v2.1.14 2013-01-30 Timo Sirainen + doveadm acl recalc command added diff -r 3ec0d772be49 -r fc75811f3c08 configure.in --- a/configure.in Wed Feb 06 19:00:52 2013 +0200 +++ b/configure.in Fri Feb 08 15:05:36 2013 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.14],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.15],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Fri Feb 8 15:12:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 08 Feb 2013 15:12:15 +0200 Subject: dovecot-2.1: Added signature for changeset fc75811f3c08 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/26fa19903dcd changeset: 14903:26fa19903dcd user: Timo Sirainen date: Fri Feb 08 15:05:40 2013 +0200 description: Added signature for changeset fc75811f3c08 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 5fe181f1497a -r 26fa19903dcd .hgsigs --- a/.hgsigs Fri Feb 08 15:05:37 2013 +0200 +++ b/.hgsigs Fri Feb 08 15:05:40 2013 +0200 @@ -54,3 +54,4 @@ 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 0 iEYEABECAAYFAlC4WKwACgkQyUhSUUBViskaOACgmcwWV8hgsCOWvkbdh0OIw1ImSQYAn1RcTL0CG3M8+XG7QrrxSfQ7+V99 cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 0 iEYEABECAAYFAlDqjXUACgkQyUhSUUBViskUEwCfYTWHeDmPr8HfxSBQN17SD5IwDygAnROhb3IVTm9niDun4gxPxbHLo/Pe b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq +fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3 From dovecot at dovecot.org Fri Feb 8 16:42:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 08 Feb 2013 16:42:30 +0200 Subject: dovecot-2.1: mdbox: Crashfix for storage rebuild Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2def25f07ca6 changeset: 14904:2def25f07ca6 user: Timo Sirainen date: Fri Feb 08 16:42:21 2013 +0200 description: mdbox: Crashfix for storage rebuild diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 26fa19903dcd -r 2def25f07ca6 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 08 15:05:40 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 08 16:42:21 2013 +0200 @@ -430,7 +430,7 @@ still try to look it up using map_uid. */ rec = map_uid == 0 ? NULL : rebuild_lookup_map_uid(ctx, map_uid); - map_uid = rec->map_uid; + map_uid = rec == NULL ? 0 : rec->map_uid; } else if (!guid_hash_have_map_uid(&rec, map_uid)) { /* message's GUID and map_uid point to different physical messages. assume that GUID is correct and From dovecot at dovecot.org Sun Feb 10 23:12:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 10 Feb 2013 23:12:04 +0200 Subject: dovecot-2.2: dsync: Fixed mailbox tree sync with some backends (... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/28db20f9c0cf changeset: 15742:28db20f9c0cf user: Timo Sirainen date: Sun Feb 10 23:05:46 2013 +0200 description: dsync: Fixed mailbox tree sync with some backends (imapc) diffstat: src/doveadm/dsync/dsync-mailbox-tree-fill.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 03a0af22100d -r 28db20f9c0cf src/doveadm/dsync/dsync-mailbox-tree-fill.c --- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Tue Feb 05 03:53:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Sun Feb 10 23:05:46 2013 +0200 @@ -38,7 +38,7 @@ /* try the fast path */ if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, metadata_r) < 0) return -1; - if (mailbox_get_status(box, STATUS_UIDVALIDITY, status_r) < 0) + if (mailbox_get_status(box, STATUS_UIDVALIDITY | STATUS_UIDNEXT, status_r) < 0) return -1; i_assert(!guid_128_is_empty(metadata_r->guid)); @@ -48,7 +48,7 @@ /* no UIDVALIDITY assigned yet. syncing a mailbox should add it. */ if (mailbox_sync(box, 0) < 0) return -1; - if (mailbox_get_status(box, STATUS_UIDVALIDITY, status_r) < 0) + if (mailbox_get_status(box, STATUS_UIDVALIDITY | STATUS_UIDNEXT, status_r) < 0) return -1; i_assert(status_r->uidvalidity != 0); return 0; From dovecot at dovecot.org Sun Feb 10 23:12:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 10 Feb 2013 23:12:04 +0200 Subject: dovecot-2.2: dsync: Removed unused DSYNC_MAILBOX_IMPORT_FLAG_MAI... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9a9d408336ea changeset: 15743:9a9d408336ea user: Timo Sirainen date: Sun Feb 10 23:09:55 2013 +0200 description: dsync: Removed unused DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS flag. diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 2 -- src/doveadm/dsync/dsync-mailbox-import.c | 3 --- src/doveadm/dsync/dsync-mailbox-import.h | 5 ++--- 3 files changed, 2 insertions(+), 8 deletions(-) diffs (47 lines): diff -r 28db20f9c0cf -r 9a9d408336ea src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Sun Feb 10 23:05:46 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Sun Feb 10 23:09:55 2013 +0200 @@ -205,8 +205,6 @@ import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_WANT_MAIL_REQUESTS; if (brain->master_brain) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN; - if (brain->mails_have_guids) - import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS; if (brain->backup_recv) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES; if (brain->debug) diff -r 28db20f9c0cf -r 9a9d408336ea src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 10 23:05:46 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 10 23:09:55 2013 +0200 @@ -84,7 +84,6 @@ unsigned int local_expunged_guids_set:1; unsigned int new_uids_assigned:1; unsigned int want_mail_requests:1; - unsigned int mails_have_guids:1; unsigned int master_brain:1; unsigned int revert_local_changes:1; }; @@ -164,8 +163,6 @@ i_array_init(&importer->mail_requests, 128); importer->want_mail_requests = TRUE; } - importer->mails_have_guids = - (flags & DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS) != 0; importer->master_brain = (flags & DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN) != 0; importer->revert_local_changes = diff -r 28db20f9c0cf -r 9a9d408336ea src/doveadm/dsync/dsync-mailbox-import.h --- a/src/doveadm/dsync/dsync-mailbox-import.h Sun Feb 10 23:05:46 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.h Sun Feb 10 23:09:55 2013 +0200 @@ -4,9 +4,8 @@ enum dsync_mailbox_import_flags { DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN = 0x01, DSYNC_MAILBOX_IMPORT_FLAG_WANT_MAIL_REQUESTS = 0x02, - DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS = 0x04, - DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES = 0x08, - DSYNC_MAILBOX_IMPORT_FLAG_DEBUG = 0x10 + DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES = 0x04, + DSYNC_MAILBOX_IMPORT_FLAG_DEBUG = 0x08 }; struct mailbox; From dovecot at dovecot.org Sun Feb 10 23:12:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 10 Feb 2013 23:12:04 +0200 Subject: dovecot-2.2: dsync: Renamed "guid_requests" to "mail_requests" Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b4e2b3b54f0a changeset: 15744:b4e2b3b54f0a user: Timo Sirainen date: Sun Feb 10 23:11:52 2013 +0200 description: dsync: Renamed "guid_requests" to "mail_requests" The mails aren't necessarily requested by their GUID. diffstat: src/doveadm/dsync/doveadm-dsync.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox.c | 8 ++++---- src/doveadm/dsync/dsync-brain-mails.c | 10 +++++----- src/doveadm/dsync/dsync-brain-private.h | 2 +- src/doveadm/dsync/dsync-brain.c | 4 ++-- src/doveadm/dsync/dsync-brain.h | 2 +- src/doveadm/dsync/dsync-ibc-stream.c | 10 +++++----- 7 files changed, 19 insertions(+), 19 deletions(-) diffs (168 lines): diff -r 9a9d408336ea -r b4e2b3b54f0a src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Sun Feb 10 23:09:55 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Sun Feb 10 23:11:52 2013 +0200 @@ -420,7 +420,7 @@ } brain_flags = DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS | - DSYNC_BRAIN_FLAG_SEND_GUID_REQUESTS; + DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS; if (ctx->sync_all_namespaces) brain_flags |= DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES; diff -r 9a9d408336ea -r b4e2b3b54f0a src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Sun Feb 10 23:09:55 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Sun Feb 10 23:11:52 2013 +0200 @@ -85,12 +85,12 @@ if (brain->backup_send) { /* we have an exporter, but no importer. */ brain->box_send_state = DSYNC_BOX_STATE_CHANGES; - brain->box_recv_state = brain->guid_requests ? + brain->box_recv_state = brain->mail_requests ? DSYNC_BOX_STATE_MAIL_REQUESTS : DSYNC_BOX_STATE_RECV_LAST_COMMON; } else if (brain->backup_recv) { /* we have an importer, but no exporter */ - brain->box_send_state = brain->guid_requests ? + brain->box_send_state = brain->mail_requests ? DSYNC_BOX_STATE_MAIL_REQUESTS : DSYNC_BOX_STATE_DONE; brain->box_recv_state = DSYNC_BOX_STATE_CHANGES; @@ -161,7 +161,7 @@ return -1; } - if (!brain->guid_requests) + if (!brain->mail_requests) exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_AUTO_EXPORT_MAILS; if (brain->mails_have_guids) exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_MAILS_HAVE_GUIDS; @@ -201,7 +201,7 @@ last_common_pvt_modseq = 0; } - if (brain->guid_requests) + if (brain->mail_requests) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_WANT_MAIL_REQUESTS; if (brain->master_brain) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN; diff -r 9a9d408336ea -r b4e2b3b54f0a src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Sun Feb 10 23:09:55 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mails.c Sun Feb 10 23:11:52 2013 +0200 @@ -69,7 +69,7 @@ return FALSE; if (ret == DSYNC_IBC_RECV_RET_FINISHED) { dsync_mailbox_import_changes_finish(brain->box_importer); - if (brain->guid_requests && brain->box_exporter != NULL) + if (brain->mail_requests && brain->box_exporter != NULL) brain->box_recv_state = DSYNC_BOX_STATE_MAIL_REQUESTS; else brain->box_recv_state = DSYNC_BOX_STATE_MAILS; @@ -88,7 +88,7 @@ return; } dsync_ibc_send_end_of_list(brain->ibc); - if (brain->guid_requests && brain->box_importer != NULL) + if (brain->mail_requests && brain->box_importer != NULL) brain->box_send_state = DSYNC_BOX_STATE_MAIL_REQUESTS; else brain->box_send_state = DSYNC_BOX_STATE_MAILS; @@ -99,7 +99,7 @@ const struct dsync_mail_request *request; enum dsync_ibc_recv_ret ret; - i_assert(brain->guid_requests); + i_assert(brain->mail_requests); i_assert(brain->box_exporter != NULL); if ((ret = dsync_ibc_recv_mail_request(brain->ibc, &request)) == 0) @@ -118,7 +118,7 @@ { const struct dsync_mail_request *request; - i_assert(brain->guid_requests); + i_assert(brain->mail_requests); while ((request = dsync_mailbox_import_next_request(brain->box_importer)) != NULL) { if (dsync_ibc_send_mail_request(brain->ibc, request) == 0) @@ -218,7 +218,7 @@ if (dsync_ibc_send_mail(brain->ibc, mail) == 0) return TRUE; } - if (brain->guid_requests && + if (brain->mail_requests && brain->box_recv_state < DSYNC_BOX_STATE_MAILS) { /* wait for mail requests to finish */ return changed; diff -r 9a9d408336ea -r b4e2b3b54f0a src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Sun Feb 10 23:09:55 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-private.h Sun Feb 10 23:11:52 2013 +0200 @@ -77,7 +77,7 @@ ARRAY_TYPE(dsync_mailbox_state) remote_mailbox_states; unsigned int master_brain:1; - unsigned int guid_requests:1; + unsigned int mail_requests:1; unsigned int mails_have_guids:1; unsigned int backup_send:1; unsigned int backup_recv:1; diff -r 9a9d408336ea -r b4e2b3b54f0a src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Sun Feb 10 23:09:55 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Sun Feb 10 23:11:52 2013 +0200 @@ -70,8 +70,8 @@ static void dsync_brain_set_flags(struct dsync_brain *brain, enum dsync_brain_flags flags) { - brain->guid_requests = - (flags & DSYNC_BRAIN_FLAG_SEND_GUID_REQUESTS) != 0; + brain->mail_requests = + (flags & DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS) != 0; brain->mails_have_guids = (flags & DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS) != 0; brain->backup_send = (flags & DSYNC_BRAIN_FLAG_BACKUP_SEND) != 0; diff -r 9a9d408336ea -r b4e2b3b54f0a src/doveadm/dsync/dsync-brain.h --- a/src/doveadm/dsync/dsync-brain.h Sun Feb 10 23:09:55 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.h Sun Feb 10 23:11:52 2013 +0200 @@ -7,7 +7,7 @@ enum dsync_brain_flags { DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS = 0x01, - DSYNC_BRAIN_FLAG_SEND_GUID_REQUESTS = 0x02, + DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS = 0x02, DSYNC_BRAIN_FLAG_BACKUP_SEND = 0x04, DSYNC_BRAIN_FLAG_BACKUP_RECV = 0x08, DSYNC_BRAIN_FLAG_DEBUG = 0x10, diff -r 9a9d408336ea -r b4e2b3b54f0a src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Sun Feb 10 23:09:55 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Sun Feb 10 23:11:52 2013 +0200 @@ -61,7 +61,7 @@ { .name = "handshake", .chr = 'H', .optional_keys = "sync_ns_prefix sync_box sync_type debug sync_all_namespaces " - "mails_have_guids send_guid_requests backup_send backup_recv" + "mails_have_guids send_mail_requests backup_send backup_recv" }, { .name = "mailbox_state", .chr = 'S', @@ -535,8 +535,8 @@ dsync_serializer_encode_add(encoder, "sync_type", sync_type); if ((set->brain_flags & DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS) != 0) dsync_serializer_encode_add(encoder, "mails_have_guids", ""); - if ((set->brain_flags & DSYNC_BRAIN_FLAG_SEND_GUID_REQUESTS) != 0) - dsync_serializer_encode_add(encoder, "send_guid_requests", ""); + if ((set->brain_flags & DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS) != 0) + dsync_serializer_encode_add(encoder, "send_mail_requests", ""); if ((set->brain_flags & DSYNC_BRAIN_FLAG_BACKUP_SEND) != 0) dsync_serializer_encode_add(encoder, "backup_send", ""); if ((set->brain_flags & DSYNC_BRAIN_FLAG_BACKUP_RECV) != 0) @@ -597,8 +597,8 @@ } if (dsync_deserializer_decode_try(decoder, "mails_have_guids", &value)) set->brain_flags |= DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS; - if (dsync_deserializer_decode_try(decoder, "send_guid_requests", &value)) - set->brain_flags |= DSYNC_BRAIN_FLAG_SEND_GUID_REQUESTS; + if (dsync_deserializer_decode_try(decoder, "send_mail_requests", &value)) + set->brain_flags |= DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS; if (dsync_deserializer_decode_try(decoder, "backup_send", &value)) set->brain_flags |= DSYNC_BRAIN_FLAG_BACKUP_SEND; if (dsync_deserializer_decode_try(decoder, "backup_recv", &value)) From dovecot at dovecot.org Sun Feb 10 23:27:54 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 10 Feb 2013 23:27:54 +0200 Subject: dovecot-2.2: dsync: When looking up header hashes, use only Date... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f7a0ef7fdaad changeset: 15745:f7a0ef7fdaad user: Timo Sirainen date: Sun Feb 10 23:27:49 2013 +0200 description: dsync: When looking up header hashes, use only Date: and Message-Id: headers This makes it more efficient, at least in future when imapc backend optimizes this. diffstat: src/doveadm/dsync/dsync-mail.c | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-) diffs (55 lines): diff -r b4e2b3b54f0a -r f7a0ef7fdaad src/doveadm/dsync/dsync-mail.c --- a/src/doveadm/dsync/dsync-mail.c Sun Feb 10 23:11:52 2013 +0200 +++ b/src/doveadm/dsync/dsync-mail.c Sun Feb 10 23:27:49 2013 +0200 @@ -9,32 +9,41 @@ #include "mail-storage.h" #include "dsync-mail.h" +/* These should be good enough to identify all normal mails. Received: header + would make it even better, but those can be somewhat large. Also these + fields can be looked up using IMAP ENVELOPE, which is more efficient in + some IMAP servers. */ +static const char *hashed_headers[] = { + "Date", "Message-ID", NULL +}; + int dsync_mail_get_hdr_hash(struct mail *mail, const char **hdr_hash_r) { - struct message_size hdr_size; - struct istream *input, *hdr_input; + struct istream *input; + struct mailbox_header_lookup_ctx *hdr_ctx; struct md5_context md5_ctx; unsigned char md5_result[MD5_RESULTLEN]; const unsigned char *data; size_t size; int ret = 0; - - if (mail_get_hdr_stream(mail, &hdr_size, &input) < 0) + + hdr_ctx = mailbox_header_lookup_init(mail->box, hashed_headers); + ret = mail_get_header_stream(mail, hdr_ctx, &input); + mailbox_header_lookup_unref(&hdr_ctx); + if (ret < 0) return -1; md5_init(&md5_ctx); - hdr_input = i_stream_create_limit(input, hdr_size.physical_size); - while (!i_stream_is_eof(hdr_input)) { - if (i_stream_read_data(hdr_input, &data, &size, 0) == -1) + while (!i_stream_is_eof(input)) { + if (i_stream_read_data(input, &data, &size, 0) == -1) break; if (size == 0) break; md5_update(&md5_ctx, data, size); - i_stream_skip(hdr_input, size); + i_stream_skip(input, size); } - if (hdr_input->stream_errno != 0) + if (input->stream_errno != 0) ret = -1; - i_stream_unref(&hdr_input); md5_final(&md5_ctx, md5_result); *hdr_hash_r = binary_to_hex(md5_result, sizeof(md5_result)); From dovecot at dovecot.org Mon Feb 11 00:25:02 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 00:25:02 +0200 Subject: dovecot-2.2: lib-storage: mailbox_status.nonpermanent_modseqs is... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2aa20ea42d6d changeset: 15746:2aa20ea42d6d user: Timo Sirainen date: Mon Feb 11 00:23:07 2013 +0200 description: lib-storage: mailbox_status.nonpermanent_modseqs is now only set with STATUS_HIGHESTMODSEQ diffstat: src/lib-storage/index/index-status.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (17 lines): diff -r f7a0ef7fdaad -r 2aa20ea42d6d src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Sun Feb 10 23:27:49 2013 +0200 +++ b/src/lib-storage/index/index-status.c Mon Feb 11 00:23:07 2013 +0200 @@ -133,10 +133,10 @@ status_r->uidvalidity = hdr->uid_validity; status_r->uidnext = hdr->next_uid; status_r->first_recent_uid = hdr->first_recent_uid; - status_r->nonpermanent_modseqs = - mail_index_is_in_memory(box->index) || - !mail_index_have_modseq_tracking(box->index); if ((items & STATUS_HIGHESTMODSEQ) != 0) { + status_r->nonpermanent_modseqs = + mail_index_is_in_memory(box->index) || + !mail_index_have_modseq_tracking(box->index); status_r->highest_modseq = mail_index_modseq_get_highest(box->view); if (status_r->highest_modseq == 0) { From dovecot at dovecot.org Mon Feb 11 00:25:02 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 00:25:02 +0200 Subject: dovecot-2.2: lib-storage: Don't unnecessarily clear mailbox_stat... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2492fa1232a0 changeset: 15747:2492fa1232a0 user: Timo Sirainen date: Mon Feb 11 00:24:56 2013 +0200 description: lib-storage: Don't unnecessarily clear mailbox_status multiple times. diffstat: src/lib-storage/fail-mailbox.c | 1 - src/lib-storage/index/index-status.c | 2 -- src/lib-storage/list/mailbox-list-index-status.c | 2 -- 3 files changed, 0 insertions(+), 5 deletions(-) diffs (35 lines): diff -r 2aa20ea42d6d -r 2492fa1232a0 src/lib-storage/fail-mailbox.c --- a/src/lib-storage/fail-mailbox.c Mon Feb 11 00:23:07 2013 +0200 +++ b/src/lib-storage/fail-mailbox.c Mon Feb 11 00:24:56 2013 +0200 @@ -81,7 +81,6 @@ enum mailbox_status_items items ATTR_UNUSED, struct mailbox_status *status_r) { - memset(status_r, 0, sizeof(*status_r)); status_r->uidvalidity = TEST_UID_VALIDITY; status_r->uidnext = 1; mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND, diff -r 2aa20ea42d6d -r 2492fa1232a0 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Mon Feb 11 00:23:07 2013 +0200 +++ b/src/lib-storage/index/index-status.c Mon Feb 11 00:24:56 2013 +0200 @@ -109,8 +109,6 @@ { const struct mail_index_header *hdr; - memset(status_r, 0, sizeof(struct mailbox_status)); - /* we can get most of the status items without any trouble */ hdr = mail_index_get_header(box->view); status_r->messages = hdr->messages_count; diff -r 2aa20ea42d6d -r 2492fa1232a0 src/lib-storage/list/mailbox-list-index-status.c --- a/src/lib-storage/list/mailbox-list-index-status.c Mon Feb 11 00:23:07 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index-status.c Mon Feb 11 00:24:56 2013 +0200 @@ -122,8 +122,6 @@ uint32_t seq; int ret; - memset(status_r, 0, sizeof(*status_r)); - if ((items & STATUS_UNSEEN) != 0 && (mailbox_get_private_flags_mask(box) & MAIL_SEEN) != 0) { /* can't get UNSEEN from list index, since each user has From dovecot at dovecot.org Mon Feb 11 00:29:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 00:29:48 +0200 Subject: dovecot-2.2: lib-storage: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/490fa658b66d changeset: 15748:490fa658b66d user: Timo Sirainen date: Mon Feb 11 00:25:29 2013 +0200 description: lib-storage: Minor code cleanup diffstat: src/lib-storage/fail-mailbox.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diffs (17 lines): diff -r 2492fa1232a0 -r 490fa658b66d src/lib-storage/fail-mailbox.c --- a/src/lib-storage/fail-mailbox.c Mon Feb 11 00:24:56 2013 +0200 +++ b/src/lib-storage/fail-mailbox.c Mon Feb 11 00:25:29 2013 +0200 @@ -116,12 +116,10 @@ static int fail_mailbox_sync_deinit(struct mailbox_sync_context *ctx, - struct mailbox_sync_status *status_r) + struct mailbox_sync_status *status_r ATTR_UNUSED) { mail_storage_set_error(ctx->box->storage, MAIL_ERROR_NOTFOUND, T_MAIL_ERR_MAILBOX_NOT_FOUND(ctx->box->vname)); - if (status_r != NULL) - memset(status_r, 0, sizeof(*status_r)); i_free(ctx); return -1; } From dovecot at dovecot.org Mon Feb 11 00:29:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 00:29:48 +0200 Subject: dovecot-2.2: lib-storage: Added mailbox_status.have_guids flag Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/91f60f0d72df changeset: 15749:91f60f0d72df user: Timo Sirainen date: Mon Feb 11 00:26:15 2013 +0200 description: lib-storage: Added mailbox_status.have_guids flag diffstat: src/lib-storage/index/dbox-multi/mdbox-storage.c | 3 +- src/lib-storage/index/dbox-single/sdbox-storage.c | 3 +- src/lib-storage/index/imapc/imapc-storage.c | 4 +- src/lib-storage/index/maildir/maildir-storage.c | 3 +- src/lib-storage/index/mbox/mbox-storage.c | 3 +- src/lib-storage/mail-storage-private.h | 4 +- src/lib-storage/mail-storage.c | 13 ++++++- src/lib-storage/mail-storage.h | 38 ++++++++++++---------- src/plugins/virtual/virtual-storage.c | 11 ++++++ src/plugins/virtual/virtual-storage.h | 1 + 10 files changed, 58 insertions(+), 25 deletions(-) diffs (230 lines): diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Mon Feb 11 00:26:15 2013 +0200 @@ -409,7 +409,8 @@ struct mail_storage mdbox_storage = { .name = MDBOX_STORAGE_NAME, - .class_flags = MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT, + .class_flags = MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT | + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS, .v = { mdbox_get_setting_parser_info, diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Mon Feb 11 00:26:15 2013 +0200 @@ -389,7 +389,8 @@ struct mail_storage sdbox_storage = { .name = SDBOX_STORAGE_NAME, - .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG, + .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG | + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS, .v = { NULL, diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/index/imapc/imapc-storage.c Mon Feb 11 00:26:15 2013 +0200 @@ -661,7 +661,9 @@ struct imapc_simple_context sctx; string_t *str; - memset(status_r, 0, sizeof(*status_r)); + if (mbox->guid_fetch_field_name != NULL || + IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_GUID_FORCED)) + status_r->have_guids = TRUE; if (box->opened) { imapc_mailbox_get_selected_status(mbox, items, status_r); diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-storage.c Mon Feb 11 00:26:15 2013 +0200 @@ -656,7 +656,8 @@ struct mail_storage maildir_storage = { .name = MAILDIR_STORAGE_NAME, - .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG, + .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG | + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS, .v = { maildir_get_setting_parser_info, diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/index/mbox/mbox-storage.c Mon Feb 11 00:26:15 2013 +0200 @@ -791,7 +791,8 @@ struct mail_storage mbox_storage = { .name = MBOX_STORAGE_NAME, .class_flags = MAIL_STORAGE_CLASS_FLAG_MAILBOX_IS_FILE | - MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS, + MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS | + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS, .v = { mbox_get_setting_parser_info, diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/mail-storage-private.h Mon Feb 11 00:26:15 2013 +0200 @@ -64,7 +64,9 @@ /* Storage doesn't need a mail root directory */ MAIL_STORAGE_CLASS_FLAG_NO_ROOT = 0x10, /* Storage uses one file per message */ - MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG = 0x20 + MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG = 0x20, + /* Messages have GUIDs (always set mailbox_status.have_guids=TRUE) */ + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS = 0x40 }; struct mail_binary_cache { diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/mail-storage.c Mon Feb 11 00:26:15 2013 +0200 @@ -1453,11 +1453,20 @@ return ns1 == ns2; } +static void +mailbox_get_status_set_defaults(struct mailbox *box, + struct mailbox_status *status_r) +{ + memset(status_r, 0, sizeof(*status_r)); + if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS) != 0) + status_r->have_guids = TRUE; +} + int mailbox_get_status(struct mailbox *box, enum mailbox_status_items items, struct mailbox_status *status_r) { - memset(status_r, 0, sizeof(*status_r)); + mailbox_get_status_set_defaults(box, status_r); if (mailbox_verify_existing_name(box) < 0) return -1; return box->v.get_status(box, items, status_r); @@ -1469,7 +1478,7 @@ { i_assert(box->opened); - memset(status_r, 0, sizeof(*status_r)); + mailbox_get_status_set_defaults(box, status_r); if (box->v.get_status(box, items, status_r) < 0) i_unreached(); } diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Mon Feb 11 00:25:29 2013 +0200 +++ b/src/lib-storage/mail-storage.h Mon Feb 11 00:26:15 2013 +0200 @@ -223,31 +223,35 @@ struct mailbox_transaction_context; struct mailbox_status { - uint32_t messages; - uint32_t recent; - uint32_t unseen; + uint32_t messages; /* STATUS_MESSAGES */ + uint32_t recent; /* STATUS_RECENT */ + uint32_t unseen; /* STATUS_UNSEEN */ - uint32_t uidvalidity; - uint32_t uidnext; + uint32_t uidvalidity; /* STATUS_UIDVALIDITY */ + uint32_t uidnext; /* STATUS_UIDNEXT */ - uint32_t first_unseen_seq; - uint32_t first_recent_uid; - uint32_t last_cached_seq; - uint64_t highest_modseq; - uint64_t highest_pvt_modseq; /* 0 if no private index */ + uint32_t first_unseen_seq; /* STATUS_FIRST_UNSEEN_SEQ */ + uint32_t first_recent_uid; /* STATUS_FIRST_RECENT_UID */ + uint32_t last_cached_seq; /* STATUS_LAST_CACHED_SEQ */ + uint64_t highest_modseq; /* STATUS_HIGHESTMODSEQ */ + /* 0 if no private index (STATUS_HIGHESTPVTMODSEQ) */ + uint64_t highest_pvt_modseq; - /* NULL-terminated array of keywords */ + /* NULL-terminated array of keywords (STATUS_KEYWORDS) */ const ARRAY_TYPE(keywords) *keywords; - /* These flags can be permanently modified */ + /* These flags can be permanently modified (STATUS_PERMANENT_FLAGS) */ enum mail_flags permanent_flags; - /* Modseqs aren't permanent (index is in memory) */ + /* All keywords can be permanently modified (STATUS_PERMANENT_FLAGS) */ + unsigned int permanent_keywords:1; + /* More keywords can be created (STATUS_PERMANENT_FLAGS) */ + unsigned int allow_new_keywords:1; + /* Modseqs aren't permanent (index is in memory) (STATUS_HIGHESTMODSEQ) */ unsigned int nonpermanent_modseqs:1; - /* All keywords can be permanently modified */ - unsigned int permanent_keywords:1; - /* More keywords can be created */ - unsigned int allow_new_keywords:1; + + /* Messages have GUIDs (always set) */ + unsigned int have_guids:1; }; struct mailbox_cache_field { diff -r 490fa658b66d -r 91f60f0d72df src/plugins/virtual/virtual-storage.c --- a/src/plugins/virtual/virtual-storage.c Mon Feb 11 00:25:29 2013 +0200 +++ b/src/plugins/virtual/virtual-storage.c Mon Feb 11 00:26:15 2013 +0200 @@ -161,6 +161,7 @@ { struct mail_user *user = mbox->storage->storage.user; struct mail_namespace *ns; + struct mailbox_status status; const char *mailbox; i_assert(bbox->box == NULL); @@ -177,6 +178,10 @@ i_array_init(&bbox->uids, 64); i_array_init(&bbox->sync_pending_removes, 64); mail_search_args_init(bbox->search_args, bbox->box, FALSE, NULL); + + mailbox_get_open_status(bbox->box, 0, &status); + if (!status.have_guids) + mbox->have_guids = FALSE; return 1; } @@ -187,6 +192,8 @@ unsigned int i, count; int ret; + mbox->have_guids = TRUE; + bboxes = array_get(&mbox->backend_boxes, &count); for (i = 0; i < count; ) { ret = virtual_backend_box_open(mbox, bboxes[i], flags); @@ -339,6 +346,8 @@ enum mailbox_status_items items, struct mailbox_status *status_r) { + struct virtual_mailbox *mbox = (struct virtual_mailbox *)box; + if ((items & STATUS_LAST_CACHED_SEQ) != 0) items |= STATUS_MESSAGES; @@ -354,6 +363,8 @@ indexed. */ status_r->last_cached_seq = status_r->messages; } + if (mbox->have_guids) + status_r->have_guids = TRUE; return 0; } diff -r 490fa658b66d -r 91f60f0d72df src/plugins/virtual/virtual-storage.h --- a/src/plugins/virtual/virtual-storage.h Mon Feb 11 00:25:29 2013 +0200 +++ b/src/plugins/virtual/virtual-storage.h Mon Feb 11 00:26:15 2013 +0200 @@ -144,6 +144,7 @@ unsigned int uids_mapped:1; unsigned int sync_initialized:1; unsigned int inconsistent:1; + unsigned int have_guids:1; }; extern MODULE_CONTEXT_DEFINE(virtual_storage_module, From dovecot at dovecot.org Mon Feb 11 00:29:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 00:29:48 +0200 Subject: dovecot-2.2: dsync: Automatically figure out which mailboxes can... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5a1fc3723371 changeset: 15750:5a1fc3723371 user: Timo Sirainen date: Mon Feb 11 00:28:28 2013 +0200 description: dsync: Automatically figure out which mailboxes can sync with message GUIDs. diffstat: src/doveadm/dsync/doveadm-dsync.c | 3 +- src/doveadm/dsync/dsync-brain-mailbox.c | 87 +++++++++++++++++--------------- src/doveadm/dsync/dsync-brain-mails.c | 3 +- src/doveadm/dsync/dsync-brain-private.h | 6 +- src/doveadm/dsync/dsync-brain.c | 2 - src/doveadm/dsync/dsync-brain.h | 11 +-- src/doveadm/dsync/dsync-ibc-stream.c | 12 ++-- src/doveadm/dsync/dsync-mailbox.h | 1 + 8 files changed, 62 insertions(+), 63 deletions(-) diffs (269 lines): diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 11 00:28:28 2013 +0200 @@ -419,8 +419,7 @@ remote_error_input, ctx); } - brain_flags = DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS | - DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS; + brain_flags = DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS; if (ctx->sync_all_namespaces) brain_flags |= DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES; diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Mon Feb 11 00:28:28 2013 +0200 @@ -136,45 +136,9 @@ } } -int dsync_brain_sync_mailbox_open(struct dsync_brain *brain) -{ - enum dsync_mailbox_exporter_flags exporter_flags = 0; - uint32_t last_common_uid, highest_wanted_uid; - uint64_t last_common_modseq, last_common_pvt_modseq; - - i_assert(brain->log_scan == NULL); - - last_common_uid = brain->mailbox_state.last_common_uid; - last_common_modseq = brain->mailbox_state.last_common_modseq; - last_common_pvt_modseq = brain->mailbox_state.last_common_pvt_modseq; - highest_wanted_uid = last_common_uid == 0 ? - (uint32_t)-1 : last_common_uid; - if (dsync_transaction_log_scan_init(brain->box->view, - brain->box->view_pvt, - highest_wanted_uid, - last_common_modseq, - last_common_pvt_modseq, - &brain->log_scan) < 0) { - i_error("Failed to read transaction log for mailbox %s", - mailbox_get_vname(brain->box)); - brain->failed = TRUE; - return -1; - } - - if (!brain->mail_requests) - exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_AUTO_EXPORT_MAILS; - if (brain->mails_have_guids) - exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_MAILS_HAVE_GUIDS; - - brain->box_exporter = brain->backup_recv ? NULL : - dsync_mailbox_export_init(brain->box, brain->log_scan, - last_common_uid, - exporter_flags); - return 0; -} - -void dsync_brain_sync_mailbox_init_remote(struct dsync_brain *brain, - const struct dsync_mailbox *remote_dsync_box) +static void +dsync_brain_sync_mailbox_init_remote(struct dsync_brain *brain, + const struct dsync_mailbox *remote_dsync_box) { enum dsync_mailbox_import_flags import_flags = 0; const struct dsync_mailbox_state *state; @@ -221,6 +185,46 @@ import_flags); } +int dsync_brain_sync_mailbox_open(struct dsync_brain *brain, + const struct dsync_mailbox *remote_dsync_box) +{ + enum dsync_mailbox_exporter_flags exporter_flags = 0; + uint32_t last_common_uid, highest_wanted_uid; + uint64_t last_common_modseq, last_common_pvt_modseq; + + i_assert(brain->log_scan == NULL); + + last_common_uid = brain->mailbox_state.last_common_uid; + last_common_modseq = brain->mailbox_state.last_common_modseq; + last_common_pvt_modseq = brain->mailbox_state.last_common_pvt_modseq; + highest_wanted_uid = last_common_uid == 0 ? + (uint32_t)-1 : last_common_uid; + if (dsync_transaction_log_scan_init(brain->box->view, + brain->box->view_pvt, + highest_wanted_uid, + last_common_modseq, + last_common_pvt_modseq, + &brain->log_scan) < 0) { + i_error("Failed to read transaction log for mailbox %s", + mailbox_get_vname(brain->box)); + brain->failed = TRUE; + return -1; + } + + if (!brain->mail_requests) + exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_AUTO_EXPORT_MAILS; + if (brain->local_dsync_box.have_guids && + remote_dsync_box->have_guids) + exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_MAILS_HAVE_GUIDS; + + brain->box_exporter = brain->backup_recv ? NULL : + dsync_mailbox_export_init(brain->box, brain->log_scan, + last_common_uid, + exporter_flags); + dsync_brain_sync_mailbox_init_remote(brain, remote_dsync_box); + return 0; +} + void dsync_brain_sync_mailbox_deinit(struct dsync_brain *brain) { i_assert(brain->box != NULL); @@ -294,6 +298,7 @@ dsync_box_r->highest_modseq = status.highest_modseq; dsync_box_r->highest_pvt_modseq = status.highest_pvt_modseq; dsync_box_r->cache_fields = *metadata.cache_fields; + dsync_box_r->have_guids = status.have_guids; return 1; } @@ -626,8 +631,8 @@ /* start export/import */ dsync_brain_sync_mailbox_init(brain, box, &local_dsync_box, FALSE); - if (dsync_brain_sync_mailbox_open(brain) == 0) - dsync_brain_sync_mailbox_init_remote(brain, dsync_box); + if (dsync_brain_sync_mailbox_open(brain, dsync_box) < 0) + return TRUE; brain->state = DSYNC_STATE_SYNC_MAILS; return TRUE; diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mails.c Mon Feb 11 00:28:28 2013 +0200 @@ -53,9 +53,8 @@ dsync_brain_sync_mailbox_deinit(brain); return TRUE; } - if (dsync_brain_sync_mailbox_open(brain) < 0) + if (dsync_brain_sync_mailbox_open(brain, dsync_box) < 0) return TRUE; - dsync_brain_sync_mailbox_init_remote(brain, dsync_box); dsync_brain_sync_init_box_states(brain); return TRUE; } diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-private.h Mon Feb 11 00:28:28 2013 +0200 @@ -78,7 +78,6 @@ unsigned int master_brain:1; unsigned int mail_requests:1; - unsigned int mails_have_guids:1; unsigned int backup_send:1; unsigned int backup_recv:1; unsigned int debug:1; @@ -108,9 +107,8 @@ void dsync_brain_master_send_mailbox(struct dsync_brain *brain); bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain); -int dsync_brain_sync_mailbox_open(struct dsync_brain *brain); -void dsync_brain_sync_mailbox_init_remote(struct dsync_brain *brain, - const struct dsync_mailbox *remote_dsync_box); +int dsync_brain_sync_mailbox_open(struct dsync_brain *brain, + const struct dsync_mailbox *remote_dsync_box); bool dsync_brain_sync_mails(struct dsync_brain *brain); #endif diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Mon Feb 11 00:28:28 2013 +0200 @@ -72,8 +72,6 @@ { brain->mail_requests = (flags & DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS) != 0; - brain->mails_have_guids = - (flags & DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS) != 0; brain->backup_send = (flags & DSYNC_BRAIN_FLAG_BACKUP_SEND) != 0; brain->backup_recv = (flags & DSYNC_BRAIN_FLAG_BACKUP_RECV) != 0; brain->debug = (flags & DSYNC_BRAIN_FLAG_DEBUG) != 0; diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/dsync-brain.h --- a/src/doveadm/dsync/dsync-brain.h Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.h Mon Feb 11 00:28:28 2013 +0200 @@ -6,12 +6,11 @@ struct dsync_ibc; enum dsync_brain_flags { - DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS = 0x01, - DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS = 0x02, - DSYNC_BRAIN_FLAG_BACKUP_SEND = 0x04, - DSYNC_BRAIN_FLAG_BACKUP_RECV = 0x08, - DSYNC_BRAIN_FLAG_DEBUG = 0x10, - DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES = 0x20 + DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS = 0x01, + DSYNC_BRAIN_FLAG_BACKUP_SEND = 0x02, + DSYNC_BRAIN_FLAG_BACKUP_RECV = 0x04, + DSYNC_BRAIN_FLAG_DEBUG = 0x08, + DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES = 0x10 }; enum dsync_brain_sync_type { diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Mon Feb 11 00:28:28 2013 +0200 @@ -61,7 +61,7 @@ { .name = "handshake", .chr = 'H', .optional_keys = "sync_ns_prefix sync_box sync_type debug sync_all_namespaces " - "mails_have_guids send_mail_requests backup_send backup_recv" + "send_mail_requests backup_send backup_recv" }, { .name = "mailbox_state", .chr = 'S', @@ -83,7 +83,7 @@ .chr = 'B', .required_keys = "mailbox_guid uid_validity uid_next messages_count " "first_recent_uid highest_modseq highest_pvt_modseq", - .optional_keys = "mailbox_lost cache_fields" + .optional_keys = "mailbox_lost cache_fields have_guids" }, { .name = "mail_change", .chr = 'C', @@ -533,8 +533,6 @@ } i_assert(sync_type[0] != '\0'); dsync_serializer_encode_add(encoder, "sync_type", sync_type); - if ((set->brain_flags & DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS) != 0) - dsync_serializer_encode_add(encoder, "mails_have_guids", ""); if ((set->brain_flags & DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS) != 0) dsync_serializer_encode_add(encoder, "send_mail_requests", ""); if ((set->brain_flags & DSYNC_BRAIN_FLAG_BACKUP_SEND) != 0) @@ -595,8 +593,6 @@ return DSYNC_IBC_RECV_RET_TRYAGAIN; } } - if (dsync_deserializer_decode_try(decoder, "mails_have_guids", &value)) - set->brain_flags |= DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS; if (dsync_deserializer_decode_try(decoder, "send_mail_requests", &value)) set->brain_flags |= DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS; if (dsync_deserializer_decode_try(decoder, "backup_send", &value)) @@ -997,6 +993,8 @@ if (dsync_box->mailbox_lost) dsync_serializer_encode_add(encoder, "mailbox_lost", ""); + if (dsync_box->have_guids) + dsync_serializer_encode_add(encoder, "have_guids", ""); dsync_serializer_encode_add(encoder, "uid_validity", dec2str(dsync_box->uid_validity)); dsync_serializer_encode_add(encoder, "uid_next", @@ -1095,6 +1093,8 @@ if (dsync_deserializer_decode_try(decoder, "mailbox_lost", &value)) box->mailbox_lost = TRUE; + if (dsync_deserializer_decode_try(decoder, "have_guids", &value)) + box->have_guids = TRUE; value = dsync_deserializer_decode_get(decoder, "uid_validity"); if (str_to_uint32(value, &box->uid_validity) < 0) { dsync_ibc_input_error(ibc, decoder, "Invalid uid_validity"); diff -r 91f60f0d72df -r 5a1fc3723371 src/doveadm/dsync/dsync-mailbox.h --- a/src/doveadm/dsync/dsync-mailbox.h Mon Feb 11 00:26:15 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox.h Mon Feb 11 00:28:28 2013 +0200 @@ -8,6 +8,7 @@ struct dsync_mailbox { guid_128_t mailbox_guid; bool mailbox_lost; + bool have_guids; uint32_t uid_validity, uid_next, messages_count, first_recent_uid; uint64_t highest_modseq, highest_pvt_modseq; From dovecot at dovecot.org Mon Feb 11 00:29:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 00:29:48 +0200 Subject: dovecot-2.2: i_stream_sync() for file should reset eof flag imme... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/45c39743f406 changeset: 15751:45c39743f406 user: Timo Sirainen date: Mon Feb 11 00:29:40 2013 +0200 description: i_stream_sync() for file should reset eof flag immediately. diffstat: src/lib/istream-file.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 5a1fc3723371 -r 45c39743f406 src/lib/istream-file.c --- a/src/lib/istream-file.c Mon Feb 11 00:28:28 2013 +0200 +++ b/src/lib/istream-file.c Mon Feb 11 00:29:40 2013 +0200 @@ -142,6 +142,7 @@ } stream->skip = stream->pos = 0; + stream->istream.eof = FALSE; } static int From dovecot at dovecot.org Mon Feb 11 01:11:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 01:11:04 +0200 Subject: dovecot-2.2: dsync: Fixes for syncing without GUIDs. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f58e7b386c6e changeset: 15753:f58e7b386c6e user: Timo Sirainen date: Mon Feb 11 01:10:57 2013 +0200 description: dsync: Fixes for syncing without GUIDs. diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 3 + src/doveadm/dsync/dsync-mailbox-import.c | 49 +++++++++++++++++++++++-------- src/doveadm/dsync/dsync-mailbox-import.h | 3 +- 3 files changed, 41 insertions(+), 14 deletions(-) diffs (162 lines): diff -r d73d04e24eee -r f58e7b386c6e src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Mon Feb 11 01:07:53 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Mon Feb 11 01:10:57 2013 +0200 @@ -173,6 +173,9 @@ import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES; if (brain->debug) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_DEBUG; + if (brain->local_dsync_box.have_guids && + remote_dsync_box->have_guids) + import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS; brain->box_importer = brain->backup_send ? NULL : dsync_mailbox_import_init(brain->box, brain->log_scan, diff -r d73d04e24eee -r f58e7b386c6e src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Mon Feb 11 01:07:53 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Mon Feb 11 01:10:57 2013 +0200 @@ -55,6 +55,7 @@ struct mail *cur_mail; const char *cur_guid; + const char *cur_hdr_hash; /* UID => struct dsync_mail_change */ HASH_TABLE_TYPE(dsync_uid_mail_change) local_changes; @@ -86,6 +87,7 @@ unsigned int want_mail_requests:1; unsigned int master_brain:1; unsigned int revert_local_changes:1; + unsigned int mails_have_guids:1; }; static void @@ -168,6 +170,8 @@ importer->revert_local_changes = (flags & DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES) != 0; importer->debug = (flags & DSYNC_MAILBOX_IMPORT_FLAG_DEBUG) != 0; + importer->mails_have_guids = + (flags & DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS) != 0; mailbox_get_open_status(importer->box, STATUS_UIDNEXT | STATUS_HIGHESTMODSEQ | STATUS_HIGHESTPVTMODSEQ, @@ -214,6 +218,9 @@ static bool importer_next_mail(struct dsync_mailbox_importer *importer, uint32_t wanted_uid) { + const char *hdr_hash; + int ret = 0; + if (importer->cur_mail == NULL) { /* end of search */ return FALSE; @@ -234,15 +241,32 @@ &importer->cur_mail)) { importer->cur_mail = NULL; importer->cur_guid = NULL; + importer->cur_hdr_hash = NULL; return FALSE; } importer->cur_uid_has_change = FALSE; } importer->cur_uid_has_change = importer->cur_mail != NULL && importer->cur_mail->uid == wanted_uid; - if (mail_get_special(importer->cur_mail, MAIL_FETCH_GUID, - &importer->cur_guid) < 0) { - dsync_mail_error(importer, importer->cur_mail, "GUID"); + if (importer->mails_have_guids) { + if (mail_get_special(importer->cur_mail, MAIL_FETCH_GUID, + &importer->cur_guid) < 0) { + dsync_mail_error(importer, importer->cur_mail, "GUID"); + ret = -1; + } + } else { + if (dsync_mail_get_hdr_hash(importer->cur_mail, + &hdr_hash) < 0) { + dsync_mail_error(importer, importer->cur_mail, + "header hash"); + ret = -1; + } else { + struct mail_private *pmail = + (struct mail_private *)importer->cur_mail; + importer->cur_hdr_hash = p_strdup(pmail->pool, hdr_hash); + } + } + if (ret < 0) { importer->next_local_seq = importer->cur_mail->seq + 1; return importer_next_mail(importer, wanted_uid); } @@ -288,7 +312,7 @@ } static void newmail_link(struct dsync_mailbox_importer *importer, - struct importer_new_mail *newmail) + struct importer_new_mail *newmail, uint32_t remote_uid) { struct importer_new_mail *first_mail, **last, *mail, *link = NULL; @@ -303,16 +327,12 @@ return; } } else { - if (!newmail->uid_in_local) { - /* FIXME: ? */ - return; - } first_mail = hash_table_lookup(importer->import_uids, - POINTER_CAST(newmail->uid)); + POINTER_CAST(remote_uid)); if (first_mail == NULL) { /* first mail for this UID */ hash_table_insert(importer->import_uids, - POINTER_CAST(newmail->uid), newmail); + POINTER_CAST(remote_uid), newmail); importer_mail_request(importer, newmail); return; } @@ -345,12 +365,14 @@ memset(&m1, 0, sizeof(m1)); if (importer->cur_mail != NULL) { - m1.guid = importer->cur_guid; + m1.guid = importer->cur_guid != NULL ? + importer->cur_guid : importer->cur_hdr_hash; m1.uid = importer->cur_mail->uid; } memset(&m2, 0, sizeof(m2)); if (save_change != NULL) { - m2.guid = save_change->guid; + m2.guid = save_change->hdr_hash != NULL ? + save_change->hdr_hash : save_change->guid; m2.uid = save_change->uid; i_assert(save_change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE); } @@ -403,7 +425,7 @@ } array_append(&importer->newmails, &newmail, 1); - newmail_link(importer, newmail); + newmail_link(importer, newmail, save_change->uid); return remote_saved; } @@ -931,6 +953,7 @@ importer->cur_mail = NULL; importer->cur_guid = NULL; + importer->cur_hdr_hash = NULL; importer->next_local_seq = 0; (void)mailbox_search_deinit(&importer->search_ctx); diff -r d73d04e24eee -r f58e7b386c6e src/doveadm/dsync/dsync-mailbox-import.h --- a/src/doveadm/dsync/dsync-mailbox-import.h Mon Feb 11 01:07:53 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.h Mon Feb 11 01:10:57 2013 +0200 @@ -5,7 +5,8 @@ DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN = 0x01, DSYNC_MAILBOX_IMPORT_FLAG_WANT_MAIL_REQUESTS = 0x02, DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES = 0x04, - DSYNC_MAILBOX_IMPORT_FLAG_DEBUG = 0x08 + DSYNC_MAILBOX_IMPORT_FLAG_DEBUG = 0x08, + DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS = 0x10 }; struct mailbox; From dovecot at dovecot.org Mon Feb 11 01:11:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 01:11:04 +0200 Subject: dovecot-2.2: dsync: When doing a header-based sync, convert all ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d73d04e24eee changeset: 15752:d73d04e24eee user: Timo Sirainen date: Mon Feb 11 01:07:53 2013 +0200 description: dsync: When doing a header-based sync, convert all linefeeds to LFs. Fixes syncing where one side used CRLFs and the other side used LFs. diffstat: src/doveadm/dsync/dsync-mail.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (43 lines): diff -r 45c39743f406 -r d73d04e24eee src/doveadm/dsync/dsync-mail.c --- a/src/doveadm/dsync/dsync-mail.c Mon Feb 11 00:29:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-mail.c Mon Feb 11 01:07:53 2013 +0200 @@ -5,6 +5,7 @@ #include "hex-binary.h" #include "md5.h" #include "istream.h" +#include "istream-crlf.h" #include "message-size.h" #include "mail-storage.h" #include "dsync-mail.h" @@ -19,7 +20,7 @@ int dsync_mail_get_hdr_hash(struct mail *mail, const char **hdr_hash_r) { - struct istream *input; + struct istream *hdr_input, *input; struct mailbox_header_lookup_ctx *hdr_ctx; struct md5_context md5_ctx; unsigned char md5_result[MD5_RESULTLEN]; @@ -28,11 +29,13 @@ int ret = 0; hdr_ctx = mailbox_header_lookup_init(mail->box, hashed_headers); - ret = mail_get_header_stream(mail, hdr_ctx, &input); + ret = mail_get_header_stream(mail, hdr_ctx, &hdr_input); mailbox_header_lookup_unref(&hdr_ctx); if (ret < 0) return -1; + input = i_stream_create_lf(hdr_input); + md5_init(&md5_ctx); while (!i_stream_is_eof(input)) { if (i_stream_read_data(input, &data, &size, 0) == -1) @@ -44,6 +47,7 @@ } if (input->stream_errno != 0) ret = -1; + i_stream_unref(&input); md5_final(&md5_ctx, md5_result); *hdr_hash_r = binary_to_hex(md5_result, sizeof(md5_result)); From dovecot at dovecot.org Mon Feb 11 01:23:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 01:23:01 +0200 Subject: dovecot-2.2: dsync: Minor fix to deciding when to use GUIDs vs. ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f6a8f0522634 changeset: 15754:f6a8f0522634 user: Timo Sirainen date: Mon Feb 11 01:22:51 2013 +0200 description: dsync: Minor fix to deciding when to use GUIDs vs. header hashes. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (21 lines): diff -r f58e7b386c6e -r f6a8f0522634 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Mon Feb 11 01:10:57 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Mon Feb 11 01:22:51 2013 +0200 @@ -365,14 +365,14 @@ memset(&m1, 0, sizeof(m1)); if (importer->cur_mail != NULL) { - m1.guid = importer->cur_guid != NULL ? + m1.guid = importer->mails_have_guids ? importer->cur_guid : importer->cur_hdr_hash; m1.uid = importer->cur_mail->uid; } memset(&m2, 0, sizeof(m2)); if (save_change != NULL) { - m2.guid = save_change->hdr_hash != NULL ? - save_change->hdr_hash : save_change->guid; + m2.guid = importer->mails_have_guids ? + save_change->guid : save_change->hdr_hash; m2.uid = save_change->uid; i_assert(save_change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE); } From dovecot at dovecot.org Mon Feb 11 01:47:17 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 01:47:17 +0200 Subject: dovecot-2.2: fts-solr: Use built-in lib-http instead of libcurl.... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b9b8286fd9fd changeset: 15755:b9b8286fd9fd user: Stephan Bosch date: Mon Feb 11 01:43:25 2013 +0200 description: fts-solr: Use built-in lib-http instead of libcurl. Removed libcurl dependency. diffstat: configure.ac | 30 +- src/plugins/fts-solr/Makefile.am | 6 +- src/plugins/fts-solr/fts-backend-solr-old.c | 15 +- src/plugins/fts-solr/fts-backend-solr.c | 13 +- src/plugins/fts-solr/solr-connection.c | 417 ++++++++++++--------------- src/plugins/fts-solr/solr-connection.h | 8 +- 6 files changed, 220 insertions(+), 269 deletions(-) diffs (truncated from 738 to 300 lines): diff -r f6a8f0522634 -r b9b8286fd9fd configure.ac --- a/configure.ac Mon Feb 11 01:22:51 2013 +0200 +++ b/configure.ac Mon Feb 11 01:43:25 2013 +0200 @@ -2642,33 +2642,21 @@ have_solr=no if test "$want_solr" != "no"; then - AC_CHECK_PROG(CURLCONFIG, curl-config, curl-config, NO) - if test $CURLCONFIG != NO; then - CURL_CFLAGS=`$CURLCONFIG --cflags` - CURL_LIBS=`$CURLCONFIG --libs` - - dnl libcurl found, also need libexpat - AC_CHECK_LIB(expat, XML_Parse, [ - AC_CHECK_HEADER(expat.h, [ - AC_SUBST(CURL_CFLAGS) - AC_SUBST(CURL_LIBS) - have_solr=yes - fts="$fts solr" - ], [ - if test $want_solr = yes; then - AC_ERROR([Can't build with Solr support: expat.h not found]) - fi - ]) + dnl need libexpat + AC_CHECK_LIB(expat, XML_Parse, [ + AC_CHECK_HEADER(expat.h, [ + have_solr=yes + fts="$fts solr" ], [ if test $want_solr = yes; then - AC_ERROR([Can't build with Solr support: libexpat not found]) + AC_ERROR([Can't build with Solr support: expat.h not found]) fi ]) - else + ], [ if test $want_solr = yes; then - AC_ERROR([Can't build with Solr support: curl-config not found]) + AC_ERROR([Can't build with Solr support: libexpat not found]) fi - fi + ]) fi AM_CONDITIONAL(BUILD_SOLR, test "$have_solr" = "yes") diff -r f6a8f0522634 -r b9b8286fd9fd src/plugins/fts-solr/Makefile.am --- a/src/plugins/fts-solr/Makefile.am Mon Feb 11 01:22:51 2013 +0200 +++ b/src/plugins/fts-solr/Makefile.am Mon Feb 11 01:43:25 2013 +0200 @@ -1,11 +1,11 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-http \ -I$(top_srcdir)/src/lib-mail \ -I$(top_srcdir)/src/lib-imap \ -I$(top_srcdir)/src/lib-index \ -I$(top_srcdir)/src/lib-storage \ - -I$(top_srcdir)/src/plugins/fts \ - $(CURL_CFLAGS) + -I$(top_srcdir)/src/plugins/fts NOPLUGIN_LDFLAGS = lib21_fts_solr_plugin_la_LDFLAGS = -module -avoid-version @@ -19,7 +19,7 @@ lib21_fts_solr_plugin_la_LIBADD = \ $(fts_plugin_dep) \ - $(CURL_LIBS) -lexpat + -lexpat lib21_fts_solr_plugin_la_SOURCES = \ fts-backend-solr.c \ diff -r f6a8f0522634 -r b9b8286fd9fd src/plugins/fts-solr/fts-backend-solr-old.c --- a/src/plugins/fts-solr/fts-backend-solr-old.c Mon Feb 11 01:22:51 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr-old.c Mon Feb 11 01:43:25 2013 +0200 @@ -6,6 +6,7 @@ #include "hash.h" #include "strescape.h" #include "unichar.h" +#include "http-url.h" #include "imap-utf7.h" #include "mail-storage-private.h" #include "mailbox-list-private.h" @@ -149,7 +150,7 @@ static void solr_quote_http(string_t *dest, const char *str) { str_append(dest, "%22"); - solr_connection_http_escape(solr_conn, dest, str); + http_url_escape_param(dest, str); str_append(dest, "%22"); } @@ -224,16 +225,18 @@ } static int -fts_backend_solr_init(struct fts_backend *_backend, - const char **error_r ATTR_UNUSED) +fts_backend_solr_init(struct fts_backend *_backend, const char **error_r) { struct solr_fts_backend *backend = (struct solr_fts_backend *)_backend; struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(_backend->ns->user); const struct fts_solr_settings *set = &fuser->set; const char *str; - if (solr_conn == NULL) - solr_conn = solr_connection_init(set->url, set->debug); + if (solr_conn == NULL) { + if (solr_connection_init(set->url, set->debug, + &solr_conn, error_r) < 0) + return -1; + } str = solr_escape_id_str(_backend->ns->user->username); backend->id_username = i_strdup(str); @@ -278,7 +281,7 @@ tmp = t_str_new(64); solr_add_ns_query(tmp, backend, ns, FALSE); - solr_connection_http_escape(solr_conn, str, str_c(tmp)); + http_url_escape_param(str, str_c(tmp)); } static int diff -r f6a8f0522634 -r b9b8286fd9fd src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Mon Feb 11 01:22:51 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr.c Mon Feb 11 01:43:25 2013 +0200 @@ -6,6 +6,7 @@ #include "hash.h" #include "strescape.h" #include "unichar.h" +#include "http-url.h" #include "mail-storage-private.h" #include "mailbox-list-private.h" #include "mail-search.h" @@ -135,7 +136,7 @@ static void solr_quote_http(string_t *dest, const char *str) { str_append(dest, "%22"); - solr_connection_http_escape(solr_conn, dest, str); + http_url_escape_param(dest, str); str_append(dest, "%22"); } @@ -149,14 +150,16 @@ } static int -fts_backend_solr_init(struct fts_backend *_backend, - const char **error_r ATTR_UNUSED) +fts_backend_solr_init(struct fts_backend *_backend, const char **error_r) { struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(_backend->ns->user); const struct fts_solr_settings *set = &fuser->set; - if (solr_conn == NULL) - solr_conn = solr_connection_init(set->url, set->debug); + if (solr_conn == NULL) { + if (solr_connection_init(set->url, set->debug, + &solr_conn, error_r) < 0) + return -1; + } return 0; } diff -r f6a8f0522634 -r b9b8286fd9fd src/plugins/fts-solr/solr-connection.c --- a/src/plugins/fts-solr/solr-connection.c Mon Feb 11 01:22:51 2013 +0200 +++ b/src/plugins/fts-solr/solr-connection.c Mon Feb 11 01:43:25 2013 +0200 @@ -1,15 +1,16 @@ /* Copyright (c) 2006-2013 Dovecot authors, see the included COPYING file */ -/* curl: 7.16.0 curl_multi_timeout */ - #include "lib.h" #include "array.h" #include "hash.h" #include "str.h" #include "strescape.h" +#include "ioloop.h" +#include "istream.h" +#include "http-url.h" +#include "http-client.h" #include "solr-connection.h" -#include #include enum solr_xml_response_state { @@ -46,44 +47,33 @@ struct solr_connection_post { struct solr_connection *conn; - const unsigned char *data; - size_t size, pos; - char *url; + + struct http_client_request *http_req; unsigned int failed:1; }; struct solr_connection { - CURL *curl; - CURLM *curlm; + struct http_client *http_client; - char curl_errorbuf[CURL_ERROR_SIZE]; - struct curl_slist *headers, *headers_post; XML_Parser xml_parser; - char *url, *last_sent_url; + char *http_host; + in_port_t http_port; + char *http_base_url; char *http_failure; + int request_status; + + struct istream *payload; + struct io *io; + unsigned int debug:1; unsigned int posting:1; unsigned int xml_failed:1; + unsigned int http_ssl:1; }; -static size_t -curl_output_func(void *data, size_t element_size, size_t nmemb, void *context) -{ - struct solr_connection_post *post = context; - size_t size = element_size * nmemb; - - /* @UNSAFE */ - if (size > post->size - post->pos) - size = post->size - post->pos; - - memcpy(data, post->data + post->pos, size); - post->pos += size; - return size; -} - static int solr_xml_parse(struct solr_connection *conn, const void *data, size_t size, bool done) { @@ -109,105 +99,57 @@ return 0; } -static size_t -curl_input_func(void *data, size_t element_size, size_t nmemb, void *context) +int solr_connection_init(const char *url, bool debug, + struct solr_connection **conn_r, const char **error_r) { - struct solr_connection *conn = context; - size_t size = element_size * nmemb; + struct http_client_settings http_set; + struct solr_connection *conn; + struct http_url *http_url; + const char *error; - (void)solr_xml_parse(conn, data, size, FALSE); - return size; -} - -static size_t -curl_header_func(void *data, size_t element_size, size_t nmemb, void *context) -{ - struct solr_connection *conn = context; - size_t size = element_size * nmemb; - const unsigned char *p; - size_t i; - - if (conn->http_failure != NULL) - return size; - - for (i = 0, p = data; i < size; i++) { - if (p[i] == ' ') { - i++; - break; - } + if (http_url_parse(url, NULL, 0, pool_datastack_create(), + &http_url, &error) < 0) { + *error_r = t_strdup_printf( + "fts_solr: Failed to parse HTTP url: %s", error); + return -1; } - if (i == size || p[i] < '0' || p[i] > '9') - i = 0; - conn->http_failure = i_strndup(p + i, size - i); - return size; -} - -struct solr_connection *solr_connection_init(const char *url, bool debug) -{ - struct solr_connection *conn; conn = i_new(struct solr_connection, 1); - conn->url = i_strdup(url); + conn->http_host = i_strdup(http_url->host_name); From dovecot at dovecot.org Mon Feb 11 02:03:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 02:03:56 +0200 Subject: dovecot-2.2: lib-storage: Added MAILBOX_ATTRIBUTE_DOVECOT_PREFIX... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0ed27889cd70 changeset: 15756:0ed27889cd70 user: Timo Sirainen date: Mon Feb 11 02:03:13 2013 +0200 description: lib-storage: Added MAILBOX_ATTRIBUTE_DOVECOT_PREFIX macro. diffstat: src/lib-storage/mail-storage.h | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diffs (25 lines): diff -r b9b8286fd9fd -r 0ed27889cd70 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Mon Feb 11 01:43:25 2013 +0200 +++ b/src/lib-storage/mail-storage.h Mon Feb 11 02:03:13 2013 +0200 @@ -199,6 +199,10 @@ MAILBOX_SYNC_TYPE_MODSEQ = 0x04 }; +/* RFC 5464 specifies that this is vendor//. The registered + vendor-tokens always begin with "vendor." so there's some redundancy.. */ +#define MAILBOX_ATTRIBUTE_PREFIX_DOVECOT "vendor/vendor.dovecot/" + enum mail_attribute_type { MAIL_ATTRIBUTE_TYPE_PRIVATE, MAIL_ATTRIBUTE_TYPE_SHARED @@ -530,7 +534,9 @@ (as opposed to flags shared between users). */ enum mail_flags mailbox_get_private_flags_mask(struct mailbox *box); -/* Set mailbox attribute key to value. */ +/* Set mailbox attribute key to value. The key should be compatible with + IMAP METADATA, so for Dovecot-specific keys use + MAILBOX_ATTRIBUTE_PREFIX_DOVECOT. */ int mailbox_attribute_set(struct mailbox *box, enum mail_attribute_type type, const char *key, const char *value); /* Delete mailbox attribute key. */ From dovecot at dovecot.org Mon Feb 11 02:03:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 02:03:56 +0200 Subject: dovecot-2.2: lib-imap-urlauth: Use MAILBOX_ATTRIBUTE_PREFIX_DOVE... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d4080bea7286 changeset: 15757:d4080bea7286 user: Timo Sirainen date: Mon Feb 11 02:03:43 2013 +0200 description: lib-imap-urlauth: Use MAILBOX_ATTRIBUTE_PREFIX_DOVECOT for the imap-urlauth key. diffstat: src/lib-imap-urlauth/imap-urlauth-backend.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 0ed27889cd70 -r d4080bea7286 src/lib-imap-urlauth/imap-urlauth-backend.c --- a/src/lib-imap-urlauth/imap-urlauth-backend.c Mon Feb 11 02:03:13 2013 +0200 +++ b/src/lib-imap-urlauth/imap-urlauth-backend.c Mon Feb 11 02:03:43 2013 +0200 @@ -10,7 +10,7 @@ #include "imap-urlauth-private.h" #include "imap-urlauth-backend.h" -#define IMAP_URLAUTH_KEY "imap-urlauth" +#define IMAP_URLAUTH_KEY MAILBOX_ATTRIBUTE_PREFIX_DOVECOT"imap-urlauth" int imap_urlauth_backend_get_mailbox_key(struct mailbox *box, bool create, unsigned char mailbox_key_r[IMAP_URLAUTH_KEY_LEN], From dovecot at dovecot.org Mon Feb 11 03:03:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 03:03:22 +0200 Subject: dovecot-2.2: lib-lda: Assert-crashfix when sending a rejection m... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7a2ca282a53e changeset: 15759:7a2ca282a53e user: Timo Sirainen date: Mon Feb 11 03:03:12 2013 +0200 description: lib-lda: Assert-crashfix when sending a rejection mail failed. diffstat: src/lib-lda/smtp-client.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (19 lines): diff -r e866b9e64f09 -r 7a2ca282a53e src/lib-lda/smtp-client.c --- a/src/lib-lda/smtp-client.c Mon Feb 11 03:02:49 2013 +0200 +++ b/src/lib-lda/smtp-client.c Mon Feb 11 03:03:12 2013 +0200 @@ -106,6 +106,7 @@ client = i_new(struct smtp_client, 1); client->output = o_stream_create_fd(fd[1], IO_BLOCK_SIZE, TRUE); + o_stream_set_no_error_handling(client->output, TRUE); client->pid = pid; *output_r = client->output; @@ -163,6 +164,7 @@ client->return_path = i_strdup(return_path); client->temp_fd = fd; client->output = o_stream_create_fd(fd, IO_BLOCK_SIZE, TRUE); + o_stream_set_no_error_handling(client->output, TRUE); client->use_smtp = TRUE; *output_r = client->output; From dovecot at dovecot.org Mon Feb 11 03:03:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 03:03:22 +0200 Subject: dovecot-2.2: quota: Added quota_last_extra setting, which defaul... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e866b9e64f09 changeset: 15758:e866b9e64f09 user: Timo Sirainen date: Mon Feb 11 03:02:49 2013 +0200 description: quota: Added quota_last_extra setting, which defaults to 10% This can be used to save the last message when user is almost over quota. So by default the last message can bring the quota over 10% of the total quota limit. The setting allows also explicit values. Setting it to 0 brings it back to previous behavior. diffstat: src/plugins/quota/quota-private.h | 13 ++- src/plugins/quota/quota-storage.c | 2 +- src/plugins/quota/quota.c | 140 ++++++++++++++++++++++++++++--------- 3 files changed, 116 insertions(+), 39 deletions(-) diffs (292 lines): diff -r d4080bea7286 -r e866b9e64f09 src/plugins/quota/quota-private.h --- a/src/plugins/quota/quota-private.h Mon Feb 11 02:03:43 2013 +0200 +++ b/src/plugins/quota/quota-private.h Mon Feb 11 03:02:49 2013 +0200 @@ -87,6 +87,10 @@ ARRAY(struct quota_rule) rules; ARRAY(struct quota_warning_rule) warning_rules; + /* If user is under quota before saving a mail, allow the last mail to + bring the user over quota by this many bytes. */ + uint64_t last_mail_max_extra_bytes; + /* Limits in default_rule override backend's quota limits */ unsigned int force_default_rule:1; }; @@ -134,8 +138,13 @@ int64_t bytes_used, count_used; /* how many bytes/mails can be saved until limit is reached. - (set once, not updated by bytes_used/count_used) */ - uint64_t bytes_ceil, count_ceil; + (set once, not updated by bytes_used/count_used). + + if last_mail_max_extra_bytes>0, the bytes_ceil is initially + increased by that much, while bytes_ceil2 contains the real ceiling. + after the first allocation is done, bytes_ceil is set to + bytes_ceil2. */ + uint64_t bytes_ceil, bytes_ceil2, count_ceil; /* how many bytes/mails we are over quota (either *_ceil or *_over is always zero) */ uint64_t bytes_over, count_over; diff -r d4080bea7286 -r e866b9e64f09 src/plugins/quota/quota-storage.c --- a/src/plugins/quota/quota-storage.c Mon Feb 11 02:03:43 2013 +0200 +++ b/src/plugins/quota/quota-storage.c Mon Feb 11 03:02:49 2013 +0200 @@ -77,7 +77,7 @@ if ((items & STATUS_CHECK_OVER_QUOTA) != 0) { qt = quota_transaction_begin(box); - if ((ret = quota_test_alloc(qt, 1, &too_large)) == 0) { + if ((ret = quota_test_alloc(qt, 0, &too_large)) == 0) { mail_storage_set_error(box->storage, MAIL_ERROR_NOSPACE, qt->quota->set->quota_exceeded_msg); ret = -1; diff -r d4080bea7286 -r e866b9e64f09 src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Mon Feb 11 02:03:43 2013 +0200 +++ b/src/plugins/quota/quota.c Mon Feb 11 03:02:49 2013 +0200 @@ -15,6 +15,7 @@ #include #include +#define QUOTA_DEFAULT_LAST_EXTRA "10%" #define DEFAULT_QUOTA_EXCEEDED_MSG \ "Quota exceeded (mailbox for user is full)" #define RULE_NAME_DEFAULT_FORCE "*" @@ -45,6 +46,10 @@ static int quota_default_test_alloc(struct quota_transaction_context *ctx, uoff_t size, bool *too_large_r); +static int +quota_root_parse_last_extra(struct mail_user *user, const char *root_name, + struct quota_root_settings *root_set, + const char **error_r); static const struct quota_backend *quota_backend_find(const char *name) { @@ -175,6 +180,8 @@ return -1; if (quota_root_add_warning_rules(user, root_name, root_set, error_r) < 0) return -1; + if (quota_root_parse_last_extra(user, root_name, root_set, error_r) < 0) + return -1; return 0; } @@ -362,8 +369,7 @@ int64_t percentage = *limit; if (percentage <= -100 || percentage >= -1U) { - *error_r = p_strdup_printf(root_set->set->pool, - "Invalid rule percentage: %lld", (long long)percentage); + *error_r = "Invalid percentage"; return -1; } @@ -381,6 +387,44 @@ return 0; } +static int quota_limit_parse(struct quota_root_settings *root_set, + struct quota_rule *rule, const char *unit, + uint64_t multiply, int64_t *limit, + const char **error_r) +{ + switch (i_toupper(*unit)) { + case '\0': + /* default */ + break; + case 'B': + multiply = 1; + break; + case 'K': + multiply = 1024; + break; + case 'M': + multiply = 1024*1024; + break; + case 'G': + multiply = 1024*1024*1024; + break; + case 'T': + multiply = 1024ULL*1024*1024*1024; + break; + case '%': + multiply = 0; + if (quota_rule_parse_percentage(root_set, rule, limit, + error_r) < 0) + return -1; + break; + default: + *error_r = t_strdup_printf("Unknown unit: %s", unit); + return -1; + } + *limit *= multiply; + return 0; +} + static void quota_rule_recalculate_relative_rules(struct quota_rule *rule, int64_t bytes_limit, int64_t count_limit) @@ -415,7 +459,7 @@ const char *full_rule_def, bool relative_rule, const char **error_r) { - const char **args, *key, *value; + const char **args, *key, *value, *error; char *p; uint64_t multiply; int64_t *limit; @@ -462,37 +506,13 @@ return -1; } - switch (i_toupper(*p)) { - case '\0': - /* default */ - break; - case 'B': - multiply = 1; - break; - case 'K': - multiply = 1024; - break; - case 'M': - multiply = 1024*1024; - break; - case 'G': - multiply = 1024*1024*1024; - break; - case 'T': - multiply = 1024ULL*1024*1024*1024; - break; - case '%': - multiply = 0; - if (quota_rule_parse_percentage(root_set, rule, limit, - error_r) < 0) - return -1; - break; - default: + if (quota_limit_parse(root_set, rule, p, multiply, + limit, &error) < 0) { *error_r = p_strdup_printf(root_set->set->pool, - "Invalid rule limit value: %s", *args); + "Invalid rule limit value '%s': %s", + *args, error); return -1; } - *limit *= multiply; } if (!relative_rule) { if (rule->bytes_limit < 0) { @@ -583,6 +603,37 @@ return ret; } +static int +quota_root_parse_last_extra(struct mail_user *user, const char *root_name, + struct quota_root_settings *root_set, + const char **error_r) +{ + const char *set_name, *value, *error; + char *p; + struct quota_rule rule; + + set_name = t_strconcat(root_name, "_last_extra", NULL); + value = mail_user_plugin_getenv(user, set_name); + if (value == NULL) { + /* default */ + value = QUOTA_DEFAULT_LAST_EXTRA; + } + + memset(&rule, 0, sizeof(rule)); + rule.bytes_limit = strtoll(value, &p, 10); + + if (quota_limit_parse(root_set, &rule, p, 1, + &rule.bytes_limit, &error) < 0) { + *error_r = p_strdup_printf(root_set->set->pool, + "Invalid %s value '%s': %s", set_name, value, error); + return -1; + } + quota_rule_recalculate_relative_rules(&rule, + root_set->default_rule.bytes_limit, 0); + root_set->last_mail_max_extra_bytes = rule.bytes_limit; + return 0; +} + static int quota_root_get_rule_limits(struct quota_root *root, const char *mailbox_name, uint64_t *bytes_limit_r, @@ -927,6 +978,7 @@ ctx->box = box; ctx->bytes_ceil = (uint64_t)-1; + ctx->bytes_ceil2 = (uint64_t)-1; ctx->count_ceil = (uint64_t)-1; if (box->storage->user->admin) { @@ -965,13 +1017,18 @@ QUOTA_NAME_STORAGE_BYTES, ¤t, &limit); if (ret > 0) { - if (limit < current) { + if (limit <= current) { + /* over quota */ ctx->bytes_ceil = 0; + ctx->bytes_ceil2 = 0; diff = current - limit; if (ctx->bytes_over < diff) ctx->bytes_over = diff; } else { diff = limit - current; + if (ctx->bytes_ceil2 > diff) + ctx->bytes_ceil2 = diff; + diff += roots[i]->set->last_mail_max_extra_bytes; if (ctx->bytes_ceil > diff) ctx->bytes_ceil = diff; } @@ -1155,6 +1212,17 @@ i_free(ctx); } +static bool quota_is_over(struct quota_transaction_context *ctx, uoff_t size) +{ + if ((ctx->count_used < 0 || + (uint64_t)ctx->count_used + 1 <= ctx->count_ceil) && + ((ctx->bytes_used < 0 && size <= ctx->bytes_ceil) || + (uint64_t)ctx->bytes_used + size <= ctx->bytes_ceil)) + return FALSE; + else + return TRUE; +} + int quota_try_alloc(struct quota_transaction_context *ctx, struct mail *mail, bool *too_large_r) { @@ -1182,6 +1250,8 @@ if (quota_transaction_set_limits(ctx) < 0) return -1; } + /* this is a virtual function mainly for trash plugin and similar, + which may automatically delete mails to stay under quota. */ return ctx->quota->set->test_alloc(ctx, size, too_large_r); } @@ -1194,10 +1264,7 @@ *too_large_r = FALSE; - if ((ctx->count_used < 0 || - (uint64_t)ctx->count_used + 1 <= ctx->count_ceil) && - ((ctx->bytes_used < 0 && size <= ctx->bytes_ceil) || - (uint64_t)ctx->bytes_used + size <= ctx->bytes_ceil)) + if (!quota_is_over(ctx, size)) return 1; /* limit reached. only thing left to do now is to set too_large_r. */ @@ -1233,6 +1300,7 @@ if (mail_get_physical_size(mail, &size) == 0) ctx->bytes_used += size; + ctx->bytes_ceil = ctx->bytes_ceil2; ctx->count_used++; } From dovecot at dovecot.org Mon Feb 11 03:07:28 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 03:07:28 +0200 Subject: dovecot-2.2: quota: Use quota_last_extra only for LDA/LMTP (not ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c890fa3b5efd changeset: 15760:c890fa3b5efd user: Timo Sirainen date: Mon Feb 11 03:07:24 2013 +0200 description: quota: Use quota_last_extra only for LDA/LMTP (not for IMAP). diffstat: src/plugins/quota/quota.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diffs (27 lines): diff -r 7a2ca282a53e -r c890fa3b5efd src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Mon Feb 11 03:03:12 2013 +0200 +++ b/src/plugins/quota/quota.c Mon Feb 11 03:07:24 2013 +0200 @@ -994,10 +994,13 @@ const char *mailbox_name; unsigned int i, count; uint64_t bytes_limit, count_limit, current, limit, diff; + bool use_last_extra; int ret; ctx->limits_set = TRUE; mailbox_name = mailbox_get_vname(ctx->box); + /* use last_mail_max_extra_bytes only for LDA/LMTP */ + use_last_extra = (ctx->box->flags & MAILBOX_FLAG_POST_SESSION) != 0; /* find the lowest quota limits from all roots and use them */ roots = array_get(&ctx->quota->roots, &count); @@ -1028,7 +1031,8 @@ diff = limit - current; if (ctx->bytes_ceil2 > diff) ctx->bytes_ceil2 = diff; - diff += roots[i]->set->last_mail_max_extra_bytes; + diff += !use_last_extra ? 0 : + roots[i]->set->last_mail_max_extra_bytes; if (ctx->bytes_ceil > diff) ctx->bytes_ceil = diff; } From dovecot at dovecot.org Mon Feb 11 03:13:52 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 11 Feb 2013 03:13:52 +0200 Subject: dovecot-2.2: NEWS, example-config: Add a note about quota_last_e... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ed5fa76f0dc7 changeset: 15761:ed5fa76f0dc7 user: Timo Sirainen date: Mon Feb 11 03:13:45 2013 +0200 description: NEWS, example-config: Add a note about quota_last_extra diffstat: NEWS | 3 +++ doc/example-config/conf.d/90-quota.conf | 5 +++++ 2 files changed, 8 insertions(+), 0 deletions(-) diffs (28 lines): diff -r c890fa3b5efd -r ed5fa76f0dc7 NEWS --- a/NEWS Mon Feb 11 03:07:24 2013 +0200 +++ b/NEWS Mon Feb 11 03:13:45 2013 +0200 @@ -8,6 +8,9 @@ It was already trivial to guess this from command replies. * dovecot.index.cache files can be safely accessed only by v2.1.11+. Older versions may think they're corrupted and delete them. + * LDA/LMTP: If saving a mail brings user from under quota to over + quota, allow it based on quota_last_extra setting (default: 10% + above quota limit). + Implemented IMAP MOVE and BINARY extensions + Implemented IMAP CATENATE, URLAUTH and URLAUTH=BINARY extensions diff -r c890fa3b5efd -r ed5fa76f0dc7 doc/example-config/conf.d/90-quota.conf --- a/doc/example-config/conf.d/90-quota.conf Mon Feb 11 03:07:24 2013 +0200 +++ b/doc/example-config/conf.d/90-quota.conf Mon Feb 11 03:13:45 2013 +0200 @@ -17,6 +17,11 @@ plugin { #quota_rule = *:storage=1G #quota_rule2 = Trash:storage=+100M + + # LDA/LMTP allows saving the last mail to bring user from under quota to + # over quota, if the quota doesn't grow too high. Default is to allow as + # long as quota will stay under 10% above the limit. Also allowed e.g. 10M. + #quota_last_extra = 10%% } ## From dovecot at dovecot.org Wed Feb 13 12:24:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 13 Feb 2013 12:24:09 +0200 Subject: dovecot-2.2: auth: When receiving SIGUSR2 log also about current... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/75c686b526d4 changeset: 15762:75c686b526d4 user: Timo Sirainen date: Wed Feb 13 12:22:22 2013 +0200 description: auth: When receiving SIGUSR2 log also about current cache usage. diffstat: src/auth/auth-cache.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diffs (47 lines): diff -r ed5fa76f0dc7 -r 75c686b526d4 src/auth/auth-cache.c --- a/src/auth/auth-cache.c Mon Feb 11 03:13:45 2013 +0200 +++ b/src/auth/auth-cache.c Wed Feb 13 12:22:22 2013 +0200 @@ -15,7 +15,7 @@ HASH_TABLE(char *, struct auth_cache_node *) hash; struct auth_cache_node *head, *tail; - size_t size_left; + size_t max_size, size_left; unsigned int ttl_secs, neg_ttl_secs; unsigned int hit_count, miss_count; @@ -199,6 +199,7 @@ { struct auth_cache *cache = context; unsigned int total_count; + size_t cache_used; total_count = cache->hit_count + cache->miss_count; i_info("Authentication cache hits %u/%u (%u%%)", @@ -206,10 +207,17 @@ total_count == 0 ? 100 : (cache->hit_count * 100 / total_count)); i_info("Authentication cache inserts: " - "positive: %u %lluB, negative: %u %lluB", + "positive: %u entries %llu bytes, " + "negative: %u entries %llu bytes", cache->pos_entries, cache->pos_size, cache->neg_entries, cache->neg_size); + cache_used = cache->max_size - cache->size_left; + i_info("Authentication cache current size: " + "%"PRIuSIZE_T" bytes used of %"PRIuSIZE_T" bytes (%u%%)", + cache_used, cache->max_size, + (unsigned int)(cache_used * 100ULL / cache->max_size)); + /* reset counters */ cache->hit_count = cache->miss_count = 0; cache->pos_entries = cache->neg_entries = 0; @@ -224,6 +232,7 @@ cache = i_new(struct auth_cache, 1); hash_table_create(&cache->hash, default_pool, 0, str_hash, strcmp); + cache->max_size = max_size; cache->size_left = max_size; cache->ttl_secs = ttl_secs; cache->neg_ttl_secs = neg_ttl_secs; From dovecot at dovecot.org Wed Feb 13 12:27:40 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 13 Feb 2013 12:27:40 +0200 Subject: dovecot-2.2: Renamed quota_last_extra to quota_grace. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c0c38c4070f5 changeset: 15763:c0c38c4070f5 user: Timo Sirainen date: Wed Feb 13 11:27:32 2013 +0100 description: Renamed quota_last_extra to quota_grace. diffstat: NEWS | 2 +- doc/example-config/conf.d/90-quota.conf | 2 +- src/plugins/quota/quota.c | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diffs (108 lines): diff -r 75c686b526d4 -r c0c38c4070f5 NEWS --- a/NEWS Wed Feb 13 12:22:22 2013 +0200 +++ b/NEWS Wed Feb 13 11:27:32 2013 +0100 @@ -9,7 +9,7 @@ * dovecot.index.cache files can be safely accessed only by v2.1.11+. Older versions may think they're corrupted and delete them. * LDA/LMTP: If saving a mail brings user from under quota to over - quota, allow it based on quota_last_extra setting (default: 10% + quota, allow it based on quota_grace setting (default: 10% above quota limit). + Implemented IMAP MOVE and BINARY extensions diff -r 75c686b526d4 -r c0c38c4070f5 doc/example-config/conf.d/90-quota.conf --- a/doc/example-config/conf.d/90-quota.conf Wed Feb 13 12:22:22 2013 +0200 +++ b/doc/example-config/conf.d/90-quota.conf Wed Feb 13 11:27:32 2013 +0100 @@ -21,7 +21,7 @@ # LDA/LMTP allows saving the last mail to bring user from under quota to # over quota, if the quota doesn't grow too high. Default is to allow as # long as quota will stay under 10% above the limit. Also allowed e.g. 10M. - #quota_last_extra = 10%% + #quota_grace = 10%% } ## diff -r 75c686b526d4 -r c0c38c4070f5 src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Wed Feb 13 12:22:22 2013 +0200 +++ b/src/plugins/quota/quota.c Wed Feb 13 11:27:32 2013 +0100 @@ -15,7 +15,7 @@ #include #include -#define QUOTA_DEFAULT_LAST_EXTRA "10%" +#define QUOTA_DEFAULT_GRACE "10%" #define DEFAULT_QUOTA_EXCEEDED_MSG \ "Quota exceeded (mailbox for user is full)" #define RULE_NAME_DEFAULT_FORCE "*" @@ -47,9 +47,9 @@ static int quota_default_test_alloc(struct quota_transaction_context *ctx, uoff_t size, bool *too_large_r); static int -quota_root_parse_last_extra(struct mail_user *user, const char *root_name, - struct quota_root_settings *root_set, - const char **error_r); +quota_root_parse_grace(struct mail_user *user, const char *root_name, + struct quota_root_settings *root_set, + const char **error_r); static const struct quota_backend *quota_backend_find(const char *name) { @@ -180,7 +180,7 @@ return -1; if (quota_root_add_warning_rules(user, root_name, root_set, error_r) < 0) return -1; - if (quota_root_parse_last_extra(user, root_name, root_set, error_r) < 0) + if (quota_root_parse_grace(user, root_name, root_set, error_r) < 0) return -1; return 0; } @@ -604,19 +604,19 @@ } static int -quota_root_parse_last_extra(struct mail_user *user, const char *root_name, - struct quota_root_settings *root_set, - const char **error_r) +quota_root_parse_grace(struct mail_user *user, const char *root_name, + struct quota_root_settings *root_set, + const char **error_r) { const char *set_name, *value, *error; char *p; struct quota_rule rule; - set_name = t_strconcat(root_name, "_last_extra", NULL); + set_name = t_strconcat(root_name, "_grace", NULL); value = mail_user_plugin_getenv(user, set_name); if (value == NULL) { /* default */ - value = QUOTA_DEFAULT_LAST_EXTRA; + value = QUOTA_DEFAULT_GRACE; } memset(&rule, 0, sizeof(rule)); @@ -994,13 +994,13 @@ const char *mailbox_name; unsigned int i, count; uint64_t bytes_limit, count_limit, current, limit, diff; - bool use_last_extra; + bool use_grace; int ret; ctx->limits_set = TRUE; mailbox_name = mailbox_get_vname(ctx->box); /* use last_mail_max_extra_bytes only for LDA/LMTP */ - use_last_extra = (ctx->box->flags & MAILBOX_FLAG_POST_SESSION) != 0; + use_grace = (ctx->box->flags & MAILBOX_FLAG_POST_SESSION) != 0; /* find the lowest quota limits from all roots and use them */ roots = array_get(&ctx->quota->roots, &count); @@ -1031,7 +1031,7 @@ diff = limit - current; if (ctx->bytes_ceil2 > diff) ctx->bytes_ceil2 = diff; - diff += !use_last_extra ? 0 : + diff += !use_grace ? 0 : roots[i]->set->last_mail_max_extra_bytes; if (ctx->bytes_ceil > diff) ctx->bytes_ceil = diff; From dovecot at dovecot.org Wed Feb 13 12:43:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 13 Feb 2013 12:43:45 +0200 Subject: dovecot-2.2: fs layout: Don't assert-crash if namespace prefix b... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fb367a977077 changeset: 15764:fb367a977077 user: Timo Sirainen date: Wed Feb 13 12:43:34 2013 +0200 description: fs layout: Don't assert-crash if namespace prefix begins with the separator. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (18 lines): diff -r c0c38c4070f5 -r fb367a977077 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Wed Feb 13 11:27:32 2013 +0100 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Wed Feb 13 12:43:34 2013 +0200 @@ -399,9 +399,12 @@ prefix_vname = t_strdup_until(pattern, last); } - if (p == last+1 && *pattern == ns_sep) + if (*pattern == ns_sep && full_fs_access) { + /* pattern=/something with full filesystem access. + (without full filesystem access we want to skip this + if namespace prefix begins with separator) */ root = "/"; - else if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && + } else if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && ns->prefix_len == 6 && strcasecmp(prefix_vname, "INBOX") == 0 && strncasecmp(ns->prefix, pattern, ns->prefix_len) == 0) { From dovecot at dovecot.org Sat Feb 16 07:16:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 07:16:58 +0200 Subject: dovecot-2.2: dsync: Wait for child process to close only after c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/44eda990f757 changeset: 15765:44eda990f757 user: Timo Sirainen date: Sat Feb 16 07:12:18 2013 +0200 description: dsync: Wait for child process to close only after closing the stdin/out/err to it. Otherwise the ssh process doesn't shutdown. diffstat: src/doveadm/dsync/doveadm-dsync.c | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-) diffs (69 lines): diff -r fb367a977077 -r 44eda990f757 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Wed Feb 13 12:43:34 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Sat Feb 16 07:12:18 2013 +0200 @@ -333,24 +333,23 @@ return 0; } -static void -cmd_dsync_run_remote(struct dsync_cmd_context *ctx, struct mail_user *user) +static void cmd_dsync_wait_remote(struct dsync_cmd_context *ctx) { int status; - i_set_failure_prefix("dsync-local(%s): ", user->username); - io_loop_run(current_ioloop); - /* wait for the remote command to finish to see any final errors. don't wait very long though. */ alarm(DSYNC_REMOTE_CMD_EXIT_WAIT_SECS); - if (wait(&status) == -1) { - if (errno != EINTR) - i_error("wait() failed: %m"); - else { + if (waitpid(ctx->remote_pid, &status, 0) == -1) { + if (errno != EINTR) { + i_error("waitpid(%ld) failed: %m", + (long)ctx->remote_pid); + } else { i_error("Remote command process isn't dying, killing it"); - if (kill(ctx->remote_pid, SIGKILL) < 0 && errno != ESRCH) - i_error("kill() failed: %m"); + if (kill(ctx->remote_pid, SIGKILL) < 0 && errno != ESRCH) { + i_error("kill(%ld, SIGKILL) failed: %m", + (long)ctx->remote_pid); + } } } else if (WIFSIGNALED(status)) i_error("Remote command died with signal %d", WTERMSIG(status)); @@ -358,6 +357,12 @@ i_error("Remote command returned error %d", WEXITSTATUS(status)); } +static void cmd_dsync_run_remote(struct mail_user *user) +{ + i_set_failure_prefix("dsync-local(%s): ", user->username); + io_loop_run(current_ioloop); +} + static const char *const * parse_ssh_location(struct dsync_cmd_context *ctx, const char *location, const char *username) @@ -439,7 +444,7 @@ if (cmd_dsync_run_local(ctx, user, brain, ibc2) < 0) ret = -1; } else { - cmd_dsync_run_remote(ctx, user); + cmd_dsync_run_remote(user); } if (ctx->state_input != NULL) { @@ -466,6 +471,8 @@ } if (ctx->fd_err != -1) i_close_fd(&ctx->fd_err); + if (ctx->remote) + cmd_dsync_wait_remote(ctx); return ret; } From dovecot at dovecot.org Sat Feb 16 07:16:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 07:16:58 +0200 Subject: dovecot-2.2: dsync: Various importer fixes. Handle unexpectedly ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4260244e57e2 changeset: 15766:4260244e57e2 user: Timo Sirainen date: Sat Feb 16 07:15:55 2013 +0200 description: dsync: Various importer fixes. Handle unexpectedly wrong mailbox state better. diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 1 + src/doveadm/dsync/dsync-brain-mails.c | 2 +- src/doveadm/dsync/dsync-mail.c | 40 +++ src/doveadm/dsync/dsync-mail.h | 2 + src/doveadm/dsync/dsync-mailbox-export.c | 43 +--- src/doveadm/dsync/dsync-mailbox-import.c | 319 +++++++++++++++++++++++------- src/doveadm/dsync/dsync-mailbox-import.h | 1 + 7 files changed, 299 insertions(+), 109 deletions(-) diffs (truncated from 785 to 300 lines): diff -r 44eda990f757 -r 4260244e57e2 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Sat Feb 16 07:12:18 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Sat Feb 16 07:15:55 2013 +0200 @@ -247,6 +247,7 @@ i_assert(brain->failed); (void)dsync_mailbox_import_deinit(&brain->box_importer, + FALSE, &last_common_uid, &last_common_modseq, &last_common_pvt_modseq, diff -r 44eda990f757 -r 4260244e57e2 src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 07:12:18 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 07:15:55 2013 +0200 @@ -169,7 +169,7 @@ state.last_common_pvt_modseq = brain->local_dsync_box.highest_pvt_modseq; } else { - if (dsync_mailbox_import_deinit(&brain->box_importer, + if (dsync_mailbox_import_deinit(&brain->box_importer, TRUE, &state.last_common_uid, &state.last_common_modseq, &state.last_common_pvt_modseq, diff -r 44eda990f757 -r 4260244e57e2 src/doveadm/dsync/dsync-mail.c --- a/src/doveadm/dsync/dsync-mail.c Sat Feb 16 07:12:18 2013 +0200 +++ b/src/doveadm/dsync/dsync-mail.c Sat Feb 16 07:15:55 2013 +0200 @@ -54,6 +54,46 @@ return ret; } +int dsync_mail_fill(struct mail *mail, struct dsync_mail *dmail_r, + const char **error_field_r) +{ + const char *guid, *str; + + memset(dmail_r, 0, sizeof(*dmail_r)); + + if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) { + *error_field_r = "GUID"; + return -1; + } + dmail_r->guid = guid; + dmail_r->uid = mail->uid; + + dmail_r->input_mail = mail; + dmail_r->input_mail_uid = mail->uid; + if (mail_get_stream(mail, NULL, NULL, &dmail_r->input) < 0) { + *error_field_r = "body"; + return -1; + } + + if (mail_get_special(mail, MAIL_FETCH_UIDL_BACKEND, &dmail_r->pop3_uidl) < 0) { + *error_field_r = "pop3-uidl"; + return -1; + } + if (mail_get_special(mail, MAIL_FETCH_POP3_ORDER, &str) < 0) { + *error_field_r = "pop3-order"; + return -1; + } + if (*str != '\0') { + if (str_to_uint(str, &dmail_r->pop3_order) < 0) + i_unreached(); + } + if (mail_get_received_date(mail, &dmail_r->received_date) < 0) { + *error_field_r = "received-date"; + return -1; + } + return 0; +} + static void const_string_array_dup(pool_t pool, const ARRAY_TYPE(const_string) *src, ARRAY_TYPE(const_string) *dest) diff -r 44eda990f757 -r 4260244e57e2 src/doveadm/dsync/dsync-mail.h --- a/src/doveadm/dsync/dsync-mail.h Sat Feb 16 07:12:18 2013 +0200 +++ b/src/doveadm/dsync/dsync-mail.h Sat Feb 16 07:15:55 2013 +0200 @@ -77,6 +77,8 @@ }; int dsync_mail_get_hdr_hash(struct mail *mail, const char **hdr_hash_r); +int dsync_mail_fill(struct mail *mail, struct dsync_mail *dmail_r, + const char **error_field_r); void dsync_mail_change_dup(pool_t pool, const struct dsync_mail_change *src, struct dsync_mail_change *dest_r); diff -r 44eda990f757 -r 4260244e57e2 src/doveadm/dsync/dsync-mailbox-export.c --- a/src/doveadm/dsync/dsync-mailbox-export.c Sat Feb 16 07:12:18 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-export.c Sat Feb 16 07:15:55 2013 +0200 @@ -566,49 +566,30 @@ static int dsync_mailbox_export_mail(struct dsync_mailbox_exporter *exporter, struct mail *mail) { - struct dsync_mail *dmail = &exporter->dsync_mail; struct dsync_mail_guid_instances *instances; - const char *guid, *str; + const char *error_field; - if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) - return dsync_mail_error(exporter, mail, "GUID"); + if (dsync_mail_fill(mail, &exporter->dsync_mail, &error_field) < 0) + return dsync_mail_error(exporter, mail, error_field); - memset(dmail, 0, sizeof(*dmail)); - if (!seq_range_exists(&exporter->requested_uids, mail->uid)) - dmail->guid = guid; - else { - dmail->uid = mail->uid; - dmail->guid = ""; - } - - instances = *guid == '\0' ? NULL : - hash_table_lookup(exporter->export_guids, guid); + instances = *exporter->dsync_mail.guid == '\0' ? NULL : + hash_table_lookup(exporter->export_guids, + exporter->dsync_mail.guid); if (instances != NULL) { /* GUID found */ - } else if (dmail->uid != 0) { + } else if (exporter->dsync_mail.uid != 0) { /* mail requested by UID */ } else { exporter->error = p_strdup_printf(exporter->pool, "GUID unexpectedly changed for UID=%u GUID=%s", - mail->uid, guid); + mail->uid, exporter->dsync_mail.guid); return -1; } - dmail->input_mail = mail; - dmail->input_mail_uid = mail->uid; - if (mail_get_stream(mail, NULL, NULL, &dmail->input) < 0) - return dsync_mail_error(exporter, mail, "body"); - - if (mail_get_special(mail, MAIL_FETCH_UIDL_BACKEND, &dmail->pop3_uidl) < 0) - return dsync_mail_error(exporter, mail, "pop3-uidl"); - if (mail_get_special(mail, MAIL_FETCH_POP3_ORDER, &str) < 0) - return dsync_mail_error(exporter, mail, "pop3-order"); - if (*str != '\0') { - if (str_to_uint(str, &dmail->pop3_order) < 0) - i_unreached(); - } - if (mail_get_received_date(mail, &dmail->received_date) < 0) - return dsync_mail_error(exporter, mail, "received-date"); + if (!seq_range_exists(&exporter->requested_uids, mail->uid)) + exporter->dsync_mail.uid = 0; + else + exporter->dsync_mail.guid = ""; /* this message was successfully returned, don't try retrying it */ if (instances != NULL) diff -r 44eda990f757 -r 4260244e57e2 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 07:12:18 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 07:15:55 2013 +0200 @@ -26,7 +26,12 @@ const char *guid; struct dsync_mail_change *change; - uint32_t uid; + /* the final UID for the message */ + uint32_t final_uid; + /* the original local UID, or 0 if exists only remotely */ + uint32_t local_uid; + /* the original remote UID, or 0 if exists only remotely */ + uint32_t remote_uid; unsigned int uid_in_local:1; unsigned int uid_is_usable:1; unsigned int skip:1; @@ -79,6 +84,7 @@ unsigned int failed:1; unsigned int debug:1; + unsigned int stateful_import:1; unsigned int last_common_uid_found:1; unsigned int cur_uid_has_change:1; unsigned int cur_mail_skip:1; @@ -90,6 +96,10 @@ unsigned int mails_have_guids:1; }; +static void dsync_mailbox_save_newmails(struct dsync_mailbox_importer *importer, + const struct dsync_mail *mail, + struct importer_new_mail *all_newmails); + static void dsync_mailbox_import_search_init(struct dsync_mailbox_importer *importer) { @@ -147,6 +157,7 @@ importer->remote_first_recent_uid = remote_first_recent_uid; importer->remote_highest_modseq = remote_highest_modseq; importer->remote_highest_pvt_modseq = remote_highest_pvt_modseq; + importer->stateful_import = importer->last_common_uid_found; hash_table_create(&importer->import_guids, pool, 0, str_hash, strcmp); hash_table_create_direct(&importer->import_uids, pool, 0); @@ -195,7 +206,8 @@ if (error == MAIL_ERROR_EXPUNGED) return; - i_error("Can't lookup %s for UID=%u: %s", field, mail->uid, errstr); + i_error("Mailbox %s: Can't lookup %s for UID=%u: %s", + mailbox_get_vname(mail->box), field, mail->uid, errstr); importer->failed = TRUE; } @@ -298,19 +310,6 @@ return 0; } -static void importer_mail_request(struct dsync_mailbox_importer *importer, - struct importer_new_mail *newmail) -{ - struct dsync_mail_request *request; - - if (importer->want_mail_requests && !newmail->uid_in_local) { - IMPORTER_DEBUG_CHANGE(importer); - request = array_append_space(&importer->mail_requests); - request->guid = newmail->guid; - request->uid = newmail->uid; - } -} - static void newmail_link(struct dsync_mailbox_importer *importer, struct importer_new_mail *newmail, uint32_t remote_uid) { @@ -323,17 +322,21 @@ /* first mail for this GUID */ hash_table_insert(importer->import_guids, newmail->guid, newmail); - importer_mail_request(importer, newmail); return; } } else { + if (remote_uid == 0) { + /* mail exists only locally. we don't want to request + it, and we'll assume it has no duplicate + instances. */ + return; + } first_mail = hash_table_lookup(importer->import_uids, POINTER_CAST(remote_uid)); if (first_mail == NULL) { /* first mail for this UID */ hash_table_insert(importer->import_uids, POINTER_CAST(remote_uid), newmail); - importer_mail_request(importer, newmail); return; } } @@ -341,7 +344,7 @@ 2) find our link */ last = &first_mail->next; for (mail = first_mail; mail != NULL; mail = mail->next) { - if (mail->uid == newmail->uid) + if (mail->final_uid == newmail->final_uid) mail->uid_is_usable = TRUE; if (link == NULL && mail->link == NULL && mail->uid_in_local != newmail->uid_in_local) @@ -389,19 +392,21 @@ } newmail = p_new(importer->pool, struct importer_new_mail, 1); newmail->guid = p_strdup(importer->pool, importer->cur_guid); - newmail->uid = importer->cur_mail->uid; + newmail->final_uid = importer->cur_mail->uid; + newmail->local_uid = importer->cur_mail->uid; newmail->uid_in_local = TRUE; newmail->uid_is_usable = - newmail->uid >= importer->remote_uid_next; + newmail->final_uid >= importer->remote_uid_next; remote_saved = FALSE; } else if (diff > 0) { i_assert(save_change != NULL); newmail = p_new(importer->pool, struct importer_new_mail, 1); newmail->guid = save_change->guid; - newmail->uid = save_change->uid; + newmail->final_uid = save_change->uid; + newmail->remote_uid = save_change->uid; newmail->uid_in_local = FALSE; newmail->uid_is_usable = - newmail->uid >= importer->local_uid_next; + newmail->final_uid >= importer->local_uid_next; remote_saved = TRUE; } else { /* identical */ @@ -409,7 +414,9 @@ i_assert(save_change != NULL); newmail = p_new(importer->pool, struct importer_new_mail, 1); newmail->guid = save_change->guid; - newmail->uid = importer->cur_mail->uid; + newmail->final_uid = importer->cur_mail->uid; + newmail->local_uid = importer->cur_mail->uid; + newmail->remote_uid = save_change->uid; newmail->uid_in_local = TRUE; newmail->uid_is_usable = TRUE; newmail->link = newmail; @@ -425,7 +432,8 @@ } array_append(&importer->newmails, &newmail, 1); - newmail_link(importer, newmail, save_change->uid); + newmail_link(importer, newmail, From dovecot at dovecot.org Sat Feb 16 07:53:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 07:53:33 +0200 Subject: dovecot-2.2: dsync: Don't log read() failed: EOF when remote int... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/93a8a32adfd8 changeset: 15767:93a8a32adfd8 user: Timo Sirainen date: Sat Feb 16 07:53:17 2013 +0200 description: dsync: Don't log read() failed: EOF when remote intentionally fails early. diffstat: src/doveadm/dsync/dsync-ibc-stream.c | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) diffs (94 lines): diff -r 4260244e57e2 -r 93a8a32adfd8 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Sat Feb 16 07:15:55 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Sat Feb 16 07:53:17 2013 +0200 @@ -32,6 +32,7 @@ enum item_type { ITEM_NONE, + ITEM_DONE, ITEM_HANDSHAKE, ITEM_MAILBOX_STATE, @@ -58,6 +59,10 @@ const char *optional_keys; } items[ITEM_END_OF_LIST+1] = { { NULL, '\0', NULL, NULL }, + { .name = "done", + .chr = 'X', + .optional_keys = "" + }, { .name = "handshake", .chr = 'H', .optional_keys = "sync_ns_prefix sync_box sync_type debug sync_all_namespaces " @@ -132,10 +137,12 @@ unsigned int version_received:1; unsigned int handshake_received:1; unsigned int has_pending_data:1; + unsigned int stopped:1; }; static void dsync_ibc_stream_stop(struct dsync_ibc_stream *ibc) { + ibc->stopped = TRUE; i_stream_close(ibc->input); o_stream_close(ibc->output); io_loop_stop(current_ioloop); @@ -280,7 +287,7 @@ o_stream_nsend_str(ibc->output, DSYNC_HANDSHAKE_VERSION); /* initialize serializers and send their headers to remote */ - for (i = 1; i < ITEM_END_OF_LIST; i++) T_BEGIN { + for (i = ITEM_DONE + 1; i < ITEM_END_OF_LIST; i++) T_BEGIN { const char *keys; keys = items[i].required_keys == NULL ? items[i].optional_keys : @@ -308,6 +315,13 @@ dsync_deserializer_decode_finish(&ibc->cur_decoder); if (ibc->mail_output != NULL) i_stream_unref(&ibc->mail_output); + else { + /* notify remote that we're closing. this is mainly to avoid + "read() failed: EOF" errors on failing dsyncs */ + o_stream_nsend_str(ibc->output, + t_strdup_printf("%c\n", items[ITEM_DONE].chr)); + o_stream_nfinish(ibc->output); + } timeout_remove(&ibc->to); if (ibc->io != NULL) @@ -330,9 +344,10 @@ *line_r = line; return 1; } - /* try reading some */ if (i_stream_read(ibc->input) == -1) { + if (ibc->stopped) + return -1; if (ibc->input->stream_errno != 0) { errno = ibc->input->stream_errno; i_error("read(%s) failed: %m", ibc->name); @@ -387,7 +402,7 @@ unsigned int i; int ret = 0; - for (i = 1; i < ITEM_END_OF_LIST; i++) { + for (i = ITEM_DONE + 1; i < ITEM_END_OF_LIST; i++) { if (ibc->deserializers[i] == NULL && (items[i].required_keys != NULL || items[i].optional_keys != NULL)) { @@ -473,6 +488,14 @@ /* end of this list */ return DSYNC_IBC_RECV_RET_FINISHED; } + if (line[0] == items[ITEM_DONE].chr) { + /* remote cleanly closed the connection, possibly because of + some failure (which it should have logged). we don't want to + log any stream errors anyway after this. */ + dsync_ibc_stream_stop(ibc); + return DSYNC_IBC_RECV_RET_TRYAGAIN; + + } for (i = 1; i < ITEM_END_OF_LIST; i++) { if (*line == items[i].chr) { line_item = i; From dovecot at dovecot.org Sat Feb 16 08:01:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 08:01:21 +0200 Subject: dovecot-2.2: dsync: Don't log a redundant "importing mailbox fai... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5ff6ff443b4c changeset: 15768:5ff6ff443b4c user: Timo Sirainen date: Sat Feb 16 07:59:44 2013 +0200 description: dsync: Don't log a redundant "importing mailbox failed" error. diffstat: src/doveadm/dsync/dsync-brain-mails.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diffs (12 lines): diff -r 93a8a32adfd8 -r 5ff6ff443b4c src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 07:53:17 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 07:59:44 2013 +0200 @@ -174,8 +174,6 @@ &state.last_common_modseq, &state.last_common_pvt_modseq, &changes_during_sync) < 0) { - i_error("Importing mailbox %s failed", - mailbox_get_vname(brain->box)); brain->failed = TRUE; return; } From dovecot at dovecot.org Sat Feb 16 08:01:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 08:01:21 +0200 Subject: dovecot-2.2: dsync: Don't log "remote failed with 75" if we alre... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/77ef526e6a0a changeset: 15769:77ef526e6a0a user: Timo Sirainen date: Sat Feb 16 08:00:51 2013 +0200 description: dsync: Don't log "remote failed with 75" if we already logged an error from remote. This reduces number of log lines when dsync fails. diffstat: src/doveadm/dsync/doveadm-dsync.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diffs (54 lines): diff -r 5ff6ff443b4c -r 77ef526e6a0a src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Sat Feb 16 07:59:44 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Sat Feb 16 08:00:51 2013 +0200 @@ -333,7 +333,8 @@ return 0; } -static void cmd_dsync_wait_remote(struct dsync_cmd_context *ctx) +static void cmd_dsync_wait_remote(struct dsync_cmd_context *ctx, + bool remote_errors_logged) { int status; @@ -353,8 +354,14 @@ } } else if (WIFSIGNALED(status)) i_error("Remote command died with signal %d", WTERMSIG(status)); - else if (WIFEXITED(status) && WEXITSTATUS(status) != 0) + else if (!WIFEXITED(status)) + i_error("Remote command failed with status %d", status); + else if (WEXITSTATUS(status) == EX_TEMPFAIL && remote_errors_logged) { + /* remote most likely already logged the error. + don't bother logging another line about it */ + } else if (WEXITSTATUS(status) != 0) { i_error("Remote command returned error %d", WEXITSTATUS(status)); + } } static void cmd_dsync_run_remote(struct mail_user *user) @@ -403,6 +410,7 @@ struct dsync_brain *brain; struct mail_namespace *sync_ns = NULL; enum dsync_brain_flags brain_flags; + bool remote_errors_logged = FALSE; int ret = 0; user->admin = TRUE; @@ -460,6 +468,7 @@ dsync_ibc_deinit(&ibc2); if (ctx->err_stream != NULL) { remote_error_input(ctx); /* print any pending errors */ + remote_errors_logged = ctx->err_stream->v_offset > 0; i_stream_destroy(&ctx->err_stream); } if (ctx->io_err != NULL) @@ -472,7 +481,7 @@ if (ctx->fd_err != -1) i_close_fd(&ctx->fd_err); if (ctx->remote) - cmd_dsync_wait_remote(ctx); + cmd_dsync_wait_remote(ctx, remote_errors_logged); return ret; } From dovecot at dovecot.org Sat Feb 16 08:01:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 08:01:21 +0200 Subject: dovecot-2.2: dsync: Avoid possibly long function recursion. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/516a337480f4 changeset: 15770:516a337480f4 user: Timo Sirainen date: Sat Feb 16 08:01:10 2013 +0200 description: dsync: Avoid possibly long function recursion. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 40 ++++++++++++++++++------------- 1 files changed, 23 insertions(+), 17 deletions(-) diffs (79 lines): diff -r 77ef526e6a0a -r 516a337480f4 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 08:00:51 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 08:01:10 2013 +0200 @@ -227,15 +227,16 @@ return memcmp(change_guid_128, guid_128, GUID_128_SIZE) == 0; } -static bool -importer_next_mail(struct dsync_mailbox_importer *importer, uint32_t wanted_uid) +static int +importer_try_next_mail(struct dsync_mailbox_importer *importer, + uint32_t wanted_uid) { + struct mail_private *pmail; const char *hdr_hash; - int ret = 0; if (importer->cur_mail == NULL) { /* end of search */ - return FALSE; + return -1; } while (importer->cur_mail->seq < importer->next_local_seq || importer->cur_mail->uid < wanted_uid) { @@ -254,7 +255,7 @@ importer->cur_mail = NULL; importer->cur_guid = NULL; importer->cur_hdr_hash = NULL; - return FALSE; + return -1; } importer->cur_uid_has_change = FALSE; } @@ -264,28 +265,33 @@ if (mail_get_special(importer->cur_mail, MAIL_FETCH_GUID, &importer->cur_guid) < 0) { dsync_mail_error(importer, importer->cur_mail, "GUID"); - ret = -1; + return 0; } } else { if (dsync_mail_get_hdr_hash(importer->cur_mail, &hdr_hash) < 0) { dsync_mail_error(importer, importer->cur_mail, "header hash"); - ret = -1; - } else { - struct mail_private *pmail = - (struct mail_private *)importer->cur_mail; - importer->cur_hdr_hash = p_strdup(pmail->pool, hdr_hash); - } - } - if (ret < 0) { - importer->next_local_seq = importer->cur_mail->seq + 1; - return importer_next_mail(importer, wanted_uid); + return 0; + } + pmail = (struct mail_private *)importer->cur_mail; + importer->cur_hdr_hash = p_strdup(pmail->pool, hdr_hash); } /* make sure next_local_seq gets updated in case we came here because of min_uid */ importer->next_local_seq = importer->cur_mail->seq; - return TRUE; + return 1; +} + +static bool +importer_next_mail(struct dsync_mailbox_importer *importer, uint32_t wanted_uid) +{ + int ret; + + while ((ret = importer_try_next_mail(importer, wanted_uid)) == 0 && + !importer->failed) + importer->next_local_seq = importer->cur_mail->seq + 1; + return ret > 0; } static int From dovecot at dovecot.org Sat Feb 16 08:09:53 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 08:09:53 +0200 Subject: dovecot-2.2: fts-solr: Don't assert-crash on failures. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e247f3a74947 changeset: 15771:e247f3a74947 user: Timo Sirainen date: Sat Feb 16 08:09:41 2013 +0200 description: fts-solr: Don't assert-crash on failures. diffstat: src/plugins/fts-solr/solr-connection.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) diffs (21 lines): diff -r 516a337480f4 -r e247f3a74947 src/plugins/fts-solr/solr-connection.c --- a/src/plugins/fts-solr/solr-connection.c Sat Feb 16 08:01:10 2013 +0200 +++ b/src/plugins/fts-solr/solr-connection.c Sat Feb 16 08:09:41 2013 +0200 @@ -544,7 +544,6 @@ struct istream *post_payload; i_assert(!conn->posting); - conn->posting = TRUE; http_req = solr_connection_post_request(conn); post_payload = i_stream_create_from_data(cmd, strlen(cmd)); @@ -557,9 +556,5 @@ conn->request_status = 0; http_client_wait(conn->http_client); - if (conn->request_status < 0) - return -1; - - conn->posting = FALSE; return conn->request_status; } From dovecot at dovecot.org Sat Feb 16 13:31:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 13:31:59 +0200 Subject: dovecot-2.2: dsync: Various importer fixes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/360661d99c42 changeset: 15772:360661d99c42 user: Timo Sirainen date: Sat Feb 16 13:31:37 2013 +0200 description: dsync: Various importer fixes. diffstat: src/doveadm/dsync/dsync-brain-mails.c | 3 +- src/doveadm/dsync/dsync-mailbox-import.c | 276 +++++++++++++++++++----------- src/doveadm/dsync/dsync-mailbox-import.h | 4 +- 3 files changed, 175 insertions(+), 108 deletions(-) diffs (truncated from 499 to 300 lines): diff -r e247f3a74947 -r 360661d99c42 src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 08:09:41 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 13:31:37 2013 +0200 @@ -74,7 +74,8 @@ brain->box_recv_state = DSYNC_BOX_STATE_MAILS; return TRUE; } - dsync_mailbox_import_change(brain->box_importer, change); + if (dsync_mailbox_import_change(brain->box_importer, change) < 0) + brain->failed = TRUE; return TRUE; } diff -r e247f3a74947 -r 360661d99c42 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 08:09:41 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 13:31:37 2013 +0200 @@ -35,6 +35,7 @@ unsigned int uid_in_local:1; unsigned int uid_is_usable:1; unsigned int skip:1; + unsigned int expunged:1; unsigned int copy_failed:1; }; @@ -432,10 +433,9 @@ if (newmail->uid_in_local) { importer->cur_mail_skip = TRUE; importer->next_local_seq++; - } else { - /* NOTE: assumes save_change is allocated from importer pool */ - newmail->change = save_change; } + /* NOTE: assumes save_change is allocated from importer pool */ + newmail->change = save_change; array_append(&importer->newmails, &newmail, 1); newmail_link(importer, newmail, @@ -502,7 +502,6 @@ dsync_import_unexpected_state(importer, t_strdup_printf( "Unexpected GUID mismatch for UID=%u: %s != %s", change->uid, guid, change->guid)); - importer->last_common_uid = 1; importer->failed = TRUE; return FALSE; } @@ -518,7 +517,6 @@ dsync_import_unexpected_state(importer, t_strdup_printf( "Unexpected GUID mismatch (2) for UID=%u: %s != %s", change->uid, importer->cur_guid, change->guid)); - importer->last_common_uid = 1; importer->failed = TRUE; return FALSE; } @@ -935,7 +933,8 @@ /* the local mail is expunged. we'll decide later if we want to save this mail locally or expunge it form remote. */ i_assert(change->uid > importer->last_common_uid); - i_assert(change->uid < importer->cur_mail->uid); + i_assert(importer->cur_mail == NULL || + change->uid < importer->cur_mail->uid); array_append(&importer->maybe_saves, &save, 1); } } @@ -1128,14 +1127,17 @@ dsync_mailbox_find_common_expunged_uid(importer, change); } -void dsync_mailbox_import_change(struct dsync_mailbox_importer *importer, - const struct dsync_mail_change *change) +int dsync_mailbox_import_change(struct dsync_mailbox_importer *importer, + const struct dsync_mail_change *change) { i_assert(!importer->new_uids_assigned); i_assert(importer->prev_uid < change->uid); importer->prev_uid = change->uid; + if (importer->failed) + return -1; + if (!importer->last_common_uid_found) dsync_mailbox_find_common_uid(importer, change); @@ -1155,7 +1157,7 @@ i_assert(change->type != DSYNC_MAIL_CHANGE_TYPE_SAVE); } else if (change->type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) { /* ignore */ - return; + return 0; } else { i_assert(change->type == DSYNC_MAIL_CHANGE_TYPE_SAVE); } @@ -1171,6 +1173,7 @@ find its GUID */ if (change->uid > importer->last_common_uid) { i_assert(change->type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE || + importer->cur_mail == NULL || change->uid < importer->cur_mail->uid); } } @@ -1187,24 +1190,7 @@ dsync_mailbox_import_flag_change(importer, change); break; } -} - -static void -dsync_msg_update_uid(struct dsync_mailbox_importer *importer, - uint32_t old_uid, uint32_t new_uid) -{ - struct mail_save_context *save_ctx; - - IMPORTER_DEBUG_CHANGE(importer); - - if (!mail_set_uid(importer->mail, old_uid)) - return; - - save_ctx = mailbox_save_alloc(importer->ext_trans); - mailbox_save_copy_flags(save_ctx, importer->mail); - mailbox_save_set_uid(save_ctx, new_uid); - if (mailbox_move(&save_ctx, importer->mail) == 0) - array_append(&importer->wanted_uids, &new_uid, 1); + return importer->failed ? -1 : 0; } static void @@ -1212,7 +1198,6 @@ { struct importer_new_mail *newmail, *const *newmailp; uint32_t common_uid_next, new_uid; - bool linked_uid; common_uid_next = I_MAX(importer->local_uid_next, importer->remote_uid_next); @@ -1220,11 +1205,6 @@ newmail = *newmailp; if (newmail->skip) { /* already assigned */ - if (newmail->uid_in_local) { - IMPORTER_DEBUG_CHANGE(importer); - if (mail_set_uid(importer->mail, newmail->local_uid)) - mail_expunge(importer->mail); - } continue; } @@ -1232,30 +1212,18 @@ if (newmail->uid_is_usable) { /* keep the UID */ new_uid = newmail->final_uid; - linked_uid = FALSE; } else if (newmail->link != NULL && newmail->link->uid_is_usable) { + /* we can use the linked message's UID and expunge + this mail */ new_uid = newmail->link->final_uid; - linked_uid = TRUE; } else { new_uid = common_uid_next++; - linked_uid = FALSE; } - if (newmail->uid_in_local && newmail->final_uid != new_uid) { - /* local UID changed, reassign it by copying */ - dsync_msg_update_uid(importer, newmail->final_uid, - new_uid); - } else if (linked_uid && newmail->link->uid_in_local) { - /* the linked message already exists. we'll just need - to forget about this message. */ - i_assert(!newmail->uid_in_local); - newmail->skip = TRUE; - } newmail->final_uid = new_uid; - - if (newmail->link != NULL && !newmail->skip) { - /* skip the linked mail */ + if (newmail->link != NULL) { + /* skip processing the linked mail */ newmail->link->skip = TRUE; } } @@ -1265,13 +1233,13 @@ static int dsync_mailbox_import_local_uid(struct dsync_mailbox_importer *importer, - struct importer_new_mail *mail, + uint32_t uid, const char *guid, struct dsync_mail *dmail_r) { const char *error_field, *errstr; enum mail_error error; - if (!mail_set_uid(importer->mail, mail->local_uid)) + if (!mail_set_uid(importer->mail, uid)) return 0; if (dsync_mail_fill(importer->mail, dmail_r, &error_field) < 0) { @@ -1281,25 +1249,136 @@ i_error("Mailbox %s: Can't lookup %s for UID=%u: %s", mailbox_get_vname(importer->box), - error_field, mail->local_uid, errstr); + error_field, uid, errstr); return -1; } - if (*mail->guid != '\0' && strcmp(mail->guid, dmail_r->guid) != 0) { + if (*guid != '\0' && strcmp(guid, dmail_r->guid) != 0) { dsync_import_unexpected_state(importer, t_strdup_printf( "Unexpected GUID mismatch (3) for UID=%u: %s != %s", - mail->local_uid, dmail_r->guid, mail->guid)); + uid, dmail_r->guid, guid)); return -1; } return 1; } -static bool newmails_need_save(struct importer_new_mail *all_newmails) +static bool +dsync_msg_change_uid(struct dsync_mailbox_importer *importer, + uint32_t old_uid, uint32_t new_uid) { + struct mail_save_context *save_ctx; + + IMPORTER_DEBUG_CHANGE(importer); + + if (!mail_set_uid(importer->mail, old_uid)) + return FALSE; + + save_ctx = mailbox_save_alloc(importer->ext_trans); + mailbox_save_copy_flags(save_ctx, importer->mail); + mailbox_save_set_uid(save_ctx, new_uid); + if (mailbox_move(&save_ctx, importer->mail) < 0) + return FALSE; + array_append(&importer->wanted_uids, &new_uid, 1); + return TRUE; +} + +static bool +dsync_mailbox_import_change_uid(struct dsync_mailbox_importer *importer, + ARRAY_TYPE(seq_range) *unwanted_uids, + uint32_t wanted_uid) +{ + const struct seq_range *range; + unsigned int count; + + while ((count = array_count(unwanted_uids)) > 0) { + range = array_idx(unwanted_uids, count-1); + if (dsync_msg_change_uid(importer, range->seq2, wanted_uid)) { + seq_range_array_remove(unwanted_uids, range->seq2); + return TRUE; + } + } + return FALSE; +} + +static bool +dsync_mailbox_import_try_local(struct dsync_mailbox_importer *importer, + struct importer_new_mail *all_newmails, + ARRAY_TYPE(seq_range) *local_uids, + ARRAY_TYPE(seq_range) *wanted_uids) +{ + ARRAY_TYPE(seq_range) assigned_uids, unwanted_uids; + struct seq_range_iter local_iter, wanted_iter; + unsigned int local_n, wanted_n; + uint32_t local_uid, wanted_uid; struct importer_new_mail *mail; + struct dsync_mail dmail; + if (array_count(local_uids) == 0) + return FALSE; + + local_n = wanted_n = 0; + seq_range_array_iter_init(&local_iter, local_uids); + seq_range_array_iter_init(&wanted_iter, wanted_uids); + + /* wanted_uids contains UIDs that need to exist at the end. those that + don't already exist in local_uids have a higher UID than any + existing local UID */ + t_array_init(&assigned_uids, array_count(wanted_uids)); + t_array_init(&unwanted_uids, 8); + while (seq_range_array_iter_nth(&local_iter, local_n++, &local_uid)) { + if (seq_range_array_iter_nth(&wanted_iter, wanted_n, + &wanted_uid)) { + if (local_uid == wanted_uid) { + /* we have exactly the UID we want. keep it. */ + seq_range_array_add(&assigned_uids, wanted_uid); + wanted_n++; + continue; + } + i_assert(local_uid < wanted_uid); + } + /* we no longer want this local UID. */ + seq_range_array_add(&unwanted_uids, local_uid); + } + + /* reuse as many existing messages as possible by changing their UIDs */ + while (seq_range_array_iter_nth(&wanted_iter, wanted_n, &wanted_uid)) { + if (!dsync_mailbox_import_change_uid(importer, &unwanted_uids, + wanted_uid)) + break; From dovecot at dovecot.org Sat Feb 16 13:33:28 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 13:33:28 +0200 Subject: dovecot-2.1: mdbox: mailbox_copy() didn't properly free the save... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/dd0eebe378fe changeset: 14905:dd0eebe378fe user: Timo Sirainen date: Sat Feb 16 13:32:57 2013 +0200 description: mdbox: mailbox_copy() didn't properly free the save context. diffstat: src/lib-storage/index/dbox-multi/mdbox-save.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (22 lines): diff -r 2def25f07ca6 -r dd0eebe378fe src/lib-storage/index/dbox-multi/mdbox-save.c --- a/src/lib-storage/index/dbox-multi/mdbox-save.c Fri Feb 08 16:42:21 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Sat Feb 16 13:32:57 2013 +0200 @@ -426,8 +426,10 @@ memset(&rec, 0, sizeof(rec)); rec.save_date = ioloop_time; if (mdbox_mail_lookup(src_mbox, mail->transaction->view, mail->seq, - &rec.map_uid) < 0) + &rec.map_uid) < 0) { + index_save_context_free(_ctx); return -1; + } mail_index_lookup_ext(mail->transaction->view, mail->seq, src_mbox->guid_ext_id, &guid_data, &expunged); @@ -462,5 +464,6 @@ if (_ctx->dest_mail != NULL) mail_set_seq_saving(_ctx->dest_mail, ctx->ctx.seq); + index_save_context_free(_ctx); return 0; } From dovecot at dovecot.org Sat Feb 16 13:38:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 13:38:25 +0200 Subject: dovecot-2.2: mdbox: mailbox_copy() didn't properly free the save... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2cf0049a8e75 changeset: 15773:2cf0049a8e75 user: Timo Sirainen date: Sat Feb 16 13:32:57 2013 +0200 description: mdbox: mailbox_copy() didn't properly free the save context. diffstat: src/lib-storage/index/dbox-multi/mdbox-save.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (22 lines): diff -r 360661d99c42 -r 2cf0049a8e75 src/lib-storage/index/dbox-multi/mdbox-save.c --- a/src/lib-storage/index/dbox-multi/mdbox-save.c Sat Feb 16 13:31:37 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Sat Feb 16 13:32:57 2013 +0200 @@ -425,8 +425,10 @@ memset(&rec, 0, sizeof(rec)); rec.save_date = ioloop_time; if (mdbox_mail_lookup(src_mbox, mail->transaction->view, mail->seq, - &rec.map_uid) < 0) + &rec.map_uid) < 0) { + index_save_context_free(_ctx); return -1; + } mail_index_lookup_ext(mail->transaction->view, mail->seq, src_mbox->guid_ext_id, &guid_data, &expunged); @@ -461,5 +463,6 @@ if (_ctx->dest_mail != NULL) mail_set_seq_saving(_ctx->dest_mail, ctx->ctx.seq); + index_save_context_free(_ctx); return 0; } From dovecot at dovecot.org Sat Feb 16 13:38:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 13:38:25 +0200 Subject: dovecot-2.2: lib-storage: Assert-crash if mailbox_save_context i... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9847164c6fd7 changeset: 15774:9847164c6fd7 user: Timo Sirainen date: Sat Feb 16 13:34:13 2013 +0200 description: lib-storage: Assert-crash if mailbox_save_context isn't properly freed before reusing. diffstat: src/lib-storage/index/index-storage.c | 1 + src/lib-storage/mail-storage-private.h | 3 +++ src/lib-storage/mail-storage.c | 2 ++ 3 files changed, 6 insertions(+), 0 deletions(-) diffs (36 lines): diff -r 2cf0049a8e75 -r 9847164c6fd7 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Sat Feb 16 13:32:57 2013 +0200 +++ b/src/lib-storage/index/index-storage.c Sat Feb 16 13:34:13 2013 +0200 @@ -754,6 +754,7 @@ i_free_and_null(ctx->data.pop3_uidl); index_attachment_save_free(ctx); memset(&ctx->data, 0, sizeof(ctx->data)); + ctx->unfinished = FALSE; } static void diff -r 2cf0049a8e75 -r 9847164c6fd7 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Sat Feb 16 13:32:57 2013 +0200 +++ b/src/lib-storage/mail-storage-private.h Sat Feb 16 13:34:13 2013 +0200 @@ -528,6 +528,9 @@ bool (*part_is_attachment)(struct mail_save_context *ctx, const struct mail_attachment_part *part); + /* mailbox_save_alloc() called, but finish/cancel not. + the same context is usually returned by the backends for reuse. */ + unsigned int unfinished:1; /* mail was copied using saving */ unsigned int copying_via_save:1; /* mail is being saved, not copied */ diff -r 2cf0049a8e75 -r 9847164c6fd7 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sat Feb 16 13:32:57 2013 +0200 +++ b/src/lib-storage/mail-storage.c Sat Feb 16 13:34:13 2013 +0200 @@ -1790,6 +1790,8 @@ struct mail_save_context *ctx; ctx = t->box->v.save_alloc(t); + i_assert(!ctx->unfinished); + ctx->unfinished = TRUE; ctx->data.received_date = (time_t)-1; ctx->data.save_date = (time_t)-1; return ctx; From dovecot at dovecot.org Sat Feb 16 13:38:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 13:38:25 +0200 Subject: dovecot-2.2: lib-index: Don't lookup mail's expunge-state in tra... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f9b1aaf844c8 changeset: 15775:f9b1aaf844c8 user: Timo Sirainen date: Sat Feb 16 13:38:10 2013 +0200 description: lib-index: Don't lookup mail's expunge-state in transaction log view if caller doesn't care. This was especially bad with dsync, which could trigger sorting of the expunges array each time after processing a mail (= potentially tens of thousands of sorts). diffstat: src/lib-index/mail-index-transaction-view.c | 9 ++++++--- src/lib-index/mail-index-view.c | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diffs (103 lines): diff -r 9847164c6fd7 -r f9b1aaf844c8 src/lib-index/mail-index-transaction-view.c --- a/src/lib-index/mail-index-transaction-view.c Sat Feb 16 13:34:13 2013 +0200 +++ b/src/lib-index/mail-index-transaction-view.c Sat Feb 16 13:38:10 2013 +0200 @@ -139,14 +139,16 @@ /* FIXME: is this right to return index map..? it's not there yet. */ *map_r = view->index->map; - *expunged_r = FALSE; + if (expunged_r != NULL) + *expunged_r = FALSE; return mail_index_transaction_lookup(tview->t, seq); } rec = tview->super->lookup_full(view, seq, map_r, expunged_r); rec = tview_apply_flag_updates(tview, *map_r, rec, seq); - if (mail_index_transaction_is_expunged(tview->t, seq)) + if (expunged_r != NULL && + mail_index_transaction_is_expunged(tview->t, seq)) *expunged_r = TRUE; return rec; } @@ -413,7 +415,8 @@ i_assert(ext_id < array_count(&view->index->extensions)); - *expunged_r = FALSE; + if (expunged_r != NULL) + *expunged_r = FALSE; if (array_is_created(&tview->t->ext_rec_updates) && ext_id < array_count(&tview->t->ext_rec_updates)) { diff -r 9847164c6fd7 -r f9b1aaf844c8 src/lib-index/mail-index-view.c --- a/src/lib-index/mail-index-view.c Sat Feb 16 13:34:13 2013 +0200 +++ b/src/lib-index/mail-index-view.c Sat Feb 16 13:38:10 2013 +0200 @@ -181,13 +181,15 @@ /* we'll need to return something so the caller doesn't crash */ *map_r = view->map; - *expunged_r = TRUE; + if (expunged_r != NULL) + *expunged_r = TRUE; return &broken_rec; } if (view->map == view->index->map) { /* view's mapping is latest. we can use it directly. */ *map_r = view->map; - *expunged_r = FALSE; + if (expunged_r != NULL) + *expunged_r = FALSE; return rec; } @@ -205,7 +207,8 @@ if (seq == 0) { /* everything is expunged from head. use the old record. */ *map_r = view->map; - *expunged_r = TRUE; + if (expunged_r != NULL) + *expunged_r = TRUE; return rec; } @@ -222,12 +225,14 @@ returned record doesn't get invalidated after next sync. */ mail_index_view_ref_map(view, view->index->map); *map_r = view->index->map; - *expunged_r = FALSE; + if (expunged_r != NULL) + *expunged_r = FALSE; return head_rec; } else { /* expuned from head. use the old record. */ *map_r = view->map; - *expunged_r = TRUE; + if (expunged_r != NULL) + *expunged_r = TRUE; return rec; } } @@ -334,10 +339,9 @@ { struct mail_index_map *map; const void *data; - bool expunged; mail_index_lookup_ext_full(view, seq, view->index->keywords_ext_id, - &map, &data, &expunged); + &map, &data, NULL); mail_index_data_lookup_keywords(map, data, keyword_idx); } @@ -442,9 +446,7 @@ mail_index_lookup_full(struct mail_index_view *view, uint32_t seq, struct mail_index_map **map_r) { - bool expunged; - - return view->v.lookup_full(view, seq, map_r, &expunged); + return view->v.lookup_full(view, seq, map_r, NULL); } bool mail_index_is_expunged(struct mail_index_view *view, uint32_t seq) From dovecot at dovecot.org Sat Feb 16 13:51:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 13:51:11 +0200 Subject: dovecot-2.2: mdbox, mbox, virtual: Avoid getting expunged-status... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e3eaa8303987 changeset: 15776:e3eaa8303987 user: Timo Sirainen date: Sat Feb 16 13:51:05 2013 +0200 description: mdbox, mbox, virtual: Avoid getting expunged-status in index lookups when not necessary. This especially improves dsync performance with mdbox. diffstat: src/lib-storage/index/dbox-multi/mdbox-mail.c | 6 +--- src/lib-storage/index/dbox-multi/mdbox-map.c | 20 ++++----------- src/lib-storage/index/dbox-multi/mdbox-save.c | 10 ++----- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 8 ++---- src/lib-storage/index/dbox-multi/mdbox-sync.c | 6 +--- src/lib-storage/index/mbox/mbox-mail.c | 3 +- src/lib-storage/index/mbox/mbox-sync.c | 10 ++----- src/plugins/virtual/virtual-mail.c | 3 +- src/plugins/virtual/virtual-search.c | 3 +- src/plugins/virtual/virtual-sync.c | 16 ++++-------- 10 files changed, 27 insertions(+), 58 deletions(-) diffs (truncated from 439 to 300 lines): diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-mail.c --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c Sat Feb 16 13:38:10 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c Sat Feb 16 13:51:05 2013 +0200 @@ -21,9 +21,8 @@ struct mdbox_index_header hdr; const void *data; uint32_t uid, cur_map_uid_validity; - bool expunged; - mail_index_lookup_ext(view, seq, mbox->ext_id, &data, &expunged); + mail_index_lookup_ext(view, seq, mbox->ext_id, &data, NULL); dbox_rec = data; if (dbox_rec == NULL || dbox_rec->map_uid == 0) { mail_index_lookup_uid(view, seq, &uid); @@ -156,10 +155,9 @@ (struct mdbox_mailbox *)mail->transaction->box; const struct mdbox_mail_index_record *dbox_rec; const void *data; - bool expunged; mail_index_lookup_ext(mail->transaction->view, mail->seq, - mbox->ext_id, &data, &expunged); + mbox->ext_id, &data, NULL); dbox_rec = data; if (dbox_rec == NULL || dbox_rec->map_uid == 0) { /* lost for some reason, use fallback */ diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Sat Feb 16 13:38:10 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Sat Feb 16 13:51:05 2013 +0200 @@ -266,10 +266,8 @@ const struct mdbox_map_mail_index_record *rec; const void *data; uint32_t uid; - bool expunged; - mail_index_lookup_ext(map->view, seq, map->map_ext_id, - &data, &expunged); + mail_index_lookup_ext(map->view, seq, map->map_ext_id, &data, NULL); rec = data; if (rec == NULL || rec->file_id == 0) { @@ -322,7 +320,6 @@ const uint16_t *ref16_p; const void *data; uint32_t seq; - bool expunged; int ret; if (mdbox_map_open_or_create(map) < 0) @@ -335,8 +332,7 @@ return -1; *rec_r = *rec; - mail_index_lookup_ext(map->view, seq, map->ref_ext_id, - &data, &expunged); + mail_index_lookup_ext(map->view, seq, map->ref_ext_id, &data, NULL); if (data == NULL) { mdbox_map_set_corrupted(map, "missing ref extension"); return -1; @@ -352,19 +348,18 @@ { const uint16_t *ref16_p; const void *data; - bool expunged; memset(rec_r, 0, sizeof(*rec_r)); mail_index_lookup_uid(view, seq, &rec_r->map_uid); - mail_index_lookup_ext(view, seq, map->map_ext_id, &data, &expunged); + mail_index_lookup_ext(view, seq, map->map_ext_id, &data, NULL); if (data == NULL) { mdbox_map_set_corrupted(map, "missing map extension"); return -1; } memcpy(&rec_r->rec, data, sizeof(rec_r->rec)); - mail_index_lookup_ext(view, seq, map->ref_ext_id, &data, &expunged); + mail_index_lookup_ext(view, seq, map->ref_ext_id, &data, NULL); if (data == NULL) { mdbox_map_set_corrupted(map, "missing ref extension"); return -1; @@ -605,7 +600,6 @@ struct mdbox_map *map = ctx->atomic->map; const void *data; uint32_t seq; - bool expunged; int old_diff, new_diff; if (unlikely(ctx->trans == NULL)) @@ -624,8 +618,7 @@ } return -1; } - mail_index_lookup_ext(map->view, seq, map->ref_ext_id, - &data, &expunged); + mail_index_lookup_ext(map->view, seq, map->ref_ext_id, &data, NULL); old_diff = data == NULL ? 0 : *((const uint16_t *)data); ctx->changed = TRUE; new_diff = mail_index_atomic_inc_ext(ctx->trans, seq, @@ -672,7 +665,6 @@ const struct mail_index_header *hdr; const struct mdbox_map_mail_index_record *rec; const void *data; - bool expunged; uint32_t seq; int ret = 0; @@ -686,7 +678,7 @@ hdr = mail_index_get_header(map->view); for (seq = 1; seq <= hdr->messages_count; seq++) { mail_index_lookup_ext(map->view, seq, map->map_ext_id, - &data, &expunged); + &data, NULL); if (data == NULL) { mdbox_map_set_corrupted(map, "missing map extension"); ret = -1; diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-save.c --- a/src/lib-storage/index/dbox-multi/mdbox-save.c Sat Feb 16 13:38:10 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Sat Feb 16 13:51:05 2013 +0200 @@ -51,11 +51,9 @@ (struct mdbox_save_context *)t->save_ctx; const struct mdbox_mail_index_record *rec; const void *data; - bool expunged; uint32_t file_id; - mail_index_lookup_ext(t->view, seq, ctx->mbox->ext_id, - &data, &expunged); + mail_index_lookup_ext(t->view, seq, ctx->mbox->ext_id, &data, NULL); rec = data; if (mdbox_map_lookup(ctx->mbox->storage->map, rec->map_uid, @@ -251,7 +249,6 @@ const struct dbox_save_mail *mails; unsigned int i, count; const void *data; - bool expunged; uint32_t next_map_uid = first_map_uid; mdbox_update_header(mbox, ctx->ctx.trans, NULL); @@ -261,7 +258,7 @@ mails = array_get(&ctx->mails, &count); for (i = 0; i < count; i++) { mail_index_lookup_ext(view, mails[i].seq, mbox->ext_id, - &data, &expunged); + &data, NULL); old_rec = data; if (old_rec != NULL && old_rec->map_uid != 0) { /* message was copied. keep the existing map uid */ @@ -413,7 +410,6 @@ struct mdbox_mail_index_record rec; const void *guid_data; guid_128_t wanted_guid; - bool expunged; ctx->ctx.finished = TRUE; @@ -431,7 +427,7 @@ } mail_index_lookup_ext(mail->transaction->view, mail->seq, - src_mbox->guid_ext_id, &guid_data, &expunged); + src_mbox->guid_ext_id, &guid_data, NULL); if (guid_data == NULL || guid_128_is_empty(guid_data)) { /* missing GUID, something's broken. don't copy using refcounting. */ diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sat Feb 16 13:38:10 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sat Feb 16 13:51:05 2013 +0200 @@ -400,7 +400,6 @@ struct mdbox_rebuild_msg *rec; const void *data; const uint8_t *guid_p; - bool expunged; uint32_t old_seq, new_seq, uid, map_uid; /* Rebuild the mailbox's index. Note that index is reset at this point, @@ -409,7 +408,7 @@ hdr = mail_index_get_header(view); for (old_seq = 1; old_seq <= hdr->messages_count; old_seq++) { mail_index_lookup_ext(view, old_seq, mbox->ext_id, - &data, &expunged); + &data, NULL); if (data == NULL) { memset(&new_dbox_rec, 0, sizeof(new_dbox_rec)); map_uid = 0; @@ -419,7 +418,7 @@ } mail_index_lookup_ext(view, old_seq, mbox->guid_ext_id, - &data, &expunged); + &data, NULL); guid_p = data; /* see if we can find this message based on @@ -764,7 +763,6 @@ const void *data; struct mdbox_rebuild_msg **msgs; const uint16_t *ref16_p; - bool expunged; uint32_t seq, map_uid; unsigned int i, count; @@ -781,7 +779,7 @@ mail_index_lookup_ext(ctx->atomic->sync_view, seq, ctx->storage->map->ref_ext_id, - &data, &expunged); + &data, NULL); ref16_p = data; if (ref16_p == NULL || *ref16_p != msgs[i]->refcount) { mail_index_update_ext(ctx->atomic->sync_trans, seq, diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-sync.c --- a/src/lib-storage/index/dbox-multi/mdbox-sync.c Sat Feb 16 13:38:10 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c Sat Feb 16 13:51:05 2013 +0200 @@ -30,11 +30,10 @@ { const void *data; uint32_t uid; - bool expunged; mail_index_lookup_uid(ctx->sync_view, seq, &uid); mail_index_lookup_ext(ctx->sync_view, seq, - ctx->mbox->guid_ext_id, &data, &expunged); + ctx->mbox->guid_ext_id, &data, NULL); if (guid_128_is_empty(guid_128) || memcmp(data, guid_128, GUID_128_SIZE) == 0) return 0; @@ -100,7 +99,6 @@ unsigned int n; const void *data; uint32_t seq, uid; - bool expunged; /* use a separate transaction here so that we can commit the changes during map transaction */ @@ -109,7 +107,7 @@ while (seq_range_array_iter_nth(&iter, n++, &seq)) { mail_index_lookup_uid(ctx->sync_view, seq, &uid); mail_index_lookup_ext(ctx->sync_view, seq, - ctx->mbox->guid_ext_id, &data, &expunged); + ctx->mbox->guid_ext_id, &data, NULL); mail_index_expunge_guid(trans, seq, data); } if (mail_index_transaction_commit(&trans) < 0) diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Sat Feb 16 13:38:10 2013 +0200 +++ b/src/lib-storage/index/mbox/mbox-mail.c Sat Feb 16 13:51:05 2013 +0200 @@ -156,7 +156,6 @@ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->mail.mail.box; const void *ext_data; - bool expunged; if (mail->data.guid != NULL) { *value_r = mail->data.guid; @@ -165,7 +164,7 @@ mail_index_lookup_ext(mail->mail.mail.transaction->view, mail->mail.mail.seq, mbox->md5hdr_ext_idx, - &ext_data, &expunged); + &ext_data, NULL); if (ext_data != NULL && memcmp(ext_data, empty_md5, 16) != 0) { mail->data.guid = p_strdup(mail->mail.data_pool, binary_to_hex(ext_data, 16)); diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/mbox/mbox-sync.c --- a/src/lib-storage/index/mbox/mbox-sync.c Sat Feb 16 13:38:10 2013 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync.c Sat Feb 16 13:51:05 2013 +0200 @@ -244,7 +244,6 @@ const struct mail_index_record *rec = NULL; uint32_t messages_count; const void *data; - bool expunged; if (sync_ctx->index_reset) { *rec_r = NULL; @@ -258,7 +257,7 @@ mail_index_lookup_ext(sync_ctx->sync_view, sync_ctx->idx_seq, sync_ctx->mbox->md5hdr_ext_idx, - &data, &expunged); + &data, NULL); if (data != NULL && memcmp(data, hdr_md5_sum, 16) == 0) break; @@ -278,13 +277,12 @@ { const void *data; uint64_t offset; - bool expunged; if (!nocheck) { /* see if from_offset needs updating */ mail_index_lookup_ext(sync_ctx->sync_view, sync_ctx->idx_seq, sync_ctx->mbox->mbox_ext_idx, - &data, &expunged); + &data, NULL); if (data != NULL && *((const uint64_t *)data) == mail->from_offset) return; From dovecot at dovecot.org Sat Feb 16 13:58:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 13:58:25 +0200 Subject: dovecot-2.2: lib-index: Avoid getting expunged-status in index l... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a709ae98a728 changeset: 15777:a709ae98a728 user: Timo Sirainen date: Sat Feb 16 13:58:14 2013 +0200 description: lib-index: Avoid getting expunged-status in index lookups when not necessary. This especially improves dsync performance. diffstat: src/lib-index/mail-cache-lookup.c | 4 +--- src/lib-index/mail-cache-transaction.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diffs (35 lines): diff -r e3eaa8303987 -r a709ae98a728 src/lib-index/mail-cache-lookup.c --- a/src/lib-index/mail-cache-lookup.c Sat Feb 16 13:51:05 2013 +0200 +++ b/src/lib-index/mail-cache-lookup.c Sat Feb 16 13:58:14 2013 +0200 @@ -63,10 +63,8 @@ struct mail_index_map *map; const void *data; uint32_t offset; - bool expunged; - mail_index_lookup_ext_full(view, seq, cache->ext_id, - &map, &data, &expunged); + mail_index_lookup_ext_full(view, seq, cache->ext_id, &map, &data, NULL); if (data == NULL) { /* no cache offsets */ return 0; diff -r e3eaa8303987 -r a709ae98a728 src/lib-index/mail-cache-transaction.c --- a/src/lib-index/mail-cache-transaction.c Sat Feb 16 13:51:05 2013 +0200 +++ b/src/lib-index/mail-cache-transaction.c Sat Feb 16 13:58:14 2013 +0200 @@ -308,7 +308,6 @@ ARRAY_TYPE(uint32_t) seq_offsets; uint32_t i, seq_count, reset_id, prev_offset, *offsetp; const void *data; - bool expunged; i_assert(ctx->min_seq != 0); @@ -323,7 +322,7 @@ else { mail_index_lookup_ext_full(ctx->view->trans_view, seqs[i], ctx->cache->ext_id, &map, - &data, &expunged); + &data, NULL); prev_offsetp = data; if (prev_offsetp == NULL || *prev_offsetp == 0) From dovecot at dovecot.org Sat Feb 16 14:09:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 14:09:48 +0200 Subject: dovecot-2.2: dsync: Assert-crashfix for previous importer changes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e49424a3b13e changeset: 15778:e49424a3b13e user: Timo Sirainen date: Sat Feb 16 14:09:42 2013 +0200 description: dsync: Assert-crashfix for previous importer changes. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r a709ae98a728 -r e49424a3b13e src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 13:58:14 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 14:09:42 2013 +0200 @@ -1222,7 +1222,7 @@ } newmail->final_uid = new_uid; - if (newmail->link != NULL) { + if (newmail->link != NULL && newmail->link != newmail) { /* skip processing the linked mail */ newmail->link->skip = TRUE; } From dovecot at dovecot.org Sat Feb 16 14:51:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 14:51:56 +0200 Subject: dovecot-2.2: dsync: Fixed last-common-uid lookup when local UID ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4e90a6911b26 changeset: 15779:4e90a6911b26 user: Timo Sirainen date: Sat Feb 16 14:51:50 2013 +0200 description: dsync: Fixed last-common-uid lookup when local UID was expunged but remote wasn't. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (22 lines): diff -r e49424a3b13e -r 4e90a6911b26 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 14:09:42 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 14:51:50 2013 +0200 @@ -1069,13 +1069,15 @@ return FALSE; i_assert(local_change->type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE); - if (!dsync_mail_change_guid_equals(local_change, change->guid)) { + if (dsync_mail_change_guid_equals(local_change, change->guid)) + importer->last_common_uid = change->uid; + else if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) + dsync_mailbox_common_uid_found(importer); + else { /* GUID mismatch for two expunged mails. dsync can't update GUIDs for already expunged messages, so we can't immediately determine that the rest of the messages are a mismatch. so for now we'll just skip over this pair. */ - } else { - importer->last_common_uid = change->uid; } return TRUE; } From dovecot at dovecot.org Sat Feb 16 16:44:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 16:44:24 +0200 Subject: dovecot-2.2: dsync: Don't hide the final error messages from rem... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e4aba707f867 changeset: 15780:e4aba707f867 user: Timo Sirainen date: Sat Feb 16 16:44:13 2013 +0200 description: dsync: Don't hide the final error messages from remote. diffstat: src/doveadm/dsync/doveadm-dsync.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diffs (39 lines): diff -r 4e90a6911b26 -r e4aba707f867 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Sat Feb 16 14:51:50 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Sat Feb 16 16:44:13 2013 +0200 @@ -466,22 +466,27 @@ dsync_ibc_deinit(&ibc); if (ibc2 != NULL) dsync_ibc_deinit(&ibc2); + if (ctx->fd_in != -1) { + if (ctx->fd_out != ctx->fd_in) + i_close_fd(&ctx->fd_out); + i_close_fd(&ctx->fd_in); + } + if (ctx->remote) + cmd_dsync_wait_remote(ctx, remote_errors_logged); + + /* print any final errors after the process has died. not closing + stdin/stdout before wait() may cause the process to hang, but stderr + shouldn't (at least with ssh) and we need stderr to be open to be + able to print the final errors */ if (ctx->err_stream != NULL) { - remote_error_input(ctx); /* print any pending errors */ + remote_error_input(ctx); remote_errors_logged = ctx->err_stream->v_offset > 0; i_stream_destroy(&ctx->err_stream); } if (ctx->io_err != NULL) io_remove(&ctx->io_err); - if (ctx->fd_in != -1) { - if (ctx->fd_out != ctx->fd_in) - i_close_fd(&ctx->fd_out); - i_close_fd(&ctx->fd_in); - } if (ctx->fd_err != -1) i_close_fd(&ctx->fd_err); - if (ctx->remote) - cmd_dsync_wait_remote(ctx, remote_errors_logged); return ret; } From dovecot at dovecot.org Sat Feb 16 16:47:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 16:47:46 +0200 Subject: dovecot-2.2: dsync: If unexpected changes happen during sync, re... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5a3586ffc644 changeset: 15781:5a3586ffc644 user: Timo Sirainen date: Sat Feb 16 16:45:47 2013 +0200 description: dsync: If unexpected changes happen during sync, return a safe last-common-uid for state. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r e4aba707f867 -r 5a3586ffc644 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 16:44:13 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sat Feb 16 16:45:47 2013 +0200 @@ -1819,6 +1819,11 @@ *changes_during_sync_r = TRUE; } } + if (*changes_during_sync_r) { + /* conflicting changes during sync, revert our last-common-uid + back to a safe value. */ + importer->last_common_uid = importer->local_uid_next - 1; + } return ret; } From dovecot at dovecot.org Sat Feb 16 16:47:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 16:47:46 +0200 Subject: dovecot-2.2: dsync: -l parameter locking is now done on the serv... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6f024e0289da changeset: 15782:6f024e0289da user: Timo Sirainen date: Sat Feb 16 16:47:40 2013 +0200 description: dsync: -l parameter locking is now done on the server with "lower" hostname. This allows running multi-master replication on two servers without two dsyncs mixing up changes by running at the same time. diffstat: src/doveadm/dsync/doveadm-dsync.c | 75 +--------------- src/doveadm/dsync/dsync-brain-private.h | 8 + src/doveadm/dsync/dsync-brain.c | 135 ++++++++++++++++++++++++++++--- src/doveadm/dsync/dsync-brain.h | 2 +- src/doveadm/dsync/dsync-ibc-stream.c | 22 ++++- src/doveadm/dsync/dsync-ibc.h | 4 + 6 files changed, 161 insertions(+), 85 deletions(-) diffs (truncated from 501 to 300 lines): diff -r 5a3586ffc644 -r 6f024e0289da src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Sat Feb 16 16:45:47 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Sat Feb 16 16:47:40 2013 +0200 @@ -30,7 +30,6 @@ #include #include -#define DSYNC_LOCK_FILENAME ".dovecot-sync.lock" #define DSYNC_COMMON_GETOPT_ARGS "+adEfl:m:n:r:Rs:" #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30 @@ -165,14 +164,12 @@ } static const char *const * -get_ssh_cmd_args(struct dsync_cmd_context *ctx, - const char *host, const char *login, const char *mail_user) +get_ssh_cmd_args(const char *host, const char *login, const char *mail_user) { static struct var_expand_table static_tab[] = { { 'u', NULL, "user" }, { '\0', NULL, "login" }, { '\0', NULL, "host" }, - { '\0', NULL, "lock_timeout" }, { '\0', NULL, NULL } }; struct var_expand_table *tab; @@ -186,7 +183,6 @@ tab[0].value = mail_user; tab[1].value = login; tab[2].value = host; - tab[3].value = dec2str(ctx->lock_timeout); t_array_init(&cmd_args, 8); str = t_str_new(128); @@ -255,7 +251,7 @@ /* we'll assume virtual users, so in user at host it really means not to give ssh a username, but to give dsync -u user parameter. */ - *cmd_args_r = get_ssh_cmd_args(ctx, host, "", user); + *cmd_args_r = get_ssh_cmd_args(host, "", user); return TRUE; } @@ -371,8 +367,7 @@ } static const char *const * -parse_ssh_location(struct dsync_cmd_context *ctx, - const char *location, const char *username) +parse_ssh_location(const char *location, const char *username) { const char *host, *login; @@ -383,7 +378,7 @@ host = location; login = ""; } - return get_ssh_cmd_args(ctx, host, login, username); + return get_ssh_cmd_args(host, login, username); } static struct dsync_ibc * @@ -404,8 +399,9 @@ } static int -cmd_dsync_run_real(struct dsync_cmd_context *ctx, struct mail_user *user) +cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { + struct dsync_cmd_context *ctx = (struct dsync_cmd_context *)_ctx; struct dsync_ibc *ibc, *ibc2 = NULL; struct dsync_brain *brain; struct mail_namespace *sync_ns = NULL; @@ -445,6 +441,7 @@ brain_flags |= DSYNC_BRAIN_FLAG_DEBUG; brain = dsync_brain_master_init(user, ibc, sync_ns, ctx->mailbox, ctx->sync_type, brain_flags, + ctx->lock_timeout, ctx->state_input == NULL ? "" : ctx->state_input); @@ -490,62 +487,6 @@ return ret; } -static int dsync_lock(struct mail_user *user, unsigned int lock_timeout, - const char **path_r, struct file_lock **lock_r) -{ - const char *home, *path; - int ret, fd; - - if ((ret = mail_user_get_home(user, &home)) < 0) { - i_error("Couldn't look up user's home dir"); - return -1; - } - if (ret == 0) { - i_error("User has no home directory"); - return -1; - } - - path = t_strconcat(home, "/"DSYNC_LOCK_FILENAME, NULL); - fd = creat(path, 0600); - if (fd == -1) { - i_error("Couldn't create lock %s: %m", path); - return -1; - } - - if (file_wait_lock(fd, path, F_WRLCK, FILE_LOCK_METHOD_FCNTL, - lock_timeout, lock_r) <= 0) { - i_error("Couldn't lock %s: %m", path); - (void)close(fd); - return -1; - } - *path_r = path; - return fd; -} - -static int -cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) -{ - struct dsync_cmd_context *ctx = (struct dsync_cmd_context *)_ctx; - const char *lock_path; - struct file_lock *lock; - int lock_fd, ret; - - if (!ctx->lock) - return cmd_dsync_run_real(ctx, user); - - lock_fd = dsync_lock(user, ctx->lock_timeout, &lock_path, &lock); - if (lock_fd == -1) { - _ctx->exit_code = EX_TEMPFAIL; - return -1; - } else { - ret = cmd_dsync_run_real(ctx, user); - file_lock_free(&lock); - if (close(lock_fd) < 0) - i_error("close(%s) failed: %m", lock_path); - return ret; - } -} - static int cmd_dsync_prerun(struct doveadm_mail_cmd_context *_ctx, struct mail_storage_service_user *service_user, const char **error_r) @@ -599,7 +540,7 @@ ctx->remote_name = NULL; } remote_cmd_args = ctx->remote_name == NULL ? NULL : - parse_ssh_location(ctx, ctx->remote_name, + parse_ssh_location(ctx->remote_name, _ctx->cur_username); } diff -r 5a3586ffc644 -r 6f024e0289da src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Sat Feb 16 16:45:47 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-private.h Sat Feb 16 16:47:40 2013 +0200 @@ -6,9 +6,12 @@ #include "dsync-mailbox.h" #include "dsync-mailbox-state.h" +#define DSYNC_LOCK_FILENAME ".dovecot-sync.lock" + struct dsync_mailbox_tree_sync_change; enum dsync_state { + DSYNC_STATE_MASTER_RECV_HANDSHAKE, DSYNC_STATE_SLAVE_RECV_HANDSHAKE, /* if sync_type=STATE, the master brain knows the saved "last common mailbox state". this state is sent to the slave. */ @@ -49,6 +52,11 @@ char *sync_box; enum dsync_brain_sync_type sync_type; + unsigned int lock_timeout; + int lock_fd; + const char *lock_path; + struct file_lock *lock; + char hierarchy_sep; struct dsync_mailbox_tree *local_mailbox_tree; struct dsync_mailbox_tree *remote_mailbox_tree; diff -r 5a3586ffc644 -r 6f024e0289da src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Sat Feb 16 16:45:47 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Sat Feb 16 16:47:40 2013 +0200 @@ -3,11 +3,14 @@ #include "lib.h" #include "array.h" #include "hash.h" +#include "hostpid.h" #include "mail-namespace.h" #include "dsync-mailbox-tree.h" #include "dsync-ibc.h" #include "dsync-brain-private.h" +#include + static const char *dsync_state_names[DSYNC_STATE_DONE+1] = { "recv_handshake", "send_last_common", @@ -61,6 +64,7 @@ brain->user = user; brain->ibc = ibc; brain->sync_type = DSYNC_BRAIN_SYNC_TYPE_UNKNOWN; + brain->lock_fd = -1; hash_table_create(&brain->mailbox_states, pool, 0, guid_128_hash, guid_128_cmp); p_array_init(&brain->remote_mailbox_states, pool, 64); @@ -83,7 +87,7 @@ dsync_brain_master_init(struct mail_user *user, struct dsync_ibc *ibc, struct mail_namespace *sync_ns, const char *sync_box, enum dsync_brain_sync_type sync_type, - enum dsync_brain_flags flags, + enum dsync_brain_flags flags, unsigned int lock_timeout, const char *state) { struct dsync_ibc_settings ibc_set; @@ -98,29 +102,26 @@ if (sync_ns != NULL) brain->sync_ns = sync_ns; brain->sync_box = p_strdup(brain->pool, sync_box); + brain->lock_timeout = lock_timeout; brain->master_brain = TRUE; dsync_brain_set_flags(brain, flags); - brain->state = DSYNC_STATE_SEND_MAILBOX_TREE; - if (sync_type == DSYNC_BRAIN_SYNC_TYPE_STATE) { - if (dsync_mailbox_states_import(brain->mailbox_states, - brain->pool, state, - &error) < 0) { - hash_table_clear(brain->mailbox_states, FALSE); - i_error("Saved sync state is invalid, " - "falling back to full sync: %s", error); - brain->sync_type = sync_type = - DSYNC_BRAIN_SYNC_TYPE_FULL; - } else { - brain->state = DSYNC_STATE_MASTER_SEND_LAST_COMMON; - } + if (sync_type == DSYNC_BRAIN_SYNC_TYPE_STATE && + dsync_mailbox_states_import(brain->mailbox_states, + brain->pool, state, &error) < 0) { + hash_table_clear(brain->mailbox_states, FALSE); + i_error("Saved sync state is invalid, " + "falling back to full sync: %s", error); + brain->sync_type = sync_type = DSYNC_BRAIN_SYNC_TYPE_FULL; } dsync_brain_mailbox_trees_init(brain); memset(&ibc_set, 0, sizeof(ibc_set)); + ibc_set.hostname = my_hostname; ibc_set.sync_ns_prefix = sync_ns == NULL ? NULL : sync_ns->prefix; ibc_set.sync_box = sync_box; ibc_set.sync_type = sync_type; + ibc_set.lock_timeout = lock_timeout; /* reverse the backup direction for the slave */ ibc_set.brain_flags = flags & ~(DSYNC_BRAIN_FLAG_BACKUP_SEND | DSYNC_BRAIN_FLAG_BACKUP_RECV); @@ -131,17 +132,23 @@ dsync_ibc_send_handshake(ibc, &ibc_set); dsync_ibc_set_io_callback(ibc, dsync_brain_run_io, brain); + brain->state = DSYNC_STATE_MASTER_RECV_HANDSHAKE; return brain; } struct dsync_brain * dsync_brain_slave_init(struct mail_user *user, struct dsync_ibc *ibc) { + struct dsync_ibc_settings ibc_set; struct dsync_brain *brain; brain = dsync_brain_common_init(user, ibc); brain->state = DSYNC_STATE_SLAVE_RECV_HANDSHAKE; + memset(&ibc_set, 0, sizeof(ibc_set)); + ibc_set.hostname = my_hostname; + dsync_ibc_send_handshake(ibc, &ibc_set); + dsync_ibc_set_io_callback(ibc, dsync_brain_run_io, brain); return brain; } @@ -166,11 +173,102 @@ hash_table_iterate_deinit(&brain->mailbox_states_iter); hash_table_destroy(&brain->mailbox_states); + if (brain->lock_fd != -1) { + /* unlink the lock file before it gets unlocked */ + if (unlink(brain->lock_path) < 0) + i_error("unlink(%s) failed: %m", brain->lock_path); + file_lock_free(&brain->lock); + i_close_fd(&brain->lock_fd); + } + ret = brain->failed ? -1 : 0; pool_unref(&brain->pool); return ret; } +static int +dsync_brain_lock(struct dsync_brain *brain, const char *remote_hostname) From dovecot at dovecot.org Sat Feb 16 17:17:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 17:17:24 +0200 Subject: dovecot-2.2: dsync: Merge last-common-* values from both local a... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/502a50925641 changeset: 15783:502a50925641 user: Timo Sirainen date: Sat Feb 16 17:17:14 2013 +0200 description: dsync: Merge last-common-* values from both local and remote when they differ. diffstat: src/doveadm/dsync/dsync-brain-mails.c | 21 +++++++++++++++++---- src/doveadm/dsync/dsync-ibc-stream.c | 7 ++++++- src/doveadm/dsync/dsync-mailbox-state.h | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diffs (92 lines): diff -r 6f024e0289da -r 502a50925641 src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 16:47:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mails.c Sat Feb 16 17:17:14 2013 +0200 @@ -140,7 +140,6 @@ static void dsync_brain_sync_half_finished(struct dsync_brain *brain) { struct dsync_mailbox_state state; - bool changes_during_sync; const char *error; if (brain->box_recv_state < DSYNC_BOX_STATE_RECV_LAST_COMMON || @@ -174,13 +173,14 @@ &state.last_common_uid, &state.last_common_modseq, &state.last_common_pvt_modseq, - &changes_during_sync) < 0) { + &state.changes_during_sync) < 0) { brain->failed = TRUE; return; } - if (changes_during_sync) + if (state.changes_during_sync) brain->changes_during_sync = TRUE; } + brain->mailbox_state = state; dsync_ibc_send_mailbox_state(brain->ibc, &state); } @@ -242,7 +242,20 @@ return TRUE; } i_assert(brain->box_send_state == DSYNC_BOX_STATE_DONE); - brain->mailbox_state = state; + i_assert(memcmp(state.mailbox_guid, brain->local_dsync_box.mailbox_guid, + sizeof(state.mailbox_guid)) == 0); + + /* normally the last_common_* values should be the same in local and + remote, but during unexpected changes they may differ. use the + values that are lower as the final state. */ + if (brain->mailbox_state.last_common_uid > state.last_common_uid) + brain->mailbox_state.last_common_uid = state.last_common_uid; + if (brain->mailbox_state.last_common_modseq > state.last_common_modseq) + brain->mailbox_state.last_common_modseq = state.last_common_modseq; + if (brain->mailbox_state.last_common_pvt_modseq > state.last_common_pvt_modseq) + brain->mailbox_state.last_common_pvt_modseq = state.last_common_pvt_modseq; + if (state.changes_during_sync) + brain->changes_during_sync = TRUE; dsync_brain_sync_mailbox_deinit(brain); return TRUE; diff -r 6f024e0289da -r 502a50925641 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Sat Feb 16 16:47:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Sat Feb 16 17:17:14 2013 +0200 @@ -72,7 +72,8 @@ { .name = "mailbox_state", .chr = 'S', .required_keys = "mailbox_guid last_uidvalidity last_common_uid " - "last_common_modseq last_common_pvt_modseq" + "last_common_modseq last_common_pvt_modseq", + .optional_keys = "changes_during_sync" }, { .name = "mailbox_tree_node", .chr = 'N', @@ -677,6 +678,8 @@ dec2str(state->last_common_modseq)); dsync_serializer_encode_add(encoder, "last_common_pvt_modseq", dec2str(state->last_common_pvt_modseq)); + if (state->changes_during_sync) + dsync_serializer_encode_add(encoder, "changes_during_sync", ""); dsync_serializer_encode_finish(&encoder, str); dsync_ibc_stream_send_string(ibc, str); @@ -722,6 +725,8 @@ dsync_ibc_input_error(ibc, decoder, "Invalid last_common_pvt_modseq"); return DSYNC_IBC_RECV_RET_TRYAGAIN; } + if (dsync_deserializer_decode_try(decoder, "changes_during_sync", &value)) + state_r->changes_during_sync = TRUE; return DSYNC_IBC_RECV_RET_OK; } diff -r 6f024e0289da -r 502a50925641 src/doveadm/dsync/dsync-mailbox-state.h --- a/src/doveadm/dsync/dsync-mailbox-state.h Sat Feb 16 16:47:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-state.h Sat Feb 16 17:17:14 2013 +0200 @@ -9,6 +9,7 @@ uint32_t last_common_uid; uint64_t last_common_modseq; uint64_t last_common_pvt_modseq; + bool changes_during_sync; }; ARRAY_DEFINE_TYPE(dsync_mailbox_state, struct dsync_mailbox_state); HASH_TABLE_DEFINE_TYPE(dsync_mailbox_state, uint8_t *, struct dsync_mailbox_state *); From dovecot at dovecot.org Sat Feb 16 17:33:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 17:33:34 +0200 Subject: dovecot-2.2: pop3: Code cleanup: INBOX always exists, no need to... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/928deb8a0b8c changeset: 15784:928deb8a0b8c user: Timo Sirainen date: Sat Feb 16 17:33:27 2013 +0200 description: pop3: Code cleanup: INBOX always exists, no need to check for it here. diffstat: src/pop3/pop3-client.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-) diffs (35 lines): diff -r 502a50925641 -r 928deb8a0b8c src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Sat Feb 16 17:17:14 2013 +0200 +++ b/src/pop3/pop3-client.c Sat Feb 16 17:33:27 2013 +0200 @@ -278,7 +278,6 @@ struct mail_storage_service_user *service_user, const struct pop3_settings *set) { - struct mail_namespace *ns; struct mail_storage *storage; const char *ident; struct client *client; @@ -320,20 +319,15 @@ pop3_client_count++; DLLIST_PREPEND(&pop3_clients, client); - ns = mail_namespace_find_inbox(user->namespaces); - if (ns == NULL) { - client_send_line(client, "-ERR [IN-USE] No INBOX namespace for user."); - client_destroy(client, "No INBOX namespace for user."); - return NULL; - } - client->inbox_ns = ns; + client->inbox_ns = mail_namespace_find_inbox(user->namespaces); + i_assert(client->inbox_ns != NULL); flags = MAILBOX_FLAG_POP3_SESSION; if (!set->pop3_no_flag_updates) flags |= MAILBOX_FLAG_DROP_RECENT; if (set->pop3_lock_session) flags |= MAILBOX_FLAG_KEEP_LOCKED; - client->mailbox = mailbox_alloc(ns->list, "INBOX", flags); + client->mailbox = mailbox_alloc(client->inbox_ns->list, "INBOX", flags); storage = mailbox_get_storage(client->mailbox); if (mailbox_open(client->mailbox) < 0) { errmsg = t_strdup_printf("Couldn't open INBOX: %s", From dovecot at dovecot.org Sat Feb 16 17:55:32 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 17:55:32 +0200 Subject: dovecot-2.2: pop3: Use RFC 3206 [SYS/*] and [AUTH] response codes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7e292b8352d9 changeset: 15785:7e292b8352d9 user: Timo Sirainen date: Sat Feb 16 17:54:57 2013 +0200 description: pop3: Use RFC 3206 [SYS/*] and [AUTH] response codes. diffstat: README | 23 +++++++++++++++-------- src/pop3-login/client-authenticate.c | 6 ++++++ src/pop3-login/client.c | 5 ++++- src/pop3-login/client.h | 1 + src/pop3/main.c | 6 +++--- src/pop3/pop3-capability.h | 3 ++- src/pop3/pop3-client.c | 31 ++++++++++++++++++++----------- 7 files changed, 51 insertions(+), 24 deletions(-) diffs (201 lines): diff -r 928deb8a0b8c -r 7e292b8352d9 README --- a/README Sat Feb 16 17:33:27 2013 +0200 +++ b/README Sat Feb 16 17:54:57 2013 +0200 @@ -13,22 +13,29 @@ RFCs conformed -------------- +email: 822 - Standard for ARPA Internet Text Messages 2822 - Internet Message Format (updated rfc822) 2045..2049 - Multipurpose Internet Mail Extensions (MIME) +auth: + 2245 - Anonymous SASL Mechanism. + 2595 - Using TLS with IMAP, POP3 and ACAP + 2831 - Using Digest Authentication as a SASL Mechanism (DIGEST-MD5) + 5802 - Salted Challenge Response Authentication Mechanism (SCRAM) + SASL and GSS-API Mechanisms + +POP3: + 1939 - Post Office Protocol - Version 3 + 2449 - POP3 Extension Mechanism + 3206 - The SYS and AUTH POP Response Codes + +IMAP base: 3501 - IMAP4rev1 2180 - IMAP4 Multi-Accessed Mailbox Practice 2683 - IMAP4 Implementation Recommendations - 1939 - Post Office Protocol - Version 3 - 2449 - POP3 Extension Mechanism - 2595 - Using TLS with IMAP, POP3 and ACAP - 2831 - Using Digest Authentication as a SASL Mechanism (DIGEST-MD5) - 2245 - Anonymous SASL Mechanism. - 5802 - Salted Challenge Response Authentication Mechanism (SCRAM) - SASL and GSS-API Mechanisms - +IMAP extensions: 2087 - IMAP4 QUOTA extension 2088 - IMAP4 non-synchronizing literals (LITERAL+) 2177 - IMAP4 IDLE command diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3-login/client-authenticate.c --- a/src/pop3-login/client-authenticate.c Sat Feb 16 17:33:27 2013 +0200 +++ b/src/pop3-login/client-authenticate.c Sat Feb 16 17:54:57 2013 +0200 @@ -61,6 +61,12 @@ case CLIENT_AUTH_RESULT_TEMPFAIL: client_send_reply(client, POP3_CMD_REPLY_TEMPFAIL, text); break; + case CLIENT_AUTH_RESULT_AUTHFAILED: + case CLIENT_AUTH_RESULT_AUTHFAILED_REASON: + case CLIENT_AUTH_RESULT_AUTHZFAILED: + case CLIENT_AUTH_RESULT_SSL_REQUIRED: + client_send_reply(client, POP3_CMD_REPLY_AUTH_ERROR, text); + break; default: client_send_reply(client, POP3_CMD_REPLY_ERROR, text); break; diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3-login/client.c --- a/src/pop3-login/client.c Sat Feb 16 17:33:27 2013 +0200 +++ b/src/pop3-login/client.c Sat Feb 16 17:54:57 2013 +0200 @@ -232,7 +232,10 @@ prefix = "+OK"; break; case POP3_CMD_REPLY_TEMPFAIL: - prefix = "-ERR [IN-USE]"; + prefix = "-ERR [SYS/TEMP]"; + break; + case POP3_CMD_REPLY_AUTH_ERROR: + prefix = "-ERR [AUTH]"; break; case POP3_CMD_REPLY_ERROR: break; diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3-login/client.h --- a/src/pop3-login/client.h Sat Feb 16 17:33:27 2013 +0200 +++ b/src/pop3-login/client.h Sat Feb 16 17:54:57 2013 +0200 @@ -25,6 +25,7 @@ enum pop3_cmd_reply { POP3_CMD_REPLY_OK, POP3_CMD_REPLY_ERROR, + POP3_CMD_REPLY_AUTH_ERROR, POP3_CMD_REPLY_TEMPFAIL }; diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3/main.c --- a/src/pop3/main.c Sat Feb 16 17:33:27 2013 +0200 +++ b/src/pop3/main.c Sat Feb 16 17:54:57 2013 +0200 @@ -99,7 +99,7 @@ const char **error_r) { const char *lookup_error_str = - "-ERR [IN-USE] "MAIL_ERRSTR_CRITICAL_MSG"\r\n"; + "-ERR [SYS/TEMP] "MAIL_ERRSTR_CRITICAL_MSG"\r\n"; struct mail_storage_service_user *user; struct mail_user *mail_user; struct client *client; @@ -184,7 +184,7 @@ { const char *msg; - msg = t_strdup_printf("-ERR [IN-USE] %s\r\n", errormsg); + msg = t_strdup_printf("-ERR [SYS/TEMP] %s\r\n", errormsg); if (write(client->fd, msg, strlen(msg)) < 0) { /* ignored */ } @@ -216,7 +216,7 @@ if (IS_STANDALONE() && getuid() == 0 && net_getpeername(1, NULL, NULL) == 0) { - printf("-ERR pop3 binary must not be started from " + printf("-ERR [SYS/PERM] pop3 binary must not be started from " "inetd, use pop3-login instead.\n"); return 1; } diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3/pop3-capability.h --- a/src/pop3/pop3-capability.h Sat Feb 16 17:33:27 2013 +0200 +++ b/src/pop3/pop3-capability.h Sat Feb 16 17:54:57 2013 +0200 @@ -6,7 +6,8 @@ "TOP\r\n" \ "UIDL\r\n" \ "RESP-CODES\r\n" \ - "PIPELINING\r\n" + "PIPELINING\r\n" \ + "AUTH-RESP-CODE\r\n" /* + SASL */ diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Sat Feb 16 17:33:27 2013 +0200 +++ b/src/pop3/pop3-client.c Sat Feb 16 17:54:57 2013 +0200 @@ -240,7 +240,7 @@ *error_r = "Can't sync mailbox: " "Messages keep getting expunged"; } - client_send_line(client, "-ERR [IN-USE] Couldn't sync mailbox."); + client_send_line(client, "-ERR [SYS/TEMP] Couldn't sync mailbox."); } return -1; } @@ -283,7 +283,6 @@ struct client *client; enum mailbox_flags flags; const char *errmsg; - enum mail_error error; pool_t pool; /* always use nonblocking I/O */ @@ -330,11 +329,9 @@ client->mailbox = mailbox_alloc(client->inbox_ns->list, "INBOX", flags); storage = mailbox_get_storage(client->mailbox); if (mailbox_open(client->mailbox) < 0) { - errmsg = t_strdup_printf("Couldn't open INBOX: %s", - mailbox_get_last_error(client->mailbox, - &error)); - i_error("%s", errmsg); - client_send_line(client, "-ERR [IN-USE] %s", errmsg); + i_error("Couldn't open INBOX: %s", + mailbox_get_last_error(client->mailbox, NULL)); + client_send_storage_error(client); client_destroy(client, "Couldn't open INBOX"); return NULL; } @@ -603,15 +600,27 @@ void client_send_storage_error(struct client *client) { + const char *errstr; + enum mail_error error; + if (mailbox_is_inconsistent(client->mailbox)) { - client_send_line(client, "-ERR Mailbox is in inconsistent " + client_send_line(client, "-ERR [SYS/TEMP] Mailbox is in inconsistent " "state, please relogin."); client_disconnect(client, "Mailbox is in inconsistent state."); return; } - client_send_line(client, "-ERR %s", - mailbox_get_last_error(client->mailbox, NULL)); + errstr = mailbox_get_last_error(client->mailbox, &error); + switch (error) { + case MAIL_ERROR_TEMP: + case MAIL_ERROR_NOSPACE: + case MAIL_ERROR_INUSE: + client_send_line(client, "-ERR [SYS/TEMP] %s", errstr); + break; + default: + client_send_line(client, "-ERR [SYS/PERM] %s", errstr); + break; + } } bool client_handle_input(struct client *client) @@ -731,7 +740,7 @@ while (pop3_clients != NULL) { if (pop3_clients->cmd == NULL) { client_send_line(pop3_clients, - "-ERR Server shutting down."); + "-ERR [SYS/TEMP] Server shutting down."); } client_destroy(pop3_clients, "Server shutting down."); } From dovecot at dovecot.org Sat Feb 16 17:58:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 17:58:26 +0200 Subject: dovecot-2.2: pop3: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/35194cf0693e changeset: 15786:35194cf0693e user: Timo Sirainen date: Sat Feb 16 17:58:20 2013 +0200 description: pop3: Minor code cleanup diffstat: src/pop3/main.c | 6 ++---- src/pop3/pop3-client.c | 15 ++++++++------- src/pop3/pop3-client.h | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diffs (80 lines): diff -r 7e292b8352d9 -r 35194cf0693e src/pop3/main.c --- a/src/pop3/main.c Sat Feb 16 17:54:57 2013 +0200 +++ b/src/pop3/main.c Sat Feb 16 17:58:20 2013 +0200 @@ -116,11 +116,9 @@ if (set->verbose_proctitle) verbose_proctitle = TRUE; - client = client_create(fd_in, fd_out, input->session_id, - mail_user, user, set); - if (client != NULL) T_BEGIN { + if (client_create(fd_in, fd_out, input->session_id, + mail_user, user, set, &client) == 0) client_add_input(client, input_buf); - } T_END; return 0; } diff -r 7e292b8352d9 -r 35194cf0693e src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Sat Feb 16 17:54:57 2013 +0200 +++ b/src/pop3/pop3-client.c Sat Feb 16 17:58:20 2013 +0200 @@ -273,10 +273,10 @@ return mask; } -struct client *client_create(int fd_in, int fd_out, const char *session_id, - struct mail_user *user, - struct mail_storage_service_user *service_user, - const struct pop3_settings *set) +int client_create(int fd_in, int fd_out, const char *session_id, + struct mail_user *user, + struct mail_storage_service_user *service_user, + const struct pop3_settings *set, struct client **client_r) { struct mail_storage *storage; const char *ident; @@ -333,14 +333,14 @@ mailbox_get_last_error(client->mailbox, NULL)); client_send_storage_error(client); client_destroy(client, "Couldn't open INBOX"); - return NULL; + return -1; } client->mail_set = mail_storage_get_settings(storage); if (init_mailbox(client, &errmsg) < 0) { i_error("Couldn't init INBOX: %s", errmsg); client_destroy(client, "Mailbox init failed"); - return NULL; + return -1; } client->uidl_keymask = @@ -371,7 +371,8 @@ hook_client_created(&client); pop3_refresh_proctitle(); - return client; + *client_r = client; + return 0; } static const char *client_build_uidl_change_string(struct client *client) diff -r 7e292b8352d9 -r 35194cf0693e src/pop3/pop3-client.h --- a/src/pop3/pop3-client.h Sat Feb 16 17:54:57 2013 +0200 +++ b/src/pop3/pop3-client.h Sat Feb 16 17:58:20 2013 +0200 @@ -103,10 +103,10 @@ /* Create new client with specified input/output handles. socket specifies if the handle is a socket. */ -struct client *client_create(int fd_in, int fd_out, const char *session_id, - struct mail_user *user, - struct mail_storage_service_user *service_user, - const struct pop3_settings *set); +int client_create(int fd_in, int fd_out, const char *session_id, + struct mail_user *user, + struct mail_storage_service_user *service_user, + const struct pop3_settings *set, struct client **client_r); void client_destroy(struct client *client, const char *reason) ATTR_NULL(2); /* Disconnect client connection */ From dovecot at dovecot.org Sat Feb 16 18:22:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:22:36 +0200 Subject: dovecot-2.2: pop3_lock_session: Use a separate dovecot-pop3-sess... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/473c0389eb10 changeset: 15787:473c0389eb10 user: Timo Sirainen date: Sat Feb 16 18:22:23 2013 +0200 description: pop3_lock_session: Use a separate dovecot-pop3-session.lock file instead of mailbox lock. This changes the behavior in a way that it's now possible for IMAP sessions to expunge mails during a POP3 session. But now it's no longer possible for POP3 sessions to hang new mail deliveries. diffstat: doc/example-config/conf.d/20-pop3.conf | 2 +- src/pop3/pop3-client.c | 76 +++++++++++++++++++++++++++++++-- src/pop3/pop3-client.h | 3 + 3 files changed, 74 insertions(+), 7 deletions(-) diffs (163 lines): diff -r 35194cf0693e -r 473c0389eb10 doc/example-config/conf.d/20-pop3.conf --- a/doc/example-config/conf.d/20-pop3.conf Sat Feb 16 17:58:20 2013 +0200 +++ b/doc/example-config/conf.d/20-pop3.conf Sat Feb 16 18:22:23 2013 +0200 @@ -16,7 +16,7 @@ # If mail has X-UIDL header, use it as the mail's UIDL. #pop3_reuse_xuidl = no - # Keep the mailbox locked for the entire POP3 session. + # Allow only one POP3 session to run simultaneously for the same user. #pop3_lock_session = no # POP3 requires message sizes to be listed as if they had CR+LF linefeeds. diff -r 35194cf0693e -r 473c0389eb10 src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Sat Feb 16 17:58:20 2013 +0200 +++ b/src/pop3/pop3-client.c Sat Feb 16 18:22:23 2013 +0200 @@ -10,6 +10,7 @@ #include "str.h" #include "llist.h" #include "hostpid.h" +#include "file-dotlock.h" #include "var-expand.h" #include "master-service.h" #include "mail-storage.h" @@ -37,6 +38,9 @@ transaction. This allows the mailbox to become unlocked. */ #define CLIENT_COMMIT_TIMEOUT_MSECS (10*1000) +#define POP3_LOCK_FNAME "dovecot-pop3-session.lock" +#define POP3_SESSION_DOTLOCK_STALE_TIMEOUT_SECS (60*5) + extern struct pop3_client_vfuncs pop3_client_vfuncs; struct pop3_module_register pop3_module_register = { 0 }; @@ -49,6 +53,13 @@ MAIL_SORT_END }; +static const struct dotlock_settings session_dotlock_set = { + .timeout = 10, + .stale_timeout = POP3_SESSION_DOTLOCK_STALE_TIMEOUT_SECS, + .lock_suffix = "", + .use_io_notify = TRUE +}; + static void client_input(struct client *client); static int client_output(struct client *client); @@ -273,6 +284,49 @@ return mask; } +static void pop3_lock_session_refresh(struct client *client) +{ + if (file_dotlock_touch(client->session_dotlock) < 0) { + client_send_line(client, + "-ERR [SYS/TEMP] Couldn't update POP3 session lock."); + client_destroy(client, "Couldn't lock POP3 session"); + } +} + +static int pop3_lock_session(struct client *client) +{ + const struct mail_storage_settings *mail_set = + mail_storage_service_user_get_mail_set(client->service_user); + struct dotlock_settings dotlock_set; + const char *dir, *path; + int ret; + + if (!mailbox_list_get_root_path(client->inbox_ns->list, + MAILBOX_LIST_PATH_TYPE_DIR, &dir) && + !mailbox_list_get_root_path(client->inbox_ns->list, + MAILBOX_LIST_PATH_TYPE_INDEX, &dir)) { + i_error("pop3_lock_session: Storage has no root/index directory, " + "can't create a POP3 session lock file"); + return -1; + } + path = t_strdup_printf("%s/"POP3_LOCK_FNAME, dir); + + dotlock_set = session_dotlock_set; + dotlock_set.use_excl_lock = mail_set->dotlock_use_excl; + dotlock_set.nfs_flush = mail_set->mail_nfs_storage; + + ret = file_dotlock_create(&dotlock_set, path, 0, + &client->session_dotlock); + if (ret < 0) + i_error("file_dotlock_create(%s) failed: %m", path); + else if (ret > 0) { + client->to_session_dotlock_refresh = + timeout_add(POP3_SESSION_DOTLOCK_STALE_TIMEOUT_SECS*1000, + pop3_lock_session_refresh, client); + } + return ret; +} + int client_create(int fd_in, int fd_out, const char *session_id, struct mail_user *user, struct mail_storage_service_user *service_user, @@ -284,6 +338,7 @@ enum mailbox_flags flags; const char *errmsg; pool_t pool; + int ret; /* always use nonblocking I/O */ net_set_nonblock(fd_in, TRUE); @@ -308,10 +363,8 @@ client->last_input = ioloop_time; client->to_idle = timeout_add(CLIENT_IDLE_TIMEOUT_MSECS, client_idle_timeout, client); - if (!set->pop3_lock_session) { - client->to_commit = timeout_add(CLIENT_COMMIT_TIMEOUT_MSECS, - client_commit_timeout, client); - } + client->to_commit = timeout_add(CLIENT_COMMIT_TIMEOUT_MSECS, + client_commit_timeout, client); client->user = user; @@ -321,11 +374,17 @@ client->inbox_ns = mail_namespace_find_inbox(user->namespaces); i_assert(client->inbox_ns != NULL); + if (set->pop3_lock_session && (ret = pop3_lock_session(client)) <= 0) { + client_send_line(client, ret < 0 ? + "-ERR [SYS/TEMP] Failed to create POP3 session lock." : + "-ERR [IN-USE] Mailbox is locked by another POP3 session."); + client_destroy(client, "Couldn't lock POP3 session"); + return -1; + } + flags = MAILBOX_FLAG_POP3_SESSION; if (!set->pop3_no_flag_updates) flags |= MAILBOX_FLAG_DROP_RECENT; - if (set->pop3_lock_session) - flags |= MAILBOX_FLAG_KEEP_LOCKED; client->mailbox = mailbox_alloc(client->inbox_ns->list, "INBOX", flags); storage = mailbox_get_storage(client->mailbox); if (mailbox_open(client->mailbox) < 0) { @@ -508,6 +567,11 @@ } mail_user_unref(&client->user); + if (client->session_dotlock != NULL) + file_dotlock_delete(&client->session_dotlock); + if (client->to_session_dotlock_refresh != NULL) + timeout_remove(&client->to_session_dotlock_refresh); + if (client->uidl_pool != NULL) pool_unref(&client->uidl_pool); i_free(client->message_sizes); diff -r 35194cf0693e -r 473c0389eb10 src/pop3/pop3-client.h --- a/src/pop3/pop3-client.h Sat Feb 16 17:58:20 2013 +0200 +++ b/src/pop3/pop3-client.h Sat Feb 16 18:22:23 2013 +0200 @@ -45,6 +45,9 @@ struct mailbox *mailbox; struct mailbox_transaction_context *trans; + struct timeout *to_session_dotlock_refresh; + struct dotlock *session_dotlock; + time_t last_input, last_output; unsigned int bad_counter; unsigned int highest_expunged_fetch_msgnum; From dovecot at dovecot.org Sat Feb 16 18:24:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:24:42 +0200 Subject: dovecot-2.2: NEWS file updated. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/890b5b52ffd0 changeset: 15788:890b5b52ffd0 user: Timo Sirainen date: Sat Feb 16 18:24:28 2013 +0200 description: NEWS file updated. diffstat: NEWS | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (19 lines): diff -r 473c0389eb10 -r 890b5b52ffd0 NEWS --- a/NEWS Sat Feb 16 18:22:23 2013 +0200 +++ b/NEWS Sat Feb 16 18:24:28 2013 +0200 @@ -1,4 +1,4 @@ -v2.2.UNSTABLE 2012-xx-xx Timo Sirainen +v2.2.UNSTABLE 2013-xx-xx Timo Sirainen * When creating home directories, the permissions are copied from the parent directory if it has setgid-bit set. For full details, see @@ -11,6 +11,9 @@ * LDA/LMTP: If saving a mail brings user from under quota to over quota, allow it based on quota_grace setting (default: 10% above quota limit). + * pop3_lock_session=yes now uses a POP3-only dovecot-pop3-session.lock + file instead of actually locking the mailbox (and causing + IMAP/LDA/LMTP to wait for the POP3 session to close). + Implemented IMAP MOVE and BINARY extensions + Implemented IMAP CATENATE, URLAUTH and URLAUTH=BINARY extensions From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: doveadm acl: Added "recalc" command to rebuild acl_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6bee6d0c611f changeset: 15789:6bee6d0c611f user: Timo Sirainen date: Mon Jan 14 13:01:33 2013 +0200 description: doveadm acl: Added "recalc" command to rebuild acl_lookup_dict for the user. diffstat: src/plugins/acl/doveadm-acl.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diffs (46 lines): diff -r 1ab8e0e699f7 -r 6bee6d0c611f src/plugins/acl/doveadm-acl.c --- a/src/plugins/acl/doveadm-acl.c Wed Jan 09 07:01:41 2013 +0200 +++ b/src/plugins/acl/doveadm-acl.c Mon Jan 14 13:01:33 2013 +0200 @@ -399,6 +399,34 @@ } static int +cmd_acl_recalc_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) +{ + struct acl_user *auser = ACL_USER_CONTEXT(user); + + if (auser == NULL) { + i_error("ACL not enabled for %s", user->username); + doveadm_mail_failed_error(ctx, MAIL_ERROR_NOTFOUND); + return -1; + } + if (acl_lookup_dict_rebuild(auser->acl_lookup_dict) < 0) { + i_error("Failed to recalculate ACL dicts"); + doveadm_mail_failed_error(ctx, MAIL_ERROR_TEMP); + return -1; + } + return 0; +} + +static struct doveadm_mail_cmd_context * +cmd_acl_recalc_alloc(void) +{ + struct doveadm_mail_cmd_context *ctx; + + ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); + ctx->v.run = cmd_acl_recalc_run; + return ctx; +} + +static int cmd_acl_debug_mailbox_open(struct doveadm_mail_cmd_context *ctx, struct mail_user *user, const char *mailbox, struct mailbox **box_r) @@ -591,6 +619,7 @@ { cmd_acl_add_alloc, "acl add", " [ ...]" }, { cmd_acl_remove_alloc, "acl remove", " [ ...]" }, { cmd_acl_delete_alloc, "acl delete", " " }, + { cmd_acl_recalc_alloc, "acl recalc", "" }, { cmd_acl_debug_alloc, "acl debug", "" } }; From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: buffer: Always keep +1 byte available for str_c()'s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c762a9af72c1 changeset: 15790:c762a9af72c1 user: Timo Sirainen date: Tue Jan 15 08:30:03 2013 +0200 description: buffer: Always keep +1 byte available for str_c()'s NUL. diffstat: src/lib/Makefile.am | 1 + src/lib/buffer.c | 11 +++++++++-- src/lib/str.c | 3 --- src/lib/test-lib.c | 1 + src/lib/test-lib.h | 1 + src/lib/test-str.c | 26 ++++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 5 deletions(-) diffs (111 lines): diff -r 6bee6d0c611f -r c762a9af72c1 src/lib/Makefile.am --- a/src/lib/Makefile.am Mon Jan 14 13:01:33 2013 +0200 +++ b/src/lib/Makefile.am Tue Jan 15 08:30:03 2013 +0200 @@ -268,6 +268,7 @@ test-primes.c \ test-priorityq.c \ test-seq-range-array.c \ + test-str.c \ test-strescape.c \ test-strfuncs.c \ test-str-find.c \ diff -r 6bee6d0c611f -r c762a9af72c1 src/lib/buffer.c --- a/src/lib/buffer.c Mon Jan 14 13:01:33 2013 +0200 +++ b/src/lib/buffer.c Tue Jan 15 08:30:03 2013 +0200 @@ -39,6 +39,7 @@ static inline void buffer_check_limits(struct real_buffer *buf, size_t pos, size_t data_size) { + unsigned int extra; size_t new_size; if (unlikely((size_t)-1 - pos < data_size)) { @@ -53,7 +54,13 @@ memset(buf->w_buffer + buf->used, 0, max - buf->used); } - if (new_size > buf->alloc) { + + /* always keep +1 byte allocated available in case str_c() is called + for this buffer. this is mainly for cases where the buffer is + allocated from data stack, and str_c() is called in a separate stack + frame. */ + extra = buf->dynamic ? 1 : 0; + if (new_size + extra > buf->alloc) { if (unlikely(!buf->dynamic)) { i_panic("Buffer full (%"PRIuSIZE_T" > %"PRIuSIZE_T", " "pool %s)", pos + data_size, buf->alloc, @@ -62,7 +69,7 @@ } buffer_alloc(buf, pool_get_exp_grown_size(buf->pool, buf->alloc, - new_size)); + new_size + extra)); } #if 0 else if (new_size > buf->used && buf->alloced && diff -r 6bee6d0c611f -r c762a9af72c1 src/lib/str.c --- a/src/lib/str.c Mon Jan 14 13:01:33 2013 +0200 +++ b/src/lib/str.c Tue Jan 15 08:30:03 2013 +0200 @@ -45,9 +45,6 @@ size_t len = str_len(str); size_t alloc = buffer_get_size(str); -#ifdef DEBUG - buffer_verify_pool(str); -#endif if (len == alloc || data[len] != '\0') { buffer_write(str, len, "", 1); /* remove the \0 - we don't want to keep it */ diff -r 6bee6d0c611f -r c762a9af72c1 src/lib/test-lib.c --- a/src/lib/test-lib.c Mon Jan 14 13:01:33 2013 +0200 +++ b/src/lib/test-lib.c Tue Jan 15 08:30:03 2013 +0200 @@ -25,6 +25,7 @@ test_primes, test_priorityq, test_seq_range_array, + test_str, test_strescape, test_strfuncs, test_str_find, diff -r 6bee6d0c611f -r c762a9af72c1 src/lib/test-lib.h --- a/src/lib/test-lib.h Mon Jan 14 13:01:33 2013 +0200 +++ b/src/lib/test-lib.h Tue Jan 15 08:30:03 2013 +0200 @@ -24,6 +24,7 @@ void test_primes(void); void test_priorityq(void); void test_seq_range_array(void); +void test_str(void); void test_strescape(void); void test_strfuncs(void); void test_str_find(void); diff -r 6bee6d0c611f -r c762a9af72c1 src/lib/test-str.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/test-str.c Tue Jan 15 08:30:03 2013 +0200 @@ -0,0 +1,26 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "test-lib.h" +#include "str.h" + +static void test_str_c(void) +{ + string_t *str; + unsigned int i, j; + + test_begin("str_c()"); + for (i = 0; i < 32; i++) T_BEGIN { + str = t_str_new(15); + for (j = 0; j < i; j++) + str_append_c(str, 'x'); + T_BEGIN { + (void)str_c(str); + } T_END; + } T_END; + test_end(); +} + +void test_str(void) +{ + test_str_c(); +} From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: lib-storage: Catch input stream errors when parsing... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2b76d357a56a changeset: 15791:2b76d357a56a user: Timo Sirainen date: Tue Jan 22 16:31:17 2013 +0200 description: lib-storage: Catch input stream errors when parsing mail. diffstat: src/lib-storage/index/index-mail-headers.c | 6 ++++- src/lib-storage/index/index-mail.c | 34 ++++++++++++++++++++++++++--- src/lib-storage/index/index-mail.h | 1 + 3 files changed, 36 insertions(+), 5 deletions(-) diffs (91 lines): diff -r c762a9af72c1 -r 2b76d357a56a src/lib-storage/index/index-mail-headers.c --- a/src/lib-storage/index/index-mail-headers.c Tue Jan 15 08:30:03 2013 +0200 +++ b/src/lib-storage/index/index-mail-headers.c Tue Jan 22 16:31:17 2013 +0200 @@ -374,6 +374,7 @@ input2 = tee_i_stream_create_child(mail->data.tee_stream); index_mail_parse_header_init(mail, NULL); + mail->data.parser_input = input; mail->data.parser_ctx = message_parser_init(mail->data_pool, input, hdr_parser_flags, msg_parser_flags); @@ -386,10 +387,13 @@ struct index_mail_data *data = &mail->data; struct message_part *parts; - if (data->parser_ctx != NULL) + if (data->parser_ctx != NULL) { + data->parser_input = NULL; (void)message_parser_deinit(&data->parser_ctx, &parts); + } if (data->parts == NULL) { + data->parser_input = data->stream; data->parser_ctx = message_parser_init(mail->data_pool, data->stream, hdr_parser_flags, diff -r c762a9af72c1 -r 2b76d357a56a src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Tue Jan 15 08:30:03 2013 +0200 +++ b/src/lib-storage/index/index-mail.c Tue Jan 22 16:31:17 2013 +0200 @@ -751,13 +751,38 @@ static int index_mail_parse_body_finish(struct index_mail *mail, enum index_cache_field field) { - if (message_parser_deinit(&mail->data.parser_ctx, - &mail->data.parts) < 0) { - mail_set_cache_corrupted(&mail->mail.mail, - MAIL_FETCH_MESSAGE_PARTS); + struct istream *parser_input = mail->data.parser_input; + int ret; + + if (parser_input == NULL) { + ret = message_parser_deinit(&mail->data.parser_ctx, + &mail->data.parts) < 0 ? 0 : 1; + } else { + mail->data.parser_input = NULL; + i_stream_ref(parser_input); + ret = message_parser_deinit(&mail->data.parser_ctx, + &mail->data.parts) < 0 ? 0 : 1; + if (parser_input->stream_errno != 0) { + errno = parser_input->stream_errno; + mail_storage_set_critical(mail->mail.mail.box->storage, + "read(%s) failed: %m", + i_stream_get_name(parser_input)); + ret = -1; + } + i_assert(i_stream_read(parser_input) == -1 && + !i_stream_have_bytes_left(parser_input)); + i_stream_unref(&parser_input); + } + if (ret <= 0) { + if (ret == 0) { + mail_set_cache_corrupted(&mail->mail.mail, + MAIL_FETCH_MESSAGE_PARTS); + } + mail->data.parts = NULL; mail->data.parsed_bodystructure = FALSE; return -1; } + if (mail->data.no_caching) { /* if we're here because we aborted parsing, don't get any further or we may crash while generating output from @@ -1150,6 +1175,7 @@ mail_set_cache_corrupted(&mail->mail.mail, MAIL_FETCH_MESSAGE_PARTS); } + mail->data.parser_input = NULL; } if (data->filter_stream != NULL) i_stream_unref(&data->filter_stream); diff -r c762a9af72c1 -r 2b76d357a56a src/lib-storage/index/index-mail.h --- a/src/lib-storage/index/index-mail.h Tue Jan 15 08:30:03 2013 +0200 +++ b/src/lib-storage/index/index-mail.h Tue Jan 22 16:31:17 2013 +0200 @@ -96,6 +96,7 @@ struct istream *stream, *filter_stream; struct tee_istream *tee_stream; struct message_size hdr_size, body_size; + struct istream *parser_input; struct message_parser_ctx *parser_ctx; int parsing_count; ARRAY_TYPE(keywords) keywords; From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: lib-index: Fixes to handling broken cache records t... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/99b7be36631b changeset: 15792:99b7be36631b user: Timo Sirainen date: Tue Jan 22 16:53:52 2013 +0200 description: lib-index: Fixes to handling broken cache records that point outside file. Especially try to avoid failing by trying to allocate gigabytes of memory. diffstat: src/lib-index/mail-cache-lookup.c | 13 ++++++------- src/lib-index/mail-cache.c | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-) diffs (76 lines): diff -r 2b76d357a56a -r 99b7be36631b src/lib-index/mail-cache-lookup.c --- a/src/lib-index/mail-cache-lookup.c Tue Jan 22 16:31:17 2013 +0200 +++ b/src/lib-index/mail-cache-lookup.c Tue Jan 22 16:53:52 2013 +0200 @@ -15,6 +15,7 @@ { const struct mail_cache_record *rec; const void *data; + int ret; i_assert(offset != 0); @@ -41,17 +42,15 @@ } if (rec->size > CACHE_PREFETCH) { /* larger than we guessed. map the rest of the record. */ - if (mail_cache_map(cache, offset, rec->size, &data) < 0) + if ((ret = mail_cache_map(cache, offset, rec->size, &data)) < 0) return -1; + if (ret == 0) { + mail_cache_set_corrupted(cache, "record points outside file"); + return -1; + } rec = data; } - if (rec->size > cache->mmap_length || - offset + rec->size > cache->mmap_length) { - mail_cache_set_corrupted(cache, "record points outside file"); - return -1; - } - *rec_r = rec; return 0; } diff -r 2b76d357a56a -r 99b7be36631b src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Tue Jan 22 16:31:17 2013 +0200 +++ b/src/lib-index/mail-cache.c Tue Jan 22 16:53:52 2013 +0200 @@ -357,12 +357,28 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size, const void **data_r) { + struct stat st; const void *data; ssize_t ret; if (size == 0) size = sizeof(struct mail_cache_header); + /* verify offset + size before trying to allocate a huge amount of + memory due to them. note that we may be prefetching more than we + actually need, so don't fail too early. */ + if (size > cache->mmap_length || offset + size > cache->mmap_length) { + if (fstat(cache->fd, &st) < 0) { + i_error("fstat(%s) failed: %m", cache->filepath); + return -1; + } + if (offset >= (uoff_t)st.st_size) { + *data_r = NULL; + return 0; + } + size = st.st_size - offset; + } + cache->remap_counter++; if (cache->map_with_read) return mail_cache_map_with_read(cache, offset, size, data_r); @@ -451,8 +467,7 @@ mail_cache_init_file_cache(cache); - if (mail_cache_map(cache, 0, sizeof(struct mail_cache_header), - &data) < 0) + if (mail_cache_map(cache, 0, 0, &data) < 0) return -1; return 1; } From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: lib-index: Fixed invalidating buffered cache file w... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0b0399f1b6aa changeset: 15793:0b0399f1b6aa user: Timo Sirainen date: Tue Jan 29 17:55:20 2013 +0200 description: lib-index: Fixed invalidating buffered cache file with map_with_read. diffstat: src/lib-index/mail-cache-fields.c | 2 ++ src/lib-index/mail-cache-sync-update.c | 5 +++++ src/lib-index/mail-cache.c | 2 ++ 3 files changed, 9 insertions(+), 0 deletions(-) diffs (51 lines): diff -r 99b7be36631b -r 0b0399f1b6aa src/lib-index/mail-cache-fields.c --- a/src/lib-index/mail-cache-fields.c Tue Jan 22 16:53:52 2013 +0200 +++ b/src/lib-index/mail-cache-fields.c Tue Jan 29 17:55:20 2013 +0200 @@ -285,6 +285,8 @@ file_cache_invalidate(cache->file_cache, offset, field_hdr_size); } + if (cache->read_buf != NULL && invalidate) + buffer_set_used_size(cache->read_buf, 0); ret = mail_cache_map(cache, offset, field_hdr_size, &data); if (ret < 0) return -1; diff -r 99b7be36631b -r 0b0399f1b6aa src/lib-index/mail-cache-sync-update.c --- a/src/lib-index/mail-cache-sync-update.c Tue Jan 22 16:53:52 2013 +0200 +++ b/src/lib-index/mail-cache-sync-update.c Tue Jan 29 17:55:20 2013 +0200 @@ -1,6 +1,7 @@ /* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "buffer.h" #include "file-cache.h" #include "mail-cache-private.h" #include "mail-index-view-private.h" @@ -144,6 +145,8 @@ ctx->invalidate_highwater - *new_cache_offset); ctx->invalidate_highwater = *new_cache_offset; + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); } } @@ -188,4 +191,6 @@ cache->fd, cache->locked); } file_cache_invalidate(cache->file_cache, 0, (uoff_t)-1); + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); } diff -r 99b7be36631b -r 0b0399f1b6aa src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Tue Jan 22 16:53:52 2013 +0200 +++ b/src/lib-index/mail-cache.c Tue Jan 29 17:55:20 2013 +0200 @@ -705,6 +705,8 @@ file_cache_invalidate(cache->file_cache, 0, sizeof(struct mail_cache_header)); } + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); if (mail_cache_map(cache, 0, 0, &data) > 0) cache->hdr_copy = *cache->hdr; else { From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: Released v2.1.14. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b314c97d4bbf changeset: 15794:b314c97d4bbf user: Timo Sirainen date: Wed Jan 30 23:45:06 2013 +0200 description: Released v2.1.14. diffstat: NEWS | 8 ++++++++ configure.in | 2 +- 2 files changed, 9 insertions(+), 1 deletions(-) diffs (25 lines): diff -r 0b0399f1b6aa -r b314c97d4bbf NEWS --- a/NEWS Tue Jan 29 17:55:20 2013 +0200 +++ b/NEWS Wed Jan 30 23:45:06 2013 +0200 @@ -1,3 +1,11 @@ +v2.1.14 2013-01-30 Timo Sirainen + + + doveadm acl recalc command added + - v2.1.11+ had a race condition where it sometimes overwrote data in + dovecot.index.cache file. This could have caused Dovecot to return + the same cached data to two different messages. + - mdbox: Fixes to handling duplicate GUIDs during index rebuild + v2.1.13 2013-01-06 Timo Sirainen - Some fixes to cache file changes in v2.1.11. diff -r 0b0399f1b6aa -r b314c97d4bbf configure.in --- a/configure.in Tue Jan 29 17:55:20 2013 +0200 +++ b/configure.in Wed Jan 30 23:45:06 2013 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.13],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.14],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: Added tag 2.1.14 for changeset b314c97d4bbf Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/49e85db52ae4 changeset: 15795:49e85db52ae4 user: Timo Sirainen date: Wed Jan 30 23:45:06 2013 +0200 description: Added tag 2.1.14 for changeset b314c97d4bbf diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r b314c97d4bbf -r 49e85db52ae4 .hgtags --- a/.hgtags Wed Jan 30 23:45:06 2013 +0200 +++ b/.hgtags Wed Jan 30 23:45:06 2013 +0200 @@ -90,3 +90,4 @@ 741d800a192fa23572bb14196df2a8917cf20614 2.1.11 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 2.1.12 cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 2.1.13 +b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14 From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: Added signature for changeset b314c97d4bbf Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/57eb9a6ac6c0 changeset: 15796:57eb9a6ac6c0 user: Timo Sirainen date: Wed Jan 30 23:45:10 2013 +0200 description: Added signature for changeset b314c97d4bbf diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 49e85db52ae4 -r 57eb9a6ac6c0 .hgsigs --- a/.hgsigs Wed Jan 30 23:45:06 2013 +0200 +++ b/.hgsigs Wed Jan 30 23:45:10 2013 +0200 @@ -53,3 +53,4 @@ 741d800a192fa23572bb14196df2a8917cf20614 0 iEYEABECAAYFAlC3A5EACgkQyUhSUUBVisnmlACcCm6jc7NRoTkBtrJLcz+P325U1xcAn2+0eghqEMiP+rzRJC55oQxV00Zy 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 0 iEYEABECAAYFAlC4WKwACgkQyUhSUUBViskaOACgmcwWV8hgsCOWvkbdh0OIw1ImSQYAn1RcTL0CG3M8+XG7QrrxSfQ7+V99 cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 0 iEYEABECAAYFAlDqjXUACgkQyUhSUUBViskUEwCfYTWHeDmPr8HfxSBQN17SD5IwDygAnROhb3IVTm9niDun4gxPxbHLo/Pe +b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: auth: Removed assert-checks, allowing plugins to se... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5751963a3be8 changeset: 15797:5751963a3be8 user: Timo Sirainen date: Thu Jan 31 00:27:17 2013 +0200 description: auth: Removed assert-checks, allowing plugins to set skip_password_check. diffstat: src/auth/auth-request.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diffs (24 lines): diff -r 57eb9a6ac6c0 -r 5751963a3be8 src/auth/auth-request.c --- a/src/auth/auth-request.c Wed Jan 30 23:45:10 2013 +0200 +++ b/src/auth/auth-request.c Thu Jan 31 00:27:17 2013 +0200 @@ -291,10 +291,9 @@ request->no_login = TRUE; else if (strcmp(key, "successful") == 0) request->successful = TRUE; - else if (strcmp(key, "skip_password_check") == 0) { - i_assert(request->master_user != NULL); + else if (strcmp(key, "skip_password_check") == 0) request->skip_password_check = TRUE; - } else if (strcmp(key, "mech") == 0) + else if (strcmp(key, "mech") == 0) request->mech_name = p_strdup(request->pool, value); else return FALSE; @@ -1705,7 +1704,6 @@ if (request->skip_password_check) { /* currently this can happen only with master logins */ - i_assert(request->master_user != NULL); return 1; } From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: iostream-rawlog: Ignore 0 byte writes instead of as... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f35a8649634c changeset: 15798:f35a8649634c user: Timo Sirainen date: Thu Jan 31 18:17:10 2013 +0200 description: iostream-rawlog: Ignore 0 byte writes instead of assert-crashing. diffstat: src/lib/iostream-rawlog.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 5751963a3be8 -r f35a8649634c src/lib/iostream-rawlog.c --- a/src/lib/iostream-rawlog.c Thu Jan 31 00:27:17 2013 +0200 +++ b/src/lib/iostream-rawlog.c Thu Jan 31 18:17:10 2013 +0200 @@ -44,7 +44,8 @@ { size_t i, start; - i_assert(size > 0); + if (size == 0) + return; io_loop_time_refresh(); if (rstream->write_timestamp) From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: lib-ssl-iostream: Pass the plain istream's fd to ss... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/bf80034a547d changeset: 15799:bf80034a547d user: Timo Sirainen date: Thu Jan 31 18:27:22 2013 +0200 description: lib-ssl-iostream: Pass the plain istream's fd to ssl_istream. diffstat: src/lib-ssl-iostream/istream-openssl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (11 lines): diff -r f35a8649634c -r bf80034a547d src/lib-ssl-iostream/istream-openssl.c --- a/src/lib-ssl-iostream/istream-openssl.c Thu Jan 31 18:17:10 2013 +0200 +++ b/src/lib-ssl-iostream/istream-openssl.c Thu Jan 31 18:27:22 2013 +0200 @@ -82,5 +82,6 @@ sstream->istream.read = i_stream_ssl_read; sstream->istream.istream.readable_fd = FALSE; - return i_stream_create(&sstream->istream, NULL, -1); + return i_stream_create(&sstream->istream, NULL, + i_stream_get_fd(ssl_io->plain_input)); } From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: dbox: Fail if trying to create a mailbox that alrea... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/004b69090776 changeset: 15800:004b69090776 user: Timo Sirainen date: Sat Feb 02 00:31:44 2013 +0200 description: dbox: Fail if trying to create a mailbox that already exists. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (16 lines): diff -r bf80034a547d -r 004b69090776 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Thu Jan 31 18:27:22 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Sat Feb 02 00:31:44 2013 +0200 @@ -254,6 +254,12 @@ if (mailbox_open(box) < 0) return -1; + if (mail_index_get_header(box->view)->uid_validity != 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "Mailbox already exists"); + return -1; + } + /* if alt path already exists and contains files, rebuild storage so that we don't start overwriting files. */ alt_path = mailbox_list_get_path(box->list, box->name, From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: i_stream_close(): Set stream_errno to EPIPE instead... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/93633121bc9d changeset: 15801:93633121bc9d user: Timo Sirainen date: Mon Feb 04 15:59:12 2013 +0200 description: i_stream_close(): Set stream_errno to EPIPE instead of ENOENT. diffstat: src/lib/istream.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 004b69090776 -r 93633121bc9d src/lib/istream.c --- a/src/lib/istream.c Sat Feb 02 00:31:44 2013 +0200 +++ b/src/lib/istream.c Mon Feb 04 15:59:12 2013 +0200 @@ -75,7 +75,7 @@ stream->closed = TRUE; if (stream->stream_errno == 0) - stream->stream_errno = ENOENT; + stream->stream_errno = EPIPE; } void i_stream_set_init_buffer_size(struct istream *stream, size_t size) From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: istream-tee: Copy the parent stream's name to child... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/eb117a619075 changeset: 15802:eb117a619075 user: Timo Sirainen date: Mon Feb 04 15:59:50 2013 +0200 description: istream-tee: Copy the parent stream's name to child streams. diffstat: src/lib/istream-tee.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 93633121bc9d -r eb117a619075 src/lib/istream-tee.c --- a/src/lib/istream-tee.c Mon Feb 04 15:59:12 2013 +0200 +++ b/src/lib/istream-tee.c Mon Feb 04 15:59:50 2013 +0200 @@ -223,6 +223,7 @@ tee->children = tstream; ret = i_stream_create(&tstream->istream, input, i_stream_get_fd(input)); + i_stream_set_name(&tstream->istream.istream, i_stream_get_name(input)); /* we keep the reference in tee stream, no need for extra references */ i_stream_unref(&input); return ret; From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: lib-storage: If message parser's input stream is cl... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b15a98fd8e15 changeset: 15804:b15a98fd8e15 user: Timo Sirainen date: Mon Feb 04 16:10:50 2013 +0200 description: lib-storage: If message parser's input stream is closed early, don't treat it as error. This seems to happen sometimes during message saving(?), although I'm not exactly sure why. In any case it shouldn't log an error about it. This behavior is probably better than failing. The caller should be the one to figure out if saving has failed or not. diffstat: src/lib-storage/index/index-mail.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diffs (29 lines): diff -r 23fb615c3628 -r b15a98fd8e15 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Mon Feb 04 16:03:54 2013 +0200 +++ b/src/lib-storage/index/index-mail.c Mon Feb 04 16:10:50 2013 +0200 @@ -762,15 +762,20 @@ i_stream_ref(parser_input); ret = message_parser_deinit(&mail->data.parser_ctx, &mail->data.parts) < 0 ? 0 : 1; - if (parser_input->stream_errno != 0) { + if (parser_input->stream_errno == 0 || + parser_input->stream_errno == EPIPE) { + /* EPIPE = input already closed. allow the caller to + decide if that is an error or not. */ + i_assert(i_stream_read(parser_input) == -1 && + !i_stream_have_bytes_left(parser_input)); + } else { errno = parser_input->stream_errno; mail_storage_set_critical(mail->mail.mail.box->storage, - "read(%s) failed: %m", - i_stream_get_name(parser_input)); + "mail parser: read(%s, box=%s) failed: %m", + i_stream_get_name(parser_input), + mail->mail.mail.box->vname); ret = -1; } - i_assert(i_stream_read(parser_input) == -1 && - !i_stream_have_bytes_left(parser_input)); i_stream_unref(&parser_input); } if (ret <= 0) { From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: imap: Set [io]stream name for imap client connections. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/23fb615c3628 changeset: 15803:23fb615c3628 user: Timo Sirainen date: Mon Feb 04 16:03:54 2013 +0200 description: imap: Set [io]stream name for imap client connections. diffstat: src/imap/imap-client.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r eb117a619075 -r 23fb615c3628 src/imap/imap-client.c --- a/src/imap/imap-client.c Mon Feb 04 15:59:50 2013 +0200 +++ b/src/imap/imap-client.c Mon Feb 04 16:03:54 2013 +0200 @@ -56,6 +56,8 @@ client->input = i_stream_create_fd(fd_in, set->imap_max_line_length, FALSE); client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE); + i_stream_set_name(client->input, ""); + o_stream_set_name(client->output, ""); o_stream_set_flush_callback(client->output, client_output, client); From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: lib-index: Bug in cache file size verification caus... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/443ff272317f changeset: 15805:443ff272317f user: Timo Sirainen date: Mon Feb 04 17:06:40 2013 +0200 description: lib-index: Bug in cache file size verification caused the whole cache file to be mapped. diffstat: src/lib-index/mail-cache.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (23 lines): diff -r b15a98fd8e15 -r 443ff272317f src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Mon Feb 04 16:10:50 2013 +0200 +++ b/src/lib-index/mail-cache.c Mon Feb 04 17:06:40 2013 +0200 @@ -367,7 +367,8 @@ /* verify offset + size before trying to allocate a huge amount of memory due to them. note that we may be prefetching more than we actually need, so don't fail too early. */ - if (size > cache->mmap_length || offset + size > cache->mmap_length) { + if ((size > cache->mmap_length || offset + size > cache->mmap_length) && + (offset > 0 || size > sizeof(struct mail_cache_header))) { if (fstat(cache->fd, &st) < 0) { i_error("fstat(%s) failed: %m", cache->filepath); return -1; @@ -376,7 +377,8 @@ *data_r = NULL; return 0; } - size = st.st_size - offset; + if (offset + size > (uoff_t)st.st_size) + size = st.st_size - offset; } cache->remap_counter++; From dovecot at dovecot.org Sat Feb 16 18:57:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:45 +0200 Subject: dovecot-2.2: lmtp: If verbose_proctitle=yes, update the process ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/63117ab893dc changeset: 15806:63117ab893dc user: Timo Sirainen date: Tue Feb 05 16:48:29 2013 +0200 description: lmtp: If verbose_proctitle=yes, update the process state in the title. diffstat: src/lmtp/client.c | 22 ++++++++++++++++++++-- src/lmtp/client.h | 2 ++ src/lmtp/commands.c | 8 ++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diffs (132 lines): diff -r 443ff272317f -r 63117ab893dc src/lmtp/client.c --- a/src/lmtp/client.c Mon Feb 04 17:06:40 2013 +0200 +++ b/src/lmtp/client.c Tue Feb 05 16:48:29 2013 +0200 @@ -8,6 +8,7 @@ #include "istream.h" #include "ostream.h" #include "hostpid.h" +#include "process-title.h" #include "var-expand.h" #include "settings-parser.h" #include "master-service.h" @@ -31,6 +32,20 @@ static struct client *clients = NULL; unsigned int clients_count = 0; +void client_state_set(struct client *client, const char *name) +{ + client->state.name = name; + + if (!client->service_set->verbose_proctitle) + return; + if (clients_count == 0) + process_title_set("[idling]"); + else if (clients_count > 1) + process_title_set(t_strdup_printf("[%u clients]", clients_count)); + else + process_title_set(t_strdup_printf("[%s]", client->state.name)); +} + static void client_idle_timeout(struct client *client) { client_destroy(client, @@ -156,6 +171,7 @@ lmtp_settings_dup(set_parser, client->pool, &lmtp_set, &lda_set); settings_var_expand(&lmtp_setting_parser_info, lmtp_set, client->pool, mail_storage_service_get_var_expand_table(storage_service, &input)); + client->service_set = master_service_settings_get(master_service); client->lmtp_set = lmtp_set; client->set = lda_set; } @@ -219,7 +235,6 @@ client_io_reset(client); client->state_pool = pool_alloconly_create("client state", 4096); client->state.mail_data_fd = -1; - client->state.name = "banner"; client_read_settings(client); client_raw_user_create(client); client_generate_session_id(client); @@ -229,6 +244,7 @@ DLLIST_PREPEND(&clients, client); clients_count++; + client_state_set(client, "banner"); client_send_line(client, "220 %s %s", client->my_domain, client->lmtp_set->login_greeting); i_info("Connect from %s", client_remote_id(client)); @@ -243,6 +259,8 @@ clients_count--; DLLIST_REMOVE(&clients, client); + client_state_set(client, "destroyed"); + if (client->raw_mail_user != NULL) mail_user_unref(&client->raw_mail_user); if (client->proxy != NULL) @@ -326,7 +344,7 @@ client->state.mail_data_fd = -1; client_generate_session_id(client); - client->state.name = "reset"; + client_state_set(client, "reset"); } void client_send_line(struct client *client, const char *fmt, ...) diff -r 443ff272317f -r 63117ab893dc src/lmtp/client.h --- a/src/lmtp/client.h Mon Feb 04 17:06:40 2013 +0200 +++ b/src/lmtp/client.h Tue Feb 05 16:48:29 2013 +0200 @@ -43,6 +43,7 @@ const struct setting_parser_info *user_set_info; const struct lda_settings *set; const struct lmtp_settings *lmtp_set; + const struct master_service_settings *service_set; int fd_in, fd_out; struct io *io; struct istream *input; @@ -76,6 +77,7 @@ const char *reason); void client_io_reset(struct client *client); void client_state_reset(struct client *client); +void client_state_set(struct client *client, const char *name); void client_input_handle(struct client *client); int client_input_read(struct client *client); diff -r 443ff272317f -r 63117ab893dc src/lmtp/commands.c --- a/src/lmtp/commands.c Mon Feb 04 17:06:40 2013 +0200 +++ b/src/lmtp/commands.c Tue Feb 05 16:48:29 2013 +0200 @@ -74,7 +74,7 @@ i_free(client->lhlo); client->lhlo = i_strdup(str_c(domain)); - client->state.name = "LHLO"; + client_state_set(client, "LHLO"); return 0; } @@ -143,7 +143,7 @@ client->state.mail_from = p_strdup(client->state_pool, addr); p_array_init(&client->state.rcpt_to, client->state_pool, 64); client_send_line(client, "250 2.1.0 OK"); - client->state.name = "MAIL FROM"; + client_state_set(client, "MAIL FROM"); return 0; } @@ -488,7 +488,7 @@ const char *error = NULL; int ret = 0; - client->state.name = "RCPT TO"; + client_state_set(client, "RCPT TO"); if (client->state.mail_from == NULL) { client_send_line(client, "503 5.5.1 MAIL needed first"); @@ -1014,7 +1014,7 @@ client_send_line(client, "354 OK"); io_remove(&client->io); - client->state.name = "DATA"; + client_state_set(client, "DATA"); client->io = io_add(client->fd_in, IO_READ, client_input_data, client); client_input_data_handle(client); return -1; From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: lib-index: Avoid assert-crashing later if mmap(dove... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a54f749f5a44 changeset: 15807:a54f749f5a44 user: Timo Sirainen date: Wed Feb 06 18:29:22 2013 +0200 description: lib-index: Avoid assert-crashing later if mmap(dovecot.index.cache) fails. diffstat: src/lib-index/mail-cache.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 63117ab893dc -r a54f749f5a44 src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Tue Feb 05 16:48:29 2013 +0200 +++ b/src/lib-index/mail-cache.c Wed Feb 06 18:29:22 2013 +0200 @@ -437,6 +437,7 @@ cache->mmap_base = mmap_ro_file(cache->fd, &cache->mmap_length); if (cache->mmap_base == MAP_FAILED) { cache->mmap_base = NULL; + cache->mmap_length = 0; mail_cache_set_syscall_error(cache, "mmap()"); return -1; } From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: lib-storage: Convert INBOX to uppercase also when n... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3ec0d772be49 changeset: 15808:3ec0d772be49 user: Timo Sirainen date: Wed Feb 06 19:00:52 2013 +0200 description: lib-storage: Convert INBOX to uppercase also when namespace has inbox=no. This fixes assert-crash in mailbox_check_mismatching_separators(). diffstat: src/lib-storage/mail-storage.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (19 lines): diff -r a54f749f5a44 -r 3ec0d772be49 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Feb 06 18:29:22 2013 +0200 +++ b/src/lib-storage/mail-storage.c Wed Feb 06 19:00:52 2013 +0200 @@ -627,10 +627,12 @@ i_assert(uni_utf8_str_is_valid(vname)); - if ((list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && - strncasecmp(vname, "INBOX", 5) == 0 && + if (strncasecmp(vname, "INBOX", 5) == 0 && strncmp(vname, "INBOX", 5) != 0) { - /* make sure INBOX shows up in uppercase everywhere */ + /* make sure INBOX shows up in uppercase everywhere. do this + regardless of whether we're in inbox=yes namespace, because + clients expect INBOX to be case insensitive regardless of + server's internal configuration. */ if (vname[5] == '\0') vname = "INBOX"; else if (vname[5] == mail_namespace_get_sep(list->ns)) From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: Released v2.1.15. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fc75811f3c08 changeset: 15809:fc75811f3c08 user: Timo Sirainen date: Fri Feb 08 15:05:36 2013 +0200 description: Released v2.1.15. diffstat: NEWS | 5 +++++ configure.in | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diffs (22 lines): diff -r 3ec0d772be49 -r fc75811f3c08 NEWS --- a/NEWS Wed Feb 06 19:00:52 2013 +0200 +++ b/NEWS Fri Feb 08 15:05:36 2013 +0200 @@ -1,3 +1,8 @@ +v2.1.15 2013-02-08 Timo Sirainen + + - v2.1.14: dovecot.index.cache fixes caused it to use more disk I/O + and memory than necessary. + v2.1.14 2013-01-30 Timo Sirainen + doveadm acl recalc command added diff -r 3ec0d772be49 -r fc75811f3c08 configure.in --- a/configure.in Wed Feb 06 19:00:52 2013 +0200 +++ b/configure.in Fri Feb 08 15:05:36 2013 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.14],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.15],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: Added tag 2.1.15 for changeset fc75811f3c08 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5fe181f1497a changeset: 15810:5fe181f1497a user: Timo Sirainen date: Fri Feb 08 15:05:37 2013 +0200 description: Added tag 2.1.15 for changeset fc75811f3c08 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r fc75811f3c08 -r 5fe181f1497a .hgtags --- a/.hgtags Fri Feb 08 15:05:36 2013 +0200 +++ b/.hgtags Fri Feb 08 15:05:37 2013 +0200 @@ -91,3 +91,4 @@ 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 2.1.12 cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 2.1.13 b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14 +fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15 From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: Added signature for changeset fc75811f3c08 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/26fa19903dcd changeset: 15811:26fa19903dcd user: Timo Sirainen date: Fri Feb 08 15:05:40 2013 +0200 description: Added signature for changeset fc75811f3c08 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 5fe181f1497a -r 26fa19903dcd .hgsigs --- a/.hgsigs Fri Feb 08 15:05:37 2013 +0200 +++ b/.hgsigs Fri Feb 08 15:05:40 2013 +0200 @@ -54,3 +54,4 @@ 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 0 iEYEABECAAYFAlC4WKwACgkQyUhSUUBViskaOACgmcwWV8hgsCOWvkbdh0OIw1ImSQYAn1RcTL0CG3M8+XG7QrrxSfQ7+V99 cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 0 iEYEABECAAYFAlDqjXUACgkQyUhSUUBViskUEwCfYTWHeDmPr8HfxSBQN17SD5IwDygAnROhb3IVTm9niDun4gxPxbHLo/Pe b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq +fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3 From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: mdbox: mailbox_copy() didn't properly free the save... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dd0eebe378fe changeset: 15813:dd0eebe378fe user: Timo Sirainen date: Sat Feb 16 13:32:57 2013 +0200 description: mdbox: mailbox_copy() didn't properly free the save context. diffstat: src/lib-storage/index/dbox-multi/mdbox-save.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (22 lines): diff -r 2def25f07ca6 -r dd0eebe378fe src/lib-storage/index/dbox-multi/mdbox-save.c --- a/src/lib-storage/index/dbox-multi/mdbox-save.c Fri Feb 08 16:42:21 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Sat Feb 16 13:32:57 2013 +0200 @@ -426,8 +426,10 @@ memset(&rec, 0, sizeof(rec)); rec.save_date = ioloop_time; if (mdbox_mail_lookup(src_mbox, mail->transaction->view, mail->seq, - &rec.map_uid) < 0) + &rec.map_uid) < 0) { + index_save_context_free(_ctx); return -1; + } mail_index_lookup_ext(mail->transaction->view, mail->seq, src_mbox->guid_ext_id, &guid_data, &expunged); @@ -462,5 +464,6 @@ if (_ctx->dest_mail != NULL) mail_set_seq_saving(_ctx->dest_mail, ctx->ctx.seq); + index_save_context_free(_ctx); return 0; } From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: mdbox: Crashfix for storage rebuild Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2def25f07ca6 changeset: 15812:2def25f07ca6 user: Timo Sirainen date: Fri Feb 08 16:42:21 2013 +0200 description: mdbox: Crashfix for storage rebuild diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 26fa19903dcd -r 2def25f07ca6 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 08 15:05:40 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 08 16:42:21 2013 +0200 @@ -430,7 +430,7 @@ still try to look it up using map_uid. */ rec = map_uid == 0 ? NULL : rebuild_lookup_map_uid(ctx, map_uid); - map_uid = rec->map_uid; + map_uid = rec == NULL ? 0 : rec->map_uid; } else if (!guid_hash_have_map_uid(&rec, map_uid)) { /* message's GUID and map_uid point to different physical messages. assume that GUID is correct and From dovecot at dovecot.org Sat Feb 16 18:57:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 18:57:46 +0200 Subject: dovecot-2.2: Merged changes from v2.1 tree. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e63d1cf19ec7 changeset: 15814:e63d1cf19ec7 user: Timo Sirainen date: Sat Feb 16 18:57:33 2013 +0200 description: Merged changes from v2.1 tree. diffstat: .hgsigs | 2 + .hgtags | 2 + src/imap/imap-client.c | 2 + src/lib-index/mail-cache-fields.c | 2 + src/lib-index/mail-cache-lookup.c | 13 +++---- src/lib-index/mail-cache.c | 24 +++++++++++++- src/lib-storage/index/dbox-common/dbox-storage.c | 6 +++ src/lib-storage/index/index-mail-headers.c | 6 +++- src/lib-storage/index/index-mail.c | 39 +++++++++++++++++++++-- src/lib-storage/index/index-mail.h | 1 + src/lib-storage/mail-storage.c | 8 +++- src/lib/Makefile.am | 1 + src/lib/buffer.c | 11 +++++- src/lib/istream-tee.c | 1 + src/lib/str.c | 3 - src/lib/test-lib.c | 1 + src/lib/test-lib.h | 1 + src/lib/test-str.c | 26 ++++++++++++++++ src/lmtp/client.c | 22 ++++++++++++- src/lmtp/client.h | 2 + src/lmtp/commands.c | 8 ++-- src/plugins/acl/doveadm-acl.c | 29 +++++++++++++++++ 22 files changed, 182 insertions(+), 28 deletions(-) diffs (truncated from 568 to 300 lines): diff -r 890b5b52ffd0 -r e63d1cf19ec7 .hgsigs --- a/.hgsigs Sat Feb 16 18:24:28 2013 +0200 +++ b/.hgsigs Sat Feb 16 18:57:33 2013 +0200 @@ -55,3 +55,5 @@ 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 0 iEYEABECAAYFAlC4WKwACgkQyUhSUUBViskaOACgmcwWV8hgsCOWvkbdh0OIw1ImSQYAn1RcTL0CG3M8+XG7QrrxSfQ7+V99 86bccdf46d172524ca19a1a8a16a50ac30a6743c 0 iEYEABECAAYFAlDqonoACgkQyUhSUUBVisnqqACfaqdR6GxUAJznotKT9WHIUVhVgcIAoJIEa0SBzlGIWThmLvtQByF9vXcc cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 0 iEYEABECAAYFAlDqjXUACgkQyUhSUUBViskUEwCfYTWHeDmPr8HfxSBQN17SD5IwDygAnROhb3IVTm9niDun4gxPxbHLo/Pe +b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq +fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3 diff -r 890b5b52ffd0 -r e63d1cf19ec7 .hgtags --- a/.hgtags Sat Feb 16 18:24:28 2013 +0200 +++ b/.hgtags Sat Feb 16 18:57:33 2013 +0200 @@ -92,3 +92,5 @@ 75bfda4a7c6c9aa04b6a6ef233fc527356171a06 2.1.12 cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 2.1.13 86bccdf46d172524ca19a1a8a16a50ac30a6743c 2.2.beta1 +b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14 +fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15 diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/imap/imap-client.c --- a/src/imap/imap-client.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/imap/imap-client.c Sat Feb 16 18:57:33 2013 +0200 @@ -83,6 +83,8 @@ set->imap_max_line_length, FALSE); client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE); o_stream_set_no_error_handling(client->output, TRUE); + i_stream_set_name(client->input, ""); + o_stream_set_name(client->output, ""); o_stream_set_flush_callback(client->output, client_output, client); diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-index/mail-cache-fields.c --- a/src/lib-index/mail-cache-fields.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-index/mail-cache-fields.c Sat Feb 16 18:57:33 2013 +0200 @@ -280,6 +280,8 @@ file_cache_invalidate(cache->file_cache, offset, field_hdr_size); } + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); ret = mail_cache_map(cache, offset, field_hdr_size, &data); if (ret < 0) return -1; diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-index/mail-cache-lookup.c --- a/src/lib-index/mail-cache-lookup.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-index/mail-cache-lookup.c Sat Feb 16 18:57:33 2013 +0200 @@ -15,6 +15,7 @@ { const struct mail_cache_record *rec; const void *data; + int ret; i_assert(offset != 0); @@ -41,17 +42,15 @@ } if (rec->size > CACHE_PREFETCH) { /* larger than we guessed. map the rest of the record. */ - if (mail_cache_map(cache, offset, rec->size, &data) < 0) + if ((ret = mail_cache_map(cache, offset, rec->size, &data)) < 0) return -1; + if (ret == 0) { + mail_cache_set_corrupted(cache, "record points outside file"); + return -1; + } rec = data; } - if (rec->size > cache->mmap_length || - offset + rec->size > cache->mmap_length) { - mail_cache_set_corrupted(cache, "record points outside file"); - return -1; - } - *rec_r = rec; return 0; } diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-index/mail-cache.c Sat Feb 16 18:57:33 2013 +0200 @@ -370,12 +370,30 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size, const void **data_r) { + struct stat st; const void *data; ssize_t ret; if (size == 0) size = sizeof(struct mail_cache_header); + /* verify offset + size before trying to allocate a huge amount of + memory due to them. note that we may be prefetching more than we + actually need, so don't fail too early. */ + if ((size > cache->mmap_length || offset + size > cache->mmap_length) && + (offset > 0 || size > sizeof(struct mail_cache_header))) { + if (fstat(cache->fd, &st) < 0) { + i_error("fstat(%s) failed: %m", cache->filepath); + return -1; + } + if (offset >= (uoff_t)st.st_size) { + *data_r = NULL; + return 0; + } + if (offset + size > (uoff_t)st.st_size) + size = st.st_size - offset; + } + cache->remap_counter++; if (cache->map_with_read) return mail_cache_map_with_read(cache, offset, size, data_r); @@ -432,6 +450,7 @@ cache->mmap_base = mmap_ro_file(cache->fd, &cache->mmap_length); if (cache->mmap_base == MAP_FAILED) { cache->mmap_base = NULL; + cache->mmap_length = 0; mail_cache_set_syscall_error(cache, "mmap()"); return -1; } @@ -464,8 +483,7 @@ mail_cache_init_file_cache(cache); - if (mail_cache_map(cache, 0, sizeof(struct mail_cache_header), - &data) < 0) + if (mail_cache_map(cache, 0, 0, &data) < 0) return -1; return 1; } @@ -685,6 +703,8 @@ file_cache_invalidate(cache->file_cache, 0, sizeof(struct mail_cache_header)); } + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); if (mail_cache_map(cache, 0, 0, &data) > 0) cache->hdr_copy = *cache->hdr; else { diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Sat Feb 16 18:57:33 2013 +0200 @@ -270,6 +270,12 @@ if (mailbox_open(box) < 0) return -1; + if (mail_index_get_header(box->view)->uid_validity != 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "Mailbox already exists"); + return -1; + } + /* if alt path already exists and contains files, rebuild storage so that we don't start overwriting files. */ ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, &alt_path); diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-storage/index/index-mail-headers.c --- a/src/lib-storage/index/index-mail-headers.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-storage/index/index-mail-headers.c Sat Feb 16 18:57:33 2013 +0200 @@ -374,6 +374,7 @@ input2 = tee_i_stream_create_child(mail->data.tee_stream); index_mail_parse_header_init(mail, NULL); + mail->data.parser_input = input; mail->data.parser_ctx = message_parser_init(mail->mail.data_pool, input, hdr_parser_flags, msg_parser_flags); @@ -386,10 +387,13 @@ struct index_mail_data *data = &mail->data; struct message_part *parts; - if (data->parser_ctx != NULL) + if (data->parser_ctx != NULL) { + data->parser_input = NULL; (void)message_parser_deinit(&data->parser_ctx, &parts); + } if (data->parts == NULL) { + data->parser_input = data->stream; data->parser_ctx = message_parser_init(mail->mail.data_pool, data->stream, hdr_parser_flags, diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-storage/index/index-mail.c Sat Feb 16 18:57:33 2013 +0200 @@ -805,13 +805,43 @@ static int index_mail_parse_body_finish(struct index_mail *mail, enum index_cache_field field) { - if (message_parser_deinit(&mail->data.parser_ctx, - &mail->data.parts) < 0) { - mail_set_cache_corrupted(&mail->mail.mail, - MAIL_FETCH_MESSAGE_PARTS); + struct istream *parser_input = mail->data.parser_input; + int ret; + + if (parser_input == NULL) { + ret = message_parser_deinit(&mail->data.parser_ctx, + &mail->data.parts) < 0 ? 0 : 1; + } else { + mail->data.parser_input = NULL; + i_stream_ref(parser_input); + ret = message_parser_deinit(&mail->data.parser_ctx, + &mail->data.parts) < 0 ? 0 : 1; + if (parser_input->stream_errno == 0 || + parser_input->stream_errno == EPIPE) { + /* EPIPE = input already closed. allow the caller to + decide if that is an error or not. */ + i_assert(i_stream_read(parser_input) == -1 && + !i_stream_have_bytes_left(parser_input)); + } else { + errno = parser_input->stream_errno; + mail_storage_set_critical(mail->mail.mail.box->storage, + "mail parser: read(%s, box=%s) failed: %m", + i_stream_get_name(parser_input), + mail->mail.mail.box->vname); + ret = -1; + } + i_stream_unref(&parser_input); + } + if (ret <= 0) { + if (ret == 0) { + mail_set_cache_corrupted(&mail->mail.mail, + MAIL_FETCH_MESSAGE_PARTS); + } + mail->data.parts = NULL; mail->data.parsed_bodystructure = FALSE; return -1; } + if (mail->data.no_caching) { /* if we're here because we aborted parsing, don't get any further or we may crash while generating output from @@ -1221,6 +1251,7 @@ mail_set_cache_corrupted(&mail->mail.mail, MAIL_FETCH_MESSAGE_PARTS); } + mail->data.parser_input = NULL; } if (data->filter_stream != NULL) i_stream_unref(&data->filter_stream); diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-storage/index/index-mail.h --- a/src/lib-storage/index/index-mail.h Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-storage/index/index-mail.h Sat Feb 16 18:57:33 2013 +0200 @@ -98,6 +98,7 @@ struct istream *stream, *filter_stream; struct tee_istream *tee_stream; struct message_size hdr_size, body_size; + struct istream *parser_input; struct message_parser_ctx *parser_ctx; int parsing_count; ARRAY_TYPE(keywords) keywords; diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib-storage/mail-storage.c Sat Feb 16 18:57:33 2013 +0200 @@ -641,10 +641,12 @@ i_assert(uni_utf8_str_is_valid(vname)); - if ((list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && - strncasecmp(vname, "INBOX", 5) == 0 && + if (strncasecmp(vname, "INBOX", 5) == 0 && strncmp(vname, "INBOX", 5) != 0) { - /* make sure INBOX shows up in uppercase everywhere */ + /* make sure INBOX shows up in uppercase everywhere. do this + regardless of whether we're in inbox=yes namespace, because + clients expect INBOX to be case insensitive regardless of + server's internal configuration. */ if (vname[5] == '\0') vname = "INBOX"; else if (vname[5] == mail_namespace_get_sep(list->ns)) diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib/Makefile.am --- a/src/lib/Makefile.am Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib/Makefile.am Sat Feb 16 18:57:33 2013 +0200 @@ -286,6 +286,7 @@ test-primes.c \ test-priorityq.c \ test-seq-range-array.c \ + test-str.c \ test-strescape.c \ test-strfuncs.c \ test-str-find.c \ diff -r 890b5b52ffd0 -r e63d1cf19ec7 src/lib/buffer.c --- a/src/lib/buffer.c Sat Feb 16 18:24:28 2013 +0200 +++ b/src/lib/buffer.c Sat Feb 16 18:57:33 2013 +0200 @@ -39,6 +39,7 @@ static inline void buffer_check_limits(struct real_buffer *buf, size_t pos, size_t data_size) { + unsigned int extra; size_t new_size; if (unlikely((size_t)-1 - pos < data_size)) { @@ -53,7 +54,13 @@ memset(buf->w_buffer + buf->used, 0, max - buf->used); } - if (new_size > buf->alloc) { + + /* always keep +1 byte allocated available in case str_c() is called + for this buffer. this is mainly for cases where the buffer is + allocated from data stack, and str_c() is called in a separate stack + frame. */ From dovecot at dovecot.org Sat Feb 16 19:06:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 16 Feb 2013 19:06:24 +0200 Subject: dovecot-2.1: login-common: Updated obsolete login_process_size s... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1713ffc870c1 changeset: 14906:1713ffc870c1 user: Timo Sirainen date: Sat Feb 16 19:06:18 2013 +0200 description: login-common: Updated obsolete login_process_size setting in error log message. diffstat: src/login-common/ssl-proxy-openssl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r dd0eebe378fe -r 1713ffc870c1 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Sat Feb 16 13:32:57 2013 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Sat Feb 16 19:06:18 2013 +0200 @@ -433,7 +433,8 @@ case SSL_ERROR_SSL: if (ERR_GET_REASON(ERR_peek_error()) == ERR_R_MALLOC_FAILURE) { i_error("OpenSSL malloc() failed. " - "You may need to increase login_process_size"); + "You may need to increase service %s { vsz_limit }", + login_binary->process_name); } errstr = t_strdup_printf("%s failed: %s", func_name, ssl_last_error()); From dovecot at dovecot.org Sun Feb 17 07:05:52 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 07:05:52 +0200 Subject: dovecot-2.2: dsync: Use full hostname+domain when comparing if h... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7aabd79c9d5 changeset: 15815:e7aabd79c9d5 user: Timo Sirainen date: Sun Feb 17 07:05:08 2013 +0200 description: dsync: Use full hostname+domain when comparing if hosts are different in locking. diffstat: src/doveadm/dsync/dsync-brain.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r e63d1cf19ec7 -r e7aabd79c9d5 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Sat Feb 16 18:57:33 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Sun Feb 17 07:05:08 2013 +0200 @@ -117,7 +117,7 @@ dsync_brain_mailbox_trees_init(brain); memset(&ibc_set, 0, sizeof(ibc_set)); - ibc_set.hostname = my_hostname; + ibc_set.hostname = my_hostdomain(); ibc_set.sync_ns_prefix = sync_ns == NULL ? NULL : sync_ns->prefix; ibc_set.sync_box = sync_box; ibc_set.sync_type = sync_type; @@ -146,7 +146,7 @@ brain->state = DSYNC_STATE_SLAVE_RECV_HANDSHAKE; memset(&ibc_set, 0, sizeof(ibc_set)); - ibc_set.hostname = my_hostname; + ibc_set.hostname = my_hostdomain(); dsync_ibc_send_handshake(ibc, &ibc_set); dsync_ibc_set_io_callback(ibc, dsync_brain_run_io, brain); From dovecot at dovecot.org Sun Feb 17 08:52:27 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 08:52:27 +0200 Subject: dovecot-2.2: dsync: If locking fails, fail instead of continuing. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/adb9857a3879 changeset: 15816:adb9857a3879 user: Timo Sirainen date: Sun Feb 17 08:50:18 2013 +0200 description: dsync: If locking fails, fail instead of continuing. diffstat: src/doveadm/dsync/dsync-brain.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (27 lines): diff -r e7aabd79c9d5 -r adb9857a3879 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Sun Feb 17 07:05:08 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Sun Feb 17 08:50:18 2013 +0200 @@ -259,8 +259,10 @@ return FALSE; if (brain->lock_timeout > 0) { - if (dsync_brain_lock(brain, ibc_set->hostname) < 0) + if (dsync_brain_lock(brain, ibc_set->hostname) < 0) { + brain->failed = TRUE; return FALSE; + } } brain->state = brain->sync_type == DSYNC_BRAIN_SYNC_TYPE_STATE ? @@ -280,8 +282,10 @@ if (ibc_set->lock_timeout > 0) { brain->lock_timeout = ibc_set->lock_timeout; - if (dsync_brain_lock(brain, ibc_set->hostname) < 0) + if (dsync_brain_lock(brain, ibc_set->hostname) < 0) { + brain->failed = TRUE; return FALSE; + } } if (ibc_set->sync_ns_prefix != NULL) { From dovecot at dovecot.org Sun Feb 17 10:11:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 10:11:35 +0200 Subject: dovecot-2.2: maildir: If we see old maildir file reappear, re-re... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c92ebbedc6f9 changeset: 15817:c92ebbedc6f9 user: Timo Sirainen date: Sun Feb 17 10:10:45 2013 +0200 description: maildir: If we see old maildir file reappear, re-read uidlist before logging error. Sometimes the old file gets added back intentionally and the dovecot-uidlist is recreated (if necessary) to give it a new UID. Existing processes should handle this situation. diffstat: src/lib-storage/index/maildir/maildir-uidlist.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diffs (41 lines): diff -r adb9857a3879 -r c92ebbedc6f9 src/lib-storage/index/maildir/maildir-uidlist.c --- a/src/lib-storage/index/maildir/maildir-uidlist.c Sun Feb 17 08:50:18 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Sun Feb 17 10:10:45 2013 +0200 @@ -100,6 +100,7 @@ unsigned int unsorted:1; unsigned int have_mailbox_guid:1; unsigned int opened_readonly:1; + unsigned int reread:1; }; struct maildir_uidlist_sync_ctx { @@ -871,8 +872,17 @@ *recreated_r = FALSE; - if ((ret = maildir_uidlist_stat(uidlist, &st)) <= 0) - return ret < 0 ? -1 : 1; + if ((ret = maildir_uidlist_stat(uidlist, &st)) < 0) + return -1; + if (ret == 0) { + *recreated_r = TRUE; + return 1; + } + if (uidlist->reread) { + uidlist->reread = FALSE; + *recreated_r = TRUE; + return 1; + } if (st.st_ino != uidlist->fd_ino || !CMP_DEV_T(st.st_dev, uidlist->fd_dev)) { @@ -2065,6 +2075,9 @@ rec = hash_table_lookup(uidlist->files, filename); i_assert(rec != NULL); + if ((flags & MAILDIR_UIDLIST_REC_FLAG_RACING) != 0) + uidlist->reread = TRUE; + rec->flags |= flags; } From dovecot at dovecot.org Sun Feb 17 10:11:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 10:11:35 +0200 Subject: dovecot-2.2: maildir: Don't try to preserve old filename when sa... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e07a8b17af8b changeset: 15818:e07a8b17af8b user: Timo Sirainen date: Sun Feb 17 10:11:20 2013 +0200 description: maildir: Don't try to preserve old filename when saving if uidlist couldn't be locked. diffstat: src/lib-storage/index/maildir/maildir-save.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (19 lines): diff -r c92ebbedc6f9 -r e07a8b17af8b src/lib-storage/index/maildir/maildir-save.c --- a/src/lib-storage/index/maildir/maildir-save.c Sun Feb 17 10:10:45 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-save.c Sun Feb 17 10:11:20 2013 +0200 @@ -818,12 +818,13 @@ { uoff_t size; - if (!ctx->locked_uidlist_refresh) { + if (!ctx->locked_uidlist_refresh && ctx->locked) { (void)maildir_uidlist_refresh(ctx->mbox->uidlist); ctx->locked_uidlist_refresh = TRUE; } - if ((prev_mf != NULL && maildir_filename_has_conflict(mf, prev_mf)) || + if (!ctx->locked_uidlist_refresh || + (prev_mf != NULL && maildir_filename_has_conflict(mf, prev_mf)) || maildir_uidlist_get_full_filename(ctx->mbox->uidlist, mf->dest_basename) != NULL) { /* file already exists. give it another name. From dovecot at dovecot.org Sun Feb 17 10:15:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 10:15:10 +0200 Subject: dovecot-2.2: dsync: Improved unexpected error logging. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9c095a50ba3e changeset: 15819:9c095a50ba3e user: Timo Sirainen date: Sun Feb 17 10:14:49 2013 +0200 description: dsync: Improved unexpected error logging. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 38 ++++++++++++++++++++++--------- 1 files changed, 27 insertions(+), 11 deletions(-) diffs (105 lines): diff -r e07a8b17af8b -r 9c095a50ba3e src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 10:11:20 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 10:14:49 2013 +0200 @@ -3,6 +3,7 @@ #include "lib.h" #include "array.h" #include "hash.h" +#include "hex-binary.h" #include "istream.h" #include "seq-range-array.h" #include "mail-storage-private.h" @@ -214,18 +215,29 @@ static bool dsync_mail_change_guid_equals(const struct dsync_mail_change *change, - const char *guid) + const char *guid, const char **cmp_guid_r) { guid_128_t guid_128, change_guid_128; - if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) + if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) { + if (cmp_guid_r != NULL) + *cmp_guid_r = change->guid; return strcmp(change->guid, guid) == 0; + } if (guid_128_from_string(change->guid, change_guid_128) < 0) i_unreached(); mail_generate_guid_128_hash(guid, guid_128); - return memcmp(change_guid_128, guid_128, GUID_128_SIZE) == 0; + if (memcmp(change_guid_128, guid_128, GUID_128_SIZE) != 0) { + if (cmp_guid_r != NULL) { + *cmp_guid_r = t_strdup_printf("%s(expunged, orig=%s)", + binary_to_hex(change_guid_128, sizeof(change_guid_128)), + change->guid); + } + return FALSE; + } + return TRUE; } static int @@ -478,7 +490,7 @@ dsync_import_set_mail(struct dsync_mailbox_importer *importer, const struct dsync_mail_change *change) { - const char *guid; + const char *guid, *cmp_guid; if (!mail_set_uid(importer->mail, change->uid)) return FALSE; @@ -498,10 +510,10 @@ dsync_mail_error(importer, importer->mail, "GUID"); return FALSE; } - if (!dsync_mail_change_guid_equals(change, guid)) { + if (!dsync_mail_change_guid_equals(change, guid, &cmp_guid)) { dsync_import_unexpected_state(importer, t_strdup_printf( "Unexpected GUID mismatch for UID=%u: %s != %s", - change->uid, guid, change->guid)); + change->uid, guid, cmp_guid)); importer->failed = TRUE; return FALSE; } @@ -511,12 +523,14 @@ static bool dsync_check_cur_guid(struct dsync_mailbox_importer *importer, const struct dsync_mail_change *change) { + const char *cmp_guid; + if (change->guid == NULL || *change->guid == '\0') return TRUE; - if (!dsync_mail_change_guid_equals(change, importer->cur_guid)) { + if (!dsync_mail_change_guid_equals(change, importer->cur_guid, &cmp_guid)) { dsync_import_unexpected_state(importer, t_strdup_printf( "Unexpected GUID mismatch (2) for UID=%u: %s != %s", - change->uid, importer->cur_guid, change->guid)); + change->uid, importer->cur_guid, cmp_guid)); importer->failed = TRUE; return FALSE; } @@ -1027,8 +1041,10 @@ if (*change->guid != '\0' && *importer->cur_guid != '\0') { /* we have GUIDs, verify them */ - return dsync_mail_change_guid_equals(change, - importer->cur_guid) ? 1 : 0; + if (dsync_mail_change_guid_equals(change, importer->cur_guid, NULL)) + return 1; + else + return 0; } /* verify hdr_hash if it exists */ @@ -1069,7 +1085,7 @@ return FALSE; i_assert(local_change->type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE); - if (dsync_mail_change_guid_equals(local_change, change->guid)) + if (dsync_mail_change_guid_equals(local_change, change->guid, NULL)) importer->last_common_uid = change->uid; else if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) dsync_mailbox_common_uid_found(importer); From dovecot at dovecot.org Sun Feb 17 10:15:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 10:15:10 +0200 Subject: dovecot-2.2: dsync: Fixed infinite loop in importer. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7396c0f7f66 changeset: 15820:e7396c0f7f66 user: Timo Sirainen date: Sun Feb 17 10:15:04 2013 +0200 description: dsync: Fixed infinite loop in importer. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-) diffs (41 lines): diff -r 9c095a50ba3e -r e7396c0f7f66 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 10:14:49 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 10:15:04 2013 +0200 @@ -1305,14 +1305,32 @@ uint32_t wanted_uid) { const struct seq_range *range; - unsigned int count; + unsigned int count, n; + struct seq_range_iter iter; + uint32_t uid; - while ((count = array_count(unwanted_uids)) > 0) { - range = array_idx(unwanted_uids, count-1); - if (dsync_msg_change_uid(importer, range->seq2, wanted_uid)) { - seq_range_array_remove(unwanted_uids, range->seq2); + /* optimize by first trying to use the latest UID */ + range = array_get(unwanted_uids, &count); + if (count == 0) + return FALSE; + if (dsync_msg_change_uid(importer, range[count-1].seq2, wanted_uid)) { + seq_range_array_remove(unwanted_uids, range[count-1].seq2); + return TRUE; + } + if (mailbox_get_last_mail_error(importer->box) == MAIL_ERROR_EXPUNGED) + seq_range_array_remove(unwanted_uids, range[count-1].seq2); + + /* now try to use any of them by iterating through them. (would be + easier&faster to just iterate backwards, but probably too much + trouble to add such API) */ + n = 0; seq_range_array_iter_init(&iter, unwanted_uids); + while (seq_range_array_iter_nth(&iter, n++, &uid)) { + if (dsync_msg_change_uid(importer, uid, wanted_uid)) { + seq_range_array_remove(unwanted_uids, uid); return TRUE; } + if (mailbox_get_last_mail_error(importer->box) == MAIL_ERROR_EXPUNGED) + seq_range_array_remove(unwanted_uids, uid); } return FALSE; } From dovecot at dovecot.org Sun Feb 17 10:47:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 10:47:56 +0200 Subject: dovecot-2.2: lib-index: Make sure unused_old_sync_* fields are c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1dd1e88ba0a2 changeset: 15821:1dd1e88ba0a2 user: Timo Sirainen date: Sun Feb 17 10:47:40 2013 +0200 description: lib-index: Make sure unused_old_sync_* fields are cleared in header in old inedx files. diffstat: src/lib-index/mail-index-map-hdr.c | 6 ++++++ src/lib-index/mail-index.h | 2 +- 2 files changed, 7 insertions(+), 1 deletions(-) diffs (28 lines): diff -r e7396c0f7f66 -r 1dd1e88ba0a2 src/lib-index/mail-index-map-hdr.c --- a/src/lib-index/mail-index-map-hdr.c Sun Feb 17 10:15:04 2013 +0200 +++ b/src/lib-index/mail-index-map-hdr.c Sun Feb 17 10:47:40 2013 +0200 @@ -272,6 +272,12 @@ /* pre-v1.1.rc6: make sure the \Recent flags are gone */ mail_index_map_clear_recent_flags(map); map->hdr.minor_version = MAIL_INDEX_MINOR_VERSION; + /* fall through */ + case 2: + /* pre-v2.2 (although should have been done in v2.1 already): + make sure the old unused fields are cleared */ + map->hdr.unused_old_sync_size = 0; + map->hdr.unused_old_sync_stamp = 0; } if (hdr->first_recent_uid == 0 || hdr->first_recent_uid > hdr->next_uid || diff -r e7396c0f7f66 -r 1dd1e88ba0a2 src/lib-index/mail-index.h --- a/src/lib-index/mail-index.h Sun Feb 17 10:15:04 2013 +0200 +++ b/src/lib-index/mail-index.h Sun Feb 17 10:47:40 2013 +0200 @@ -8,7 +8,7 @@ #include "seq-range-array.h" #define MAIL_INDEX_MAJOR_VERSION 7 -#define MAIL_INDEX_MINOR_VERSION 2 +#define MAIL_INDEX_MINOR_VERSION 3 #define MAIL_INDEX_HEADER_MIN_SIZE 120 From dovecot at dovecot.org Sun Feb 17 11:48:27 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 11:48:27 +0200 Subject: dovecot-2.2: mbox: Fixed mailbox_update() for changing mailbox G... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7d1479aa534b changeset: 15822:7d1479aa534b user: Timo Sirainen date: Sun Feb 17 11:46:14 2013 +0200 description: mbox: Fixed mailbox_update() for changing mailbox GUID. diffstat: src/lib-storage/index/mbox/mbox-storage.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 1dd1e88ba0a2 -r 7d1479aa534b src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Sun Feb 17 10:47:40 2013 +0200 +++ b/src/lib-storage/index/mbox/mbox-storage.c Sun Feb 17 11:46:14 2013 +0200 @@ -498,7 +498,8 @@ return -1; } - if (update->uid_validity != 0 || update->min_next_uid != 0) { + if (update->uid_validity != 0 || update->min_next_uid != 0 || + !guid_128_is_empty(update->mailbox_guid)) { mbox->sync_hdr_update = update; ret = mbox_sync(mbox, MBOX_SYNC_HEADER | MBOX_SYNC_FORCE_SYNC | MBOX_SYNC_REWRITE); From dovecot at dovecot.org Sun Feb 17 11:48:27 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 11:48:27 +0200 Subject: dovecot-2.2: dsync: Fail if changing mailbox GUID update doesn't... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/945ea8abe713 changeset: 15823:945ea8abe713 user: Timo Sirainen date: Sun Feb 17 11:47:32 2013 +0200 description: dsync: Fail if changing mailbox GUID update doesn't work. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diffs (24 lines): diff -r 7d1479aa534b -r 945ea8abe713 src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Sun Feb 17 11:46:14 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Sun Feb 17 11:47:32 2013 +0200 @@ -58,6 +58,20 @@ mailbox_get_last_error(box, NULL)); return -1; } + /* verify that the update worked */ + if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, + &metadata) < 0) { + i_error("Can't get mailbox GUID %s: %s", + mailbox_get_vname(box), + mailbox_get_last_error(box, NULL)); + return -1; + } + if (memcmp(mailbox_guid, metadata.guid, + sizeof(metadata.guid)) != 0) { + i_error("Backend didn't update mailbox %s GUID", + mailbox_get_vname(box)); + return -1; + } } return 0; } From dovecot at dovecot.org Sun Feb 17 11:48:27 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 11:48:27 +0200 Subject: dovecot-2.2: dsync: Fixes to handling local changes during dsync. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/953594b35bb3 changeset: 15824:953594b35bb3 user: Timo Sirainen date: Sun Feb 17 11:48:16 2013 +0200 description: dsync: Fixes to handling local changes during dsync. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 123 ++++++++++++++++-------------- 1 files changed, 64 insertions(+), 59 deletions(-) diffs (217 lines): diff -r 945ea8abe713 -r 953594b35bb3 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 11:47:32 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 11:48:16 2013 +0200 @@ -77,6 +77,7 @@ ARRAY(struct importer_new_mail *) newmails; ARRAY_TYPE(uint32_t) wanted_uids; + uint32_t highest_wanted_uid; ARRAY(struct dsync_mail_request) mail_requests; unsigned int mail_request_idx; @@ -1279,6 +1280,15 @@ return 1; } +static void +dsync_mailbox_import_want_uid(struct dsync_mailbox_importer *importer, + uint32_t uid) +{ + if (importer->highest_wanted_uid < uid) + importer->highest_wanted_uid = uid; + array_append(&importer->wanted_uids, &uid, 1); +} + static bool dsync_msg_change_uid(struct dsync_mailbox_importer *importer, uint32_t old_uid, uint32_t new_uid) @@ -1295,7 +1305,7 @@ mailbox_save_set_uid(save_ctx, new_uid); if (mailbox_move(&save_ctx, importer->mail) < 0) return FALSE; - array_append(&importer->wanted_uids, &new_uid, 1); + dsync_mailbox_import_want_uid(importer, new_uid); return TRUE; } @@ -1643,7 +1653,7 @@ } if (ret > 0) { i_assert(save_ctx == NULL); - array_append(&importer->wanted_uids, &newmail->final_uid, 1); + dsync_mailbox_import_want_uid(importer, newmail->final_uid); return; } /* fallback to saving from remote stream */ @@ -1691,8 +1701,8 @@ mailbox_get_last_error(importer->box, NULL)); importer->failed = TRUE; } else { - array_append(&importer->wanted_uids, - &newmail->final_uid, 1); + dsync_mailbox_import_want_uid(importer, + newmail->final_uid); } } } @@ -1742,23 +1752,34 @@ } static int -reassign_uids_in_seq_range(struct mailbox *box, uint32_t seq1, uint32_t seq2) +reassign_uids_in_seq_range(struct mailbox *box, + const ARRAY_TYPE(seq_range) *unwanted_uids) { const enum mailbox_transaction_flags trans_flags = MAILBOX_TRANSACTION_FLAG_EXTERNAL | MAILBOX_TRANSACTION_FLAG_ASSIGN_UIDS; struct mailbox_transaction_context *trans; + struct mail_search_args *search_args; + struct mail_search_arg *arg; + struct mail_search_context *search_ctx; struct mail_save_context *save_ctx; struct mail *mail; - uint32_t seq; - int ret = 0; + int ret = 1; + + if (array_count(unwanted_uids) == 0) + return 1; + + search_args = mail_search_build_init(); + arg = mail_search_build_add(search_args, SEARCH_UIDSET); + p_array_init(&arg->value.seqset, search_args->pool, + array_count(unwanted_uids)); + array_append_array(&arg->value.seqset, unwanted_uids); trans = mailbox_transaction_begin(box, trans_flags); - mail = mail_alloc(trans, 0, NULL); + search_ctx = mailbox_search_init(trans, search_args, NULL, 0, NULL); + mail_search_args_unref(&search_args); - for (seq = seq1; seq <= seq2; seq++) { - mail_set_seq(mail, seq); - + while (mailbox_search_next(search_ctx, &mail)) { save_ctx = mailbox_save_alloc(trans); mailbox_save_copy_flags(save_ctx, mail); if (mailbox_move(&save_ctx, mail) < 0) { @@ -1766,9 +1787,16 @@ mailbox_get_vname(box), mailbox_get_last_error(box, NULL)); ret = -1; + } else if (ret > 0) { + ret = 0; } } - mail_free(&mail); + if (mailbox_search_deinit(&search_ctx) < 0) { + i_error("Mailbox %s: mail search failed: %s", + mailbox_get_vname(box), + mailbox_get_last_error(box, NULL)); + ret = -1; + } if (mailbox_transaction_commit(&trans) < 0) { i_error("Mailbox %s: UID reassign commit failed: %s", @@ -1784,14 +1812,18 @@ const struct mail_transaction_commit_changes *changes, bool *changes_during_sync_r) { + ARRAY_TYPE(seq_range) unwanted_uids; struct seq_range_iter iter; const uint32_t *wanted_uids; - uint32_t saved_uid, highest_wanted_uid = 0; - uint32_t seq1, seq2, lowest_saved_uid = (uint32_t)-1; - uint32_t lowest_unwanted_uid = (uint32_t)-1; + uint32_t saved_uid, highest_seen_uid; unsigned int i, n, wanted_count; int ret = 0; + wanted_uids = array_get(&importer->wanted_uids, &wanted_count); + if (wanted_count == 0) { + i_assert(array_count(&changes->saved_uids) == 0); + return 0; + } /* wanted_uids contains the UIDs we tried to save mails with. if nothing changed during dsync, we should have the expected UIDs (changes->saved_uids) and all is well. @@ -1804,61 +1836,34 @@ locally added new uid=5 -> saved_uids = 10,7,9 - we'll now need to reassign UIDs 5 and 10. or more generally, we - need to reassign UIDs [original local uidnext .. lowest saved_uid-1] - and [lowest unwanted uid .. remote uidnext-1] */ + we'll now need to reassign UIDs 5 and 10. to be fully future-proof + we'll reassign all UIDs between [original local uidnext .. highest + UID we think we know] that aren't in saved_uids. */ - /* find the highest wanted UID that doesn't match what we got */ - wanted_uids = array_get(&importer->wanted_uids, &wanted_count); + /* create uidset for the list of UIDs we don't want to exist */ + t_array_init(&unwanted_uids, 8); + highest_seen_uid = I_MAX(importer->remote_uid_next-1, + importer->highest_wanted_uid); + i_assert(importer->local_uid_next <= highest_seen_uid); + seq_range_array_add_range(&unwanted_uids, + importer->local_uid_next, highest_seen_uid); seq_range_array_iter_init(&iter, &changes->saved_uids); i = n = 0; while (seq_range_array_iter_nth(&iter, n++, &saved_uid)) { i_assert(i < wanted_count); - if (lowest_saved_uid > saved_uid) - lowest_saved_uid = saved_uid; - if (saved_uid == wanted_uids[i]) { - if (highest_wanted_uid < saved_uid) - highest_wanted_uid = saved_uid; - } else { - IMPORTER_DEBUG_CHANGE(importer); - if (lowest_unwanted_uid > saved_uid) - lowest_unwanted_uid = saved_uid; - } + if (saved_uid == wanted_uids[i]) + seq_range_array_remove(&unwanted_uids, saved_uid); i++; } - i_assert(lowest_unwanted_uid == (uint32_t)-1 || - lowest_unwanted_uid == highest_wanted_uid+1 || - highest_wanted_uid == 0); + i_assert(i == wanted_count); - if (importer->local_uid_next != lowest_saved_uid && - lowest_saved_uid != (uint32_t)-1) { - /* [original local uidnext .. lowest saved_uid-1] */ - mailbox_get_seq_range(importer->box, importer->local_uid_next, - lowest_saved_uid-1, &seq1, &seq2); - if (seq1 > 0) { - if (reassign_uids_in_seq_range(importer->box, - seq1, seq2) < 0) - ret = -1; - *changes_during_sync_r = TRUE; - } - } - - if (lowest_unwanted_uid < importer->remote_uid_next) { - /* [highest wanted_uid+1 .. remote uidnext-1] */ - mailbox_get_seq_range(importer->box, lowest_unwanted_uid, - importer->remote_uid_next-1, &seq1, &seq2); - if (seq1 > 0) { - if (reassign_uids_in_seq_range(importer->box, - seq1, seq2) < 0) - ret = -1; - *changes_during_sync_r = TRUE; - } - } - if (*changes_during_sync_r) { + ret = reassign_uids_in_seq_range(importer->box, &unwanted_uids); + if (ret == 0) { + *changes_during_sync_r = TRUE; /* conflicting changes during sync, revert our last-common-uid back to a safe value. */ importer->last_common_uid = importer->local_uid_next - 1; } - return ret; + return ret < 0 ? -1 : 0; } static int dsync_mailbox_import_commit(struct dsync_mailbox_importer *importer, From dovecot at dovecot.org Sun Feb 17 12:03:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 17 Feb 2013 12:03:33 +0200 Subject: dovecot-2.1: mbox: If namespace prefix is used, don't show details: http://hg.dovecot.org/dovecot-2.1/rev/b96df105ec55 changeset: 14907:b96df105ec55 user: Timo Sirainen date: Sun Feb 17 12:03:06 2013 +0200 description: mbox: If namespace prefix is used, don't show /inbox mailbox. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 1713ffc870c1 -r b96df105ec55 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Sat Feb 16 19:06:18 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Sun Feb 17 12:03:06 2013 +0200 @@ -707,6 +707,10 @@ ctx->info.flags |= MAILBOX_NOSELECT; } else if ((ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 && list_file_is_any_inbox(ctx, storage_name)) { + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { + /* probably mbox inbox file */ + return 0; + } /* shared/user/INBOX */ ctx->info.flags &= ~(MAILBOX_NOSELECT | MAILBOX_NONEXISTENT); ctx->info.flags |= MAILBOX_SELECT; From dovecot at dovecot.org Mon Feb 18 06:32:03 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 06:32:03 +0200 Subject: dovecot-2.2: dsync: Fix to checking which side should do the loc... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/df29194c1ab6 changeset: 15825:df29194c1ab6 user: Timo Sirainen date: Mon Feb 18 06:31:51 2013 +0200 description: dsync: Fix to checking which side should do the locking. diffstat: src/doveadm/dsync/dsync-brain.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 953594b35bb3 -r df29194c1ab6 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Sun Feb 17 11:48:16 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Mon Feb 18 06:31:51 2013 +0200 @@ -193,7 +193,7 @@ const char *home; int ret; - if ((ret = strcmp(remote_hostname, my_hostname)) < 0) { + if ((ret = strcmp(remote_hostname, my_hostdomain())) < 0) { /* locking done by remote */ return 0; } From dovecot at dovecot.org Mon Feb 18 06:36:02 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 06:36:02 +0200 Subject: dovecot-2.2: example-config: Updated hostname setting's comments. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6a67a1440e15 changeset: 15826:6a67a1440e15 user: Timo Sirainen date: Mon Feb 18 06:35:41 2013 +0200 description: example-config: Updated hostname setting's comments. diffstat: doc/example-config/conf.d/15-lda.conf | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r df29194c1ab6 -r 6a67a1440e15 doc/example-config/conf.d/15-lda.conf --- a/doc/example-config/conf.d/15-lda.conf Mon Feb 18 06:31:51 2013 +0200 +++ b/doc/example-config/conf.d/15-lda.conf Mon Feb 18 06:35:41 2013 +0200 @@ -6,8 +6,8 @@ # Default is postmaster@. #postmaster_address = -# Hostname to use in various parts of sent mails, eg. in Message-Id. -# Default is the system's real hostname. +# Hostname to use in various parts of sent mails (e.g. in Message-Id) and +# in LMTP replies. Default is the system's real hostname at domain. #hostname = # If user is over quota, return with temporary failure instead of From dovecot at dovecot.org Mon Feb 18 06:50:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 06:50:10 +0200 Subject: dovecot-2.2: Free my_hostdomain at deinit. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/420477745a17 changeset: 15827:420477745a17 user: Timo Sirainen date: Mon Feb 18 06:49:57 2013 +0200 description: Free my_hostdomain at deinit. diffstat: src/lib/hostpid.c | 5 +++++ src/lib/hostpid.h | 1 + src/lib/lib.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-) diffs (37 lines): diff -r 6a67a1440e15 -r 420477745a17 src/lib/hostpid.c --- a/src/lib/hostpid.c Mon Feb 18 06:35:41 2013 +0200 +++ b/src/lib/hostpid.c Mon Feb 18 06:49:57 2013 +0200 @@ -32,6 +32,11 @@ my_pid = pid; } +void hostpid_deinit(void) +{ + i_free(my_domain); +} + const char *my_hostdomain(void) { struct hostent *hent; diff -r 6a67a1440e15 -r 420477745a17 src/lib/hostpid.h --- a/src/lib/hostpid.h Mon Feb 18 06:35:41 2013 +0200 +++ b/src/lib/hostpid.h Mon Feb 18 06:49:57 2013 +0200 @@ -6,6 +6,7 @@ /* Initializes my_hostname and my_pid. */ void hostpid_init(void); +void hostpid_deinit(void); /* Returns the current host+domain, or if it fails fallback to returning hostname. */ diff -r 6a67a1440e15 -r 420477745a17 src/lib/lib.c --- a/src/lib/lib.c Mon Feb 18 06:35:41 2013 +0200 +++ b/src/lib/lib.c Mon Feb 18 06:49:57 2013 +0200 @@ -77,6 +77,7 @@ } ipwd_deinit(); + hostpid_deinit(); data_stack_deinit(); env_deinit(); failures_deinit(); From dovecot at dovecot.org Mon Feb 18 07:13:03 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 07:13:03 +0200 Subject: dovecot-2.2: master: Don't close stderr. If log process fails at... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cc681437372a changeset: 15828:cc681437372a user: Timo Sirainen date: Mon Feb 18 07:12:44 2013 +0200 description: master: Don't close stderr. If log process fails at startup, the errors are logged there. diffstat: src/master/main.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diffs (16 lines): diff -r 420477745a17 -r cc681437372a src/master/main.c --- a/src/master/main.c Mon Feb 18 06:49:57 2013 +0200 +++ b/src/master/main.c Mon Feb 18 07:12:44 2013 +0200 @@ -894,12 +894,6 @@ if (chdir(set->base_dir) < 0) i_fatal("chdir(%s) failed: %m", set->base_dir); - if (strcmp(services->service_set->log_path, "/dev/stderr") != 0 && - strcmp(services->service_set->info_log_path, "/dev/stderr") != 0 && - strcmp(services->service_set->debug_log_path, "/dev/stderr") != 0) { - if (dup2(null_fd, STDERR_FILENO) < 0) - i_fatal("dup2(null_fd) failed: %m"); - } i_set_fatal_handler(master_fatal_callback); i_set_error_handler(orig_error_callback); From dovecot at dovecot.org Mon Feb 18 07:20:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 07:20:19 +0200 Subject: dovecot-2.2: Master looks up system hostdomain now and sends it ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a6b40687c0a4 changeset: 15829:a6b40687c0a4 user: Timo Sirainen date: Mon Feb 18 07:20:03 2013 +0200 description: Master looks up system hostdomain now and sends it to child processes via environment. This avoids doing a gethostbyname() lookup at startup for each process that needs it. diffstat: src/lib/hostpid.c | 28 ++++++++++++++++++---------- src/lib/hostpid.h | 5 +++++ src/master/service-process.c | 2 ++ 3 files changed, 25 insertions(+), 10 deletions(-) diffs (81 lines): diff -r cc681437372a -r a6b40687c0a4 src/lib/hostpid.c --- a/src/lib/hostpid.c Mon Feb 18 07:12:44 2013 +0200 +++ b/src/lib/hostpid.c Mon Feb 18 07:20:03 2013 +0200 @@ -3,6 +3,7 @@ #include "lib.h" #include "hostpid.h" +#include #include #include @@ -17,13 +18,17 @@ { static char hostname[256], pid[MAX_INT_STRLEN]; - if (gethostname(hostname, sizeof(hostname)-1) == -1) - i_fatal("gethostname() failed: %m"); - hostname[sizeof(hostname)-1] = '\0'; - my_hostname = hostname; + my_hostname = getenv(MY_HOSTNAME_ENV); + if (my_hostname == NULL) { + if (gethostname(hostname, sizeof(hostname)-1) < 0) + i_fatal("gethostname() failed: %m"); + hostname[sizeof(hostname)-1] = '\0'; + my_hostname = hostname; + } - if (strcspn(hostname, HOSTNAME_DISALLOWED_CHARS) != strlen(hostname)) - i_fatal("Invalid system hostname: %s", hostname); + if (my_hostname[0] == '\0' || + strcspn(my_hostname, HOSTNAME_DISALLOWED_CHARS) != strlen(my_hostname)) + i_error("Invalid system hostname: '%s'", my_hostname); /* allow calling hostpid_init() multiple times to reset hostname */ i_free_and_null(my_domain); @@ -43,11 +48,14 @@ const char *name; if (my_domain == NULL) { - hent = gethostbyname(my_hostname); - name = hent != NULL ? hent->h_name : NULL; + name = getenv(MY_HOSTDOMAIN_ENV); if (name == NULL) { - /* failed, use just the hostname */ - name = my_hostname; + hent = gethostbyname(my_hostname); + name = hent != NULL ? hent->h_name : NULL; + if (name == NULL) { + /* failed, use just the hostname */ + name = my_hostname; + } } my_domain = i_strdup(name); } diff -r cc681437372a -r a6b40687c0a4 src/lib/hostpid.h --- a/src/lib/hostpid.h Mon Feb 18 07:12:44 2013 +0200 +++ b/src/lib/hostpid.h Mon Feb 18 07:20:03 2013 +0200 @@ -1,6 +1,11 @@ #ifndef HOSTPID_H #define HOSTPID_H +/* These environments override the hostname/hostdomain if they're set. + Master process normally sets these to child processes. */ +#define MY_HOSTNAME_ENV "DOVECOT_HOSTNAME" +#define MY_HOSTDOMAIN_ENV "DOVECOT_HOSTDOMAIN" + extern const char *my_hostname; extern const char *my_pid; diff -r cc681437372a -r a6b40687c0a4 src/master/service-process.c --- a/src/master/service-process.c Mon Feb 18 07:12:44 2013 +0200 +++ b/src/master/service-process.c Mon Feb 18 07:20:03 2013 +0200 @@ -235,6 +235,8 @@ service->set->service_count)); } env_put(t_strdup_printf(MASTER_UID_ENV"=%u", uid)); + env_put(t_strdup_printf(MY_HOSTNAME_ENV"=%s", my_hostname)); + env_put(t_strdup_printf(MY_HOSTDOMAIN_ENV"=%s", my_hostdomain())); if (!service->set->master_set->version_ignore) env_put(MASTER_DOVECOT_VERSION_ENV"="PACKAGE_VERSION); From dovecot at dovecot.org Mon Feb 18 08:46:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 08:46:15 +0200 Subject: dovecot-2.2: Added guid_128_host_hash_get(). Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/80344aedd8fd changeset: 15830:80344aedd8fd user: Timo Sirainen date: Mon Feb 18 08:45:54 2013 +0200 description: Added guid_128_host_hash_get(). diffstat: src/lib/guid.c | 21 ++++++++++++++------- src/lib/guid.h | 6 ++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diffs (68 lines): diff -r a6b40687c0a4 -r 80344aedd8fd src/lib/guid.c --- a/src/lib/guid.c Mon Feb 18 07:20:03 2013 +0200 +++ b/src/lib/guid.c Mon Feb 18 08:45:54 2013 +0200 @@ -34,12 +34,23 @@ pid, my_hostname); } +void guid_128_host_hash_get(const char *host, + unsigned char hash_r[GUID_128_HOST_HASH_SIZE]) +{ + unsigned char full_hash[SHA1_RESULTLEN]; + + sha1_get_digest(host, strlen(host), full_hash); + memcpy(hash_r, full_hash + sizeof(full_hash)-GUID_128_HOST_HASH_SIZE, + GUID_128_HOST_HASH_SIZE); +} + void guid_128_generate(guid_128_t guid_r) { +#if GUID_128_HOST_HASH_SIZE != 4 +# error GUID_128_HOST_HASH_SIZE must be 4 +#endif static struct timespec ts = { 0, 0 }; static uint8_t guid_static[8]; - unsigned char hostdomain_hash[SHA1_RESULTLEN]; - const char *hostdomain; uint32_t pid; /* we'll use the current time in nanoseconds as the initial 64bit @@ -48,16 +59,12 @@ if (clock_gettime(CLOCK_REALTIME, &ts) < 0) i_fatal("clock_gettime() failed: %m"); pid = getpid(); - hostdomain = my_hostdomain(); - sha1_get_digest(hostdomain, strlen(hostdomain), - hostdomain_hash); guid_static[0] = (pid & 0x000000ff); guid_static[1] = (pid & 0x0000ff00) >> 8; guid_static[2] = (pid & 0x00ff0000) >> 16; guid_static[3] = (pid & 0xff000000) >> 24; - memcpy(guid_static+4, - hostdomain_hash+sizeof(hostdomain_hash)-4, 4); + guid_128_host_hash_get(my_hostdomain(), guid_static+4); } else if ((uint32_t)ts.tv_nsec < (uint32_t)-1) { ts.tv_nsec++; } else { diff -r a6b40687c0a4 -r 80344aedd8fd src/lib/guid.h --- a/src/lib/guid.h Mon Feb 18 07:20:03 2013 +0200 +++ b/src/lib/guid.h Mon Feb 18 08:45:54 2013 +0200 @@ -4,6 +4,8 @@ #define GUID_128_SIZE 16 typedef uint8_t guid_128_t[GUID_128_SIZE]; +#define GUID_128_HOST_HASH_SIZE 4 + /* Generate a GUID (contains host name) */ const char *guid_generate(void); /* Generate 128 bit GUID */ @@ -20,4 +22,8 @@ unsigned int guid_128_hash(const uint8_t *guid); int guid_128_cmp(const uint8_t *guid1, const uint8_t *guid2); +/* Return the hash of host used by guid_128_generate(). */ +void guid_128_host_hash_get(const char *host, + unsigned char hash_r[GUID_128_HOST_HASH_SIZE]); + #endif From dovecot at dovecot.org Mon Feb 18 08:46:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 08:46:15 +0200 Subject: dovecot-2.2: doveconf: Added -H parameter to check for hostname ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/62a930eb22b5 changeset: 15831:62a930eb22b5 user: Timo Sirainen date: Mon Feb 18 08:46:06 2013 +0200 description: doveconf: Added -H parameter to check for hostname hash duplicates. diffstat: src/config/doveconf.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 116 insertions(+), 2 deletions(-) diffs (170 lines): diff -r 80344aedd8fd -r 62a930eb22b5 src/config/doveconf.c --- a/src/config/doveconf.c Mon Feb 18 08:45:54 2013 +0200 +++ b/src/config/doveconf.c Mon Feb 18 08:46:06 2013 +0200 @@ -5,6 +5,9 @@ #include "abspath.h" #include "module-dir.h" #include "env-util.h" +#include "guid.h" +#include "hash.h" +#include "hostpid.h" #include "ostream.h" #include "str.h" #include "strescape.h" @@ -19,6 +22,7 @@ #include #include +#include #include #include @@ -564,6 +568,110 @@ } } +struct hostname_format { + const char *prefix, *suffix; + unsigned int numcount; + bool zeropadding; +}; + +static void +hostname_format_write(string_t *str, const struct hostname_format *fmt, + unsigned int num) +{ + str_truncate(str, 0); + str_append(str, fmt->prefix); + if (!fmt->zeropadding) + str_printfa(str, "%d", num); + else + str_printfa(str, "%0*d", fmt->numcount, num); + str_append(str, fmt->suffix); +} + +static void hostname_verify_format(const char *arg) +{ + struct hostname_format fmt; + const char *p; + unsigned char hash[GUID_128_HOST_HASH_SIZE]; + unsigned int len, n, limit; + HASH_TABLE(void *, void *) hosts; + void *key, *value; + string_t *host; + const char *host2; + bool duplicates = FALSE; + + memset(&fmt, 0, sizeof(fmt)); + if (arg != NULL) { + /* host%d, host%2d, host%02d */ + p = strchr(arg, '%'); + if (p == NULL) + i_fatal("Host parameter missing %%d"); + fmt.prefix = t_strdup_until(arg, p++); + if (*p == '0') { + fmt.zeropadding = TRUE; + p++; + } + if (!i_isdigit(*p)) + fmt.numcount = 1; + else + fmt.numcount = *p++ - '0'; + if (*p++ != 'd') + i_fatal("Host parameter missing %%d"); + fmt.suffix = p; + } else { + /* detect host1[suffix] vs host01[suffix] */ + len = strlen(my_hostname); + while (len > 0 && !i_isdigit(my_hostname[len-1])) + len--; + fmt.suffix = my_hostname + len; + fmt.numcount = 0; + while (len > 0 && i_isdigit(my_hostname[len-1])) { + len--; + fmt.numcount++; + } + if (my_hostname[len] == '0') + fmt.zeropadding = TRUE; + fmt.prefix = t_strndup(my_hostname, len); + if (fmt.numcount == 0) { + i_fatal("Hostname '%s' has no digits, can't verify", + my_hostname); + } + } + for (n = 0, limit = 1; n < fmt.numcount; n++) + limit *= 10; + host = t_str_new(128); + hash_table_create_direct(&hosts, default_pool, limit); + for (n = 0; n < limit; n++) { + hostname_format_write(host, &fmt, n); + + guid_128_host_hash_get(str_c(host), hash); + i_assert(sizeof(key) >= sizeof(hash)); + key = NULL; memcpy(&key, hash, sizeof(hash)); + + value = hash_table_lookup(hosts, key); + if (value != NULL) { + host2 = t_strdup(str_c(host)); + hostname_format_write(host, &fmt, + POINTER_CAST_TO(value, unsigned int)-1); + i_error("Duplicate host hashes: %s and %s", + str_c(host), host2); + duplicates = TRUE; + } else { + hash_table_insert(hosts, key, POINTER_CAST(n+1)); + } + } + hash_table_destroy(&hosts); + + if (duplicates) + exit(EX_CONFIG); + else { + host2 = t_strdup(str_c(host)); + hostname_format_write(host, &fmt, 0); + printf("No duplicate host hashes in %s .. %s\n", + str_c(host), host2); + exit(0); + } +} + static void check_wrong_config(const char *config_path) { const char *base_dir, *symlink_path, *prev_path; @@ -598,7 +706,7 @@ int c, ret, ret2; bool config_path_specified, expand_vars = FALSE, hide_key = FALSE; bool parse_full_config = FALSE, simple_output = FALSE; - bool dump_defaults = FALSE; + bool dump_defaults = FALSE, host_verify = FALSE; if (getenv("USE_SYSEXITS") != NULL) { /* we're coming from (e.g.) LDA */ @@ -608,7 +716,7 @@ memset(&filter, 0, sizeof(filter)); master_service = master_service_init("config", MASTER_SERVICE_FLAG_STANDALONE, - &argc, &argv, "adf:hm:nNpexS"); + &argc, &argv, "adf:hHm:nNpexS"); orig_config_path = master_service_get_config_path(master_service); i_set_failure_prefix("doveconf: "); @@ -630,6 +738,9 @@ case 'h': hide_key = TRUE; break; + case 'H': + host_verify = TRUE; + break; case 'm': module = t_strdup(optarg); array_append(&module_names, &module, 1); @@ -662,6 +773,9 @@ -c parameter */ config_path_specified = strcmp(config_path, orig_config_path) != 0; + if (host_verify) + hostname_verify_format(argv[optind]); + if (c == 'e') { if (argv[optind] == NULL) i_fatal("Missing command for -e"); From dovecot at dovecot.org Mon Feb 18 15:14:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 15:14:12 +0200 Subject: dovecot-2.2: my_hostname was broken because of recent change. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/19e4448dee4f changeset: 15832:19e4448dee4f user: Timo Sirainen date: Mon Feb 18 15:12:26 2013 +0200 description: my_hostname was broken because of recent change. diffstat: src/lib/hostpid.c | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) diffs (54 lines): diff -r 62a930eb22b5 -r 19e4448dee4f src/lib/hostpid.c --- a/src/lib/hostpid.c Mon Feb 18 08:46:06 2013 +0200 +++ b/src/lib/hostpid.c Mon Feb 18 15:12:26 2013 +0200 @@ -12,26 +12,32 @@ const char *my_hostname = NULL; const char *my_pid = NULL; +static char *my_hostname_dup = NULL; static char *my_domain = NULL; void hostpid_init(void) { - static char hostname[256], pid[MAX_INT_STRLEN]; + static char pid[MAX_INT_STRLEN]; + char hostname[256]; + const char *value; - my_hostname = getenv(MY_HOSTNAME_ENV); - if (my_hostname == NULL) { + /* allow calling hostpid_init() multiple times to reset hostname */ + i_free_and_null(my_hostname_dup); + i_free_and_null(my_domain); + + value = getenv(MY_HOSTNAME_ENV); + if (value == NULL) { if (gethostname(hostname, sizeof(hostname)-1) < 0) i_fatal("gethostname() failed: %m"); hostname[sizeof(hostname)-1] = '\0'; - my_hostname = hostname; + value = hostname; } - if (my_hostname[0] == '\0' || - strcspn(my_hostname, HOSTNAME_DISALLOWED_CHARS) != strlen(my_hostname)) - i_error("Invalid system hostname: '%s'", my_hostname); - - /* allow calling hostpid_init() multiple times to reset hostname */ - i_free_and_null(my_domain); + if (value[0] == '\0' || + strcspn(value, HOSTNAME_DISALLOWED_CHARS) != strlen(value)) + i_error("Invalid system hostname: '%s'", value); + my_hostname_dup = i_strdup(value); + my_hostname = my_hostname_dup; i_snprintf(pid, sizeof(pid), "%lld", (long long)getpid()); my_pid = pid; @@ -39,6 +45,7 @@ void hostpid_deinit(void) { + i_free(my_hostname_dup); i_free(my_domain); } From dovecot at dovecot.org Mon Feb 18 15:14:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 18 Feb 2013 15:14:12 +0200 Subject: dovecot-2.2: log: Don't crash if log client sends line with pid=0. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3ca7e0eaaf4b changeset: 15833:3ca7e0eaaf4b user: Timo Sirainen date: Mon Feb 18 15:14:05 2013 +0200 description: log: Don't crash if log client sends line with pid=0. diffstat: src/log/log-connection.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 19e4448dee4f -r 3ca7e0eaaf4b src/log/log-connection.c --- a/src/log/log-connection.c Mon Feb 18 15:12:26 2013 +0200 +++ b/src/log/log-connection.c Mon Feb 18 15:14:05 2013 +0200 @@ -201,6 +201,11 @@ } i_failure_parse_line(line, &failure); + if (failure.pid == 0) { + i_error("Invalid log line: %s", line); + return; + } + switch (failure.log_type) { case LOG_TYPE_FATAL: case LOG_TYPE_PANIC: From dovecot at dovecot.org Tue Feb 19 08:18:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 08:18:01 +0200 Subject: dovecot-2.2: log: Recent log parser change started logging "Inva... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/be857a95b381 changeset: 15834:be857a95b381 user: Timo Sirainen date: Tue Feb 19 08:17:50 2013 +0200 description: log: Recent log parser change started logging "Invalid log line" errors unintentionally. diffstat: src/log/log-connection.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diffs (34 lines): diff -r 3ca7e0eaaf4b -r be857a95b381 src/log/log-connection.c --- a/src/log/log-connection.c Mon Feb 18 15:14:05 2013 +0200 +++ b/src/log/log-connection.c Tue Feb 19 08:17:50 2013 +0200 @@ -201,23 +201,21 @@ } i_failure_parse_line(line, &failure); - if (failure.pid == 0) { - i_error("Invalid log line: %s", line); - return; - } - switch (failure.log_type) { case LOG_TYPE_FATAL: case LOG_TYPE_PANIC: - client = log_client_get(log, failure.pid); - client->fatal_logged = TRUE; + if (failure.pid != 0) { + client = log_client_get(log, failure.pid); + client->fatal_logged = TRUE; + } break; case LOG_TYPE_OPTION: log_parse_option(log, &failure); return; default: - client = hash_table_lookup(log->clients, - POINTER_CAST(failure.pid)); + client = failure.pid == 0 ? NULL : + hash_table_lookup(log->clients, + POINTER_CAST(failure.pid)); break; } i_assert(failure.log_type < LOG_TYPE_COUNT); From dovecot at dovecot.org Tue Feb 19 08:27:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 08:27:50 +0200 Subject: dovecot-2.2: lib-storage: Saving/copying no longer discards priv... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/02529503c59c changeset: 15835:02529503c59c user: Timo Sirainen date: Tue Feb 19 08:27:40 2013 +0200 description: lib-storage: Saving/copying no longer discards private message flags. diffstat: src/lib-storage/index/index-sync-private.h | 14 +- src/lib-storage/index/index-sync-pvt.c | 266 ++++++++++++++++++++-------- src/lib-storage/index/index-sync.c | 9 +- src/lib-storage/index/index-transaction.c | 17 + src/lib-storage/mail-storage-private.h | 13 + src/lib-storage/mail-storage.c | 51 ++++- src/plugins/acl/acl-mailbox.c | 20 +- src/plugins/virtual/virtual-save.c | 3 +- 8 files changed, 293 insertions(+), 100 deletions(-) diffs (truncated from 716 to 300 lines): diff -r be857a95b381 -r 02529503c59c src/lib-storage/index/index-sync-private.h --- a/src/lib-storage/index/index-sync-private.h Tue Feb 19 08:17:50 2013 +0200 +++ b/src/lib-storage/index/index-sync-private.h Tue Feb 19 08:27:40 2013 +0200 @@ -3,6 +3,8 @@ #include "index-storage.h" +struct index_mailbox_sync_pvt_context; + struct index_mailbox_sync_context { struct mailbox_sync_context ctx; @@ -22,8 +24,14 @@ void index_sync_search_results_update(struct index_mailbox_sync_context *ctx); void index_sync_search_results_expunge(struct index_mailbox_sync_context *ctx); -int index_storage_mailbox_sync_pvt(struct mailbox *box, - ARRAY_TYPE(seq_range) *flag_updates, - ARRAY_TYPE(seq_range) *hidden_updates); +/* Returns 1 = ok, 0 = no private indexes, -1 = error */ +int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock, + struct index_mailbox_sync_pvt_context **ctx_r); +int index_mailbox_sync_pvt_newmails(struct index_mailbox_sync_pvt_context *ctx, + struct mailbox_transaction_context *trans); +int index_mailbox_sync_pvt_view(struct index_mailbox_sync_pvt_context *ctx, + ARRAY_TYPE(seq_range) *flag_updates, + ARRAY_TYPE(seq_range) *hidden_updates); +void index_mailbox_sync_pvt_deinit(struct index_mailbox_sync_pvt_context **ctx); #endif diff -r be857a95b381 -r 02529503c59c src/lib-storage/index/index-sync-pvt.c --- a/src/lib-storage/index/index-sync-pvt.c Tue Feb 19 08:17:50 2013 +0200 +++ b/src/lib-storage/index/index-sync-pvt.c Tue Feb 19 08:27:40 2013 +0200 @@ -4,31 +4,37 @@ #include "mailbox-list-private.h" #include "index-sync-private.h" -static int sync_pvt_expunges(struct mailbox *box, - struct mail_index_view *view_pvt, - struct mail_index_transaction *trans_pvt, - struct mail_index_view *view_shared) +struct index_mailbox_sync_pvt_context { + struct mailbox *box; + + struct mail_index_sync_ctx *sync_ctx; + struct mail_index_view *view_pvt; + struct mail_index_transaction *trans_pvt; + struct mail_index_view *view_shared; +}; + +static int sync_pvt_expunges(struct index_mailbox_sync_pvt_context *ctx) { uint32_t seq_shared, seq_pvt, count_shared, count_pvt; uint32_t uid_shared, uid_pvt; - count_shared = mail_index_view_get_messages_count(view_shared); - count_pvt = mail_index_view_get_messages_count(view_pvt); + count_shared = mail_index_view_get_messages_count(ctx->view_shared); + count_pvt = mail_index_view_get_messages_count(ctx->view_pvt); seq_shared = seq_pvt = 1; while (seq_pvt <= count_pvt && seq_shared <= count_shared) { - mail_index_lookup_uid(view_pvt, seq_pvt, &uid_pvt); - mail_index_lookup_uid(view_shared, seq_shared, &uid_shared); + mail_index_lookup_uid(ctx->view_pvt, seq_pvt, &uid_pvt); + mail_index_lookup_uid(ctx->view_shared, seq_shared, &uid_shared); if (uid_pvt == uid_shared) { seq_pvt++; seq_shared++; } else if (uid_pvt < uid_shared) { /* message expunged */ - mail_index_expunge(trans_pvt, seq_pvt); + mail_index_expunge(ctx->trans_pvt, seq_pvt); seq_pvt++; } else { - mail_storage_set_critical(box->storage, + mail_storage_set_critical(ctx->box->storage, "%s: Message UID=%u unexpectedly inserted to mailbox", - box->index_pvt->filepath, uid_shared); + ctx->box->index_pvt->filepath, uid_shared); return -1; } } @@ -36,78 +42,122 @@ } static void -sync_pvt_copy_self_flags(struct mailbox *box, - struct mail_index_view *view, - struct mail_index_transaction *trans, +sync_pvt_copy_self_flags(struct index_mailbox_sync_pvt_context *ctx, ARRAY_TYPE(keyword_indexes) *keywords, uint32_t seq_old, uint32_t seq_new) { const struct mail_index_record *old_rec; - old_rec = mail_index_lookup(view, seq_old); - mail_index_lookup_keywords(view, seq_old, keywords); + old_rec = mail_index_lookup(ctx->view_pvt, seq_old); + mail_index_lookup_keywords(ctx->view_pvt, seq_old, keywords); if (old_rec->flags != 0) { - mail_index_update_flags(trans, seq_new, + mail_index_update_flags(ctx->trans_pvt, seq_new, MODIFY_ADD, old_rec->flags); } if (array_count(keywords) > 0) { struct mail_keywords *kw; - kw = mail_index_keywords_create_from_indexes(box->index_pvt, + kw = mail_index_keywords_create_from_indexes(ctx->box->index_pvt, keywords); - mail_index_update_keywords(trans, seq_new, MODIFY_ADD, kw); + mail_index_update_keywords(ctx->trans_pvt, seq_new, + MODIFY_ADD, kw); mail_index_keywords_unref(&kw); } } static int -index_storage_mailbox_sync_pvt_index(struct mailbox *box) +index_mailbox_sync_view_refresh(struct index_mailbox_sync_pvt_context *ctx) { - struct mail_index_sync_ctx *sync_ctx; - struct mail_index_view *view_pvt; - struct mail_index_transaction *trans_pvt; + /* open a view for the latest version of the index */ + if (mail_index_refresh(ctx->box->index_pvt) < 0 || + mail_index_refresh(ctx->box->index) < 0) { + mailbox_set_index_error(ctx->box); + return -1; + } + if (ctx->view_shared != NULL) + mail_index_view_close(&ctx->view_shared); + ctx->view_shared = mail_index_view_open(ctx->box->index); + return 0; +} + +static int +index_mailbox_sync_open(struct index_mailbox_sync_pvt_context *ctx, bool force) +{ const struct mail_index_header *hdr_shared, *hdr_pvt; - struct mail_index_view *view_shared; + + if (index_mailbox_sync_view_refresh(ctx) < 0) + return -1; + + hdr_shared = mail_index_get_header(ctx->view_shared); + if (hdr_shared->uid_validity == 0 && !force) { + /* the mailbox hasn't been fully created yet, + no need for a private index yet */ + return 0; + } + hdr_pvt = mail_index_get_header(ctx->box->view_pvt); + if (hdr_pvt->next_uid == hdr_shared->next_uid && + hdr_pvt->messages_count == hdr_shared->messages_count && !force) { + /* no new or expunged mails, don't bother syncing */ + return 0; + } + if (mail_index_sync_begin(ctx->box->index_pvt, &ctx->sync_ctx, + &ctx->view_pvt, &ctx->trans_pvt, 0) < 0) { + mailbox_set_index_error(ctx->box); + return -1; + } + /* refresh once more now that we're locked */ + if (index_mailbox_sync_view_refresh(ctx) < 0) + return -1; + return 1; +} + +int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock, + struct index_mailbox_sync_pvt_context **ctx_r) +{ + struct index_mailbox_sync_pvt_context *ctx; + int ret; + + *ctx_r = NULL; + + if ((ret = mailbox_open_index_pvt(box)) <= 0) + return ret; + + ctx = i_new(struct index_mailbox_sync_pvt_context, 1); + ctx->box = box; + if (lock) { + if (index_mailbox_sync_open(ctx, TRUE) < 0) { + index_mailbox_sync_pvt_deinit(&ctx); + return -1; + } + } + + *ctx_r = ctx; + return 1; +} + +static int +index_mailbox_sync_pvt_index(struct index_mailbox_sync_pvt_context *ctx, + const struct mail_save_private_changes *pvt_changes, + unsigned int pvt_changes_count) +{ + const struct mail_index_header *hdr_shared, *hdr_pvt; ARRAY_TYPE(keyword_indexes) keywords; uint32_t seq_shared, seq_pvt, seq_old_pvt, seq2, count_shared, uid; + unsigned int pc_idx = 0; bool reset = FALSE, preserve_old_flags = FALSE; int ret; - /* open a view for the latest version of the index */ - if (mail_index_refresh(box->index) < 0 || - mail_index_refresh(box->index_pvt) < 0) { - mailbox_set_index_error(box); - return -1; + if (ctx->sync_ctx == NULL) { + if ((ret = index_mailbox_sync_open(ctx, FALSE)) <= 0) + return ret; } - view_shared = mail_index_view_open(box->index); - hdr_shared = mail_index_get_header(view_shared); - if (hdr_shared->uid_validity == 0) { - /* the mailbox hasn't been fully created yet, - no need for a private index yet */ - mail_index_view_close(&view_shared); - return 0; - } - hdr_pvt = mail_index_get_header(box->view_pvt); - if (hdr_pvt->next_uid == hdr_shared->next_uid && - hdr_pvt->messages_count == hdr_shared->messages_count) { - /* no new or expunged mails, don't bother syncing */ - mail_index_view_close(&view_shared); - return 0; - } - - if (mail_index_sync_begin(box->index_pvt, &sync_ctx, - &view_pvt, &trans_pvt, 0) < 0) { - mailbox_set_index_error(box); - mail_index_view_close(&view_shared); - return -1; - } - /* get an updated private header */ - hdr_pvt = mail_index_get_header(view_pvt); + hdr_pvt = mail_index_get_header(ctx->view_pvt); + hdr_shared = mail_index_get_header(ctx->view_shared); if (hdr_shared->uid_validity == hdr_pvt->uid_validity) { /* same mailbox. expunge messages from private index that no longer exist. */ - if (sync_pvt_expunges(box, view_pvt, trans_pvt, view_shared) < 0) { + if (sync_pvt_expunges(ctx) < 0) { reset = TRUE; preserve_old_flags = TRUE; t_array_init(&keywords, 32); @@ -117,17 +167,18 @@ reset = TRUE; } - count_shared = mail_index_view_get_messages_count(view_shared); + count_shared = mail_index_view_get_messages_count(ctx->view_shared); if (!reset) { - if (!mail_index_lookup_seq_range(view_shared, hdr_pvt->next_uid, + if (!mail_index_lookup_seq_range(ctx->view_shared, + hdr_pvt->next_uid, hdr_shared->next_uid, &seq_shared, &seq2)) { /* no new messages */ seq_shared = count_shared+1; } } else { - mail_index_reset(trans_pvt); - mail_index_update_header(trans_pvt, + mail_index_reset(ctx->trans_pvt); + mail_index_update_header(ctx->trans_pvt, offsetof(struct mail_index_header, uid_validity), &hdr_shared->uid_validity, sizeof(hdr_shared->uid_validity), TRUE); @@ -136,56 +187,100 @@ uid = 0; for (; seq_shared <= count_shared; seq_shared++) { - mail_index_lookup_uid(view_shared, seq_shared, &uid); - mail_index_append(trans_pvt, uid, &seq_pvt); + mail_index_lookup_uid(ctx->view_shared, seq_shared, &uid); + mail_index_append(ctx->trans_pvt, uid, &seq_pvt); if (preserve_old_flags && - mail_index_lookup_seq(view_pvt, uid, &seq_old_pvt)) { - /* copy flags from the original index */ - sync_pvt_copy_self_flags(box, view_pvt, trans_pvt, - &keywords, + mail_index_lookup_seq(ctx->view_pvt, uid, &seq_old_pvt)) { + /* copy flags from the original private index */ + sync_pvt_copy_self_flags(ctx, &keywords, seq_old_pvt, seq_pvt); } + /* add private flags for the recently saved/copied messages */ + while (pc_idx < pvt_changes_count && + pvt_changes[pc_idx].mailnum <= uid) { + if (pvt_changes[pc_idx].mailnum == uid) { + mail_index_update_flags(ctx->trans_pvt, seq_pvt, + MODIFY_ADD, pvt_changes[pc_idx].flags); + } + pc_idx++; + } } From dovecot at dovecot.org Tue Feb 19 08:36:08 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 08:36:08 +0200 Subject: dovecot-2.2: dsync: Renamed -a parameter to -N. It also now skip... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/607758d425e7 changeset: 15836:607758d425e7 user: Timo Sirainen date: Tue Feb 19 08:35:23 2013 +0200 description: dsync: Renamed -a parameter to -N. It also now skips invisible namespaces. diffstat: src/doveadm/dsync/doveadm-dsync.c | 18 +++++++++--------- src/doveadm/dsync/dsync-brain-mailbox-tree.c | 9 +++++++-- src/doveadm/dsync/dsync-brain-private.h | 2 +- src/doveadm/dsync/dsync-brain.c | 4 ++-- src/doveadm/dsync/dsync-brain.h | 2 +- src/doveadm/dsync/dsync-ibc-stream.c | 10 +++++----- 6 files changed, 25 insertions(+), 20 deletions(-) diffs (154 lines): diff -r 02529503c59c -r 607758d425e7 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Tue Feb 19 08:27:40 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Tue Feb 19 08:35:23 2013 +0200 @@ -30,7 +30,7 @@ #include #include -#define DSYNC_COMMON_GETOPT_ARGS "+adEfl:m:n:r:Rs:" +#define DSYNC_COMMON_GETOPT_ARGS "+dEfl:m:n:Nr:Rs:" #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30 struct dsync_cmd_context { @@ -50,7 +50,7 @@ unsigned int lock_timeout; unsigned int lock:1; - unsigned int sync_all_namespaces:1; + unsigned int sync_visible_namespaces:1; unsigned int default_replica_location:1; unsigned int backup:1; unsigned int reverse_backup:1; @@ -429,8 +429,8 @@ } brain_flags = DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS; - if (ctx->sync_all_namespaces) - brain_flags |= DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES; + if (ctx->sync_visible_namespaces) + brain_flags |= DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES; if (ctx->reverse_backup) brain_flags |= DSYNC_BRAIN_FLAG_BACKUP_RECV; @@ -550,8 +550,8 @@ run_cmd(ctx, remote_cmd_args); ctx->remote = TRUE; } - if (ctx->sync_all_namespaces && !ctx->remote) - i_fatal("-a parameter requires syncing with remote host"); + if (ctx->sync_visible_namespaces && !ctx->remote) + i_fatal("-N parameter requires syncing with remote host"); return 0; } @@ -583,9 +583,6 @@ struct dsync_cmd_context *ctx = (struct dsync_cmd_context *)_ctx; switch (c) { - case 'a': - ctx->sync_all_namespaces = TRUE; - break; case 'd': ctx->default_replica_location = TRUE; break; @@ -607,6 +604,9 @@ case 'n': ctx->namespace_prefix = optarg; break; + case 'N': + ctx->sync_visible_namespaces = TRUE; + break; case 'r': ctx->rawlog_path = optarg; break; diff -r 02529503c59c -r 607758d425e7 src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Tue Feb 19 08:27:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Tue Feb 19 08:35:23 2013 +0200 @@ -16,8 +16,13 @@ { if (brain->sync_ns == ns) return TRUE; - if (brain->sync_all_namespaces) - return TRUE; + if (brain->sync_visible_namespaces) { + if ((ns->flags & NAMESPACE_FLAG_HIDDEN) == 0) + return TRUE; + if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) != 0) + return TRUE; + } return brain->sync_ns == NULL && strcmp(ns->unexpanded_set->location, diff -r 02529503c59c -r 607758d425e7 src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Tue Feb 19 08:27:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-private.h Tue Feb 19 08:35:23 2013 +0200 @@ -89,7 +89,7 @@ unsigned int backup_send:1; unsigned int backup_recv:1; unsigned int debug:1; - unsigned int sync_all_namespaces:1; + unsigned int sync_visible_namespaces:1; unsigned int changes_during_sync:1; unsigned int failed:1; }; diff -r 02529503c59c -r 607758d425e7 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Tue Feb 19 08:27:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Tue Feb 19 08:35:23 2013 +0200 @@ -79,8 +79,8 @@ brain->backup_send = (flags & DSYNC_BRAIN_FLAG_BACKUP_SEND) != 0; brain->backup_recv = (flags & DSYNC_BRAIN_FLAG_BACKUP_RECV) != 0; brain->debug = (flags & DSYNC_BRAIN_FLAG_DEBUG) != 0; - brain->sync_all_namespaces = - (flags & DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES) != 0; + brain->sync_visible_namespaces = + (flags & DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES) != 0; } struct dsync_brain * diff -r 02529503c59c -r 607758d425e7 src/doveadm/dsync/dsync-brain.h --- a/src/doveadm/dsync/dsync-brain.h Tue Feb 19 08:27:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.h Tue Feb 19 08:35:23 2013 +0200 @@ -10,7 +10,7 @@ DSYNC_BRAIN_FLAG_BACKUP_SEND = 0x02, DSYNC_BRAIN_FLAG_BACKUP_RECV = 0x04, DSYNC_BRAIN_FLAG_DEBUG = 0x08, - DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES = 0x10 + DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES= 0x10 }; enum dsync_brain_sync_type { diff -r 02529503c59c -r 607758d425e7 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Tue Feb 19 08:27:40 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Tue Feb 19 08:35:23 2013 +0200 @@ -66,7 +66,7 @@ { .name = "handshake", .chr = 'H', .required_keys = "hostname", - .optional_keys = "sync_ns_prefix sync_box sync_type debug sync_all_namespaces " + .optional_keys = "sync_ns_prefix sync_box sync_type debug sync_visible_namespaces " "send_mail_requests backup_send backup_recv lock_timeout" }, { .name = "mailbox_state", @@ -571,8 +571,8 @@ dsync_serializer_encode_add(encoder, "backup_recv", ""); if ((set->brain_flags & DSYNC_BRAIN_FLAG_DEBUG) != 0) dsync_serializer_encode_add(encoder, "debug", ""); - if ((set->brain_flags & DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES) != 0) - dsync_serializer_encode_add(encoder, "sync_all_namespaces", ""); + if ((set->brain_flags & DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES) != 0) + dsync_serializer_encode_add(encoder, "sync_visible_namespaces", ""); dsync_serializer_encode_finish(&encoder, str); dsync_ibc_stream_send_string(ibc, str); @@ -641,8 +641,8 @@ set->brain_flags |= DSYNC_BRAIN_FLAG_BACKUP_RECV; if (dsync_deserializer_decode_try(decoder, "debug", &value)) set->brain_flags |= DSYNC_BRAIN_FLAG_DEBUG; - if (dsync_deserializer_decode_try(decoder, "sync_all_namespaces", &value)) - set->brain_flags |= DSYNC_BRAIN_FLAG_SYNC_ALL_NAMESPACES; + if (dsync_deserializer_decode_try(decoder, "sync_visible_namespaces", &value)) + set->brain_flags |= DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES; *set_r = set; return DSYNC_IBC_RECV_RET_OK; From dovecot at dovecot.org Tue Feb 19 08:36:08 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 08:36:08 +0200 Subject: dovecot-2.2: replicator: Use -N parameter for dsync (replicate a... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fc2dca0b54c5 changeset: 15837:fc2dca0b54c5 user: Timo Sirainen date: Tue Feb 19 08:35:57 2013 +0200 description: replicator: Use -N parameter for dsync (replicate all visible namespaces). diffstat: src/replication/replicator/doveadm-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 607758d425e7 -r fc2dca0b54c5 src/replication/replicator/doveadm-connection.c --- a/src/replication/replicator/doveadm-connection.c Tue Feb 19 08:35:23 2013 +0200 +++ b/src/replication/replicator/doveadm-connection.c Tue Feb 19 08:35:57 2013 +0200 @@ -206,7 +206,7 @@ cmd = t_str_new(256); str_append_c(cmd, '\t'); str_append_tabescaped(cmd, username); - str_printfa(cmd, "\tsync\t-d\t-l\t%u", DSYNC_LOCK_TIMEOUT_SECS); + str_printfa(cmd, "\tsync\t-d\t-N\t-l\t%u", DSYNC_LOCK_TIMEOUT_SECS); if (full) str_append(cmd, "\t-f"); str_append(cmd, "\t-s\t"); From dovecot at dovecot.org Tue Feb 19 08:54:43 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 08:54:43 +0200 Subject: dovecot-2.2: lib-storage: Copy initial private message flags fro... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0e236dd1bad3 changeset: 15838:0e236dd1bad3 user: Timo Sirainen date: Tue Feb 19 08:54:32 2013 +0200 description: lib-storage: Copy initial private message flags from shared flags for public mailboxes. diffstat: src/lib-storage/index/index-sync-pvt.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diffs (52 lines): diff -r fc2dca0b54c5 -r 0e236dd1bad3 src/lib-storage/index/index-sync-pvt.c --- a/src/lib-storage/index/index-sync-pvt.c Tue Feb 19 08:35:57 2013 +0200 +++ b/src/lib-storage/index/index-sync-pvt.c Tue Feb 19 08:54:32 2013 +0200 @@ -65,6 +65,17 @@ } } +static void +sync_pvt_copy_shared_flags(struct index_mailbox_sync_pvt_context *ctx, + uint32_t seq_shared, uint32_t seq_pvt) +{ + const struct mail_index_record *rec; + + rec = mail_index_lookup(ctx->view_shared, seq_shared); + mail_index_update_flags(ctx->trans_pvt, seq_pvt, MODIFY_ADD, + rec->flags & mailbox_get_private_flags_mask(ctx->box)); +} + static int index_mailbox_sync_view_refresh(struct index_mailbox_sync_pvt_context *ctx) { @@ -144,7 +155,7 @@ ARRAY_TYPE(keyword_indexes) keywords; uint32_t seq_shared, seq_pvt, seq_old_pvt, seq2, count_shared, uid; unsigned int pc_idx = 0; - bool reset = FALSE, preserve_old_flags = FALSE; + bool reset = FALSE, preserve_old_flags = FALSE, copy_shared_flags; int ret; if (ctx->sync_ctx == NULL) { @@ -166,6 +177,10 @@ /* mailbox created/recreated */ reset = TRUE; } + /* for public namespaces copy the initial private flags from the shared + index. this allows Sieve scripts to set the initial flags. */ + copy_shared_flags = + ctx->box->list->ns->type == MAIL_NAMESPACE_TYPE_PUBLIC; count_shared = mail_index_view_get_messages_count(ctx->view_shared); if (!reset) { @@ -194,7 +209,10 @@ /* copy flags from the original private index */ sync_pvt_copy_self_flags(ctx, &keywords, seq_old_pvt, seq_pvt); + } else if (copy_shared_flags) { + sync_pvt_copy_shared_flags(ctx, seq_shared, seq_pvt); } + /* add private flags for the recently saved/copied messages */ while (pc_idx < pvt_changes_count && pvt_changes[pc_idx].mailnum <= uid) { From dovecot at dovecot.org Tue Feb 19 09:32:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 09:32:57 +0200 Subject: dovecot-2.2: replication plugin: Notify replicator also for chan... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/556d05100810 changeset: 15839:556d05100810 user: Timo Sirainen date: Tue Feb 19 09:32:11 2013 +0200 description: replication plugin: Notify replicator also for changes in public mailboxes. diffstat: src/plugins/replication/replication-plugin.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diffs (14 lines): diff -r 0e236dd1bad3 -r 556d05100810 src/plugins/replication/replication-plugin.c --- a/src/plugins/replication/replication-plugin.c Tue Feb 19 08:54:32 2013 +0200 +++ b/src/plugins/replication/replication-plugin.c Tue Feb 19 09:32:11 2013 +0200 @@ -186,10 +186,6 @@ return; } - if (ns->owner == NULL) { - /* public namespace. we can't handle this for now. */ - return; - } ruser = REPLICATION_USER_CONTEXT(ns->owner); if (priority == REPLICATION_PRIORITY_SYNC) { From dovecot at dovecot.org Tue Feb 19 09:35:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 09:35:18 +0200 Subject: dovecot-2.2: replicator plugin: And crashfix for the previous ch... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c79e5ff5e30d changeset: 15840:c79e5ff5e30d user: Timo Sirainen date: Tue Feb 19 09:35:10 2013 +0200 description: replicator plugin: And crashfix for the previous change.. diffstat: src/plugins/replication/replication-plugin.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (25 lines): diff -r 556d05100810 -r c79e5ff5e30d src/plugins/replication/replication-plugin.c --- a/src/plugins/replication/replication-plugin.c Tue Feb 19 09:32:11 2013 +0200 +++ b/src/plugins/replication/replication-plugin.c Tue Feb 19 09:35:10 2013 +0200 @@ -186,10 +186,10 @@ return; } - ruser = REPLICATION_USER_CONTEXT(ns->owner); + ruser = REPLICATION_USER_CONTEXT(ns->user); if (priority == REPLICATION_PRIORITY_SYNC) { - if (replication_notify_sync(ns->owner) == 0) { + if (replication_notify_sync(ns->user) == 0) { timeout_remove(&ruser->to); ruser->priority = REPLICATION_PRIORITY_NONE; return; @@ -202,7 +202,7 @@ ruser->priority = priority; if (ruser->to == NULL) { ruser->to = timeout_add_short(REPLICATION_NOTIFY_DELAY_MSECS, - replication_notify_now, ns->owner); + replication_notify_now, ns->user); } } From dovecot at dovecot.org Tue Feb 19 09:45:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 09:45:22 +0200 Subject: dovecot-2.2: dsync: Assert-crashfix for handling conflicting pri... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7f5c29a81f03 changeset: 15841:7f5c29a81f03 user: Timo Sirainen date: Tue Feb 19 09:45:12 2013 +0200 description: dsync: Assert-crashfix for handling conflicting private flags. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r c79e5ff5e30d -r 7f5c29a81f03 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Tue Feb 19 09:35:10 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Tue Feb 19 09:45:12 2013 +0200 @@ -562,7 +562,7 @@ else remote_remove &= ~conflict_pvt_flags; } - conflict_flags = (local_remove & remote_add) & ~pvt_mask; + conflict_flags = local_remove & remote_add; if (conflict_flags != 0) { conflict_pvt_flags = conflict_flags & pvt_mask; conflict_flags &= ~pvt_mask; From dovecot at dovecot.org Tue Feb 19 10:14:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 10:14:14 +0200 Subject: dovecot-2.2: dsync: Improved debug output. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ff56652304dd changeset: 15842:ff56652304dd user: Timo Sirainen date: Tue Feb 19 10:14:04 2013 +0200 description: dsync: Improved debug output. diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 7f5c29a81f03 -r ff56652304dd src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Tue Feb 19 09:45:12 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Tue Feb 19 10:14:04 2013 +0200 @@ -564,6 +564,11 @@ { struct dsync_mailbox delete_box; + if (brain->debug) { + i_debug("brain %c: We don't have mailbox %s", + brain->master_brain ? 'M' : 'S', + guid_128_to_string(dsync_box->mailbox_guid)); + } memset(&delete_box, 0, sizeof(delete_box)); memcpy(delete_box.mailbox_guid, dsync_box->mailbox_guid, sizeof(delete_box.mailbox_guid)); From dovecot at dovecot.org Tue Feb 19 10:39:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 10:39:01 +0200 Subject: dovecot-2.2: auth: If user in passwd-file has no userdb info, us... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/31e48b4732a5 changeset: 15843:31e48b4732a5 user: Timo Sirainen date: Tue Feb 19 10:38:51 2013 +0200 description: auth: If user in passwd-file has no userdb info, userdb lookup now returns it as nonexistent. diffstat: src/auth/db-passwd-file.c | 3 +++ src/auth/userdb-passwd-file.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diffs (25 lines): diff -r ff56652304dd -r 31e48b4732a5 src/auth/db-passwd-file.c --- a/src/auth/db-passwd-file.c Tue Feb 19 10:14:04 2013 +0200 +++ b/src/auth/db-passwd-file.c Tue Feb 19 10:38:51 2013 +0200 @@ -96,6 +96,9 @@ i_error("passwd-file %s: User %s is missing " "userdb info", pw->path, username); } + /* don't allow userdb lookups */ + pu->uid = 0; + pu->gid = 0; } else if (!pw->db->userdb || **args == '\0') args++; else { diff -r ff56652304dd -r 31e48b4732a5 src/auth/userdb-passwd-file.c --- a/src/auth/userdb-passwd-file.c Tue Feb 19 10:14:04 2013 +0200 +++ b/src/auth/userdb-passwd-file.c Tue Feb 19 10:38:51 2013 +0200 @@ -43,7 +43,7 @@ pu = db_passwd_file_lookup(module->pwf, auth_request, module->username_format); - if (pu == NULL) { + if (pu == NULL || pu->uid == 0) { callback(USERDB_RESULT_USER_UNKNOWN, auth_request); return; } From dovecot at dovecot.org Tue Feb 19 11:08:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 11:08:55 +0200 Subject: dovecot-2.2: dsync: Added more debug logging. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2ee278eaa1e3 changeset: 15844:2ee278eaa1e3 user: Timo Sirainen date: Tue Feb 19 11:08:49 2013 +0200 description: dsync: Added more debug logging. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c | 26 +++++++++++++++++++--- 1 files changed, 22 insertions(+), 4 deletions(-) diffs (62 lines): diff -r 31e48b4732a5 -r 2ee278eaa1e3 src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Tue Feb 19 10:38:51 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Tue Feb 19 11:08:49 2013 +0200 @@ -7,13 +7,14 @@ #include "dsync-brain-private.h" static int -sync_create_box(struct mailbox *box, const guid_128_t mailbox_guid, - uint32_t uid_validity) +sync_create_box(struct dsync_brain *brain, struct mailbox *box, + const guid_128_t mailbox_guid, uint32_t uid_validity) { struct mailbox_metadata metadata; struct mailbox_update update; enum mail_error error; const char *errstr; + int ret; memset(&update, 0, sizeof(update)); memcpy(update.mailbox_guid, mailbox_guid, sizeof(update.mailbox_guid)); @@ -48,7 +49,15 @@ return -1; } - if (memcmp(mailbox_guid, metadata.guid, sizeof(metadata.guid)) > 0) { + ret = memcmp(mailbox_guid, metadata.guid, sizeof(metadata.guid)); + if (ret > 0) { + if (brain->debug) { + i_debug("brain %c: Changing mailbox %s GUID %s -> %s", + brain->master_brain ? 'M' : 'S', + mailbox_get_vname(box), + guid_128_to_string(metadata.guid), + guid_128_to_string(mailbox_guid)); + } memset(&update, 0, sizeof(update)); memcpy(update.mailbox_guid, mailbox_guid, sizeof(update.mailbox_guid)); @@ -72,6 +81,15 @@ mailbox_get_vname(box)); return -1; } + } else if (ret < 0) { + if (brain->debug) { + i_debug("brain %c: Other brain should change mailbox " + "%s GUID %s -> %s", + brain->master_brain ? 'M' : 'S', + mailbox_get_vname(box), + guid_128_to_string(mailbox_guid), + guid_128_to_string(metadata.guid)); + } } return 0; } @@ -118,7 +136,7 @@ } switch (change->type) { case DSYNC_MAILBOX_TREE_SYNC_TYPE_CREATE_BOX: - ret = sync_create_box(box, change->mailbox_guid, + ret = sync_create_box(brain, box, change->mailbox_guid, change->uid_validity); mailbox_free(&box); return ret; From dovecot at dovecot.org Tue Feb 19 11:23:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 11:23:04 +0200 Subject: dovecot-2.2: auth: userdb passwd-file iteration now skips passdb... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0fc8856e24aa changeset: 15845:0fc8856e24aa user: Timo Sirainen date: Tue Feb 19 11:22:57 2013 +0200 description: auth: userdb passwd-file iteration now skips passdb-only entries if there are other userdbs. diffstat: src/auth/userdb-passwd-file.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diffs (41 lines): diff -r 2ee278eaa1e3 -r 0fc8856e24aa src/auth/userdb-passwd-file.c --- a/src/auth/userdb-passwd-file.c Tue Feb 19 11:08:49 2013 +0200 +++ b/src/auth/userdb-passwd-file.c Tue Feb 19 11:22:57 2013 +0200 @@ -20,6 +20,7 @@ struct userdb_iterate_context ctx; struct istream *input; char *path; + bool skip_passdb_entries; }; struct passwd_file_userdb_module { @@ -98,6 +99,7 @@ ctx->ctx.auth_request = auth_request; ctx->ctx.callback = callback; ctx->ctx.context = context; + ctx->skip_passdb_entries = module->pwf->userdb_warn_missing; if (module->pwf->default_file == NULL) { i_error("passwd-file: User iteration isn't currently supported " "with %%variable paths"); @@ -121,7 +123,7 @@ { struct passwd_file_userdb_iterate_context *ctx = (struct passwd_file_userdb_iterate_context *)_ctx; - const char *line; + const char *line, *p; if (ctx->input == NULL) line = NULL; @@ -129,6 +131,12 @@ while ((line = i_stream_read_next_line(ctx->input)) != NULL) { if (*line == '\0' || *line == ':' || *line == '#') continue; /* no username or comment */ + if (ctx->skip_passdb_entries && + ((p = strchr(line, ':')) == NULL || + strchr(p+1, ':') == NULL)) { + /* only passdb info */ + continue; + } break; } if (line == NULL && ctx->input->stream_errno != 0) { From dovecot at dovecot.org Tue Feb 19 11:25:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 11:25:26 +0200 Subject: dovecot-2.2: auth: Fix to previous change. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/670e8d50ce73 changeset: 15846:670e8d50ce73 user: Timo Sirainen date: Tue Feb 19 11:25:21 2013 +0200 description: auth: Fix to previous change. diffstat: src/auth/userdb-passwd-file.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 0fc8856e24aa -r 670e8d50ce73 src/auth/userdb-passwd-file.c --- a/src/auth/userdb-passwd-file.c Tue Feb 19 11:22:57 2013 +0200 +++ b/src/auth/userdb-passwd-file.c Tue Feb 19 11:25:21 2013 +0200 @@ -99,7 +99,7 @@ ctx->ctx.auth_request = auth_request; ctx->ctx.callback = callback; ctx->ctx.context = context; - ctx->skip_passdb_entries = module->pwf->userdb_warn_missing; + ctx->skip_passdb_entries = !module->pwf->userdb_warn_missing; if (module->pwf->default_file == NULL) { i_error("passwd-file: User iteration isn't currently supported " "with %%variable paths"); From dovecot at dovecot.org Tue Feb 19 13:18:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 13:18:49 +0200 Subject: dovecot-2.2: Added guid_128_equals() helper function. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/19e24db0bbd4 changeset: 15847:19e24db0bbd4 user: Timo Sirainen date: Tue Feb 19 13:17:05 2013 +0200 description: Added guid_128_equals() helper function. diffstat: src/lib/guid.c | 5 +++++ src/lib/guid.h | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diffs (27 lines): diff -r 670e8d50ce73 -r 19e24db0bbd4 src/lib/guid.c --- a/src/lib/guid.c Tue Feb 19 11:25:21 2013 +0200 +++ b/src/lib/guid.c Tue Feb 19 13:17:05 2013 +0200 @@ -94,6 +94,11 @@ return TRUE; } +bool guid_128_equals(const guid_128_t guid1, const guid_128_t guid2) +{ + return memcmp(guid1, guid2, GUID_128_SIZE) == 0; +} + int guid_128_from_string(const char *str, guid_128_t guid_r) { buffer_t buf; diff -r 670e8d50ce73 -r 19e24db0bbd4 src/lib/guid.h --- a/src/lib/guid.h Tue Feb 19 11:25:21 2013 +0200 +++ b/src/lib/guid.h Tue Feb 19 13:17:05 2013 +0200 @@ -12,6 +12,8 @@ void guid_128_generate(guid_128_t guid_r); /* Returns TRUE if GUID is empty (not set / unknown). */ bool guid_128_is_empty(const guid_128_t guid); +/* Returns TRUE if two GUIDs are equal. */ +bool guid_128_equals(const guid_128_t guid1, const guid_128_t guid2); /* Returns GUID as a hex string. */ const char *guid_128_to_string(const guid_128_t guid); From dovecot at dovecot.org Tue Feb 19 13:18:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 13:18:49 +0200 Subject: dovecot-2.2: lib-storage: Fixed mailbox_update() when using mail... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2529f4e12665 changeset: 15848:2529f4e12665 user: Timo Sirainen date: Tue Feb 19 13:17:42 2013 +0200 description: lib-storage: Fixed mailbox_update() when using mailbox_list_index=yes diffstat: src/lib-storage/list/mailbox-list-index-backend.c | 67 ++++++++++- src/lib-storage/list/mailbox-list-index-status.c | 121 +++++++++++++++------ src/lib-storage/list/mailbox-list-index.c | 16 ++- src/lib-storage/list/mailbox-list-index.h | 2 + 4 files changed, 162 insertions(+), 44 deletions(-) diffs (truncated from 348 to 300 lines): diff -r 19e24db0bbd4 -r 2529f4e12665 src/lib-storage/list/mailbox-list-index-backend.c --- a/src/lib-storage/list/mailbox-list-index-backend.c Tue Feb 19 13:17:05 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index-backend.c Tue Feb 19 13:17:42 2013 +0200 @@ -9,6 +9,8 @@ #include "mailbox-list-index-storage.h" #include "mailbox-list-index-sync.h" +#include + #define GLOBAL_TEMP_PREFIX ".temp." struct index_mailbox_list { @@ -79,6 +81,20 @@ return 1; } +static const char * +index_get_guid_path(struct mailbox_list *_list, const char *root_dir, + const guid_128_t mailbox_guid) +{ + if (_list->set.mailbox_dir_name == '\0') { + return t_strconcat(root_dir, "/", + guid_128_to_string(mailbox_guid), NULL); + } else { + return t_strdup_printf("%s/%s%s", root_dir, + _list->set.mailbox_dir_name, + guid_128_to_string(mailbox_guid)); + } +} + static int index_list_get_path(struct mailbox_list *_list, const char *name, enum mailbox_list_path_type type, const char **path_r) @@ -128,14 +144,8 @@ mailbox_list_set_error(_list, MAIL_ERROR_NOTFOUND, T_MAIL_ERR_MAILBOX_NOT_FOUND(name)); ret = -1; - } else if (_list->set.mailbox_dir_name == '\0') { - *path_r = t_strconcat(root_dir, "/", - guid_128_to_string(mailbox_guid), NULL); - ret = 1; } else { - *path_r = t_strdup_printf("%s/%s%s", root_dir, - _list->set.mailbox_dir_name, - guid_128_to_string(mailbox_guid)); + *path_r = index_get_guid_path(_list, root_dir, mailbox_guid); ret = 1; } mail_index_view_close(&view); @@ -310,6 +320,48 @@ ibox->module_ctx.super.create_box(box, update, directory); } +static int +index_list_mailbox_update(struct mailbox *box, + const struct mailbox_update *update) +{ + struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box); + const char *root_dir, *old_path, *new_path; + + if (mailbox_list_get_path(box->list, box->name, + MAILBOX_LIST_PATH_TYPE_MAILBOX, + &old_path) <= 0) + old_path = NULL; + + if (ibox->module_ctx.super.update_box(box, update) < 0) + return -1; + + /* rename the directory */ + if (!guid_128_is_empty(update->mailbox_guid) && + mailbox_list_set_get_root_path(&box->list->set, + MAILBOX_LIST_PATH_TYPE_MAILBOX, + &root_dir)) { + new_path = index_get_guid_path(box->list, root_dir, + update->mailbox_guid); + if (strcmp(old_path, new_path) == 0) + ; + else if (rename(old_path, new_path) == 0) + ; + else if (errno == ENOENT) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND, + T_MAIL_ERR_MAILBOX_NOT_FOUND(box->name)); + return -1; + } else { + mail_storage_set_critical(box->storage, + "rename(%s, %s) failed: %m", + old_path, new_path); + return -1; + } + } + + mailbox_list_index_update_mailbox_index(box, update); + return 0; +} + static void index_list_try_delete(struct index_mailbox_list *list, const char *name, enum mailbox_list_path_type type) @@ -609,4 +661,5 @@ if (strcmp(box->list->name, MAILBOX_LIST_NAME_INDEX) != 0) return; box->v.create_box = index_list_mailbox_create; + box->v.update_box = index_list_mailbox_update; } diff -r 19e24db0bbd4 -r 2529f4e12665 src/lib-storage/list/mailbox-list-index-status.c --- a/src/lib-storage/list/mailbox-list-index-status.c Tue Feb 19 13:17:05 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index-status.c Tue Feb 19 13:17:42 2013 +0200 @@ -129,8 +129,7 @@ return 0; } - ret = index_list_open_view(box, &view, &seq); - if (ret <= 0) + if ((ret = index_list_open_view(box, &view, &seq)) <= 0) return ret; ret = mailbox_list_index_status(box->list, view, seq, items, @@ -167,8 +166,7 @@ return 0; } - ret = index_list_open_view(box, &view, &seq); - if (ret <= 0) + if ((ret = index_list_open_view(box, &view, &seq)) <= 0) return ret; ret = mailbox_list_index_status(box->list, view, seq, 0, @@ -195,37 +193,34 @@ } static int -index_list_update(struct mailbox *box, struct mail_index_view *view, - uint32_t seq, const struct mailbox_status *status) +index_list_update_full(struct mailbox *box, struct mail_index_view *view, + uint32_t seq, const guid_128_t new_guid, + const struct mailbox_status *new_status, + bool update_backend) { struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(box->list); struct mail_index_transaction *trans; struct mail_index_transaction_commit_result result; - struct mailbox_metadata metadata; struct mailbox_status old_status; - guid_128_t mailbox_guid; + guid_128_t old_guid; bool rec_changed, msgs_changed, hmodseq_changed; - i_assert(box->opened); + memset(&old_status, 0, sizeof(old_status)); + memset(old_guid, 0, sizeof(old_guid)); + (void)mailbox_list_index_status(box->list, view, seq, CACHED_STATUS_ITEMS, + &old_status, old_guid); - if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) - memset(&metadata, 0, sizeof(metadata)); - - memset(&old_status, 0, sizeof(old_status)); - memset(mailbox_guid, 0, sizeof(mailbox_guid)); - (void)mailbox_list_index_status(box->list, view, seq, CACHED_STATUS_ITEMS, - &old_status, mailbox_guid); - - rec_changed = old_status.uidvalidity != status->uidvalidity; - if (memcmp(metadata.guid, mailbox_guid, sizeof(metadata.guid)) != 0 && - guid_128_is_empty(metadata.guid)) + rec_changed = old_status.uidvalidity != new_status->uidvalidity && + new_status->uidvalidity != 0; + if (!guid_128_equals(new_guid, old_guid) && + !guid_128_is_empty(new_guid)) rec_changed = TRUE; - msgs_changed = old_status.messages != status->messages || - old_status.unseen != status->unseen || - old_status.recent != status->recent || - old_status.uidnext != status->uidnext; + msgs_changed = old_status.messages != new_status->messages || + old_status.unseen != new_status->unseen || + old_status.recent != new_status->recent || + old_status.uidnext != new_status->uidnext; /* update highest-modseq only if they're ever been used */ - if (old_status.highest_modseq == status->highest_modseq) { + if (old_status.highest_modseq == new_status->highest_modseq) { hmodseq_changed = FALSE; } else if ((box->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0 || old_status.highest_modseq != 0) { @@ -240,7 +235,7 @@ } if (hmodseq_changed && - old_status.highest_modseq != status->highest_modseq) + old_status.highest_modseq != new_status->highest_modseq) hmodseq_changed = TRUE; if (!rec_changed && !msgs_changed && !hmodseq_changed) @@ -259,9 +254,10 @@ i_assert(old_data != NULL); memcpy(&rec, old_data, sizeof(rec)); - rec.uid_validity = status->uidvalidity; - if (!guid_128_is_empty(metadata.guid)) - memcpy(rec.guid, metadata.guid, sizeof(rec.guid)); + if (new_status->uidvalidity != 0) + rec.uid_validity = new_status->uidvalidity; + if (!guid_128_is_empty(new_guid)) + memcpy(rec.guid, new_guid, sizeof(rec.guid)); mail_index_update_ext(trans, seq, ilist->ext_id, &rec, NULL); } @@ -269,21 +265,23 @@ struct mailbox_list_index_msgs_record msgs; memset(&msgs, 0, sizeof(msgs)); - msgs.messages = status->messages; - msgs.unseen = status->unseen; - msgs.recent = status->recent; - msgs.uidnext = status->uidnext; + msgs.messages = new_status->messages; + msgs.unseen = new_status->unseen; + msgs.recent = new_status->recent; + msgs.uidnext = new_status->uidnext; mail_index_update_ext(trans, seq, ilist->msgs_ext_id, &msgs, NULL); } if (hmodseq_changed) { mail_index_update_ext(trans, seq, ilist->hmodseq_ext_id, - &status->highest_modseq, NULL); + &new_status->highest_modseq, NULL); } - if (box->v.list_index_update_sync != NULL) - box->v.list_index_update_sync(box, trans, seq); + if (update_backend) { + if (box->v.list_index_update_sync != NULL) + box->v.list_index_update_sync(box, trans, seq); + } if (mail_index_transaction_commit_full(&trans, &result) < 0) { mailbox_list_index_set_index_error(box->list); @@ -292,6 +290,20 @@ return 0; } +static int +index_list_update(struct mailbox *box, struct mail_index_view *view, + uint32_t seq, const struct mailbox_status *status) +{ + struct mailbox_metadata metadata; + + i_assert(box->opened); + + if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) + memset(&metadata, 0, sizeof(metadata)); + return index_list_update_full(box, view, seq, metadata.guid, + status, TRUE); +} + static void index_list_update_mailbox(struct mailbox *box, struct mail_index_view *view) { @@ -349,6 +361,43 @@ mail_index_view_close(&list_view); } +void mailbox_list_index_update_mailbox_index(struct mailbox *box, + const struct mailbox_update *update) +{ + struct mailbox_status status; + struct mail_index_view *view; + guid_128_t mailbox_guid; + uint32_t seq; + int ret; + + if ((ret = index_list_open_view(box, &view, &seq)) <= 0) + return; + + (void)mailbox_list_index_status(box->list, view, seq, + CACHED_STATUS_ITEMS, &status, + mailbox_guid); + if (update->uid_validity != 0) + status.uidvalidity = update->uid_validity; + if ((!guid_128_equals(update->mailbox_guid, mailbox_guid) && + !guid_128_is_empty(update->mailbox_guid) && + !guid_128_is_empty(mailbox_guid)) || + update->uid_validity != 0 || + update->min_next_uid != 0 || + update->min_first_recent_uid != 0 || + update->min_highest_modseq != 0) { + /* reset status counters. let the syncing later figure out + their correct values. */ + status.messages = 0; + status.unseen = 0; + status.recent = 0; + status.uidnext = 0; + status.highest_modseq = 0; + } + index_list_update_full(box, view, seq, update->mailbox_guid, + &status, FALSE); + mail_index_view_close(&view); +} + static int index_list_sync_deinit(struct mailbox_sync_context *ctx, From dovecot at dovecot.org Tue Feb 19 13:18:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 13:18:49 +0200 Subject: dovecot-2.2: LAYOUT=index: Index is the only source for mailbox ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d977a746819d changeset: 15849:d977a746819d user: Timo Sirainen date: Tue Feb 19 13:18:38 2013 +0200 description: LAYOUT=index: Index is the only source for mailbox info, don't try any syncing with storage. diffstat: src/lib-storage/list/mailbox-list-index-backend.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 2529f4e12665 -r d977a746819d src/lib-storage/list/mailbox-list-index-backend.c --- a/src/lib-storage/list/mailbox-list-index-backend.c Tue Feb 19 13:17:42 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index-backend.c Tue Feb 19 13:18:38 2013 +0200 @@ -662,4 +662,7 @@ return; box->v.create_box = index_list_mailbox_create; box->v.update_box = index_list_mailbox_update; + + box->v.list_index_has_changed = NULL; + box->v.list_index_update_sync = NULL; } From dovecot at dovecot.org Tue Feb 19 13:43:54 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 13:43:54 +0200 Subject: dovecot-2.2: lib-index: Give a better error message if index is ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d40e3bf2de89 changeset: 15850:d40e3bf2de89 user: Timo Sirainen date: Tue Feb 19 13:43:42 2013 +0200 description: lib-index: Give a better error message if index is readonly and log is tried to be locked. diffstat: src/lib-index/mail-transaction-log-file.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r d977a746819d -r d40e3bf2de89 src/lib-index/mail-transaction-log-file.c --- a/src/lib-index/mail-transaction-log-file.c Tue Feb 19 13:18:38 2013 +0200 +++ b/src/lib-index/mail-transaction-log-file.c Tue Feb 19 13:43:42 2013 +0200 @@ -362,6 +362,13 @@ if (file->log->index->lock_method == FILE_LOCK_METHOD_DOTLOCK) return mail_transaction_log_file_dotlock(file); + if (file->log->index->readonly) { + mail_index_set_error(file->log->index, + "Index is read-only, can't write-lock %s", + file->filepath); + return -1; + } + i_assert(file->file_lock == NULL); lock_timeout_secs = I_MIN(MAIL_TRANSACTION_LOG_LOCK_TIMEOUT, file->log->index->max_lock_timeout_secs); From dovecot at dovecot.org Tue Feb 19 15:52:32 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 15:52:32 +0200 Subject: dovecot-2.2: hostpid_init() should die if hostname is invalid. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cce9a8ebb386 changeset: 15851:cce9a8ebb386 user: Timo Sirainen date: Tue Feb 19 15:52:21 2013 +0200 description: hostpid_init() should die if hostname is invalid. This was accidentally changes during last commit. diffstat: src/lib/hostpid.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r d40e3bf2de89 -r cce9a8ebb386 src/lib/hostpid.c --- a/src/lib/hostpid.c Tue Feb 19 13:43:42 2013 +0200 +++ b/src/lib/hostpid.c Tue Feb 19 15:52:21 2013 +0200 @@ -35,7 +35,7 @@ if (value[0] == '\0' || strcspn(value, HOSTNAME_DISALLOWED_CHARS) != strlen(value)) - i_error("Invalid system hostname: '%s'", value); + i_fatal("Invalid system hostname: '%s'", value); my_hostname_dup = i_strdup(value); my_hostname = my_hostname_dup; From dovecot at dovecot.org Tue Feb 19 17:37:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 19 Feb 2013 17:37:22 +0200 Subject: dovecot-2.1: Added quota-status service for asking if user is ov... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/980be1dc80c2 changeset: 14908:980be1dc80c2 user: Timo Sirainen date: Tue Feb 19 17:36:59 2013 +0200 description: Added quota-status service for asking if user is over quota. Implemented Postfix-compatible policy server protocol initially. Usage: service quota-status { executable = quota-status -p postfix unix_listener /var/spool/postfix/private/quota-status { user = postfix } client_limit = 1 } Postfix: smtpd_recipient_restrictions = ... check_policy_service unix:private/quota-status diffstat: .hgignore | 1 + src/plugins/quota/Makefile.am | 28 +++++ src/plugins/quota/quota-status.c | 214 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 243 insertions(+), 0 deletions(-) diffs (284 lines): diff -r b96df105ec55 -r 980be1dc80c2 .hgignore --- a/.hgignore Sun Feb 17 12:03:06 2013 +0200 +++ b/.hgignore Tue Feb 19 17:36:59 2013 +0200 @@ -97,6 +97,7 @@ src/plugins/fts/xml2text src/plugins/quota/rquota_xdr.c src/plugins/quota/rquota.h +src/plugins/quota/quota-status syntax: regexp src/.*/test-[^\.]*$ diff -r b96df105ec55 -r 980be1dc80c2 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Sun Feb 17 12:03:06 2013 +0200 +++ b/src/plugins/quota/Makefile.am Tue Feb 19 17:36:59 2013 +0200 @@ -1,7 +1,10 @@ doveadm_moduledir = $(moduledir)/doveadm +pkglibexec_PROGRAMS = quota-status + AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-dict \ -I$(top_srcdir)/src/lib-index \ -I$(top_srcdir)/src/lib-mail \ @@ -27,6 +30,17 @@ quota-plugin.c \ quota-storage.c +quota_common_objects = \ + quota.lo \ + quota-count.lo \ + quota-fs.lo \ + quota-dict.lo \ + quota-dirsize.lo \ + quota-maildir.lo \ + quota-plugin.lo \ + quota-storage.lo \ + $(RQUOTA_XDR_LO) + lib10_quota_plugin_la_SOURCES = $(quota_dist_sources) nodist_lib10_quota_plugin_la_SOURCES = $(RQUOTA_XDR) @@ -36,8 +50,22 @@ lib10_doveadm_quota_plugin_la_SOURCES = \ doveadm-quota.c +quota_status_SOURCES = \ + quota-status.c + +quota_status_LDADD = \ + $(quota_common_objects) \ + $(LIBDOVECOT_STORAGE) \ + $(LIBDOVECOT) \ + $(MODULE_LIBS) +quota_status_DEPENDENCIES = \ + $(quota_common_objects) \ + $(LIBDOVECOT_STORAGE_DEPS) \ + $(LIBDOVECOT_DEPS) + if HAVE_RQUOTA RQUOTA_XDR = rquota_xdr.c +RQUOTA_XDR_LO = rquota_xdr.lo #RQUOTA_X = /usr/include/rpcsvc/rquota.x RQUOTA_X = $(srcdir)/rquota.x rquota_xdr.c: Makefile $(RQUOTA_X) diff -r b96df105ec55 -r 980be1dc80c2 src/plugins/quota/quota-status.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins/quota/quota-status.c Tue Feb 19 17:36:59 2013 +0200 @@ -0,0 +1,214 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "module-dir.h" +#include "ostream.h" +#include "connection.h" +#include "restrict-access.h" +#include "master-service.h" +#include "mail-namespace.h" +#include "mail-storage.h" +#include "mail-storage-settings.h" +#include "mail-storage-service.h" +#include "quota-private.h" +#include "quota-plugin.h" + +enum quota_protocol { + QUOTA_PROTOCOL_UNKNOWN = 0, + QUOTA_PROTOCOL_POSTFIX +}; + +struct quota_client { + struct connection conn; + + char *recipient; +}; + +static enum quota_protocol protocol; +static struct mail_storage_service_ctx *storage_service; +static struct connection_list *clients; + +static struct module quota_module = { + .path = "quota", + .name = "quota" +}; + +static void client_connected(struct master_service_connection *conn) +{ + struct quota_client *client; + + client = i_new(struct quota_client, 1); + connection_init_server(clients, &client->conn, + "(quota client)", conn->fd, conn->fd); + master_service_client_connection_accept(conn); +} + +static void client_reset(struct quota_client *client) +{ + i_free_and_null(client->recipient); +} + +static int quota_check(struct mail_user *user, const char **error_r) +{ + struct quota_user *quser = QUOTA_USER_CONTEXT(user); + struct mail_namespace *ns; + struct mailbox *box; + struct quota_transaction_context *ctx; + bool too_large; + int ret; + + if (quser == NULL) { + /* no quota for user */ + return 1; + } + + ns = mail_namespace_find_inbox(user->namespaces); + box = mailbox_alloc(ns->list, "INBOX", 0); + + ctx = quota_transaction_begin(box); + ret = quota_test_alloc(ctx, 1, &too_large); + quota_transaction_rollback(&ctx); + + mailbox_free(&box); + + if (ret < 0) + *error_r = "Internal quota calculation error"; + else if (ret == 0) + *error_r = quser->quota->set->quota_exceeded_msg; + return ret; +} + +static void client_handle_request(struct quota_client *client) +{ + struct mail_storage_service_input input; + struct mail_storage_service_user *service_user; + struct mail_user *user; + const char *error; + int ret; + + if (client->recipient == NULL) { + o_stream_send_str(client->conn.output, "action=DUNNO\n\n"); + return; + } + + memset(&input, 0, sizeof(input)); + input.username = client->recipient; + + ret = mail_storage_service_lookup_next(storage_service, &input, + &service_user, &user, &error); + restrict_access_allow_coredumps(TRUE); + if (ret == 0) { + o_stream_send_str(client->conn.output, + "action=REJECT Unknown user\n\n"); + } else if (ret > 0) { + if ((ret = quota_check(user, &error)) > 0) + o_stream_send_str(client->conn.output, "action=OK\n\n"); + else if (ret == 0) { + o_stream_send_str(client->conn.output, t_strdup_printf( + "action=552 5.2.2 %s\n\n", error)); + } + mail_user_unref(&user); + mail_storage_service_user_free(&service_user); + } + if (ret < 0) { + o_stream_send_str(client->conn.output, t_strdup_printf( + "action=DEFER_IF_PERMIT %s\n\n", error)); + } +} + +static int client_input_line(struct connection *conn, const char *line) +{ + struct quota_client *client = (struct quota_client *)conn; + + if (*line == '\0') { + o_stream_cork(conn->output); + client_handle_request(client); + o_stream_uncork(conn->output); + client_reset(client); + return 1; + } + if (client->recipient == NULL && + strncmp(line, "recipient=", 10) == 0) + client->recipient = i_strdup(line + 10); + return 1; +} + +static void client_destroy(struct connection *conn) +{ + struct quota_client *client = (struct quota_client *)conn; + + connection_deinit(&client->conn); + client_reset(client); + i_free(client); + + master_service_client_connection_destroyed(master_service); +} + +static struct connection_settings client_set = { + .input_max_size = (size_t)-1, + .output_max_size = (size_t)-1, + .client = FALSE +}; + +static const struct connection_vfuncs client_vfuncs = { + .destroy = client_destroy, + .input_line = client_input_line +}; + +static void main_preinit(void) +{ + restrict_access_by_env(NULL, FALSE); + restrict_access_allow_coredumps(TRUE); +} + +static void main_init(void) +{ + clients = connection_list_init(&client_set, &client_vfuncs); + storage_service = mail_storage_service_init(master_service, NULL, + MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | + MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP | + MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS | + MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR | + MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS); + quota_plugin_init("a_module); +} + +static void main_deinit(void) +{ + connection_list_deinit(&clients); + quota_plugin_deinit(); + mail_storage_service_deinit(&storage_service); +} + +int main(int argc, char *argv[]) +{ + int c; + + protocol = QUOTA_PROTOCOL_UNKNOWN; + master_service = master_service_init("quota-status", 0, + &argc, &argv, "p:"); + while ((c = master_getopt(master_service)) > 0) { + switch (c) { + case 'p': + if (strcmp(optarg, "postfix") == 0) + protocol = QUOTA_PROTOCOL_POSTFIX; + else + i_fatal("Unknown -p parameter: '%s'", optarg); + break; + default: + return FATAL_DEFAULT; + } + } + if (protocol == QUOTA_PROTOCOL_UNKNOWN) + i_fatal("Missing -p parameter"); + + master_service_init_log(master_service, "doveadm: "); + main_preinit(); + master_service_init_finish(master_service); + + main_init(); + master_service_run(master_service, client_connected); + main_deinit(); + master_service_deinit(&master_service); + return 0; +} From dovecot at dovecot.org Wed Feb 20 10:58:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 10:58:15 +0200 Subject: dovecot-2.2: lib-index: Added assert. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/61a61657d887 changeset: 15852:61a61657d887 user: Timo Sirainen date: Wed Feb 20 10:57:13 2013 +0200 description: lib-index: Added assert. diffstat: src/lib-index/mail-index-sync.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r cce9a8ebb386 -r 61a61657d887 src/lib-index/mail-index-sync.c --- a/src/lib-index/mail-index-sync.c Tue Feb 19 15:52:21 2013 +0200 +++ b/src/lib-index/mail-index-sync.c Wed Feb 20 10:57:13 2013 +0200 @@ -500,6 +500,8 @@ bool retry; int ret; + i_assert(index->open_count > 0); + ret = mail_index_sync_begin_to2(index, ctx_r, view_r, trans_r, log_file_seq, log_file_offset, flags, &retry); From dovecot at dovecot.org Wed Feb 20 10:58:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 10:58:15 +0200 Subject: dovecot-2.2: mailbox_list_index: Removed race conditions from in... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5a068b9c04a9 changeset: 15853:5a068b9c04a9 user: Timo Sirainen date: Wed Feb 20 10:58:02 2013 +0200 description: mailbox_list_index: Removed race conditions from index updates. diffstat: src/lib-storage/list/mailbox-list-index-status.c | 350 +++++++++++++--------- 1 files changed, 203 insertions(+), 147 deletions(-) diffs (truncated from 448 to 300 lines): diff -r 61a61657d887 -r 5a068b9c04a9 src/lib-storage/list/mailbox-list-index-status.c --- a/src/lib-storage/list/mailbox-list-index-status.c Wed Feb 20 10:57:13 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index-status.c Wed Feb 20 10:58:02 2013 +0200 @@ -10,6 +10,16 @@ (STATUS_MESSAGES | STATUS_UNSEEN | STATUS_RECENT | \ STATUS_UIDNEXT | STATUS_UIDVALIDITY | STATUS_HIGHESTMODSEQ) +struct index_list_changes { + struct mailbox_status status; + guid_128_t guid; + uint32_t seq; + + bool rec_changed; + bool msgs_changed; + bool hmodseq_changed; +}; + struct index_list_storage_module index_list_storage_module = MODULE_CONTEXT_INIT(&mail_storage_module_register); @@ -192,210 +202,259 @@ return ibox->module_ctx.super.get_metadata(box, items, metadata_r); } -static int -index_list_update_full(struct mailbox *box, struct mail_index_view *view, - uint32_t seq, const guid_128_t new_guid, - const struct mailbox_status *new_status, - bool update_backend) +static bool +index_list_update_fill_changes(struct mailbox *box, + struct mail_index_view *list_view, + struct index_list_changes *changes_r) +{ + struct mailbox_list_index_node *node; + struct mail_index_view *view; + const struct mail_index_header *hdr; + struct mailbox_metadata metadata; + uint32_t seq1, seq2; + + memset(changes_r, 0, sizeof(*changes_r)); + + node = mailbox_list_index_lookup(box->list, box->name); + if (node == NULL) + return FALSE; + if (!mail_index_lookup_seq(list_view, node->uid, &changes_r->seq)) + return FALSE; + + /* get STATUS info using the latest data in index. + note that for shared mailboxes (with private indexes) this + also means that the unseen count is always the owner's + count, not what exists in the private index. */ + view = mail_index_view_open(box->index); + hdr = mail_index_get_header(view); + + changes_r->status.messages = hdr->messages_count; + changes_r->status.unseen = + hdr->messages_count - hdr->seen_messages_count; + changes_r->status.uidvalidity = hdr->uid_validity; + changes_r->status.uidnext = hdr->next_uid; + + if (!mail_index_lookup_seq_range(view, hdr->first_recent_uid, + (uint32_t)-1, &seq1, &seq2)) + changes_r->status.recent = 0; + else + changes_r->status.recent = seq2 - seq1 + 1; + + changes_r->status.highest_modseq = mail_index_modseq_get_highest(view); + if (changes_r->status.highest_modseq == 0) { + /* modseqs not enabled yet, but we can't return 0 */ + changes_r->status.highest_modseq = 1; + } + mail_index_view_close(&view); hdr = NULL; + + if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) == 0) + memcpy(changes_r->guid, metadata.guid, sizeof(changes_r->guid)); + return TRUE; +} + +static bool +index_list_has_changed(struct mailbox *box, struct mail_index_view *list_view, + struct index_list_changes *changes) { struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(box->list); - struct mail_index_transaction *trans; - struct mail_index_transaction_commit_result result; struct mailbox_status old_status; guid_128_t old_guid; - bool rec_changed, msgs_changed, hmodseq_changed; memset(&old_status, 0, sizeof(old_status)); memset(old_guid, 0, sizeof(old_guid)); - (void)mailbox_list_index_status(box->list, view, seq, CACHED_STATUS_ITEMS, + (void)mailbox_list_index_status(box->list, list_view, changes->seq, + CACHED_STATUS_ITEMS, &old_status, old_guid); - rec_changed = old_status.uidvalidity != new_status->uidvalidity && - new_status->uidvalidity != 0; - if (!guid_128_equals(new_guid, old_guid) && - !guid_128_is_empty(new_guid)) - rec_changed = TRUE; - msgs_changed = old_status.messages != new_status->messages || - old_status.unseen != new_status->unseen || - old_status.recent != new_status->recent || - old_status.uidnext != new_status->uidnext; + changes->rec_changed = + old_status.uidvalidity != changes->status.uidvalidity && + changes->status.uidvalidity != 0; + if (!guid_128_equals(changes->guid, old_guid) && + !guid_128_is_empty(changes->guid)) + changes->rec_changed = TRUE; + changes->msgs_changed = + old_status.messages != changes->status.messages || + old_status.unseen != changes->status.unseen || + old_status.recent != changes->status.recent || + old_status.uidnext != changes->status.uidnext; /* update highest-modseq only if they're ever been used */ - if (old_status.highest_modseq == new_status->highest_modseq) { - hmodseq_changed = FALSE; + if (old_status.highest_modseq == changes->status.highest_modseq) { + changes->hmodseq_changed = FALSE; } else if ((box->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0 || old_status.highest_modseq != 0) { - hmodseq_changed = TRUE; + changes->hmodseq_changed = TRUE; } else { const void *data; bool expunged; - mail_index_lookup_ext(view, seq, ilist->hmodseq_ext_id, - &data, &expunged); - hmodseq_changed = data != NULL; + mail_index_lookup_ext(list_view, changes->seq, + ilist->hmodseq_ext_id, &data, &expunged); + changes->hmodseq_changed = data != NULL; } - if (hmodseq_changed && - old_status.highest_modseq != new_status->highest_modseq) - hmodseq_changed = TRUE; + if (changes->hmodseq_changed && + old_status.highest_modseq != changes->status.highest_modseq) + changes->hmodseq_changed = TRUE; - if (!rec_changed && !msgs_changed && !hmodseq_changed) - return 0; + return changes->rec_changed || changes->msgs_changed || + changes->hmodseq_changed; +} - trans = mail_index_transaction_begin(view, - MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); +static void +index_list_update(struct mailbox *box, struct mail_index_view *list_view, + struct mail_index_transaction *list_trans, + const struct index_list_changes *changes) +{ + struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(box->list); - if (rec_changed) { + if (changes->rec_changed) { struct mailbox_list_index_record rec; const void *old_data; bool expunged; - mail_index_lookup_ext(view, seq, ilist->ext_id, + mail_index_lookup_ext(list_view, changes->seq, ilist->ext_id, &old_data, &expunged); i_assert(old_data != NULL); memcpy(&rec, old_data, sizeof(rec)); - if (new_status->uidvalidity != 0) - rec.uid_validity = new_status->uidvalidity; - if (!guid_128_is_empty(new_guid)) - memcpy(rec.guid, new_guid, sizeof(rec.guid)); - mail_index_update_ext(trans, seq, ilist->ext_id, &rec, NULL); + if (changes->status.uidvalidity != 0) + rec.uid_validity = changes->status.uidvalidity; + if (!guid_128_is_empty(changes->guid)) + memcpy(rec.guid, changes->guid, sizeof(rec.guid)); + mail_index_update_ext(list_trans, changes->seq, ilist->ext_id, + &rec, NULL); } - if (msgs_changed) { + if (changes->msgs_changed) { struct mailbox_list_index_msgs_record msgs; memset(&msgs, 0, sizeof(msgs)); - msgs.messages = new_status->messages; - msgs.unseen = new_status->unseen; - msgs.recent = new_status->recent; - msgs.uidnext = new_status->uidnext; + msgs.messages = changes->status.messages; + msgs.unseen = changes->status.unseen; + msgs.recent = changes->status.recent; + msgs.uidnext = changes->status.uidnext; - mail_index_update_ext(trans, seq, ilist->msgs_ext_id, - &msgs, NULL); + mail_index_update_ext(list_trans, changes->seq, + ilist->msgs_ext_id, &msgs, NULL); } - if (hmodseq_changed) { - mail_index_update_ext(trans, seq, ilist->hmodseq_ext_id, - &new_status->highest_modseq, NULL); + if (changes->hmodseq_changed) { + mail_index_update_ext(list_trans, changes->seq, + ilist->hmodseq_ext_id, + &changes->status.highest_modseq, NULL); + } +} + +static int index_list_update_mailbox(struct mailbox *box) +{ + struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(box->list); + struct mail_index_sync_ctx *list_sync_ctx; + struct mail_index_view *list_view; + struct mail_index_transaction *list_trans; + struct index_list_changes changes; + int ret; + + i_assert(box->opened); + + if (ilist->syncing || ilist->updating_status) + return 0; + + /* refresh the mailbox list index once. we can't do this again after + locking, because it could trigger list syncing. */ + (void)mailbox_list_index_refresh(box->list); + + /* first do a quick check while unlocked to see if anything changes */ + list_view = mail_index_view_open(ilist->index); + if (!index_list_update_fill_changes(box, list_view, &changes)) + ret = -1; + else if (!index_list_has_changed(box, list_view, &changes)) + ret = 0; + else + ret = 1; + mail_index_view_close(&list_view); + if (ret <= 0) { + if (ret < 0) + mailbox_list_index_refresh_later(box->list); + return 0; } - if (update_backend) { - if (box->v.list_index_update_sync != NULL) - box->v.list_index_update_sync(box, trans, seq); + /* looks like there are some changes. now lock the list index and do + the whole thing all over again while locked. this guarantees + that we'll always write the latest state of the mailbox. */ + if (mail_index_sync_begin(ilist->index, &list_sync_ctx, + &list_view, &list_trans, 0) < 0) { + mailbox_set_index_error(box); + return -1; + } + /* refresh to latest state of the mailbox now that we're locked */ + if (mail_index_refresh(box->index) < 0) { + mailbox_set_index_error(box); + mail_index_sync_rollback(&list_sync_ctx); + return -1; } - if (mail_index_transaction_commit_full(&trans, &result) < 0) { - mailbox_list_index_set_index_error(box->list); + if (!index_list_update_fill_changes(box, list_view, &changes)) + mailbox_list_index_refresh_later(box->list); + else if (index_list_has_changed(box, list_view, &changes)) { + ilist->updating_status = TRUE; + index_list_update(box, list_view, list_trans, &changes); + if (box->v.list_index_update_sync != NULL) { + box->v.list_index_update_sync(box, list_trans, + changes.seq); + } + ilist->updating_status = FALSE; + } + + if (mail_index_sync_commit(&list_sync_ctx) < 0) { + mailbox_set_index_error(box); return -1; } return 0; } -static int -index_list_update(struct mailbox *box, struct mail_index_view *view, - uint32_t seq, const struct mailbox_status *status) -{ - struct mailbox_metadata metadata; - - i_assert(box->opened); - - if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) - memset(&metadata, 0, sizeof(metadata)); - return index_list_update_full(box, view, seq, metadata.guid, - status, TRUE); -} - From dovecot at dovecot.org Wed Feb 20 11:19:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 11:19:26 +0200 Subject: dovecot-2.2: lib-http: Minor API change: Added http_client_reque... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3bc84d6c9e8d changeset: 15854:3bc84d6c9e8d user: Timo Sirainen date: Wed Feb 20 11:18:59 2013 +0200 description: lib-http: Minor API change: Added http_client_request_finish_payload() diffstat: src/lib-http/http-client-request.c | 22 ++++++++++++++++++---- src/lib-http/http-client.h | 4 +++- src/plugins/fts-solr/solr-connection.c | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diffs (88 lines): diff -r 5a068b9c04a9 -r 3bc84d6c9e8d src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Wed Feb 20 10:58:02 2013 +0200 +++ b/src/lib-http/http-client-request.c Wed Feb 20 11:18:59 2013 +0200 @@ -176,7 +176,7 @@ } static void -http_client_request_finish_payload(struct http_client_request *req) +http_client_request_finish_payload_out(struct http_client_request *req) { if (req->payload_output != NULL) { o_stream_unref(&req->payload_output); @@ -187,7 +187,8 @@ http_client_request_debug(req, "Sent all payload"); } -int http_client_request_send_payload(struct http_client_request **_req, +static int +http_client_request_continue_payload(struct http_client_request **_req, const unsigned char *data, size_t size) { struct ioloop *prev_ioloop = current_ioloop; @@ -208,7 +209,7 @@ if (data == NULL) { req->payload_input = NULL; if (req->state == HTTP_REQUEST_STATE_PAYLOAD_OUT) - http_client_request_finish_payload(req); + http_client_request_finish_payload_out(req); } else { req->payload_input = i_stream_create_from_data(data, size); } @@ -255,6 +256,19 @@ return ret; } +int http_client_request_send_payload(struct http_client_request **_req, + const unsigned char *data, size_t size) +{ + i_assert(data != NULL); + + return http_client_request_continue_payload(_req, data, size); +} + +int http_client_request_finish_payload(struct http_client_request **_req) +{ + return http_client_request_continue_payload(_req, NULL, 0); +} + int http_client_request_send_more(struct http_client_request *req) { struct http_client_connection *conn = req->conn; @@ -279,7 +293,7 @@ if (req->client->ioloop != NULL) io_loop_stop(req->client->ioloop); } else { - http_client_request_finish_payload(req); + http_client_request_finish_payload_out(req); } } else { diff -r 5a068b9c04a9 -r 3bc84d6c9e8d src/lib-http/http-client.h --- a/src/lib-http/http-client.h Wed Feb 20 10:58:02 2013 +0200 +++ b/src/lib-http/http-client.h Wed Feb 20 11:18:59 2013 +0200 @@ -84,9 +84,11 @@ void *context); /* submits request and blocks until provided payload is sent. Multiple calls - are allowed; payload transmission is ended when data == NULL. */ + are allowed; payload transmission is ended with + http_client_request_finish_payload(). */ int http_client_request_send_payload(struct http_client_request **req, const unsigned char *data, size_t size); +int http_client_request_finish_payload(struct http_client_request **req); void http_client_switch_ioloop(struct http_client *client); diff -r 5a068b9c04a9 -r 3bc84d6c9e8d src/plugins/fts-solr/solr-connection.c --- a/src/plugins/fts-solr/solr-connection.c Wed Feb 20 10:58:02 2013 +0200 +++ b/src/plugins/fts-solr/solr-connection.c Wed Feb 20 11:18:59 2013 +0200 @@ -524,7 +524,7 @@ i_assert(conn->posting); if (!post->failed) { - if (http_client_request_send_payload(&post->http_req, NULL, 0) <= 0 || + if (http_client_request_finish_payload(&post->http_req) <= 0 || conn->request_status < 0) { ret = -1; } From dovecot at dovecot.org Wed Feb 20 11:59:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 11:59:14 +0200 Subject: dovecot-2.2: lib-http: Avoid hanging in http_client_wait() while... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/164c70254dd0 changeset: 15855:164c70254dd0 user: Timo Sirainen date: Wed Feb 20 11:57:55 2013 +0200 description: lib-http: Avoid hanging in http_client_wait() while there's nothing to do. diffstat: src/lib-http/http-client-request.c | 3 +++ src/lib-http/http-client.c | 3 +++ 2 files changed, 6 insertions(+), 0 deletions(-) diffs (26 lines): diff -r 3bc84d6c9e8d -r 164c70254dd0 src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Wed Feb 20 11:18:59 2013 +0200 +++ b/src/lib-http/http-client-request.c Wed Feb 20 11:57:55 2013 +0200 @@ -87,6 +87,9 @@ http_client_request_debug(req, "Destroy (requests left=%d)", client->pending_requests); + if (client->pending_requests == 0 && client->ioloop != NULL) + io_loop_stop(client->ioloop); + if (req->payload_input != NULL) i_stream_unref(&req->payload_input); if (req->payload_output != NULL) diff -r 3bc84d6c9e8d -r 164c70254dd0 src/lib-http/http-client.c --- a/src/lib-http/http-client.c Wed Feb 20 11:18:59 2013 +0200 +++ b/src/lib-http/http-client.c Wed Feb 20 11:57:55 2013 +0200 @@ -165,6 +165,9 @@ i_assert(client->ioloop == NULL); + if (client->pending_requests == 0) + return; + client->ioloop = io_loop_create(); http_client_switch_ioloop(client); From dovecot at dovecot.org Wed Feb 20 11:59:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 11:59:14 +0200 Subject: dovecot-2.2: test-http-client: If given a parameter, GET it. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/98c86534d4b7 changeset: 15856:98c86534d4b7 user: Timo Sirainen date: Wed Feb 20 11:58:34 2013 +0200 description: test-http-client: If given a parameter, GET it. diffstat: src/lib-http/test-http-client.c | 85 ++++++++++++++++++++++++++++------------ 1 files changed, 60 insertions(+), 25 deletions(-) diffs (130 lines): diff -r 164c70254dd0 -r 98c86534d4b7 src/lib-http/test-http-client.c --- a/src/lib-http/test-http-client.c Wed Feb 20 11:57:55 2013 +0200 +++ b/src/lib-http/test-http-client.c Wed Feb 20 11:58:34 2013 +0200 @@ -4,11 +4,13 @@ #include "ioloop.h" #include "istream.h" #include "write-full.h" +#include "http-url.h" #include "http-client.h" struct http_test_request { struct io *io; struct istream *payload; + bool write_output; }; static void payload_input(struct http_test_request *req) @@ -20,7 +22,8 @@ /* read payload */ while ((ret=i_stream_read_data(req->payload, &data, &size, 0)) > 0) { i_info("DEBUG: got data (size=%d)", (int)size); - //write_full(1, data, size); + if (req->write_output) + write_full(1, data, size); i_stream_skip(req->payload, size); } @@ -75,36 +78,14 @@ static const char *test_query2 = "data=This%20is%20a%20test&submit=Submit"; static const char *test_query3 = "foo=bar"; -int main(void) +static void run_tests(struct http_client *http_client) { - struct http_client_settings http_set; - struct http_client *http_client; struct http_client_request *http_req; - struct ioloop *ioloop; struct http_test_request *test_req; struct istream *post_payload; - memset(&http_set, 0, sizeof(http_set)); - http_set.dns_client_socket_path = "/var/run/dovecot/dns-client"; - http_set.debug = TRUE; - http_set.ssl_ca_dir = "/etc/ssl/certs"; - http_set.max_idle_time_msecs = 5*1000; - http_set.max_parallel_connections = 4; - http_set.max_pipelined_requests = 4; - http_set.max_redirects = 2; - http_set.max_attempts = 1; - http_set.debug = TRUE; - http_set.rawlog_dir = "/tmp/http-test"; - - lib_init(); - - ioloop = io_loop_create(); - io_loop_set_running(ioloop); - // JigSAW is useful for testing: http://jigsaw.w3.org/HTTP/ - http_client = http_client_init(&http_set); - test_req = i_new(struct http_test_request, 1); http_req = http_client_request(http_client, "GET", "pigeonhole.dovecot.org", "/", @@ -280,9 +261,63 @@ http_client_request_set_payload(http_req, post_payload, TRUE); i_stream_unref(&post_payload); http_client_request_submit(http_req); +} + +static void run_http_get(struct http_client *http_client, const char *url_str) +{ + struct http_client_request *http_req; + struct http_test_request *test_req; + struct http_url *url; + const char *error; + + if (http_url_parse(url_str, NULL, 0, pool_datastack_create(), + &url, &error) < 0) + i_fatal("Invalid URL %s: %s", url_str, error); + + test_req = i_new(struct http_test_request, 1); + test_req->write_output = TRUE; + http_req = http_client_request(http_client, + "GET", url->host_name, + t_strconcat("/", url->path, url->enc_query, NULL), + got_request_response, test_req); + if (url->have_port) + http_client_request_set_port(http_req, url->port); + if (url->have_ssl) + http_client_request_set_ssl(http_req, TRUE); + http_client_request_submit(http_req); +} + +int main(int argc, char *argv[]) +{ + struct http_client_settings http_set; + struct http_client *http_client; + struct ioloop *ioloop; + + memset(&http_set, 0, sizeof(http_set)); + http_set.dns_client_socket_path = "/var/run/dovecot/dns-client"; + http_set.debug = TRUE; + http_set.ssl_ca_dir = "/etc/ssl/certs"; + http_set.max_idle_time_msecs = 5*1000; + http_set.max_parallel_connections = 4; + http_set.max_pipelined_requests = 4; + http_set.max_redirects = 2; + http_set.max_attempts = 1; + http_set.debug = TRUE; + http_set.rawlog_dir = "/tmp/http-test"; + + lib_init(); + + ioloop = io_loop_create(); + io_loop_set_running(ioloop); + + http_client = http_client_init(&http_set); + + if (argc > 1) + run_http_get(http_client, argv[1]); + else + run_tests(http_client); http_client_wait(http_client); - http_client_deinit(&http_client); io_loop_destroy(&ioloop); From dovecot at dovecot.org Wed Feb 20 12:24:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 12:24:46 +0200 Subject: dovecot-2.2: test-http-client: Added POST functionality also. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/07dfd4391d22 changeset: 15857:07dfd4391d22 user: Timo Sirainen date: Wed Feb 20 12:24:36 2013 +0200 description: test-http-client: Added POST functionality also. diffstat: src/lib-http/test-http-client.c | 48 ++++++++++++++++++++++++++++++++++++---- 1 files changed, 43 insertions(+), 5 deletions(-) diffs (79 lines): diff -r 98c86534d4b7 -r 07dfd4391d22 src/lib-http/test-http-client.c --- a/src/lib-http/test-http-client.c Wed Feb 20 11:58:34 2013 +0200 +++ b/src/lib-http/test-http-client.c Wed Feb 20 12:24:36 2013 +0200 @@ -263,7 +263,11 @@ http_client_request_submit(http_req); } -static void run_http_get(struct http_client *http_client, const char *url_str) +static void +test_http_request_init(struct http_client *http_client, + const char *method, const char *url_str, + struct http_client_request **http_req_r, + struct http_test_request **test_req_r) { struct http_client_request *http_req; struct http_test_request *test_req; @@ -277,13 +281,38 @@ test_req = i_new(struct http_test_request, 1); test_req->write_output = TRUE; http_req = http_client_request(http_client, - "GET", url->host_name, + method, url->host_name, t_strconcat("/", url->path, url->enc_query, NULL), got_request_response, test_req); if (url->have_port) http_client_request_set_port(http_req, url->port); if (url->have_ssl) http_client_request_set_ssl(http_req, TRUE); + + *http_req_r = http_req; + *test_req_r = test_req; +} + +static void run_http_get(struct http_client *http_client, const char *url_str) +{ + struct http_client_request *http_req; + struct http_test_request *test_req; + + test_http_request_init(http_client, "GET", url_str, &http_req, &test_req); + http_client_request_submit(http_req); +} + +static void run_http_post(struct http_client *http_client, const char *url_str, + const char *path) +{ + struct http_client_request *http_req; + struct http_test_request *test_req; + struct istream *input; + + test_http_request_init(http_client, "POST", url_str, &http_req, &test_req); + input = i_stream_create_file(path, IO_BLOCK_SIZE); + http_client_request_set_payload(http_req, input, FALSE); + i_stream_unref(&input); http_client_request_submit(http_req); } @@ -312,10 +341,19 @@ http_client = http_client_init(&http_set); - if (argc > 1) + switch (argc) { + case 1: + run_tests(http_client); + break; + case 2: run_http_get(http_client, argv[1]); - else - run_tests(http_client); + break; + case 3: + run_http_post(http_client, argv[1], argv[2]); + break; + default: + i_fatal("Too many parameters"); + } http_client_wait(http_client); http_client_deinit(&http_client); From dovecot at dovecot.org Wed Feb 20 15:53:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 15:53:24 +0200 Subject: dovecot-2.2: lib-storage: Reset saving/moving/copying_via_save f... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7df4ca451d2e changeset: 15858:7df4ca451d2e user: Timo Sirainen date: Wed Feb 20 15:40:16 2013 +0200 description: lib-storage: Reset saving/moving/copying_via_save flag between mail_save_context uses. diffstat: src/lib-storage/index/index-storage.c | 4 ++++ src/lib-storage/mail-storage.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletions(-) diffs (32 lines): diff -r 07dfd4391d22 -r 7df4ca451d2e src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed Feb 20 12:24:36 2013 +0200 +++ b/src/lib-storage/index/index-storage.c Wed Feb 20 15:40:16 2013 +0200 @@ -754,7 +754,11 @@ i_free_and_null(ctx->data.pop3_uidl); index_attachment_save_free(ctx); memset(&ctx->data, 0, sizeof(ctx->data)); + ctx->unfinished = FALSE; + ctx->copying_via_save = FALSE; + ctx->saving = FALSE; + ctx->moving = FALSE; } static void diff -r 07dfd4391d22 -r 7df4ca451d2e src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Feb 20 12:24:36 2013 +0200 +++ b/src/lib-storage/mail-storage.c Wed Feb 20 15:40:16 2013 +0200 @@ -1941,11 +1941,12 @@ struct mailbox_transaction_context *t = ctx->transaction; struct mail_keywords *keywords = ctx->data.keywords; enum mail_flags pvt_flags = ctx->data.pvt_flags; + bool copying_via_save = ctx->copying_via_save; int ret; *_ctx = NULL; ret = t->box->v.save_finish(ctx); - if (ret == 0 && !ctx->copying_via_save) { + if (ret == 0 && !copying_via_save) { if (pvt_flags != 0) mailbox_save_add_pvt_flags(t, pvt_flags); t->save_count++; From dovecot at dovecot.org Wed Feb 20 15:53:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 15:53:24 +0200 Subject: dovecot-2.2: lib-storage: If mailbox is deleted, mailbox_save_be... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e383647dc9dd changeset: 15859:e383647dc9dd user: Timo Sirainen date: Wed Feb 20 15:41:17 2013 +0200 description: lib-storage: If mailbox is deleted, mailbox_save_begin() should cancel mail_save_context. diffstat: src/lib-storage/mail-storage.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 7df4ca451d2e -r e383647dc9dd src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Feb 20 15:40:16 2013 +0200 +++ b/src/lib-storage/mail-storage.c Wed Feb 20 15:41:17 2013 +0200 @@ -1897,6 +1897,7 @@ if (mail_index_is_deleted(box->index)) { mailbox_set_deleted(box); + mailbox_save_cancel(ctx); return -1; } From dovecot at dovecot.org Wed Feb 20 15:53:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 15:53:24 +0200 Subject: dovecot-2.2: lib-storage: Added more asserts to catch missing ma... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/990ff0e1eb6a changeset: 15860:990ff0e1eb6a user: Timo Sirainen date: Wed Feb 20 15:49:06 2013 +0200 description: lib-storage: Added more asserts to catch missing mail_save_context frees. Arguably mail_save_context could already freed at this time, but some other code relies on this as well. These could be removed later if this is no longer true. diffstat: src/lib-storage/mail-storage.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (27 lines): diff -r e383647dc9dd -r 990ff0e1eb6a src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Feb 20 15:41:17 2013 +0200 +++ b/src/lib-storage/mail-storage.c Wed Feb 20 15:49:06 2013 +0200 @@ -1954,6 +1954,7 @@ } if (keywords != NULL) mailbox_keywords_unref(&keywords); + i_assert(!ctx->unfinished); return ret; } @@ -1974,6 +1975,7 @@ mail = (struct mail_private *)ctx->dest_mail; mail->v.close(&mail->mail); } + i_assert(!ctx->unfinished); } struct mailbox_transaction_context * @@ -2010,6 +2012,7 @@ } if (keywords != NULL) mailbox_keywords_unref(&keywords); + i_assert(!ctx->unfinished); return ret; } From dovecot at dovecot.org Wed Feb 20 15:53:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 15:53:24 +0200 Subject: dovecot-2.2: acl: If copy() doesn't have enough permissions, fre... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cfdd31b26493 changeset: 15861:cfdd31b26493 user: Timo Sirainen date: Wed Feb 20 15:49:46 2013 +0200 description: acl: If copy() doesn't have enough permissions, free mail_save_context properly. diffstat: src/plugins/acl/acl-mailbox.c | 38 +++++++++++++++++++++++++------------- 1 files changed, 25 insertions(+), 13 deletions(-) diffs (56 lines): diff -r 990ff0e1eb6a -r cfdd31b26493 src/plugins/acl/acl-mailbox.c --- a/src/plugins/acl/acl-mailbox.c Wed Feb 20 15:49:06 2013 +0200 +++ b/src/plugins/acl/acl-mailbox.c Wed Feb 20 15:49:46 2013 +0200 @@ -391,27 +391,39 @@ return abox->module_ctx.super.save_begin(ctx, input); } +static bool +acl_copy_has_rights(struct mail_save_context *ctx, struct mail *mail) +{ + struct mailbox *destbox = ctx->transaction->box; + enum acl_storage_rights save_right; + + if (ctx->moving) { + if (acl_mailbox_right_lookup(mail->box, + ACL_STORAGE_RIGHT_EXPUNGE) <= 0) + return FALSE; + } + + save_right = (destbox->flags & MAILBOX_FLAG_POST_SESSION) != 0 ? + ACL_STORAGE_RIGHT_POST : ACL_STORAGE_RIGHT_INSERT; + if (acl_mailbox_right_lookup(destbox, save_right) <= 0) + return FALSE; + if (acl_save_get_flags(destbox, &ctx->data.flags, + &ctx->data.pvt_flags, &ctx->data.keywords) < 0) + return FALSE; + return TRUE; +} + static int acl_copy(struct mail_save_context *ctx, struct mail *mail) { struct mailbox_transaction_context *t = ctx->transaction; struct acl_mailbox *abox = ACL_CONTEXT(t->box); - enum acl_storage_rights save_right; - if (ctx->moving) { - if (acl_mailbox_right_lookup(mail->box, - ACL_STORAGE_RIGHT_EXPUNGE) <= 0) - return -1; + if (!acl_copy_has_rights(ctx, mail)) { + mailbox_save_cancel(&ctx); + return -1; } - save_right = (t->box->flags & MAILBOX_FLAG_POST_SESSION) != 0 ? - ACL_STORAGE_RIGHT_POST : ACL_STORAGE_RIGHT_INSERT; - if (acl_mailbox_right_lookup(t->box, save_right) <= 0) - return -1; - if (acl_save_get_flags(t->box, &ctx->data.flags, - &ctx->data.pvt_flags, &ctx->data.keywords) < 0) - return -1; - return abox->module_ctx.super.copy(ctx, mail); } From dovecot at dovecot.org Wed Feb 20 16:03:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 16:03:59 +0200 Subject: dovecot-2.2: mbox: Fixed mailbox_update() to not shrink uidnext. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/808a64899e8a changeset: 15863:808a64899e8a user: Timo Sirainen date: Wed Feb 20 16:03:53 2013 +0200 description: mbox: Fixed mailbox_update() to not shrink uidnext. diffstat: src/lib-storage/index/mbox/mbox-sync.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 8e992ae76c45 -r 808a64899e8a src/lib-storage/index/mbox/mbox-sync.c --- a/src/lib-storage/index/mbox/mbox-sync.c Wed Feb 20 15:56:56 2013 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync.c Wed Feb 20 16:03:53 2013 +0200 @@ -975,7 +975,8 @@ mail_ctx->need_rewrite = TRUE; } if (update->min_next_uid != 0 && - sync_ctx->base_uid_last <= update->min_next_uid) { + sync_ctx->base_uid_last+1 < update->min_next_uid) { + i_assert(sync_ctx->next_uid <= update->min_next_uid); sync_ctx->base_uid_last = update->min_next_uid-1; sync_ctx->next_uid = update->min_next_uid; mail_ctx->imapbase_rewrite = TRUE; From dovecot at dovecot.org Wed Feb 20 16:03:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 16:03:59 +0200 Subject: dovecot-2.2: acl: Skip ACLs if admin user flag is set (especiall... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8e992ae76c45 changeset: 15862:8e992ae76c45 user: Timo Sirainen date: Wed Feb 20 15:56:56 2013 +0200 description: acl: Skip ACLs if admin user flag is set (especially dsync). diffstat: src/plugins/acl/acl-api.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (25 lines): diff -r cfdd31b26493 -r 8e992ae76c45 src/plugins/acl/acl-api.c --- a/src/plugins/acl/acl-api.c Wed Feb 20 15:49:46 2013 +0200 +++ b/src/plugins/acl/acl-api.c Wed Feb 20 15:56:56 2013 +0200 @@ -3,6 +3,8 @@ #include "lib.h" #include "str.h" #include "hash.h" +#include "mail-user.h" +#include "mailbox-list.h" #include "acl-cache.h" #include "acl-api-private.h" @@ -31,6 +33,12 @@ struct acl_backend *backend = aclobj->backend; const struct acl_mask *have_mask; + if (mailbox_list_get_user(aclobj->backend->list)->admin) { + /* admin user (especially dsync) can do anything regardless + of ACLs */ + return 1; + } + if (backend->v.object_refresh_cache(aclobj) < 0) return -1; From dovecot at dovecot.org Wed Feb 20 16:49:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 16:49:25 +0200 Subject: dovecot-2.2: mailbox_list_index: Delay allocating the index so m... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f703e1fd7c21 changeset: 15864:f703e1fd7c21 user: Timo Sirainen date: Wed Feb 20 16:49:14 2013 +0200 description: mailbox_list_index: Delay allocating the index so mbox can override the index path. diffstat: src/lib-storage/list/mailbox-list-index-status.c | 2 +- src/lib-storage/list/mailbox-list-index.c | 39 +++++++++++++++++++---- src/lib-storage/list/mailbox-list-index.h | 3 +- 3 files changed, 34 insertions(+), 10 deletions(-) diffs (112 lines): diff -r 808a64899e8a -r f703e1fd7c21 src/lib-storage/list/mailbox-list-index-status.c --- a/src/lib-storage/list/mailbox-list-index-status.c Wed Feb 20 16:03:53 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index-status.c Wed Feb 20 16:49:14 2013 +0200 @@ -529,7 +529,7 @@ box->v.transaction_commit = index_list_transaction_commit; } -void mailbox_list_index_status_init_list(struct mailbox_list *list) +void mailbox_list_index_status_init_finish(struct mailbox_list *list) { struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list); diff -r 808a64899e8a -r f703e1fd7c21 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Wed Feb 20 16:03:53 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index.c Wed Feb 20 16:49:14 2013 +0200 @@ -528,7 +528,6 @@ static void mailbox_list_index_created(struct mailbox_list *list) { struct mailbox_list_index *ilist; - const char *dir; bool has_backing_store; /* layout=index doesn't have any backing store */ @@ -543,16 +542,11 @@ MODULE_CONTEXT_SET(list, mailbox_list_index_module, ilist); return; } - if (!mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_INDEX, - &dir)) { - /* in-memory indexes */ - dir = NULL; - } - i_assert(has_backing_store || dir != NULL); ilist = p_new(list->pool, struct mailbox_list_index, 1); ilist->module_ctx.super = list->v; ilist->has_backing_store = has_backing_store; + ilist->pending_init = TRUE; list->v.deinit = mailbox_list_index_deinit; list->v.iter_init = mailbox_list_index_iter_init; @@ -570,6 +564,25 @@ list->v.notify_wait = mailbox_list_index_notify_wait; MODULE_CONTEXT_SET(list, mailbox_list_index_module, ilist); +} + +static void mailbox_list_index_init_finish(struct mailbox_list *list) +{ + struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list); + const char *dir; + + if (!ilist->pending_init) + return; + ilist->pending_init = FALSE; + + /* we've delayed this part of the initialization so that mbox format + can override the index root directory path */ + if (!mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_INDEX, + &dir)) { + /* in-memory indexes */ + dir = NULL; + } + i_assert(ilist->has_backing_store || dir != NULL); ilist->path = dir == NULL ? "(in-memory mailbox list index)" : p_strdup_printf(list->pool, "%s/"MAILBOX_LIST_INDEX_PREFIX, dir); @@ -587,7 +600,16 @@ hash_table_create_direct(&ilist->mailbox_names, ilist->mailbox_pool, 0); hash_table_create_direct(&ilist->mailbox_hash, ilist->mailbox_pool, 0); - mailbox_list_index_status_init_list(list); + mailbox_list_index_status_init_finish(list); +} + +static void +mailbox_list_index_namespaces_created(struct mail_namespace *namespaces) +{ + struct mail_namespace *ns; + + for (ns = namespaces; ns != NULL; ns = ns->next) + mailbox_list_index_init_finish(ns->list); } static void mailbox_list_index_mailbox_allocated(struct mailbox *box) @@ -612,6 +634,7 @@ static struct mail_storage_hooks mailbox_list_index_hooks = { .mailbox_list_created = mailbox_list_index_created, + .mail_namespaces_created = mailbox_list_index_namespaces_created, .mailbox_allocated = mailbox_list_index_mailbox_allocated }; diff -r 808a64899e8a -r f703e1fd7c21 src/lib-storage/list/mailbox-list-index.h --- a/src/lib-storage/list/mailbox-list-index.h Wed Feb 20 16:03:53 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index.h Wed Feb 20 16:49:14 2013 +0200 @@ -105,6 +105,7 @@ HASH_TABLE(void *, struct mailbox_list_index_node *) mailbox_hash; struct mailbox_list_index_node *mailbox_tree; + unsigned int pending_init:1; unsigned int opened:1; unsigned int syncing:1; unsigned int updating_status:1; @@ -181,6 +182,6 @@ void mailbox_list_index_status_init_mailbox(struct mailbox *box); void mailbox_list_index_backend_init_mailbox(struct mailbox *box); -void mailbox_list_index_status_init_list(struct mailbox_list *list); +void mailbox_list_index_status_init_finish(struct mailbox_list *list); #endif From dovecot at dovecot.org Wed Feb 20 16:58:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 16:58:50 +0200 Subject: dovecot-2.1: quota-status: Load plugins after all. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f12f2f2f7459 changeset: 14909:f12f2f2f7459 user: Timo Sirainen date: Wed Feb 20 16:58:45 2013 +0200 description: quota-status: Load plugins after all. They may be needed for user initialization to work (e.g. virtual plugin) or maybe even for quota itself to work (external quota backend plugin). diffstat: src/plugins/quota/Makefile.am | 8 ++++++++ src/plugins/quota/quota-status.c | 11 +---------- 2 files changed, 9 insertions(+), 10 deletions(-) diffs (60 lines): diff -r 980be1dc80c2 -r f12f2f2f7459 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Tue Feb 19 17:36:59 2013 +0200 +++ b/src/plugins/quota/Makefile.am Wed Feb 20 16:58:45 2013 +0200 @@ -53,8 +53,16 @@ quota_status_SOURCES = \ quota-status.c +if !BUILD_SHARED_LIBS +unused_objects = \ + ../../lib/mountpoint.o \ + ../../lib-imap/imap-util.o \ + ../../lib-storage/mail-search-parser-imap.o +endif + quota_status_LDADD = \ $(quota_common_objects) \ + $(unused_objects) \ $(LIBDOVECOT_STORAGE) \ $(LIBDOVECOT) \ $(MODULE_LIBS) diff -r 980be1dc80c2 -r f12f2f2f7459 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Tue Feb 19 17:36:59 2013 +0200 +++ b/src/plugins/quota/quota-status.c Wed Feb 20 16:58:45 2013 +0200 @@ -1,7 +1,6 @@ /* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ #include "lib.h" -#include "module-dir.h" #include "ostream.h" #include "connection.h" #include "restrict-access.h" @@ -28,11 +27,6 @@ static struct mail_storage_service_ctx *storage_service; static struct connection_list *clients; -static struct module quota_module = { - .path = "quota", - .name = "quota" -}; - static void client_connected(struct master_service_connection *conn) { struct quota_client *client; @@ -168,15 +162,12 @@ MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP | MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS | - MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR | - MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS); - quota_plugin_init("a_module); + MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR); } static void main_deinit(void) { connection_list_deinit(&clients); - quota_plugin_deinit(); mail_storage_service_deinit(&storage_service); } From dovecot at dovecot.org Wed Feb 20 19:35:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 20 Feb 2013 19:35:09 +0200 Subject: dovecot-2.2: lib-http: Fixed hang with failed DNS lookups Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fe24e69ea0c5 changeset: 15865:fe24e69ea0c5 user: Stephan Bosch date: Wed Feb 20 19:34:51 2013 +0200 description: lib-http: Fixed hang with failed DNS lookups diffstat: src/lib-http/http-client-host.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (27 lines): diff -r f703e1fd7c21 -r fe24e69ea0c5 src/lib-http/http-client-host.c --- a/src/lib-http/http-client-host.c Wed Feb 20 16:49:14 2013 +0200 +++ b/src/lib-http/http-client-host.c Wed Feb 20 19:34:51 2013 +0200 @@ -289,17 +289,20 @@ req->host = host; - if (host->ips_count == 0 && host->dns_lookup == NULL) - http_client_host_lookup(host); + /* add request to host (grouped by tcp port) */ hport = http_client_host_port_init(host, req->port, req->ssl); if (req->urgent) array_append(&hport->urgent_request_queue, &req, 1); else array_append(&hport->request_queue, &req, 1); + /* start DNS lookup if necessary */ + if (host->ips_count == 0 && host->dns_lookup == NULL) + http_client_host_lookup(host); + + /* make a connection if we have an IP already */ if (host->ips_count == 0) return; - http_client_host_connection_setup(host, hport); } From dovecot at dovecot.org Thu Feb 21 06:22:53 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 06:22:53 +0200 Subject: dovecot-2.2: lib-storage: Fixed crash with mailbox_list_index=no Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c945d06207b8 changeset: 15866:c945d06207b8 user: Timo Sirainen date: Thu Feb 21 06:22:40 2013 +0200 description: lib-storage: Fixed crash with mailbox_list_index=no diffstat: src/lib-storage/list/mailbox-list-index.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r fe24e69ea0c5 -r c945d06207b8 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Wed Feb 20 19:34:51 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index.c Thu Feb 21 06:22:40 2013 +0200 @@ -571,7 +571,7 @@ struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list); const char *dir; - if (!ilist->pending_init) + if (ilist == NULL || !ilist->pending_init) return; ilist->pending_init = FALSE; From dovecot at dovecot.org Thu Feb 21 07:55:40 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 07:55:40 +0200 Subject: dovecot-2.1: Added quota plugin's headers to LIBDOVECOT_STORAGE_... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/20ea109b30a7 changeset: 14910:20ea109b30a7 user: Timo Sirainen date: Thu Feb 21 07:55:24 2013 +0200 description: Added quota plugin's headers to LIBDOVECOT_STORAGE_INCLUDE. This allows creating external plugins that depend on the quota plugin (similar to trash plugin). diffstat: dovecot-config.in.in | 2 +- src/plugins/quota/Makefile.am | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diffs (25 lines): diff -r f12f2f2f7459 -r 20ea109b30a7 dovecot-config.in.in --- a/dovecot-config.in.in Wed Feb 20 16:58:45 2013 +0200 +++ b/dovecot-config.in.in Thu Feb 21 07:55:24 2013 +0200 @@ -18,7 +18,7 @@ LIBDOVECOT_INCLUDE="-I$(incdir) -I$(incdir)/src/lib -I$(incdir)/src/lib-dict -I$(incdir)/src/lib-dns -I$(incdir)/src/lib-mail -I$(incdir)/src/lib-imap -I$(incdir)/src/lib-fs -I$(incdir)/src/lib-charset" LIBDOVECOT_LDA_INCLUDE="-I$(incdir)/src/lib-lda -I$(incdir)/src/lda" LIBDOVECOT_SERVICE_INCLUDE="-I$(incdir)/src/lib-master -I$(incdir)/src/lib-settings" -LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw" +LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw -I$(incdir)/src/plugins/quota" LIBDOVECOT_LOGIN_INCLUDE="-I$(incdir)/src/lib-auth -I$(incdir)/src/login-common" LIBDOVECOT_IMAP_INCLUDE="-I$(incdir)/src/imap" LIBDOVECOT_CONFIG_INCLUDE="-I$(incdir)/src/config" diff -r f12f2f2f7459 -r 20ea109b30a7 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Wed Feb 20 16:58:45 2013 +0200 +++ b/src/plugins/quota/Makefile.am Thu Feb 21 07:55:24 2013 +0200 @@ -95,7 +95,8 @@ endif -noinst_HEADERS = \ +pkginc_libdir=$(pkgincludedir) +pkginc_lib_HEADERS = \ quota.h \ quota-fs.h \ quota-plugin.h \ From dovecot at dovecot.org Thu Feb 21 10:23:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 10:23:01 +0200 Subject: dovecot-2.2: lib-http: Fixed hangs/crashes with chunked ostream. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3b905464ea09 changeset: 15867:3b905464ea09 user: Timo Sirainen date: Thu Feb 21 10:21:31 2013 +0200 description: lib-http: Fixed hangs/crashes with chunked ostream. Based on patch by Stephan Bosch. diffstat: src/lib-http/http-client-request.c | 7 ++++++- src/lib-http/http-transfer-chunked.c | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diffs (81 lines): diff -r c945d06207b8 -r 3b905464ea09 src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Thu Feb 21 06:22:40 2013 +0200 +++ b/src/lib-http/http-client-request.c Thu Feb 21 10:21:31 2013 +0200 @@ -230,6 +230,9 @@ while (req->state < HTTP_REQUEST_STATE_FINISHED) { http_client_request_debug(req, "Waiting for request to finish"); + + if (req->state == HTTP_REQUEST_STATE_PAYLOAD_OUT) + o_stream_set_flush_pending(req->payload_output, TRUE); io_loop_run(client->ioloop); if (req->state == HTTP_REQUEST_STATE_PAYLOAD_OUT && @@ -280,7 +283,8 @@ i_assert(req->payload_input != NULL); - o_stream_set_max_buffer_size(output, 0); + /* chunked ostream needs to write to the parent stream's buffer */ + o_stream_set_max_buffer_size(output, IO_BLOCK_SIZE); if (o_stream_send_istream(output, req->payload_input) < 0) ret = -1; o_stream_set_max_buffer_size(output, (size_t)-1); @@ -293,6 +297,7 @@ } if (req->payload_wait) { + conn->output_locked = TRUE; if (req->client->ioloop != NULL) io_loop_stop(req->client->ioloop); } else { diff -r c945d06207b8 -r 3b905464ea09 src/lib-http/http-transfer-chunked.c --- a/src/lib-http/http-transfer-chunked.c Thu Feb 21 06:22:40 2013 +0200 +++ b/src/lib-http/http-transfer-chunked.c Thu Feb 21 10:21:31 2013 +0200 @@ -8,6 +8,8 @@ #include "http-transfer.h" +#define MIN_CHUNK_SIZE_WITH_EXTRA 6 + /* * Chunked input stream */ @@ -540,14 +542,17 @@ static size_t _max_chunk_size(size_t avail) { + size_t chunk_extra = 2*2; + /* Make sure we have room for both chunk data and overhead chunk = chunk-size CRLF chunk-data CRLF chunk-size = 1*HEXDIG */ - avail -= (2*2); - return avail - (_log16(avail)); + chunk_extra += _log16(avail); + return avail < chunk_extra ? 0 : + avail - chunk_extra; } static void @@ -572,6 +577,8 @@ ssize_t ret; const char *prefix; + i_assert(stream->parent->real_stream->max_buffer_size >= MIN_CHUNK_SIZE_WITH_EXTRA); + if ((ret=o_stream_flush(stream->parent)) <= 0) { /* error / we still couldn't flush existing data to parent stream. */ @@ -588,7 +595,7 @@ /* check if we have room to send at least one byte */ max_bytes = o_stream_get_buffer_avail_size(stream->parent); max_bytes = _max_chunk_size(max_bytes); - if (max_bytes < 6) + if (max_bytes < MIN_CHUNK_SIZE_WITH_EXTRA) return 0; tcstream->chunk_size = bytes > max_bytes ? max_bytes : bytes; From dovecot at dovecot.org Thu Feb 21 10:23:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 10:23:24 +0200 Subject: dovecot-2.2: lib-http: Minor improvements. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b0c4a5ce4933 changeset: 15868:b0c4a5ce4933 user: Stephan Bosch date: Thu Feb 21 10:23:08 2013 +0200 description: lib-http: Minor improvements. diffstat: src/lib-http/http-client-peer.c | 2 +- src/lib-http/http-response-parser.c | 30 ++++++++++++++++-------------- src/lib-http/test-http-client.c | 11 +++++++++++ 3 files changed, 28 insertions(+), 15 deletions(-) diffs (144 lines): diff -r 3b905464ea09 -r b0c4a5ce4933 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Thu Feb 21 10:21:31 2013 +0200 +++ b/src/lib-http/http-client-peer.c Thu Feb 21 10:23:08 2013 +0200 @@ -361,7 +361,7 @@ struct http_client_connection *const *conn_idx; unsigned int idle = 0; - /* find the least busy connection */ + /* find idle connections */ array_foreach(&peer->conns, conn_idx) { if (http_client_connection_is_idle(*conn_idx)) idle++; diff -r 3b905464ea09 -r b0c4a5ce4933 src/lib-http/http-response-parser.c --- a/src/lib-http/http-response-parser.c Thu Feb 21 10:21:31 2013 +0200 +++ b/src/lib-http/http-response-parser.c Thu Feb 21 10:23:08 2013 +0200 @@ -98,7 +98,8 @@ if (str_len(parser->strbuf) + (parser->cur-first) > 8) return -1; - str_append_n(parser->strbuf, first, parser->cur-first); + if ((parser->cur - first) > 0) + str_append_n(parser->strbuf, first, parser->cur-first); if (parser->cur == parser->end) return 0; @@ -116,30 +117,35 @@ if (!i_isdigit(*p)) return -1; parser->response->version_minor = *p - '0'; + str_truncate(parser->strbuf, 0); return 1; } static int http_response_parse_status(struct http_response_parser *parser) { const unsigned char *first = parser->cur; - const char *p; + const unsigned char *p; /* status-code = 3DIGIT */ - while (parser->cur < parser->end && i_isdigit(*parser->cur)) + while (parser->cur < parser->end && i_isdigit(*parser->cur)) { parser->cur++; + if ((parser->cur - first) > 3) + return -1; + } - if (str_len(parser->strbuf) + (parser->cur-first) > 3) + if (str_len(parser->strbuf) + (parser->cur - first) > 3) return -1; - - str_append_n(parser->strbuf, first, parser->cur-first); + if ((parser->cur - first) > 0) + str_append_n(parser->strbuf, first, parser->cur-first); if (parser->cur == parser->end) return 0; if (str_len(parser->strbuf) != 3) return -1; - p = str_c(parser->strbuf); + p = str_data(parser->strbuf); parser->response->status = (p[0] - '0')*100 + (p[1] - '0')*10 + (p[2] - '0'); + str_truncate(parser->strbuf, 0); return 1; } @@ -152,12 +158,13 @@ while (parser->cur < parser->end && http_char_is_text(*parser->cur)) parser->cur++; - str_append_n(parser->strbuf, first, parser->cur-first); - + if ((parser->cur - first) > 0) + str_append_n(parser->strbuf, first, parser->cur-first); if (parser->cur == parser->end) return 0; parser->response->reason = p_strdup(parser->response_pool, str_c(parser->strbuf)); + str_truncate(parser->strbuf, 0); return 1; } @@ -189,7 +196,6 @@ parser->error = "Invalid HTTP version in response"; return ret; } - str_truncate(parser->strbuf, 0); parser->state = HTTP_RESPONSE_PARSE_STATE_SP1; if (parser->cur == parser->end) return 0; @@ -202,7 +208,6 @@ return -1; } parser->cur++; - str_truncate(parser->strbuf, 0); parser->state = HTTP_RESPONSE_PARSE_STATE_STATUS; if (parser->cur >= parser->end) return 0; @@ -213,7 +218,6 @@ parser->error = "Invalid HTTP status code in response"; return ret; } - str_truncate(parser->strbuf, 0); parser->state = HTTP_RESPONSE_PARSE_STATE_SP2; if (parser->cur == parser->end) return 0; @@ -226,7 +230,6 @@ return -1; } parser->cur++; - str_truncate(parser->strbuf, 0); parser->state = HTTP_RESPONSE_PARSE_STATE_REASON; if (parser->cur >= parser->end) return 0; @@ -234,7 +237,6 @@ case HTTP_RESPONSE_PARSE_STATE_REASON: if ((ret=http_response_parse_reason(parser)) <= 0) return ret; - str_truncate(parser->strbuf, 0); parser->state = HTTP_RESPONSE_PARSE_STATE_CR; if (parser->cur == parser->end) return 0; diff -r 3b905464ea09 -r b0c4a5ce4933 src/lib-http/test-http-client.c --- a/src/lib-http/test-http-client.c Thu Feb 21 10:21:31 2013 +0200 +++ b/src/lib-http/test-http-client.c Thu Feb 21 10:23:08 2013 +0200 @@ -213,6 +213,17 @@ test_req = i_new(struct http_test_request, 1); http_req = http_client_request(http_client, + "POST", "posttestserver.com", "/post.php", + got_request_response, test_req); + post_payload = i_stream_create_from_data + ((unsigned char *)test_query1, strlen(test_query1)); + http_client_request_set_payload(http_req, post_payload, TRUE); + i_stream_unref(&post_payload); + http_client_request_set_ssl(http_req, TRUE); + http_client_request_submit(http_req); + + test_req = i_new(struct http_test_request, 1); + http_req = http_client_request(http_client, "GET", "wiki2.dovecot.org", "/Pigeonhole", got_request_response, test_req); http_client_request_submit(http_req); From dovecot at dovecot.org Thu Feb 21 13:21:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:21:33 +0200 Subject: dovecot-2.2: login-common: Updated obsolete login_process_size s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1713ffc870c1 changeset: 15869:1713ffc870c1 user: Timo Sirainen date: Sat Feb 16 19:06:18 2013 +0200 description: login-common: Updated obsolete login_process_size setting in error log message. diffstat: src/login-common/ssl-proxy-openssl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r dd0eebe378fe -r 1713ffc870c1 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Sat Feb 16 13:32:57 2013 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Sat Feb 16 19:06:18 2013 +0200 @@ -433,7 +433,8 @@ case SSL_ERROR_SSL: if (ERR_GET_REASON(ERR_peek_error()) == ERR_R_MALLOC_FAILURE) { i_error("OpenSSL malloc() failed. " - "You may need to increase login_process_size"); + "You may need to increase service %s { vsz_limit }", + login_binary->process_name); } errstr = t_strdup_printf("%s failed: %s", func_name, ssl_last_error()); From dovecot at dovecot.org Thu Feb 21 13:21:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:21:33 +0200 Subject: dovecot-2.2: mbox: If namespace prefix is used, don't show details: http://hg.dovecot.org/dovecot-2.2/rev/b96df105ec55 changeset: 15870:b96df105ec55 user: Timo Sirainen date: Sun Feb 17 12:03:06 2013 +0200 description: mbox: If namespace prefix is used, don't show /inbox mailbox. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 1713ffc870c1 -r b96df105ec55 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Sat Feb 16 19:06:18 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Sun Feb 17 12:03:06 2013 +0200 @@ -707,6 +707,10 @@ ctx->info.flags |= MAILBOX_NOSELECT; } else if ((ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 && list_file_is_any_inbox(ctx, storage_name)) { + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { + /* probably mbox inbox file */ + return 0; + } /* shared/user/INBOX */ ctx->info.flags &= ~(MAILBOX_NOSELECT | MAILBOX_NONEXISTENT); ctx->info.flags |= MAILBOX_SELECT; From dovecot at dovecot.org Thu Feb 21 13:21:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:21:33 +0200 Subject: dovecot-2.2: Added quota-status service for asking if user is ov... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/980be1dc80c2 changeset: 15871:980be1dc80c2 user: Timo Sirainen date: Tue Feb 19 17:36:59 2013 +0200 description: Added quota-status service for asking if user is over quota. Implemented Postfix-compatible policy server protocol initially. Usage: service quota-status { executable = quota-status -p postfix unix_listener /var/spool/postfix/private/quota-status { user = postfix } client_limit = 1 } Postfix: smtpd_recipient_restrictions = ... check_policy_service unix:private/quota-status diffstat: .hgignore | 1 + src/plugins/quota/Makefile.am | 28 +++++ src/plugins/quota/quota-status.c | 214 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 243 insertions(+), 0 deletions(-) diffs (284 lines): diff -r b96df105ec55 -r 980be1dc80c2 .hgignore --- a/.hgignore Sun Feb 17 12:03:06 2013 +0200 +++ b/.hgignore Tue Feb 19 17:36:59 2013 +0200 @@ -97,6 +97,7 @@ src/plugins/fts/xml2text src/plugins/quota/rquota_xdr.c src/plugins/quota/rquota.h +src/plugins/quota/quota-status syntax: regexp src/.*/test-[^\.]*$ diff -r b96df105ec55 -r 980be1dc80c2 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Sun Feb 17 12:03:06 2013 +0200 +++ b/src/plugins/quota/Makefile.am Tue Feb 19 17:36:59 2013 +0200 @@ -1,7 +1,10 @@ doveadm_moduledir = $(moduledir)/doveadm +pkglibexec_PROGRAMS = quota-status + AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-dict \ -I$(top_srcdir)/src/lib-index \ -I$(top_srcdir)/src/lib-mail \ @@ -27,6 +30,17 @@ quota-plugin.c \ quota-storage.c +quota_common_objects = \ + quota.lo \ + quota-count.lo \ + quota-fs.lo \ + quota-dict.lo \ + quota-dirsize.lo \ + quota-maildir.lo \ + quota-plugin.lo \ + quota-storage.lo \ + $(RQUOTA_XDR_LO) + lib10_quota_plugin_la_SOURCES = $(quota_dist_sources) nodist_lib10_quota_plugin_la_SOURCES = $(RQUOTA_XDR) @@ -36,8 +50,22 @@ lib10_doveadm_quota_plugin_la_SOURCES = \ doveadm-quota.c +quota_status_SOURCES = \ + quota-status.c + +quota_status_LDADD = \ + $(quota_common_objects) \ + $(LIBDOVECOT_STORAGE) \ + $(LIBDOVECOT) \ + $(MODULE_LIBS) +quota_status_DEPENDENCIES = \ + $(quota_common_objects) \ + $(LIBDOVECOT_STORAGE_DEPS) \ + $(LIBDOVECOT_DEPS) + if HAVE_RQUOTA RQUOTA_XDR = rquota_xdr.c +RQUOTA_XDR_LO = rquota_xdr.lo #RQUOTA_X = /usr/include/rpcsvc/rquota.x RQUOTA_X = $(srcdir)/rquota.x rquota_xdr.c: Makefile $(RQUOTA_X) diff -r b96df105ec55 -r 980be1dc80c2 src/plugins/quota/quota-status.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins/quota/quota-status.c Tue Feb 19 17:36:59 2013 +0200 @@ -0,0 +1,214 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "module-dir.h" +#include "ostream.h" +#include "connection.h" +#include "restrict-access.h" +#include "master-service.h" +#include "mail-namespace.h" +#include "mail-storage.h" +#include "mail-storage-settings.h" +#include "mail-storage-service.h" +#include "quota-private.h" +#include "quota-plugin.h" + +enum quota_protocol { + QUOTA_PROTOCOL_UNKNOWN = 0, + QUOTA_PROTOCOL_POSTFIX +}; + +struct quota_client { + struct connection conn; + + char *recipient; +}; + +static enum quota_protocol protocol; +static struct mail_storage_service_ctx *storage_service; +static struct connection_list *clients; + +static struct module quota_module = { + .path = "quota", + .name = "quota" +}; + +static void client_connected(struct master_service_connection *conn) +{ + struct quota_client *client; + + client = i_new(struct quota_client, 1); + connection_init_server(clients, &client->conn, + "(quota client)", conn->fd, conn->fd); + master_service_client_connection_accept(conn); +} + +static void client_reset(struct quota_client *client) +{ + i_free_and_null(client->recipient); +} + +static int quota_check(struct mail_user *user, const char **error_r) +{ + struct quota_user *quser = QUOTA_USER_CONTEXT(user); + struct mail_namespace *ns; + struct mailbox *box; + struct quota_transaction_context *ctx; + bool too_large; + int ret; + + if (quser == NULL) { + /* no quota for user */ + return 1; + } + + ns = mail_namespace_find_inbox(user->namespaces); + box = mailbox_alloc(ns->list, "INBOX", 0); + + ctx = quota_transaction_begin(box); + ret = quota_test_alloc(ctx, 1, &too_large); + quota_transaction_rollback(&ctx); + + mailbox_free(&box); + + if (ret < 0) + *error_r = "Internal quota calculation error"; + else if (ret == 0) + *error_r = quser->quota->set->quota_exceeded_msg; + return ret; +} + +static void client_handle_request(struct quota_client *client) +{ + struct mail_storage_service_input input; + struct mail_storage_service_user *service_user; + struct mail_user *user; + const char *error; + int ret; + + if (client->recipient == NULL) { + o_stream_send_str(client->conn.output, "action=DUNNO\n\n"); + return; + } + + memset(&input, 0, sizeof(input)); + input.username = client->recipient; + + ret = mail_storage_service_lookup_next(storage_service, &input, + &service_user, &user, &error); + restrict_access_allow_coredumps(TRUE); + if (ret == 0) { + o_stream_send_str(client->conn.output, + "action=REJECT Unknown user\n\n"); + } else if (ret > 0) { + if ((ret = quota_check(user, &error)) > 0) + o_stream_send_str(client->conn.output, "action=OK\n\n"); + else if (ret == 0) { + o_stream_send_str(client->conn.output, t_strdup_printf( + "action=552 5.2.2 %s\n\n", error)); + } + mail_user_unref(&user); + mail_storage_service_user_free(&service_user); + } + if (ret < 0) { + o_stream_send_str(client->conn.output, t_strdup_printf( + "action=DEFER_IF_PERMIT %s\n\n", error)); + } +} + +static int client_input_line(struct connection *conn, const char *line) +{ + struct quota_client *client = (struct quota_client *)conn; + + if (*line == '\0') { + o_stream_cork(conn->output); + client_handle_request(client); + o_stream_uncork(conn->output); + client_reset(client); + return 1; + } + if (client->recipient == NULL && + strncmp(line, "recipient=", 10) == 0) + client->recipient = i_strdup(line + 10); + return 1; +} + +static void client_destroy(struct connection *conn) +{ + struct quota_client *client = (struct quota_client *)conn; + + connection_deinit(&client->conn); + client_reset(client); + i_free(client); + + master_service_client_connection_destroyed(master_service); +} + +static struct connection_settings client_set = { + .input_max_size = (size_t)-1, + .output_max_size = (size_t)-1, + .client = FALSE +}; + +static const struct connection_vfuncs client_vfuncs = { + .destroy = client_destroy, + .input_line = client_input_line +}; + +static void main_preinit(void) +{ + restrict_access_by_env(NULL, FALSE); + restrict_access_allow_coredumps(TRUE); +} + +static void main_init(void) +{ + clients = connection_list_init(&client_set, &client_vfuncs); + storage_service = mail_storage_service_init(master_service, NULL, + MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | + MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP | + MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS | + MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR | + MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS); + quota_plugin_init("a_module); +} + +static void main_deinit(void) +{ + connection_list_deinit(&clients); + quota_plugin_deinit(); + mail_storage_service_deinit(&storage_service); +} + +int main(int argc, char *argv[]) +{ + int c; + + protocol = QUOTA_PROTOCOL_UNKNOWN; + master_service = master_service_init("quota-status", 0, + &argc, &argv, "p:"); + while ((c = master_getopt(master_service)) > 0) { + switch (c) { + case 'p': + if (strcmp(optarg, "postfix") == 0) + protocol = QUOTA_PROTOCOL_POSTFIX; + else + i_fatal("Unknown -p parameter: '%s'", optarg); + break; + default: + return FATAL_DEFAULT; + } + } + if (protocol == QUOTA_PROTOCOL_UNKNOWN) + i_fatal("Missing -p parameter"); + + master_service_init_log(master_service, "doveadm: "); + main_preinit(); + master_service_init_finish(master_service); + + main_init(); + master_service_run(master_service, client_connected); + main_deinit(); + master_service_deinit(&master_service); + return 0; +} From dovecot at dovecot.org Thu Feb 21 13:21:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:21:33 +0200 Subject: dovecot-2.2: quota-status: Load plugins after all. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f12f2f2f7459 changeset: 15872:f12f2f2f7459 user: Timo Sirainen date: Wed Feb 20 16:58:45 2013 +0200 description: quota-status: Load plugins after all. They may be needed for user initialization to work (e.g. virtual plugin) or maybe even for quota itself to work (external quota backend plugin). diffstat: src/plugins/quota/Makefile.am | 8 ++++++++ src/plugins/quota/quota-status.c | 11 +---------- 2 files changed, 9 insertions(+), 10 deletions(-) diffs (60 lines): diff -r 980be1dc80c2 -r f12f2f2f7459 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Tue Feb 19 17:36:59 2013 +0200 +++ b/src/plugins/quota/Makefile.am Wed Feb 20 16:58:45 2013 +0200 @@ -53,8 +53,16 @@ quota_status_SOURCES = \ quota-status.c +if !BUILD_SHARED_LIBS +unused_objects = \ + ../../lib/mountpoint.o \ + ../../lib-imap/imap-util.o \ + ../../lib-storage/mail-search-parser-imap.o +endif + quota_status_LDADD = \ $(quota_common_objects) \ + $(unused_objects) \ $(LIBDOVECOT_STORAGE) \ $(LIBDOVECOT) \ $(MODULE_LIBS) diff -r 980be1dc80c2 -r f12f2f2f7459 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Tue Feb 19 17:36:59 2013 +0200 +++ b/src/plugins/quota/quota-status.c Wed Feb 20 16:58:45 2013 +0200 @@ -1,7 +1,6 @@ /* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ #include "lib.h" -#include "module-dir.h" #include "ostream.h" #include "connection.h" #include "restrict-access.h" @@ -28,11 +27,6 @@ static struct mail_storage_service_ctx *storage_service; static struct connection_list *clients; -static struct module quota_module = { - .path = "quota", - .name = "quota" -}; - static void client_connected(struct master_service_connection *conn) { struct quota_client *client; @@ -168,15 +162,12 @@ MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP | MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS | - MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR | - MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS); - quota_plugin_init("a_module); + MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR); } static void main_deinit(void) { connection_list_deinit(&clients); - quota_plugin_deinit(); mail_storage_service_deinit(&storage_service); } From dovecot at dovecot.org Thu Feb 21 13:21:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:21:33 +0200 Subject: dovecot-2.2: Added quota plugin's headers to LIBDOVECOT_STORAGE_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/20ea109b30a7 changeset: 15873:20ea109b30a7 user: Timo Sirainen date: Thu Feb 21 07:55:24 2013 +0200 description: Added quota plugin's headers to LIBDOVECOT_STORAGE_INCLUDE. This allows creating external plugins that depend on the quota plugin (similar to trash plugin). diffstat: dovecot-config.in.in | 2 +- src/plugins/quota/Makefile.am | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diffs (25 lines): diff -r f12f2f2f7459 -r 20ea109b30a7 dovecot-config.in.in --- a/dovecot-config.in.in Wed Feb 20 16:58:45 2013 +0200 +++ b/dovecot-config.in.in Thu Feb 21 07:55:24 2013 +0200 @@ -18,7 +18,7 @@ LIBDOVECOT_INCLUDE="-I$(incdir) -I$(incdir)/src/lib -I$(incdir)/src/lib-dict -I$(incdir)/src/lib-dns -I$(incdir)/src/lib-mail -I$(incdir)/src/lib-imap -I$(incdir)/src/lib-fs -I$(incdir)/src/lib-charset" LIBDOVECOT_LDA_INCLUDE="-I$(incdir)/src/lib-lda -I$(incdir)/src/lda" LIBDOVECOT_SERVICE_INCLUDE="-I$(incdir)/src/lib-master -I$(incdir)/src/lib-settings" -LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw" +LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw -I$(incdir)/src/plugins/quota" LIBDOVECOT_LOGIN_INCLUDE="-I$(incdir)/src/lib-auth -I$(incdir)/src/login-common" LIBDOVECOT_IMAP_INCLUDE="-I$(incdir)/src/imap" LIBDOVECOT_CONFIG_INCLUDE="-I$(incdir)/src/config" diff -r f12f2f2f7459 -r 20ea109b30a7 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Wed Feb 20 16:58:45 2013 +0200 +++ b/src/plugins/quota/Makefile.am Thu Feb 21 07:55:24 2013 +0200 @@ -95,7 +95,8 @@ endif -noinst_HEADERS = \ +pkginc_libdir=$(pkgincludedir) +pkginc_lib_HEADERS = \ quota.h \ quota-fs.h \ quota-plugin.h \ From dovecot at dovecot.org Thu Feb 21 13:21:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:21:33 +0200 Subject: dovecot-2.2: Merged changes from v2.1 tree. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/68e855648d92 changeset: 15874:68e855648d92 user: Timo Sirainen date: Thu Feb 21 13:21:18 2013 +0200 description: Merged changes from v2.1 tree. diffstat: .hgignore | 1 + dovecot-config.in.in | 2 +- src/lib-storage/list/mailbox-list-fs-iter.c | 4 + src/login-common/ssl-proxy-openssl.c | 3 +- src/plugins/quota/Makefile.am | 39 +++++- src/plugins/quota/quota-status.c | 205 ++++++++++++++++++++++++++++ 6 files changed, 251 insertions(+), 3 deletions(-) diffs (truncated from 332 to 300 lines): diff -r b0c4a5ce4933 -r 68e855648d92 .hgignore --- a/.hgignore Thu Feb 21 10:23:08 2013 +0200 +++ b/.hgignore Thu Feb 21 13:21:18 2013 +0200 @@ -102,6 +102,7 @@ src/plugins/fts/xml2text src/plugins/quota/rquota_xdr.c src/plugins/quota/rquota.h +src/plugins/quota/quota-status syntax: regexp src/.*/test-[^\.]*$ diff -r b0c4a5ce4933 -r 68e855648d92 dovecot-config.in.in --- a/dovecot-config.in.in Thu Feb 21 10:23:08 2013 +0200 +++ b/dovecot-config.in.in Thu Feb 21 13:21:18 2013 +0200 @@ -21,7 +21,7 @@ LIBDOVECOT_INCLUDE="-I$(incdir) -I$(incdir)/src/lib -I$(incdir)/src/lib-dict -I$(incdir)/src/lib-dns -I$(incdir)/src/lib-http -I$(incdir)/src/lib-mail -I$(incdir)/src/lib-imap -I$(incdir)/src/lib-fs -I$(incdir)/src/lib-charset -I$(incdir)/src/lib-auth -I$(incdir)/src/lib-master -I$(incdir)/src/lib-ssl-iostream -I$(incdir)/src/lib-compression -I$(incdir)/src/lib-settings -I$(incdir)/src/lib-test" LIBDOVECOT_LDA_INCLUDE="-I$(incdir)/src/lib-lda -I$(incdir)/src/lda" LIBDOVECOT_DOVEADM_INCLUDE="-I$(incdir)/src/doveadm" -LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/list -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw" +LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/list -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw -I$(incdir)/src/plugins/quota" LIBDOVECOT_LOGIN_INCLUDE="-I$(incdir)/src/login-common" LIBDOVECOT_IMAP_INCLUDE="-I$(incdir)/src/imap" LIBDOVECOT_CONFIG_INCLUDE="-I$(incdir)/src/config" diff -r b0c4a5ce4933 -r 68e855648d92 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Thu Feb 21 10:23:08 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Thu Feb 21 13:21:18 2013 +0200 @@ -696,6 +696,10 @@ ctx->info.flags |= MAILBOX_NOSELECT; } else if ((ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 && list_file_is_any_inbox(ctx, storage_name)) { + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { + /* probably mbox inbox file */ + return 0; + } /* shared/user/INBOX */ ctx->info.flags &= ~(MAILBOX_NOSELECT | MAILBOX_NONEXISTENT); ctx->info.flags |= MAILBOX_SELECT; diff -r b0c4a5ce4933 -r 68e855648d92 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Thu Feb 21 10:23:08 2013 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Thu Feb 21 13:21:18 2013 +0200 @@ -434,7 +434,8 @@ case SSL_ERROR_SSL: if (ERR_GET_REASON(ERR_peek_error()) == ERR_R_MALLOC_FAILURE) { i_error("OpenSSL malloc() failed. " - "You may need to increase login_process_size"); + "You may need to increase service %s { vsz_limit }", + login_binary->process_name); } errstr = t_strdup_printf("%s failed: %s", func_name, ssl_last_error()); diff -r b0c4a5ce4933 -r 68e855648d92 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Thu Feb 21 10:23:08 2013 +0200 +++ b/src/plugins/quota/Makefile.am Thu Feb 21 13:21:18 2013 +0200 @@ -1,7 +1,10 @@ doveadm_moduledir = $(moduledir)/doveadm +pkglibexec_PROGRAMS = quota-status + AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-dict \ -I$(top_srcdir)/src/lib-index \ -I$(top_srcdir)/src/lib-mail \ @@ -27,6 +30,17 @@ quota-plugin.c \ quota-storage.c +quota_common_objects = \ + quota.lo \ + quota-count.lo \ + quota-fs.lo \ + quota-dict.lo \ + quota-dirsize.lo \ + quota-maildir.lo \ + quota-plugin.lo \ + quota-storage.lo \ + $(RQUOTA_XDR_LO) + lib10_quota_plugin_la_SOURCES = $(quota_dist_sources) nodist_lib10_quota_plugin_la_SOURCES = $(RQUOTA_XDR) @@ -36,8 +50,30 @@ lib10_doveadm_quota_plugin_la_SOURCES = \ doveadm-quota.c +quota_status_SOURCES = \ + quota-status.c + +if !BUILD_SHARED_LIBS +unused_objects = \ + ../../lib/mountpoint.o \ + ../../lib-imap/imap-util.o \ + ../../lib-storage/mail-search-parser-imap.o +endif + +quota_status_LDADD = \ + $(quota_common_objects) \ + $(unused_objects) \ + $(LIBDOVECOT_STORAGE) \ + $(LIBDOVECOT) \ + $(MODULE_LIBS) +quota_status_DEPENDENCIES = \ + $(quota_common_objects) \ + $(LIBDOVECOT_STORAGE_DEPS) \ + $(LIBDOVECOT_DEPS) + if HAVE_RQUOTA RQUOTA_XDR = rquota_xdr.c +RQUOTA_XDR_LO = rquota_xdr.lo #RQUOTA_X = /usr/include/rpcsvc/rquota.x RQUOTA_X = $(srcdir)/rquota.x rquota_xdr.c: Makefile $(RQUOTA_X) @@ -59,7 +95,8 @@ endif -noinst_HEADERS = \ +pkginc_libdir=$(pkgincludedir) +pkginc_lib_HEADERS = \ quota.h \ quota-fs.h \ quota-plugin.h \ diff -r b0c4a5ce4933 -r 68e855648d92 src/plugins/quota/quota-status.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins/quota/quota-status.c Thu Feb 21 13:21:18 2013 +0200 @@ -0,0 +1,205 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "ostream.h" +#include "connection.h" +#include "restrict-access.h" +#include "master-service.h" +#include "mail-namespace.h" +#include "mail-storage.h" +#include "mail-storage-settings.h" +#include "mail-storage-service.h" +#include "quota-private.h" +#include "quota-plugin.h" + +enum quota_protocol { + QUOTA_PROTOCOL_UNKNOWN = 0, + QUOTA_PROTOCOL_POSTFIX +}; + +struct quota_client { + struct connection conn; + + char *recipient; +}; + +static enum quota_protocol protocol; +static struct mail_storage_service_ctx *storage_service; +static struct connection_list *clients; + +static void client_connected(struct master_service_connection *conn) +{ + struct quota_client *client; + + client = i_new(struct quota_client, 1); + connection_init_server(clients, &client->conn, + "(quota client)", conn->fd, conn->fd); + master_service_client_connection_accept(conn); +} + +static void client_reset(struct quota_client *client) +{ + i_free_and_null(client->recipient); +} + +static int quota_check(struct mail_user *user, const char **error_r) +{ + struct quota_user *quser = QUOTA_USER_CONTEXT(user); + struct mail_namespace *ns; + struct mailbox *box; + struct quota_transaction_context *ctx; + bool too_large; + int ret; + + if (quser == NULL) { + /* no quota for user */ + return 1; + } + + ns = mail_namespace_find_inbox(user->namespaces); + box = mailbox_alloc(ns->list, "INBOX", 0); + + ctx = quota_transaction_begin(box); + ret = quota_test_alloc(ctx, 1, &too_large); + quota_transaction_rollback(&ctx); + + mailbox_free(&box); + + if (ret < 0) + *error_r = "Internal quota calculation error"; + else if (ret == 0) + *error_r = quser->quota->set->quota_exceeded_msg; + return ret; +} + +static void client_handle_request(struct quota_client *client) +{ + struct mail_storage_service_input input; + struct mail_storage_service_user *service_user; + struct mail_user *user; + const char *error; + int ret; + + if (client->recipient == NULL) { + o_stream_send_str(client->conn.output, "action=DUNNO\n\n"); + return; + } + + memset(&input, 0, sizeof(input)); + input.username = client->recipient; + + ret = mail_storage_service_lookup_next(storage_service, &input, + &service_user, &user, &error); + restrict_access_allow_coredumps(TRUE); + if (ret == 0) { + o_stream_send_str(client->conn.output, + "action=REJECT Unknown user\n\n"); + } else if (ret > 0) { + if ((ret = quota_check(user, &error)) > 0) + o_stream_send_str(client->conn.output, "action=OK\n\n"); + else if (ret == 0) { + o_stream_send_str(client->conn.output, t_strdup_printf( + "action=552 5.2.2 %s\n\n", error)); + } + mail_user_unref(&user); + mail_storage_service_user_free(&service_user); + } + if (ret < 0) { + o_stream_send_str(client->conn.output, t_strdup_printf( + "action=DEFER_IF_PERMIT %s\n\n", error)); + } +} + +static int client_input_line(struct connection *conn, const char *line) +{ + struct quota_client *client = (struct quota_client *)conn; + + if (*line == '\0') { + o_stream_cork(conn->output); + client_handle_request(client); + o_stream_uncork(conn->output); + client_reset(client); + return 1; + } + if (client->recipient == NULL && + strncmp(line, "recipient=", 10) == 0) + client->recipient = i_strdup(line + 10); + return 1; +} + +static void client_destroy(struct connection *conn) +{ + struct quota_client *client = (struct quota_client *)conn; + + connection_deinit(&client->conn); + client_reset(client); + i_free(client); + + master_service_client_connection_destroyed(master_service); +} + +static struct connection_settings client_set = { + .input_max_size = (size_t)-1, + .output_max_size = (size_t)-1, + .client = FALSE +}; + +static const struct connection_vfuncs client_vfuncs = { + .destroy = client_destroy, + .input_line = client_input_line +}; + +static void main_preinit(void) +{ + restrict_access_by_env(NULL, FALSE); + restrict_access_allow_coredumps(TRUE); +} + +static void main_init(void) +{ + clients = connection_list_init(&client_set, &client_vfuncs); + storage_service = mail_storage_service_init(master_service, NULL, + MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | + MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP | + MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS | + MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR); +} + +static void main_deinit(void) +{ + connection_list_deinit(&clients); + mail_storage_service_deinit(&storage_service); +} + From dovecot at dovecot.org Thu Feb 21 13:22:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:22:49 +0200 Subject: dovecot-2.2: TODO updated Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/28f4d5a841e7 changeset: 15875:28f4d5a841e7 user: Timo Sirainen date: Thu Feb 21 13:22:33 2013 +0200 description: TODO updated diffstat: TODO | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diffs (55 lines): diff -r 68e855648d92 -r 28f4d5a841e7 TODO --- a/TODO Thu Feb 21 13:21:18 2013 +0200 +++ b/TODO Thu Feb 21 13:22:33 2013 +0200 @@ -1,24 +1,24 @@ + - dsync over tcp + - if transaction log file corruption is noticed, make sure new dovecot.index + snapshot gets written and don't mark the whole file corrupted.. rather maybe + just rotate and truncate it - LAYOUT=index: - force-resync should fix the index, finding any missing mailboxes, same for when internally detecting the error - see if there are any race conditions? and check other error handling - after doing a lot of changes the list's memory pool keeps growing. do an occasional re-parsing to clear the pool - - mailbox_update() needs to update also uidvalidity/guid - quota recalc + dict-file [+acl?] assert-crashes in !indexing->syncing + - imaptest: add condstore, qresync tests + + - zlib plugin should do caching similar to binary fetches. otherwise + partial fetches from large compressed mails are hopelessly slow. + - Track highestmodseq always, just don't keep per-message modseqs unless + they're enabled. Then don't return [NOMODSEQ] on select. - URLAUTH: if client tries to access nonexistent user, do a delay in imap-urlauth-client.c (AFTER destroying the worker) - special response in the control connection to make the imap-urlauth master wait before starting a new worker - - dsync to sync both shared and private message flags - - pop3_lock_session=yes should use its own separate pop3-lock file - - Track highestmodseq always, just don't keep per-message modseqs unless - they're enabled. - - LDA/LMTP: Allow saving one last mail even if it brings user over quota? - - zlib plugin should do caching similar to binary fetches. otherwise - partial fetches from large compressed mails are hopelessly slow. - - imaptest: add condstore, qresync tests - - shared user should get settings from userdb extra fields, especially plugin/quota_rule to get different quota limits for shared mailboxes. the problem is that user doesn't currently have set_parser available, @@ -35,6 +35,7 @@ - FIFOs maybe should be counted as connections, but unlisten should unlink+reopen it in master? - lmtp client/proxy: Handle multiline replies better + - lmtp: support DSN extension (especially ORCPT) - recreate mailbox -> existing sessions log "indexid changed" error - add message/mime limits - imapc: @@ -70,6 +71,8 @@ users, 2) create mail_user only once for each user, 3) remember in src_mail the previously copied mail, 4) use that for mailbox_copy()ing to following recipients + - make sure this removes duplicate dbox mails when sieve saves mail to + multiple mailboxes - notify_sync() could have "what changed" struct with old/new flags - maildir: copy dovecot-shared file from parent mailbox, not root. - if global ACL path points to a file instead of a directory, read all of From dovecot at dovecot.org Thu Feb 21 13:27:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 13:27:55 +0200 Subject: dovecot-2.2: quota-status: Fixed compiling Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/87c206c1eaf4 changeset: 15876:87c206c1eaf4 user: Timo Sirainen date: Thu Feb 21 13:27:42 2013 +0200 description: quota-status: Fixed compiling diffstat: src/plugins/quota/Makefile.am | 8 -------- 1 files changed, 0 insertions(+), 8 deletions(-) diffs (20 lines): diff -r 28f4d5a841e7 -r 87c206c1eaf4 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Thu Feb 21 13:22:33 2013 +0200 +++ b/src/plugins/quota/Makefile.am Thu Feb 21 13:27:42 2013 +0200 @@ -53,16 +53,8 @@ quota_status_SOURCES = \ quota-status.c -if !BUILD_SHARED_LIBS -unused_objects = \ - ../../lib/mountpoint.o \ - ../../lib-imap/imap-util.o \ - ../../lib-storage/mail-search-parser-imap.o -endif - quota_status_LDADD = \ $(quota_common_objects) \ - $(unused_objects) \ $(LIBDOVECOT_STORAGE) \ $(LIBDOVECOT) \ $(MODULE_LIBS) From dovecot at dovecot.org Thu Feb 21 14:15:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 14:15:26 +0200 Subject: dovecot-2.2: dsync: Fixed hiding the "remote command returned er... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/69af3ef3a482 changeset: 15877:69af3ef3a482 user: Timo Sirainen date: Thu Feb 21 14:15:15 2013 +0200 description: dsync: Fixed hiding the "remote command returned error" message when it was unnecessary. diffstat: src/doveadm/dsync/doveadm-dsync.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diffs (63 lines): diff -r 87c206c1eaf4 -r 69af3ef3a482 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Thu Feb 21 13:27:42 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Thu Feb 21 14:15:15 2013 +0200 @@ -330,14 +330,12 @@ } static void cmd_dsync_wait_remote(struct dsync_cmd_context *ctx, - bool remote_errors_logged) + int *status_r) { - int status; - /* wait for the remote command to finish to see any final errors. don't wait very long though. */ alarm(DSYNC_REMOTE_CMD_EXIT_WAIT_SECS); - if (waitpid(ctx->remote_pid, &status, 0) == -1) { + if (waitpid(ctx->remote_pid, status_r, 0) == -1) { if (errno != EINTR) { i_error("waitpid(%ld) failed: %m", (long)ctx->remote_pid); @@ -348,7 +346,15 @@ (long)ctx->remote_pid); } } - } else if (WIFSIGNALED(status)) + *status_r = -1; + } +} + +static void cmd_dsync_log_remote_status(int status, bool remote_errors_logged) +{ + if (status == -1) + ; + else if (WIFSIGNALED(status)) i_error("Remote command died with signal %d", WTERMSIG(status)); else if (!WIFEXITED(status)) i_error("Remote command failed with status %d", status); @@ -407,7 +413,7 @@ struct mail_namespace *sync_ns = NULL; enum dsync_brain_flags brain_flags; bool remote_errors_logged = FALSE; - int ret = 0; + int status, ret = 0; user->admin = TRUE; user->dsyncing = TRUE; @@ -469,7 +475,7 @@ i_close_fd(&ctx->fd_in); } if (ctx->remote) - cmd_dsync_wait_remote(ctx, remote_errors_logged); + cmd_dsync_wait_remote(ctx, &status); /* print any final errors after the process has died. not closing stdin/stdout before wait() may cause the process to hang, but stderr @@ -480,6 +486,7 @@ remote_errors_logged = ctx->err_stream->v_offset > 0; i_stream_destroy(&ctx->err_stream); } + cmd_dsync_log_remote_status(status, remote_errors_logged); if (ctx->io_err != NULL) io_remove(&ctx->io_err); if (ctx->fd_err != -1) From dovecot at dovecot.org Thu Feb 21 14:16:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 14:16:50 +0200 Subject: dovecot-2.2: Removed dead assignments. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fda302d15042 changeset: 15878:fda302d15042 user: Timo Sirainen date: Thu Feb 21 14:16:45 2013 +0200 description: Removed dead assignments. diffstat: src/lib-http/test-http-transfer.c | 1 - src/lib-storage/list/mailbox-list-fs-iter.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-) diffs (22 lines): diff -r 69af3ef3a482 -r fda302d15042 src/lib-http/test-http-transfer.c --- a/src/lib-http/test-http-transfer.c Thu Feb 21 14:15:15 2013 +0200 +++ b/src/lib-http/test-http-transfer.c Thu Feb 21 14:16:45 2013 +0200 @@ -273,7 +273,6 @@ ochunked = http_transfer_chunked_ostream_create(output); /* send input through chunked stream; chunk size is limited */ - ret = 0; for (;;) { ret = i_stream_read_data(input, &rdata, &rsize, 0); if (ret < 0) { diff -r 69af3ef3a482 -r fda302d15042 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Thu Feb 21 14:15:15 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Thu Feb 21 14:16:45 2013 +0200 @@ -388,7 +388,6 @@ where we could optimize with root=prefix, but probably too much trouble to implement. */ prefix_vname = ""; - p = last = pattern; } else { for (p = last = pattern; *p != '\0'; p++) { if (*p == '%' || *p == '*') From dovecot at dovecot.org Thu Feb 21 17:07:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 17:07:09 +0200 Subject: dovecot-2.2: lib-http: Fixed hanging on errors Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fc9bfa8a3980 changeset: 15879:fc9bfa8a3980 user: Stephan Bosch date: Thu Feb 21 17:06:27 2013 +0200 description: lib-http: Fixed hanging on errors diffstat: src/lib-http/http-client-connection.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (19 lines): diff -r fda302d15042 -r fc9bfa8a3980 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Feb 21 14:16:45 2013 +0200 +++ b/src/lib-http/http-client-connection.c Thu Feb 21 17:06:27 2013 +0200 @@ -79,6 +79,7 @@ array_foreach_modifiable(&conn->request_wait_list, req) { http_client_request_retry(*req, status, error); + http_client_request_unref(req); } array_clear(&conn->request_wait_list); } @@ -132,6 +133,7 @@ array_foreach_modifiable(&conn->request_wait_list, req) { http_client_request_error(*req, status, error); + http_client_request_unref(req); } array_clear(&conn->request_wait_list); http_client_connection_unref(_conn); From dovecot at dovecot.org Thu Feb 21 17:36:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 17:36:19 +0200 Subject: dovecot-2.2: Released v2.2.beta1. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/018de2aa893a changeset: 15880:018de2aa893a user: Timo Sirainen date: Thu Feb 21 17:07:55 2013 +0200 description: Released v2.2.beta1. diffstat: configure.ac | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r fc9bfa8a3980 -r 018de2aa893a configure.ac --- a/configure.ac Thu Feb 21 17:06:27 2013 +0200 +++ b/configure.ac Thu Feb 21 17:07:55 2013 +0200 @@ -2,7 +2,7 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.beta1],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.2.beta2],[dovecot at dovecot.org]) AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv0($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) From dovecot at dovecot.org Thu Feb 21 17:36:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 17:36:19 +0200 Subject: dovecot-2.2: Added tag 2.2.beta2 for changeset 018de2aa893a Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2a52cc85c67d changeset: 15881:2a52cc85c67d user: Timo Sirainen date: Thu Feb 21 17:09:02 2013 +0200 description: Added tag 2.2.beta2 for changeset 018de2aa893a diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 018de2aa893a -r 2a52cc85c67d .hgtags --- a/.hgtags Thu Feb 21 17:07:55 2013 +0200 +++ b/.hgtags Thu Feb 21 17:09:02 2013 +0200 @@ -94,3 +94,4 @@ 86bccdf46d172524ca19a1a8a16a50ac30a6743c 2.2.beta1 b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14 fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15 +018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 2.2.beta2 From dovecot at dovecot.org Thu Feb 21 17:36:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 17:36:19 +0200 Subject: dovecot-2.2: Added signature for changeset 018de2aa893a Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5c83eacce0de changeset: 15882:5c83eacce0de user: Timo Sirainen date: Thu Feb 21 17:09:08 2013 +0200 description: Added signature for changeset 018de2aa893a diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 2a52cc85c67d -r 5c83eacce0de .hgsigs --- a/.hgsigs Thu Feb 21 17:09:02 2013 +0200 +++ b/.hgsigs Thu Feb 21 17:09:08 2013 +0200 @@ -57,3 +57,4 @@ cf9d62fd0b143efa8e49fac998eb78a648cdd8a9 0 iEYEABECAAYFAlDqjXUACgkQyUhSUUBViskUEwCfYTWHeDmPr8HfxSBQN17SD5IwDygAnROhb3IVTm9niDun4gxPxbHLo/Pe b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3 +018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 0 iEYEABECAAYFAlEmOJEACgkQyUhSUUBVismawgCfbfY6KuH+/AauPkRZs4ish20YeV8Ani5DMLh02DUyJvDIpVPJMmTn2Mu/ From dovecot at dovecot.org Thu Feb 21 19:30:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 19:30:49 +0200 Subject: dovecot-2.2: mailbox_list_index=yes: Don't crash if destroying l... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3fb9a8bc35aa changeset: 15883:3fb9a8bc35aa user: Timo Sirainen date: Thu Feb 21 19:30:38 2013 +0200 description: mailbox_list_index=yes: Don't crash if destroying list before its init finished. diffstat: src/lib-storage/list/mailbox-list-index.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diffs (24 lines): diff -r 5c83eacce0de -r 3fb9a8bc35aa src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Thu Feb 21 17:09:08 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-index.c Thu Feb 21 19:30:38 2013 +0200 @@ -420,12 +420,14 @@ if (ilist->to_refresh != NULL) timeout_remove(&ilist->to_refresh); - hash_table_destroy(&ilist->mailbox_hash); - hash_table_destroy(&ilist->mailbox_names); - pool_unref(&ilist->mailbox_pool); - if (ilist->opened) - mail_index_close(ilist->index); - mail_index_free(&ilist->index); + if (ilist->index != NULL) { + hash_table_destroy(&ilist->mailbox_hash); + hash_table_destroy(&ilist->mailbox_names); + pool_unref(&ilist->mailbox_pool); + if (ilist->opened) + mail_index_close(ilist->index); + mail_index_free(&ilist->index); + } ilist->module_ctx.super.deinit(list); } From dovecot at dovecot.org Thu Feb 21 19:58:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 21 Feb 2013 19:58:56 +0200 Subject: dovecot-2.1: imap: Allocate LIST patterns from command pool so t... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6c9b182d9a8c changeset: 14911:6c9b182d9a8c user: Timo Sirainen date: Thu Feb 21 19:58:39 2013 +0200 description: imap: Allocate LIST patterns from command pool so they don't get corrupted in long runs. diffstat: src/imap/cmd-list.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 20ea109b30a7 -r 6c9b182d9a8c src/imap/cmd-list.c --- a/src/imap/cmd-list.c Thu Feb 21 07:55:24 2013 +0200 +++ b/src/imap/cmd-list.c Thu Feb 21 19:58:39 2013 +0200 @@ -1026,7 +1026,7 @@ return TRUE; } if (imap_utf7_to_utf8(pattern, str) == 0) - pattern = t_strdup(str_c(str)); + pattern = p_strdup(cmd->pool, str_c(str)); array_append(&patterns, &pattern, 1); str_truncate(str, 0); } @@ -1037,7 +1037,7 @@ return TRUE; } if (imap_utf7_to_utf8(pattern, str) == 0) - pattern = str_c(str); + pattern = p_strdup(cmd->pool, str_c(str)); p_array_init(&patterns, cmd->pool, 1); array_append(&patterns, &pattern, 1); From dovecot at dovecot.org Fri Feb 22 07:37:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 07:37:30 +0200 Subject: dovecot-2.1: quota-status: Fixed compiling with older autotools. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/8ec52854e823 changeset: 14912:8ec52854e823 user: Timo Sirainen date: Fri Feb 22 07:37:18 2013 +0200 description: quota-status: Fixed compiling with older autotools. diffstat: src/plugins/quota/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (10 lines): diff -r 6c9b182d9a8c -r 8ec52854e823 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Thu Feb 21 19:58:39 2013 +0200 +++ b/src/plugins/quota/Makefile.am Fri Feb 22 07:37:18 2013 +0200 @@ -1,5 +1,6 @@ doveadm_moduledir = $(moduledir)/doveadm +pkglibexecdir = $(libexecdir)/dovecot pkglibexec_PROGRAMS = quota-status AM_CPPFLAGS = \ From dovecot at dovecot.org Fri Feb 22 09:44:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 09:44:48 +0200 Subject: dovecot-2.1: mdbox: Don't try to undelete any mailboxes in stora... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9cb64709dd8c changeset: 14913:9cb64709dd8c user: Timo Sirainen date: Fri Feb 22 09:43:59 2013 +0200 description: mdbox: Don't try to undelete any mailboxes in storage rebuild to avoid assert-crashes. diffstat: src/lib-storage/mail-storage.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 8ec52854e823 -r 9cb64709dd8c src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Feb 22 07:37:18 2013 +0200 +++ b/src/lib-storage/mail-storage.c Fri Feb 22 09:43:59 2013 +0200 @@ -928,6 +928,13 @@ { time_t mtime; + if ((box->flags & MAILBOX_FLAG_READONLY) != 0) { + /* most importantly we don't do this because we want to avoid + a loop: mdbox storage rebuild -> mailbox_open() -> + mailbox_mark_index_deleted() -> mailbox_sync() -> + mdbox storage rebuild. */ + return FALSE; + } if (mail_index_get_modification_time(box->index, &mtime) < 0) return FALSE; if (mtime + MAILBOX_DELETE_RETRY_SECS > time(NULL)) From dovecot at dovecot.org Fri Feb 22 10:01:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 10:01:16 +0200 Subject: dovecot-2.1: mdbox: If m.X file has no mails, don't try to fix i... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b91e1b94af21 changeset: 14914:b91e1b94af21 user: Timo Sirainen date: Fri Feb 22 10:01:06 2013 +0200 description: mdbox: If m.X file has no mails, don't try to fix it infinitely in storage rebuild. diffstat: src/lib-storage/index/dbox-common/dbox-file-fix.c | 14 ++++++++++++-- src/lib-storage/index/dbox-common/dbox-file.h | 3 ++- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 6 ++++-- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diffs (85 lines): diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-common/dbox-file-fix.c --- a/src/lib-storage/index/dbox-common/dbox-file-fix.c Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c Fri Feb 22 10:01:06 2013 +0200 @@ -291,7 +291,7 @@ { struct ostream *output; const char *dir, *p, *temp_path, *broken_path; - bool deleted; + bool deleted, have_messages; int fd, ret; i_assert(dbox_file_is_open(file)); @@ -307,6 +307,7 @@ output = o_stream_create_fd_file(fd, 0, FALSE); ret = dbox_file_fix_write_stream(file, start_offset, temp_path, output); + have_messages = output->offset > file->file_header_size; o_stream_unref(&output); if (close(fd) < 0) { mail_storage_set_critical(&file->storage->storage, @@ -332,6 +333,15 @@ i_warning("dbox: Copy of the broken file saved to %s", broken_path); } + if (!have_messages) { + /* the resulting file has no messages. just delete the file. */ + dbox_file_close(file); + if (unlink(temp_path) < 0) + i_error("unlink(%s) failed: %m", temp_path); + if (unlink(file->cur_path) < 0) + i_error("unlink(%s) failed: %m", file->cur_path); + return 0; + } if (rename(temp_path, file->cur_path) < 0) { mail_storage_set_critical(&file->storage->storage, "rename(%s, %s) failed: %m", @@ -347,5 +357,5 @@ file->cur_path); return -1; } - return 0; + return 1; } diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-common/dbox-file.h --- a/src/lib-storage/index/dbox-common/dbox-file.h Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-file.h Fri Feb 22 10:01:06 2013 +0200 @@ -190,7 +190,8 @@ /* Fix a broken dbox file by rename()ing over it with a fixed file. Everything before start_offset is assumed to be valid and is simply copied. The file - is reopened afterwards. Returns 0 if ok, -1 if I/O error. */ + is reopened afterwards. Returns 1 if ok, 0 if the resulting file has no + mails and was deleted, -1 if I/O error. */ int dbox_file_fix(struct dbox_file *file, uoff_t start_offset); /* Delete the given dbox file. Returns 1 if deleted, 0 if file wasn't found or -1 if error. */ diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 22 10:01:06 2013 +0200 @@ -152,9 +152,11 @@ /* use existing file header if it was ok */ prev_offset = offset; } - if (dbox_file_fix(file, prev_offset) < 0) { - ret = -1; + if ((ret = dbox_file_fix(file, prev_offset)) < 0) break; + if (ret == 0) { + /* file was deleted */ + return 1; } fixed = TRUE; if (!first) { diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Fri Feb 22 10:01:06 2013 +0200 @@ -39,7 +39,7 @@ ret = dbox_file_seek(file, 0); } if (ret == 0) { - if ((ret = dbox_file_fix(file, 0)) == 0) + if ((ret = dbox_file_fix(file, 0)) > 0) ret = dbox_file_seek(file, 0); } From dovecot at dovecot.org Fri Feb 22 10:09:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 10:09:25 +0200 Subject: dovecot-2.2: lib-storage: Fixed assert-crash when saving mails i... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0158c7b2c5db changeset: 15884:0158c7b2c5db user: Timo Sirainen date: Fri Feb 22 10:09:19 2013 +0200 description: lib-storage: Fixed assert-crash when saving mails if UIDs weren't assigned. diffstat: src/lib-storage/mail-storage.c | 5 ++++- src/lib-storage/mail-storage.h | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diffs (36 lines): diff -r 3fb9a8bc35aa -r 0158c7b2c5db src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Feb 21 19:30:38 2013 +0200 +++ b/src/lib-storage/mail-storage.c Fri Feb 22 10:09:19 2013 +0200 @@ -1745,6 +1745,7 @@ { struct mailbox_transaction_context *t = *_t; unsigned int save_count = t->save_count; + bool assign_uids = (t->flags & MAILBOX_TRANSACTION_FLAG_ASSIGN_UIDS) != 0; int ret; t->box->transaction_count--; @@ -1754,7 +1755,9 @@ T_BEGIN { ret = t->box->v.transaction_commit(t, changes_r); } T_END; - i_assert(ret < 0 || seq_range_count(&changes_r->saved_uids) == save_count); + i_assert(ret < 0 || + seq_range_count(&changes_r->saved_uids) == save_count || + (array_count(&changes_r->saved_uids) == 0 && !assign_uids)); if (ret < 0 && changes_r->pool != NULL) pool_unref(&changes_r->pool); return ret; diff -r 3fb9a8bc35aa -r 0158c7b2c5db src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Thu Feb 21 19:30:38 2013 +0200 +++ b/src/lib-storage/mail-storage.h Fri Feb 22 10:09:19 2013 +0200 @@ -299,7 +299,9 @@ /* UIDVALIDITY for assigned UIDs. */ uint32_t uid_validity; - /* UIDs assigned to saved messages. Not necessarily ascending. */ + /* UIDs assigned to saved messages. Not necessarily ascending. + If UID assignment wasn't required (e.g. LDA), this array may also be + empty. Otherwise all of the saved mails got an UID. */ ARRAY_TYPE(seq_range) saved_uids; /* number of modseq changes that couldn't be changed as requested */ From dovecot at dovecot.org Fri Feb 22 10:17:45 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 10:17:45 +0200 Subject: dovecot-2.1: fts: Don't send binary MIME parts to backend throug... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b0e68c53771e changeset: 14915:b0e68c53771e user: Timo Sirainen date: Fri Feb 22 10:17:14 2013 +0200 description: fts: Don't send binary MIME parts to backend through UTF8 text conversion. Based on patch by Mike Abbott / Apple. diffstat: src/plugins/fts/fts-build-mail.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r b91e1b94af21 -r b0e68c53771e src/plugins/fts/fts-build-mail.c --- a/src/plugins/fts/fts-build-mail.c Fri Feb 22 10:01:06 2013 +0200 +++ b/src/plugins/fts/fts-build-mail.c Fri Feb 22 10:17:14 2013 +0200 @@ -170,6 +170,7 @@ strncmp(content_type, "message/", 8) == 0) { /* text body parts */ key.type = FTS_BACKEND_BUILD_KEY_BODY_PART; + ctx->body_parser = fts_parser_text_init(); } else { /* possibly binary */ if ((ctx->update_ctx->backend->flags & @@ -178,8 +179,6 @@ *binary_body_r = TRUE; key.type = FTS_BACKEND_BUILD_KEY_BODY_PART_BINARY; } - if (ctx->body_parser == NULL) - ctx->body_parser = fts_parser_text_init(); key.body_content_type = content_type; key.body_content_disposition = ctx->content_disposition; return fts_backend_update_set_build_key(ctx->update_ctx, &key); From dovecot at dovecot.org Fri Feb 22 10:32:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 10:32:18 +0200 Subject: dovecot-2.2: doveadm, indexer: Don't crash if STATUS_LAST_CACHED... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/994298d9c3d5 changeset: 15885:994298d9c3d5 user: Timo Sirainen date: Fri Feb 22 10:31:38 2013 +0200 description: doveadm, indexer: Don't crash if STATUS_LAST_CACHED_SEQ lookup fails. (I'm sure I did this change already once, where did it go?..) diffstat: src/doveadm/doveadm-mail-index.c | 6 +++--- src/indexer/master-connection.c | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diffs (35 lines): diff -r 0158c7b2c5db -r 994298d9c3d5 src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Fri Feb 22 10:09:19 2013 +0200 +++ b/src/doveadm/doveadm-mail-index.c Fri Feb 22 10:31:38 2013 +0200 @@ -39,10 +39,10 @@ int ret = 0; if (mailbox_get_metadata(box, MAILBOX_METADATA_PRECACHE_FIELDS, - &metadata) < 0) + &metadata) < 0 || + mailbox_get_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ, + &status) < 0) return -1; - mailbox_get_open_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ, - &status); seq = status.last_cached_seq + 1; if (seq > status.messages) { diff -r 0158c7b2c5db -r 994298d9c3d5 src/indexer/master-connection.c --- a/src/indexer/master-connection.c Fri Feb 22 10:09:19 2013 +0200 +++ b/src/indexer/master-connection.c Fri Feb 22 10:31:38 2013 +0200 @@ -68,11 +68,10 @@ int ret = 0; if (mailbox_get_metadata(box, MAILBOX_METADATA_PRECACHE_FIELDS, - &metadata) < 0) + &metadata) < 0 || + mailbox_get_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ, + &status) < 0) return -1; - - mailbox_get_open_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ, - &status); seq = status.last_cached_seq + 1; trans = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC); From dovecot at dovecot.org Fri Feb 22 10:32:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 10:32:18 +0200 Subject: dovecot-2.2: lib-storage: Make sure mailbox_get_open_status() ca... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8740056e9b2f changeset: 15886:8740056e9b2f user: Timo Sirainen date: Fri Feb 22 10:32:05 2013 +0200 description: lib-storage: Make sure mailbox_get_open_status() can't be used with items that can fail. diffstat: src/lib-storage/mail-storage.c | 1 + src/lib-storage/mail-storage.h | 4 ++++ 2 files changed, 5 insertions(+), 0 deletions(-) diffs (25 lines): diff -r 994298d9c3d5 -r 8740056e9b2f src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Feb 22 10:31:38 2013 +0200 +++ b/src/lib-storage/mail-storage.c Fri Feb 22 10:32:05 2013 +0200 @@ -1479,6 +1479,7 @@ struct mailbox_status *status_r) { i_assert(box->opened); + i_assert((items & MAILBOX_STATUS_FAILING_ITEMS) == 0); mailbox_get_status_set_defaults(box, status_r); if (box->v.get_status(box, items, status_r) < 0) diff -r 994298d9c3d5 -r 8740056e9b2f src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Fri Feb 22 10:31:38 2013 +0200 +++ b/src/lib-storage/mail-storage.h Fri Feb 22 10:32:05 2013 +0200 @@ -78,6 +78,10 @@ STATUS_LAST_CACHED_SEQ = 0x800, STATUS_CHECK_OVER_QUOTA = 0x1000, /* return error if over quota */ STATUS_HIGHESTPVTMODSEQ = 0x2000, + /* status items that must not be looked up with + mailbox_get_open_status(), because they can return failure. */ +#define MAILBOX_STATUS_FAILING_ITEMS \ + (STATUS_LAST_CACHED_SEQ | STATUS_CHECK_OVER_QUOTA) }; enum mailbox_metadata_items { From dovecot at dovecot.org Fri Feb 22 10:42:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 10:42:50 +0200 Subject: dovecot-2.1: indexer-worker: Fixed keeping config connection ope... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6d45b9bd1cff changeset: 14916:6d45b9bd1cff user: Timo Sirainen date: Fri Feb 22 10:42:40 2013 +0200 description: indexer-worker: Fixed keeping config connection open before dropping root privileges. The initial settings reading doesn't really do anything, since the real settings are again read by mail-storage-service. diffstat: src/indexer/indexer-worker.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (21 lines): diff -r b0e68c53771e -r 6d45b9bd1cff src/indexer/indexer-worker.c --- a/src/indexer/indexer-worker.c Fri Feb 22 10:17:14 2013 +0200 +++ b/src/indexer/indexer-worker.c Fri Feb 22 10:42:40 2013 +0200 @@ -45,6 +45,8 @@ int main(int argc, char *argv[]) { + enum master_service_flags service_flags = + MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN; enum mail_storage_service_flags storage_service_flags = MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT | MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | @@ -52,7 +54,7 @@ MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT; int c; - master_service = master_service_init("indexer-worker", 0, + master_service = master_service_init("indexer-worker", service_flags, &argc, &argv, "D"); while ((c = master_getopt(master_service)) > 0) { switch (c) { From dovecot at dovecot.org Fri Feb 22 12:12:44 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 12:12:44 +0200 Subject: dovecot-2.1: dict-sql: Iterating with multiple SQL queries didn'... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0e0fd4b5a582 changeset: 14917:0e0fd4b5a582 user: Timo Sirainen date: Fri Feb 22 12:12:26 2013 +0200 description: dict-sql: Iterating with multiple SQL queries didn't free all the queries. diffstat: src/lib-dict/dict-sql.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 6d45b9bd1cff -r 0e0fd4b5a582 src/lib-dict/dict-sql.c --- a/src/lib-dict/dict-sql.c Fri Feb 22 10:42:40 2013 +0200 +++ b/src/lib-dict/dict-sql.c Fri Feb 22 12:12:26 2013 +0200 @@ -351,6 +351,9 @@ if (map == NULL) return FALSE; + if (ctx->result != NULL) + sql_result_unref(ctx->result); + T_BEGIN { string_t *query = t_str_new(256); From dovecot at dovecot.org Fri Feb 22 12:19:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 12:19:46 +0200 Subject: dovecot-2.1: lib-lda: Give a better error message if dotlocking ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/81ea622b6394 changeset: 14918:81ea622b6394 user: Timo Sirainen date: Fri Feb 22 12:19:36 2013 +0200 description: lib-lda: Give a better error message if dotlocking duplicate db fails. diffstat: src/lib-lda/duplicate.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 0e0fd4b5a582 -r 81ea622b6394 src/lib-lda/duplicate.c --- a/src/lib-lda/duplicate.c Fri Feb 22 12:12:26 2013 +0200 +++ b/src/lib-lda/duplicate.c Fri Feb 22 12:19:36 2013 +0200 @@ -212,8 +212,14 @@ file->path = p_strdup(pool, ctx->path); file->new_fd = file_dotlock_open(&ctx->dotlock_set, file->path, 0, &file->dotlock); - if (file->new_fd == -1) - i_error("file_dotlock_create(%s) failed: %m", file->path); + if (file->new_fd != -1) + ; + else if (errno != EAGAIN) + i_error("file_dotlock_open(%s) failed: %m", file->path); + else { + i_error("Creating lock file for %s timed out in %u secs", + file->path, ctx->dotlock_set.timeout); + } file->hash = hash_table_create(default_pool, pool, 0, duplicate_hash, duplicate_cmp); (void)duplicate_read(file); From dovecot at dovecot.org Fri Feb 22 12:42:40 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 12:42:40 +0200 Subject: dovecot-2.2: proxying cleanup: Send TTL=1 (instead of TTL=0) as ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/48c1c58948f5 changeset: 15887:48c1c58948f5 user: Timo Sirainen date: Fri Feb 22 12:42:26 2013 +0200 description: proxying cleanup: Send TTL=1 (instead of TTL=0) as "no more proxying". diffstat: src/imap-login/imap-proxy.c | 2 +- src/lib-lda/lmtp-client.c | 6 +++--- src/lib-lda/lmtp-client.h | 4 ++-- src/lmtp/commands.c | 2 +- src/lmtp/lmtp-proxy.c | 3 ++- src/login-common/login-proxy.c | 2 +- src/pop3-login/pop3-proxy.c | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diffs (106 lines): diff -r 8740056e9b2f -r 48c1c58948f5 src/imap-login/imap-proxy.c --- a/src/imap-login/imap-proxy.c Fri Feb 22 10:32:05 2013 +0200 +++ b/src/imap-login/imap-proxy.c Fri Feb 22 12:42:26 2013 +0200 @@ -29,7 +29,7 @@ static void proxy_write_id(struct imap_client *client, string_t *str) { - i_assert(client->common.proxy_ttl > 0); + i_assert(client->common.proxy_ttl > 1); str_printfa(str, "I ID (" "\"x-session-id\" \"%s\" " diff -r 8740056e9b2f -r 48c1c58948f5 src/lib-lda/lmtp-client.c --- a/src/lib-lda/lmtp-client.c Fri Feb 22 10:32:05 2013 +0200 +++ b/src/lib-lda/lmtp-client.c Fri Feb 22 12:42:26 2013 +0200 @@ -97,7 +97,7 @@ p_strdup(pool, set->dns_client_socket_path); client->set.source_ip = set->source_ip; client->set.source_port = set->source_port; - client->set.proxy_ttl_plus_1 = set->proxy_ttl_plus_1; + client->set.proxy_ttl = set->proxy_ttl; client->set.proxy_timeout_secs = set->proxy_timeout_secs; client->finish_callback = finish_callback; client->finish_context = context; @@ -433,9 +433,9 @@ if (client->set.source_port != 0 && str_array_icase_find(client->xclient_args, "PORT")) str_printfa(str, " PORT=%u", client->set.source_port); - if (client->set.proxy_ttl_plus_1 != 0 && + if (client->set.proxy_ttl != 0 && str_array_icase_find(client->xclient_args, "TTL")) - str_printfa(str, " TTL=%u", client->set.proxy_ttl_plus_1-1); + str_printfa(str, " TTL=%u", client->set.proxy_ttl); if (client->set.proxy_timeout_secs != 0 && str_array_icase_find(client->xclient_args, "TIMEOUT")) str_printfa(str, " TIMEOUT=%u", client->set.proxy_timeout_secs); diff -r 8740056e9b2f -r 48c1c58948f5 src/lib-lda/lmtp-client.h --- a/src/lib-lda/lmtp-client.h Fri Feb 22 10:32:05 2013 +0200 +++ b/src/lib-lda/lmtp-client.h Fri Feb 22 12:42:26 2013 +0200 @@ -21,8 +21,8 @@ send the these as ADDR/PORT/TTL/TIMEOUT */ struct ip_addr source_ip; unsigned int source_port; - /* send TTL as this -1, so the default 0 means "don't send it" */ - unsigned int proxy_ttl_plus_1; + /* send TTL as this (default 0 means "don't send it") */ + unsigned int proxy_ttl; /* remote is notified that the connection is going to be closed after this many seconds, so it should try to keep lock waits and such lower than this. */ diff -r 8740056e9b2f -r 48c1c58948f5 src/lmtp/commands.c --- a/src/lmtp/commands.c Fri Feb 22 10:32:05 2013 +0200 +++ b/src/lmtp/commands.c Fri Feb 22 12:42:26 2013 +0200 @@ -297,7 +297,7 @@ return TRUE; } - if (client->proxy_ttl == 0) { + if (client->proxy_ttl <= 1) { i_error("Proxying to <%s> appears to be looping (TTL=0)", username); client_send_line(client, "554 5.4.6 <%s> " diff -r 8740056e9b2f -r 48c1c58948f5 src/lmtp/lmtp-proxy.c --- a/src/lmtp/lmtp-proxy.c Fri Feb 22 10:32:05 2013 +0200 +++ b/src/lmtp/lmtp-proxy.c Fri Feb 22 12:42:26 2013 +0200 @@ -61,6 +61,7 @@ struct lmtp_proxy *proxy; pool_t pool; + i_assert(set->proxy_ttl > 0); o_stream_ref(client_output); pool = pool_alloconly_create("lmtp proxy", 1024); @@ -136,7 +137,7 @@ client_set.dns_client_socket_path = proxy->set.dns_client_socket_path; client_set.source_ip = proxy->set.source_ip; client_set.source_port = proxy->set.source_port; - client_set.proxy_ttl_plus_1 = proxy->set.proxy_ttl+1; + client_set.proxy_ttl = proxy->set.proxy_ttl; client_set.proxy_timeout_secs = set->timeout_msecs/1000; conn = p_new(proxy->pool, struct lmtp_proxy_connection, 1); diff -r 8740056e9b2f -r 48c1c58948f5 src/login-common/login-proxy.c --- a/src/login-common/login-proxy.c Fri Feb 22 10:32:05 2013 +0200 +++ b/src/login-common/login-proxy.c Fri Feb 22 12:42:26 2013 +0200 @@ -299,7 +299,7 @@ return -1; } - if (client->proxy_ttl == 0) { + if (client->proxy_ttl <= 1) { i_error("proxy(%s): TTL reached zero - " "proxies appear to be looping?", client->virtual_user); return -1; diff -r 8740056e9b2f -r 48c1c58948f5 src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Fri Feb 22 10:32:05 2013 +0200 +++ b/src/pop3-login/pop3-proxy.c Fri Feb 22 12:42:26 2013 +0200 @@ -37,7 +37,7 @@ { string_t *str; - i_assert(client->common.proxy_ttl > 0); + i_assert(client->common.proxy_ttl > 1); if (client->proxy_xclient) { /* remote supports XCLIENT, send it */ o_stream_nsend_str(output, t_strdup_printf( From dovecot at dovecot.org Fri Feb 22 13:05:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 13:05:34 +0200 Subject: dovecot-2.2: auth: Added real_[lr]ip, real_[lr]port variables. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c43fcfa2c4b4 changeset: 15888:c43fcfa2c4b4 user: Timo Sirainen date: Fri Feb 22 13:04:45 2013 +0200 description: auth: Added real_[lr]ip, real_[lr]port variables. The unreal ones differ when a trusted proxy overrides them. diffstat: src/auth/auth-request.c | 47 ++++++++++++++++++++++++++++++++++--- src/auth/auth-request.h | 6 ++-- src/lib-auth/auth-client-request.c | 20 ++++++++++++++++ src/lib-auth/auth-client.h | 4 +- src/login-common/client-common.c | 13 +++++++--- src/login-common/client-common.h | 3 +- src/login-common/main.c | 4 +- src/login-common/sasl-server.c | 4 +++ 8 files changed, 85 insertions(+), 16 deletions(-) diffs (229 lines): diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/auth/auth-request.c --- a/src/auth/auth-request.c Fri Feb 22 12:42:26 2013 +0200 +++ b/src/auth/auth-request.c Fri Feb 22 13:04:45 2013 +0200 @@ -230,6 +230,18 @@ str_printfa(dest, "\tlport=%u", request->local_port); if (request->remote_port != 0) str_printfa(dest, "\trport=%u", request->remote_port); + if (request->real_local_ip.family != 0) { + auth_str_add_keyvalue(dest, "real_lip", + net_ip2addr(&request->real_local_ip)); + } + if (request->real_remote_ip.family != 0) { + auth_str_add_keyvalue(dest, "real_rip", + net_ip2addr(&request->real_remote_ip)); + } + if (request->real_local_port != 0) + str_printfa(dest, "\treal_lport=%u", request->real_local_port); + if (request->real_remote_port != 0) + str_printfa(dest, "\treal_rport=%u", request->real_remote_port); if (request->secured) str_append(dest, "\tsecured"); if (request->skip_password_check) @@ -250,14 +262,31 @@ /* authentication and user lookups may set these */ if (strcmp(key, "service") == 0) request->service = p_strdup(request->pool, value); - else if (strcmp(key, "lip") == 0) + else if (strcmp(key, "lip") == 0) { (void)net_addr2ip(value, &request->local_ip); - else if (strcmp(key, "rip") == 0) + if (request->real_local_ip.family == 0) + request->real_local_ip = request->local_ip; + } else if (strcmp(key, "rip") == 0) { (void)net_addr2ip(value, &request->remote_ip); - else if (strcmp(key, "lport") == 0) + if (request->real_remote_ip.family == 0) + request->real_remote_ip = request->remote_ip; + } else if (strcmp(key, "lport") == 0) { request->local_port = atoi(value); - else if (strcmp(key, "rport") == 0) + if (request->real_local_port == 0) + request->real_local_port = request->local_port; + } else if (strcmp(key, "rport") == 0) { request->remote_port = atoi(value); + if (request->real_remote_port == 0) + request->real_remote_port = request->remote_port; + } + else if (strcmp(key, "real_lip") == 0) + (void)net_addr2ip(value, &request->real_local_ip); + else if (strcmp(key, "real_rip") == 0) + (void)net_addr2ip(value, &request->real_remote_ip); + else if (strcmp(key, "real_lport") == 0) + request->real_local_port = atoi(value); + else if (strcmp(key, "real_rport") == 0) + request->real_remote_port = atoi(value); else if (strcmp(key, "session") == 0) request->session_id = p_strdup(request->pool, value); else @@ -1812,6 +1841,10 @@ { '\0', NULL, "login_username" }, { '\0', NULL, "login_domain" }, { '\0', NULL, "session" }, + { '\0', NULL, "real_lip" }, + { '\0', NULL, "real_rip" }, + { '\0', NULL, "real_lport" }, + { '\0', NULL, "real_rport" }, { '\0', NULL, NULL } }; @@ -1882,6 +1915,12 @@ } tab[18].value = auth_request->session_id == NULL ? NULL : escape_func(auth_request->session_id, auth_request); + if (auth_request->real_local_ip.family != 0) + tab[19].value = net_ip2addr(&auth_request->real_local_ip); + if (auth_request->real_remote_ip.family != 0) + tab[20].value = net_ip2addr(&auth_request->real_remote_ip); + tab[21].value = dec2str(auth_request->real_local_port); + tab[22].value = dec2str(auth_request->real_remote_port); return ret_tab; } diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/auth/auth-request.h --- a/src/auth/auth-request.h Fri Feb 22 12:42:26 2013 +0200 +++ b/src/auth/auth-request.h Fri Feb 22 13:04:45 2013 +0200 @@ -73,8 +73,8 @@ pid_t session_pid; const char *service, *mech_name, *session_id; - struct ip_addr local_ip, remote_ip; - unsigned int local_port, remote_port; + struct ip_addr local_ip, remote_ip, real_local_ip, real_remote_ip; + unsigned int local_port, remote_port, real_local_port, real_remote_port; struct timeout *to_abort, *to_penalty; unsigned int last_penalty; @@ -140,7 +140,7 @@ #define AUTH_REQUEST_VAR_TAB_USER_IDX 0 #define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1 #define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2 -#define AUTH_REQUEST_VAR_TAB_COUNT 19 +#define AUTH_REQUEST_VAR_TAB_COUNT 23 extern const struct var_expand_table auth_request_var_expand_static_tab[]; struct auth_request * diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/lib-auth/auth-client-request.c --- a/src/lib-auth/auth-client-request.c Fri Feb 22 12:42:26 2013 +0200 +++ b/src/lib-auth/auth-client-request.c Fri Feb 22 13:04:45 2013 +0200 @@ -60,6 +60,26 @@ str_printfa(str, "\tlport=%u", info->local_port); if (info->remote_port != 0) str_printfa(str, "\trport=%u", info->remote_port); + + /* send the real_* variants only when they differ from the unreal + ones */ + if (info->real_local_ip.family != 0 && + !net_ip_compare(&info->real_local_ip, &info->local_ip)) { + str_printfa(str, "\treal_lip=%s", + net_ip2addr(&info->real_local_ip)); + } + if (info->real_remote_ip.family != 0 && + !net_ip_compare(&info->real_remote_ip, &info->remote_ip)) { + str_printfa(str, "\treal_rip=%s", + net_ip2addr(&info->real_remote_ip)); + } + if (info->real_local_port != 0 && + info->real_local_port != info->local_port) + str_printfa(str, "\treal_lport=%u", info->real_local_port); + if (info->real_remote_port != 0 && + info->real_remote_port != info->remote_port) + str_printfa(str, "\treal_rport=%u", info->real_remote_port); + if (info->initial_resp_base64 != NULL) { str_append(str, "\tresp="); str_append_tabescaped(str, info->initial_resp_base64); diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/lib-auth/auth-client.h --- a/src/lib-auth/auth-client.h Fri Feb 22 12:42:26 2013 +0200 +++ b/src/lib-auth/auth-client.h Fri Feb 22 13:04:45 2013 +0200 @@ -41,8 +41,8 @@ const char *cert_username; enum auth_request_flags flags; - struct ip_addr local_ip, remote_ip; - unsigned int local_port, remote_port; + struct ip_addr local_ip, remote_ip, real_local_ip, real_remote_ip; + unsigned int local_port, remote_port, real_local_port, real_remote_port; const char *initial_resp_base64; }; diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/login-common/client-common.c --- a/src/login-common/client-common.c Fri Feb 22 12:42:26 2013 +0200 +++ b/src/login-common/client-common.c Fri Feb 22 13:04:45 2013 +0200 @@ -123,9 +123,8 @@ client->pool = pool; client->set = set; client->ssl_set = ssl_set; - client->local_ip = *local_ip; - client->ip = *remote_ip; - client->real_ip = *remote_ip; + client->real_local_ip = client->local_ip = *local_ip; + client->real_remote_ip = client->ip = *remote_ip; client->fd = fd; client->tls = ssl; client->trusted = client_is_trusted(client); @@ -463,7 +462,10 @@ { 'k', NULL, "ssl_security" }, { 'e', NULL, "mail_pid" }, { '\0', NULL, "session" }, + { '\0', NULL, "real_lip" }, { '\0', NULL, "real_rip" }, + { '\0', NULL, "real_lport" }, + { '\0', NULL, "real_rport" }, { '\0', NULL, NULL } }; @@ -513,7 +515,10 @@ tab[13].value = client->mail_pid == 0 ? "" : dec2str(client->mail_pid); tab[14].value = client_get_session_id(client); - tab[15].value = net_ip2addr(&client->real_ip); + tab[15].value = net_ip2addr(&client->real_local_ip); + tab[16].value = net_ip2addr(&client->real_remote_ip); + tab[17].value = dec2str(client->real_local_port); + tab[18].value = dec2str(client->real_remote_port); return tab; } diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/login-common/client-common.h --- a/src/login-common/client-common.h Fri Feb 22 12:42:26 2013 +0200 +++ b/src/login-common/client-common.h Fri Feb 22 13:04:45 2013 +0200 @@ -102,8 +102,9 @@ struct ip_addr local_ip; struct ip_addr ip; - struct ip_addr real_ip; + struct ip_addr real_remote_ip, real_local_ip; unsigned int local_port, remote_port; + unsigned int real_local_port, real_remote_port; struct ssl_proxy *ssl_proxy; const struct login_settings *set; const struct master_service_ssl_settings *ssl_set; diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/login-common/main.c --- a/src/login-common/main.c Fri Feb 22 12:42:26 2013 +0200 +++ b/src/login-common/main.c Fri Feb 22 13:04:45 2013 +0200 @@ -143,8 +143,8 @@ ssl_proxy_start(proxy); } - client->remote_port = conn->remote_port; - client->local_port = local_port; + client->real_remote_port = client->remote_port = conn->remote_port; + client->real_local_port = client->local_port = local_port; if (auth_client_to != NULL) timeout_remove(&auth_client_to); diff -r 48c1c58948f5 -r c43fcfa2c4b4 src/login-common/sasl-server.c --- a/src/login-common/sasl-server.c Fri Feb 22 12:42:26 2013 +0200 +++ b/src/login-common/sasl-server.c Fri Feb 22 13:04:45 2013 +0200 @@ -327,6 +327,10 @@ info.remote_ip = client->ip; info.local_port = client->local_port; info.remote_port = client->remote_port; + info.real_local_ip = client->real_local_ip; + info.real_remote_ip = client->real_remote_ip; + info.real_local_port = client->real_local_port; + info.real_remote_port = client->real_remote_port; info.initial_resp_base64 = initial_resp_base64; client->auth_request = From dovecot at dovecot.org Fri Feb 22 13:05:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 13:05:34 +0200 Subject: dovecot-2.2: auth: Use real_lip for proxy_maybe checks. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/68c9d01ae5d2 changeset: 15889:68c9d01ae5d2 user: Timo Sirainen date: Fri Feb 22 13:05:21 2013 +0200 description: auth: Use real_lip for proxy_maybe checks. diffstat: src/auth/auth-request.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r c43fcfa2c4b4 -r 68c9d01ae5d2 src/auth/auth-request.c --- a/src/auth/auth-request.c Fri Feb 22 13:04:45 2013 +0200 +++ b/src/auth/auth-request.c Fri Feb 22 13:05:21 2013 +0200 @@ -1526,7 +1526,7 @@ { unsigned int i; - if (net_ip_compare(ip, &request->local_ip)) + if (net_ip_compare(ip, &request->real_local_ip)) return TRUE; for (i = 0; request->set->proxy_self_ips[i].family != 0; i++) { From dovecot at dovecot.org Fri Feb 22 13:21:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 13:21:42 +0200 Subject: dovecot-2.2: mail_shared_explicit_inbox: Switched the default fr... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c3d3d3360425 changeset: 15890:c3d3d3360425 user: Timo Sirainen date: Fri Feb 22 13:21:09 2013 +0200 description: mail_shared_explicit_inbox: Switched the default from "yes" to "no". diffstat: NEWS | 1 + doc/example-config/conf.d/10-mail.conf | 2 +- src/lib-storage/mail-storage-settings.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diffs (35 lines): diff -r 68c9d01ae5d2 -r c3d3d3360425 NEWS --- a/NEWS Fri Feb 22 13:05:21 2013 +0200 +++ b/NEWS Fri Feb 22 13:21:09 2013 +0200 @@ -14,6 +14,7 @@ * pop3_lock_session=yes now uses a POP3-only dovecot-pop3-session.lock file instead of actually locking the mailbox (and causing IMAP/LDA/LMTP to wait for the POP3 session to close). + * mail_shared_explicit_inbox setting's default switched to "no". + Implemented IMAP MOVE and BINARY extensions + Implemented IMAP CATENATE, URLAUTH and URLAUTH=BINARY extensions diff -r 68c9d01ae5d2 -r c3d3d3360425 doc/example-config/conf.d/10-mail.conf --- a/doc/example-config/conf.d/10-mail.conf Fri Feb 22 13:05:21 2013 +0200 +++ b/doc/example-config/conf.d/10-mail.conf Fri Feb 22 13:21:09 2013 +0200 @@ -98,7 +98,7 @@ #list = children #} # Should shared INBOX be visible as "shared/user" or "shared/user/INBOX"? -#mail_shared_explicit_inbox = yes +#mail_shared_explicit_inbox = no # System user and group used to access mails. If you use multiple, userdb # can override these by returning uid or gid fields. You can use either numbers diff -r 68c9d01ae5d2 -r c3d3d3360425 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Fri Feb 22 13:05:21 2013 +0200 +++ b/src/lib-storage/mail-storage-settings.c Fri Feb 22 13:21:09 2013 +0200 @@ -81,7 +81,7 @@ .mail_debug = FALSE, .mail_full_filesystem_access = FALSE, .maildir_stat_dirs = FALSE, - .mail_shared_explicit_inbox = TRUE, + .mail_shared_explicit_inbox = FALSE, .lock_method = "fcntl:flock:dotlock", .pop3_uidl_format = "%08Xu%08Xv" }; From dovecot at dovecot.org Fri Feb 22 13:51:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 13:51:12 +0200 Subject: dovecot-2.1: lib-dict: Fixed hang if async commit's callback did... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/225c64ed0439 changeset: 14919:225c64ed0439 user: Timo Sirainen date: Fri Feb 22 13:51:02 2013 +0200 description: lib-dict: Fixed hang if async commit's callback did more dict access. Specifically this fixes a hang with dict-quota plugin when user didn't exist and quota was changed before calculating it. diffstat: src/lib-dict/dict-client.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diffs (26 lines): diff -r 81ea622b6394 -r 225c64ed0439 src/lib-dict/dict-client.c --- a/src/lib-dict/dict-client.c Fri Feb 22 12:19:36 2013 +0200 +++ b/src/lib-dict/dict-client.c Fri Feb 22 13:51:02 2013 +0200 @@ -262,15 +262,17 @@ i_error("dict-client: Unknown transaction id %u", id); return; } - if (ctx->callback != NULL) - ctx->callback(ret, ctx->context); - DLLIST_REMOVE(&dict->transactions, ctx); - i_free(ctx); - + /* the callback may call the dict code again, so remove this + transaction before calling it */ i_assert(dict->async_commits > 0); if (--dict->async_commits == 0) io_remove(&dict->io); + DLLIST_REMOVE(&dict->transactions, ctx); + + if (ctx->callback != NULL) + ctx->callback(ret, ctx->context); + i_free(ctx); } static ssize_t client_dict_read_timeout(struct client_dict *dict) From dovecot at dovecot.org Fri Feb 22 14:49:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 14:49:38 +0200 Subject: dovecot-2.1: fts-solr: Truncate header if it's over 1 MB. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0a932ba1f01f changeset: 14920:0a932ba1f01f user: Timo Sirainen date: Fri Feb 22 14:49:27 2013 +0200 description: fts-solr: Truncate header if it's over 1 MB. Previously we just warned about it. diffstat: src/plugins/fts-solr/fts-backend-solr.c | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) diffs (75 lines): diff -r 225c64ed0439 -r 0a932ba1f01f src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 22 13:51:02 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 22 14:49:27 2013 +0200 @@ -17,9 +17,14 @@ #define SOLR_CMDBUF_SIZE (1024*64) #define SOLR_CMDBUF_FLUSH_SIZE (SOLR_CMDBUF_SIZE-128) -#define SOLR_BUFFER_WARN_SIZE (1024*1024) #define SOLR_MAX_MULTI_ROWS 100000 +/* If header is larger than this, truncate it. */ +#define SOLR_HEADER_MAX_SIZE (1024*1024) +/* If SOLR_HEADER_MAX_SIZE was already reached, write still to individual + header fields as long as they're smaller than this */ +#define SOLR_HEADER_LINE_MAX_TRUNC_SIZE 1024 + struct solr_fts_backend { struct fts_backend backend; }; @@ -42,12 +47,12 @@ ARRAY_DEFINE(fields, struct solr_fts_field); uint32_t last_indexed_uid; - uint32_t size_warned_uid; unsigned int last_indexed_uid_set:1; unsigned int body_open:1; unsigned int documents_added:1; unsigned int expunges:1; + unsigned int truncate_header:1; }; static struct solr_connection *solr_conn = NULL; @@ -445,6 +450,7 @@ fts_backend_solr_doc_close(ctx); } ctx->prev_uid = uid; + ctx->truncate_header = FALSE; fts_backend_solr_doc_open(ctx, uid); } @@ -531,8 +537,11 @@ } xml_encode_data(ctx->cmd, data, size); } else { - xml_encode_data(ctx->cur_value, data, size); - if (ctx->cur_value2 != NULL) + if (!ctx->truncate_header) + xml_encode_data(ctx->cur_value, data, size); + if (ctx->cur_value2 != NULL && + (!ctx->truncate_header || + str_len(ctx->cur_value2) < SOLR_HEADER_LINE_MAX_TRUNC_SIZE)) xml_encode_data(ctx->cur_value2, data, size); } @@ -541,15 +550,15 @@ str_len(ctx->cmd)); str_truncate(ctx->cmd, 0); } - if (str_len(ctx->cur_value) >= SOLR_BUFFER_WARN_SIZE && - ctx->size_warned_uid != ctx->prev_uid) { + if (!ctx->truncate_header && + str_len(ctx->cur_value) >= SOLR_HEADER_MAX_SIZE) { /* a large header */ i_assert(ctx->cur_value != ctx->cmd); - ctx->size_warned_uid = ctx->prev_uid; - i_warning("fts-solr(%s): Mailbox %s UID=%u header size is huge", + i_warning("fts-solr(%s): Mailbox %s UID=%u header size is huge, truncating", ctx->cur_box->storage->user->username, mailbox_get_vname(ctx->cur_box), ctx->prev_uid); + ctx->truncate_header = TRUE; } return 0; } From dovecot at dovecot.org Fri Feb 22 15:14:28 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 15:14:28 +0200 Subject: dovecot-2.2: auth: userdb passwd iteration no longer skips shells. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4eea2224e16b changeset: 15891:4eea2224e16b user: Timo Sirainen date: Fri Feb 22 15:14:19 2013 +0200 description: auth: userdb passwd iteration no longer skips shells. Some systems are using passwd for mail users with shell set to nologin. Maybe first_valid_uid check is good enough alone? diffstat: src/auth/userdb-passwd.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-) diffs (17 lines): diff -r c3d3d3360425 -r 4eea2224e16b src/auth/userdb-passwd.c --- a/src/auth/userdb-passwd.c Fri Feb 22 13:21:09 2013 +0200 +++ b/src/auth/userdb-passwd.c Fri Feb 22 15:14:19 2013 +0200 @@ -146,13 +146,6 @@ return FALSE; if (pw->pw_uid > (uid_t)set->last_valid_uid && set->last_valid_uid != 0) return FALSE; - - /* skip entries that don't have a valid shell. - they're again probably not real users. */ - if (strcmp(pw->pw_shell, "/bin/false") == 0 || - strcmp(pw->pw_shell, "/sbin/nologin") == 0 || - strcmp(pw->pw_shell, "/usr/sbin/nologin") == 0) - return FALSE; return TRUE; } From dovecot at dovecot.org Fri Feb 22 15:24:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 15:24:18 +0200 Subject: dovecot-2.2: doveconf: Discourage using plain "doveconf" by reco... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/eb03b24ffa65 changeset: 15892:eb03b24ffa65 user: Timo Sirainen date: Fri Feb 22 15:24:01 2013 +0200 description: doveconf: Discourage using plain "doveconf" by recommending -n parameter in the output. diffstat: src/config/doveconf.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 4eea2224e16b -r eb03b24ffa65 src/config/doveconf.c --- a/src/config/doveconf.c Fri Feb 22 15:14:19 2013 +0200 +++ b/src/config/doveconf.c Fri Feb 22 15:24:01 2013 +0200 @@ -833,6 +833,8 @@ printf("# %s\n", info); if (!config_path_specified) check_wrong_config(config_path); + if (scope == CONFIG_DUMP_SCOPE_ALL) + printf("# NOTE: Send doveconf -n output instead when asking for help.\n"); fflush(stdout); ret2 = config_dump_human(&filter, wanted_modules, scope, NULL); } else { From dovecot at dovecot.org Fri Feb 22 15:35:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 15:35:10 +0200 Subject: dovecot-2.2: doveadm user: Write an error if user doesn't exist. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/bf817bc963f7 changeset: 15893:bf817bc963f7 user: Timo Sirainen date: Fri Feb 22 15:34:59 2013 +0200 description: doveadm user: Write an error if user doesn't exist. diffstat: src/doveadm/doveadm-auth.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diffs (17 lines): diff -r eb03b24ffa65 -r bf817bc963f7 src/doveadm/doveadm-auth.c --- a/src/doveadm/doveadm-auth.c Fri Feb 22 15:24:01 2013 +0200 +++ b/src/doveadm/doveadm-auth.c Fri Feb 22 15:34:59 2013 +0200 @@ -325,7 +325,12 @@ &service_user, &user, &error)) <= 0) { pool_unref(&pool); - return ret == 0 ? 0 : -1; + if (ret < 0) + return -1; + fprintf(show_field == NULL ? stdout : stderr, + "userdb lookup: user %s doesn't exist\n", + input->username); + return 0; } if (show_field == NULL) { From dovecot at dovecot.org Fri Feb 22 15:49:40 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 15:49:40 +0200 Subject: dovecot-2.1: lib-index: Fixed assert-crash on some error conditi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e33fe1a7bb89 changeset: 14921:e33fe1a7bb89 user: Timo Sirainen date: Fri Feb 22 15:49:35 2013 +0200 description: lib-index: Fixed assert-crash on some error conditions. diffstat: src/lib-index/mail-transaction-log-file.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 0a932ba1f01f -r e33fe1a7bb89 src/lib-index/mail-transaction-log-file.c --- a/src/lib-index/mail-transaction-log-file.c Fri Feb 22 14:49:27 2013 +0200 +++ b/src/lib-index/mail-transaction-log-file.c Fri Feb 22 15:49:35 2013 +0200 @@ -1683,7 +1683,7 @@ } if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) { - if (start_offset < file->buffer_offset) { + if (start_offset < file->buffer_offset || file->buffer == NULL) { /* we had moved the log to memory but failed to read the beginning of the log file */ mail_index_set_error(index, @@ -1691,7 +1691,6 @@ file->filepath); return 0; } - i_assert(file->buffer != NULL); return log_file_map_check_offsets(file, start_offset, end_offset); } From dovecot at dovecot.org Fri Feb 22 16:03:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 16:03:11 +0200 Subject: dovecot-2.2: quota-fs: Support NetBSD 6.0 libquota. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b3f890c4a41c changeset: 15894:b3f890c4a41c user: Timo Sirainen date: Fri Feb 22 16:03:00 2013 +0200 description: quota-fs: Support NetBSD 6.0 libquota. Patch by Emmanuel Dreyfus. diffstat: configure.ac | 10 ++++++++- src/plugins/quota/Makefile.am | 4 ++- src/plugins/quota/quota-fs.c | 46 ++++++++++++++++++++++++++++++++++++++++++- src/plugins/quota/quota-fs.h | 10 +++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) diffs (150 lines): diff -r bf817bc963f7 -r b3f890c4a41c configure.ac --- a/configure.ac Fri Feb 22 15:34:59 2013 +0200 +++ b/configure.ac Fri Feb 22 16:03:00 2013 +0200 @@ -299,7 +299,8 @@ AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \ sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \ - sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h sys/fs/quota_common.h \ + sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h \ + quota.h sys/fs/quota_common.h \ mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \ xfs/xqm.h execinfo.h ucontext.h malloc_np.h sys/utsname.h sys/vmount.h \ sys/utsname.h glob.h linux/falloc.h ucred.h sys/ucred.h) @@ -2633,6 +2634,13 @@ fi AM_CONDITIONAL(HAVE_RQUOTA, test "$have_rquota" = "yes") +QUOTA_LIBS="" +AC_SEARCH_LIBS(quota_open, quota, [ + AC_DEFINE(HAVE_QUOTA_OPEN,, Define if you have quota_open()) + QUOTA_LIBS="-lquota" +]) +AC_SUBST(QUOTA_LIBS) + dnl dnl ** Full text search dnl diff -r bf817bc963f7 -r b3f890c4a41c src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Fri Feb 22 15:34:59 2013 +0200 +++ b/src/plugins/quota/Makefile.am Fri Feb 22 16:03:00 2013 +0200 @@ -43,6 +43,7 @@ lib10_quota_plugin_la_SOURCES = $(quota_dist_sources) nodist_lib10_quota_plugin_la_SOURCES = $(RQUOTA_XDR) +lib10_quota_plugin_la_LIBADD = $(QUOTA_LIBS) doveadm_module_LTLIBRARIES = \ lib10_doveadm_quota_plugin.la @@ -57,7 +58,8 @@ $(quota_common_objects) \ $(LIBDOVECOT_STORAGE) \ $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(MODULE_LIBS) \ + $(QUOTA_LIBS) quota_status_DEPENDENCIES = \ $(quota_common_objects) \ $(LIBDOVECOT_STORAGE_DEPS) \ diff -r bf817bc963f7 -r b3f890c4a41c src/plugins/quota/quota-fs.c --- a/src/plugins/quota/quota-fs.c Fri Feb 22 15:34:59 2013 +0200 +++ b/src/plugins/quota/quota-fs.c Fri Feb 22 16:03:00 2013 +0200 @@ -77,6 +77,9 @@ unsigned int inode_per_mail:1; unsigned int user_disabled:1; unsigned int group_disabled:1; +#ifdef FS_QUOTA_NETBSD + struct quotahandle *qh; +#endif }; extern struct quota_backend quota_backend_fs; @@ -527,7 +530,8 @@ } #endif -#if defined(FS_QUOTA_LINUX) || defined(FS_QUOTA_BSDAIX) +#if defined(FS_QUOTA_LINUX) || defined(FS_QUOTA_BSDAIX) || \ + defined(FS_QUOTA_NETBSD) static void fs_quota_root_disable(struct fs_quota_root *root, bool group) { if (group) @@ -661,6 +665,44 @@ } #endif +#ifdef FS_QUOTA_NETBSD +static int +fs_quota_get_netbsd(struct fs_quota_root *root, bool group, bool bytes, + uint64_t *value_r, uint64_t *limit_r) +{ + struct quotakey qk; + struct quotaval qv; + + if (root->qh == NULL) { + if ((root->qh = quota_open(root->mount->mount_path)) == NULL) { + i_error("cannot open quota for %s: %m", + root->mount->mount_path); + fs_quota_root_disable(root, group); + return 0; + } + } + + qk.qk_idtype = group ? QUOTA_IDTYPE_GROUP : QUOTA_IDTYPE_USER; + qk.qk_id = group ? root->gid : root->uid; + qk.qk_objtype = bytes ? QUOTA_OBJTYPE_BLOCKS : QUOTA_OBJTYPE_FILES; + + if (quota_get(root->qh, &qk, &qv) != 0) { + if (errno == ESRCH) { + fs_quota_root_disable(root, group); + return 0; + } + i_error("quotactl(Q_GETQUOTA, %s) failed: %m", + root->mount->mount_path); + return -1; + } + + *value_r = qv.qv_usage * DEV_BSIZE; + *limit_r = qv.qv_softlimit * DEV_BSIZE; + + return 1; +} +#endif + #ifdef FS_QUOTA_HPUX static int fs_quota_get_hpux(struct fs_quota_root *root, bool bytes, @@ -747,6 +789,8 @@ } #ifdef FS_QUOTA_LINUX return fs_quota_get_linux(root, group, bytes, value_r, limit_r); +#elif defined (FS_QUOTA_NETBSD) + return fs_quota_get_netbsd(root, group, bytes, value_r, limit_r); #elif defined (FS_QUOTA_BSDAIX) return fs_quota_get_bsdaix(root, group, bytes, value_r, limit_r); #else diff -r bf817bc963f7 -r b3f890c4a41c src/plugins/quota/quota-fs.h --- a/src/plugins/quota/quota-fs.h Fri Feb 22 15:34:59 2013 +0200 +++ b/src/plugins/quota/quota-fs.h Fri Feb 22 16:03:00 2013 +0200 @@ -6,6 +6,10 @@ # define HAVE_FS_QUOTA #endif +#ifdef HAVE_QUOTA_OPEN +# include /* NetBSD with libquota */ +#endif + #ifdef HAVE_SYS_QUOTA_H # include /* Linux, HP-UX */ #elif defined(HAVE_SYS_FS_UFS_QUOTA_H) @@ -37,4 +41,10 @@ # undef HAVE_FS_QUOTA #endif +#ifdef HAVE_QUOTA_OPEN /* NetBSD with libquota */ +# define FS_QUOTA_NETBSD +# define HAVE_FS_QUOTA +# undef FS_QUOTA_LINUX /* obtained because we also have */ #endif + +#endif From dovecot at dovecot.org Fri Feb 22 16:21:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 16:21:33 +0200 Subject: dovecot-2.2: pop3: Fixed infinite looping Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dcbebe49922a changeset: 15895:dcbebe49922a user: Timo Sirainen date: Fri Feb 22 16:21:20 2013 +0200 description: pop3: Fixed infinite looping diffstat: src/pop3/pop3-client.c | 27 +++++++++------------------ src/pop3/pop3-client.h | 6 +++++- 2 files changed, 14 insertions(+), 19 deletions(-) diffs (70 lines): diff -r b3f890c4a41c -r dcbebe49922a src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Fri Feb 22 16:03:00 2013 +0200 +++ b/src/pop3/pop3-client.c Fri Feb 22 16:21:20 2013 +0200 @@ -25,10 +25,6 @@ /* max. length of input command line (spec says 512) */ #define MAX_INBUF_SIZE 2048 -/* Stop reading input when output buffer has this many bytes. Once the buffer - size has dropped to half of it, start reading input again. */ -#define OUTBUF_THROTTLE_SIZE 4096 - /* Disconnect client when it sends too many bad commands in a row */ #define CLIENT_MAX_BAD_COMMANDS 20 @@ -643,21 +639,16 @@ i_assert(ret < 0 || (size_t)ret == str_len(str)); } T_END; if (ret >= 0) { - if (o_stream_get_buffer_used_size(client->output) < - OUTBUF_THROTTLE_SIZE) { + if (!POP3_CLIENT_OUTPUT_FULL(client)) client->last_output = ioloop_time; - } else { - if (client->io != NULL) { - /* no more input until client has read - our output */ - io_remove(&client->io); + else if (client->io != NULL) { + /* no more input until client has read + our output */ + io_remove(&client->io); - /* If someone happens to flush output, - we want to get our IO handler back in - flush callback */ - o_stream_set_flush_pending(client->output, - TRUE); - } + /* If someone happens to flush output, we want to get + our IO handler back in flush callback */ + o_stream_set_flush_pending(client->output, TRUE); } } va_end(va); @@ -775,7 +766,7 @@ if (client->cmd == NULL) { if (o_stream_get_buffer_used_size(client->output) < - OUTBUF_THROTTLE_SIZE/2 && client->io == NULL) { + POP3_OUTBUF_THROTTLE_SIZE/2 && client->io == NULL) { /* enable input again */ client->io = io_add(i_stream_get_fd(client->input), IO_READ, client_input, client); diff -r b3f890c4a41c -r dcbebe49922a src/pop3/pop3-client.h --- a/src/pop3/pop3-client.h Fri Feb 22 16:03:00 2013 +0200 +++ b/src/pop3/pop3-client.h Fri Feb 22 16:21:20 2013 +0200 @@ -9,8 +9,12 @@ #define MSGS_BITMASK_SIZE(client) \ (((client)->messages_count + (CHAR_BIT-1)) / CHAR_BIT) +/* Stop reading input when output buffer has this many bytes. Once the buffer + size has dropped to half of it, start reading input again. */ +#define POP3_OUTBUF_THROTTLE_SIZE 4096 + #define POP3_CLIENT_OUTPUT_FULL(client) \ - ((client)->io == NULL) + (o_stream_get_buffer_used_size((client)->output) >= POP3_OUTBUF_THROTTLE_SIZE) struct pop3_client_vfuncs { void (*destroy)(struct client *client, const char *reason); From dovecot at dovecot.org Fri Feb 22 16:42:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 22 Feb 2013 16:42:34 +0200 Subject: dovecot-2.2: auth_debug_passwords: Add a warning to AUTH/CONT li... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0ceb0029a781 changeset: 15896:0ceb0029a781 user: Timo Sirainen date: Fri Feb 22 16:42:23 2013 +0200 description: auth_debug_passwords: Add a warning to AUTH/CONT lines about them having sensitive data. diffstat: src/auth/auth-client-connection.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diffs (67 lines): diff -r dcbebe49922a -r 0ceb0029a781 src/auth/auth-client-connection.c --- a/src/auth/auth-client-connection.c Fri Feb 22 16:21:20 2013 +0200 +++ b/src/auth/auth-client-connection.c Fri Feb 22 16:42:23 2013 +0200 @@ -24,6 +24,9 @@ #define OUTBUF_THROTTLE_SIZE (1024*50) +#define AUTH_DEBUG_SENSITIVE_SUFFIX \ + " (previous base64 data may contain sensitive data)" + static void auth_client_disconnected(struct auth_client_connection **_conn); static void auth_client_connection_unref(struct auth_client_connection **_conn); static void auth_client_input(struct auth_client_connection *conn); @@ -150,7 +153,8 @@ return 1; } -static const char *auth_line_hide_pass(const char *line) +static const char * +auth_line_hide_pass(struct auth_client_connection *conn, const char *line) { const char *p, *p2; @@ -159,15 +163,22 @@ return line; p += 6; + if (conn->auth->set->debug_passwords) + return t_strconcat(line, AUTH_DEBUG_SENSITIVE_SUFFIX, NULL); + p2 = strchr(p, '\t'); return t_strconcat(t_strdup_until(line, p), PASSWORD_HIDDEN_STR, p2, NULL); } -static const char *cont_line_hide_pass(const char *line) +static const char * +cont_line_hide_pass(struct auth_client_connection *conn, const char *line) { const char *p; + if (conn->auth->set->debug_passwords) + return t_strconcat(line, AUTH_DEBUG_SENSITIVE_SUFFIX, NULL); + p = strchr(line, '\t'); if (p == NULL) return line; @@ -195,8 +206,7 @@ if (strncmp(line, "AUTH\t", 5) == 0) { if (conn->auth->set->debug) { i_debug("client in: %s", - conn->auth->set->debug_passwords ? line : - auth_line_hide_pass(line)); + auth_line_hide_pass(conn, line)); } return auth_request_handler_auth_begin(conn->request_handler, line + 5); @@ -204,8 +214,7 @@ if (strncmp(line, "CONT\t", 5) == 0) { if (conn->auth->set->debug) { i_debug("client in: %s", - conn->auth->set->debug_passwords ? line : - cont_line_hide_pass(line)); + cont_line_hide_pass(conn, line)); } return auth_request_handler_auth_continue(conn->request_handler, line + 5); From dovecot at dovecot.org Sun Feb 24 08:07:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 08:07:05 +0200 Subject: dovecot-2.2: dsync: Don't log about remote dsync status if we're... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c05773011313 changeset: 15897:c05773011313 user: Timo Sirainen date: Sun Feb 24 08:06:51 2013 +0200 description: dsync: Don't log about remote dsync status if we're not doing a remote sync. diffstat: src/doveadm/dsync/doveadm-dsync.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 0ceb0029a781 -r c05773011313 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Fri Feb 22 16:42:23 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Sun Feb 24 08:06:51 2013 +0200 @@ -486,7 +486,8 @@ remote_errors_logged = ctx->err_stream->v_offset > 0; i_stream_destroy(&ctx->err_stream); } - cmd_dsync_log_remote_status(status, remote_errors_logged); + if (ctx->remote) + cmd_dsync_log_remote_status(status, remote_errors_logged); if (ctx->io_err != NULL) io_remove(&ctx->io_err); if (ctx->fd_err != -1) From dovecot at dovecot.org Sun Feb 24 08:07:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 08:07:05 +0200 Subject: dovecot-2.2: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/357b1f1285ea changeset: 15898:357b1f1285ea user: Timo Sirainen date: Sun Feb 24 08:06:59 2013 +0200 description: Compiler warning fix. diffstat: src/lib/test-json-parser.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (17 lines): diff -r c05773011313 -r 357b1f1285ea src/lib/test-json-parser.c --- a/src/lib/test-json-parser.c Sun Feb 24 08:06:51 2013 +0200 +++ b/src/lib/test-json-parser.c Sun Feb 24 08:06:59 2013 +0200 @@ -128,11 +128,11 @@ test_istream_set_size(input, i); for (;;) { - if (json_output[pos].type == TYPE_SKIP) { + if (json_output[pos].type == (enum json_type)TYPE_SKIP) { json_parse_skip_next(parser); pos++; continue; - } else if (json_output[pos].type != TYPE_STREAM) { + } else if (json_output[pos].type != (enum json_type)TYPE_STREAM) { ret = json_parse_next(parser, &type, &value); } else { ret = jsoninput != NULL ? 1 : From dovecot at dovecot.org Sun Feb 24 08:49:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 08:49:36 +0200 Subject: dovecot-2.2: Use proper HAVE_TYPEOF check instead of checking wi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e2ffe53ac89c changeset: 15899:e2ffe53ac89c user: Timo Sirainen date: Sun Feb 24 08:44:27 2013 +0200 description: Use proper HAVE_TYPEOF check instead of checking with gcc versions. diffstat: configure.ac | 1 + src/lib/macros.h | 1 - 2 files changed, 1 insertions(+), 1 deletions(-) diffs (22 lines): diff -r 357b1f1285ea -r e2ffe53ac89c configure.ac --- a/configure.ac Sun Feb 24 08:06:59 2013 +0200 +++ b/configure.ac Sun Feb 24 08:44:27 2013 +0200 @@ -290,6 +290,7 @@ AC_PROG_CXX # lucene plugin needs this AC_HEADER_STDC AC_C_INLINE +AC_C_TYPEOF AC_PROG_LIBTOOL AM_ICONV diff -r 357b1f1285ea -r e2ffe53ac89c src/lib/macros.h --- a/src/lib/macros.h Sun Feb 24 08:06:59 2013 +0200 +++ b/src/lib/macros.h Sun Feb 24 08:44:27 2013 +0200 @@ -151,7 +151,6 @@ #endif #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)) && !defined(__cplusplus) -# define HAVE_TYPEOF # define COMPILE_ERROR_IF_TRUE(condition) \ (sizeof(char[1 - 2 * !!(condition)]) - 1) # define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) \ From dovecot at dovecot.org Sun Feb 24 08:49:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 08:49:36 +0200 Subject: dovecot-2.2: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/88c325e81c7c changeset: 15900:88c325e81c7c user: Timo Sirainen date: Sun Feb 24 08:43:34 2013 +0200 description: Minor code cleanup diffstat: src/lib-storage/mail-search-register-human.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r e2ffe53ac89c -r 88c325e81c7c src/lib-storage/mail-search-register-human.c --- a/src/lib-storage/mail-search-register-human.c Sun Feb 24 08:44:27 2013 +0200 +++ b/src/lib-storage/mail-search-register-human.c Sun Feb 24 08:43:34 2013 +0200 @@ -191,7 +191,7 @@ { struct mail_search_register *reg; mail_search_register_fallback_t *fallback; - ARRAY(const struct mail_search_register_arg) copy_args; + ARRAY(struct mail_search_register_arg) copy_args; const struct mail_search_register_arg *human_args, *imap_args; unsigned int i, j, human_count, imap_count; int ret; From dovecot at dovecot.org Sun Feb 24 08:49:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 08:49:36 +0200 Subject: dovecot-2.2: Fixed "duplicate const" warnings with new clang. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/871154fc93f2 changeset: 15901:871154fc93f2 user: Timo Sirainen date: Sun Feb 24 08:46:28 2013 +0200 description: Fixed "duplicate const" warnings with new clang. diffstat: src/lib/hash-decl.h | 1 - src/lib/hash.h | 16 +++------------- src/lib/macros.h | 3 +++ 3 files changed, 6 insertions(+), 14 deletions(-) diffs (74 lines): diff -r 88c325e81c7c -r 871154fc93f2 src/lib/hash-decl.h --- a/src/lib/hash-decl.h Sun Feb 24 08:43:34 2013 +0200 +++ b/src/lib/hash-decl.h Sun Feb 24 08:46:28 2013 +0200 @@ -5,7 +5,6 @@ struct hash_table *_table; \ key_type _key; \ key_type *_keyp; \ - const key_type _const_key; \ value_type _value; \ value_type *_valuep; \ } diff -r 88c325e81c7c -r 871154fc93f2 src/lib/hash.h --- a/src/lib/hash.h Sun Feb 24 08:43:34 2013 +0200 +++ b/src/lib/hash.h Sun Feb 24 08:46:28 2013 +0200 @@ -27,16 +27,6 @@ ({(void)COMPILE_ERROR_IF_TRUE( \ sizeof((*table)._key) != sizeof(void *) || \ sizeof((*table)._value) != sizeof(void *)); \ - (void)COMPILE_ERROR_IF_TRUE( \ - !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ - int (*)(typeof((*table)._key), typeof((*table)._key))) && \ - !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ - int (*)(typeof((*table)._const_key), typeof((*table)._const_key)))); \ - (void)COMPILE_ERROR_IF_TRUE( \ - !__builtin_types_compatible_p(typeof(&hash_cb), \ - unsigned int (*)(typeof((*table)._key))) && \ - !__builtin_types_compatible_p(typeof(&hash_cb), \ - unsigned int (*)(typeof((*table)._const_key)))); \ hash_table_create(&(*table)._table, pool, size, \ (hash_callback_t *)hash_cb, \ (hash_cmp_callback_t *)key_cmp_cb);}) @@ -77,14 +67,14 @@ void *hash_table_lookup(const struct hash_table *table, const void *key) ATTR_PURE; #define hash_table_lookup(table, key) \ HASH_VALUE_CAST(table)hash_table_lookup((table)._table, \ - (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._key, (table)._const_key, key))) + (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key))) bool hash_table_lookup_full(const struct hash_table *table, const void *lookup_key, void **orig_key_r, void **value_r); #define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \ hash_table_lookup_full((table)._table, \ - (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \ + (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, lookup_key)), \ (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \ COMPILE_ERROR_IF_TRUE(sizeof(*orig_key_r) != sizeof(void *))), \ (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \ @@ -106,7 +96,7 @@ void hash_table_remove(struct hash_table *table, const void *key); #define hash_table_remove(table, key) \ hash_table_remove((table)._table, \ - (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, key))) + (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key))) unsigned int hash_table_count(const struct hash_table *table) ATTR_PURE; #define hash_table_count(table) \ hash_table_count((table)._table) diff -r 88c325e81c7c -r 871154fc93f2 src/lib/macros.h --- a/src/lib/macros.h Sun Feb 24 08:43:34 2013 +0200 +++ b/src/lib/macros.h Sun Feb 24 08:46:28 2013 +0200 @@ -160,10 +160,13 @@ COMPILE_ERROR_IF_TRUE( \ !__builtin_types_compatible_p(typeof(_a1), typeof(_b)) && \ !__builtin_types_compatible_p(typeof(_a2), typeof(_b))) +#define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) \ + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a, typeof(const typeof(*_a) *), _b) #else # define COMPILE_ERROR_IF_TRUE(condition) 0 # define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) 0 # define COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a1, _a2, _b) 0 +# define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) 0 #endif #if __GNUC__ > 2 From dovecot at dovecot.org Sun Feb 24 08:57:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 08:57:47 +0200 Subject: dovecot-2.2: Previous "duplicate const" fix accidentally deleted... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ecd923186510 changeset: 15902:ecd923186510 user: Timo Sirainen date: Sun Feb 24 08:54:58 2013 +0200 description: Previous "duplicate const" fix accidentally deleted some checking code instead of fixing it. diffstat: src/lib/hash.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diffs (20 lines): diff -r 871154fc93f2 -r ecd923186510 src/lib/hash.h --- a/src/lib/hash.h Sun Feb 24 08:46:28 2013 +0200 +++ b/src/lib/hash.h Sun Feb 24 08:54:58 2013 +0200 @@ -27,6 +27,16 @@ ({(void)COMPILE_ERROR_IF_TRUE( \ sizeof((*table)._key) != sizeof(void *) || \ sizeof((*table)._value) != sizeof(void *)); \ + (void)COMPILE_ERROR_IF_TRUE( \ + !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ + int (*)(typeof((*table)._key), typeof((*table)._key))) && \ + !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ + int (*)(typeof(const typeof(*(*table)._key) *), typeof(const typeof(*(*table)._key) *)))); \ + (void)COMPILE_ERROR_IF_TRUE( \ + !__builtin_types_compatible_p(typeof(&hash_cb), \ + unsigned int (*)(typeof((*table)._key))) && \ + !__builtin_types_compatible_p(typeof(&hash_cb), \ + unsigned int (*)(typeof(const typeof(*(*table)._key) *)))); \ hash_table_create(&(*table)._table, pool, size, \ (hash_callback_t *)hash_cb, \ (hash_cmp_callback_t *)key_cmp_cb);}) From dovecot at dovecot.org Sun Feb 24 08:58:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 08:58:09 +0200 Subject: dovecot-2.2: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f1e8f8a73196 changeset: 15903:f1e8f8a73196 user: Timo Sirainen date: Sun Feb 24 08:58:03 2013 +0200 description: Compiler warning fix. diffstat: src/doveadm/doveadm-mail-fetch.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r ecd923186510 -r f1e8f8a73196 src/doveadm/doveadm-mail-fetch.c --- a/src/doveadm/doveadm-mail-fetch.c Sun Feb 24 08:54:58 2013 +0200 +++ b/src/doveadm/doveadm-mail-fetch.c Sun Feb 24 08:58:03 2013 +0200 @@ -28,7 +28,7 @@ struct ostream *output; struct mail *mail; - ARRAY(const struct fetch_field) fields; + ARRAY(struct fetch_field) fields; ARRAY_TYPE(const_string) header_fields; enum mail_fetch_field wanted_fields; From dovecot at dovecot.org Sun Feb 24 09:16:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 09:16:39 +0200 Subject: dovecot-2.2: Replaced all -1U and (unsigned int)-1 with UINT_MAX. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d3cf06639864 changeset: 15904:d3cf06639864 user: Timo Sirainen date: Sun Feb 24 09:16:31 2013 +0200 description: Replaced all -1U and (unsigned int)-1 with UINT_MAX. It's somewhat clearer this way. Also clang's -fsanitize=integer gives runtime errors about -1U (but not about explicit casts, so no need to change (type)-1 casts). diffstat: configure.ac | 2 +- src/anvil/anvil-settings.c | 2 +- src/auth/db-ldap.c | 4 ++-- src/config/doveconf.c | 20 ++++++++++---------- src/director/director-settings.c | 2 +- src/director/doveadm-connection.c | 6 +++--- src/doveadm/doveadm-director.c | 4 ++-- src/doveadm/doveadm-mail-fetch.c | 4 ++-- src/doveadm/doveadm-stats.c | 4 ++-- src/lib-auth/auth-master.c | 8 ++++---- src/lib-dict/dict-sql.c | 4 ++-- src/lib-dict/dict.c | 4 ++-- src/lib-http/http-client-peer.c | 2 +- src/lib-imap/imap-envelope.c | 2 +- src/lib-index/mail-cache-compress.c | 2 +- src/lib-index/mail-cache-fields.c | 4 ++-- src/lib-index/mail-cache-lookup.c | 2 +- src/lib-index/mail-cache-transaction.c | 6 +++--- src/lib-index/mail-cache.h | 2 +- src/lib-index/mail-index-map.c | 4 ++-- src/lib-index/mail-index-sync-keywords.c | 2 +- src/lib-index/mail-index-sync.c | 4 ++-- src/lib-index/mail-index.c | 4 ++-- src/lib-index/mail-index.h | 3 ++- src/lib-index/mail-transaction-log-file.c | 12 ++++++------ src/lib-mail/test-message-address.c | 6 +++--- src/lib-master/master-service.c | 4 ++-- src/lib-settings/settings-parser.c | 4 ++-- src/lib-sql/driver-sqlpool.c | 12 ++++++------ src/lib-storage/index/dbox-multi/mdbox-map.c | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/index/index-mail-headers.c | 4 ++-- src/lib-storage/index/index-mail.c | 4 ++-- src/lib-storage/index/index-rebuild.c | 3 ++- src/lib-storage/index/index-search.c | 4 ++-- src/lib-storage/index/index-storage.c | 6 +++--- src/lib-storage/index/maildir/maildir-uidlist.c | 18 +++++++++--------- src/lib-storage/list/mailbox-list-index.c | 2 +- src/lib-storage/list/mailbox-list-iter.c | 2 +- src/lib-storage/mail-storage-hooks.c | 8 ++++---- src/lib-storage/mail-storage.c | 2 +- src/lib/istream-concat.c | 6 +++--- src/lib/priorityq.c | 4 ++-- src/lib/strnum.c | 2 +- src/lib/test-aqueue.c | 2 +- src/lib/test-base64.c | 8 ++++---- src/lib/test-bsearch-insert-pos.c | 10 +++++----- src/lib/test-seq-range-array.c | 22 +++++++++++----------- src/lmtp/commands.c | 4 ++-- src/log/log-settings.c | 2 +- src/master/service-monitor.c | 2 +- src/plugins/fts/fts-build-mail.c | 2 +- src/plugins/quota/quota.c | 2 +- src/replication/replicator/replicator-settings.c | 2 +- src/stats/stats-settings.c | 2 +- 55 files changed, 134 insertions(+), 132 deletions(-) diffs (truncated from 1204 to 300 lines): diff -r f1e8f8a73196 -r d3cf06639864 configure.ac --- a/configure.ac Sun Feb 24 08:58:03 2013 +0200 +++ b/configure.ac Sun Feb 24 09:16:31 2013 +0200 @@ -346,7 +346,7 @@ if test "$have_clang" = "yes"; then # clang specific options if test "$want_devel_checks" = "yes"; then - CFLAGS="$CFLAGS -fcatch-undefined-behavior -ftrapv" + CFLAGS="$CFLAGS -fsanitize=address,integer,undefined -ftrapv" fi fi diff -r f1e8f8a73196 -r d3cf06639864 src/anvil/anvil-settings.c --- a/src/anvil/anvil-settings.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/anvil/anvil-settings.c Sun Feb 24 09:16:31 2013 +0200 @@ -38,7 +38,7 @@ .process_limit = 1, .client_limit = 0, .service_count = 0, - .idle_kill = -1U, + .idle_kill = UINT_MAX, .vsz_limit = (uoff_t)-1, .unix_listeners = { { &anvil_unix_listeners_buf, diff -r f1e8f8a73196 -r d3cf06639864 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/auth/db-ldap.c Sun Feb 24 09:16:31 2013 +0200 @@ -928,7 +928,7 @@ static void db_ldap_disconnect_timeout(struct ldap_connection *conn) { - db_ldap_abort_requests(conn, -1U, + db_ldap_abort_requests(conn, UINT_MAX, DB_LDAP_REQUEST_DISCONNECT_TIMEOUT_SECS, FALSE, "Aborting (timeout), we're not connected to LDAP server"); @@ -1469,7 +1469,7 @@ } } - db_ldap_abort_requests(conn, -1U, 0, FALSE, "Shutting down"); + db_ldap_abort_requests(conn, UINT_MAX, 0, FALSE, "Shutting down"); i_assert(conn->pending_count == 0); db_ldap_conn_close(conn); i_assert(conn->to == NULL); diff -r f1e8f8a73196 -r d3cf06639864 src/config/doveconf.c --- a/src/config/doveconf.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/config/doveconf.c Sun Feb 24 09:16:31 2013 +0200 @@ -104,7 +104,7 @@ s = array_get(stack, &count); i_assert(count > 0); if (count == 1) { - sc.prefix_idx = -1U; + sc.prefix_idx = UINT_MAX; } else { sc.prefix_idx = s[count-2].prefix_idx; } @@ -118,7 +118,7 @@ struct prefix_stack *s; array_foreach_modifiable(stack, s) - s->str_pos = -1U; + s->str_pos = UINT_MAX; } static struct config_dump_human_context * @@ -178,7 +178,7 @@ const char *const *strings, *const *args, *p, *str, *const *prefixes; const char *key, *key2, *value; unsigned int i, j, count, len, prefix_count, skip_len; - unsigned int setting_name_filter_len, prefix_idx = -1U; + unsigned int setting_name_filter_len, prefix_idx = UINT_MAX; bool unique_key; int ret = 0; @@ -238,12 +238,12 @@ j = 0; /* if there are open sections and this key isn't in it, close the sections */ - while (prefix_idx != -1U) { + while (prefix_idx != UINT_MAX) { len = strlen(prefixes[prefix_idx]); if (strncmp(prefixes[prefix_idx], key, len) != 0) { prefix = prefix_stack_pop(&prefix_stack); indent--; - if (prefix.str_pos != -1U) + if (prefix.str_pos != UINT_MAX) str_truncate(ctx->list_prefix, prefix.str_pos); else { o_stream_nsend(output, indent_str, indent*2); @@ -260,9 +260,9 @@ for (; j < prefix_count; j++) { len = strlen(prefixes[j]); if (strncmp(prefixes[j], key, len) == 0) { - key2 = key + (prefix_idx == -1U ? 0 : + key2 = key + (prefix_idx == UINT_MAX ? 0 : strlen(prefixes[prefix_idx])); - prefix.str_pos = !unique_key ? -1U : + prefix.str_pos = !unique_key ? UINT_MAX : str_len(ctx->list_prefix); prefix_idx = j; prefix.prefix_idx = prefix_idx; @@ -294,7 +294,7 @@ prefix_stack_reset_str(&prefix_stack); ctx->list_prefix_sent = TRUE; - skip_len = prefix_idx == -1U ? 0 : strlen(prefixes[prefix_idx]); + skip_len = prefix_idx == UINT_MAX ? 0 : strlen(prefixes[prefix_idx]); i_assert(skip_len == 0 || strncmp(prefixes[prefix_idx], strings[i], skip_len) == 0); o_stream_nsend(output, indent_str, indent*2); @@ -314,9 +314,9 @@ end: ; } T_END; - while (prefix_idx != -1U) { + while (prefix_idx != UINT_MAX) { prefix = prefix_stack_pop(&prefix_stack); - if (prefix.str_pos != -1U) + if (prefix.str_pos != UINT_MAX) break; prefix_idx = prefix.prefix_idx; indent--; diff -r f1e8f8a73196 -r d3cf06639864 src/director/director-settings.c --- a/src/director/director-settings.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/director/director-settings.c Sun Feb 24 09:16:31 2013 +0200 @@ -48,7 +48,7 @@ .process_limit = 1, .client_limit = 0, .service_count = 0, - .idle_kill = -1U, + .idle_kill = UINT_MAX, .vsz_limit = (uoff_t)-1, .unix_listeners = { { &director_unix_listeners_buf, diff -r f1e8f8a73196 -r d3cf06639864 src/director/doveadm-connection.c --- a/src/director/doveadm-connection.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/director/doveadm-connection.c Sun Feb 24 09:16:31 2013 +0200 @@ -189,7 +189,7 @@ const char *const *args; struct mail_host *host; struct ip_addr ip; - unsigned int vhost_count = -1U; + unsigned int vhost_count = UINT_MAX; args = t_strsplit_tab(line); if (args[0] == NULL || @@ -198,14 +198,14 @@ i_error("doveadm sent invalid HOST-SET parameters: %s", line); return FALSE; } - if (vhost_count > MAX_VALID_VHOST_COUNT && vhost_count != -1U) { + if (vhost_count > MAX_VALID_VHOST_COUNT && vhost_count != UINT_MAX) { o_stream_nsend_str(conn->output, "vhost count too large\n"); return TRUE; } host = mail_host_lookup(dir->mail_hosts, &ip); if (host == NULL) host = mail_host_add_ip(dir->mail_hosts, &ip); - if (vhost_count != -1U) + if (vhost_count != UINT_MAX) mail_host_set_vhost_count(dir->mail_hosts, host, vhost_count); director_update_host(dir, dir->self_host, NULL, host); diff -r f1e8f8a73196 -r d3cf06639864 src/doveadm/doveadm-director.c --- a/src/doveadm/doveadm-director.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/doveadm/doveadm-director.c Sun Feb 24 09:16:31 2013 +0200 @@ -357,7 +357,7 @@ { struct director_context *ctx; struct ip_addr *ips; - unsigned int i, ips_count, vhost_count = -1U; + unsigned int i, ips_count, vhost_count = UINT_MAX; const char *host, *cmd, *line; ctx = cmd_director_init(argc, argv, "a:", cmd_director_add); @@ -373,7 +373,7 @@ director_get_host(host, &ips, &ips_count); for (i = 0; i < ips_count; i++) { - cmd = vhost_count == -1U ? + cmd = vhost_count == UINT_MAX ? t_strdup_printf("HOST-SET\t%s\n", net_ip2addr(&ips[i])) : t_strdup_printf("HOST-SET\t%s\t%u\n", diff -r f1e8f8a73196 -r d3cf06639864 src/doveadm/doveadm-mail-fetch.c --- a/src/doveadm/doveadm-mail-fetch.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/doveadm/doveadm-mail-fetch.c Sun Feb 24 09:16:31 2013 +0200 @@ -170,8 +170,8 @@ struct message_address *addr; addr = message_address_parse(pool_datastack_create(), - str_data(str), str_len(str), -1U, - FALSE); + str_data(str), str_len(str), + UINT_MAX, FALSE); str_truncate(str, 0); add_lf = FALSE; for (; addr != NULL; addr = addr->next) { diff -r f1e8f8a73196 -r d3cf06639864 src/doveadm/doveadm-stats.c --- a/src/doveadm/doveadm-stats.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/doveadm/doveadm-stats.c Sun Feb 24 09:16:31 2013 +0200 @@ -438,7 +438,7 @@ for (i = 0; i < N_ELEMENTS(names); i++) { if (!stats_header_find(ctx, names[i], &indexes[i])) - indexes[i] = -1U; + indexes[i] = UINT_MAX; } if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0) @@ -448,7 +448,7 @@ lines = array_get(&ctx->lines, &count); for (i = 0, row = 1; row < maxrow && i < count; i++, row++) { for (j = 0; j < N_ELEMENTS(names); j++) { - if (indexes[j] == -1U) + if (indexes[j] == UINT_MAX) doveadm_print("?"); else stats_top_output_diff(ctx, lines[i], indexes[j]); diff -r f1e8f8a73196 -r d3cf06639864 src/lib-auth/auth-master.c --- a/src/lib-auth/auth-master.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/lib-auth/auth-master.c Sun Feb 24 09:16:31 2013 +0200 @@ -577,9 +577,9 @@ unsigned int *countp = context; if (strcmp(cmd, "OK") != 0) - *countp = -1U; + *countp = UINT_MAX; else if (args[0] == NULL || str_to_uint(args[0], countp) < 0) - *countp = -1U; + *countp = UINT_MAX; io_loop_stop(current_ioloop); return TRUE; @@ -590,7 +590,7 @@ { string_t *str; - *count_r = -1U; + *count_r = UINT_MAX; conn->reply_callback = auth_cache_flush_reply_callback; conn->reply_context = count_r; @@ -609,7 +609,7 @@ (void)auth_master_run_cmd(conn, str_c(str)); conn->prefix = DEFAULT_USERDB_LOOKUP_PREFIX; - return *count_r == -1U ? -1 : 0; + return *count_r == UINT_MAX ? -1 : 0; } static bool diff -r f1e8f8a73196 -r d3cf06639864 src/lib-dict/dict-sql.c --- a/src/lib-dict/dict-sql.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/lib-dict/dict-sql.c Sun Feb 24 09:16:31 2013 +0200 @@ -525,7 +525,7 @@ ret = -1; } else { while (ctx->inc_row != NULL) { - i_assert(ctx->inc_row->rows != -1U); + i_assert(ctx->inc_row->rows != UINT_MAX); if (ctx->inc_row->rows == 0) { ret = 0; break; @@ -759,7 +759,7 @@ } row = p_new(ctx->inc_row_pool, struct sql_dict_inc_row, 1); row->prev = ctx->inc_row; - row->rows = -1U; + row->rows = UINT_MAX; ctx->inc_row = row; return &row->rows; } diff -r f1e8f8a73196 -r d3cf06639864 src/lib-dict/dict.c --- a/src/lib-dict/dict.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/lib-dict/dict.c Sun Feb 24 09:16:31 2013 +0200 @@ -37,7 +37,7 @@ void dict_driver_unregister(struct dict *driver) { struct dict *const *dicts; - unsigned int idx = -1U; + unsigned int idx = UINT_MAX; array_foreach(&dict_drivers, dicts) { if (*dicts == driver) { @@ -45,7 +45,7 @@ break; } } - i_assert(idx != -1U); + i_assert(idx != UINT_MAX); array_delete(&dict_drivers, idx, 1); if (array_count(&dict_drivers) == 0) diff -r f1e8f8a73196 -r d3cf06639864 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Sun Feb 24 08:58:03 2013 +0200 +++ b/src/lib-http/http-client-peer.c Sun Feb 24 09:16:31 2013 +0200 @@ -122,7 +122,7 @@ { From dovecot at dovecot.org Sun Feb 24 11:58:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 11:58:58 +0200 Subject: dovecot-2.2: lib-index: Don't unnecessarily update dovecot.index... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/76f576fc28dc changeset: 15905:76f576fc28dc user: Timo Sirainen date: Sun Feb 24 10:49:38 2013 +0200 description: lib-index: Don't unnecessarily update dovecot.index again after log rotation. diffstat: src/lib-index/mail-index-sync.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r d3cf06639864 -r 76f576fc28dc src/lib-index/mail-index-sync.c --- a/src/lib-index/mail-index-sync.c Sun Feb 24 09:16:31 2013 +0200 +++ b/src/lib-index/mail-index-sync.c Sun Feb 24 10:49:38 2013 +0200 @@ -760,6 +760,11 @@ { uint32_t log_diff; + if (index->last_read_log_file_seq != index->map->hdr.log_file_seq) { + /* we recently just rotated the log and rewrote index */ + return FALSE; + } + log_diff = index->map->hdr.log_file_tail_offset - index->last_read_log_file_tail_offset; if (log_diff > MAIL_INDEX_MAX_WRITE_BYTES || From dovecot at dovecot.org Sun Feb 24 11:58:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 11:58:58 +0200 Subject: dovecot-2.2: Avoid overflow error from clang -fsanitize=integer. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/11858b3dbd84 changeset: 15906:11858b3dbd84 user: Timo Sirainen date: Sun Feb 24 10:50:35 2013 +0200 description: Avoid overflow error from clang -fsanitize=integer. diffstat: src/lib/istream-crlf.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 76f576fc28dc -r 11858b3dbd84 src/lib/istream-crlf.c --- a/src/lib/istream-crlf.c Sun Feb 24 10:49:38 2013 +0200 +++ b/src/lib/istream-crlf.c Sun Feb 24 10:50:35 2013 +0200 @@ -144,7 +144,7 @@ stream->w_buffer[dest++] = data[0]; } - diff = -1; + diff = 1; for (i = 1; i < size && dest < stream->buffer_size; i++) { if (data[i] == '\r') { if (data[i-1] != '\r') @@ -159,7 +159,7 @@ stream->w_buffer[dest++] = data[i]; } - cstream->pending_cr = data[i+diff] == '\r'; + cstream->pending_cr = data[i-diff] == '\r'; i_stream_skip(stream->parent, i); ret = dest - stream->pos; From dovecot at dovecot.org Sun Feb 24 11:58:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 11:58:58 +0200 Subject: dovecot-2.2: seq_range_array_add(): Fixed handling sequence rang... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/db0ada89b81a changeset: 15907:db0ada89b81a user: Timo Sirainen date: Sun Feb 24 11:54:00 2013 +0200 description: seq_range_array_add(): Fixed handling sequence ranges that contain zeros. diffstat: src/lib/seq-range-array.c | 24 ++++++++++++------------ src/lib/test-seq-range-array.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 12 deletions(-) diffs (91 lines): diff -r 11858b3dbd84 -r db0ada89b81a src/lib/seq-range-array.c --- a/src/lib/seq-range-array.c Sun Feb 24 10:50:35 2013 +0200 +++ b/src/lib/seq-range-array.c Sun Feb 24 11:54:00 2013 +0200 @@ -48,22 +48,22 @@ } /* quick checks */ - if (data[count-1].seq2 == seq-1) { - /* grow last range */ - data[count-1].seq2 = seq; - return FALSE; - } if (data[count-1].seq2 < seq) { - array_append(array, &value, 1); - return FALSE; - } - if (data[0].seq1 == seq+1) { - /* grow down first range */ - data[0].seq1 = seq; + if (data[count-1].seq2 == seq-1) { + /* grow last range */ + data[count-1].seq2 = seq; + } else { + array_append(array, &value, 1); + } return FALSE; } if (data[0].seq1 > seq) { - array_insert(array, 0, &value, 1); + if (data[0].seq1-1 == seq) { + /* grow down first range */ + data[0].seq1 = seq; + } else { + array_insert(array, 0, &value, 1); + } return FALSE; } diff -r 11858b3dbd84 -r db0ada89b81a src/lib/test-seq-range-array.c --- a/src/lib/test-seq-range-array.c Sun Feb 24 10:50:35 2013 +0200 +++ b/src/lib/test-seq-range-array.c Sun Feb 24 11:54:00 2013 +0200 @@ -6,6 +6,41 @@ #include +static void +boundaries_permute(uint32_t *input, unsigned int i, unsigned int count) +{ + ARRAY_TYPE(seq_range) range; + const struct seq_range *seqs; + unsigned int seqs_count; + uint32_t tmp; + unsigned int j; + + if (i+1 < count) { + for (j = i; j < count; j++) { + tmp = input[i]; input[i] = input[j]; input[j] = tmp; + boundaries_permute(input, i+1, count); + tmp = input[i]; input[i] = input[j]; input[j] = tmp; + } + return; + } + t_array_init(&range, 4); + for (i = 0; i < count; i++) + seq_range_array_add(&range, input[i]); + seqs = array_get(&range, &seqs_count); + test_assert(seqs_count == 2); + test_assert(seqs[0].seq1 == 0); + test_assert(seqs[0].seq2 == 1); + test_assert(seqs[1].seq1 == (uint32_t)-2); + test_assert(seqs[1].seq2 == (uint32_t)-1); +} + +static void test_seq_range_array_add_boundaries(void) +{ + static uint32_t input[] = { 0, 1, (uint32_t)-2, (uint32_t)-1 }; + + boundaries_permute(input, 0, N_ELEMENTS(input)); +} + static void test_seq_range_array_add_merge(void) { ARRAY_TYPE(seq_range) range; @@ -169,6 +204,7 @@ void test_seq_range_array(void) { + test_seq_range_array_add_boundaries(); test_seq_range_array_add_merge(); test_seq_range_array_invert(); test_seq_range_array_have_common(); From dovecot at dovecot.org Sun Feb 24 11:58:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 11:58:58 +0200 Subject: dovecot-2.2: test-json-parser: Don't access memory out of bounds. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/573682b34a76 changeset: 15908:573682b34a76 user: Timo Sirainen date: Sun Feb 24 11:55:07 2013 +0200 description: test-json-parser: Don't access memory out of bounds. diffstat: src/lib/test-json-parser.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (19 lines): diff -r db0ada89b81a -r 573682b34a76 src/lib/test-json-parser.c --- a/src/lib/test-json-parser.c Sun Feb 24 11:54:00 2013 +0200 +++ b/src/lib/test-json-parser.c Sun Feb 24 11:55:07 2013 +0200 @@ -128,11 +128,13 @@ test_istream_set_size(input, i); for (;;) { - if (json_output[pos].type == (enum json_type)TYPE_SKIP) { + if (pos < N_ELEMENTS(json_output) && + json_output[pos].type == (enum json_type)TYPE_SKIP) { json_parse_skip_next(parser); pos++; continue; - } else if (json_output[pos].type != (enum json_type)TYPE_STREAM) { + } else if (pos == N_ELEMENTS(json_output) || + json_output[pos].type != (enum json_type)TYPE_STREAM) { ret = json_parse_next(parser, &type, &value); } else { ret = jsoninput != NULL ? 1 : From dovecot at dovecot.org Sun Feb 24 11:58:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 11:58:58 +0200 Subject: dovecot-2.2: Avoid under/overflows in unsigned integer calculati... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f74bf0521d69 changeset: 15909:f74bf0521d69 user: Timo Sirainen date: Sun Feb 24 11:58:46 2013 +0200 description: Avoid under/overflows in unsigned integer calculations. diffstat: src/lib/str-find.c | 10 +++++----- src/lib/test-bsearch-insert-pos.c | 2 +- src/lib/time-util.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diffs (58 lines): diff -r 573682b34a76 -r f74bf0521d69 src/lib/str-find.c --- a/src/lib/str-find.c Sun Feb 24 11:55:07 2013 +0200 +++ b/src/lib/str-find.c Sun Feb 24 11:58:46 2013 +0200 @@ -37,7 +37,7 @@ suffixes[len_1] = ctx->key_len; g = len_1; - for (i = ctx->key_len - 2; i >= 0; i--) { + for (i = (int)ctx->key_len - 2; i >= 0; i--) { if (i > g && (int)suffixes[i + len_1 - f] < i - g) suffixes[i] = suffixes[i + len_1 - f]; else { @@ -53,9 +53,8 @@ static void init_goodtab(struct str_find_context *ctx) { - unsigned int len_1 = ctx->key_len - 1; - unsigned int j, *suffixes; - int i; + unsigned int *suffixes; + int j, i, len_1 = ctx->key_len - 1; suffixes = t_buffer_get(sizeof(*suffixes) * ctx->key_len); init_suffixes(ctx, suffixes); @@ -153,7 +152,8 @@ i--; } - bad_value = ctx->badtab[data[i + j]] + i + 1 - key_len; + bad_value = (int)(ctx->badtab[data[i + j]] + i + 1) - + (int)key_len; j += I_MAX(ctx->goodtab[i], bad_value); } i_assert(j <= size); diff -r 573682b34a76 -r f74bf0521d69 src/lib/test-bsearch-insert-pos.c --- a/src/lib/test-bsearch-insert-pos.c Sun Feb 24 11:55:07 2013 +0200 +++ b/src/lib/test-bsearch-insert-pos.c Sun Feb 24 11:58:46 2013 +0200 @@ -5,7 +5,7 @@ static int cmp_uint(const unsigned int *i1, const unsigned int *i2) { - return *i1 - *i2; + return (int)*i1 - (int)*i2; } void test_bsearch_insert_pos(void) diff -r 573682b34a76 -r f74bf0521d69 src/lib/time-util.c --- a/src/lib/time-util.c Sun Feb 24 11:55:07 2013 +0200 +++ b/src/lib/time-util.c Sun Feb 24 11:58:46 2013 +0200 @@ -37,7 +37,7 @@ secs--; usecs += 1000000; } - return ((long long)secs * 1000000ULL) + usecs; + return ((long long)secs * 1000000LL) + usecs; } const char *t_strflocaltime(const char *fmt, time_t t) From dovecot at dovecot.org Sun Feb 24 14:58:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 14:58:46 +0200 Subject: dovecot-2.2: lib-storage: If mail saving is cancelled, don't che... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b787cf83bca8 changeset: 15910:b787cf83bca8 user: Timo Sirainen date: Sun Feb 24 14:58:32 2013 +0200 description: lib-storage: If mail saving is cancelled, don't check that all the input was read. diffstat: src/lib-storage/index/index-mail.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diffs (43 lines): diff -r f74bf0521d69 -r b787cf83bca8 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Sun Feb 24 11:58:46 2013 +0200 +++ b/src/lib-storage/index/index-mail.c Sun Feb 24 14:58:32 2013 +0200 @@ -802,8 +802,9 @@ (void)index_mail_cache_sent_date(mail); } -static int index_mail_parse_body_finish(struct index_mail *mail, - enum index_cache_field field) +static int +index_mail_parse_body_finish(struct index_mail *mail, + enum index_cache_field field, bool success) { struct istream *parser_input = mail->data.parser_input; int ret; @@ -820,7 +821,8 @@ parser_input->stream_errno == EPIPE) { /* EPIPE = input already closed. allow the caller to decide if that is an error or not. */ - i_assert(i_stream_read(parser_input) == -1 && + i_assert(!success || + i_stream_read(parser_input) == -1 && !i_stream_have_bytes_left(parser_input)); } else { errno = parser_input->stream_errno; @@ -897,7 +899,7 @@ *null_message_part_header_callback, (void *)NULL); } ret = index_mail_stream_check_failure(mail); - if (index_mail_parse_body_finish(mail, field) < 0) + if (index_mail_parse_body_finish(mail, field, TRUE) < 0) ret = -1; i_stream_seek(data->stream, old_offset); @@ -1693,7 +1695,7 @@ mail->data.save_bodystructure_body = FALSE; mail->data.parsed_bodystructure = TRUE; - (void)index_mail_parse_body_finish(mail, 0); + (void)index_mail_parse_body_finish(mail, 0, success); } static void index_mail_drop_recent_flag(struct mail *mail) From dovecot at dovecot.org Sun Feb 24 15:00:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 15:00:20 +0200 Subject: dovecot-2.2: imap: Added assert+comment to give easier to unders... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b0682d64a990 changeset: 15911:b0682d64a990 user: Timo Sirainen date: Sun Feb 24 14:59:54 2013 +0200 description: imap: Added assert+comment to give easier to understand error. diffstat: src/imap/cmd-append.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r b787cf83bca8 -r b0682d64a990 src/imap/cmd-append.c --- a/src/imap/cmd-append.c Sun Feb 24 14:58:32 2013 +0200 +++ b/src/imap/cmd-append.c Sun Feb 24 14:59:54 2013 +0200 @@ -230,6 +230,9 @@ client_send_storage_error(cmd, ctx->storage); ret = -1; } else { + /* all the input must be consumed, so istream-chain's read() + unreferences the stream and we can free its parent mail */ + i_assert(!i_stream_have_bytes_left(mpresult.input)); ret = 0; } imap_msgpart_url_free(&mpurl); From dovecot at dovecot.org Sun Feb 24 15:00:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 15:00:20 +0200 Subject: dovecot-2.2: Avoid unsigned integer overflows. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/94ebc333c47a changeset: 15912:94ebc333c47a user: Timo Sirainen date: Sun Feb 24 15:00:13 2013 +0200 description: Avoid unsigned integer overflows. diffstat: src/imap/imap-commands-util.c | 4 +++- src/lib-index/mail-index-util.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diffs (26 lines): diff -r b0682d64a990 -r 94ebc333c47a src/imap/imap-commands-util.c --- a/src/imap/imap-commands-util.c Sun Feb 24 14:59:54 2013 +0200 +++ b/src/imap/imap-commands-util.c Sun Feb 24 15:00:13 2013 +0200 @@ -326,7 +326,9 @@ void msgset_generator_next(struct msgset_generator_context *ctx, uint32_t uid) { - if (uid != ctx->last_uid+1) { + i_assert(uid > 0); + + if (uid-1 != ctx->last_uid) { if (ctx->first_uid == 0) ; else if (ctx->first_uid == ctx->last_uid) diff -r b0682d64a990 -r 94ebc333c47a src/lib-index/mail-index-util.c --- a/src/lib-index/mail-index-util.c Sun Feb 24 14:59:54 2013 +0200 +++ b/src/lib-index/mail-index-util.c Sun Feb 24 15:00:13 2013 +0200 @@ -106,7 +106,7 @@ static int mail_index_seq_record_cmp(const uint32_t *key_seq, const uint32_t *data_seq) { - return *key_seq - *data_seq; + return (int)*key_seq - (int)*data_seq; } bool mail_index_seq_array_lookup(const ARRAY_TYPE(seq_array) *array, From dovecot at dovecot.org Sun Feb 24 15:02:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 15:02:57 +0200 Subject: dovecot-2.2: o_stream_send_istream(): Fixed copying when [io]str... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2747055fc91b changeset: 15913:2747055fc91b user: Timo Sirainen date: Sun Feb 24 15:02:44 2013 +0200 description: o_stream_send_istream(): Fixed copying when [io]streams neither have usable fds. diffstat: src/lib/ostream-file.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 94ebc333c47a -r 2747055fc91b src/lib/ostream-file.c --- a/src/lib/ostream-file.c Sun Feb 24 15:00:13 2013 +0200 +++ b/src/lib/ostream-file.c Sun Feb 24 15:02:44 2013 +0200 @@ -873,7 +873,8 @@ foutstream->no_sendfile = TRUE; } - same_stream = i_stream_get_fd(instream) == foutstream->fd; + same_stream = i_stream_get_fd(instream) == foutstream->fd && + foutstream->fd != -1; return io_stream_copy_stream(outstream, instream, same_stream); } From dovecot at dovecot.org Sun Feb 24 15:53:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 15:53:09 +0200 Subject: dovecot-2.1: lib-storage: Fixed \Recent flag race conditions. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cd413ab7aeb3 changeset: 14922:cd413ab7aeb3 user: Timo Sirainen date: Sun Feb 24 15:50:26 2013 +0200 description: lib-storage: Fixed \Recent flag race conditions. The \Recent flags should only be set while locked within mail_index_sync_begin()..commit(). The following view syncing syncs only up to how far the index was synced, so it won't see any new messages that haven't yet been assigned a \Recent flag. diffstat: src/lib-storage/index/index-status.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diffs (23 lines): diff -r e33fe1a7bb89 -r cd413ab7aeb3 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Fri Feb 22 15:49:35 2013 +0200 +++ b/src/lib-storage/index/index-status.c Sun Feb 24 15:50:26 2013 +0200 @@ -48,9 +48,16 @@ hdr = mail_index_get_header(box->view); status_r->messages = hdr->messages_count; if ((items & STATUS_RECENT) != 0) { - /* make sure recent count is set, in case syncing hasn't - been done yet */ - index_sync_update_recent_count(box); + if ((box->flags & MAILBOX_FLAG_DROP_RECENT) != 0) { + /* recent flags are set and dropped by the previous + sync while index was locked. if we updated the + recent flags here we'd have a race condition. */ + i_assert(box->synced); + } else { + /* make sure recent count is set, in case we haven't + synced yet */ + index_sync_update_recent_count(box); + } status_r->recent = index_mailbox_get_recent_count(box); i_assert(status_r->recent <= status_r->messages); } From dovecot at dovecot.org Sun Feb 24 15:53:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 15:53:09 +0200 Subject: dovecot-2.1: lib-storage: Fixed setting \Recent flags for sessio... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/10c1eb4ddef2 changeset: 14923:10c1eb4ddef2 user: Timo Sirainen date: Sun Feb 24 15:52:57 2013 +0200 description: lib-storage: Fixed setting \Recent flags for sessions that didn't drop them. If another session wasn't dropping the \Recent flags, no new mails were getting them unless the mailbox was reopened. diffstat: src/lib-storage/index/index-storage.h | 2 +- src/lib-storage/index/index-sync.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diffs (26 lines): diff -r cd413ab7aeb3 -r 10c1eb4ddef2 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Sun Feb 24 15:50:26 2013 +0200 +++ b/src/lib-storage/index/index-storage.h Sun Feb 24 15:52:57 2013 +0200 @@ -37,7 +37,7 @@ struct mail_cache_field *cache_fields; ARRAY_TYPE(seq_range) recent_flags; - uint32_t recent_flags_prev_uid; + uint32_t recent_flags_prev_uid, recent_flags_last_check_nextuid; uint32_t recent_flags_count; uint32_t vsize_hdr_ext_id; diff -r cd413ab7aeb3 -r 10c1eb4ddef2 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Sun Feb 24 15:50:26 2013 +0200 +++ b/src/lib-storage/index/index-sync.c Sun Feb 24 15:52:57 2013 +0200 @@ -348,7 +348,9 @@ uint32_t seq1, seq2; hdr = mail_index_get_header(box->view); - if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) { + if (hdr->first_recent_uid > ibox->recent_flags_prev_uid || + hdr->next_uid > ibox->recent_flags_last_check_nextuid) { + ibox->recent_flags_last_check_nextuid = hdr->next_uid; mail_index_lookup_seq_range(box->view, hdr->first_recent_uid, hdr->next_uid, From dovecot at dovecot.org Sun Feb 24 16:02:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 16:02:57 +0200 Subject: dovecot-2.2: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/12f12add18d2 changeset: 15914:12f12add18d2 user: Timo Sirainen date: Sun Feb 24 15:26:53 2013 +0200 description: Compiler warning fix. diffstat: src/lib-storage/index/index-mail.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 2747055fc91b -r 12f12add18d2 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Sun Feb 24 15:02:44 2013 +0200 +++ b/src/lib-storage/index/index-mail.c Sun Feb 24 15:26:53 2013 +0200 @@ -822,8 +822,8 @@ /* EPIPE = input already closed. allow the caller to decide if that is an error or not. */ i_assert(!success || - i_stream_read(parser_input) == -1 && - !i_stream_have_bytes_left(parser_input)); + (i_stream_read(parser_input) == -1 && + !i_stream_have_bytes_left(parser_input))); } else { errno = parser_input->stream_errno; mail_storage_set_critical(mail->mail.mail.box->storage, From dovecot at dovecot.org Sun Feb 24 16:02:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 16:02:57 +0200 Subject: dovecot-2.2: imap: Don't leak mailboxes on CATENATE errors. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/514b8fc1e278 changeset: 15915:514b8fc1e278 user: Timo Sirainen date: Sun Feb 24 16:02:47 2013 +0200 description: imap: Don't leak mailboxes on CATENATE errors. diffstat: src/imap/cmd-append.c | 49 +++++++++++++++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 20 deletions(-) diffs (87 lines): diff -r 12f12add18d2 -r 514b8fc1e278 src/imap/cmd-append.c --- a/src/imap/cmd-append.c Sun Feb 24 15:26:53 2013 +0200 +++ b/src/imap/cmd-append.c Sun Feb 24 16:02:47 2013 +0200 @@ -156,31 +156,15 @@ } static int -cmd_append_catenate_url(struct client_command_context *cmd, const char *caturl) +cmd_append_catenate_mpurl(struct client_command_context *cmd, + const char *caturl, struct imap_msgpart_url *mpurl) { struct cmd_append_context *ctx = cmd->context; - struct imap_msgpart_url *mpurl; struct imap_msgpart_open_result mpresult; uoff_t newsize; const char *error; int ret; - if (ctx->failed) - return -1; - - ret = imap_msgpart_url_parse(cmd->client->user, cmd->client->mailbox, - caturl, &mpurl, &error); - if (ret < 0) { - client_send_storage_error(cmd, ctx->storage); - return -1; - } - if (ret == 0) { - /* invalid url, abort */ - client_send_tagline(cmd, - t_strdup_printf("NO [BADURL %s] %s.", caturl, error)); - return -1; - } - /* catenate URL */ ret = imap_msgpart_url_read_part(mpurl, &mpresult, &error); if (ret < 0) { @@ -195,7 +179,6 @@ } if (mpresult.size == 0) { /* empty input */ - imap_msgpart_url_free(&mpurl); return 0; } @@ -203,7 +186,6 @@ if (newsize < ctx->cat_msg_size) { client_send_tagline(cmd, "NO [TOOBIG] Composed message grows too big."); - imap_msgpart_url_free(&mpurl); return -1; } @@ -235,6 +217,33 @@ i_assert(!i_stream_have_bytes_left(mpresult.input)); ret = 0; } + return ret; +} + +static int +cmd_append_catenate_url(struct client_command_context *cmd, const char *caturl) +{ + struct cmd_append_context *ctx = cmd->context; + struct imap_msgpart_url *mpurl; + const char *error; + int ret; + + if (ctx->failed) + return -1; + + ret = imap_msgpart_url_parse(cmd->client->user, cmd->client->mailbox, + caturl, &mpurl, &error); + if (ret < 0) { + client_send_storage_error(cmd, ctx->storage); + return -1; + } + if (ret == 0) { + /* invalid url, abort */ + client_send_tagline(cmd, + t_strdup_printf("NO [BADURL %s] %s.", caturl, error)); + return -1; + } + ret = cmd_append_catenate_mpurl(cmd, caturl, mpurl); imap_msgpart_url_free(&mpurl); return ret; } From dovecot at dovecot.org Sun Feb 24 16:15:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 16:15:35 +0200 Subject: dovecot-2.2: lib-settings: Parse block names {} case-insensitively. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a4f82af20821 changeset: 15916:a4f82af20821 user: Timo Sirainen date: Sun Feb 24 16:15:23 2013 +0200 description: lib-settings: Parse block names {} case-insensitively. This fixes namespace { mailbox foo { .. } } settings when they go through environment and get uppercased. diffstat: src/lib-settings/settings-parser.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diffs (27 lines): diff -r 514b8fc1e278 -r a4f82af20821 src/lib-settings/settings-parser.c --- a/src/lib-settings/settings-parser.c Sun Feb 24 16:02:47 2013 +0200 +++ b/src/lib-settings/settings-parser.c Sun Feb 24 16:15:23 2013 +0200 @@ -209,7 +209,13 @@ ctx->set_pool = set_pool; ctx->parser_pool = parser_pool; ctx->flags = flags; - hash_table_create(&ctx->links, ctx->parser_pool, 0, str_hash, strcmp); + /* use case-insensitive comparisons. this is mainly because settings + may go through environment variables where their keys get + uppercased. of course the alternative would be to not uppercase + environment. probably doesn't make much difference which way is + chosen. */ + hash_table_create(&ctx->links, ctx->parser_pool, 0, + strcase_hash, strcasecmp); ctx->root_count = count; ctx->roots = p_new(ctx->parser_pool, struct setting_link, count); @@ -1778,7 +1784,7 @@ } hash_table_create(&new_ctx->links, new_ctx->parser_pool, 0, - str_hash, strcmp); + strcase_hash, strcasecmp); iter = hash_table_iterate_init(old_ctx->links); while (hash_table_iterate(iter, old_ctx->links, &key, &value)) { From dovecot at dovecot.org Sun Feb 24 16:33:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 16:33:35 +0200 Subject: dovecot-2.2: lib-storage: Added MAIL_FETCH_REFCOUNT for getting ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5e0c1ecad4a5 changeset: 15917:5e0c1ecad4a5 user: Timo Sirainen date: Sun Feb 24 16:33:24 2013 +0200 description: lib-storage: Added MAIL_FETCH_REFCOUNT for getting mail's reference count. This is useful only for backends where mailbox_copy() increases the refcount. With maildir&sdbox it can be looked up from the file's link count. With mdbox the refcount is stored in the map index. Other formats don't currently implement this. diffstat: src/lib-storage/index/dbox-multi/mdbox-mail.c | 29 +++++++++++++++++++++++++- src/lib-storage/index/dbox-single/sdbox-mail.c | 28 ++++++++++++++++++++++++- src/lib-storage/index/index-mail.c | 1 + src/lib-storage/index/maildir/maildir-mail.c | 7 ++++++ src/lib-storage/mail-storage.h | 3 +- 5 files changed, 65 insertions(+), 3 deletions(-) diffs (139 lines): diff -r a4f82af20821 -r 5e0c1ecad4a5 src/lib-storage/index/dbox-multi/mdbox-mail.c --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c Sun Feb 24 16:15:23 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c Sun Feb 24 16:33:24 2013 +0200 @@ -168,6 +168,33 @@ return 0; } +static int +mdbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field, + const char **value_r) +{ + struct dbox_mail *mail = (struct dbox_mail *)_mail; + struct mdbox_mailbox *mbox = + (struct mdbox_mailbox *)_mail->transaction->box; + struct mdbox_map_mail_index_record rec; + uint32_t map_uid; + uint16_t refcount; + + switch (field) { + case MAIL_FETCH_REFCOUNT: + if (mdbox_mail_lookup(mbox, _mail->transaction->view, + _mail->seq, &map_uid) < 0) + return -1; + if (mdbox_map_lookup_full(mbox->storage->map, map_uid, + &rec, &refcount) < 0) + return -1; + *value_r = p_strdup_printf(mail->imail.mail.data_pool, "%u", + refcount); + return 0; + default: + return dbox_mail_get_special(_mail, field, value_r); + } +} + static void mdbox_mail_update_flags(struct mail *mail, enum modify_type modify_type, enum mail_flags flags) @@ -208,7 +235,7 @@ index_mail_get_header_stream, dbox_mail_get_stream, index_mail_get_binary_stream, - dbox_mail_get_special, + mdbox_mail_get_special, index_mail_get_real_mail, mdbox_mail_update_flags, index_mail_update_keywords, diff -r a4f82af20821 -r 5e0c1ecad4a5 src/lib-storage/index/dbox-single/sdbox-mail.c --- a/src/lib-storage/index/dbox-single/sdbox-mail.c Sun Feb 24 16:15:23 2013 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-mail.c Sun Feb 24 16:33:24 2013 +0200 @@ -61,6 +61,32 @@ } } +static int +sdbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field, + const char **value_r) +{ + struct dbox_mail *mail = (struct dbox_mail *)_mail; + struct stat st; + + switch (field) { + case MAIL_FETCH_REFCOUNT: + if (sdbox_mail_file_set(mail) < 0) + return -1; + + _mail->transaction->stats.fstat_lookup_count++; + if (dbox_file_stat(mail->open_file, &st) < 0) { + if (errno == ENOENT) + mail_set_expunged(_mail); + return -1; + } + *value_r = p_strdup_printf(mail->imail.mail.data_pool, "%lu", + (unsigned long)st.st_nlink); + return 0; + default: + return dbox_mail_get_special(_mail, field, value_r); + } +} + int sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r, struct dbox_file **file_r) { @@ -118,7 +144,7 @@ index_mail_get_header_stream, dbox_mail_get_stream, index_mail_get_binary_stream, - dbox_mail_get_special, + sdbox_mail_get_special, index_mail_get_real_mail, index_mail_update_flags, index_mail_update_keywords, diff -r a4f82af20821 -r 5e0c1ecad4a5 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Sun Feb 24 16:15:23 2013 +0200 +++ b/src/lib-storage/index/index-mail.c Sun Feb 24 16:33:24 2013 +0200 @@ -1189,6 +1189,7 @@ case MAIL_FETCH_GUID: case MAIL_FETCH_HEADER_MD5: case MAIL_FETCH_POP3_ORDER: + case MAIL_FETCH_REFCOUNT: *value_r = ""; return 0; case MAIL_FETCH_MAILBOX_NAME: diff -r a4f82af20821 -r 5e0c1ecad4a5 src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Sun Feb 24 16:15:23 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-mail.c Sun Feb 24 16:33:24 2013 +0200 @@ -475,6 +475,7 @@ struct index_mail *mail = (struct index_mail *)_mail; struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box; const char *path, *fname = NULL, *end, *guid, *uidl, *order; + struct stat st; switch (field) { case MAIL_FETCH_GUID: @@ -559,6 +560,12 @@ *value_r = p_strdup(mail->mail.data_pool, order); } return 0; + case MAIL_FETCH_REFCOUNT: + if (maildir_mail_stat(_mail, &st) < 0) + return -1; + *value_r = p_strdup_printf(mail->mail.data_pool, "%lu", + (unsigned long)st.st_nlink); + return 0; default: return index_mail_get_special(_mail, field, value_r); } diff -r a4f82af20821 -r 5e0c1ecad4a5 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Sun Feb 24 16:15:23 2013 +0200 +++ b/src/lib-storage/mail-storage.h Sun Feb 24 16:33:24 2013 +0200 @@ -153,7 +153,8 @@ MAIL_FETCH_MAILBOX_NAME = 0x00080000, MAIL_FETCH_SEARCH_RELEVANCY = 0x00100000, MAIL_FETCH_GUID = 0x00200000, - MAIL_FETCH_POP3_ORDER = 0x00400000 + MAIL_FETCH_POP3_ORDER = 0x00400000, + MAIL_FETCH_REFCOUNT = 0x00800000 }; enum mailbox_transaction_flags { From dovecot at dovecot.org Sun Feb 24 16:43:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 16:43:34 +0200 Subject: dovecot-2.2: lazy-expunge: If lazy_expunge_only_last_instance is... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5c31615ce111 changeset: 15918:5c31615ce111 user: Timo Sirainen date: Sun Feb 24 16:43:28 2013 +0200 description: lazy-expunge: If lazy_expunge_only_last_instance is set, copy only last instances of mails. Requires storage backend to support refcounts. diffstat: src/plugins/lazy-expunge/lazy-expunge-plugin.c | 98 ++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) diffs (171 lines): diff -r 5e0c1ecad4a5 -r 5c31615ce111 src/plugins/lazy-expunge/lazy-expunge-plugin.c --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Sun Feb 24 16:33:24 2013 +0200 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Sun Feb 24 16:43:28 2013 +0200 @@ -4,6 +4,7 @@ #include "ioloop.h" #include "array.h" #include "str.h" +#include "hash.h" #include "seq-range-array.h" #include "mkdir-parents.h" #include "mail-storage-private.h" @@ -32,6 +33,7 @@ struct mail_namespace *lazy_ns; const char *env; + bool copy_only_last_instance; }; struct lazy_expunge_mailbox_list { @@ -47,7 +49,11 @@ struct mailbox *dest_box; struct mailbox_transaction_context *dest_trans; + pool_t pool; + HASH_TABLE(const char *, void *) guids; + bool failed; + bool copy_only_last_instance; }; const char *lazy_expunge_plugin_version = DOVECOT_ABI_VERSION; @@ -112,6 +118,74 @@ return box; } +static unsigned int +lazy_expunge_count_in_transaction(struct lazy_expunge_transaction *lt, + const char *guid) +{ + void *refcountp; + unsigned int refcount; + + if (lt->pool == NULL) { + lt->pool = pool_alloconly_create("lazy expunge transaction", + 1024); + hash_table_create(<->guids, lt->pool, 0, str_hash, strcmp); + } + + refcountp = hash_table_lookup(lt->guids, guid); + refcount = POINTER_CAST_TO(refcountp, unsigned int) + 1; + refcountp = POINTER_CAST(refcount); + if (refcount == 1) { + guid = p_strdup(lt->pool, guid); + hash_table_insert(lt->guids, guid, refcountp); + } else { + hash_table_update(lt->guids, guid, refcountp); + } + return refcount-1; +} + +static int lazy_expunge_mail_is_last_instace(struct mail *_mail) +{ + struct lazy_expunge_transaction *lt = + LAZY_EXPUNGE_CONTEXT(_mail->transaction); + const char *value; + unsigned long refcount; + + if (mail_get_special(_mail, MAIL_FETCH_REFCOUNT, &value) < 0) { + mail_storage_set_critical(_mail->box->storage, + "lazy_expunge: Couldn't lookup message's refcount"); + return -1; + } + if (*value == '\0') { + /* refcounts not supported by backend. assume all mails are + the last instance. */ + return 1; + } + if (str_to_ulong(value, &refcount) < 0) + i_panic("Invalid mail refcount number: %s", value); + if (refcount > 1) { + /* this probably isn't the last instance of the mail, but + it's possible that the same mail was copied to this mailbox + multiple times and we're deleting more than one instance + within this transaction. in those cases each expunge will + see the same refcount, so we need to adjust the refcount + by tracking the expunged message GUIDs. */ + if (mail_get_special(_mail, MAIL_FETCH_GUID, &value) < 0) { + mail_storage_set_critical(_mail->box->storage, + "lazy_expunge: Couldn't lookup message's GUID"); + return -1; + } + if (*value == '\0') { + /* GUIDs not supported by backend, but refcounts are? + not with our current backends. */ + mail_storage_set_critical(_mail->box->storage, + "lazy_expunge: Message unexpectedly has no GUID"); + return -1; + } + refcount -= lazy_expunge_count_in_transaction(lt, value); + } + return refcount <= 1 ? 1 : 0; +} + static void lazy_expunge_mail_expunge(struct mail *_mail) { struct mail_namespace *ns = _mail->box->list->ns; @@ -125,6 +199,7 @@ struct mailbox *real_box; struct mail_save_context *save_ctx; const char *error; + int ret; /* don't copy the mail if we're expunging from lazy_expunge namespace (even if it's via a virtual mailbox) */ @@ -135,6 +210,20 @@ return; } + if (lt->copy_only_last_instance) { + /* we want to copy only the last instance of the mail to + lazy_expunge namespace. other instances will be expunged + immediately. */ + if ((ret = lazy_expunge_mail_is_last_instace(_mail)) < 0) { + lt->failed = TRUE; + return; + } + if (ret == 0) { + mmail->super.expunge(_mail); + return; + } + } + if (lt->dest_box == NULL) { lt->dest_box = mailbox_open_or_create(luser->lazy_ns->list, _mail->box, &error); @@ -169,12 +258,15 @@ lazy_expunge_transaction_begin(struct mailbox *box, enum mailbox_transaction_flags flags) { + struct lazy_expunge_mail_user *luser = + LAZY_EXPUNGE_USER_CONTEXT(box->list->ns->user); union mailbox_module_context *mbox = LAZY_EXPUNGE_CONTEXT(box); struct mailbox_transaction_context *t; struct lazy_expunge_transaction *lt; t = mbox->super.transaction_begin(box, flags); lt = i_new(struct lazy_expunge_transaction, 1); + lt->copy_only_last_instance = luser->copy_only_last_instance; MODULE_CONTEXT_SET(t, lazy_expunge_mail_storage_module, lt); return t; @@ -186,6 +278,10 @@ mailbox_transaction_rollback(<->dest_trans); if (lt->dest_box != NULL) mailbox_free(<->dest_box); + if (hash_table_is_created(lt->guids)) + hash_table_destroy(<->guids); + if (lt->pool != NULL) + pool_unref(<->pool); i_free(lt); } @@ -349,6 +445,8 @@ user->vlast = &luser->module_ctx.super; v->deinit = lazy_expunge_user_deinit; luser->env = env; + luser->copy_only_last_instance = + mail_user_plugin_getenv(user, "lazy_expunge_only_last_instance") != NULL; MODULE_CONTEXT_SET(user, lazy_expunge_mail_user_module, luser); } else if (user->mail_debug) { From dovecot at dovecot.org Sun Feb 24 18:02:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 18:02:37 +0200 Subject: dovecot-2.2: dsync: Always skip alias namespaces. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f5fb1ca222e3 changeset: 15919:f5fb1ca222e3 user: Timo Sirainen date: Sun Feb 24 18:02:25 2013 +0200 description: dsync: Always skip alias namespaces. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 5c31615ce111 -r f5fb1ca222e3 src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Sun Feb 24 16:43:28 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Sun Feb 24 18:02:25 2013 +0200 @@ -16,6 +16,10 @@ { if (brain->sync_ns == ns) return TRUE; + if (ns->alias_for != NULL) { + /* always skip aliases */ + return FALSE; + } if (brain->sync_visible_namespaces) { if ((ns->flags & NAMESPACE_FLAG_HIDDEN) == 0) return TRUE; From dovecot at dovecot.org Sun Feb 24 18:19:52 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 18:19:52 +0200 Subject: dovecot-2.2: lmtp: Log a bit nicer message when client QUITs. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/df3da60fa137 changeset: 15920:df3da60fa137 user: Timo Sirainen date: Sun Feb 24 18:19:40 2013 +0200 description: lmtp: Log a bit nicer message when client QUITs. I did think about removing the connect and successful disconnect messages entirely, but these may be useful when debugging problems with MTA. diffstat: src/lmtp/client.c | 2 +- src/lmtp/client.h | 1 + src/lmtp/commands.c | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diffs (39 lines): diff -r f5fb1ca222e3 -r df3da60fa137 src/lmtp/client.c --- a/src/lmtp/client.c Sun Feb 24 18:02:25 2013 +0200 +++ b/src/lmtp/client.c Sun Feb 24 18:19:40 2013 +0200 @@ -190,7 +190,7 @@ client->state.session_id = p_strdup(client->state_pool, str_c(id)); } -static const char *client_remote_id(struct client *client) +const char *client_remote_id(struct client *client) { const char *addr; diff -r f5fb1ca222e3 -r df3da60fa137 src/lmtp/client.h --- a/src/lmtp/client.h Sun Feb 24 18:02:25 2013 +0200 +++ b/src/lmtp/client.h Sun Feb 24 18:19:40 2013 +0200 @@ -80,6 +80,7 @@ void client_io_reset(struct client *client); void client_state_reset(struct client *client); void client_state_set(struct client *client, const char *name); +const char *client_remote_id(struct client *client); void client_input_handle(struct client *client); int client_input_read(struct client *client); diff -r f5fb1ca222e3 -r df3da60fa137 src/lmtp/commands.c --- a/src/lmtp/commands.c Sun Feb 24 18:02:25 2013 +0200 +++ b/src/lmtp/commands.c Sun Feb 24 18:19:40 2013 +0200 @@ -585,7 +585,11 @@ int cmd_quit(struct client *client, const char *args ATTR_UNUSED) { - client_destroy(client, "221 2.0.0", "Client quit"); + client_send_line(client, "221 2.0.0 OK"); + /* don't log the (state name) for successful QUITs */ + i_info("Disconnect from %s: Successful quit", client_remote_id(client)); + client->disconnected = TRUE; + client_destroy(client, NULL, NULL); return -1; } From dovecot at dovecot.org Sun Feb 24 19:36:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 19:36:05 +0200 Subject: dovecot-2.2: doveadm: Renamed doveadm_proxy_port setting to dove... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/75d76f1b884d changeset: 15921:75d76f1b884d user: Timo Sirainen date: Sun Feb 24 19:35:39 2013 +0200 description: doveadm: Renamed doveadm_proxy_port setting to doveadm_port. There's still an alias for doveadm_proxy_port. diffstat: src/doveadm/doveadm-mail-server.c | 4 ++-- src/doveadm/doveadm-settings.c | 5 +++-- src/doveadm/doveadm-settings.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diffs (55 lines): diff -r df3da60fa137 -r 75d76f1b884d src/doveadm/doveadm-mail-server.c --- a/src/doveadm/doveadm-mail-server.c Sun Feb 24 18:19:40 2013 +0200 +++ b/src/doveadm/doveadm-mail-server.c Sun Feb 24 19:35:39 2013 +0200 @@ -182,7 +182,7 @@ *host_r = ctx->set->doveadm_socket_path; - if (ctx->set->doveadm_proxy_port == 0) + if (ctx->set->doveadm_port == 0) return 0; /* make sure we have an auth connection */ @@ -227,7 +227,7 @@ ret = -1; } else { *host_r = t_strdup_printf("%s:%u", proxy_host, - ctx->set->doveadm_proxy_port); + ctx->set->doveadm_port); } } pool_unref(&pool); diff -r df3da60fa137 -r 75d76f1b884d src/doveadm/doveadm-settings.c --- a/src/doveadm/doveadm-settings.c Sun Feb 24 18:19:40 2013 +0200 +++ b/src/doveadm/doveadm-settings.c Sun Feb 24 19:35:39 2013 +0200 @@ -58,7 +58,8 @@ DEF(SET_STR, mail_plugin_dir), DEF(SET_STR, doveadm_socket_path), DEF(SET_UINT, doveadm_worker_count), - DEF(SET_UINT, doveadm_proxy_port), + DEF(SET_UINT, doveadm_port), + { SET_ALIAS, "doveadm_proxy_port", 0, NULL }, DEF(SET_STR, doveadm_password), DEF(SET_STR, doveadm_allowed_commands), DEF(SET_STR, dsync_alt_char), @@ -76,7 +77,7 @@ .mail_plugin_dir = MODULEDIR, .doveadm_socket_path = "doveadm-server", .doveadm_worker_count = 0, - .doveadm_proxy_port = 0, + .doveadm_port = 0, .doveadm_password = "", .doveadm_allowed_commands = "", .dsync_alt_char = "_", diff -r df3da60fa137 -r 75d76f1b884d src/doveadm/doveadm-settings.h --- a/src/doveadm/doveadm-settings.h Sun Feb 24 18:19:40 2013 +0200 +++ b/src/doveadm/doveadm-settings.h Sun Feb 24 19:35:39 2013 +0200 @@ -8,7 +8,7 @@ const char *mail_plugin_dir; const char *doveadm_socket_path; unsigned int doveadm_worker_count; - unsigned int doveadm_proxy_port; + unsigned int doveadm_port; const char *doveadm_password; const char *doveadm_allowed_commands; const char *dsync_alt_char; From dovecot at dovecot.org Sun Feb 24 19:37:51 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 19:37:51 +0200 Subject: dovecot-2.2: doveadm: When connecting to doveadm socket without ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b2bc9dd5f8d9 changeset: 15922:b2bc9dd5f8d9 user: Timo Sirainen date: Sun Feb 24 19:37:45 2013 +0200 description: doveadm: When connecting to doveadm socket without :port, use doveadm_port setting. diffstat: src/doveadm/doveadm-util.c | 25 +++++++++++++++++++------ src/doveadm/doveadm-util.h | 2 ++ src/doveadm/server-connection.c | 3 ++- 3 files changed, 23 insertions(+), 7 deletions(-) diffs (83 lines): diff -r 75d76f1b884d -r b2bc9dd5f8d9 src/doveadm/doveadm-util.c --- a/src/doveadm/doveadm-util.c Sun Feb 24 19:35:39 2013 +0200 +++ b/src/doveadm/doveadm-util.c Sun Feb 24 19:37:45 2013 +0200 @@ -97,15 +97,21 @@ } static bool -parse_hostport(const char *str, const char **host_r, unsigned int *port_r) +parse_hostport(const char *str, unsigned int default_port, + const char **host_r, unsigned int *port_r) { const char *p; /* host:port */ p = strrchr(str, ':'); - if (p == NULL || str_to_uint(p+1, port_r) < 0) - return FALSE; - *host_r = t_strdup_until(str, p); + if (p == NULL && default_port != 0) { + *host_r = str; + *port_r = default_port; + } else { + if (p == NULL || str_to_uint(p+1, port_r) < 0) + return FALSE; + *host_r = t_strdup_until(str, p); + } /* there is any '/' character (unlikely to be found from host names), assume ':' is part of a file path */ @@ -114,7 +120,8 @@ return TRUE; } -int doveadm_connect(const char *path) +int doveadm_connect_with_default_port(const char *path, + unsigned int default_port) { struct stat st; const char *host; @@ -122,7 +129,8 @@ unsigned int port, ips_count; int fd, ret; - if (parse_hostport(path, &host, &port) && stat(path, &st) < 0) { + if (parse_hostport(path, default_port, &host, &port) && + stat(path, &st) < 0) { /* it's a host:port, connect via TCP */ ret = net_gethostbyname(host, &ips, &ips_count); if (ret != 0) { @@ -141,3 +149,8 @@ } return fd; } + +int doveadm_connect(const char *path) +{ + return doveadm_connect_with_default_port(path, 0); +} diff -r 75d76f1b884d -r b2bc9dd5f8d9 src/doveadm/doveadm-util.h --- a/src/doveadm/doveadm-util.h Sun Feb 24 19:35:39 2013 +0200 +++ b/src/doveadm/doveadm-util.h Sun Feb 24 19:37:45 2013 +0200 @@ -8,6 +8,8 @@ const char *unixdate2str(time_t timestamp); const char *doveadm_plugin_getenv(const char *name); int doveadm_connect(const char *path); +int doveadm_connect_with_default_port(const char *path, + unsigned int default_port); void doveadm_load_modules(void); void doveadm_unload_modules(void); diff -r 75d76f1b884d -r b2bc9dd5f8d9 src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Sun Feb 24 19:35:39 2013 +0200 +++ b/src/doveadm/server-connection.c Sun Feb 24 19:37:45 2013 +0200 @@ -317,7 +317,8 @@ conn = p_new(pool, struct server_connection, 1); conn->pool = pool; conn->server = server; - conn->fd = doveadm_connect(server->name); + conn->fd = doveadm_connect_with_default_port(server->name, + doveadm_settings->doveadm_port); net_set_nonblock(conn->fd, TRUE); conn->io = io_add(conn->fd, IO_READ, server_connection_input, conn); conn->input = i_stream_create_fd(conn->fd, MAX_INBUF_SIZE, FALSE); From dovecot at dovecot.org Sun Feb 24 19:39:13 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 19:39:13 +0200 Subject: dovecot-2.2: doveadm: If doveadm-server sends broken input, disc... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8e54e73bdade changeset: 15923:8e54e73bdade user: Timo Sirainen date: Sun Feb 24 19:38:27 2013 +0200 description: doveadm: If doveadm-server sends broken input, disconnect. diffstat: src/doveadm/server-connection.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diffs (32 lines): diff -r b2bc9dd5f8d9 -r 8e54e73bdade src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Sun Feb 24 19:37:45 2013 +0200 +++ b/src/doveadm/server-connection.c Sun Feb 24 19:38:27 2013 +0200 @@ -139,8 +139,11 @@ str = t_str_new(128); for (i = start = 0; i < size; i++) { if (data[i] == '\n') { - if (i != start) - i_error("doveadm server sent broken input"); + if (i != start) { + i_error("doveadm server sent broken print input"); + server_connection_destroy(&conn); + return; + } conn->state = SERVER_REPLY_STATE_RET; i_stream_skip(conn->input, i + 1); @@ -267,8 +270,12 @@ SERVER_CMD_REPLY_UNKNOWN_USER : SERVER_CMD_REPLY_FAIL; server_connection_callback(conn, reply); - } else - i_error("doveadm server sent broken input"); + } else { + i_error("doveadm server sent broken input " + "(expected cmd reply): %s", line); + server_connection_destroy(&conn); + break; + } if (conn->callback == NULL) { /* we're finished, close the connection */ server_connection_destroy(&conn); From dovecot at dovecot.org Sun Feb 24 19:39:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 19:39:58 +0200 Subject: dovecot-2.2: dsync: Added tcp:host[:port] target for syncing via... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/08edb5716823 changeset: 15924:08edb5716823 user: Timo Sirainen date: Sun Feb 24 19:39:52 2013 +0200 description: dsync: Added tcp:host[:port] target for syncing via doveadm-server. diffstat: src/doveadm/client-connection.c | 16 +--- src/doveadm/client-connection.h | 16 +++ src/doveadm/doveadm-mail.h | 2 + src/doveadm/dsync/doveadm-dsync.c | 175 ++++++++++++++++++++++++++++++++----- src/doveadm/server-connection.c | 5 + src/doveadm/server-connection.h | 2 + 6 files changed, 175 insertions(+), 41 deletions(-) diffs (truncated from 389 to 300 lines): diff -r 8e54e73bdade -r 08edb5716823 src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Sun Feb 24 19:38:27 2013 +0200 +++ b/src/doveadm/client-connection.c Sun Feb 24 19:39:52 2013 +0200 @@ -23,20 +23,6 @@ static void client_connection_input(struct client_connection *conn); -struct client_connection { - pool_t pool; - - int fd; - struct io *io; - struct istream *input; - struct ostream *output; - struct ip_addr local_ip, remote_ip; - const struct doveadm_settings *set; - - unsigned int handshaked:1; - unsigned int authenticated:1; -}; - static struct doveadm_mail_cmd_context * doveadm_mail_cmd_server_parse(const char *cmd_name, const struct doveadm_settings *set, @@ -119,6 +105,8 @@ const char *error; int ret; + ctx->conn = conn; + if (ctx->v.preinit != NULL) ctx->v.preinit(ctx); diff -r 8e54e73bdade -r 08edb5716823 src/doveadm/client-connection.h --- a/src/doveadm/client-connection.h Sun Feb 24 19:38:27 2013 +0200 +++ b/src/doveadm/client-connection.h Sun Feb 24 19:39:52 2013 +0200 @@ -1,6 +1,22 @@ #ifndef CLIENT_CONNECTION_H #define CLIENT_CONNECTION_H +#include "net.h" + +struct client_connection { + pool_t pool; + + int fd; + struct io *io; + struct istream *input; + struct ostream *output; + struct ip_addr local_ip, remote_ip; + const struct doveadm_settings *set; + + unsigned int handshaked:1; + unsigned int authenticated:1; +}; + struct client_connection *client_connection_create(int fd, int listen_fd); void client_connection_destroy(struct client_connection **conn); diff -r 8e54e73bdade -r 08edb5716823 src/doveadm/doveadm-mail.h --- a/src/doveadm/doveadm-mail.h Sun Feb 24 19:38:27 2013 +0200 +++ b/src/doveadm/doveadm-mail.h Sun Feb 24 19:39:52 2013 +0200 @@ -43,6 +43,8 @@ const char *const *args; /* args including -options */ const char *const *full_args; + /* connection via doveadm-server */ + struct client_connection *conn; const char *getopt_args; const struct doveadm_settings *set; diff -r 8e54e73bdade -r 08edb5716823 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Sun Feb 24 19:38:27 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Sun Feb 24 19:39:52 2013 +0200 @@ -10,6 +10,7 @@ #include "iostream-rawlog.h" #include "write-full.h" #include "str.h" +#include "strescape.h" #include "var-expand.h" #include "settings-parser.h" #include "master-service.h" @@ -20,6 +21,9 @@ #include "doveadm-settings.h" #include "doveadm-mail.h" #include "doveadm-print.h" +#include "doveadm-server.h" +#include "client-connection.h" +#include "server-connection.h" #include "dsync-brain.h" #include "dsync-ibc.h" #include "doveadm-dsync.h" @@ -33,6 +37,12 @@ #define DSYNC_COMMON_GETOPT_ARGS "+dEfl:m:n:Nr:Rs:" #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30 +enum dsync_run_type { + DSYNC_RUN_TYPE_LOCAL, + DSYNC_RUN_TYPE_STREAM, + DSYNC_RUN_TYPE_CMD +}; + struct dsync_cmd_context { struct doveadm_mail_cmd_context ctx; enum dsync_brain_sync_type sync_type; @@ -47,6 +57,10 @@ struct io *io_err; struct istream *err_stream; + enum dsync_run_type run_type; + struct server_connection *tcp_conn; + const char *error; + unsigned int lock_timeout; unsigned int lock:1; @@ -54,7 +68,6 @@ unsigned int default_replica_location:1; unsigned int backup:1; unsigned int reverse_backup:1; - unsigned int remote:1; unsigned int remote_user_prefix:1; }; @@ -423,15 +436,17 @@ ctx->namespace_prefix); } - if (!ctx->remote) + if (ctx->run_type == DSYNC_RUN_TYPE_LOCAL) dsync_ibc_init_pipe(&ibc, &ibc2); else { string_t *temp_prefix = t_str_new(64); mail_user_set_get_temp_prefix(temp_prefix, user->set); ibc = cmd_dsync_icb_stream_init(ctx, ctx->remote_name, str_c(temp_prefix)); - ctx->io_err = io_add(ctx->fd_err, IO_READ, - remote_error_input, ctx); + if (ctx->fd_err != -1) { + ctx->io_err = io_add(ctx->fd_err, IO_READ, + remote_error_input, ctx); + } } brain_flags = DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS; @@ -451,7 +466,7 @@ ctx->state_input == NULL ? "" : ctx->state_input); - if (!ctx->remote) { + if (ctx->run_type == DSYNC_RUN_TYPE_LOCAL) { if (cmd_dsync_run_local(ctx, user, brain, ibc2) < 0) ret = -1; } else { @@ -474,7 +489,7 @@ i_close_fd(&ctx->fd_out); i_close_fd(&ctx->fd_in); } - if (ctx->remote) + if (ctx->run_type == DSYNC_RUN_TYPE_CMD) cmd_dsync_wait_remote(ctx, &status); /* print any final errors after the process has died. not closing @@ -486,7 +501,7 @@ remote_errors_logged = ctx->err_stream->v_offset > 0; i_stream_destroy(&ctx->err_stream); } - if (ctx->remote) + if (ctx->run_type == DSYNC_RUN_TYPE_CMD) cmd_dsync_log_remote_status(status, remote_errors_logged); if (ctx->io_err != NULL) io_remove(&ctx->io_err); @@ -495,6 +510,109 @@ return ret; } +static void dsync_connected_callback(enum server_cmd_reply reply, void *context) +{ + struct dsync_cmd_context *ctx = context; + + switch (reply) { + case SERVER_CMD_REPLY_UNKNOWN_USER: + ctx->error = "Unknown user in remote"; + ctx->ctx.exit_code = EX_NOUSER; + break; + case SERVER_CMD_REPLY_FAIL: + ctx->error = "Failed to start dsync-server command"; + break; + case SERVER_CMD_REPLY_OK: + ctx->fd_in = ctx->fd_out = + dup(server_connection_get_fd(ctx->tcp_conn)); + if (ctx->fd_in == -1) + ctx->error = t_strdup_printf("dup() failed: %m"); + break; + case SERVER_CMD_REPLY_INTERNAL_FAILURE: + ctx->error = "Disconnected from remote"; + break; + default: + i_unreached(); + } + io_loop_stop(current_ioloop); +} + +static int dsync_connect_tcp(struct dsync_cmd_context *ctx, const char *target, + const char **error_r) +{ + struct doveadm_server *server; + struct server_connection *conn; + struct ioloop *ioloop; + string_t *cmd; + + server = p_new(ctx->ctx.pool, struct doveadm_server, 1); + server->name = p_strdup(ctx->ctx.pool, target); + p_array_init(&server->connections, ctx->ctx.pool, 1); + p_array_init(&server->queue, ctx->ctx.pool, 1); + + ioloop = io_loop_create(); + + if (server_connection_create(server, &conn) < 0) { + *error_r = "Couldn't create server connection"; + return -1; + } + + /* [] */ + cmd = t_str_new(256); + if (doveadm_debug) + str_append_c(cmd, 'D'); + str_append_c(cmd, '\t'); + str_append_tabescaped(cmd, ctx->ctx.cur_username); + str_append(cmd, "\tdsync-server\t-u"); + str_append_tabescaped(cmd, ctx->ctx.cur_username); + str_append_c(cmd, '\n'); + + ctx->tcp_conn = conn; + server_connection_cmd(conn, str_c(cmd), + dsync_connected_callback, ctx); + io_loop_run(ioloop); + ctx->tcp_conn = NULL; + + if (array_count(&server->connections) > 0) + server_connection_destroy(&conn); + io_loop_destroy(&ioloop); + + if (ctx->error != NULL) { + *error_r = ctx->error; + return -1; + } + ctx->run_type = DSYNC_RUN_TYPE_STREAM; + return 0; +} + +static int +parse_location(struct dsync_cmd_context *ctx, const char *location, + const char *const **remote_cmd_args_r, const char **error_r) +{ + if (strncmp(location, "tcp:", 4) == 0) { + /* TCP connection to remote dsync */ + ctx->remote_name = location+4; + return dsync_connect_tcp(ctx, ctx->remote_name, error_r); + } + + if (strncmp(location, "remote:", 7) == 0) { + /* this is a remote (ssh) command */ + ctx->remote_name = location+7; + } else if (strncmp(location, "remoteprefix:", 13) == 0) { + /* this is a remote (ssh) command with a "user\n" + prefix sent before dsync actually starts */ + ctx->remote_name = location+13; + ctx->remote_user_prefix = TRUE; + } else { + /* local with e.g. maildir:path */ + ctx->remote_name = NULL; + return 0; + } + *remote_cmd_args_r = + parse_ssh_location(ctx->remote_name, ctx->ctx.cur_username); + return 0; +} + static int cmd_dsync_prerun(struct doveadm_mail_cmd_context *_ctx, struct mail_storage_service_user *service_user, const char **error_r) @@ -509,7 +627,7 @@ ctx->fd_in = STDIN_FILENO; ctx->fd_out = STDOUT_FILENO; ctx->fd_err = -1; - ctx->remote = FALSE; + ctx->run_type = DSYNC_RUN_TYPE_LOCAL; ctx->remote_name = "remote"; if (ctx->default_replica_location) { @@ -536,29 +654,20 @@ } if (remote_cmd_args == NULL && ctx->local_location != NULL) { - if (strncmp(ctx->local_location, "remote:", 7) == 0) { - /* this is a remote (ssh) command */ - ctx->remote_name = ctx->local_location+7; - } else if (strncmp(ctx->local_location, "remoteprefix:", 13) == 0) { - /* this is a remote (ssh) command with a "user\n" From dovecot at dovecot.org Sun Feb 24 19:49:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 24 Feb 2013 19:49:06 +0200 Subject: dovecot-2.2: imap: Handle UID commands without a wrapper UID com... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/558b0b13779d changeset: 15925:558b0b13779d user: Timo Sirainen date: Sun Feb 24 19:48:55 2013 +0200 description: imap: Handle UID commands without a wrapper UID command. This avoids calling command hooks once for UID command and again for the real command. diffstat: src/imap/Makefile.am | 1 - src/imap/cmd-uid.c | 28 ---------------------------- src/imap/imap-client.c | 12 +++++++++++- src/imap/imap-commands.c | 1 - 4 files changed, 11 insertions(+), 31 deletions(-) diffs (76 lines): diff -r 08edb5716823 -r 558b0b13779d src/imap/Makefile.am --- a/src/imap/Makefile.am Sun Feb 24 19:39:52 2013 +0200 +++ b/src/imap/Makefile.am Sun Feb 24 19:48:55 2013 +0200 @@ -57,7 +57,6 @@ cmd-store.c \ cmd-subscribe.c \ cmd-thread.c \ - cmd-uid.c \ cmd-unselect.c \ cmd-unsubscribe.c \ cmd-urlfetch.c \ diff -r 08edb5716823 -r 558b0b13779d src/imap/cmd-uid.c --- a/src/imap/cmd-uid.c Sun Feb 24 19:39:52 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */ - -#include "imap-common.h" -#include "imap-commands.h" - -bool cmd_uid(struct client_command_context *cmd) -{ - struct command *command; - const char *cmd_name; - - /* UID */ - cmd_name = imap_parser_read_word(cmd->parser); - if (cmd_name == NULL) - return FALSE; - - command = command_find(t_strconcat("UID ", cmd_name, NULL)); - if (command == NULL) { - client_send_command_error(cmd, t_strconcat( - "Unknown UID command ", cmd_name, NULL)); - return TRUE; - } - - cmd->name = p_strconcat(cmd->pool, "UID ", cmd_name, NULL); - cmd->cmd_flags = command->flags; - cmd->func = command->func; - cmd->uid = TRUE; - return command_exec(cmd); -} diff -r 08edb5716823 -r 558b0b13779d src/imap/imap-client.c --- a/src/imap/imap-client.c Sun Feb 24 19:39:52 2013 +0200 +++ b/src/imap/imap-client.c Sun Feb 24 19:48:55 2013 +0200 @@ -794,7 +794,17 @@ cmd->name = imap_parser_read_word(cmd->parser); if (cmd->name == NULL) return FALSE; /* need more data */ - cmd->name = p_strdup(cmd->pool, cmd->name); + + /* UID commands are a special case. better to handle them + here. */ + if (!cmd->uid && strcasecmp(cmd->name, "UID") == 0) { + cmd->uid = TRUE; + cmd->name = imap_parser_read_word(cmd->parser); + if (cmd->name == NULL) + return FALSE; /* need more data */ + } + cmd->name = !cmd->uid ? p_strdup(cmd->pool, cmd->name) : + p_strconcat(cmd->pool, "UID ", cmd->name, NULL); imap_refresh_proctitle(); } diff -r 08edb5716823 -r 558b0b13779d src/imap/imap-commands.c --- a/src/imap/imap-commands.c Sun Feb 24 19:39:52 2013 +0200 +++ b/src/imap/imap-commands.c Sun Feb 24 19:48:55 2013 +0200 @@ -38,7 +38,6 @@ { "FETCH", cmd_fetch, COMMAND_FLAG_USES_SEQS }, { "SEARCH", cmd_search, COMMAND_FLAG_USES_SEQS }, { "STORE", cmd_store, COMMAND_FLAG_USES_SEQS }, - { "UID", cmd_uid, 0 }, { "UID COPY", cmd_copy, COMMAND_FLAG_BREAKS_SEQS }, { "UID FETCH", cmd_fetch, COMMAND_FLAG_BREAKS_SEQS }, { "UID SEARCH", cmd_search, COMMAND_FLAG_BREAKS_SEQS }, From dovecot at dovecot.org Mon Feb 25 09:07:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 09:07:20 +0200 Subject: dovecot-2.2: configure: Removed accidentally enabled clang -fsan... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5be9659a2738 changeset: 15926:5be9659a2738 user: Timo Sirainen date: Mon Feb 25 09:07:13 2013 +0200 description: configure: Removed accidentally enabled clang -fsanitize options for now. diffstat: configure.ac | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 558b0b13779d -r 5be9659a2738 configure.ac --- a/configure.ac Sun Feb 24 19:48:55 2013 +0200 +++ b/configure.ac Mon Feb 25 09:07:13 2013 +0200 @@ -290,7 +290,6 @@ AC_PROG_CXX # lucene plugin needs this AC_HEADER_STDC AC_C_INLINE -AC_C_TYPEOF AC_PROG_LIBTOOL AM_ICONV @@ -346,7 +345,8 @@ if test "$have_clang" = "yes"; then # clang specific options if test "$want_devel_checks" = "yes"; then - CFLAGS="$CFLAGS -fsanitize=address,integer,undefined -ftrapv" + # FIXME: enable once md[45], sha[12] can be compiled without + #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv" fi fi From dovecot at dovecot.org Mon Feb 25 09:12:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 09:12:18 +0200 Subject: dovecot-2.2: configure: Fix previous commit & implement AC_C_TYP... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/61508a42a44b changeset: 15927:61508a42a44b user: Timo Sirainen date: Mon Feb 25 09:12:06 2013 +0200 description: configure: Fix previous commit & implement AC_C_TYPEOF ourself. RHEL5's autoconf was old enough to not have AC_C_TYPEOF. diffstat: configure.ac | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diffs (33 lines): diff -r 5be9659a2738 -r 61508a42a44b configure.ac --- a/configure.ac Mon Feb 25 09:07:13 2013 +0200 +++ b/configure.ac Mon Feb 25 09:12:06 2013 +0200 @@ -347,6 +347,7 @@ if test "$want_devel_checks" = "yes"; then # FIXME: enable once md[45], sha[12] can be compiled without #CFLAGS="$CFLAGS -fsanitize=integer,undefined -ftrapv" + : fi fi @@ -426,6 +427,21 @@ AC_DEFINE(HAVE_CLOCK_GETTIME,, Define if you have the clock_gettime function) ]) +AC_CACHE_CHECK([for typeof],i_cv_have_typeof,[ + AC_TRY_COMPILE([ + ], [ + int foo; + typeof(foo) bar; + ], [ + i_cv_have_typeof=yes + ], [ + i_cv_have_typeof=no + ]) +]) +if test $i_cv_have_typeof = yes; then + AC_DEFINE(HAVE_TYPEOF,, Define if you have typeof()) +fi + dnl strtoimax and strtoumax are macros in HP-UX, so inttypes.h must be included dnl Link instead of just compiling since there's something wrong with Tru64 AC_CACHE_CHECK([for strtoimax],i_cv_have_strtoimax,[ From dovecot at dovecot.org Mon Feb 25 13:00:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 13:00:47 +0200 Subject: dovecot-2.2: MODULE_LIBS is now part of LIBDOVECOT. No need to e... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/217fb4ca9b5a changeset: 15928:217fb4ca9b5a user: Timo Sirainen date: Mon Feb 25 13:00:40 2013 +0200 description: MODULE_LIBS is now part of LIBDOVECOT. No need to explicitly link it everywhere. diffstat: Makefile.am | 1 + configure.ac | 2 +- dovecot-config.in.in | 2 +- src/anvil/Makefile.am | 1 - src/auth/Makefile.am | 2 +- src/config/Makefile.am | 2 -- src/dict/Makefile.am | 1 - src/dns/Makefile.am | 2 +- src/doveadm/Makefile.am | 6 ++---- src/imap-urlauth/Makefile.am | 4 ++-- src/imap/Makefile.am | 3 +-- src/indexer/Makefile.am | 5 ++--- src/ipc/Makefile.am | 4 +--- src/lda/Makefile.am | 3 +-- src/lib-compression/Makefile.am | 2 +- src/lib-sql/Makefile.am | 2 +- src/lib-storage/Makefile.am | 2 +- src/lmtp/Makefile.am | 3 +-- src/plugins/quota/Makefile.am | 1 - src/pop3/Makefile.am | 3 +-- src/replication/aggregator/Makefile.am | 2 +- src/replication/replicator/Makefile.am | 2 +- src/stats/Makefile.am | 4 +--- src/util/Makefile.am | 7 +++---- 24 files changed, 25 insertions(+), 41 deletions(-) diffs (truncated from 343 to 300 lines): diff -r 61508a42a44b -r 217fb4ca9b5a Makefile.am --- a/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -41,6 +41,7 @@ -e "s|\$$(top_builddir)|$$abs_builddir|g" \ -e "s|\$$(incdir)|$$abs_srcdir|g" \ -e "s|\$$(LIBICONV)|$(LIBICONV)|g" \ + -e "s|\$$(MODULE_LIBS)|$(MODULE_LIBS)|g" \ -e "s|^\(dovecot_pkgincludedir\)=|\1=$(pkgincludedir)|" \ -e "s|^\(dovecot_pkglibdir\)=|\1=$(pkglibdir)|" \ -e "s|^\(dovecot_pkglibexecdir\)=|\1=$(libexecdir)/dovecot|" \ diff -r 61508a42a44b -r 217fb4ca9b5a configure.ac --- a/configure.ac Mon Feb 25 09:12:06 2013 +0200 +++ b/configure.ac Mon Feb 25 13:00:40 2013 +0200 @@ -2545,7 +2545,7 @@ LIBDOVECOT_LDA='$(top_builddir)/src/lib-lda/libdovecot-lda.la' else LIBDOVECOT_DEPS='$(top_builddir)/src/lib-master/libmaster.la $(top_builddir)/src/lib-settings/libsettings.la $(top_builddir)/src/lib-http/libhttp.la $(top_builddir)/src/lib-dict/libdict.la $(top_builddir)/src/lib-dns/libdns.la $(top_builddir)/src/lib-fs/libfs.la $(top_builddir)/src/lib-imap/libimap.la $(top_builddir)/src/lib-mail/libmail.la $(top_builddir)/src/lib-auth/libauth.la $(top_builddir)/src/lib-charset/libcharset.la $(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la $(top_builddir)/src/lib-test/libtest.la $(top_builddir)/src/lib/liblib.la' - LIBDOVECOT="$LIBDOVECOT_DEPS \$(LIBICONV)" + LIBDOVECOT="$LIBDOVECOT_DEPS \$(LIBICONV) \$(MODULE_LIBS)" LIBDOVECOT_STORAGE_LAST='$(top_builddir)/src/lib-storage/list/libstorage_list.la $(top_builddir)/src/lib-storage/index/libstorage_index.la $(top_builddir)/src/lib-storage/libstorage.la $(top_builddir)/src/lib-index/libindex.la $(top_builddir)/src/lib-imap-storage/libimap-storage.la' LIBDOVECOT_STORAGE_FIRST='$(top_builddir)/src/lib-storage/libstorage_service.la $(top_builddir)/src/lib-storage/register/libstorage_register.la' LIBDOVECOT_STORAGE_DEPS="$LIBDOVECOT_STORAGE_FIRST $LINKED_STORAGE_LIBS $LIBDOVECOT_STORAGE_LAST" diff -r 61508a42a44b -r 217fb4ca9b5a dovecot-config.in.in --- a/dovecot-config.in.in Mon Feb 25 09:12:06 2013 +0200 +++ b/dovecot-config.in.in Mon Feb 25 13:00:40 2013 +0200 @@ -4,7 +4,7 @@ DOVECOT_SQL_LIBS="@SQL_LIBS@" DOVECOT_COMPRESS_LIBS="@COMPRESS_LIBS@" -LIBDOVECOT="@LIBDOVECOT@ @MODULE_LIBS@" +LIBDOVECOT="@LIBDOVECOT@" LIBDOVECOT_LOGIN="@LIBDOVECOT_LOGIN@ @SSL_LIBS@" LIBDOVECOT_SQL="@LIBDOVECOT_SQL@" LIBDOVECOT_COMPRESS="@LIBDOVECOT_COMPRESS@" diff -r 61508a42a44b -r 217fb4ca9b5a src/anvil/Makefile.am --- a/src/anvil/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/anvil/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -10,7 +10,6 @@ anvil_LDADD = \ $(LIBDOVECOT) \ - $(MODULE_LIBS) \ $(RAND_LIBS) anvil_DEPENDENCIES = $(LIBDOVECOT_DEPS) diff -r 61508a42a44b -r 217fb4ca9b5a src/auth/Makefile.am --- a/src/auth/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/auth/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -54,7 +54,7 @@ ../lib-otp/libotp.a \ $(LIBDOVECOT_SQL) -auth_LDADD = $(auth_libs) $(LIBDOVECOT) $(AUTH_LIBS) $(MODULE_LIBS) +auth_LDADD = $(auth_libs) $(LIBDOVECOT) $(AUTH_LIBS) auth_DEPENDENCIES = $(auth_libs) $(LIBDOVECOT_DEPS) ldap_sources = db-ldap.c passdb-ldap.c userdb-ldap.c diff -r 61508a42a44b -r 217fb4ca9b5a src/config/Makefile.am --- a/src/config/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/config/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -17,13 +17,11 @@ config_LDADD = \ $(LIBDOVECOT) \ - $(MODULE_LIBS) \ $(RAND_LIBS) config_DEPENDENCIES = $(LIBDOVECOT_DEPS) doveconf_LDADD = \ $(LIBDOVECOT) \ - $(MODULE_LIBS) \ $(RAND_LIBS) doveconf_DEPENDENCIES = $(LIBDOVECOT_DEPS) diff -r 61508a42a44b -r 217fb4ca9b5a src/dict/Makefile.am --- a/src/dict/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/dict/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -20,7 +20,6 @@ dict_LDADD = \ $(libs) \ $(LIBDOVECOT) \ - $(MODULE_LIBS) \ $(DICT_LIBS) \ $(SQL_LIBS) dict_DEPENDENCIES = $(libs) $(LIBDOVECOT_DEPS) diff -r 61508a42a44b -r 217fb4ca9b5a src/dns/Makefile.am --- a/src/dns/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/dns/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -7,7 +7,7 @@ -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-settings -dns_client_LDADD = $(LIBDOVECOT) $(MODULE_LIBS) +dns_client_LDADD = $(LIBDOVECOT) dns_client_DEPENDENCIES = $(LIBDOVECOT_DEPS) dns_client_SOURCES = \ dns-client.c \ diff -r 61508a42a44b -r 217fb4ca9b5a src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/doveadm/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -41,8 +41,7 @@ $(cmd_pw_libs) \ $(CRYPT_LIBS) \ $(LIBDOVECOT_STORAGE) \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(LIBDOVECOT) doveadm_DEPENDENCIES = \ $(libs) \ $(cmd_pw_libs) \ @@ -52,8 +51,7 @@ doveadm_server_LDADD = \ $(libs) \ $(LIBDOVECOT_STORAGE) \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(LIBDOVECOT) doveadm_server_DEPENDENCIES = \ $(libs) \ $(LIBDOVECOT_STORAGE_DEPS) \ diff -r 61508a42a44b -r 217fb4ca9b5a src/imap-urlauth/Makefile.am --- a/src/imap-urlauth/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/imap-urlauth/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -36,7 +36,7 @@ imap_urlauth_LDFLAGS = -export-dynamic -imap_urlauth_LDADD = $(LIBDOVECOT) $(MODULE_LIBS) +imap_urlauth_LDADD = $(LIBDOVECOT) imap_urlauth_DEPENDENCIES = $(LIBDOVECOT_DEPS) imap_urlauth_SOURCES = \ @@ -65,7 +65,7 @@ urlauth_libs = \ $(top_builddir)/src/lib-imap-urlauth/libimap-urlauth.la -imap_urlauth_worker_LDADD = $(urlauth_libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT) $(MODULE_LIBS) +imap_urlauth_worker_LDADD = $(urlauth_libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT) imap_urlauth_worker_DEPENDENCIES = $(urlauth_libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS) imap_urlauth_worker_SOURCES = \ diff -r 61508a42a44b -r 217fb4ca9b5a src/imap/Makefile.am --- a/src/imap/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/imap/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -19,8 +19,7 @@ imap_LDADD = \ ../lib-imap-urlauth/libimap-urlauth.la \ $(LIBDOVECOT_STORAGE) \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(LIBDOVECOT) imap_DEPENDENCIES = \ ../lib-imap-urlauth/libimap-urlauth.la \ $(LIBDOVECOT_STORAGE_DEPS) \ diff -r 61508a42a44b -r 217fb4ca9b5a src/indexer/Makefile.am --- a/src/indexer/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/indexer/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -11,7 +11,7 @@ -I$(top_srcdir)/src/lib-storage \ -DPKG_RUNDIR=\""$(rundir)"\" -indexer_LDADD = $(LIBDOVECOT) $(MODULE_LIBS) +indexer_LDADD = $(LIBDOVECOT) indexer_DEPENDENCIES = $(LIBDOVECOT_DEPS) indexer_SOURCES = \ indexer.c \ @@ -23,8 +23,7 @@ indexer_worker_LDADD = \ $(LIBDOVECOT_STORAGE) \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(LIBDOVECOT) indexer_worker_DEPENDENCIES = \ $(LIBDOVECOT_STORAGE_DEPS) \ $(LIBDOVECOT_DEPS) diff -r 61508a42a44b -r 217fb4ca9b5a src/ipc/Makefile.am --- a/src/ipc/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/ipc/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -7,9 +7,7 @@ -I$(top_srcdir)/src/lib-settings \ -I$(top_srcdir)/src/lib-master -ipc_LDADD = \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) +ipc_LDADD = $(LIBDOVECOT) ipc_DEPENDENCIES = $(LIBDOVECOT_DEPS) ipc_SOURCES = \ diff -r 61508a42a44b -r 217fb4ca9b5a src/lda/Makefile.am --- a/src/lda/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/lda/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -19,8 +19,7 @@ dovecot_lda_LDADD = \ $(LIBDOVECOT_LDA) \ $(LIBDOVECOT_STORAGE) \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(LIBDOVECOT) dovecot_lda_DEPENDENCIES = \ $(LIBDOVECOT_LDA) \ $(LIBDOVECOT_STORAGE_DEPS) \ diff -r 61508a42a44b -r 217fb4ca9b5a src/lib-compression/Makefile.am --- a/src/lib-compression/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/lib-compression/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -21,6 +21,6 @@ pkglib_LTLIBRARIES = libdovecot-compression.la libdovecot_compression_la_SOURCES = -libdovecot_compression_la_LIBADD = libcompression.la ../lib/liblib.la $(MODULE_LIBS) $(COMPRESS_LIBS) +libdovecot_compression_la_LIBADD = libcompression.la ../lib/liblib.la $(COMPRESS_LIBS) libdovecot_compression_la_DEPENDENCIES = libcompression.la libdovecot_compression_la_LDFLAGS = -export-dynamic diff -r 61508a42a44b -r 217fb4ca9b5a src/lib-sql/Makefile.am --- a/src/lib-sql/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/lib-sql/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -79,7 +79,7 @@ pkglib_LTLIBRARIES = libdovecot-sql.la libdovecot_sql_la_SOURCES = -libdovecot_sql_la_LIBADD = libsql.la $(deplibs) $(MODULE_LIBS) $(sql_libs) +libdovecot_sql_la_LIBADD = libsql.la $(deplibs) $(sql_libs) libdovecot_sql_la_DEPENDENCIES = libsql.la libdovecot_sql_la_LDFLAGS = -export-dynamic diff -r 61508a42a44b -r 217fb4ca9b5a src/lib-storage/Makefile.am --- a/src/lib-storage/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/lib-storage/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -89,7 +89,7 @@ pkglib_LTLIBRARIES = libdovecot-storage.la libdovecot_storage_la_SOURCES = -libdovecot_storage_la_LIBADD = $(shlibs) $(LINKED_STORAGE_LDADD) $(MODULE_LIBS) +libdovecot_storage_la_LIBADD = $(shlibs) $(LINKED_STORAGE_LDADD) libdovecot_storage_la_DEPENDENCIES = $(shlibs) libdovecot_storage_la_LDFLAGS = -export-dynamic diff -r 61508a42a44b -r 217fb4ca9b5a src/lmtp/Makefile.am --- a/src/lmtp/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/lmtp/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -20,8 +20,7 @@ lmtp_LDADD = \ $(LIBDOVECOT_LDA) \ $(LIBDOVECOT_STORAGE) \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(LIBDOVECOT) lmtp_DEPENDENCIES = \ $(LIBDOVECOT_LDA) \ $(LIBDOVECOT_STORAGE_DEPS) \ diff -r 61508a42a44b -r 217fb4ca9b5a src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/plugins/quota/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -58,7 +58,6 @@ $(quota_common_objects) \ $(LIBDOVECOT_STORAGE) \ $(LIBDOVECOT) \ - $(MODULE_LIBS) \ $(QUOTA_LIBS) quota_status_DEPENDENCIES = \ $(quota_common_objects) \ diff -r 61508a42a44b -r 217fb4ca9b5a src/pop3/Makefile.am --- a/src/pop3/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/pop3/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -14,8 +14,7 @@ pop3_LDADD = \ $(LIBDOVECOT_STORAGE) \ - $(LIBDOVECOT) \ - $(MODULE_LIBS) + $(LIBDOVECOT) pop3_DEPENDENCIES = \ $(LIBDOVECOT_STORAGE_DEPS) \ $(LIBDOVECOT_DEPS) diff -r 61508a42a44b -r 217fb4ca9b5a src/replication/aggregator/Makefile.am --- a/src/replication/aggregator/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/replication/aggregator/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -11,7 +11,7 @@ -DPKG_STATEDIR=\""$(statedir)"\" aggregator_LDFLAGS = -export-dynamic -aggregator_LDADD = $(LIBDOVECOT) $(MODULE_LIBS) +aggregator_LDADD = $(LIBDOVECOT) aggregator_DEPENDENCIES = $(LIBDOVECOT_DEPS) aggregator_SOURCES = \ diff -r 61508a42a44b -r 217fb4ca9b5a src/replication/replicator/Makefile.am --- a/src/replication/replicator/Makefile.am Mon Feb 25 09:12:06 2013 +0200 +++ b/src/replication/replicator/Makefile.am Mon Feb 25 13:00:40 2013 +0200 @@ -11,7 +11,7 @@ -DPKG_STATEDIR=\""$(statedir)"\" replicator_LDFLAGS = -export-dynamic -replicator_LDADD = $(LIBDOVECOT) $(MODULE_LIBS) +replicator_LDADD = $(LIBDOVECOT) replicator_DEPENDENCIES = $(LIBDOVECOT_DEPS) replicator_SOURCES = \ From dovecot at dovecot.org Mon Feb 25 14:00:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 14:00:21 +0200 Subject: dovecot-2.2: dsync: Use iostreams instead of fd when receiving c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1841a4b95783 changeset: 15929:1841a4b95783 user: Timo Sirainen date: Mon Feb 25 14:00:10 2013 +0200 description: dsync: Use iostreams instead of fd when receiving connection from doveadm-server. diffstat: src/doveadm/dsync/doveadm-dsync.c | 53 ++++++++++++++++++++------------------ src/doveadm/server-connection.c | 25 +++++++++++++---- src/doveadm/server-connection.h | 6 +++- 3 files changed, 52 insertions(+), 32 deletions(-) diffs (149 lines): diff -r 217fb4ca9b5a -r 1841a4b95783 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 13:00:40 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 14:00:10 2013 +0200 @@ -55,7 +55,8 @@ int fd_in, fd_out, fd_err; struct io *io_err; - struct istream *err_stream; + struct istream *input, *err_stream; + struct ostream *output; enum dsync_run_type run_type; struct server_connection *tcp_conn; @@ -404,17 +405,21 @@ cmd_dsync_icb_stream_init(struct dsync_cmd_context *ctx, const char *name, const char *temp_prefix) { - struct istream *input; - struct ostream *output; - - fd_set_nonblock(ctx->fd_in, TRUE); - fd_set_nonblock(ctx->fd_out, TRUE); - - input = i_stream_create_fd(ctx->fd_in, (size_t)-1, FALSE); - output = o_stream_create_fd(ctx->fd_out, (size_t)-1, FALSE); - if (ctx->rawlog_path != NULL) - iostream_rawlog_create_path(ctx->rawlog_path, &input, &output); - return dsync_ibc_init_stream(input, output, name, temp_prefix); + if (ctx->input == NULL) { + fd_set_nonblock(ctx->fd_in, TRUE); + fd_set_nonblock(ctx->fd_out, TRUE); + ctx->input = i_stream_create_fd(ctx->fd_in, (size_t)-1, FALSE); + ctx->output = o_stream_create_fd(ctx->fd_out, (size_t)-1, FALSE); + } else { + i_stream_ref(ctx->input); + o_stream_ref(ctx->output); + } + if (ctx->rawlog_path != NULL) { + iostream_rawlog_create_path(ctx->rawlog_path, + &ctx->input, &ctx->output); + } + return dsync_ibc_init_stream(ctx->input, ctx->output, + name, temp_prefix); } static int @@ -523,10 +528,9 @@ ctx->error = "Failed to start dsync-server command"; break; case SERVER_CMD_REPLY_OK: - ctx->fd_in = ctx->fd_out = - dup(server_connection_get_fd(ctx->tcp_conn)); - if (ctx->fd_in == -1) - ctx->error = t_strdup_printf("dup() failed: %m"); + server_connection_extract(ctx->tcp_conn, &ctx->input, + &ctx->output); + ctx->fd_in = ctx->fd_out = -1; break; case SERVER_CMD_REPLY_INTERNAL_FAILURE: ctx->error = "Disconnected from remote"; @@ -786,15 +790,10 @@ if (_ctx->conn != NULL) { /* doveadm-server connection. start with a success reply. after that follows the regular dsync protocol. */ - ctx->fd_in = _ctx->conn->fd; - ctx->fd_out = _ctx->conn->fd; - if (write_full(ctx->fd_out, "\n+\n", 3) < 0) { - i_error("write(initial reply) failed: %m"); - return -1; - } - /* make sure nothing more is written by the generic doveadm - connection code */ - o_stream_close(_ctx->conn->output); + ctx->fd_in = ctx->fd_out = -1; + ctx->input = _ctx->conn->input; + ctx->output = _ctx->conn->output; + o_stream_nsend(ctx->output, "\n+\n", 3); } user->admin = TRUE; @@ -814,6 +813,10 @@ _ctx->exit_code = EX_TEMPFAIL; dsync_ibc_deinit(&ibc); + /* make sure nothing more is written by the generic doveadm + connection code */ + o_stream_close(_ctx->conn->output); + return _ctx->exit_code == 0 ? 0 : -1; } diff -r 217fb4ca9b5a -r 1841a4b95783 src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Mon Feb 25 13:00:40 2013 +0200 +++ b/src/doveadm/server-connection.c Mon Feb 25 14:00:10 2013 +0200 @@ -366,12 +366,16 @@ if (printing_conn == conn) print_connection_released(); - i_stream_destroy(&conn->input); - o_stream_destroy(&conn->output); + if (conn->input != NULL) + i_stream_destroy(&conn->input); + if (conn->output != NULL) + o_stream_destroy(&conn->output); if (conn->io != NULL) io_remove(&conn->io); - if (close(conn->fd) < 0) - i_error("close(server) failed: %m"); + if (conn->fd != -1) { + if (close(conn->fd) < 0) + i_error("close(server) failed: %m"); + } pool_unref(&conn->pool); } @@ -400,7 +404,16 @@ return conn->callback == NULL; } -int server_connection_get_fd(struct server_connection *conn) +void server_connection_extract(struct server_connection *conn, + struct istream **istream_r, + struct ostream **ostream_r) { - return conn->fd; + *istream_r = conn->input; + *ostream_r = conn->output; + + conn->input = NULL; + conn->output = NULL; + if (conn->io != NULL) + io_remove(&conn->io); + conn->fd = -1; } diff -r 217fb4ca9b5a -r 1841a4b95783 src/doveadm/server-connection.h --- a/src/doveadm/server-connection.h Mon Feb 25 13:00:40 2013 +0200 +++ b/src/doveadm/server-connection.h Mon Feb 25 14:00:10 2013 +0200 @@ -26,6 +26,10 @@ /* Returns TRUE if no command is being processed */ bool server_connection_is_idle(struct server_connection *conn); -int server_connection_get_fd(struct server_connection *conn); +/* Extract iostreams from connection. Afterwards the server_connection simply + waits for itself to be destroyed. */ +void server_connection_extract(struct server_connection *conn, + struct istream **istream_r, + struct ostream **ostream_r); #endif From dovecot at dovecot.org Mon Feb 25 15:51:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 15:51:05 +0200 Subject: dovecot-2.2: lib-ssl-iostream: Support wildcard certificates whe... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ca262f790338 changeset: 15930:ca262f790338 user: Timo Sirainen date: Mon Feb 25 15:50:50 2013 +0200 description: lib-ssl-iostream: Support wildcard certificates when verifying hostname. diffstat: src/lib-ssl-iostream/iostream-openssl-common.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diffs (45 lines): diff -r 1841a4b95783 -r ca262f790338 src/lib-ssl-iostream/iostream-openssl-common.c --- a/src/lib-ssl-iostream/iostream-openssl-common.c Mon Feb 25 14:00:10 2013 +0200 +++ b/src/lib-ssl-iostream/iostream-openssl-common.c Mon Feb 25 15:50:50 2013 +0200 @@ -97,6 +97,20 @@ return asn1_string_to_c(str); } +static bool openssl_hostname_equals(const char *ssl_name, const char *host) +{ + const char *p; + + if (strcmp(ssl_name, host) == 0) + return TRUE; + + /* check for *.example.com wildcard */ + if (ssl_name[0] != '*' || ssl_name[1] != '.') + return FALSE; + p = strchr(host, '.'); + return p != NULL && strcmp(ssl_name+2, p+1) == 0; +} + int openssl_cert_match_name(SSL *ssl, const char *verify_name) { X509 *cert; @@ -118,7 +132,7 @@ if (gn->type == GEN_DNS) { dns_names = TRUE; dnsname = get_general_dns_name(gn); - if (strcmp(dnsname, verify_name) == 0) + if (openssl_hostname_equals(dnsname, verify_name)) break; } } @@ -128,8 +142,10 @@ SubjectAltNames */ if (dns_names) ret = i < count ? 0 : -1; + else if (openssl_hostname_equals(get_cname(cert), verify_name)) + ret = 0; else - ret = strcmp(get_cname(cert), verify_name) == 0 ? 0 : -1; + ret = -1; X509_free(cert); return ret; } From dovecot at dovecot.org Mon Feb 25 15:52:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 15:52:39 +0200 Subject: dovecot-2.2: lib-master: If ssl settings are used, initialize ss... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6b0c284ecede changeset: 15931:6b0c284ecede user: Timo Sirainen date: Mon Feb 25 15:51:16 2013 +0200 description: lib-master: If ssl settings are used, initialize ssl context automatically. diffstat: src/lib-master/master-service.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (28 lines): diff -r ca262f790338 -r 6b0c284ecede src/lib-master/master-service.c --- a/src/lib-master/master-service.c Mon Feb 25 15:50:50 2013 +0200 +++ b/src/lib-master/master-service.c Mon Feb 25 15:51:16 2013 +0200 @@ -15,6 +15,7 @@ #include "syslog-util.h" #include "master-instance.h" #include "master-login.h" +#include "master-service-ssl.h" #include "master-service-private.h" #include "master-service-settings.h" @@ -441,6 +442,8 @@ master_status_error, service); } master_service_io_listeners_add(service); + if (service->want_ssl_settings) + master_service_ssl_ctx_init(service); if ((service->flags & MASTER_SERVICE_FLAG_STD_CLIENT) != 0) { /* we already have a connection to be served */ @@ -714,6 +717,7 @@ *_service = NULL; master_service_io_listeners_remove(service); + master_service_ssl_ctx_deinit(service); master_service_close_config_fd(service); if (service->to_die != NULL) From dovecot at dovecot.org Mon Feb 25 15:52:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 15:52:39 +0200 Subject: dovecot-2.2: lib-storage: Replaced pop3c_ssl_ca_dir and imapc_ss... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5998396f0928 changeset: 15932:5998396f0928 user: Timo Sirainen date: Mon Feb 25 15:52:00 2013 +0200 description: lib-storage: Replaced pop3c_ssl_ca_dir and imapc_ssl_ca_dir with generic ssl_client_ca_dir. diffstat: src/lib-storage/index/imapc/imapc-settings.c | 12 ++++++------ src/lib-storage/index/imapc/imapc-settings.h | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/index/pop3c/pop3c-settings.c | 12 ++++++------ src/lib-storage/index/pop3c/pop3c-settings.h | 2 +- src/lib-storage/index/pop3c/pop3c-storage.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diffs (152 lines): diff -r 6b0c284ecede -r 5998396f0928 src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Mon Feb 25 15:51:16 2013 +0200 +++ b/src/lib-storage/index/imapc/imapc-settings.c Mon Feb 25 15:52:00 2013 +0200 @@ -22,7 +22,6 @@ DEF(SET_STR, imapc_password), DEF(SET_ENUM, imapc_ssl), - DEF(SET_STR, imapc_ssl_ca_dir), DEF(SET_BOOL, imapc_ssl_verify), DEF(SET_STR, imapc_features), @@ -30,6 +29,7 @@ DEF(SET_STR, imapc_list_prefix), DEF(SET_TIME, imapc_max_idle_time), + DEF(SET_STR, ssl_client_ca_dir), DEF(SET_STR, ssl_crypto_device), SETTING_DEFINE_LIST_END @@ -44,7 +44,6 @@ .imapc_password = "", .imapc_ssl = "no:imaps:starttls", - .imapc_ssl_ca_dir = "", .imapc_ssl_verify = TRUE, .imapc_features = "", @@ -52,6 +51,7 @@ .imapc_list_prefix = "", .imapc_max_idle_time = 60*29, + .ssl_client_ca_dir = "", .ssl_crypto_device = "" }; @@ -123,11 +123,11 @@ return FALSE; } #ifndef CONFIG_BINARY - if (*set->imapc_ssl_ca_dir != '\0' && - access(set->imapc_ssl_ca_dir, X_OK) < 0) { + if (*set->ssl_client_ca_dir != '\0' && + access(set->ssl_client_ca_dir, X_OK) < 0) { *error_r = t_strdup_printf( - "imapc_ssl_ca_dir: access(%s) failed: %m", - set->imapc_ssl_ca_dir); + "ssl_client_ca_dir: access(%s) failed: %m", + set->ssl_client_ca_dir); return FALSE; } #endif diff -r 6b0c284ecede -r 5998396f0928 src/lib-storage/index/imapc/imapc-settings.h --- a/src/lib-storage/index/imapc/imapc-settings.h Mon Feb 25 15:51:16 2013 +0200 +++ b/src/lib-storage/index/imapc/imapc-settings.h Mon Feb 25 15:52:00 2013 +0200 @@ -17,7 +17,6 @@ const char *imapc_password; const char *imapc_ssl; - const char *imapc_ssl_ca_dir; bool imapc_ssl_verify; const char *imapc_features; @@ -25,6 +24,7 @@ const char *imapc_list_prefix; unsigned int imapc_max_idle_time; + const char *ssl_client_ca_dir; const char *ssl_crypto_device; enum imapc_features parsed_features; diff -r 6b0c284ecede -r 5998396f0928 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Mon Feb 25 15:51:16 2013 +0200 +++ b/src/lib-storage/index/imapc/imapc-storage.c Mon Feb 25 15:52:00 2013 +0200 @@ -243,7 +243,7 @@ mail_user_set_get_temp_prefix(str, _storage->user->set); set.temp_path_prefix = str_c(str); - set.ssl_ca_dir = storage->set->imapc_ssl_ca_dir; + set.ssl_ca_dir = storage->set->ssl_client_ca_dir; set.ssl_verify = storage->set->imapc_ssl_verify; if (strcmp(storage->set->imapc_ssl, "imaps") == 0) set.ssl_mode = IMAPC_CLIENT_SSL_MODE_IMMEDIATE; diff -r 6b0c284ecede -r 5998396f0928 src/lib-storage/index/pop3c/pop3c-settings.c --- a/src/lib-storage/index/pop3c/pop3c-settings.c Mon Feb 25 15:51:16 2013 +0200 +++ b/src/lib-storage/index/pop3c/pop3c-settings.c Mon Feb 25 15:52:00 2013 +0200 @@ -22,10 +22,10 @@ DEF(SET_STR, pop3c_password), DEF(SET_ENUM, pop3c_ssl), - DEF(SET_STR, pop3c_ssl_ca_dir), DEF(SET_BOOL, pop3c_ssl_verify), DEF(SET_STR, pop3c_rawlog_dir), + DEF(SET_STR, ssl_client_ca_dir), DEF(SET_STR, ssl_crypto_device), SETTING_DEFINE_LIST_END @@ -40,10 +40,10 @@ .pop3c_password = "", .pop3c_ssl = "no:pop3s:starttls", - .pop3c_ssl_ca_dir = "", .pop3c_ssl_verify = TRUE, .pop3c_rawlog_dir = "", + .ssl_client_ca_dir = "", .ssl_crypto_device = "" }; @@ -77,11 +77,11 @@ return FALSE; } #ifndef CONFIG_BINARY - if (*set->pop3c_ssl_ca_dir != '\0' && - access(set->pop3c_ssl_ca_dir, X_OK) < 0) { + if (*set->ssl_client_ca_dir != '\0' && + access(set->ssl_client_ca_dir, X_OK) < 0) { *error_r = t_strdup_printf( - "pop3c_ssl_ca_dir: access(%s) failed: %m", - set->pop3c_ssl_ca_dir); + "ssl_client_ca_dir: access(%s) failed: %m", + set->ssl_client_ca_dir); return FALSE; } #endif diff -r 6b0c284ecede -r 5998396f0928 src/lib-storage/index/pop3c/pop3c-settings.h --- a/src/lib-storage/index/pop3c/pop3c-settings.h Mon Feb 25 15:51:16 2013 +0200 +++ b/src/lib-storage/index/pop3c/pop3c-settings.h Mon Feb 25 15:52:00 2013 +0200 @@ -10,10 +10,10 @@ const char *pop3c_password; const char *pop3c_ssl; - const char *pop3c_ssl_ca_dir; bool pop3c_ssl_verify; const char *pop3c_rawlog_dir; + const char *ssl_client_ca_dir; const char *ssl_crypto_device; }; diff -r 6b0c284ecede -r 5998396f0928 src/lib-storage/index/pop3c/pop3c-storage.c --- a/src/lib-storage/index/pop3c/pop3c-storage.c Mon Feb 25 15:51:16 2013 +0200 +++ b/src/lib-storage/index/pop3c/pop3c-storage.c Mon Feb 25 15:52:00 2013 +0200 @@ -73,7 +73,7 @@ client_set.rawlog_dir = mail_user_home_expand(user, set->pop3c_rawlog_dir); - client_set.ssl_ca_dir = set->pop3c_ssl_ca_dir; + client_set.ssl_ca_dir = set->ssl_client_ca_dir; client_set.ssl_verify = set->pop3c_ssl_verify; if (strcmp(set->pop3c_ssl, "pop3s") == 0) client_set.ssl_mode = POP3C_CLIENT_SSL_MODE_IMMEDIATE; From dovecot at dovecot.org Mon Feb 25 15:54:13 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 15:54:13 +0200 Subject: dovecot-2.2: doveadm-server: Added support for ssl listeners. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9a7680fe65ce changeset: 15933:9a7680fe65ce user: Timo Sirainen date: Mon Feb 25 15:54:01 2013 +0200 description: doveadm-server: Added support for ssl listeners. diffstat: src/doveadm/Makefile.am | 1 + src/doveadm/client-connection.c | 65 +++++++++++++++++++++++++++++++--------- src/doveadm/client-connection.h | 4 +- src/doveadm/main.c | 3 +- 4 files changed, 56 insertions(+), 17 deletions(-) diffs (145 lines): diff -r 5998396f0928 -r 9a7680fe65ce src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Mon Feb 25 15:52:00 2013 +0200 +++ b/src/doveadm/Makefile.am Mon Feb 25 15:54:01 2013 +0200 @@ -13,6 +13,7 @@ -I$(top_srcdir)/src/lib-compression \ -I$(top_srcdir)/src/lib-dict \ -I$(top_srcdir)/src/lib-fs \ + -I$(top_srcdir)/src/lib-ssl-iostream \ -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-mail \ -I$(top_srcdir)/src/lib-imap \ diff -r 5998396f0928 -r 9a7680fe65ce src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Mon Feb 25 15:52:00 2013 +0200 +++ b/src/doveadm/client-connection.c Mon Feb 25 15:54:01 2013 +0200 @@ -7,7 +7,9 @@ #include "ostream.h" #include "strescape.h" #include "settings-parser.h" +#include "iostream-ssl.h" #include "master-service.h" +#include "master-service-ssl.h" #include "master-service-settings.h" #include "mail-storage-service.h" #include "doveadm-util.h" @@ -345,11 +347,44 @@ return 0; } -struct client_connection *client_connection_create(int fd, int listen_fd) +static int client_connection_init_ssl(struct client_connection *conn) +{ + if (master_service_ssl_init(master_service, + &conn->input, &conn->output, + &conn->ssl_iostream) < 0) + return -1; + if (ssl_iostream_handshake(conn->ssl_iostream) < 0) { + i_error("SSL handshake failed: %s", + ssl_iostream_get_last_error(conn->ssl_iostream)); + return -1; + } + return 0; +} + +static void +client_connection_send_auth_handshake(struct client_connection * + conn, int listen_fd) +{ + const char *listen_path; + struct stat st; + + /* we'll have to do this with stat(), because at least in Linux + fstat() always returns mode as 0777 */ + if (net_getunixname(listen_fd, &listen_path) == 0 && + stat(listen_path, &st) == 0 && S_ISSOCK(st.st_mode) && + (st.st_mode & 0777) == 0600) { + /* no need for client to authenticate */ + conn->authenticated = TRUE; + o_stream_nsend(conn->output, "+\n", 2); + } else { + o_stream_nsend(conn->output, "-\n", 2); + } +} + +struct client_connection * +client_connection_create(int fd, int listen_fd, bool ssl) { struct client_connection *conn; - struct stat st; - const char *listen_path; unsigned int port; pool_t pool; @@ -365,19 +400,17 @@ (void)net_getsockname(fd, &conn->local_ip, &port); (void)net_getpeername(fd, &conn->remote_ip, &port); - /* we'll have to do this with stat(), because at least in Linux - fstat() always returns mode as 0777 */ - if (net_getunixname(listen_fd, &listen_path) == 0 && - stat(listen_path, &st) == 0 && S_ISSOCK(st.st_mode) && - (st.st_mode & 0777) == 0600) { - /* no need for client to authenticate */ - conn->authenticated = TRUE; - o_stream_nsend(conn->output, "+\n", 2); - } else { - o_stream_nsend(conn->output, "-\n", 2); + if (client_connection_read_settings(conn) < 0) { + client_connection_destroy(&conn); + return NULL; } - if (client_connection_read_settings(conn) < 0) - client_connection_destroy(&conn); + if (ssl) { + if (client_connection_init_ssl(conn) < 0) { + client_connection_destroy(&conn); + return NULL; + } + } + client_connection_send_auth_handshake(conn, listen_fd); return conn; } @@ -387,6 +420,8 @@ *_conn = NULL; + if (conn->ssl_iostream != NULL) + ssl_iostream_destroy(&conn->ssl_iostream); i_stream_destroy(&conn->input); o_stream_destroy(&conn->output); io_remove(&conn->io); diff -r 5998396f0928 -r 9a7680fe65ce src/doveadm/client-connection.h --- a/src/doveadm/client-connection.h Mon Feb 25 15:52:00 2013 +0200 +++ b/src/doveadm/client-connection.h Mon Feb 25 15:54:01 2013 +0200 @@ -10,6 +10,7 @@ struct io *io; struct istream *input; struct ostream *output; + struct ssl_iostream *ssl_iostream; struct ip_addr local_ip, remote_ip; const struct doveadm_settings *set; @@ -17,7 +18,8 @@ unsigned int authenticated:1; }; -struct client_connection *client_connection_create(int fd, int listen_fd); +struct client_connection * +client_connection_create(int fd, int listen_fd, bool ssl); void client_connection_destroy(struct client_connection **conn); struct ostream *client_connection_get_output(struct client_connection *conn); diff -r 5998396f0928 -r 9a7680fe65ce src/doveadm/main.c --- a/src/doveadm/main.c Mon Feb 25 15:52:00 2013 +0200 +++ b/src/doveadm/main.c Mon Feb 25 15:54:01 2013 +0200 @@ -32,7 +32,8 @@ } master_service_client_connection_accept(conn); - doveadm_client = client_connection_create(conn->fd, conn->listen_fd); + doveadm_client = client_connection_create(conn->fd, conn->listen_fd, + conn->ssl); } static void main_preinit(void) From dovecot at dovecot.org Mon Feb 25 15:55:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 15:55:26 +0200 Subject: dovecot-2.2: dsync: Added tcps (TCP+SSL) target. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/95ecdd9e13bf changeset: 15934:95ecdd9e13bf user: Timo Sirainen date: Mon Feb 25 15:55:06 2013 +0200 description: dsync: Added tcps (TCP+SSL) target. diffstat: src/doveadm/doveadm-server.h | 1 + src/doveadm/doveadm-settings.c | 6 ++ src/doveadm/doveadm-settings.h | 3 + src/doveadm/dsync/Makefile.am | 1 + src/doveadm/dsync/doveadm-dsync.c | 40 +++++++++++++++++- src/doveadm/server-connection.c | 84 ++++++++++++++++++++++++++++++++++++-- src/doveadm/server-connection.h | 4 +- 7 files changed, 129 insertions(+), 10 deletions(-) diffs (truncated from 317 to 300 lines): diff -r 9a7680fe65ce -r 95ecdd9e13bf src/doveadm/doveadm-server.h --- a/src/doveadm/doveadm-server.h Mon Feb 25 15:54:01 2013 +0200 +++ b/src/doveadm/doveadm-server.h Mon Feb 25 15:55:06 2013 +0200 @@ -8,6 +8,7 @@ struct doveadm_server { const char *name; + struct ssl_iostream_context *ssl_ctx; ARRAY(struct server_connection *) connections; ARRAY_TYPE(string) queue; diff -r 9a7680fe65ce -r 95ecdd9e13bf src/doveadm/doveadm-settings.c --- a/src/doveadm/doveadm-settings.c Mon Feb 25 15:54:01 2013 +0200 +++ b/src/doveadm/doveadm-settings.c Mon Feb 25 15:55:06 2013 +0200 @@ -65,6 +65,9 @@ DEF(SET_STR, dsync_alt_char), DEF(SET_STR, dsync_remote_cmd), + DEF(SET_STR, ssl_client_ca_dir), + DEF(SET_STR, ssl_crypto_device), + { SET_STRLIST, "plugin", offsetof(struct doveadm_settings, plugin_envs), NULL }, SETTING_DEFINE_LIST_END @@ -83,6 +86,9 @@ .dsync_alt_char = "_", .dsync_remote_cmd = "ssh -l%{login} %{host} doveadm dsync-server -u%u", + .ssl_client_ca_dir = "", + .ssl_crypto_device = "", + .plugin_envs = ARRAY_INIT }; diff -r 9a7680fe65ce -r 95ecdd9e13bf src/doveadm/doveadm-settings.h --- a/src/doveadm/doveadm-settings.h Mon Feb 25 15:54:01 2013 +0200 +++ b/src/doveadm/doveadm-settings.h Mon Feb 25 15:55:06 2013 +0200 @@ -14,6 +14,9 @@ const char *dsync_alt_char; const char *dsync_remote_cmd; + const char *ssl_client_ca_dir; + const char *ssl_crypto_device; + ARRAY(const char *) plugin_envs; }; diff -r 9a7680fe65ce -r 95ecdd9e13bf src/doveadm/dsync/Makefile.am --- a/src/doveadm/dsync/Makefile.am Mon Feb 25 15:54:01 2013 +0200 +++ b/src/doveadm/dsync/Makefile.am Mon Feb 25 15:55:06 2013 +0200 @@ -4,6 +4,7 @@ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-test \ -I$(top_srcdir)/src/lib-settings \ + -I$(top_srcdir)/src/lib-ssl-iostream \ -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-mail \ -I$(top_srcdir)/src/lib-imap \ diff -r 9a7680fe65ce -r 95ecdd9e13bf src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 15:54:01 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 15:55:06 2013 +0200 @@ -7,6 +7,7 @@ #include "fd-set-nonblock.h" #include "istream.h" #include "ostream.h" +#include "iostream-ssl.h" #include "iostream-rawlog.h" #include "write-full.h" #include "str.h" @@ -14,6 +15,7 @@ #include "var-expand.h" #include "settings-parser.h" #include "master-service.h" +#include "master-service-ssl-settings.h" #include "mail-storage-service.h" #include "mail-user.h" #include "mail-namespace.h" @@ -58,6 +60,9 @@ struct istream *input, *err_stream; struct ostream *output; + struct ssl_iostream_context *ssl_ctx; + struct ssl_iostream *ssl_iostream; + enum dsync_run_type run_type; struct server_connection *tcp_conn; const char *error; @@ -489,6 +494,10 @@ dsync_ibc_deinit(&ibc); if (ibc2 != NULL) dsync_ibc_deinit(&ibc2); + if (ctx->ssl_iostream != NULL) + ssl_iostream_destroy(&ctx->ssl_iostream); + if (ctx->ssl_ctx != NULL) + ssl_iostream_context_deinit(&ctx->ssl_ctx); if (ctx->fd_in != -1) { if (ctx->fd_out != ctx->fd_in) i_close_fd(&ctx->fd_out); @@ -529,7 +538,7 @@ break; case SERVER_CMD_REPLY_OK: server_connection_extract(ctx->tcp_conn, &ctx->input, - &ctx->output); + &ctx->output, &ctx->ssl_iostream); ctx->fd_in = ctx->fd_out = -1; break; case SERVER_CMD_REPLY_INTERNAL_FAILURE: @@ -541,8 +550,21 @@ io_loop_stop(current_ioloop); } +static int dsync_init_ssl_ctx(struct dsync_cmd_context *ctx) +{ + struct ssl_iostream_settings ssl_set; + + memset(&ssl_set, 0, sizeof(ssl_set)); + ssl_set.ca_dir = doveadm_settings->ssl_client_ca_dir; + ssl_set.verify_remote_cert = TRUE; + ssl_set.crypto_device = doveadm_settings->ssl_crypto_device; + + return ssl_iostream_context_init_client("doveadm", &ssl_set, + &ctx->ssl_ctx); +} + static int dsync_connect_tcp(struct dsync_cmd_context *ctx, const char *target, - const char **error_r) + bool ssl, const char **error_r) { struct doveadm_server *server; struct server_connection *conn; @@ -551,6 +573,13 @@ server = p_new(ctx->ctx.pool, struct doveadm_server, 1); server->name = p_strdup(ctx->ctx.pool, target); + if (ssl) { + if (dsync_init_ssl_ctx(ctx) < 0) { + *error_r = "Couldn't initialize SSL context"; + return -1; + } + server->ssl_ctx = ctx->ssl_ctx; + } p_array_init(&server->connections, ctx->ctx.pool, 1); p_array_init(&server->queue, ctx->ctx.pool, 1); @@ -596,7 +625,12 @@ if (strncmp(location, "tcp:", 4) == 0) { /* TCP connection to remote dsync */ ctx->remote_name = location+4; - return dsync_connect_tcp(ctx, ctx->remote_name, error_r); + return dsync_connect_tcp(ctx, ctx->remote_name, FALSE, error_r); + } + if (strncmp(location, "tcps:", 5) == 0) { + /* TCP+SSL connection to remote dsync */ + ctx->remote_name = location+5; + return dsync_connect_tcp(ctx, ctx->remote_name, TRUE, error_r); } if (strncmp(location, "remote:", 7) == 0) { diff -r 9a7680fe65ce -r 95ecdd9e13bf src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Mon Feb 25 15:54:01 2013 +0200 +++ b/src/doveadm/server-connection.c Mon Feb 25 15:55:06 2013 +0200 @@ -9,6 +9,7 @@ #include "ostream.h" #include "str.h" #include "strescape.h" +#include "iostream-ssl.h" #include "master-service.h" #include "master-service-settings.h" #include "settings-parser.h" @@ -38,6 +39,7 @@ struct io *io; struct istream *input; struct ostream *output; + struct ssl_iostream *ssl_iostream; const char *delayed_cmd; server_cmd_callback_t *callback; @@ -313,6 +315,67 @@ return 0; } +static int server_connection_ssl_handshaked(void *context) +{ + struct server_connection *conn = context; + const char *host, *p; + + host = conn->server->name; + p = strrchr(host, ':'); + if (p != NULL) + host = t_strdup_until(host, p); + + if (!ssl_iostream_has_valid_client_cert(conn->ssl_iostream)) { + if (!ssl_iostream_has_broken_client_cert(conn->ssl_iostream)) { + i_error("%s: SSL certificate not received", + conn->server->name); + } else { + i_error("%s: Received invalid SSL certificate", + conn->server->name); + } + } else if (ssl_iostream_cert_match_name(conn->ssl_iostream, host) < 0) { + i_error("%s: SSL certificate doesn't match host name", + conn->server->name); + } else { + if (doveadm_debug) { + i_debug("%s: SSL handshake successful", + conn->server->name); + } + return 0; + } + i_stream_close(conn->input); + return -1; +} + +static int server_connection_init_ssl(struct server_connection *conn) +{ + struct ssl_iostream_settings ssl_set; + + if (conn->server->ssl_ctx == NULL) + return 0; + + memset(&ssl_set, 0, sizeof(ssl_set)); + ssl_set.verify_remote_cert = TRUE; + ssl_set.require_valid_cert = TRUE; + ssl_set.verbose_invalid_cert = TRUE; + + if (io_stream_create_ssl(conn->server->ssl_ctx, "doveadm", &ssl_set, + &conn->input, &conn->output, + &conn->ssl_iostream) < 0) { + i_error("Couldn't initialize SSL client"); + return -1; + } + ssl_iostream_set_handshake_callback(conn->ssl_iostream, + server_connection_ssl_handshaked, + conn); + if (ssl_iostream_handshake(conn->ssl_iostream) < 0) { + i_error("SSL handshake failed: %s", + ssl_iostream_get_last_error(conn->ssl_iostream)); + return -1; + } + return 0; +} + int server_connection_create(struct doveadm_server *server, struct server_connection **conn_r) { @@ -330,15 +393,19 @@ conn->io = io_add(conn->fd, IO_READ, server_connection_input, conn); conn->input = i_stream_create_fd(conn->fd, MAX_INBUF_SIZE, FALSE); conn->output = o_stream_create_fd(conn->fd, (size_t)-1, FALSE); + + array_append(&conn->server->connections, &conn, 1); + + if (server_connection_read_settings(conn) < 0 || + server_connection_init_ssl(conn) < 0) { + server_connection_destroy(&conn); + return -1; + } + o_stream_set_no_error_handling(conn->output, TRUE); conn->state = SERVER_REPLY_STATE_DONE; o_stream_nsend_str(conn->output, DOVEADM_SERVER_HANDSHAKE); - array_append(&conn->server->connections, &conn, 1); - if (server_connection_read_settings(conn) < 0) { - server_connection_destroy(&conn); - return -1; - } *conn_r = conn; return 0; } @@ -370,6 +437,8 @@ i_stream_destroy(&conn->input); if (conn->output != NULL) o_stream_destroy(&conn->output); + if (conn->ssl_iostream != NULL) + ssl_iostream_unref(&conn->ssl_iostream); if (conn->io != NULL) io_remove(&conn->io); if (conn->fd != -1) { @@ -406,13 +475,16 @@ void server_connection_extract(struct server_connection *conn, struct istream **istream_r, - struct ostream **ostream_r) + struct ostream **ostream_r, + struct ssl_iostream **ssl_iostream_r) { *istream_r = conn->input; *ostream_r = conn->output; + *ssl_iostream_r = conn->ssl_iostream; conn->input = NULL; conn->output = NULL; + conn->ssl_iostream = NULL; if (conn->io != NULL) io_remove(&conn->io); conn->fd = -1; diff -r 9a7680fe65ce -r 95ecdd9e13bf src/doveadm/server-connection.h --- a/src/doveadm/server-connection.h Mon Feb 25 15:54:01 2013 +0200 +++ b/src/doveadm/server-connection.h Mon Feb 25 15:55:06 2013 +0200 From dovecot at dovecot.org Mon Feb 25 16:13:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 16:13:09 +0200 Subject: dovecot-2.2: Reverted the recent hash.h changes. Instead use -Wn... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4baf0183f13d changeset: 15935:4baf0183f13d user: Timo Sirainen date: Mon Feb 25 16:12:49 2013 +0200 description: Reverted the recent hash.h changes. Instead use -Wno-duplicate-decl-specifier with clang. The modified version required hash table users to know the structs' contents, which isn't otherwise necessary. diffstat: configure.ac | 11 ++++++++++- src/lib/hash-decl.h | 1 + src/lib/hash.h | 10 +++++----- src/lib/macros.h | 3 --- 4 files changed, 16 insertions(+), 9 deletions(-) diffs (93 lines): diff -r 95ecdd9e13bf -r 4baf0183f13d configure.ac --- a/configure.ac Mon Feb 25 15:55:06 2013 +0200 +++ b/configure.ac Mon Feb 25 16:12:49 2013 +0200 @@ -318,7 +318,16 @@ # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast" - if test "$have_clang" != "yes"; then + if test "$have_clang" = "yes"; then + AC_TRY_COMPILE([ + #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3) + # error new clang + #endif + ],,,[ + # clang 3.3+ unfortunately this gives warnings with hash.h + CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier" + ]) + else # This is simply to avoid warning when building strftime() wrappers.. CFLAGS="$CFLAGS -fno-builtin-strftime" fi diff -r 95ecdd9e13bf -r 4baf0183f13d src/lib/hash-decl.h --- a/src/lib/hash-decl.h Mon Feb 25 15:55:06 2013 +0200 +++ b/src/lib/hash-decl.h Mon Feb 25 16:12:49 2013 +0200 @@ -5,6 +5,7 @@ struct hash_table *_table; \ key_type _key; \ key_type *_keyp; \ + const key_type _const_key; \ value_type _value; \ value_type *_valuep; \ } diff -r 95ecdd9e13bf -r 4baf0183f13d src/lib/hash.h --- a/src/lib/hash.h Mon Feb 25 15:55:06 2013 +0200 +++ b/src/lib/hash.h Mon Feb 25 16:12:49 2013 +0200 @@ -31,12 +31,12 @@ !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ int (*)(typeof((*table)._key), typeof((*table)._key))) && \ !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ - int (*)(typeof(const typeof(*(*table)._key) *), typeof(const typeof(*(*table)._key) *)))); \ + int (*)(typeof((*table)._const_key), typeof((*table)._const_key)))); \ (void)COMPILE_ERROR_IF_TRUE( \ !__builtin_types_compatible_p(typeof(&hash_cb), \ unsigned int (*)(typeof((*table)._key))) && \ !__builtin_types_compatible_p(typeof(&hash_cb), \ - unsigned int (*)(typeof(const typeof(*(*table)._key) *)))); \ + unsigned int (*)(typeof((*table)._const_key)))); \ hash_table_create(&(*table)._table, pool, size, \ (hash_callback_t *)hash_cb, \ (hash_cmp_callback_t *)key_cmp_cb);}) @@ -77,14 +77,14 @@ void *hash_table_lookup(const struct hash_table *table, const void *key) ATTR_PURE; #define hash_table_lookup(table, key) \ HASH_VALUE_CAST(table)hash_table_lookup((table)._table, \ - (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key))) + (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._key, (table)._const_key, key))) bool hash_table_lookup_full(const struct hash_table *table, const void *lookup_key, void **orig_key_r, void **value_r); #define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \ hash_table_lookup_full((table)._table, \ - (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, lookup_key)), \ + (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \ (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \ COMPILE_ERROR_IF_TRUE(sizeof(*orig_key_r) != sizeof(void *))), \ (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \ @@ -106,7 +106,7 @@ void hash_table_remove(struct hash_table *table, const void *key); #define hash_table_remove(table, key) \ hash_table_remove((table)._table, \ - (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key))) + (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, key))) unsigned int hash_table_count(const struct hash_table *table) ATTR_PURE; #define hash_table_count(table) \ hash_table_count((table)._table) diff -r 95ecdd9e13bf -r 4baf0183f13d src/lib/macros.h --- a/src/lib/macros.h Mon Feb 25 15:55:06 2013 +0200 +++ b/src/lib/macros.h Mon Feb 25 16:12:49 2013 +0200 @@ -160,13 +160,10 @@ COMPILE_ERROR_IF_TRUE( \ !__builtin_types_compatible_p(typeof(_a1), typeof(_b)) && \ !__builtin_types_compatible_p(typeof(_a2), typeof(_b))) -#define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) \ - COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a, typeof(const typeof(*_a) *), _b) #else # define COMPILE_ERROR_IF_TRUE(condition) 0 # define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) 0 # define COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a1, _a2, _b) 0 -# define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) 0 #endif #if __GNUC__ > 2 From dovecot at dovecot.org Mon Feb 25 16:45:08 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 16:45:08 +0200 Subject: dovecot-2.1: maildir: Preserve [SW]=sizes when renaming a maildi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cfd3f39102bd changeset: 14924:cfd3f39102bd user: Timo Sirainen date: Mon Feb 25 16:44:57 2013 +0200 description: maildir: Preserve [SW]=sizes when renaming a maildir duplicate file. diffstat: src/lib-storage/index/maildir/maildir-sync.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diffs (28 lines): diff -r 10c1eb4ddef2 -r cfd3f39102bd src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Sun Feb 24 15:52:57 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 16:44:57 2013 +0200 @@ -288,6 +288,7 @@ const char *fname1, *path1, *path2; const char *new_fname, *new_path; struct stat st1, st2; + uoff_t size; fname1 = maildir_uidlist_sync_get_full_filename(ctx->uidlist_sync_ctx, fname2); @@ -330,6 +331,16 @@ } new_fname = maildir_filename_generate(); + /* preserve S= and W= sizes if they're available. + (S=size is required for zlib plugin to work) */ + if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_FILE_SIZE, &size)) { + new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T, + new_fname, MAILDIR_EXTRA_FILE_SIZE, size); + } + if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_VIRTUAL_SIZE, &size)) { + new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T, + new_fname, MAILDIR_EXTRA_VIRTUAL_SIZE, size); + } new_path = t_strconcat(mailbox_get_path(&ctx->mbox->box), "/new/", new_fname, NULL); From dovecot at dovecot.org Mon Feb 25 16:58:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 16:58:10 +0200 Subject: dovecot-2.2: dsync: Don't close stdin/stdout when not supposed to. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/608d07701d54 changeset: 15936:608d07701d54 user: Timo Sirainen date: Mon Feb 25 16:58:02 2013 +0200 description: dsync: Don't close stdin/stdout when not supposed to. diffstat: src/doveadm/dsync/doveadm-dsync.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diffs (31 lines): diff -r 4baf0183f13d -r 608d07701d54 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 16:12:49 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 16:58:02 2013 +0200 @@ -539,7 +539,6 @@ case SERVER_CMD_REPLY_OK: server_connection_extract(ctx->tcp_conn, &ctx->input, &ctx->output, &ctx->ssl_iostream); - ctx->fd_in = ctx->fd_out = -1; break; case SERVER_CMD_REPLY_INTERNAL_FAILURE: ctx->error = "Disconnected from remote"; @@ -662,8 +661,8 @@ user_set = mail_storage_service_user_get_set(service_user)[0]; - ctx->fd_in = STDIN_FILENO; - ctx->fd_out = STDOUT_FILENO; + ctx->fd_in = -1; + ctx->fd_out = -1; ctx->fd_err = -1; ctx->run_type = DSYNC_RUN_TYPE_LOCAL; ctx->remote_name = "remote"; @@ -700,6 +699,8 @@ if (remote_cmd_args != NULL) { /* do this before mail_storage_service_next() in case it drops process privileges */ + ctx->fd_in = STDIN_FILENO; + ctx->fd_out = STDIN_FILENO; run_cmd(ctx, remote_cmd_args); ctx->run_type = DSYNC_RUN_TYPE_CMD; } From dovecot at dovecot.org Mon Feb 25 17:08:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:08:01 +0200 Subject: dovecot-2.2: dsync: Minor code cleanup. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c20696d7ecb0 changeset: 15937:c20696d7ecb0 user: Timo Sirainen date: Mon Feb 25 17:07:38 2013 +0200 description: dsync: Minor code cleanup. diffstat: src/doveadm/dsync/doveadm-dsync.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diffs (12 lines): diff -r 608d07701d54 -r c20696d7ecb0 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 16:58:02 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 17:07:38 2013 +0200 @@ -699,8 +699,6 @@ if (remote_cmd_args != NULL) { /* do this before mail_storage_service_next() in case it drops process privileges */ - ctx->fd_in = STDIN_FILENO; - ctx->fd_out = STDIN_FILENO; run_cmd(ctx, remote_cmd_args); ctx->run_type = DSYNC_RUN_TYPE_CMD; } From dovecot at dovecot.org Mon Feb 25 17:08:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:08:01 +0200 Subject: dovecot-2.2: dsync-server: Don't crash if connection didn't come... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c0deb3a9bb3d changeset: 15938:c0deb3a9bb3d user: Timo Sirainen date: Mon Feb 25 17:07:55 2013 +0200 description: dsync-server: Don't crash if connection didn't come from doveadm-server diffstat: src/doveadm/dsync/doveadm-dsync.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (18 lines): diff -r c20696d7ecb0 -r c0deb3a9bb3d src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 17:07:38 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 25 17:07:55 2013 +0200 @@ -846,9 +846,11 @@ _ctx->exit_code = EX_TEMPFAIL; dsync_ibc_deinit(&ibc); - /* make sure nothing more is written by the generic doveadm - connection code */ - o_stream_close(_ctx->conn->output); + if (_ctx->conn != NULL) { + /* make sure nothing more is written by the generic doveadm + connection code */ + o_stream_close(_ctx->conn->output); + } return _ctx->exit_code == 0 ? 0 : -1; } From dovecot at dovecot.org Mon Feb 25 17:23:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:23:39 +0200 Subject: dovecot-2.2: Fixed checking UTF8 input validity. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2aee41cd72b0 changeset: 15939:2aee41cd72b0 user: Timo Sirainen date: Mon Feb 25 17:23:25 2013 +0200 description: Fixed checking UTF8 input validity. diffstat: src/lib/unichar.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r c0deb3a9bb3d -r 2aee41cd72b0 src/lib/unichar.c --- a/src/lib/unichar.c Mon Feb 25 17:07:55 2013 +0200 +++ b/src/lib/unichar.c Mon Feb 25 17:23:25 2013 +0200 @@ -38,7 +38,7 @@ int uni_utf8_get_char_n(const void *_input, size_t max_len, unichar_t *chr_r) { static unichar_t lowest_valid_chr_table[] = - { 0, 0, 0x80, 0x800, 0x10000, 0x20000, 0x40000 }; + { 0, 0, 0x80, 0x800, 0x10000, 0x200000, 0x4000000 }; const unsigned char *input = _input; unichar_t chr, lowest_valid_chr; unsigned int i, len; From dovecot at dovecot.org Mon Feb 25 17:24:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:24:10 +0200 Subject: dovecot-2.1: Fixed checking UTF8 input validity. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fa9387588430 changeset: 14925:fa9387588430 user: Timo Sirainen date: Mon Feb 25 17:23:25 2013 +0200 description: Fixed checking UTF8 input validity. diffstat: src/lib/unichar.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r cfd3f39102bd -r fa9387588430 src/lib/unichar.c --- a/src/lib/unichar.c Mon Feb 25 16:44:57 2013 +0200 +++ b/src/lib/unichar.c Mon Feb 25 17:23:25 2013 +0200 @@ -38,7 +38,7 @@ int uni_utf8_get_char_n(const void *_input, size_t max_len, unichar_t *chr_r) { static unichar_t lowest_valid_chr_table[] = - { 0, 0, 0x80, 0x800, 0x10000, 0x20000, 0x40000 }; + { 0, 0, 0x80, 0x800, 0x10000, 0x200000, 0x4000000 }; const unsigned char *input = _input; unichar_t chr, lowest_valid_chr; unsigned int i, len; From dovecot at dovecot.org Mon Feb 25 17:25:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:25:19 +0200 Subject: dovecot-2.2: TODO updated Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/539baf0adc2e changeset: 15940:539baf0adc2e user: Timo Sirainen date: Mon Feb 25 17:25:10 2013 +0200 description: TODO updated diffstat: TODO | 35 +++++++---------------------------- 1 files changed, 7 insertions(+), 28 deletions(-) diffs (117 lines): diff -r 2aee41cd72b0 -r 539baf0adc2e TODO --- a/TODO Mon Feb 25 17:23:25 2013 +0200 +++ b/TODO Mon Feb 25 17:25:10 2013 +0200 @@ -1,4 +1,3 @@ - - dsync over tcp - if transaction log file corruption is noticed, make sure new dovecot.index snapshot gets written and don't mark the whole file corrupted.. rather maybe just rotate and truncate it @@ -45,6 +44,10 @@ so mail_storage_settings are copied to mail_namespace_settings. use the change tracking to figure out what settings are namespace-specific. + - doveadm import: add -d parameter to deduplicate mails based on their GUID + (or perhaps do it by default?) + - sdbox: altmoving is done with mailbox locked. that's not necessary, it could + do the copying while unlocked and delete the primary files while locked - passdb, userdb { username_format } that doesn't permanently change the username - mdbox/sdbox index rebuild -> quota rebuild? @@ -61,10 +64,7 @@ - with in-memory indexes be sure to refresh it more often - refreshing could refresh only the parts that are actually requested, e.g. % - - mailbox_get_metadata(guid) could be optimized - virtual could use it to avoid keeping all mailboxes open - - check: - - dsyncing between two namespace separators is probably broken.. - remove mail_deliver_session after all, do all the stuff transparently by hooking into mailbox_copy(). - use this hook also to do the mail deduplication: 1) sort all destination @@ -93,13 +93,14 @@ - sent, drafts: .Sent/dovecot.index: modseq_hdr.log_offset too large - mail_max_lock_timeout error could be reported more nicely, also ones coming from lib-index - - dsync: if mailbox is renamed due to it being invalid, its subscription - isn't renamed - sql pool: if async query is pending and sync query is sent and there are no more empty connections, it should flush the async query first - NTLMv1 and LM should be disabled if disable_plaintext_auth=yes - SEARCH SENT*/HEADER/etc. doesn't seem optimized when using with TEXT/BODY - dict sql: support ignoring some search key hierarchies (e.g. acl "anyone") + - dsync: avoid sending email when it could be copied from another mailbox. + probably requires storage to have guid => { instances } map? that's + rather annoying to add. - mdbox - dotlocking: cleanup should delete stale *.lock files @@ -124,7 +125,6 @@ - maildir: out-of-disk-space failures apparently cause all kinds of problems, e.g. "Expunged message reappeared", "Duplicate file entry"? - deliver -r
used as autoreplies' From-address? - - add fd limit checks/warnings - istream-seekable is inefficient. it shouldn't be reading the temp file immediately after writing to it - config process is handling requests too slowly. maybe add some caching. @@ -134,17 +134,6 @@ - ipv6: auth penalty should begin from /64 and gradually grow to /48 if necessary. and the same could be done for ipv4 as well.. - - dsync: - - check for uid conflicts in the middle of mailbox based on next existing - message, not previous - - subscriptions syncing doesn't handle mixed hierarchy separators - - Can't rename mailbox INBOX_019acf2169c5784b307f000074ccac23 to INBOX: Target mailbox already exists - - copying can't work in non-full mode unless source mailbox is modified - in some way. possibly add some COPY records to transaction log in future? - - superfast mode: when syncing changes within a mailbox, use modseqs to - figure out what has changed similar to QRESYNC. - - - lda: add some -h 'Header: value' parameter that adds/replaces header - ldap: fix multiple-gid support somehow - search: use mail_get_parts() only when it's already cached. if it's not, add it to cache afterwards. @@ -155,18 +144,12 @@ //FIXME:i_assert((t->flags & MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL) != 0); ^ appears to work now though, probably because of the added syncing stuff.. - - transaction log corruption should make sure dovecot.index is rewritten - and perhaps not delete the file. - use backup index in mail_index_fsck() - - proxying: support fallbacking to local (or other?) server if the first one is down - i_panic("Message count decreased") happens - why? - at least one backtrace shows client_destroy -> client_command_cancel -> imap_sync_deinit - - fsck -> log_file_tail_offset 2273345664 -> 996 -> - mail-transaction-log.c: line 341 (mail_transaction_log_set_mailbox_sync_pos): - assertion failed: (file_offset >= log->head->saved_tail_offset) - virtual: If last message matching INTHREAD rule gets expunged, the rest of the thread doesn't go away - how do shared mailboxes work with plugins? @@ -180,7 +163,6 @@ dovecot-acl files? at least not that often.. - fs quota: getquotaroot inbox vs. other-box should return different quotas if two quotas are defined - - new primes code: are hash tables now being resized too often? - auth_log_prefix setting similar to mail_log_prefix - thread indexes: if we expunge a duplicate message-id: and we have a sibling @@ -221,8 +203,6 @@ } - maildir+pop3 fast updates: - - with locking enabled, pop3 could just keep the one and same sync lock and - do the whole thing using sync transaction - don't update dovecot-uidlist if dovecot.index.cache doesn't exist / there's nothing to cache - if all messages are expunged and there are no unknown extensions in index, @@ -268,7 +248,6 @@ - COPY doesn't work to itself (lock assert crash, for now just disallowed) - index - - read-only support for mailboxes where we don't have write-access - index file format changes: - split to "old" and "new" indexes and try to avoid loading "old" into memory until needed From dovecot at dovecot.org Mon Feb 25 17:48:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:20 +0200 Subject: dovecot-2.2: imap: Allocate LIST patterns from command pool so t... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6c9b182d9a8c changeset: 15941:6c9b182d9a8c user: Timo Sirainen date: Thu Feb 21 19:58:39 2013 +0200 description: imap: Allocate LIST patterns from command pool so they don't get corrupted in long runs. diffstat: src/imap/cmd-list.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 20ea109b30a7 -r 6c9b182d9a8c src/imap/cmd-list.c --- a/src/imap/cmd-list.c Thu Feb 21 07:55:24 2013 +0200 +++ b/src/imap/cmd-list.c Thu Feb 21 19:58:39 2013 +0200 @@ -1026,7 +1026,7 @@ return TRUE; } if (imap_utf7_to_utf8(pattern, str) == 0) - pattern = t_strdup(str_c(str)); + pattern = p_strdup(cmd->pool, str_c(str)); array_append(&patterns, &pattern, 1); str_truncate(str, 0); } @@ -1037,7 +1037,7 @@ return TRUE; } if (imap_utf7_to_utf8(pattern, str) == 0) - pattern = str_c(str); + pattern = p_strdup(cmd->pool, str_c(str)); p_array_init(&patterns, cmd->pool, 1); array_append(&patterns, &pattern, 1); From dovecot at dovecot.org Mon Feb 25 17:48:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:20 +0200 Subject: dovecot-2.2: quota-status: Fixed compiling with older autotools. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8ec52854e823 changeset: 15942:8ec52854e823 user: Timo Sirainen date: Fri Feb 22 07:37:18 2013 +0200 description: quota-status: Fixed compiling with older autotools. diffstat: src/plugins/quota/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (10 lines): diff -r 6c9b182d9a8c -r 8ec52854e823 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Thu Feb 21 19:58:39 2013 +0200 +++ b/src/plugins/quota/Makefile.am Fri Feb 22 07:37:18 2013 +0200 @@ -1,5 +1,6 @@ doveadm_moduledir = $(moduledir)/doveadm +pkglibexecdir = $(libexecdir)/dovecot pkglibexec_PROGRAMS = quota-status AM_CPPFLAGS = \ From dovecot at dovecot.org Mon Feb 25 17:48:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:20 +0200 Subject: dovecot-2.2: mdbox: Don't try to undelete any mailboxes in stora... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9cb64709dd8c changeset: 15943:9cb64709dd8c user: Timo Sirainen date: Fri Feb 22 09:43:59 2013 +0200 description: mdbox: Don't try to undelete any mailboxes in storage rebuild to avoid assert-crashes. diffstat: src/lib-storage/mail-storage.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 8ec52854e823 -r 9cb64709dd8c src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Feb 22 07:37:18 2013 +0200 +++ b/src/lib-storage/mail-storage.c Fri Feb 22 09:43:59 2013 +0200 @@ -928,6 +928,13 @@ { time_t mtime; + if ((box->flags & MAILBOX_FLAG_READONLY) != 0) { + /* most importantly we don't do this because we want to avoid + a loop: mdbox storage rebuild -> mailbox_open() -> + mailbox_mark_index_deleted() -> mailbox_sync() -> + mdbox storage rebuild. */ + return FALSE; + } if (mail_index_get_modification_time(box->index, &mtime) < 0) return FALSE; if (mtime + MAILBOX_DELETE_RETRY_SECS > time(NULL)) From dovecot at dovecot.org Mon Feb 25 17:48:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:20 +0200 Subject: dovecot-2.2: mdbox: If m.X file has no mails, don't try to fix i... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b91e1b94af21 changeset: 15944:b91e1b94af21 user: Timo Sirainen date: Fri Feb 22 10:01:06 2013 +0200 description: mdbox: If m.X file has no mails, don't try to fix it infinitely in storage rebuild. diffstat: src/lib-storage/index/dbox-common/dbox-file-fix.c | 14 ++++++++++++-- src/lib-storage/index/dbox-common/dbox-file.h | 3 ++- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 6 ++++-- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diffs (85 lines): diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-common/dbox-file-fix.c --- a/src/lib-storage/index/dbox-common/dbox-file-fix.c Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c Fri Feb 22 10:01:06 2013 +0200 @@ -291,7 +291,7 @@ { struct ostream *output; const char *dir, *p, *temp_path, *broken_path; - bool deleted; + bool deleted, have_messages; int fd, ret; i_assert(dbox_file_is_open(file)); @@ -307,6 +307,7 @@ output = o_stream_create_fd_file(fd, 0, FALSE); ret = dbox_file_fix_write_stream(file, start_offset, temp_path, output); + have_messages = output->offset > file->file_header_size; o_stream_unref(&output); if (close(fd) < 0) { mail_storage_set_critical(&file->storage->storage, @@ -332,6 +333,15 @@ i_warning("dbox: Copy of the broken file saved to %s", broken_path); } + if (!have_messages) { + /* the resulting file has no messages. just delete the file. */ + dbox_file_close(file); + if (unlink(temp_path) < 0) + i_error("unlink(%s) failed: %m", temp_path); + if (unlink(file->cur_path) < 0) + i_error("unlink(%s) failed: %m", file->cur_path); + return 0; + } if (rename(temp_path, file->cur_path) < 0) { mail_storage_set_critical(&file->storage->storage, "rename(%s, %s) failed: %m", @@ -347,5 +357,5 @@ file->cur_path); return -1; } - return 0; + return 1; } diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-common/dbox-file.h --- a/src/lib-storage/index/dbox-common/dbox-file.h Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-file.h Fri Feb 22 10:01:06 2013 +0200 @@ -190,7 +190,8 @@ /* Fix a broken dbox file by rename()ing over it with a fixed file. Everything before start_offset is assumed to be valid and is simply copied. The file - is reopened afterwards. Returns 0 if ok, -1 if I/O error. */ + is reopened afterwards. Returns 1 if ok, 0 if the resulting file has no + mails and was deleted, -1 if I/O error. */ int dbox_file_fix(struct dbox_file *file, uoff_t start_offset); /* Delete the given dbox file. Returns 1 if deleted, 0 if file wasn't found or -1 if error. */ diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Fri Feb 22 10:01:06 2013 +0200 @@ -152,9 +152,11 @@ /* use existing file header if it was ok */ prev_offset = offset; } - if (dbox_file_fix(file, prev_offset) < 0) { - ret = -1; + if ((ret = dbox_file_fix(file, prev_offset)) < 0) break; + if (ret == 0) { + /* file was deleted */ + return 1; } fixed = TRUE; if (!first) { diff -r 9cb64709dd8c -r b91e1b94af21 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Fri Feb 22 09:43:59 2013 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Fri Feb 22 10:01:06 2013 +0200 @@ -39,7 +39,7 @@ ret = dbox_file_seek(file, 0); } if (ret == 0) { - if ((ret = dbox_file_fix(file, 0)) == 0) + if ((ret = dbox_file_fix(file, 0)) > 0) ret = dbox_file_seek(file, 0); } From dovecot at dovecot.org Mon Feb 25 17:48:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:20 +0200 Subject: dovecot-2.2: fts: Don't send binary MIME parts to backend throug... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b0e68c53771e changeset: 15945:b0e68c53771e user: Timo Sirainen date: Fri Feb 22 10:17:14 2013 +0200 description: fts: Don't send binary MIME parts to backend through UTF8 text conversion. Based on patch by Mike Abbott / Apple. diffstat: src/plugins/fts/fts-build-mail.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r b91e1b94af21 -r b0e68c53771e src/plugins/fts/fts-build-mail.c --- a/src/plugins/fts/fts-build-mail.c Fri Feb 22 10:01:06 2013 +0200 +++ b/src/plugins/fts/fts-build-mail.c Fri Feb 22 10:17:14 2013 +0200 @@ -170,6 +170,7 @@ strncmp(content_type, "message/", 8) == 0) { /* text body parts */ key.type = FTS_BACKEND_BUILD_KEY_BODY_PART; + ctx->body_parser = fts_parser_text_init(); } else { /* possibly binary */ if ((ctx->update_ctx->backend->flags & @@ -178,8 +179,6 @@ *binary_body_r = TRUE; key.type = FTS_BACKEND_BUILD_KEY_BODY_PART_BINARY; } - if (ctx->body_parser == NULL) - ctx->body_parser = fts_parser_text_init(); key.body_content_type = content_type; key.body_content_disposition = ctx->content_disposition; return fts_backend_update_set_build_key(ctx->update_ctx, &key); From dovecot at dovecot.org Mon Feb 25 17:48:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:20 +0200 Subject: dovecot-2.2: indexer-worker: Fixed keeping config connection ope... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6d45b9bd1cff changeset: 15946:6d45b9bd1cff user: Timo Sirainen date: Fri Feb 22 10:42:40 2013 +0200 description: indexer-worker: Fixed keeping config connection open before dropping root privileges. The initial settings reading doesn't really do anything, since the real settings are again read by mail-storage-service. diffstat: src/indexer/indexer-worker.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (21 lines): diff -r b0e68c53771e -r 6d45b9bd1cff src/indexer/indexer-worker.c --- a/src/indexer/indexer-worker.c Fri Feb 22 10:17:14 2013 +0200 +++ b/src/indexer/indexer-worker.c Fri Feb 22 10:42:40 2013 +0200 @@ -45,6 +45,8 @@ int main(int argc, char *argv[]) { + enum master_service_flags service_flags = + MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN; enum mail_storage_service_flags storage_service_flags = MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT | MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | @@ -52,7 +54,7 @@ MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT; int c; - master_service = master_service_init("indexer-worker", 0, + master_service = master_service_init("indexer-worker", service_flags, &argc, &argv, "D"); while ((c = master_getopt(master_service)) > 0) { switch (c) { From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: dict-sql: Iterating with multiple SQL queries didn'... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0e0fd4b5a582 changeset: 15947:0e0fd4b5a582 user: Timo Sirainen date: Fri Feb 22 12:12:26 2013 +0200 description: dict-sql: Iterating with multiple SQL queries didn't free all the queries. diffstat: src/lib-dict/dict-sql.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 6d45b9bd1cff -r 0e0fd4b5a582 src/lib-dict/dict-sql.c --- a/src/lib-dict/dict-sql.c Fri Feb 22 10:42:40 2013 +0200 +++ b/src/lib-dict/dict-sql.c Fri Feb 22 12:12:26 2013 +0200 @@ -351,6 +351,9 @@ if (map == NULL) return FALSE; + if (ctx->result != NULL) + sql_result_unref(ctx->result); + T_BEGIN { string_t *query = t_str_new(256); From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: lib-lda: Give a better error message if dotlocking ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/81ea622b6394 changeset: 15948:81ea622b6394 user: Timo Sirainen date: Fri Feb 22 12:19:36 2013 +0200 description: lib-lda: Give a better error message if dotlocking duplicate db fails. diffstat: src/lib-lda/duplicate.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 0e0fd4b5a582 -r 81ea622b6394 src/lib-lda/duplicate.c --- a/src/lib-lda/duplicate.c Fri Feb 22 12:12:26 2013 +0200 +++ b/src/lib-lda/duplicate.c Fri Feb 22 12:19:36 2013 +0200 @@ -212,8 +212,14 @@ file->path = p_strdup(pool, ctx->path); file->new_fd = file_dotlock_open(&ctx->dotlock_set, file->path, 0, &file->dotlock); - if (file->new_fd == -1) - i_error("file_dotlock_create(%s) failed: %m", file->path); + if (file->new_fd != -1) + ; + else if (errno != EAGAIN) + i_error("file_dotlock_open(%s) failed: %m", file->path); + else { + i_error("Creating lock file for %s timed out in %u secs", + file->path, ctx->dotlock_set.timeout); + } file->hash = hash_table_create(default_pool, pool, 0, duplicate_hash, duplicate_cmp); (void)duplicate_read(file); From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: lib-dict: Fixed hang if async commit's callback did... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/225c64ed0439 changeset: 15949:225c64ed0439 user: Timo Sirainen date: Fri Feb 22 13:51:02 2013 +0200 description: lib-dict: Fixed hang if async commit's callback did more dict access. Specifically this fixes a hang with dict-quota plugin when user didn't exist and quota was changed before calculating it. diffstat: src/lib-dict/dict-client.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diffs (26 lines): diff -r 81ea622b6394 -r 225c64ed0439 src/lib-dict/dict-client.c --- a/src/lib-dict/dict-client.c Fri Feb 22 12:19:36 2013 +0200 +++ b/src/lib-dict/dict-client.c Fri Feb 22 13:51:02 2013 +0200 @@ -262,15 +262,17 @@ i_error("dict-client: Unknown transaction id %u", id); return; } - if (ctx->callback != NULL) - ctx->callback(ret, ctx->context); - DLLIST_REMOVE(&dict->transactions, ctx); - i_free(ctx); - + /* the callback may call the dict code again, so remove this + transaction before calling it */ i_assert(dict->async_commits > 0); if (--dict->async_commits == 0) io_remove(&dict->io); + DLLIST_REMOVE(&dict->transactions, ctx); + + if (ctx->callback != NULL) + ctx->callback(ret, ctx->context); + i_free(ctx); } static ssize_t client_dict_read_timeout(struct client_dict *dict) From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: fts-solr: Truncate header if it's over 1 MB. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0a932ba1f01f changeset: 15950:0a932ba1f01f user: Timo Sirainen date: Fri Feb 22 14:49:27 2013 +0200 description: fts-solr: Truncate header if it's over 1 MB. Previously we just warned about it. diffstat: src/plugins/fts-solr/fts-backend-solr.c | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) diffs (75 lines): diff -r 225c64ed0439 -r 0a932ba1f01f src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 22 13:51:02 2013 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr.c Fri Feb 22 14:49:27 2013 +0200 @@ -17,9 +17,14 @@ #define SOLR_CMDBUF_SIZE (1024*64) #define SOLR_CMDBUF_FLUSH_SIZE (SOLR_CMDBUF_SIZE-128) -#define SOLR_BUFFER_WARN_SIZE (1024*1024) #define SOLR_MAX_MULTI_ROWS 100000 +/* If header is larger than this, truncate it. */ +#define SOLR_HEADER_MAX_SIZE (1024*1024) +/* If SOLR_HEADER_MAX_SIZE was already reached, write still to individual + header fields as long as they're smaller than this */ +#define SOLR_HEADER_LINE_MAX_TRUNC_SIZE 1024 + struct solr_fts_backend { struct fts_backend backend; }; @@ -42,12 +47,12 @@ ARRAY_DEFINE(fields, struct solr_fts_field); uint32_t last_indexed_uid; - uint32_t size_warned_uid; unsigned int last_indexed_uid_set:1; unsigned int body_open:1; unsigned int documents_added:1; unsigned int expunges:1; + unsigned int truncate_header:1; }; static struct solr_connection *solr_conn = NULL; @@ -445,6 +450,7 @@ fts_backend_solr_doc_close(ctx); } ctx->prev_uid = uid; + ctx->truncate_header = FALSE; fts_backend_solr_doc_open(ctx, uid); } @@ -531,8 +537,11 @@ } xml_encode_data(ctx->cmd, data, size); } else { - xml_encode_data(ctx->cur_value, data, size); - if (ctx->cur_value2 != NULL) + if (!ctx->truncate_header) + xml_encode_data(ctx->cur_value, data, size); + if (ctx->cur_value2 != NULL && + (!ctx->truncate_header || + str_len(ctx->cur_value2) < SOLR_HEADER_LINE_MAX_TRUNC_SIZE)) xml_encode_data(ctx->cur_value2, data, size); } @@ -541,15 +550,15 @@ str_len(ctx->cmd)); str_truncate(ctx->cmd, 0); } - if (str_len(ctx->cur_value) >= SOLR_BUFFER_WARN_SIZE && - ctx->size_warned_uid != ctx->prev_uid) { + if (!ctx->truncate_header && + str_len(ctx->cur_value) >= SOLR_HEADER_MAX_SIZE) { /* a large header */ i_assert(ctx->cur_value != ctx->cmd); - ctx->size_warned_uid = ctx->prev_uid; - i_warning("fts-solr(%s): Mailbox %s UID=%u header size is huge", + i_warning("fts-solr(%s): Mailbox %s UID=%u header size is huge, truncating", ctx->cur_box->storage->user->username, mailbox_get_vname(ctx->cur_box), ctx->prev_uid); + ctx->truncate_header = TRUE; } return 0; } From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: lib-index: Fixed assert-crash on some error conditi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e33fe1a7bb89 changeset: 15951:e33fe1a7bb89 user: Timo Sirainen date: Fri Feb 22 15:49:35 2013 +0200 description: lib-index: Fixed assert-crash on some error conditions. diffstat: src/lib-index/mail-transaction-log-file.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 0a932ba1f01f -r e33fe1a7bb89 src/lib-index/mail-transaction-log-file.c --- a/src/lib-index/mail-transaction-log-file.c Fri Feb 22 14:49:27 2013 +0200 +++ b/src/lib-index/mail-transaction-log-file.c Fri Feb 22 15:49:35 2013 +0200 @@ -1683,7 +1683,7 @@ } if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) { - if (start_offset < file->buffer_offset) { + if (start_offset < file->buffer_offset || file->buffer == NULL) { /* we had moved the log to memory but failed to read the beginning of the log file */ mail_index_set_error(index, @@ -1691,7 +1691,6 @@ file->filepath); return 0; } - i_assert(file->buffer != NULL); return log_file_map_check_offsets(file, start_offset, end_offset); } From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: lib-storage: Fixed \Recent flag race conditions. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cd413ab7aeb3 changeset: 15952:cd413ab7aeb3 user: Timo Sirainen date: Sun Feb 24 15:50:26 2013 +0200 description: lib-storage: Fixed \Recent flag race conditions. The \Recent flags should only be set while locked within mail_index_sync_begin()..commit(). The following view syncing syncs only up to how far the index was synced, so it won't see any new messages that haven't yet been assigned a \Recent flag. diffstat: src/lib-storage/index/index-status.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diffs (23 lines): diff -r e33fe1a7bb89 -r cd413ab7aeb3 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Fri Feb 22 15:49:35 2013 +0200 +++ b/src/lib-storage/index/index-status.c Sun Feb 24 15:50:26 2013 +0200 @@ -48,9 +48,16 @@ hdr = mail_index_get_header(box->view); status_r->messages = hdr->messages_count; if ((items & STATUS_RECENT) != 0) { - /* make sure recent count is set, in case syncing hasn't - been done yet */ - index_sync_update_recent_count(box); + if ((box->flags & MAILBOX_FLAG_DROP_RECENT) != 0) { + /* recent flags are set and dropped by the previous + sync while index was locked. if we updated the + recent flags here we'd have a race condition. */ + i_assert(box->synced); + } else { + /* make sure recent count is set, in case we haven't + synced yet */ + index_sync_update_recent_count(box); + } status_r->recent = index_mailbox_get_recent_count(box); i_assert(status_r->recent <= status_r->messages); } From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: lib-storage: Fixed setting \Recent flags for sessio... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/10c1eb4ddef2 changeset: 15953:10c1eb4ddef2 user: Timo Sirainen date: Sun Feb 24 15:52:57 2013 +0200 description: lib-storage: Fixed setting \Recent flags for sessions that didn't drop them. If another session wasn't dropping the \Recent flags, no new mails were getting them unless the mailbox was reopened. diffstat: src/lib-storage/index/index-storage.h | 2 +- src/lib-storage/index/index-sync.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diffs (26 lines): diff -r cd413ab7aeb3 -r 10c1eb4ddef2 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Sun Feb 24 15:50:26 2013 +0200 +++ b/src/lib-storage/index/index-storage.h Sun Feb 24 15:52:57 2013 +0200 @@ -37,7 +37,7 @@ struct mail_cache_field *cache_fields; ARRAY_TYPE(seq_range) recent_flags; - uint32_t recent_flags_prev_uid; + uint32_t recent_flags_prev_uid, recent_flags_last_check_nextuid; uint32_t recent_flags_count; uint32_t vsize_hdr_ext_id; diff -r cd413ab7aeb3 -r 10c1eb4ddef2 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Sun Feb 24 15:50:26 2013 +0200 +++ b/src/lib-storage/index/index-sync.c Sun Feb 24 15:52:57 2013 +0200 @@ -348,7 +348,9 @@ uint32_t seq1, seq2; hdr = mail_index_get_header(box->view); - if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) { + if (hdr->first_recent_uid > ibox->recent_flags_prev_uid || + hdr->next_uid > ibox->recent_flags_last_check_nextuid) { + ibox->recent_flags_last_check_nextuid = hdr->next_uid; mail_index_lookup_seq_range(box->view, hdr->first_recent_uid, hdr->next_uid, From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: Fixed checking UTF8 input validity. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fa9387588430 changeset: 15955:fa9387588430 user: Timo Sirainen date: Mon Feb 25 17:23:25 2013 +0200 description: Fixed checking UTF8 input validity. diffstat: src/lib/unichar.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r cfd3f39102bd -r fa9387588430 src/lib/unichar.c --- a/src/lib/unichar.c Mon Feb 25 16:44:57 2013 +0200 +++ b/src/lib/unichar.c Mon Feb 25 17:23:25 2013 +0200 @@ -38,7 +38,7 @@ int uni_utf8_get_char_n(const void *_input, size_t max_len, unichar_t *chr_r) { static unichar_t lowest_valid_chr_table[] = - { 0, 0, 0x80, 0x800, 0x10000, 0x20000, 0x40000 }; + { 0, 0, 0x80, 0x800, 0x10000, 0x200000, 0x4000000 }; const unsigned char *input = _input; unichar_t chr, lowest_valid_chr; unsigned int i, len; From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: maildir: Preserve [SW]=sizes when renaming a maildi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cfd3f39102bd changeset: 15954:cfd3f39102bd user: Timo Sirainen date: Mon Feb 25 16:44:57 2013 +0200 description: maildir: Preserve [SW]=sizes when renaming a maildir duplicate file. diffstat: src/lib-storage/index/maildir/maildir-sync.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diffs (28 lines): diff -r 10c1eb4ddef2 -r cfd3f39102bd src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Sun Feb 24 15:52:57 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 16:44:57 2013 +0200 @@ -288,6 +288,7 @@ const char *fname1, *path1, *path2; const char *new_fname, *new_path; struct stat st1, st2; + uoff_t size; fname1 = maildir_uidlist_sync_get_full_filename(ctx->uidlist_sync_ctx, fname2); @@ -330,6 +331,16 @@ } new_fname = maildir_filename_generate(); + /* preserve S= and W= sizes if they're available. + (S=size is required for zlib plugin to work) */ + if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_FILE_SIZE, &size)) { + new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T, + new_fname, MAILDIR_EXTRA_FILE_SIZE, size); + } + if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_VIRTUAL_SIZE, &size)) { + new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T, + new_fname, MAILDIR_EXTRA_VIRTUAL_SIZE, size); + } new_path = t_strconcat(mailbox_get_path(&ctx->mbox->box), "/new/", new_fname, NULL); From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: Released v2.2.rc1. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/508d46f85815 changeset: 15957:508d46f85815 user: Timo Sirainen date: Mon Feb 25 17:33:02 2013 +0200 description: Released v2.2.rc1. diffstat: NEWS | 2 +- configure.ac | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diffs (28 lines): diff -r d3815278ed19 -r 508d46f85815 NEWS --- a/NEWS Mon Feb 25 17:29:28 2013 +0200 +++ b/NEWS Mon Feb 25 17:33:02 2013 +0200 @@ -1,4 +1,4 @@ -v2.2.UNSTABLE 2013-xx-xx Timo Sirainen +v2.2.rc1 2013-02-15 Timo Sirainen * When creating home directories, the permissions are copied from the parent directory if it has setgid-bit set. For full details, see diff -r d3815278ed19 -r 508d46f85815 configure.ac --- a/configure.ac Mon Feb 25 17:29:28 2013 +0200 +++ b/configure.ac Mon Feb 25 17:33:02 2013 +0200 @@ -2,7 +2,7 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.beta2],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.2.rc1],[dovecot at dovecot.org]) AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv0($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) @@ -2921,6 +2921,3 @@ if test "$not_fts" != ""; then echo " :$not_fts" fi - -echo -echo "NOTE: This is the UNSTABLE development branch of Dovecot v2.2." From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: Merged changes from v2.1 tree. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d3815278ed19 changeset: 15956:d3815278ed19 user: Timo Sirainen date: Mon Feb 25 17:29:28 2013 +0200 description: Merged changes from v2.1 tree. diffstat: src/imap/cmd-list.c | 4 +- src/indexer/indexer-worker.c | 4 +- src/lib-dict/dict-client.c | 12 ++++--- src/lib-dict/dict-sql.c | 3 + src/lib-index/mail-transaction-log-file.c | 3 +- src/lib-lda/duplicate.c | 11 +++++- src/lib-storage/index/dbox-common/dbox-file-fix.c | 14 +++++++- src/lib-storage/index/dbox-common/dbox-file.h | 3 +- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 6 ++- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +- src/lib-storage/index/index-status.c | 13 ++++++- src/lib-storage/index/index-storage.h | 2 +- src/lib-storage/index/index-sync.c | 4 +- src/lib-storage/index/maildir/maildir-sync.c | 11 +++++++ src/lib-storage/mail-storage.c | 7 ++++ src/plugins/fts-solr/fts-backend-solr.c | 25 ++++++++++----- src/plugins/fts/fts-build-mail.c | 3 +- src/plugins/quota/Makefile.am | 1 + 18 files changed, 95 insertions(+), 33 deletions(-) diffs (truncated from 407 to 300 lines): diff -r 539baf0adc2e -r d3815278ed19 src/imap/cmd-list.c --- a/src/imap/cmd-list.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/imap/cmd-list.c Mon Feb 25 17:29:28 2013 +0200 @@ -397,7 +397,7 @@ return TRUE; } if (imap_utf7_to_utf8(pattern, str) == 0) - pattern = t_strdup(str_c(str)); + pattern = p_strdup(cmd->pool, str_c(str)); array_append(&patterns, &pattern, 1); str_truncate(str, 0); } @@ -408,7 +408,7 @@ return TRUE; } if (imap_utf7_to_utf8(pattern, str) == 0) - pattern = str_c(str); + pattern = p_strdup(cmd->pool, str_c(str)); p_array_init(&patterns, cmd->pool, 1); array_append(&patterns, &pattern, 1); diff -r 539baf0adc2e -r d3815278ed19 src/indexer/indexer-worker.c --- a/src/indexer/indexer-worker.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/indexer/indexer-worker.c Mon Feb 25 17:29:28 2013 +0200 @@ -45,6 +45,8 @@ int main(int argc, char *argv[]) { + enum master_service_flags service_flags = + MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN; enum mail_storage_service_flags storage_service_flags = MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT | MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | @@ -52,7 +54,7 @@ MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT; int c; - master_service = master_service_init("indexer-worker", 0, + master_service = master_service_init("indexer-worker", service_flags, &argc, &argv, "D"); while ((c = master_getopt(master_service)) > 0) { switch (c) { diff -r 539baf0adc2e -r d3815278ed19 src/lib-dict/dict-client.c --- a/src/lib-dict/dict-client.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-dict/dict-client.c Mon Feb 25 17:29:28 2013 +0200 @@ -262,15 +262,17 @@ i_error("dict-client: Unknown transaction id %u", id); return; } - if (ctx->callback != NULL) - ctx->callback(ret, ctx->context); - DLLIST_REMOVE(&dict->transactions, ctx); - i_free(ctx); - + /* the callback may call the dict code again, so remove this + transaction before calling it */ i_assert(dict->async_commits > 0); if (--dict->async_commits == 0) io_remove(&dict->io); + DLLIST_REMOVE(&dict->transactions, ctx); + + if (ctx->callback != NULL) + ctx->callback(ret, ctx->context); + i_free(ctx); } static ssize_t client_dict_read_timeout(struct client_dict *dict) diff -r 539baf0adc2e -r d3815278ed19 src/lib-dict/dict-sql.c --- a/src/lib-dict/dict-sql.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-dict/dict-sql.c Mon Feb 25 17:29:28 2013 +0200 @@ -353,6 +353,9 @@ if (map == NULL) return FALSE; + if (ctx->result != NULL) + sql_result_unref(ctx->result); + T_BEGIN { string_t *query = t_str_new(256); diff -r 539baf0adc2e -r d3815278ed19 src/lib-index/mail-transaction-log-file.c --- a/src/lib-index/mail-transaction-log-file.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-index/mail-transaction-log-file.c Mon Feb 25 17:29:28 2013 +0200 @@ -1721,7 +1721,7 @@ } if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) { - if (start_offset < file->buffer_offset) { + if (start_offset < file->buffer_offset || file->buffer == NULL) { /* we had moved the log to memory but failed to read the beginning of the log file */ mail_index_set_error(index, @@ -1729,7 +1729,6 @@ file->filepath); return 0; } - i_assert(file->buffer != NULL); return log_file_map_check_offsets(file, start_offset, end_offset); } diff -r 539baf0adc2e -r d3815278ed19 src/lib-lda/duplicate.c --- a/src/lib-lda/duplicate.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-lda/duplicate.c Mon Feb 25 17:29:28 2013 +0200 @@ -209,9 +209,16 @@ file->path = p_strdup(pool, ctx->path); file->new_fd = file_dotlock_open(&ctx->dotlock_set, file->path, 0, &file->dotlock); - if (file->new_fd == -1) - i_error("file_dotlock_create(%s) failed: %m", file->path); + if (file->new_fd != -1) + ; + else if (errno != EAGAIN) + i_error("file_dotlock_open(%s) failed: %m", file->path); + else { + i_error("Creating lock file for %s timed out in %u secs", + file->path, ctx->dotlock_set.timeout); + } hash_table_create(&file->hash, pool, 0, duplicate_hash, duplicate_cmp); + (void)duplicate_read(file); return file; } diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-common/dbox-file-fix.c --- a/src/lib-storage/index/dbox-common/dbox-file-fix.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c Mon Feb 25 17:29:28 2013 +0200 @@ -299,7 +299,7 @@ { struct ostream *output; const char *dir, *p, *temp_path, *broken_path; - bool deleted; + bool deleted, have_messages; int fd, ret; i_assert(dbox_file_is_open(file)); @@ -318,6 +318,7 @@ ret = dbox_file_fix_write_stream(file, start_offset, temp_path, output); if (ret < 0) o_stream_ignore_last_errors(output); + have_messages = output->offset > file->file_header_size; o_stream_unref(&output); if (close(fd) < 0) { mail_storage_set_critical(&file->storage->storage, @@ -343,6 +344,15 @@ i_warning("dbox: Copy of the broken file saved to %s", broken_path); } + if (!have_messages) { + /* the resulting file has no messages. just delete the file. */ + dbox_file_close(file); + if (unlink(temp_path) < 0) + i_error("unlink(%s) failed: %m", temp_path); + if (unlink(file->cur_path) < 0) + i_error("unlink(%s) failed: %m", file->cur_path); + return 0; + } if (rename(temp_path, file->cur_path) < 0) { mail_storage_set_critical(&file->storage->storage, "rename(%s, %s) failed: %m", @@ -358,5 +368,5 @@ file->cur_path); return -1; } - return 0; + return 1; } diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-common/dbox-file.h --- a/src/lib-storage/index/dbox-common/dbox-file.h Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-file.h Mon Feb 25 17:29:28 2013 +0200 @@ -190,7 +190,8 @@ /* Fix a broken dbox file by rename()ing over it with a fixed file. Everything before start_offset is assumed to be valid and is simply copied. The file - is reopened afterwards. Returns 0 if ok, -1 if I/O error. */ + is reopened afterwards. Returns 1 if ok, 0 if the resulting file has no + mails and was deleted, -1 if I/O error. */ int dbox_file_fix(struct dbox_file *file, uoff_t start_offset); /* Delete the given dbox file. Returns 1 if deleted, 0 if file wasn't found or -1 if error. */ diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Mon Feb 25 17:29:28 2013 +0200 @@ -153,9 +153,11 @@ /* use existing file header if it was ok */ prev_offset = offset; } - if (dbox_file_fix(file, prev_offset) < 0) { - ret = -1; + if ((ret = dbox_file_fix(file, prev_offset)) < 0) break; + if (ret == 0) { + /* file was deleted */ + return 1; } fixed = TRUE; if (!first) { diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Mon Feb 25 17:29:28 2013 +0200 @@ -39,7 +39,7 @@ ret = dbox_file_seek(file, 0); } if (ret == 0) { - if ((ret = dbox_file_fix(file, 0)) == 0) + if ((ret = dbox_file_fix(file, 0)) > 0) ret = dbox_file_seek(file, 0); } diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/index-status.c Mon Feb 25 17:29:28 2013 +0200 @@ -113,9 +113,16 @@ hdr = mail_index_get_header(box->view); status_r->messages = hdr->messages_count; if ((items & STATUS_RECENT) != 0) { - /* make sure recent count is set, in case syncing hasn't - been done yet */ - index_sync_update_recent_count(box); + if ((box->flags & MAILBOX_FLAG_DROP_RECENT) != 0) { + /* recent flags are set and dropped by the previous + sync while index was locked. if we updated the + recent flags here we'd have a race condition. */ + i_assert(box->synced); + } else { + /* make sure recent count is set, in case we haven't + synced yet */ + index_sync_update_recent_count(box); + } status_r->recent = index_mailbox_get_recent_count(box); i_assert(status_r->recent <= status_r->messages); } diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/index-storage.h Mon Feb 25 17:29:28 2013 +0200 @@ -37,7 +37,7 @@ struct mail_cache_field *cache_fields; ARRAY_TYPE(seq_range) recent_flags; - uint32_t recent_flags_prev_uid; + uint32_t recent_flags_prev_uid, recent_flags_last_check_nextuid; uint32_t recent_flags_count; uint32_t vsize_hdr_ext_id; diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/index-sync.c Mon Feb 25 17:29:28 2013 +0200 @@ -367,7 +367,9 @@ uint32_t seq1, seq2; hdr = mail_index_get_header(box->view); - if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) { + if (hdr->first_recent_uid > ibox->recent_flags_prev_uid || + hdr->next_uid > ibox->recent_flags_last_check_nextuid) { + ibox->recent_flags_last_check_nextuid = hdr->next_uid; if (mail_index_lookup_seq_range(box->view, hdr->first_recent_uid, hdr->next_uid, diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 17:29:28 2013 +0200 @@ -288,6 +288,7 @@ const char *fname1, *path1, *path2; const char *new_fname, *new_path; struct stat st1, st2; + uoff_t size; fname1 = maildir_uidlist_sync_get_full_filename(ctx->uidlist_sync_ctx, fname2); @@ -330,6 +331,16 @@ } new_fname = maildir_filename_generate(); + /* preserve S= and W= sizes if they're available. + (S=size is required for zlib plugin to work) */ + if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_FILE_SIZE, &size)) { + new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T, + new_fname, MAILDIR_EXTRA_FILE_SIZE, size); + } + if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_VIRTUAL_SIZE, &size)) { + new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T, + new_fname, MAILDIR_EXTRA_VIRTUAL_SIZE, size); + } new_path = t_strconcat(mailbox_get_path(&ctx->mbox->box), "/new/", new_fname, NULL); diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Mon Feb 25 17:25:10 2013 +0200 +++ b/src/lib-storage/mail-storage.c Mon Feb 25 17:29:28 2013 +0200 @@ -1036,6 +1036,13 @@ { time_t mtime; + if ((box->flags & MAILBOX_FLAG_READONLY) != 0) { + /* most importantly we don't do this because we want to avoid + a loop: mdbox storage rebuild -> mailbox_open() -> + mailbox_mark_index_deleted() -> mailbox_sync() -> + mdbox storage rebuild. */ + return FALSE; + } if (mail_index_get_modification_time(box->index, &mtime) < 0) From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: Added tag 2.2.rc1 for changeset 508d46f85815 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/37126d25c614 changeset: 15958:37126d25c614 user: Timo Sirainen date: Mon Feb 25 17:33:13 2013 +0200 description: Added tag 2.2.rc1 for changeset 508d46f85815 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 508d46f85815 -r 37126d25c614 .hgtags --- a/.hgtags Mon Feb 25 17:33:02 2013 +0200 +++ b/.hgtags Mon Feb 25 17:33:13 2013 +0200 @@ -95,3 +95,4 @@ b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14 fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15 018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 2.2.beta2 +508d46f858153c85ae777e87e1c5143a534a51fe 2.2.rc1 From dovecot at dovecot.org Mon Feb 25 17:48:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 17:48:21 +0200 Subject: dovecot-2.2: Added signature for changeset 508d46f85815 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1739a61bcd39 changeset: 15959:1739a61bcd39 user: Timo Sirainen date: Mon Feb 25 17:33:16 2013 +0200 description: Added signature for changeset 508d46f85815 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 37126d25c614 -r 1739a61bcd39 .hgsigs --- a/.hgsigs Mon Feb 25 17:33:13 2013 +0200 +++ b/.hgsigs Mon Feb 25 17:33:16 2013 +0200 @@ -58,3 +58,4 @@ b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3 018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 0 iEYEABECAAYFAlEmOJEACgkQyUhSUUBVismawgCfbfY6KuH+/AauPkRZs4ish20YeV8Ani5DMLh02DUyJvDIpVPJMmTn2Mu/ +508d46f858153c85ae777e87e1c5143a534a51fe 0 iEYEABECAAYFAlErhDkACgkQyUhSUUBViskRdwCeJ61F0qLZ/3xxIQruTujzo0AEWK0An3PH7nkTY7ouyBdUr0QCra5KLXEZ From dovecot at dovecot.org Mon Feb 25 19:38:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 19:38:01 +0200 Subject: dovecot-2.2: configure: Fixed plugins when compiling --with-shar... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1ad404473d81 changeset: 15960:1ad404473d81 user: Timo Sirainen date: Mon Feb 25 19:37:53 2013 +0200 description: configure: Fixed plugins when compiling --with-shared-libs diffstat: configure.ac | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 1739a61bcd39 -r 1ad404473d81 configure.ac --- a/configure.ac Mon Feb 25 17:33:16 2013 +0200 +++ b/configure.ac Mon Feb 25 19:37:53 2013 +0200 @@ -2547,7 +2547,7 @@ if test "$want_shared_libs" = "yes"; then LIBDOVECOT_DEPS='$(top_builddir)/src/lib-dovecot/libdovecot.la' - LIBDOVECOT="$LIBDOVECOT_DEPS" + LIBDOVECOT="$LIBDOVECOT_DEPS \$(MODULE_LIBS)" LIBDOVECOT_STORAGE_DEPS='$(top_builddir)/src/lib-storage/libdovecot-storage.la $(top_builddir)/src/lib-imap-storage/libimap-storage.la' LIBDOVECOT_LOGIN='$(top_builddir)/src/login-common/libdovecot-login.la' LIBDOVECOT_COMPRESS='$(top_builddir)/src/lib-compression/libcompression.la' From dovecot at dovecot.org Mon Feb 25 19:52:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 19:52:47 +0200 Subject: dovecot-2.2: lib-storage: Fixed listing subscriptions for namesp... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e47910ee4459 changeset: 15961:e47910ee4459 user: Timo Sirainen date: Mon Feb 25 19:52:40 2013 +0200 description: lib-storage: Fixed listing subscriptions for namespaces with prefix. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (17 lines): diff -r 1ad404473d81 -r e47910ee4459 src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Mon Feb 25 19:37:53 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Mon Feb 25 19:52:40 2013 +0200 @@ -44,8 +44,11 @@ ns_name = t_strconcat(src_list->ns->prefix, name, NULL); } ns = mail_namespace_find_unsubscribable(namespaces, ns_name); - if (ns != NULL && ns != default_ns) - return 0; + if (ns != NULL && ns != default_ns) { + if (ns->prefix_len > default_ns->prefix_len) + return 0; + ns = default_ns; + } /* 2) when listing pub/ namespace, skip over entries that don't begin with pub/. */ From dovecot at dovecot.org Mon Feb 25 20:04:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 20:04:22 +0200 Subject: dovecot-2.2: login: Don't fail at startup by trying to load SSL ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/effecdd32cb0 changeset: 15962:effecdd32cb0 user: Timo Sirainen date: Mon Feb 25 20:04:10 2013 +0200 description: login: Don't fail at startup by trying to load SSL plugin. diffstat: src/lib-master/master-service.c | 3 ++- src/lib-master/master-service.h | 4 +++- src/login-common/main.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diffs (40 lines): diff -r e47910ee4459 -r effecdd32cb0 src/lib-master/master-service.c --- a/src/lib-master/master-service.c Mon Feb 25 19:52:40 2013 +0200 +++ b/src/lib-master/master-service.c Mon Feb 25 20:04:10 2013 +0200 @@ -442,7 +442,8 @@ master_status_error, service); } master_service_io_listeners_add(service); - if (service->want_ssl_settings) + if (service->want_ssl_settings && + (service->flags & MASTER_SERVICE_FLAG_NO_SSL_INIT) == 0) master_service_ssl_ctx_init(service); if ((service->flags & MASTER_SERVICE_FLAG_STD_CLIENT) != 0) { diff -r e47910ee4459 -r effecdd32cb0 src/lib-master/master-service.h --- a/src/lib-master/master-service.h Mon Feb 25 19:52:40 2013 +0200 +++ b/src/lib-master/master-service.h Mon Feb 25 20:04:10 2013 +0200 @@ -26,7 +26,9 @@ /* SSL settings are always looked up when we have ssl listeners. This flag enables looking up SSL settings even without ssl listeners (i.e. the service does STARTTLS). */ - MASTER_SERVICE_FLAG_USE_SSL_SETTINGS = 0x200 + MASTER_SERVICE_FLAG_USE_SSL_SETTINGS = 0x200, + /* Don't initialize SSL context automatically. */ + MASTER_SERVICE_FLAG_NO_SSL_INIT = 0x400 }; struct master_service_connection { diff -r e47910ee4459 -r effecdd32cb0 src/login-common/main.c --- a/src/login-common/main.c Mon Feb 25 19:52:40 2013 +0200 +++ b/src/login-common/main.c Mon Feb 25 20:04:10 2013 +0200 @@ -365,7 +365,8 @@ enum master_service_flags service_flags = MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN | MASTER_SERVICE_FLAG_TRACK_LOGIN_STATE | - MASTER_SERVICE_FLAG_USE_SSL_SETTINGS; + MASTER_SERVICE_FLAG_USE_SSL_SETTINGS | + MASTER_SERVICE_FLAG_NO_SSL_INIT; pool_t set_pool; bool allow_core_dumps = FALSE; const char *login_socket; From dovecot at dovecot.org Mon Feb 25 20:10:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 20:10:06 +0200 Subject: dovecot-2.2: lib-storage: Fixed up previous subscription list ch... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c8fc02c88cf6 changeset: 15963:c8fc02c88cf6 user: Timo Sirainen date: Mon Feb 25 20:09:52 2013 +0200 description: lib-storage: Fixed up previous subscription list change. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r effecdd32cb0 -r c8fc02c88cf6 src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Mon Feb 25 20:04:10 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Mon Feb 25 20:09:52 2013 +0200 @@ -45,7 +45,8 @@ } ns = mail_namespace_find_unsubscribable(namespaces, ns_name); if (ns != NULL && ns != default_ns) { - if (ns->prefix_len > default_ns->prefix_len) + if (ns->prefix_len > default_ns->prefix_len || + strncmp(ns->prefix, default_ns->prefix, ns->prefix_len) != 0) return 0; ns = default_ns; } From dovecot at dovecot.org Mon Feb 25 20:20:29 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 20:20:29 +0200 Subject: dovecot-2.2: lib-storage: Still more fixing to listing subscript... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ef7eb84d9a3a changeset: 15964:ef7eb84d9a3a user: Timo Sirainen date: Mon Feb 25 20:20:18 2013 +0200 description: lib-storage: Still more fixing to listing subscriptions. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diffs (18 lines): diff -r c8fc02c88cf6 -r ef7eb84d9a3a src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Mon Feb 25 20:09:52 2013 +0200 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Mon Feb 25 20:20:18 2013 +0200 @@ -45,10 +45,11 @@ } ns = mail_namespace_find_unsubscribable(namespaces, ns_name); if (ns != NULL && ns != default_ns) { - if (ns->prefix_len > default_ns->prefix_len || - strncmp(ns->prefix, default_ns->prefix, ns->prefix_len) != 0) + if (ns->prefix_len > 0) return 0; - ns = default_ns; + /* prefix="" namespace=no : catching this is basically the + same as not finding any namespace. */ + ns = NULL; } /* 2) when listing pub/ namespace, skip over entries that don't From dovecot at dovecot.org Mon Feb 25 20:44:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 20:44:05 +0200 Subject: dovecot-2.2: Released v2.2.rc2. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e62fa121f4a2 changeset: 15965:e62fa121f4a2 user: Timo Sirainen date: Mon Feb 25 20:40:09 2013 +0200 description: Released v2.2.rc2. diffstat: NEWS | 6 ++++++ configure.ac | 2 +- 2 files changed, 7 insertions(+), 1 deletions(-) diffs (32 lines): diff -r ef7eb84d9a3a -r e62fa121f4a2 NEWS --- a/NEWS Mon Feb 25 20:20:18 2013 +0200 +++ b/NEWS Mon Feb 25 20:40:09 2013 +0200 @@ -1,3 +1,7 @@ +v2.2.rc2 2013-02-15 Timo Sirainen + + - rc1 wasn't actually usable in most configurations. + v2.2.rc1 2013-02-15 Timo Sirainen * When creating home directories, the permissions are copied from the @@ -15,6 +19,8 @@ file instead of actually locking the mailbox (and causing IMAP/LDA/LMTP to wait for the POP3 session to close). * mail_shared_explicit_inbox setting's default switched to "no". + * ssl_client_ca_dir setting replaced imapc_ssl_ca_dir and + pop3c_ssl_ca_dir settings. + Implemented IMAP MOVE and BINARY extensions + Implemented IMAP CATENATE, URLAUTH and URLAUTH=BINARY extensions diff -r ef7eb84d9a3a -r e62fa121f4a2 configure.ac --- a/configure.ac Mon Feb 25 20:20:18 2013 +0200 +++ b/configure.ac Mon Feb 25 20:40:09 2013 +0200 @@ -2,7 +2,7 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.rc1],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.2.rc2],[dovecot at dovecot.org]) AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv0($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) From dovecot at dovecot.org Mon Feb 25 20:44:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 20:44:05 +0200 Subject: dovecot-2.2: Added tag 2.2.rc2 for changeset e62fa121f4a2 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/98dbd335085a changeset: 15966:98dbd335085a user: Timo Sirainen date: Mon Feb 25 20:40:12 2013 +0200 description: Added tag 2.2.rc2 for changeset e62fa121f4a2 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r e62fa121f4a2 -r 98dbd335085a .hgtags --- a/.hgtags Mon Feb 25 20:40:09 2013 +0200 +++ b/.hgtags Mon Feb 25 20:40:12 2013 +0200 @@ -96,3 +96,4 @@ fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15 018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 2.2.beta2 508d46f858153c85ae777e87e1c5143a534a51fe 2.2.rc1 +e62fa121f4a2db3348fd79bb176dd363cc1224bf 2.2.rc2 From dovecot at dovecot.org Mon Feb 25 20:44:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 25 Feb 2013 20:44:05 +0200 Subject: dovecot-2.2: Added signature for changeset e62fa121f4a2 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/508e677af12d changeset: 15967:508e677af12d user: Timo Sirainen date: Mon Feb 25 20:40:15 2013 +0200 description: Added signature for changeset e62fa121f4a2 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 98dbd335085a -r 508e677af12d .hgsigs --- a/.hgsigs Mon Feb 25 20:40:12 2013 +0200 +++ b/.hgsigs Mon Feb 25 20:40:15 2013 +0200 @@ -59,3 +59,4 @@ fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3 018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 0 iEYEABECAAYFAlEmOJEACgkQyUhSUUBVismawgCfbfY6KuH+/AauPkRZs4ish20YeV8Ani5DMLh02DUyJvDIpVPJMmTn2Mu/ 508d46f858153c85ae777e87e1c5143a534a51fe 0 iEYEABECAAYFAlErhDkACgkQyUhSUUBViskRdwCeJ61F0qLZ/3xxIQruTujzo0AEWK0An3PH7nkTY7ouyBdUr0QCra5KLXEZ +e62fa121f4a2db3348fd79bb176dd363cc1224bf 0 iEYEABECAAYFAlErsAwACgkQyUhSUUBVismarACbBffm3XY21sfkTsbmF8o8udtRZk4An0ofYy2VminZ3S8EFApHymk/UpNv From dovecot at dovecot.org Tue Feb 26 09:05:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 09:05:21 +0200 Subject: dovecot-2.2: scram-sha1: Support authzid field. Check fields' co... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2583040ca9aa changeset: 15968:2583040ca9aa user: Timo Sirainen date: Tue Feb 26 09:05:09 2013 +0200 description: scram-sha1: Support authzid field. Check fields' correctness better. diffstat: src/auth/mech-scram-sha1.c | 64 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 52 insertions(+), 12 deletions(-) diffs (106 lines): diff -r 508e677af12d -r 2583040ca9aa src/auth/mech-scram-sha1.c --- a/src/auth/mech-scram-sha1.c Mon Feb 25 20:40:15 2013 +0200 +++ b/src/auth/mech-scram-sha1.c Tue Feb 26 09:05:09 2013 +0200 @@ -120,40 +120,75 @@ const unsigned char *data, size_t size, const char **error_r) { - const char *const *fields; + const char *const *fields, *login_username = NULL; + const char *gs2_cbind_flag, *authzid, *username, *nonce; fields = t_strsplit(t_strndup(data, size), ","); if (str_array_length(fields) < 4) { *error_r = "Invalid initial client message"; return FALSE; } + gs2_cbind_flag = fields[0]; + authzid = fields[1]; + username = fields[2]; + nonce = fields[3]; - switch (fields[0][0]) { + /* Order of fields is fixed: + + client-first-message = gs2-header client-first-message-bare + gs2-header = gs2-cbind-flag "," [ authzid ] "," + gs2-cbind-flag = ("p=" cb-name) / "n" / "y" + + client-first-message-bare = [reserved-mext ","] + username "," nonce ["," extensions] + reserved-mext = "m=" 1*(value-char) + + username = "n=" saslname + nonce = "r=" c-nonce [s-nonce] + + extensions = attr-val *("," attr-val) + ;; All extensions are optional, + ;; i.e., unrecognized attributes + ;; not defined in this document + ;; MUST be ignored. + attr-val = ALPHA "=" value + + */ + switch (gs2_cbind_flag[0]) { case 'p': *error_r = "Channel binding not supported"; return FALSE; case 'y': case 'n': - request->gs2_cbind_flag = p_strdup(request->pool, fields[0]); + request->gs2_cbind_flag = + p_strdup(request->pool, gs2_cbind_flag); break; default: *error_r = "Invalid GS2 header"; return FALSE; } - if (fields[1][0] != '\0') { - *error_r = "authzid not supported"; + if (authzid[0] == '\0') + ; + else if (authzid[0] == 'a' && authzid[1] == '=') { + /* Unescape authzid */ + login_username = scram_unescape_username(authzid + 2); + + if (login_username == NULL) { + *error_r = "authzid escaping is invalid"; + return FALSE; + } + } else { + *error_r = "Invalid authzid field"; return FALSE; } - if (fields[2][0] == 'm') { + if (username[0] == 'm') { *error_r = "Mandatory extension(s) not supported"; return FALSE; } - if (fields[2][0] == 'n') { + if (username[0] == 'n' && username[1] == '=') { /* Unescape username */ - const char *username = - scram_unescape_username(fields[2] + 2); - + username = scram_unescape_username(username + 2); if (username == NULL) { *error_r = "Username escaping is invalid"; return FALSE; @@ -165,9 +200,14 @@ *error_r = "Invalid username field"; return FALSE; } + if (login_username != NULL) { + if (!auth_request_set_login_username(&request->auth_request, + login_username, error_r)) + return FALSE; + } - if (fields[3][0] == 'r') - request->cnonce = p_strdup(request->pool, fields[3]+2); + if (nonce[0] == 'r' && nonce[1] == '=') + request->cnonce = p_strdup(request->pool, nonce+2); else { *error_r = "Invalid client nonce"; return FALSE; From dovecot at dovecot.org Tue Feb 26 09:06:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 09:06:14 +0200 Subject: dovecot-2.1: scram-sha1: Support authzid field. Check fields' co... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0af0def22533 changeset: 14926:0af0def22533 user: Timo Sirainen date: Tue Feb 26 09:05:09 2013 +0200 description: scram-sha1: Support authzid field. Check fields' correctness better. diffstat: src/auth/mech-scram-sha1.c | 64 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 52 insertions(+), 12 deletions(-) diffs (106 lines): diff -r fa9387588430 -r 0af0def22533 src/auth/mech-scram-sha1.c --- a/src/auth/mech-scram-sha1.c Mon Feb 25 17:23:25 2013 +0200 +++ b/src/auth/mech-scram-sha1.c Tue Feb 26 09:05:09 2013 +0200 @@ -150,40 +150,75 @@ const unsigned char *data, size_t size, const char **error_r) { - const char *const *fields; + const char *const *fields, *login_username = NULL; + const char *gs2_cbind_flag, *authzid, *username, *nonce; fields = t_strsplit(t_strndup(data, size), ","); if (str_array_length(fields) < 4) { *error_r = "Invalid initial client message"; return FALSE; } + gs2_cbind_flag = fields[0]; + authzid = fields[1]; + username = fields[2]; + nonce = fields[3]; - switch (fields[0][0]) { + /* Order of fields is fixed: + + client-first-message = gs2-header client-first-message-bare + gs2-header = gs2-cbind-flag "," [ authzid ] "," + gs2-cbind-flag = ("p=" cb-name) / "n" / "y" + + client-first-message-bare = [reserved-mext ","] + username "," nonce ["," extensions] + reserved-mext = "m=" 1*(value-char) + + username = "n=" saslname + nonce = "r=" c-nonce [s-nonce] + + extensions = attr-val *("," attr-val) + ;; All extensions are optional, + ;; i.e., unrecognized attributes + ;; not defined in this document + ;; MUST be ignored. + attr-val = ALPHA "=" value + + */ + switch (gs2_cbind_flag[0]) { case 'p': *error_r = "Channel binding not supported"; return FALSE; case 'y': case 'n': - request->gs2_cbind_flag = p_strdup(request->pool, fields[0]); + request->gs2_cbind_flag = + p_strdup(request->pool, gs2_cbind_flag); break; default: *error_r = "Invalid GS2 header"; return FALSE; } - if (fields[1][0] != '\0') { - *error_r = "authzid not supported"; + if (authzid[0] == '\0') + ; + else if (authzid[0] == 'a' && authzid[1] == '=') { + /* Unescape authzid */ + login_username = scram_unescape_username(authzid + 2); + + if (login_username == NULL) { + *error_r = "authzid escaping is invalid"; + return FALSE; + } + } else { + *error_r = "Invalid authzid field"; return FALSE; } - if (fields[2][0] == 'm') { + if (username[0] == 'm') { *error_r = "Mandatory extension(s) not supported"; return FALSE; } - if (fields[2][0] == 'n') { + if (username[0] == 'n' && username[1] == '=') { /* Unescape username */ - const char *username = - scram_unescape_username(fields[2] + 2); - + username = scram_unescape_username(username + 2); if (username == NULL) { *error_r = "Username escaping is invalid"; return FALSE; @@ -195,9 +230,14 @@ *error_r = "Invalid username field"; return FALSE; } + if (login_username != NULL) { + if (!auth_request_set_login_username(&request->auth_request, + login_username, error_r)) + return FALSE; + } - if (fields[3][0] == 'r') - request->cnonce = p_strdup(request->pool, fields[3]+2); + if (nonce[0] == 'r' && nonce[1] == '=') + request->cnonce = p_strdup(request->pool, nonce+2); else { *error_r = "Invalid client nonce"; return FALSE; From dovecot at dovecot.org Tue Feb 26 10:30:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 10:30:21 +0200 Subject: dovecot-2.2: lib-storage: Never auto-remove the auto-created pre... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c9491a07998b changeset: 15969:c9491a07998b user: Timo Sirainen date: Tue Feb 26 10:30:15 2013 +0200 description: lib-storage: Never auto-remove the auto-created prefix="" namespace. diffstat: src/lib-storage/mail-user.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diffs (20 lines): diff -r 2583040ca9aa -r c9491a07998b src/lib-storage/mail-user.c --- a/src/lib-storage/mail-user.c Tue Feb 26 09:05:09 2013 +0200 +++ b/src/lib-storage/mail-user.c Tue Feb 26 10:30:15 2013 +0200 @@ -264,11 +264,15 @@ { struct mail_namespace *ns, *next; + /* drop all autocreated unusable (typically shared) namespaces. + don't drop the autocreated prefix="" namespace that we explicitly + created for being the fallback namespace. */ for (ns = user->namespaces; ns != NULL; ns = next) { next = ns->next; if ((ns->flags & NAMESPACE_FLAG_USABLE) == 0 && - (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0) + (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0 && + ns->prefix_len > 0) mail_namespace_destroy(ns); } } From dovecot at dovecot.org Tue Feb 26 10:37:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 10:37:30 +0200 Subject: dovecot-2.1: lib-storage: If namespace has disabled=yes, don't v... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a46951762a27 changeset: 14927:a46951762a27 user: Timo Sirainen date: Tue Feb 26 10:37:19 2013 +0200 description: lib-storage: If namespace has disabled=yes, don't verify alias_for validity. diffstat: src/lib-storage/mail-storage-settings.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 0af0def22533 -r a46951762a27 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Tue Feb 26 09:05:09 2013 +0200 +++ b/src/lib-storage/mail-storage-settings.c Tue Feb 26 10:37:19 2013 +0200 @@ -452,7 +452,7 @@ return FALSE; } - if (ns->alias_for != NULL) { + if (ns->alias_for != NULL && !ns->disabled) { if (array_is_created(&ns->user_set->namespaces)) { namespaces = array_get(&ns->user_set->namespaces, &count); From dovecot at dovecot.org Tue Feb 26 10:54:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 10:54:23 +0200 Subject: dovecot-2.2: doveadm: Improved deciding whether to use TCP or UN... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/91631438abce changeset: 15970:91631438abce user: Timo Sirainen date: Tue Feb 26 10:54:09 2013 +0200 description: doveadm: Improved deciding whether to use TCP or UNIX socket for a given name. diffstat: src/doveadm/doveadm-util.c | 63 ++++++++++++++++++++++++++++----------------- src/doveadm/doveadm-util.h | 1 + 2 files changed, 40 insertions(+), 24 deletions(-) diffs (94 lines): diff -r c9491a07998b -r 91631438abce src/doveadm/doveadm-util.c --- a/src/doveadm/doveadm-util.c Tue Feb 26 10:30:15 2013 +0200 +++ b/src/doveadm/doveadm-util.c Tue Feb 26 10:54:09 2013 +0200 @@ -112,40 +112,55 @@ return FALSE; *host_r = t_strdup_until(str, p); } + return TRUE; +} - /* there is any '/' character (unlikely to be found from host names), - assume ':' is part of a file path */ - if (strchr(str, '/') != NULL) - return FALSE; - return TRUE; +static int +doveadm_tcp_connect_port(const char *host, unsigned int port) +{ + struct ip_addr *ips; + unsigned int ips_count; + int ret, fd; + + ret = net_gethostbyname(host, &ips, &ips_count); + if (ret != 0) { + i_fatal("Lookup of host %s failed: %s", + host, net_gethosterror(ret)); + } + fd = net_connect_ip_blocking(&ips[0], port, NULL); + if (fd == -1) { + i_fatal("connect(%s:%u) failed: %m", + net_ip2addr(&ips[0]), port); + } + return fd; +} + +int doveadm_tcp_connect(const char *target, unsigned int default_port) +{ + const char *host; + unsigned int port; + + if (!parse_hostport(target, default_port, &host, &port)) { + i_fatal("Port not known for %s. Either set proxy_port " + "or use %s:port", target, target); + } + return doveadm_tcp_connect_port(host, port); } int doveadm_connect_with_default_port(const char *path, unsigned int default_port) { - struct stat st; - const char *host; - struct ip_addr *ips; - unsigned int port, ips_count; - int fd, ret; + int fd; - if (parse_hostport(path, default_port, &host, &port) && - stat(path, &st) < 0) { - /* it's a host:port, connect via TCP */ - ret = net_gethostbyname(host, &ips, &ips_count); - if (ret != 0) { - i_fatal("Lookup of host %s failed: %s", - host, net_gethosterror(ret)); - } - fd = net_connect_ip_blocking(&ips[0], port, NULL); - if (fd == -1) { - i_fatal("connect(%s:%u) failed: %m", - net_ip2addr(&ips[0]), port); - } - } else { + /* we'll assume UNIX sockets typically have an absolute path, + or at the very least '/' somewhere. */ + if (strchr(path, '/') == NULL) + fd = doveadm_tcp_connect(path, default_port); + else { fd = net_connect_unix(path); if (fd == -1) i_fatal("net_connect_unix(%s) failed: %m", path); + return -1; } return fd; } diff -r c9491a07998b -r 91631438abce src/doveadm/doveadm-util.h --- a/src/doveadm/doveadm-util.h Tue Feb 26 10:30:15 2013 +0200 +++ b/src/doveadm/doveadm-util.h Tue Feb 26 10:54:09 2013 +0200 @@ -8,6 +8,7 @@ const char *unixdate2str(time_t timestamp); const char *doveadm_plugin_getenv(const char *name); int doveadm_connect(const char *path); +int doveadm_tcp_connect(const char *target, unsigned int default_port); int doveadm_connect_with_default_port(const char *path, unsigned int default_port); From dovecot at dovecot.org Tue Feb 26 11:30:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 11:30:24 +0200 Subject: dovecot-2.2: lib-storage: Write dovecot.mailbox.log entries usin... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b90a89ca840f changeset: 15971:b90a89ca840f user: Timo Sirainen date: Tue Feb 26 11:30:11 2013 +0200 description: lib-storage: Write dovecot.mailbox.log entries using virtual names, not storage names. This file is used only by dsync, and the new dsync design uses only virtual names everywhere. This of course means that now it's not easily possible to use different virtual names for the same user, but nobody really did that before anyway. The only other fully working solution would be to send both the virtual and the storage names in dsync, but that's a bit of a waste. diffstat: src/lib-storage/index/index-storage.c | 13 +++++++++++-- src/lib-storage/mailbox-list.c | 9 --------- 2 files changed, 11 insertions(+), 11 deletions(-) diffs (70 lines): diff -r 91631438abce -r b90a89ca840f src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Tue Feb 26 10:54:09 2013 +0200 +++ b/src/lib-storage/index/index-storage.c Tue Feb 26 11:30:11 2013 +0200 @@ -595,7 +595,7 @@ /* failed directory deletion, but mailbox deletion succeeded. this was probably maildir++, which internally deleted the directory as well. add changelog record about that too. */ - mailbox_name_get_sha128(box->name, dir_sha128); + mailbox_name_get_sha128(box->vname, dir_sha128); mailbox_list_add_change(box->list, MAILBOX_LOG_RECORD_DELETE_DIR, dir_sha128); return 0; @@ -731,7 +731,7 @@ /* we'll track mailbox names, instead of GUIDs. We may be renaming a non-selectable mailbox (directory), which doesn't even have a GUID */ - mailbox_name_get_sha128(dest->name, guid); + mailbox_name_get_sha128(dest->vname, guid); mailbox_list_add_change(src->list, MAILBOX_LOG_RECORD_RENAME, guid); return 0; } @@ -828,6 +828,7 @@ struct mail_namespace *ns; struct mailbox_list *list = box->list; const char *subs_name; + guid_128_t guid; if ((list->ns->flags & NAMESPACE_FLAG_SUBSCRIPTIONS) != 0) subs_name = box->name; @@ -854,6 +855,14 @@ mail_storage_copy_list_error(box->storage, list); return -1; } + + /* subscriptions are about names, not about mailboxes. it's possible + to have a subscription to nonexistent mailbox. renames also don't + change subscriptions. so instead of using actual GUIDs, we'll use + hash of the name. */ + mailbox_name_get_sha128(box->vname, guid); + mailbox_list_add_change(list, set ? MAILBOX_LOG_RECORD_SUBSCRIBE : + MAILBOX_LOG_RECORD_UNSUBSCRIBE, guid); return 0; } diff -r 91631438abce -r b90a89ca840f src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Feb 26 10:54:09 2013 +0200 +++ b/src/lib-storage/mailbox-list.c Tue Feb 26 11:30:11 2013 +0200 @@ -1473,7 +1473,6 @@ int mailbox_list_set_subscribed(struct mailbox_list *list, const char *name, bool set) { - guid_128_t guid; int ret; /* make sure we'll refresh the file on next list */ @@ -1481,14 +1480,6 @@ if ((ret = list->v.set_subscribed(list, name, set)) <= 0) return ret; - - /* subscriptions are about names, not about mailboxes. it's possible - to have a subscription to nonexistent mailbox. renames also don't - change subscriptions. so instead of using actual GUIDs, we'll use - hash of the name. */ - mailbox_name_get_sha128(name, guid); - mailbox_list_add_change(list, set ? MAILBOX_LOG_RECORD_SUBSCRIBE : - MAILBOX_LOG_RECORD_UNSUBSCRIBE, guid); return 0; } From dovecot at dovecot.org Tue Feb 26 13:03:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 13:03:42 +0200 Subject: dovecot-2.2: lib-http: Track list of hosts using a linked list a... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4655adf5affc changeset: 15972:4655adf5affc user: Timo Sirainen date: Tue Feb 26 13:03:30 2013 +0200 description: lib-http: Track list of hosts using a linked list also. http_client_switch_ioloop() is done very often, and scanning a few entries in a linked list is much faster than going through a hash table. diffstat: src/lib-http/http-client-host.c | 6 ++++++ src/lib-http/http-client-private.h | 3 +++ src/lib-http/http-client.c | 13 +++---------- 3 files changed, 12 insertions(+), 10 deletions(-) diffs (95 lines): diff -r b90a89ca840f -r 4655adf5affc src/lib-http/http-client-host.c --- a/src/lib-http/http-client-host.c Tue Feb 26 11:30:11 2013 +0200 +++ b/src/lib-http/http-client-host.c Tue Feb 26 13:03:30 2013 +0200 @@ -5,6 +5,7 @@ #include "str.h" #include "hash.h" #include "array.h" +#include "llist.h" #include "ioloop.h" #include "istream.h" #include "ostream.h" @@ -276,6 +277,7 @@ hostname = host->name; hash_table_insert(client->hosts, hostname, host); + DLLIST_PREPEND(&client->hosts_list, host); http_client_host_debug(host, "Host created"); } @@ -367,9 +369,13 @@ { struct http_client_host *host = *_host; struct http_client_host_port *hport; + const char *hostname = host->name; http_client_host_debug(host, "Host destroy"); + DLLIST_REMOVE(&host->client->hosts_list, host); + hash_table_remove(host->client->hosts, hostname); + if (host->dns_lookup != NULL) dns_lookup_abort(&host->dns_lookup); diff -r b90a89ca840f -r 4655adf5affc src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Tue Feb 26 11:30:11 2013 +0200 +++ b/src/lib-http/http-client-private.h Tue Feb 26 13:03:30 2013 +0200 @@ -94,6 +94,8 @@ }; struct http_client_host { + struct http_client_host *prev, *next; + struct http_client *client; char *name; @@ -175,6 +177,7 @@ struct connection_list *conn_list; HASH_TABLE_TYPE(http_client_host) hosts; + struct http_client_host *hosts_list; HASH_TABLE_TYPE(http_client_peer) peers; unsigned int pending_requests; }; diff -r b90a89ca840f -r 4655adf5affc src/lib-http/http-client.c --- a/src/lib-http/http-client.c Tue Feb 26 11:30:11 2013 +0200 +++ b/src/lib-http/http-client.c Tue Feb 26 13:03:30 2013 +0200 @@ -104,7 +104,6 @@ { struct http_client *client = *_client; struct hash_iterate_context *iter; - const char *hostname; struct http_client_host *host; const struct http_client_peer_addr *addr; struct http_client_peer *peer; @@ -118,11 +117,10 @@ hash_table_destroy(&client->peers); /* free hosts */ - iter = hash_table_iterate_init(client->hosts); - while (hash_table_iterate(iter, client->hosts, &hostname, &host)) { + while (client->hosts_list != NULL) { + host = client->hosts_list; http_client_host_free(&host); } - hash_table_iterate_deinit(&iter); hash_table_destroy(&client->hosts); connection_list_deinit(&client->conn_list); @@ -147,15 +145,10 @@ /* move dns lookups */ if (client->set.dns_client_socket_path != '\0') { - struct hash_iterate_context *iter; struct http_client_host *host; - const char *hostname; - iter = hash_table_iterate_init(client->hosts); - while (hash_table_iterate(iter, client->hosts, &hostname, &host)) { + for (host = client->hosts_list; host != NULL; host = host->next) http_client_host_switch_ioloop(host); - } - hash_table_iterate_deinit(&iter); } } From dovecot at dovecot.org Tue Feb 26 13:04:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 13:04:58 +0200 Subject: dovecot-2.2: Added io_loop_have_ios() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4517f9b201f2 changeset: 15973:4517f9b201f2 user: Timo Sirainen date: Tue Feb 26 13:04:09 2013 +0200 description: Added io_loop_have_ios() diffstat: src/lib/ioloop.c | 5 +++++ src/lib/ioloop.h | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diffs (23 lines): diff -r 4655adf5affc -r 4517f9b201f2 src/lib/ioloop.c --- a/src/lib/ioloop.c Tue Feb 26 13:03:30 2013 +0200 +++ b/src/lib/ioloop.c Tue Feb 26 13:04:09 2013 +0200 @@ -660,3 +660,8 @@ timeout_remove(_timeout); return new_to; } + +bool io_loop_have_ios(struct ioloop *ioloop) +{ + return ioloop->io_files; +} diff -r 4655adf5affc -r 4517f9b201f2 src/lib/ioloop.h --- a/src/lib/ioloop.h Tue Feb 26 13:03:30 2013 +0200 +++ b/src/lib/ioloop.h Tue Feb 26 13:04:09 2013 +0200 @@ -137,5 +137,7 @@ struct io *io_loop_move_io(struct io **io); /* Like io_loop_move_io(), but for timeouts. */ struct timeout *io_loop_move_timeout(struct timeout **timeout); +/* Returns TRUE if any IOs have been added to the ioloop. */ +bool io_loop_have_ios(struct ioloop *ioloop); #endif From dovecot at dovecot.org Tue Feb 26 13:04:58 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 13:04:58 +0200 Subject: dovecot-2.2: lib-http: Assert-crash in http_client_wait() if it'... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/90d6ba26fb95 changeset: 15974:90d6ba26fb95 user: Timo Sirainen date: Tue Feb 26 13:04:50 2013 +0200 description: lib-http: Assert-crash in http_client_wait() if it's waiting without doing anything. diffstat: src/lib-http/http-client.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 4517f9b201f2 -r 90d6ba26fb95 src/lib-http/http-client.c --- a/src/lib-http/http-client.c Tue Feb 26 13:04:09 2013 +0200 +++ b/src/lib-http/http-client.c Tue Feb 26 13:04:50 2013 +0200 @@ -163,6 +163,7 @@ client->ioloop = io_loop_create(); http_client_switch_ioloop(client); + i_assert(io_loop_have_ios(client->ioloop)); do { http_client_debug(client, From dovecot at dovecot.org Tue Feb 26 15:53:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 15:53:42 +0200 Subject: dovecot-2.2: lib-fs: fs-metawrap should prefetch using the same ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2f8ccc958a6d changeset: 15975:2f8ccc958a6d user: Timo Sirainen date: Tue Feb 26 15:53:30 2013 +0200 description: lib-fs: fs-metawrap should prefetch using the same file as it uses for reading. diffstat: src/lib-fs/fs-metawrap.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (25 lines): diff -r 90d6ba26fb95 -r 2f8ccc958a6d src/lib-fs/fs-metawrap.c --- a/src/lib-fs/fs-metawrap.c Tue Feb 26 13:04:50 2013 +0200 +++ b/src/lib-fs/fs-metawrap.c Tue Feb 26 15:53:30 2013 +0200 @@ -119,7 +119,8 @@ flags &= ~FS_OPEN_FLAG_SEEKABLE; file->super = fs_file_init(fs->super, path, mode | flags); - if (mode == FS_OPEN_MODE_READONLY && (flags & FS_OPEN_FLAG_ASYNC) == 0) { + if (file->fs->wrap_metadata && mode == FS_OPEN_MODE_READONLY && + (flags & FS_OPEN_FLAG_ASYNC) == 0) { /* use async stream for super, so fs_read_stream() won't create another seekable stream unneededly */ file->super_read = fs_file_init(fs->super, path, mode | flags | @@ -211,7 +212,10 @@ { struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file; - return fs_prefetch(file->super, length); + if (!file->fs->wrap_metadata) + return fs_prefetch(file->super, length); + else + return fs_prefetch(file->super_read, length); } static ssize_t fs_metawrap_read(struct fs_file *_file, void *buf, size_t size) From dovecot at dovecot.org Tue Feb 26 17:16:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 17:16:55 +0200 Subject: dovecot-2.2: lib-http: Track peers using a linked list also. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/287e48607c96 changeset: 15976:287e48607c96 user: Timo Sirainen date: Tue Feb 26 15:55:16 2013 +0200 description: lib-http: Track peers using a linked list also. Mainly because this makes it much easier to debug using gdb. The overhead isn't that much extra either. diffstat: src/lib-http/http-client-peer.c | 3 +++ src/lib-http/http-client-private.h | 2 ++ src/lib-http/http-client.c | 7 ++----- 3 files changed, 7 insertions(+), 5 deletions(-) diffs (69 lines): diff -r 2f8ccc958a6d -r 287e48607c96 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Tue Feb 26 15:53:30 2013 +0200 +++ b/src/lib-http/http-client-peer.c Tue Feb 26 15:55:16 2013 +0200 @@ -5,6 +5,7 @@ #include "str.h" #include "hash.h" #include "array.h" +#include "llist.h" #include "istream.h" #include "ostream.h" #include "iostream-ssl.h" @@ -204,6 +205,7 @@ hash_table_insert (client->peers, (const struct http_client_peer_addr *)&peer->addr, peer); + DLLIST_PREPEND(&client->peers_list, peer); http_client_peer_debug(peer, "Peer created"); @@ -271,6 +273,7 @@ hash_table_remove (peer->client->peers, (const struct http_client_peer_addr *)&peer->addr); + DLLIST_REMOVE(&peer->client->peers_list, peer); i_free(peer); *_peer = NULL; diff -r 2f8ccc958a6d -r 287e48607c96 src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Tue Feb 26 15:53:30 2013 +0200 +++ b/src/lib-http/http-client-private.h Tue Feb 26 15:55:16 2013 +0200 @@ -119,6 +119,7 @@ struct http_client_peer { struct http_client_peer_addr addr; struct http_client *client; + struct http_client_peer *prev, *next; /* hosts served through this peer */ ARRAY_TYPE(http_client_host) hosts; @@ -179,6 +180,7 @@ HASH_TABLE_TYPE(http_client_host) hosts; struct http_client_host *hosts_list; HASH_TABLE_TYPE(http_client_peer) peers; + struct http_client_peer *peers_list; unsigned int pending_requests; }; diff -r 2f8ccc958a6d -r 287e48607c96 src/lib-http/http-client.c --- a/src/lib-http/http-client.c Tue Feb 26 15:53:30 2013 +0200 +++ b/src/lib-http/http-client.c Tue Feb 26 15:55:16 2013 +0200 @@ -103,17 +103,14 @@ void http_client_deinit(struct http_client **_client) { struct http_client *client = *_client; - struct hash_iterate_context *iter; struct http_client_host *host; - const struct http_client_peer_addr *addr; struct http_client_peer *peer; /* free peers */ - iter = hash_table_iterate_init(client->peers); - while (hash_table_iterate(iter, client->peers, &addr, &peer)) { + while (client->peers_list != NULL) { + peer = client->peers_list; http_client_peer_free(&peer); } - hash_table_iterate_deinit(&iter); hash_table_destroy(&client->peers); /* free hosts */ From dovecot at dovecot.org Tue Feb 26 17:16:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 17:16:55 +0200 Subject: dovecot-2.2: fs-api: Fixed fs_copy() generic implementation's er... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/38b9ea9fef2c changeset: 15977:38b9ea9fef2c user: Timo Sirainen date: Tue Feb 26 17:16:18 2013 +0200 description: fs-api: Fixed fs_copy() generic implementation's error messages diffstat: src/lib-fs/fs-api.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 287e48607c96 -r 38b9ea9fef2c src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Tue Feb 26 15:55:16 2013 +0200 +++ b/src/lib-fs/fs-api.c Tue Feb 26 17:16:18 2013 +0200 @@ -451,11 +451,13 @@ } while (o_stream_send_istream(dest->copy_output, dest->copy_input) > 0) ; if (dest->copy_input->stream_errno != 0) { + errno = dest->copy_input->stream_errno; fs_set_error(dest->fs, "read(%s) failed: %m", i_stream_get_name(dest->copy_input)); return -1; } if (dest->copy_output->stream_errno != 0) { + errno = dest->copy_output->stream_errno; fs_set_error(dest->fs, "write(%s) failed: %m", o_stream_get_name(dest->copy_output)); return -1; From dovecot at dovecot.org Tue Feb 26 17:16:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 17:16:55 +0200 Subject: dovecot-2.2: istream-metawrap: Support seeking if underlying str... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/526cd348936a changeset: 15978:526cd348936a user: Timo Sirainen date: Tue Feb 26 17:16:33 2013 +0200 description: istream-metawrap: Support seeking if underlying stream supports seeking diffstat: src/lib-fs/istream-metawrap.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diffs (39 lines): diff -r 38b9ea9fef2c -r 526cd348936a src/lib-fs/istream-metawrap.c --- a/src/lib-fs/istream-metawrap.c Tue Feb 26 17:16:18 2013 +0200 +++ b/src/lib-fs/istream-metawrap.c Tue Feb 26 17:16:33 2013 +0200 @@ -62,6 +62,20 @@ return i_stream_read_copy_from_parent(&stream->istream); } +static void +i_stream_metawrap_seek(struct istream_private *stream, + uoff_t v_offset, bool mark ATTR_UNUSED) +{ + struct metawrap_istream *mstream = (struct metawrap_istream *)stream; + + /* support seeking only after reading the metadata */ + i_assert(!mstream->in_metadata || + (mstream->start_offset == 0 && v_offset == 0)); + + stream->istream.v_offset = v_offset; + stream->skip = stream->pos = 0; +} + static int i_stream_metawrap_stat(struct istream_private *stream, bool exact) { struct metawrap_istream *mstream = (struct metawrap_istream *)stream; @@ -96,11 +110,12 @@ mstream->istream.max_buffer_size = input->real_stream->max_buffer_size; mstream->istream.read = i_stream_metawrap_read; - mstream->istream.stat = i_stream_metawrap_stat; + mstream->istream.seek = i_stream_metawrap_seek; + mstream->istream.stat = input->seekable ? i_stream_metawrap_stat : NULL; mstream->istream.istream.readable_fd = input->readable_fd; mstream->istream.istream.blocking = input->blocking; - mstream->istream.istream.seekable = FALSE; + mstream->istream.istream.seekable = input->seekable; mstream->in_metadata = TRUE; mstream->callback = callback; mstream->context = context; From dovecot at dovecot.org Tue Feb 26 17:18:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 17:18:23 +0200 Subject: dovecot-2.2: istream-seekable: Don't forcibly close underlying s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9297e1fcbe9e changeset: 15979:9297e1fcbe9e user: Timo Sirainen date: Tue Feb 26 17:18:18 2013 +0200 description: istream-seekable: Don't forcibly close underlying streams when stream is destroyed. The underlying streams may still have references and be reused for other purposes. diffstat: src/lib/istream-seekable.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diffs (17 lines): diff -r 526cd348936a -r 9297e1fcbe9e src/lib/istream-seekable.c --- a/src/lib/istream-seekable.c Tue Feb 26 17:16:33 2013 +0200 +++ b/src/lib/istream-seekable.c Tue Feb 26 17:18:18 2013 +0200 @@ -35,13 +35,10 @@ static void i_stream_seekable_close(struct iostream_private *stream) { struct seekable_istream *sstream = (struct seekable_istream *)stream; - unsigned int i; sstream->fd = -1; if (sstream->fd_input != NULL) i_stream_close(sstream->fd_input); - for (i = 0; sstream->input[i] != NULL; i++) - i_stream_close(sstream->input[i]); } static void unref_streams(struct seekable_istream *sstream) From dovecot at dovecot.org Tue Feb 26 17:44:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 26 Feb 2013 17:44:47 +0200 Subject: dovecot-2.2: lib-fs: If fs_read_stream() creates a seekable stre... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d84c7c11d7b7 changeset: 15980:d84c7c11d7b7 user: Timo Sirainen date: Tue Feb 26 17:44:34 2013 +0200 description: lib-fs: If fs_read_stream() creates a seekable stream, keep it open for future reads. diffstat: src/lib-fs/fs-api-private.h | 1 + src/lib-fs/fs-api.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diffs (45 lines): diff -r 9297e1fcbe9e -r d84c7c11d7b7 src/lib-fs/fs-api-private.h --- a/src/lib-fs/fs-api-private.h Tue Feb 26 17:18:18 2013 +0200 +++ b/src/lib-fs/fs-api-private.h Tue Feb 26 17:44:34 2013 +0200 @@ -69,6 +69,7 @@ char *path; enum fs_open_flags flags; + struct istream *seekable_input; struct istream *pending_read_input; bool write_pending; diff -r 9297e1fcbe9e -r d84c7c11d7b7 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Tue Feb 26 17:18:18 2013 +0200 +++ b/src/lib-fs/fs-api.c Tue Feb 26 17:44:34 2013 +0200 @@ -166,6 +166,8 @@ if (file->pending_read_input != NULL) i_stream_unref(&file->pending_read_input); + if (file->seekable_input != NULL) + i_stream_unref(&file->seekable_input); if (file->copy_input != NULL) { i_stream_unref(&file->copy_input); @@ -287,6 +289,11 @@ ssize_t ret; bool want_seekable = FALSE; + if (file->seekable_input != NULL) { + i_stream_seek(file->seekable_input, 0); + i_stream_ref(file->seekable_input); + return file->seekable_input; + } input = file->fs->v.read_stream(file, max_buffer_size); if (input->stream_errno != 0) { /* read failed already */ @@ -306,6 +313,9 @@ file->fs->temp_path_prefix); i_stream_set_name(input, i_stream_get_name(inputs[0])); i_stream_unref(&inputs[0]); + + file->seekable_input = input; + i_stream_ref(file->seekable_input); } if ((file->flags & FS_OPEN_FLAG_ASYNC) == 0 && !input->blocking) { /* read the whole input stream before returning */ From dovecot at dovecot.org Wed Feb 27 11:05:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 11:05:47 +0200 Subject: dovecot-2.2: dsync: Skip mailbox aliases (symlinks) for now. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/323b76127e3a changeset: 15981:323b76127e3a user: Timo Sirainen date: Wed Feb 27 11:04:14 2013 +0200 description: dsync: Skip mailbox aliases (symlinks) for now. diffstat: src/doveadm/dsync/dsync-mailbox-tree-fill.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r d84c7c11d7b7 -r 323b76127e3a src/doveadm/dsync/dsync-mailbox-tree-fill.c --- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Tue Feb 26 17:44:34 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Wed Feb 27 11:04:14 2013 +0200 @@ -195,6 +195,10 @@ struct mail_namespace *ns, const char *box_name) { const enum mailbox_list_iter_flags list_flags = + /* FIXME: we'll skip symlinks, because we can't handle them + currently. in future we could detect them and create them + by creating the symlink. */ + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_NO_AUTO_BOXES; const enum mailbox_list_iter_flags subs_list_flags = MAILBOX_LIST_ITER_NO_AUTO_BOXES | From dovecot at dovecot.org Wed Feb 27 11:22:08 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 11:22:08 +0200 Subject: dovecot-2.2: dsync: Change duplicate local mailbox GUIDs if they... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6bebab0d5c02 changeset: 15982:6bebab0d5c02 user: Timo Sirainen date: Wed Feb 27 11:21:48 2013 +0200 description: dsync: Change duplicate local mailbox GUIDs if they're found. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree.c | 27 ++++++++---- src/doveadm/dsync/dsync-mailbox-tree-fill.c | 49 +++++++++++++++++++++-- src/doveadm/dsync/dsync-mailbox-tree.c | 24 +++++----- src/doveadm/dsync/dsync-mailbox-tree.h | 11 +++- src/doveadm/dsync/test-dsync-mailbox-tree-sync.c | 9 ++- 5 files changed, 87 insertions(+), 33 deletions(-) diffs (247 lines): diff -r 323b76127e3a -r 6bebab0d5c02 src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Wed Feb 27 11:04:14 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Wed Feb 27 11:21:48 2013 +0200 @@ -315,7 +315,7 @@ bool dsync_brain_recv_mailbox_tree(struct dsync_brain *brain) { const struct dsync_mailbox_node *remote_node; - struct dsync_mailbox_node *node; + struct dsync_mailbox_node *node, *dup_node1, *dup_node2; const char *const *parts, *name; struct mail_namespace *ns; enum dsync_ibc_recv_ret ret; @@ -335,14 +335,22 @@ node->ns = ns; dsync_mailbox_node_copy_data(node, remote_node); } - if (ret == DSYNC_IBC_RECV_RET_FINISHED) { - if (dsync_mailbox_tree_build_guid_hash(brain->remote_mailbox_tree) < 0) - brain->failed = TRUE; + if (ret != DSYNC_IBC_RECV_RET_FINISHED) + return changed; - brain->state = DSYNC_STATE_RECV_MAILBOX_TREE_DELETES; - changed = TRUE; + if (dsync_mailbox_tree_build_guid_hash(brain->remote_mailbox_tree, + &dup_node1, &dup_node2) < 0) { + i_error("Remote sent duplicate mailbox GUID %s for mailboxes %s and %s", + guid_128_to_string(dup_node1->mailbox_guid), + dsync_mailbox_node_get_full_name(brain->remote_mailbox_tree, + dup_node1), + dsync_mailbox_node_get_full_name(brain->remote_mailbox_tree, + dup_node2)); + brain->failed = TRUE; } - return changed; + + brain->state = DSYNC_STATE_RECV_MAILBOX_TREE_DELETES; + return TRUE; } static void @@ -351,7 +359,7 @@ const struct dsync_mailbox_delete *other_del) { const struct dsync_mailbox_node *node; - struct dsync_mailbox_node *other_node; + struct dsync_mailbox_node *other_node, *old_node; const char *name; /* see if we can find the deletion based on mailbox tree that should @@ -388,7 +396,8 @@ other_node->ns = node->ns; other_node->existence = DSYNC_MAILBOX_NODE_DELETED; - if (dsync_mailbox_tree_guid_hash_add(other_tree, other_node) < 0) + if (dsync_mailbox_tree_guid_hash_add(other_tree, other_node, + &old_node) < 0) i_unreached(); } diff -r 323b76127e3a -r 6bebab0d5c02 src/doveadm/dsync/dsync-mailbox-tree-fill.c --- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Wed Feb 27 11:04:14 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Wed Feb 27 11:21:48 2013 +0200 @@ -191,6 +191,40 @@ return 0; } +static int +dsync_mailbox_tree_fix_guid_duplicate(struct dsync_mailbox_tree *tree, + struct dsync_mailbox_node *node1, + struct dsync_mailbox_node *node2) +{ + struct mailbox *box; + struct mailbox_update update; + const char *node2_name; + int ret = 0; + + memset(&update, 0, sizeof(update)); + guid_128_generate(update.mailbox_guid); + + node2_name = dsync_mailbox_node_get_full_name(tree, node2); + i_error("Duplicate mailbox GUID %s for mailboxes %s and %s - " + "giving a new GUID %s to %s", + guid_128_to_string(node1->mailbox_guid), + dsync_mailbox_node_get_full_name(tree, node1), node2_name, + guid_128_to_string(update.mailbox_guid), node2_name); + + i_assert(node2->ns != NULL); + box = mailbox_alloc(node2->ns->list, node2->name, 0); + if (mailbox_update(box, &update) < 0) { + i_error("Couldn't update mailbox %s GUID: %s", + node2->name, mailbox_get_last_error(box, NULL)); + ret = -1; + } else { + memcpy(node2->mailbox_guid, update.mailbox_guid, + sizeof(node2->mailbox_guid)); + } + mailbox_free(&box); + return ret; +} + int dsync_mailbox_tree_fill(struct dsync_mailbox_tree *tree, struct mail_namespace *ns, const char *box_name) { @@ -205,7 +239,7 @@ MAILBOX_LIST_ITER_SELECT_SUBSCRIBED | MAILBOX_LIST_ITER_RETURN_NO_FLAGS; struct mailbox_list_iterate_context *iter; - struct dsync_mailbox_node *node; + struct dsync_mailbox_node *node, *dup_node1, *dup_node2; const struct mailbox_info *info; const char *list_pattern = box_name != NULL ? box_name : "*"; int ret = 0; @@ -244,12 +278,17 @@ i_error("Mailbox listing for namespace '%s' failed", ns->prefix); ret = -1; } + if (ret < 0) + return -1; - if (dsync_mailbox_tree_build_guid_hash(tree) < 0) - ret = -1; + while (dsync_mailbox_tree_build_guid_hash(tree, &dup_node1, + &dup_node2) < 0) { + if (dsync_mailbox_tree_fix_guid_duplicate(tree, dup_node1, dup_node2) < 0) + return -1; + } /* add timestamps */ if (dsync_mailbox_tree_add_change_timestamps(tree, ns) < 0) - ret = -1; - return ret; + return -1; + return 0; } diff -r 323b76127e3a -r 6bebab0d5c02 src/doveadm/dsync/dsync-mailbox-tree.c --- a/src/doveadm/dsync/dsync-mailbox-tree.c Wed Feb 27 11:04:14 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-tree.c Wed Feb 27 11:21:48 2013 +0200 @@ -292,7 +292,8 @@ } int dsync_mailbox_tree_guid_hash_add(struct dsync_mailbox_tree *tree, - struct dsync_mailbox_node *node) + struct dsync_mailbox_node *node, + struct dsync_mailbox_node **old_node_r) { struct dsync_mailbox_node *old_node; uint8_t *guid = node->mailbox_guid; @@ -300,24 +301,20 @@ if (guid_128_is_empty(node->mailbox_guid)) return 0; - old_node = hash_table_lookup(tree->guid_hash, guid); + *old_node_r = old_node = hash_table_lookup(tree->guid_hash, guid); if (old_node == NULL) hash_table_insert(tree->guid_hash, guid, node); - else if (old_node != node) { - i_error("Duplicate mailbox GUID %s " - "for mailboxes %s and %s", - guid_128_to_string(node->mailbox_guid), - dsync_mailbox_node_get_full_name(tree, old_node), - dsync_mailbox_node_get_full_name(tree, node)); + else if (old_node != node) return -1; - } return 0; } -int dsync_mailbox_tree_build_guid_hash(struct dsync_mailbox_tree *tree) +int dsync_mailbox_tree_build_guid_hash(struct dsync_mailbox_tree *tree, + struct dsync_mailbox_node **dup_node1_r, + struct dsync_mailbox_node **dup_node2_r) { struct dsync_mailbox_tree_iter *iter; - struct dsync_mailbox_node *node; + struct dsync_mailbox_node *node, *old_node; const char *name; int ret = 0; @@ -327,8 +324,11 @@ } iter = dsync_mailbox_tree_iter_init(tree); while (dsync_mailbox_tree_iter_next(iter, &name, &node)) { - if (dsync_mailbox_tree_guid_hash_add(tree, node) < 0) + if (dsync_mailbox_tree_guid_hash_add(tree, node, &old_node) < 0) { + *dup_node1_r = node; + *dup_node2_r = old_node; ret = -1; + } } dsync_mailbox_tree_iter_deinit(&iter); return ret; diff -r 323b76127e3a -r 6bebab0d5c02 src/doveadm/dsync/dsync-mailbox-tree.h --- a/src/doveadm/dsync/dsync-mailbox-tree.h Wed Feb 27 11:04:14 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-tree.h Wed Feb 27 11:21:48 2013 +0200 @@ -137,11 +137,16 @@ struct dsync_mailbox_node * dsync_mailbox_tree_find_delete(struct dsync_mailbox_tree *tree, const struct dsync_mailbox_delete *del); -/* Build GUID lookup hash, if it's not already built. */ -int dsync_mailbox_tree_build_guid_hash(struct dsync_mailbox_tree *tree); +/* Build GUID lookup hash, if it's not already built. Returns 0 if ok, -1 if + there are duplicate GUIDs. The nodes with the duplicate GUIDs are + returned. */ +int dsync_mailbox_tree_build_guid_hash(struct dsync_mailbox_tree *tree, + struct dsync_mailbox_node **dup_node1_r, + struct dsync_mailbox_node **dup_node2_r); /* Manually add a new node to hash. */ int dsync_mailbox_tree_guid_hash_add(struct dsync_mailbox_tree *tree, - struct dsync_mailbox_node *node); + struct dsync_mailbox_node *node, + struct dsync_mailbox_node **old_node_r); /* Set remote separator used for directory deletions in dsync_mailbox_tree_find_delete() */ void dsync_mailbox_tree_set_remote_sep(struct dsync_mailbox_tree *tree, diff -r 323b76127e3a -r 6bebab0d5c02 src/doveadm/dsync/test-dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Wed Feb 27 11:04:14 2013 +0200 +++ b/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Wed Feb 27 11:21:48 2013 +0200 @@ -159,14 +159,15 @@ { struct dsync_mailbox_tree *orig_tree1, *orig_tree2; struct dsync_mailbox_tree_sync_ctx *ctx; + struct dsync_mailbox_node *dup_node1, *dup_node2; const struct dsync_mailbox_tree_sync_change *change; orig_tree1 = dsync_mailbox_tree_dup(tree1); orig_tree2 = dsync_mailbox_tree_dup(tree2); /* test tree1 -> tree2 */ - dsync_mailbox_tree_build_guid_hash(tree1); - dsync_mailbox_tree_build_guid_hash(tree2); + dsync_mailbox_tree_build_guid_hash(tree1, &dup_node1, &dup_node2); + dsync_mailbox_tree_build_guid_hash(tree2, &dup_node1, &dup_node2); ctx = dsync_mailbox_trees_sync_init(tree1, tree2, DSYNC_MAILBOX_TREES_SYNC_TYPE_TWOWAY); while ((change = dsync_mailbox_trees_sync_next(ctx)) != NULL) { @@ -180,8 +181,8 @@ } /* test tree2 -> tree1 */ - dsync_mailbox_tree_build_guid_hash(orig_tree1); - dsync_mailbox_tree_build_guid_hash(orig_tree2); + dsync_mailbox_tree_build_guid_hash(orig_tree1, &dup_node1, &dup_node2); + dsync_mailbox_tree_build_guid_hash(orig_tree2, &dup_node1, &dup_node2); ctx = dsync_mailbox_trees_sync_init(orig_tree2, orig_tree1, DSYNC_MAILBOX_TREES_SYNC_TYPE_TWOWAY); while ((change = dsync_mailbox_trees_sync_next(ctx)) != NULL) { From dovecot at dovecot.org Wed Feb 27 11:47:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 11:47:20 +0200 Subject: dovecot-2.2: dsync: Don't unnecessarily try to create all the ma... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fe170fd8168e changeset: 15983:fe170fd8168e user: Timo Sirainen date: Wed Feb 27 11:47:08 2013 +0200 description: dsync: Don't unnecessarily try to create all the mailboxes when they already exist. diffstat: src/doveadm/dsync/dsync-mailbox-tree-sync.c | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) diffs (45 lines): diff -r 6bebab0d5c02 -r fe170fd8168e src/doveadm/dsync/dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c Wed Feb 27 11:21:48 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c Wed Feb 27 11:47:08 2013 +0200 @@ -990,7 +990,17 @@ other_node = hash_table_lookup(other_tree->guid_hash, guid_p); if (other_node == NULL) other_node = sorted_tree_get(other_tree, name); - if (!dsync_mailbox_node_is_dir(other_node)) { + if (dsync_mailbox_node_is_dir(other_node)) { + /* create a missing mailbox */ + other_node->existence = DSYNC_MAILBOX_NODE_EXISTS; + other_node->ns = node->ns; + other_node->uid_validity = node->uid_validity; + memcpy(other_node->mailbox_guid, node->mailbox_guid, + sizeof(other_node->mailbox_guid)); + if (other_tree == ctx->local_tree) + sync_add_create_change(ctx, other_node, name); + } else if (!guid_128_equals(node->mailbox_guid, + other_node->mailbox_guid)) { /* mailbox with same name exists both locally and remotely, but they have different GUIDs and neither side has the other's GUID. typically this means that @@ -998,16 +1008,15 @@ INBOX). we'll just change the GUID for one of them. */ i_assert(node->existence == DSYNC_MAILBOX_NODE_EXISTS); + i_assert(node->ns == other_node->ns); + if (other_tree == ctx->local_tree) sync_add_create_change(ctx, node, name); } else { - other_node->existence = DSYNC_MAILBOX_NODE_EXISTS; - other_node->ns = node->ns; - other_node->uid_validity = node->uid_validity; - memcpy(other_node->mailbox_guid, node->mailbox_guid, - sizeof(other_node->mailbox_guid)); - if (other_tree == ctx->local_tree) - sync_add_create_change(ctx, other_node, name); + /* existing mailbox. mismatching UIDVALIDITY is handled + later while syncing the mailbox. */ + i_assert(node->existence == DSYNC_MAILBOX_NODE_EXISTS); + i_assert(node->ns == other_node->ns); } } dsync_mailbox_tree_iter_deinit(&iter); From dovecot at dovecot.org Wed Feb 27 12:00:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 12:00:20 +0200 Subject: dovecot-2.2: dsync: When changing duplicate mailbox GUIDs, choos... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1aa33a573234 changeset: 15984:1aa33a573234 user: Timo Sirainen date: Wed Feb 27 12:00:03 2013 +0200 description: dsync: When changing duplicate mailbox GUIDs, choose the same mailbox on both sides. diffstat: src/doveadm/dsync/dsync-mailbox-tree-fill.c | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diffs (50 lines): diff -r fe170fd8168e -r 1aa33a573234 src/doveadm/dsync/dsync-mailbox-tree-fill.c --- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Wed Feb 27 11:47:08 2013 +0200 +++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Wed Feb 27 12:00:03 2013 +0200 @@ -198,28 +198,37 @@ { struct mailbox *box; struct mailbox_update update; - const char *node2_name; + struct dsync_mailbox_node *change_node; int ret = 0; memset(&update, 0, sizeof(update)); guid_128_generate(update.mailbox_guid); - node2_name = dsync_mailbox_node_get_full_name(tree, node2); + /* just in case the duplication exists in both sides, + make them choose the same node */ + if (strcmp(dsync_mailbox_node_get_full_name(tree, node1), + dsync_mailbox_node_get_full_name(tree, node2)) <= 0) + change_node = node1; + else + change_node = node2; + i_error("Duplicate mailbox GUID %s for mailboxes %s and %s - " "giving a new GUID %s to %s", guid_128_to_string(node1->mailbox_guid), - dsync_mailbox_node_get_full_name(tree, node1), node2_name, - guid_128_to_string(update.mailbox_guid), node2_name); + dsync_mailbox_node_get_full_name(tree, node1), + dsync_mailbox_node_get_full_name(tree, node2), + guid_128_to_string(update.mailbox_guid), + dsync_mailbox_node_get_full_name(tree, change_node)); - i_assert(node2->ns != NULL); - box = mailbox_alloc(node2->ns->list, node2->name, 0); + i_assert(node1->ns != NULL && node2->ns != NULL); + box = mailbox_alloc(change_node->ns->list, change_node->name, 0); if (mailbox_update(box, &update) < 0) { i_error("Couldn't update mailbox %s GUID: %s", - node2->name, mailbox_get_last_error(box, NULL)); + change_node->name, mailbox_get_last_error(box, NULL)); ret = -1; } else { - memcpy(node2->mailbox_guid, update.mailbox_guid, - sizeof(node2->mailbox_guid)); + memcpy(change_node->mailbox_guid, update.mailbox_guid, + sizeof(change_node->mailbox_guid)); } mailbox_free(&box); return ret; From dovecot at dovecot.org Wed Feb 27 12:07:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 12:07:14 +0200 Subject: dovecot-2.2: dsync: Fixed running dsync for multiple users withi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/82ce71d8625c changeset: 15985:82ce71d8625c user: Timo Sirainen date: Wed Feb 27 12:07:06 2013 +0200 description: dsync: Fixed running dsync for multiple users within same command. diffstat: src/doveadm/dsync/doveadm-dsync.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (30 lines): diff -r 1aa33a573234 -r 82ce71d8625c src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Wed Feb 27 12:00:03 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Wed Feb 27 12:07:06 2013 +0200 @@ -521,6 +521,8 @@ io_remove(&ctx->io_err); if (ctx->fd_err != -1) i_close_fd(&ctx->fd_err); + ctx->input = NULL; + ctx->output = NULL; return ret; } @@ -553,6 +555,9 @@ { struct ssl_iostream_settings ssl_set; + if (ctx->ssl_ctx != NULL) + return 0; + memset(&ssl_set, 0, sizeof(ssl_set)); ssl_set.ca_dir = doveadm_settings->ssl_client_ca_dir; ssl_set.verify_remote_cert = TRUE; @@ -611,6 +616,7 @@ if (ctx->error != NULL) { *error_r = ctx->error; + ctx->error = NULL; return -1; } ctx->run_type = DSYNC_RUN_TYPE_STREAM; From dovecot at dovecot.org Wed Feb 27 12:34:29 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 12:34:29 +0200 Subject: dovecot-2.2: dsync: If I/O gets stalled, log the state in which ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f6377e089dee changeset: 15986:f6377e089dee user: Timo Sirainen date: Wed Feb 27 12:34:00 2013 +0200 description: dsync: If I/O gets stalled, log the state in which it happened. diffstat: src/doveadm/dsync/dsync-brain-mails.c | 2 +- src/doveadm/dsync/dsync-brain-private.h | 2 ++ src/doveadm/dsync/dsync-brain.c | 8 ++++++++ src/doveadm/dsync/dsync-ibc-private.h | 1 + src/doveadm/dsync/dsync-ibc-stream.c | 1 + src/doveadm/dsync/dsync-ibc.c | 5 +++++ src/doveadm/dsync/dsync-ibc.h | 1 + 7 files changed, 19 insertions(+), 1 deletions(-) diffs (90 lines): diff -r 82ce71d8625c -r f6377e089dee src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Wed Feb 27 12:07:06 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-mails.c Wed Feb 27 12:34:00 2013 +0200 @@ -8,7 +8,7 @@ #include "dsync-mailbox-export.h" #include "dsync-brain-private.h" -static const char *dsync_box_state_names[DSYNC_BOX_STATE_DONE+1] = { +const char *dsync_box_state_names[DSYNC_BOX_STATE_DONE+1] = { "mailbox", "changes", "mail_requests", diff -r 82ce71d8625c -r f6377e089dee src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Wed Feb 27 12:07:06 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain-private.h Wed Feb 27 12:34:00 2013 +0200 @@ -94,6 +94,8 @@ unsigned int failed:1; }; +extern const char *dsync_box_state_names[DSYNC_BOX_STATE_DONE+1]; + void dsync_brain_mailbox_trees_init(struct dsync_brain *brain); void dsync_brain_send_mailbox_tree(struct dsync_brain *brain); void dsync_brain_send_mailbox_tree_deletes(struct dsync_brain *brain); diff -r 82ce71d8625c -r f6377e089dee src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Wed Feb 27 12:07:06 2013 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Wed Feb 27 12:34:00 2013 +0200 @@ -160,6 +160,14 @@ *_brain = NULL; + if (dsync_ibc_has_timed_out(brain->ibc)) { + i_error("Timeout during state=%s%s", + dsync_state_names[brain->state], + brain->state != DSYNC_STATE_SYNC_MAILS ? "" : + t_strdup_printf(" (send=%s recv=%s)", + dsync_box_state_names[brain->box_send_state], + dsync_box_state_names[brain->box_recv_state])); + } if (dsync_ibc_has_failed(brain->ibc) || brain->state != DSYNC_STATE_DONE) brain->failed = TRUE; diff -r 82ce71d8625c -r f6377e089dee src/doveadm/dsync/dsync-ibc-private.h --- a/src/doveadm/dsync/dsync-ibc-private.h Wed Feb 27 12:07:06 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc-private.h Wed Feb 27 12:34:00 2013 +0200 @@ -73,6 +73,7 @@ void *io_context; unsigned int failed:1; + unsigned int timeout:1; }; #endif diff -r 82ce71d8625c -r f6377e089dee src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Wed Feb 27 12:07:06 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Wed Feb 27 12:34:00 2013 +0200 @@ -273,6 +273,7 @@ { i_error("dsync(%s): I/O has stalled, no activity for %u seconds", ibc->name, DSYNC_IBC_STREAM_TIMEOUT_MSECS/1000); + ibc->ibc.timeout = TRUE; dsync_ibc_stream_stop(ibc); } diff -r 82ce71d8625c -r f6377e089dee src/doveadm/dsync/dsync-ibc.c --- a/src/doveadm/dsync/dsync-ibc.c Wed Feb 27 12:07:06 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc.c Wed Feb 27 12:34:00 2013 +0200 @@ -188,6 +188,11 @@ return ibc->failed; } +bool dsync_ibc_has_timed_out(struct dsync_ibc *ibc) +{ + return ibc->timeout; +} + bool dsync_ibc_is_send_queue_full(struct dsync_ibc *ibc) { return ibc->v.is_send_queue_full(ibc); diff -r 82ce71d8625c -r f6377e089dee src/doveadm/dsync/dsync-ibc.h --- a/src/doveadm/dsync/dsync-ibc.h Wed Feb 27 12:07:06 2013 +0200 +++ b/src/doveadm/dsync/dsync-ibc.h Wed Feb 27 12:34:00 2013 +0200 @@ -119,6 +119,7 @@ void dsync_ibc_close_mail_streams(struct dsync_ibc *ibc); bool dsync_ibc_has_failed(struct dsync_ibc *ibc); +bool dsync_ibc_has_timed_out(struct dsync_ibc *ibc); bool dsync_ibc_is_send_queue_full(struct dsync_ibc *ibc); bool dsync_ibc_has_pending_data(struct dsync_ibc *ibc); From dovecot at dovecot.org Wed Feb 27 12:34:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 12:34:30 +0200 Subject: dovecot-2.2: timeout_add_short(1) may have caused infinite looping. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2bbec4dadcb6 changeset: 15987:2bbec4dadcb6 user: Timo Sirainen date: Wed Feb 27 12:34:18 2013 +0200 description: timeout_add_short(1) may have caused infinite looping. diffstat: src/lib/ioloop.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r f6377e089dee -r 2bbec4dadcb6 src/lib/ioloop.c --- a/src/lib/ioloop.c Wed Feb 27 12:34:00 2013 +0200 +++ b/src/lib/ioloop.c Wed Feb 27 12:34:18 2013 +0200 @@ -193,7 +193,7 @@ timeout_reset_timeval(struct timeout *timeout, struct timeval *tv_now) { timeout_update_next(timeout, tv_now); - if (timeout->msecs == 0) { + if (timeout->msecs <= 1) { /* if we came here from io_loop_handle_timeouts(), next_run must be larger than tv_now or we could go to infinite loop. +1000 to get 1 ms further, another +1000 to From dovecot at dovecot.org Wed Feb 27 13:05:51 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 13:05:51 +0200 Subject: dovecot-2.1: message-decoder: Fixed assert-crash when trying to ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cf7b590d19f9 changeset: 14928:cf7b590d19f9 user: Timo Sirainen date: Wed Feb 27 13:05:40 2013 +0200 description: message-decoder: Fixed assert-crash when trying to decode partial character twice. diffstat: src/lib-mail/message-decoder.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diffs (34 lines): diff -r a46951762a27 -r cf7b590d19f9 src/lib-mail/message-decoder.c --- a/src/lib-mail/message-decoder.c Tue Feb 26 10:37:19 2013 +0200 +++ b/src/lib-mail/message-decoder.c Wed Feb 27 13:05:40 2013 +0200 @@ -207,7 +207,7 @@ { unsigned char trans_buf[MAX_TRANSLATION_BUF_SIZE+1]; unsigned int data_wanted, skip; - size_t trans_size; + size_t trans_size, orig_size; /* @UNSAFE: move the previously untranslated bytes to trans_buf and see if we have now enough data to get the next character @@ -218,11 +218,19 @@ data_wanted = *size; memcpy(trans_buf + ctx->translation_size, *data, data_wanted); - trans_size = ctx->translation_size + data_wanted; + orig_size = trans_size = ctx->translation_size + data_wanted; (void)charset_to_utf8(ctx->charset_trans, trans_buf, &trans_size, ctx->buf2); - i_assert(trans_size > ctx->translation_size); + if (trans_size < ctx->translation_size) { + /* need more data to finish the translation. */ + i_assert(orig_size < MAX_TRANSLATION_BUF_SIZE); + memcpy(ctx->translation_buf, trans_buf, orig_size); + ctx->translation_size = orig_size; + *data += *size; + *size = 0; + return; + } skip = trans_size - ctx->translation_size; i_assert(*size >= skip); From dovecot at dovecot.org Wed Feb 27 13:07:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 13:07:42 +0200 Subject: dovecot-2.1: message-decode: Minor fix to previous change. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/311371856dcf changeset: 14929:311371856dcf user: Timo Sirainen date: Wed Feb 27 13:07:35 2013 +0200 description: message-decode: Minor fix to previous change. The == condition should probably never happen, but handle it anyway. diffstat: src/lib-mail/message-decoder.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r cf7b590d19f9 -r 311371856dcf src/lib-mail/message-decoder.c --- a/src/lib-mail/message-decoder.c Wed Feb 27 13:05:40 2013 +0200 +++ b/src/lib-mail/message-decoder.c Wed Feb 27 13:07:35 2013 +0200 @@ -222,7 +222,7 @@ (void)charset_to_utf8(ctx->charset_trans, trans_buf, &trans_size, ctx->buf2); - if (trans_size < ctx->translation_size) { + if (trans_size <= ctx->translation_size) { /* need more data to finish the translation. */ i_assert(orig_size < MAX_TRANSLATION_BUF_SIZE); memcpy(ctx->translation_buf, trans_buf, orig_size); From dovecot at dovecot.org Wed Feb 27 14:26:40 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 14:26:40 +0200 Subject: dovecot-2.2: acl: Don't assert-crash on storages that have no ro... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2020ed15efb9 changeset: 15988:2020ed15efb9 user: Timo Sirainen date: Wed Feb 27 14:26:28 2013 +0200 description: acl: Don't assert-crash on storages that have no root directory. diffstat: src/plugins/acl/acl-backend-vfile-acllist.c | 35 +++++++++++++++++----------- 1 files changed, 21 insertions(+), 14 deletions(-) diffs (89 lines): diff -r 2bbec4dadcb6 -r 2020ed15efb9 src/plugins/acl/acl-backend-vfile-acllist.c --- a/src/plugins/acl/acl-backend-vfile-acllist.c Wed Feb 27 12:34:18 2013 +0200 +++ b/src/plugins/acl/acl-backend-vfile-acllist.c Wed Feb 27 14:26:28 2013 +0200 @@ -38,14 +38,16 @@ } } -static const char *acl_list_get_root_dir(struct acl_backend_vfile *backend, - enum mailbox_list_path_type *type_r) +static bool acl_list_get_root_dir(struct acl_backend_vfile *backend, + const char **root_dir_r, + enum mailbox_list_path_type *type_r) { struct mail_storage *storage; const char *rootdir, *maildir; - rootdir = mailbox_list_get_root_forced(backend->backend.list, - MAILBOX_LIST_PATH_TYPE_DIR); + if (!mailbox_list_get_root_path(backend->backend.list, + MAILBOX_LIST_PATH_TYPE_DIR, &rootdir)) + return FALSE; *type_r = MAILBOX_LIST_PATH_TYPE_DIR; storage = mailbox_list_get_namespace(backend->backend.list)->storage; @@ -62,15 +64,20 @@ *type_r = MAILBOX_LIST_PATH_TYPE_CONTROL; } } - return rootdir; + *root_dir_r = rootdir; + return TRUE; } -static const char *acl_list_get_path(struct acl_backend_vfile *backend) +static bool acl_list_get_path(struct acl_backend_vfile *backend, + const char **path_r) { enum mailbox_list_path_type type; + const char *root_dir; - return t_strconcat(acl_list_get_root_dir(backend, &type), - "/"ACLLIST_FILENAME, NULL); + if (!acl_list_get_root_dir(backend, &root_dir, &type)) + return FALSE; + *path_r = t_strconcat(root_dir, "/"ACLLIST_FILENAME, NULL); + return TRUE; } static int acl_backend_vfile_acllist_read(struct acl_backend_vfile *backend) @@ -83,8 +90,7 @@ backend->acllist_last_check = ioloop_time; - path = acl_list_get_path(backend); - if (path == NULL) { + if (!acl_list_get_path(backend, &path)) { /* we're never going to build acllist for this namespace. */ acllist_clear(backend, 0); return 0; @@ -216,8 +222,7 @@ i_assert(!backend->rebuilding_acllist); - rootdir = acl_list_get_root_dir(backend, &type); - if (rootdir == NULL) + if (!acl_list_get_root_dir(backend, &rootdir, &type)) return 0; ns = mailbox_list_get_namespace(list); @@ -290,7 +295,8 @@ } if (ret == 0) { - acllist_path = acl_list_get_path(backend); + if (!acl_list_get_path(backend, &acllist_path)) + i_unreached(); if (rename(str_c(path), acllist_path) < 0) { i_error("rename(%s, %s) failed: %m", str_c(path), acllist_path); @@ -321,7 +327,8 @@ return 0; else { /* delete it to make sure it gets rebuilt later */ - acllist_path = acl_list_get_path(backend); + if (!acl_list_get_path(backend, &acllist_path)) + i_unreached(); if (unlink(acllist_path) < 0 && errno != ENOENT) i_error("unlink(%s) failed: %m", acllist_path); return -1; From dovecot at dovecot.org Wed Feb 27 18:00:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Feb 2013 18:00:34 +0200 Subject: dovecot-2.2: doveadm: Fixed connecting to UNIX sockets. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/976bf9e69367 changeset: 15989:976bf9e69367 user: Timo Sirainen date: Wed Feb 27 18:00:29 2013 +0200 description: doveadm: Fixed connecting to UNIX sockets. diffstat: src/doveadm/doveadm-util.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 2020ed15efb9 -r 976bf9e69367 src/doveadm/doveadm-util.c --- a/src/doveadm/doveadm-util.c Wed Feb 27 14:26:28 2013 +0200 +++ b/src/doveadm/doveadm-util.c Wed Feb 27 18:00:29 2013 +0200 @@ -160,7 +160,6 @@ fd = net_connect_unix(path); if (fd == -1) i_fatal("net_connect_unix(%s) failed: %m", path); - return -1; } return fd; }