From dovecot at dovecot.org Thu Sep 1 12:34:22 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Sep 2011 12:34:22 +0300 Subject: dovecot-2.1: stats plugin: Get disk I/O from getrusage(), not fr... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ea0b4da3ceef changeset: 13367:ea0b4da3ceef user: Timo Sirainen date: Thu Sep 01 12:34:11 2011 +0300 description: stats plugin: Get disk I/O from getrusage(), not from /proc/self/io. They're pretty much the same values anyway, and getrusage() is more portable. diffstat: src/plugins/stats/stats-plugin.c | 80 +--------------------------------------- 1 files changed, 2 insertions(+), 78 deletions(-) diffs (104 lines): diff -r c05ac0650e23 -r ea0b4da3ceef src/plugins/stats/stats-plugin.c --- a/src/plugins/stats/stats-plugin.c Thu Sep 01 11:59:21 2011 +0300 +++ b/src/plugins/stats/stats-plugin.c Thu Sep 01 12:34:11 2011 +0300 @@ -2,8 +2,6 @@ #include "lib.h" #include "ioloop.h" -#include "array.h" -#include "hostpid.h" #include "llist.h" #include "str.h" #include "time-util.h" @@ -50,80 +48,6 @@ static void session_stats_refresh_timeout(struct mail_user *user); -static int -process_io_buffer_parse(const char *buf, uint64_t *read_bytes_r, - uint64_t *write_bytes_r) -{ - const char *const *tmp; - uint64_t cbytes; - - tmp = t_strsplit(buf, "\n"); - for (; *tmp != NULL; tmp++) { - if (strncmp(*tmp, "read_bytes: ", 12) == 0) { - if (str_to_uint64(*tmp + 12, read_bytes_r) < 0) - return -1; - } else if (strncmp(*tmp, "write_bytes: ", 13) == 0) { - if (str_to_uint64(*tmp + 13, write_bytes_r) < 0) - return -1; - } else if (strncmp(*tmp, "cancelled_write_bytes: ", 23) == 0) { - if (str_to_uint64(*tmp + 23, &cbytes) < 0) - return -1; - /* it's not 100% correct to simply subtract the - cancelled bytes from write bytes, but it's close - enough. */ - if (*write_bytes_r < cbytes) - *write_bytes_r = 0; - else - *write_bytes_r -= cbytes; - } - } - return 0; -} - -static void -process_read_io_stats(uint64_t *read_bytes_r, uint64_t *write_bytes_r) -{ - static bool io_disabled = FALSE; - char path[100], buf[1024]; - int fd, ret; - - *read_bytes_r = *write_bytes_r = 0; - - if (io_disabled) - return; - - i_snprintf(path, sizeof(path), "/proc/%s/io", my_pid); - fd = open(path, O_RDONLY); - if (fd == -1) { - if (errno != ENOENT) - i_error("open(%s) failed: %m", path); - io_disabled = TRUE; - return; - } - ret = read(fd, buf, sizeof(buf)); - if (ret <= 0) { - if (ret == -1) - i_error("read(%s) failed: %m", path); - else - i_error("read(%s) returned EOF", path); - } else if (ret == sizeof(buf)) { - /* just shouldn't happen.. */ - i_error("%s is larger than expected", path); - io_disabled = TRUE; - } else { - buf[ret] = '\0'; - T_BEGIN { - if (process_io_buffer_parse(buf, read_bytes_r, - write_bytes_r) < 0) { - i_error("Invalid input in file %s", path); - io_disabled = TRUE; - } - } T_END; - } - if (close(fd) < 0) - i_error("close(%s) failed: %m", path); -} - static void trans_stats_dec(struct mailbox_transaction_stats *dest, const struct mailbox_transaction_stats *src) { @@ -171,8 +95,8 @@ stats_r->maj_faults = usage.ru_majflt; stats_r->vol_cs = usage.ru_nvcsw; stats_r->invol_cs = usage.ru_nivcsw; - /* disk io */ - process_read_io_stats(&stats_r->disk_input, &stats_r->disk_output); + stats_r->disk_input = (unsigned long long)usage.ru_inblock * 512ULL; + stats_r->disk_output = (unsigned long long)usage.ru_oublock * 512ULL; user_trans_stats_get(suser, &stats_r->trans_stats); } From dovecot at dovecot.org Thu Sep 1 17:53:03 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Sep 2011 17:53:03 +0300 Subject: dovecot-2.1: stats: Log more verbosely what happened if stats sh... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1c2d8da38a06 changeset: 13368:1c2d8da38a06 user: Timo Sirainen date: Thu Sep 01 17:52:51 2011 +0300 description: stats: Log more verbosely what happened if stats shrink. diffstat: src/stats/mail-command.c | 7 +++++-- src/stats/mail-session.c | 6 ++++-- src/stats/mail-stats.c | 27 +++++++++++++++++++++++---- src/stats/mail-stats.h | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) diffs (114 lines): diff -r ea0b4da3ceef -r 1c2d8da38a06 src/stats/mail-command.c --- a/src/stats/mail-command.c Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-command.c Thu Sep 01 17:52:51 2011 +0300 @@ -94,6 +94,7 @@ struct mail_session *session; struct mail_command *cmd; struct mail_stats stats, diff_stats; + const char *error; unsigned int cmd_id; bool done; int ret; @@ -134,8 +135,10 @@ if (session->ip != NULL) session->ip->num_cmds++; } else { - if (!mail_stats_diff(&cmd->stats, &stats, &diff_stats)) { - *error_r = "UPDATE-SESSION: stats shrank"; + if (!mail_stats_diff(&cmd->stats, &stats, &diff_stats, + &error)) { + *error_r = t_strconcat("UPDATE-SESSION: stats shrank: ", + error, NULL); return -1; } cmd->last_update = ioloop_timeval; diff -r ea0b4da3ceef -r 1c2d8da38a06 src/stats/mail-session.c --- a/src/stats/mail-session.c Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-session.c Thu Sep 01 17:52:51 2011 +0300 @@ -201,6 +201,7 @@ { struct mail_session *session; struct mail_stats stats, diff_stats; + const char *error; int ret; /* [key=value ..] */ @@ -212,8 +213,9 @@ return -1; } - if (!mail_stats_diff(&session->stats, &stats, &diff_stats)) { - *error_r = "UPDATE-SESSION: stats shrank"; + if (!mail_stats_diff(&session->stats, &stats, &diff_stats, &error)) { + *error_r = t_strconcat("UPDATE-SESSION: stats shrank: ", + error, NULL); return -1; } mail_session_refresh(session, &diff_stats); diff -r ea0b4da3ceef -r 1c2d8da38a06 src/stats/mail-stats.c --- a/src/stats/mail-stats.c Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-stats.c Thu Sep 01 17:52:51 2011 +0300 @@ -162,7 +162,7 @@ bool mail_stats_diff(const struct mail_stats *stats1, const struct mail_stats *stats2, - struct mail_stats *diff_stats_r) + struct mail_stats *diff_stats_r, const char **error_r) { unsigned int i; @@ -178,20 +178,39 @@ case TYPE_NUM: switch (parse_map[i].size) { case sizeof(uint32_t): - if (!mail_stats_diff_uint32(dest, src1, src2)) + if (!mail_stats_diff_uint32(dest, src1, src2)) { + *error_r = t_strdup_printf("%s %u < %u", + parse_map[i].name, + *(const uint32_t *)src2, + *(const uint32_t *)src1); return FALSE; + } break; case sizeof(uint64_t): - if (!mail_stats_diff_uint64(dest, src1, src2)) + if (!mail_stats_diff_uint64(dest, src1, src2)) { + const uint64_t *n1 = src1, *n2 = src2; + + *error_r = t_strdup_printf("%s %llu < %llu", + parse_map[i].name, + (unsigned long long)n2, + (unsigned long long)n1); return FALSE; + } break; default: i_unreached(); } break; case TYPE_TIMEVAL: - if (!mail_stats_diff_timeval(dest, src1, src2)) + if (!mail_stats_diff_timeval(dest, src1, src2)) { + const struct timeval *tv1 = src1, *tv2 = src2; + + *error_r = t_strdup_printf("%s %ld.%d < %ld.%d", + parse_map[i].name, + (long)tv2->tv_sec, (int)tv2->tv_usec, + (long)tv1->tv_sec, (int)tv1->tv_usec); return FALSE; + } break; } } diff -r ea0b4da3ceef -r 1c2d8da38a06 src/stats/mail-stats.h --- a/src/stats/mail-stats.h Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-stats.h Thu Sep 01 17:52:51 2011 +0300 @@ -107,7 +107,7 @@ is so, FALSE if not */ bool mail_stats_diff(const struct mail_stats *stats1, const struct mail_stats *stats2, - struct mail_stats *diff_stats_r); + struct mail_stats *diff_stats_r, const char **error_r); void mail_stats_add(struct mail_stats *dest, const struct mail_stats *src); #endif From dovecot at dovecot.org Thu Sep 1 19:33:34 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Sep 2011 19:33:34 +0300 Subject: dovecot-2.0: lib-index: Make sure mail_index_sync_record() doesn... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1a6528646e11 changeset: 12898:1a6528646e11 user: Timo Sirainen date: Thu Sep 01 19:33:22 2011 +0300 description: lib-index: Make sure mail_index_sync_record() doesn't waste data stack. diffstat: src/lib-index/mail-index-sync-update.c | 24 +++++++++++++++++------- src/lib-index/mail-index-view-sync.c | 6 ++---- 2 files changed, 19 insertions(+), 11 deletions(-) diffs (64 lines): diff -r 5320315600a4 -r 1a6528646e11 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Tue Aug 30 04:32:55 2011 +0300 +++ b/src/lib-index/mail-index-sync-update.c Thu Sep 01 19:33:22 2011 +0300 @@ -518,9 +518,10 @@ return 1; } -int mail_index_sync_record(struct mail_index_sync_map_ctx *ctx, - const struct mail_transaction_header *hdr, - const void *data) +static int +mail_index_sync_record_real(struct mail_index_sync_map_ctx *ctx, + const struct mail_transaction_header *hdr, + const void *data) { int ret = 0; @@ -813,6 +814,18 @@ return ret; } +int mail_index_sync_record(struct mail_index_sync_map_ctx *ctx, + const struct mail_transaction_header *hdr, + const void *data) +{ + int ret; + + T_BEGIN { + ret = mail_index_sync_record_real(ctx, hdr, data); + } T_END; + return ret; +} + void mail_index_sync_map_init(struct mail_index_sync_map_ctx *sync_map_ctx, struct mail_index_view *view, enum mail_index_sync_handler_type type) @@ -1020,10 +1033,7 @@ } /* we'll just skip over broken entries */ - T_BEGIN { - (void)mail_index_sync_record(&sync_map_ctx, - thdr, tdata); - } T_END; + (void)mail_index_sync_record(&sync_map_ctx, thdr, tdata); } map = view->map; diff -r 5320315600a4 -r 1a6528646e11 src/lib-index/mail-index-view-sync.c --- a/src/lib-index/mail-index-view-sync.c Tue Aug 30 04:32:55 2011 +0300 +++ b/src/lib-index/mail-index-view-sync.c Thu Sep 01 19:33:22 2011 +0300 @@ -736,10 +736,8 @@ if (ctx->sync_map_update && !synced_to_map) { if ((hdr->type & (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_GUID)) == 0) { - T_BEGIN { - ret = mail_index_sync_record(&ctx->sync_map_ctx, - hdr, ctx->data); - } T_END; + ret = mail_index_sync_record(&ctx->sync_map_ctx, + hdr, ctx->data); } if (ret < 0) return -1; From dovecot at dovecot.org Fri Sep 2 07:11:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 Sep 2011 07:11:33 +0300 Subject: dovecot-2.1: fts-solr: Don't send delete to Solr if we're quite ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/338ba56340c0 changeset: 13369:338ba56340c0 user: Timo Sirainen date: Fri Sep 02 07:11:16 2011 +0300 description: fts-solr: Don't send delete to Solr if we're quite sure it doesn't exist. diffstat: src/plugins/fts-solr/fts-backend-solr.c | 42 +++++++++++++++++++++++++------- 1 files changed, 32 insertions(+), 10 deletions(-) diffs (66 lines): diff -r 1c2d8da38a06 -r 338ba56340c0 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Thu Sep 01 17:52:51 2011 +0300 +++ b/src/plugins/fts-solr/fts-backend-solr.c Fri Sep 02 07:11:16 2011 +0300 @@ -32,9 +32,13 @@ uint32_t prev_uid; string_t *cmd, *hdr, *hdr_fields; - bool headers_open; - bool cur_header_index; - bool documents_added; + uint32_t last_indexed_uid; + + unsigned int last_indexed_uid_set:1; + unsigned int headers_open:1; + unsigned int cur_header_index:1; + unsigned int documents_added:1; + unsigned int expunges:1; }; static struct solr_connection *solr_conn = NULL; @@ -294,13 +298,15 @@ if (fts_backed_solr_build_commit(ctx) < 0) ret = -1; - /* commit and wait until the documents we just indexed are - visible to the following search */ - str = t_strdup_printf("", - ctx->documents_added ? "true" : "false"); - if (solr_connection_post(solr_conn, str) < 0) - ret = -1; + if (ctx->documents_added || ctx->expunges) { + /* commit and wait until the documents we just indexed are + visible to the following search */ + str = t_strdup_printf("", + ctx->documents_added ? "true" : "false"); + if (solr_connection_post(solr_conn, str) < 0) + ret = -1; + } str_free(&ctx->cmd); str_free(&ctx->hdr); @@ -340,6 +346,22 @@ { struct solr_fts_backend_update_context *ctx = (struct solr_fts_backend_update_context *)_ctx; + struct fts_index_header hdr; + + if (!ctx->last_indexed_uid_set) { + if (!fts_index_get_header(ctx->cur_box, &hdr)) + ctx->last_indexed_uid = 0; + else + ctx->last_indexed_uid = hdr.last_indexed_uid; + ctx->last_indexed_uid_set = TRUE; + } + if (ctx->last_indexed_uid == 0 || + uid > ctx->last_indexed_uid + 100) { + /* don't waste time asking Solr to expunge a message that is + highly unlikely to be indexed at this time. */ + return; + } + ctx->expunges = TRUE; T_BEGIN { string_t *cmd; From dovecot at dovecot.org Sat Sep 3 12:05:09 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 03 Sep 2011 12:05:09 +0300 Subject: dovecot-2.1: lib-sql: Don't link sql libraries to libdovecot-sql... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d2b27eae9221 changeset: 13370:d2b27eae9221 user: Timo Sirainen date: Sat Sep 03 12:04:56 2011 +0300 description: lib-sql: Don't link sql libraries to libdovecot-sql.so when building them as plugins. diffstat: src/lib-sql/Makefile.am | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diffs (27 lines): diff -r 338ba56340c0 -r d2b27eae9221 src/lib-sql/Makefile.am --- a/src/lib-sql/Makefile.am Fri Sep 02 07:11:16 2011 +0300 +++ b/src/lib-sql/Makefile.am Sat Sep 03 12:04:56 2011 +0300 @@ -68,15 +68,18 @@ libdriver_sqlite_la_LIBADD = $(SQLITE_LIBS) libdriver_sqlite_la_CPPFLAGS = -I$(top_srcdir)/src/lib $(SQLITE_CFLAGS) libdriver_sqlite_la_SOURCES = driver-sqlite.c + +sql_libs = +else +sql_libs = \ + $(MYSQL_LIBS) \ + $(PGSQL_LIBS) \ + $(SQLITE_LIBS) endif pkglib_LTLIBRARIES = libdovecot-sql.la libdovecot_sql_la_SOURCES = -libdovecot_sql_la_LIBADD = libsql.la $(deplibs) \ - $(MYSQL_LIBS) \ - $(PGSQL_LIBS) \ - $(SQLITE_LIBS) \ - $(MODULE_LIBS) +libdovecot_sql_la_LIBADD = libsql.la $(deplibs) $(MODULE_LIBS) $(sql_libs) libdovecot_sql_la_DEPENDENCIES = libsql.la libdovecot_sql_la_LDFLAGS = -export-dynamic From dovecot at dovecot.org Sun Sep 4 11:30:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:30:18 +0300 Subject: dovecot-2.1: stats: Don't assert-crash at exit if there are unfi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ddcf7d2f109a changeset: 13371:ddcf7d2f109a user: Timo Sirainen date: Sun Sep 04 10:12:30 2011 +0300 description: stats: Don't assert-crash at exit if there are unfinished commands. diffstat: src/stats/mail-command.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diffs (16 lines): diff -r d2b27eae9221 -r ddcf7d2f109a src/stats/mail-command.c --- a/src/stats/mail-command.c Sat Sep 03 12:04:56 2011 +0300 +++ b/src/stats/mail-command.c Sun Sep 04 10:12:30 2011 +0300 @@ -173,6 +173,11 @@ void mail_commands_deinit(void) { - while (stable_mail_commands != NULL) + while (stable_mail_commands != NULL) { + struct mail_command *cmd = stable_mail_commands; + + if (cmd->id != 0) + mail_command_unref(&cmd); mail_command_free(stable_mail_commands); + } } From dovecot at dovecot.org Sun Sep 4 11:30:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:30:18 +0300 Subject: dovecot-2.1: anvil: Assert-crashfix at exit when there were fifo... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/66453d942761 changeset: 13372:66453d942761 user: Timo Sirainen date: Sun Sep 04 10:15:16 2011 +0300 description: anvil: Assert-crashfix at exit when there were fifo connections. diffstat: src/anvil/anvil-connection.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diffs (37 lines): diff -r ddcf7d2f109a -r 66453d942761 src/anvil/anvil-connection.c --- a/src/anvil/anvil-connection.c Sun Sep 04 10:12:30 2011 +0300 +++ b/src/anvil/anvil-connection.c Sun Sep 04 10:15:16 2011 +0300 @@ -29,6 +29,7 @@ unsigned int version_received:1; unsigned int handshaked:1; unsigned int master:1; + unsigned int fifo:1; }; struct anvil_connection *anvil_connections = NULL; @@ -180,12 +181,15 @@ conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE); conn->io = io_add(fd, IO_READ, anvil_connection_input, conn); conn->master = master; + conn->fifo = fifo; DLLIST_PREPEND(&anvil_connections, conn); return conn; } void anvil_connection_destroy(struct anvil_connection *conn) { + bool fifo = conn->fifo; + DLLIST_REMOVE(&anvil_connections, conn); io_remove(&conn->io); @@ -196,7 +200,8 @@ i_error("close(anvil conn) failed: %m"); i_free(conn); - master_service_client_connection_destroyed(master_service); + if (!fifo) + master_service_client_connection_destroyed(master_service); } void anvil_connections_destroy_all(void) From dovecot at dovecot.org Sun Sep 4 11:30:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:30:18 +0300 Subject: dovecot-2.1: stats: Don't increase session stats based on comman... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9434093229aa changeset: 13373:9434093229aa user: Timo Sirainen date: Sun Sep 04 10:25:39 2011 +0300 description: stats: Don't increase session stats based on command stats. This was buggy because the session stats were now increased twice. It could have been possible to keep doing this and on UPDATE-SESSION simply replace the old session stats, but that might still have caused the session stats to temporarily go too high and then drop down. diffstat: src/stats/mail-command.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 66453d942761 -r 9434093229aa src/stats/mail-command.c --- a/src/stats/mail-command.c Sun Sep 04 10:15:16 2011 +0300 +++ b/src/stats/mail-command.c Sun Sep 04 10:25:39 2011 +0300 @@ -137,7 +137,7 @@ } else { if (!mail_stats_diff(&cmd->stats, &stats, &diff_stats, &error)) { - *error_r = t_strconcat("UPDATE-SESSION: stats shrank: ", + *error_r = t_strconcat("UPDATE-CMD: stats shrank: ", error, NULL); return -1; } @@ -148,7 +148,7 @@ cmd->id = 0; mail_command_unref(&cmd); } - mail_session_refresh(session, &diff_stats); + mail_session_refresh(session, NULL); return 0; } From dovecot at dovecot.org Sun Sep 4 11:30:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:30:18 +0300 Subject: dovecot-2.1: imapc: Use EXAMINE command when possible. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/54318eaada67 changeset: 13374:54318eaada67 user: Timo Sirainen date: Sun Sep 04 10:30:21 2011 +0300 description: imapc: Use EXAMINE command when possible. diffstat: src/lib-storage/index/imapc/imapc-storage.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (28 lines): diff -r 9434093229aa -r 54318eaada67 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 10:25:39 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 10:30:21 2011 +0300 @@ -312,6 +312,7 @@ { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; struct imapc_open_context ctx; + bool examine; if (index_storage_mailbox_open(box, FALSE) < 0) return -1; @@ -320,13 +321,15 @@ /* We don't actually want to SELECT the mailbox. */ return 0; } + examine = (box->flags & MAILBOX_FLAG_READONLY) != 0 && + (box->flags & MAILBOX_FLAG_DROP_RECENT) == 0; mbox->opening = TRUE; ctx.mbox = mbox; ctx.ret = -2; mbox->client_box = imapc_client_mailbox_open(mbox->storage->client, - box->name, FALSE, + box->name, examine, imapc_mailbox_open_callback, &ctx, mbox); while (ctx.ret == -2) From dovecot at dovecot.org Sun Sep 4 11:30:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:30:18 +0300 Subject: dovecot-2.1: stats: Minor error message fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/583023c4db60 changeset: 13375:583023c4db60 user: Timo Sirainen date: Sun Sep 04 10:40:58 2011 +0300 description: stats: Minor error message fix. diffstat: src/stats/mail-session.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 54318eaada67 -r 583023c4db60 src/stats/mail-session.c --- a/src/stats/mail-session.c Sun Sep 04 10:30:21 2011 +0300 +++ b/src/stats/mail-session.c Sun Sep 04 10:40:58 2011 +0300 @@ -37,7 +37,7 @@ static void mail_session_idle_timeout(struct mail_session *session) { - i_warning("Session %s appears to be have crashed, disconnecting it", + i_warning("Session %s appears to have crashed, disconnecting it", guid_128_to_string(session->guid)); mail_session_disconnect(session); } From dovecot at dovecot.org Sun Sep 4 11:30:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:30:18 +0300 Subject: dovecot-2.1: imapc: Fixed IDLE handling. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e1a8ad9c83cd changeset: 13376:e1a8ad9c83cd user: Timo Sirainen date: Sun Sep 04 10:48:46 2011 +0300 description: imapc: Fixed IDLE handling. diffstat: src/lib-storage/index/imapc/imapc-storage.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diffs (29 lines): diff -r 583023c4db60 -r e1a8ad9c83cd src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 10:40:58 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 10:48:46 2011 +0300 @@ -510,6 +510,16 @@ imapc_async_callback, mbox->storage); } +static void imapc_idle_noop_callback(const struct imapc_command_reply *reply, + void *context) + +{ + struct imapc_mailbox *mbox = context; + + imapc_async_callback(reply, mbox->box.storage); + imapc_client_mailbox_idle(mbox->client_box); +} + static void imapc_notify_changes(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; @@ -528,7 +538,7 @@ here by sending a NOOP. this helps with clients that break IDLE when clicking "get mail". */ imapc_client_mailbox_cmd(mbox->client_box, "NOOP", - imapc_async_callback, mbox->storage); + imapc_idle_noop_callback, mbox); } else { /* remote server doesn't support IDLE. check for changes with NOOP every once in a while. */ From dovecot at dovecot.org Sun Sep 4 11:30:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:30:18 +0300 Subject: dovecot-2.1: imapc: Added assert. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/44e3c053f9f8 changeset: 13377:44e3c053f9f8 user: Timo Sirainen date: Sun Sep 04 10:55:33 2011 +0300 description: imapc: Added assert. diffstat: src/lib-storage/index/imapc/imapc-client.c | 5 +++++ src/lib-storage/index/imapc/imapc-client.h | 1 + src/lib-storage/index/imapc/imapc-storage.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-) diffs (37 lines): diff -r e1a8ad9c83cd -r 44e3c053f9f8 src/lib-storage/index/imapc/imapc-client.c --- a/src/lib-storage/index/imapc/imapc-client.c Sun Sep 04 10:48:46 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.c Sun Sep 04 10:55:33 2011 +0300 @@ -136,6 +136,11 @@ io_loop_stop(client->ioloop); } +bool imapc_client_is_running(struct imapc_client *client) +{ + return client->ioloop != NULL; +} + void imapc_client_stop_now(struct imapc_client *client) { client->stop_now = TRUE; diff -r e1a8ad9c83cd -r 44e3c053f9f8 src/lib-storage/index/imapc/imapc-client.h --- a/src/lib-storage/index/imapc/imapc-client.h Sun Sep 04 10:48:46 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.h Sun Sep 04 10:55:33 2011 +0300 @@ -117,6 +117,7 @@ /* Stop immediately, don't finish even any already read pending replies. They'll be finished when imapc_client_run() is again called. */ void imapc_client_stop_now(struct imapc_client *client); +bool imapc_client_is_running(struct imapc_client *client); struct imapc_client_mailbox * imapc_client_mailbox_open(struct imapc_client *client, diff -r e1a8ad9c83cd -r 44e3c053f9f8 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 10:48:46 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 10:55:33 2011 +0300 @@ -542,6 +542,7 @@ } else { /* remote server doesn't support IDLE. check for changes with NOOP every once in a while. */ + i_assert(!imapc_client_is_running(mbox->storage->client)); mbox->to_idle_check = timeout_add(box->notify_min_interval * 1000, imapc_idle_timeout, mbox); From dovecot at dovecot.org Sun Sep 4 11:51:37 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:51:37 +0300 Subject: dovecot-2.1: imapc: Fixed syncing external changes to mailbox wh... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f8d5f872498d changeset: 13378:f8d5f872498d user: Timo Sirainen date: Sun Sep 04 11:51:23 2011 +0300 description: imapc: Fixed syncing external changes to mailbox when opening it. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 58 ++++++++++++++++++++++++---- src/lib-storage/index/imapc/imapc-storage.h | 2 + 2 files changed, 51 insertions(+), 9 deletions(-) diffs (111 lines): diff -r 44e3c053f9f8 -r f8d5f872498d src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 10:55:33 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 11:51:23 2011 +0300 @@ -60,6 +60,29 @@ return ret; } +static void imapc_mailbox_open_finish(struct imapc_mailbox *mbox) +{ + const struct mail_index_record *rec; + struct imapc_seqmap *seqmap; + uint32_t lseq, rseq, old_count; + + /* if we haven't seen FETCH reply for some messages at the end of + mailbox they've been externally expunged. */ + imapc_mailbox_init_delayed_trans(mbox); + seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); + + old_count = mail_index_view_get_messages_count(mbox->delayed_sync_view); + for (lseq = old_count; lseq > 0; lseq--) { + rec = mail_index_lookup(mbox->delayed_sync_view, lseq); + if (rec->uid <= mbox->highest_seen_uid) + break; + + rseq = imapc_seqmap_lseq_to_rseq(seqmap, lseq); + imapc_seqmap_expunge(seqmap, rseq); + mail_index_expunge(mbox->delayed_sync_trans, lseq); + } +} + static void imapc_newmsgs_callback(const struct imapc_command_reply *reply, void *context) @@ -75,8 +98,10 @@ mail_storage_set_critical(&mbox->storage->storage, "imapc: Command failed: %s", reply->text_full); } - if (mbox->opening) + if (mbox->opening) { + imapc_mailbox_open_finish(mbox); imapc_client_stop(mbox->storage->client); + } } static void imapc_untagged_exists(const struct imapc_untagged_reply *reply, @@ -94,15 +119,26 @@ if (view == NULL) view = mbox->box.view; - seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); - next_lseq = mail_index_view_get_messages_count(view) + 1; - next_rseq = imapc_seqmap_lseq_to_rseq(seqmap, next_lseq); - if (next_rseq > rcount) { - if (rcount == 0 || !mbox->opening) - return; - /* initial SELECT. we don't know what the flags are. */ + if (rcount == 0) { + /* nothing in this mailbox */ + return; + } + if (mbox->opening) { + /* We don't know the latest flags, refresh them. */ first_uid = 1; } else { + seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); + next_lseq = mail_index_view_get_messages_count(view) + 1; + next_rseq = imapc_seqmap_lseq_to_rseq(seqmap, next_lseq); + if (rcount < next_rseq) { + if (rcount == next_rseq-1) { + /* duplicate EXISTS - ignore */ + return; + } + imapc_mailbox_set_corrupted(mbox, + "EXISTS reply shrank mailbox size"); + return; + } hdr = mail_index_get_header(view); first_uid = hdr->next_uid; } @@ -225,7 +261,9 @@ return; } /* we're opening the mailbox. this message was expunged - externally, so expunge it ourself too. */ + externally, so expunge it ourself too. this code assumes + that FETCH responses come in ascending order when opening + mailbox. */ imapc_seqmap_expunge(seqmap, rseq); mail_index_expunge(mbox->delayed_sync_trans, lseq); lseq++; @@ -258,6 +296,8 @@ } mail_index_keywords_unref(&kw); } T_END; + if (mbox->highest_seen_uid < uid) + mbox->highest_seen_uid = uid; imapc_mailbox_idle_notify(mbox); } diff -r 44e3c053f9f8 -r f8d5f872498d src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 10:55:33 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 11:51:23 2011 +0300 @@ -54,6 +54,8 @@ ARRAY_DEFINE(untagged_callbacks, struct imapc_mailbox_event_callback); ARRAY_DEFINE(resp_text_callbacks, struct imapc_mailbox_event_callback); + uint32_t highest_seen_uid; + unsigned int opening:1; unsigned int new_msgs:1; }; From dovecot at dovecot.org Sun Sep 4 11:52:25 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 11:52:25 +0300 Subject: dovecot-2.1: lib-index: When marking index corrupted, delete als... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7b240ecc37b5 changeset: 13379:7b240ecc37b5 user: Timo Sirainen date: Sun Sep 04 11:52:16 2011 +0300 description: lib-index: When marking index corrupted, delete also transaction log file. diffstat: src/lib-index/mail-index.c | 1 + src/lib-index/mail-transaction-log.c | 11 +++++++++++ src/lib-index/mail-transaction-log.h | 2 ++ 3 files changed, 14 insertions(+), 0 deletions(-) diffs (43 lines): diff -r f8d5f872498d -r 7b240ecc37b5 src/lib-index/mail-index.c --- a/src/lib-index/mail-index.c Sun Sep 04 11:51:23 2011 +0300 +++ b/src/lib-index/mail-index.c Sun Sep 04 11:52:16 2011 +0300 @@ -771,6 +771,7 @@ if (unlink(index->filepath) < 0 && errno != ENOENT && errno != ESTALE) mail_index_set_syscall_error(index, "unlink()"); + (void)mail_transaction_log_unlink(index->log); } } diff -r f8d5f872498d -r 7b240ecc37b5 src/lib-index/mail-transaction-log.c --- a/src/lib-index/mail-transaction-log.c Sun Sep 04 11:51:23 2011 +0300 +++ b/src/lib-index/mail-transaction-log.c Sun Sep 04 11:52:16 2011 +0300 @@ -539,6 +539,17 @@ return 0; } +int mail_transaction_log_unlink(struct mail_transaction_log *log) +{ + if (unlink(log->filepath) < 0 && + errno != ENOENT && errno != ESTALE) { + mail_index_file_set_syscall_error(log->index, log->filepath, + "unlink()"); + return -1; + } + return 0; +} + void mail_transaction_log_get_dotlock_set(struct mail_transaction_log *log, struct dotlock_settings *set_r) { diff -r f8d5f872498d -r 7b240ecc37b5 src/lib-index/mail-transaction-log.h --- a/src/lib-index/mail-transaction-log.h Sun Sep 04 11:51:23 2011 +0300 +++ b/src/lib-index/mail-transaction-log.h Sun Sep 04 11:52:16 2011 +0300 @@ -282,5 +282,7 @@ If it doesn't exist, mtime_r is set to 0. */ int mail_transaction_log_get_mtime(struct mail_transaction_log *log, time_t *mtime_r); +/* Unlink transaction log files */ +int mail_transaction_log_unlink(struct mail_transaction_log *log); #endif From dovecot at dovecot.org Sun Sep 4 12:03:22 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 12:03:22 +0300 Subject: dovecot-2.1: imapc: Fixed error handling while opening mailbox. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0b786a676453 changeset: 13380:0b786a676453 user: Timo Sirainen date: Sun Sep 04 12:03:12 2011 +0300 description: imapc: Fixed error handling while opening mailbox. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 11 +++++++---- src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/index/imapc/imapc-storage.h | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diffs (50 lines): diff -r 7b240ecc37b5 -r 0b786a676453 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 11:52:16 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 12:03:12 2011 +0300 @@ -90,16 +90,19 @@ struct imapc_mailbox *mbox = context; if (reply->state == IMAPC_COMMAND_STATE_OK) - ; + mbox->open_success = TRUE; else if (reply->state == IMAPC_COMMAND_STATE_NO) { imapc_copy_error_from_reply(mbox->storage, MAIL_ERROR_PARAMS, reply); - } else { + } else if (mbox->opening || + reply->state != IMAPC_COMMAND_STATE_DISCONNECTED) { mail_storage_set_critical(&mbox->storage->storage, - "imapc: Command failed: %s", reply->text_full); + "imapc: Mailbox newmsgs fetch failed: %s", + reply->text_full); } if (mbox->opening) { - imapc_mailbox_open_finish(mbox); + if (reply->state == IMAPC_COMMAND_STATE_OK) + imapc_mailbox_open_finish(mbox); imapc_client_stop(mbox->storage->client); } } diff -r 7b240ecc37b5 -r 0b786a676453 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 11:52:16 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 12:03:12 2011 +0300 @@ -335,7 +335,7 @@ while (ctx.ret == -2) imapc_client_run(mbox->storage->client); mbox->opening = FALSE; - if (ctx.ret < 0) { + if (!mbox->open_success) { mailbox_close(box); return -1; } diff -r 7b240ecc37b5 -r 0b786a676453 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 11:52:16 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 12:03:12 2011 +0300 @@ -57,6 +57,7 @@ uint32_t highest_seen_uid; unsigned int opening:1; + unsigned int open_success:1; unsigned int new_msgs:1; }; From dovecot at dovecot.org Sun Sep 4 12:04:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 12:04:31 +0300 Subject: dovecot-2.1: imapc: Error logging cleanups. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7db3ed5e17ed changeset: 13381:7db3ed5e17ed user: Timo Sirainen date: Sun Sep 04 12:04:09 2011 +0300 description: imapc: Error logging cleanups. Don't bother to log disconnection errors for NOOP. diffstat: src/lib-storage/index/imapc/imapc-mail-fetch.c | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 16 ++++++++-------- src/lib-storage/index/imapc/imapc-storage.h | 4 ++-- src/lib-storage/index/imapc/imapc-sync.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diffs (93 lines): diff -r 0b786a676453 -r 7db3ed5e17ed src/lib-storage/index/imapc/imapc-mail-fetch.c --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Sun Sep 04 12:03:12 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Sun Sep 04 12:04:09 2011 +0300 @@ -41,7 +41,7 @@ reply); } else { mail_storage_set_critical(&mbox->storage->storage, - "imapc: Command failed: %s", reply->text_full); + "imapc: Mail prefetch failed: %s", reply->text_full); } imapc_client_stop(mbox->storage->client); } diff -r 0b786a676453 -r 7db3ed5e17ed src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 12:03:12 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 12:04:09 2011 +0300 @@ -126,8 +126,8 @@ imapc_client_stop(ctx->storage->client); } -static void imapc_async_callback(const struct imapc_command_reply *reply, - void *context) +static void imapc_noop_callback(const struct imapc_command_reply *reply, + void *context) { struct imapc_storage *storage = context; @@ -136,18 +136,18 @@ ; else if (reply->state == IMAPC_COMMAND_STATE_NO) { imapc_copy_error_from_reply(storage, MAIL_ERROR_PARAMS, reply); - } else { + } else if (reply->state != IMAPC_COMMAND_STATE_DISCONNECTED) { mail_storage_set_critical(&storage->storage, - "imapc: Command failed: %s", reply->text_full); + "imapc: NOOP failed: %s", reply->text_full); } } -void imapc_async_stop_callback(const struct imapc_command_reply *reply, +void imapc_noop_stop_callback(const struct imapc_command_reply *reply, void *context) { struct imapc_storage *storage = context; - imapc_async_callback(reply, context); + imapc_noop_callback(reply, context); imapc_client_stop(storage->client); } @@ -507,7 +507,7 @@ static void imapc_idle_timeout(struct imapc_mailbox *mbox) { imapc_client_mailbox_cmd(mbox->client_box, "NOOP", - imapc_async_callback, mbox->storage); + imapc_noop_callback, mbox->storage); } static void imapc_idle_noop_callback(const struct imapc_command_reply *reply, @@ -516,7 +516,7 @@ { struct imapc_mailbox *mbox = context; - imapc_async_callback(reply, mbox->box.storage); + imapc_noop_callback(reply, mbox->box.storage); imapc_client_mailbox_idle(mbox->client_box); } diff -r 0b786a676453 -r 7db3ed5e17ed src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 12:03:12 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 12:04:09 2011 +0300 @@ -87,8 +87,8 @@ void imapc_simple_run(struct imapc_simple_context *sctx); void imapc_simple_callback(const struct imapc_command_reply *reply, void *context); -void imapc_async_stop_callback(const struct imapc_command_reply *reply, - void *context); +void imapc_noop_stop_callback(const struct imapc_command_reply *reply, + void *context); int imapc_mailbox_commit_delayed_trans(struct imapc_mailbox *mbox, bool *changes_r); diff -r 0b786a676453 -r 7db3ed5e17ed src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Sun Sep 04 12:03:12 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Sun Sep 04 12:04:09 2011 +0300 @@ -314,7 +314,7 @@ /* IDLE not supported. do NOOP to get latest changes before starting sync. */ imapc_client_mailbox_cmdf(mbox->client_box, - imapc_async_stop_callback, + imapc_noop_stop_callback, mbox->storage, "NOOP"); imapc_client_run(mbox->storage->client); } From dovecot at dovecot.org Sun Sep 4 12:38:34 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 12:38:34 +0300 Subject: dovecot-2.1: imapc: Fixed handling immediate changes when starti... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e404a1bef6bc changeset: 13383:e404a1bef6bc user: Timo Sirainen date: Sun Sep 04 12:37:51 2011 +0300 description: imapc: Fixed handling immediate changes when starting IDLE. diffstat: src/lib-storage/index/imapc/imapc-client.c | 9 ++++++- src/lib-storage/index/imapc/imapc-client.h | 3 +- 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-save.c | 4 +- src/lib-storage/index/imapc/imapc-storage.c | 28 +++++++++++++++++++++++-- src/lib-storage/index/imapc/imapc-storage.h | 2 + src/lib-storage/index/imapc/imapc-sync.c | 4 +- 8 files changed, 42 insertions(+), 12 deletions(-) diffs (170 lines): diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-client.c --- a/src/lib-storage/index/imapc/imapc-client.c Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.c Sun Sep 04 12:37:51 2011 +0300 @@ -99,7 +99,7 @@ client->untagged_context = context; } -void imapc_client_run(struct imapc_client *client) +void imapc_client_run_pre(struct imapc_client *client) { struct imapc_client_connection *const *connp; struct ioloop *prev_ioloop = current_ioloop; @@ -121,8 +121,13 @@ if (io_loop_is_running(client->ioloop)) io_loop_run(client->ioloop); + current_ioloop = prev_ioloop; +} - current_ioloop = prev_ioloop; +void imapc_client_run_post(struct imapc_client *client) +{ + struct imapc_client_connection *const *connp; + array_foreach(&client->conns, connp) imapc_connection_ioloop_changed((*connp)->conn); diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-client.h --- a/src/lib-storage/index/imapc/imapc-client.h Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.h Sun Sep 04 12:37:51 2011 +0300 @@ -112,7 +112,8 @@ imapc_untagged_callback_t *callback, void *context); -void imapc_client_run(struct imapc_client *client); +void imapc_client_run_pre(struct imapc_client *client); +void imapc_client_run_post(struct imapc_client *client); void imapc_client_stop(struct imapc_client *client); /* Stop immediately, don't finish even any already read pending replies. They'll be finished when imapc_client_run() is again called. */ diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-mail-fetch.c --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Sun Sep 04 12:37:51 2011 +0300 @@ -156,7 +156,7 @@ or until all FETCH replies have been received (i.e. some FETCHes failed) */ while (!imapc_mail_have_fields(imail, fields) && imail->fetch_count > 0) - imapc_client_run(storage->client); + imapc_storage_run(storage); return 0; } diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Sun Sep 04 12:37:51 2011 +0300 @@ -210,7 +210,7 @@ (struct imapc_storage *)_mail->box->storage; while (imail->fetch_count > 0) - imapc_client_run(storage->client); + imapc_storage_run(storage); index_mail_close(_mail); } diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-save.c --- a/src/lib-storage/index/imapc/imapc-save.c Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-save.c Sun Sep 04 12:37:51 2011 +0300 @@ -191,7 +191,7 @@ ctx->mbox->box.name, flags, internaldate, input); i_stream_unref(&input); while (sctx.ret == -2) - imapc_client_run(ctx->mbox->storage->client); + imapc_storage_run(ctx->mbox->storage); return sctx.ret; } @@ -337,7 +337,7 @@ "UID COPY %u %s", mail->uid, _t->box->name); while (sctx.ret == -2) - imapc_client_run(src_mbox->storage->client); + imapc_storage_run(src_mbox->storage); ctx->finished = TRUE; return sctx.ret; } diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 12:37:51 2011 +0300 @@ -6,7 +6,8 @@ #include "imap-arg.h" #include "imap-resp-code.h" #include "imapc-mail.h" -#include "imapc-client.h" +#include "imapc-client-private.h" +#include "imapc-connection.h" #include "imapc-list.h" #include "imapc-sync.h" #include "imapc-settings.h" @@ -105,7 +106,28 @@ void imapc_simple_run(struct imapc_simple_context *sctx) { while (sctx->ret == -2) - imapc_client_run(sctx->storage->client); + imapc_storage_run(sctx->storage); +} + +void imapc_storage_run(struct imapc_storage *storage) +{ + struct imapc_client_mailbox *client_box; + struct imapc_client_connection *const *connp; + struct imapc_mailbox *mbox; + + imapc_client_run_pre(storage->client); + + array_foreach(&storage->client->conns, connp) { + client_box = imapc_connection_get_mailbox((*connp)->conn); + if (client_box == NULL) + continue; + + mbox = client_box->untagged_box_context; + if (mbox->to_idle_delay != NULL) + mbox->to_idle_delay = io_loop_move_timeout(&mbox->to_idle_delay); + } + + imapc_client_run_post(storage->client); } void imapc_simple_callback(const struct imapc_command_reply *reply, @@ -333,7 +355,7 @@ imapc_mailbox_open_callback, &ctx, mbox); while (ctx.ret == -2) - imapc_client_run(mbox->storage->client); + imapc_storage_run(mbox->storage); mbox->opening = FALSE; if (!mbox->open_success) { mailbox_close(box); diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 12:37:51 2011 +0300 @@ -79,6 +79,8 @@ struct mail_index_transaction_commit_result *result); void imapc_transaction_save_rollback(struct mail_save_context *ctx); +void imapc_storage_run(struct imapc_storage *storage); + void imapc_copy_error_from_reply(struct imapc_storage *storage, enum mail_error default_error, const struct imapc_command_reply *reply); diff -r b9c967c7d66b -r e404a1bef6bc src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Sun Sep 04 12:29:45 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Sun Sep 04 12:37:51 2011 +0300 @@ -204,7 +204,7 @@ imapc_sync_expunge_finish(ctx); while (ctx->sync_command_count > 0) - imapc_client_run(ctx->mbox->storage->client); + imapc_storage_run(ctx->mbox->storage); array_free(&ctx->expunged_uids); if (box->v.sync_notify != NULL) @@ -316,7 +316,7 @@ imapc_client_mailbox_cmdf(mbox->client_box, imapc_noop_stop_callback, mbox->storage, "NOOP"); - imapc_client_run(mbox->storage->client); + imapc_storage_run(mbox->storage); } if (imapc_mailbox_commit_delayed_trans(mbox, &changes) < 0) From dovecot at dovecot.org Sun Sep 4 12:38:34 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 12:38:34 +0300 Subject: dovecot-2.1: imapc: Avoid assert-crashing if a new message's UID... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b9c967c7d66b changeset: 13382:b9c967c7d66b user: Timo Sirainen date: Sun Sep 04 12:29:45 2011 +0300 description: imapc: Avoid assert-crashing if a new message's UID is smaller than next_uid. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) diffs (68 lines): diff -r 7db3ed5e17ed -r b9c967c7d66b src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 12:04:09 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 12:29:45 2011 +0300 @@ -64,15 +64,15 @@ { const struct mail_index_record *rec; struct imapc_seqmap *seqmap; - uint32_t lseq, rseq, old_count; + uint32_t lseq, rseq, cur_count; /* if we haven't seen FETCH reply for some messages at the end of mailbox they've been externally expunged. */ imapc_mailbox_init_delayed_trans(mbox); seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); - old_count = mail_index_view_get_messages_count(mbox->delayed_sync_view); - for (lseq = old_count; lseq > 0; lseq--) { + cur_count = mail_index_view_get_messages_count(mbox->delayed_sync_view); + for (lseq = cur_count; lseq > 0; lseq--) { rec = mail_index_lookup(mbox->delayed_sync_view, lseq); if (rec->uid <= mbox->highest_seen_uid) break; @@ -198,9 +198,10 @@ struct imapc_mail *const *mailp; const struct imap_arg *list, *flags_list; const char *atom; + const struct mail_index_header *old_hdr; const struct mail_index_record *rec = NULL; enum mail_flags flags; - uint32_t uid, old_count; + uint32_t uid, cur_count; unsigned int i, j; ARRAY_TYPE(const_string) keywords = ARRAY_INIT; bool seen_flags = FALSE; @@ -252,8 +253,10 @@ } imapc_mailbox_init_delayed_trans(mbox); - old_count = mail_index_view_get_messages_count(mbox->delayed_sync_view); - while (lseq <= old_count) { + old_hdr = mail_index_get_header(mbox->sync_view); + + cur_count = mail_index_view_get_messages_count(mbox->delayed_sync_view); + while (lseq <= cur_count) { rec = mail_index_lookup(mbox->delayed_sync_view, lseq); if (rec->uid == uid || uid == 0) break; @@ -271,10 +274,17 @@ mail_index_expunge(mbox->delayed_sync_trans, lseq); lseq++; } - if (lseq > old_count) { - if (uid == 0 || lseq != old_count + 1) + if (lseq > cur_count) { + if (uid == 0 || lseq != cur_count + 1) return; - i_assert(lseq == old_count + 1); + if (uid < old_hdr->next_uid) { + imapc_mailbox_set_corrupted(mbox, + "Expunged message reappeared " + "(uid=%u < next_uid=%u)", + uid, old_hdr->next_uid); + return; + } + i_assert(lseq == cur_count + 1); mail_index_append(mbox->delayed_sync_trans, uid, &lseq); rec = NULL; } From dovecot at dovecot.org Sun Sep 4 12:38:34 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 12:38:34 +0300 Subject: dovecot-2.1: lib-index: Fixed reopening index file that was mark... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/33dc66d4286d changeset: 13384:33dc66d4286d user: Timo Sirainen date: Sun Sep 04 12:38:24 2011 +0300 description: lib-index: Fixed reopening index file that was marked as corrupted. diffstat: src/lib-index/mail-index.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 36 insertions(+), 5 deletions(-) diffs (65 lines): diff -r e404a1bef6bc -r 33dc66d4286d src/lib-index/mail-index.c --- a/src/lib-index/mail-index.c Sun Sep 04 12:37:51 2011 +0300 +++ b/src/lib-index/mail-index.c Sun Sep 04 12:38:24 2011 +0300 @@ -504,8 +504,33 @@ return -1; } - index->cache = created ? mail_cache_create(index) : - mail_cache_open_or_create(index); + if (index->cache == NULL) { + index->cache = created ? mail_cache_create(index) : + mail_cache_open_or_create(index); + } + return 1; +} + +static int +mail_index_open_opened(struct mail_index *index, + enum mail_index_open_flags flags) +{ + int ret; + + i_assert(index->map != NULL); + + if ((index->map->hdr.flags & MAIL_INDEX_HDR_FLAG_CORRUPTED) != 0) { + /* index was marked corrupted. we'll probably need to + recreate the files. */ + if (index->map != NULL) + mail_index_unmap(&index->map); + mail_index_close_file(index); + mail_transaction_log_close(index->log); + if ((ret = mail_index_open_files(index, flags)) <= 0) + return ret; + } + + index->open_count++; return 1; } @@ -514,9 +539,12 @@ int ret; if (index->open_count > 0) { - i_assert(index->map != NULL); - index->open_count++; - return 1; + if ((ret = mail_index_open_opened(index, flags)) <= 0) { + /* doesn't exist and create flag not used */ + index->open_count++; + mail_index_close(index); + } + return ret; } index->filepath = MAIL_INDEX_IS_IN_MEMORY(index) ? @@ -542,6 +570,9 @@ (flags & MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE) == 0) i_fatal("nfs flush requires mmap_disable=yes"); + /* NOTE: increase open_count only after mail_index_open_files(). + it's used elsewhere to check if we're doing an initial opening + of the index files */ if ((ret = mail_index_open_files(index, flags)) <= 0) { /* doesn't exist and create flag not used */ index->open_count++; From dovecot at dovecot.org Sun Sep 4 13:20:58 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 13:20:58 +0300 Subject: dovecot-2.1: imapc: Never use box->view for syncing related purp... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5dac75d12c59 changeset: 13385:5dac75d12c59 user: Timo Sirainen date: Sun Sep 04 13:20:27 2011 +0300 description: imapc: Never use box->view for syncing related purposes. The view isn't up to date when MAILBOX_SYNC_FLAG_NO_EXPUNGES is used to sync it. Instead always use a separate sync view. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diffs (54 lines): diff -r 33dc66d4286d -r 5dac75d12c59 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 12:38:24 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 13:20:27 2011 +0300 @@ -26,14 +26,21 @@ imapc_client_mailbox_disconnect(mbox->client_box); } +static struct mail_index_view * +imapc_mailbox_get_sync_view(struct imapc_mailbox *mbox) +{ + if (mbox->sync_view == NULL) + mbox->sync_view = mail_index_view_open(mbox->box.index); + return mbox->sync_view; +} + static void imapc_mailbox_init_delayed_trans(struct imapc_mailbox *mbox) { if (mbox->delayed_sync_trans != NULL) return; - mbox->sync_view = mail_index_view_open(mbox->box.index); mbox->delayed_sync_trans = - mail_index_transaction_begin(mbox->sync_view, + mail_index_transaction_begin(imapc_mailbox_get_sync_view(mbox), MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); mbox->delayed_sync_view = mail_index_transaction_open_updated_view(mbox->delayed_sync_trans); @@ -120,7 +127,7 @@ return; if (view == NULL) - view = mbox->box.view; + view = imapc_mailbox_get_sync_view(mbox); if (rcount == 0) { /* nothing in this mailbox */ @@ -356,7 +363,7 @@ str_to_uint32(reply->resp_text_value, &uid_validity) < 0) return; - hdr = mail_index_get_header(mbox->box.view); + hdr = mail_index_get_header(imapc_mailbox_get_sync_view(mbox)); if (hdr->uid_validity != uid_validity) { imapc_mailbox_init_delayed_trans(mbox); if (hdr->uid_validity != 0) { @@ -382,7 +389,7 @@ str_to_uint32(reply->resp_text_value, &uid_next) < 0) return; - hdr = mail_index_get_header(mbox->box.view); + hdr = mail_index_get_header(imapc_mailbox_get_sync_view(mbox)); if (hdr->next_uid != uid_next) { imapc_mailbox_init_delayed_trans(mbox); mail_index_update_header(mbox->delayed_sync_trans, From dovecot at dovecot.org Sun Sep 4 16:34:42 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 16:34:42 +0300 Subject: dovecot-2.1: imapc: Delay handling new messages and setting uidv... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1da4bc23d4dc changeset: 13386:1da4bc23d4dc user: Timo Sirainen date: Sun Sep 04 16:34:23 2011 +0300 description: imapc: Delay handling new messages and setting uidvalidity/uidnext until sync. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 94 +++------------------------- src/lib-storage/index/imapc/imapc-storage.c | 5 +- src/lib-storage/index/imapc/imapc-storage.h | 8 +- src/lib-storage/index/imapc/imapc-sync.c | 65 +++++++++++++++++++- 4 files changed, 83 insertions(+), 89 deletions(-) diffs (truncated from 367 to 300 lines): diff -r 5dac75d12c59 -r 1da4bc23d4dc src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 13:20:27 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 16:34:23 2011 +0300 @@ -44,6 +44,8 @@ MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); mbox->delayed_sync_view = mail_index_transaction_open_updated_view(mbox->delayed_sync_trans); + mbox->min_append_uid = + mail_index_get_header(mbox->delayed_sync_view)->next_uid; } int imapc_mailbox_commit_delayed_trans(struct imapc_mailbox *mbox, @@ -67,53 +69,6 @@ return ret; } -static void imapc_mailbox_open_finish(struct imapc_mailbox *mbox) -{ - const struct mail_index_record *rec; - struct imapc_seqmap *seqmap; - uint32_t lseq, rseq, cur_count; - - /* if we haven't seen FETCH reply for some messages at the end of - mailbox they've been externally expunged. */ - imapc_mailbox_init_delayed_trans(mbox); - seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); - - cur_count = mail_index_view_get_messages_count(mbox->delayed_sync_view); - for (lseq = cur_count; lseq > 0; lseq--) { - rec = mail_index_lookup(mbox->delayed_sync_view, lseq); - if (rec->uid <= mbox->highest_seen_uid) - break; - - rseq = imapc_seqmap_lseq_to_rseq(seqmap, lseq); - imapc_seqmap_expunge(seqmap, rseq); - mail_index_expunge(mbox->delayed_sync_trans, lseq); - } -} - -static void -imapc_newmsgs_callback(const struct imapc_command_reply *reply, - void *context) -{ - struct imapc_mailbox *mbox = context; - - if (reply->state == IMAPC_COMMAND_STATE_OK) - mbox->open_success = TRUE; - else if (reply->state == IMAPC_COMMAND_STATE_NO) { - imapc_copy_error_from_reply(mbox->storage, MAIL_ERROR_PARAMS, - reply); - } else if (mbox->opening || - reply->state != IMAPC_COMMAND_STATE_DISCONNECTED) { - mail_storage_set_critical(&mbox->storage->storage, - "imapc: Mailbox newmsgs fetch failed: %s", - reply->text_full); - } - if (mbox->opening) { - if (reply->state == IMAPC_COMMAND_STATE_OK) - imapc_mailbox_open_finish(mbox); - imapc_client_stop(mbox->storage->client); - } -} - static void imapc_untagged_exists(const struct imapc_untagged_reply *reply, struct imapc_mailbox *mbox) { @@ -121,7 +76,7 @@ uint32_t rcount = reply->num; const struct mail_index_header *hdr; struct imapc_seqmap *seqmap; - uint32_t first_uid, next_lseq, next_rseq; + uint32_t next_lseq, next_rseq; if (mbox == NULL) return; @@ -135,7 +90,7 @@ } if (mbox->opening) { /* We don't know the latest flags, refresh them. */ - first_uid = 1; + mbox->sync_fetch_first_uid = 1; } else { seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); next_lseq = mail_index_view_get_messages_count(view) + 1; @@ -150,12 +105,8 @@ return; } hdr = mail_index_get_header(view); - first_uid = hdr->next_uid; + mbox->sync_fetch_first_uid = hdr->next_uid; } - - mbox->new_msgs = TRUE; - imapc_client_mailbox_cmdf(mbox->client_box, imapc_newmsgs_callback, - mbox, "UID FETCH %u:* FLAGS", first_uid); } static void imapc_mailbox_idle_timeout(struct imapc_mailbox *mbox) @@ -205,7 +156,6 @@ struct imapc_mail *const *mailp; const struct imap_arg *list, *flags_list; const char *atom; - const struct mail_index_header *old_hdr; const struct mail_index_record *rec = NULL; enum mail_flags flags; uint32_t uid, cur_count; @@ -260,8 +210,6 @@ } imapc_mailbox_init_delayed_trans(mbox); - old_hdr = mail_index_get_header(mbox->sync_view); - cur_count = mail_index_view_get_messages_count(mbox->delayed_sync_view); while (lseq <= cur_count) { rec = mail_index_lookup(mbox->delayed_sync_view, lseq); @@ -282,17 +230,20 @@ lseq++; } if (lseq > cur_count) { + if (!mbox->syncing) + return; if (uid == 0 || lseq != cur_count + 1) return; - if (uid < old_hdr->next_uid) { + if (uid < mbox->min_append_uid) { imapc_mailbox_set_corrupted(mbox, "Expunged message reappeared " "(uid=%u < next_uid=%u)", - uid, old_hdr->next_uid); + uid, mbox->min_append_uid); return; } i_assert(lseq == cur_count + 1); mail_index_append(mbox->delayed_sync_trans, uid, &lseq); + mbox->min_append_uid = uid + 1; rec = NULL; } if (seen_flags && (rec == NULL || rec->flags != flags)) { @@ -355,47 +306,26 @@ imapc_resp_text_uidvalidity(const struct imapc_untagged_reply *reply, struct imapc_mailbox *mbox) { - const struct mail_index_header *hdr; uint32_t uid_validity; - bool changes; if (mbox == NULL || reply->resp_text_value == NULL || str_to_uint32(reply->resp_text_value, &uid_validity) < 0) return; - hdr = mail_index_get_header(imapc_mailbox_get_sync_view(mbox)); - if (hdr->uid_validity != uid_validity) { - imapc_mailbox_init_delayed_trans(mbox); - if (hdr->uid_validity != 0) { - /* uidvalidity changed, reset the entire mailbox */ - mail_index_reset(mbox->delayed_sync_trans); - (void)imapc_mailbox_commit_delayed_trans(mbox, &changes); - imapc_mailbox_init_delayed_trans(mbox); - } - mail_index_update_header(mbox->delayed_sync_trans, - offsetof(struct mail_index_header, uid_validity), - &uid_validity, sizeof(uid_validity), TRUE); - } + mbox->sync_uid_validity = uid_validity; } static void imapc_resp_text_uidnext(const struct imapc_untagged_reply *reply, struct imapc_mailbox *mbox) { - const struct mail_index_header *hdr; uint32_t uid_next; if (mbox == NULL || reply->resp_text_value == NULL || str_to_uint32(reply->resp_text_value, &uid_next) < 0) return; - hdr = mail_index_get_header(imapc_mailbox_get_sync_view(mbox)); - if (hdr->next_uid != uid_next) { - imapc_mailbox_init_delayed_trans(mbox); - mail_index_update_header(mbox->delayed_sync_trans, - offsetof(struct mail_index_header, next_uid), - &uid_next, sizeof(uid_next), FALSE); - } + mbox->sync_uid_next = uid_next; } void imapc_mailbox_register_untagged(struct imapc_mailbox *mbox, diff -r 5dac75d12c59 -r 1da4bc23d4dc src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 13:20:27 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 04 16:34:23 2011 +0300 @@ -326,8 +326,7 @@ ctx->mbox->box.name, reply->text_full); ctx->ret = -1; } - if (!ctx->mbox->new_msgs) - imapc_client_stop(ctx->mbox->storage->client); + imapc_client_stop(ctx->mbox->storage->client); } static int imapc_mailbox_open(struct mailbox *box) @@ -357,7 +356,7 @@ while (ctx.ret == -2) imapc_storage_run(mbox->storage); mbox->opening = FALSE; - if (!mbox->open_success) { + if (ctx.ret < 0) { mailbox_close(box); return -1; } diff -r 5dac75d12c59 -r 1da4bc23d4dc src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 13:20:27 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 04 16:34:23 2011 +0300 @@ -54,11 +54,15 @@ ARRAY_DEFINE(untagged_callbacks, struct imapc_mailbox_event_callback); ARRAY_DEFINE(resp_text_callbacks, struct imapc_mailbox_event_callback); + uint32_t min_append_uid; uint32_t highest_seen_uid; + uint32_t sync_uid_validity; + uint32_t sync_uid_next; + uint32_t sync_fetch_first_uid; + unsigned int opening:1; - unsigned int open_success:1; - unsigned int new_msgs:1; + unsigned int syncing:1; }; struct imapc_simple_context { diff -r 5dac75d12c59 -r 1da4bc23d4dc src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Sun Sep 04 13:20:27 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Sun Sep 04 16:34:23 2011 +0300 @@ -166,6 +166,49 @@ imapc_sync_cmd(ctx, str_c(str)); } +static void imapc_sync_expunge_eom(struct imapc_sync_context *ctx) +{ + const struct mail_index_record *rec; + uint32_t lseq, cur_count; + + /* if we haven't seen FETCH reply for some messages at the end of + mailbox they've been externally expunged. */ + cur_count = mail_index_view_get_messages_count(ctx->sync_view); + for (lseq = cur_count; lseq > 0; lseq--) { + rec = mail_index_lookup(ctx->sync_view, lseq); + if (rec->uid <= ctx->mbox->highest_seen_uid) + break; + + mail_index_expunge(ctx->trans, lseq); + } +} + +static void imapc_sync_index_header(struct imapc_sync_context *ctx) +{ + struct imapc_mailbox *mbox = ctx->mbox; + const struct mail_index_header *hdr; + + hdr = mail_index_get_header(ctx->sync_view); + if (hdr->uid_validity != mbox->sync_uid_validity && + mbox->sync_uid_validity != 0) { + if (hdr->uid_validity != 0) { + /* uidvalidity changed, reset the entire mailbox */ + mail_index_reset(ctx->trans); + mbox->sync_fetch_first_uid = 1; + } + mail_index_update_header(ctx->trans, + offsetof(struct mail_index_header, uid_validity), + &mbox->sync_uid_validity, + sizeof(mbox->sync_uid_validity), TRUE); + } + if (hdr->next_uid < mbox->sync_uid_next) { + mail_index_update_header(ctx->trans, + offsetof(struct mail_index_header, next_uid), + &mbox->sync_uid_next, sizeof(mbox->sync_uid_next), + FALSE); + } +} + static void imapc_sync_index(struct imapc_sync_context *ctx) { struct mailbox *box = &ctx->mbox->box; @@ -175,6 +218,7 @@ i_array_init(&ctx->expunged_uids, 64); ctx->keywords = mail_index_get_keywords(box->index); + imapc_sync_index_header(ctx); while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) T_BEGIN { if (!mail_index_lookup_seq_range(ctx->sync_view, sync_rec.uid1, sync_rec.uid2, @@ -202,11 +246,22 @@ } } T_END; + if (ctx->mbox->sync_fetch_first_uid != 0) { + /* we'll resync existing messages' flags and add new messages. + adding new messages requires sync locking to avoid + duplicates. */ From dovecot at dovecot.org Sun Sep 4 18:29:50 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 18:29:50 +0300 Subject: dovecot-2.1: imapc: Redesigned remote sequence <-> index file re... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/26c38da7b7fc changeset: 13387:26c38da7b7fc user: Timo Sirainen date: Sun Sep 04 17:59:58 2011 +0300 description: imapc: Redesigned remote sequence <-> index file record mapping is done. The previous code didn't work when multiple connections modified the same index files. diffstat: src/lib-storage/index/imapc/Makefile.am | 23 +-- src/lib-storage/index/imapc/imapc-client-private.h | 2 +- src/lib-storage/index/imapc/imapc-client.c | 12 +- src/lib-storage/index/imapc/imapc-client.h | 4 +- src/lib-storage/index/imapc/imapc-connection.c | 1 - src/lib-storage/index/imapc/imapc-mail.c | 10 +- src/lib-storage/index/imapc/imapc-mailbox.c | 162 +++++++++----------- src/lib-storage/index/imapc/imapc-msgmap.c | 85 +++++++++++ src/lib-storage/index/imapc/imapc-msgmap.h | 17 ++ src/lib-storage/index/imapc/imapc-seqmap.c | 124 ---------------- src/lib-storage/index/imapc/imapc-seqmap.h | 27 --- src/lib-storage/index/imapc/imapc-storage.h | 7 +- src/lib-storage/index/imapc/imapc-sync.c | 61 ++++--- src/lib-storage/index/imapc/test-imapc-seqmap.c | 111 -------------- 14 files changed, 232 insertions(+), 414 deletions(-) diffs (truncated from 968 to 300 lines): diff -r 1da4bc23d4dc -r 26c38da7b7fc src/lib-storage/index/imapc/Makefile.am --- a/src/lib-storage/index/imapc/Makefile.am Sun Sep 04 16:34:23 2011 +0300 +++ b/src/lib-storage/index/imapc/Makefile.am Sun Sep 04 17:59:58 2011 +0300 @@ -20,8 +20,8 @@ imapc-mail.c \ imapc-mail-fetch.c \ imapc-mailbox.c \ + imapc-msgmap.c \ imapc-save.c \ - imapc-seqmap.c \ imapc-settings.c \ imapc-sync.c \ imapc-storage.c @@ -32,29 +32,10 @@ imapc-connection.h \ imapc-list.h \ imapc-mail.h \ - imapc-seqmap.h \ + imapc-msgmap.h \ imapc-settings.h \ imapc-storage.h \ imapc-sync.h pkginc_libdir=$(pkgincludedir) pkginc_lib_HEADERS = $(headers) - -test_programs = \ - test-imapc-seqmap - -noinst_PROGRAMS = $(test_programs) - -test_libs = \ - ../../../lib-test/libtest.la \ - ../../../lib/liblib.la - -test_imapc_seqmap_SOURCES = test-imapc-seqmap.c -test_imapc_seqmap_LDADD = imapc-seqmap.lo $(test_libs) -test_imapc_seqmap_DEPENDENCIES = imapc-seqmap.lo $(test_libs) - -check: check-am check-test -check-test: all-am - for bin in $(test_programs); do \ - if ! $(RUN_TEST) ./$$bin; then exit 1; fi; \ - done diff -r 1da4bc23d4dc -r 26c38da7b7fc src/lib-storage/index/imapc/imapc-client-private.h --- a/src/lib-storage/index/imapc/imapc-client-private.h Sun Sep 04 16:34:23 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client-private.h Sun Sep 04 17:59:58 2011 +0300 @@ -26,7 +26,7 @@ struct imapc_client_mailbox { struct imapc_client *client; struct imapc_connection *conn; - struct imapc_seqmap *seqmap; + struct imapc_msgmap *msgmap; void *untagged_box_context; unsigned int pending_box_command_count; diff -r 1da4bc23d4dc -r 26c38da7b7fc src/lib-storage/index/imapc/imapc-client.c --- a/src/lib-storage/index/imapc/imapc-client.c Sun Sep 04 16:34:23 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.c Sun Sep 04 17:59:58 2011 +0300 @@ -6,7 +6,7 @@ #include "ioloop.h" #include "safe-mkstemp.h" #include "iostream-ssl.h" -#include "imapc-seqmap.h" +#include "imapc-msgmap.h" #include "imapc-connection.h" #include "imapc-client-private.h" @@ -219,7 +219,7 @@ conn = imapc_client_get_unboxed_connection(client); conn->box = box; box->conn = conn->conn; - box->seqmap = imapc_seqmap_init(); + box->msgmap = imapc_msgmap_init(); imapc_connection_select(box, name, examine, callback, context); return box; @@ -247,7 +247,7 @@ if (box->conn != NULL) imapc_connection_unselect(box); - imapc_seqmap_deinit(&box->seqmap); + imapc_msgmap_deinit(&box->msgmap); i_free(box); } @@ -340,10 +340,10 @@ va_end(args); } -struct imapc_seqmap * -imapc_client_mailbox_get_seqmap(struct imapc_client_mailbox *box) +struct imapc_msgmap * +imapc_client_mailbox_get_msgmap(struct imapc_client_mailbox *box) { - return box->seqmap; + return box->msgmap; } void imapc_client_mailbox_idle(struct imapc_client_mailbox *box) diff -r 1da4bc23d4dc -r 26c38da7b7fc src/lib-storage/index/imapc/imapc-client.h --- a/src/lib-storage/index/imapc/imapc-client.h Sun Sep 04 16:34:23 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.h Sun Sep 04 17:59:58 2011 +0300 @@ -135,8 +135,8 @@ imapc_command_callback_t *callback, void *context, const char *cmd_fmt, ...) ATTR_FORMAT(4, 5); -struct imapc_seqmap * -imapc_client_mailbox_get_seqmap(struct imapc_client_mailbox *box); +struct imapc_msgmap * +imapc_client_mailbox_get_msgmap(struct imapc_client_mailbox *box); void imapc_client_mailbox_idle(struct imapc_client_mailbox *box); bool imapc_client_mailbox_is_connected(struct imapc_client_mailbox *box); diff -r 1da4bc23d4dc -r 26c38da7b7fc src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Sun Sep 04 16:34:23 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Sun Sep 04 17:59:58 2011 +0300 @@ -14,7 +14,6 @@ #include "imap-util.h" #include "imap-parser.h" #include "imapc-client-private.h" -#include "imapc-seqmap.h" #include "imapc-connection.h" #include diff -r 1da4bc23d4dc -r 26c38da7b7fc src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Sun Sep 04 16:34:23 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Sun Sep 04 17:59:58 2011 +0300 @@ -4,7 +4,7 @@ #include "str.h" #include "istream.h" #include "imap-envelope.h" -#include "imapc-seqmap.h" +#include "imapc-msgmap.h" #include "imapc-mail.h" #include "imapc-client.h" #include "imapc-storage.h" @@ -101,8 +101,8 @@ static bool imapc_mail_is_expunged(struct mail *_mail) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; - struct imapc_seqmap *seqmap; - uint32_t lseq; + struct imapc_msgmap *msgmap; + uint32_t lseq, rseq; /* first we'll need to convert the mail's sequence to sync_view's sequence. if there's no sync_view, then no mails have been @@ -113,8 +113,8 @@ if (!mail_index_lookup_seq(mbox->sync_view, _mail->uid, &lseq)) return TRUE; - seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); - return imapc_seqmap_lseq_to_rseq(seqmap, lseq) == 0; + msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); + return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq); } static int diff -r 1da4bc23d4dc -r 26c38da7b7fc src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 16:34:23 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 17:59:58 2011 +0300 @@ -5,8 +5,8 @@ #include "imap-arg.h" #include "imap-util.h" #include "imapc-client.h" -#include "imapc-seqmap.h" #include "imapc-mail.h" +#include "imapc-msgmap.h" #include "imapc-sync.h" #include "imapc-storage.h" @@ -22,6 +22,8 @@ mbox->box.name, t_strdup_vprintf(reason, va)); va_end(va); + sleep(3600); + mail_index_mark_corrupted(mbox->box.index); imapc_client_mailbox_disconnect(mbox->client_box); } @@ -44,8 +46,6 @@ MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); mbox->delayed_sync_view = mail_index_transaction_open_updated_view(mbox->delayed_sync_trans); - mbox->min_append_uid = - mail_index_get_header(mbox->delayed_sync_view)->next_uid; } int imapc_mailbox_commit_delayed_trans(struct imapc_mailbox *mbox, @@ -73,10 +73,7 @@ struct imapc_mailbox *mbox) { struct mail_index_view *view = mbox->delayed_sync_view; - uint32_t rcount = reply->num; const struct mail_index_header *hdr; - struct imapc_seqmap *seqmap; - uint32_t next_lseq, next_rseq; if (mbox == NULL) return; @@ -84,26 +81,10 @@ if (view == NULL) view = imapc_mailbox_get_sync_view(mbox); - if (rcount == 0) { - /* nothing in this mailbox */ - return; - } if (mbox->opening) { /* We don't know the latest flags, refresh them. */ mbox->sync_fetch_first_uid = 1; - } else { - seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); - next_lseq = mail_index_view_get_messages_count(view) + 1; - next_rseq = imapc_seqmap_lseq_to_rseq(seqmap, next_lseq); - if (rcount < next_rseq) { - if (rcount == next_rseq-1) { - /* duplicate EXISTS - ignore */ - return; - } - imapc_mailbox_set_corrupted(mbox, - "EXISTS reply shrank mailbox size"); - return; - } + } else if (mbox->sync_fetch_first_uid != 1) { hdr = mail_index_get_header(view); mbox->sync_fetch_first_uid = hdr->next_uid; } @@ -152,13 +133,13 @@ struct imapc_mailbox *mbox) { uint32_t lseq, rseq = reply->num; - struct imapc_seqmap *seqmap; struct imapc_mail *const *mailp; const struct imap_arg *list, *flags_list; const char *atom; const struct mail_index_record *rec = NULL; + struct imapc_msgmap *msgmap; enum mail_flags flags; - uint32_t uid, cur_count; + uint32_t fetch_uid, uid, msg_count; unsigned int i, j; ARRAY_TYPE(const_string) keywords = ARRAY_INIT; bool seen_flags = FALSE; @@ -166,14 +147,14 @@ if (mbox == NULL || rseq == 0 || !imap_arg_get_list(reply->args, &list)) return; - uid = 0; flags = 0; + fetch_uid = 0; flags = 0; for (i = 0; list[i].type != IMAP_ARG_EOL; i += 2) { if (!imap_arg_get_atom(&list[i], &atom)) return; if (strcasecmp(atom, "UID") == 0) { if (!imap_arg_get_atom(&list[i+1], &atom) || - str_to_uint32(atom, &uid) < 0) + str_to_uint32(atom, &fetch_uid) < 0) return; } else if (strcasecmp(atom, "FLAGS") == 0) { if (!imap_arg_get_list(&list[i+1], &flags_list)) @@ -196,12 +177,52 @@ /* FIXME: need to do something about recent flags */ flags &= ~MAIL_RECENT; - seqmap = imapc_client_mailbox_get_seqmap(mbox->client_box); - lseq = imapc_seqmap_rseq_to_lseq(seqmap, rseq); + imapc_mailbox_init_delayed_trans(mbox); - /* fetch_mails' view is different from sync_view, so we can't compare - their sequences directly. that is why this code supports only - UID FETCH commands which are guaranteed to have UID in the reply. */ + msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); + msg_count = imapc_msgmap_count(msgmap); + if (rseq > msg_count) { + /* newly seen message */ + if (!mbox->syncing || fetch_uid == 0 || rseq != msg_count+1) + return; + uid = fetch_uid; + + if (uid < imapc_msgmap_uidnext(msgmap)) { + imapc_mailbox_set_corrupted(mbox, + "Expunged message reappeared " + "(uid=%u < next_uid=%u)", + uid, imapc_msgmap_uidnext(msgmap)); + return; + } + + imapc_msgmap_append(msgmap, rseq, uid); + if (uid < mbox->min_append_uid) { + /* message is already added to index */ + lseq = 0; + } else { + mail_index_append(mbox->delayed_sync_trans, uid, &lseq); + mbox->min_append_uid = uid + 1; + } + } else { + uid = imapc_msgmap_rseq_to_uid(msgmap, rseq); + if (uid != fetch_uid && fetch_uid != 0) { From dovecot at dovecot.org Sun Sep 4 18:29:50 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 18:29:50 +0300 Subject: dovecot-2.1: imapc: Syncing fixes Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/581597411f6b changeset: 13388:581597411f6b user: Timo Sirainen date: Sun Sep 04 18:29:21 2011 +0300 description: imapc: Syncing fixes diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 25 +++++++++++++++---------- 1 files changed, 15 insertions(+), 10 deletions(-) diffs (71 lines): diff -r 26c38da7b7fc -r 581597411f6b src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 17:59:58 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 18:29:21 2011 +0300 @@ -73,6 +73,7 @@ struct imapc_mailbox *mbox) { struct mail_index_view *view = mbox->delayed_sync_view; + uint32_t rcount = reply->num; const struct mail_index_header *hdr; if (mbox == NULL) @@ -183,8 +184,11 @@ msg_count = imapc_msgmap_count(msgmap); if (rseq > msg_count) { /* newly seen message */ - if (!mbox->syncing || fetch_uid == 0 || rseq != msg_count+1) + if (fetch_uid == 0 || rseq != msg_count+1) { + /* can't handle this one now. we should get another + FETCH reply for it. */ return; + } uid = fetch_uid; if (uid < imapc_msgmap_uidnext(msgmap)) { @@ -199,7 +203,7 @@ if (uid < mbox->min_append_uid) { /* message is already added to index */ lseq = 0; - } else { + } else if (mbox->syncing) { mail_index_append(mbox->delayed_sync_trans, uid, &lseq); mbox->min_append_uid = uid + 1; } @@ -213,6 +217,14 @@ } lseq = 0; } + /* if this is a reply to some FETCH request, update the mail's fields */ + array_foreach(&mbox->fetch_mails, mailp) { + struct imapc_mail *mail = *mailp; + + if (mail->imail.mail.mail.uid == uid) + imapc_mail_fetch_update(mail, reply, list); + } + if (lseq == 0) { if (!mail_index_lookup_seq(mbox->delayed_sync_view, uid, &lseq)) { @@ -222,14 +234,6 @@ rec = mail_index_lookup(mbox->delayed_sync_view, lseq); } - /* if this is a reply to some FETCH request, update the mail's fields */ - array_foreach(&mbox->fetch_mails, mailp) { - struct imapc_mail *mail = *mailp; - - if (mail->imail.mail.mail.uid == uid) - imapc_mail_fetch_update(mail, reply, list); - } - if (rseq == mbox->sync_next_rseq) { /* we're doing the initial full sync of mails. expunge any mails that no longer exist. */ @@ -244,6 +248,7 @@ mbox->sync_next_rseq++; mbox->sync_next_lseq++; } + if (seen_flags && (rec == NULL || rec->flags != flags)) { mail_index_update_flags(mbox->delayed_sync_trans, lseq, MODIFY_REPLACE, flags); From dovecot at dovecot.org Sun Sep 4 18:29:50 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 18:29:50 +0300 Subject: dovecot-2.1: imapc: Fixed checking if mail is expunged. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5e3d217ceedf changeset: 13389:5e3d217ceedf user: Timo Sirainen date: Sun Sep 04 18:29:38 2011 +0300 description: imapc: Fixed checking if mail is expunged. diffstat: src/lib-storage/index/imapc/imapc-mail.c | 50 +++++++++++++++++-------------- 1 files changed, 28 insertions(+), 22 deletions(-) diffs (81 lines): diff -r 581597411f6b -r 5e3d217ceedf src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Sun Sep 04 18:29:21 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Sun Sep 04 18:29:38 2011 +0300 @@ -34,6 +34,23 @@ index_mail_free(_mail); } +static bool imapc_mail_is_expunged(struct mail *_mail) +{ + struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; + struct imapc_msgmap *msgmap; + uint32_t lseq, rseq; + + if (mbox->sync_view != NULL) { + /* check if another session has already expunged it */ + if (!mail_index_lookup_seq(mbox->sync_view, _mail->uid, &lseq)) + return TRUE; + } + + /* check if we've received EXPUNGE for it */ + msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); + return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq); +} + static int imapc_mail_get_received_date(struct mail *_mail, time_t *date_r) { struct index_mail *mail = (struct index_mail *)_mail; @@ -46,8 +63,14 @@ if (imapc_mail_fetch(_mail, MAIL_FETCH_RECEIVED_DATE) < 0) return -1; if (data->received_date == (time_t)-1) { - mail_storage_set_critical(_mail->box->storage, - "imapc: Remote server didn't send INTERNALDATE"); + if (_mail->expunged || imapc_mail_is_expunged(_mail)) + mail_set_expunged(_mail); + else { + mail_storage_set_critical(_mail->box->storage, + "imapc: Remote server didn't send " + "INTERNALDATE for UID %u", _mail->uid); + sleep(3600); + } return -1; } } @@ -98,25 +121,6 @@ return 0; } -static bool imapc_mail_is_expunged(struct mail *_mail) -{ - struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; - struct imapc_msgmap *msgmap; - uint32_t lseq, rseq; - - /* first we'll need to convert the mail's sequence to sync_view's - sequence. if there's no sync_view, then no mails have been - expunged. */ - if (mbox->sync_view == NULL) - return FALSE; - - if (!mail_index_lookup_seq(mbox->sync_view, _mail->uid, &lseq)) - return TRUE; - - msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); - return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq); -} - static int imapc_mail_get_stream(struct mail *_mail, struct message_size *hdr_size, struct message_size *body_size, struct istream **stream_r) @@ -141,7 +145,9 @@ mail_set_expunged(_mail); else { mail_storage_set_critical(_mail->box->storage, - "imapc: Remote server didn't send BODY[]"); + "imapc: Remote server didn't send " + "BODY[] for UID %u", _mail->uid); + sleep(3600); } return -1; } From dovecot at dovecot.org Sun Sep 4 18:46:41 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 18:46:41 +0300 Subject: dovecot-2.1: imapc: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d504c507ba2f changeset: 13390:d504c507ba2f user: Timo Sirainen date: Sun Sep 04 18:46:20 2011 +0300 description: imapc: Compiler warning fix. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 5e3d217ceedf -r d504c507ba2f src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 18:29:38 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 18:46:20 2011 +0300 @@ -73,7 +73,6 @@ struct imapc_mailbox *mbox) { struct mail_index_view *view = mbox->delayed_sync_view; - uint32_t rcount = reply->num; const struct mail_index_header *hdr; if (mbox == NULL) From dovecot at dovecot.org Sun Sep 4 18:47:39 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 18:47:39 +0300 Subject: dovecot-2.1: imapc: Another compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7d1260ab78ac changeset: 13391:7d1260ab78ac user: Timo Sirainen date: Sun Sep 04 18:47:30 2011 +0300 description: imapc: Another compiler warning fix. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (15 lines): diff -r d504c507ba2f -r 7d1260ab78ac src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 18:46:20 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Sep 04 18:47:30 2011 +0300 @@ -69,8 +69,9 @@ return ret; } -static void imapc_untagged_exists(const struct imapc_untagged_reply *reply, - struct imapc_mailbox *mbox) +static void +imapc_untagged_exists(const struct imapc_untagged_reply *reply ATTR_UNUSED, + struct imapc_mailbox *mbox) { struct mail_index_view *view = mbox->delayed_sync_view; const struct mail_index_header *hdr; From dovecot at dovecot.org Sun Sep 4 19:01:28 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 19:01:28 +0300 Subject: dovecot-2.1: master: fifos weren't created with correct user/group. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/667b3e80acf5 changeset: 13392:667b3e80acf5 user: Timo Sirainen date: Sun Sep 04 19:00:47 2011 +0300 description: master: fifos weren't created with correct user/group. diffstat: src/master/service-listen.c | 48 ++++++++++++++++++++++---------------------- 1 files changed, 24 insertions(+), 24 deletions(-) diffs (80 lines): diff -r 7d1260ab78ac -r 667b3e80acf5 src/master/service-listen.c --- a/src/master/service-listen.c Sun Sep 04 18:47:30 2011 +0300 +++ b/src/master/service-listen.c Sun Sep 04 19:00:47 2011 +0300 @@ -37,6 +37,25 @@ return I_MAX(backlog, MIN_BACKLOG); } +static int +service_file_chown(const struct service_listener *l) +{ + uid_t uid = l->set.fileset.uid; + uid_t gid = l->set.fileset.gid; + + if ((uid == (uid_t)-1 || uid == master_uid) && + (gid == (gid_t)-1 || gid == master_gid)) + return 0; + + if (chown(l->set.fileset.set->path, uid, gid) < 0) { + service_error(l->service, "chown(%s, %lld, %lld) failed: %m", + l->set.fileset.set->path, + (long long)uid, (long long)gid); + return -1; + } + return 0; +} + static int service_unix_listener_listen(struct service_listener *l) { struct service *service = l->service; @@ -83,20 +102,10 @@ i_assert(fd != -1); - /* see if we need to change its owner/group */ - if ((l->set.fileset.uid != (uid_t)-1 && - l->set.fileset.uid != master_uid) || - (l->set.fileset.gid != (gid_t)-1 && - l->set.fileset.gid != master_gid)) { - if (chown(set->path, l->set.fileset.uid, l->set.fileset.gid) < 0) { - i_error("chown(%s, %lld, %lld) failed: %m", set->path, - (long long)l->set.fileset.uid, - (long long)l->set.fileset.gid); - (void)close(fd); - return -1; - } + if (service_file_chown(l) < 0) { + (void)close(fd); + return -1; } - net_set_nonblock(fd, TRUE); fd_close_on_exec(fd, TRUE); @@ -130,6 +139,8 @@ return -1; } } + if (service_file_chown(l) < 0) + return -1; /* open as RDWR, so that even if the last writer closes, we won't get EOF errors */ @@ -139,17 +150,6 @@ return -1; } - /* see if we need to change its owner/group */ - if ((service->uid != (uid_t)-1 && service->uid != master_uid) || - (service->gid != (gid_t)-1 && service->gid != master_gid)) { - if (chown(set->path, service->uid, service->gid) < 0) { - i_error("chown(%s, %lld, %lld) failed: %m", set->path, - (long long)service->uid, - (long long)service->gid); - (void)close(fd); - return -1; - } - } fd_close_on_exec(fd, TRUE); l->fd = fd; From dovecot at dovecot.org Sun Sep 4 20:11:52 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Sep 2011 20:11:52 +0300 Subject: dovecot-2.1: stats: Add stats_ prefix to all settings. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c979efcc13cf changeset: 13393:c979efcc13cf user: Timo Sirainen date: Sun Sep 04 20:11:33 2011 +0300 description: stats: Add stats_ prefix to all settings. diffstat: src/stats/stats-settings.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 667b3e80acf5 -r c979efcc13cf src/stats/stats-settings.c --- a/src/stats/stats-settings.c Sun Sep 04 19:00:47 2011 +0300 +++ b/src/stats/stats-settings.c Sun Sep 04 20:11:33 2011 +0300 @@ -55,9 +55,10 @@ .inet_listeners = ARRAY_INIT }; +/* we're kind of kludging here to avoid "stats_" prefix in the struct fields */ #undef DEF #define DEF(type, name) \ - { type, #name, offsetof(struct stats_settings, name), NULL } + { type, "stats_"#name, offsetof(struct stats_settings, name), NULL } static const struct setting_define stats_setting_defines[] = { DEF(SET_SIZE, memory_limit), From dovecot at dovecot.org Mon Sep 5 10:33:36 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 10:33:36 +0300 Subject: dovecot-2.1: lib-storage: mailbox_keyword_is_valid() returns now... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a5e47ce5a5a0 changeset: 13395:a5e47ce5a5a0 user: Timo Sirainen date: Mon Sep 05 10:30:15 2011 +0300 description: lib-storage: mailbox_keyword_is_valid() returns now FALSE if keyword can't be created. diffstat: src/lib-storage/mailbox-keywords.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r d15b173688f9 -r a5e47ce5a5a0 src/lib-storage/mailbox-keywords.c --- a/src/lib-storage/mailbox-keywords.c Mon Sep 05 10:28:49 2011 +0300 +++ b/src/lib-storage/mailbox-keywords.c Mon Sep 05 10:30:15 2011 +0300 @@ -109,6 +109,10 @@ *error_r = "Empty keywords not allowed"; return FALSE; } + if (box->disallow_new_keywords) { + *error_r = "Can't create new keywords"; + return FALSE; + } /* these are IMAP-specific restrictions, but for now IMAP is all we care about */ From dovecot at dovecot.org Mon Sep 5 10:33:36 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 10:33:36 +0300 Subject: dovecot-2.1: lib-storage: Added mailbox.disallow_new_keywords an... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d15b173688f9 changeset: 13394:d15b173688f9 user: Timo Sirainen date: Mon Sep 05 10:28:49 2011 +0300 description: lib-storage: Added mailbox.disallow_new_keywords and use it for mailbox_status. diffstat: src/lib-storage/index/index-status.c | 4 ++-- src/lib-storage/mail-storage-private.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diffs (26 lines): diff -r c979efcc13cf -r d15b173688f9 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Sun Sep 04 20:11:33 2011 +0300 +++ b/src/lib-storage/index/index-status.c Mon Sep 05 10:28:49 2011 +0300 @@ -81,8 +81,8 @@ if (!mailbox_is_readonly(box)) { status_r->permanent_flags = MAIL_FLAGS_NONRECENT; status_r->permanent_keywords = TRUE; - /* FIXME: set to FALSE if we're full */ - status_r->allow_new_keywords = TRUE; + status_r->allow_new_keywords = + !box->disallow_new_keywords; } } return 0; diff -r c979efcc13cf -r d15b173688f9 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Sun Sep 04 20:11:33 2011 +0300 +++ b/src/lib-storage/mail-storage-private.h Mon Sep 05 10:28:49 2011 +0300 @@ -267,6 +267,8 @@ mailbox_save_*() to actually save a new physical copy rather than simply incrementing a reference count (e.g. via hard link) */ unsigned int disable_reflink_copy_to:1; + /* Don't allow creating any new keywords */ + unsigned int disallow_new_keywords:1; }; struct mail_vfuncs { From dovecot at dovecot.org Mon Sep 5 10:33:36 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 10:33:36 +0300 Subject: dovecot-2.1: imapc: mailbox_status now returns permanent flags/k... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4ddbbfa1c515 changeset: 13396:4ddbbfa1c515 user: Timo Sirainen date: Mon Sep 05 10:32:47 2011 +0300 description: imapc: mailbox_status now returns permanent flags/keywords as they are on remote server. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 39 +++++++++++++++++++++++++++++ src/lib-storage/index/imapc/imapc-storage.c | 8 +++++- src/lib-storage/index/imapc/imapc-storage.h | 3 ++ 3 files changed, 49 insertions(+), 1 deletions(-) diffs (99 lines): diff -r a5e47ce5a5a0 -r 4ddbbfa1c515 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Mon Sep 05 10:30:15 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Mon Sep 05 10:32:47 2011 +0300 @@ -325,6 +325,43 @@ mbox->sync_uid_next = uid_next; } +static void +imapc_resp_text_permanentflags(const struct imapc_untagged_reply *reply, + struct imapc_mailbox *mbox) +{ + const struct imap_arg *flags_args, *arg; + const char *flag; + + i_assert(reply->args[0].type == IMAP_ARG_ATOM); + + if (mbox == NULL || !imap_arg_get_list(&reply->args[1], &flags_args)) + return; + + mbox->permanent_flags = 0; + array_clear(&mbox->permanent_keywords); + mbox->box.disallow_new_keywords = TRUE; + + for (arg = flags_args; arg->type != IMAP_ARG_EOL; arg++) { + if (!imap_arg_get_atom(arg, &flag)) + continue; + + if (strcmp(flag, "\\*") == 0) + mbox->box.disallow_new_keywords = FALSE; + else if (*flag == '\\') + mbox->permanent_flags |= imap_parse_system_flag(flag); + else { + /* this wastes some memory when called multiple times, + but that should happen quite rarely */ + flag = p_strdup(mbox->box.pool, flag); + array_append(&mbox->permanent_keywords, &flag, 1); + } + } + /* NULL-terminate it */ + (void)array_append_space(&mbox->permanent_keywords); + array_delete(&mbox->permanent_keywords, + array_count(&mbox->permanent_keywords)-1, 1); +} + void imapc_mailbox_register_untagged(struct imapc_mailbox *mbox, const char *key, imapc_mailbox_callback_t *callback) @@ -359,4 +396,6 @@ imapc_resp_text_uidvalidity); imapc_mailbox_register_resp_text(mbox, "UIDNEXT", imapc_resp_text_uidnext); + imapc_mailbox_register_resp_text(mbox, "PERMANENTFLAGS", + imapc_resp_text_permanentflags); } diff -r a5e47ce5a5a0 -r 4ddbbfa1c515 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 05 10:30:15 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 05 10:32:47 2011 +0300 @@ -304,6 +304,7 @@ p_array_init(&mbox->untagged_callbacks, pool, 16); p_array_init(&mbox->resp_text_callbacks, pool, 16); p_array_init(&mbox->fetch_mails, pool, 16); + p_array_init(&mbox->permanent_keywords, pool, 32); imapc_mailbox_register_callbacks(mbox); return &mbox->box; } @@ -456,6 +457,10 @@ struct mailbox_status *status_r) { index_storage_get_status(&mbox->box, items, status_r); + if ((items & STATUS_KEYWORDS) != 0) + status_r->keywords = &mbox->permanent_keywords; + if ((items & STATUS_PERMANENT_FLAGS) != 0) + status_r->permanent_flags = mbox->permanent_flags; } static int imapc_mailbox_get_status(struct mailbox *box, @@ -474,7 +479,8 @@ } /* mailbox isn't opened yet */ - if ((items & (STATUS_FIRST_UNSEEN_SEQ | STATUS_KEYWORDS)) != 0) { + if ((items & (STATUS_FIRST_UNSEEN_SEQ | STATUS_KEYWORDS | + STATUS_PERMANENT_FLAGS)) != 0) { /* getting these requires opening the mailbox */ if (mailbox_open(box) < 0) return -1; diff -r a5e47ce5a5a0 -r 4ddbbfa1c515 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Mon Sep 05 10:30:15 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Mon Sep 05 10:32:47 2011 +0300 @@ -54,6 +54,9 @@ ARRAY_DEFINE(untagged_callbacks, struct imapc_mailbox_event_callback); ARRAY_DEFINE(resp_text_callbacks, struct imapc_mailbox_event_callback); + enum mail_flags permanent_flags; + ARRAY_TYPE(keywords) permanent_keywords; + uint32_t sync_uid_validity; uint32_t sync_uid_next; uint32_t sync_fetch_first_uid; From dovecot at dovecot.org Mon Sep 5 11:13:21 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 11:13:21 +0300 Subject: dovecot-2.1: stats: If forcibly disconnecting a session, show th... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7669b0fbada5 changeset: 13397:7669b0fbada5 user: Timo Sirainen date: Mon Sep 05 11:13:12 2011 +0300 description: stats: If forcibly disconnecting a session, show the session's username also. diffstat: src/stats/mail-session.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (15 lines): diff -r 4ddbbfa1c515 -r 7669b0fbada5 src/stats/mail-session.c --- a/src/stats/mail-session.c Mon Sep 05 10:32:47 2011 +0300 +++ b/src/stats/mail-session.c Mon Sep 05 11:13:12 2011 +0300 @@ -37,8 +37,9 @@ static void mail_session_idle_timeout(struct mail_session *session) { - i_warning("Session %s appears to have crashed, disconnecting it", - guid_128_to_string(session->guid)); + i_warning("Session %s (user %s) appears to have crashed, " + "disconnecting it", + guid_128_to_string(session->guid), session->user->name); mail_session_disconnect(session); } From dovecot at dovecot.org Mon Sep 5 11:34:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 11:34:55 +0300 Subject: dovecot-2.1: stats: Don't crash at deinit if there are still con... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/361aafbd448c changeset: 13398:361aafbd448c user: Timo Sirainen date: Mon Sep 05 11:34:43 2011 +0300 description: stats: Don't crash at deinit if there are still connected sessions. diffstat: src/stats/mail-session.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diffs (17 lines): diff -r 7669b0fbada5 -r 361aafbd448c src/stats/mail-session.c --- a/src/stats/mail-session.c Mon Sep 05 11:13:12 2011 +0300 +++ b/src/stats/mail-session.c Mon Sep 05 11:34:43 2011 +0300 @@ -247,7 +247,12 @@ void mail_sessions_deinit(void) { - while (mail_sessions_head != NULL) + while (mail_sessions_head != NULL) { + struct mail_session *session = mail_sessions_head; + + if (!session->disconnected) + mail_session_unref(&session); mail_session_free(mail_sessions_head); + } hash_table_destroy(&mail_sessions_hash); } From dovecot at dovecot.org Mon Sep 5 11:45:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 11:45:55 +0300 Subject: dovecot-2.1: maildir: Drop internal new-flag from mails that hav... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ed8ed96cc828 changeset: 13399:ed8ed96cc828 user: Timo Sirainen date: Mon Sep 05 11:45:45 2011 +0300 description: maildir: Drop internal new-flag from mails that have been moved from new/ to cur/. This avoids unnecessary cur/ directory scans. diffstat: src/lib-storage/index/maildir/maildir-uidlist.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (14 lines): diff -r 361aafbd448c -r ed8ed96cc828 src/lib-storage/index/maildir/maildir-uidlist.c --- a/src/lib-storage/index/maildir/maildir-uidlist.c Mon Sep 05 11:34:43 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Mon Sep 05 11:45:45 2011 +0300 @@ -1688,7 +1688,9 @@ } } - rec->flags = (rec->flags | flags) & ~MAILDIR_UIDLIST_REC_FLAG_NONSYNCED; + rec->flags = (rec->flags | flags) & + ~(MAILDIR_UIDLIST_REC_FLAG_NONSYNCED | + MAILDIR_UIDLIST_REC_FLAG_NEW_DIR); rec->filename = p_strdup(uidlist->record_pool, filename); hash_table_insert(uidlist->files, rec->filename, rec); From dovecot at dovecot.org Mon Sep 5 11:48:20 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 11:48:20 +0300 Subject: dovecot-2.1: maildir: When logging "scanning took n secs" warnin... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ae7a7282af83 changeset: 13400:ae7a7282af83 user: Timo Sirainen date: Mon Sep 05 11:48:11 2011 +0300 description: maildir: When logging "scanning took n secs" warning, log also why scan was done. This could help debugging why cur/ directory is sometimes scanned with maildir_very_dirty_syncs=yes (if the previous commit didn't fully solve it). diffstat: src/lib-storage/index/maildir/maildir-sync.c | 74 ++++++++++++++++++++------- 1 files changed, 54 insertions(+), 20 deletions(-) diffs (193 lines): diff -r ed8ed96cc828 -r ae7a7282af83 src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Mon Sep 05 11:45:45 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Sep 05 11:48:11 2011 +0300 @@ -206,6 +206,17 @@ #define DUPE_LINKS_DELETE_SECS 30 +enum maildir_scan_why { + WHY_FORCED = 0x01, + WHY_FIRSTSYNC = 0x02, + WHY_NEWCHANGED = 0x04, + WHY_CURCHANGED = 0x08, + WHY_DROPRECENT = 0x10, + WHY_FINDRECENT = 0x20, + WHY_DELAYEDNEW = 0x40, + WHY_DELAYEDCUR = 0x80 +}; + struct maildir_sync_context { struct maildir_mailbox *mbox; const char *new_dir, *cur_dir; @@ -355,7 +366,8 @@ } static int -maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final) +maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final, + enum maildir_scan_why why) { struct mail_storage *storage = &ctx->mbox->storage->storage; const char *path; @@ -531,8 +543,8 @@ time_diff = time(NULL) - start_time; if (time_diff >= MAILDIR_SYNC_TIME_WARN_SECS) { i_warning("Maildir: Scanning %s took %u seconds " - "(%u readdir()s, %u rename()s to cur/)", - path, time_diff, readdir_count, move_count); + "(%u readdir()s, %u rename()s to cur/, why=0x%x)", + path, time_diff, readdir_count, move_count, why); } return ret < 0 ? -1 : @@ -566,7 +578,8 @@ static int maildir_sync_quick_check(struct maildir_mailbox *mbox, bool undirty, const char *new_dir, const char *cur_dir, - bool *new_changed_r, bool *cur_changed_r) + bool *new_changed_r, bool *cur_changed_r, + enum maildir_scan_why *why_r) { #define DIR_DELAYED_REFRESH(hdr, name) \ ((hdr)->name ## _check_time <= \ @@ -586,6 +599,7 @@ maildir_sync_get_header(mbox); if (mbox->maildir_hdr.new_mtime == 0) { /* first sync */ + *why_r |= WHY_FIRSTSYNC; *new_changed_r = *cur_changed_r = TRUE; return 0; } @@ -602,11 +616,15 @@ return -1; refreshed = TRUE; - if (DIR_DELAYED_REFRESH(hdr, new)) + if (DIR_DELAYED_REFRESH(hdr, new)) { + *why_r |= WHY_DELAYEDNEW; *new_changed_r = TRUE; + } if (DIR_DELAYED_REFRESH(hdr, cur) && - !mbox->storage->set->maildir_very_dirty_syncs) + !mbox->storage->set->maildir_very_dirty_syncs) { + *why_r |= WHY_DELAYEDCUR; *cur_changed_r = TRUE; + } if (*new_changed_r && *cur_changed_r) return 0; } @@ -623,10 +641,16 @@ } for (;;) { - if (check_new) + if (check_new) { *new_changed_r = DIR_MTIME_CHANGED(new_st, hdr, new); - if (check_cur) + if (*new_changed_r) + *why_r |= WHY_NEWCHANGED; + } + if (check_cur) { *cur_changed_r = DIR_MTIME_CHANGED(cur_st, hdr, cur); + if (*cur_changed_r) + *why_r |= WHY_CURCHANGED; + } if ((!*new_changed_r && !*cur_changed_r) || refreshed) break; @@ -679,27 +703,32 @@ } static int maildir_sync_get_changes(struct maildir_sync_context *ctx, - bool *new_changed_r, bool *cur_changed_r) + bool *new_changed_r, bool *cur_changed_r, + enum maildir_scan_why *why_r) { struct maildir_mailbox *mbox = ctx->mbox; enum mail_index_sync_flags flags = 0; bool undirty = (ctx->flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0; if (maildir_sync_quick_check(mbox, undirty, ctx->new_dir, ctx->cur_dir, - new_changed_r, cur_changed_r) < 0) + new_changed_r, cur_changed_r, why_r) < 0) return -1; /* if there are files in new/, we'll need to move them. we'll check this by seeing if we have any recent messages */ if ((mbox->box.flags & MAILBOX_FLAG_DROP_RECENT) != 0) { - if (!*new_changed_r) - *new_changed_r = have_recent_messages(ctx, FALSE); + if (!*new_changed_r && have_recent_messages(ctx, FALSE)) { + *new_changed_r = TRUE; + *why_r |= WHY_DROPRECENT; + } } else if (*new_changed_r) { /* if recent messages have been externally deleted from new/, we need to get them out of index. this requires that we make sure they weren't just moved to cur/. */ - if (!*cur_changed_r) - *cur_changed_r = have_recent_messages(ctx, TRUE); + if (!*cur_changed_r && have_recent_messages(ctx, TRUE)) { + *cur_changed_r = TRUE; + *why_r |= WHY_FINDRECENT; + } } if (*new_changed_r || *cur_changed_r) @@ -723,14 +752,17 @@ enum maildir_uidlist_rec_flag flags; bool new_changed, cur_changed, lock_failure; const char *fname; + enum maildir_scan_why why = 0; int ret; *lost_files_r = FALSE; - if (forced) + if (forced) { new_changed = cur_changed = TRUE; - else { - ret = maildir_sync_get_changes(ctx, &new_changed, &cur_changed); + why = WHY_FORCED; + } else { + ret = maildir_sync_get_changes(ctx, &new_changed, &cur_changed, + &why); if (ret <= 0) return ret; } @@ -840,7 +872,7 @@ unsigned int count = 0; bool final = FALSE; - while ((ret = maildir_scan_dir(ctx, TRUE, final)) > 0) { + while ((ret = maildir_scan_dir(ctx, TRUE, final, why)) > 0) { /* rename()d at least some files, which might have caused some other files to be missed. check again (see MAILDIR_RENAME_RESCAN_COUNT). */ @@ -851,7 +883,7 @@ return -1; if (cur_changed) { - if (maildir_scan_dir(ctx, FALSE, TRUE) < 0) + if (maildir_scan_dir(ctx, FALSE, TRUE, why) < 0) return -1; } @@ -1020,6 +1052,7 @@ int maildir_sync_is_synced(struct maildir_mailbox *mbox) { bool new_changed, cur_changed; + enum maildir_scan_why why; int ret; T_BEGIN { @@ -1030,7 +1063,8 @@ cur_dir = t_strconcat(box_path, "/cur", NULL); ret = maildir_sync_quick_check(mbox, FALSE, new_dir, cur_dir, - &new_changed, &cur_changed); + &new_changed, &cur_changed, + &why); } T_END; return ret < 0 ? -1 : (!new_changed && !cur_changed); } From dovecot at dovecot.org Mon Sep 5 12:47:10 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 12:47:10 +0300 Subject: dovecot-2.1: maildir: Avoid refreshing uidlist unnecessarily. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4124c28db2a4 changeset: 13401:4124c28db2a4 user: Timo Sirainen date: Mon Sep 05 12:46:49 2011 +0300 description: maildir: Avoid refreshing uidlist unnecessarily. Even if the uidlist itself wasn't read, it was still stat()ed. diffstat: src/lib-storage/index/maildir/maildir-storage.h | 1 + src/lib-storage/index/maildir/maildir-sync.c | 36 +++++++++++++----------- 2 files changed, 20 insertions(+), 17 deletions(-) diffs (67 lines): diff -r ae7a7282af83 -r 4124c28db2a4 src/lib-storage/index/maildir/maildir-storage.h --- a/src/lib-storage/index/maildir/maildir-storage.h Mon Sep 05 11:48:11 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.h Mon Sep 05 12:46:49 2011 +0300 @@ -93,6 +93,7 @@ unsigned int private_flags_mask_set:1; unsigned int backend_readonly:1; unsigned int backend_readonly_set:1; + unsigned int sync_uidlist_refreshed:1; }; extern struct mail_vfuncs maildir_mail_vfuncs; diff -r ae7a7282af83 -r 4124c28db2a4 src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Mon Sep 05 11:48:11 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Sep 05 12:46:49 2011 +0300 @@ -942,26 +942,27 @@ int ret; ret = maildir_uidlist_lookup(mbox->uidlist, uid, flags_r, fname_r); - if (ret <= 0) { - if (ret < 0) + if (ret != 0) + return ret; + + if (maildir_uidlist_is_open(mbox->uidlist)) { + /* refresh uidlist and check again in case it was added + after the last mailbox sync */ + if (mbox->sync_uidlist_refreshed) { + /* we've already refreshed it, don't bother again */ + return ret; + } + mbox->sync_uidlist_refreshed = TRUE; + if (maildir_uidlist_refresh(mbox->uidlist) < 0) return -1; - if (maildir_uidlist_is_open(mbox->uidlist)) { - /* refresh uidlist and check again in case it was added - after the last mailbox sync */ - if (maildir_uidlist_refresh(mbox->uidlist) < 0) - return -1; - } else { - /* the uidlist doesn't exist. */ - if (maildir_storage_sync_force(mbox, uid) < 0) - return -1; - } - - /* try again */ - ret = maildir_uidlist_lookup(mbox->uidlist, uid, - flags_r, fname_r); + } else { + /* the uidlist doesn't exist. */ + if (maildir_storage_sync_force(mbox, uid) < 0) + return -1; } - return ret; + /* try again */ + return maildir_uidlist_lookup(mbox->uidlist, uid, flags_r, fname_r); } int maildir_storage_sync_force(struct maildir_mailbox *mbox, uint32_t uid) @@ -1046,6 +1047,7 @@ maildir_uidlist_set_all_nonsynced(mbox->uidlist); } mbox->synced = TRUE; + mbox->sync_uidlist_refreshed = FALSE; return index_mailbox_sync_init(box, flags, ret < 0); } From dovecot at dovecot.org Mon Sep 5 14:23:23 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Sep 2011 14:23:23 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Avoid assert-crashing when remote... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/44bbbb238f2a changeset: 13402:44bbbb238f2a user: Timo Sirainen date: Mon Sep 05 14:23:11 2011 +0300 description: lib-ssl-iostream: Avoid assert-crashing when remote disconnects during write. diffstat: src/lib-ssl-iostream/iostream-openssl.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (16 lines): diff -r 4124c28db2a4 -r 44bbbb238f2a src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Mon Sep 05 12:46:49 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Mon Sep 05 14:23:11 2011 +0300 @@ -264,6 +264,12 @@ i_assert(ret == (int)bytes); sent = o_stream_send(ssl_io->plain_output, buffer, bytes); + if (sent < 0) { + i_assert(ssl_io->plain_output->stream_errno != 0); + ssl_io->ssl_output->stream_errno = + ssl_io->plain_output->stream_errno; + break; + } i_assert(sent == (ssize_t)bytes); bytes_sent = TRUE; } From dovecot at dovecot.org Tue Sep 6 13:41:16 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 13:41:16 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Code cleanups, fixes, asserts and... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6a3f3a5ad9a5 changeset: 13403:6a3f3a5ad9a5 user: Timo Sirainen date: Tue Sep 06 13:40:50 2011 +0300 description: lib-ssl-iostream: Code cleanups, fixes, asserts and comments. diffstat: src/lib-ssl-iostream/iostream-openssl.c | 54 ++++++++++++++++-- src/lib-ssl-iostream/iostream-openssl.h | 12 ++++ src/lib-ssl-iostream/istream-openssl.c | 14 ++-- src/lib-ssl-iostream/ostream-openssl.c | 96 ++++++++++++++++++++------------ 4 files changed, 128 insertions(+), 48 deletions(-) diffs (truncated from 375 to 300 lines): diff -r 44bbbb238f2a -r 6a3f3a5ad9a5 src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Mon Sep 05 14:23:11 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Tue Sep 06 13:40:50 2011 +0300 @@ -178,6 +178,11 @@ return -1; } + /* BIO pairs use default buffer sizes (17 kB in OpenSSL 0.9.8e). + Each of the BIOs have one "write buffer". BIO_write() copies data + to them, while BIO_read() reads from the other BIO's write buffer + into the given buffer. The bio_int is used by OpenSSL and bio_ext + is used by this library. */ if (BIO_new_bio_pair(&bio_int, 0, &bio_ext, 0) != 1) { i_error("BIO_new_bio_pair() failed: %s", ssl_iostream_error()); SSL_free(ssl); @@ -192,6 +197,7 @@ ssl_io->plain_input = *input; ssl_io->plain_output = *output; ssl_io->source = i_strdup(source); + /* bio_int will be freed by SSL_free() */ SSL_set_bio(ssl_io->ssl, bio_int, bio_int); SSL_set_ex_data(ssl_io->ssl, dovecot_ssl_extdata_index, ssl_io); @@ -244,11 +250,14 @@ { size_t bytes, max_bytes; ssize_t sent; - unsigned char buffer[1024]; + unsigned char buffer[IO_BLOCK_SIZE]; bool bytes_sent = FALSE; int ret; + o_stream_cork(ssl_io->plain_output); while ((bytes = BIO_ctrl_pending(ssl_io->bio_ext)) > 0) { + /* bytes contains how many SSL encrypted bytes we should be + sending out */ max_bytes = o_stream_get_buffer_avail_size(ssl_io->plain_output); if (bytes > max_bytes) { if (max_bytes == 0) { @@ -260,9 +269,14 @@ if (bytes > sizeof(buffer)) bytes = sizeof(buffer); + /* BIO_read() is guaranteed to return all the bytes that + BIO_ctrl_pending() returned */ ret = BIO_read(ssl_io->bio_ext, buffer, bytes); i_assert(ret == (int)bytes); + /* we limited number of read bytes to plain_output's + available size. this send() is guaranteed to either + fully succeed or completely fail due to some error. */ sent = o_stream_send(ssl_io->plain_output, buffer, bytes); if (sent < 0) { i_assert(ssl_io->plain_output->stream_errno != 0); @@ -273,22 +287,27 @@ i_assert(sent == (ssize_t)bytes); bytes_sent = TRUE; } + o_stream_uncork(ssl_io->plain_output); return bytes_sent; } static bool ssl_iostream_bio_input(struct ssl_iostream *ssl_io) { const unsigned char *data; - size_t size; + size_t bytes, size; bool bytes_read = FALSE; int ret; - while (BIO_ctrl_get_read_request(ssl_io->bio_ext) > 0) { + while ((bytes = BIO_ctrl_get_write_guarantee(ssl_io->bio_ext)) > 0) { + /* bytes contains how many bytes we can write to bio_ext */ (void)i_stream_read_data(ssl_io->plain_input, &data, &size, 0); if (size == 0) { /* wait for more input */ break; } + if (size > bytes) + size = bytes; + ret = BIO_write(ssl_io->bio_ext, data, size); i_assert(ret == (ssize_t)size); @@ -303,11 +322,29 @@ bool ret; ret = ssl_iostream_bio_output(ssl_io); - if (ssl_iostream_bio_input(ssl_io)) + if (ssl_iostream_bio_input(ssl_io)) { + if (ssl_io->ostream_flush_waiting_input) { + ssl_io->ostream_flush_waiting_input = FALSE; + o_stream_set_flush_pending(ssl_io->plain_output, TRUE); + } + ssl_io->want_read = FALSE; ret = TRUE; + } return ret; } +int ssl_iostream_more(struct ssl_iostream *ssl_io) +{ + int ret; + + if (!ssl_io->handshaked) { + if ((ret = ssl_iostream_handshake(ssl_io)) <= 0) + return ret; + } + (void)ssl_iostream_bio_sync(ssl_io); + return 1; +} + int ssl_iostream_handle_error(struct ssl_iostream *ssl_io, int ret, const char *func_name) { @@ -317,12 +354,16 @@ err = SSL_get_error(ssl_io->ssl, ret); switch (err) { case SSL_ERROR_WANT_WRITE: - if (!ssl_iostream_bio_sync(ssl_io)) + if (!ssl_iostream_bio_sync(ssl_io)) { + i_panic("SSL ostream buffer size not unlimited"); return 0; + } return 1; case SSL_ERROR_WANT_READ: - if (!ssl_iostream_bio_sync(ssl_io)) + if (!ssl_iostream_bio_sync(ssl_io)) { + ssl_io->want_read = TRUE; return 0; + } return 1; case SSL_ERROR_SYSCALL: /* eat up the error queue */ @@ -384,6 +425,7 @@ return ret; } } + /* handshake finished */ (void)ssl_iostream_bio_sync(ssl_io); i_free_and_null(ssl_io->last_error); diff -r 44bbbb238f2a -r 6a3f3a5ad9a5 src/lib-ssl-iostream/iostream-openssl.h --- a/src/lib-ssl-iostream/iostream-openssl.h Mon Sep 05 14:23:11 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.h Tue Sep 06 13:40:50 2011 +0300 @@ -45,6 +45,8 @@ unsigned int handshaked:1; unsigned int cert_received:1; unsigned int cert_broken:1; + unsigned int want_read:1; + unsigned int ostream_flush_waiting_input:1; }; extern int dovecot_ssl_extdata_index; @@ -57,7 +59,17 @@ const char *key_source, EVP_PKEY **pkey_r); const char *ssl_iostream_get_use_certificate_error(const char *cert); +/* Sync plain_input/plain_output streams with BIOs. Returns TRUE if at least + one byte was read/written. */ bool ssl_iostream_bio_sync(struct ssl_iostream *ssl_io); +/* Call when there's more data available in plain_input/plain_output. + Returns 1 if it's ok to continue with SSL_read/SSL_write, 0 if not + (still handshaking), -1 if error occurred. */ +int ssl_iostream_more(struct ssl_iostream *ssl_io); + +/* Returns 1 if the operation should be retried (we read/wrote more data), + 0 if the operation should retried later once more data has been + read/written, -1 if a fatal error occurred (errno is set). */ int ssl_iostream_handle_error(struct ssl_iostream *ssl_io, int ret, const char *func_name); diff -r 44bbbb238f2a -r 6a3f3a5ad9a5 src/lib-ssl-iostream/istream-openssl.c --- a/src/lib-ssl-iostream/istream-openssl.c Mon Sep 05 14:23:11 2011 +0300 +++ b/src/lib-ssl-iostream/istream-openssl.c Tue Sep 06 13:40:50 2011 +0300 @@ -27,12 +27,13 @@ stream->istream.eof = TRUE; return -1; } - if (!sstream->ssl_io->handshaked) { - if ((ret = ssl_iostream_handshake(sstream->ssl_io)) <= 0) { - if (ret < 0) - stream->istream.stream_errno = errno; - return ret; + ret = ssl_iostream_more(sstream->ssl_io); + if (ret <= 0) { + if (ret < 0) { + /* handshake failed */ + stream->istream.stream_errno = errno; } + return ret; } if (!i_stream_get_buffer_space(stream, 1, &size)) @@ -40,6 +41,7 @@ while ((ret = SSL_read(sstream->ssl_io->ssl, stream->w_buffer + stream->pos, size)) <= 0) { + /* failed to read anything */ ret = ssl_iostream_handle_error(sstream->ssl_io, ret, "SSL_read"); if (ret <= 0) { @@ -50,7 +52,7 @@ } return ret; } - (void)ssl_iostream_bio_sync(sstream->ssl_io); + /* we did some BIO I/O, try reading again */ } stream->pos += ret; return ret; diff -r 44bbbb238f2a -r 6a3f3a5ad9a5 src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Mon Sep 05 14:23:11 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Tue Sep 06 13:40:50 2011 +0300 @@ -66,22 +66,25 @@ static int o_stream_ssl_flush_buffer(struct ssl_ostream *sstream) { size_t pos = 0; - int ret; + int ret = 1; while (pos < sstream->buffer->used) { + /* we're writing plaintext data to OpenSSL, which it encrypts + and writes to bio_int's buffer. ssl_iostream_bio_sync() + reads it from there and adds to plain_output stream. */ ret = SSL_write(sstream->ssl_io->ssl, CONST_PTR_OFFSET(sstream->buffer->data, pos), sstream->buffer->used - pos); if (ret <= 0) { ret = ssl_iostream_handle_error(sstream->ssl_io, ret, "SSL_write"); - if (ret <= 0) { - if (ret < 0) { - sstream->ostream.ostream.stream_errno = - errno; - } - buffer_delete(sstream->buffer, 0, pos); - return ret; + if (ret < 0) { + sstream->ostream.ostream.stream_errno = errno; + break; + } + if (ret == 0) { + /* bio_int's buffer is full */ + break; } } else { pos += ret; @@ -89,7 +92,7 @@ } } buffer_delete(sstream->buffer, 0, pos); - return 1; + return ret <= 0 ? ret : 1; } static int o_stream_ssl_flush(struct ostream_private *stream) @@ -97,34 +100,33 @@ struct ssl_ostream *sstream = (struct ssl_ostream *)stream; int ret; - if (!sstream->ssl_io->handshaked) { - if ((ret = ssl_iostream_handshake(sstream->ssl_io)) <= 0) { - if (ret < 0) - stream->ostream.stream_errno = errno; - return ret; - } + if ((ret = ssl_iostream_more(sstream->ssl_io)) < 0) { + /* handshake failed */ + stream->ostream.stream_errno = errno; + } else if (ret > 0 && sstream->buffer != NULL && + sstream->buffer->used > 0) { + /* we can try to send some of our buffered data */ + ret = o_stream_ssl_flush_buffer(sstream); } - if (sstream->buffer != NULL && sstream->buffer->used > 0) { - if ((ret = o_stream_ssl_flush_buffer(sstream)) <= 0) - return ret; + if (ret == 0 && sstream->ssl_io->want_read) { + /* we need to read more data until we can continue. */ + sstream->ssl_io->ostream_flush_waiting_input = TRUE; + ret = 1; } - return 1; + return ret; } static ssize_t -o_stream_ssl_sendv(struct ostream_private *stream, - const struct const_iovec *iov, unsigned int iov_count) +o_stream_ssl_sendv_try(struct ssl_ostream *sstream, + const struct const_iovec *iov, unsigned int iov_count, + size_t *bytes_sent_r) { - struct ssl_ostream *sstream = (struct ssl_ostream *)stream; unsigned int i; - size_t bytes_sent = 0; size_t pos; - int ret = 0; From dovecot at dovecot.org Tue Sep 6 16:33:25 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 16:33:25 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Added ssl_iostream_cert_match_name() Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c3dc563c9800 changeset: 13404:c3dc563c9800 user: Timo Sirainen date: Tue Sep 06 16:32:20 2011 +0300 description: lib-ssl-iostream: Added ssl_iostream_cert_match_name() diffstat: src/lib-ssl-iostream/iostream-openssl.c | 107 +++++++++++++++++++++++++++++-- src/lib-ssl-iostream/iostream-ssl.h | 1 + 2 files changed, 99 insertions(+), 9 deletions(-) diffs (171 lines): diff -r 6a3f3a5ad9a5 -r c3dc563c9800 src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Tue Sep 06 13:40:50 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Tue Sep 06 16:32:20 2011 +0300 @@ -6,6 +6,7 @@ #include "iostream-openssl.h" #include +#include static void ssl_iostream_free(struct ssl_iostream *ssl_io); @@ -94,7 +95,8 @@ X509_NAME *subject; subject = X509_get_subject_name(ctx->current_cert); - if (X509_NAME_oneline(subject, buf, sizeof(buf)) == NULL) + if (subject == NULL || + X509_NAME_oneline(subject, buf, sizeof(buf)) == NULL) buf[0] = '\0'; else buf[sizeof(buf)-1] = '\0'; /* just in case.. */ @@ -118,6 +120,7 @@ const struct ssl_iostream_settings *set) { const struct ssl_iostream_settings *ctx_set = ssl_io->ctx->set; + int verify_flags; if (set->verbose) SSL_set_info_callback(ssl_io->ssl, ssl_info_callback); @@ -141,8 +144,11 @@ return -1; } if (set->verify_remote_cert) { - SSL_set_verify(ssl_io->ssl, - SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, + if (ssl_io->ctx->client_ctx) + verify_flags = SSL_VERIFY_NONE; + else + verify_flags = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; + SSL_set_verify(ssl_io->ssl, verify_flags, ssl_iostream_verify_client_cert); } @@ -345,6 +351,12 @@ return 1; } +static void ssl_iostream_set_error(struct ssl_iostream *ssl_io, const char *str) +{ + i_free(ssl_io->last_error); + ssl_io->last_error = i_strdup(str); +} + int ssl_iostream_handle_error(struct ssl_iostream *ssl_io, int ret, const char *func_name) { @@ -397,11 +409,89 @@ break; } - if (errstr != NULL) { - i_free(ssl_io->last_error); - ssl_io->last_error = i_strdup(errstr); + if (errstr != NULL) + ssl_iostream_set_error(ssl_io, errstr); + return -1; +} + +static const char *asn1_string_to_c(ASN1_STRING *asn_str) +{ + const char *cstr; + unsigned int len; + + len = ASN1_STRING_length(asn_str); + cstr = t_strndup(ASN1_STRING_data(asn_str), len); + if (strlen(cstr) != len) { + /* NULs in the name - could be some MITM attack. + never allow. */ + return ""; } - return -1; + return cstr; +} + +static const char *get_general_dns_name(const GENERAL_NAME *name) +{ + if (ASN1_STRING_type(name->d.ia5) != V_ASN1_IA5STRING) + return ""; + + return asn1_string_to_c(name->d.ia5); +} + +static const char *get_cname(X509 *cert) +{ + X509_NAME *name; + X509_NAME_ENTRY *entry; + ASN1_STRING *str; + int cn_idx; + + name = X509_get_subject_name(cert); + if (name == NULL) + return ""; + cn_idx = X509_NAME_get_index_by_NID(name, NID_commonName, -1); + if (cn_idx == -1) + return ""; + entry = X509_NAME_get_entry(name, cn_idx); + i_assert(entry != NULL); + str = X509_NAME_ENTRY_get_data(entry); + i_assert(str != NULL); + return asn1_string_to_c(str); +} + +int ssl_iostream_cert_match_name(struct ssl_iostream *ssl_io, + const char *verify_name) +{ + X509 *cert; + STACK_OF(GENERAL_NAME) *gnames; + const GENERAL_NAME *gn; + const char *dnsname; + bool dns_names = FALSE; + unsigned int i, count; + + if (!ssl_iostream_has_valid_client_cert(ssl_io)) + return -1; + + cert = SSL_get_peer_certificate(ssl_io->ssl); + i_assert(cert != NULL); + + /* verify against SubjectAltNames */ + gnames = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); + count = gnames == NULL ? 0 : sk_GENERAL_NAME_num(gnames); + for (i = 0; i < count; i++) { + gn = sk_GENERAL_NAME_value(gnames, i); + if (gn->type == GEN_DNS) { + dns_names = TRUE; + dnsname = get_general_dns_name(gn); + if (strcmp(dnsname, verify_name) == 0) + break; + } + } + sk_GENERAL_NAME_pop_free(gnames, GENERAL_NAME_free); + /* verify against CommonName only when there wasn't any DNS + SubjectAltNames */ + if (dns_names) + return i < count ? 0 : -1; + + return strcmp(get_cname(cert), verify_name) == 0 ? 0 : -1; } int ssl_iostream_handshake(struct ssl_iostream *ssl_io) @@ -475,8 +565,7 @@ return NULL; x509 = SSL_get_peer_certificate(ssl_io->ssl); - if (x509 == NULL) - return NULL; /* we should have had it.. */ + i_assert(x509 != NULL); len = X509_NAME_get_text_by_NID(X509_get_subject_name(x509), ssl_io->username_nid, NULL, 0); diff -r 6a3f3a5ad9a5 -r c3dc563c9800 src/lib-ssl-iostream/iostream-ssl.h --- a/src/lib-ssl-iostream/iostream-ssl.h Tue Sep 06 13:40:50 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-ssl.h Tue Sep 06 16:32:20 2011 +0300 @@ -32,6 +32,7 @@ bool ssl_iostream_is_handshaked(const struct ssl_iostream *ssl_io); bool ssl_iostream_has_valid_client_cert(const struct ssl_iostream *ssl_io); bool ssl_iostream_has_broken_client_cert(struct ssl_iostream *ssl_io); +int ssl_iostream_cert_match_name(struct ssl_iostream *ssl_io, const char *name); const char *ssl_iostream_get_peer_name(struct ssl_iostream *ssl_io); const char *ssl_iostream_get_security_string(struct ssl_iostream *ssl_io); const char *ssl_iostream_get_last_error(struct ssl_iostream *ssl_io); From dovecot at dovecot.org Tue Sep 6 16:33:25 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 16:33:25 +0300 Subject: dovecot-2.1: imapc: Verify that SSL certificate matches the conn... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e40d6b5ef97e changeset: 13405:e40d6b5ef97e user: Timo Sirainen date: Tue Sep 06 16:33:09 2011 +0300 description: imapc: Verify that SSL certificate matches the connected hostname. diffstat: src/lib-storage/index/imapc/imapc-connection.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diffs (37 lines): diff -r c3dc563c9800 -r e40d6b5ef97e src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Tue Sep 06 16:32:20 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Tue Sep 06 16:33:09 2011 +0300 @@ -966,20 +966,25 @@ { struct imapc_connection *conn = context; - if (ssl_iostream_has_valid_client_cert(conn->ssl_iostream)) { + if (!ssl_iostream_has_valid_client_cert(conn->ssl_iostream)) { + if (!ssl_iostream_has_broken_client_cert(conn->ssl_iostream)) { + i_error("imapc(%s): SSL certificate not received", + conn->name); + } else { + i_error("imapc(%s): Received invalid SSL certificate", + conn->name); + } + } else if (ssl_iostream_cert_match_name(conn->ssl_iostream, + conn->client->set.host) < 0) { + i_error("imapc(%s): SSL certificate doesn't match host name", + conn->name); + } else { if (conn->client->set.debug) { i_debug("imapc(%s): SSL handshake successful", conn->name); } return 0; } - - if (!ssl_iostream_has_broken_client_cert(conn->ssl_iostream)) { - i_error("imapc(%s): SSL certificate not received", conn->name); - } else { - i_error("imapc(%s): Received invalid SSL certificate", - conn->name); - } i_stream_close(conn->input); return -1; } From dovecot at dovecot.org Tue Sep 6 16:42:30 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 16:42:30 +0300 Subject: dovecot-2.1: imapc: Error logging fix when SSL handshake fails. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/991ce1aed5f7 changeset: 13406:991ce1aed5f7 user: Timo Sirainen date: Tue Sep 06 16:42:19 2011 +0300 description: imapc: Error logging fix when SSL handshake fails. diffstat: src/lib-storage/index/imapc/imapc-connection.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diffs (41 lines): diff -r e40d6b5ef97e -r 991ce1aed5f7 src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Tue Sep 06 16:33:09 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Tue Sep 06 16:42:19 2011 +0300 @@ -99,6 +99,7 @@ unsigned int idling:1; unsigned int idle_stopping:1; unsigned int idle_plus_waiting:1; + unsigned int handshake_failed:1; }; static int imapc_connection_output(struct imapc_connection *conn); @@ -941,6 +942,7 @@ static void imapc_connection_input(struct imapc_connection *conn) { + const char *errstr; ssize_t ret = 0; /* we need to read as much as we can with SSL streams to avoid @@ -953,9 +955,10 @@ if (conn->ssl_iostream == NULL) { i_error("imapc(%s): Server disconnected unexpectedly", conn->name); - } else { - i_error("imapc(%s): Server disconnected: %s", conn->name, - ssl_iostream_get_last_error(conn->ssl_iostream)); + } else if (!conn->handshake_failed) { + errstr = ssl_iostream_get_last_error(conn->ssl_iostream); + i_error("imapc(%s): Server disconnected: %s", + conn->name, errstr != NULL ? errstr : ""); } imapc_connection_disconnect(conn); return; @@ -985,6 +988,7 @@ } return 0; } + conn->handshake_failed = TRUE; i_stream_close(conn->input); return -1; } From dovecot at dovecot.org Tue Sep 6 17:04:39 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 17:04:39 +0300 Subject: dovecot-2.1: auth: If auth_debug_passwords=no, hide values of us... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7b115033405d changeset: 13407:7b115033405d user: Timo Sirainen date: Tue Sep 06 17:01:29 2011 +0300 description: auth: If auth_debug_passwords=no, hide values of userdb keys containing "pass" string. diffstat: src/auth/auth-master-connection.c | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-) diffs (60 lines): diff -r 991ce1aed5f7 -r 7b115033405d src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Tue Sep 06 16:42:19 2011 +0300 +++ b/src/auth/auth-master-connection.c Tue Sep 06 17:01:29 2011 +0300 @@ -44,6 +44,30 @@ ARRAY_TYPE(auth_master_connections) auth_master_connections; +static const char * +auth_master_reply_hide_passwords(struct auth_master_connection *conn, + const char *str) +{ + char **args, *p, *p2; + unsigned int i; + + if (conn->auth->set->debug_passwords) + return str; + + /* hide all parameters that have "pass" in their key */ + args = p_strsplit(pool_datastack_create(), str, "\t"); + for (i = 0; args[i] != NULL; i++) { + p = strstr(args[i], "pass"); + p2 = strchr(args[i], '='); + if (p != NULL && p < p2) { + *p2 = '\0'; + args[i] = p_strconcat(pool_datastack_create(), + args[i], "=", NULL); + } + } + return t_strarray_join((void *)args, "\t"); +} + void auth_master_request_callback(struct auth_stream_reply *reply, void *context) { @@ -53,8 +77,10 @@ reply_str = auth_stream_reply_export(reply); - if (conn->auth->set->debug) - i_debug("master out: %s", reply_str); + if (conn->auth->set->debug) { + i_debug("master out: %s", + auth_master_reply_hide_passwords(conn, reply_str)); + } iov[0].iov_base = reply_str; iov[0].iov_len = strlen(reply_str); @@ -228,8 +254,10 @@ break; } - if (conn->auth->set->debug) - i_debug("master out: %s", str_c(str)); + if (conn->auth->set->debug) { + i_debug("master out: %s", + auth_master_reply_hide_passwords(conn, str_c(str))); + } str_append_c(str, '\n'); (void)o_stream_send(conn->output, str_data(str), str_len(str)); From dovecot at dovecot.org Tue Sep 6 17:04:39 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 17:04:39 +0300 Subject: dovecot-2.1: lib-auth: When debug logging auth input, hide value... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1180505cdcdb changeset: 13408:1180505cdcdb user: Timo Sirainen date: Tue Sep 06 17:03:06 2011 +0300 description: lib-auth: When debug logging auth input, hide values of all fields containing "pass" in key. diffstat: src/lib-auth/auth-master.c | 37 ++++++++++++++++++++++++++++++++++++- 1 files changed, 36 insertions(+), 1 deletions(-) diffs (55 lines): diff -r 7b115033405d -r 1180505cdcdb src/lib-auth/auth-master.c --- a/src/lib-auth/auth-master.c Tue Sep 06 17:01:29 2011 +0300 +++ b/src/lib-auth/auth-master.c Tue Sep 06 17:03:06 2011 +0300 @@ -157,6 +157,39 @@ return -1; } +static const char *const *args_hide_passwords(const char *const *args) +{ + ARRAY_TYPE(const_string) new_args; + const char *p, *p2; + unsigned int i; + + /* if there are any keys that contain "pass" string */ + for (i = 0; args[i] != NULL; i++) { + p = strstr(args[i], "pass"); + if (p != NULL && p < strchr(args[i], '=')) + break; + } + if (args[i] == NULL) + return args; + + /* there are. replace their values with */ + t_array_init(&new_args, i + 16); + array_append(&new_args, args, i); + for (; args[i] != NULL; i++) { + p = strstr(args[i], "pass"); + p2 = strchr(args[i], '='); + if (p != NULL && p < p2) { + p = t_strconcat(t_strdup_until(args[i], p2), + "=", NULL); + array_append(&new_args, &p, 1); + } else { + array_append(&new_args, &args[i], 1); + } + } + (void)array_append_space(&new_args); + return array_idx(&new_args, 0); +} + static bool auth_lookup_reply_callback(const char *cmd, const char *const *args, void *context) { @@ -185,8 +218,10 @@ } } } - if (debug) + if (debug) { + args = args_hide_passwords(args); i_debug("auth input: %s", t_strarray_join(args, " ")); + } return TRUE; } From dovecot at dovecot.org Tue Sep 6 17:04:39 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 17:04:39 +0300 Subject: dovecot-2.1: lib-storage: When mail_debug=yes logs userdb fields... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/af6a6da91978 changeset: 13409:af6a6da91978 user: Timo Sirainen date: Tue Sep 06 17:03:55 2011 +0300 description: lib-storage: When mail_debug=yes logs userdb fields, hide values of all whose key contains "pass". diffstat: src/lib-storage/mail-storage-service.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 1180505cdcdb -r af6a6da91978 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Sep 06 17:03:06 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Sep 06 17:03:55 2011 +0300 @@ -164,6 +164,11 @@ ret = settings_parse_line(set_parser, line); if (mail_debug && ret >= 0) { + if (strstr(key, "pass") != NULL) { + /* possibly a password field (e.g. imapc_password). + hide the value. */ + line = t_strconcat(key, "=", NULL); + } i_debug(ret == 0 ? "Unknown userdb setting: %s" : "Added userdb setting: %s", line); From dovecot at dovecot.org Tue Sep 6 17:29:50 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Sep 2011 17:29:50 +0300 Subject: dovecot-2.1: imapc: Don't crash when trying to use imapc's subsc... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7ae9c4aa5edb changeset: 13410:7ae9c4aa5edb user: Timo Sirainen date: Tue Sep 06 17:29:38 2011 +0300 description: imapc: Don't crash when trying to use imapc's subscription list for another namespace. diffstat: src/lib-storage/index/imapc/imapc-list.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diffs (23 lines): diff -r af6a6da91978 -r 7ae9c4aa5edb src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Tue Sep 06 17:03:55 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Tue Sep 06 17:29:38 2011 +0300 @@ -417,11 +417,18 @@ struct imapc_mailbox_list *src_list = (struct imapc_mailbox_list *)_src_list; struct imapc_simple_context ctx; + char sep; i_assert(src_list->tmp_subscriptions == NULL); - if (src_list->refreshed_subscriptions) + if (src_list->refreshed_subscriptions) { + if (dest_list->subscriptions == NULL) { + sep = mailbox_list_get_hierarchy_sep(dest_list); + dest_list->subscriptions = + mailbox_tree_init(sep); + } return 0; + } if (src_list->sep == '\0') (void)mailbox_list_get_hierarchy_sep(_src_list); From dovecot at dovecot.org Wed Sep 7 08:41:36 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 08:41:36 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fb03574ddd34 changeset: 13411:fb03574ddd34 user: Timo Sirainen date: Wed Sep 07 08:40:41 2011 +0300 description: lib-ssl-iostream: Compiler warning fix. diffstat: src/lib-ssl-iostream/ostream-openssl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 7ae9c4aa5edb -r fb03574ddd34 src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Tue Sep 06 17:29:38 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 08:40:41 2011 +0300 @@ -124,7 +124,7 @@ { unsigned int i; size_t pos; - ssize_t ret; + ssize_t ret = 0; *bytes_sent_r = 0; for (i = 0, pos = 0; i < iov_count; ) { @@ -151,7 +151,7 @@ (void)ssl_iostream_bio_sync(sstream->ssl_io); } } - return ret <= 0 ? ret : 1; + return ret < 0 ? -1 : 0; } static ssize_t From dovecot at dovecot.org Wed Sep 7 08:41:36 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 08:41:36 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Fixed compiling when SSL is disab... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/513802d016a0 changeset: 13412:513802d016a0 user: Timo Sirainen date: Wed Sep 07 08:41:25 2011 +0300 description: lib-ssl-iostream: Fixed compiling when SSL is disabled. diffstat: src/lib-ssl-iostream/iostream-ssl-none.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r fb03574ddd34 -r 513802d016a0 src/lib-ssl-iostream/iostream-ssl-none.c --- a/src/lib-ssl-iostream/iostream-ssl-none.c Wed Sep 07 08:40:41 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-ssl-none.c Wed Sep 07 08:41:25 2011 +0300 @@ -29,6 +29,7 @@ bool ssl_iostream_is_handshaked(const struct ssl_iostream *ssl_io ATTR_UNUSED) { return FALSE; } bool ssl_iostream_has_valid_client_cert(const struct ssl_iostream *ssl_io ATTR_UNUSED) { return FALSE; } bool ssl_iostream_has_broken_client_cert(struct ssl_iostream *ssl_io ATTR_UNUSED) { return TRUE; } +int ssl_iostream_cert_match_name(struct ssl_iostream *ssl_io ATTR_UNUSED, const char *name ATTR_UNUSED) { return -1; } const char *ssl_iostream_get_peer_name(struct ssl_iostream *ssl_io ATTR_UNUSED) { return NULL; } const char *ssl_iostream_get_security_string(struct ssl_iostream *ssl_io ATTR_UNUSED) { return NULL; } const char *ssl_iostream_get_last_error(struct ssl_iostream *ssl_io ATTR_UNUSED) { return NULL; } From dovecot at dovecot.org Wed Sep 7 09:40:29 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 09:40:29 +0300 Subject: dovecot-2.1: imapc: Removed accidentally committed debug sleeps. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3828fa3b8fd4 changeset: 13413:3828fa3b8fd4 user: Timo Sirainen date: Wed Sep 07 09:40:16 2011 +0300 description: imapc: Removed accidentally committed debug sleeps. diffstat: src/lib-storage/index/imapc/imapc-mail.c | 2 -- src/lib-storage/index/imapc/imapc-mailbox.c | 2 -- 2 files changed, 0 insertions(+), 4 deletions(-) diffs (31 lines): diff -r 513802d016a0 -r 3828fa3b8fd4 src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Wed Sep 07 08:41:25 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Wed Sep 07 09:40:16 2011 +0300 @@ -69,7 +69,6 @@ mail_storage_set_critical(_mail->box->storage, "imapc: Remote server didn't send " "INTERNALDATE for UID %u", _mail->uid); - sleep(3600); } return -1; } @@ -147,7 +146,6 @@ mail_storage_set_critical(_mail->box->storage, "imapc: Remote server didn't send " "BODY[] for UID %u", _mail->uid); - sleep(3600); } return -1; } diff -r 513802d016a0 -r 3828fa3b8fd4 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Wed Sep 07 08:41:25 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Wed Sep 07 09:40:16 2011 +0300 @@ -22,8 +22,6 @@ mbox->box.name, t_strdup_vprintf(reason, va)); va_end(va); - sleep(3600); - mail_index_mark_corrupted(mbox->box.index); imapc_client_mailbox_disconnect(mbox->client_box); } From dovecot at dovecot.org Wed Sep 7 10:01:47 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 10:01:47 +0300 Subject: dovecot-2.1: imapc: Don't crash if a newly seen uncommitted mess... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3ae5d7e0a4b4 changeset: 13414:3ae5d7e0a4b4 user: Timo Sirainen date: Wed Sep 07 10:01:36 2011 +0300 description: imapc: Don't crash if a newly seen uncommitted message is expunged. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 42 ++++++++++++++++++++++++++-- src/lib-storage/index/imapc/imapc-storage.c | 1 + src/lib-storage/index/imapc/imapc-storage.h | 1 + src/lib-storage/index/imapc/imapc-sync.c | 7 ++++ 4 files changed, 48 insertions(+), 3 deletions(-) diffs (113 lines): diff -r 3828fa3b8fd4 -r 3ae5d7e0a4b4 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Wed Sep 07 09:40:16 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Wed Sep 07 10:01:36 2011 +0300 @@ -46,6 +46,27 @@ mail_index_transaction_open_updated_view(mbox->delayed_sync_trans); } +static int imapc_mailbox_commit_delayed_expunges(struct imapc_mailbox *mbox) +{ + struct mail_index_view *view = imapc_mailbox_get_sync_view(mbox); + struct mail_index_transaction *trans; + const uint32_t *uidp; + uint32_t lseq; + int ret; + + trans = mail_index_transaction_begin(view, + MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); + array_foreach(&mbox->delayed_expunged_uids, uidp) { + if (mail_index_lookup_seq(view, *uidp, &lseq)) + mail_index_expunge(trans, lseq); + } + array_clear(&mbox->delayed_expunged_uids); + ret = mail_index_transaction_commit(&trans); + if (ret < 0) + mail_storage_set_index_error(&mbox->box); + return ret; +} + int imapc_mailbox_commit_delayed_trans(struct imapc_mailbox *mbox, bool *changes_r) { @@ -64,6 +85,13 @@ } if (mbox->sync_view != NULL) mail_index_view_close(&mbox->sync_view); + + if (array_count(&mbox->delayed_expunged_uids) > 0) { + /* delayed expunges - commit them now in a separate + transaction */ + if (imapc_mailbox_commit_delayed_expunges(mbox) < 0) + ret = -1; + } return ret; } @@ -289,10 +317,18 @@ imapc_msgmap_expunge(msgmap, rseq); imapc_mailbox_init_delayed_trans(mbox); - if (!mail_index_lookup_seq(mbox->delayed_sync_view, uid, &lseq)) { + if (mail_index_lookup_seq(mbox->sync_view, uid, &lseq)) + mail_index_expunge(mbox->delayed_sync_trans, lseq); + else if (mail_index_lookup_seq(mbox->delayed_sync_view, uid, &lseq)) { + /* this message exists only in this transaction. lib-index + can't currently handle expunging anything except the last + appended message in a transaction, and fixing it would be + quite a lot of trouble. so instead we'll just delay doing + this expunge until after the current transaction has been + committed. */ + array_append(&mbox->delayed_expunged_uids, &uid, 1); + } else { /* already expunged by another session */ - } else { - mail_index_expunge(mbox->delayed_sync_trans, lseq); } imapc_mailbox_idle_notify(mbox); } diff -r 3828fa3b8fd4 -r 3ae5d7e0a4b4 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 07 09:40:16 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 07 10:01:36 2011 +0300 @@ -305,6 +305,7 @@ p_array_init(&mbox->resp_text_callbacks, pool, 16); p_array_init(&mbox->fetch_mails, pool, 16); p_array_init(&mbox->permanent_keywords, pool, 32); + p_array_init(&mbox->delayed_expunged_uids, pool, 16); imapc_mailbox_register_callbacks(mbox); return &mbox->box; } diff -r 3828fa3b8fd4 -r 3ae5d7e0a4b4 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Wed Sep 07 09:40:16 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Wed Sep 07 10:01:36 2011 +0300 @@ -57,6 +57,7 @@ enum mail_flags permanent_flags; ARRAY_TYPE(keywords) permanent_keywords; + ARRAY_TYPE(uint32_t) delayed_expunged_uids; uint32_t sync_uid_validity; uint32_t sync_uid_next; uint32_t sync_fetch_first_uid; diff -r 3828fa3b8fd4 -r 3ae5d7e0a4b4 src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Wed Sep 07 09:40:16 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Wed Sep 07 10:01:36 2011 +0300 @@ -331,6 +331,7 @@ static int imapc_sync_finish(struct imapc_sync_context **_ctx) { struct imapc_sync_context *ctx = *_ctx; + bool changes; int ret = ctx->failed ? -1 : 0; *_ctx = NULL; @@ -343,6 +344,12 @@ mail_index_sync_rollback(&ctx->index_sync_ctx); } ctx->mbox->syncing = FALSE; + + /* this is done simply to commit delayed expunges if there are any + (has to be done after sync is committed) */ + if (imapc_mailbox_commit_delayed_trans(ctx->mbox, &changes) < 0) + ctx->failed = TRUE; + i_free(ctx); return ret; } From dovecot at dovecot.org Wed Sep 7 10:28:25 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 10:28:25 +0300 Subject: dovecot-2.1: lib-ssl-iostream: When SSL i/ostream is closed, clo... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0e1a65d30964 changeset: 13415:0e1a65d30964 user: Timo Sirainen date: Wed Sep 07 10:24:11 2011 +0300 description: lib-ssl-iostream: When SSL i/ostream is closed, close also the plain stream. diffstat: src/lib-ssl-iostream/istream-openssl.c | 8 ++++++++ src/lib-ssl-iostream/ostream-openssl.c | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diffs (54 lines): diff -r 3ae5d7e0a4b4 -r 0e1a65d30964 src/lib-ssl-iostream/istream-openssl.c --- a/src/lib-ssl-iostream/istream-openssl.c Wed Sep 07 10:01:36 2011 +0300 +++ b/src/lib-ssl-iostream/istream-openssl.c Wed Sep 07 10:24:11 2011 +0300 @@ -10,6 +10,13 @@ bool seen_eof; }; +static void i_stream_ssl_close(struct iostream_private *stream) +{ + struct ssl_istream *sstream = (struct ssl_istream *)stream; + + i_stream_close(sstream->ssl_io->plain_input); +} + static void i_stream_ssl_destroy(struct iostream_private *stream) { struct ssl_istream *sstream = (struct ssl_istream *)stream; @@ -66,6 +73,7 @@ sstream = i_new(struct ssl_istream, 1); sstream->ssl_io = ssl_io; + sstream->istream.iostream.close = i_stream_ssl_close; sstream->istream.iostream.destroy = i_stream_ssl_destroy; sstream->istream.max_buffer_size = ssl_io->plain_input->real_stream->max_buffer_size; diff -r 3ae5d7e0a4b4 -r 0e1a65d30964 src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 10:01:36 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 10:24:11 2011 +0300 @@ -11,7 +11,14 @@ buffer_t *buffer; }; -static void i_stream_ssl_destroy(struct iostream_private *stream) +static void o_stream_ssl_close(struct iostream_private *stream) +{ + struct ssl_ostream *sstream = (struct ssl_ostream *)stream; + + o_stream_close(sstream->ssl_io->plain_output); +} + +static void o_stream_ssl_destroy(struct iostream_private *stream) { struct ssl_ostream *sstream = (struct ssl_ostream *)stream; @@ -198,7 +205,8 @@ sstream->ssl_io = ssl_io; sstream->ostream.max_buffer_size = ssl_io->plain_output->real_stream->max_buffer_size; - sstream->ostream.iostream.destroy = i_stream_ssl_destroy; + sstream->ostream.iostream.close = o_stream_ssl_close; + sstream->ostream.iostream.destroy = o_stream_ssl_destroy; sstream->ostream.sendv = o_stream_ssl_sendv; sstream->ostream.flush = o_stream_ssl_flush; From dovecot at dovecot.org Wed Sep 7 10:38:15 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 10:38:15 +0300 Subject: dovecot-2.1: imapc: Connect to server immediately at startup and... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e5570ee5d695 changeset: 13416:e5570ee5d695 user: Timo Sirainen date: Wed Sep 07 10:38:01 2011 +0300 description: imapc: Connect to server immediately at startup and lookup hierarchy separator. If connecting to server fails, this makes it fail earlier. Also we don't have to worry about what to do later if hierarchy separator lookup fails. diffstat: src/lib-storage/index/imapc/imapc-list.c | 14 ++------------ src/lib-storage/index/imapc/imapc-list.h | 3 --- src/lib-storage/index/imapc/imapc-storage.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 15 deletions(-) diffs (85 lines): diff -r 0e1a65d30964 -r e5570ee5d695 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Wed Sep 07 10:24:11 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Wed Sep 07 10:38:01 2011 +0300 @@ -165,20 +165,10 @@ static char imapc_list_get_hierarchy_sep(struct mailbox_list *_list) { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; - struct imapc_simple_context ctx; - if (list->sep == '\0') { - imapc_simple_context_init(&ctx, list->storage); - imapc_client_cmdf(list->storage->client, - imapc_list_simple_callback, &ctx, - "LIST \"\" \"\""); - imapc_simple_run(&ctx); + /* storage should have looked this up when it was created */ + i_assert(list->sep != '\0'); - if (ctx.ret < 0) { - list->broken = TRUE; - return '/'; - } - } return list->sep; } diff -r 0e1a65d30964 -r e5570ee5d695 src/lib-storage/index/imapc/imapc-list.h --- a/src/lib-storage/index/imapc/imapc-list.h Wed Sep 07 10:24:11 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.h Wed Sep 07 10:38:01 2011 +0300 @@ -17,9 +17,6 @@ unsigned int iter_count; - /* we've returned wrong separator. all mailbox list operations must - fail from now on. */ - unsigned int broken:1; unsigned int refreshed_subscriptions:1; unsigned int refreshed_mailboxes:1; unsigned int index_list_failed:1; diff -r 0e1a65d30964 -r e5570ee5d695 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 07 10:24:11 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 07 10:38:01 2011 +0300 @@ -203,6 +203,30 @@ } static int +imapc_storage_get_hierarchy_sep(struct imapc_storage *storage, + const char **error_r) +{ + struct imapc_simple_context sctx; + + imapc_simple_context_init(&sctx, storage); + imapc_client_cmdf(storage->client, imapc_simple_callback, &sctx, + "LIST \"\" \"\""); + imapc_simple_run(&sctx); + + if (sctx.ret < 0) { + *error_r = t_strdup_printf("LIST failed: %s", + mail_storage_get_last_error(&storage->storage, NULL)); + return -1; + } + + if (storage->list->sep == '\0') { + *error_r = "LIST didn't return hierarchy separator"; + return -1; + } + return sctx.ret; +} + +static int imapc_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, const char **error_r) @@ -253,6 +277,11 @@ imapc_list_register_callbacks(storage->list); imapc_storage_register_untagged(storage, "STATUS", imapc_untagged_status); + /* connect to imap server and get the hierarchy separator. */ + if (imapc_storage_get_hierarchy_sep(storage, error_r) < 0) { + imapc_client_deinit(&storage->client); + return -1; + } return 0; } From dovecot at dovecot.org Wed Sep 7 11:00:58 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 11:00:58 +0300 Subject: dovecot-2.1: Added o_stream_switch_ioloop() and implemented it t... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/977dcd541f69 changeset: 13417:977dcd541f69 user: Timo Sirainen date: Wed Sep 07 10:59:35 2011 +0300 description: Added o_stream_switch_ioloop() and implemented it to all ostreams. diffstat: src/lib-ssl-iostream/ostream-openssl.c | 8 ++++++++ src/lib/ostream-file.c | 9 +++++++++ src/lib/ostream-internal.h | 1 + src/lib/ostream.c | 8 ++++++++ src/lib/ostream.h | 4 ++++ src/plugins/zlib/ostream-bzlib.c | 8 ++++++++ src/plugins/zlib/ostream-zlib.c | 8 ++++++++ 7 files changed, 46 insertions(+), 0 deletions(-) diffs (139 lines): diff -r e5570ee5d695 -r 977dcd541f69 src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 10:38:01 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 10:59:35 2011 +0300 @@ -180,6 +180,13 @@ return bytes_sent != 0 ? (ssize_t)bytes_sent : ret; } +static void o_stream_ssl_switch_ioloop(struct ostream_private *stream) +{ + struct ssl_ostream *sstream = (struct ssl_ostream *)stream; + + o_stream_switch_ioloop(sstream->ssl_io->plain_output); +} + static int plain_flush_callback(struct ssl_ostream *sstream) { int ret, ret2; @@ -209,6 +216,7 @@ sstream->ostream.iostream.destroy = o_stream_ssl_destroy; sstream->ostream.sendv = o_stream_ssl_sendv; sstream->ostream.flush = o_stream_ssl_flush; + sstream->ostream.switch_ioloop = o_stream_ssl_switch_ioloop; o_stream_set_flush_callback(ssl_io->plain_output, plain_flush_callback, sstream); diff -r e5570ee5d695 -r 977dcd541f69 src/lib/ostream-file.c --- a/src/lib/ostream-file.c Wed Sep 07 10:38:01 2011 +0300 +++ b/src/lib/ostream-file.c Wed Sep 07 10:59:35 2011 +0300 @@ -870,6 +870,14 @@ return io_stream_copy_stream(outstream, instream, same_stream); } +static void o_stream_file_switch_ioloop(struct ostream_private *stream) +{ + struct file_ostream *fstream = (struct file_ostream *)stream; + + if (fstream->io != NULL) + fstream->io = io_loop_move_io(&fstream->io); +} + static struct file_ostream * o_stream_create_fd_common(int fd, bool autoclose_fd) { @@ -891,6 +899,7 @@ fstream->ostream.sendv = o_stream_file_sendv; fstream->ostream.write_at = o_stream_file_write_at; fstream->ostream.send_istream = o_stream_file_send_istream; + fstream->ostream.switch_ioloop = o_stream_file_switch_ioloop; return fstream; } diff -r e5570ee5d695 -r 977dcd541f69 src/lib/ostream-internal.h --- a/src/lib/ostream-internal.h Wed Sep 07 10:38:01 2011 +0300 +++ b/src/lib/ostream-internal.h Wed Sep 07 10:59:35 2011 +0300 @@ -21,6 +21,7 @@ const void *data, size_t size, uoff_t offset); off_t (*send_istream)(struct ostream_private *outstream, struct istream *instream); + void (*switch_ioloop)(struct ostream_private *stream); /* data: */ struct ostream ostream; diff -r e5570ee5d695 -r 977dcd541f69 src/lib/ostream.c --- a/src/lib/ostream.c Wed Sep 07 10:38:01 2011 +0300 +++ b/src/lib/ostream.c Wed Sep 07 10:59:35 2011 +0300 @@ -292,3 +292,11 @@ return (off_t)(instream->v_offset - start_offset); } + +void o_stream_switch_ioloop(struct ostream *stream) +{ + struct ostream_private *_stream = stream->real_stream; + + if (_stream->switch_ioloop != NULL) + _stream->switch_ioloop(_stream); +} diff -r e5570ee5d695 -r 977dcd541f69 src/lib/ostream.h --- a/src/lib/ostream.h Wed Sep 07 10:38:01 2011 +0300 +++ b/src/lib/ostream.h Wed Sep 07 10:59:35 2011 +0300 @@ -106,4 +106,8 @@ int o_stream_pwrite(struct ostream *stream, const void *data, size_t size, uoff_t offset); +/* If there are any I/O loop items associated with the stream, move all of + them to current_ioloop. */ +void o_stream_switch_ioloop(struct ostream *stream); + #endif diff -r e5570ee5d695 -r 977dcd541f69 src/plugins/zlib/ostream-bzlib.c --- a/src/plugins/zlib/ostream-bzlib.c Wed Sep 07 10:38:01 2011 +0300 +++ b/src/plugins/zlib/ostream-bzlib.c Wed Sep 07 10:59:35 2011 +0300 @@ -146,6 +146,13 @@ return ret; } +static void o_stream_bzlib_switch_ioloop(struct ostream_private *stream) +{ + struct bzlib_ostream *zstream = (struct bzlib_ostream *)stream; + + o_stream_switch_ioloop(zstream->output); +} + static ssize_t o_stream_bzlib_sendv(struct ostream_private *stream, const struct const_iovec *iov, unsigned int iov_count) @@ -176,6 +183,7 @@ zstream->ostream.sendv = o_stream_bzlib_sendv; zstream->ostream.cork = o_stream_bzlib_cork; zstream->ostream.flush = o_stream_bzlib_flush; + zstream->ostream.switch_ioloop = o_stream_bzlib_switch_ioloop; zstream->ostream.iostream.close = o_stream_bzlib_close; zstream->output = output; o_stream_ref(output); diff -r e5570ee5d695 -r 977dcd541f69 src/plugins/zlib/ostream-zlib.c --- a/src/plugins/zlib/ostream-zlib.c Wed Sep 07 10:38:01 2011 +0300 +++ b/src/plugins/zlib/ostream-zlib.c Wed Sep 07 10:59:35 2011 +0300 @@ -209,6 +209,13 @@ return ret; } +static void o_stream_zlib_switch_ioloop(struct ostream_private *stream) +{ + struct zlib_ostream *zstream = (struct zlib_ostream *)stream; + + o_stream_switch_ioloop(zstream->output); +} + static ssize_t o_stream_zlib_sendv(struct ostream_private *stream, const struct const_iovec *iov, unsigned int iov_count) @@ -260,6 +267,7 @@ zstream->ostream.sendv = o_stream_zlib_sendv; zstream->ostream.cork = o_stream_zlib_cork; zstream->ostream.flush = o_stream_zlib_flush; + zstream->ostream.switch_ioloop = o_stream_zlib_switch_ioloop; zstream->ostream.iostream.close = o_stream_zlib_close; zstream->output = output; zstream->crc = 0; From dovecot at dovecot.org Wed Sep 7 11:03:05 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 11:03:05 +0300 Subject: dovecot-2.1: lib-ssl-iostream: When plain_output's buffer is ful... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d96c03d7eeef changeset: 13418:d96c03d7eeef user: Timo Sirainen date: Wed Sep 07 11:02:55 2011 +0300 description: lib-ssl-iostream: When plain_output's buffer is full, set it flush-pending. This fixes hangs when the output buffer got full. diffstat: src/lib-ssl-iostream/iostream-openssl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 977dcd541f69 -r d96c03d7eeef src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Wed Sep 07 10:59:35 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Wed Sep 07 11:02:55 2011 +0300 @@ -268,6 +268,8 @@ if (bytes > max_bytes) { if (max_bytes == 0) { /* wait until output buffer clears */ + o_stream_set_flush_pending(ssl_io->plain_output, + TRUE); break; } bytes = max_bytes; From dovecot at dovecot.org Wed Sep 7 11:03:42 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 11:03:42 +0300 Subject: dovecot-2.1: imapc: Switch connection output streams' ioloop whe... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/31471ce338ab changeset: 13419:31471ce338ab user: Timo Sirainen date: Wed Sep 07 11:03:33 2011 +0300 description: imapc: Switch connection output streams' ioloop when needed. This fixes hangs when output stream got full. diffstat: src/lib-storage/index/imapc/imapc-connection.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r d96c03d7eeef -r 31471ce338ab src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 07 11:02:55 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 07 11:03:33 2011 +0300 @@ -148,6 +148,8 @@ conn->io = io_loop_move_io(&conn->io); if (conn->to != NULL) conn->to = io_loop_move_timeout(&conn->to); + if (conn->output != NULL) + o_stream_switch_ioloop(conn->output); } static const char *imapc_command_get_readable(struct imapc_command *cmd) From dovecot at dovecot.org Wed Sep 7 11:19:20 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 11:19:20 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Handle flush_pending and set_max_... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4b707b98176e changeset: 13421:4b707b98176e user: Timo Sirainen date: Wed Sep 07 11:19:03 2011 +0300 description: lib-ssl-iostream: Handle flush_pending and set_max_buffer_size properly. diffstat: src/lib-ssl-iostream/ostream-openssl.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diffs (38 lines): diff -r de7f3810589a -r 4b707b98176e src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 11:18:15 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 11:19:03 2011 +0300 @@ -210,6 +210,23 @@ return ret > 0 && ret2 > 0 ? 1 : 0; } +static void +o_stream_ssl_flush_pending(struct ostream_private *_stream, bool set) +{ + struct ssl_ostream *sstream = (struct ssl_ostream *)_stream; + + o_stream_set_flush_pending(sstream->ssl_io->plain_output, set); +} + +static void o_stream_ssl_set_max_buffer_size(struct iostream_private *_stream, + size_t max_size) +{ + struct ssl_ostream *sstream = (struct ssl_ostream *)_stream; + + sstream->ostream.max_buffer_size = max_size; + o_stream_set_max_buffer_size(sstream->ssl_io->plain_output, max_size); +} + struct ostream *o_stream_create_ssl(struct ssl_iostream *ssl_io) { struct ssl_ostream *sstream; @@ -226,6 +243,10 @@ sstream->ostream.flush = o_stream_ssl_flush; sstream->ostream.switch_ioloop = o_stream_ssl_switch_ioloop; + sstream->ostream.flush_pending = o_stream_ssl_flush_pending; + sstream->ostream.iostream.set_max_buffer_size = + o_stream_ssl_set_max_buffer_size; + sstream->ostream.callback = ssl_io->plain_output->real_stream->callback; sstream->ostream.context = ssl_io->plain_output->real_stream->context; o_stream_set_flush_callback(ssl_io->plain_output, From dovecot at dovecot.org Wed Sep 7 11:19:20 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 11:19:20 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Fixed ostream to preserve/use flu... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/de7f3810589a changeset: 13420:de7f3810589a user: Timo Sirainen date: Wed Sep 07 11:18:15 2011 +0300 description: lib-ssl-iostream: Fixed ostream to preserve/use flush callback correctly. diffstat: src/lib-ssl-iostream/ostream-openssl.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diffs (36 lines): diff -r 31471ce338ab -r de7f3810589a src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 11:03:33 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 07 11:18:15 2011 +0300 @@ -189,6 +189,7 @@ static int plain_flush_callback(struct ssl_ostream *sstream) { + struct ostream *ostream = &sstream->ostream.ostream; int ret, ret2; /* try to actually flush the pending data */ @@ -196,7 +197,14 @@ return -1; /* we may be able to copy more data, try it */ - ret2 = o_stream_flush(&sstream->ostream.ostream); + o_stream_ref(ostream); + if (sstream->ostream.callback != NULL) + ret2 = sstream->ostream.callback(sstream->ostream.context); + else + ret2 = o_stream_flush(&sstream->ostream.ostream); + if (ret2 == 0) + o_stream_set_flush_pending(sstream->ssl_io->plain_output, TRUE); + o_stream_unref(&ostream); if (ret2 < 0) return -1; return ret > 0 && ret2 > 0 ? 1 : 0; @@ -218,6 +226,8 @@ sstream->ostream.flush = o_stream_ssl_flush; sstream->ostream.switch_ioloop = o_stream_ssl_switch_ioloop; + sstream->ostream.callback = ssl_io->plain_output->real_stream->callback; + sstream->ostream.context = ssl_io->plain_output->real_stream->context; o_stream_set_flush_callback(ssl_io->plain_output, plain_flush_callback, sstream); From dovecot at dovecot.org Wed Sep 7 11:30:15 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 11:30:15 +0300 Subject: dovecot-2.1: lib-index: Don't allow syncing to begin if index is... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9815d3292470 changeset: 13422:9815d3292470 user: Timo Sirainen date: Wed Sep 07 11:30:05 2011 +0300 description: lib-index: Don't allow syncing to begin if index is marked corrupted. diffstat: src/lib-index/mail-index-sync.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (16 lines): diff -r 4b707b98176e -r 9815d3292470 src/lib-index/mail-index-sync.c --- a/src/lib-index/mail-index-sync.c Wed Sep 07 11:19:03 2011 +0300 +++ b/src/lib-index/mail-index-sync.c Wed Sep 07 11:30:05 2011 +0300 @@ -434,6 +434,12 @@ i_assert(!index->syncing); + if (index->map != NULL && + (index->map->hdr.flags & MAIL_INDEX_HDR_FLAG_CORRUPTED) != 0) { + /* index is corrupted and need to be reopened */ + return -1; + } + if (log_file_seq != (uint32_t)-1) flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES; From dovecot at dovecot.org Wed Sep 7 11:52:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 11:52:18 +0300 Subject: dovecot-2.1: imapc: Place index files under root_dir/indexes/ di... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c943580d3a1b changeset: 13423:c943580d3a1b user: Timo Sirainen date: Wed Sep 07 11:52:08 2011 +0300 description: imapc: Place index files under root_dir/indexes/ directory. diffstat: src/lib-storage/index/imapc/imapc-list.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 9815d3292470 -r c943580d3a1b src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Wed Sep 07 11:30:05 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Wed Sep 07 11:52:08 2011 +0300 @@ -189,8 +189,8 @@ /* the root dir shouldn't actually ever be used. we just need it to be different from index_dir so the index directories get autocreated */ - list_set.root_dir = t_strconcat(dir, "/", NULL); - list_set.index_dir = dir; + list_set.root_dir = dir; + list_set.index_dir = t_strconcat(dir, "/indexes", NULL); list_set.escape_char = '%'; if (mailbox_list_create(list_set.layout, list->list.ns, From dovecot at dovecot.org Wed Sep 7 15:46:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 15:46:55 +0300 Subject: dovecot-2.1: imapc: Fixed assert-crashing when deleting a mailbox Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f7de547a54d5 changeset: 13424:f7de547a54d5 user: Timo Sirainen date: Wed Sep 07 15:46:43 2011 +0300 description: imapc: Fixed assert-crashing when deleting a mailbox diffstat: src/lib-storage/index/imapc/imapc-sync.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r c943580d3a1b -r f7de547a54d5 src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Wed Sep 07 11:52:08 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Wed Sep 07 15:46:43 2011 +0300 @@ -318,7 +318,8 @@ mbox->min_append_uid = mail_index_get_header(ctx->sync_view)->next_uid; mbox->syncing = TRUE; - imapc_sync_index(ctx); + if (!mbox->box.deleting) + imapc_sync_index(ctx); mail_index_view_close(&mbox->delayed_sync_view); mbox->delayed_sync_trans = NULL; From dovecot at dovecot.org Wed Sep 7 16:10:25 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 16:10:25 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Some tweaks to BIO handling. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9380133c8531 changeset: 13425:9380133c8531 user: Timo Sirainen date: Wed Sep 07 16:10:16 2011 +0300 description: lib-ssl-iostream: Some tweaks to BIO handling. diffstat: src/lib-ssl-iostream/iostream-openssl.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) diffs (52 lines): diff -r f7de547a54d5 -r 9380133c8531 src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Wed Sep 07 15:46:43 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Wed Sep 07 16:10:16 2011 +0300 @@ -322,6 +322,17 @@ i_stream_skip(ssl_io->plain_input, size); bytes_read = TRUE; } + if (bytes == 0 && !bytes_read && ssl_io->want_read) { + /* shouldn't happen */ + i_panic("SSL BIO buffer size too small"); + } + if (bytes_read) { + if (ssl_io->ostream_flush_waiting_input) { + ssl_io->ostream_flush_waiting_input = FALSE; + o_stream_set_flush_pending(ssl_io->plain_output, TRUE); + } + ssl_io->want_read = FALSE; + } return bytes_read; } @@ -330,14 +341,8 @@ bool ret; ret = ssl_iostream_bio_output(ssl_io); - if (ssl_iostream_bio_input(ssl_io)) { - if (ssl_io->ostream_flush_waiting_input) { - ssl_io->ostream_flush_waiting_input = FALSE; - o_stream_set_flush_pending(ssl_io->plain_output, TRUE); - } - ssl_io->want_read = FALSE; + if (ssl_iostream_bio_input(ssl_io)) ret = TRUE; - } return ret; } @@ -374,11 +379,9 @@ } return 1; case SSL_ERROR_WANT_READ: - if (!ssl_iostream_bio_sync(ssl_io)) { - ssl_io->want_read = TRUE; - return 0; - } - return 1; + ssl_io->want_read = TRUE; + (void)ssl_iostream_bio_sync(ssl_io); + return ssl_io->want_read ? 0 : 1; case SSL_ERROR_SYSCALL: /* eat up the error queue */ if (ERR_peek_error() != 0) { From dovecot at dovecot.org Wed Sep 7 16:44:28 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 16:44:28 +0300 Subject: dovecot-2.1: auth: Don't crash when using default static userdb. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fdca1c2cce01 changeset: 13426:fdca1c2cce01 user: Timo Sirainen date: Wed Sep 07 16:44:14 2011 +0300 description: auth: Don't crash when using default static userdb. diffstat: src/auth/auth.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (14 lines): diff -r 9380133c8531 -r fdca1c2cce01 src/auth/auth.c --- a/src/auth/auth.c Wed Sep 07 16:10:16 2011 +0300 +++ b/src/auth/auth.c Wed Sep 07 16:44:14 2011 +0300 @@ -11,7 +11,9 @@ struct auth_userdb_settings userdb_dummy_set = { .driver = "static", - .args = "" + .args = "", + .default_fields = "", + .override_fields = "" }; static ARRAY_DEFINE(auths, struct auth *); From dovecot at dovecot.org Wed Sep 7 17:15:21 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Sep 2011 17:15:21 +0300 Subject: dovecot-2.1: imapc: When closing mailbox, don't abort any pendin... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d3335654e9a7 changeset: 13427:d3335654e9a7 user: Timo Sirainen date: Wed Sep 07 17:15:10 2011 +0300 description: imapc: When closing mailbox, don't abort any pending non-mailbox commands. diffstat: src/lib-storage/index/imapc/imapc-client.c | 7 +- src/lib-storage/index/imapc/imapc-connection.c | 72 +++++++++++++++---------- src/lib-storage/index/imapc/imapc-connection.h | 11 ++- 3 files changed, 52 insertions(+), 38 deletions(-) diffs (242 lines): diff -r fdca1c2cce01 -r d3335654e9a7 src/lib-storage/index/imapc/imapc-client.c --- a/src/lib-storage/index/imapc/imapc-client.c Wed Sep 07 16:44:14 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.c Wed Sep 07 17:15:10 2011 +0300 @@ -185,7 +185,7 @@ conn = imapc_client_find_connection(client); va_start(args, cmd_fmt); - imapc_connection_cmdvf(conn, callback, context, cmd_fmt, args); + imapc_connection_cmdvf(conn, FALSE, callback, context, cmd_fmt, args); va_end(args); } @@ -317,7 +317,8 @@ } ctx = imapc_client_mailbox_cmd_common(box, callback, context); - imapc_connection_cmd(box->conn, cmd, imapc_client_mailbox_cmd_cb, ctx); + imapc_connection_cmd(box->conn, TRUE, cmd, + imapc_client_mailbox_cmd_cb, ctx); } void imapc_client_mailbox_cmdf(struct imapc_client_mailbox *box, @@ -335,7 +336,7 @@ ctx = imapc_client_mailbox_cmd_common(box, callback, context); va_start(args, cmd_fmt); - imapc_connection_cmdvf(box->conn, imapc_client_mailbox_cmd_cb, + imapc_connection_cmdvf(box->conn, TRUE, imapc_client_mailbox_cmd_cb, ctx, cmd_fmt, args); va_end(args); } diff -r fdca1c2cce01 -r d3335654e9a7 src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 07 16:44:14 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 07 17:15:10 2011 +0300 @@ -50,6 +50,7 @@ void *context; unsigned int idle:1; + unsigned int mailboxcmd:1; }; struct imapc_connection_literal { @@ -613,18 +614,18 @@ need_literal(set->username) && need_literal(set->password)) || (conn->capabilities & IMAPC_CAPABILITY_AUTH_PLAIN) == 0) { /* We can use LOGIN command */ - imapc_connection_cmdf(conn, imapc_connection_login_cb, conn, - "LOGIN %s %s", + imapc_connection_cmdf(conn, FALSE, imapc_connection_login_cb, + conn, "LOGIN %s %s", set->username, set->password); } else if ((conn->capabilities & IMAPC_CAPABILITY_SASL_IR) != 0) { cmd = t_strdup_printf("AUTHENTICATE PLAIN %s", imapc_connection_get_sasl_plain_request(conn)); - imapc_connection_cmd(conn, cmd, + imapc_connection_cmd(conn, FALSE, cmd, imapc_connection_login_cb, conn); } else { cmd = t_strdup_printf("AUTHENTICATE PLAIN\r\n%s", imapc_connection_get_sasl_plain_request(conn)); - imapc_connection_cmd(conn, cmd, + imapc_connection_cmd(conn, FALSE, cmd, imapc_connection_login_cb, conn); } } @@ -658,7 +659,7 @@ imapc_connection_disconnect(conn); return; } - imapc_connection_cmd(conn, "STARTTLS", + imapc_connection_cmd(conn, FALSE, "STARTTLS", imapc_connection_starttls_cb, conn); return; } @@ -698,7 +699,7 @@ if (conn->capabilities == 0) { /* capabilities weren't sent in the banner. ask for them. */ - imapc_connection_cmd(conn, "CAPABILITY", + imapc_connection_cmd(conn, FALSE, "CAPABILITY", imapc_connection_capability_cb, conn); } else { imapc_connection_starttls(conn); @@ -1293,7 +1294,7 @@ static void imapc_command_send_more(struct imapc_connection *conn, struct imapc_command *cmd) { - const unsigned char *p; + const unsigned char *p, *data; unsigned int seek_pos, start_pos, end_pos, size; int ret; @@ -1324,9 +1325,9 @@ p[-1] == '\r' && p[-2] == '}' && p[-3] == '+'); end_pos = seek_pos; - o_stream_send(conn->output, - CONST_PTR_OFFSET(cmd->data->data, cmd->send_pos), - end_pos - cmd->send_pos); + data = CONST_PTR_OFFSET(cmd->data->data, cmd->send_pos); + size = end_pos - cmd->send_pos; + o_stream_send(conn->output, data, size); cmd->send_pos = end_pos; if (cmd->send_pos == cmd->data->used) { @@ -1422,27 +1423,30 @@ return cmd; } -void imapc_connection_cmd(struct imapc_connection *conn, const char *cmdline, +void imapc_connection_cmd(struct imapc_connection *conn, bool mailboxcmd, + const char *cmdline, imapc_command_callback_t *callback, void *context) { struct imapc_command *cmd; cmd = imapc_connection_cmd_build(cmdline, callback, context); + cmd->mailboxcmd = mailboxcmd; imapc_command_send(conn, cmd); } -void imapc_connection_cmdf(struct imapc_connection *conn, +void imapc_connection_cmdf(struct imapc_connection *conn, bool mailboxcmd, imapc_command_callback_t *callback, void *context, const char *cmd_fmt, ...) { va_list args; va_start(args, cmd_fmt); - imapc_connection_cmdvf(conn, callback, context, cmd_fmt, args); + imapc_connection_cmdvf(conn, mailboxcmd, callback, context, + cmd_fmt, args); va_end(args); } -void imapc_connection_cmdvf(struct imapc_connection *conn, +void imapc_connection_cmdvf(struct imapc_connection *conn, bool mailboxcmd, imapc_command_callback_t *callback, void *context, const char *cmd_fmt, va_list args) { @@ -1450,6 +1454,7 @@ unsigned int i; cmd = imapc_command_begin(callback, context); + cmd->mailboxcmd = mailboxcmd; cmd->data = str_new(cmd->pool, 128); str_printfa(cmd->data, "%u ", cmd->tag); @@ -1546,14 +1551,16 @@ conn->selected_box = box; } - imapc_connection_cmdf(conn, callback, context, + imapc_connection_cmdf(conn, FALSE, callback, context, examine ? "EXAMINE %s" : "SELECT %s", name); } void imapc_connection_unselect(struct imapc_client_mailbox *box) { - struct imapc_command *const *cmdp; + struct imapc_connection *conn = box->conn; + struct imapc_command *const *cmdp, *cmd; struct imapc_command_reply reply; + unsigned int i; /* mailbox is being closed. if there are any pending commands, we must finish them immediately so callbacks don't access any freed @@ -1562,30 +1569,35 @@ reply.state = IMAPC_COMMAND_STATE_DISCONNECTED; reply.text_without_resp = reply.text_full = "Closing mailbox"; - imapc_connection_send_idle_done(box->conn); + imapc_connection_send_idle_done(conn); - array_foreach(&box->conn->cmd_wait_list, cmdp) { - if ((*cmdp)->callback != NULL) { + array_foreach(&conn->cmd_wait_list, cmdp) { + if ((*cmdp)->callback != NULL && (*cmdp)->mailboxcmd) { (*cmdp)->callback(&reply, (*cmdp)->context); (*cmdp)->callback = NULL; } } - array_foreach(&box->conn->cmd_send_queue, cmdp) { - if ((*cmdp)->callback != NULL) { - (*cmdp)->callback(&reply, (*cmdp)->context); - (*cmdp)->callback = NULL; + for (i = 0; i < array_count(&conn->cmd_send_queue); ) { + cmdp = array_idx(&conn->cmd_send_queue, i); + cmd = *cmdp; + if (!cmd->mailboxcmd) + i++; + else { + array_delete(&conn->cmd_send_queue, i, 1); + if (cmd->callback != NULL) + cmd->callback(&reply, cmd->context); + imapc_command_free(cmd); } } - if (box->conn->selected_box == NULL && - box->conn->selecting_box == NULL) { - i_assert(box->conn->state == IMAPC_CONNECTION_STATE_DISCONNECTED); + if (conn->selected_box == NULL && conn->selecting_box == NULL) { + i_assert(conn->state == IMAPC_CONNECTION_STATE_DISCONNECTED); } else { - i_assert(box->conn->selected_box == box || - box->conn->selecting_box == box); + i_assert(conn->selected_box == box || + conn->selecting_box == box); - box->conn->selected_box = NULL; - box->conn->selecting_box = NULL; + conn->selected_box = NULL; + conn->selecting_box = NULL; } } diff -r fdca1c2cce01 -r d3335654e9a7 src/lib-storage/index/imapc/imapc-connection.h --- a/src/lib-storage/index/imapc/imapc-connection.h Wed Sep 07 16:44:14 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.h Wed Sep 07 17:15:10 2011 +0300 @@ -26,15 +26,16 @@ void imapc_connection_ioloop_changed(struct imapc_connection *conn); void imapc_connection_input_pending(struct imapc_connection *conn); -void imapc_connection_cmd(struct imapc_connection *conn, const char *cmdline, +void imapc_connection_cmd(struct imapc_connection *conn, bool mailboxcmd, + const char *cmdline, imapc_command_callback_t *callback, void *context); -void imapc_connection_cmdf(struct imapc_connection *conn, +void imapc_connection_cmdf(struct imapc_connection *conn, bool mailboxcmd, imapc_command_callback_t *callback, void *context, - const char *cmd_fmt, ...) ATTR_FORMAT(4, 5); -void imapc_connection_cmdvf(struct imapc_connection *conn, + const char *cmd_fmt, ...) ATTR_FORMAT(5, 6); +void imapc_connection_cmdvf(struct imapc_connection *conn, bool mailboxcmd, imapc_command_callback_t *callback, void *context, const char *cmd_fmt, va_list args) - ATTR_FORMAT(4, 0); + ATTR_FORMAT(5, 0); void imapc_connection_select(struct imapc_client_mailbox *box, const char *name, bool examine, imapc_command_callback_t *callback, void *context); From dovecot at dovecot.org Thu Sep 8 11:16:38 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:16:38 +0300 Subject: dovecot-2.1: lib-index: Make sure mail_index_sync_record() doesn... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ad9b826df5a2 changeset: 13428:ad9b826df5a2 user: Timo Sirainen date: Thu Sep 01 19:33:22 2011 +0300 description: lib-index: Make sure mail_index_sync_record() doesn't waste data stack. diffstat: src/lib-index/mail-index-sync-update.c | 24 +++++++++++++++++------- src/lib-index/mail-index-view-sync.c | 6 ++---- 2 files changed, 19 insertions(+), 11 deletions(-) diffs (64 lines): diff -r d3335654e9a7 -r ad9b826df5a2 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Wed Sep 07 17:15:10 2011 +0300 +++ b/src/lib-index/mail-index-sync-update.c Thu Sep 01 19:33:22 2011 +0300 @@ -518,9 +518,10 @@ return 1; } -int mail_index_sync_record(struct mail_index_sync_map_ctx *ctx, - const struct mail_transaction_header *hdr, - const void *data) +static int +mail_index_sync_record_real(struct mail_index_sync_map_ctx *ctx, + const struct mail_transaction_header *hdr, + const void *data) { int ret = 0; @@ -813,6 +814,18 @@ return ret; } +int mail_index_sync_record(struct mail_index_sync_map_ctx *ctx, + const struct mail_transaction_header *hdr, + const void *data) +{ + int ret; + + T_BEGIN { + ret = mail_index_sync_record_real(ctx, hdr, data); + } T_END; + return ret; +} + void mail_index_sync_map_init(struct mail_index_sync_map_ctx *sync_map_ctx, struct mail_index_view *view, enum mail_index_sync_handler_type type) @@ -1020,10 +1033,7 @@ } /* we'll just skip over broken entries */ - T_BEGIN { - (void)mail_index_sync_record(&sync_map_ctx, - thdr, tdata); - } T_END; + (void)mail_index_sync_record(&sync_map_ctx, thdr, tdata); } map = view->map; diff -r d3335654e9a7 -r ad9b826df5a2 src/lib-index/mail-index-view-sync.c --- a/src/lib-index/mail-index-view-sync.c Wed Sep 07 17:15:10 2011 +0300 +++ b/src/lib-index/mail-index-view-sync.c Thu Sep 01 19:33:22 2011 +0300 @@ -736,10 +736,8 @@ if (ctx->sync_map_update && !synced_to_map) { if ((hdr->type & (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_GUID)) == 0) { - T_BEGIN { - ret = mail_index_sync_record(&ctx->sync_map_ctx, - hdr, ctx->data); - } T_END; + ret = mail_index_sync_record(&ctx->sync_map_ctx, + hdr, ctx->data); } if (ret < 0) return -1; From dovecot at dovecot.org Thu Sep 8 11:17:16 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:17:16 +0300 Subject: dovecot-2.0: lib-storage: Minor error handling cleanups. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1903d5fd7e76 changeset: 12899:1903d5fd7e76 user: Timo Sirainen date: Thu Sep 08 11:16:55 2011 +0300 description: lib-storage: Minor error handling cleanups. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 3 +-- src/lib-storage/index/dbox-single/sdbox-storage.c | 3 +-- src/lib-storage/index/index-storage.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diffs (38 lines): diff -r 1a6528646e11 -r 1903d5fd7e76 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -202,8 +202,7 @@ ret = mail_index_sync_begin(box->index, &sync_ctx, &view, &trans, 0); if (ret <= 0) { i_assert(ret != 0); - mail_storage_set_internal_error(box->storage); - mail_index_reset_error(box->index); + mail_storage_set_index_error(box); return -1; } diff -r 1a6528646e11 -r 1903d5fd7e76 src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -180,8 +180,7 @@ sdbox_update_header(mbox, trans, update); if (new_trans != NULL) { if (mail_index_transaction_commit(&new_trans) < 0) { - mail_storage_set_internal_error(box->storage); - mail_index_reset_error(box->index); + mail_storage_set_index_error(box); return -1; } } diff -r 1a6528646e11 -r 1903d5fd7e76 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/index-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -404,7 +404,7 @@ } if ((ret = mail_index_transaction_commit(&trans)) < 0) - mail_storage_set_internal_error(box->storage); + mail_storage_set_index_error(box); mail_index_view_close(&view); return ret; } From dovecot at dovecot.org Thu Sep 8 11:17:25 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:17:25 +0300 Subject: dovecot-2.1: lib-storage: Minor error handling cleanups. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/bba92468b051 changeset: 13429:bba92468b051 user: Timo Sirainen date: Thu Sep 08 11:16:55 2011 +0300 description: lib-storage: Minor error handling cleanups. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 3 +-- src/lib-storage/index/dbox-single/sdbox-storage.c | 3 +-- src/lib-storage/index/index-storage.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diffs (38 lines): diff -r ad9b826df5a2 -r bba92468b051 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -267,8 +267,7 @@ ret = mail_index_sync_begin(box->index, &sync_ctx, &view, &trans, 0); if (ret <= 0) { i_assert(ret != 0); - mail_storage_set_internal_error(box->storage); - mail_index_reset_error(box->index); + mail_storage_set_index_error(box); return -1; } diff -r ad9b826df5a2 -r bba92468b051 src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -171,8 +171,7 @@ sdbox_update_header(mbox, trans, update); if (new_trans != NULL) { if (mail_index_transaction_commit(&new_trans) < 0) { - mail_storage_set_internal_error(box->storage); - mail_index_reset_error(box->index); + mail_storage_set_index_error(box); return -1; } } diff -r ad9b826df5a2 -r bba92468b051 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/index-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -462,7 +462,7 @@ } if ((ret = mail_index_transaction_commit(&trans)) < 0) - mail_storage_set_internal_error(box->storage); + mail_storage_set_index_error(box); mail_index_view_close(&view); return ret; } From dovecot at dovecot.org Thu Sep 8 11:39:12 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:39:12 +0300 Subject: dovecot-2.1: lib-storage: Code cleanup to mail_storage_set_criti... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/84bce2c8626f changeset: 13430:84bce2c8626f user: Timo Sirainen date: Thu Sep 08 11:39:00 2011 +0300 description: lib-storage: Code cleanup to mail_storage_set_critical() diffstat: src/lib-storage/mail-storage.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-) diffs (28 lines): diff -r bba92468b051 -r 84bce2c8626f src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Sep 08 11:16:55 2011 +0300 +++ b/src/lib-storage/mail-storage.c Thu Sep 08 11:39:00 2011 +0300 @@ -448,17 +448,14 @@ { va_list va; - mail_storage_clear_error(storage); - if (fmt != NULL) { - va_start(va, fmt); - i_error("%s", t_strdup_vprintf(fmt, va)); - va_end(va); + va_start(va, fmt); + i_error("%s", t_strdup_vprintf(fmt, va)); + va_end(va); - /* critical errors may contain sensitive data, so let user - see only "Internal error" with a timestamp to make it - easier to look from log files the actual error message. */ - mail_storage_set_internal_error(storage); - } + /* critical errors may contain sensitive data, so let user + see only "Internal error" with a timestamp to make it + easier to look from log files the actual error message. */ + mail_storage_set_internal_error(storage); } void mail_storage_copy_list_error(struct mail_storage *storage, From dovecot at dovecot.org Thu Sep 8 11:50:34 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:50:34 +0300 Subject: dovecot-2.0: lib-storage: Fixed mail_storage_copy() error handling. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/858298eb101f changeset: 12900:858298eb101f user: Timo Sirainen date: Thu Sep 08 11:50:23 2011 +0300 description: lib-storage: Fixed mail_storage_copy() error handling. diffstat: src/lib-storage/mail-copy.c | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-) diffs (62 lines): diff -r 1903d5fd7e76 -r 858298eb101f src/lib-storage/mail-copy.c --- a/src/lib-storage/mail-copy.c Thu Sep 08 11:16:55 2011 +0300 +++ b/src/lib-storage/mail-copy.c Thu Sep 08 11:50:23 2011 +0300 @@ -5,6 +5,21 @@ #include "mail-storage-private.h" #include "mail-copy.h" +static void +mail_copy_set_failed(struct mail_save_context *ctx, struct mail *mail, + const char *func) +{ + const char *errstr; + enum mail_error error; + + if (ctx->transaction->box->storage == mail->box->storage) + return; + + errstr = mail_storage_get_last_error(mail->box->storage, &error); + mail_storage_set_error(ctx->transaction->box->storage, error, + t_strdup_printf("%s (%s)", errstr, func)); +} + static int mail_storage_try_copy(struct mail_save_context **_ctx, struct mail *mail) { @@ -20,24 +35,32 @@ to help anything. */ pmail->v.set_uid_cache_updates(mail, TRUE); - if (mail_get_stream(mail, NULL, NULL, &input) < 0) + if (mail_get_stream(mail, NULL, NULL, &input) < 0) { + mail_copy_set_failed(ctx, mail, "stream"); return -1; + } if (ctx->received_date == (time_t)-1) { - if (mail_get_received_date(mail, &received_date) < 0) + if (mail_get_received_date(mail, &received_date) < 0) { + mail_copy_set_failed(ctx, mail, "received-date"); return -1; + } mailbox_save_set_received_date(ctx, received_date, 0); } if (ctx->from_envelope == NULL) { if (mail_get_special(mail, MAIL_FETCH_FROM_ENVELOPE, - &from_envelope) < 0) + &from_envelope) < 0) { + mail_copy_set_failed(ctx, mail, "from-envelope"); return -1; + } if (*from_envelope != '\0') mailbox_save_set_from_envelope(ctx, from_envelope); } if (ctx->guid == NULL) { - if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) + if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) { + mail_copy_set_failed(ctx, mail, "guid"); return -1; + } if (*guid != '\0') mailbox_save_set_guid(ctx, guid); } From dovecot at dovecot.org Thu Sep 8 11:51:30 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:51:30 +0300 Subject: dovecot-2.0: lib-lda: Log message improvement to differentiate m... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/323ab62983b6 changeset: 12901:323ab62983b6 user: Timo Sirainen date: Thu Sep 08 11:51:18 2011 +0300 description: lib-lda: Log message improvement to differentiate mailbox open vs. save error. diffstat: src/lib-lda/mail-deliver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 858298eb101f -r 323ab62983b6 src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Thu Sep 08 11:50:23 2011 +0300 +++ b/src/lib-lda/mail-deliver.c Thu Sep 08 11:51:18 2011 +0300 @@ -291,7 +291,7 @@ &error, &errstr) < 0) { if (box != NULL) mailbox_free(&box); - mail_deliver_log(ctx, "save failed to %s: %s", + mail_deliver_log(ctx, "save failed to open mailbox %s: %s", mailbox_name, errstr); return -1; } From dovecot at dovecot.org Thu Sep 8 11:51:41 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:51:41 +0300 Subject: dovecot-2.1: lib-lda: Log message improvement to differentiate m... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2d82377dc855 changeset: 13432:2d82377dc855 user: Timo Sirainen date: Thu Sep 08 11:51:18 2011 +0300 description: lib-lda: Log message improvement to differentiate mailbox open vs. save error. diffstat: src/lib-lda/mail-deliver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r b69feb0352f1 -r 2d82377dc855 src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Thu Sep 08 11:50:23 2011 +0300 +++ b/src/lib-lda/mail-deliver.c Thu Sep 08 11:51:18 2011 +0300 @@ -284,7 +284,7 @@ &error, &errstr) < 0) { if (box != NULL) mailbox_free(&box); - mail_deliver_log(ctx, "save failed to %s: %s", + mail_deliver_log(ctx, "save failed to open mailbox %s: %s", mailbox_name, errstr); return -1; } From dovecot at dovecot.org Thu Sep 8 11:51:41 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 11:51:41 +0300 Subject: dovecot-2.1: lib-storage: Fixed mail_storage_copy() error handling. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b69feb0352f1 changeset: 13431:b69feb0352f1 user: Timo Sirainen date: Thu Sep 08 11:50:23 2011 +0300 description: lib-storage: Fixed mail_storage_copy() error handling. diffstat: src/lib-storage/mail-copy.c | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-) diffs (62 lines): diff -r 84bce2c8626f -r b69feb0352f1 src/lib-storage/mail-copy.c --- a/src/lib-storage/mail-copy.c Thu Sep 08 11:39:00 2011 +0300 +++ b/src/lib-storage/mail-copy.c Thu Sep 08 11:50:23 2011 +0300 @@ -5,6 +5,21 @@ #include "mail-storage-private.h" #include "mail-copy.h" +static void +mail_copy_set_failed(struct mail_save_context *ctx, struct mail *mail, + const char *func) +{ + const char *errstr; + enum mail_error error; + + if (ctx->transaction->box->storage == mail->box->storage) + return; + + errstr = mail_storage_get_last_error(mail->box->storage, &error); + mail_storage_set_error(ctx->transaction->box->storage, error, + t_strdup_printf("%s (%s)", errstr, func)); +} + static int mail_storage_try_copy(struct mail_save_context **_ctx, struct mail *mail) { @@ -20,24 +35,32 @@ to help anything. */ pmail->v.set_uid_cache_updates(mail, TRUE); - if (mail_get_stream(mail, NULL, NULL, &input) < 0) + if (mail_get_stream(mail, NULL, NULL, &input) < 0) { + mail_copy_set_failed(ctx, mail, "stream"); return -1; + } if (ctx->received_date == (time_t)-1) { - if (mail_get_received_date(mail, &received_date) < 0) + if (mail_get_received_date(mail, &received_date) < 0) { + mail_copy_set_failed(ctx, mail, "received-date"); return -1; + } mailbox_save_set_received_date(ctx, received_date, 0); } if (ctx->from_envelope == NULL) { if (mail_get_special(mail, MAIL_FETCH_FROM_ENVELOPE, - &from_envelope) < 0) + &from_envelope) < 0) { + mail_copy_set_failed(ctx, mail, "from-envelope"); return -1; + } if (*from_envelope != '\0') mailbox_save_set_from_envelope(ctx, from_envelope); } if (ctx->guid == NULL) { - if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) + if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) { + mail_copy_set_failed(ctx, mail, "guid"); return -1; + } if (*guid != '\0') mailbox_save_set_guid(ctx, guid); } From dovecot at dovecot.org Thu Sep 8 12:15:15 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 12:15:15 +0300 Subject: dovecot-2.1: lib-ssl-iostream: If plain stream disconnects, disc... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c53f15aab7aa changeset: 13433:c53f15aab7aa user: Timo Sirainen date: Thu Sep 08 12:14:54 2011 +0300 description: lib-ssl-iostream: If plain stream disconnects, disconnect SSL stream also. diffstat: src/lib-ssl-iostream/iostream-openssl.c | 20 ++++++++++++++++++-- src/lib-ssl-iostream/iostream-openssl.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diffs (68 lines): diff -r 2d82377dc855 -r c53f15aab7aa src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Thu Sep 08 11:51:18 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Thu Sep 08 12:14:54 2011 +0300 @@ -288,8 +288,9 @@ sent = o_stream_send(ssl_io->plain_output, buffer, bytes); if (sent < 0) { i_assert(ssl_io->plain_output->stream_errno != 0); - ssl_io->ssl_output->stream_errno = + ssl_io->plain_stream_errno = ssl_io->plain_output->stream_errno; + ssl_io->closed = TRUE; break; } i_assert(sent == (ssize_t)bytes); @@ -308,7 +309,14 @@ while ((bytes = BIO_ctrl_get_write_guarantee(ssl_io->bio_ext)) > 0) { /* bytes contains how many bytes we can write to bio_ext */ - (void)i_stream_read_data(ssl_io->plain_input, &data, &size, 0); + if (i_stream_read_data(ssl_io->plain_input, + &data, &size, 0) == -1 && + size == 0 && !bytes_read) { + ssl_io->plain_stream_errno = + ssl_io->plain_input->stream_errno; + ssl_io->closed = TRUE; + return FALSE; + } if (size == 0) { /* wait for more input */ break; @@ -377,10 +385,18 @@ i_panic("SSL ostream buffer size not unlimited"); return 0; } + if (ssl_io->closed) { + errno = ssl_io->plain_stream_errno; + return -1; + } return 1; case SSL_ERROR_WANT_READ: ssl_io->want_read = TRUE; (void)ssl_iostream_bio_sync(ssl_io); + if (ssl_io->closed) { + errno = ssl_io->plain_stream_errno; + return -1; + } return ssl_io->want_read ? 0 : 1; case SSL_ERROR_SYSCALL: /* eat up the error queue */ diff -r 2d82377dc855 -r c53f15aab7aa src/lib-ssl-iostream/iostream-openssl.h --- a/src/lib-ssl-iostream/iostream-openssl.h Thu Sep 08 11:51:18 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.h Thu Sep 08 12:14:54 2011 +0300 @@ -34,6 +34,7 @@ char *source; char *last_error; + int plain_stream_errno; /* copied settings */ bool verbose, verbose_invalid_cert, require_valid_cert; @@ -47,6 +48,7 @@ unsigned int cert_broken:1; unsigned int want_read:1; unsigned int ostream_flush_waiting_input:1; + unsigned int closed:1; }; extern int dovecot_ssl_extdata_index; From dovecot at dovecot.org Thu Sep 8 12:46:35 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 12:46:35 +0300 Subject: dovecot-2.1: imapc: Send NOOP command every 29 minutes to remote... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1aa51cd11614 changeset: 13434:1aa51cd11614 user: Timo Sirainen date: Thu Sep 08 12:39:13 2011 +0300 description: imapc: Send NOOP command every 29 minutes to remote server. This avoids server idle-disconnecting us after doing nothing for 30 minutes. diffstat: src/lib-storage/index/imapc/imapc-client.c | 6 +++- src/lib-storage/index/imapc/imapc-connection.c | 34 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diffs (106 lines): diff -r c53f15aab7aa -r 1aa51cd11614 src/lib-storage/index/imapc/imapc-client.c --- a/src/lib-storage/index/imapc/imapc-client.c Thu Sep 08 12:14:54 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.c Thu Sep 08 12:39:13 2011 +0300 @@ -127,12 +127,14 @@ void imapc_client_run_post(struct imapc_client *client) { struct imapc_client_connection *const *connp; + struct ioloop *ioloop = client->ioloop; + client->ioloop = NULL; array_foreach(&client->conns, connp) imapc_connection_ioloop_changed((*connp)->conn); - current_ioloop = client->ioloop; - io_loop_destroy(&client->ioloop); + current_ioloop = ioloop; + io_loop_destroy(&ioloop); } void imapc_client_stop(struct imapc_client *client) diff -r c53f15aab7aa -r 1aa51cd11614 src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Thu Sep 08 12:14:54 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Thu Sep 08 12:39:13 2011 +0300 @@ -23,6 +23,8 @@ #define IMAPC_CONNECT_TIMEOUT_MSECS (1000*30) #define IMAPC_COMMAND_TIMEOUT_MSECS (1000*60*5) #define IMAPC_MAX_INLINE_LITERAL_SIZE (1024*32) +/* IMAP protocol requires activity at least every 30 minutes */ +#define IMAPC_MAX_IDLE_MSECS (1000*60*29) enum imapc_input_state { IMAPC_INPUT_STATE_NONE = 0, @@ -72,6 +74,7 @@ struct ostream *output; struct imap_parser *parser; struct timeout *to; + struct timeout *to_output; struct ssl_iostream *ssl_iostream; @@ -151,6 +154,13 @@ conn->to = io_loop_move_timeout(&conn->to); if (conn->output != NULL) o_stream_switch_ioloop(conn->output); + + if (conn->client->ioloop == NULL && conn->to_output != NULL) { + /* we're only once moving the to_output to the main ioloop, + since timeout moves currently also reset the timeout. + (the rest of the times this is a no-op) */ + conn->to_output = io_loop_move_timeout(&conn->to_output); + } } static const char *imapc_command_get_readable(struct imapc_command *cmd) @@ -257,6 +267,8 @@ imapc_connection_literal_reset(&conn->literal); if (conn->to != NULL) timeout_remove(&conn->to); + if (conn->to_output != NULL) + timeout_remove(&conn->to_output); imap_parser_destroy(&conn->parser); io_remove(&conn->io); if (conn->ssl_iostream != NULL) @@ -1075,6 +1087,25 @@ imapc_connection_disconnect(conn); } +static void +imapc_reidle_callback(const struct imapc_command_reply *reply ATTR_UNUSED, + void *context) +{ + struct imapc_connection *conn = context; + + imapc_connection_idle(conn); +} + +static void imapc_connection_reset_idle(struct imapc_connection *conn) +{ + if (!conn->idling) + imapc_connection_cmd(conn, FALSE, "NOOP", NULL, NULL); + else { + imapc_connection_cmd(conn, FALSE, "NOOP", + imapc_reidle_callback, conn); + } +} + static void imapc_connection_connect_next_ip(struct imapc_connection *conn) { const struct ip_addr *ip; @@ -1097,6 +1128,8 @@ conn->parser = imap_parser_create(conn->input, NULL, (size_t)-1); conn->to = timeout_add(IMAPC_CONNECT_TIMEOUT_MSECS, imapc_connection_timeout, conn); + conn->to_output = timeout_add(IMAPC_MAX_IDLE_MSECS, + imapc_connection_reset_idle, conn); if (conn->client->set.debug) { i_debug("imapc(%s): Connecting to %s:%u", conn->name, net_ip2addr(ip), conn->client->set.port); @@ -1300,6 +1333,7 @@ i_assert(cmd->send_pos < cmd->data->used); + timeout_reset(conn->to_output); if ((ret = imapc_command_try_send_stream(conn, cmd)) == 0) return; From dovecot at dovecot.org Thu Sep 8 13:41:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 13:41:32 +0300 Subject: dovecot-2.0: lmtp: Improved "DATA output timeout" error message. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8de8752b2e94 changeset: 12902:8de8752b2e94 user: Timo Sirainen date: Thu Sep 08 13:41:20 2011 +0300 description: lmtp: Improved "DATA output timeout" error message. diffstat: src/lmtp/lmtp-proxy.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diffs (29 lines): diff -r 323ab62983b6 -r 8de8752b2e94 src/lmtp/lmtp-proxy.c --- a/src/lmtp/lmtp-proxy.c Thu Sep 08 11:51:18 2011 +0300 +++ b/src/lmtp/lmtp-proxy.c Thu Sep 08 13:41:20 2011 +0300 @@ -336,6 +336,8 @@ { struct lmtp_proxy_connection *const *conns; uoff_t min_offset; + size_t size; + const char *errstr; min_offset = lmtp_proxy_find_lowest_offset(proxy); if (min_offset == (uoff_t)-1) @@ -348,9 +350,13 @@ if (conn->data_input != NULL && conn->data_input->v_offset == min_offset) { - lmtp_client_fail(conn->client, - ERRSTR_TEMP_REMOTE_FAILURE - " (DATA output timeout)"); + (void)i_stream_get_data(conn->data_input, &size); + errstr = t_strdup_printf(ERRSTR_TEMP_REMOTE_FAILURE + " (DATA output stalled for %u secs, " + "%"PRIuUOFF_T"B sent, %"PRIuSIZE_T"B buffered)", + proxy->max_timeout_msecs/1000, + min_offset, size); + lmtp_client_fail(conn->client, errstr); } } return TRUE; From dovecot at dovecot.org Thu Sep 8 16:24:30 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 16:24:30 +0300 Subject: dovecot-2.0: lib-storage: Error handling fix for key+=value when... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0f63b7c5dd7c changeset: 12903:0f63b7c5dd7c user: Timo Sirainen date: Thu Sep 08 16:24:18 2011 +0300 description: lib-storage: Error handling fix for key+=value when key isn't of string type. diffstat: src/lib-storage/mail-storage-service.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 8de8752b2e94 -r 0f63b7c5dd7c src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Thu Sep 08 13:41:20 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Thu Sep 08 16:24:18 2011 +0300 @@ -122,7 +122,6 @@ /* key+=value */ append_value = line + len + 1; key = t_strndup(key, len-1); - line++; } if (!settings_parse_is_valid_key(set_parser, key)) { From dovecot at dovecot.org Thu Sep 8 16:38:07 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 16:38:07 +0300 Subject: dovecot-2.1: fts-solr: Fixed indexing messages with multiple MIM... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/283e08771d92 changeset: 13435:283e08771d92 user: Timo Sirainen date: Thu Sep 08 16:37:56 2011 +0300 description: fts-solr: Fixed indexing messages with multiple MIME body parts. diffstat: src/plugins/fts-solr/fts-backend-solr-old.c | 18 ++++++++++++++---- src/plugins/fts-solr/fts-backend-solr.c | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diffs (103 lines): diff -r 1aa51cd11614 -r 283e08771d92 src/plugins/fts-solr/fts-backend-solr-old.c --- a/src/plugins/fts-solr/fts-backend-solr-old.c Thu Sep 08 12:39:13 2011 +0300 +++ b/src/plugins/fts-solr/fts-backend-solr-old.c Thu Sep 08 16:37:56 2011 +0300 @@ -36,6 +36,7 @@ string_t *cmd, *hdr; bool headers_open; + bool body_open; bool documents_added; }; @@ -513,6 +514,10 @@ str_append(ctx->cmd, ""); } else { ctx->headers_open = FALSE; + if (ctx->body_open) { + ctx->body_open = FALSE; + str_append(ctx->cmd, ""); + } str_append(ctx->cmd, ""); str_append_str(ctx->cmd, ctx->hdr); str_append(ctx->cmd, ""); @@ -547,7 +552,10 @@ break; case FTS_BACKEND_BUILD_KEY_BODY_PART: ctx->headers_open = FALSE; - str_append(ctx->cmd, ""); + if (!ctx->body_open) { + ctx->body_open = TRUE; + str_append(ctx->cmd, ""); + } break; case FTS_BACKEND_BUILD_KEY_BODY_PART_BINARY: i_unreached(); @@ -561,10 +569,12 @@ struct solr_fts_backend_update_context *ctx = (struct solr_fts_backend_update_context *)_ctx; - if (!ctx->headers_open) - str_append(ctx->cmd, ""); - else + if (ctx->headers_open) str_append_c(ctx->hdr, '\n'); + else { + i_assert(ctx->body_open); + str_append_c(ctx->cmd, '\n'); + } } static int diff -r 1aa51cd11614 -r 283e08771d92 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Thu Sep 08 12:39:13 2011 +0300 +++ b/src/plugins/fts-solr/fts-backend-solr.c Thu Sep 08 16:37:56 2011 +0300 @@ -36,6 +36,7 @@ unsigned int last_indexed_uid_set:1; unsigned int headers_open:1; + unsigned int body_open:1; unsigned int cur_header_index:1; unsigned int documents_added:1; unsigned int expunges:1; @@ -260,6 +261,10 @@ fts_backend_solr_doc_close(struct solr_fts_backend_update_context *ctx) { ctx->headers_open = FALSE; + if (ctx->body_open) { + ctx->body_open = FALSE; + str_append(ctx->cmd, ""); + } if (str_len(ctx->hdr) > 0) { str_append(ctx->cmd, ""); str_append_str(ctx->cmd, ctx->hdr); @@ -416,7 +421,10 @@ break; case FTS_BACKEND_BUILD_KEY_BODY_PART: ctx->headers_open = FALSE; - str_append(ctx->cmd, ""); + if (!ctx->body_open) { + ctx->body_open = TRUE; + str_append(ctx->cmd, ""); + } break; case FTS_BACKEND_BUILD_KEY_BODY_PART_BINARY: i_unreached(); @@ -430,12 +438,15 @@ struct solr_fts_backend_update_context *ctx = (struct solr_fts_backend_update_context *)_ctx; - if (!ctx->headers_open) - str_append(ctx->cmd, ""); - else { + if (ctx->headers_open) { /* this is called individually for each header line. headers are finished only when key changes to body */ str_append_c(ctx->hdr, '\n'); + } else { + i_assert(ctx->body_open); + /* messages can have multiple MIME bodies. + add them all as one. */ + str_append_c(ctx->cmd, '\n'); } if (ctx->cur_header_index) { From dovecot at dovecot.org Thu Sep 8 16:52:43 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 16:52:43 +0300 Subject: dovecot-2.1: imapc: If NOOP fails with disconnection, set "inter... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/960907bfc29e changeset: 13436:960907bfc29e user: Timo Sirainen date: Thu Sep 08 16:51:51 2011 +0300 description: imapc: If NOOP fails with disconnection, set "internal error" to storage. diffstat: src/lib-storage/index/imapc/imapc-storage.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (17 lines): diff -r 283e08771d92 -r 960907bfc29e src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Thu Sep 08 16:37:56 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Thu Sep 08 16:51:51 2011 +0300 @@ -156,9 +156,11 @@ if (reply->state == IMAPC_COMMAND_STATE_OK) ; - else if (reply->state == IMAPC_COMMAND_STATE_NO) { + else if (reply->state == IMAPC_COMMAND_STATE_NO) imapc_copy_error_from_reply(storage, MAIL_ERROR_PARAMS, reply); - } else if (reply->state != IMAPC_COMMAND_STATE_DISCONNECTED) { + else if (reply->state == IMAPC_COMMAND_STATE_DISCONNECTED) + mail_storage_set_internal_error(&storage->storage); + else { mail_storage_set_critical(&storage->storage, "imapc: NOOP failed: %s", reply->text_full); } From dovecot at dovecot.org Thu Sep 8 16:52:43 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Sep 2011 16:52:43 +0300 Subject: dovecot-2.1: imapc: If mail prefetching fails because of disconn... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ec947cc9c9c7 changeset: 13437:ec947cc9c9c7 user: Timo Sirainen date: Thu Sep 08 16:52:32 2011 +0300 description: imapc: If mail prefetching fails because of disconnection, don't log about it again. diffstat: src/lib-storage/index/imapc/imapc-mail-fetch.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 960907bfc29e -r ec947cc9c9c7 src/lib-storage/index/imapc/imapc-mail-fetch.c --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Thu Sep 08 16:51:51 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Thu Sep 08 16:52:32 2011 +0300 @@ -39,6 +39,9 @@ else if (reply->state == IMAPC_COMMAND_STATE_NO) { imapc_copy_error_from_reply(mbox->storage, MAIL_ERROR_PARAMS, reply); + } else if (reply->state == IMAPC_COMMAND_STATE_DISCONNECTED) { + /* The disconnection message was already logged */ + mail_storage_set_internal_error(&mbox->storage->storage); } else { mail_storage_set_critical(&mbox->storage->storage, "imapc: Mail prefetch failed: %s", reply->text_full); From dovecot at dovecot.org Fri Sep 9 12:57:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 09 Sep 2011 12:57:55 +0300 Subject: dovecot-2.1: imapc: Use mUTF-7 for mailbox names. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/92ab9fa4ec36 changeset: 13438:92ab9fa4ec36 user: Timo Sirainen date: Fri Sep 09 12:57:36 2011 +0300 description: imapc: Use mUTF-7 for mailbox names. diffstat: src/lib-storage/index/imapc/imapc-list.c | 20 ++++++++++++++++---- src/lib-storage/index/imapc/imapc-save.c | 3 ++- src/lib-storage/index/imapc/imapc-storage.c | 19 +++++++++++++++---- src/lib-storage/index/imapc/imapc-storage.h | 1 + 4 files changed, 34 insertions(+), 9 deletions(-) diffs (120 lines): diff -r ec947cc9c9c7 -r 92ab9fa4ec36 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Thu Sep 08 16:52:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Fri Sep 09 12:57:36 2011 +0300 @@ -1,8 +1,10 @@ /* Copyright (c) 2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "str.h" #include "imap-arg.h" #include "imap-match.h" +#include "imap-utf7.h" #include "mailbox-tree.h" #include "mailbox-list-subscriptions.h" #include "imapc-client.h" @@ -82,10 +84,20 @@ flags++; } - if ((info_flags & MAILBOX_NONEXISTENT) != 0) - node = mailbox_tree_lookup(tree, name); - else - node = mailbox_tree_get(tree, name, &created); + T_BEGIN { + string_t *utf8_name = t_str_new(64); + + if (imap_utf7_to_utf8(name, utf8_name)) { + str_truncate(utf8_name, 0); + str_append(utf8_name, name); + } + if ((info_flags & MAILBOX_NONEXISTENT) != 0) + node = mailbox_tree_lookup(tree, str_c(utf8_name)); + else { + node = mailbox_tree_get(tree, str_c(utf8_name), + &created); + } + } T_END; if (node != NULL) node->flags = info_flags; return node; diff -r ec947cc9c9c7 -r 92ab9fa4ec36 src/lib-storage/index/imapc/imapc-save.c --- a/src/lib-storage/index/imapc/imapc-save.c Thu Sep 08 16:52:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-save.c Fri Sep 09 12:57:36 2011 +0300 @@ -335,7 +335,8 @@ imapc_client_mailbox_cmdf(src_mbox->client_box, imapc_copy_callback, &sctx, "UID COPY %u %s", - mail->uid, _t->box->name); + mail->uid, + imapc_mutf7_mailbox_name(_t->box)); while (sctx.ret == -2) imapc_storage_run(src_mbox->storage); ctx->finished = TRUE; diff -r ec947cc9c9c7 -r 92ab9fa4ec36 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Thu Sep 08 16:52:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Fri Sep 09 12:57:36 2011 +0300 @@ -5,6 +5,7 @@ #include "str.h" #include "imap-arg.h" #include "imap-resp-code.h" +#include "imap-utf7.h" #include "imapc-mail.h" #include "imapc-client-private.h" #include "imapc-connection.h" @@ -362,6 +363,15 @@ imapc_client_stop(ctx->mbox->storage->client); } +const char *imapc_mutf7_mailbox_name(struct mailbox *box) +{ + const char *mutf7_name; + + if (t_imap_utf8_to_utf7(box->name, &mutf7_name) < 0) + i_unreached(); + return mutf7_name; +} + static int imapc_mailbox_open(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; @@ -383,8 +393,8 @@ ctx.ret = -2; mbox->client_box = imapc_client_mailbox_open(mbox->storage->client, - box->name, examine, - imapc_mailbox_open_callback, + imapc_mutf7_mailbox_name(box), + examine, imapc_mailbox_open_callback, &ctx, mbox); while (ctx.ret == -2) imapc_storage_run(mbox->storage); @@ -424,7 +434,7 @@ { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; struct imapc_simple_context sctx; - const char *name = box->name; + const char *name = imapc_mutf7_mailbox_name(box); if (directory) { name = t_strdup_printf("%s%c", name, @@ -544,7 +554,8 @@ mbox->storage->cur_status = status_r; imapc_client_cmdf(mbox->storage->client, imapc_simple_callback, &sctx, - "STATUS %s (%1s)", box->name, str_c(str)+1); + "STATUS %s (%1s)", imapc_mutf7_mailbox_name(box), + str_c(str)+1); imapc_simple_run(&sctx); mbox->storage->cur_status_box = NULL; mbox->storage->cur_status = NULL; diff -r ec947cc9c9c7 -r 92ab9fa4ec36 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Thu Sep 08 16:52:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Fri Sep 09 12:57:36 2011 +0300 @@ -90,6 +90,7 @@ void imapc_storage_run(struct imapc_storage *storage); +const char *imapc_mutf7_mailbox_name(struct mailbox *box); void imapc_copy_error_from_reply(struct imapc_storage *storage, enum mail_error default_error, const struct imapc_command_reply *reply); From dovecot at dovecot.org Fri Sep 9 13:05:44 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 09 Sep 2011 13:05:44 +0300 Subject: dovecot-2.1: imapc: Another try at fixing mUTF-7 mailbox names. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0801852b2156 changeset: 13439:0801852b2156 user: Timo Sirainen date: Fri Sep 09 13:05:33 2011 +0300 description: imapc: Another try at fixing mUTF-7 mailbox names. diffstat: src/lib-storage/index/imapc/imapc-list.c | 2 +- src/lib-storage/index/imapc/imapc-save.c | 3 +-- src/lib-storage/index/imapc/imapc-storage.c | 20 ++++---------------- src/lib-storage/index/imapc/imapc-storage.h | 1 - 4 files changed, 6 insertions(+), 20 deletions(-) diffs (87 lines): diff -r 92ab9fa4ec36 -r 0801852b2156 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Fri Sep 09 12:57:36 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Fri Sep 09 13:05:33 2011 +0300 @@ -87,7 +87,7 @@ T_BEGIN { string_t *utf8_name = t_str_new(64); - if (imap_utf7_to_utf8(name, utf8_name)) { + if (imap_utf7_to_utf8(name, utf8_name) < 0) { str_truncate(utf8_name, 0); str_append(utf8_name, name); } diff -r 92ab9fa4ec36 -r 0801852b2156 src/lib-storage/index/imapc/imapc-save.c --- a/src/lib-storage/index/imapc/imapc-save.c Fri Sep 09 12:57:36 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-save.c Fri Sep 09 13:05:33 2011 +0300 @@ -335,8 +335,7 @@ imapc_client_mailbox_cmdf(src_mbox->client_box, imapc_copy_callback, &sctx, "UID COPY %u %s", - mail->uid, - imapc_mutf7_mailbox_name(_t->box)); + mail->uid, _t->box->name); while (sctx.ret == -2) imapc_storage_run(src_mbox->storage); ctx->finished = TRUE; diff -r 92ab9fa4ec36 -r 0801852b2156 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Fri Sep 09 12:57:36 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Fri Sep 09 13:05:33 2011 +0300 @@ -363,15 +363,6 @@ imapc_client_stop(ctx->mbox->storage->client); } -const char *imapc_mutf7_mailbox_name(struct mailbox *box) -{ - const char *mutf7_name; - - if (t_imap_utf8_to_utf7(box->name, &mutf7_name) < 0) - i_unreached(); - return mutf7_name; -} - static int imapc_mailbox_open(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; @@ -392,8 +383,7 @@ ctx.mbox = mbox; ctx.ret = -2; mbox->client_box = - imapc_client_mailbox_open(mbox->storage->client, - imapc_mutf7_mailbox_name(box), + imapc_client_mailbox_open(mbox->storage->client, box->name, examine, imapc_mailbox_open_callback, &ctx, mbox); while (ctx.ret == -2) @@ -434,7 +424,7 @@ { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; struct imapc_simple_context sctx; - const char *name = imapc_mutf7_mailbox_name(box); + const char *name = box->name; if (directory) { name = t_strdup_printf("%s%c", name, @@ -552,10 +542,8 @@ imapc_simple_context_init(&sctx, mbox->storage); mbox->storage->cur_status_box = mbox; mbox->storage->cur_status = status_r; - imapc_client_cmdf(mbox->storage->client, - imapc_simple_callback, &sctx, - "STATUS %s (%1s)", imapc_mutf7_mailbox_name(box), - str_c(str)+1); + imapc_client_cmdf(mbox->storage->client, imapc_simple_callback, &sctx, + "STATUS %s (%1s)", box->name, str_c(str)+1); imapc_simple_run(&sctx); mbox->storage->cur_status_box = NULL; mbox->storage->cur_status = NULL; diff -r 92ab9fa4ec36 -r 0801852b2156 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Fri Sep 09 12:57:36 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Fri Sep 09 13:05:33 2011 +0300 @@ -90,7 +90,6 @@ void imapc_storage_run(struct imapc_storage *storage); -const char *imapc_mutf7_mailbox_name(struct mailbox *box); void imapc_copy_error_from_reply(struct imapc_storage *storage, enum mail_error default_error, const struct imapc_command_reply *reply); From dovecot at dovecot.org Fri Sep 9 13:14:18 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 09 Sep 2011 13:14:18 +0300 Subject: dovecot-2.1: imapc: More fixes to listing mailbox names. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3e1aad7bfd97 changeset: 13440:3e1aad7bfd97 user: Timo Sirainen date: Fri Sep 09 13:14:07 2011 +0300 description: imapc: More fixes to listing mailbox names. diffstat: src/lib-storage/index/imapc/imapc-list.c | 22 +++++++++------------- src/lib-storage/index/imapc/imapc-storage.c | 1 - 2 files changed, 9 insertions(+), 14 deletions(-) diffs (66 lines): diff -r 0801852b2156 -r 3e1aad7bfd97 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Fri Sep 09 13:05:33 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Fri Sep 09 13:14:07 2011 +0300 @@ -58,7 +58,8 @@ } static struct mailbox_node * -imapc_list_update_tree(struct mailbox_tree_context *tree, +imapc_list_update_tree(struct imapc_mailbox_list *list, + struct mailbox_tree_context *tree, const struct imap_arg *args) { struct mailbox_node *node; @@ -85,18 +86,13 @@ } T_BEGIN { - string_t *utf8_name = t_str_new(64); + const char *vname = + mailbox_list_default_get_vname(&list->list, name); - if (imap_utf7_to_utf8(name, utf8_name) < 0) { - str_truncate(utf8_name, 0); - str_append(utf8_name, name); - } if ((info_flags & MAILBOX_NONEXISTENT) != 0) - node = mailbox_tree_lookup(tree, str_c(utf8_name)); - else { - node = mailbox_tree_get(tree, str_c(utf8_name), - &created); - } + node = mailbox_tree_lookup(tree, vname); + else + node = mailbox_tree_get(tree, vname, &created); } T_END; if (node != NULL) node->flags = info_flags; @@ -123,7 +119,7 @@ if (list->mailboxes != NULL) mailbox_tree_set_separator(list->mailboxes, list->sep); } else { - (void)imapc_list_update_tree(list->mailboxes, args); + (void)imapc_list_update_tree(list, list->mailboxes, args); } } @@ -138,7 +134,7 @@ /* we haven't asked for the separator yet */ return; } - node = imapc_list_update_tree(list->tmp_subscriptions != NULL ? + node = imapc_list_update_tree(list, list->tmp_subscriptions != NULL ? list->tmp_subscriptions : list->list.subscriptions, args); if (node != NULL) diff -r 0801852b2156 -r 3e1aad7bfd97 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Fri Sep 09 13:05:33 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Fri Sep 09 13:14:07 2011 +0300 @@ -5,7 +5,6 @@ #include "str.h" #include "imap-arg.h" #include "imap-resp-code.h" -#include "imap-utf7.h" #include "imapc-mail.h" #include "imapc-client-private.h" #include "imapc-connection.h" From pigeonhole at rename-it.nl Sun Sep 11 01:41:11 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 11 Sep 2011 00:41:11 +0200 Subject: dovecot-2.0-pigeonhole: variables extension: fixed segfault bug ... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/75bb6c3f4176 changeset: 1522:75bb6c3f4176 user: Stephan Bosch date: Sun Sep 11 00:19:07 2011 +0200 description: variables extension: fixed segfault bug triggered when dumping binary variable scopes. diffstat: src/lib-sieve/plugins/include/ext-include-common.c | 2 +- src/lib-sieve/plugins/variables/ext-variables-common.c | 18 ++++++++++-------- src/lib-sieve/plugins/variables/ext-variables-dump.c | 3 ++- src/lib-sieve/plugins/variables/sieve-ext-variables.h | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diffs (125 lines): diff -r 2b7f00ea1062 -r 75bb6c3f4176 src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Mon Aug 29 17:33:00 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Sun Sep 11 00:19:07 2011 +0200 @@ -164,7 +164,7 @@ sieve_variable_scope_ref(actx->global_vars); } else { - actx->global_vars = sieve_variable_scope_create(this_ext); + actx->global_vars = sieve_variable_scope_create(this_ext->svinst, this_ext); } sieve_ast_extension_register diff -r 2b7f00ea1062 -r 75bb6c3f4176 src/lib-sieve/plugins/variables/ext-variables-common.c --- a/src/lib-sieve/plugins/variables/ext-variables-common.c Mon Aug 29 17:33:00 2011 +0200 +++ b/src/lib-sieve/plugins/variables/ext-variables-common.c Sun Sep 11 00:19:07 2011 +0200 @@ -42,10 +42,11 @@ pool_t pool; int refcount; + struct sieve_instance *svinst; + const struct sieve_extension *ext; + struct sieve_variable *error_var; - const struct sieve_extension *ext; - struct hash_table *variables; ARRAY_DEFINE(variable_index, struct sieve_variable *); }; @@ -64,7 +65,7 @@ }; struct sieve_variable_scope *sieve_variable_scope_create -(const struct sieve_extension *ext) +(struct sieve_instance *svinst, const struct sieve_extension *ext) { struct sieve_variable_scope *scope; pool_t pool; @@ -74,6 +75,7 @@ scope->pool = pool; scope->refcount = 1; + scope->svinst = svinst; scope->ext = ext; scope->variables = hash_table_create @@ -234,7 +236,7 @@ /* Scope binary */ struct sieve_variable_scope *sieve_variable_scope_binary_dump -(const struct sieve_extension *ext, +(struct sieve_instance *svinst, const struct sieve_extension *ext, const struct sieve_dumptime_env *denv, sieve_size_t *address) { struct sieve_variable_scope *local_scope; @@ -253,7 +255,7 @@ return FALSE; /* Create scope */ - local_scope = sieve_variable_scope_create(ext); + local_scope = sieve_variable_scope_create(svinst, ext); /* Read and dump scope itself */ @@ -336,7 +338,7 @@ } /* Create scope */ - scope = sieve_variable_scope_create(ext); + scope = sieve_variable_scope_create(svinst, ext); scpbin = sieve_variable_scope_binary_create(scope); scpbin->size = scope_size; @@ -352,7 +354,7 @@ (struct sieve_variable_scope_binary *scpbin) { const struct sieve_extension *ext = scpbin->scope->ext; - struct sieve_instance *svinst = ext->svinst; + struct sieve_instance *svinst = scpbin->scope->svinst; const char *ext_name = ( ext == NULL ? "variables" : sieve_extension_name(ext) ); unsigned int i; @@ -551,7 +553,7 @@ { struct sieve_variable_scope *scope; - scope = sieve_variable_scope_create(NULL); + scope = sieve_variable_scope_create(this_ext->svinst, NULL); sieve_ast_extension_register (ast, this_ext, &variables_ast_extension, (void *) scope); diff -r 2b7f00ea1062 -r 75bb6c3f4176 src/lib-sieve/plugins/variables/ext-variables-dump.c --- a/src/lib-sieve/plugins/variables/ext-variables-dump.c Mon Aug 29 17:33:00 2011 +0200 +++ b/src/lib-sieve/plugins/variables/ext-variables-dump.c Sun Sep 11 00:19:07 2011 +0200 @@ -73,7 +73,8 @@ struct ext_variables_dump_context *dctx; struct sieve_variable_scope *local_scope; - local_scope = sieve_variable_scope_binary_dump(NULL, denv, address); + local_scope = sieve_variable_scope_binary_dump + (ext->svinst, NULL, denv, address); dctx = ext_variables_dump_get_context(ext, denv); dctx->local_scope = local_scope; diff -r 2b7f00ea1062 -r 75bb6c3f4176 src/lib-sieve/plugins/variables/sieve-ext-variables.h --- a/src/lib-sieve/plugins/variables/sieve-ext-variables.h Mon Aug 29 17:33:00 2011 +0200 +++ b/src/lib-sieve/plugins/variables/sieve-ext-variables.h Sun Sep 11 00:19:07 2011 +0200 @@ -63,7 +63,7 @@ struct sieve_variable_scope; struct sieve_variable_scope *sieve_variable_scope_create - (const struct sieve_extension *ext); + (struct sieve_instance *svinst, const struct sieve_extension *ext); void sieve_variable_scope_ref (struct sieve_variable_scope *scope); void sieve_variable_scope_unref @@ -91,7 +91,7 @@ (struct sieve_variable_scope_binary **scpbin); struct sieve_variable_scope *sieve_variable_scope_binary_dump - (const struct sieve_extension *ext, + (struct sieve_instance *svinst, const struct sieve_extension *ext, const struct sieve_dumptime_env *denv, sieve_size_t *address); struct sieve_variable_scope_binary *sieve_variable_scope_binary_read (struct sieve_instance *svinst, const struct sieve_extension *ext, From pigeonhole at rename-it.nl Sun Sep 11 01:41:12 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 11 Sep 2011 00:41:12 +0200 Subject: dovecot-2.0-pigeonhole: variables extension: fixed deinitializat... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/6d0da356f0fd changeset: 1523:6d0da356f0fd user: Stephan Bosch date: Sun Sep 11 00:41:04 2011 +0200 description: variables extension: fixed deinitialization problem (unfreed variable scope data) newly found by Valgrind. diffstat: src/lib-sieve/plugins/variables/ext-variables-common.c | 34 +++++++++++++---- 1 files changed, 26 insertions(+), 8 deletions(-) diffs (63 lines): diff -r 75bb6c3f4176 -r 6d0da356f0fd src/lib-sieve/plugins/variables/ext-variables-common.c --- a/src/lib-sieve/plugins/variables/ext-variables-common.c Sun Sep 11 00:19:07 2011 +0200 +++ b/src/lib-sieve/plugins/variables/ext-variables-common.c Sun Sep 11 00:41:04 2011 +0200 @@ -90,17 +90,19 @@ scope->refcount++; } -void sieve_variable_scope_unref(struct sieve_variable_scope **scope) +void sieve_variable_scope_unref(struct sieve_variable_scope **_scope) { - i_assert((*scope)->refcount > 0); + struct sieve_variable_scope *scope = *_scope; - if (--(*scope)->refcount != 0) + i_assert(scope->refcount > 0); + + if (--scope->refcount != 0) return; - hash_table_destroy(&(*scope)->variables); + hash_table_destroy(&scope->variables); - pool_unref(&(*scope)->pool); - *scope = NULL; + *_scope = NULL; + pool_unref(&scope->pool); } pool_t sieve_variable_scope_pool(struct sieve_variable_scope *scope) @@ -691,6 +693,22 @@ ARRAY_DEFINE(ext_storages, struct sieve_variable_storage *); }; +static void ext_variables_interpreter_free +(const struct sieve_extension *ext ATTR_UNUSED, + struct sieve_interpreter *interp ATTR_UNUSED, void *context) +{ + struct ext_variables_interpreter_context *ctx = + (struct ext_variables_interpreter_context *)context; + + sieve_variable_scope_binary_unref(&ctx->local_scope_bin); +} + +static struct sieve_interpreter_extension variables_interpreter_extension = { + &variables_extension, + NULL, + ext_variables_interpreter_free +}; + static struct ext_variables_interpreter_context * ext_variables_interpreter_context_create (const struct sieve_extension *this_ext, struct sieve_interpreter *interp, @@ -707,8 +725,8 @@ p_array_init(&ctx->ext_storages, pool, sieve_extensions_get_count(this_ext->svinst)); - sieve_interpreter_extension_set_context - (interp, this_ext, (void *) ctx); + sieve_interpreter_extension_register + (interp, this_ext, &variables_interpreter_extension, (void *) ctx); return ctx; } From pigeonhole at rename-it.nl Sun Sep 11 11:52:04 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 11 Sep 2011 10:52:04 +0200 Subject: dovecot-2.0-pigeonhole: include extension: implemented proper co... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/ce825c9671a6 changeset: 1524:ce825c9671a6 user: Stephan Bosch date: Sun Sep 11 10:51:40 2011 +0200 description: include extension: implemented proper configuration handling Configuration is now only read once at extension initialization. diffstat: src/lib-sieve/plugins/include/ext-include-common.c | 116 ++++++++-- src/lib-sieve/plugins/include/ext-include-common.h | 9 + src/lib-sieve/plugins/include/ext-include.c | 33 --- src/testsuite/testsuite.c | 21 +- tests/extensions/include/errors/included/action-fileinto.sieve | 3 - tests/extensions/include/errors/included/action-reject.sieve | 3 - tests/extensions/include/errors/included/circular-one.sieve | 5 - tests/extensions/include/errors/included/circular-three-2.sieve | 3 - tests/extensions/include/errors/included/circular-three-3.sieve | 3 - tests/extensions/include/errors/included/circular-three.sieve | 7 - tests/extensions/include/errors/included/circular-two-2.sieve | 3 - tests/extensions/include/errors/included/circular-two.sieve | 7 - tests/extensions/include/execute/included/actions-fileinto1.sieve | 3 - tests/extensions/include/execute/included/actions-fileinto2.sieve | 4 - tests/extensions/include/execute/included/actions-fileinto3.sieve | 3 - tests/extensions/include/included/action-fileinto.sieve | 3 + tests/extensions/include/included/action-reject.sieve | 3 + tests/extensions/include/included/actions-fileinto1.sieve | 3 + tests/extensions/include/included/actions-fileinto2.sieve | 4 + tests/extensions/include/included/actions-fileinto3.sieve | 3 + tests/extensions/include/included/circular-one.sieve | 5 + tests/extensions/include/included/circular-three-2.sieve | 3 + tests/extensions/include/included/circular-three-3.sieve | 3 + tests/extensions/include/included/circular-three.sieve | 7 + tests/extensions/include/included/circular-two-2.sieve | 3 + tests/extensions/include/included/circular-two.sieve | 7 + 26 files changed, 152 insertions(+), 115 deletions(-) diffs (truncated from 453 to 300 lines): diff -r 6d0da356f0fd -r ce825c9671a6 src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Sun Sep 11 00:41:04 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Sun Sep 11 10:51:40 2011 +0200 @@ -65,6 +65,74 @@ bool returned; }; +/* + * Extension configuration + */ + +/* Extension hooks */ + +bool ext_include_load +(const struct sieve_extension *ext, void **context) +{ + struct sieve_instance *svinst = ext->svinst; + struct ext_include_context *ctx; + const char *global_dir, *personal_dir, *home; + + if ( *context != NULL ) { + ext_include_unload(ext); + } + + /* Get directory for :global scripts */ + global_dir = sieve_setting_get(svinst, "sieve_global_dir"); + + if ( global_dir == NULL && svinst->debug ) { + sieve_sys_debug(svinst, "include: sieve_global_dir is not set; " + "it is currently not possible to include `:global' scripts."); + } + + /* Get directory for :personal scripts */ + personal_dir = sieve_setting_get(svinst, "sieve_dir"); + + home = sieve_environment_get_homedir(svinst); + + if ( personal_dir == NULL ) { + if ( home == NULL ) { + if ( svinst->debug ) { + sieve_sys_debug(svinst, "include: sieve_dir is not set " + "and no home directory is set for the default `~/sieve'; " + "it is currently not possible to include `:personal' scripts."); + } + } else { + personal_dir = "~/sieve"; + } + } + + if ( home != NULL ) + personal_dir = home_expand_tilde(personal_dir, home); + + ctx = i_new(struct ext_include_context, 1); + ctx->personal_dir = i_strdup(personal_dir); + ctx->global_dir = i_strdup(global_dir); + + /* Extension dependencies */ + ctx->var_ext = sieve_ext_variables_get_extension(ext->svinst); + + *context = (void *)ctx; + + return TRUE; +} + +void ext_include_unload +(const struct sieve_extension *ext) +{ + struct ext_include_context *ctx = + (struct ext_include_context *) ext->context; + + i_free(ctx->personal_dir); + i_free(ctx->global_dir); + i_free(ctx); +} + /* * Script access */ @@ -74,42 +142,36 @@ const char *script_name) { struct sieve_instance *svinst = ext->svinst; - const char *home = NULL, *sieve_dir = NULL; + struct ext_include_context *ctx = + (struct ext_include_context *) ext->context; + const char *sieve_dir; switch ( location ) { case EXT_INCLUDE_LOCATION_PERSONAL: - sieve_dir = sieve_setting_get(svinst, "sieve_dir"); - home = sieve_environment_get_homedir(svinst); - - if ( sieve_dir == NULL ) { - if ( home == NULL ) { - sieve_sys_error(svinst, - "include: sieve_dir and home not set for :personal script include " - "(wanted script '%s')", str_sanitize(script_name, 80)); - return NULL; - } - - sieve_dir = "~/sieve"; - } - - if ( home != NULL ) - sieve_dir = home_expand_tilde(sieve_dir, home); - - break; - case EXT_INCLUDE_LOCATION_GLOBAL: - sieve_dir = sieve_setting_get(svinst, "sieve_global_dir"); - - if (sieve_dir == NULL) { - sieve_sys_error(svinst, - "include: sieve_global_dir not set for :global script include " - "(wanted script '%s')", str_sanitize(script_name, 80)); + if ( ctx->personal_dir == NULL ) { + sieve_sys_error(svinst, "include: sieve_dir is unconfigured; " + "include of `:personal' script `%s' is therefore not possible", + str_sanitize(script_name, 80)); return NULL; } + sieve_dir = ctx->personal_dir; + break; + + case EXT_INCLUDE_LOCATION_GLOBAL: + + if ( ctx->global_dir == NULL ) { + sieve_sys_error(svinst, "include: sieve_global_dir is unconfigured; " + "include of `:global' script `%s' is therefore not possible", + str_sanitize(script_name, 80)); + return NULL; + } + + sieve_dir = ctx->global_dir; break; default: - break; + i_unreached(); } return sieve_dir; diff -r 6d0da356f0fd -r ce825c9671a6 src/lib-sieve/plugins/include/ext-include-common.h --- a/src/lib-sieve/plugins/include/ext-include-common.h Sun Sep 11 00:41:04 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.h Sun Sep 11 10:51:40 2011 +0200 @@ -52,6 +52,11 @@ extern const struct sieve_extension_def include_extension; extern const struct sieve_binary_extension include_binary_ext; +bool ext_include_load + (const struct sieve_extension *ext, void **context); +void ext_include_unload + (const struct sieve_extension *ext); + /* * Commands */ @@ -95,6 +100,10 @@ struct ext_include_context { /* Extension dependencies */ const struct sieve_extension *var_ext; + + /* Configuration */ + char *global_dir; + char *personal_dir; }; static inline struct ext_include_context *ext_include_get_context diff -r 6d0da356f0fd -r ce825c9671a6 src/lib-sieve/plugins/include/ext-include.c --- a/src/lib-sieve/plugins/include/ext-include.c Sun Sep 11 00:41:04 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include.c Sun Sep 11 10:51:40 2011 +0200 @@ -50,10 +50,6 @@ /* Forward declaration */ -static bool ext_include_load - (const struct sieve_extension *ext, void **context); -static void ext_include_unload - (const struct sieve_extension *ext); static bool ext_include_validator_load (const struct sieve_extension *ext, struct sieve_validator *validator); static bool ext_include_generator_load @@ -80,35 +76,6 @@ SIEVE_EXT_DEFINE_NO_OPERANDS }; -/* Extension hooks */ - -static bool ext_include_load -(const struct sieve_extension *ext, void **context) -{ - struct ext_include_context *ctx; - - if ( *context != NULL ) { - ctx = (struct ext_include_context *) ext->context; - } else { - ctx = i_new(struct ext_include_context, 1); - } - - /* Extension dependencies */ - ctx->var_ext = sieve_ext_variables_get_extension(ext->svinst); - - *context = ctx; - - return TRUE; -} - -static void ext_include_unload -(const struct sieve_extension *ext) -{ - struct ext_include_context *ctx = (struct ext_include_context *) ext->context; - - i_free(ctx); -} - static bool ext_include_validator_load (const struct sieve_extension *ext, struct sieve_validator *valdtr) { diff -r 6d0da356f0fd -r ce825c9671a6 src/testsuite/testsuite.c --- a/src/testsuite/testsuite.c Sun Sep 11 00:41:04 2011 +0200 +++ b/src/testsuite/testsuite.c Sun Sep 11 10:51:40 2011 +0200 @@ -49,7 +49,7 @@ static void print_help(void) { printf( -"Usage: testsuite [-E] [-d ]\n" +"Usage: testsuite [-D] [-E] [-d ]\n" " [-t ] [-T ]\n" " [-P ] [-x ]\n" " \n" @@ -91,7 +91,7 @@ int ret, c; sieve_tool = sieve_tool_init - ("testsuite", &argc, &argv, "d:t:T:EP:", TRUE); + ("testsuite", &argc, &argv, "d:t:T:EDP:", TRUE); /* Parse arguments */ scriptfile = dumpfile = tracefile = NULL; @@ -136,16 +136,10 @@ /* Initialize mail user */ sieve_tool_set_homedir(sieve_tool, t_abspath("")); - /* Finish tool initialization */ - svinst = sieve_tool_init_finish(sieve_tool, FALSE); - - testsuite_init(svinst, log_stdout); + /* Initialize settings environment */ testsuite_settings_init(); - printf("Test case: %s:\n\n", scriptfile); - - /* Initialize environment */ - + /* Currently needed for include (FIXME) */ sieve_dir = strrchr(scriptfile, '/'); if ( sieve_dir == NULL ) sieve_dir= "./"; @@ -153,12 +147,17 @@ sieve_dir = t_strdup_until(scriptfile, sieve_dir+1); } - /* Currently needed for include (FIXME) */ testsuite_setting_set ("sieve_dir", t_strconcat(sieve_dir, "included", NULL)); testsuite_setting_set ("sieve_global_dir", t_strconcat(sieve_dir, "included-global", NULL)); + /* Finish testsuite initialization */ + svinst = sieve_tool_init_finish(sieve_tool, FALSE); + testsuite_init(svinst, log_stdout); + + printf("Test case: %s:\n\n", scriptfile); + /* Compile sieve script */ if ( (sbin = sieve_compile (svinst, scriptfile, NULL, testsuite_log_main_ehandler, NULL)) != NULL ) { diff -r 6d0da356f0fd -r ce825c9671a6 tests/extensions/include/errors/included/action-fileinto.sieve --- a/tests/extensions/include/errors/included/action-fileinto.sieve Sun Sep 11 00:41:04 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -require "fileinto"; - -fileinto "frop"; diff -r 6d0da356f0fd -r ce825c9671a6 tests/extensions/include/errors/included/action-reject.sieve --- a/tests/extensions/include/errors/included/action-reject.sieve Sun Sep 11 00:41:04 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -require "reject"; - -reject "Ik heb geen zin in die rommel."; diff -r 6d0da356f0fd -r ce825c9671a6 tests/extensions/include/errors/included/circular-one.sieve --- a/tests/extensions/include/errors/included/circular-one.sieve Sun Sep 11 00:41:04 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -require "include"; - -keep; - -include "circular-one.sieve"; From pigeonhole at rename-it.nl Sun Sep 11 12:39:12 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 11 Sep 2011 11:39:12 +0200 Subject: dovecot-2.0-pigeonhole: include extension: made nesting_depth an... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/f12899a3d02f changeset: 1525:f12899a3d02f user: Stephan Bosch date: Sun Sep 11 11:39:07 2011 +0200 description: include extension: made nesting_depth and max_includes limits configurable. diffstat: src/lib-sieve/plugins/include/ext-include-binary.c | 6 +- src/lib-sieve/plugins/include/ext-include-common.c | 59 +++++++++++++------ src/lib-sieve/plugins/include/ext-include-common.h | 3 + src/lib-sieve/plugins/include/ext-include-limits.h | 4 +- src/testsuite/testsuite-script.c | 13 ---- tests/extensions/include/errors.svtest | 57 +++++++++++++++++-- tests/extensions/include/errors/depth-limit.sieve | 3 + tests/extensions/include/errors/include-limit.sieve | 6 ++ tests/extensions/include/included/depth-limit-1.sieve | 3 + tests/extensions/include/included/depth-limit-2.sieve | 3 + tests/extensions/include/included/depth-limit-3.sieve | 1 + 11 files changed, 115 insertions(+), 43 deletions(-) diffs (truncated from 327 to 300 lines): diff -r ce825c9671a6 -r f12899a3d02f src/lib-sieve/plugins/include/ext-include-binary.c --- a/src/lib-sieve/plugins/include/ext-include-binary.c Sun Sep 11 10:51:40 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.c Sun Sep 11 11:39:07 2011 +0200 @@ -234,6 +234,8 @@ (const struct sieve_extension *ext, struct sieve_binary *sbin, void *context) { struct sieve_instance *svinst = ext->svinst; + struct ext_include_context *ext_ctx = + (struct ext_include_context *)ext->context; struct ext_include_binary_context *binctx = (struct ext_include_binary_context *) context; struct sieve_binary_block *sblock; @@ -254,10 +256,10 @@ } /* Check include limit */ - if ( depcount > EXT_INCLUDE_MAX_INCLUDES ) { + if ( depcount > ext_ctx->max_includes ) { sieve_sys_error(svinst, "include: binary %s includes too many scripts (%u > %u)", - sieve_binary_path(sbin), depcount, EXT_INCLUDE_MAX_INCLUDES); + sieve_binary_path(sbin), depcount, ext_ctx->max_includes); return FALSE; } diff -r ce825c9671a6 -r f12899a3d02f src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Sun Sep 11 10:51:40 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Sun Sep 11 11:39:07 2011 +0200 @@ -31,7 +31,7 @@ /* Generator context */ struct ext_include_generator_context { - unsigned int nesting_level; + unsigned int nesting_depth; struct sieve_script *script; struct ext_include_generator_context *parent; }; @@ -56,7 +56,7 @@ struct sieve_interpreter *interp; pool_t pool; - unsigned int nesting_level; + unsigned int nesting_depth; struct sieve_script *script; const struct ext_include_script_info *script_info; @@ -76,26 +76,31 @@ { struct sieve_instance *svinst = ext->svinst; struct ext_include_context *ctx; - const char *global_dir, *personal_dir, *home; + const char *sieve_dir, *home; + unsigned long long int uint_setting; if ( *context != NULL ) { ext_include_unload(ext); } + ctx = i_new(struct ext_include_context, 1); + /* Get directory for :global scripts */ - global_dir = sieve_setting_get(svinst, "sieve_global_dir"); + sieve_dir = sieve_setting_get(svinst, "sieve_global_dir"); - if ( global_dir == NULL && svinst->debug ) { + if ( sieve_dir == NULL && svinst->debug ) { sieve_sys_debug(svinst, "include: sieve_global_dir is not set; " "it is currently not possible to include `:global' scripts."); } + ctx->global_dir = i_strdup(sieve_dir); + /* Get directory for :personal scripts */ - personal_dir = sieve_setting_get(svinst, "sieve_dir"); + sieve_dir = sieve_setting_get(svinst, "sieve_dir"); home = sieve_environment_get_homedir(svinst); - if ( personal_dir == NULL ) { + if ( sieve_dir == NULL ) { if ( home == NULL ) { if ( svinst->debug ) { sieve_sys_debug(svinst, "include: sieve_dir is not set " @@ -103,16 +108,28 @@ "it is currently not possible to include `:personal' scripts."); } } else { - personal_dir = "~/sieve"; + sieve_dir = "~/sieve"; } } if ( home != NULL ) - personal_dir = home_expand_tilde(personal_dir, home); + sieve_dir = home_expand_tilde(sieve_dir, home); - ctx = i_new(struct ext_include_context, 1); - ctx->personal_dir = i_strdup(personal_dir); - ctx->global_dir = i_strdup(global_dir); + ctx->personal_dir = i_strdup(sieve_dir); + + /* Get limits */ + ctx->max_nesting_depth = EXT_INCLUDE_DEFAULT_MAX_NESTING_DEPTH; + ctx->max_includes = EXT_INCLUDE_DEFAULT_MAX_INCLUDES; + + if ( sieve_setting_get_uint_value + (svinst, "sieve_include_max_nesting_depth", &uint_setting) ) { + ctx->max_nesting_depth = (unsigned int) uint_setting; + } + + if ( sieve_setting_get_uint_value + (svinst, "sieve_include_max_includes", &uint_setting) ) { + ctx->max_includes = (unsigned int) uint_setting; + } /* Extension dependencies */ ctx->var_ext = sieve_ext_variables_get_extension(ext->svinst); @@ -280,9 +297,9 @@ ctx->parent = parent; ctx->script = script; if ( parent == NULL ) { - ctx->nesting_level = 0; + ctx->nesting_depth = 0; } else { - ctx->nesting_level = parent->nesting_level + 1; + ctx->nesting_depth = parent->nesting_depth + 1; } return ctx; @@ -381,9 +398,9 @@ ctx->script_info = sinfo; if ( parent == NULL ) { - ctx->nesting_level = 0; + ctx->nesting_depth = 0; } else { - ctx->nesting_level = parent->nesting_level + 1; + ctx->nesting_depth = parent->nesting_depth + 1; } return ctx; @@ -451,6 +468,8 @@ const struct ext_include_script_info **included_r, bool once) { const struct sieve_extension *this_ext = cmd->ext; + struct ext_include_context *ext_ctx = + (struct ext_include_context *)this_ext->context; bool result = TRUE; struct sieve_ast *ast; struct sieve_binary *sbin = cgenv->sbin; @@ -472,10 +491,10 @@ return FALSE; /* Limit nesting level */ - if ( ctx->nesting_level >= EXT_INCLUDE_MAX_NESTING_LEVEL ) { + if ( ctx->nesting_depth >= ext_ctx->max_nesting_depth ) { sieve_command_generate_error (gentr, cmd, "cannot nest includes deeper than %d levels", - EXT_INCLUDE_MAX_NESTING_LEVEL); + ext_ctx->max_nesting_depth); return FALSE; } @@ -504,10 +523,10 @@ /* Check whether include limit is exceeded */ if ( ext_include_binary_script_get_count(binctx) >= - EXT_INCLUDE_MAX_INCLUDES ) { + ext_ctx->max_includes ) { sieve_command_generate_error(gentr, cmd, "failed to include script '%s': no more than %u includes allowed", - str_sanitize(script_name, 80), EXT_INCLUDE_MAX_INCLUDES); + str_sanitize(script_name, 80), ext_ctx->max_includes); return FALSE; } diff -r ce825c9671a6 -r f12899a3d02f src/lib-sieve/plugins/include/ext-include-common.h --- a/src/lib-sieve/plugins/include/ext-include-common.h Sun Sep 11 10:51:40 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.h Sun Sep 11 11:39:07 2011 +0200 @@ -104,6 +104,9 @@ /* Configuration */ char *global_dir; char *personal_dir; + + unsigned int max_nesting_depth; + unsigned int max_includes; }; static inline struct ext_include_context *ext_include_get_context diff -r ce825c9671a6 -r f12899a3d02f src/lib-sieve/plugins/include/ext-include-limits.h --- a/src/lib-sieve/plugins/include/ext-include-limits.h Sun Sep 11 10:51:40 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-limits.h Sun Sep 11 11:39:07 2011 +0200 @@ -6,7 +6,7 @@ #include "sieve-common.h" -#define EXT_INCLUDE_MAX_NESTING_LEVEL 10 -#define EXT_INCLUDE_MAX_INCLUDES 255 +#define EXT_INCLUDE_DEFAULT_MAX_NESTING_DEPTH 10 +#define EXT_INCLUDE_DEFAULT_MAX_INCLUDES 255 #endif /* __EXT_INCLUDE_LIMITS_H */ diff -r ce825c9671a6 -r f12899a3d02f src/testsuite/testsuite-script.c --- a/src/testsuite/testsuite-script.c Sun Sep 11 10:51:40 2011 +0200 +++ b/src/testsuite/testsuite-script.c Sun Sep 11 11:39:07 2011 +0200 @@ -51,19 +51,6 @@ return SIEVE_EXEC_FAILURE; script_path = t_strconcat(script_path, "/", script, NULL); - - /* Initialize environment */ - sieve_dir = strrchr(script_path, '/'); - if ( sieve_dir == NULL ) - sieve_dir= "./"; - else - sieve_dir = t_strdup_until(script_path, sieve_dir+1); - - /* Currently needed for include (FIXME) */ - testsuite_setting_set - ("sieve_dir", t_strconcat(sieve_dir, "included", NULL)); - testsuite_setting_set - ("sieve_global_dir", t_strconcat(sieve_dir, "included-global", NULL)); if ( (sbin = sieve_compile(svinst, script_path, NULL, testsuite_log_ehandler, NULL)) == NULL ) diff -r ce825c9671a6 -r f12899a3d02f tests/extensions/include/errors.svtest --- a/tests/extensions/include/errors.svtest Sun Sep 11 10:51:40 2011 +0200 +++ b/tests/extensions/include/errors.svtest Sun Sep 11 11:39:07 2011 +0200 @@ -94,11 +94,56 @@ */ test "Invalid Script Names" { - if test_script_compile "errors/scriptname.sieve" { - test_fail "compile should have failed"; - } + if test_script_compile "errors/scriptname.sieve" { + test_fail "compile should have failed"; + } - if not test_error :count "eq" :comparator "i;ascii-numeric" "8" { - test_fail "wrong number of errors reported"; - } + if not test_error :count "eq" :comparator "i;ascii-numeric" "8" { + test_fail "wrong number of errors reported"; + } } + +/* Include limit */ + +test "Include limit" { + test_config_set "sieve_include_max_includes" "3"; + test_config_reload :extension "include"; + + if test_script_compile "errors/include-limit.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "2" { + test_fail "wrong number of errors reported"; + } + + test_config_set "sieve_include_max_includes" "255"; + test_config_reload :extension "include"; + + if not test_script_compile "errors/include-limit.sieve" { + test_fail "compile should have succeeded"; + } +} + +/* Depth limit */ + +test "Depth limit" { + test_config_set "sieve_include_max_nesting_depth" "2"; + test_config_reload :extension "include"; + + if test_script_compile "errors/depth-limit.sieve" { + test_fail "compile should have failed"; + } + + if not test_error :count "eq" :comparator "i;ascii-numeric" "4" { + test_fail "wrong number of errors reported"; + } + + test_config_set "sieve_include_max_nesting_depth" "10"; + test_config_reload :extension "include"; + + if not test_script_compile "errors/depth-limit.sieve" { + test_fail "compile should have succeeded"; + } +} + diff -r ce825c9671a6 -r f12899a3d02f tests/extensions/include/errors/depth-limit.sieve --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/extensions/include/errors/depth-limit.sieve Sun Sep 11 11:39:07 2011 +0200 @@ -0,0 +1,3 @@ +require "include"; + +include :personal "depth-limit-1"; diff -r ce825c9671a6 -r f12899a3d02f tests/extensions/include/errors/include-limit.sieve --- /dev/null Thu Jan 01 00:00:00 1970 +0000 From pigeonhole at rename-it.nl Sun Sep 11 12:56:12 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 11 Sep 2011 11:56:12 +0200 Subject: dovecot-2.0-pigeonhole: Updated INSTALL documentation for new co... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/6e46c17ab0b7 changeset: 1526:6e46c17ab0b7 user: Stephan Bosch date: Sun Sep 11 11:56:07 2011 +0200 description: Updated INSTALL documentation for new configuration options of the include extension. diffstat: INSTALL | 9 + doc/include.txt | 32 + doc/rfc/draft-ietf-sieve-include-03.txt | 784 ------------------------------------- doc/rfc/draft-ietf-sieve-include-05.txt | 784 +++++++++++++++++++++++++++++++++++++ doc/vacation.txt | 2 +- 5 files changed, 826 insertions(+), 785 deletions(-) diffs (truncated from 1643 to 300 lines): diff -r f12899a3d02f -r 6e46c17ab0b7 INSTALL --- a/INSTALL Sun Sep 11 11:39:07 2011 +0200 +++ b/INSTALL Sun Sep 11 11:56:07 2011 +0200 @@ -268,6 +268,15 @@ configuration options. Refer to doc/vacation.txt for settings specific to the vacation extension. +- Include extension: + + The Sieve include extension (draft) permits users to include one Sieve script + into another. + + The include extension is available by default, but it has its own specific + configuration options. Refer to doc/include.txt for settings specific to the + include extension. + - Spamtest and Virustest extensions: Using the spamtest and virustest extensions (RFC 5235), the Sieve language diff -r f12899a3d02f -r 6e46c17ab0b7 doc/include.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/include.txt Sun Sep 11 11:56:07 2011 +0200 @@ -0,0 +1,32 @@ +Include Extension + +Relevant Specifications +======================= + +draft-ietf-sieve-include-05 - doc/rfc/draft-ietf-sieve-include-05.txt + +Description +=========== + +The Sieve include extension permits users to include one Sieve script into +another. This can make managing large scripts or multiple sets of scripts much +easier, and allows a site and its users to build up libraries of scripts. Users +are able to include their own personal scripts or site-wide scripts. + +Included scripts can include more scripts of their own, yielding a tree of +included scripts with the main script (typically the user's personal script) at +its root. + +Configuration +============= + +The include extension is available by default. The include extension has its own +specific settings. The following settings can be configured for the include +extension (default values are indicated): + +sieve_include_max_includes = 255 + The maximum number of scripts that may be included. This is the total number + of scripts involved in the include tree. + +sieve_include_max_nesting_depth = 10 + The maximum nesting depth for the include tree. diff -r f12899a3d02f -r 6e46c17ab0b7 doc/rfc/draft-ietf-sieve-include-03.txt --- a/doc/rfc/draft-ietf-sieve-include-03.txt Sun Sep 11 11:39:07 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,784 +0,0 @@ - - - -Network Working Group C. Daboo -Internet-Draft A. Stone -Expires: January 30, 2010 July 29, 2009 - - - Sieve Email Filtering: Include Extension - draft-ietf-sieve-include-03 - -Status of this Memo - - This Internet-Draft is submitted to IETF in full conformance with the - provisions of BCP 78 and BCP 79. This document may contain material - from IETF Documents or IETF Contributions published or made publicly - available before November 10, 2008. The person(s) controlling the - copyright in some of this material may not have granted the IETF - Trust the right to allow modifications of such material outside the - IETF Standards Process. Without obtaining an adequate license from - the person(s) controlling the copyright in such materials, this - document may not be modified outside the IETF Standards Process, and - derivative works of it may not be created outside the IETF Standards - Process, except to format it for publication as an RFC or to - translate it into languages other than English. - - Internet-Drafts are working documents of the Internet Engineering - Task Force (IETF), its areas, and its working groups. Note that - other groups may also distribute working documents as Internet- - Drafts. - - Internet-Drafts are draft documents valid for a maximum of six months - and may be updated, replaced, or obsoleted by other documents at any - time. It is inappropriate to use Internet-Drafts as reference - material or to cite them other than as "work in progress." - - The list of current Internet-Drafts can be accessed at - http://www.ietf.org/ietf/1id-abstracts.txt. - - The list of Internet-Draft Shadow Directories can be accessed at - http://www.ietf.org/shadow.html. - - This Internet-Draft will expire on January 30, 2010. - -Copyright Notice - - Copyright (c) 2009 IETF Trust and the persons identified as the - document authors. All rights reserved. - - This document is subject to BCP 78 and the IETF Trust's Legal - Provisions Relating to IETF Documents in effect on the date of - - - -Daboo & Stone Expires January 30, 2010 [Page 1] - -Internet-Draft Sieve Extension: Include July 2009 - - - publication of this document (http://trustee.ietf.org/license-info). - Please review these documents carefully, as they describe your rights - and restrictions with respect to this document. - -Abstract - - The Sieve Email Filtering "include" extension permits users to - include one Sieve script inside another. This can make managing - large scripts or multiple sets of scripts much easier, and allows a - site and its users to build up libraries of scripts. Users are able - to include their own personal scripts or site-wide scripts. - -Change History (to be removed prior to publication as an RFC) - - Changes from ietf-02 to ietf-03: - - a. Setting a variable then calling global on it is an error - (something like 'use strict'). - - b. Specify that the 'global' keyword is only available when - 'variables' has also been required. - - c. Uploading a script that includes a nonexistent script is not an - error at upload time. - - Changes from ietf-01 to ietf-02: - - a. Require that script names must be constant strings, not subject - to variable expansion. - - b. Try the phrase immediate script instead of current script. - - c. Clarify that "global 'varname'" and "global.varname" refer to the - same variable. - - d. Drop the requirement the global keywords come after require and - before anything else. - - Changes from ietf-00 to ietf-01: - - a. Replaced import/export with global. - - b. Added :once modifier to include. - - c. Added global namespace to see if it holds water. - - Changes from daboo-06 to ietf-00: - - - - -Daboo & Stone Expires January 30, 2010 [Page 2] - -Internet-Draft Sieve Extension: Include July 2009 - - - a. None - - Changes from -05 to -06: - - a. Aaron Stone joins as author. - - b. Removed | characters from the script examples. - - c. Updated draft references to published RFCs. - - Changes from -04 to -05: - - a. Fixed examples. - - b. Relaxed requirement that imported/exported variables be set - before being used. - - Changes from -03 to -04: - - a. Fixed missing 2119 definitions. - - b. Defined interaction with variables through use of import and - export commands. - - Changes from -02 to -03: - - a. Refreshing expired draft (updated for nits). - - b. Syntax -> Usage. - - c. Updated to 3028bis reference. - - Changes from -01 to -02: - - a. Minor formatting changes only - refreshing expired draft. - - Changes from -00 to -01: - - a. Added IPR boiler plate. - - b. Re-ordered sections at start to conform to RFC style. - - c. Moved recursion comment into General Considerations section. - - d. Switched to using optional parameter to indicate personal vs - global. - - - - - -Daboo & Stone Expires January 30, 2010 [Page 3] - -Internet-Draft Sieve Extension: Include July 2009 - - - e. Explicitly state that an error occurs when a missing script is - included. - - -Table of Contents - - 1. Introduction and Overview . . . . . . . . . . . . . . . . . . 5 - 2. Conventions Used in This Document . . . . . . . . . . . . . . 5 - 3. Include Extension . . . . . . . . . . . . . . . . . . . . . . 5 - 3.1. General Considerations . . . . . . . . . . . . . . . . . . 5 - 3.2. Control Structure include . . . . . . . . . . . . . . . . 6 - 3.3. Control Structure return . . . . . . . . . . . . . . . . . 10 - 3.4. Interaction with Variables . . . . . . . . . . . . . . . . 10 - 3.4.1. Control Structure global . . . . . . . . . . . . . . . 10 - 3.4.2. Variables Namespace global . . . . . . . . . . . . . . 12 - 4. Security Considerations . . . . . . . . . . . . . . . . . . . 12 - 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 - 5.1. "include" Extension Registration . . . . . . . . . . . . . 13 - 6. References . . . . . . . . . . . . . . . . . . . . . . . . . . 13 - 6.1. Normative References . . . . . . . . . . . . . . . . . . . 13 - 6.2. Informative References . . . . . . . . . . . . . . . . . . 13 - Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 13 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 13 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Daboo & Stone Expires January 30, 2010 [Page 4] - -Internet-Draft Sieve Extension: Include July 2009 - - -1. Introduction and Overview - - It's convenient to be able to break SIEVE [RFC5228] scripts down into - smaller components which can be reused in a variety of different - circumstances. For example, users may want to have a default script - and a special 'vacation' script, the latter being activated when the - user goes on vacation. In that case the default actions should - continue to be run, but a vacation command should be executed first. - One option is to edit the default script to add or remove the - vacation command as needed. Another is to have a vacation script - that simply has a vacation command and then includes the default - script. - - From dovecot at dovecot.org Mon Sep 12 12:02:48 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 12:02:48 +0300 Subject: dovecot-2.1: lib-storage: Removed unused struct stat parameter f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/896ed71917aa changeset: 13441:896ed71917aa user: Timo Sirainen date: Mon Sep 12 12:02:33 2011 +0300 description: lib-storage: Removed unused struct stat parameter from mailbox_list.get_mailbox_flags() diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 3 +-- src/lib-storage/list/mailbox-list-maildir-iter.c | 9 ++------- src/lib-storage/list/mailbox-list-maildir.h | 1 - src/lib-storage/list/mailbox-list-none.c | 1 - src/lib-storage/mailbox-list-private.h | 1 - src/lib-storage/mailbox-list.c | 3 +-- 6 files changed, 4 insertions(+), 14 deletions(-) diffs (129 lines): diff -r 3e1aad7bfd97 -r 896ed71917aa src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Fri Sep 09 13:14:07 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Mon Sep 12 12:02:33 2011 +0300 @@ -523,7 +523,6 @@ const char *fname = entry->fname; const char *list_path, *root_dir; enum imap_match_result match; - struct stat st; int ret; /* skip . and .. */ @@ -556,7 +555,7 @@ /* get the info.flags using callback */ ret = ctx->ctx.list->v. get_mailbox_flags(ctx->ctx.list, ctx->dir->real_path, fname, - entry->type, &st, &ctx->info.flags); + entry->type, &ctx->info.flags); if (ret <= 0) return ret; diff -r 3e1aad7bfd97 -r 896ed71917aa src/lib-storage/list/mailbox-list-maildir-iter.c --- a/src/lib-storage/list/mailbox-list-maildir-iter.c Fri Sep 09 13:14:07 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir-iter.c Mon Sep 12 12:02:33 2011 +0300 @@ -150,7 +150,6 @@ static bool maildir_get_type(const char *dir, const char *fname, enum mailbox_list_file_type *type_r, - struct stat *st_r, enum mailbox_info_flags *flags) { const char *path; @@ -168,7 +167,6 @@ return FALSE; } - *st_r = st; if (S_ISDIR(st.st_mode)) { *type_r = MAILBOX_LIST_FILE_TYPE_DIR; return TRUE; @@ -184,10 +182,8 @@ int maildir_list_get_mailbox_flags(struct mailbox_list *list, const char *dir, const char *fname, enum mailbox_list_file_type type, - struct stat *st_r, enum mailbox_info_flags *flags_r) { - memset(st_r, 0, sizeof(*st_r)); *flags_r = 0; switch (type) { @@ -205,7 +201,7 @@ return 1; } - if (!maildir_get_type(dir, fname, &type, st_r, flags_r)) + if (!maildir_get_type(dir, fname, &type, flags_r)) return 0; break; } @@ -272,7 +268,6 @@ enum imap_match_result match; struct mailbox_node *node; bool created; - struct stat st; int ret; fname = d->d_name; @@ -302,7 +297,7 @@ T_BEGIN { ret = list->v.get_mailbox_flags(list, ctx->dir, fname, - mailbox_list_get_file_type(d), &st, &flags); + mailbox_list_get_file_type(d), &flags); } T_END; if (ret <= 0) return ret; diff -r 3e1aad7bfd97 -r 896ed71917aa src/lib-storage/list/mailbox-list-maildir.h --- a/src/lib-storage/list/mailbox-list-maildir.h Fri Sep 09 13:14:07 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir.h Mon Sep 12 12:02:33 2011 +0300 @@ -28,7 +28,6 @@ int maildir_list_get_mailbox_flags(struct mailbox_list *list, const char *dir, const char *fname, enum mailbox_list_file_type type, - struct stat *st_r, enum mailbox_info_flags *flags); #endif diff -r 3e1aad7bfd97 -r 896ed71917aa src/lib-storage/list/mailbox-list-none.c --- a/src/lib-storage/list/mailbox-list-none.c Fri Sep 09 13:14:07 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-none.c Mon Sep 12 12:02:33 2011 +0300 @@ -176,7 +176,6 @@ const char *dir ATTR_UNUSED, const char *fname ATTR_UNUSED, enum mailbox_list_file_type type ATTR_UNUSED, - struct stat *st_r ATTR_UNUSED, enum mailbox_info_flags *flags) { *flags = MAILBOX_NONEXISTENT; diff -r 3e1aad7bfd97 -r 896ed71917aa src/lib-storage/mailbox-list-private.h --- a/src/lib-storage/mailbox-list-private.h Fri Sep 09 13:14:07 2011 +0300 +++ b/src/lib-storage/mailbox-list-private.h Mon Sep 12 12:02:33 2011 +0300 @@ -66,7 +66,6 @@ int (*get_mailbox_flags)(struct mailbox_list *list, const char *dir, const char *fname, enum mailbox_list_file_type type, - struct stat *st_r, enum mailbox_info_flags *flags_r); /* Returns TRUE if name is mailbox's internal file/directory. If it does, mailbox deletion assumes it can safely delete it. */ diff -r 3e1aad7bfd97 -r 896ed71917aa src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Fri Sep 09 13:14:07 2011 +0300 +++ b/src/lib-storage/mailbox-list.c Mon Sep 12 12:02:33 2011 +0300 @@ -1282,7 +1282,6 @@ enum mailbox_info_flags *flags_r) { const char *path, *fname, *rootdir, *dir, *inbox; - struct stat st; unsigned int len; *flags_r = 0; @@ -1356,7 +1355,7 @@ } return list->v.get_mailbox_flags(list, dir, fname, MAILBOX_LIST_FILE_TYPE_UNKNOWN, - &st, flags_r); + flags_r); } static bool mailbox_list_init_changelog(struct mailbox_list *list) From dovecot at dovecot.org Mon Sep 12 12:38:17 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 12:38:17 +0300 Subject: dovecot-2.1: lib-storage: Finished previous get_mailbox_flags() ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7669862d95e7 changeset: 13442:7669862d95e7 user: Timo Sirainen date: Mon Sep 12 12:38:04 2011 +0300 description: lib-storage: Finished previous get_mailbox_flags() change. diffstat: src/lib-storage/list/mailbox-list-fs-flags.c | 3 --- src/lib-storage/list/mailbox-list-fs.h | 1 - 2 files changed, 0 insertions(+), 4 deletions(-) diffs (36 lines): diff -r 896ed71917aa -r 7669862d95e7 src/lib-storage/list/mailbox-list-fs-flags.c --- a/src/lib-storage/list/mailbox-list-fs-flags.c Mon Sep 12 12:02:33 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-flags.c Mon Sep 12 12:38:04 2011 +0300 @@ -109,13 +109,11 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list, const char *dir, const char *fname, enum mailbox_list_file_type type, - struct stat *st_r, enum mailbox_info_flags *flags_r) { struct stat st; const char *path; - memset(st_r, 0, sizeof(*st_r)); *flags_r = 0; if (*list->set.maildir_name != '\0') { @@ -165,7 +163,6 @@ return -1; } } - *st_r = st; if (!S_ISDIR(st.st_mode)) { if (strncmp(fname, ".nfs", 4) == 0) { diff -r 896ed71917aa -r 7669862d95e7 src/lib-storage/list/mailbox-list-fs.h --- a/src/lib-storage/list/mailbox-list-fs.h Mon Sep 12 12:02:33 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.h Mon Sep 12 12:38:04 2011 +0300 @@ -27,7 +27,6 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list, const char *dir, const char *fname, enum mailbox_list_file_type type, - struct stat *st_r, enum mailbox_info_flags *flags); #endif From dovecot at dovecot.org Mon Sep 12 12:41:17 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 12:41:17 +0300 Subject: dovecot-2.1: lib-storage: Fixed mailbox_list_mailbox() for backe... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/84e31a32293e changeset: 13443:84e31a32293e user: Timo Sirainen date: Mon Sep 12 12:40:34 2011 +0300 description: lib-storage: Fixed mailbox_list_mailbox() for backends without get_mailbox_flags(). diffstat: src/lib-storage/mailbox-list.c | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-) diffs (34 lines): diff -r 7669862d95e7 -r 84e31a32293e src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Mon Sep 12 12:38:04 2011 +0300 +++ b/src/lib-storage/mailbox-list.c Mon Sep 12 12:40:34 2011 +0300 @@ -1314,13 +1314,26 @@ return 1; } + if (list->v.get_mailbox_flags == NULL) { + /* can't do this optimized. do it the slow way. */ + struct mailbox_list_iterate_context *iter; + const struct mailbox_info *info; + const char *vname; + + vname = mailbox_list_get_vname(list, name); + iter = mailbox_list_iter_init(list, vname, 0); + info = mailbox_list_iter_next(iter); + if (info == NULL) + *flags_r = MAILBOX_NONEXISTENT; + else + *flags_r = info->flags; + return mailbox_list_iter_deinit(&iter); + } + rootdir = mailbox_list_get_path(list, NULL, MAILBOX_LIST_PATH_TYPE_MAILBOX); + i_assert(rootdir != NULL); path = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_DIR); - if (rootdir == NULL) { - /* shouldn't happen with anything except shared mailboxes */ - return 0; - } fname = strrchr(path, '/'); if (fname == NULL) { From dovecot at dovecot.org Mon Sep 12 12:41:17 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 12:41:17 +0300 Subject: dovecot-2.1: imapc: Fixes to handling non-empty imapc namespace ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/59c7b30973cf changeset: 13444:59c7b30973cf user: Timo Sirainen date: Mon Sep 12 12:41:09 2011 +0300 description: imapc: Fixes to handling non-empty imapc namespace prefix. diffstat: src/lib-storage/index/imapc/imapc-list.c | 18 +++++++++++++++--- src/lib-storage/index/imapc/imapc-storage.c | 10 ++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diffs (69 lines): diff -r 84e31a32293e -r 59c7b30973cf src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Mon Sep 12 12:40:34 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Mon Sep 12 12:41:09 2011 +0300 @@ -14,6 +14,8 @@ struct imapc_mailbox_list_iterate_context { struct mailbox_list_iterate_context ctx; struct mailbox_tree_context *tree; + struct mailbox_node *ns_root; + struct mailbox_tree_iterate_context *iter; struct mailbox_info info; }; @@ -321,6 +323,7 @@ struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; struct mailbox_list_iterate_context *_ctx; struct imapc_mailbox_list_iterate_context *ctx; + const char *ns_root_name; char sep; int ret = 0; @@ -353,6 +356,13 @@ ctx->tree = mailbox_tree_init(sep); imapc_list_build_match_tree(ctx); + + if (list->list.ns->prefix_len > 0) { + ns_root_name = t_strndup(_list->ns->prefix, + _list->ns->prefix_len - 1); + ctx->ns_root = mailbox_tree_lookup(ctx->tree, ns_root_name); + } + ctx->iter = mailbox_tree_iterate_init(ctx->tree, NULL, 0); if (ret < 0) ctx->ctx.failed = TRUE; @@ -373,9 +383,11 @@ if ((_ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) return mailbox_list_subscriptions_iter_next(_ctx); - node = mailbox_tree_iterate_next(ctx->iter, &name); - if (node == NULL) - return NULL; + do { + node = mailbox_tree_iterate_next(ctx->iter, &name); + if (node == NULL) + return NULL; + } while (node == ctx->ns_root); ctx->info.name = name; ctx->info.flags = node->flags; diff -r 84e31a32293e -r 59c7b30973cf src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 12 12:40:34 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 12 12:41:09 2011 +0300 @@ -378,6 +378,16 @@ examine = (box->flags & MAILBOX_FLAG_READONLY) != 0 && (box->flags & MAILBOX_FLAG_DROP_RECENT) == 0; + if (*box->name == '\0' && + (box->list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) { + /* trying to open INBOX as the namespace prefix. + Don't allow this. */ + mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND, + "Mailbox isn't selectable"); + mailbox_close(box); + return -1; + } + mbox->opening = TRUE; ctx.mbox = mbox; ctx.ret = -2; From dovecot at dovecot.org Mon Sep 12 13:14:36 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 13:14:36 +0300 Subject: dovecot-2.1: lib-storage: Handle INBOX in the common mailbox_exi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3844653d483a changeset: 13445:3844653d483a user: Timo Sirainen date: Mon Sep 12 13:13:35 2011 +0300 description: lib-storage: Handle INBOX in the common mailbox_exists() code. diffstat: src/lib-storage/index/index-storage.c | 17 ++++------------- src/lib-storage/index/index-storage.h | 3 +-- src/lib-storage/index/maildir/maildir-storage.c | 8 ++++---- src/lib-storage/mail-storage.c | 6 ++++++ 4 files changed, 15 insertions(+), 19 deletions(-) diffs (84 lines): diff -r 59c7b30973cf -r 3844653d483a src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Mon Sep 12 12:41:09 2011 +0300 +++ b/src/lib-storage/index/index-storage.c Mon Sep 12 13:13:35 2011 +0300 @@ -151,28 +151,19 @@ box->index_prefix); } -int index_storage_mailbox_exists(struct mailbox *box, bool auto_boxes, +int index_storage_mailbox_exists(struct mailbox *box, + bool auto_boxes ATTR_UNUSED, enum mailbox_existence *existence_r) { - return index_storage_mailbox_exists_full(box, auto_boxes, - NULL, existence_r); + return index_storage_mailbox_exists_full(box, NULL, existence_r); } -int index_storage_mailbox_exists_full(struct mailbox *box, bool auto_boxes, - const char *subdir, +int index_storage_mailbox_exists_full(struct mailbox *box, const char *subdir, enum mailbox_existence *existence_r) { struct stat st; const char *path, *path2; - if (strcmp(box->name, "INBOX") == 0 && - (box->list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && - auto_boxes) { - /* INBOX always exists */ - *existence_r = MAILBOX_EXISTENCE_SELECT; - return 0; - } - /* see if it's selectable */ path = mailbox_list_get_path(box->list, box->name, MAILBOX_LIST_PATH_TYPE_MAILBOX); diff -r 59c7b30973cf -r 3844653d483a src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Mon Sep 12 12:41:09 2011 +0300 +++ b/src/lib-storage/index/index-storage.h Mon Sep 12 13:13:35 2011 +0300 @@ -59,8 +59,7 @@ const char *index_prefix); int index_storage_mailbox_exists(struct mailbox *box, bool auto_boxes, enum mailbox_existence *existence_r); -int index_storage_mailbox_exists_full(struct mailbox *box, bool auto_boxes, - const char *subdir, +int index_storage_mailbox_exists_full(struct mailbox *box, const char *subdir, enum mailbox_existence *existence_r); int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory); int index_storage_mailbox_enable(struct mailbox *box, diff -r 59c7b30973cf -r 3844653d483a src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Mon Sep 12 12:41:09 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Mon Sep 12 13:13:35 2011 +0300 @@ -323,11 +323,11 @@ return FALSE; } -static int maildir_mailbox_exists(struct mailbox *box, bool auto_boxes, - enum mailbox_existence *existence_r) +static int +maildir_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED, + enum mailbox_existence *existence_r) { - return index_storage_mailbox_exists_full(box, auto_boxes, - "cur", existence_r); + return index_storage_mailbox_exists_full(box, "cur", existence_r); } static int maildir_mailbox_open(struct mailbox *box) diff -r 59c7b30973cf -r 3844653d483a src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Mon Sep 12 12:41:09 2011 +0300 +++ b/src/lib-storage/mail-storage.c Mon Sep 12 13:13:35 2011 +0300 @@ -694,6 +694,12 @@ return 0; } + if (strcmp(box->name, "INBOX") == 0 && box->inbox_user && auto_boxes) { + /* INBOX always exists */ + *existence_r = MAILBOX_EXISTENCE_SELECT; + return 0; + } + return box->v.exists(box, auto_boxes, existence_r); } From dovecot at dovecot.org Mon Sep 12 13:14:36 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 13:14:36 +0300 Subject: dovecot-2.1: imapc: Fixed mailbox_exists() to actually work. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cc9332de9982 changeset: 13446:cc9332de9982 user: Timo Sirainen date: Mon Sep 12 13:14:26 2011 +0300 description: imapc: Fixed mailbox_exists() to actually work. This fixes problems with subscribing to mailboxes. diffstat: src/lib-storage/index/imapc/imapc-list.c | 47 +++++++++++++++++++++++----- src/lib-storage/index/imapc/imapc-list.h | 3 + src/lib-storage/index/imapc/imapc-storage.c | 20 +++++++++++- 3 files changed, 60 insertions(+), 10 deletions(-) diffs (148 lines): diff -r 3844653d483a -r cc9332de9982 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Mon Sep 12 13:13:35 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Mon Sep 12 13:14:26 2011 +0300 @@ -31,6 +31,8 @@ list = p_new(pool, struct imapc_mailbox_list, 1); list->list = imapc_mailbox_list; list->list.pool = pool; + /* separator is set when storage is created */ + list->mailboxes = mailbox_tree_init('\0'); return &list->list; } @@ -38,8 +40,7 @@ { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; - if (list->mailboxes != NULL) - mailbox_tree_deinit(&list->mailboxes); + mailbox_tree_deinit(&list->mailboxes); if (list->tmp_subscriptions != NULL) mailbox_tree_deinit(&list->tmp_subscriptions); pool_unref(&list->list.pool); @@ -118,8 +119,7 @@ /* we can't handle NIL separator yet */ list->sep = sep == NULL ? '/' : sep[0]; - if (list->mailboxes != NULL) - mailbox_tree_set_separator(list->mailboxes, list->sep); + mailbox_tree_set_separator(list->mailboxes, list->sep); } else { (void)imapc_list_update_tree(list, list->mailboxes, args); } @@ -273,17 +273,15 @@ { struct imapc_simple_context ctx; + i_assert(list->sep != '\0'); + if (list->refreshed_mailboxes) return 0; - if (list->sep == '\0') - (void)mailbox_list_get_hierarchy_sep(&list->list); - imapc_simple_context_init(&ctx, list->storage); imapc_client_cmdf(list->storage->client, imapc_list_simple_callback, &ctx, "LIST \"\" *"); - if (list->mailboxes != NULL) - mailbox_tree_deinit(&list->mailboxes); + mailbox_tree_deinit(&list->mailboxes); list->mailboxes = mailbox_tree_init(list->sep); imapc_simple_run(&ctx); @@ -557,6 +555,37 @@ return ctx.ret; } +int imapc_list_get_mailbox_flags(struct mailbox_list *_list, const char *name, + enum mailbox_info_flags *flags_r) +{ + struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; + struct imapc_simple_context sctx; + struct mailbox_node *node; + const char *vname; + + i_assert(list->sep != '\0'); + + vname = mailbox_list_default_get_vname(_list, name); + node = mailbox_tree_lookup(list->mailboxes, vname); + if (node != NULL) + node->flags |= MAILBOX_NONEXISTENT; + + /* refresh the mailbox flags */ + imapc_simple_context_init(&sctx, list->storage); + imapc_client_cmdf(list->storage->client, imapc_simple_callback, + &sctx, "LIST \"\" %s", name); + imapc_simple_run(&sctx); + if (sctx.ret < 0) + return -1; + + node = mailbox_tree_lookup(list->mailboxes, vname); + if (node == NULL) + *flags_r = MAILBOX_NONEXISTENT; + else + *flags_r = node->flags; + return 0; +} + struct mailbox_list imapc_mailbox_list = { .name = MAILBOX_LIST_NAME_IMAPC, .props = MAILBOX_LIST_PROP_NO_ROOT, diff -r 3844653d483a -r cc9332de9982 src/lib-storage/index/imapc/imapc-list.h --- a/src/lib-storage/index/imapc/imapc-list.h Mon Sep 12 13:13:35 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.h Mon Sep 12 13:14:26 2011 +0300 @@ -22,6 +22,9 @@ unsigned int index_list_failed:1; }; +int imapc_list_get_mailbox_flags(struct mailbox_list *list, const char *name, + enum mailbox_info_flags *flags_r); + void imapc_list_register_callbacks(struct imapc_mailbox_list *list); #endif diff -r 3844653d483a -r cc9332de9982 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 12 13:13:35 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 12 13:14:26 2011 +0300 @@ -5,6 +5,7 @@ #include "str.h" #include "imap-arg.h" #include "imap-resp-code.h" +#include "mailbox-tree.h" #include "imapc-mail.h" #include "imapc-client-private.h" #include "imapc-connection.h" @@ -341,6 +342,23 @@ return &mbox->box; } +static int +imapc_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED, + enum mailbox_existence *existence_r) +{ + enum mailbox_info_flags flags; + + if (imapc_list_get_mailbox_flags(box->list, box->name, &flags) < 0) + return -1; + if ((flags & MAILBOX_NONEXISTENT) != 0) + *existence_r = MAILBOX_EXISTENCE_NONE; + else if ((flags & MAILBOX_NOSELECT) != 0) + *existence_r = MAILBOX_EXISTENCE_NOSELECT; + else + *existence_r = MAILBOX_EXISTENCE_SELECT; + return 0; +} + static void imapc_mailbox_open_callback(const struct imapc_command_reply *reply, void *context) @@ -647,7 +665,7 @@ .v = { index_storage_is_readonly, index_storage_mailbox_enable, - index_storage_mailbox_exists, + imapc_mailbox_exists, imapc_mailbox_open, imapc_mailbox_close, index_storage_mailbox_free, From dovecot at dovecot.org Mon Sep 12 14:01:53 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:01:53 +0300 Subject: dovecot-2.1: quota-dirsize: Get the quota from "mail root dir", ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1a39f7648c9d changeset: 13447:1a39f7648c9d user: Timo Sirainen date: Mon Sep 12 14:01:36 2011 +0300 description: quota-dirsize: Get the quota from "mail root dir", not "mailboxes dir". Normally they are different only with dbox (~/dbox vs. ~/dbox/mailboxes). This mainly fixes using dirsize with mdbox, where the mail data is in ~/dbox/storage/ directory. Patch by ????? ??????. diffstat: src/plugins/quota/quota-dirsize.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r cc9332de9982 -r 1a39f7648c9d src/plugins/quota/quota-dirsize.c --- a/src/plugins/quota/quota-dirsize.c Mon Sep 12 13:14:26 2011 +0300 +++ b/src/plugins/quota/quota-dirsize.c Mon Sep 12 14:01:36 2011 +0300 @@ -163,7 +163,7 @@ is_file = mail_storage_is_mailbox_file(namespaces[i]->storage); path = mailbox_list_get_path(namespaces[i]->list, NULL, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + MAILBOX_LIST_PATH_TYPE_DIR); quota_count_path_add(&paths, path, FALSE); /* INBOX may be in different path. */ From dovecot at dovecot.org Mon Sep 12 14:02:47 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:02:47 +0300 Subject: dovecot-2.0: quota-dirsize: Get the quota from "mail root dir", ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/9ea79795088d changeset: 12905:9ea79795088d user: Timo Sirainen date: Mon Sep 12 14:01:36 2011 +0300 description: quota-dirsize: Get the quota from "mail root dir", not "mailboxes dir". Normally they are different only with dbox (~/dbox vs. ~/dbox/mailboxes). This mainly fixes using dirsize with mdbox, where the mail data is in ~/dbox/storage/ directory. Patch by ????? ??????. diffstat: src/plugins/quota/quota-dirsize.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r d00c95f33643 -r 9ea79795088d src/plugins/quota/quota-dirsize.c --- a/src/plugins/quota/quota-dirsize.c Mon Sep 12 14:02:30 2011 +0300 +++ b/src/plugins/quota/quota-dirsize.c Mon Sep 12 14:01:36 2011 +0300 @@ -163,7 +163,7 @@ is_file = mail_storage_is_mailbox_file(namespaces[i]->storage); path = mailbox_list_get_path(namespaces[i]->list, NULL, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + MAILBOX_LIST_PATH_TYPE_DIR); quota_count_path_add(&paths, path, FALSE); /* INBOX may be in different path. */ From dovecot at dovecot.org Mon Sep 12 14:02:46 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:02:46 +0300 Subject: dovecot-2.0: ldap: Fixed auth binds for nonexistent users with s... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/d00c95f33643 changeset: 12904:d00c95f33643 user: Timo Sirainen date: Mon Sep 12 14:02:30 2011 +0300 description: ldap: Fixed auth binds for nonexistent users with some LDAP servers. diffstat: src/auth/passdb-ldap.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 0f63b7c5dd7c -r d00c95f33643 src/auth/passdb-ldap.c --- a/src/auth/passdb-ldap.c Thu Sep 08 16:24:18 2011 +0300 +++ b/src/auth/passdb-ldap.c Mon Sep 12 14:02:30 2011 +0300 @@ -157,6 +157,10 @@ } auth_request_log_info(auth_request, "ldap", "%s", str); passdb_result = PASSDB_RESULT_PASSWORD_MISMATCH; + } else if (ret == LDAP_NO_SUCH_OBJECT) { + passdb_result = PASSDB_RESULT_USER_UNKNOWN; + auth_request_log_info(auth_request, "ldap", + "unknown user"); } else { auth_request_log_error(auth_request, "ldap", "ldap_bind() failed: %s", From dovecot at dovecot.org Mon Sep 12 14:28:21 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:28:21 +0300 Subject: dovecot-2.0: mbox: Fixed fetching last message from compressed m... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/a930318a74a1 changeset: 12906:a930318a74a1 user: Timo Sirainen date: Mon Sep 12 14:27:46 2011 +0300 description: mbox: Fixed fetching last message from compressed mboxes. diffstat: src/lib-storage/index/mbox/mbox-mail.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diffs (28 lines): diff -r 9ea79795088d -r a930318a74a1 src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Mon Sep 12 14:01:36 2011 +0300 +++ b/src/lib-storage/index/mbox/mbox-mail.c Mon Sep 12 14:27:46 2011 +0300 @@ -259,15 +259,19 @@ if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq)) i_panic("Message unexpectedly expunged from index"); - if (seq == hdr->messages_count) { + if (seq < hdr->messages_count) { + if (mbox_file_lookup_offset(mbox, view, seq + 1, + next_offset_r) <= 0) + ret = -1; + } else if (mail->mail.mail.box->input != NULL) { + /* opened the mailbox as input stream. we can't trust the + sync_size, since it's wrong with compressed mailboxes */ + ret = 0; + } else { /* last message, use the synced mbox size */ trailer_size = mbox->storage->storage.set->mail_save_crlf ? 2 : 1; *next_offset_r = mbox->mbox_hdr.sync_size - trailer_size; - } else { - if (mbox_file_lookup_offset(mbox, view, seq + 1, - next_offset_r) <= 0) - ret = -1; } mail_index_view_close(&view); return ret; From dovecot at dovecot.org Mon Sep 12 14:28:21 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:28:21 +0300 Subject: dovecot-2.1: mbox: Fixed fetching last message from compressed m... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ea8f667ac6ef changeset: 13448:ea8f667ac6ef user: Timo Sirainen date: Mon Sep 12 14:27:46 2011 +0300 description: mbox: Fixed fetching last message from compressed mboxes. diffstat: src/lib-storage/index/mbox/mbox-mail.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diffs (28 lines): diff -r 1a39f7648c9d -r ea8f667ac6ef src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Mon Sep 12 14:01:36 2011 +0300 +++ b/src/lib-storage/index/mbox/mbox-mail.c Mon Sep 12 14:27:46 2011 +0300 @@ -259,15 +259,19 @@ if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq)) i_panic("Message unexpectedly expunged from index"); - if (seq == hdr->messages_count) { + if (seq < hdr->messages_count) { + if (mbox_file_lookup_offset(mbox, view, seq + 1, + next_offset_r) <= 0) + ret = -1; + } else if (mail->mail.mail.box->input != NULL) { + /* opened the mailbox as input stream. we can't trust the + sync_size, since it's wrong with compressed mailboxes */ + ret = 0; + } else { /* last message, use the synced mbox size */ trailer_size = mbox->storage->storage.set->mail_save_crlf ? 2 : 1; *next_offset_r = mbox->mbox_hdr.sync_size - trailer_size; - } else { - if (mbox_file_lookup_offset(mbox, view, seq + 1, - next_offset_r) <= 0) - ret = -1; } mail_index_view_close(&view); return ret; From dovecot at dovecot.org Mon Sep 12 14:32:48 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:32:48 +0300 Subject: dovecot-2.1: indexer: Fixed assert-crash when number of indexed ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f4899179ad4c changeset: 13449:f4899179ad4c user: Timo Sirainen date: Mon Sep 12 14:32:37 2011 +0300 description: indexer: Fixed assert-crash when number of indexed messages was divisible by 100. diffstat: src/indexer/master-connection.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diffs (14 lines): diff -r ea8f667ac6ef -r f4899179ad4c src/indexer/master-connection.c --- a/src/indexer/master-connection.c Mon Sep 12 14:27:46 2011 +0300 +++ b/src/indexer/master-connection.c Mon Sep 12 14:32:37 2011 +0300 @@ -87,9 +87,7 @@ mail_precache(mail); if (++counter % 100 == 0) { percentage = counter*100 / max; - if (percentage != percentage_sent) { - i_assert(percentage < 100); - + if (percentage != percentage_sent && percentage < 100) { percentage_sent = percentage; i_snprintf(percentage_str, sizeof(percentage_str), "%u\n", From dovecot at dovecot.org Mon Sep 12 14:41:03 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:41:03 +0300 Subject: dovecot-2.1: virtual: Compile fix for recent mailbox_exists() ch... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a2c62701a1c4 changeset: 13450:a2c62701a1c4 user: Timo Sirainen date: Mon Sep 12 14:40:49 2011 +0300 description: virtual: Compile fix for recent mailbox_exists() change. diffstat: src/plugins/virtual/virtual-storage.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diffs (19 lines): diff -r f4899179ad4c -r a2c62701a1c4 src/plugins/virtual/virtual-storage.c --- a/src/plugins/virtual/virtual-storage.c Mon Sep 12 14:32:37 2011 +0300 +++ b/src/plugins/virtual/virtual-storage.c Mon Sep 12 14:40:49 2011 +0300 @@ -259,11 +259,11 @@ } } -static int virtual_mailbox_exists(struct mailbox *box, bool auto_boxes, - enum mailbox_existence *existence_r) +static int +virtual_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED, + enum mailbox_existence *existence_r) { - return index_storage_mailbox_exists_full(box, auto_boxes, - VIRTUAL_CONFIG_FNAME, + return index_storage_mailbox_exists_full(box, VIRTUAL_CONFIG_FNAME, existence_r); } From dovecot at dovecot.org Mon Sep 12 14:44:10 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:44:10 +0300 Subject: dovecot-2.1: stats: Avoid duplicate "Couldn't find session GUID"... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2492161a87f5 changeset: 13451:2492161a87f5 user: Timo Sirainen date: Mon Sep 12 14:43:31 2011 +0300 description: stats: Avoid duplicate "Couldn't find session GUID" warnings. When it happens, just create a dummy session for it and log a warning once. diffstat: src/stats/mail-command.c | 5 ++--- src/stats/mail-session.c | 29 +++++++++++++++++++++++++---- src/stats/mail-session.h | 2 ++ 3 files changed, 29 insertions(+), 7 deletions(-) diffs (87 lines): diff -r a2c62701a1c4 -r 2492161a87f5 src/stats/mail-command.c --- a/src/stats/mail-command.c Mon Sep 12 14:40:49 2011 +0300 +++ b/src/stats/mail-command.c Mon Sep 12 14:43:31 2011 +0300 @@ -97,15 +97,14 @@ const char *error; unsigned int cmd_id; bool done; - int ret; /* [key=value ..] */ if (str_array_length(args) < 4) { *error_r = "UPDATE-CMD: Too few parameters"; return -1; } - if ((ret = mail_session_lookup(args[0], &session, error_r)) <= 0) - return ret; + if (mail_session_get(args[0], &session, error_r) < 0) + return -1; if (str_to_uint(args[1], &cmd_id) < 0 || cmd_id == 0) { *error_r = "UPDATE-CMD: Invalid command id"; diff -r a2c62701a1c4 -r 2492161a87f5 src/stats/mail-session.c --- a/src/stats/mail-session.c Mon Sep 12 14:40:49 2011 +0300 +++ b/src/stats/mail-session.c Mon Sep 12 14:43:31 2011 +0300 @@ -160,13 +160,35 @@ } *session_r = hash_table_lookup(mail_sessions_hash, session_guid); if (*session_r == NULL) { - i_warning("mail disconnect couldn't find session GUID: %s", + i_warning("Couldn't find session GUID: %s", guid_128_to_string(session_guid)); return 0; } return 1; } +int mail_session_get(const char *guid, struct mail_session **session_r, + const char **error_r) +{ + const char *new_args[5]; + int ret; + + if ((ret = mail_session_lookup(guid, session_r, error_r)) != 0) + return ret; + + /* Create a new dummy session to avoid repeated warnings */ + new_args[0] = guid; + new_args[1] = ""; /* username */ + new_args[2] = ""; /* service */ + new_args[3] = "0"; /* pid */ + new_args[4] = NULL; + if (mail_session_connect_parse(new_args, error_r) < 0) + i_unreached(); + if (mail_session_lookup(guid, session_r, error_r) != 1) + i_unreached(); + return 0; +} + int mail_session_disconnect_parse(const char *const *args, const char **error_r) { struct mail_session *session; @@ -203,11 +225,10 @@ struct mail_session *session; struct mail_stats stats, diff_stats; const char *error; - int ret; /* [key=value ..] */ - if ((ret = mail_session_lookup(args[0], &session, error_r)) <= 0) - return ret; + if (mail_session_get(args[0], &session, error_r) < 0) + return -1; if (mail_stats_parse(args+1, &stats, error_r) < 0) { *error_r = t_strconcat("UPDATE-SESSION: ", *error_r, NULL); diff -r a2c62701a1c4 -r 2492161a87f5 src/stats/mail-session.h --- a/src/stats/mail-session.h Mon Sep 12 14:40:49 2011 +0300 +++ b/src/stats/mail-session.h Mon Sep 12 14:43:31 2011 +0300 @@ -16,6 +16,8 @@ int mail_session_lookup(const char *guid, struct mail_session **session_r, const char **error_r); +int mail_session_get(const char *guid, struct mail_session **session_r, + const char **error_r); void mail_session_refresh(struct mail_session *session, const struct mail_stats *diff_stats); From dovecot at dovecot.org Mon Sep 12 14:44:10 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 14:44:10 +0300 Subject: dovecot-2.1: stats: Increased idle timeout to 15 minutes. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/502b794f654b changeset: 13452:502b794f654b user: Timo Sirainen date: Mon Sep 12 14:44:01 2011 +0300 description: stats: Increased idle timeout to 15 minutes. diffstat: src/stats/mail-session.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 2492161a87f5 -r 502b794f654b src/stats/mail-session.c --- a/src/stats/mail-session.c Mon Sep 12 14:43:31 2011 +0300 +++ b/src/stats/mail-session.c Mon Sep 12 14:44:01 2011 +0300 @@ -15,7 +15,7 @@ process associated with it has crashed, and forcibly disconnect the session. Must be larger than SESSION_STATS_FORCE_REFRESH_SECS in stats plugin */ -#define MAIL_SESSION_IDLE_TIMEOUT_MSECS (1000*60*10) +#define MAIL_SESSION_IDLE_TIMEOUT_MSECS (1000*60*15) static struct hash_table *mail_sessions_hash; /* sessions are sorted by their last_update timestamp, oldest first */ From dovecot at dovecot.org Mon Sep 12 16:19:07 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 16:19:07 +0300 Subject: dovecot-2.1: fts-solr: Don't break when there are duplicate From... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/600034b77a1c changeset: 13453:600034b77a1c user: Timo Sirainen date: Mon Sep 12 16:18:56 2011 +0300 description: fts-solr: Don't break when there are duplicate From/To/Subject/etc. fields. diffstat: src/plugins/fts-solr/fts-backend-solr.c | 101 +++++++++++++++++-------------- 1 files changed, 56 insertions(+), 45 deletions(-) diffs (189 lines): diff -r 502b794f654b -r 600034b77a1c src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Mon Sep 12 14:44:01 2011 +0300 +++ b/src/plugins/fts-solr/fts-backend-solr.c Mon Sep 12 16:18:56 2011 +0300 @@ -22,6 +22,11 @@ struct fts_backend backend; }; +struct solr_fts_field { + char *key; + string_t *value; +}; + struct solr_fts_backend_update_context { struct fts_backend_update_context ctx; @@ -30,14 +35,13 @@ struct solr_connection_post *post; uint32_t prev_uid; - string_t *cmd, *hdr, *hdr_fields; + string_t *cmd, *cur_value, *cur_value2; + ARRAY_DEFINE(fields, struct solr_fts_field); uint32_t last_indexed_uid; unsigned int last_indexed_uid_set:1; - unsigned int headers_open:1; unsigned int body_open:1; - unsigned int cur_header_index:1; unsigned int documents_added:1; unsigned int expunges:1; }; @@ -222,8 +226,7 @@ ctx = i_new(struct solr_fts_backend_update_context, 1); ctx->ctx.backend = _backend; ctx->cmd = str_new(default_pool, SOLR_CMDBUF_SIZE); - ctx->hdr = str_new(default_pool, 4096); - ctx->hdr_fields = str_new(default_pool, 1024); + i_array_init(&ctx->fields, 16); return &ctx->ctx; } @@ -257,23 +260,39 @@ str_append(ctx->cmd, ""); } +static string_t * +fts_solr_field_get(struct solr_fts_backend_update_context *ctx, const char *key) +{ + const struct solr_fts_field *field; + struct solr_fts_field new_field; + + /* there are only a few fields. this lookup is fast enough. */ + array_foreach(&ctx->fields, field) { + if (strcasecmp(field->key, key) == 0) + return field->value; + } + + memset(&new_field, 0, sizeof(new_field)); + new_field.key = str_lcase(i_strdup(key)); + new_field.value = str_new(default_pool, 128); + array_append(&ctx->fields, &new_field, 1); + return new_field.value; +} + static void fts_backend_solr_doc_close(struct solr_fts_backend_update_context *ctx) { - ctx->headers_open = FALSE; + struct solr_fts_field *field; + if (ctx->body_open) { ctx->body_open = FALSE; str_append(ctx->cmd, ""); } - if (str_len(ctx->hdr) > 0) { - str_append(ctx->cmd, ""); - str_append_str(ctx->cmd, ctx->hdr); + array_foreach_modifiable(&ctx->fields, field) { + str_printfa(ctx->cmd, "", field->key); + str_append_str(ctx->cmd, field->value); str_append(ctx->cmd, ""); - str_truncate(ctx->hdr, 0); - } - if (str_len(ctx->hdr_fields) > 0) { - str_append_str(ctx->cmd, ctx->hdr_fields); - str_truncate(ctx->hdr_fields, 0); + str_truncate(field->value, 0); } str_append(ctx->cmd, ""); } @@ -297,6 +316,7 @@ { struct solr_fts_backend_update_context *ctx = (struct solr_fts_backend_update_context *)_ctx; + struct solr_fts_field *field; const char *str; int ret = _ctx->failed ? -1 : 0; @@ -314,8 +334,11 @@ } str_free(&ctx->cmd); - str_free(&ctx->hdr); - str_free(&ctx->hdr_fields); + array_foreach_modifiable(&ctx->fields, field) { + str_free(&field->value); + i_free(field->key); + } + array_free(&ctx->fields); i_free(ctx); return ret; } @@ -409,22 +432,21 @@ switch (key->type) { case FTS_BACKEND_BUILD_KEY_HDR: if (fts_header_want_indexed(key->hdr_name)) { - ctx->cur_header_index = TRUE; - str_printfa(ctx->hdr_fields, "", - t_str_lcase(key->hdr_name)); + ctx->cur_value2 = + fts_solr_field_get(ctx, key->hdr_name); } /* fall through */ case FTS_BACKEND_BUILD_KEY_MIME_HDR: - xml_encode(ctx->hdr, key->hdr_name); - str_append(ctx->hdr, ": "); - ctx->headers_open = TRUE; + ctx->cur_value = fts_solr_field_get(ctx, "hdr"); + xml_encode(ctx->cur_value, key->hdr_name); + str_append(ctx->cur_value, ": "); break; case FTS_BACKEND_BUILD_KEY_BODY_PART: - ctx->headers_open = FALSE; if (!ctx->body_open) { ctx->body_open = TRUE; str_append(ctx->cmd, ""); } + ctx->cur_value = ctx->cmd; break; case FTS_BACKEND_BUILD_KEY_BODY_PART_BINARY: i_unreached(); @@ -438,20 +460,14 @@ struct solr_fts_backend_update_context *ctx = (struct solr_fts_backend_update_context *)_ctx; - if (ctx->headers_open) { - /* this is called individually for each header line. - headers are finished only when key changes to body */ - str_append_c(ctx->hdr, '\n'); - } else { - i_assert(ctx->body_open); - /* messages can have multiple MIME bodies. - add them all as one. */ - str_append_c(ctx->cmd, '\n'); - } - - if (ctx->cur_header_index) { - str_append(ctx->hdr_fields, ""); - ctx->cur_header_index = FALSE; + /* There can be multiple duplicate keys (duplicate header lines, + multiple MIME body parts). Make sure they are separated by + whitespace. */ + str_append_c(ctx->cur_value, '\n'); + ctx->cur_value = NULL; + if (ctx->cur_value2 != NULL) { + str_append_c(ctx->cur_value2, '\n'); + ctx->cur_value2 = NULL; } } @@ -465,14 +481,9 @@ if (_ctx->failed) return -1; - if (ctx->headers_open) { - if (ctx->cur_header_index) - xml_encode_data(ctx->hdr_fields, data, size); - xml_encode_data(ctx->hdr, data, size); - } else { - i_assert(!ctx->cur_header_index); - xml_encode_data(ctx->cmd, data, size); - } + xml_encode_data(ctx->cur_value, data, size); + if (ctx->cur_value2 != NULL) + xml_encode_data(ctx->cur_value2, data, size); if (str_len(ctx->cmd) > SOLR_CMDBUF_SIZE-128) { solr_connection_post_more(ctx->post, str_data(ctx->cmd), From dovecot at dovecot.org Mon Sep 12 16:23:30 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 16:23:30 +0300 Subject: dovecot-2.1: fts-squat: Crashfixes on indexing. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ddb5c2a8f3d2 changeset: 13454:ddb5c2a8f3d2 user: Timo Sirainen date: Mon Sep 12 16:23:21 2011 +0300 description: fts-squat: Crashfixes on indexing. diffstat: src/plugins/fts-squat/fts-backend-squat.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diffs (36 lines): diff -r 600034b77a1c -r ddb5c2a8f3d2 src/plugins/fts-squat/fts-backend-squat.c --- a/src/plugins/fts-squat/fts-backend-squat.c Mon Sep 12 16:18:56 2011 +0300 +++ b/src/plugins/fts-squat/fts-backend-squat.c Mon Sep 12 16:23:21 2011 +0300 @@ -101,7 +101,7 @@ fts_backend_squat_set_box(struct squat_fts_backend *backend, struct mailbox *box) { - const struct mailbox_permissions *perm = mailbox_get_permissions(box); + const struct mailbox_permissions *perm; struct mail_storage *storage; struct mailbox_status status; const char *path; @@ -110,7 +110,10 @@ if (backend->box == box) return; fts_backend_squat_unset_box(backend); + if (box == NULL) + return; + perm = mailbox_get_permissions(box); storage = mailbox_get_storage(box); path = mailbox_list_get_path(box->list, box->name, MAILBOX_LIST_PATH_TYPE_INDEX); @@ -255,8 +258,10 @@ ctx->failed = TRUE; fts_backend_squat_set_box(backend, box); - if (squat_trie_build_init(backend->trie, &ctx->build_ctx) < 0) - ctx->failed = TRUE; + if (box != NULL) { + if (squat_trie_build_init(backend->trie, &ctx->build_ctx) < 0) + ctx->failed = TRUE; + } } static void From dovecot at dovecot.org Mon Sep 12 16:31:00 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 16:31:00 +0300 Subject: dovecot-2.1: dsync: If mailbox can't be opened, log an error but... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/74e945315e2c changeset: 13455:74e945315e2c user: Timo Sirainen date: Mon Sep 12 16:30:51 2011 +0300 description: dsync: If mailbox can't be opened, log an error but continue anyway. diffstat: src/dsync/dsync-worker-local.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diffs (30 lines): diff -r ddb5c2a8f3d2 -r 74e945315e2c src/dsync/dsync-worker-local.c --- a/src/dsync/dsync-worker-local.c Mon Sep 12 16:23:21 2011 +0300 +++ b/src/dsync/dsync-worker-local.c Mon Sep 12 16:30:51 2011 +0300 @@ -527,6 +527,7 @@ struct local_dsync_mailbox_change *change; struct local_dsync_dir_change *dir_change, change_lookup; struct local_dsync_mailbox *old_lbox; + enum mail_error error; const char *const *fields; unsigned int i, field_count; @@ -564,8 +565,17 @@ if (mailbox_get_status(box, status_items, &status) < 0 || mailbox_get_metadata(box, metadata_items, &metadata) < 0) { i_error("Failed to sync mailbox %s: %s", info->name, - mailbox_get_last_error(box, NULL)); + mailbox_get_last_error(box, &error)); mailbox_free(&box); + if (error == MAIL_ERROR_NOTFOUND || + error == MAIL_ERROR_NOTPOSSIBLE) { + /* Mailbox isn't selectable, try the next one. We + should have already caught \Noselect mailboxes, but + check them anyway here. The NOTPOSSIBLE check is + mainly for invalid mbox files. */ + return local_worker_mailbox_iter_next(_iter, + dsync_box_r); + } _iter->failed = TRUE; return -1; } From dovecot at dovecot.org Mon Sep 12 16:32:29 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 16:32:29 +0300 Subject: dovecot-2.0: dsync: If mailbox can't be opened, log an error but... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/3c8b44bb1974 changeset: 12907:3c8b44bb1974 user: Timo Sirainen date: Mon Sep 12 16:32:20 2011 +0300 description: dsync: If mailbox can't be opened, log an error but continue anyway. diffstat: src/dsync/dsync-worker-local.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diffs (30 lines): diff -r a930318a74a1 -r 3c8b44bb1974 src/dsync/dsync-worker-local.c --- a/src/dsync/dsync-worker-local.c Mon Sep 12 14:27:46 2011 +0300 +++ b/src/dsync/dsync-worker-local.c Mon Sep 12 16:32:20 2011 +0300 @@ -521,6 +521,7 @@ struct local_dsync_mailbox_change *change; struct local_dsync_dir_change *dir_change, change_lookup; struct local_dsync_mailbox *old_lbox; + enum mail_error error; const char *const *fields; unsigned int i, field_count; @@ -560,8 +561,17 @@ struct mail_storage *storage = mailbox_get_storage(box); i_error("Failed to sync mailbox %s: %s", info->name, - mail_storage_get_last_error(storage, NULL)); + mail_storage_get_last_error(storage, &error)); mailbox_free(&box); + if (error == MAIL_ERROR_NOTFOUND || + error == MAIL_ERROR_NOTPOSSIBLE) { + /* Mailbox isn't selectable, try the next one. We + should have already caught \Noselect mailboxes, but + check them anyway here. The NOTPOSSIBLE check is + mainly for invalid mbox files. */ + return local_worker_mailbox_iter_next(_iter, + dsync_box_r); + } _iter->failed = TRUE; return -1; } From dovecot at dovecot.org Mon Sep 12 18:26:41 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 18:26:41 +0300 Subject: dovecot-2.1: stats: Added mail_ prefix to mail transaction stati... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b1870cf2d3ff changeset: 13456:b1870cf2d3ff user: Timo Sirainen date: Mon Sep 12 18:26:29 2011 +0300 description: stats: Added mail_ prefix to mail transaction statistics. Also added "m" prefix for them in the internal protocol. diffstat: src/plugins/stats/stats-plugin.c | 10 +++++----- src/stats/client-export.c | 11 ++++++----- src/stats/mail-stats.c | 11 ++++++----- src/stats/mail-stats.h | 5 +++-- 4 files changed, 20 insertions(+), 17 deletions(-) diffs (86 lines): diff -r 74e945315e2c -r b1870cf2d3ff src/plugins/stats/stats-plugin.c --- a/src/plugins/stats/stats-plugin.c Mon Sep 12 16:30:51 2011 +0300 +++ b/src/plugins/stats/stats-plugin.c Mon Sep 12 18:26:29 2011 +0300 @@ -238,13 +238,13 @@ (unsigned long long)stats->disk_input); str_printfa(str, "\tdiskout=%llu", (unsigned long long)stats->disk_output); - str_printfa(str, "\tlpath=%lu", + str_printfa(str, "\tmlpath=%lu", tstats->open_lookup_count + tstats->stat_lookup_count); - str_printfa(str, "\tlattr=%lu", + str_printfa(str, "\tmlattr=%lu", tstats->fstat_lookup_count + tstats->stat_lookup_count); - str_printfa(str, "\trcount=%lu", tstats->files_read_count); - str_printfa(str, "\trbytes=%llu", tstats->files_read_bytes); - str_printfa(str, "\tcache=%lu", tstats->cache_hit_count); + str_printfa(str, "\tmrcount=%lu", tstats->files_read_count); + str_printfa(str, "\tmrbytes=%llu", tstats->files_read_bytes); + str_printfa(str, "\tmcache=%lu", tstats->cache_hit_count); } static void stats_add_session(struct mail_user *user) diff -r 74e945315e2c -r b1870cf2d3ff src/stats/client-export.c --- a/src/stats/client-export.c Mon Sep 12 16:30:51 2011 +0300 +++ b/src/stats/client-export.c Mon Sep 12 18:26:29 2011 +0300 @@ -100,7 +100,8 @@ #define MAIL_STATS_HEADER "\tuser_cpu\tsys_cpu" \ "\tmin_faults\tmaj_faults\tvol_cs\tinvol_cs" \ "\tdisk_input\tdisk_output" \ - "\tlookup_path\tlookup_attr\tread_count\tread_bytes\tcache_hits\n" + "\tmail_lookup_path\tmail_lookup_attr" \ + "\tmail_read_count\tmail_read_bytes\tmail_cache_hits\n" str_printfa(str, "\t%ld.%06u", (long)stats->user_cpu.tv_sec, (unsigned int)stats->user_cpu.tv_usec); @@ -112,10 +113,10 @@ (unsigned long long)stats->disk_input, (unsigned long long)stats->disk_output); str_printfa(str, "\t%u\t%u\t%u\t%llu\t%u", - stats->lookup_path, stats->lookup_attr, - stats->read_count, - (unsigned long long)stats->read_bytes, - stats->cache_hits); + stats->mail_lookup_path, stats->mail_lookup_attr, + stats->mail_read_count, + (unsigned long long)stats->mail_read_bytes, + stats->mail_cache_hits); } static bool diff -r 74e945315e2c -r b1870cf2d3ff src/stats/mail-stats.c --- a/src/stats/mail-stats.c Mon Sep 12 16:30:51 2011 +0300 +++ b/src/stats/mail-stats.c Mon Sep 12 18:26:29 2011 +0300 @@ -25,11 +25,12 @@ EN("involcs", invol_cs), EN("diskin", disk_input), EN("diskout", disk_output), - EN("lpath", lookup_path), - EN("lattr", lookup_attr), - EN("rcount", read_count), - EN("rbytes", read_bytes), - EN("cache", cache_hits) + + EN("mlpath", mail_lookup_path), + EN("mlattr", mail_lookup_attr), + EN("mrcount", mail_read_count), + EN("mrbytes", mail_read_bytes), + EN("mcache", mail_cache_hits) }; static int mail_stats_parse_timeval(const char *value, struct timeval *tv) diff -r 74e945315e2c -r b1870cf2d3ff src/stats/mail-stats.h --- a/src/stats/mail-stats.h Mon Sep 12 16:30:51 2011 +0300 +++ b/src/stats/mail-stats.h Mon Sep 12 18:26:29 2011 +0300 @@ -10,8 +10,9 @@ uint32_t vol_cs, invol_cs; uint64_t disk_input, disk_output; - uint32_t lookup_path, lookup_attr, read_count, cache_hits; - uint64_t read_bytes; + uint32_t mail_lookup_path, mail_lookup_attr, mail_read_count; + uint32_t mail_cache_hits; + uint64_t mail_read_bytes; }; struct mail_command { From dovecot at dovecot.org Mon Sep 12 18:29:26 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Sep 2011 18:29:26 +0300 Subject: dovecot-2.1: stats: Track [rw]char and sysc[rw] fields in /proc/... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/835891cf2eef changeset: 13457:835891cf2eef user: Timo Sirainen date: Mon Sep 12 18:29:17 2011 +0300 description: stats: Track [rw]char and sysc[rw] fields in /proc/self/io (with Linux). diffstat: src/plugins/stats/stats-plugin.c | 77 ++++++++++++++++++++++++++++++++++++++++ src/plugins/stats/stats-plugin.h | 3 + src/stats/client-export.c | 4 ++ src/stats/mail-stats.c | 5 ++ src/stats/mail-stats.h | 3 + 5 files changed, 92 insertions(+), 0 deletions(-) diffs (177 lines): diff -r b1870cf2d3ff -r 835891cf2eef src/plugins/stats/stats-plugin.c --- a/src/plugins/stats/stats-plugin.c Mon Sep 12 18:26:29 2011 +0300 +++ b/src/plugins/stats/stats-plugin.c Mon Sep 12 18:29:17 2011 +0300 @@ -81,6 +81,70 @@ trans_stats_add(dest_r, &strans->trans->stats); } +static int +process_io_buffer_parse(const char *buf, struct mail_stats *stats) +{ + const char *const *tmp; + + tmp = t_strsplit(buf, "\n"); + for (; *tmp != NULL; tmp++) { + if (strncmp(*tmp, "rchar: ", 7) == 0) { + if (str_to_uint64(*tmp + 7, &stats->read_bytes) < 0) + return -1; + } else if (strncmp(*tmp, "wchar: ", 7) == 0) { + if (str_to_uint64(*tmp + 7, &stats->write_bytes) < 0) + return -1; + } else if (strncmp(*tmp, "syscr: ", 7) == 0) { + if (str_to_uint32(*tmp + 7, &stats->read_count) < 0) + return -1; + } else if (strncmp(*tmp, "syscw: ", 7) == 0) { + if (str_to_uint32(*tmp + 7, &stats->write_count) < 0) + return -1; + } + } + return 0; +} + +static void process_read_io_stats(struct mail_stats *stats) +{ + const char *path = "/proc/self/io"; + static bool io_disabled = FALSE; + char buf[1024]; + int fd, ret; + + if (io_disabled) + return; + + fd = open(path, O_RDONLY); + if (fd == -1) { + if (errno != ENOENT) + i_error("open(%s) failed: %m", path); + io_disabled = TRUE; + return; + } + ret = read(fd, buf, sizeof(buf)); + if (ret <= 0) { + if (ret == -1) + i_error("read(%s) failed: %m", path); + else + i_error("read(%s) returned EOF", path); + } else if (ret == sizeof(buf)) { + /* just shouldn't happen.. */ + i_error("%s is larger than expected", path); + io_disabled = TRUE; + } else { + buf[ret] = '\0'; + T_BEGIN { + if (process_io_buffer_parse(buf, stats) < 0) { + i_error("Invalid input in file %s", path); + io_disabled = TRUE; + } + } T_END; + } + if (close(fd) < 0) + i_error("close(%s) failed: %m", path); +} + void mail_stats_get(struct stats_user *suser, struct mail_stats *stats_r) { struct rusage usage; @@ -97,6 +161,7 @@ stats_r->invol_cs = usage.ru_nivcsw; stats_r->disk_input = (unsigned long long)usage.ru_inblock * 512ULL; stats_r->disk_output = (unsigned long long)usage.ru_oublock * 512ULL; + process_read_io_stats(stats_r); user_trans_stats_get(suser, &stats_r->trans_stats); } @@ -213,6 +278,10 @@ dest->maj_faults += new_stats->maj_faults - old_stats->maj_faults; dest->vol_cs += new_stats->vol_cs - old_stats->vol_cs; dest->invol_cs += new_stats->invol_cs - old_stats->invol_cs; + dest->read_count += new_stats->read_count - old_stats->read_count; + dest->write_count += new_stats->write_count - old_stats->write_count; + dest->read_bytes += new_stats->read_bytes - old_stats->read_bytes; + dest->write_bytes += new_stats->write_bytes - old_stats->write_bytes; timeval_add_diff(&dest->user_cpu, &new_stats->user_cpu, &old_stats->user_cpu); @@ -238,6 +307,12 @@ (unsigned long long)stats->disk_input); str_printfa(str, "\tdiskout=%llu", (unsigned long long)stats->disk_output); + str_printfa(str, "\trchar=%llu", + (unsigned long long)stats->read_bytes); + str_printfa(str, "\twchar=%llu", + (unsigned long long)stats->write_bytes); + str_printfa(str, "\tsyscr=%u", stats->read_count); + str_printfa(str, "\tsyscw=%u", stats->write_count); str_printfa(str, "\tmlpath=%lu", tstats->open_lookup_count + tstats->stat_lookup_count); str_printfa(str, "\tmlattr=%lu", @@ -278,6 +353,8 @@ return TRUE; if (cur->invol_cs > prev->invol_cs+10) return TRUE; + /* don't check for read/write count/bytes changes, since they get + changed by stats checking itself */ return FALSE; } diff -r b1870cf2d3ff -r 835891cf2eef src/plugins/stats/stats-plugin.h --- a/src/plugins/stats/stats-plugin.h Mon Sep 12 18:26:29 2011 +0300 +++ b/src/plugins/stats/stats-plugin.h Mon Sep 12 18:29:17 2011 +0300 @@ -18,6 +18,9 @@ uint32_t vol_cs, invol_cs; /* disk input/output bytes */ uint64_t disk_input, disk_output; + /* read()/write() syscall count and number of bytes */ + uint32_t read_count, write_count; + uint64_t read_bytes, write_bytes; struct mailbox_transaction_stats trans_stats; }; diff -r b1870cf2d3ff -r 835891cf2eef src/stats/client-export.c --- a/src/stats/client-export.c Mon Sep 12 18:26:29 2011 +0300 +++ b/src/stats/client-export.c Mon Sep 12 18:29:17 2011 +0300 @@ -100,6 +100,7 @@ #define MAIL_STATS_HEADER "\tuser_cpu\tsys_cpu" \ "\tmin_faults\tmaj_faults\tvol_cs\tinvol_cs" \ "\tdisk_input\tdisk_output" \ + "\tread_count\tread_bytes\twrite_count\twrite_bytes" \ "\tmail_lookup_path\tmail_lookup_attr" \ "\tmail_read_count\tmail_read_bytes\tmail_cache_hits\n" @@ -112,6 +113,9 @@ str_printfa(str, "\t%llu\t%llu", (unsigned long long)stats->disk_input, (unsigned long long)stats->disk_output); + str_printfa(str, "\t%u\t%llu\t%u\t%llu", + stats->read_count, (unsigned long long)stats->read_bytes, + stats->write_count, (unsigned long long)stats->write_bytes); str_printfa(str, "\t%u\t%u\t%u\t%llu\t%u", stats->mail_lookup_path, stats->mail_lookup_attr, stats->mail_read_count, diff -r b1870cf2d3ff -r 835891cf2eef src/stats/mail-stats.c --- a/src/stats/mail-stats.c Mon Sep 12 18:26:29 2011 +0300 +++ b/src/stats/mail-stats.c Mon Sep 12 18:29:17 2011 +0300 @@ -26,6 +26,11 @@ EN("diskin", disk_input), EN("diskout", disk_output), + EN("rchar", read_bytes), + EN("wchar", write_bytes), + EN("syscr", read_count), + EN("syscw", write_count), + EN("mlpath", mail_lookup_path), EN("mlattr", mail_lookup_attr), EN("mrcount", mail_read_count), diff -r b1870cf2d3ff -r 835891cf2eef src/stats/mail-stats.h --- a/src/stats/mail-stats.h Mon Sep 12 18:26:29 2011 +0300 +++ b/src/stats/mail-stats.h Mon Sep 12 18:29:17 2011 +0300 @@ -10,6 +10,9 @@ uint32_t vol_cs, invol_cs; uint64_t disk_input, disk_output; + uint32_t read_count, write_count; + uint64_t read_bytes, write_bytes; + uint32_t mail_lookup_path, mail_lookup_attr, mail_read_count; uint32_t mail_cache_hits; uint64_t mail_read_bytes; From dovecot at dovecot.org Tue Sep 13 02:07:43 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 02:07:43 +0300 Subject: dovecot-2.0: lib-index: mail_index_view_clone() didn't properly ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/df8bd044a47d changeset: 12908:df8bd044a47d user: Timo Sirainen date: Tue Sep 13 02:07:30 2011 +0300 description: lib-index: mail_index_view_clone() didn't properly clear all fields in the destination view. The only caller already had it cleared though. Patch by Mike Abbott / Apple. diffstat: src/lib-index/mail-index-view.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3c8b44bb1974 -r df8bd044a47d src/lib-index/mail-index-view.c --- a/src/lib-index/mail-index-view.c Mon Sep 12 16:32:20 2011 +0300 +++ b/src/lib-index/mail-index-view.c Tue Sep 13 02:07:30 2011 +0300 @@ -9,7 +9,7 @@ void mail_index_view_clone(struct mail_index_view *dest, const struct mail_index_view *src) { - memset(dest, 0, sizeof(dest)); + memset(dest, 0, sizeof(*dest)); dest->refcount = 1; dest->v = src->v; dest->index = src->index; From dovecot at dovecot.org Tue Sep 13 02:09:12 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 02:09:12 +0300 Subject: dovecot-2.0: dsync: Ignore SIGHUP Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/41dd8f4d44d5 changeset: 12909:41dd8f4d44d5 user: Timo Sirainen date: Tue Sep 13 02:08:15 2011 +0300 description: dsync: Ignore SIGHUP diffstat: src/dsync/dsync.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (19 lines): diff -r df8bd044a47d -r 41dd8f4d44d5 src/dsync/dsync.c --- a/src/dsync/dsync.c Tue Sep 13 02:07:30 2011 +0300 +++ b/src/dsync/dsync.c Tue Sep 13 02:08:15 2011 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "lib-signals.h" #include "array.h" #include "execv-const.h" #include "settings-parser.h" @@ -230,6 +231,7 @@ usage(); } master_service_init_finish(master_service); + lib_signals_ignore(SIGHUP, TRUE); if (!dsync_debug) { /* disable debugging unless -D is given */ From dovecot at dovecot.org Tue Sep 13 02:09:12 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 02:09:12 +0300 Subject: dovecot-2.0: Removed unnecessary code. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/d635bcf35df7 changeset: 12910:d635bcf35df7 user: Timo Sirainen date: Tue Sep 13 02:09:02 2011 +0300 description: Removed unnecessary code. diffstat: src/lib-storage/mail-storage-service.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 41dd8f4d44d5 -r d635bcf35df7 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Sep 13 02:08:15 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Sep 13 02:09:02 2011 +0300 @@ -869,7 +869,6 @@ } user = p_new(user_pool, struct mail_storage_service_user, 1); - memset(user_r, 0, sizeof(user_r)); user->pool = user_pool; user->input = *input; user->input.userdb_fields = NULL; From dovecot at dovecot.org Tue Sep 13 10:32:28 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 10:32:28 +0300 Subject: dovecot-2.1: imapc: Crashfix when sometimes closing mailbox. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e60a3b29117c changeset: 13458:e60a3b29117c user: Timo Sirainen date: Tue Sep 13 10:32:11 2011 +0300 description: imapc: Crashfix when sometimes closing mailbox. diffstat: src/lib-storage/index/imapc/imapc-client.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (23 lines): diff -r 835891cf2eef -r e60a3b29117c src/lib-storage/index/imapc/imapc-client.c --- a/src/lib-storage/index/imapc/imapc-client.c Mon Sep 12 18:29:17 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.c Tue Sep 13 10:32:11 2011 +0300 @@ -238,8 +238,6 @@ struct imapc_client_mailbox *box = *_box; struct imapc_client_connection *const *connp; - *_box = NULL; - array_foreach(&box->client->conns, connp) { if ((*connp)->box == box) { (*connp)->box = NULL; @@ -251,6 +249,10 @@ imapc_connection_unselect(box); imapc_msgmap_deinit(&box->msgmap); i_free(box); + + /* set this only after unselect, which may cancel some commands that + reference this box */ + *_box = NULL; } static void imapc_client_mailbox_cmd_cb(const struct imapc_command_reply *reply, From dovecot at dovecot.org Tue Sep 13 11:36:43 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 11:36:43 +0300 Subject: dovecot-2.1: lib-storage: Fixed handling subscriptions when they... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f3eb6cc4b627 changeset: 13459:f3eb6cc4b627 user: Timo Sirainen date: Tue Sep 13 11:34:21 2011 +0300 description: lib-storage: Fixed handling subscriptions when they were saved to prefix!="" namespace. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 33 ++++++++++++++++------ 1 files changed, 23 insertions(+), 10 deletions(-) diffs (85 lines): diff -r e60a3b29117c -r f3eb6cc4b627 src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Tue Sep 13 10:32:11 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Tue Sep 13 11:34:21 2011 +0300 @@ -20,12 +20,13 @@ static int mailbox_list_subscription_fill_one(struct mailbox_list *list, + struct mailbox_list *src_list, const char *name) { struct mail_namespace *ns, *default_ns = list->ns; struct mail_namespace *namespaces = default_ns->user->namespaces; struct mailbox_node *node; - const char *vname; + const char *vname, *ns_name; unsigned int len; bool created; @@ -35,7 +36,13 @@ 1) when listing "" namespace we want to skip over any names that begin with pub/. */ - ns = mail_namespace_find_unsubscribable(namespaces, name); + if (src_list->ns->prefix_len == 0) + ns_name = name; + else { + /* we could have two-level namespace: ns/ns2/ */ + 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; @@ -54,7 +61,7 @@ one easy way is to just ask if a mailbox name under it is valid, and it gets created */ (void)mailbox_list_is_valid_existing_name(list, name); - ns = mail_namespace_find_unsubscribable(namespaces, name); + ns = mail_namespace_find_unsubscribable(namespaces, ns_name); i_assert(ns != NULL && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0); } @@ -63,14 +70,15 @@ prefix in the name. the rest of the name is storage_name. */ if (ns == NULL) ns = default_ns; - else if (strncmp(name, ns->prefix, ns->prefix_len) == 0) - name += ns->prefix_len; - else { + else if (strncmp(ns_name, ns->prefix, ns->prefix_len) == 0) { + ns_name += ns->prefix_len; + name = ns_name; + } else { /* "pub" entry - this shouldn't be possible normally, because it should be saved as "pub/", but handle it anyway */ - i_assert(strncmp(name, ns->prefix, ns->prefix_len-1) == 0 && - name[ns->prefix_len-1] == '\0'); - name = ""; + i_assert(strncmp(ns_name, ns->prefix, ns->prefix_len-1) == 0 && + ns_name[ns->prefix_len-1] == '\0'); + name = ns_name = ""; } len = strlen(name); @@ -99,6 +107,7 @@ struct stat st; const char *path, *name; char sep; + int ret; i_assert((src_list->ns->flags & NAMESPACE_FLAG_SUBSCRIPTIONS) != 0); @@ -133,7 +142,11 @@ if (subsfile_list_fstat(subsfile_ctx, &st) == 0) dest_list->subscriptions_mtime = st.st_mtime; while ((name = subsfile_list_next(subsfile_ctx)) != NULL) T_BEGIN { - if (mailbox_list_subscription_fill_one(dest_list, name) < 0) { + T_BEGIN { + ret = mailbox_list_subscription_fill_one(dest_list, + src_list, name); + } T_END; + if (ret < 0) { i_warning("Subscriptions file %s: " "Removing invalid entry: %s", path, name); From dovecot at dovecot.org Tue Sep 13 11:38:59 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 11:38:59 +0300 Subject: dovecot-2.1: imapc: Handle \Noselect flag properly for untagged ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/50d0906b556f changeset: 13460:50d0906b556f user: Timo Sirainen date: Tue Sep 13 11:38:49 2011 +0300 description: imapc: Handle \Noselect flag properly for untagged LSUB replies. diffstat: src/lib-storage/index/imapc/imapc-list.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diffs (21 lines): diff -r f3eb6cc4b627 -r 50d0906b556f src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Tue Sep 13 11:34:21 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Tue Sep 13 11:38:49 2011 +0300 @@ -139,8 +139,15 @@ node = imapc_list_update_tree(list, list->tmp_subscriptions != NULL ? list->tmp_subscriptions : list->list.subscriptions, args); - if (node != NULL) - node->flags |= MAILBOX_SUBSCRIBED; + if (node != NULL) { + if ((node->flags & MAILBOX_NOSELECT) == 0) + node->flags |= MAILBOX_SUBSCRIBED; + else { + /* LSUB \Noselect means that the mailbox isn't + subscribed, but it has children that are */ + node->flags &= ~MAILBOX_NOSELECT; + } + } } void imapc_list_register_callbacks(struct imapc_mailbox_list *list) From dovecot at dovecot.org Tue Sep 13 12:42:46 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 12:42:46 +0300 Subject: dovecot-2.1: auth: Use auth-worker(pid) prefix for auth processes. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/667f604e79c5 changeset: 13462:667f604e79c5 user: Timo Sirainen date: Tue Sep 13 12:42:30 2011 +0300 description: auth: Use auth-worker(pid) prefix for auth processes. diffstat: src/auth/main.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (20 lines): diff -r 8eea5682ac5b -r 667f604e79c5 src/auth/main.c --- a/src/auth/main.c Tue Sep 13 11:55:25 2011 +0300 +++ b/src/auth/main.c Tue Sep 13 12:42:30 2011 +0300 @@ -9,6 +9,7 @@ #include "child-wait.h" #include "sql-api.h" #include "module-dir.h" +#include "hostpid.h" #include "randgen.h" #include "process-title.h" #include "settings-parser.h" @@ -309,6 +310,8 @@ while ((c = master_getopt(master_service)) > 0) { switch (c) { case 'w': + master_service_init_log(master_service, + t_strdup_printf("auth-worker(%s): ", my_pid)); worker = TRUE; break; default: From dovecot at dovecot.org Tue Sep 13 12:42:46 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Sep 2011 12:42:46 +0300 Subject: dovecot-2.1: lib-storage: Make sure status/metadata structs are ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/8eea5682ac5b changeset: 13461:8eea5682ac5b user: Timo Sirainen date: Tue Sep 13 11:55:25 2011 +0300 description: lib-storage: Make sure status/metadata structs are cleared when they're looked up. diffstat: src/lib-storage/mail-storage.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (29 lines): diff -r 50d0906b556f -r 8eea5682ac5b src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Tue Sep 13 11:38:49 2011 +0300 +++ b/src/lib-storage/mail-storage.c Tue Sep 13 11:55:25 2011 +0300 @@ -1146,6 +1146,7 @@ enum mailbox_status_items items, struct mailbox_status *status_r) { + memset(status_r, 0, sizeof(*status_r)); return box->v.get_status(box, items, status_r); } @@ -1154,6 +1155,8 @@ struct mailbox_status *status_r) { i_assert(box->opened); + + memset(status_r, 0, sizeof(*status_r)); if (box->v.get_status(box, items, status_r) < 0) i_unreached(); } @@ -1161,6 +1164,8 @@ int mailbox_get_metadata(struct mailbox *box, enum mailbox_metadata_items items, struct mailbox_metadata *metadata_r) { + memset(metadata_r, 0, sizeof(*metadata_r)); + if (!box->opened) { if (mailbox_open(box) < 0) return -1; From pigeonhole at rename-it.nl Tue Sep 13 23:42:33 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 13 Sep 2011 22:42:33 +0200 Subject: dovecot-2.0-pigeonhole: Added tag 0.2.4 for changeset 0d071eaa6d5e Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/5459f69f6aa2 changeset: 1528:5459f69f6aa2 user: Stephan Bosch date: Tue Sep 13 22:42:18 2011 +0200 description: Added tag 0.2.4 for changeset 0d071eaa6d5e diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 0d071eaa6d5e -r 5459f69f6aa2 .hgtags --- a/.hgtags Tue Sep 13 22:42:06 2011 +0200 +++ b/.hgtags Tue Sep 13 22:42:18 2011 +0200 @@ -7,3 +7,4 @@ d768f911252d6b798400a382b41a98d2b2cde770 0.2.1 df8b38da248cbd6d83e9bd476ec2c92716ea193c 0.2.2 3ab2a125e1e2d478382c07853e99a5973d06afd6 0.2.3 +0d071eaa6d5e2a9f524c94ddf1686f1b3091f604 0.2.4 From pigeonhole at rename-it.nl Tue Sep 13 23:42:33 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 13 Sep 2011 22:42:33 +0200 Subject: dovecot-2.0-pigeonhole: Released v0.2.4 for Dovecot v2.0.14. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/0d071eaa6d5e changeset: 1527:0d071eaa6d5e user: Stephan Bosch date: Tue Sep 13 22:42:06 2011 +0200 description: Released v0.2.4 for Dovecot v2.0.14. diffstat: NEWS | 5 ++++- configure.in | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diffs (26 lines): diff -r 6e46c17ab0b7 -r 0d071eaa6d5e NEWS --- a/NEWS Sun Sep 11 11:56:07 2011 +0200 +++ b/NEWS Tue Sep 13 22:42:06 2011 +0200 @@ -1,9 +1,12 @@ -v0.2.4 29-08-2011 Stephan Bosch +v0.2.4 13-09-2011 Stephan Bosch + Vacation extension: finally added support for using the original recipient in vacation address check. It is also possible to disable the recipient address check entirely. Check doc/vacation.txt for configuration information. + + Include extension: made limits on the include depth and the total number of + included scripts configurable. Check doc/include.txt for configuration + information. + Implemented ihave extension. This allows checking for the availability of Sieve language extensions at 'runtime'. Actually, this is checked at compile time. At runtime the interpreter checks whether extensions diff -r 6e46c17ab0b7 -r 0d071eaa6d5e configure.in --- a/configure.in Sun Sep 11 11:56:07 2011 +0200 +++ b/configure.in Tue Sep 13 22:42:06 2011 +0200 @@ -1,4 +1,4 @@ -AC_INIT([Pigeonhole], [0.2.3], [dovecot at dovecot.org], [dovecot-2.0-pigeonhole]) +AC_INIT([Pigeonhole], [0.2.4], [dovecot at dovecot.org], [dovecot-2.0-pigeonhole]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) From pigeonhole at rename-it.nl Tue Sep 13 23:43:43 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 13 Sep 2011 22:43:43 +0200 Subject: dovecot-2.0-pigeonhole: Added signature for changeset 0d071eaa6d5e Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/9e0d1a75c546 changeset: 1529:9e0d1a75c546 user: Stephan Bosch date: Tue Sep 13 22:43:27 2011 +0200 description: Added signature for changeset 0d071eaa6d5e diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 5459f69f6aa2 -r 9e0d1a75c546 .hgsigs --- a/.hgsigs Tue Sep 13 22:42:18 2011 +0200 +++ b/.hgsigs Tue Sep 13 22:43:27 2011 +0200 @@ -1,3 +1,4 @@ d768f911252d6b798400a382b41a98d2b2cde770 0 iQEcBAABAgAGBQJMn9w7AAoJEATWKx49+7T0LwwH/iZXNVppEZRfPOZPvkg+pSw4twuqmmV7h8yELaHKxyyqcKjSO6/A7Mkxf6FVZ6LerJ59h+iqib42TcGGDRTETH8OfN/jbZ0HX5F6jYAYvbs7RzjrO6FAthT3BnWvGLGPBuPrGCSS3FSF5AS8qhSOgpSlKheV/K7S4DeU5+4UNv49+icHZIGFYLjahb+rbL5aNqLx8NewVeKU77Fe9Jk0NRNO9p9g+JQEswEUQONhKta1hovZcOqKtZ45Xfq+/KvBIsITT/sSfRe+z8Mn7DhXYxFajRnVf2pBBQTrBRoy3Z4PtU1BvEUbUfGohLnnn3RQP092dfqwkovevT82lOLHtlc= df8b38da248cbd6d83e9bd476ec2c92716ea193c 0 iQEcBAABAgAGBQJM/WxCAAoJEATWKx49+7T0blMH/0Cdwr16xm5I9koqhVu3KKToePJqVIG723rdLjyBeTgr/0T5UTXzkPT8OHnzJ/SRcI8AiVJiLtTEFYAKsegJxFo3TEztlZ+cO2k8JT2HnL1w8RYeagihMyDdBPD+dpv+US+0eWHGmbmLvxi1UlfyqGiPZrKQmCuRtpzJTwzkGKOGdg+ln+kifvwzNhVGNC1URdfYOkO/vZL8W47OREtF4U2zV6l/KM6m4fnrUp7YdOBdYFwen6Yux6NDQzqXkUoJQ0xNsqp4HYGvSDCzRBI6tba++mGQ5tAvYyJuqwRKToMH/fk5al4igraZI8MH0tSZplHGxUAhsq8JO1/v83kudbM= 3ab2a125e1e2d478382c07853e99a5973d06afd6 0 iQEcBAABAgAGBQJNp1ztAAoJEATWKx49+7T0CJcH/24Txa1ynS5hBUhOuWTpUTGtm+9cMpWoQ33exiMR0pm8ycxsUQcKfRtO/cRHQX1CW3PqQs3DGZ31QdEEg0CyX8OsBbP/dwdEcnLRYF5BsJMyfy+Qnbhxn+wV0k9s9AUgZTdvPKrg1hFa6XS+6SE3N33AA4Y2eYYZGzFuDiSoN7fGx7PATCrobMsmp5WtBiKoy4WyP2SwDv/VgKy0PQTF+6+0t0MMCBSurLzpHk8dDuBonWIBgbJRM/sk9f+cYbU/ESRMcryZbbau9EwMQIQJfprGH6WP/gwysF0pu47zQERMuVt3fFzXUzrfxVpMOI7EkLgnF+Tes0vA7dKh1x+vvec= +0d071eaa6d5e2a9f524c94ddf1686f1b3091f604 0 iQEcBAABAgAGBQJOb8BjAAoJEATWKx49+7T0cAcH/3coc1MhQj8zUdC+NB3N8eUkQ3AF3QQgSfP9uXs9BhvPw70Ts9MLJiO54RhhYf/k9VxptzWk7MPJF47v4NEEKHkjDDMXtPbVOxHjNa2Ny8EAuWe4dv5X0faAlH4Ks58enDchCmunX1DgQtC1f+gHqVtvTpGAROFPqkBe5RGOJ0jQd+2hTTlf1BpLl44fiBdYd6350haX0KjDGNthX9ETVc3bnbdIiXSy7DPnn0ELhvTbgkl4Zu1tA778IJy/JjsCPb2YueX7LsksvxcSZHqv80Zd3JJhs5a3ZeHijN6twpe7VZD9FO+jPOKA1rr/HYwCv0KweKgmwVHCdaT+Mq4OLPc= From dovecot at dovecot.org Thu Sep 15 11:54:22 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 11:54:22 +0300 Subject: dovecot-2.0: doveadm altmove: Added -r parameter to move mails b... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1910c76a6cc9 changeset: 12911:1910c76a6cc9 user: Timo Sirainen date: Thu Sep 15 11:54:11 2011 +0300 description: doveadm altmove: Added -r parameter to move mails back to primary storage. diffstat: src/doveadm/doveadm-mail-altmove.c | 47 +++++++++++++++++++++++++++++-------- 1 files changed, 36 insertions(+), 11 deletions(-) diffs (103 lines): diff -r d635bcf35df7 -r 1910c76a6cc9 src/doveadm/doveadm-mail-altmove.c --- a/src/doveadm/doveadm-mail-altmove.c Tue Sep 13 02:09:02 2011 +0300 +++ b/src/doveadm/doveadm-mail-altmove.c Thu Sep 15 11:54:11 2011 +0300 @@ -9,13 +9,20 @@ #include "doveadm-mail-iter.h" #include "doveadm-mail.h" +struct altmove_cmd_context { + struct doveadm_mail_cmd_context ctx; + bool reverse; +}; + static int cmd_altmove_box(const struct mailbox_info *info, - struct mail_search_args *search_args) + struct mail_search_args *search_args, bool reverse) { struct doveadm_mail_iter *iter; struct mailbox_transaction_context *trans; struct mail *mail; + enum modify_type modify_type = + !reverse ? MODIFY_ADD : MODIFY_REMOVE; if (doveadm_mail_iter_init(info, search_args, &trans, &iter) < 0) return -1; @@ -26,7 +33,7 @@ i_debug("altmove: box=%s uid=%u", info->name, mail->uid); } - mail_update_flags(mail, MODIFY_ADD, + mail_update_flags(mail, modify_type, (enum mail_flags)MAIL_INDEX_MAIL_FLAG_BACKEND); } mail_free(&mail); @@ -42,8 +49,9 @@ } static void -cmd_altmove_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) +cmd_altmove_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { + struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx; const enum mailbox_list_iter_flags iter_flags = MAILBOX_LIST_ITER_RAW_LIST | MAILBOX_LIST_ITER_NO_AUTO_INBOX | @@ -56,7 +64,7 @@ unsigned int i, count; t_array_init(&purged_storages, 8); - iter = doveadm_mail_list_iter_init(user, ctx->search_args, iter_flags); + iter = doveadm_mail_list_iter_init(user, _ctx->search_args, iter_flags); while ((info = doveadm_mail_list_iter_next(iter)) != NULL) T_BEGIN { if (info->ns != prev_ns) { if (prev_ns != NULL) { @@ -66,7 +74,7 @@ } prev_ns = info->ns; } - (void)cmd_altmove_box(info, ctx->search_args); + (void)cmd_altmove_box(info, _ctx->search_args, ctx->reverse); } T_END; doveadm_mail_list_iter_deinit(&iter); @@ -95,16 +103,33 @@ ctx->search_args = doveadm_mail_build_search_args(args); } +static bool +cmd_mailbox_altmove_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +{ + struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx; + + switch (c) { + case 'r': + ctx->reverse = TRUE; + break; + default: + return FALSE; + } + return TRUE; +} + static struct doveadm_mail_cmd_context *cmd_altmove_alloc(void) { - struct doveadm_mail_cmd_context *ctx; + struct altmove_cmd_context *ctx; - ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); - ctx->v.init = cmd_altmove_init; - ctx->v.run = cmd_altmove_run; - return ctx; + ctx = doveadm_mail_cmd_alloc(struct altmove_cmd_context); + ctx->ctx.getopt_args = "r"; + ctx->ctx.v.parse_arg = cmd_mailbox_altmove_parse_arg; + ctx->ctx.v.init = cmd_altmove_init; + ctx->ctx.v.run = cmd_altmove_run; + return &ctx->ctx; } struct doveadm_mail_cmd cmd_altmove = { - cmd_altmove_alloc, "altmove", "" + cmd_altmove_alloc, "altmove", "[-r] " }; From dovecot at dovecot.org Thu Sep 15 12:21:07 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 12:21:07 +0300 Subject: dovecot-2.1: lib-storage: Fixed listing subscriptions in shared ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/309a707c22c0 changeset: 13463:309a707c22c0 user: Timo Sirainen date: Thu Sep 15 12:20:55 2011 +0300 description: lib-storage: Fixed listing subscriptions in shared namespaces. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (22 lines): diff -r 667f604e79c5 -r 309a707c22c0 src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Tue Sep 13 12:42:30 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Thu Sep 15 12:20:55 2011 +0300 @@ -26,7 +26,7 @@ struct mail_namespace *ns, *default_ns = list->ns; struct mail_namespace *namespaces = default_ns->user->namespaces; struct mailbox_node *node; - const char *vname, *ns_name; + const char *vname, *ns_name, *list_name; unsigned int len; bool created; @@ -60,7 +60,8 @@ /* we'll need to get the namespace autocreated. one easy way is to just ask if a mailbox name under it is valid, and it gets created */ - (void)mailbox_list_is_valid_existing_name(list, name); + list_name = ns_name + ns->prefix_len; + (void)mailbox_list_is_valid_existing_name(list, list_name); ns = mail_namespace_find_unsubscribable(namespaces, ns_name); i_assert(ns != NULL && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0); From dovecot at dovecot.org Thu Sep 15 12:34:13 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 12:34:13 +0300 Subject: dovecot-2.0: mbox: mailbox_get_guid() works now without trying t... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0264ac68c770 changeset: 12912:0264ac68c770 user: Timo Sirainen date: Thu Sep 15 12:34:03 2011 +0300 description: mbox: mailbox_get_guid() works now without trying to sync the opened mailbox. This fixes assert-crash when LDA was trying to get mailbox GUID during save. diffstat: src/lib-storage/index/mbox/mbox-storage.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diffs (25 lines): diff -r 1910c76a6cc9 -r 0264ac68c770 src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Thu Sep 15 11:54:11 2011 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Thu Sep 15 12:34:03 2011 +0300 @@ -584,8 +584,19 @@ return -1; } if (mail_guid_128_is_empty(mbox->mbox_hdr.mailbox_guid)) { - if (mailbox_sync(&mbox->box, 0) < 0) - return -1; + /* create another mailbox and sync */ + struct mailbox *box2; + struct mbox_mailbox *mbox2; + int ret; + + i_assert(mbox->mbox_lock_type == F_UNLCK); + box2 = mailbox_alloc(box->list, box->name, + MAILBOX_FLAG_KEEP_RECENT); + ret = mailbox_sync(box2, 0); + mbox2 = (struct mbox_mailbox *)box2; + memcpy(guid, mbox2->mbox_hdr.mailbox_guid, MAIL_GUID_128_SIZE); + mailbox_free(&box2); + return ret; } memcpy(guid, mbox->mbox_hdr.mailbox_guid, MAIL_GUID_128_SIZE); return 0; From dovecot at dovecot.org Thu Sep 15 13:10:04 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:10:04 +0300 Subject: dovecot-2.0: auth: Don't assert-crash if login client disconnect... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0dffdc3bfad1 changeset: 12913:0dffdc3bfad1 user: Timo Sirainen date: Thu Sep 15 13:09:50 2011 +0300 description: auth: Don't assert-crash if login client disconnects during multi-reply mechanism. diffstat: src/auth/auth-request-handler.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 0264ac68c770 -r 0dffdc3bfad1 src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Thu Sep 15 12:34:03 2011 +0300 +++ b/src/auth/auth-request-handler.c Thu Sep 15 13:09:50 2011 +0300 @@ -244,6 +244,9 @@ anything but abort this request */ request->internal_failure = TRUE; result = AUTH_CLIENT_RESULT_FAILURE; + /* make sure this request is set to finished state + (it's not with result=continue) */ + auth_request_set_state(request, AUTH_REQUEST_STATE_FINISHED); } reply = auth_stream_reply_init(pool_datastack_create()); From dovecot at dovecot.org Thu Sep 15 13:48:37 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:48:37 +0300 Subject: dovecot-2.0: lib-sql: If MySQL connect fails, update ioloop time... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/c056bd23fdcc changeset: 12915:c056bd23fdcc user: Timo Sirainen date: Thu Sep 15 13:41:03 2011 +0300 description: lib-sql: If MySQL connect fails, update ioloop times so later timeouts get added properly. diffstat: src/lib-sql/driver-mysql.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (23 lines): diff -r 3334c12a2b1a -r c056bd23fdcc src/lib-sql/driver-mysql.c --- a/src/lib-sql/driver-mysql.c Thu Sep 15 13:38:54 2011 +0300 +++ b/src/lib-sql/driver-mysql.c Thu Sep 15 13:41:03 2011 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "ioloop.h" #include "array.h" #include "str.h" #include "sql-api-private.h" @@ -109,6 +110,11 @@ client_flags) == NULL; alarm(0); if (failed) { + /* connecting could have taken a while. make sure that any + timeouts that get added soon will get a refreshed + timestamp. */ + io_loop_time_refresh(); + sql_db_set_state(&db->api, SQL_DB_STATE_DISCONNECTED); i_error("%s: Connect failed to database (%s): %s - " "waiting for %u seconds before retry", From dovecot at dovecot.org Thu Sep 15 13:48:37 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:48:37 +0300 Subject: dovecot-2.0: liblib: Added io_loop_time_refresh() Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/3334c12a2b1a changeset: 12914:3334c12a2b1a user: Timo Sirainen date: Thu Sep 15 13:38:54 2011 +0300 description: liblib: Added io_loop_time_refresh() diffstat: src/lib/ioloop.c | 7 +++++++ src/lib/ioloop.h | 3 +++ 2 files changed, 10 insertions(+), 0 deletions(-) diffs (30 lines): diff -r 0dffdc3bfad1 -r 3334c12a2b1a src/lib/ioloop.c --- a/src/lib/ioloop.c Thu Sep 15 13:09:50 2011 +0300 +++ b/src/lib/ioloop.c Thu Sep 15 13:38:54 2011 +0300 @@ -425,6 +425,13 @@ return ioloop->running; } +void io_loop_time_refresh(void) +{ + if (gettimeofday(&ioloop_timeval, NULL) < 0) + i_fatal("gettimeofday(): %m"); + ioloop_time = ioloop_timeval.tv_sec; +} + struct ioloop *io_loop_create(void) { struct ioloop *ioloop; diff -r 0dffdc3bfad1 -r 3334c12a2b1a src/lib/ioloop.h --- a/src/lib/ioloop.h Thu Sep 15 13:09:50 2011 +0300 +++ b/src/lib/ioloop.h Thu Sep 15 13:38:54 2011 +0300 @@ -78,6 +78,9 @@ /* Reset timeout so it's next run after now+msecs. */ void timeout_reset(struct timeout *timeout); +/* Refresh ioloop_time and ioloop_timeval variables. */ +void io_loop_time_refresh(void); + void io_loop_run(struct ioloop *ioloop); void io_loop_stop(struct ioloop *ioloop); /* safe to run in signal handler */ From dovecot at dovecot.org Thu Sep 15 13:48:37 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:48:37 +0300 Subject: dovecot-2.0: lib-sql: When escaping a string, use the first read... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1b829680dce4 changeset: 12917:1b829680dce4 user: Timo Sirainen date: Thu Sep 15 13:46:45 2011 +0300 description: lib-sql: When escaping a string, use the first ready connection (if any). This avoids unnecessarily trying to reconnect to a failing connection. diffstat: src/lib-sql/driver-sqlpool.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diffs (26 lines): diff -r 11273f581686 -r 1b829680dce4 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:45:35 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:46:45 2011 +0300 @@ -533,11 +533,18 @@ driver_sqlpool_escape_string(struct sql_db *_db, const char *string) { struct sqlpool_db *db = (struct sqlpool_db *)_db; - const struct sqlpool_connection *conn; + const struct sqlpool_connection *conns; + unsigned int i, count; - /* we always have at least one connection */ - conn = array_idx(&db->all_connections, 0); - return sql_escape_string(conn->db, string); + /* use the first ready connection */ + conns = array_get(&db->all_connections, &count); + for (i = 0; i < count; i++) { + if (SQL_DB_IS_READY(conns[i].db)) + return sql_escape_string(conns[i].db, string); + } + /* no ready connections. just use the first one (we're guaranteed + to always have one) */ + return sql_escape_string(conns[0].db, string); } static void driver_sqlpool_timeout(struct sqlpool_db *db) From dovecot at dovecot.org Thu Sep 15 13:48:37 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:48:37 +0300 Subject: dovecot-2.0: lib-sql: If MySQL connect takes more than 1 sec, do... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/11273f581686 changeset: 12916:11273f581686 user: Timo Sirainen date: Thu Sep 15 13:45:35 2011 +0300 description: lib-sql: If MySQL connect takes more than 1 sec, don't try to reconnect for that many secs. diffstat: src/lib-sql/driver-mysql.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (28 lines): diff -r c056bd23fdcc -r 11273f581686 src/lib-sql/driver-mysql.c --- a/src/lib-sql/driver-mysql.c Thu Sep 15 13:41:03 2011 +0300 +++ b/src/lib-sql/driver-mysql.c Thu Sep 15 13:45:35 2011 +0300 @@ -63,6 +63,7 @@ struct mysql_db *db = (struct mysql_db *)_db; const char *unix_socket, *host; unsigned long client_flags = db->client_flags; + unsigned int secs_used; bool failed; i_assert(db->api.state == SQL_DB_STATE_DISCONNECTED); @@ -108,13 +109,15 @@ failed = mysql_real_connect(db->mysql, host, db->user, db->password, db->dbname, db->port, unix_socket, client_flags) == NULL; - alarm(0); + secs_used = SQL_CONNECT_TIMEOUT_SECS - alarm(0); if (failed) { /* connecting could have taken a while. make sure that any timeouts that get added soon will get a refreshed timestamp. */ io_loop_time_refresh(); + if (db->api.connect_delay < secs_used) + db->api.connect_delay = secs_used; sql_db_set_state(&db->api, SQL_DB_STATE_DISCONNECTED); i_error("%s: Connect failed to database (%s): %s - " "waiting for %u seconds before retry", From dovecot at dovecot.org Thu Sep 15 13:48:37 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:48:37 +0300 Subject: dovecot-2.0: lib-sql: Don't try to connect to connections that a... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/3955a5b2a917 changeset: 12919:3955a5b2a917 user: Timo Sirainen date: Thu Sep 15 13:48:26 2011 +0300 description: lib-sql: Don't try to connect to connections that are going to be reconnected later. This avoids unnecessarily trying to connect to failing connections. diffstat: src/lib-sql/driver-sqlpool.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (22 lines): diff -r 55552b4e8c65 -r 3955a5b2a917 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:47:44 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:48:26 2011 +0300 @@ -309,7 +309,7 @@ if (conns[idx].host_idx == unwanted_host_idx) continue; - if (!SQL_DB_IS_READY(conndb)) { + if (!SQL_DB_IS_READY(conndb) && conndb->to_reconnect == NULL) { /* see if we could reconnect to it immediately */ (void)sql_connect(conndb); } @@ -523,7 +523,8 @@ int ret = -1, ret2; array_foreach(&db->all_connections, conn) { - ret2 = sql_connect(conn->db); + ret2 = conn->db->to_reconnect != NULL ? -1 : + sql_connect(conn->db); if (ret2 > 0) return 1; if (ret2 == 0) From dovecot at dovecot.org Thu Sep 15 13:48:37 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:48:37 +0300 Subject: dovecot-2.0: lib-sql: Connect to all configured hosts immediately. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/55552b4e8c65 changeset: 12918:55552b4e8c65 user: Timo Sirainen date: Thu Sep 15 13:47:44 2011 +0300 description: lib-sql: Connect to all configured hosts immediately. This makes load balancing between them actually work always. diffstat: src/lib-sql/driver-sqlpool.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diffs (34 lines): diff -r 1b829680dce4 -r 55552b4e8c65 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:46:45 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:47:44 2011 +0300 @@ -447,6 +447,19 @@ db->connection_limit = SQL_DEFAULT_CONNECTION_LIMIT; } +static void sqlpool_add_all_once(struct sqlpool_db *db) +{ + struct sqlpool_host *host; + unsigned int host_idx; + + for (;;) { + host = sqlpool_find_host_with_least_connections(db, &host_idx); + if (host->connection_count > 0) + break; + (void)sqlpool_add_connection(db, host, host_idx); + } +} + struct sql_db * driver_sqlpool_init(const char *connect_string, const struct sql_db *driver) { @@ -465,8 +478,8 @@ } T_END; i_array_init(&db->all_connections, 16); - /* always have at least one backend connection initialized */ - (void)sqlpool_add_new_connection(db); + /* connect to all databases so we can do load balancing immediately */ + sqlpool_add_all_once(db); return &db->api; } From dovecot at dovecot.org Thu Sep 15 13:53:23 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 13:53:23 +0300 Subject: dovecot-2.0: lib-sql: Dropped connect timeout to 5 seconds. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/20a901f1de31 changeset: 12920:20a901f1de31 user: Timo Sirainen date: Thu Sep 15 13:53:10 2011 +0300 description: lib-sql: Dropped connect timeout to 5 seconds. Postfix is using 10 second auth timeout and this needs to be less than that. diffstat: src/lib-sql/sql-api-private.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3955a5b2a917 -r 20a901f1de31 src/lib-sql/sql-api-private.h --- a/src/lib-sql/sql-api-private.h Thu Sep 15 13:48:26 2011 +0300 +++ b/src/lib-sql/sql-api-private.h Thu Sep 15 13:53:10 2011 +0300 @@ -25,7 +25,7 @@ is never used). */ #define SQL_CONNECT_RESET_DELAY 15 /* Abort connect() if it can't connect within this time. */ -#define SQL_CONNECT_TIMEOUT_SECS 10 +#define SQL_CONNECT_TIMEOUT_SECS 5 /* Abort queries after this many seconds */ #define SQL_QUERY_TIMEOUT_SECS 60 /* Default max. number of connections to create per host */ From dovecot at dovecot.org Thu Sep 15 22:56:23 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 22:56:23 +0300 Subject: dovecot-2.0: man: Added -r option to doveadm-altmove.1. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/85853915c8c0 changeset: 12921:85853915c8c0 user: Pascal Volk date: Thu Sep 15 19:51:27 2011 +0000 description: man: Added -r option to doveadm-altmove.1. diffstat: doc/man/doveadm-altmove.1.in | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diffs (45 lines): diff -r 20a901f1de31 -r 85853915c8c0 doc/man/doveadm-altmove.1.in --- a/doc/man/doveadm-altmove.1.in Thu Sep 15 13:53:10 2011 +0300 +++ b/doc/man/doveadm-altmove.1.in Thu Sep 15 19:51:27 2011 +0000 @@ -1,19 +1,19 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-ALTMOVE 1 "2010-11-25" "Dovecot v2.0" "Dovecot" +.\" Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file +.TH DOVEADM\-ALTMOVE 1 "2011-09-15" "Dovecot v2.0" "Dovecot" .SH NAME doveadm\-altmove \- Move matching mails to the alternative storage (dbox\-only) .\"------------------------------------------------------------------------ .SH SYNOPSIS -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " search_query .br .\"------------------------------------- -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " .BI \-A " search_query" .br .\"------------------------------------- -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " .BI \-u " user search_query" .\"------------------------------------------------------------------------ @@ -42,6 +42,16 @@ .\"------------------------------------- @INCLUDE:option-A@ .\"------------------------------------- +.TP +.B \-r +When the +.B \-r +option is given this +.I command +works the other way round. +Mails will be moved from the alternative storage back to the default mail +location. +.\"------------------------------------- @INCLUDE:option-S-socket@ .\"------------------------------------- @INCLUDE:option-u-user@ From dovecot at dovecot.org Thu Sep 15 23:39:47 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Sep 2011 23:39:47 +0300 Subject: dovecot-2.1: stats: Export also username for commands. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/61d3544f8fdf changeset: 13464:61d3544f8fdf user: Timo Sirainen date: Thu Sep 15 23:39:33 2011 +0300 description: stats: Export also username for commands. diffstat: src/stats/client-export.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (22 lines): diff -r 309a707c22c0 -r 61d3544f8fdf src/stats/client-export.c --- a/src/stats/client-export.c Thu Sep 15 12:20:55 2011 +0300 +++ b/src/stats/client-export.c Thu Sep 15 23:39:33 2011 +0300 @@ -256,7 +256,7 @@ if (!cmd->header_sent) { o_stream_send_str(client->output, - "cmd\targs\tsession\tlast_update"MAIL_STATS_HEADER); + "cmd\targs\tsession\tuser\tlast_update"MAIL_STATS_HEADER); cmd->header_sent = TRUE; } @@ -275,6 +275,9 @@ T_BEGIN { str_append(cmd->str, guid_128_to_string(command->session->guid)); + str_append_c(cmd->str, '\t'); + str_tabescape_write(cmd->str, + command->session->user->name); } T_END; client_export_timeval(cmd->str, &command->last_update); client_export_mail_stats(cmd->str, &command->stats); From dovecot at dovecot.org Fri Sep 16 11:59:29 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 11:59:29 +0300 Subject: dovecot-2.0: man: Escape fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/2795be14f37f changeset: 12922:2795be14f37f user: Timo Sirainen date: Fri Sep 16 11:59:15 2011 +0300 description: man: Escape fix. diffstat: doc/man/dsync.1.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 85853915c8c0 -r 2795be14f37f doc/man/dsync.1.in --- a/doc/man/dsync.1.in Thu Sep 15 19:51:27 2011 +0000 +++ b/doc/man/dsync.1.in Fri Sep 16 11:59:15 2011 +0300 @@ -167,7 +167,7 @@ For example: .sp .nf -ssh mailuser at host dsync -u user +ssh mailuser at host dsync \-u user .fi .\"------------------------------------------------------------------------ .SH COMMANDS From dovecot at dovecot.org Fri Sep 16 12:09:03 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 12:09:03 +0300 Subject: dovecot-2.0: config: Don't crash strlist section contains a subs... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1a57526721d7 changeset: 12923:1a57526721d7 user: Timo Sirainen date: Fri Sep 16 12:08:49 2011 +0300 description: config: Don't crash strlist section contains a subsection. diffstat: src/config/config-parser.c | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diffs (61 lines): diff -r 2795be14f37f -r 1a57526721d7 src/config/config-parser.c --- a/src/config/config-parser.c Fri Sep 16 11:59:15 2011 +0300 +++ b/src/config/config-parser.c Fri Sep 16 12:08:49 2011 +0300 @@ -52,8 +52,8 @@ return NULL; } -static void config_add_type(struct setting_parser_context *parser, - const char *line, const char *section_name) +static int config_add_type(struct setting_parser_context *parser, + const char *line, const char *section_name) { const struct setting_parser_info *info; const char *p; @@ -61,21 +61,28 @@ int ret; info = settings_parse_get_prev_info(parser); + if (info == NULL) { + /* section inside strlist */ + return -1; + } if (info->type_offset == (size_t)-1) - return; + return 0; str = t_str_new(256); p = strchr(line, '='); str_append_n(str, line, p-line); str_append_c(str, SETTINGS_SEPARATOR); str_append(str, p+1); - str_append_c(str, SETTINGS_SEPARATOR); - str_append(str, info_type_name_find(info)); + if (info != NULL) { + str_append_c(str, SETTINGS_SEPARATOR); + str_append(str, info_type_name_find(info)); + } str_append_c(str, '='); str_append(str, section_name); ret = settings_parse_line(parser, str_c(str)); i_assert(ret > 0); + return 0; } static bool @@ -106,8 +113,12 @@ key, NULL); return -1; } - if (section_name != NULL) - config_add_type(l->parser, line, section_name); + if (section_name != NULL) { + if (config_add_type(l->parser, line, section_name) < 0) { + ctx->error = "Section not allowed here"; + return -1; + } + } } else if (ret < 0) { ctx->error = settings_parser_get_error(l->parser); return -1; From dovecot at dovecot.org Fri Sep 16 12:11:58 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 12:11:58 +0300 Subject: dovecot-2.0: s/commiting/committing/ Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/79d54b6ccfe1 changeset: 12924:79d54b6ccfe1 user: Timo Sirainen date: Fri Sep 16 12:11:25 2011 +0300 description: s/commiting/committing/ Caught by Marco Nenciarini. diffstat: src/doveadm/doveadm-mail-iter.c | 2 +- src/lib-index/mail-index-transaction-update.c | 2 +- src/lib-storage/index/index-sync.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diffs (36 lines): diff -r 1a57526721d7 -r 79d54b6ccfe1 src/doveadm/doveadm-mail-iter.c --- a/src/doveadm/doveadm-mail-iter.c Fri Sep 16 12:08:49 2011 +0300 +++ b/src/doveadm/doveadm-mail-iter.c Fri Sep 16 12:11:25 2011 +0300 @@ -63,7 +63,7 @@ } if (commit) { if (mailbox_transaction_commit(&iter->t) < 0) { - i_error("Commiting mailbox %s failed: %s", + i_error("Committing mailbox %s failed: %s", mailbox_get_vname(iter->box), mail_storage_get_last_error(iter->storage, NULL)); ret = -1; diff -r 1a57526721d7 -r 79d54b6ccfe1 src/lib-index/mail-index-transaction-update.c --- a/src/lib-index/mail-index-transaction-update.c Fri Sep 16 12:08:49 2011 +0300 +++ b/src/lib-index/mail-index-transaction-update.c Fri Sep 16 12:11:25 2011 +0300 @@ -358,7 +358,7 @@ } else { t->log_updates = TRUE; - /* ignore duplicates here. drop them when commiting. */ + /* ignore duplicates here. drop them when committing. */ if (!array_is_created(&t->expunges)) i_array_init(&t->expunges, 64); else if (!t->expunges_nonsorted) { diff -r 1a57526721d7 -r 79d54b6ccfe1 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Fri Sep 16 12:08:49 2011 +0300 +++ b/src/lib-storage/index/index-sync.c Fri Sep 16 12:11:25 2011 +0300 @@ -434,7 +434,7 @@ } mail_free(&mail); if (mailbox_transaction_commit(&trans) < 0) { - i_error("Commiting mailbox %s failed: %s", + i_error("Committing mailbox %s failed: %s", mailbox_get_vname(box), mail_storage_get_last_error(mailbox_get_storage(box), NULL)); return -1; From dovecot at dovecot.org Fri Sep 16 12:21:13 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 12:21:13 +0300 Subject: dovecot-2.0: lib-sql: Fixed load balancing between multiple SQL ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/327698228158 changeset: 12925:327698228158 user: Timo Sirainen date: Fri Sep 16 12:21:02 2011 +0300 description: lib-sql: Fixed load balancing between multiple SQL hosts to actually work. diffstat: src/lib-sql/driver-sqlpool.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (23 lines): diff -r 79d54b6ccfe1 -r 327698228158 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Fri Sep 16 12:11:25 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Fri Sep 16 12:21:02 2011 +0300 @@ -303,7 +303,7 @@ conns = array_get(&db->all_connections, &count); for (i = 0; i < count; i++) { - unsigned int idx = (i + db->last_query_conn_idx) % count; + unsigned int idx = (i + db->last_query_conn_idx + 1) % count; struct sql_db *conndb = conns[idx].db; if (conns[idx].host_idx == unwanted_host_idx) @@ -526,8 +526,8 @@ ret2 = conn->db->to_reconnect != NULL ? -1 : sql_connect(conn->db); if (ret2 > 0) - return 1; - if (ret2 == 0) + ret = 1; + else if (ret2 == 0 && ret < 0) ret = 0; } return ret; From dovecot at dovecot.org Fri Sep 16 12:40:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 12:40:31 +0300 Subject: dovecot-2.1: lib-storage: Added mail_namespace_find_unalias() Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ff6272a52f0d changeset: 13465:ff6272a52f0d user: Timo Sirainen date: Fri Sep 16 12:39:19 2011 +0300 description: lib-storage: Added mail_namespace_find_unalias() diffstat: src/lib-storage/mail-namespace.c | 17 +++++++++++++++++ src/lib-storage/mail-namespace.h | 6 ++++++ 2 files changed, 23 insertions(+), 0 deletions(-) diffs (43 lines): diff -r 61d3544f8fdf -r ff6272a52f0d src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Thu Sep 15 23:39:33 2011 +0300 +++ b/src/lib-storage/mail-namespace.c Fri Sep 16 12:39:19 2011 +0300 @@ -581,6 +581,23 @@ } struct mail_namespace * +mail_namespace_find_unalias(struct mail_namespace *namespaces, + const char **mailbox) +{ + struct mail_namespace *ns; + const char *storage_name; + + ns = mail_namespace_find(namespaces, *mailbox); + if (ns->alias_for != NULL) { + storage_name = + mailbox_list_get_storage_name(ns->list, *mailbox); + ns = ns->alias_for; + *mailbox = mailbox_list_get_vname(ns->list, storage_name); + } + return ns; +} + +struct mail_namespace * mail_namespace_find_visible(struct mail_namespace *namespaces, const char *mailbox) { diff -r 61d3544f8fdf -r ff6272a52f0d src/lib-storage/mail-namespace.h --- a/src/lib-storage/mail-namespace.h Thu Sep 15 23:39:33 2011 +0300 +++ b/src/lib-storage/mail-namespace.h Fri Sep 16 12:39:19 2011 +0300 @@ -108,6 +108,12 @@ namespace could be found. */ struct mail_namespace * mail_namespace_find(struct mail_namespace *namespaces, const char *mailbox); +/* Find namespace for mailbox and return it. If the namespace has alias_for + set, return that namespace instead and change mailbox name to be a valid + inside it. */ +struct mail_namespace * +mail_namespace_find_unalias(struct mail_namespace *namespaces, + const char **mailbox); /* Like above, but ignore hidden namespaces. */ struct mail_namespace * mail_namespace_find_visible(struct mail_namespace *namespaces, From dovecot at dovecot.org Fri Sep 16 12:40:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 12:40:31 +0300 Subject: dovecot-2.1: quota: When matching mailbox names in quota rules, ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7f7dc4c89d04 changeset: 13466:7f7dc4c89d04 user: Timo Sirainen date: Fri Sep 16 12:40:19 2011 +0300 description: quota: When matching mailbox names in quota rules, unalias namespaces first. diffstat: src/plugins/quota/quota.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (22 lines): diff -r ff6272a52f0d -r 7f7dc4c89d04 src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Fri Sep 16 12:39:19 2011 +0300 +++ b/src/plugins/quota/quota.c Fri Sep 16 12:40:19 2011 +0300 @@ -604,6 +604,8 @@ ignore any specific quota rules */ enabled = bytes_limit != 0 || count_limit != 0; + (void)mail_namespace_find_unalias(root->quota->user->namespaces, + &mailbox_name); rule = enabled ? quota_root_rule_find(root->set, mailbox_name) : NULL; if (rule != NULL) { if (!rule->ignore) { @@ -1093,6 +1095,9 @@ ARRAY_DEFINE(warn_roots, struct quota_root *); mailbox_name = mailbox_get_vname(ctx->box); + (void)mail_namespace_find_unalias( + ctx->box->storage->user->namespaces, &mailbox_name); + roots = array_get(&ctx->quota->roots, &count); t_array_init(&warn_roots, count); for (i = 0; i < count; i++) { From dovecot at dovecot.org Fri Sep 16 12:57:52 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 12:57:52 +0300 Subject: dovecot-2.0: lib-storage: Changed debug message to sound less li... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/99e1a9aa03f7 changeset: 12926:99e1a9aa03f7 user: Timo Sirainen date: Fri Sep 16 12:57:40 2011 +0300 description: lib-storage: Changed debug message to sound less like an error message. diffstat: src/lib-storage/mailbox-list.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (15 lines): diff -r 327698228158 -r 99e1a9aa03f7 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Fri Sep 16 12:21:02 2011 +0300 +++ b/src/lib-storage/mailbox-list.c Fri Sep 16 12:57:40 2011 +0300 @@ -434,8 +434,9 @@ mailbox_list_set_critical(list, "stat(%s) failed: %m", path); } else if (list->mail_set->mail_debug) { - i_debug("Namespace %s: Permission lookup failed from %s", - list->ns->prefix, path); + i_debug("Namespace %s: %s doesn't exist yet, " + "using default permissions", + list->ns->prefix, path); } if (name != NULL) { /* return defaults */ From dovecot at dovecot.org Fri Sep 16 13:06:59 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 13:06:59 +0300 Subject: dovecot-2.0: lib-storage: If mailbox_rename() isn't possible and... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/e57bd3e2ec27 changeset: 12927:e57bd3e2ec27 user: Timo Sirainen date: Fri Sep 16 13:06:48 2011 +0300 description: lib-storage: If mailbox_rename() isn't possible and mail_debug=yes, log the reason why. diffstat: src/lib-storage/mail-storage.c | 46 +++++++++++++++++++++++++++++++++-------- 1 files changed, 37 insertions(+), 9 deletions(-) diffs (82 lines): diff -r 99e1a9aa03f7 -r e57bd3e2ec27 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Sep 16 12:57:40 2011 +0300 +++ b/src/lib-storage/mail-storage.c Fri Sep 16 13:06:48 2011 +0300 @@ -805,15 +805,24 @@ static bool mail_storages_rename_compatible(struct mail_storage *storage1, - struct mail_storage *storage2) + struct mail_storage *storage2, + const char **error_r) { if (storage1 == storage2) return TRUE; - if (strcmp(storage1->name, storage2->name) != 0) + if (strcmp(storage1->name, storage2->name) != 0) { + *error_r = t_strdup_printf("storage %s != %s", + storage1->name, storage2->name); return FALSE; - if ((storage1->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0) + } + if ((storage1->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0) { + /* e.g. mdbox where all mails are in storage/ directory and + they can't be easily moved from there. */ + *error_r = t_strdup_printf("storage %s uses unique root", + storage1->name); return FALSE; + } return TRUE; } @@ -824,16 +833,29 @@ static bool mailbox_lists_rename_compatible(struct mailbox_list *list1, - struct mailbox_list *list2) + struct mailbox_list *list2, + const char **error_r) { - return nullequals(list1->set.alt_dir, list2->set.alt_dir) && - nullequals(list1->set.index_dir, list2->set.index_dir) && - nullequals(list1->set.control_dir, list2->set.control_dir); + if (!nullequals(list1->set.alt_dir, list2->set.alt_dir)) { + *error_r = "alt dirs don't match"; + return FALSE; + } + if (!nullequals(list1->set.index_dir, list2->set.index_dir)) { + *error_r = "index dirs don't match"; + return FALSE; + } + if (!nullequals(list1->set.control_dir, list2->set.control_dir)) { + *error_r = "control dirs don't match"; + return FALSE; + } + return TRUE; } int mailbox_rename(struct mailbox *src, struct mailbox *dest, bool rename_children) { + const char *error = NULL; + if (!mailbox_list_is_valid_existing_name(src->list, src->name) || *src->name == '\0' || !mailbox_list_is_valid_create_name(dest->list, dest->name)) { @@ -841,8 +863,14 @@ "Invalid mailbox name"); return -1; } - if (!mail_storages_rename_compatible(src->storage, dest->storage) || - !mailbox_lists_rename_compatible(src->list, dest->list)) { + if (!mail_storages_rename_compatible(src->storage, + dest->storage, &error) || + !mailbox_lists_rename_compatible(src->list, + dest->list, &error)) { + if (src->storage->set->mail_debug) { + i_debug("Can't rename '%s' to '%s': %s", + src->vname, dest->vname, error); + } mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, "Can't rename mailboxes across specified storages."); return -1; From dovecot at dovecot.org Fri Sep 16 13:14:23 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 13:14:23 +0300 Subject: dovecot-2.0: lib-storage: If shared namespace prefix doesn't end... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/ea657df52a85 changeset: 12928:ea657df52a85 user: Timo Sirainen date: Fri Sep 16 13:14:11 2011 +0300 description: lib-storage: If shared namespace prefix doesn't end with hierarchy separator, fail. diffstat: src/lib-storage/index/shared/shared-storage.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (16 lines): diff -r e57bd3e2ec27 -r ea657df52a85 src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Fri Sep 16 13:06:48 2011 +0300 +++ b/src/lib-storage/index/shared/shared-storage.c Fri Sep 16 13:14:11 2011 +0300 @@ -79,6 +79,12 @@ *error_r = "Shared namespace prefix doesn't contain %u or %n"; return -1; } + if (p[-1] != ns->sep && + (ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) != 0) { + *error_r = "Shared namespace prefix doesn't end with hierarchy separator"; + return -1; + } /* truncate prefix after the above checks are done, so they can log the full prefix in error conditions */ From dovecot at dovecot.org Fri Sep 16 14:52:46 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 14:52:46 +0300 Subject: dovecot-2.1: Fixes to listing mailboxes/subscriptions in shared ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/080c8f9521d2 changeset: 13467:080c8f9521d2 user: Timo Sirainen date: Fri Sep 16 14:52:29 2011 +0300 description: Fixes to listing mailboxes/subscriptions in shared namespaces. diffstat: src/imap/cmd-list.c | 2 +- src/lib-storage/index/shared/shared-list.c | 100 ++++++++++----------- src/lib-storage/list/mailbox-list-subscriptions.c | 7 +- 3 files changed, 51 insertions(+), 58 deletions(-) diffs (168 lines): diff -r 7f7dc4c89d04 -r 080c8f9521d2 src/imap/cmd-list.c --- a/src/imap/cmd-list.c Fri Sep 16 12:40:19 2011 +0300 +++ b/src/imap/cmd-list.c Fri Sep 16 14:52:29 2011 +0300 @@ -707,7 +707,7 @@ if (list_want_send_prefix(ctx, orig_cur_pattern)) ctx->cur_ns_send_prefix = TRUE; } - return (match & IMAP_MATCH_CHILDREN) != 0; + return match != IMAP_MATCH_NO; } } diff -r 7f7dc4c89d04 -r 080c8f9521d2 src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Fri Sep 16 12:40:19 2011 +0300 +++ b/src/lib-storage/index/shared/shared-list.c Fri Sep 16 14:52:29 2011 +0300 @@ -6,12 +6,6 @@ #include "index-storage.h" #include "shared-storage.h" -struct shared_mailbox_list_iterate_context { - struct mailbox_list_iterate_context ctx; - struct mail_namespace *cur_ns; - struct mailbox_info info; -}; - extern struct mailbox_list shared_mailbox_list; static struct mailbox_list *shared_list_alloc(void) @@ -146,67 +140,69 @@ return pattern; } +static void +shared_list_create_missing_namespaces(struct mailbox_list *list, + const char *const *patterns) +{ + char sep = mail_namespace_get_sep(list->ns); + const char *list_pat, *name; + unsigned int i; + + for (i = 0; patterns[i] != NULL; i++) { + const char *last = NULL, *p; + + /* we'll require that the pattern begins with the list's + namespace prefix. we could also handle other patterns + (e.g. %/user/%), but it's more of a theoretical problem. */ + if (strncmp(list->ns->prefix, patterns[i], + list->ns->prefix_len) != 0) + continue; + list_pat = patterns[i] + list->ns->prefix_len; + + for (p = list_pat; *p != '\0'; p++) { + if (*p == '%' || *p == '*') + break; + if (*p == sep) + last = p; + } + if (last != NULL) { + name = t_strdup_until(list_pat, last); + (void)mailbox_list_is_valid_existing_name(list, name); + } + } +} + static struct mailbox_list_iterate_context * shared_list_iter_init(struct mailbox_list *list, const char *const *patterns, enum mailbox_list_iter_flags flags) { - struct shared_mailbox_list_iterate_context *ctx; + struct mailbox_list_iterate_context *ctx; char sep = mail_namespace_get_sep(list->ns); - ctx = i_new(struct shared_mailbox_list_iterate_context, 1); - ctx->ctx.list = list; - ctx->ctx.flags = flags; - ctx->ctx.glob = imap_match_init_multiple(default_pool, patterns, - FALSE, sep); - array_create(&ctx->ctx.module_contexts, default_pool, sizeof(void *), 5); + ctx = i_new(struct mailbox_list_iterate_context, 1); + ctx->list = list; + ctx->flags = flags; + ctx->glob = imap_match_init_multiple(default_pool, patterns, + FALSE, sep); + array_create(&ctx->module_contexts, default_pool, sizeof(void *), 5); - ctx->cur_ns = list->ns->user->namespaces; - ctx->info.ns = list->ns; - ctx->info.flags = MAILBOX_NONEXISTENT; - return &ctx->ctx; + if ((flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0 && + (list->ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) T_BEGIN { + shared_list_create_missing_namespaces(list, patterns); + } T_END; + return ctx; } static const struct mailbox_info * -shared_list_iter_next(struct mailbox_list_iterate_context *_ctx) +shared_list_iter_next(struct mailbox_list_iterate_context *ctx ATTR_UNUSED) { - struct shared_mailbox_list_iterate_context *ctx = - (struct shared_mailbox_list_iterate_context *)_ctx; - struct mail_namespace *ns = ctx->cur_ns; - - for (; ns != NULL; ns = ns->next) { - if (ns->type != NAMESPACE_SHARED || - (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) - continue; - if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | - NAMESPACE_FLAG_LIST_CHILDREN)) == 0) - continue; - - if (ns->prefix_len < ctx->info.ns->prefix_len || - strncmp(ns->prefix, ctx->info.ns->prefix, - ctx->info.ns->prefix_len) != 0) - continue; - - /* visible and listable namespace under ourself, see if the - prefix matches without the trailing separator */ - i_assert(ns->prefix_len > 0); - ctx->info.name = t_strndup(ns->prefix, ns->prefix_len - 1); - if (imap_match(ctx->ctx.glob, ctx->info.name) == IMAP_MATCH_YES) { - ctx->cur_ns = ns->next; - return &ctx->info; - } - } - - ctx->cur_ns = NULL; return NULL; } -static int shared_list_iter_deinit(struct mailbox_list_iterate_context *_ctx) +static int shared_list_iter_deinit(struct mailbox_list_iterate_context *ctx) { - struct shared_mailbox_list_iterate_context *ctx = - (struct shared_mailbox_list_iterate_context *)_ctx; - - imap_match_deinit(&ctx->ctx.glob); - array_free(&ctx->ctx.module_contexts); + imap_match_deinit(&ctx->glob); + array_free(&ctx->module_contexts); i_free(ctx); return 0; } diff -r 7f7dc4c89d04 -r 080c8f9521d2 src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Fri Sep 16 12:40:19 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Fri Sep 16 14:52:29 2011 +0300 @@ -53,8 +53,8 @@ return 0; /* When listing shared namespace's subscriptions, we need to - autocreate all the visible child namespaces and use the - child namespace. */ + autocreate all the visible child namespaces. their subscriptions + are listed later. */ if (ns != NULL && ns->type == NAMESPACE_SHARED && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) { /* we'll need to get the namespace autocreated. @@ -62,9 +62,6 @@ it is valid, and it gets created */ list_name = ns_name + ns->prefix_len; (void)mailbox_list_is_valid_existing_name(list, list_name); - ns = mail_namespace_find_unsubscribable(namespaces, ns_name); - i_assert(ns != NULL && - (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0); } /* When listing pub/ namespace, skip over the namespace From dovecot at dovecot.org Fri Sep 16 14:59:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 14:59:45 +0300 Subject: dovecot-2.0: lib-storage: Improved debug logging messages. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/19086b0d53f4 changeset: 12929:19086b0d53f4 user: Timo Sirainen date: Fri Sep 16 14:59:34 2011 +0300 description: lib-storage: Improved debug logging messages. diffstat: src/lib-storage/mail-storage.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (22 lines): diff -r ea657df52a85 -r 19086b0d53f4 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Sep 16 13:14:11 2011 +0300 +++ b/src/lib-storage/mail-storage.c Fri Sep 16 14:59:34 2011 +0300 @@ -837,15 +837,15 @@ const char **error_r) { if (!nullequals(list1->set.alt_dir, list2->set.alt_dir)) { - *error_r = "alt dirs don't match"; + *error_r = "one namespace has alt dir and another doesn't"; return FALSE; } if (!nullequals(list1->set.index_dir, list2->set.index_dir)) { - *error_r = "index dirs don't match"; + *error_r = "one namespace has index dir and another doesn't"; return FALSE; } if (!nullequals(list1->set.control_dir, list2->set.control_dir)) { - *error_r = "control dirs don't match"; + *error_r = "one namespace has control dir and another doesn't"; return FALSE; } return TRUE; From dovecot at dovecot.org Fri Sep 16 16:02:09 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:02:09 +0300 Subject: dovecot-2.1: lib-storage: Don't try to use the same mail_storage... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cfbca51c0ade changeset: 13468:cfbca51c0ade user: Timo Sirainen date: Fri Sep 16 16:01:29 2011 +0300 description: lib-storage: Don't try to use the same mail_storage for shared storages. This fixes having multiple independent shared namespaces. diffstat: src/lib-storage/mail-storage.c | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diffs (42 lines): diff -r 080c8f9521d2 -r cfbca51c0ade src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Sep 16 14:52:29 2011 +0300 +++ b/src/lib-storage/mail-storage.c Fri Sep 16 16:01:29 2011 +0300 @@ -260,6 +260,26 @@ } } +static bool +mail_storage_match_class(struct mail_storage *storage, + const struct mail_storage *storage_class, + const struct mailbox_list_settings *set) +{ + if (strcmp(storage->name, storage_class->name) != 0) + return FALSE; + + if ((storage->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0 && + strcmp(storage->unique_root_dir, set->root_dir) != 0) + return FALSE; + + if (strcmp(storage->name, "shared") == 0) { + /* allow multiple independent shared namespaces */ + return FALSE; + } + + return storage; +} + static struct mail_storage * mail_storage_find(struct mail_user *user, const struct mail_storage *storage_class, @@ -268,10 +288,7 @@ struct mail_storage *storage = user->storages; for (; storage != NULL; storage = storage->next) { - if (strcmp(storage->name, storage_class->name) == 0 && - ((storage->class_flags & - MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) == 0 || - strcmp(storage->unique_root_dir, set->root_dir) == 0)) + if (mail_storage_match_class(storage, storage_class, set)) return storage; } return NULL; From dovecot at dovecot.org Fri Sep 16 16:02:09 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:02:09 +0300 Subject: dovecot-2.1: acl: Fixed listing multiple shared namespaces. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4552430ae44e changeset: 13469:4552430ae44e user: Timo Sirainen date: Fri Sep 16 16:01:53 2011 +0300 description: acl: Fixed listing multiple shared namespaces. diffstat: src/plugins/acl/acl-plugin.h | 3 ++- src/plugins/acl/acl-shared-storage.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diffs (45 lines): diff -r cfbca51c0ade -r 4552430ae44e src/plugins/acl/acl-plugin.h --- a/src/plugins/acl/acl-plugin.h Fri Sep 16 16:01:29 2011 +0300 +++ b/src/plugins/acl/acl-plugin.h Fri Sep 16 16:01:53 2011 +0300 @@ -21,7 +21,6 @@ const char *const *groups; struct acl_lookup_dict *acl_lookup_dict; - time_t last_shared_add_check; }; struct acl_storage_rights_context { @@ -32,6 +31,8 @@ struct acl_mailbox_list { union mailbox_list_module_context module_ctx; struct acl_storage_rights_context rights; + + time_t last_shared_add_check; }; extern MODULE_CONTEXT_DEFINE(acl_storage_module, &mail_storage_module_register); diff -r cfbca51c0ade -r 4552430ae44e src/plugins/acl/acl-shared-storage.c --- a/src/plugins/acl/acl-shared-storage.c Fri Sep 16 16:01:29 2011 +0300 +++ b/src/plugins/acl/acl-shared-storage.c Fri Sep 16 16:01:53 2011 +0300 @@ -65,6 +65,7 @@ int acl_shared_namespaces_add(struct mail_namespace *ns) { struct acl_user *auser = ACL_USER_CONTEXT(ns->user); + struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(ns->list); struct mail_storage *storage = ns->storage; struct acl_lookup_dict_iter *iter; const char *name; @@ -72,11 +73,11 @@ i_assert(ns->type == NAMESPACE_SHARED); i_assert(strcmp(storage->name, SHARED_STORAGE_NAME) == 0); - if (ioloop_time < auser->last_shared_add_check + SHARED_NS_RETRY_SECS) { + if (ioloop_time < alist->last_shared_add_check + SHARED_NS_RETRY_SECS) { /* already added, don't bother rechecking */ return 0; } - auser->last_shared_add_check = ioloop_time; + alist->last_shared_add_check = ioloop_time; iter = acl_lookup_dict_iterate_visible_init(auser->acl_lookup_dict); while ((name = acl_lookup_dict_iterate_visible_next(iter)) != NULL) { From dovecot at dovecot.org Fri Sep 16 16:14:30 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:14:30 +0300 Subject: dovecot-2.1: TODO updated Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6a918d40d6f7 changeset: 13470:6a918d40d6f7 user: Timo Sirainen date: Fri Sep 16 16:14:14 2011 +0300 description: TODO updated diffstat: TODO | 27 ++------------------------- 1 files changed, 2 insertions(+), 25 deletions(-) diffs (79 lines): diff -r 4552430ae44e -r 6a918d40d6f7 TODO --- a/TODO Fri Sep 16 16:01:53 2011 +0300 +++ b/TODO Fri Sep 16 16:14:14 2011 +0300 @@ -1,3 +1,4 @@ + - mdbox/sdbox index rebuild -> quota rebuild? - anvil crash -> Error: Anvil client not compatible with this server (mixed old and new binaries?) - solr separate attachments (patch) - sql connection pooling: Count lookup latencies, avoid servers with @@ -15,18 +16,10 @@ e.g. % - mailbox_get_metadata(guid) could be optimized - virtual could use it to avoid keeping all mailboxes open - - lib-ssl-iostream: - - Verify remote server name. get logic from postfix. - - WANT_READ/WANT_WRITE handling isn't done right.. - imapc: + - lda/lmtp crashes because saved mail's seq=0 - prefetching to THREAD and SORT - - fix hangs if remote disconnects (still happening?) - after LIST "" * is refreshed, delete all unlisted local index dirs - - fix lib-index assert-crash when >1 messages are expunged while they're - still in delayed_trans - - if there's no sync after mailbox_notify(), IDLE isn't called again.. - - mbox->to_idle_delay could get added during imapc_client_run() and its - timeout goes to wrong ioloop.. - check: - dsyncing between two namespace separators is probably broken.. - remove mail_deliver_session after all, do all the stuff transparently @@ -137,9 +130,6 @@ 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 - - virtual: "Searched n% of the mailbox" gives broken numbers since - ctx->seq jumps around. And why is it also returned when fts is enabled - along with "Indexed n% of the mailbox"? - how do shared mailboxes work with plugins? - lazy-expunge, fts, etc.? - listescape+acl can't handle shared mailboxes with escape chars @@ -170,7 +160,6 @@ filesystem block size instead of hardcoded DEV_BSIZE? not with AIX.. - lucene: handle replacement chars? - squat: - - support ORs - wrong indexid - fts_build_init() assertion failed: (last_uid < last_uid_locked) - is locking done right? it reads header without file being locked? @@ -205,9 +194,6 @@ - maildir - don't allow more than 26 keywords - - physical separator could be configurable - - lda+maildir: if new mails are in new/ or cur/ they're not added to - dovecot-uidlist but newly saved mails are, so UIDs will be in wrong order - file_cache: we're growing the mmap in page size blocks, which is horribly slow if mremap() doesn't exist. @@ -277,13 +263,6 @@ untrusted computers. Maybe always send [ALERT] about the previous read-only login time with IP? - - quota - - if dovecot-uidlist can't be written, assume the new mails have UIDs - beginning from uidlist.next_uid. Whenever mails are expunged, overwrite - the next_uid field with the current highest next_uid. Whenever we have - assumed UIDs and uidlist gets updated, throw the client out with - "inconsist mailbox". - - ssl - add setting: ssl_options = bitmask. by default we enable all openssl workarounds, this could be used to disable some of them @@ -294,8 +273,6 @@ - message_search_init() could accept multiple search keywords so we wouldn't need to call it separately for each one (so we wouldn't need to parse the message multiple times). - - could optionally support scanning inside file attachments and use - plugins to extract text out of them (word, excel, pdf, etc. etc.) - Create our own extension: When searching with TEXT/BODY, return the message text surrounding the keywords just like web search engines do. like: SEARCH X-PRINT-MATCHES TEXT "hello" -> * SEARCH 1 "He said: From dovecot at dovecot.org Fri Sep 16 16:40:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:40:45 +0300 Subject: dovecot-2.0: auth: Use "auth-worker:" log prefix for auth worker... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8379707478d7 changeset: 12930:8379707478d7 user: Timo Sirainen date: Fri Sep 16 16:40:32 2011 +0300 description: auth: Use "auth-worker:" log prefix for auth worker processes. diffstat: src/auth/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 19086b0d53f4 -r 8379707478d7 src/auth/main.c --- a/src/auth/main.c Fri Sep 16 14:59:34 2011 +0300 +++ b/src/auth/main.c Fri Sep 16 16:40:32 2011 +0300 @@ -282,6 +282,8 @@ while ((c = master_getopt(master_service)) > 0) { switch (c) { case 'w': + master_service_init_log(master_service, + "auth-worker: "); worker = TRUE; break; default: From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-storage: Added MAILBOX_TRANSACTION_FLAG_NO_CACH... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5320315600a4 changeset: 13472:5320315600a4 user: Timo Sirainen date: Tue Aug 30 04:32:55 2011 +0300 description: lib-storage: Added MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC and use it when precaching. The result is that "doveadm index" no longer changes caching decisions. diffstat: src/lib-storage/index/index-sync.c | 2 +- src/lib-storage/index/index-transaction.c | 3 +++ src/lib-storage/mail-storage.h | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diffs (40 lines): diff -r efedf0644da8 -r 5320315600a4 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Tue Aug 30 04:31:00 2011 +0300 +++ b/src/lib-storage/index/index-sync.c Tue Aug 30 04:32:55 2011 +0300 @@ -392,7 +392,7 @@ } /* find the first message we need to index */ - trans = mailbox_transaction_begin(box, 0); + trans = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC); mail = mail_alloc(trans, 0, NULL); for (seq = status->messages; seq > 0; seq--) { mail_set_seq(mail, seq); diff -r efedf0644da8 -r 5320315600a4 src/lib-storage/index/index-transaction.c --- a/src/lib-storage/index/index-transaction.c Tue Aug 30 04:31:00 2011 +0300 +++ b/src/lib-storage/index/index-transaction.c Tue Aug 30 04:32:55 2011 +0300 @@ -91,6 +91,9 @@ t->cache_view = it->cache_view; t->cache_trans = it->cache_trans; + if ((flags & MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC) != 0) + mail_cache_view_update_cache_decisions(t->cache_view, FALSE); + /* set up after mail_cache_get_transaction(), so that we'll still have the cache_trans available in _index_commit() */ it->super = t->itrans->v; diff -r efedf0644da8 -r 5320315600a4 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Tue Aug 30 04:31:00 2011 +0300 +++ b/src/lib-storage/mail-storage.h Tue Aug 30 04:32:55 2011 +0300 @@ -140,7 +140,10 @@ is done only if it can be done easily. */ MAILBOX_TRANSACTION_FLAG_ASSIGN_UIDS = 0x04, /* Refresh the index so lookups return latest flags/modseqs */ - MAILBOX_TRANSACTION_FLAG_REFRESH = 0x08 + MAILBOX_TRANSACTION_FLAG_REFRESH = 0x08, + /* Don't update caching decisions no matter what we do in this + transaction (useful for e.g. precaching) */ + MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC = 0x10 }; enum mailbox_sync_flags { From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-index: Added mail_cache_view_update_cache_decis... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/efedf0644da8 changeset: 13471:efedf0644da8 user: Timo Sirainen date: Tue Aug 30 04:31:00 2011 +0300 description: lib-index: Added mail_cache_view_update_cache_decisions() diffstat: src/lib-index/mail-cache-decisions.c | 5 ++++- src/lib-index/mail-cache-private.h | 2 ++ src/lib-index/mail-cache.c | 6 ++++++ src/lib-index/mail-cache.h | 5 +++++ 4 files changed, 17 insertions(+), 1 deletions(-) diffs (65 lines): diff -r e01c9f89b0b0 -r efedf0644da8 src/lib-index/mail-cache-decisions.c --- a/src/lib-index/mail-cache-decisions.c Mon Aug 29 07:08:04 2011 +0300 +++ b/src/lib-index/mail-cache-decisions.c Tue Aug 30 04:31:00 2011 +0300 @@ -79,6 +79,9 @@ i_assert(field < cache->fields_count); + if (view->no_decision_updates) + return; + mail_index_lookup_uid(view->view, seq, &uid); hdr = mail_index_get_header(view->view); @@ -124,7 +127,7 @@ i_assert(field < cache->fields_count); - if (MAIL_CACHE_IS_UNUSABLE(cache)) + if (MAIL_CACHE_IS_UNUSABLE(cache) || view->no_decision_updates) return; if (cache->fields[field].field.decision != MAIL_CACHE_DECISION_NO) { diff -r e01c9f89b0b0 -r efedf0644da8 src/lib-index/mail-cache-private.h --- a/src/lib-index/mail-cache-private.h Mon Aug 29 07:08:04 2011 +0300 +++ b/src/lib-index/mail-cache-private.h Tue Aug 30 04:31:00 2011 +0300 @@ -198,6 +198,8 @@ buffer_t *cached_exists_buf; uint8_t cached_exists_value; uint32_t cached_exists_seq; + + unsigned int no_decision_updates:1; }; struct mail_cache_iterate_field { diff -r e01c9f89b0b0 -r efedf0644da8 src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Mon Aug 29 07:08:04 2011 +0300 +++ b/src/lib-index/mail-cache.c Tue Aug 30 04:31:00 2011 +0300 @@ -714,6 +714,12 @@ i_free(view); } +void mail_cache_view_update_cache_decisions(struct mail_cache_view *view, + bool update) +{ + view->no_decision_updates = !update; +} + uint32_t mail_cache_get_first_new_seq(struct mail_index_view *view) { const struct mail_index_header *idx_hdr; diff -r e01c9f89b0b0 -r efedf0644da8 src/lib-index/mail-cache.h --- a/src/lib-index/mail-cache.h Mon Aug 29 07:08:04 2011 +0300 +++ b/src/lib-index/mail-cache.h Tue Aug 30 04:31:00 2011 +0300 @@ -71,6 +71,11 @@ mail_cache_view_open(struct mail_cache *cache, struct mail_index_view *iview); void mail_cache_view_close(struct mail_cache_view *view); +/* Normally cache decisions are updated on lookup/add. Use this function to + enable/disable this (useful for precaching data). */ +void mail_cache_view_update_cache_decisions(struct mail_cache_view *view, + bool update); + /* Get index transaction specific cache transaction. */ struct mail_cache_transaction_ctx * mail_cache_get_transaction(struct mail_cache_view *view, From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-index: Make sure mail_index_sync_record() doesn... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1a6528646e11 changeset: 13473:1a6528646e11 user: Timo Sirainen date: Thu Sep 01 19:33:22 2011 +0300 description: lib-index: Make sure mail_index_sync_record() doesn't waste data stack. diffstat: src/lib-index/mail-index-sync-update.c | 24 +++++++++++++++++------- src/lib-index/mail-index-view-sync.c | 6 ++---- 2 files changed, 19 insertions(+), 11 deletions(-) diffs (64 lines): diff -r 5320315600a4 -r 1a6528646e11 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Tue Aug 30 04:32:55 2011 +0300 +++ b/src/lib-index/mail-index-sync-update.c Thu Sep 01 19:33:22 2011 +0300 @@ -518,9 +518,10 @@ return 1; } -int mail_index_sync_record(struct mail_index_sync_map_ctx *ctx, - const struct mail_transaction_header *hdr, - const void *data) +static int +mail_index_sync_record_real(struct mail_index_sync_map_ctx *ctx, + const struct mail_transaction_header *hdr, + const void *data) { int ret = 0; @@ -813,6 +814,18 @@ return ret; } +int mail_index_sync_record(struct mail_index_sync_map_ctx *ctx, + const struct mail_transaction_header *hdr, + const void *data) +{ + int ret; + + T_BEGIN { + ret = mail_index_sync_record_real(ctx, hdr, data); + } T_END; + return ret; +} + void mail_index_sync_map_init(struct mail_index_sync_map_ctx *sync_map_ctx, struct mail_index_view *view, enum mail_index_sync_handler_type type) @@ -1020,10 +1033,7 @@ } /* we'll just skip over broken entries */ - T_BEGIN { - (void)mail_index_sync_record(&sync_map_ctx, - thdr, tdata); - } T_END; + (void)mail_index_sync_record(&sync_map_ctx, thdr, tdata); } map = view->map; diff -r 5320315600a4 -r 1a6528646e11 src/lib-index/mail-index-view-sync.c --- a/src/lib-index/mail-index-view-sync.c Tue Aug 30 04:32:55 2011 +0300 +++ b/src/lib-index/mail-index-view-sync.c Thu Sep 01 19:33:22 2011 +0300 @@ -736,10 +736,8 @@ if (ctx->sync_map_update && !synced_to_map) { if ((hdr->type & (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_GUID)) == 0) { - T_BEGIN { - ret = mail_index_sync_record(&ctx->sync_map_ctx, - hdr, ctx->data); - } T_END; + ret = mail_index_sync_record(&ctx->sync_map_ctx, + hdr, ctx->data); } if (ret < 0) return -1; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-storage: Minor error handling cleanups. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1903d5fd7e76 changeset: 13474:1903d5fd7e76 user: Timo Sirainen date: Thu Sep 08 11:16:55 2011 +0300 description: lib-storage: Minor error handling cleanups. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 3 +-- src/lib-storage/index/dbox-single/sdbox-storage.c | 3 +-- src/lib-storage/index/index-storage.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diffs (38 lines): diff -r 1a6528646e11 -r 1903d5fd7e76 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -202,8 +202,7 @@ ret = mail_index_sync_begin(box->index, &sync_ctx, &view, &trans, 0); if (ret <= 0) { i_assert(ret != 0); - mail_storage_set_internal_error(box->storage); - mail_index_reset_error(box->index); + mail_storage_set_index_error(box); return -1; } diff -r 1a6528646e11 -r 1903d5fd7e76 src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -180,8 +180,7 @@ sdbox_update_header(mbox, trans, update); if (new_trans != NULL) { if (mail_index_transaction_commit(&new_trans) < 0) { - mail_storage_set_internal_error(box->storage); - mail_index_reset_error(box->index); + mail_storage_set_index_error(box); return -1; } } diff -r 1a6528646e11 -r 1903d5fd7e76 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Thu Sep 01 19:33:22 2011 +0300 +++ b/src/lib-storage/index/index-storage.c Thu Sep 08 11:16:55 2011 +0300 @@ -404,7 +404,7 @@ } if ((ret = mail_index_transaction_commit(&trans)) < 0) - mail_storage_set_internal_error(box->storage); + mail_storage_set_index_error(box); mail_index_view_close(&view); return ret; } From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-storage: Fixed mail_storage_copy() error handling. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/858298eb101f changeset: 13475:858298eb101f user: Timo Sirainen date: Thu Sep 08 11:50:23 2011 +0300 description: lib-storage: Fixed mail_storage_copy() error handling. diffstat: src/lib-storage/mail-copy.c | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-) diffs (62 lines): diff -r 1903d5fd7e76 -r 858298eb101f src/lib-storage/mail-copy.c --- a/src/lib-storage/mail-copy.c Thu Sep 08 11:16:55 2011 +0300 +++ b/src/lib-storage/mail-copy.c Thu Sep 08 11:50:23 2011 +0300 @@ -5,6 +5,21 @@ #include "mail-storage-private.h" #include "mail-copy.h" +static void +mail_copy_set_failed(struct mail_save_context *ctx, struct mail *mail, + const char *func) +{ + const char *errstr; + enum mail_error error; + + if (ctx->transaction->box->storage == mail->box->storage) + return; + + errstr = mail_storage_get_last_error(mail->box->storage, &error); + mail_storage_set_error(ctx->transaction->box->storage, error, + t_strdup_printf("%s (%s)", errstr, func)); +} + static int mail_storage_try_copy(struct mail_save_context **_ctx, struct mail *mail) { @@ -20,24 +35,32 @@ to help anything. */ pmail->v.set_uid_cache_updates(mail, TRUE); - if (mail_get_stream(mail, NULL, NULL, &input) < 0) + if (mail_get_stream(mail, NULL, NULL, &input) < 0) { + mail_copy_set_failed(ctx, mail, "stream"); return -1; + } if (ctx->received_date == (time_t)-1) { - if (mail_get_received_date(mail, &received_date) < 0) + if (mail_get_received_date(mail, &received_date) < 0) { + mail_copy_set_failed(ctx, mail, "received-date"); return -1; + } mailbox_save_set_received_date(ctx, received_date, 0); } if (ctx->from_envelope == NULL) { if (mail_get_special(mail, MAIL_FETCH_FROM_ENVELOPE, - &from_envelope) < 0) + &from_envelope) < 0) { + mail_copy_set_failed(ctx, mail, "from-envelope"); return -1; + } if (*from_envelope != '\0') mailbox_save_set_from_envelope(ctx, from_envelope); } if (ctx->guid == NULL) { - if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) + if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) { + mail_copy_set_failed(ctx, mail, "guid"); return -1; + } if (*guid != '\0') mailbox_save_set_guid(ctx, guid); } From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-lda: Log message improvement to differentiate m... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/323ab62983b6 changeset: 13476:323ab62983b6 user: Timo Sirainen date: Thu Sep 08 11:51:18 2011 +0300 description: lib-lda: Log message improvement to differentiate mailbox open vs. save error. diffstat: src/lib-lda/mail-deliver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 858298eb101f -r 323ab62983b6 src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Thu Sep 08 11:50:23 2011 +0300 +++ b/src/lib-lda/mail-deliver.c Thu Sep 08 11:51:18 2011 +0300 @@ -291,7 +291,7 @@ &error, &errstr) < 0) { if (box != NULL) mailbox_free(&box); - mail_deliver_log(ctx, "save failed to %s: %s", + mail_deliver_log(ctx, "save failed to open mailbox %s: %s", mailbox_name, errstr); return -1; } From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lmtp: Improved "DATA output timeout" error message. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/8de8752b2e94 changeset: 13477:8de8752b2e94 user: Timo Sirainen date: Thu Sep 08 13:41:20 2011 +0300 description: lmtp: Improved "DATA output timeout" error message. diffstat: src/lmtp/lmtp-proxy.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diffs (29 lines): diff -r 323ab62983b6 -r 8de8752b2e94 src/lmtp/lmtp-proxy.c --- a/src/lmtp/lmtp-proxy.c Thu Sep 08 11:51:18 2011 +0300 +++ b/src/lmtp/lmtp-proxy.c Thu Sep 08 13:41:20 2011 +0300 @@ -336,6 +336,8 @@ { struct lmtp_proxy_connection *const *conns; uoff_t min_offset; + size_t size; + const char *errstr; min_offset = lmtp_proxy_find_lowest_offset(proxy); if (min_offset == (uoff_t)-1) @@ -348,9 +350,13 @@ if (conn->data_input != NULL && conn->data_input->v_offset == min_offset) { - lmtp_client_fail(conn->client, - ERRSTR_TEMP_REMOTE_FAILURE - " (DATA output timeout)"); + (void)i_stream_get_data(conn->data_input, &size); + errstr = t_strdup_printf(ERRSTR_TEMP_REMOTE_FAILURE + " (DATA output stalled for %u secs, " + "%"PRIuUOFF_T"B sent, %"PRIuSIZE_T"B buffered)", + proxy->max_timeout_msecs/1000, + min_offset, size); + lmtp_client_fail(conn->client, errstr); } } return TRUE; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-storage: Error handling fix for key+=value when... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0f63b7c5dd7c changeset: 13478:0f63b7c5dd7c user: Timo Sirainen date: Thu Sep 08 16:24:18 2011 +0300 description: lib-storage: Error handling fix for key+=value when key isn't of string type. diffstat: src/lib-storage/mail-storage-service.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 8de8752b2e94 -r 0f63b7c5dd7c src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Thu Sep 08 13:41:20 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Thu Sep 08 16:24:18 2011 +0300 @@ -122,7 +122,6 @@ /* key+=value */ append_value = line + len + 1; key = t_strndup(key, len-1); - line++; } if (!settings_parse_is_valid_key(set_parser, key)) { From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: ldap: Fixed auth binds for nonexistent users with s... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d00c95f33643 changeset: 13479:d00c95f33643 user: Timo Sirainen date: Mon Sep 12 14:02:30 2011 +0300 description: ldap: Fixed auth binds for nonexistent users with some LDAP servers. diffstat: src/auth/passdb-ldap.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 0f63b7c5dd7c -r d00c95f33643 src/auth/passdb-ldap.c --- a/src/auth/passdb-ldap.c Thu Sep 08 16:24:18 2011 +0300 +++ b/src/auth/passdb-ldap.c Mon Sep 12 14:02:30 2011 +0300 @@ -157,6 +157,10 @@ } auth_request_log_info(auth_request, "ldap", "%s", str); passdb_result = PASSDB_RESULT_PASSWORD_MISMATCH; + } else if (ret == LDAP_NO_SUCH_OBJECT) { + passdb_result = PASSDB_RESULT_USER_UNKNOWN; + auth_request_log_info(auth_request, "ldap", + "unknown user"); } else { auth_request_log_error(auth_request, "ldap", "ldap_bind() failed: %s", From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: quota-dirsize: Get the quota from "mail root dir", ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9ea79795088d changeset: 13480:9ea79795088d user: Timo Sirainen date: Mon Sep 12 14:01:36 2011 +0300 description: quota-dirsize: Get the quota from "mail root dir", not "mailboxes dir". Normally they are different only with dbox (~/dbox vs. ~/dbox/mailboxes). This mainly fixes using dirsize with mdbox, where the mail data is in ~/dbox/storage/ directory. Patch by ????? ??????. diffstat: src/plugins/quota/quota-dirsize.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r d00c95f33643 -r 9ea79795088d src/plugins/quota/quota-dirsize.c --- a/src/plugins/quota/quota-dirsize.c Mon Sep 12 14:02:30 2011 +0300 +++ b/src/plugins/quota/quota-dirsize.c Mon Sep 12 14:01:36 2011 +0300 @@ -163,7 +163,7 @@ is_file = mail_storage_is_mailbox_file(namespaces[i]->storage); path = mailbox_list_get_path(namespaces[i]->list, NULL, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + MAILBOX_LIST_PATH_TYPE_DIR); quota_count_path_add(&paths, path, FALSE); /* INBOX may be in different path. */ From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: mbox: Fixed fetching last message from compressed m... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a930318a74a1 changeset: 13481:a930318a74a1 user: Timo Sirainen date: Mon Sep 12 14:27:46 2011 +0300 description: mbox: Fixed fetching last message from compressed mboxes. diffstat: src/lib-storage/index/mbox/mbox-mail.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diffs (28 lines): diff -r 9ea79795088d -r a930318a74a1 src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Mon Sep 12 14:01:36 2011 +0300 +++ b/src/lib-storage/index/mbox/mbox-mail.c Mon Sep 12 14:27:46 2011 +0300 @@ -259,15 +259,19 @@ if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq)) i_panic("Message unexpectedly expunged from index"); - if (seq == hdr->messages_count) { + if (seq < hdr->messages_count) { + if (mbox_file_lookup_offset(mbox, view, seq + 1, + next_offset_r) <= 0) + ret = -1; + } else if (mail->mail.mail.box->input != NULL) { + /* opened the mailbox as input stream. we can't trust the + sync_size, since it's wrong with compressed mailboxes */ + ret = 0; + } else { /* last message, use the synced mbox size */ trailer_size = mbox->storage->storage.set->mail_save_crlf ? 2 : 1; *next_offset_r = mbox->mbox_hdr.sync_size - trailer_size; - } else { - if (mbox_file_lookup_offset(mbox, view, seq + 1, - next_offset_r) <= 0) - ret = -1; } mail_index_view_close(&view); return ret; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-index: mail_index_view_clone() didn't properly ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/df8bd044a47d changeset: 13483:df8bd044a47d user: Timo Sirainen date: Tue Sep 13 02:07:30 2011 +0300 description: lib-index: mail_index_view_clone() didn't properly clear all fields in the destination view. The only caller already had it cleared though. Patch by Mike Abbott / Apple. diffstat: src/lib-index/mail-index-view.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3c8b44bb1974 -r df8bd044a47d src/lib-index/mail-index-view.c --- a/src/lib-index/mail-index-view.c Mon Sep 12 16:32:20 2011 +0300 +++ b/src/lib-index/mail-index-view.c Tue Sep 13 02:07:30 2011 +0300 @@ -9,7 +9,7 @@ void mail_index_view_clone(struct mail_index_view *dest, const struct mail_index_view *src) { - memset(dest, 0, sizeof(dest)); + memset(dest, 0, sizeof(*dest)); dest->refcount = 1; dest->v = src->v; dest->index = src->index; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: dsync: If mailbox can't be opened, log an error but... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3c8b44bb1974 changeset: 13482:3c8b44bb1974 user: Timo Sirainen date: Mon Sep 12 16:32:20 2011 +0300 description: dsync: If mailbox can't be opened, log an error but continue anyway. diffstat: src/dsync/dsync-worker-local.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diffs (30 lines): diff -r a930318a74a1 -r 3c8b44bb1974 src/dsync/dsync-worker-local.c --- a/src/dsync/dsync-worker-local.c Mon Sep 12 14:27:46 2011 +0300 +++ b/src/dsync/dsync-worker-local.c Mon Sep 12 16:32:20 2011 +0300 @@ -521,6 +521,7 @@ struct local_dsync_mailbox_change *change; struct local_dsync_dir_change *dir_change, change_lookup; struct local_dsync_mailbox *old_lbox; + enum mail_error error; const char *const *fields; unsigned int i, field_count; @@ -560,8 +561,17 @@ struct mail_storage *storage = mailbox_get_storage(box); i_error("Failed to sync mailbox %s: %s", info->name, - mail_storage_get_last_error(storage, NULL)); + mail_storage_get_last_error(storage, &error)); mailbox_free(&box); + if (error == MAIL_ERROR_NOTFOUND || + error == MAIL_ERROR_NOTPOSSIBLE) { + /* Mailbox isn't selectable, try the next one. We + should have already caught \Noselect mailboxes, but + check them anyway here. The NOTPOSSIBLE check is + mainly for invalid mbox files. */ + return local_worker_mailbox_iter_next(_iter, + dsync_box_r); + } _iter->failed = TRUE; return -1; } From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: dsync: Ignore SIGHUP Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/41dd8f4d44d5 changeset: 13484:41dd8f4d44d5 user: Timo Sirainen date: Tue Sep 13 02:08:15 2011 +0300 description: dsync: Ignore SIGHUP diffstat: src/dsync/dsync.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (19 lines): diff -r df8bd044a47d -r 41dd8f4d44d5 src/dsync/dsync.c --- a/src/dsync/dsync.c Tue Sep 13 02:07:30 2011 +0300 +++ b/src/dsync/dsync.c Tue Sep 13 02:08:15 2011 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "lib-signals.h" #include "array.h" #include "execv-const.h" #include "settings-parser.h" @@ -230,6 +231,7 @@ usage(); } master_service_init_finish(master_service); + lib_signals_ignore(SIGHUP, TRUE); if (!dsync_debug) { /* disable debugging unless -D is given */ From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: Removed unnecessary code. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d635bcf35df7 changeset: 13485:d635bcf35df7 user: Timo Sirainen date: Tue Sep 13 02:09:02 2011 +0300 description: Removed unnecessary code. diffstat: src/lib-storage/mail-storage-service.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 41dd8f4d44d5 -r d635bcf35df7 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Sep 13 02:08:15 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Sep 13 02:09:02 2011 +0300 @@ -869,7 +869,6 @@ } user = p_new(user_pool, struct mail_storage_service_user, 1); - memset(user_r, 0, sizeof(user_r)); user->pool = user_pool; user->input = *input; user->input.userdb_fields = NULL; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: doveadm altmove: Added -r parameter to move mails b... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1910c76a6cc9 changeset: 13486:1910c76a6cc9 user: Timo Sirainen date: Thu Sep 15 11:54:11 2011 +0300 description: doveadm altmove: Added -r parameter to move mails back to primary storage. diffstat: src/doveadm/doveadm-mail-altmove.c | 47 +++++++++++++++++++++++++++++-------- 1 files changed, 36 insertions(+), 11 deletions(-) diffs (103 lines): diff -r d635bcf35df7 -r 1910c76a6cc9 src/doveadm/doveadm-mail-altmove.c --- a/src/doveadm/doveadm-mail-altmove.c Tue Sep 13 02:09:02 2011 +0300 +++ b/src/doveadm/doveadm-mail-altmove.c Thu Sep 15 11:54:11 2011 +0300 @@ -9,13 +9,20 @@ #include "doveadm-mail-iter.h" #include "doveadm-mail.h" +struct altmove_cmd_context { + struct doveadm_mail_cmd_context ctx; + bool reverse; +}; + static int cmd_altmove_box(const struct mailbox_info *info, - struct mail_search_args *search_args) + struct mail_search_args *search_args, bool reverse) { struct doveadm_mail_iter *iter; struct mailbox_transaction_context *trans; struct mail *mail; + enum modify_type modify_type = + !reverse ? MODIFY_ADD : MODIFY_REMOVE; if (doveadm_mail_iter_init(info, search_args, &trans, &iter) < 0) return -1; @@ -26,7 +33,7 @@ i_debug("altmove: box=%s uid=%u", info->name, mail->uid); } - mail_update_flags(mail, MODIFY_ADD, + mail_update_flags(mail, modify_type, (enum mail_flags)MAIL_INDEX_MAIL_FLAG_BACKEND); } mail_free(&mail); @@ -42,8 +49,9 @@ } static void -cmd_altmove_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) +cmd_altmove_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { + struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx; const enum mailbox_list_iter_flags iter_flags = MAILBOX_LIST_ITER_RAW_LIST | MAILBOX_LIST_ITER_NO_AUTO_INBOX | @@ -56,7 +64,7 @@ unsigned int i, count; t_array_init(&purged_storages, 8); - iter = doveadm_mail_list_iter_init(user, ctx->search_args, iter_flags); + iter = doveadm_mail_list_iter_init(user, _ctx->search_args, iter_flags); while ((info = doveadm_mail_list_iter_next(iter)) != NULL) T_BEGIN { if (info->ns != prev_ns) { if (prev_ns != NULL) { @@ -66,7 +74,7 @@ } prev_ns = info->ns; } - (void)cmd_altmove_box(info, ctx->search_args); + (void)cmd_altmove_box(info, _ctx->search_args, ctx->reverse); } T_END; doveadm_mail_list_iter_deinit(&iter); @@ -95,16 +103,33 @@ ctx->search_args = doveadm_mail_build_search_args(args); } +static bool +cmd_mailbox_altmove_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +{ + struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx; + + switch (c) { + case 'r': + ctx->reverse = TRUE; + break; + default: + return FALSE; + } + return TRUE; +} + static struct doveadm_mail_cmd_context *cmd_altmove_alloc(void) { - struct doveadm_mail_cmd_context *ctx; + struct altmove_cmd_context *ctx; - ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); - ctx->v.init = cmd_altmove_init; - ctx->v.run = cmd_altmove_run; - return ctx; + ctx = doveadm_mail_cmd_alloc(struct altmove_cmd_context); + ctx->ctx.getopt_args = "r"; + ctx->ctx.v.parse_arg = cmd_mailbox_altmove_parse_arg; + ctx->ctx.v.init = cmd_altmove_init; + ctx->ctx.v.run = cmd_altmove_run; + return &ctx->ctx; } struct doveadm_mail_cmd cmd_altmove = { - cmd_altmove_alloc, "altmove", "" + cmd_altmove_alloc, "altmove", "[-r] " }; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: mbox: mailbox_get_guid() works now without trying t... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0264ac68c770 changeset: 13487:0264ac68c770 user: Timo Sirainen date: Thu Sep 15 12:34:03 2011 +0300 description: mbox: mailbox_get_guid() works now without trying to sync the opened mailbox. This fixes assert-crash when LDA was trying to get mailbox GUID during save. diffstat: src/lib-storage/index/mbox/mbox-storage.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diffs (25 lines): diff -r 1910c76a6cc9 -r 0264ac68c770 src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Thu Sep 15 11:54:11 2011 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Thu Sep 15 12:34:03 2011 +0300 @@ -584,8 +584,19 @@ return -1; } if (mail_guid_128_is_empty(mbox->mbox_hdr.mailbox_guid)) { - if (mailbox_sync(&mbox->box, 0) < 0) - return -1; + /* create another mailbox and sync */ + struct mailbox *box2; + struct mbox_mailbox *mbox2; + int ret; + + i_assert(mbox->mbox_lock_type == F_UNLCK); + box2 = mailbox_alloc(box->list, box->name, + MAILBOX_FLAG_KEEP_RECENT); + ret = mailbox_sync(box2, 0); + mbox2 = (struct mbox_mailbox *)box2; + memcpy(guid, mbox2->mbox_hdr.mailbox_guid, MAIL_GUID_128_SIZE); + mailbox_free(&box2); + return ret; } memcpy(guid, mbox->mbox_hdr.mailbox_guid, MAIL_GUID_128_SIZE); return 0; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: auth: Don't assert-crash if login client disconnect... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0dffdc3bfad1 changeset: 13488:0dffdc3bfad1 user: Timo Sirainen date: Thu Sep 15 13:09:50 2011 +0300 description: auth: Don't assert-crash if login client disconnects during multi-reply mechanism. diffstat: src/auth/auth-request-handler.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 0264ac68c770 -r 0dffdc3bfad1 src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Thu Sep 15 12:34:03 2011 +0300 +++ b/src/auth/auth-request-handler.c Thu Sep 15 13:09:50 2011 +0300 @@ -244,6 +244,9 @@ anything but abort this request */ request->internal_failure = TRUE; result = AUTH_CLIENT_RESULT_FAILURE; + /* make sure this request is set to finished state + (it's not with result=continue) */ + auth_request_set_state(request, AUTH_REQUEST_STATE_FINISHED); } reply = auth_stream_reply_init(pool_datastack_create()); From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: liblib: Added io_loop_time_refresh() Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3334c12a2b1a changeset: 13489:3334c12a2b1a user: Timo Sirainen date: Thu Sep 15 13:38:54 2011 +0300 description: liblib: Added io_loop_time_refresh() diffstat: src/lib/ioloop.c | 7 +++++++ src/lib/ioloop.h | 3 +++ 2 files changed, 10 insertions(+), 0 deletions(-) diffs (30 lines): diff -r 0dffdc3bfad1 -r 3334c12a2b1a src/lib/ioloop.c --- a/src/lib/ioloop.c Thu Sep 15 13:09:50 2011 +0300 +++ b/src/lib/ioloop.c Thu Sep 15 13:38:54 2011 +0300 @@ -425,6 +425,13 @@ return ioloop->running; } +void io_loop_time_refresh(void) +{ + if (gettimeofday(&ioloop_timeval, NULL) < 0) + i_fatal("gettimeofday(): %m"); + ioloop_time = ioloop_timeval.tv_sec; +} + struct ioloop *io_loop_create(void) { struct ioloop *ioloop; diff -r 0dffdc3bfad1 -r 3334c12a2b1a src/lib/ioloop.h --- a/src/lib/ioloop.h Thu Sep 15 13:09:50 2011 +0300 +++ b/src/lib/ioloop.h Thu Sep 15 13:38:54 2011 +0300 @@ -78,6 +78,9 @@ /* Reset timeout so it's next run after now+msecs. */ void timeout_reset(struct timeout *timeout); +/* Refresh ioloop_time and ioloop_timeval variables. */ +void io_loop_time_refresh(void); + void io_loop_run(struct ioloop *ioloop); void io_loop_stop(struct ioloop *ioloop); /* safe to run in signal handler */ From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-sql: If MySQL connect takes more than 1 sec, do... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/11273f581686 changeset: 13491:11273f581686 user: Timo Sirainen date: Thu Sep 15 13:45:35 2011 +0300 description: lib-sql: If MySQL connect takes more than 1 sec, don't try to reconnect for that many secs. diffstat: src/lib-sql/driver-mysql.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (28 lines): diff -r c056bd23fdcc -r 11273f581686 src/lib-sql/driver-mysql.c --- a/src/lib-sql/driver-mysql.c Thu Sep 15 13:41:03 2011 +0300 +++ b/src/lib-sql/driver-mysql.c Thu Sep 15 13:45:35 2011 +0300 @@ -63,6 +63,7 @@ struct mysql_db *db = (struct mysql_db *)_db; const char *unix_socket, *host; unsigned long client_flags = db->client_flags; + unsigned int secs_used; bool failed; i_assert(db->api.state == SQL_DB_STATE_DISCONNECTED); @@ -108,13 +109,15 @@ failed = mysql_real_connect(db->mysql, host, db->user, db->password, db->dbname, db->port, unix_socket, client_flags) == NULL; - alarm(0); + secs_used = SQL_CONNECT_TIMEOUT_SECS - alarm(0); if (failed) { /* connecting could have taken a while. make sure that any timeouts that get added soon will get a refreshed timestamp. */ io_loop_time_refresh(); + if (db->api.connect_delay < secs_used) + db->api.connect_delay = secs_used; sql_db_set_state(&db->api, SQL_DB_STATE_DISCONNECTED); i_error("%s: Connect failed to database (%s): %s - " "waiting for %u seconds before retry", From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-sql: If MySQL connect fails, update ioloop time... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c056bd23fdcc changeset: 13490:c056bd23fdcc user: Timo Sirainen date: Thu Sep 15 13:41:03 2011 +0300 description: lib-sql: If MySQL connect fails, update ioloop times so later timeouts get added properly. diffstat: src/lib-sql/driver-mysql.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (23 lines): diff -r 3334c12a2b1a -r c056bd23fdcc src/lib-sql/driver-mysql.c --- a/src/lib-sql/driver-mysql.c Thu Sep 15 13:38:54 2011 +0300 +++ b/src/lib-sql/driver-mysql.c Thu Sep 15 13:41:03 2011 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "ioloop.h" #include "array.h" #include "str.h" #include "sql-api-private.h" @@ -109,6 +110,11 @@ client_flags) == NULL; alarm(0); if (failed) { + /* connecting could have taken a while. make sure that any + timeouts that get added soon will get a refreshed + timestamp. */ + io_loop_time_refresh(); + sql_db_set_state(&db->api, SQL_DB_STATE_DISCONNECTED); i_error("%s: Connect failed to database (%s): %s - " "waiting for %u seconds before retry", From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-sql: When escaping a string, use the first read... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1b829680dce4 changeset: 13492:1b829680dce4 user: Timo Sirainen date: Thu Sep 15 13:46:45 2011 +0300 description: lib-sql: When escaping a string, use the first ready connection (if any). This avoids unnecessarily trying to reconnect to a failing connection. diffstat: src/lib-sql/driver-sqlpool.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diffs (26 lines): diff -r 11273f581686 -r 1b829680dce4 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:45:35 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:46:45 2011 +0300 @@ -533,11 +533,18 @@ driver_sqlpool_escape_string(struct sql_db *_db, const char *string) { struct sqlpool_db *db = (struct sqlpool_db *)_db; - const struct sqlpool_connection *conn; + const struct sqlpool_connection *conns; + unsigned int i, count; - /* we always have at least one connection */ - conn = array_idx(&db->all_connections, 0); - return sql_escape_string(conn->db, string); + /* use the first ready connection */ + conns = array_get(&db->all_connections, &count); + for (i = 0; i < count; i++) { + if (SQL_DB_IS_READY(conns[i].db)) + return sql_escape_string(conns[i].db, string); + } + /* no ready connections. just use the first one (we're guaranteed + to always have one) */ + return sql_escape_string(conns[0].db, string); } static void driver_sqlpool_timeout(struct sqlpool_db *db) From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-sql: Connect to all configured hosts immediately. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/55552b4e8c65 changeset: 13493:55552b4e8c65 user: Timo Sirainen date: Thu Sep 15 13:47:44 2011 +0300 description: lib-sql: Connect to all configured hosts immediately. This makes load balancing between them actually work always. diffstat: src/lib-sql/driver-sqlpool.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diffs (34 lines): diff -r 1b829680dce4 -r 55552b4e8c65 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:46:45 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:47:44 2011 +0300 @@ -447,6 +447,19 @@ db->connection_limit = SQL_DEFAULT_CONNECTION_LIMIT; } +static void sqlpool_add_all_once(struct sqlpool_db *db) +{ + struct sqlpool_host *host; + unsigned int host_idx; + + for (;;) { + host = sqlpool_find_host_with_least_connections(db, &host_idx); + if (host->connection_count > 0) + break; + (void)sqlpool_add_connection(db, host, host_idx); + } +} + struct sql_db * driver_sqlpool_init(const char *connect_string, const struct sql_db *driver) { @@ -465,8 +478,8 @@ } T_END; i_array_init(&db->all_connections, 16); - /* always have at least one backend connection initialized */ - (void)sqlpool_add_new_connection(db); + /* connect to all databases so we can do load balancing immediately */ + sqlpool_add_all_once(db); return &db->api; } From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-sql: Don't try to connect to connections that a... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3955a5b2a917 changeset: 13494:3955a5b2a917 user: Timo Sirainen date: Thu Sep 15 13:48:26 2011 +0300 description: lib-sql: Don't try to connect to connections that are going to be reconnected later. This avoids unnecessarily trying to connect to failing connections. diffstat: src/lib-sql/driver-sqlpool.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (22 lines): diff -r 55552b4e8c65 -r 3955a5b2a917 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:47:44 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Thu Sep 15 13:48:26 2011 +0300 @@ -309,7 +309,7 @@ if (conns[idx].host_idx == unwanted_host_idx) continue; - if (!SQL_DB_IS_READY(conndb)) { + if (!SQL_DB_IS_READY(conndb) && conndb->to_reconnect == NULL) { /* see if we could reconnect to it immediately */ (void)sql_connect(conndb); } @@ -523,7 +523,8 @@ int ret = -1, ret2; array_foreach(&db->all_connections, conn) { - ret2 = sql_connect(conn->db); + ret2 = conn->db->to_reconnect != NULL ? -1 : + sql_connect(conn->db); if (ret2 > 0) return 1; if (ret2 == 0) From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-sql: Dropped connect timeout to 5 seconds. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/20a901f1de31 changeset: 13495:20a901f1de31 user: Timo Sirainen date: Thu Sep 15 13:53:10 2011 +0300 description: lib-sql: Dropped connect timeout to 5 seconds. Postfix is using 10 second auth timeout and this needs to be less than that. diffstat: src/lib-sql/sql-api-private.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3955a5b2a917 -r 20a901f1de31 src/lib-sql/sql-api-private.h --- a/src/lib-sql/sql-api-private.h Thu Sep 15 13:48:26 2011 +0300 +++ b/src/lib-sql/sql-api-private.h Thu Sep 15 13:53:10 2011 +0300 @@ -25,7 +25,7 @@ is never used). */ #define SQL_CONNECT_RESET_DELAY 15 /* Abort connect() if it can't connect within this time. */ -#define SQL_CONNECT_TIMEOUT_SECS 10 +#define SQL_CONNECT_TIMEOUT_SECS 5 /* Abort queries after this many seconds */ #define SQL_QUERY_TIMEOUT_SECS 60 /* Default max. number of connections to create per host */ From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: man: Added -r option to doveadm-altmove.1. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/85853915c8c0 changeset: 13496:85853915c8c0 user: Pascal Volk date: Thu Sep 15 19:51:27 2011 +0000 description: man: Added -r option to doveadm-altmove.1. diffstat: doc/man/doveadm-altmove.1.in | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diffs (45 lines): diff -r 20a901f1de31 -r 85853915c8c0 doc/man/doveadm-altmove.1.in --- a/doc/man/doveadm-altmove.1.in Thu Sep 15 13:53:10 2011 +0300 +++ b/doc/man/doveadm-altmove.1.in Thu Sep 15 19:51:27 2011 +0000 @@ -1,19 +1,19 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-ALTMOVE 1 "2010-11-25" "Dovecot v2.0" "Dovecot" +.\" Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file +.TH DOVEADM\-ALTMOVE 1 "2011-09-15" "Dovecot v2.0" "Dovecot" .SH NAME doveadm\-altmove \- Move matching mails to the alternative storage (dbox\-only) .\"------------------------------------------------------------------------ .SH SYNOPSIS -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " search_query .br .\"------------------------------------- -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " .BI \-A " search_query" .br .\"------------------------------------- -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " .BI \-u " user search_query" .\"------------------------------------------------------------------------ @@ -42,6 +42,16 @@ .\"------------------------------------- @INCLUDE:option-A@ .\"------------------------------------- +.TP +.B \-r +When the +.B \-r +option is given this +.I command +works the other way round. +Mails will be moved from the alternative storage back to the default mail +location. +.\"------------------------------------- @INCLUDE:option-S-socket@ .\"------------------------------------- @INCLUDE:option-u-user@ From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: man: Escape fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2795be14f37f changeset: 13497:2795be14f37f user: Timo Sirainen date: Fri Sep 16 11:59:15 2011 +0300 description: man: Escape fix. diffstat: doc/man/dsync.1.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 85853915c8c0 -r 2795be14f37f doc/man/dsync.1.in --- a/doc/man/dsync.1.in Thu Sep 15 19:51:27 2011 +0000 +++ b/doc/man/dsync.1.in Fri Sep 16 11:59:15 2011 +0300 @@ -167,7 +167,7 @@ For example: .sp .nf -ssh mailuser at host dsync -u user +ssh mailuser at host dsync \-u user .fi .\"------------------------------------------------------------------------ .SH COMMANDS From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: config: Don't crash strlist section contains a subs... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1a57526721d7 changeset: 13498:1a57526721d7 user: Timo Sirainen date: Fri Sep 16 12:08:49 2011 +0300 description: config: Don't crash strlist section contains a subsection. diffstat: src/config/config-parser.c | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diffs (61 lines): diff -r 2795be14f37f -r 1a57526721d7 src/config/config-parser.c --- a/src/config/config-parser.c Fri Sep 16 11:59:15 2011 +0300 +++ b/src/config/config-parser.c Fri Sep 16 12:08:49 2011 +0300 @@ -52,8 +52,8 @@ return NULL; } -static void config_add_type(struct setting_parser_context *parser, - const char *line, const char *section_name) +static int config_add_type(struct setting_parser_context *parser, + const char *line, const char *section_name) { const struct setting_parser_info *info; const char *p; @@ -61,21 +61,28 @@ int ret; info = settings_parse_get_prev_info(parser); + if (info == NULL) { + /* section inside strlist */ + return -1; + } if (info->type_offset == (size_t)-1) - return; + return 0; str = t_str_new(256); p = strchr(line, '='); str_append_n(str, line, p-line); str_append_c(str, SETTINGS_SEPARATOR); str_append(str, p+1); - str_append_c(str, SETTINGS_SEPARATOR); - str_append(str, info_type_name_find(info)); + if (info != NULL) { + str_append_c(str, SETTINGS_SEPARATOR); + str_append(str, info_type_name_find(info)); + } str_append_c(str, '='); str_append(str, section_name); ret = settings_parse_line(parser, str_c(str)); i_assert(ret > 0); + return 0; } static bool @@ -106,8 +113,12 @@ key, NULL); return -1; } - if (section_name != NULL) - config_add_type(l->parser, line, section_name); + if (section_name != NULL) { + if (config_add_type(l->parser, line, section_name) < 0) { + ctx->error = "Section not allowed here"; + return -1; + } + } } else if (ret < 0) { ctx->error = settings_parser_get_error(l->parser); return -1; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: s/commiting/committing/ Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/79d54b6ccfe1 changeset: 13499:79d54b6ccfe1 user: Timo Sirainen date: Fri Sep 16 12:11:25 2011 +0300 description: s/commiting/committing/ Caught by Marco Nenciarini. diffstat: src/doveadm/doveadm-mail-iter.c | 2 +- src/lib-index/mail-index-transaction-update.c | 2 +- src/lib-storage/index/index-sync.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diffs (36 lines): diff -r 1a57526721d7 -r 79d54b6ccfe1 src/doveadm/doveadm-mail-iter.c --- a/src/doveadm/doveadm-mail-iter.c Fri Sep 16 12:08:49 2011 +0300 +++ b/src/doveadm/doveadm-mail-iter.c Fri Sep 16 12:11:25 2011 +0300 @@ -63,7 +63,7 @@ } if (commit) { if (mailbox_transaction_commit(&iter->t) < 0) { - i_error("Commiting mailbox %s failed: %s", + i_error("Committing mailbox %s failed: %s", mailbox_get_vname(iter->box), mail_storage_get_last_error(iter->storage, NULL)); ret = -1; diff -r 1a57526721d7 -r 79d54b6ccfe1 src/lib-index/mail-index-transaction-update.c --- a/src/lib-index/mail-index-transaction-update.c Fri Sep 16 12:08:49 2011 +0300 +++ b/src/lib-index/mail-index-transaction-update.c Fri Sep 16 12:11:25 2011 +0300 @@ -358,7 +358,7 @@ } else { t->log_updates = TRUE; - /* ignore duplicates here. drop them when commiting. */ + /* ignore duplicates here. drop them when committing. */ if (!array_is_created(&t->expunges)) i_array_init(&t->expunges, 64); else if (!t->expunges_nonsorted) { diff -r 1a57526721d7 -r 79d54b6ccfe1 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Fri Sep 16 12:08:49 2011 +0300 +++ b/src/lib-storage/index/index-sync.c Fri Sep 16 12:11:25 2011 +0300 @@ -434,7 +434,7 @@ } mail_free(&mail); if (mailbox_transaction_commit(&trans) < 0) { - i_error("Commiting mailbox %s failed: %s", + i_error("Committing mailbox %s failed: %s", mailbox_get_vname(box), mail_storage_get_last_error(mailbox_get_storage(box), NULL)); return -1; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-sql: Fixed load balancing between multiple SQL ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/327698228158 changeset: 13500:327698228158 user: Timo Sirainen date: Fri Sep 16 12:21:02 2011 +0300 description: lib-sql: Fixed load balancing between multiple SQL hosts to actually work. diffstat: src/lib-sql/driver-sqlpool.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (23 lines): diff -r 79d54b6ccfe1 -r 327698228158 src/lib-sql/driver-sqlpool.c --- a/src/lib-sql/driver-sqlpool.c Fri Sep 16 12:11:25 2011 +0300 +++ b/src/lib-sql/driver-sqlpool.c Fri Sep 16 12:21:02 2011 +0300 @@ -303,7 +303,7 @@ conns = array_get(&db->all_connections, &count); for (i = 0; i < count; i++) { - unsigned int idx = (i + db->last_query_conn_idx) % count; + unsigned int idx = (i + db->last_query_conn_idx + 1) % count; struct sql_db *conndb = conns[idx].db; if (conns[idx].host_idx == unwanted_host_idx) @@ -526,8 +526,8 @@ ret2 = conn->db->to_reconnect != NULL ? -1 : sql_connect(conn->db); if (ret2 > 0) - return 1; - if (ret2 == 0) + ret = 1; + else if (ret2 == 0 && ret < 0) ret = 0; } return ret; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-storage: Changed debug message to sound less li... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/99e1a9aa03f7 changeset: 13501:99e1a9aa03f7 user: Timo Sirainen date: Fri Sep 16 12:57:40 2011 +0300 description: lib-storage: Changed debug message to sound less like an error message. diffstat: src/lib-storage/mailbox-list.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (15 lines): diff -r 327698228158 -r 99e1a9aa03f7 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Fri Sep 16 12:21:02 2011 +0300 +++ b/src/lib-storage/mailbox-list.c Fri Sep 16 12:57:40 2011 +0300 @@ -434,8 +434,9 @@ mailbox_list_set_critical(list, "stat(%s) failed: %m", path); } else if (list->mail_set->mail_debug) { - i_debug("Namespace %s: Permission lookup failed from %s", - list->ns->prefix, path); + i_debug("Namespace %s: %s doesn't exist yet, " + "using default permissions", + list->ns->prefix, path); } if (name != NULL) { /* return defaults */ From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-storage: If mailbox_rename() isn't possible and... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e57bd3e2ec27 changeset: 13502:e57bd3e2ec27 user: Timo Sirainen date: Fri Sep 16 13:06:48 2011 +0300 description: lib-storage: If mailbox_rename() isn't possible and mail_debug=yes, log the reason why. diffstat: src/lib-storage/mail-storage.c | 46 +++++++++++++++++++++++++++++++++-------- 1 files changed, 37 insertions(+), 9 deletions(-) diffs (82 lines): diff -r 99e1a9aa03f7 -r e57bd3e2ec27 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Sep 16 12:57:40 2011 +0300 +++ b/src/lib-storage/mail-storage.c Fri Sep 16 13:06:48 2011 +0300 @@ -805,15 +805,24 @@ static bool mail_storages_rename_compatible(struct mail_storage *storage1, - struct mail_storage *storage2) + struct mail_storage *storage2, + const char **error_r) { if (storage1 == storage2) return TRUE; - if (strcmp(storage1->name, storage2->name) != 0) + if (strcmp(storage1->name, storage2->name) != 0) { + *error_r = t_strdup_printf("storage %s != %s", + storage1->name, storage2->name); return FALSE; - if ((storage1->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0) + } + if ((storage1->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0) { + /* e.g. mdbox where all mails are in storage/ directory and + they can't be easily moved from there. */ + *error_r = t_strdup_printf("storage %s uses unique root", + storage1->name); return FALSE; + } return TRUE; } @@ -824,16 +833,29 @@ static bool mailbox_lists_rename_compatible(struct mailbox_list *list1, - struct mailbox_list *list2) + struct mailbox_list *list2, + const char **error_r) { - return nullequals(list1->set.alt_dir, list2->set.alt_dir) && - nullequals(list1->set.index_dir, list2->set.index_dir) && - nullequals(list1->set.control_dir, list2->set.control_dir); + if (!nullequals(list1->set.alt_dir, list2->set.alt_dir)) { + *error_r = "alt dirs don't match"; + return FALSE; + } + if (!nullequals(list1->set.index_dir, list2->set.index_dir)) { + *error_r = "index dirs don't match"; + return FALSE; + } + if (!nullequals(list1->set.control_dir, list2->set.control_dir)) { + *error_r = "control dirs don't match"; + return FALSE; + } + return TRUE; } int mailbox_rename(struct mailbox *src, struct mailbox *dest, bool rename_children) { + const char *error = NULL; + if (!mailbox_list_is_valid_existing_name(src->list, src->name) || *src->name == '\0' || !mailbox_list_is_valid_create_name(dest->list, dest->name)) { @@ -841,8 +863,14 @@ "Invalid mailbox name"); return -1; } - if (!mail_storages_rename_compatible(src->storage, dest->storage) || - !mailbox_lists_rename_compatible(src->list, dest->list)) { + if (!mail_storages_rename_compatible(src->storage, + dest->storage, &error) || + !mailbox_lists_rename_compatible(src->list, + dest->list, &error)) { + if (src->storage->set->mail_debug) { + i_debug("Can't rename '%s' to '%s': %s", + src->vname, dest->vname, error); + } mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, "Can't rename mailboxes across specified storages."); return -1; From dovecot at dovecot.org Fri Sep 16 16:59:32 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:32 +0300 Subject: dovecot-2.1: lib-storage: If shared namespace prefix doesn't end... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ea657df52a85 changeset: 13503:ea657df52a85 user: Timo Sirainen date: Fri Sep 16 13:14:11 2011 +0300 description: lib-storage: If shared namespace prefix doesn't end with hierarchy separator, fail. diffstat: src/lib-storage/index/shared/shared-storage.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (16 lines): diff -r e57bd3e2ec27 -r ea657df52a85 src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Fri Sep 16 13:06:48 2011 +0300 +++ b/src/lib-storage/index/shared/shared-storage.c Fri Sep 16 13:14:11 2011 +0300 @@ -79,6 +79,12 @@ *error_r = "Shared namespace prefix doesn't contain %u or %n"; return -1; } + if (p[-1] != ns->sep && + (ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) != 0) { + *error_r = "Shared namespace prefix doesn't end with hierarchy separator"; + return -1; + } /* truncate prefix after the above checks are done, so they can log the full prefix in error conditions */ From dovecot at dovecot.org Fri Sep 16 16:59:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:33 +0300 Subject: dovecot-2.1: lib-storage: Improved debug logging messages. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/19086b0d53f4 changeset: 13504:19086b0d53f4 user: Timo Sirainen date: Fri Sep 16 14:59:34 2011 +0300 description: lib-storage: Improved debug logging messages. diffstat: src/lib-storage/mail-storage.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (22 lines): diff -r ea657df52a85 -r 19086b0d53f4 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Sep 16 13:14:11 2011 +0300 +++ b/src/lib-storage/mail-storage.c Fri Sep 16 14:59:34 2011 +0300 @@ -837,15 +837,15 @@ const char **error_r) { if (!nullequals(list1->set.alt_dir, list2->set.alt_dir)) { - *error_r = "alt dirs don't match"; + *error_r = "one namespace has alt dir and another doesn't"; return FALSE; } if (!nullequals(list1->set.index_dir, list2->set.index_dir)) { - *error_r = "index dirs don't match"; + *error_r = "one namespace has index dir and another doesn't"; return FALSE; } if (!nullequals(list1->set.control_dir, list2->set.control_dir)) { - *error_r = "control dirs don't match"; + *error_r = "one namespace has control dir and another doesn't"; return FALSE; } return TRUE; From dovecot at dovecot.org Fri Sep 16 16:59:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:33 +0300 Subject: dovecot-2.1: auth: Use "auth-worker:" log prefix for auth worker... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/8379707478d7 changeset: 13505:8379707478d7 user: Timo Sirainen date: Fri Sep 16 16:40:32 2011 +0300 description: auth: Use "auth-worker:" log prefix for auth worker processes. diffstat: src/auth/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 19086b0d53f4 -r 8379707478d7 src/auth/main.c --- a/src/auth/main.c Fri Sep 16 14:59:34 2011 +0300 +++ b/src/auth/main.c Fri Sep 16 16:40:32 2011 +0300 @@ -282,6 +282,8 @@ while ((c = master_getopt(master_service)) > 0) { switch (c) { case 'w': + master_service_init_log(master_service, + "auth-worker: "); worker = TRUE; break; default: From dovecot at dovecot.org Fri Sep 16 16:59:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:33 +0300 Subject: dovecot-2.1: Added tag 2.0.15 for changeset 11ef52450096 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/48395777f852 changeset: 13507:48395777f852 user: Timo Sirainen date: Fri Sep 16 16:45:22 2011 +0300 description: Added tag 2.0.15 for changeset 11ef52450096 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 11ef52450096 -r 48395777f852 .hgtags --- a/.hgtags Fri Sep 16 16:45:22 2011 +0300 +++ b/.hgtags Fri Sep 16 16:45:22 2011 +0300 @@ -65,3 +65,4 @@ 606faab2b896295b7dae7941b47e9374dbf90a66 2.0.12 aa8dfa085a99b5c6e1bb6d304adc67b8a199c63a 2.0.13 aa68f38c04f080fe4d3142fb3f73425b78ef98bd 2.0.14 +11ef524500964054ae8e4e6150f890b1864139eb 2.0.15 From dovecot at dovecot.org Fri Sep 16 16:59:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:33 +0300 Subject: dovecot-2.1: Released v2.0.15. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/11ef52450096 changeset: 13506:11ef52450096 user: Timo Sirainen date: Fri Sep 16 16:45:22 2011 +0300 description: Released v2.0.15. diffstat: NEWS | 13 +++++++++++++ configure.in | 2 +- 2 files changed, 14 insertions(+), 1 deletions(-) diffs (30 lines): diff -r 8379707478d7 -r 11ef52450096 NEWS --- a/NEWS Fri Sep 16 16:40:32 2011 +0300 +++ b/NEWS Fri Sep 16 16:45:22 2011 +0300 @@ -1,3 +1,16 @@ +v2.0.15 2011-09-16 Timo Sirainen + + + doveadm altmove: Added -r parameter to move mails back to primary + storage. + - v2.0.14: Index reading could have eaten a lot of memory in some + situations + - doveadm index no longer affects future caching decisions + - mbox: Fixed crash during mail delivery when mailbox didn't yet have + GUID assigned to it. + - zlib+mbox: Fetching last message from compressed mailboxes crashed. + - lib-sql: Fixed load balancing and error handling when multiple hosts + are used. + v2.0.14 2011-08-29 Timo Sirainen + doveadm: Added support for running mail commands by proxying to diff -r 8379707478d7 -r 11ef52450096 configure.in --- a/configure.in Fri Sep 16 16:40:32 2011 +0300 +++ b/configure.in Fri Sep 16 16:45:22 2011 +0300 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.0.14],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.0.15],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Fri Sep 16 16:59:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:33 +0300 Subject: dovecot-2.1: Added signature for changeset 11ef52450096 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/22858efc84bb changeset: 13508:22858efc84bb user: Timo Sirainen date: Fri Sep 16 16:45:25 2011 +0300 description: Added signature for changeset 11ef52450096 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 48395777f852 -r 22858efc84bb .hgsigs --- a/.hgsigs Fri Sep 16 16:45:22 2011 +0300 +++ b/.hgsigs Fri Sep 16 16:45:25 2011 +0300 @@ -28,3 +28,4 @@ 606faab2b896295b7dae7941b47e9374dbf90a66 0 iEYEABECAAYFAk2kh3YACgkQyUhSUUBViskrNgCfdmuKZ1/9HDFOvBuBnTCw6lUuiaEAn207VAo55MOIb1RwAQgaP8wNC7YS aa8dfa085a99b5c6e1bb6d304adc67b8a199c63a 0 iEYEABECAAYFAk3KpGwACgkQyUhSUUBVismbmQCfTKfNrQnIy2cIQCYUE7zFrRl6nvgAnAu5W0iAfzKwFEAGtnGj1h+D+tY0 aa68f38c04f080fe4d3142fb3f73425b78ef98bd 0 iEYEABECAAYFAk5bEKIACgkQyUhSUUBVislRhwCePWvqh3c+EitvNe1XlMqxpwWvDDgAoJKjDnmLwk0U62IhIQ+x90DEIgl6 +11ef524500964054ae8e4e6150f890b1864139eb 0 iEYEABECAAYFAk5zUvIACgkQyUhSUUBVisnDTgCdHVHSwKeZjHV4KrlTmqipFoO26mkAoIMqPTna3Y1ETIGnPq6XRCB90C8p From dovecot at dovecot.org Fri Sep 16 16:59:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 16:59:33 +0300 Subject: dovecot-2.1: Merged changes from v2.0.15. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/490a85b869e0 changeset: 13509:490a85b869e0 user: Timo Sirainen date: Fri Sep 16 16:59:10 2011 +0300 description: Merged changes from v2.0.15. diffstat: .hgsigs | 1 + .hgtags | 1 + NEWS | 13 +++++++ doc/man/doveadm-altmove.1.in | 20 ++++++++-- doc/man/dsync.1.in | 2 +- src/auth/auth-request-handler.c | 3 + src/auth/passdb-ldap.c | 4 ++ src/config/config-parser.c | 25 ++++++++++---- src/doveadm/doveadm-mail-altmove.c | 47 ++++++++++++++++++++------ src/doveadm/doveadm-mail-iter.c | 2 +- src/dsync/dsync.c | 2 + src/lib-index/mail-cache.h | 5 ++ src/lib-index/mail-index-transaction-update.c | 2 +- src/lib-index/mail-index-view.c | 2 +- src/lib-index/mail-index.h | 2 +- src/lib-sql/driver-mysql.c | 11 +++++- src/lib-sql/driver-sqlpool.c | 43 ++++++++++++++++++------ src/lib-sql/sql-api-private.h | 2 +- src/lib-storage/index/index-transaction.c | 3 + src/lib-storage/index/mbox/mbox-storage.c | 14 ++++++- src/lib-storage/index/shared/shared-storage.c | 6 +++ src/lib-storage/mail-storage-service.c | 2 - src/lib-storage/mail-storage.c | 46 +++++++++++++++++++++----- src/lib-storage/mailbox-list.c | 5 +- src/lib/ioloop.c | 7 ++++ src/lib/ioloop.h | 3 + src/lmtp/lmtp-proxy.c | 12 +++++- 27 files changed, 226 insertions(+), 59 deletions(-) diffs (truncated from 733 to 300 lines): diff -r 6a918d40d6f7 -r 490a85b869e0 .hgsigs --- a/.hgsigs Fri Sep 16 16:14:14 2011 +0300 +++ b/.hgsigs Fri Sep 16 16:59:10 2011 +0300 @@ -29,3 +29,4 @@ aa8dfa085a99b5c6e1bb6d304adc67b8a199c63a 0 iEYEABECAAYFAk3KpGwACgkQyUhSUUBVismbmQCfTKfNrQnIy2cIQCYUE7zFrRl6nvgAnAu5W0iAfzKwFEAGtnGj1h+D+tY0 aa68f38c04f080fe4d3142fb3f73425b78ef98bd 0 iEYEABECAAYFAk5bEKIACgkQyUhSUUBVislRhwCePWvqh3c+EitvNe1XlMqxpwWvDDgAoJKjDnmLwk0U62IhIQ+x90DEIgl6 8ae243558677b23f2077c3fe9683cc7890f5eb5d 0 iEYEABECAAYFAk5fSWYACgkQyUhSUUBVism47wCeJe0dWWZZLLXgn3r5oBg+jy9UtN0An3qCOCwxFxql7Ik42c/6kUKiCd1V +11ef524500964054ae8e4e6150f890b1864139eb 0 iEYEABECAAYFAk5zUvIACgkQyUhSUUBVisnDTgCdHVHSwKeZjHV4KrlTmqipFoO26mkAoIMqPTna3Y1ETIGnPq6XRCB90C8p diff -r 6a918d40d6f7 -r 490a85b869e0 .hgtags --- a/.hgtags Fri Sep 16 16:14:14 2011 +0300 +++ b/.hgtags Fri Sep 16 16:59:10 2011 +0300 @@ -66,3 +66,4 @@ aa8dfa085a99b5c6e1bb6d304adc67b8a199c63a 2.0.13 aa68f38c04f080fe4d3142fb3f73425b78ef98bd 2.0.14 8ae243558677b23f2077c3fe9683cc7890f5eb5d 2.1.alpha1 +11ef524500964054ae8e4e6150f890b1864139eb 2.0.15 diff -r 6a918d40d6f7 -r 490a85b869e0 NEWS --- a/NEWS Fri Sep 16 16:14:14 2011 +0300 +++ b/NEWS Fri Sep 16 16:59:10 2011 +0300 @@ -27,6 +27,19 @@ override_fields settings to specify template defaults/overrides. - listescape plugin works perfectly now +v2.0.15 2011-09-16 Timo Sirainen + + + doveadm altmove: Added -r parameter to move mails back to primary + storage. + - v2.0.14: Index reading could have eaten a lot of memory in some + situations + - doveadm index no longer affects future caching decisions + - mbox: Fixed crash during mail delivery when mailbox didn't yet have + GUID assigned to it. + - zlib+mbox: Fetching last message from compressed mailboxes crashed. + - lib-sql: Fixed load balancing and error handling when multiple hosts + are used. + v2.0.14 2011-08-29 Timo Sirainen + doveadm: Added support for running mail commands by proxying to diff -r 6a918d40d6f7 -r 490a85b869e0 doc/man/doveadm-altmove.1.in --- a/doc/man/doveadm-altmove.1.in Fri Sep 16 16:14:14 2011 +0300 +++ b/doc/man/doveadm-altmove.1.in Fri Sep 16 16:59:10 2011 +0300 @@ -1,19 +1,19 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-ALTMOVE 1 "2010-11-25" "Dovecot v2.0" "Dovecot" +.\" Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file +.TH DOVEADM\-ALTMOVE 1 "2011-09-15" "Dovecot v2.0" "Dovecot" .SH NAME doveadm\-altmove \- Move matching mails to the alternative storage (dbox\-only) .\"------------------------------------------------------------------------ .SH SYNOPSIS -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " search_query .br .\"------------------------------------- -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " .BI \-A " search_query" .br .\"------------------------------------- -.BR doveadm " [" \-Dv "] " altmove " [" \-S +.BR doveadm " [" \-Dv "] " altmove " [" \-r "] ["\-S .IR socket_path "] " .BI \-u " user search_query" .\"------------------------------------------------------------------------ @@ -42,6 +42,16 @@ .\"------------------------------------- @INCLUDE:option-A@ .\"------------------------------------- +.TP +.B \-r +When the +.B \-r +option is given this +.I command +works the other way round. +Mails will be moved from the alternative storage back to the default mail +location. +.\"------------------------------------- @INCLUDE:option-S-socket@ .\"------------------------------------- @INCLUDE:option-u-user@ diff -r 6a918d40d6f7 -r 490a85b869e0 doc/man/dsync.1.in --- a/doc/man/dsync.1.in Fri Sep 16 16:14:14 2011 +0300 +++ b/doc/man/dsync.1.in Fri Sep 16 16:59:10 2011 +0300 @@ -167,7 +167,7 @@ For example: .sp .nf -ssh mailuser at host dsync -u user +ssh mailuser at host dsync \-u user .fi .\"------------------------------------------------------------------------ .SH COMMANDS diff -r 6a918d40d6f7 -r 490a85b869e0 src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Fri Sep 16 16:14:14 2011 +0300 +++ b/src/auth/auth-request-handler.c Fri Sep 16 16:59:10 2011 +0300 @@ -244,6 +244,9 @@ anything but abort this request */ request->internal_failure = TRUE; result = AUTH_CLIENT_RESULT_FAILURE; + /* make sure this request is set to finished state + (it's not with result=continue) */ + auth_request_set_state(request, AUTH_REQUEST_STATE_FINISHED); } reply = auth_stream_reply_init(pool_datastack_create()); diff -r 6a918d40d6f7 -r 490a85b869e0 src/auth/passdb-ldap.c --- a/src/auth/passdb-ldap.c Fri Sep 16 16:14:14 2011 +0300 +++ b/src/auth/passdb-ldap.c Fri Sep 16 16:59:10 2011 +0300 @@ -157,6 +157,10 @@ } auth_request_log_info(auth_request, "ldap", "%s", str); passdb_result = PASSDB_RESULT_PASSWORD_MISMATCH; + } else if (ret == LDAP_NO_SUCH_OBJECT) { + passdb_result = PASSDB_RESULT_USER_UNKNOWN; + auth_request_log_info(auth_request, "ldap", + "unknown user"); } else { auth_request_log_error(auth_request, "ldap", "ldap_bind() failed: %s", diff -r 6a918d40d6f7 -r 490a85b869e0 src/config/config-parser.c --- a/src/config/config-parser.c Fri Sep 16 16:14:14 2011 +0300 +++ b/src/config/config-parser.c Fri Sep 16 16:59:10 2011 +0300 @@ -52,8 +52,8 @@ return NULL; } -static void config_add_type(struct setting_parser_context *parser, - const char *line, const char *section_name) +static int config_add_type(struct setting_parser_context *parser, + const char *line, const char *section_name) { const struct setting_parser_info *info; const char *p; @@ -61,21 +61,28 @@ int ret; info = settings_parse_get_prev_info(parser); + if (info == NULL) { + /* section inside strlist */ + return -1; + } if (info->type_offset == (size_t)-1) - return; + return 0; str = t_str_new(256); p = strchr(line, '='); str_append_n(str, line, p-line); str_append_c(str, SETTINGS_SEPARATOR); str_append(str, p+1); - str_append_c(str, SETTINGS_SEPARATOR); - str_append(str, info_type_name_find(info)); + if (info != NULL) { + str_append_c(str, SETTINGS_SEPARATOR); + str_append(str, info_type_name_find(info)); + } str_append_c(str, '='); str_append(str, section_name); ret = settings_parse_line(parser, str_c(str)); i_assert(ret > 0); + return 0; } static bool @@ -106,8 +113,12 @@ key, NULL); return -1; } - if (section_name != NULL) - config_add_type(l->parser, line, section_name); + if (section_name != NULL) { + if (config_add_type(l->parser, line, section_name) < 0) { + ctx->error = "Section not allowed here"; + return -1; + } + } } else if (ret < 0) { ctx->error = settings_parser_get_error(l->parser); return -1; diff -r 6a918d40d6f7 -r 490a85b869e0 src/doveadm/doveadm-mail-altmove.c --- a/src/doveadm/doveadm-mail-altmove.c Fri Sep 16 16:14:14 2011 +0300 +++ b/src/doveadm/doveadm-mail-altmove.c Fri Sep 16 16:59:10 2011 +0300 @@ -9,13 +9,20 @@ #include "doveadm-mail-iter.h" #include "doveadm-mail.h" +struct altmove_cmd_context { + struct doveadm_mail_cmd_context ctx; + bool reverse; +}; + static int cmd_altmove_box(const struct mailbox_info *info, - struct mail_search_args *search_args) + struct mail_search_args *search_args, bool reverse) { struct doveadm_mail_iter *iter; struct mailbox_transaction_context *trans; struct mail *mail; + enum modify_type modify_type = + !reverse ? MODIFY_ADD : MODIFY_REMOVE; if (doveadm_mail_iter_init(info, search_args, 0, NULL, &trans, &iter) < 0) @@ -26,7 +33,7 @@ i_debug("altmove: box=%s uid=%u", info->name, mail->uid); } - mail_update_flags(mail, MODIFY_ADD, + mail_update_flags(mail, modify_type, (enum mail_flags)MAIL_INDEX_MAIL_FLAG_BACKEND); } return doveadm_mail_iter_deinit_sync(&iter); @@ -41,8 +48,9 @@ } static void -cmd_altmove_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) +cmd_altmove_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { + struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx; const enum mailbox_list_iter_flags iter_flags = MAILBOX_LIST_ITER_RAW_LIST | MAILBOX_LIST_ITER_NO_AUTO_BOXES | @@ -55,7 +63,7 @@ unsigned int i, count; t_array_init(&purged_storages, 8); - iter = doveadm_mail_list_iter_init(user, ctx->search_args, iter_flags); + iter = doveadm_mail_list_iter_init(user, _ctx->search_args, iter_flags); while ((info = doveadm_mail_list_iter_next(iter)) != NULL) T_BEGIN { if (info->ns != prev_ns) { if (prev_ns != NULL) { @@ -65,7 +73,7 @@ } prev_ns = info->ns; } - (void)cmd_altmove_box(info, ctx->search_args); + (void)cmd_altmove_box(info, _ctx->search_args, ctx->reverse); } T_END; doveadm_mail_list_iter_deinit(&iter); @@ -94,16 +102,33 @@ ctx->search_args = doveadm_mail_build_search_args(args); } +static bool +cmd_mailbox_altmove_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +{ + struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx; + + switch (c) { + case 'r': + ctx->reverse = TRUE; + break; + default: + return FALSE; + } + return TRUE; +} + static struct doveadm_mail_cmd_context *cmd_altmove_alloc(void) { - struct doveadm_mail_cmd_context *ctx; + struct altmove_cmd_context *ctx; - ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); - ctx->v.init = cmd_altmove_init; - ctx->v.run = cmd_altmove_run; - return ctx; + ctx = doveadm_mail_cmd_alloc(struct altmove_cmd_context); + ctx->ctx.getopt_args = "r"; + ctx->ctx.v.parse_arg = cmd_mailbox_altmove_parse_arg; + ctx->ctx.v.init = cmd_altmove_init; + ctx->ctx.v.run = cmd_altmove_run; + return &ctx->ctx; } struct doveadm_mail_cmd cmd_altmove = { - cmd_altmove_alloc, "altmove", "" + cmd_altmove_alloc, "altmove", "[-r] " }; diff -r 6a918d40d6f7 -r 490a85b869e0 src/doveadm/doveadm-mail-iter.c --- a/src/doveadm/doveadm-mail-iter.c Fri Sep 16 16:14:14 2011 +0300 +++ b/src/doveadm/doveadm-mail-iter.c Fri Sep 16 16:59:10 2011 +0300 @@ -64,7 +64,7 @@ } if (commit) { if (mailbox_transaction_commit(&iter->t) < 0) { - i_error("Commiting mailbox %s failed: %s", + i_error("Committing mailbox %s failed: %s", mailbox_get_vname(iter->box), mailbox_get_last_error(iter->box, NULL)); ret = -1; diff -r 6a918d40d6f7 -r 490a85b869e0 src/dsync/dsync.c From dovecot at dovecot.org Fri Sep 16 17:12:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 17:12:31 +0300 Subject: dovecot-2.1: Released v2.1.alpha2. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f9e744ffe021 changeset: 13510:f9e744ffe021 user: Timo Sirainen date: Fri Sep 16 17:00:24 2011 +0300 description: Released v2.1.alpha2. diffstat: configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (10 lines): diff -r 490a85b869e0 -r f9e744ffe021 configure.in --- a/configure.in Fri Sep 16 16:59:10 2011 +0300 +++ b/configure.in Fri Sep 16 17:00:24 2011 +0300 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.alpha1],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.alpha2],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Fri Sep 16 17:12:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 17:12:31 +0300 Subject: dovecot-2.1: Added tag 2.1.alpha2 for changeset f9e744ffe021 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9b2c23b63474 changeset: 13511:9b2c23b63474 user: Timo Sirainen date: Fri Sep 16 17:00:24 2011 +0300 description: Added tag 2.1.alpha2 for changeset f9e744ffe021 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r f9e744ffe021 -r 9b2c23b63474 .hgtags --- a/.hgtags Fri Sep 16 17:00:24 2011 +0300 +++ b/.hgtags Fri Sep 16 17:00:24 2011 +0300 @@ -67,3 +67,4 @@ aa68f38c04f080fe4d3142fb3f73425b78ef98bd 2.0.14 8ae243558677b23f2077c3fe9683cc7890f5eb5d 2.1.alpha1 11ef524500964054ae8e4e6150f890b1864139eb 2.0.15 +f9e744ffe02135f6dc75e62db366bd39a8e19f99 2.1.alpha2 From dovecot at dovecot.org Fri Sep 16 17:12:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 17:12:31 +0300 Subject: dovecot-2.1: Added signature for changeset f9e744ffe021 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/823b7ab2e1d7 changeset: 13512:823b7ab2e1d7 user: Timo Sirainen date: Fri Sep 16 17:00:30 2011 +0300 description: Added signature for changeset f9e744ffe021 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 9b2c23b63474 -r 823b7ab2e1d7 .hgsigs --- a/.hgsigs Fri Sep 16 17:00:24 2011 +0300 +++ b/.hgsigs Fri Sep 16 17:00:30 2011 +0300 @@ -30,3 +30,4 @@ aa68f38c04f080fe4d3142fb3f73425b78ef98bd 0 iEYEABECAAYFAk5bEKIACgkQyUhSUUBVislRhwCePWvqh3c+EitvNe1XlMqxpwWvDDgAoJKjDnmLwk0U62IhIQ+x90DEIgl6 8ae243558677b23f2077c3fe9683cc7890f5eb5d 0 iEYEABECAAYFAk5fSWYACgkQyUhSUUBVism47wCeJe0dWWZZLLXgn3r5oBg+jy9UtN0An3qCOCwxFxql7Ik42c/6kUKiCd1V 11ef524500964054ae8e4e6150f890b1864139eb 0 iEYEABECAAYFAk5zUvIACgkQyUhSUUBVisnDTgCdHVHSwKeZjHV4KrlTmqipFoO26mkAoIMqPTna3Y1ETIGnPq6XRCB90C8p +f9e744ffe02135f6dc75e62db366bd39a8e19f99 0 iEYEABECAAYFAk5zVngACgkQyUhSUUBVisntgQCfaceKIsHTtbu6LpUd2Tjj8lIHXZYAn3mCNW+Fc43t6M1tIE/ZUEwiWzCv From dovecot at dovecot.org Fri Sep 16 17:12:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 17:12:31 +0300 Subject: dovecot-2.0: Released v2.0.15. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/11ef52450096 changeset: 12931:11ef52450096 user: Timo Sirainen date: Fri Sep 16 16:45:22 2011 +0300 description: Released v2.0.15. diffstat: NEWS | 13 +++++++++++++ configure.in | 2 +- 2 files changed, 14 insertions(+), 1 deletions(-) diffs (30 lines): diff -r 8379707478d7 -r 11ef52450096 NEWS --- a/NEWS Fri Sep 16 16:40:32 2011 +0300 +++ b/NEWS Fri Sep 16 16:45:22 2011 +0300 @@ -1,3 +1,16 @@ +v2.0.15 2011-09-16 Timo Sirainen + + + doveadm altmove: Added -r parameter to move mails back to primary + storage. + - v2.0.14: Index reading could have eaten a lot of memory in some + situations + - doveadm index no longer affects future caching decisions + - mbox: Fixed crash during mail delivery when mailbox didn't yet have + GUID assigned to it. + - zlib+mbox: Fetching last message from compressed mailboxes crashed. + - lib-sql: Fixed load balancing and error handling when multiple hosts + are used. + v2.0.14 2011-08-29 Timo Sirainen + doveadm: Added support for running mail commands by proxying to diff -r 8379707478d7 -r 11ef52450096 configure.in --- a/configure.in Fri Sep 16 16:40:32 2011 +0300 +++ b/configure.in Fri Sep 16 16:45:22 2011 +0300 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.0.14],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.0.15],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Fri Sep 16 17:12:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 17:12:31 +0300 Subject: dovecot-2.0: Added tag 2.0.15 for changeset 11ef52450096 Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/48395777f852 changeset: 12932:48395777f852 user: Timo Sirainen date: Fri Sep 16 16:45:22 2011 +0300 description: Added tag 2.0.15 for changeset 11ef52450096 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 11ef52450096 -r 48395777f852 .hgtags --- a/.hgtags Fri Sep 16 16:45:22 2011 +0300 +++ b/.hgtags Fri Sep 16 16:45:22 2011 +0300 @@ -65,3 +65,4 @@ 606faab2b896295b7dae7941b47e9374dbf90a66 2.0.12 aa8dfa085a99b5c6e1bb6d304adc67b8a199c63a 2.0.13 aa68f38c04f080fe4d3142fb3f73425b78ef98bd 2.0.14 +11ef524500964054ae8e4e6150f890b1864139eb 2.0.15 From dovecot at dovecot.org Fri Sep 16 17:12:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 16 Sep 2011 17:12:31 +0300 Subject: dovecot-2.0: Added signature for changeset 11ef52450096 Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/22858efc84bb changeset: 12933:22858efc84bb user: Timo Sirainen date: Fri Sep 16 16:45:25 2011 +0300 description: Added signature for changeset 11ef52450096 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 48395777f852 -r 22858efc84bb .hgsigs --- a/.hgsigs Fri Sep 16 16:45:22 2011 +0300 +++ b/.hgsigs Fri Sep 16 16:45:25 2011 +0300 @@ -28,3 +28,4 @@ 606faab2b896295b7dae7941b47e9374dbf90a66 0 iEYEABECAAYFAk2kh3YACgkQyUhSUUBViskrNgCfdmuKZ1/9HDFOvBuBnTCw6lUuiaEAn207VAo55MOIb1RwAQgaP8wNC7YS aa8dfa085a99b5c6e1bb6d304adc67b8a199c63a 0 iEYEABECAAYFAk3KpGwACgkQyUhSUUBVismbmQCfTKfNrQnIy2cIQCYUE7zFrRl6nvgAnAu5W0iAfzKwFEAGtnGj1h+D+tY0 aa68f38c04f080fe4d3142fb3f73425b78ef98bd 0 iEYEABECAAYFAk5bEKIACgkQyUhSUUBVislRhwCePWvqh3c+EitvNe1XlMqxpwWvDDgAoJKjDnmLwk0U62IhIQ+x90DEIgl6 +11ef524500964054ae8e4e6150f890b1864139eb 0 iEYEABECAAYFAk5zUvIACgkQyUhSUUBVisnDTgCdHVHSwKeZjHV4KrlTmqipFoO26mkAoIMqPTna3Y1ETIGnPq6XRCB90C8p From pigeonhole at rename-it.nl Sat Sep 17 01:00:13 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 17 Sep 2011 00:00:13 +0200 Subject: dovecot-2.0-pigeonhole: lda-sieve: fall back to global recipient... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/296bb15850b4 changeset: 1530:296bb15850b4 user: Stephan Bosch date: Sat Sep 17 00:00:03 2011 +0200 description: lda-sieve: fall back to global recipient_delimiter setting if plugin/recipient_delimiter is not set. diffstat: src/plugins/lda-sieve/lda-sieve-plugin.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diffs (52 lines): diff -r 9e0d1a75c546 -r 296bb15850b4 src/plugins/lda-sieve/lda-sieve-plugin.c --- a/src/plugins/lda-sieve/lda-sieve-plugin.c Tue Sep 13 22:43:27 2011 +0200 +++ b/src/plugins/lda-sieve/lda-sieve-plugin.c Sat Sep 17 00:00:03 2011 +0200 @@ -42,13 +42,13 @@ static const char *lda_sieve_get_homedir (void *context) { - struct mail_user *mail_user = (struct mail_user *) context; + struct mail_deliver_context *mdctx = (struct mail_deliver_context *)context; const char *home = NULL; - if ( mail_user == NULL ) + if ( mdctx == NULL || mdctx->dest_user == NULL ) return NULL; - if ( mail_user_get_home(mail_user, &home) <= 0 ) + if ( mail_user_get_home(mdctx->dest_user, &home) <= 0 ) return NULL; return home; @@ -57,12 +57,19 @@ static const char *lda_sieve_get_setting (void *context, const char *identifier) { - struct mail_user *mail_user = (struct mail_user *) context; + struct mail_deliver_context *mdctx = (struct mail_deliver_context *)context; + const char *value = NULL; - if ( mail_user == NULL ) + if ( mdctx == NULL ) return NULL; - return mail_user_plugin_getenv(mail_user, identifier); + if ( mdxtx->dest_user == NULL || + (value=mail_user_plugin_getenv(mail_user, identifier)) == NULL ) { + if ( strcmp(identifier, "recipient_delimiter") == 0 ) + value = mdctx->set->recipient_delimiter; + } + + return value; } static const struct sieve_environment lda_sieve_env = { @@ -665,7 +672,7 @@ /* Initialize Sieve engine */ - svinst = sieve_init(&lda_sieve_env, mdctx->dest_user, debug); + svinst = sieve_init(&lda_sieve_env, mdctx, debug); /* Initialize master error handler */ From pigeonhole at rename-it.nl Sat Sep 17 01:32:06 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 17 Sep 2011 00:32:06 +0200 Subject: dovecot-2.0-pigeonhole: Last change did not even compile. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/7cd2dce9ab6b changeset: 1531:7cd2dce9ab6b user: Stephan Bosch date: Sat Sep 17 00:31:55 2011 +0200 description: Last change did not even compile. diffstat: src/plugins/lda-sieve/lda-sieve-plugin.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 296bb15850b4 -r 7cd2dce9ab6b src/plugins/lda-sieve/lda-sieve-plugin.c --- a/src/plugins/lda-sieve/lda-sieve-plugin.c Sat Sep 17 00:00:03 2011 +0200 +++ b/src/plugins/lda-sieve/lda-sieve-plugin.c Sat Sep 17 00:31:55 2011 +0200 @@ -63,8 +63,8 @@ if ( mdctx == NULL ) return NULL; - if ( mdxtx->dest_user == NULL || - (value=mail_user_plugin_getenv(mail_user, identifier)) == NULL ) { + if ( mdctx->dest_user == NULL || + (value=mail_user_plugin_getenv(mdctx->dest_user, identifier)) == NULL ) { if ( strcmp(identifier, "recipient_delimiter") == 0 ) value = mdctx->set->recipient_delimiter; } From pigeonhole at rename-it.nl Sat Sep 17 10:05:06 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 17 Sep 2011 09:05:06 +0200 Subject: dovecot-2.0-pigeonhole: testsuite: fixed compiler warning. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/6cb7f5478ca4 changeset: 1533:6cb7f5478ca4 user: Stephan Bosch date: Wed Sep 14 17:18:24 2011 +0200 description: testsuite: fixed compiler warning. diffstat: src/testsuite/testsuite-script.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r f3a4ddd68bc8 -r 6cb7f5478ca4 src/testsuite/testsuite-script.c --- a/src/testsuite/testsuite-script.c Wed Sep 14 17:17:15 2011 +0200 +++ b/src/testsuite/testsuite-script.c Wed Sep 14 17:18:24 2011 +0200 @@ -41,7 +41,6 @@ { struct sieve_instance *svinst = testsuite_sieve_instance; struct sieve_binary *sbin; - const char *sieve_dir; const char *script_path; sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, "compile script `%s'", script); @@ -51,7 +50,7 @@ return SIEVE_EXEC_FAILURE; script_path = t_strconcat(script_path, "/", script, NULL); - + if ( (sbin = sieve_compile(svinst, script_path, NULL, testsuite_log_ehandler, NULL)) == NULL ) return NULL; From pigeonhole at rename-it.nl Sat Sep 17 10:05:06 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 17 Sep 2011 09:05:06 +0200 Subject: dovecot-2.0-pigeonhole: Updated TODO. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/78654f55c9a0 changeset: 1534:78654f55c9a0 user: Stephan Bosch date: Fri Sep 16 17:57:56 2011 +0200 description: Updated TODO. diffstat: TODO | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 6cb7f5478ca4 -r 78654f55c9a0 TODO --- a/TODO Wed Sep 14 17:18:24 2011 +0200 +++ b/TODO Fri Sep 16 17:57:56 2011 +0200 @@ -34,7 +34,6 @@ accordingly) * Finish body extension: - Implement proper :content "multipart" behavior - - Implement proper :content "message/rfc822" behavior - Build test cases for decoding MIME encodings to UTF-8 * Cleanup the test suite - Restructure test scripts From pigeonhole at rename-it.nl Sat Sep 17 10:05:05 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 17 Sep 2011 09:05:05 +0200 Subject: dovecot-2.0-pigeonhole: body extension: fixed handling of :conte... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/f3a4ddd68bc8 changeset: 1532:f3a4ddd68bc8 user: Stephan Bosch date: Wed Sep 14 17:17:15 2011 +0200 description: body extension: fixed handling of :content message/rfc822. diffstat: src/lib-sieve/plugins/body/ext-body-common.c | 88 +++++++++++++++++++++++------ tests/extensions/body/content.svtest | 19 +++++- 2 files changed, 86 insertions(+), 21 deletions(-) diffs (222 lines): diff -r 5459f69f6aa2 -r f3a4ddd68bc8 src/lib-sieve/plugins/body/ext-body-common.c --- a/src/lib-sieve/plugins/body/ext-body-common.c Tue Sep 13 22:42:18 2011 +0200 +++ b/src/lib-sieve/plugins/body/ext-body-common.c Wed Sep 14 17:17:15 2011 +0200 @@ -61,12 +61,14 @@ i_assert( wanted_types != NULL ); for (; *wanted_types != NULL; wanted_types++) { - const char *wanted_subtype = strchr(*wanted_types, '/'); + const char *wanted_subtype; if (**wanted_types == '\0') { /* empty string matches everything */ return TRUE; } + + wanted_subtype = strchr(*wanted_types, '/'); if (wanted_subtype == NULL) { /* match only main type */ if (strlen(*wanted_types) == type_len && @@ -112,7 +114,7 @@ /* Add new item to the result */ return_part = array_append_space(&ctx->return_body_parts); - + /* Depending on whether a decoded body part is requested, the appropriate * cache item is read. If it is missing, this function fails and the cache * needs to be completed by ext_body_parts_add_missing(). @@ -134,7 +136,7 @@ } static void ext_body_part_save -(struct ext_body_message_context *ctx, struct message_part *part, +(struct ext_body_message_context *ctx, struct ext_body_part_cached *body_part, bool decoded) { buffer_t *buf = ctx->tmp_buffer; @@ -154,8 +156,6 @@ if ( !decoded ) { body_part->raw_body = part_data; body_part->raw_body_size = part_size; - printf("%ld <=> %ld\n", (long) buf->used - 1, (long) part->body_size.physical_size); - i_assert(buf->used - 1 == part->body_size.physical_size); } else { body_part->decoded_body = part_data; body_part->decoded_body_size = part_size; @@ -195,7 +195,7 @@ (const struct sieve_message_data *msgdata, struct ext_body_message_context *ctx, const char * const *content_types, bool decode_to_plain) { - struct ext_body_part_cached *body_part = NULL; + struct ext_body_part_cached *body_part = NULL, *header_part = NULL; struct message_parser_ctx *parser; struct message_decoder_context *decoder; struct message_block block, decoded; @@ -214,25 +214,50 @@ /* Get the message stream */ if ( mail_get_stream(msgdata->mail, NULL, NULL, &input) < 0 ) return FALSE; - + //if (mail_get_parts(msgdata->mail, &parts) < 0) + // return FALSE; + buffer_set_used_size(ctx->tmp_buffer, 0); /* Initialize body decoder */ - decoder = decode_to_plain ? message_decoder_init(FALSE) : NULL; - + decoder = decode_to_plain ? message_decoder_init(FALSE) : NULL; + + //parser = message_parser_init_from_parts(parts, input, 0, 0); parser = message_parser_init(ctx->pool, input, 0, 0); + while ( (ret = message_parser_parse_next_block(parser, &block)) > 0 ) { + if ( block.part != prev_part ) { + bool message_rfc822 = FALSE; + /* Save previous body part */ - if ( body_part != NULL && save_body ) { - ext_body_part_save(ctx, prev_part, body_part, decoder != NULL); + if ( body_part != NULL ) { + /* Treat message/rfc822 separately; headers become content */ + if ( block.part->parent == prev_part && + strcmp(body_part->content_type, "message/rfc822") == 0 ) { + message_rfc822 = TRUE; + } else { + if ( save_body ) + ext_body_part_save(ctx, body_part, decoder != NULL); + } } - + /* Start processing next */ + body_part = array_idx_modifiable(&ctx->cached_body_parts, idx); + body_part->content_type = "text/plain"; + + /* If this is message/rfc822 content retain the enveloping part for + * storing headers as content. + */ + if ( message_rfc822 ) { + i_assert(idx > 0); + header_part = array_idx_modifiable(&ctx->cached_body_parts, idx-1); + } else { + header_part = NULL; + } + prev_part = block.part; - body_part = array_idx_modifiable(&ctx->cached_body_parts, idx); - idx++; - body_part->content_type = "text/plain"; + idx++; } if ( block.hdr != NULL || block.size == 0 ) { @@ -244,6 +269,12 @@ /* Check for end of headers */ if ( block.hdr == NULL ) { + /* Save headers for message/rfc822 part */ + if ( header_part != NULL ) { + ext_body_part_save(ctx, header_part, decoder != NULL); + header_part = NULL; + } + /* Save bodies only if we have a wanted content-type */ save_body = _is_wanted_content_type (content_types, body_part->content_type); @@ -255,9 +286,22 @@ */ if ( block.hdr->eoh ) body_part->have_body = TRUE; + else if ( header_part != NULL ) { + /* Save message/rfc822 header as part content */ + if ( block.hdr->continued ) { + buffer_append(ctx->tmp_buffer, block.hdr->value, block.hdr->value_len); + } else { + buffer_append(ctx->tmp_buffer, block.hdr->name, block.hdr->name_len); + buffer_append(ctx->tmp_buffer, block.hdr->middle, block.hdr->middle_len); + buffer_append(ctx->tmp_buffer, block.hdr->value, block.hdr->value_len); + } + if ( !block.hdr->no_newline ) { + buffer_append(ctx->tmp_buffer, "\r\n", 2); + } + } /* We're interested of only Content-Type: header */ - if ( strcasecmp(block.hdr->name, "Content-Type" ) != 0) + if ( strcasecmp(block.hdr->name, "Content-Type" ) != 0 ) continue; /* Header can have folding whitespace. Acquire the full value before @@ -289,8 +333,11 @@ } /* Save last body part if necessary */ - if ( body_part != NULL && save_body ) - ext_body_part_save(ctx, prev_part, body_part, decoder != NULL); + if ( header_part != NULL ) { + ext_body_part_save(ctx, header_part, decoder != NULL); + } else if ( body_part != NULL && save_body ) { + ext_body_part_save(ctx, body_part, decoder != NULL); + } /* Try to fill the return_body_parts array once more */ have_all = ext_body_get_return_parts(ctx, content_types, decode_to_plain); @@ -310,7 +357,6 @@ static struct ext_body_message_context *ext_body_get_context (const struct sieve_extension *this_ext, struct sieve_message_context *msgctx) { - pool_t pool = sieve_message_context_pool(msgctx); struct ext_body_message_context *ctx; /* Get message context (contains cached message body information) */ @@ -319,8 +365,12 @@ /* Create it if it does not exist already */ if ( ctx == NULL ) { + pool_t pool; + + pool = sieve_message_context_pool(msgctx); ctx = p_new(pool, struct ext_body_message_context, 1); ctx->pool = pool; + p_array_init(&ctx->cached_body_parts, pool, 8); p_array_init(&ctx->return_body_parts, pool, 8); ctx->tmp_buffer = buffer_create_dynamic(pool, 1024*64); diff -r 5459f69f6aa2 -r f3a4ddd68bc8 tests/extensions/body/content.svtest --- a/tests/extensions/body/content.svtest Tue Sep 13 22:42:18 2011 +0200 +++ b/tests/extensions/body/content.svtest Wed Sep 14 17:17:15 2011 +0200 @@ -204,7 +204,8 @@ Content-Type: message/rfc822 From: Someone Else -Subject: hello request +Subject: Hello, this is an elaborate request for you to finally say hello + already! Please say Hello @@ -313,6 +314,20 @@ * matches the :content specification. */ -/* FIXME */ +test "Content-Type: message/rfc822" { + if not body :content "message/rfc822" :contains + "From: Someone Else" { + test_fail "missed raw message/rfc822 from header"; + } + if not body :content "message/rfc822" :is text: +From: Someone Else +Subject: Hello, this is an elaborate request for you to finally say hello + already! +. + { + test_fail "header content does not match exactly"; + } +} + From pigeonhole at rename-it.nl Sat Sep 17 10:05:06 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 17 Sep 2011 09:05:06 +0200 Subject: dovecot-2.0-pigeonhole: Merged concurrent changes. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/b4f0fe1f54c3 changeset: 1535:b4f0fe1f54c3 user: Stephan Bosch date: Sat Sep 17 09:04:55 2011 +0200 description: Merged concurrent changes. diffstat: .hgsigs | 1 + src/plugins/lda-sieve/lda-sieve-plugin.c | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diffs (60 lines): diff -r 78654f55c9a0 -r b4f0fe1f54c3 .hgsigs --- a/.hgsigs Fri Sep 16 17:57:56 2011 +0200 +++ b/.hgsigs Sat Sep 17 09:04:55 2011 +0200 @@ -1,3 +1,4 @@ d768f911252d6b798400a382b41a98d2b2cde770 0 iQEcBAABAgAGBQJMn9w7AAoJEATWKx49+7T0LwwH/iZXNVppEZRfPOZPvkg+pSw4twuqmmV7h8yELaHKxyyqcKjSO6/A7Mkxf6FVZ6LerJ59h+iqib42TcGGDRTETH8OfN/jbZ0HX5F6jYAYvbs7RzjrO6FAthT3BnWvGLGPBuPrGCSS3FSF5AS8qhSOgpSlKheV/K7S4DeU5+4UNv49+icHZIGFYLjahb+rbL5aNqLx8NewVeKU77Fe9Jk0NRNO9p9g+JQEswEUQONhKta1hovZcOqKtZ45Xfq+/KvBIsITT/sSfRe+z8Mn7DhXYxFajRnVf2pBBQTrBRoy3Z4PtU1BvEUbUfGohLnnn3RQP092dfqwkovevT82lOLHtlc= df8b38da248cbd6d83e9bd476ec2c92716ea193c 0 iQEcBAABAgAGBQJM/WxCAAoJEATWKx49+7T0blMH/0Cdwr16xm5I9koqhVu3KKToePJqVIG723rdLjyBeTgr/0T5UTXzkPT8OHnzJ/SRcI8AiVJiLtTEFYAKsegJxFo3TEztlZ+cO2k8JT2HnL1w8RYeagihMyDdBPD+dpv+US+0eWHGmbmLvxi1UlfyqGiPZrKQmCuRtpzJTwzkGKOGdg+ln+kifvwzNhVGNC1URdfYOkO/vZL8W47OREtF4U2zV6l/KM6m4fnrUp7YdOBdYFwen6Yux6NDQzqXkUoJQ0xNsqp4HYGvSDCzRBI6tba++mGQ5tAvYyJuqwRKToMH/fk5al4igraZI8MH0tSZplHGxUAhsq8JO1/v83kudbM= 3ab2a125e1e2d478382c07853e99a5973d06afd6 0 iQEcBAABAgAGBQJNp1ztAAoJEATWKx49+7T0CJcH/24Txa1ynS5hBUhOuWTpUTGtm+9cMpWoQ33exiMR0pm8ycxsUQcKfRtO/cRHQX1CW3PqQs3DGZ31QdEEg0CyX8OsBbP/dwdEcnLRYF5BsJMyfy+Qnbhxn+wV0k9s9AUgZTdvPKrg1hFa6XS+6SE3N33AA4Y2eYYZGzFuDiSoN7fGx7PATCrobMsmp5WtBiKoy4WyP2SwDv/VgKy0PQTF+6+0t0MMCBSurLzpHk8dDuBonWIBgbJRM/sk9f+cYbU/ESRMcryZbbau9EwMQIQJfprGH6WP/gwysF0pu47zQERMuVt3fFzXUzrfxVpMOI7EkLgnF+Tes0vA7dKh1x+vvec= +0d071eaa6d5e2a9f524c94ddf1686f1b3091f604 0 iQEcBAABAgAGBQJOb8BjAAoJEATWKx49+7T0cAcH/3coc1MhQj8zUdC+NB3N8eUkQ3AF3QQgSfP9uXs9BhvPw70Ts9MLJiO54RhhYf/k9VxptzWk7MPJF47v4NEEKHkjDDMXtPbVOxHjNa2Ny8EAuWe4dv5X0faAlH4Ks58enDchCmunX1DgQtC1f+gHqVtvTpGAROFPqkBe5RGOJ0jQd+2hTTlf1BpLl44fiBdYd6350haX0KjDGNthX9ETVc3bnbdIiXSy7DPnn0ELhvTbgkl4Zu1tA778IJy/JjsCPb2YueX7LsksvxcSZHqv80Zd3JJhs5a3ZeHijN6twpe7VZD9FO+jPOKA1rr/HYwCv0KweKgmwVHCdaT+Mq4OLPc= diff -r 78654f55c9a0 -r b4f0fe1f54c3 src/plugins/lda-sieve/lda-sieve-plugin.c --- a/src/plugins/lda-sieve/lda-sieve-plugin.c Fri Sep 16 17:57:56 2011 +0200 +++ b/src/plugins/lda-sieve/lda-sieve-plugin.c Sat Sep 17 09:04:55 2011 +0200 @@ -42,13 +42,13 @@ static const char *lda_sieve_get_homedir (void *context) { - struct mail_user *mail_user = (struct mail_user *) context; + struct mail_deliver_context *mdctx = (struct mail_deliver_context *)context; const char *home = NULL; - if ( mail_user == NULL ) + if ( mdctx == NULL || mdctx->dest_user == NULL ) return NULL; - if ( mail_user_get_home(mail_user, &home) <= 0 ) + if ( mail_user_get_home(mdctx->dest_user, &home) <= 0 ) return NULL; return home; @@ -57,12 +57,19 @@ static const char *lda_sieve_get_setting (void *context, const char *identifier) { - struct mail_user *mail_user = (struct mail_user *) context; + struct mail_deliver_context *mdctx = (struct mail_deliver_context *)context; + const char *value = NULL; - if ( mail_user == NULL ) + if ( mdctx == NULL ) return NULL; - return mail_user_plugin_getenv(mail_user, identifier); + if ( mdctx->dest_user == NULL || + (value=mail_user_plugin_getenv(mdctx->dest_user, identifier)) == NULL ) { + if ( strcmp(identifier, "recipient_delimiter") == 0 ) + value = mdctx->set->recipient_delimiter; + } + + return value; } static const struct sieve_environment lda_sieve_env = { @@ -665,7 +672,7 @@ /* Initialize Sieve engine */ - svinst = sieve_init(&lda_sieve_env, mdctx->dest_user, debug); + svinst = sieve_init(&lda_sieve_env, mdctx, debug); /* Initialize master error handler */ From dovecot at dovecot.org Mon Sep 19 14:25:41 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 19 Sep 2011 14:25:41 +0300 Subject: dovecot-2.0: doveadm: Typofix s/messsage/message/ Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/6b7242ead6ed changeset: 12934:6b7242ead6ed user: Timo Sirainen date: Mon Sep 19 14:25:29 2011 +0300 description: doveadm: Typofix s/messsage/message/ diffstat: src/doveadm/doveadm-mail-move.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 22858efc84bb -r 6b7242ead6ed src/doveadm/doveadm-mail-move.c --- a/src/doveadm/doveadm-mail-move.c Fri Sep 16 16:45:25 2011 +0300 +++ b/src/doveadm/doveadm-mail-move.c Mon Sep 19 14:25:29 2011 +0300 @@ -45,7 +45,7 @@ if (mailbox_copy(&save_ctx, mail) == 0) mail_expunge(mail); else { - i_error("Copying messsage UID %u from '%s' failed: %s", + i_error("Copying message UID %u from '%s' failed: %s", mail->uid, info->name, mail_storage_get_last_error(deststorage, NULL)); ret = -1; From dovecot at dovecot.org Mon Sep 19 14:26:01 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 19 Sep 2011 14:26:01 +0300 Subject: dovecot-2.1: doveadm: Typofix s/messsage/message/ Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ee36cef69246 changeset: 13513:ee36cef69246 user: Timo Sirainen date: Mon Sep 19 14:25:29 2011 +0300 description: doveadm: Typofix s/messsage/message/ diffstat: src/doveadm/doveadm-mail-move.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 823b7ab2e1d7 -r ee36cef69246 src/doveadm/doveadm-mail-move.c --- a/src/doveadm/doveadm-mail-move.c Fri Sep 16 17:00:30 2011 +0300 +++ b/src/doveadm/doveadm-mail-move.c Mon Sep 19 14:25:29 2011 +0300 @@ -44,7 +44,7 @@ if (mailbox_copy(&save_ctx, mail) == 0) mail_expunge(mail); else { - i_error("Copying messsage UID %u from '%s' failed: %s", + i_error("Copying message UID %u from '%s' failed: %s", mail->uid, info->name, mail_storage_get_last_error(deststorage, NULL)); ret = -1; From dovecot at dovecot.org Mon Sep 19 18:29:06 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 19 Sep 2011 18:29:06 +0300 Subject: dovecot-2.1: Compile fix for OpenBSD. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/97135a53951e changeset: 13514:97135a53951e user: Timo Sirainen date: Mon Sep 19 18:28:14 2011 +0300 description: Compile fix for OpenBSD. diffstat: src/lib/network.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diffs (33 lines): diff -r ee36cef69246 -r 97135a53951e src/lib/network.c --- a/src/lib/network.c Mon Sep 19 14:25:29 2011 +0300 +++ b/src/lib/network.c Mon Sep 19 18:28:14 2011 +0300 @@ -697,7 +697,14 @@ int net_getunixcred(int fd, struct net_unix_cred *cred_r) { -#if defined(SO_PEERCRED) +#if defined(HAVE_GETPEEREID) + /* OSX 10.4+, FreeBSD 4.6+, OpenBSD 3.0+, NetBSD 5.0+ */ + if (getpeereid(fd, &cred_r->uid, &cred_r->gid) < 0) { + i_error("getpeereid() failed: %m"); + return -1; + } + return 0; +#elif defined(SO_PEERCRED) /* Linux */ struct ucred ucred; socklen_t len = sizeof(ucred); @@ -709,13 +716,6 @@ cred_r->uid = ucred.uid; cred_r->gid = ucred.gid; return 0; -#elif defined(HAVE_GETPEEREID) - /* OSX 10.4+, FreeBSD 4.6+, OpenBSD 3.0+, NetBSD 5.0+ */ - if (getpeereid(fd, &cred_r->uid, &cred_r->gid) < 0) { - i_error("getpeereid() failed: %m"); - return -1; - } - return 0; #elif defined(HAVE_GETPEERUCRED) /* Solaris */ ucred_t *ucred; From dovecot at dovecot.org Mon Sep 19 18:34:02 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 19 Sep 2011 18:34:02 +0300 Subject: dovecot-2.1: fts-lucene: Fixed to work without stemmer support. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/02c84406c661 changeset: 13515:02c84406c661 user: Timo Sirainen date: Mon Sep 19 18:33:40 2011 +0300 description: fts-lucene: Fixed to work without stemmer support. diffstat: src/plugins/fts-lucene/fts-lucene-plugin.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (31 lines): diff -r 97135a53951e -r 02c84406c661 src/plugins/fts-lucene/fts-lucene-plugin.c --- a/src/plugins/fts-lucene/fts-lucene-plugin.c Mon Sep 19 18:28:14 2011 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Mon Sep 19 18:33:40 2011 +0300 @@ -18,7 +18,6 @@ { const char *const *tmp; - set->default_language = "english"; for (tmp = t_strsplit_spaces(str, " "); *tmp != NULL; tmp++) { if (strncmp(*tmp, "default_language=", 17) == 0) { set->default_language = @@ -46,6 +45,9 @@ "but Dovecot built without stemmer support"); return -1; } +#else + if (set->default_language == NULL) + set->default_language = "english"; #endif #ifndef HAVE_LUCENE_TEXTCAT if (set->textcat_conf != NULL) { @@ -60,7 +62,8 @@ uint32_t fts_lucene_settings_checksum(const struct fts_lucene_settings *set) { /* only the default language change matters */ - return crc32_str(set->default_language); + return set->default_language == NULL ? 0 : + crc32_str(set->default_language); } static void fts_lucene_mail_user_created(struct mail_user *user) From dovecot at dovecot.org Mon Sep 19 18:41:59 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 19 Sep 2011 18:41:59 +0300 Subject: dovecot-2.1: Enable --no-undefined linker flag only for Linux. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7d9163ce4253 changeset: 13516:7d9163ce4253 user: Timo Sirainen date: Mon Sep 19 18:41:36 2011 +0300 description: Enable --no-undefined linker flag only for Linux. BSDs don't seem to be happy with it. diffstat: configure.in | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diffs (20 lines): diff -r 02c84406c661 -r 7d9163ce4253 configure.in --- a/configure.in Mon Sep 19 18:33:40 2011 +0300 +++ b/configure.in Mon Sep 19 18:41:36 2011 +0300 @@ -2674,7 +2674,15 @@ CFLAGS="$CFLAGS $EXTRA_CFLAGS" if test "$with_gnu_ld" = yes; then - NOPLUGIN_LDFLAGS="-Wl,--as-needed -Wl,--no-undefined" + NOPLUGIN_LDFLAGS="-Wl,--as-needed" + case "$host_os" in + linux*) + # This appears to work in Linux, but not in BSDs.. + NOPLUGIN_LDFLAGS="$NOPLUGIN_LDFLAGS -Wl,--no-undefined" + ;; + *) + ;; + esac LDFLAGS="\$(NOPLUGIN_LDFLAGS) $LDFLAGS" AC_SUBST(NOPLUGIN_LDFLAGS) fi From dovecot at dovecot.org Tue Sep 20 11:53:19 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 11:53:19 +0300 Subject: dovecot-2.1: imapc: Handle disconnection better when fetching a ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/25f9856be51e changeset: 13517:25f9856be51e user: Timo Sirainen date: Tue Sep 20 11:53:02 2011 +0300 description: imapc: Handle disconnection better when fetching a mail. diffstat: src/lib-storage/index/imapc/imapc-mail.c | 32 ++++++++++++++++++-------------- 1 files changed, 18 insertions(+), 14 deletions(-) diffs (56 lines): diff -r 7d9163ce4253 -r 25f9856be51e src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Mon Sep 19 18:41:36 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Tue Sep 20 11:53:02 2011 +0300 @@ -51,6 +51,22 @@ return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq); } +static void imapc_mail_failed(struct mail *mail, const char *field) +{ + struct imapc_mailbox *mbox = (struct imapc_mailbox *)mail->box; + + if (mail->expunged || imapc_mail_is_expunged(mail)) + mail_set_expunged(mail); + else if (!imapc_client_mailbox_is_connected(mbox->client_box)) { + /* we've already logged a disconnection error */ + mail_storage_set_internal_error(mail->box->storage); + } else { + mail_storage_set_critical(mail->box->storage, + "imapc: Remote server didn't send %s for UID %u", + field, mail->uid); + } +} + static int imapc_mail_get_received_date(struct mail *_mail, time_t *date_r) { struct index_mail *mail = (struct index_mail *)_mail; @@ -63,13 +79,7 @@ if (imapc_mail_fetch(_mail, MAIL_FETCH_RECEIVED_DATE) < 0) return -1; if (data->received_date == (time_t)-1) { - if (_mail->expunged || imapc_mail_is_expunged(_mail)) - mail_set_expunged(_mail); - else { - mail_storage_set_critical(_mail->box->storage, - "imapc: Remote server didn't send " - "INTERNALDATE for UID %u", _mail->uid); - } + imapc_mail_failed(_mail, "INTERNALDATE"); return -1; } } @@ -140,13 +150,7 @@ return -1; if (data->stream == NULL) { - if (_mail->expunged || imapc_mail_is_expunged(_mail)) - mail_set_expunged(_mail); - else { - mail_storage_set_critical(_mail->box->storage, - "imapc: Remote server didn't send " - "BODY[] for UID %u", _mail->uid); - } + imapc_mail_failed(_mail, "BODY[]"); return -1; } } From dovecot at dovecot.org Tue Sep 20 13:35:13 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 13:35:13 +0300 Subject: dovecot-2.1: inotify: If read() fails with EAGAIN, ignore it ins... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/803979bc30ab changeset: 13518:803979bc30ab user: Timo Sirainen date: Tue Sep 20 13:30:08 2011 +0300 description: inotify: If read() fails with EAGAIN, ignore it instead of dying. diffstat: src/lib/ioloop-notify-inotify.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 25f9856be51e -r 803979bc30ab src/lib/ioloop-notify-inotify.c --- a/src/lib/ioloop-notify-inotify.c Tue Sep 20 11:53:02 2011 +0300 +++ b/src/lib/ioloop-notify-inotify.c Tue Sep 20 13:30:08 2011 +0300 @@ -45,7 +45,7 @@ only full events are returned by the kernel. */ ret = read(ctx->inotify_fd, event_buf, sizeof(event_buf)); if (ret <= 0) { - if (ret == 0) { + if (ret == 0 || errno == EAGAIN) { /* nothing more to read */ return FALSE; } From dovecot at dovecot.org Tue Sep 20 13:35:14 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 13:35:14 +0300 Subject: dovecot-2.1: imapc: When IMAP server unexpectedly doesn't send a... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/60f31136af52 changeset: 13519:60f31136af52 user: Timo Sirainen date: Tue Sep 20 13:31:32 2011 +0300 description: imapc: When IMAP server unexpectedly doesn't send a reply, log also the mailbox name. diffstat: src/lib-storage/index/imapc/imapc-mail.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 803979bc30ab -r 60f31136af52 src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Tue Sep 20 13:30:08 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Tue Sep 20 13:31:32 2011 +0300 @@ -62,8 +62,8 @@ mail_storage_set_internal_error(mail->box->storage); } else { mail_storage_set_critical(mail->box->storage, - "imapc: Remote server didn't send %s for UID %u", - field, mail->uid); + "imapc: Remote server didn't send %s for UID %u in %s", + field, mail->uid, mail->box->vname); } } From dovecot at dovecot.org Tue Sep 20 13:35:14 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 13:35:14 +0300 Subject: dovecot-2.1: imapc: next_uid was sometimes lowered. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5a27ac58db25 changeset: 13520:5a27ac58db25 user: Timo Sirainen date: Tue Sep 20 13:33:34 2011 +0300 description: imapc: next_uid was sometimes lowered. diffstat: src/lib-storage/index/imapc/imapc-sync.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diffs (57 lines): diff -r 60f31136af52 -r 5a27ac58db25 src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Tue Sep 20 13:31:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Tue Sep 20 13:33:34 2011 +0300 @@ -190,7 +190,7 @@ mbox->sync_next_rseq = 0; } -static void imapc_sync_index_header(struct imapc_sync_context *ctx) +static void imapc_sync_uid_validity(struct imapc_sync_context *ctx) { struct imapc_mailbox *mbox = ctx->mbox; const struct mail_index_header *hdr; @@ -208,11 +208,22 @@ &mbox->sync_uid_validity, sizeof(mbox->sync_uid_validity), TRUE); } - if (hdr->next_uid < mbox->sync_uid_next) { +} + +static void imapc_sync_uid_next(struct imapc_sync_context *ctx) +{ + struct imapc_mailbox *mbox = ctx->mbox; + const struct mail_index_header *hdr; + uint32_t uid_next = mbox->sync_uid_next; + + if (uid_next < mbox->min_append_uid) + uid_next = mbox->min_append_uid; + + hdr = mail_index_get_header(ctx->sync_view); + if (hdr->next_uid < uid_next) { mail_index_update_header(ctx->trans, offsetof(struct mail_index_header, next_uid), - &mbox->sync_uid_next, sizeof(mbox->sync_uid_next), - FALSE); + &uid_next, sizeof(uid_next), FALSE); } } @@ -225,7 +236,7 @@ i_array_init(&ctx->expunged_uids, 64); ctx->keywords = mail_index_get_keywords(mbox->box.index); - imapc_sync_index_header(ctx); + imapc_sync_uid_validity(ctx); while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) T_BEGIN { if (!mail_index_lookup_seq_range(ctx->sync_view, sync_rec.uid1, sync_rec.uid2, @@ -275,6 +286,9 @@ imapc_storage_run(mbox->storage); array_free(&ctx->expunged_uids); + /* add uidnext after all appends */ + imapc_sync_uid_next(ctx); + imapc_sync_expunge_eom(ctx); if (mbox->box.v.sync_notify != NULL) mbox->box.v.sync_notify(&mbox->box, 0, 0); From dovecot at dovecot.org Tue Sep 20 13:35:14 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 13:35:14 +0300 Subject: dovecot-2.1: imapc: If mailbox sync fails, don't mark index corr... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c9b758cd6c43 changeset: 13521:c9b758cd6c43 user: Timo Sirainen date: Tue Sep 20 13:34:36 2011 +0300 description: imapc: If mailbox sync fails, don't mark index corrupted. The sync could have failed because of disconnection. The failure will just cause the sync to be rollbacked and retried later. No need to delete the whole index. diffstat: src/lib-storage/index/imapc/imapc-sync.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diffs (14 lines): diff -r 5a27ac58db25 -r c9b758cd6c43 src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Tue Sep 20 13:33:34 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Tue Sep 20 13:34:36 2011 +0300 @@ -413,10 +413,6 @@ ret == 0) ret = imapc_sync(mbox); - if (changes && ret < 0) { - /* we're now out of sync and can't safely continue */ - mail_index_mark_corrupted(mbox->box.index); - } return index_mailbox_sync_init(box, flags, ret < 0); } From dovecot at dovecot.org Tue Sep 20 13:35:14 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 13:35:14 +0300 Subject: dovecot-2.1: Increased initial memory pool sizes. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/bed9bc9b9e22 changeset: 13522:bed9bc9b9e22 user: Timo Sirainen date: Tue Sep 20 13:34:52 2011 +0300 description: Increased initial memory pool sizes. diffstat: src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/mail-storage-service.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diffs (24 lines): diff -r c9b758cd6c43 -r bed9bc9b9e22 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Tue Sep 20 13:34:36 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Tue Sep 20 13:34:52 2011 +0300 @@ -320,7 +320,7 @@ struct imapc_mailbox *mbox; pool_t pool; - pool = pool_alloconly_create("imapc mailbox", 1024*3); + pool = pool_alloconly_create("imapc mailbox", 1024*4); mbox = p_new(pool, struct imapc_mailbox, 1); mbox->box = imapc_mailbox; mbox->box.pool = pool; diff -r c9b758cd6c43 -r bed9bc9b9e22 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Sep 20 13:34:36 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Sep 20 13:34:52 2011 +0300 @@ -854,7 +854,7 @@ pool_t user_pool, temp_pool; int ret = 1; - user_pool = pool_alloconly_create("mail storage service user", 1024*6); + user_pool = pool_alloconly_create("mail storage service user", 1024*8); if (mail_storage_service_read_settings(ctx, input, user_pool, &user_info, &set_parser, From dovecot at dovecot.org Tue Sep 20 15:22:49 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 15:22:49 +0300 Subject: dovecot-2.1: imapc: If FETCH is missing a reply, but we haven't ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a15a1b1994cc changeset: 13523:a15a1b1994cc user: Timo Sirainen date: Tue Sep 20 15:22:37 2011 +0300 description: imapc: If FETCH is missing a reply, but we haven't seen EXPUNGE for it, do NOOP and check again. This fixes checking if message is expunged with servers that don't immediately send EXPUNGE during UID FETCH. diffstat: src/lib-storage/index/imapc/imapc-mail.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diffs (28 lines): diff -r bed9bc9b9e22 -r a15a1b1994cc src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Tue Sep 20 13:34:52 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Tue Sep 20 15:22:37 2011 +0300 @@ -38,6 +38,7 @@ { struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; struct imapc_msgmap *msgmap; + struct imapc_simple_context sctx; uint32_t lseq, rseq; if (mbox->sync_view != NULL) { @@ -48,6 +49,16 @@ /* check if we've received EXPUNGE for it */ msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); + if (!imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq)) + return TRUE; + + /* we may be running against a server that hasn't bothered sending + us an EXPUNGE. see if NOOP sends it. */ + imapc_simple_context_init(&sctx, mbox->storage); + imapc_client_cmdf(mbox->storage->client, imapc_simple_callback, + &sctx, "NOOP"); + imapc_simple_run(&sctx); + return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq); } From dovecot at dovecot.org Tue Sep 20 15:36:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 15:36:55 +0300 Subject: dovecot-2.1: imapc: Filter out X-Message-Flag: header from incom... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/501b33c4aa28 changeset: 13524:501b33c4aa28 user: Timo Sirainen date: Tue Sep 20 15:36:39 2011 +0300 description: imapc: Filter out X-Message-Flag: header from incoming mails. This is only added by MS Exchange when \Flagged flag is set, so it could be made optional, but it probably doesn't really hurt to just make it unconditional to ease the configuration. diffstat: src/lib-storage/index/imapc/imapc-mail-fetch.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diffs (43 lines): diff -r a15a1b1994cc -r 501b33c4aa28 src/lib-storage/index/imapc/imapc-mail-fetch.c --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Tue Sep 20 15:22:37 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Tue Sep 20 15:36:39 2011 +0300 @@ -3,6 +3,7 @@ #include "lib.h" #include "str.h" #include "istream.h" +#include "istream-header-filter.h" #include "imap-arg.h" #include "imap-date.h" #include "imapc-client.h" @@ -182,6 +183,23 @@ return FALSE; } +static void imapc_stream_filter(struct istream **input) +{ + static const char *imapc_hide_headers[] = { + /* Added by MS Exchange 2010 when \Flagged flag is set. + This violates IMAP guarantee of messages being immutable. */ + "X-Message-Flag" + }; + struct istream *filter_input; + + filter_input = i_stream_create_header_filter(*input, + HEADER_FILTER_EXCLUDE, + imapc_hide_headers, N_ELEMENTS(imapc_hide_headers), + null_header_filter_callback, NULL); + i_stream_unref(input); + *input = filter_input; +} + static void imapc_fetch_stream(struct imapc_mail *mail, const struct imapc_untagged_reply *reply, @@ -230,6 +248,7 @@ t_strdup_printf("imapc mail uid=%u", _mail->uid)); index_mail_set_read_buffer_size(_mail, imail->data.stream); + imapc_stream_filter(&imail->data.stream); if (imail->mail.v.istream_opened != NULL) { if (imail->mail.v.istream_opened(_mail, &imail->data.stream) < 0) { From dovecot at dovecot.org Tue Sep 20 16:44:43 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 16:44:43 +0300 Subject: dovecot-2.1: imapc: Added more checks to catch buggy IMAP server... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d174fa047d56 changeset: 13526:d174fa047d56 user: Timo Sirainen date: Tue Sep 20 16:44:32 2011 +0300 description: imapc: Added more checks to catch buggy IMAP server responses. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 133 +++++++++++++++++++-------- src/lib-storage/index/imapc/imapc-msgmap.c | 7 +- src/lib-storage/index/imapc/imapc-storage.h | 3 + 3 files changed, 101 insertions(+), 42 deletions(-) diffs (237 lines): diff -r 1dcc1ebe9516 -r d174fa047d56 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Tue Sep 20 16:42:58 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Tue Sep 20 16:44:32 2011 +0300 @@ -103,10 +103,11 @@ } static void -imapc_untagged_exists(const struct imapc_untagged_reply *reply ATTR_UNUSED, +imapc_untagged_exists(const struct imapc_untagged_reply *reply, struct imapc_mailbox *mbox) { struct mail_index_view *view = mbox->delayed_sync_view; + uint32_t exists_count = reply->num; const struct mail_index_header *hdr; if (mbox == NULL) @@ -122,6 +123,7 @@ hdr = mail_index_get_header(view); mbox->sync_fetch_first_uid = hdr->next_uid; } + mbox->exists_count = exists_count; } static void imapc_mailbox_idle_timeout(struct imapc_mailbox *mbox) @@ -163,6 +165,82 @@ return TRUE; } +static int +imapc_mailbox_msgmap_update(struct imapc_mailbox *mbox, + uint32_t rseq, uint32_t fetch_uid, + uint32_t *lseq_r, uint32_t *uid_r) +{ + struct imapc_msgmap *msgmap; + uint32_t uid, msg_count, rseq2; + + *lseq_r = 0; + *uid_r = uid = fetch_uid; + + if (rseq > mbox->exists_count) { + /* Receiving a FETCH for a message that EXISTS hasn't + announced yet. MS Exchange has a bug where our UID FETCH + request sometimes sends replies where sequences are above + EXISTS value, but their UIDs are for existing messages. + We'll just ignore these replies. */ + return 0; + } + if (rseq < mbox->prev_skipped_rseq && + fetch_uid > mbox->prev_skipped_uid) { + /* This was the initial attempt at catching the above + MS Exchange bug, but the above one appears to catch all + these cases. But keep it here just in case. */ + imapc_mailbox_set_corrupted(mbox, + "FETCH sequence/UID order is mixed " + "(seq=%u,%u vs uid=%u,%u)", + mbox->prev_skipped_rseq, rseq, + mbox->prev_skipped_uid, fetch_uid); + return -1; + } + + msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); + msg_count = imapc_msgmap_count(msgmap); + if (rseq <= msg_count) { + uid = imapc_msgmap_rseq_to_uid(msgmap, rseq); + if (uid != fetch_uid && fetch_uid != 0) { + imapc_mailbox_set_corrupted(mbox, + "FETCH UID mismatch (%u != %u)", + fetch_uid, uid); + return -1; + } + } else if (fetch_uid == 0 || rseq != msg_count+1) { + /* probably a flag update for a message we haven't yet + received our initial UID FETCH for. we should get + another one. */ + if (fetch_uid == 0) + return 0; + + if (imapc_msgmap_uid_to_rseq(msgmap, fetch_uid, &rseq2)) { + imapc_mailbox_set_corrupted(mbox, + "FETCH returned wrong sequence for UID %u " + "(%u != %u)", fetch_uid, rseq, rseq2); + return -1; + } + mbox->prev_skipped_rseq = rseq; + mbox->prev_skipped_uid = fetch_uid; + } else if (fetch_uid < imapc_msgmap_uidnext(msgmap)) { + imapc_mailbox_set_corrupted(mbox, + "Expunged message reappeared (uid=%u < next_uid=%u)", + fetch_uid, imapc_msgmap_uidnext(msgmap)); + return -1; + } else { + /* newly seen message */ + imapc_msgmap_append(msgmap, rseq, uid); + if (uid < mbox->min_append_uid) { + /* message is already added to index */ + } else if (mbox->syncing) { + mail_index_append(mbox->delayed_sync_trans, + uid, lseq_r); + mbox->min_append_uid = uid + 1; + } + } + return 0; +} + static void imapc_untagged_fetch(const struct imapc_untagged_reply *reply, struct imapc_mailbox *mbox) { @@ -171,9 +249,8 @@ const struct imap_arg *list, *flags_list; const char *atom; const struct mail_index_record *rec = NULL; - struct imapc_msgmap *msgmap; enum mail_flags flags; - uint32_t fetch_uid, uid, msg_count; + uint32_t fetch_uid, uid; unsigned int i, j; ARRAY_TYPE(const_string) keywords = ARRAY_INIT; bool seen_flags = FALSE; @@ -212,44 +289,10 @@ flags &= ~MAIL_RECENT; imapc_mailbox_init_delayed_trans(mbox); + if (imapc_mailbox_msgmap_update(mbox, rseq, fetch_uid, + &lseq, &uid) < 0 || uid == 0) + return; - msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); - msg_count = imapc_msgmap_count(msgmap); - if (rseq > msg_count) { - /* newly seen message */ - if (fetch_uid == 0 || rseq != msg_count+1) { - /* can't handle this one now. we should get another - FETCH reply for it. */ - return; - } - uid = fetch_uid; - - if (uid < imapc_msgmap_uidnext(msgmap)) { - imapc_mailbox_set_corrupted(mbox, - "Expunged message reappeared " - "(uid=%u < next_uid=%u)", - uid, imapc_msgmap_uidnext(msgmap)); - return; - } - - imapc_msgmap_append(msgmap, rseq, uid); - if (uid < mbox->min_append_uid) { - /* message is already added to index */ - lseq = 0; - } else if (mbox->syncing) { - mail_index_append(mbox->delayed_sync_trans, uid, &lseq); - mbox->min_append_uid = uid + 1; - } - } else { - uid = imapc_msgmap_rseq_to_uid(msgmap, rseq); - if (uid != fetch_uid && fetch_uid != 0) { - imapc_mailbox_set_corrupted(mbox, - "FETCH UID mismatch (%u != %u)", - fetch_uid, uid); - return; - } - lseq = 0; - } /* if this is a reply to some FETCH request, update the mail's fields */ array_foreach(&mbox->fetch_mails, mailp) { struct imapc_mail *mail = *mailp; @@ -315,6 +358,16 @@ if (mbox == NULL || rseq == 0) return; + mbox->prev_skipped_rseq = 0; + mbox->prev_skipped_uid = 0; + + if (mbox->exists_count == 0) { + imapc_mailbox_set_corrupted(mbox, + "EXPUNGE received for empty mailbox"); + return; + } + mbox->exists_count--; + msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box); if (rseq > imapc_msgmap_count(msgmap)) { /* we haven't even seen this message yet */ diff -r 1dcc1ebe9516 -r d174fa047d56 src/lib-storage/index/imapc/imapc-msgmap.c --- a/src/lib-storage/index/imapc/imapc-msgmap.c Tue Sep 20 16:42:58 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-msgmap.c Tue Sep 20 16:44:32 2011 +0300 @@ -6,6 +6,7 @@ struct imapc_msgmap { ARRAY_TYPE(uint32_t) uids; + uint32_t uid_next; }; struct imapc_msgmap *imapc_msgmap_init(void) @@ -14,6 +15,7 @@ msgmap = i_new(struct imapc_msgmap, 1); i_array_init(&msgmap->uids, 128); + msgmap->uid_next = 1; return msgmap; } @@ -34,8 +36,7 @@ uint32_t imapc_msgmap_uidnext(struct imapc_msgmap *msgmap) { - return imapc_msgmap_count(msgmap) == 0 ? 1 : - imapc_msgmap_rseq_to_uid(msgmap, 1) + 1; + return msgmap->uid_next; } uint32_t imapc_msgmap_rseq_to_uid(struct imapc_msgmap *msgmap, uint32_t rseq) @@ -72,7 +73,9 @@ uint32_t rseq, uint32_t uid) { i_assert(rseq == imapc_msgmap_count(msgmap) + 1); + i_assert(uid >= msgmap->uid_next); + msgmap->uid_next = uid + 1; array_append(&msgmap->uids, &uid, 1); } diff -r 1dcc1ebe9516 -r d174fa047d56 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Tue Sep 20 16:42:58 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Tue Sep 20 16:44:32 2011 +0300 @@ -63,8 +63,11 @@ uint32_t sync_fetch_first_uid; uint32_t sync_next_lseq; uint32_t sync_next_rseq; + uint32_t exists_count; uint32_t min_append_uid; + uint32_t prev_skipped_rseq, prev_skipped_uid; + unsigned int opening:1; unsigned int syncing:1; unsigned int initial_sync_done:1; From dovecot at dovecot.org Tue Sep 20 16:44:43 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 20 Sep 2011 16:44:43 +0300 Subject: dovecot-2.1: imapc: When remote IMAP server becomes confused, do... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1dcc1ebe9516 changeset: 13525:1dcc1ebe9516 user: Timo Sirainen date: Tue Sep 20 16:42:58 2011 +0300 description: imapc: When remote IMAP server becomes confused, don't mark our indexes corrupted. Mark them corrupted only when after a reconnection the initial mailbox sync doesn't work. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diffs (19 lines): diff -r 501b33c4aa28 -r 1dcc1ebe9516 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Tue Sep 20 15:36:39 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Tue Sep 20 16:42:58 2011 +0300 @@ -22,7 +22,14 @@ mbox->box.name, t_strdup_vprintf(reason, va)); va_end(va); - mail_index_mark_corrupted(mbox->box.index); + if (!mbox->initial_sync_done) { + /* we failed during initial sync. need to rebuild indexes if + we want to get this fixed */ + mail_index_mark_corrupted(mbox->box.index); + } else { + /* maybe the remote server is buggy and has become confused. + try reconnecting. */ + } imapc_client_mailbox_disconnect(mbox->client_box); } From pigeonhole at rename-it.nl Wed Sep 21 02:05:13 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 21 Sep 2011 01:05:13 +0200 Subject: dovecot-2.0-pigeonhole: test suite: added test for usage of vari... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/4353ad991f1c changeset: 1536:4353ad991f1c user: Stephan Bosch date: Wed Sep 21 00:54:52 2011 +0200 description: test suite: added test for usage of variables in vacation command. diffstat: tests/extensions/vacation/message.svtest | 44 ++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diffs (57 lines): diff -r b4f0fe1f54c3 -r 4353ad991f1c tests/extensions/vacation/message.svtest --- a/tests/extensions/vacation/message.svtest Sat Sep 17 09:04:55 2011 +0200 +++ b/tests/extensions/vacation/message.svtest Wed Sep 21 00:54:52 2011 +0200 @@ -1,5 +1,7 @@ require "vnd.dovecot.testsuite"; require "vacation"; +require "variables"; +require "body"; test_set "message" text: From: stephan at example.org @@ -46,3 +48,45 @@ test_fail "in-reply-to header set incorrectly"; } } + +test_result_reset; + +test_set "message" text: +From: stephan at example.org +Subject: frop +References: <1234 at local.machine.example> <3456 at example.net> + <435444 at ttms.example.org> <4223 at froop.example.net> +Message-ID: <432df324 at example.org> +To: nico at frop.example.org + +Frop +. +; + +test "Variables" { + set "message" "I am not in today!"; + set "subject" "Out of office"; + set "from" "user at example.com"; + + vacation :from "${from}" :subject "${subject}" "${message}"; + + test_result_print; + + if not test_result_execute { + test_fail "execution of result failed"; + } + + test_message :smtp 0; + + if not header :contains "subject" "Out of office" { + test_fail "subject not set properly"; + } + + if not header :contains "from" "user at example.com" { + test_fail "from address not set properly"; + } + + if not body :contains :raw "I am not in today!" { + test_fail "message not set properly"; + } +} From pigeonhole at rename-it.nl Wed Sep 21 02:05:13 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 21 Sep 2011 01:05:13 +0200 Subject: dovecot-2.0-pigeonhole: lib-sieve: vacation: handled FIXME regar... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/fe6df3425850 changeset: 1537:fe6df3425850 user: Stephan Bosch date: Wed Sep 21 00:55:58 2011 +0200 description: lib-sieve: vacation: handled FIXME regarding the use of variables in the :handle argument. Variables are now handled correctly. diffstat: src/lib-sieve/plugins/vacation/cmd-vacation.c | 84 +++++++++++++++------------ 1 files changed, 46 insertions(+), 38 deletions(-) diffs (136 lines): diff -r 4353ad991f1c -r fe6df3425850 src/lib-sieve/plugins/vacation/cmd-vacation.c --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c Wed Sep 21 00:54:52 2011 +0200 +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c Wed Sep 21 00:55:58 2011 +0200 @@ -231,7 +231,7 @@ bool mime; - string_t *handle; + struct sieve_ast_argument *handle_arg; }; /* @@ -348,10 +348,10 @@ *arg = sieve_ast_argument_next(*arg); } else if ( sieve_argument_is(tag, vacation_handle_tag) ) { - ctx_data->handle = sieve_ast_argument_str(*arg); - + ctx_data->handle_arg = *arg; + /* Detach optional argument (emitted as mandatory) */ - *arg = sieve_ast_arguments_detach(*arg,1); + *arg = sieve_ast_arguments_detach(*arg, 1); } return TRUE; @@ -468,34 +468,48 @@ return FALSE; /* Construct handle if not set explicitly */ - if ( ctx_data->handle == NULL ) { - string_t *reason = sieve_ast_argument_str(arg); - unsigned int size = str_len(reason); + if ( ctx_data->handle_arg == NULL ) { + T_BEGIN { + string_t *handle; + string_t *reason = sieve_ast_argument_str(arg); + unsigned int size = str_len(reason); - /* Precalculate the size of it all */ - size += ctx_data->subject == NULL ? - sizeof(_handle_empty_subject) - 1 : str_len(ctx_data->subject); - size += ctx_data->from == NULL ? - sizeof(_handle_empty_from) - 1 : str_len(ctx_data->from); - size += ctx_data->mime ? - sizeof(_handle_mime_enabled) - 1 : sizeof(_handle_mime_disabled) - 1; + /* Precalculate the size of it all */ + size += ctx_data->subject == NULL ? + sizeof(_handle_empty_subject) - 1 : str_len(ctx_data->subject); + size += ctx_data->from == NULL ? + sizeof(_handle_empty_from) - 1 : str_len(ctx_data->from); + size += ctx_data->mime ? + sizeof(_handle_mime_enabled) - 1 : sizeof(_handle_mime_disabled) - 1; - /* Construct the string */ - ctx_data->handle = str_new(sieve_command_pool(cmd), size); - str_append_str(ctx_data->handle, reason); + /* Construct the string */ + handle = t_str_new(size); + str_append_str(handle, reason); - if ( ctx_data->subject != NULL ) - str_append_str(ctx_data->handle, ctx_data->subject); - else - str_append(ctx_data->handle, _handle_empty_subject); + if ( ctx_data->subject != NULL ) + str_append_str(handle, ctx_data->subject); + else + str_append(handle, _handle_empty_subject); - if ( ctx_data->from != NULL ) - str_append_str(ctx_data->handle, ctx_data->from); - else - str_append(ctx_data->handle, _handle_empty_from); + if ( ctx_data->from != NULL ) + str_append_str(handle, ctx_data->from); + else + str_append(handle, _handle_empty_from); - str_append(ctx_data->handle, - ctx_data->mime ? _handle_mime_enabled : _handle_mime_disabled ); + str_append(handle, + ctx_data->mime ? _handle_mime_enabled : _handle_mime_disabled ); + + /* Create positional handle argument */ + ctx_data->handle_arg = sieve_ast_argument_string_create + (cmd->ast_node, handle, sieve_ast_node_line(cmd->ast_node)); + } T_END; + + if ( !sieve_validator_argument_activate + (valdtr, cmd, ctx_data->handle_arg, TRUE) ) + return FALSE; + } else { + /* Attach explicit handle argument as positional */ + (void)sieve_ast_argument_attach(cmd->ast_node, ctx_data->handle_arg); } return TRUE; @@ -507,18 +521,12 @@ static bool cmd_vacation_generate (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd) -{ - struct cmd_vacation_context_data *ctx_data = - (struct cmd_vacation_context_data *) cmd->data; - +{ sieve_operation_emit(cgenv->sblock, cmd->ext, &vacation_operation); /* Generate arguments */ if ( !sieve_generate_arguments(cgenv, cmd, NULL) ) return FALSE; - - /* FIXME: this will not allow the handle to be a variable */ - sieve_opr_string_emit(cgenv->sblock, ctx_data->handle); return TRUE; } @@ -779,13 +787,13 @@ (struct act_vacation_context *) action->context; sieve_result_action_printf( rpenv, "send vacation message:"); - sieve_result_printf(rpenv, " => seconds : %d\n", ctx->seconds); + sieve_result_printf(rpenv, " => seconds : %d\n", ctx->seconds); if ( ctx->subject != NULL ) - sieve_result_printf(rpenv, " => subject: %s\n", ctx->subject); + sieve_result_printf(rpenv, " => subject : %s\n", ctx->subject); if ( ctx->from != NULL ) - sieve_result_printf(rpenv, " => from : %s\n", ctx->from); + sieve_result_printf(rpenv, " => from : %s\n", ctx->from); if ( ctx->handle != NULL ) - sieve_result_printf(rpenv, " => handle : %s\n", ctx->handle); + sieve_result_printf(rpenv, " => handle : %s\n", ctx->handle); sieve_result_printf(rpenv, "\nSTART MESSAGE\n%s\nEND MESSAGE\n", ctx->reason); } From pigeonhole at rename-it.nl Wed Sep 21 12:33:16 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 21 Sep 2011 11:33:16 +0200 Subject: dovecot-2.0-pigeonhole: test suite: forgot to remove test_result... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/e10d402769fb changeset: 1538:e10d402769fb user: Stephan Bosch date: Wed Sep 21 11:33:00 2011 +0200 description: test suite: forgot to remove test_result_print command in previous change. diffstat: tests/extensions/vacation/message.svtest | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diffs (12 lines): diff -r fe6df3425850 -r e10d402769fb tests/extensions/vacation/message.svtest --- a/tests/extensions/vacation/message.svtest Wed Sep 21 00:55:58 2011 +0200 +++ b/tests/extensions/vacation/message.svtest Wed Sep 21 11:33:00 2011 +0200 @@ -70,8 +70,6 @@ vacation :from "${from}" :subject "${subject}" "${message}"; - test_result_print; - if not test_result_execute { test_fail "execution of result failed"; } From dovecot at dovecot.org Wed Sep 21 12:34:21 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 12:34:21 +0300 Subject: dovecot-2.1: lib-ssl-iostream: Don't require SSL ostream to alwa... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b97c53c54f72 changeset: 13527:b97c53c54f72 user: Timo Sirainen date: Wed Sep 21 12:34:02 2011 +0300 description: lib-ssl-iostream: Don't require SSL ostream to always have unlimited buffer size. It's important when reading/handshaking wants to write to output buffer, but writing itself can safely have zero sized buffer (e.g. while sending a large input stream). diffstat: src/lib-ssl-iostream/iostream-openssl.c | 20 +++++++++++++++++--- src/lib-ssl-iostream/iostream-openssl.h | 2 ++ src/lib-ssl-iostream/ostream-openssl.c | 15 ++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diffs (100 lines): diff -r d174fa047d56 -r b97c53c54f72 src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Tue Sep 20 16:44:32 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Wed Sep 21 12:34:02 2011 +0300 @@ -372,8 +372,9 @@ ssl_io->last_error = i_strdup(str); } -int ssl_iostream_handle_error(struct ssl_iostream *ssl_io, int ret, - const char *func_name) +static int +ssl_iostream_handle_error_full(struct ssl_iostream *ssl_io, int ret, + const char *func_name, bool write_error) { const char *errstr = NULL; int err; @@ -382,7 +383,8 @@ switch (err) { case SSL_ERROR_WANT_WRITE: if (!ssl_iostream_bio_sync(ssl_io)) { - i_panic("SSL ostream buffer size not unlimited"); + if (!write_error) + i_panic("SSL ostream buffer size not unlimited"); return 0; } if (ssl_io->closed) { @@ -435,6 +437,18 @@ return -1; } +int ssl_iostream_handle_error(struct ssl_iostream *ssl_io, int ret, + const char *func_name) +{ + return ssl_iostream_handle_error_full(ssl_io, ret, func_name, FALSE); +} + +int ssl_iostream_handle_write_error(struct ssl_iostream *ssl_io, int ret, + const char *func_name) +{ + return ssl_iostream_handle_error_full(ssl_io, ret, func_name, TRUE); +} + static const char *asn1_string_to_c(ASN1_STRING *asn_str) { const char *cstr; diff -r d174fa047d56 -r b97c53c54f72 src/lib-ssl-iostream/iostream-openssl.h --- a/src/lib-ssl-iostream/iostream-openssl.h Tue Sep 20 16:44:32 2011 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.h Wed Sep 21 12:34:02 2011 +0300 @@ -74,6 +74,8 @@ read/written, -1 if a fatal error occurred (errno is set). */ int ssl_iostream_handle_error(struct ssl_iostream *ssl_io, int ret, const char *func_name); +int ssl_iostream_handle_write_error(struct ssl_iostream *ssl_io, int ret, + const char *func_name); const char *ssl_iostream_error(void); const char *ssl_iostream_key_load_error(void); diff -r d174fa047d56 -r b97c53c54f72 src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Tue Sep 20 16:44:32 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 21 12:34:02 2011 +0300 @@ -56,6 +56,9 @@ if (size != iov[i].iov_len) i = iov_count; } + if (avail > 0) + o_stream_set_flush_pending(sstream->ssl_io->plain_output, TRUE); + for (; i < iov_count; i++) { size = I_MIN(iov[i].iov_len, avail); buffer_append(sstream->buffer, iov[i].iov_base, size); @@ -83,16 +86,14 @@ CONST_PTR_OFFSET(sstream->buffer->data, pos), sstream->buffer->used - pos); if (ret <= 0) { - ret = ssl_iostream_handle_error(sstream->ssl_io, ret, - "SSL_write"); + ret = ssl_iostream_handle_write_error(sstream->ssl_io, + ret, "SSL_write"); if (ret < 0) { sstream->ostream.ostream.stream_errno = errno; break; } - if (ret == 0) { - /* bio_int's buffer is full */ + if (ret == 0) break; - } } else { pos += ret; (void)ssl_iostream_bio_sync(sstream->ssl_io); @@ -139,8 +140,8 @@ CONST_PTR_OFFSET(iov[i].iov_base, pos), iov[i].iov_len - pos); if (ret <= 0) { - ret = ssl_iostream_handle_error(sstream->ssl_io, ret, - "SSL_write"); + ret = ssl_iostream_handle_write_error(sstream->ssl_io, + ret, "SSL_write"); if (ret < 0) { sstream->ostream.ostream.stream_errno = errno; break; From dovecot at dovecot.org Wed Sep 21 13:43:16 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 13:43:16 +0300 Subject: dovecot-2.1: doveadm: Fixed sending commands to doveadm server w... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1d8009c7b67e changeset: 13528:1d8009c7b67e user: Timo Sirainen date: Mon Sep 19 17:10:11 2011 +0300 description: doveadm: Fixed sending commands to doveadm server when it didn't require authentication. diffstat: src/doveadm/server-connection.c | 28 +++++++++++----------------- 1 files changed, 11 insertions(+), 17 deletions(-) diffs (59 lines): diff -r b97c53c54f72 -r 1d8009c7b67e src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Wed Sep 21 12:34:02 2011 +0300 +++ b/src/doveadm/server-connection.c Mon Sep 19 17:10:11 2011 +0300 @@ -158,6 +158,15 @@ i_stream_skip(conn->input, size); } +static void server_connection_authenticated(struct server_connection *conn) +{ + conn->authenticated = TRUE; + if (conn->delayed_cmd != NULL) { + o_stream_send_str(conn->output, conn->delayed_cmd); + conn->delayed_cmd = NULL; + } +} + static int server_connection_authenticate(struct server_connection *conn) { @@ -180,10 +189,7 @@ str_append_c(cmd, '\n'); o_stream_send(conn->output, cmd->data, cmd->used); - if (conn->delayed_cmd != NULL) { - o_stream_send_str(conn->output, conn->delayed_cmd); - conn->delayed_cmd = NULL; - } + server_connection_authenticated(conn); return 0; } @@ -202,7 +208,7 @@ conn->handshaked = TRUE; if (strcmp(line, "+") == 0) - conn->authenticated = TRUE; + server_connection_authenticated(conn); else if (strcmp(line, "-") == 0) { if (server_connection_authenticate(conn) < 0) { server_connection_destroy(&conn); @@ -222,18 +228,6 @@ return; } - if (!conn->authenticated) { - if ((line = i_stream_next_line(conn->input)) == NULL) - return; - if (strcmp(line, "+") == 0) - conn->authenticated = TRUE; - else { - i_error("doveadm authentication failed (%s)", line+1); - server_connection_destroy(&conn); - return; - } - } - data = i_stream_get_data(conn->input, &size); if (size == 0) return; From dovecot at dovecot.org Wed Sep 21 14:40:48 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 14:40:48 +0300 Subject: dovecot-2.1: Simplified creating filter ostreams. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/8c3c0e01e00d changeset: 13530:8c3c0e01e00d user: Timo Sirainen date: Wed Sep 21 14:40:35 2011 +0300 description: Simplified creating filter ostreams. diffstat: src/lib-fs/ostream-cmp.c | 34 +--- src/lib-ssl-iostream/ostream-openssl.c | 2 +- src/lib/ostream-buffer.c | 2 +- src/lib/ostream-file.c | 4 +- src/lib/ostream-private.h | 10 +- src/lib/ostream.c | 248 ++++++++++++++++++++++++-------- src/plugins/zlib/ostream-bzlib.c | 53 +----- src/plugins/zlib/ostream-zlib.c | 66 +------ 8 files changed, 224 insertions(+), 195 deletions(-) diffs (truncated from 765 to 300 lines): diff -r cf77e448295c -r 8c3c0e01e00d src/lib-fs/ostream-cmp.c --- a/src/lib-fs/ostream-cmp.c Wed Sep 21 13:56:13 2011 +0300 +++ b/src/lib-fs/ostream-cmp.c Wed Sep 21 14:40:35 2011 +0300 @@ -9,41 +9,18 @@ struct ostream_private ostream; struct istream *input; - struct ostream *output; bool equals; }; -static void cstream_copy_error(struct cmp_ostream *cstream) -{ - struct ostream *src = cstream->output; - struct ostream *dest = &cstream->ostream.ostream; - - dest->stream_errno = src->stream_errno; - dest->last_failed_errno = src->last_failed_errno; - dest->overflow = src->overflow; -} - static void o_stream_cmp_close(struct iostream_private *stream) { struct cmp_ostream *cstream = (struct cmp_ostream *)stream; - if (cstream->output == NULL) + if (cstream->input == NULL) return; i_stream_unref(&cstream->input); o_stream_flush(&cstream->ostream.ostream); - o_stream_unref(&cstream->output); -} - -static int o_stream_cmp_flush(struct ostream_private *stream) -{ - struct cmp_ostream *cstream = (struct cmp_ostream *)stream; - int ret; - - ret = o_stream_flush(cstream->output); - if (ret < 0) - cstream_copy_error(cstream); - return ret; } bool stream_cmp_block(struct istream *input, @@ -82,8 +59,8 @@ } } - if ((ret = o_stream_sendv(cstream->output, iov, iov_count)) < 0) { - cstream_copy_error(cstream); + if ((ret = o_stream_sendv(stream->parent, iov, iov_count)) < 0) { + o_stream_copy_error_from_parent(stream); return -1; } @@ -98,15 +75,12 @@ cstream = i_new(struct cmp_ostream, 1); cstream->ostream.sendv = o_stream_cmp_sendv; - cstream->ostream.flush = o_stream_cmp_flush; cstream->ostream.iostream.close = o_stream_cmp_close; cstream->input = input; - cstream->output = output; cstream->equals = TRUE; i_stream_ref(input); - o_stream_ref(output); - return o_stream_create(&cstream->ostream); + return o_stream_create(&cstream->ostream, output); } bool o_stream_cmp_equals(struct ostream *_output) diff -r cf77e448295c -r 8c3c0e01e00d src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 21 13:56:13 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 21 14:40:35 2011 +0300 @@ -253,5 +253,5 @@ o_stream_set_flush_callback(ssl_io->plain_output, plain_flush_callback, sstream); - return o_stream_create(&sstream->ostream); + return o_stream_create(&sstream->ostream, NULL); } diff -r cf77e448295c -r 8c3c0e01e00d src/lib/ostream-buffer.c --- a/src/lib/ostream-buffer.c Wed Sep 21 13:56:13 2011 +0300 +++ b/src/lib/ostream-buffer.c Wed Sep 21 14:40:35 2011 +0300 @@ -59,5 +59,5 @@ bstream->ostream.write_at = o_stream_buffer_write_at; bstream->buf = buf; - return o_stream_create(&bstream->ostream); + return o_stream_create(&bstream->ostream, NULL); } diff -r cf77e448295c -r 8c3c0e01e00d src/lib/ostream-file.c --- a/src/lib/ostream-file.c Wed Sep 21 13:56:13 2011 +0300 +++ b/src/lib/ostream-file.c Wed Sep 21 14:40:35 2011 +0300 @@ -933,7 +933,7 @@ fstream = o_stream_create_fd_common(fd, autoclose_fd); fstream->ostream.max_buffer_size = max_buffer_size; - ostream = o_stream_create(&fstream->ostream); + ostream = o_stream_create(&fstream->ostream, NULL); offset = lseek(fd, 0, SEEK_CUR); if (offset >= 0) { @@ -969,7 +969,7 @@ fstream->real_offset = offset; fstream->buffer_offset = offset; - ostream = o_stream_create(&fstream->ostream); + ostream = o_stream_create(&fstream->ostream, NULL); ostream->offset = offset; return ostream; } diff -r cf77e448295c -r 8c3c0e01e00d src/lib/ostream-private.h --- a/src/lib/ostream-private.h Wed Sep 21 13:56:13 2011 +0300 +++ b/src/lib/ostream-private.h Wed Sep 21 14:40:35 2011 +0300 @@ -11,6 +11,9 @@ /* methods: */ void (*cork)(struct ostream_private *stream, bool set); int (*flush)(struct ostream_private *stream); + void (*set_flush_callback)(struct ostream_private *stream, + stream_flush_callback_t *callback, + void *context); void (*flush_pending)(struct ostream_private *stream, bool set); size_t (*get_used_size)(const struct ostream_private *stream); int (*seek)(struct ostream_private *stream, uoff_t offset); @@ -27,15 +30,20 @@ struct ostream ostream; size_t max_buffer_size; + struct ostream *parent; /* for filter streams */ + stream_flush_callback_t *callback; void *context; unsigned int corked:1; }; -struct ostream *o_stream_create(struct ostream_private *_stream); +struct ostream * +o_stream_create(struct ostream_private *_stream, struct ostream *parent); off_t io_stream_copy(struct ostream *outstream, struct istream *instream, size_t block_size); +void o_stream_copy_error_from_parent(struct ostream_private *_stream); + #endif diff -r cf77e448295c -r 8c3c0e01e00d src/lib/ostream.c --- a/src/lib/ostream.c Wed Sep 21 13:56:13 2011 +0300 +++ b/src/lib/ostream.c Wed Sep 21 14:40:35 2011 +0300 @@ -12,8 +12,12 @@ const char *o_stream_get_name(struct ostream *stream) { - return stream->real_stream->iostream.name == NULL ? "" : - stream->real_stream->iostream.name; + while (stream->real_stream->iostream.name == NULL) { + stream = stream->real_stream->parent; + if (stream == NULL) + return ""; + } + return stream->real_stream->iostream.name; } void o_stream_destroy(struct ostream **stream) @@ -46,26 +50,17 @@ { struct ostream_private *_stream = stream->real_stream; - _stream->callback = callback; - _stream->context = context; + _stream->set_flush_callback(_stream, callback, context); } void o_stream_unset_flush_callback(struct ostream *stream) { - struct ostream_private *_stream = stream->real_stream; - - _stream->callback = NULL; - _stream->context = NULL; + o_stream_set_flush_callback(stream, NULL, NULL); } void o_stream_set_max_buffer_size(struct ostream *stream, size_t max_size) { - if (stream->real_stream->iostream.set_max_buffer_size != NULL) { - io_stream_set_max_buffer_size(&stream->real_stream->iostream, - max_size); - } else { - stream->real_stream->max_buffer_size = max_size; - } + io_stream_set_max_buffer_size(&stream->real_stream->iostream, max_size); } void o_stream_cork(struct ostream *stream) @@ -75,10 +70,7 @@ if (unlikely(stream->closed)) return; - if (_stream->cork != NULL) - _stream->cork(_stream, TRUE); - else - _stream->corked = TRUE; + _stream->cork(_stream, TRUE); } void o_stream_uncork(struct ostream *stream) @@ -88,12 +80,7 @@ if (unlikely(stream->closed)) return; - if (_stream->cork != NULL) - _stream->cork(_stream, FALSE); - else { - _stream->corked = FALSE; - (void)o_stream_flush(stream); - } + _stream->cork(_stream, FALSE); } int o_stream_flush(struct ostream *stream) @@ -105,11 +92,9 @@ return -1; stream->stream_errno = 0; - if (_stream->flush != NULL) { - if (unlikely((ret = _stream->flush(_stream)) < 0)) { - i_assert(stream->stream_errno != 0); - stream->last_failed_errno = stream->stream_errno; - } + if (unlikely((ret = _stream->flush(_stream)) < 0)) { + i_assert(stream->stream_errno != 0); + stream->last_failed_errno = stream->stream_errno; } return ret; } @@ -121,16 +106,14 @@ if (unlikely(stream->closed)) return; - if (_stream->flush_pending != NULL) - _stream->flush_pending(_stream, set); + _stream->flush_pending(_stream, set); } size_t o_stream_get_buffer_used_size(const struct ostream *stream) { const struct ostream_private *_stream = stream->real_stream; - return _stream->get_used_size == NULL ? 0 : - _stream->get_used_size(_stream); + return _stream->get_used_size(_stream); } size_t o_stream_get_buffer_avail_size(const struct ostream *stream) @@ -149,14 +132,9 @@ return -1; stream->stream_errno = 0; - if (_stream->seek != NULL) { - if (unlikely(_stream->seek(_stream, offset) < 0)) { - i_assert(stream->stream_errno != 0); - stream->last_failed_errno = stream->stream_errno; - } - } else { - stream->stream_errno = EPIPE; - stream->last_failed_errno = EPIPE; + if (unlikely(_stream->seek(_stream, offset) < 0)) { + i_assert(stream->stream_errno != 0); + stream->last_failed_errno = stream->stream_errno; return -1; } return 1; @@ -230,11 +208,6 @@ if (unlikely(stream->closed)) return -1; - if (stream->real_stream->write_at == NULL) { - /* stream doesn't support seeking */ - stream->stream_errno = EPIPE; - return -1; - } ret = stream->real_stream->write_at(stream->real_stream, data, size, offset); if (unlikely(ret < 0)) { @@ -244,22 +217,6 @@ return ret; } -static off_t o_stream_default_send_istream(struct ostream_private *outstream, - struct istream *instream) -{ - return io_stream_copy(&outstream->ostream, instream, IO_BLOCK_SIZE); -} - -struct ostream *o_stream_create(struct ostream_private *_stream) -{ From dovecot at dovecot.org Wed Sep 21 14:40:48 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 14:40:48 +0300 Subject: dovecot-2.1: Renamed lib/*-internal.h files to lib/*-private.h f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cf77e448295c changeset: 13529:cf77e448295c user: Timo Sirainen date: Wed Sep 21 13:56:13 2011 +0300 description: Renamed lib/*-internal.h files to lib/*-private.h for consistency. diffstat: src/lib-fs/ostream-cmp.c | 2 +- src/lib-mail/istream-dot.c | 2 +- src/lib-mail/istream-header-filter.c | 2 +- src/lib-ssl-iostream/istream-openssl.c | 2 +- src/lib-ssl-iostream/ostream-openssl.c | 2 +- src/lib-storage/index/istream-attachment.c | 2 +- src/lib-storage/index/istream-mail-stats.c | 2 +- src/lib-storage/index/mbox/istream-raw-mbox.c | 2 +- src/lib-test/test-common.c | 2 +- src/lib/Makefile.am | 8 +- src/lib/ioloop-epoll.c | 2 +- src/lib/ioloop-internal.h | 92 --------------------------- src/lib/ioloop-iolist.c | 2 +- src/lib/ioloop-kqueue.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-kqueue.c | 2 +- src/lib/ioloop-notify-none.c | 2 +- src/lib/ioloop-poll.c | 2 +- src/lib/ioloop-private.h | 92 +++++++++++++++++++++++++++ src/lib/ioloop-select.c | 2 +- src/lib/ioloop.c | 2 +- src/lib/iostream-internal.h | 26 ------- src/lib/iostream-private.h | 26 +++++++ src/lib/iostream.c | 2 +- src/lib/istream-base64-encoder.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-internal.h | 61 ----------------- src/lib/istream-limit.c | 2 +- src/lib/istream-mmap.c | 2 +- src/lib/istream-private.h | 61 +++++++++++++++++ src/lib/istream-seekable.c | 2 +- src/lib/istream-tee.c | 2 +- src/lib/istream.c | 2 +- src/lib/ostream-buffer.c | 2 +- src/lib/ostream-file.c | 4 +- src/lib/ostream-internal.h | 41 ------------ src/lib/ostream-private.h | 41 ++++++++++++ src/lib/ostream.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/plugins/zlib/istream-bzlib.c | 2 +- src/plugins/zlib/istream-zlib.c | 2 +- src/plugins/zlib/ostream-bzlib.c | 2 +- src/plugins/zlib/ostream-zlib.c | 2 +- 52 files changed, 268 insertions(+), 268 deletions(-) diffs (truncated from 1023 to 300 lines): diff -r 1d8009c7b67e -r cf77e448295c src/lib-fs/ostream-cmp.c --- a/src/lib-fs/ostream-cmp.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-fs/ostream-cmp.c Wed Sep 21 13:56:13 2011 +0300 @@ -2,7 +2,7 @@ #include "lib.h" #include "istream.h" -#include "ostream-internal.h" +#include "ostream-private.h" #include "ostream-cmp.h" struct cmp_ostream { diff -r 1d8009c7b67e -r cf77e448295c src/lib-mail/istream-dot.c --- a/src/lib-mail/istream-dot.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-mail/istream-dot.c Wed Sep 21 13:56:13 2011 +0300 @@ -1,7 +1,7 @@ /* Copyright (c) 2007-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" -#include "istream-internal.h" +#include "istream-private.h" #include "istream-dot.h" struct dot_istream { diff -r 1d8009c7b67e -r cf77e448295c src/lib-mail/istream-header-filter.c --- a/src/lib-mail/istream-header-filter.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-mail/istream-header-filter.c Wed Sep 21 13:56:13 2011 +0300 @@ -3,7 +3,7 @@ #include "lib.h" #include "array.h" #include "message-parser.h" -#include "istream-internal.h" +#include "istream-private.h" #include "istream-header-filter.h" #include diff -r 1d8009c7b67e -r cf77e448295c src/lib-ssl-iostream/istream-openssl.c --- a/src/lib-ssl-iostream/istream-openssl.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-ssl-iostream/istream-openssl.c Wed Sep 21 13:56:13 2011 +0300 @@ -1,7 +1,7 @@ /* Copyright (c) 2009 Dovecot authors, see the included COPYING file */ #include "lib.h" -#include "istream-internal.h" +#include "istream-private.h" #include "iostream-openssl.h" struct ssl_istream { diff -r 1d8009c7b67e -r cf77e448295c src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 21 13:56:13 2011 +0300 @@ -2,7 +2,7 @@ #include "lib.h" #include "buffer.h" -#include "ostream-internal.h" +#include "ostream-private.h" #include "iostream-openssl.h" struct ssl_ostream { diff -r 1d8009c7b67e -r cf77e448295c src/lib-storage/index/istream-attachment.c --- a/src/lib-storage/index/istream-attachment.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-storage/index/istream-attachment.c Wed Sep 21 13:56:13 2011 +0300 @@ -1,7 +1,7 @@ /* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" -#include "istream-internal.h" +#include "istream-private.h" #include "istream-attachment.h" struct attachment_istream { diff -r 1d8009c7b67e -r cf77e448295c src/lib-storage/index/istream-mail-stats.c --- a/src/lib-storage/index/istream-mail-stats.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-storage/index/istream-mail-stats.c Wed Sep 21 13:56:13 2011 +0300 @@ -2,7 +2,7 @@ #include "lib.h" #include "mail-storage-private.h" -#include "istream-internal.h" +#include "istream-private.h" #include "istream-mail-stats.h" struct mail_stats_istream { diff -r 1d8009c7b67e -r cf77e448295c src/lib-storage/index/mbox/istream-raw-mbox.c --- a/src/lib-storage/index/mbox/istream-raw-mbox.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Wed Sep 21 13:56:13 2011 +0300 @@ -2,7 +2,7 @@ #include "lib.h" #include "buffer.h" -#include "istream-internal.h" +#include "istream-private.h" #include "istream-raw-mbox.h" #include "mbox-from.h" diff -r 1d8009c7b67e -r cf77e448295c src/lib-test/test-common.c --- a/src/lib-test/test-common.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib-test/test-common.c Wed Sep 21 13:56:13 2011 +0300 @@ -1,7 +1,7 @@ /* Copyright (c) 2007-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" -#include "istream-internal.h" +#include "istream-private.h" #include "test-common.h" #include diff -r 1d8009c7b67e -r cf77e448295c src/lib/Makefile.am --- a/src/lib/Makefile.am Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib/Makefile.am Wed Sep 21 13:56:13 2011 +0300 @@ -161,17 +161,17 @@ hostpid.h \ imem.h \ ipwd.h \ - iostream-internal.h \ + iostream-private.h \ istream.h \ istream-base64-encoder.h \ istream-concat.h \ istream-crlf.h \ - istream-internal.h \ + istream-private.h \ istream-seekable.h \ istream-tee.h \ ioloop.h \ ioloop-iolist.h \ - ioloop-internal.h \ + ioloop-private.h \ ioloop-notify-fd.h \ lib.h \ lib-signals.h \ @@ -188,7 +188,7 @@ network.h \ nfs-workarounds.h \ ostream.h \ - ostream-internal.h \ + ostream-private.h \ primes.h \ printf-format-fix.h \ process-title.h \ diff -r 1d8009c7b67e -r cf77e448295c src/lib/ioloop-epoll.c --- a/src/lib/ioloop-epoll.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib/ioloop-epoll.c Wed Sep 21 13:56:13 2011 +0300 @@ -9,7 +9,7 @@ #include "lib.h" #include "array.h" #include "fd-close-on-exec.h" -#include "ioloop-internal.h" +#include "ioloop-private.h" #include "ioloop-iolist.h" #ifdef IOLOOP_EPOLL diff -r 1d8009c7b67e -r cf77e448295c src/lib/ioloop-internal.h --- a/src/lib/ioloop-internal.h Mon Sep 19 17:10:11 2011 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -#ifndef IOLOOP_INTERNAL_H -#define IOLOOP_INTERNAL_H - -#include "priorityq.h" -#include "ioloop.h" - -#ifndef IOLOOP_INITIAL_FD_COUNT -# define IOLOOP_INITIAL_FD_COUNT 128 -#endif - -struct ioloop { - struct ioloop *prev; - - struct ioloop_context *cur_ctx; - - struct io_file *io_files; - struct io_file *next_io_file; - struct priorityq *timeouts; - - struct ioloop_handler_context *handler_context; - struct ioloop_notify_handler_context *notify_handler_context; - unsigned int max_fd_count; - - io_loop_time_moved_callback_t *time_moved_callback; - time_t next_max_time; - - unsigned int running:1; -}; - -struct io { - enum io_condition condition; - - io_callback_t *callback; - void *context; - - struct ioloop *ioloop; - struct ioloop_context *ctx; -}; - -struct io_file { - struct io io; - - /* use a doubly linked list so that io_remove() is quick */ - struct io_file *prev, *next; - - int refcount; - int fd; -}; - -struct timeout { - struct priorityq_item item; - - unsigned int msecs; - struct timeval next_run; - - timeout_callback_t *callback; - void *context; - - struct ioloop *ioloop; - struct ioloop_context *ctx; -}; - -struct ioloop_context_callback { - io_callback_t *activate; - io_callback_t *deactivate; - void *context; -}; - -struct ioloop_context { - int refcount; - struct ioloop *ioloop; - ARRAY_DEFINE(callbacks, struct ioloop_context_callback); -}; - -int io_loop_get_wait_time(struct ioloop *ioloop, struct timeval *tv_r); -void io_loop_handle_timeouts(struct ioloop *ioloop); -void io_loop_call_io(struct io *io); - -/* I/O handler calls */ -void io_loop_handle_add(struct io_file *io); -void io_loop_handle_remove(struct io_file *io, bool closed); - -void io_loop_handler_init(struct ioloop *ioloop, unsigned int initial_fd_count); -void io_loop_handler_deinit(struct ioloop *ioloop); - -void io_loop_notify_remove(struct io *io); -void io_loop_notify_handler_deinit(struct ioloop *ioloop); - -void io_loop_context_activate(struct ioloop_context *ctx); -void io_loop_context_deactivate(struct ioloop_context *ctx); - -#endif diff -r 1d8009c7b67e -r cf77e448295c src/lib/ioloop-iolist.c --- a/src/lib/ioloop-iolist.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib/ioloop-iolist.c Wed Sep 21 13:56:13 2011 +0300 @@ -5,7 +5,7 @@ */ #include "lib.h" -#include "ioloop-internal.h" +#include "ioloop-private.h" #include "ioloop-iolist.h" bool ioloop_iolist_add(struct io_list *list, struct io_file *io) diff -r 1d8009c7b67e -r cf77e448295c src/lib/ioloop-kqueue.c --- a/src/lib/ioloop-kqueue.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib/ioloop-kqueue.c Wed Sep 21 13:56:13 2011 +0300 @@ -10,7 +10,7 @@ #include "array.h" #include "fd-close-on-exec.h" -#include "ioloop-internal.h" +#include "ioloop-private.h" #include #include diff -r 1d8009c7b67e -r cf77e448295c src/lib/ioloop-notify-dn.c --- a/src/lib/ioloop-notify-dn.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib/ioloop-notify-dn.c Wed Sep 21 13:56:13 2011 +0300 @@ -7,7 +7,7 @@ #ifdef IOLOOP_NOTIFY_DNOTIFY -#include "ioloop-internal.h" +#include "ioloop-private.h" #include "ioloop-notify-fd.h" #include "fd-set-nonblock.h" #include "fd-close-on-exec.h" diff -r 1d8009c7b67e -r cf77e448295c src/lib/ioloop-notify-fd.c --- a/src/lib/ioloop-notify-fd.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib/ioloop-notify-fd.c Wed Sep 21 13:56:13 2011 +0300 @@ -1,7 +1,7 @@ /* Copyright (c) 2007-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" -#include "ioloop-internal.h" +#include "ioloop-private.h" #include "ioloop-notify-fd.h" #if defined(IOLOOP_NOTIFY_DNOTIFY) || defined(IOLOOP_NOTIFY_INOTIFY) diff -r 1d8009c7b67e -r cf77e448295c src/lib/ioloop-notify-inotify.c --- a/src/lib/ioloop-notify-inotify.c Mon Sep 19 17:10:11 2011 +0300 +++ b/src/lib/ioloop-notify-inotify.c Wed Sep 21 13:56:13 2011 +0300 From dovecot at dovecot.org Wed Sep 21 15:58:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 15:58:45 +0300 Subject: dovecot-2.1: i_stream_next_line(): Don't fail if stream doesn't ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0fb296c11edc changeset: 13531:0fb296c11edc user: Timo Sirainen date: Wed Sep 21 15:51:00 2011 +0300 description: i_stream_next_line(): Don't fail if stream doesn't have write buffer, we can handle it. diffstat: src/lib/istream.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diffs (16 lines): diff -r 8c3c0e01e00d -r 0fb296c11edc src/lib/istream.c --- a/src/lib/istream.c Wed Sep 21 14:40:35 2011 +0300 +++ b/src/lib/istream.c Wed Sep 21 15:51:00 2011 +0300 @@ -349,12 +349,6 @@ return NULL; } - if (unlikely(_stream->w_buffer == NULL)) { - i_error("i_stream_next_line(%s) called for unmodifiable stream", - i_stream_get_name(stream)); - return NULL; - } - pos = memchr(_stream->buffer + _stream->skip, '\n', _stream->pos - _stream->skip); if (pos != NULL) { From dovecot at dovecot.org Wed Sep 21 15:58:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 15:58:45 +0300 Subject: dovecot-2.1: ostream: Keep track of flush callback for filter os... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/62e1c575b16a changeset: 13532:62e1c575b16a user: Timo Sirainen date: Wed Sep 21 15:53:00 2011 +0300 description: ostream: Keep track of flush callback for filter ostreams as well. diffstat: src/lib/ostream.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diffs (33 lines): diff -r 0fb296c11edc -r 62e1c575b16a src/lib/ostream.c --- a/src/lib/ostream.c Wed Sep 21 15:51:00 2011 +0300 +++ b/src/lib/ostream.c Wed Sep 21 15:53:00 2011 +0300 @@ -323,14 +323,11 @@ stream_flush_callback_t *callback, void *context) { - if (_stream->parent == NULL) { - _stream->callback = callback; - _stream->context = context; - } else { - /* this is a filter stream, we don't have a flush - callback ourself */ + if (_stream->parent != NULL) o_stream_set_flush_callback(_stream->parent, callback, context); - } + + _stream->callback = callback; + _stream->context = context; } static void @@ -385,6 +382,10 @@ if (parent != NULL) { _stream->parent = parent; o_stream_ref(parent); + + _stream->callback = parent->real_stream->callback; + _stream->context = parent->real_stream->context; + _stream->max_buffer_size = parent->real_stream->max_buffer_size; } if (_stream->iostream.close == NULL) From dovecot at dovecot.org Wed Sep 21 15:58:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 15:58:45 +0300 Subject: dovecot-2.1: lib-ssl-iostream: If flush wants to read, make sure... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e0bee6c56a05 changeset: 13533:e0bee6c56a05 user: Timo Sirainen date: Wed Sep 21 15:54:06 2011 +0300 description: lib-ssl-iostream: If flush wants to read, make sure the flush callback isn't being called again. diffstat: src/lib-ssl-iostream/ostream-openssl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 62e1c575b16a -r e0bee6c56a05 src/lib-ssl-iostream/ostream-openssl.c --- a/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 21 15:53:00 2011 +0300 +++ b/src/lib-ssl-iostream/ostream-openssl.c Wed Sep 21 15:54:06 2011 +0300 @@ -119,6 +119,8 @@ if (ret == 0 && sstream->ssl_io->want_read) { /* we need to read more data until we can continue. */ + o_stream_set_flush_pending(sstream->ssl_io->plain_output, + FALSE); sstream->ssl_io->ostream_flush_waiting_input = TRUE; ret = 1; } From dovecot at dovecot.org Wed Sep 21 15:58:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 15:58:45 +0300 Subject: dovecot-2.1: Added rawlog i/ostreams. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0860ac364dec changeset: 13534:0860ac364dec user: Timo Sirainen date: Wed Sep 21 15:57:57 2011 +0300 description: Added rawlog i/ostreams. diffstat: src/lib/Makefile.am | 7 ++ src/lib/iostream-rawlog-private.h | 18 +++++ src/lib/iostream-rawlog.c | 118 ++++++++++++++++++++++++++++++++++++++ src/lib/iostream-rawlog.h | 7 ++ src/lib/istream-rawlog.c | 104 +++++++++++++++++++++++++++++++++ src/lib/istream-rawlog.h | 8 ++ src/lib/ostream-rawlog.c | 62 +++++++++++++++++++ src/lib/ostream-rawlog.h | 8 ++ 8 files changed, 332 insertions(+), 0 deletions(-) diffs (truncated from 403 to 300 lines): diff -r e0bee6c56a05 -r 0860ac364dec src/lib/Makefile.am --- a/src/lib/Makefile.am Wed Sep 21 15:54:06 2011 +0300 +++ b/src/lib/Makefile.am Wed Sep 21 15:57:57 2011 +0300 @@ -48,6 +48,7 @@ imem.c \ ipwd.c \ iostream.c \ + iostream-rawlog.c \ istream.c \ istream-base64-encoder.c \ istream-concat.c \ @@ -56,6 +57,7 @@ istream-file.c \ istream-limit.c \ istream-mmap.c \ + istream-rawlog.c \ istream-seekable.c \ istream-tee.c \ ioloop.c \ @@ -88,6 +90,7 @@ ostream.c \ ostream-file.c \ ostream-buffer.c \ + ostream-rawlog.c \ primes.c \ printf-format-fix.c \ process-title.c \ @@ -162,11 +165,14 @@ imem.h \ ipwd.h \ iostream-private.h \ + iostream-rawlog.h \ + iostream-rawlog-private.h \ istream.h \ istream-base64-encoder.h \ istream-concat.h \ istream-crlf.h \ istream-private.h \ + istream-rawlog.h \ istream-seekable.h \ istream-tee.h \ ioloop.h \ @@ -189,6 +195,7 @@ nfs-workarounds.h \ ostream.h \ ostream-private.h \ + ostream-rawlog.h \ primes.h \ printf-format-fix.h \ process-title.h \ diff -r e0bee6c56a05 -r 0860ac364dec src/lib/iostream-rawlog-private.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/iostream-rawlog-private.h Wed Sep 21 15:57:57 2011 +0300 @@ -0,0 +1,18 @@ +#ifndef IOSTREAM_RAWLOG_PRIVATE_H +#define IOSTREAM_RAWLOG_PRIVATE_H + +struct rawlog_iostream { + struct iostream_private *iostream; + + char *rawlog_path; + int rawlog_fd; + + bool autoclose_fd; + bool write_timestamp; +}; + +void iostream_rawlog_write(struct rawlog_iostream *rstream, + const unsigned char *data, size_t size); +void iostream_rawlog_close(struct rawlog_iostream *rstream); + +#endif diff -r e0bee6c56a05 -r 0860ac364dec src/lib/iostream-rawlog.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/iostream-rawlog.c Wed Sep 21 15:57:57 2011 +0300 @@ -0,0 +1,118 @@ +/* Copyright (c) 2011 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "hostpid.h" +#include "ioloop.h" +#include "write-full.h" +#include "istream.h" +#include "ostream.h" +#include "istream-rawlog.h" +#include "ostream-rawlog.h" +#include "iostream-private.h" +#include "iostream-rawlog-private.h" +#include "iostream-rawlog.h" + +#include +#include + +static void +rawlog_write(struct rawlog_iostream *rstream, const void *data, size_t size) +{ + if (rstream->rawlog_fd == -1) + return; + + if (write_full(rstream->rawlog_fd, data, size) < 0) { + i_error("rawlog_istream.write(%s) failed: %m", + rstream->rawlog_path); + iostream_rawlog_close(rstream); + } +} + +static void rawlog_write_timestamp(struct rawlog_iostream *rstream) +{ + char buf[MAX_INT_STRLEN + 6 + 2]; + + i_snprintf(buf, sizeof(buf), "%lu.%06u ", + (unsigned long)ioloop_timeval.tv_sec, + (unsigned int)ioloop_timeval.tv_usec); + rawlog_write(rstream, buf, strlen(buf)); +} + +void iostream_rawlog_write(struct rawlog_iostream *rstream, + const unsigned char *data, size_t size) +{ + size_t i, start; + + i_assert(size > 0); + + io_loop_time_refresh(); + if (rstream->write_timestamp) + rawlog_write_timestamp(rstream); + + for (start = 0, i = 1; i < size; i++) { + if (data[i-1] == '\n') { + rawlog_write(rstream, data + start, i - start); + rawlog_write_timestamp(rstream); + start = i; + } + } + if (start != size) + rawlog_write(rstream, data + start, size - start); + rstream->write_timestamp = data[size-1] == '\n'; +} + +void iostream_rawlog_close(struct rawlog_iostream *rstream) +{ + if (rstream->autoclose_fd && rstream->rawlog_fd != -1) { + if (close(rstream->rawlog_fd) < 0) { + i_error("rawlog_istream.close(%s) failed: %m", + rstream->rawlog_path); + } + } + rstream->rawlog_fd = -1; + i_free_and_null(rstream->rawlog_path); +} + +int iostream_rawlog_create(const char *dir, struct istream **input, + struct ostream **output) +{ + static unsigned int counter = 0; + const char *in_path, *out_path; + struct istream *old_input; + struct ostream *old_output; + struct tm *tm; + char timestamp[50]; + int in_fd, out_fd; + + tm = localtime(&ioloop_time); + if (strftime(timestamp, sizeof(timestamp), "%Y%m%d-%H%M%S", tm) <= 0) + i_fatal("strftime() failed"); + + counter++; + in_path = t_strdup_printf("%s/%s.%s.%u.in", + dir, timestamp, my_pid, counter); + out_path = t_strdup_printf("%s/%s.%s.%u.out", + dir, timestamp, my_pid, counter); + + in_fd = open(in_path, O_CREAT | O_APPEND | O_WRONLY, 0600); + if (in_fd == -1) { + i_error("creat(%s) failed: %m", in_path); + return -1; + } + + out_fd = open(out_path, O_CREAT | O_APPEND | O_WRONLY, 0600); + if (out_fd == -1) { + i_error("creat(%s) failed: %m", out_path); + (void)close(in_fd); + (void)unlink(in_path); + return -1; + } + + old_input = *input; + old_output = *output; + *input = i_stream_create_rawlog(old_input, in_path, in_fd, TRUE); + *output = o_stream_create_rawlog(old_output, out_path, out_fd, TRUE); + i_stream_unref(&old_input); + o_stream_unref(&old_output); + return 0; +} diff -r e0bee6c56a05 -r 0860ac364dec src/lib/iostream-rawlog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/iostream-rawlog.h Wed Sep 21 15:57:57 2011 +0300 @@ -0,0 +1,7 @@ +#ifndef IOSTREAM_RAWLOG_H +#define IOSTREAM_RAWLOG_H + +int iostream_rawlog_create(const char *dir, struct istream **input, + struct ostream **output); + +#endif diff -r e0bee6c56a05 -r 0860ac364dec src/lib/istream-rawlog.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/istream-rawlog.c Wed Sep 21 15:57:57 2011 +0300 @@ -0,0 +1,104 @@ +/* Copyright (c) 2011 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "iostream-rawlog-private.h" +#include "istream-private.h" +#include "istream-rawlog.h" + +struct rawlog_istream { + struct istream_private istream; + struct rawlog_iostream riostream; +}; + +static void i_stream_rawlog_close(struct iostream_private *stream) +{ + struct rawlog_istream *rstream = (struct rawlog_istream *)stream; + + iostream_rawlog_close(&rstream->riostream); +} + +static void i_stream_rawlog_destroy(struct iostream_private *stream) +{ + struct rawlog_istream *rstream = (struct rawlog_istream *)stream; + uoff_t v_offset; + + v_offset = rstream->istream.parent_start_offset + + rstream->istream.istream.v_offset; + if (rstream->istream.parent->seekable || + v_offset > rstream->istream.parent->v_offset) { + /* get to same position in parent stream */ + i_stream_seek(rstream->istream.parent, v_offset); + } + i_stream_unref(&rstream->istream.parent); +} + +static ssize_t i_stream_rawlog_read(struct istream_private *stream) +{ + struct rawlog_istream *rstream = (struct rawlog_istream *)stream; + ssize_t ret; + size_t pos; + + i_stream_seek(stream->parent, rstream->istream.parent_start_offset + + stream->istream.v_offset); + + stream->pos -= stream->skip; + stream->skip = 0; + + stream->buffer = i_stream_get_data(stream->parent, &pos); + if (pos > stream->pos) + ret = 0; + else do { + if ((ret = i_stream_read(stream->parent)) == -2) + return -2; + + stream->istream.stream_errno = stream->parent->stream_errno; + stream->istream.eof = stream->parent->eof; + stream->buffer = i_stream_get_data(stream->parent, &pos); + } while (pos <= stream->pos && ret > 0); + + if (pos <= stream->pos) + ret = ret == 0 ? 0 : -1; + else { + ret = (ssize_t)(pos - stream->pos); + iostream_rawlog_write(&rstream->riostream, + stream->buffer + stream->pos, ret); + } + stream->pos = pos; + i_assert(ret != -1 || stream->istream.eof || + stream->istream.stream_errno != 0); + return ret; +} + +static const struct stat * +i_stream_rawlog_stat(struct istream_private *stream, bool exact) +{ + return i_stream_stat(stream->parent, exact); +} + +struct istream * +i_stream_create_rawlog(struct istream *input, const char *rawlog_path, + int rawlog_fd, bool autoclose_fd) +{ + struct rawlog_istream *rstream; + + i_assert(rawlog_path != NULL); + i_assert(rawlog_fd != -1); + + rstream = i_new(struct rawlog_istream, 1); + rstream->istream.max_buffer_size = input->real_stream->max_buffer_size; + rstream->riostream.rawlog_path = i_strdup(rawlog_path); + rstream->riostream.rawlog_fd = rawlog_fd; + rstream->riostream.autoclose_fd = autoclose_fd; From dovecot at dovecot.org Wed Sep 21 15:58:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 15:58:45 +0300 Subject: dovecot-2.1: imapc: Added imapc_rawlog_dir setting. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/87662d9ceff8 changeset: 13535:87662d9ceff8 user: Timo Sirainen date: Wed Sep 21 15:58:26 2011 +0300 description: imapc: Added imapc_rawlog_dir setting. diffstat: src/lib-storage/index/imapc/imapc-client.c | 1 + src/lib-storage/index/imapc/imapc-client.h | 1 + src/lib-storage/index/imapc/imapc-connection.c | 35 ++++++++++++++++++++++--- src/lib-storage/index/imapc/imapc-settings.c | 6 +++- src/lib-storage/index/imapc/imapc-settings.h | 2 + src/lib-storage/index/imapc/imapc-storage.c | 2 + 6 files changed, 41 insertions(+), 6 deletions(-) diffs (144 lines): diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-client.c --- a/src/lib-storage/index/imapc/imapc-client.c Wed Sep 21 15:57:57 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.c Wed Sep 21 15:58:26 2011 +0300 @@ -54,6 +54,7 @@ p_strdup(pool, set->dns_client_socket_path); client->set.temp_path_prefix = p_strdup(pool, set->temp_path_prefix); + client->set.rawlog_dir = p_strdup(pool, set->rawlog_dir); if (set->ssl_mode != IMAPC_CLIENT_SSL_MODE_NONE) { client->set.ssl_mode = set->ssl_mode; diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-client.h --- a/src/lib-storage/index/imapc/imapc-client.h Wed Sep 21 15:57:57 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-client.h Wed Sep 21 15:58:26 2011 +0300 @@ -45,6 +45,7 @@ enum imapc_client_ssl_mode ssl_mode; const char *ssl_ca_dir; + const char *rawlog_dir; bool debug; }; diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 21 15:57:57 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 21 15:58:26 2011 +0300 @@ -9,6 +9,7 @@ #include "write-full.h" #include "str.h" #include "dns-lookup.h" +#include "iostream-rawlog.h" #include "iostream-ssl.h" #include "imap-quote.h" #include "imap-util.h" @@ -70,8 +71,8 @@ int fd; struct io *io; - struct istream *input; - struct ostream *output; + struct istream *input, *raw_input; + struct ostream *output, *raw_output; struct imap_parser *parser; struct timeout *to; struct timeout *to_output; @@ -1026,6 +1027,16 @@ if (conn->client->set.debug) i_debug("imapc(%s): Starting SSL handshake", conn->name); + if (conn->raw_input != conn->input) { + /* recreate rawlog after STARTTLS */ + i_stream_ref(conn->raw_input); + o_stream_ref(conn->raw_output); + i_stream_destroy(&conn->input); + o_stream_destroy(&conn->output); + conn->input = conn->raw_input; + conn->output = conn->raw_output; + } + source = t_strdup_printf("imapc(%s): ", conn->name); if (io_stream_create_ssl(conn->client->ssl_ctx, source, &ssl_set, &conn->input, &conn->output, @@ -1038,9 +1049,16 @@ imapc_connection_ssl_handshaked, conn); if (ssl_iostream_handshake(conn->ssl_iostream) < 0) { - i_error("imapc(%s): SSL handshake failed", conn->name); + i_error("imapc(%s): SSL handshake failed: %s", conn->name, + ssl_iostream_get_last_error(conn->ssl_iostream)); return -1; } + + if (*conn->client->set.rawlog_dir != '\0') { + (void)iostream_rawlog_create(conn->client->set.rawlog_dir, + &conn->input, &conn->output); + } + imap_parser_set_streams(conn->parser, conn->input, NULL); return 0; } @@ -1120,8 +1138,15 @@ return; } conn->fd = fd; - conn->input = i_stream_create_fd(fd, (size_t)-1, FALSE); - conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE); + conn->input = conn->raw_input = i_stream_create_fd(fd, (size_t)-1, FALSE); + conn->output = conn->raw_output = o_stream_create_fd(fd, (size_t)-1, FALSE); + + if (*conn->client->set.rawlog_dir != '\0' && + conn->client->set.ssl_mode != IMAPC_CLIENT_SSL_MODE_IMMEDIATE) { + (void)iostream_rawlog_create(conn->client->set.rawlog_dir, + &conn->input, &conn->output); + } + o_stream_set_flush_callback(conn->output, imapc_connection_output, conn); conn->io = io_add(fd, IO_WRITE, imapc_connection_connected, conn); diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Wed Sep 21 15:57:57 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.c Wed Sep 21 15:58:26 2011 +0300 @@ -23,6 +23,8 @@ DEF(SET_ENUM, imapc_ssl), DEF(SET_STR, imapc_ssl_ca_dir), + DEF(SET_STR, imapc_rawlog_dir), + SETTING_DEFINE_LIST_END }; @@ -34,7 +36,9 @@ .imapc_password = "", .imapc_ssl = "no:imaps:starttls", - .imapc_ssl_ca_dir = "" + .imapc_ssl_ca_dir = "", + + .imapc_rawlog_dir = "" }; static const struct setting_parser_info imapc_setting_parser_info = { diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-settings.h --- a/src/lib-storage/index/imapc/imapc-settings.h Wed Sep 21 15:57:57 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.h Wed Sep 21 15:58:26 2011 +0300 @@ -10,6 +10,8 @@ const char *imapc_ssl; const char *imapc_ssl_ca_dir; + + const char *imapc_rawlog_dir; }; const struct setting_parser_info *imapc_get_setting_parser_info(void); diff -r 0860ac364dec -r 87662d9ceff8 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 21 15:57:57 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Wed Sep 21 15:58:26 2011 +0300 @@ -257,6 +257,8 @@ t_strconcat(_storage->user->set->base_dir, "/", DNS_CLIENT_SOCKET_NAME, NULL); set.debug = _storage->set->mail_debug; + set.rawlog_dir = mail_user_home_expand(_storage->user, + storage->set->imapc_rawlog_dir); str = t_str_new(128); mail_user_set_get_temp_prefix(str, _storage->user->set); From dovecot at dovecot.org Wed Sep 21 16:18:29 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 16:18:29 +0300 Subject: dovecot-2.1: imapc: Don't try to send literal stream output unti... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9a42e3690b1b changeset: 13536:9a42e3690b1b user: Timo Sirainen date: Wed Sep 21 16:18:19 2011 +0300 description: imapc: Don't try to send literal stream output until its '+' has been received. diffstat: src/lib-storage/index/imapc/imapc-connection.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diffs (73 lines): diff -r 87662d9ceff8 -r 9a42e3690b1b src/lib-storage/index/imapc/imapc-connection.c --- a/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 21 15:58:26 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-connection.c Wed Sep 21 16:18:19 2011 +0300 @@ -54,6 +54,7 @@ unsigned int idle:1; unsigned int mailboxcmd:1; + unsigned int wait_for_literal:1; }; struct imapc_connection_literal { @@ -291,6 +292,7 @@ va_start(va, fmt); i_error("imapc(%s): Server sent invalid input: %s", conn->name, t_strdup_vprintf(fmt, va)); + sleep(3600); imapc_connection_disconnect(conn); va_end(va); } @@ -793,20 +795,22 @@ static int imapc_connection_input_plus(struct imapc_connection *conn) { - struct imapc_command *const *cmd_p; + struct imapc_command *const *cmds; + unsigned int cmds_count; const char *line; if ((line = i_stream_next_line(conn->input)) == NULL) return 0; + cmds = array_get(&conn->cmd_send_queue, &cmds_count); if (conn->idle_plus_waiting) { /* "+ idling" reply for IDLE command */ conn->idle_plus_waiting = FALSE; conn->idling = TRUE; - } else if (array_count(&conn->cmd_send_queue) > 0) { + } else if (cmds_count > 0 && cmds[0]->wait_for_literal) { /* reply for literal */ - cmd_p = array_idx(&conn->cmd_send_queue, 0); - imapc_command_send_more(conn, *cmd_p); + cmds[0]->wait_for_literal = FALSE; + imapc_command_send_more(conn, cmds[0]); } else { imapc_connection_input_error(conn, "Unexpected '+': %s", line); return -1; @@ -1356,6 +1360,7 @@ unsigned int seek_pos, start_pos, end_pos, size; int ret; + i_assert(!cmd->wait_for_literal); i_assert(cmd->send_pos < cmd->data->used); timeout_reset(conn->to_output); @@ -1393,6 +1398,8 @@ i_assert(!array_is_created(&cmd->streams) || array_count(&cmd->streams) == 0); imapc_command_send_done(conn, cmd); + } else { + cmd->wait_for_literal = TRUE; } } @@ -1460,7 +1467,8 @@ cmds = array_get(&conn->cmd_send_queue, &count); if (count > 0) { - if (imapc_command_get_sending_stream(cmds[0]) != NULL) { + if (imapc_command_get_sending_stream(cmds[0]) != NULL && + !cmds[0]->wait_for_literal) { /* we're sending a stream. send more. */ imapc_command_send_more(conn, cmds[0]); } From dovecot at dovecot.org Wed Sep 21 17:52:19 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Sep 2011 17:52:19 +0300 Subject: dovecot-2.1: Added new mail_location setting "UTF8" to use UTF-8... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fbbf2802e11f changeset: 13537:fbbf2802e11f user: Timo Sirainen date: Wed Sep 21 17:51:59 2011 +0300 description: Added new mail_location setting "UTF8" to use UTF-8 instead of mUTF-7 in storage names. This basically changes mailbox names to be UTF-8 everywhere where they are mUTF-7 currently (filesystem, subscriptions, etc.) diffstat: src/lib-storage/mailbox-list.c | 27 +++++++++++++++++++-------- src/lib-storage/mailbox-list.h | 2 ++ 2 files changed, 21 insertions(+), 8 deletions(-) diffs (87 lines): diff -r 9a42e3690b1b -r fbbf2802e11f src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Wed Sep 21 16:18:19 2011 +0300 +++ b/src/lib-storage/mailbox-list.c Wed Sep 21 17:51:59 2011 +0300 @@ -14,6 +14,7 @@ #include "write-full.h" #include "safe-mkstemp.h" #include "unlink-directory.h" +#include "unichar.h" #include "settings-parser.h" #include "imap-match.h" #include "imap-utf7.h" @@ -185,6 +186,7 @@ list->set.mailbox_dir_name = p_strconcat(list->pool, set->mailbox_dir_name, "/", NULL); } + list->set.utf8 = set->utf8; if (ns->mail_set->mail_debug) { i_debug("%s: root=%s, index=%s, control=%s, inbox=%s, alt=%s", @@ -281,6 +283,11 @@ while (*tmp != NULL) { str = split_next_arg(&tmp); + if (strcmp(str, "UTF-8") == 0) { + set_r->utf8 = TRUE; + continue; + } + value = strchr(str, '='); if (value == NULL) { key = str; @@ -421,11 +428,13 @@ } } - /* UTF-8 -> mUTF-7 conversion */ - str = t_str_new(strlen(storage_name)*2); - if (imap_utf8_to_utf7(storage_name, str) < 0) - i_panic("Mailbox name not UTF-8: %s", vname); - storage_name = str_c(str); + if (!list->set.utf8) { + /* UTF-8 -> mUTF-7 conversion */ + str = t_str_new(strlen(storage_name)*2); + if (imap_utf8_to_utf7(storage_name, str) < 0) + i_panic("Mailbox name not UTF-8: %s", vname); + storage_name = str_c(str); + } list_sep = mailbox_list_get_hierarchy_sep(list); ns_sep = mail_namespace_get_sep(ns); @@ -505,7 +514,7 @@ return t_strndup(list->ns->prefix, list->ns->prefix_len - 1); } - } else { + } else if (!list->set.utf8) { /* mUTF-7 -> UTF-8 conversion */ string_t *str = t_str_new(strlen(vname)); if (imap_utf7_to_utf8(vname, str) == 0) @@ -885,11 +894,13 @@ /* safer to just disallow all control characters */ for (p = name; *p != '\0'; p++) { - if (*p < ' ') + if ((unsigned char)*p < ' ') return FALSE; } - T_BEGIN { + if (list->set.utf8) + ret = uni_utf8_str_is_valid(name) ? 0 : -1; + else T_BEGIN { string_t *str = t_str_new(256); ret = imap_utf7_to_utf8(name, str); } T_END; diff -r 9a42e3690b1b -r fbbf2802e11f src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Wed Sep 21 16:18:19 2011 +0300 +++ b/src/lib-storage/mailbox-list.h Wed Sep 21 17:51:59 2011 +0300 @@ -135,6 +135,8 @@ /* Encode "bad" characters in mailbox names as */ char escape_char; + /* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */ + bool utf8; }; struct mailbox_info { From dovecot at dovecot.org Thu Sep 22 01:38:50 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 01:38:50 +0300 Subject: dovecot-2.0: login: "cert required, client didn't start TLS" err... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/956bfcc89dea changeset: 12935:956bfcc89dea user: Timo Sirainen date: Thu Sep 22 01:38:34 2011 +0300 description: login: "cert required, client didn't start TLS" error could have been logged wrongly. diffstat: src/login-common/client-common.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 6b7242ead6ed -r 956bfcc89dea src/login-common/client-common.c --- a/src/login-common/client-common.c Mon Sep 19 14:25:29 2011 +0300 +++ b/src/login-common/client-common.c Thu Sep 22 01:38:34 2011 +0300 @@ -511,7 +511,8 @@ /* some auth attempts without SSL/TLS */ if (client->auth_tried_disabled_plaintext) return "(tried to use disabled plaintext auth)"; - if (client->set->auth_ssl_require_client_cert) + if (client->set->auth_ssl_require_client_cert && + client->ssl_proxy == NULL) return "(cert required, client didn't start TLS)"; if (client->auth_tried_unsupported_mech) return "(tried to use unsupported auth mechanism)"; From dovecot at dovecot.org Thu Sep 22 01:39:11 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 01:39:11 +0300 Subject: dovecot-2.1: login: "cert required, client didn't start TLS" err... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e19a3a2d554d changeset: 13538:e19a3a2d554d user: Timo Sirainen date: Thu Sep 22 01:38:34 2011 +0300 description: login: "cert required, client didn't start TLS" error could have been logged wrongly. diffstat: src/login-common/client-common.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r fbbf2802e11f -r e19a3a2d554d src/login-common/client-common.c --- a/src/login-common/client-common.c Wed Sep 21 17:51:59 2011 +0300 +++ b/src/login-common/client-common.c Thu Sep 22 01:38:34 2011 +0300 @@ -511,7 +511,8 @@ /* some auth attempts without SSL/TLS */ if (client->auth_tried_disabled_plaintext) return "(tried to use disabled plaintext auth)"; - if (client->set->auth_ssl_require_client_cert) + if (client->set->auth_ssl_require_client_cert && + client->ssl_proxy == NULL) return "(cert required, client didn't start TLS)"; if (client->auth_tried_unsupported_mech) return "(tried to use unsupported auth mechanism)"; From dovecot at dovecot.org Thu Sep 22 12:54:41 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 12:54:41 +0300 Subject: dovecot-2.1: login: Added -R parameter to write pre-login ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1ff636720b9f changeset: 13539:1ff636720b9f user: Timo Sirainen date: Thu Sep 22 12:54:27 2011 +0300 description: login: Added -R parameter to write pre-login rawlogs to given directory. diffstat: src/login-common/client-common.c | 7 +++++++ src/login-common/login-common.h | 1 + src/login-common/main.c | 14 +++++++++++++- 3 files changed, 21 insertions(+), 1 deletions(-) diffs (80 lines): diff -r e19a3a2d554d -r 1ff636720b9f src/login-common/client-common.c --- a/src/login-common/client-common.c Thu Sep 22 01:38:34 2011 +0300 +++ b/src/login-common/client-common.c Thu Sep 22 12:54:27 2011 +0300 @@ -5,6 +5,7 @@ #include "llist.h" #include "istream.h" #include "ostream.h" +#include "iostream-rawlog.h" #include "process-title.h" #include "str.h" #include "str-sanitize.h" @@ -36,6 +37,12 @@ i_stream_create_fd(client->fd, LOGIN_MAX_INBUF_SIZE, FALSE); client->output = o_stream_create_fd(client->fd, LOGIN_MAX_OUTBUF_SIZE, FALSE); + + if (login_rawlog_dir != NULL) { + if (iostream_rawlog_create(login_rawlog_dir, &client->input, + &client->output) < 0) + login_rawlog_dir = NULL; + } } struct client * diff -r e19a3a2d554d -r 1ff636720b9f src/login-common/login-common.h --- a/src/login-common/login-common.h Thu Sep 22 01:38:34 2011 +0300 +++ b/src/login-common/login-common.h Thu Sep 22 12:54:27 2011 +0300 @@ -34,6 +34,7 @@ extern struct master_auth *master_auth; extern bool closing_down; extern struct anvil_client *anvil; +extern const char *login_rawlog_dir; extern const struct login_settings *global_login_settings; extern void **global_other_settings; diff -r e19a3a2d554d -r 1ff636720b9f src/login-common/main.c --- a/src/login-common/main.c Thu Sep 22 01:38:34 2011 +0300 +++ b/src/login-common/main.c Thu Sep 22 12:54:27 2011 +0300 @@ -36,6 +36,7 @@ struct master_auth *master_auth; bool closing_down; struct anvil_client *anvil; +const char *login_rawlog_dir = NULL; const struct login_settings *global_login_settings; void **global_other_settings; @@ -297,6 +298,13 @@ i_fatal("chdir(login) failed: %m"); } + if (login_rawlog_dir != NULL && + access(login_rawlog_dir, W_OK | X_OK) < 0) { + i_error("access(%s, wx) failed: %m - disabling rawlog", + login_rawlog_dir); + login_rawlog_dir = NULL; + } + master_service_set_avail_overflow_callback(master_service, client_destroy_oldest); master_service_set_die_callback(master_service, login_die); @@ -340,7 +348,8 @@ login_binary = binary; master_service = master_service_init(login_binary->process_name, - service_flags, &argc, &argv, "DS"); + service_flags, &argc, &argv, + "DR:S"); master_service_init_log(master_service, t_strconcat( login_binary->process_name, ": ", NULL)); @@ -349,6 +358,9 @@ case 'D': allow_core_dumps = TRUE; break; + case 'R': + login_rawlog_dir = optarg; + break; case 'S': ssl_connections = TRUE; break; From dovecot at dovecot.org Thu Sep 22 13:09:29 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 13:09:29 +0300 Subject: dovecot-2.1: lib-mail: Added broken input workaround to rfc822_p... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/00b6848a5a63 changeset: 13540:00b6848a5a63 user: Timo Sirainen date: Thu Sep 22 13:09:18 2011 +0300 description: lib-mail: Added broken input workaround to rfc822_parse_content_param(). diffstat: src/lib-mail/rfc822-parser.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diffs (19 lines): diff -r 1ff636720b9f -r 00b6848a5a63 src/lib-mail/rfc822-parser.c --- a/src/lib-mail/rfc822-parser.c Thu Sep 22 12:54:27 2011 +0300 +++ b/src/lib-mail/rfc822-parser.c Thu Sep 22 13:09:18 2011 +0300 @@ -408,6 +408,15 @@ } else if (*ctx->data == '"') { ret = rfc822_parse_quoted_string(ctx, tmp); str_unescape(str_c_modifiable(tmp) + value_pos); + } else if (ctx->data != ctx->end && *ctx->data == '=') { + /* workaround for broken input: + name==?utf-8?b?...?= */ + while (ctx->data != ctx->end && *ctx->data != ';' && + *ctx->data != ' ' && *ctx->data != '\t' && + *ctx->data != '\r' && *ctx->data != '\n') { + str_append_c(tmp, *ctx->data); + ctx->data++; + } } else { ret = rfc822_parse_mime_token(ctx, tmp); } From dovecot at dovecot.org Thu Sep 22 13:10:21 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 13:10:21 +0300 Subject: dovecot-2.0: lib-mail: Added broken input workaround to rfc822_p... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/dc9028da338b changeset: 12936:dc9028da338b user: Timo Sirainen date: Thu Sep 22 13:09:18 2011 +0300 description: lib-mail: Added broken input workaround to rfc822_parse_content_param(). diffstat: src/lib-mail/rfc822-parser.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diffs (19 lines): diff -r 956bfcc89dea -r dc9028da338b src/lib-mail/rfc822-parser.c --- a/src/lib-mail/rfc822-parser.c Thu Sep 22 01:38:34 2011 +0300 +++ b/src/lib-mail/rfc822-parser.c Thu Sep 22 13:09:18 2011 +0300 @@ -408,6 +408,15 @@ } else if (*ctx->data == '"') { ret = rfc822_parse_quoted_string(ctx, tmp); str_unescape(str_c_modifiable(tmp) + value_pos); + } else if (ctx->data != ctx->end && *ctx->data == '=') { + /* workaround for broken input: + name==?utf-8?b?...?= */ + while (ctx->data != ctx->end && *ctx->data != ';' && + *ctx->data != ' ' && *ctx->data != '\t' && + *ctx->data != '\r' && *ctx->data != '\n') { + str_append_c(tmp, *ctx->data); + ctx->data++; + } } else { ret = rfc822_parse_mime_token(ctx, tmp); } From dovecot at dovecot.org Thu Sep 22 14:24:16 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 14:24:16 +0300 Subject: dovecot-2.1: imapc: Allow accessing a mail that is being saved w... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b6633cb57814 changeset: 13542:b6633cb57814 user: Timo Sirainen date: Thu Sep 22 14:24:03 2011 +0300 description: imapc: Allow accessing a mail that is being saved without crashing. This fixes crashes with LDA, LMTP, mail_log plugin, etc. diffstat: src/lib-storage/index/imapc/imapc-mail-fetch.c | 76 +++++++++++++++---------- src/lib-storage/index/imapc/imapc-mail.c | 2 +- src/lib-storage/index/imapc/imapc-mail.h | 1 + src/lib-storage/index/imapc/imapc-save.c | 60 ++++++++++++++++++-- 4 files changed, 101 insertions(+), 38 deletions(-) diffs (280 lines): diff -r 645a56f9d8ee -r b6633cb57814 src/lib-storage/index/imapc/imapc-mail-fetch.c --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Thu Sep 22 14:21:56 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Thu Sep 22 14:24:03 2011 +0300 @@ -67,6 +67,12 @@ if (fields == 0) return 0; + if (_mail->saving) { + mail_storage_set_critical(_mail->box->storage, + "Can't fetch data from uncommitted message"); + return -1; + } + /* if we already know that the mail is expunged, don't try to FETCH it */ view = mbox->delayed_sync_view != NULL ? @@ -200,17 +206,50 @@ *input = filter_input; } +void imapc_mail_init_stream(struct imapc_mail *mail, bool have_body) +{ + struct index_mail *imail = &mail->imail; + struct mail *_mail = &imail->mail.mail; + struct istream *input; + uoff_t size; + int ret; + + i_stream_set_name(imail->data.stream, + t_strdup_printf("imapc mail uid=%u", _mail->uid)); + index_mail_set_read_buffer_size(_mail, imail->data.stream); + + imapc_stream_filter(&imail->data.stream); + if (imail->mail.v.istream_opened != NULL) { + if (imail->mail.v.istream_opened(_mail, + &imail->data.stream) < 0) { + i_stream_unref(&imail->data.stream); + return; + } + } else if (have_body) { + ret = i_stream_get_size(imail->data.stream, TRUE, &size); + if (ret < 0) { + i_stream_unref(&imail->data.stream); + return; + } + i_assert(ret != 0); + imail->data.physical_size = size; + /* we'll assume that the remote server is working properly and + sending CRLF linefeeds */ + imail->data.virtual_size = size; + } + + if (index_mail_init_stream(imail, NULL, NULL, &input) < 0) + i_stream_unref(&imail->data.stream); +} + static void imapc_fetch_stream(struct imapc_mail *mail, const struct imapc_untagged_reply *reply, const struct imap_arg *arg, bool body) { struct index_mail *imail = &mail->imail; - struct mail *_mail = &imail->mail.mail; - struct istream *input; - uoff_t size; const char *value; - int fd, ret; + int fd; if (imail->data.stream != NULL) { if (!body) @@ -231,7 +270,7 @@ if (!imap_arg_get_nstring(arg, &value)) return; if (value == NULL) { - mail_set_expunged(_mail); + mail_set_expunged(&imail->mail.mail); return; } if (mail->body == NULL) { @@ -244,32 +283,7 @@ mail->body->used); } - i_stream_set_name(imail->data.stream, - t_strdup_printf("imapc mail uid=%u", _mail->uid)); - index_mail_set_read_buffer_size(_mail, imail->data.stream); - - imapc_stream_filter(&imail->data.stream); - if (imail->mail.v.istream_opened != NULL) { - if (imail->mail.v.istream_opened(_mail, - &imail->data.stream) < 0) { - i_stream_unref(&imail->data.stream); - return; - } - } else if (body) { - ret = i_stream_get_size(imail->data.stream, TRUE, &size); - if (ret < 0) { - i_stream_unref(&imail->data.stream); - return; - } - i_assert(ret != 0); - imail->data.physical_size = size; - /* we'll assume that the remote server is working properly and - sending CRLF linefeeds */ - imail->data.virtual_size = size; - } - - if (index_mail_init_stream(imail, NULL, NULL, &input) < 0) - i_stream_unref(&imail->data.stream); + imapc_mail_init_stream(mail, body); } void imapc_mail_fetch_update(struct imapc_mail *mail, diff -r 645a56f9d8ee -r b6633cb57814 src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Thu Sep 22 14:21:56 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Thu Sep 22 14:24:03 2011 +0300 @@ -218,7 +218,7 @@ } /* searching code handles prefetching internally, elsewhere we want to do it immediately */ - if (!mail->search_mail) + if (!mail->search_mail && !_mail->saving) (void)imapc_mail_prefetch(_mail); } diff -r 645a56f9d8ee -r b6633cb57814 src/lib-storage/index/imapc/imapc-mail.h --- a/src/lib-storage/index/imapc/imapc-mail.h Thu Sep 22 14:21:56 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.h Thu Sep 22 14:24:03 2011 +0300 @@ -23,6 +23,7 @@ struct mailbox_header_lookup_ctx *wanted_headers); int imapc_mail_fetch(struct mail *mail, enum mail_fetch_field fields); bool imapc_mail_prefetch(struct mail *mail); +void imapc_mail_init_stream(struct imapc_mail *mail, bool have_body); void imapc_mail_fetch_update(struct imapc_mail *mail, const struct imapc_untagged_reply *reply, diff -r 645a56f9d8ee -r b6633cb57814 src/lib-storage/index/imapc/imapc-save.c --- a/src/lib-storage/index/imapc/imapc-save.c Thu Sep 22 14:21:56 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-save.c Thu Sep 22 14:24:03 2011 +0300 @@ -12,6 +12,7 @@ #include "imapc-client.h" #include "imapc-storage.h" #include "imapc-sync.h" +#include "imapc-mail.h" struct imapc_save_context { struct mail_save_context ctx; @@ -25,6 +26,7 @@ uint32_t dest_uid_validity; ARRAY_TYPE(seq_range) dest_saved_uids; + unsigned int save_count; unsigned int failed:1; unsigned int finished:1; @@ -103,11 +105,14 @@ } static void imapc_save_appenduid(struct imapc_save_context *ctx, - const struct imapc_command_reply *reply) + const struct imapc_command_reply *reply, + uint32_t *uid_r) { const char *const *args; uint32_t uid_validity, dest_uid; + *uid_r = 0; + /* */ args = t_strsplit(reply->resp_text_value, " "); if (str_array_length(args) != 2) @@ -120,18 +125,48 @@ else if (ctx->dest_uid_validity != uid_validity) return; - if (str_to_uint32(args[1], &dest_uid) == 0) + if (str_to_uint32(args[1], &dest_uid) == 0) { seq_range_array_add(&ctx->dest_saved_uids, 0, dest_uid); + *uid_r = dest_uid; + } +} + +static void +imapc_save_add_to_index(struct imapc_save_context *ctx, uint32_t uid) +{ + struct mail *_mail = ctx->ctx.dest_mail; + struct index_mail *imail = (struct index_mail *)_mail; + uint32_t seq; + + if (_mail == NULL) + return; + + /* we'll temporarily append messages and at commit time expunge + them all, since we can't guarantee that no one else has saved + messages to remote server during our transaction */ + mail_index_append(ctx->trans, uid, &seq); + mail_set_seq_saving(_mail, seq); + imail->data.forced_no_caching = TRUE; + + if (ctx->fd != -1) { + imail->data.stream = i_stream_create_fd(ctx->fd, 0, TRUE); + imapc_mail_init_stream((struct imapc_mail *)imail, TRUE); + ctx->fd = -1; + } + + ctx->save_count++; } static void imapc_save_callback(const struct imapc_command_reply *reply, void *context) { struct imapc_save_cmd_context *ctx = context; + uint32_t uid = 0; if (reply->state == IMAPC_COMMAND_STATE_OK) { if (strcasecmp(reply->resp_text_key, "APPENDUID") == 0) - imapc_save_appenduid(ctx->ctx, reply); + imapc_save_appenduid(ctx->ctx, reply, &uid); + imapc_save_add_to_index(ctx->ctx, uid); ctx->ret = 0; } else if (reply->state == IMAPC_COMMAND_STATE_NO) { imapc_copy_error_from_reply(ctx->ctx->mbox->storage, @@ -245,9 +280,15 @@ struct imapc_save_context *ctx = (struct imapc_save_context *)_ctx; struct mail_transaction_commit_changes *changes = _ctx->transaction->changes; + uint32_t i, last_seq; i_assert(ctx->finished); + /* expunge all added messages from index before commit */ + last_seq = mail_index_view_get_messages_count(ctx->trans->view); + for (i = 0; i < ctx->save_count; i++) + mail_index_expunge(ctx->trans, last_seq - i); + if (array_is_created(&ctx->dest_saved_uids)) { changes->uid_validity = ctx->dest_uid_validity; array_append_array(&changes->saved_uids, &ctx->dest_saved_uids); @@ -277,11 +318,14 @@ } static void imapc_save_copyuid(struct imapc_save_context *ctx, - const struct imapc_command_reply *reply) + const struct imapc_command_reply *reply, + uint32_t *uid_r) { const char *const *args; uint32_t uid_validity, dest_uid; + *uid_r = 0; + /* */ args = t_strsplit(reply->resp_text_value, " "); if (str_array_length(args) != 3) @@ -294,18 +338,22 @@ else if (ctx->dest_uid_validity != uid_validity) return; - if (str_to_uint32(args[2], &dest_uid) == 0) + if (str_to_uint32(args[2], &dest_uid) == 0) { seq_range_array_add(&ctx->dest_saved_uids, 0, dest_uid); + *uid_r = dest_uid; + } } static void imapc_copy_callback(const struct imapc_command_reply *reply, void *context) { struct imapc_save_cmd_context *ctx = context; + uint32_t uid = 0; if (reply->state == IMAPC_COMMAND_STATE_OK) { if (strcasecmp(reply->resp_text_key, "COPYUID") == 0) - imapc_save_copyuid(ctx->ctx, reply); + imapc_save_copyuid(ctx->ctx, reply, &uid); + imapc_save_add_to_index(ctx->ctx, uid); ctx->ret = 0; } else if (reply->state == IMAPC_COMMAND_STATE_NO) { imapc_copy_error_from_reply(ctx->ctx->mbox->storage, From dovecot at dovecot.org Thu Sep 22 14:24:16 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 14:24:16 +0300 Subject: dovecot-2.1: iampc: Small code cleanup. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/645a56f9d8ee changeset: 13541:645a56f9d8ee user: Timo Sirainen date: Thu Sep 22 14:21:56 2011 +0300 description: iampc: Small code cleanup. diffstat: src/lib-storage/index/imapc/imapc-mailbox.c | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 37 +++++++++++++++++----------- src/lib-storage/index/imapc/imapc-storage.h | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diffs (88 lines): diff -r 00b6848a5a63 -r 645a56f9d8ee src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Thu Sep 22 13:09:18 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Thu Sep 22 14:21:56 2011 +0300 @@ -116,7 +116,7 @@ if (view == NULL) view = imapc_mailbox_get_sync_view(mbox); - if (mbox->opening) { + if (mbox->selecting) { /* We don't know the latest flags, refresh them. */ mbox->sync_fetch_first_uid = 1; } else if (mbox->sync_fetch_first_uid != 1) { diff -r 00b6848a5a63 -r 645a56f9d8ee src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Thu Sep 22 13:09:18 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Thu Sep 22 14:21:56 2011 +0300 @@ -382,11 +382,30 @@ imapc_client_stop(ctx->mbox->storage->client); } +static int imapc_mailbox_select(struct imapc_mailbox *mbox) +{ + struct imapc_open_context ctx; + bool examine; + + examine = (mbox->box.flags & MAILBOX_FLAG_READONLY) != 0 && + (mbox->box.flags & MAILBOX_FLAG_DROP_RECENT) == 0; + + mbox->selecting = TRUE; + ctx.mbox = mbox; + ctx.ret = -2; + mbox->client_box = + imapc_client_mailbox_open(mbox->storage->client, mbox->box.name, + examine, imapc_mailbox_open_callback, + &ctx, mbox); + while (ctx.ret == -2) + imapc_storage_run(mbox->storage); + mbox->selecting = FALSE; + return ctx.ret; +} + static int imapc_mailbox_open(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; - struct imapc_open_context ctx; - bool examine; if (index_storage_mailbox_open(box, FALSE) < 0) return -1; @@ -395,8 +414,6 @@ /* We don't actually want to SELECT the mailbox. */ return 0; } - examine = (box->flags & MAILBOX_FLAG_READONLY) != 0 && - (box->flags & MAILBOX_FLAG_DROP_RECENT) == 0; if (*box->name == '\0' && (box->list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) { @@ -408,17 +425,7 @@ return -1; } - mbox->opening = TRUE; - ctx.mbox = mbox; - ctx.ret = -2; - mbox->client_box = - imapc_client_mailbox_open(mbox->storage->client, box->name, - examine, imapc_mailbox_open_callback, - &ctx, mbox); - while (ctx.ret == -2) - imapc_storage_run(mbox->storage); - mbox->opening = FALSE; - if (ctx.ret < 0) { + if (imapc_mailbox_select(mbox) < 0) { mailbox_close(box); return -1; } diff -r 00b6848a5a63 -r 645a56f9d8ee src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Thu Sep 22 13:09:18 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Thu Sep 22 14:21:56 2011 +0300 @@ -68,7 +68,7 @@ uint32_t prev_skipped_rseq, prev_skipped_uid; - unsigned int opening:1; + unsigned int selecting:1; unsigned int syncing:1; unsigned int initial_sync_done:1; }; From dovecot at dovecot.org Thu Sep 22 14:32:19 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 22 Sep 2011 14:32:19 +0300 Subject: dovecot-2.1: imapc: Fix to previous message saving change. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/43df6495edb8 changeset: 13543:43df6495edb8 user: Timo Sirainen date: Thu Sep 22 14:31:57 2011 +0300 description: imapc: Fix to previous message saving change. diffstat: src/lib-storage/index/imapc/imapc-save.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r b6633cb57814 -r 43df6495edb8 src/lib-storage/index/imapc/imapc-save.c --- a/src/lib-storage/index/imapc/imapc-save.c Thu Sep 22 14:24:03 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-save.c Thu Sep 22 14:31:57 2011 +0300 @@ -285,7 +285,7 @@ i_assert(ctx->finished); /* expunge all added messages from index before commit */ - last_seq = mail_index_view_get_messages_count(ctx->trans->view); + last_seq = mail_index_view_get_messages_count(_ctx->transaction->view); for (i = 0; i < ctx->save_count; i++) mail_index_expunge(ctx->trans, last_seq - i); From dovecot at dovecot.org Fri Sep 23 00:00:27 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 00:00:27 +0300 Subject: dovecot-2.1: fts: Fixed running attachment decoder scripts. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2b219b549007 changeset: 13544:2b219b549007 user: Timo Sirainen date: Thu Sep 22 23:59:48 2011 +0300 description: fts: Fixed running attachment decoder scripts. diffstat: src/plugins/fts/fts-parser-script.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diffs (71 lines): diff -r 43df6495edb8 -r 2b219b549007 src/plugins/fts/fts-parser-script.c --- a/src/plugins/fts/fts-parser-script.c Thu Sep 22 14:31:57 2011 +0300 +++ b/src/plugins/fts/fts-parser-script.c Thu Sep 22 23:59:48 2011 +0300 @@ -108,10 +108,11 @@ static bool script_support_content(struct mail_user *user, const char **content_type, - const char *extension) + const char *filename) { struct fts_parser_script_user *suser = SCRIPT_USER_CONTEXT(user); const struct content *content; + const char *extension; if (suser == NULL) { suser = p_new(user->pool, struct fts_parser_script_user, 1); @@ -123,9 +124,13 @@ return FALSE; } - if (strcmp(*content_type, "application/octet-stream") != 0) { + if (strcmp(*content_type, "application/octet-stream") == 0) { + if (filename == NULL) + return FALSE; + extension = strrchr(filename, '.'); if (extension == NULL) return FALSE; + extension = filename + 1; array_foreach(&suser->content, content) { if (content->extensions != NULL && @@ -144,13 +149,13 @@ } static void parse_content_disposition(const char *content_disposition, - const char **extension_r) + const char **filename_r) { struct rfc822_parser_context parser; const char *const *results; string_t *str; - *extension_r = NULL; + *filename_r = NULL; if (content_disposition == NULL) return; @@ -167,7 +172,7 @@ (void)rfc2231_parse(&parser, &results); for (; *results != NULL; results += 2) { if (strcasecmp(results[0], "filename") == 0) { - *extension_r = results[1]; + *filename_r = results[1]; break; } } @@ -179,11 +184,11 @@ const char *content_disposition) { struct script_fts_parser *parser; - const char *extension, *path, *cmd; + const char *filename, *path, *cmd; int fd; - parse_content_disposition(content_disposition, &extension); - if (script_support_content(user, &content_type, extension) <= 0) + parse_content_disposition(content_disposition, &filename); + if (script_support_content(user, &content_type, filename) <= 0) return NULL; fd = script_connect(user, &path); From dovecot at dovecot.org Fri Sep 23 00:04:26 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 00:04:26 +0300 Subject: dovecot-2.1: fts: Support also RFC 2231 style parsing when findi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e932f81eba48 changeset: 13545:e932f81eba48 user: Timo Sirainen date: Fri Sep 23 00:04:11 2011 +0300 description: fts: Support also RFC 2231 style parsing when finding the attachment filename. diffstat: src/plugins/fts/fts-parser-script.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diffs (32 lines): diff -r 2b219b549007 -r e932f81eba48 src/plugins/fts/fts-parser-script.c --- a/src/plugins/fts/fts-parser-script.c Thu Sep 22 23:59:48 2011 +0300 +++ b/src/plugins/fts/fts-parser-script.c Fri Sep 23 00:04:11 2011 +0300 @@ -152,7 +152,7 @@ const char **filename_r) { struct rfc822_parser_context parser; - const char *const *results; + const char *const *results, *filename2; string_t *str; *filename_r = NULL; @@ -170,11 +170,19 @@ return; (void)rfc2231_parse(&parser, &results); + filename2 = NULL; for (; *results != NULL; results += 2) { if (strcasecmp(results[0], "filename") == 0) { *filename_r = results[1]; break; } + if (strcasecmp(results[0], "filename*") == 0) + filename2 = results[1]; + } + if (*filename_r == NULL) { + /* RFC 2231 style non-ascii filename. we don't really care + much about the filename actually, just about its extension */ + *filename_r = filename2; } } From dovecot at dovecot.org Fri Sep 23 00:46:29 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 00:46:29 +0300 Subject: dovecot-2.1: doveadm server: Previous non-authentication fix bro... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/46e90b44d378 changeset: 13546:46e90b44d378 user: Timo Sirainen date: Fri Sep 23 00:46:19 2011 +0300 description: doveadm server: Previous non-authentication fix broken authentication. diffstat: src/doveadm/server-connection.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diffs (38 lines): diff -r e932f81eba48 -r 46e90b44d378 src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Fri Sep 23 00:04:11 2011 +0300 +++ b/src/doveadm/server-connection.c Fri Sep 23 00:46:19 2011 +0300 @@ -189,7 +189,6 @@ str_append_c(cmd, '\n'); o_stream_send(conn->output, cmd->data, cmd->used); - server_connection_authenticated(conn); return 0; } @@ -214,6 +213,7 @@ server_connection_destroy(&conn); return; } + return; } else { i_error("doveadm server sent invalid handshake: %s", line); @@ -228,6 +228,18 @@ return; } + if (!conn->authenticated) { + if ((line = i_stream_next_line(conn->input)) == NULL) + return; + if (strcmp(line, "+") == 0) + server_connection_authenticated(conn); + else { + i_error("doveadm authentication failed (%s)", line+1); + server_connection_destroy(&conn); + return; + } + } + data = i_stream_get_data(conn->input, &size); if (size == 0) return; From dovecot at dovecot.org Fri Sep 23 00:50:00 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 00:50:00 +0300 Subject: dovecot-2.1: lib-storage: mail_namespace_find_unalias() crashed ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ed97724884a2 changeset: 13547:ed97724884a2 user: Timo Sirainen date: Fri Sep 23 00:49:51 2011 +0300 description: lib-storage: mail_namespace_find_unalias() crashed when namespace wasn't found. diffstat: src/lib-storage/mail-namespace.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 46e90b44d378 -r ed97724884a2 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Fri Sep 23 00:46:19 2011 +0300 +++ b/src/lib-storage/mail-namespace.c Fri Sep 23 00:49:51 2011 +0300 @@ -588,7 +588,7 @@ const char *storage_name; ns = mail_namespace_find(namespaces, *mailbox); - if (ns->alias_for != NULL) { + if (ns != NULL && ns->alias_for != NULL) { storage_name = mailbox_list_get_storage_name(ns->list, *mailbox); ns = ns->alias_for; From dovecot at dovecot.org Fri Sep 23 14:52:58 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 14:52:58 +0300 Subject: dovecot-2.1: maildir: Don't always drop new flag from files when... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f24550491039 changeset: 13548:f24550491039 user: Timo Sirainen date: Fri Sep 23 14:38:24 2011 +0300 description: maildir: Don't always drop new flag from files when syncing. diffstat: src/lib-storage/index/maildir/maildir-uidlist.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (15 lines): diff -r ed97724884a2 -r f24550491039 src/lib-storage/index/maildir/maildir-uidlist.c --- a/src/lib-storage/index/maildir/maildir-uidlist.c Fri Sep 23 00:49:51 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Fri Sep 23 14:38:24 2011 +0300 @@ -1688,9 +1688,9 @@ } } + rec->flags &= ~MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; rec->flags = (rec->flags | flags) & - ~(MAILDIR_UIDLIST_REC_FLAG_NONSYNCED | - MAILDIR_UIDLIST_REC_FLAG_NEW_DIR); + ~MAILDIR_UIDLIST_REC_FLAG_NONSYNCED; rec->filename = p_strdup(uidlist->record_pool, filename); hash_table_insert(uidlist->files, rec->filename, rec); From dovecot at dovecot.org Fri Sep 23 14:52:58 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 14:52:58 +0300 Subject: dovecot-2.1: maildir: Improved guessing filename when it's still... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b3111bbbaf22 changeset: 13549:b3111bbbaf22 user: Timo Sirainen date: Fri Sep 23 14:52:46 2011 +0300 description: maildir: Improved guessing filename when it's still in new/ dir. diffstat: src/lib-storage/index/maildir/maildir-util.c | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diffs (56 lines): diff -r f24550491039 -r b3111bbbaf22 src/lib-storage/index/maildir/maildir-util.c --- a/src/lib-storage/index/maildir/maildir-util.c Fri Sep 23 14:38:24 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-util.c Fri Sep 23 14:52:46 2011 +0300 @@ -23,13 +23,16 @@ static const char * maildir_filename_guess(struct maildir_mailbox *mbox, uint32_t uid, - const char *fname, bool *have_flags_r) + const char *fname, + enum maildir_uidlist_rec_flag *uidlist_flags, + bool *have_flags_r) { struct mail_index_view *view = mbox->flags_view; struct maildir_keywords_sync_ctx *kw_ctx; enum mail_flags flags; ARRAY_TYPE(keyword_indexes) keywords; + const char *p; uint32_t seq; if (view == NULL || !mail_index_lookup_seq(view, uid, &seq)) { @@ -50,6 +53,20 @@ flags, &keywords); maildir_keywords_sync_deinit(&kw_ctx); } + + if (*have_flags_r) { + /* don't even bother looking into new/ dir */ + *uidlist_flags &= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; + } else if ((*uidlist_flags & MAILDIR_UIDLIST_REC_FLAG_MOVED) == 0 && + ((*uidlist_flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0 || + index_mailbox_is_recent(&mbox->box, uid))) { + /* probably in new/ dir, drop ":2," from fname */ + *uidlist_flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; + p = strrchr(fname, MAILDIR_INFO_SEP); + if (p != NULL) + fname = t_strdup_until(fname, p); + } + return fname; } @@ -67,11 +84,8 @@ if ((flags & MAILDIR_UIDLIST_REC_FLAG_NONSYNCED) != 0) { /* let's see if we can guess the filename based on index */ - fname = maildir_filename_guess(mbox, uid, fname, &have_flags); - if (have_flags) { - /* don't even bother looking into new/ dir */ - flags &= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; - } + fname = maildir_filename_guess(mbox, uid, fname, + &flags, &have_flags); } if ((flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0) { From dovecot at dovecot.org Fri Sep 23 15:01:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 15:01:33 +0300 Subject: dovecot-2.1: file_dotlock: Don't warn about changed mtime when i... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fecd095394b6 changeset: 13550:fecd095394b6 user: Timo Sirainen date: Fri Sep 23 15:01:23 2011 +0300 description: file_dotlock: Don't warn about changed mtime when it's 1 second. This is mainly to avoid bogus warnings with NFS and its caching. diffstat: src/lib/file-dotlock.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diffs (44 lines): diff -r b3111bbbaf22 -r fecd095394b6 src/lib/file-dotlock.c --- a/src/lib/file-dotlock.c Fri Sep 23 14:52:46 2011 +0300 +++ b/src/lib/file-dotlock.c Fri Sep 23 15:01:23 2011 +0300 @@ -33,6 +33,10 @@ /* Maximum difference between current time and create file's ctime before logging a warning. Should be less than a second in normal operation. */ #define MAX_TIME_DIFF 30 +/* NFS may return a cached mtime in stat(). A later non-cached stat() may + return a slightly different mtime. Allow the difference to be this much + and still consider it to be the same mtime. */ +#define FILE_DOTLOCK_MAX_STAT_MTIME_DIFF 1 struct dotlock { struct dotlock_settings settings; @@ -699,6 +703,19 @@ } } +static bool file_dotlock_has_mtime_changed(time_t t1, time_t t2) +{ + time_t diff; + + if (t1 == t2) + return FALSE; + + /* with NFS t1 may have been looked up from local cache. + allow it to be a little bit different. */ + diff = t1 > t2 ? t1-t2 : t2-t1; + return diff <= FILE_DOTLOCK_MAX_STAT_MTIME_DIFF; +} + int file_dotlock_delete(struct dotlock **dotlock_p) { struct dotlock *dotlock; @@ -729,7 +746,8 @@ return 0; } - if (dotlock->mtime != st.st_mtime && dotlock->fd == -1) { + if (file_dotlock_has_mtime_changed(dotlock->mtime, st.st_mtime) && + dotlock->fd == -1) { i_warning("Our dotlock file %s was modified (%s vs %s), " "assuming it wasn't overridden (kept it %d secs)", lock_path, From dovecot at dovecot.org Fri Sep 23 15:02:10 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 15:02:10 +0300 Subject: dovecot-2.1: file_dotlock: And fix to previous change.. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/df74f0052707 changeset: 13551:df74f0052707 user: Timo Sirainen date: Fri Sep 23 15:01:57 2011 +0300 description: file_dotlock: And fix to previous change.. diffstat: src/lib/file-dotlock.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r fecd095394b6 -r df74f0052707 src/lib/file-dotlock.c --- a/src/lib/file-dotlock.c Fri Sep 23 15:01:23 2011 +0300 +++ b/src/lib/file-dotlock.c Fri Sep 23 15:01:57 2011 +0300 @@ -713,7 +713,7 @@ /* with NFS t1 may have been looked up from local cache. allow it to be a little bit different. */ diff = t1 > t2 ? t1-t2 : t2-t1; - return diff <= FILE_DOTLOCK_MAX_STAT_MTIME_DIFF; + return diff > FILE_DOTLOCK_MAX_STAT_MTIME_DIFF; } int file_dotlock_delete(struct dotlock **dotlock_p) From dovecot at dovecot.org Fri Sep 23 16:07:39 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 23 Sep 2011 16:07:39 +0300 Subject: dovecot-2.1: stats: Make sure unfinished commands get freed when... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/67a545272b3f changeset: 13552:67a545272b3f user: Timo Sirainen date: Fri Sep 23 16:07:29 2011 +0300 description: stats: Make sure unfinished commands get freed when their session disconnects. diffstat: src/stats/mail-command.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diffs (24 lines): diff -r df74f0052707 -r 67a545272b3f src/stats/mail-command.c --- a/src/stats/mail-command.c Fri Sep 23 15:01:57 2011 +0300 +++ b/src/stats/mail-command.c Fri Sep 23 16:07:29 2011 +0300 @@ -153,9 +153,17 @@ void mail_commands_free_memory(void) { - while (stable_mail_commands != NULL && - stable_mail_commands->refcount == 0) { - i_assert(stable_mail_commands->id == 0); + while (stable_mail_commands != NULL) { + struct mail_command *cmd = stable_mail_commands; + + if (cmd->refcount == 0) + i_assert(cmd->id == 0); + else if (cmd->refcount == 1 && cmd->session->disconnected) { + /* session was probably lost */ + mail_command_unref(&cmd); + } else { + break; + } mail_command_free(stable_mail_commands); if (global_used_memory < stats_settings->memory_limit) From dovecot at dovecot.org Sun Sep 25 22:49:48 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 25 Sep 2011 22:49:48 +0300 Subject: dovecot-2.0: doveadm move: Use UTF-8 for destination mailbox name. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/447d20eae931 changeset: 12937:447d20eae931 user: Pascal Volk date: Sun Sep 25 19:52:43 2011 +0000 description: doveadm move: Use UTF-8 for destination mailbox name. diffstat: src/doveadm/doveadm-mail-move.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (29 lines): diff -r dc9028da338b -r 447d20eae931 src/doveadm/doveadm-mail-move.c --- a/src/doveadm/doveadm-mail-move.c Thu Sep 22 13:09:18 2011 +0300 +++ b/src/doveadm/doveadm-mail-move.c Sun Sep 25 19:52:43 2011 +0000 @@ -1,6 +1,8 @@ /* Copyright (c) 2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "str.h" +#include "imap-utf7.h" #include "mail-storage.h" #include "mail-namespace.h" #include "doveadm-print.h" @@ -112,10 +114,16 @@ { struct move_cmd_context *ctx = (struct move_cmd_context *)_ctx; const char *destname = args[0]; + string_t *str; if (destname == NULL || args[1] == NULL) doveadm_mail_help_name("move"); + str = t_str_new(128); + if (imap_utf8_to_utf7(destname, str) < 0) + i_fatal("Mailbox name not valid UTF-8: %s", destname); + destname = str_c(str); + ctx->destname = p_strdup(ctx->ctx.pool, destname); ctx->ctx.search_args = doveadm_mail_build_search_args(args + 1); expunge_search_args_check(ctx->ctx.search_args, "move"); From dovecot at dovecot.org Mon Sep 26 01:25:09 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 Sep 2011 01:25:09 +0300 Subject: dovecot-2.0: man: Added doveadm move. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/c194c76b98ff changeset: 12938:c194c76b98ff user: Pascal Volk date: Sun Sep 25 22:32:04 2011 +0000 description: man: Added doveadm move. diffstat: .hgignore | 2 +- doc/man/Makefile.am | 6 +++ doc/man/doveadm-move.1.in | 88 +++++++++++++++++++++++++++++++++++++++++++++++ doc/man/doveadm.1.in | 5 ++ 4 files changed, 100 insertions(+), 1 deletions(-) diffs (148 lines): diff -r 447d20eae931 -r c194c76b98ff .hgignore --- a/.hgignore Sun Sep 25 19:52:43 2011 +0000 +++ b/.hgignore Sun Sep 25 22:32:04 2011 +0000 @@ -95,5 +95,5 @@ syntax: regexp src/.*/test-[^\.]*$ -doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|index|force-resync|help|kick|log|mailbox|penalty|purge|pw|quota|search|user|who)\.1$ +doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|index|force-resync|help|kick|log|mailbox|move|penalty|purge|pw|quota|search|user|who)\.1$ doc/man/(doveadm|doveconf|dovecot-lda|dovecot|dsync)\.1$ diff -r 447d20eae931 -r c194c76b98ff doc/man/Makefile.am --- a/doc/man/Makefile.am Sun Sep 25 19:52:43 2011 +0000 +++ b/doc/man/Makefile.am Sun Sep 25 22:32:04 2011 +0000 @@ -24,6 +24,7 @@ doveadm-kick.1 \ doveadm-log.1 \ doveadm-mailbox.1 \ + doveadm-move.1 \ doveadm-penalty.1 \ doveadm-purge.1 \ doveadm-pw.1 \ @@ -59,6 +60,7 @@ doveadm-kick.1.in \ doveadm-log.1.in \ doveadm-mailbox.1.in \ + doveadm-move.1.in \ doveadm-penalty.1.in \ doveadm-purge.1.in \ doveadm-pw.1.in \ @@ -131,6 +133,10 @@ $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-mailbox.1.in > doveadm-mailbox.1 +doveadm-move.1: $(srcdir)/doveadm-move.1.in $(man_includefiles) Makefile + $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ + < $(srcdir)/doveadm-move.1.in > doveadm-move.1 + doveadm-penalty.1: $(srcdir)/doveadm-penalty.1.in $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-penalty.1.in > doveadm-penalty.1 diff -r 447d20eae931 -r c194c76b98ff doc/man/doveadm-move.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-move.1.in Sun Sep 25 22:32:04 2011 +0000 @@ -0,0 +1,88 @@ +.\" Copyright (c) 2011 Dovecot authors, see the included COPYING file +.TH DOVEADM\-MOVE 1 "2011-09-25" "Dovecot v2.0" "Dovecot" +.SH NAME +doveadm\-move \- Move messages matching the given search query into another +mailbox +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] " move " [" \-S +.IR socket_path "] " "destination search_query" +.br +.\"------------------------------------- +.BR doveadm " [" \-Dv "] " move " [" \-S +.IR socket_path "] " +.BI \-A " destination search_query" +.br +.\"------------------------------------- +.BR doveadm " [" \-Dv "] " move " [" \-S +.IR socket_path "] " +.BI \-u " user destination search_query" +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +.B doveadm move +can be used for moving mails between mailboxes for one or more users. +The +.I search_query +is used to restrict which messages are moved into the +.I destination +mailbox. +.PP +In the first form, +.BR doveadm (1) +will executed the +.B move +action with the environment of the logged in system user. +.PP +In the second form, +.BR doveadm (1) +will iterate over all users, found in the configured +.IR user_db (s), +and move each user\(aqs messages, matching the given +.IR search_query , +into the user\(aqs +.IR destination " mailbox." +.PP +In the third form, matching mails will be moved only for given +.IR user (s). +.\"------------------------------------------------------------------------ + at INCLUDE:global-options@ +.\" --- command specific options --- "/. +.PP +Command specific +.IR options : +.\"------------------------------------- + at INCLUDE:option-A@ +.\"------------------------------------- + at INCLUDE:option-S-socket@ +.\"------------------------------------- + at INCLUDE:option-u-user@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I destination +The name of the destination mailbox, into which the mails should be moved. +The +.I destination +mailbox must exist, otherwise this command will fail. +.\"------------------------------------- +.TP +.I search_query +Move messages matching the given search query. +See +.BR doveadm\-search\-query (7) +for details. +.\"------------------------------------------------------------------------ +.SH EXAMPLE +Move jane\(aqs messages \- received in September 2011 \- from her INBOX +into her archive. +.PP +.nf +.B doveadm move \-u jane Archive/2011/09 mailbox INBOX BEFORE \(rs +.B 2011-10-01 SINCE 01-Sep-2011 +.fi +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1), +.BR doveadm\-search\-query (7) \ No newline at end of file diff -r 447d20eae931 -r c194c76b98ff doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Sun Sep 25 19:52:43 2011 +0000 +++ b/doc/man/doveadm.1.in Sun Sep 25 22:32:04 2011 +0000 @@ -122,6 +122,11 @@ Various commands related to handling mailboxes. .\"------------------------------------- .TP +.B doveadm move +.BR doveadm\-move (1) +Move messages matching the given search query into another mailbox. +.\"------------------------------------- +.TP .B doveadm purge .BR doveadm\-purge (1) Remove messages with refcount=0 from mdbox files. From dovecot at dovecot.org Mon Sep 26 01:25:41 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 Sep 2011 01:25:41 +0300 Subject: dovecot-2.1: man: Added doveadm move. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/af13ef62d083 changeset: 13553:af13ef62d083 user: Pascal Volk date: Sun Sep 25 22:32:04 2011 +0000 description: man: Added doveadm move. diffstat: .hgignore | 2 +- doc/man/Makefile.am | 6 +++ doc/man/doveadm-move.1.in | 88 +++++++++++++++++++++++++++++++++++++++++++++++ doc/man/doveadm.1.in | 5 ++ 4 files changed, 100 insertions(+), 1 deletions(-) diffs (148 lines): diff -r 67a545272b3f -r af13ef62d083 .hgignore --- a/.hgignore Fri Sep 23 16:07:29 2011 +0300 +++ b/.hgignore Sun Sep 25 22:32:04 2011 +0000 @@ -99,5 +99,5 @@ syntax: regexp src/.*/test-[^\.]*$ -doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|index|force-resync|help|kick|log|mailbox|penalty|purge|pw|quota|search|user|who)\.1$ +doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|index|force-resync|help|kick|log|mailbox|move|penalty|purge|pw|quota|search|user|who)\.1$ doc/man/(doveadm|doveconf|dovecot-lda|dovecot|dsync)\.1$ diff -r 67a545272b3f -r af13ef62d083 doc/man/Makefile.am --- a/doc/man/Makefile.am Fri Sep 23 16:07:29 2011 +0300 +++ b/doc/man/Makefile.am Sun Sep 25 22:32:04 2011 +0000 @@ -24,6 +24,7 @@ doveadm-kick.1 \ doveadm-log.1 \ doveadm-mailbox.1 \ + doveadm-move.1 \ doveadm-penalty.1 \ doveadm-purge.1 \ doveadm-pw.1 \ @@ -59,6 +60,7 @@ doveadm-kick.1.in \ doveadm-log.1.in \ doveadm-mailbox.1.in \ + doveadm-move.1.in \ doveadm-penalty.1.in \ doveadm-purge.1.in \ doveadm-pw.1.in \ @@ -131,6 +133,10 @@ $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-mailbox.1.in > doveadm-mailbox.1 +doveadm-move.1: $(srcdir)/doveadm-move.1.in $(man_includefiles) Makefile + $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ + < $(srcdir)/doveadm-move.1.in > doveadm-move.1 + doveadm-penalty.1: $(srcdir)/doveadm-penalty.1.in $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-penalty.1.in > doveadm-penalty.1 diff -r 67a545272b3f -r af13ef62d083 doc/man/doveadm-move.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-move.1.in Sun Sep 25 22:32:04 2011 +0000 @@ -0,0 +1,88 @@ +.\" Copyright (c) 2011 Dovecot authors, see the included COPYING file +.TH DOVEADM\-MOVE 1 "2011-09-25" "Dovecot v2.0" "Dovecot" +.SH NAME +doveadm\-move \- Move messages matching the given search query into another +mailbox +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] " move " [" \-S +.IR socket_path "] " "destination search_query" +.br +.\"------------------------------------- +.BR doveadm " [" \-Dv "] " move " [" \-S +.IR socket_path "] " +.BI \-A " destination search_query" +.br +.\"------------------------------------- +.BR doveadm " [" \-Dv "] " move " [" \-S +.IR socket_path "] " +.BI \-u " user destination search_query" +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +.B doveadm move +can be used for moving mails between mailboxes for one or more users. +The +.I search_query +is used to restrict which messages are moved into the +.I destination +mailbox. +.PP +In the first form, +.BR doveadm (1) +will executed the +.B move +action with the environment of the logged in system user. +.PP +In the second form, +.BR doveadm (1) +will iterate over all users, found in the configured +.IR user_db (s), +and move each user\(aqs messages, matching the given +.IR search_query , +into the user\(aqs +.IR destination " mailbox." +.PP +In the third form, matching mails will be moved only for given +.IR user (s). +.\"------------------------------------------------------------------------ + at INCLUDE:global-options@ +.\" --- command specific options --- "/. +.PP +Command specific +.IR options : +.\"------------------------------------- + at INCLUDE:option-A@ +.\"------------------------------------- + at INCLUDE:option-S-socket@ +.\"------------------------------------- + at INCLUDE:option-u-user@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I destination +The name of the destination mailbox, into which the mails should be moved. +The +.I destination +mailbox must exist, otherwise this command will fail. +.\"------------------------------------- +.TP +.I search_query +Move messages matching the given search query. +See +.BR doveadm\-search\-query (7) +for details. +.\"------------------------------------------------------------------------ +.SH EXAMPLE +Move jane\(aqs messages \- received in September 2011 \- from her INBOX +into her archive. +.PP +.nf +.B doveadm move \-u jane Archive/2011/09 mailbox INBOX BEFORE \(rs +.B 2011-10-01 SINCE 01-Sep-2011 +.fi +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1), +.BR doveadm\-search\-query (7) \ No newline at end of file diff -r 67a545272b3f -r af13ef62d083 doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Fri Sep 23 16:07:29 2011 +0300 +++ b/doc/man/doveadm.1.in Sun Sep 25 22:32:04 2011 +0000 @@ -122,6 +122,11 @@ Various commands related to handling mailboxes. .\"------------------------------------- .TP +.B doveadm move +.BR doveadm\-move (1) +Move messages matching the given search query into another mailbox. +.\"------------------------------------- +.TP .B doveadm purge .BR doveadm\-purge (1) Remove messages with refcount=0 from mdbox files. From dovecot at dovecot.org Mon Sep 26 15:28:38 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 Sep 2011 15:28:38 +0300 Subject: dovecot-2.1: auth: Added passdb imap plugin. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fe89e95867a4 changeset: 13555:fe89e95867a4 user: Timo Sirainen date: Mon Sep 26 15:36:21 2011 +0300 description: auth: Added passdb imap plugin. diffstat: src/auth/Makefile.am | 14 +++- src/auth/auth-settings.c | 2 + src/auth/auth-settings.h | 1 + src/auth/passdb-imap.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 207 insertions(+), 1 deletions(-) diffs (263 lines): diff -r 743ebecc1224 -r fe89e95867a4 src/auth/Makefile.am --- a/src/auth/Makefile.am Mon Sep 26 15:34:58 2011 +0300 +++ b/src/auth/Makefile.am Mon Sep 26 15:36:21 2011 +0300 @@ -14,7 +14,8 @@ auth_module_LTLIBRARIES = \ $(GSSAPI_LIB) \ - $(LDAP_LIB) + $(LDAP_LIB) \ + libpassdb_imap.la pkglibexecdir = $(libexecdir)/dovecot @@ -30,6 +31,7 @@ -I$(top_srcdir)/src/lib-master \ -DAUTH_MODULE_DIR=\""$(auth_moduledir)"\" \ -DPKG_LIBEXECDIR=\""$(pkglibexecdir)"\" \ + -DPKG_RUNDIR=\""$(rundir)"\" \ $(AUTH_CFLAGS) auth_LDFLAGS = -export-dynamic @@ -157,6 +159,16 @@ libauthdb_ldap_la_SOURCES = $(ldap_sources) endif +libpassdb_imap_la_LDFLAGS = -module -avoid-version +libpassdb_imap_la_LIBADD = \ + ../lib-imap-client/libimap_client.la \ + ../lib-ssl-iostream/libssl_iostream.la +libpassdb_imap_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir)/src/lib-imap \ + -I$(top_srcdir)/src/lib-imap-client +libpassdb_imap_la_SOURCES = passdb-imap.c + pkginc_libdir=$(pkgincludedir) pkginc_lib_HEADERS = $(headers) diff -r 743ebecc1224 -r fe89e95867a4 src/auth/auth-settings.c --- a/src/auth/auth-settings.c Mon Sep 26 15:34:58 2011 +0300 +++ b/src/auth/auth-settings.c Mon Sep 26 15:36:21 2011 +0300 @@ -215,6 +215,7 @@ DEFLIST(passdbs, "passdb", &auth_passdb_setting_parser_info), DEFLIST(userdbs, "userdb", &auth_userdb_setting_parser_info), + DEF_NOPREFIX(SET_STR, base_dir), DEF_NOPREFIX(SET_BOOL, verbose_proctitle), SETTING_DEFINE_LIST_END @@ -252,6 +253,7 @@ .passdbs = ARRAY_INIT, .userdbs = ARRAY_INIT, + .base_dir = PKG_RUNDIR, .verbose_proctitle = FALSE }; diff -r 743ebecc1224 -r fe89e95867a4 src/auth/auth-settings.h --- a/src/auth/auth-settings.h Mon Sep 26 15:34:58 2011 +0300 +++ b/src/auth/auth-settings.h Mon Sep 26 15:36:21 2011 +0300 @@ -51,6 +51,7 @@ ARRAY_DEFINE(passdbs, struct auth_passdb_settings *); ARRAY_DEFINE(userdbs, struct auth_userdb_settings *); + const char *base_dir; bool verbose_proctitle; /* generated: */ diff -r 743ebecc1224 -r fe89e95867a4 src/auth/passdb-imap.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/auth/passdb-imap.c Mon Sep 26 15:36:21 2011 +0300 @@ -0,0 +1,191 @@ +/* Copyright (c) 2011 Dovecot authors, see the included COPYING file */ + +#include "auth-common.h" +#include "passdb.h" +#include "str.h" +#include "var-expand.h" +#include "imap-resp-code.h" +#include "imapc-client.h" + +#define IMAP_DEFAULT_PORT 143 +#define IMAPS_DEFAULT_PORT 993 +#define DNS_CLIENT_SOCKET_NAME "dns-client" + +struct imap_passdb_module { + struct passdb_module module; + struct imapc_client_settings set; + bool set_have_vars; +}; + +struct imap_auth_request { + struct imapc_client *client; + struct auth_request *auth_request; + verify_plain_callback_t *verify_callback; +}; + +static enum passdb_result +passdb_imap_get_failure_result(const struct imapc_command_reply *reply) +{ + const char *key = reply->resp_text_key; + + if (key == NULL) + return PASSDB_RESULT_PASSWORD_MISMATCH; + + if (strcasecmp(key, IMAP_RESP_CODE_AUTHFAILED) == 0 || + strcasecmp(key, IMAP_RESP_CODE_AUTHZFAILED) == 0) + return PASSDB_RESULT_PASSWORD_MISMATCH; + if (strcasecmp(key, IMAP_RESP_CODE_EXPIRED) == 0) + return PASSDB_RESULT_PASS_EXPIRED; + return PASSDB_RESULT_INTERNAL_FAILURE; +} + +static void +passdb_imap_login_callback(const struct imapc_command_reply *reply, + void *context) +{ + struct imap_auth_request *request = context; + enum passdb_result result = PASSDB_RESULT_INTERNAL_FAILURE; + + switch (reply->state) { + case IMAPC_COMMAND_STATE_OK: + result = PASSDB_RESULT_OK; + break; + case IMAPC_COMMAND_STATE_NO: + result = passdb_imap_get_failure_result(reply); + break; + case IMAPC_COMMAND_STATE_BAD: + case IMAPC_COMMAND_STATE_DISCONNECTED: + break; + } + request->verify_callback(result, request->auth_request); + imapc_client_deinit(&request->client); +} + +static void +passdb_imap_verify_plain(struct auth_request *auth_request, + const char *password, + verify_plain_callback_t *callback) +{ + struct passdb_module *_module = auth_request->passdb->passdb; + struct imap_passdb_module *module = + (struct imap_passdb_module *)_module; + struct imap_auth_request *request; + struct imapc_client_settings set; + const struct var_expand_table *table; + string_t *str; + + set = module->set; + set.debug = auth_request->set->debug; + set.dns_client_socket_path = + t_strconcat(auth_request->set->base_dir, "/", + DNS_CLIENT_SOCKET_NAME, NULL); + set.password = password; + + if (module->set_have_vars) { + str = t_str_new(128); + table = auth_request_get_var_expand_table(auth_request, NULL); + var_expand(str, set.username, table); + set.username = t_strdup(str_c(str)); + + str_truncate(str, 0); + var_expand(str, set.host, table); + set.host = t_strdup(str_c(str)); + } + auth_request_log_debug(auth_request, "imap", "lookup host=%s port=%d", + set.host, set.port); + + request = p_new(auth_request->pool, struct imap_auth_request, 1); + request->client = imapc_client_init(&set); + request->auth_request = auth_request; + request->verify_callback = callback; + + imapc_client_login(request->client, passdb_imap_login_callback, + request); +} + +static struct passdb_module * +passdb_imap_preinit(pool_t pool, const char *args) +{ + struct imap_passdb_module *module; + char **tmp; + const char *key, *value; + bool port_set = FALSE; + + module = p_new(pool, struct imap_passdb_module, 1); + module->module.default_pass_scheme = "PLAIN"; + module->set.port = IMAP_DEFAULT_PORT; + module->set.ssl_mode = IMAPC_CLIENT_SSL_MODE_NONE; + module->set.username = "%u"; + module->set.rawlog_dir = ""; + + for (tmp = p_strsplit(pool, args, " "); *tmp != NULL; tmp++) { + key = *tmp; + value = strchr(key, '='); + if (value == NULL) + value = ""; + else + key = t_strdup_until(key, value++); + if (strcmp(key, "host") == 0) + module->set.host = value; + else if (strcmp(key, "port") == 0) { + if (str_to_uint(value, &module->set.port) < 0 || + module->set.port == 0 || module->set.port > 65535) + i_fatal("passdb imap: Invalid port: %s", value); + port_set = TRUE; + } else if (strcmp(key, "username") == 0) + module->set.username = value; + else if (strcmp(key, "ssl_ca_dir") == 0) + module->set.ssl_ca_dir = value; + else if (strcmp(key, "rawlog_dir") == 0) + module->set.rawlog_dir = value; + else if (strcmp(key, "ssl") == 0) { + if (strcmp(value, "imaps") == 0) { + if (!port_set) + module->set.port = IMAPS_DEFAULT_PORT; + module->set.ssl_mode = + IMAPC_CLIENT_SSL_MODE_IMMEDIATE; + } else if (strcmp(value, "starttls") == 0) { + module->set.ssl_mode = + IMAPC_CLIENT_SSL_MODE_STARTTLS; + } else { + i_fatal("passdb imap: Invalid ssl mode: %s", + value); + } + } else { + i_fatal("passdb imap: Unknown parameter: %s", key); + } + } + + if (module->set.host == NULL) + i_fatal("passdb imap: Missing host parameter"); + + module->set_have_vars = + strchr(module->set.username, '%') != NULL || + strchr(module->set.host, '%') != NULL; + return &module->module; +} + +static struct passdb_module_interface passdb_imap_plugin = { + "imap", + + passdb_imap_preinit, + NULL, + NULL, + + passdb_imap_verify_plain, + NULL, + NULL +}; + +void passdb_imap_init(void); +void passdb_imap_deinit(void); + +void passdb_imap_init(void) +{ + passdb_register_module(&passdb_imap_plugin); + +} +void passdb_imap_deinit(void) +{ + passdb_unregister_module(&passdb_imap_plugin); +} From dovecot at dovecot.org Mon Sep 26 15:28:38 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 Sep 2011 15:28:38 +0300 Subject: dovecot-2.1: Moved imapc-client into its own lib-imap-client lib... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/743ebecc1224 changeset: 13554:743ebecc1224 user: Timo Sirainen date: Mon Sep 26 15:34:58 2011 +0300 description: Moved imapc-client into its own lib-imap-client library. diffstat: configure.in | 3 +- src/Makefile.am | 1 + src/lib-imap-client/Makefile.am | 22 + src/lib-imap-client/imapc-client-private.h | 40 + src/lib-imap-client/imapc-client.c | 444 +++++ src/lib-imap-client/imapc-client.h | 155 + src/lib-imap-client/imapc-connection.c | 1758 ++++++++++++++++++++ src/lib-imap-client/imapc-connection.h | 56 + src/lib-imap-client/imapc-msgmap.c | 88 + src/lib-imap-client/imapc-msgmap.h | 17 + src/lib-storage/index/imapc/Makefile.am | 10 +- src/lib-storage/index/imapc/imapc-client-private.h | 35 - src/lib-storage/index/imapc/imapc-client.c | 402 ---- src/lib-storage/index/imapc/imapc-client.h | 151 - src/lib-storage/index/imapc/imapc-connection.c | 1704 ------------------- src/lib-storage/index/imapc/imapc-connection.h | 54 - src/lib-storage/index/imapc/imapc-msgmap.c | 88 - src/lib-storage/index/imapc/imapc-msgmap.h | 17 - 18 files changed, 2584 insertions(+), 2461 deletions(-) diffs (truncated from 5162 to 300 lines): diff -r af13ef62d083 -r 743ebecc1224 configure.in --- a/configure.in Sun Sep 25 22:32:04 2011 +0000 +++ b/configure.in Mon Sep 26 15:34:58 2011 +0300 @@ -2435,7 +2435,7 @@ sdbox_libs='$(top_builddir)/src/lib-storage/index/dbox-single/libstorage_dbox_single.la' mdbox_libs='$(top_builddir)/src/lib-storage/index/dbox-multi/libstorage_dbox_multi.la' cydir_libs='$(top_builddir)/src/lib-storage/index/cydir/libstorage_cydir.la' -imapc_libs='$(top_builddir)/src/lib-storage/index/imapc/libstorage_imapc.la $(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la' +imapc_libs='$(top_builddir)/src/lib-storage/index/imapc/libstorage_imapc.la $(top_builddir)/src/lib-imap-client/libimap_client.la $(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la' raw_libs='$(top_builddir)/src/lib-storage/index/raw/libstorage_raw.la' shared_libs='$(top_builddir)/src/lib-storage/index/shared/libstorage_shared.la' @@ -2719,6 +2719,7 @@ src/lib-dns/Makefile src/lib-fs/Makefile src/lib-imap/Makefile +src/lib-imap-client/Makefile src/lib-index/Makefile src/lib-lda/Makefile src/lib-mail/Makefile diff -r af13ef62d083 -r 743ebecc1224 src/Makefile.am --- a/src/Makefile.am Sun Sep 25 22:32:04 2011 +0000 +++ b/src/Makefile.am Mon Sep 26 15:34:58 2011 +0300 @@ -14,6 +14,7 @@ lib-test \ $(LIBDOVECOT_SUBDIRS) \ lib-ssl-iostream \ + lib-imap-client \ lib-dovecot \ lib-index \ lib-storage \ diff -r af13ef62d083 -r 743ebecc1224 src/lib-imap-client/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-imap-client/Makefile.am Mon Sep 26 15:34:58 2011 +0300 @@ -0,0 +1,22 @@ +noinst_LTLIBRARIES = libimap_client.la + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-dns \ + -I$(top_srcdir)/src/lib-ssl-iostream \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-imap + +libimap_client_la_SOURCES = \ + imapc-client.c \ + imapc-connection.c \ + imapc-msgmap.c + +headers = \ + imapc-client.h \ + imapc-client-private.h \ + imapc-connection.h \ + imapc-msgmap.h + +pkginc_libdir=$(pkgincludedir) +pkginc_lib_HEADERS = $(headers) diff -r af13ef62d083 -r 743ebecc1224 src/lib-imap-client/imapc-client-private.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-imap-client/imapc-client-private.h Mon Sep 26 15:34:58 2011 +0300 @@ -0,0 +1,40 @@ +#ifndef IMAPC_CLIENT_PRIVATE_H +#define IMAPC_CLIENT_PRIVATE_H + +#include "imapc-client.h" + +struct imapc_client_connection { + struct imapc_connection *conn; + struct imapc_client_mailbox *box; +}; + +struct imapc_client { + pool_t pool; + int refcount; + + struct imapc_client_settings set; + struct ssl_iostream_context *ssl_ctx; + + imapc_untagged_callback_t *untagged_callback; + void *untagged_context; + + ARRAY_DEFINE(conns, struct imapc_client_connection *); + + struct ioloop *ioloop; + + unsigned int stop_now:1; +}; + +struct imapc_client_mailbox { + struct imapc_client *client; + struct imapc_connection *conn; + struct imapc_msgmap *msgmap; + + void *untagged_box_context; + unsigned int pending_box_command_count; +}; + +void imapc_client_ref(struct imapc_client *client); +void imapc_client_unref(struct imapc_client **client); + +#endif diff -r af13ef62d083 -r 743ebecc1224 src/lib-imap-client/imapc-client.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-imap-client/imapc-client.c Mon Sep 26 15:34:58 2011 +0300 @@ -0,0 +1,444 @@ +/* Copyright (c) 2011 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "str.h" +#include "ioloop.h" +#include "safe-mkstemp.h" +#include "iostream-ssl.h" +#include "imapc-msgmap.h" +#include "imapc-connection.h" +#include "imapc-client-private.h" + +#include + +struct imapc_client_command_context { + struct imapc_client_mailbox *box; + + imapc_command_callback_t *callback; + void *context; +}; + +const struct imapc_capability_name imapc_capability_names[] = { + { "SASL-IR", IMAPC_CAPABILITY_SASL_IR }, + { "LITERAL+", IMAPC_CAPABILITY_LITERALPLUS }, + { "QRESYNC", IMAPC_CAPABILITY_QRESYNC }, + { "IDLE", IMAPC_CAPABILITY_IDLE }, + { "UIDPLUS", IMAPC_CAPABILITY_UIDPLUS }, + { "AUTH=PLAIN", IMAPC_CAPABILITY_AUTH_PLAIN }, + { "STARTTLS", IMAPC_CAPABILITY_STARTTLS }, + + { "IMAP4REV1", IMAPC_CAPABILITY_IMAP4REV1 }, + { NULL, 0 } +}; + +static void +default_untagged_callback(const struct imapc_untagged_reply *reply ATTR_UNUSED, + void *context ATTR_UNUSED) +{ +} + +struct imapc_client * +imapc_client_init(const struct imapc_client_settings *set) +{ + struct imapc_client *client; + struct ssl_iostream_settings ssl_set; + const char *source; + pool_t pool; + + pool = pool_alloconly_create("imapc client", 1024); + client = p_new(pool, struct imapc_client, 1); + client->pool = pool; + client->refcount = 1; + + client->set.debug = set->debug; + client->set.host = p_strdup(pool, set->host); + client->set.port = set->port; + client->set.master_user = p_strdup(pool, set->master_user); + client->set.username = p_strdup(pool, set->username); + client->set.password = p_strdup(pool, set->password); + client->set.dns_client_socket_path = + p_strdup(pool, set->dns_client_socket_path); + client->set.temp_path_prefix = + p_strdup(pool, set->temp_path_prefix); + client->set.rawlog_dir = p_strdup(pool, set->rawlog_dir); + + if (set->ssl_mode != IMAPC_CLIENT_SSL_MODE_NONE) { + client->set.ssl_mode = set->ssl_mode; + client->set.ssl_ca_dir = p_strdup(pool, set->ssl_ca_dir); + + memset(&ssl_set, 0, sizeof(ssl_set)); + ssl_set.ca_dir = set->ssl_ca_dir; + ssl_set.verify_remote_cert = TRUE; + + source = t_strdup_printf("%s:%u", set->host, set->port); + if (ssl_iostream_context_init_client(source, &ssl_set, + &client->ssl_ctx) < 0) { + i_error("imapc(%s): Couldn't initialize SSL context", + source); + } + } + client->untagged_callback = default_untagged_callback; + + p_array_init(&client->conns, pool, 8); + return client; +} + +void imapc_client_ref(struct imapc_client *client) +{ + i_assert(client->refcount > 0); + + client->refcount++; +} + +void imapc_client_unref(struct imapc_client **_client) +{ + struct imapc_client *client = *_client; + + i_assert(client->refcount > 0); + if (--client->refcount > 0) + return; + + if (client->ssl_ctx != NULL) + ssl_iostream_context_deinit(&client->ssl_ctx); + pool_unref(&client->pool); +} + +void imapc_client_deinit(struct imapc_client **_client) +{ + struct imapc_client *client = *_client; + struct imapc_client_connection **connp; + + array_foreach_modifiable(&client->conns, connp) { + imapc_connection_deinit(&(*connp)->conn); + i_free(*connp); + } + array_clear(&client->conns); + imapc_client_unref(_client); +} + +void imapc_client_register_untagged(struct imapc_client *client, + imapc_untagged_callback_t *callback, + void *context) +{ + client->untagged_callback = callback; + client->untagged_context = context; +} + +void imapc_client_run_pre(struct imapc_client *client) +{ + struct imapc_client_connection *const *connp; + struct ioloop *prev_ioloop = current_ioloop; + bool handle_pending = client->stop_now; + + i_assert(client->ioloop == NULL); + + client->stop_now = FALSE; + + client->ioloop = io_loop_create(); + io_loop_set_running(client->ioloop); + + array_foreach(&client->conns, connp) { + imapc_connection_ioloop_changed((*connp)->conn); + imapc_connection_connect((*connp)->conn, NULL, NULL); + if (handle_pending) + imapc_connection_input_pending((*connp)->conn); + } + + if (io_loop_is_running(client->ioloop)) + io_loop_run(client->ioloop); + current_ioloop = prev_ioloop; +} + +void imapc_client_run_post(struct imapc_client *client) +{ + struct imapc_client_connection *const *connp; + struct ioloop *ioloop = client->ioloop; + + client->ioloop = NULL; + array_foreach(&client->conns, connp) + imapc_connection_ioloop_changed((*connp)->conn); + + current_ioloop = ioloop; + io_loop_destroy(&ioloop); +} + +void imapc_client_stop(struct imapc_client *client) +{ + if (client->ioloop != NULL) + io_loop_stop(client->ioloop); +} + +bool imapc_client_is_running(struct imapc_client *client) +{ + return client->ioloop != NULL; +} + +void imapc_client_stop_now(struct imapc_client *client) +{ + client->stop_now = TRUE; + imapc_client_stop(client); +} + +static struct imapc_client_connection * +imapc_client_add_connection(struct imapc_client *client) +{ + struct imapc_client_connection *conn; + + conn = i_new(struct imapc_client_connection, 1); + conn->conn = imapc_connection_init(client); + array_append(&client->conns, &conn, 1); + return conn; +} + +static struct imapc_connection * +imapc_client_find_connection(struct imapc_client *client) From dovecot at dovecot.org Mon Sep 26 21:42:34 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 Sep 2011 21:42:34 +0300 Subject: dovecot-2.0: Memory leak fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1fd2494465ba changeset: 12939:1fd2494465ba user: Timo Sirainen date: Mon Sep 26 21:50:52 2011 +0300 description: Memory leak fix. (Only happened at deinit.) diffstat: src/lib/ioloop.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r c194c76b98ff -r 1fd2494465ba src/lib/ioloop.c --- a/src/lib/ioloop.c Sun Sep 25 22:32:04 2011 +0000 +++ b/src/lib/ioloop.c Mon Sep 26 21:50:52 2011 +0300 @@ -487,6 +487,7 @@ i_assert(ioloop == current_ioloop); current_ioloop = current_ioloop->prev; + i_free(ioloop->default_log_prefix); i_free(ioloop); } From dovecot at dovecot.org Mon Sep 26 21:46:52 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 Sep 2011 21:46:52 +0300 Subject: dovecot-2.0: sdbox: Memory leak fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/3d1b4d0b5880 changeset: 12940:3d1b4d0b5880 user: Timo Sirainen date: Mon Sep 26 21:55:10 2011 +0300 description: sdbox: Memory leak fix. diffstat: src/lib-storage/index/dbox-single/sdbox-sync.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (19 lines): diff -r 1fd2494465ba -r 3d1b4d0b5880 src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Mon Sep 26 21:50:52 2011 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Mon Sep 26 21:55:10 2011 +0300 @@ -194,6 +194,7 @@ if (ret <= 0) { if (ret < 0) mail_storage_set_index_error(&mbox->box); + array_free(&ctx->expunged_uids); i_free(ctx); *ctx_r = NULL; return ret; @@ -225,6 +226,7 @@ } mail_index_sync_rollback(&ctx->index_sync_ctx); if (ret < 0) { + array_free(&ctx->expunged_uids); i_free(ctx); return -1; } From dovecot at dovecot.org Mon Sep 26 21:48:27 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 26 Sep 2011 21:48:27 +0300 Subject: dovecot-2.1: sdbox: Memory leak fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/415aa8e92203 changeset: 13556:415aa8e92203 user: Timo Sirainen date: Mon Sep 26 21:55:10 2011 +0300 description: sdbox: Memory leak fix. diffstat: src/lib-storage/index/dbox-single/sdbox-sync.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (19 lines): diff -r fe89e95867a4 -r 415aa8e92203 src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Mon Sep 26 15:36:21 2011 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Mon Sep 26 21:55:10 2011 +0300 @@ -194,6 +194,7 @@ if (ret <= 0) { if (ret < 0) mail_storage_set_index_error(&mbox->box); + array_free(&ctx->expunged_uids); i_free(ctx); *ctx_r = NULL; return ret; @@ -225,6 +226,7 @@ } mail_index_sync_rollback(&ctx->index_sync_ctx); if (ret < 0) { + array_free(&ctx->expunged_uids); i_free(ctx); return -1; } From dovecot at dovecot.org Tue Sep 27 00:04:30 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 Sep 2011 00:04:30 +0300 Subject: dovecot-2.1: Compile fix for Solaris. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b020b9f7aa54 changeset: 13557:b020b9f7aa54 user: Timo Sirainen date: Tue Sep 27 00:12:49 2011 +0300 description: Compile fix for Solaris. diffstat: src/lib/network.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diffs (38 lines): diff -r 415aa8e92203 -r b020b9f7aa54 src/lib/network.c --- a/src/lib/network.c Mon Sep 26 21:55:10 2011 +0300 +++ b/src/lib/network.c Tue Sep 27 00:12:49 2011 +0300 @@ -27,7 +27,7 @@ union sockaddr_union_unix { struct sockaddr sa; - struct sockaddr_un sun; + struct sockaddr_un un; }; #ifdef HAVE_IPV6 @@ -271,10 +271,7 @@ int net_connect_unix(const char *path) { - union { - struct sockaddr sa; - struct sockaddr_un un; - } sa; + union sockaddr_union_unix sa; int fd, ret; memset(&sa, 0, sizeof(sa)); @@ -687,11 +684,11 @@ if (getsockname(fd, &so.sa, &addrlen) < 0) return -1; - if (so.sun.sun_family != AF_UNIX) { + if (so.un.sun_family != AF_UNIX) { errno = ENOTSOCK; return -1; } - *name_r = t_strdup(so.sun.sun_path); + *name_r = t_strdup(so.un.sun_path); return 0; } From dovecot at dovecot.org Tue Sep 27 00:33:29 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 Sep 2011 00:33:29 +0300 Subject: dovecot-2.1: stats: Error message fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4538030286f6 changeset: 13558:4538030286f6 user: Timo Sirainen date: Tue Sep 27 00:41:49 2011 +0300 description: stats: Error message fix. diffstat: src/stats/mail-stats.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r b020b9f7aa54 -r 4538030286f6 src/stats/mail-stats.c --- a/src/stats/mail-stats.c Tue Sep 27 00:12:49 2011 +0300 +++ b/src/stats/mail-stats.c Tue Sep 27 00:41:49 2011 +0300 @@ -198,8 +198,8 @@ *error_r = t_strdup_printf("%s %llu < %llu", parse_map[i].name, - (unsigned long long)n2, - (unsigned long long)n1); + (unsigned long long)*n2, + (unsigned long long)*n1); return FALSE; } break; From dovecot at dovecot.org Tue Sep 27 00:35:44 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 Sep 2011 00:35:44 +0300 Subject: dovecot-2.1: stats: Compiler warning fixes. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b36ad0f9b3cf changeset: 13559:b36ad0f9b3cf user: Timo Sirainen date: Tue Sep 27 00:44:03 2011 +0300 description: stats: Compiler warning fixes. diffstat: src/stats/mail-command.c | 7 +++++-- src/stats/mail-domain.c | 7 +++++-- src/stats/mail-ip.c | 7 +++++-- src/stats/mail-session.c | 7 +++++-- src/stats/mail-user.c | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diffs (114 lines): diff -r 4538030286f6 -r b36ad0f9b3cf src/stats/mail-command.c --- a/src/stats/mail-command.c Tue Sep 27 00:41:49 2011 +0300 +++ b/src/stats/mail-command.c Tue Sep 27 00:44:03 2011 +0300 @@ -153,6 +153,8 @@ void mail_commands_free_memory(void) { + unsigned int diff; + while (stable_mail_commands != NULL) { struct mail_command *cmd = stable_mail_commands; @@ -168,8 +170,9 @@ if (global_used_memory < stats_settings->memory_limit) break; - if (ioloop_time - - stable_mail_commands->last_update.tv_sec < stats_settings->command_min_time) + + diff = ioloop_time - stable_mail_commands->last_update.tv_sec; + if (diff < stats_settings->command_min_time) break; } } diff -r 4538030286f6 -r b36ad0f9b3cf src/stats/mail-domain.c --- a/src/stats/mail-domain.c Tue Sep 27 00:41:49 2011 +0300 +++ b/src/stats/mail-domain.c Tue Sep 27 00:44:03 2011 +0300 @@ -95,13 +95,16 @@ void mail_domains_free_memory(void) { + unsigned int diff; + while (mail_domains_head != NULL && mail_domains_head->refcount == 0) { mail_domain_free(mail_domains_head); if (global_used_memory < stats_settings->memory_limit) break; - if (ioloop_time - - mail_domains_head->last_update.tv_sec < stats_settings->domain_min_time) + + diff = ioloop_time - mail_domains_head->last_update.tv_sec; + if (diff < stats_settings->domain_min_time) break; } } diff -r 4538030286f6 -r b36ad0f9b3cf src/stats/mail-ip.c --- a/src/stats/mail-ip.c Tue Sep 27 00:41:49 2011 +0300 +++ b/src/stats/mail-ip.c Tue Sep 27 00:44:03 2011 +0300 @@ -91,13 +91,16 @@ void mail_ips_free_memory(void) { + unsigned int diff; + while (mail_ips_head != NULL && mail_ips_head->refcount == 0) { mail_ip_free(mail_ips_head); if (global_used_memory < stats_settings->memory_limit) break; - if (ioloop_time - - mail_ips_head->last_update.tv_sec < stats_settings->ip_min_time) + + diff = ioloop_time - mail_ips_head->last_update.tv_sec; + if (diff < stats_settings->ip_min_time) break; } } diff -r 4538030286f6 -r b36ad0f9b3cf src/stats/mail-session.c --- a/src/stats/mail-session.c Tue Sep 27 00:41:49 2011 +0300 +++ b/src/stats/mail-session.c Tue Sep 27 00:44:03 2011 +0300 @@ -246,6 +246,8 @@ void mail_sessions_free_memory(void) { + unsigned int diff; + while (mail_sessions_head != NULL && mail_sessions_head->refcount == 0) { i_assert(mail_sessions_head->disconnected); @@ -253,8 +255,9 @@ if (global_used_memory < stats_settings->memory_limit) break; - if (ioloop_time - - mail_sessions_head->last_update.tv_sec < stats_settings->session_min_time) + + diff = ioloop_time - mail_sessions_head->last_update.tv_sec; + if (diff < stats_settings->session_min_time) break; } } diff -r 4538030286f6 -r b36ad0f9b3cf src/stats/mail-user.c --- a/src/stats/mail-user.c Tue Sep 27 00:41:49 2011 +0300 +++ b/src/stats/mail-user.c Tue Sep 27 00:44:03 2011 +0300 @@ -112,13 +112,16 @@ void mail_users_free_memory(void) { + unsigned int diff; + while (mail_users_head != NULL && mail_users_head->refcount == 0) { mail_user_free(mail_users_head); if (global_used_memory < stats_settings->memory_limit) break; - if (ioloop_time - - mail_users_head->last_update.tv_sec < stats_settings->user_min_time) + + diff = ioloop_time - mail_users_head->last_update.tv_sec; + if (diff < stats_settings->user_min_time) break; } } From dovecot at dovecot.org Tue Sep 27 18:06:15 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 Sep 2011 18:06:15 +0300 Subject: dovecot-2.1: pop3: Fixed POP3-order sorting. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/69826dc7a959 changeset: 13560:69826dc7a959 user: Timo Sirainen date: Tue Sep 27 18:14:32 2011 +0300 description: pop3: Fixed POP3-order sorting. diffstat: src/pop3/pop3-client.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diffs (23 lines): diff -r b36ad0f9b3cf -r 69826dc7a959 src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Tue Sep 27 00:44:03 2011 +0300 +++ b/src/pop3/pop3-client.c Tue Sep 27 18:14:32 2011 +0300 @@ -118,13 +118,12 @@ if (!array_is_created(msgnum_to_seq_map)) i_array_init(msgnum_to_seq_map, client->messages_count); - else { - /* add any messages between this and the previous one that had - a POP3 order defined */ - seq = array_count(msgnum_to_seq_map) + 1; - for (; seq <= msgnum; seq++) - array_append(msgnum_to_seq_map, &seq, 1); - } + + /* add any messages between this and the previous one that had + a POP3 order defined */ + seq = array_count(msgnum_to_seq_map) + 1; + for (; seq <= msgnum; seq++) + array_append(msgnum_to_seq_map, &seq, 1); array_append(msgnum_to_seq_map, &mail->seq, 1); } From dovecot at dovecot.org Tue Sep 27 18:48:56 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 Sep 2011 18:48:56 +0300 Subject: dovecot-2.1: stats: Mail commands were sorted in wrong order, so... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e62621d28591 changeset: 13561:e62621d28591 user: Timo Sirainen date: Tue Sep 27 18:57:14 2011 +0300 description: stats: Mail commands were sorted in wrong order, so they were never removed from memory. diffstat: src/stats/client-export.c | 2 +- src/stats/mail-command.c | 23 +++++++++++++---------- src/stats/mail-command.h | 3 ++- 3 files changed, 16 insertions(+), 12 deletions(-) diffs (99 lines): diff -r 69826dc7a959 -r e62621d28591 src/stats/client-export.c --- a/src/stats/client-export.c Tue Sep 27 18:14:32 2011 +0300 +++ b/src/stats/client-export.c Tue Sep 27 18:57:14 2011 +0300 @@ -546,7 +546,7 @@ switch (cmd->level) { case MAIL_EXPORT_LEVEL_COMMAND: - client->mail_cmd_iter = stable_mail_commands; + client->mail_cmd_iter = stable_mail_commands_head; if (client->mail_cmd_iter == NULL) return FALSE; mail_command_ref(client->mail_cmd_iter); diff -r 69826dc7a959 -r e62621d28591 src/stats/mail-command.c --- a/src/stats/mail-command.c Tue Sep 27 18:14:32 2011 +0300 +++ b/src/stats/mail-command.c Tue Sep 27 18:57:14 2011 +0300 @@ -10,7 +10,8 @@ #include "mail-command.h" /* commands are sorted by their last_update timestamp, oldest first */ -struct mail_command *stable_mail_commands; +struct mail_command *stable_mail_commands_head; +struct mail_command *stable_mail_commands_tail; static size_t mail_command_memsize(const struct mail_command *cmd) { @@ -49,7 +50,8 @@ cmd->args = i_strdup(args); cmd->last_update = ioloop_timeval; - DLLIST_PREPEND_FULL(&stable_mail_commands, cmd, + DLLIST2_APPEND_FULL(&stable_mail_commands_head, + &stable_mail_commands_tail, cmd, stable_prev, stable_next); DLLIST_PREPEND_FULL(&session->commands, cmd, session_prev, session_next); @@ -64,7 +66,8 @@ global_memory_free(mail_command_memsize(cmd)); - DLLIST_REMOVE_FULL(&stable_mail_commands, cmd, + DLLIST2_REMOVE_FULL(&stable_mail_commands_head, + &stable_mail_commands_tail, cmd, stable_prev, stable_next); DLLIST_REMOVE_FULL(&cmd->session->commands, cmd, session_prev, session_next); @@ -155,8 +158,8 @@ { unsigned int diff; - while (stable_mail_commands != NULL) { - struct mail_command *cmd = stable_mail_commands; + while (stable_mail_commands_head != NULL) { + struct mail_command *cmd = stable_mail_commands_head; if (cmd->refcount == 0) i_assert(cmd->id == 0); @@ -166,12 +169,12 @@ } else { break; } - mail_command_free(stable_mail_commands); + mail_command_free(stable_mail_commands_head); if (global_used_memory < stats_settings->memory_limit) break; - diff = ioloop_time - stable_mail_commands->last_update.tv_sec; + diff = ioloop_time - stable_mail_commands_head->last_update.tv_sec; if (diff < stats_settings->command_min_time) break; } @@ -183,11 +186,11 @@ void mail_commands_deinit(void) { - while (stable_mail_commands != NULL) { - struct mail_command *cmd = stable_mail_commands; + while (stable_mail_commands_head != NULL) { + struct mail_command *cmd = stable_mail_commands_head; if (cmd->id != 0) mail_command_unref(&cmd); - mail_command_free(stable_mail_commands); + mail_command_free(stable_mail_commands_head); } } diff -r 69826dc7a959 -r e62621d28591 src/stats/mail-command.h --- a/src/stats/mail-command.h Tue Sep 27 18:14:32 2011 +0300 +++ b/src/stats/mail-command.h Tue Sep 27 18:57:14 2011 +0300 @@ -3,7 +3,8 @@ struct mail_command; -extern struct mail_command *stable_mail_commands; +extern struct mail_command *stable_mail_commands_head; +extern struct mail_command *stable_mail_commands_tail; int mail_command_update_parse(const char *const *args, const char **error_r); From dovecot at dovecot.org Fri Sep 30 15:46:02 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 30 Sep 2011 15:46:02 +0300 Subject: dovecot-2.1: maildir: Handle open() failing with ESTALE. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/64d3f748a612 changeset: 13562:64d3f748a612 user: Timo Sirainen date: Fri Sep 30 15:54:20 2011 +0300 description: maildir: Handle open() failing with ESTALE. diffstat: src/lib-storage/index/maildir/maildir-mail.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (20 lines): diff -r e62621d28591 -r 64d3f748a612 src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Tue Sep 27 18:57:14 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-mail.c Fri Sep 30 15:54:20 2011 +0300 @@ -2,6 +2,7 @@ #include "lib.h" #include "istream.h" +#include "nfs-workarounds.h" #include "index-mail.h" #include "maildir-storage.h" #include "maildir-filename.h" @@ -22,7 +23,7 @@ do_open(struct maildir_mailbox *mbox, const char *path, struct maildir_open_context *ctx) { - ctx->fd = open(path, O_RDONLY); + ctx->fd = nfs_safe_open(path, O_RDONLY); if (ctx->fd != -1) { ctx->path = i_strdup(path); return 1; From dovecot at dovecot.org Fri Sep 30 18:10:57 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 30 Sep 2011 18:10:57 +0300 Subject: dovecot-2.1: imap: Moved partial fetch cache from static variabl... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/690f60827f59 changeset: 13563:690f60827f59 user: Timo Sirainen date: Fri Sep 30 18:19:17 2011 +0300 description: imap: Moved partial fetch cache from static variable into struct client. diffstat: src/imap/imap-client.h | 12 ++++++++++++ src/imap/imap-fetch-body.c | 28 ++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diffs (95 lines): diff -r 64d3f748a612 -r 690f60827f59 src/imap/imap-client.h --- a/src/imap/imap-client.h Fri Sep 30 15:54:20 2011 +0300 +++ b/src/imap/imap-client.h Fri Sep 30 18:19:17 2011 +0300 @@ -2,6 +2,7 @@ #define IMAP_CLIENT_H #include "imap-commands.h" +#include "message-size.h" #define CLIENT_COMMAND_QUEUE_MAX_SIZE 4 /* Maximum number of CONTEXT=SEARCH UPDATEs. Clients probably won't need more @@ -86,6 +87,15 @@ unsigned int temp_executed:1; /* temporary execution state tracking */ }; +struct partial_fetch_cache { + unsigned int select_counter; + unsigned int uid; + + uoff_t physical_start; + bool cr_skipped; + struct message_size pos; +}; + struct client { struct client *prev, *next; @@ -122,6 +132,8 @@ uint64_t sync_last_full_modseq; uint64_t highest_fetch_modseq; + struct partial_fetch_cache last_partial; + /* SEARCHRES extension: Last saved SEARCH result */ ARRAY_TYPE(seq_range) search_saved_uidset; /* SEARCH=CONTEXT extension: Searches that get updated */ diff -r 64d3f748a612 -r 690f60827f59 src/imap/imap-fetch-body.c --- a/src/imap/imap-fetch-body.c Fri Sep 30 15:54:20 2011 +0300 +++ b/src/imap/imap-fetch-body.c Fri Sep 30 18:19:17 2011 +0300 @@ -32,17 +32,6 @@ unsigned int peek:1; }; -struct partial_cache { - unsigned int select_counter; - unsigned int uid; - - uoff_t physical_start; - bool cr_skipped; - struct message_size pos; -}; - -static struct partial_cache last_partial = { 0, 0, 0, 0, { 0, 0, 0 } }; - static void fetch_read_error(struct imap_fetch_context *ctx) { errno = ctx->cur_input->stream_errno; @@ -53,7 +42,8 @@ } static int seek_partial(unsigned int select_counter, unsigned int uid, - struct partial_cache *partial, struct istream *stream, + struct partial_fetch_cache *partial, + struct istream *stream, uoff_t virtual_skip, bool *cr_skipped_r) { if (select_counter == partial->select_counter && uid == partial->uid && @@ -236,10 +226,12 @@ ctx->cur_offset += ret; if (ctx->update_partial) { - last_partial.cr_skipped = ctx->skip_cr != 0; - last_partial.pos.physical_size = - ctx->cur_input->v_offset - last_partial.physical_start; - last_partial.pos.virtual_size += ret; + struct partial_fetch_cache *p = &ctx->client->last_partial; + + p->cr_skipped = ctx->skip_cr != 0; + p->pos.physical_size = + ctx->cur_input->v_offset - p->physical_start; + p->pos.virtual_size += ret; } return ctx->cur_offset == ctx->cur_size; @@ -330,8 +322,8 @@ } } else { if (seek_partial(ctx->select_counter, ctx->cur_mail->uid, - &last_partial, ctx->cur_input, body->skip, - &ctx->skip_cr) < 0) { + &ctx->client->last_partial, ctx->cur_input, + body->skip, &ctx->skip_cr) < 0) { fetch_read_error(ctx); return -1; } From dovecot at dovecot.org Fri Sep 30 18:44:50 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 30 Sep 2011 18:44:50 +0300 Subject: dovecot-2.1: imapc: Keep the last fetched message body cached un... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5726f89486a0 changeset: 13564:5726f89486a0 user: Timo Sirainen date: Fri Sep 30 18:53:09 2011 +0300 description: imapc: Keep the last fetched message body cached until mailbox is closed. This primarily helps partial IMAP fetches so each partial fetch doesn't redownload the message body. diffstat: src/lib-storage/index/imapc/imapc-mail-fetch.c | 37 +++++++++++++++++++++++++- src/lib-storage/index/imapc/imapc-mail.c | 19 +++++++++++++ src/lib-storage/index/imapc/imapc-mail.h | 2 + src/lib-storage/index/imapc/imapc-mailbox.c | 5 ++- src/lib-storage/index/imapc/imapc-storage.c | 13 +++++++++ src/lib-storage/index/imapc/imapc-storage.h | 13 +++++++++ 6 files changed, 87 insertions(+), 2 deletions(-) diffs (208 lines): diff -r 690f60827f59 -r 5726f89486a0 src/lib-storage/index/imapc/imapc-mail-fetch.c --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Fri Sep 30 18:19:17 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Fri Sep 30 18:53:09 2011 +0300 @@ -109,12 +109,40 @@ return 0; } +static void imapc_mail_cache_get(struct imapc_mail *mail, + struct imapc_mail_cache *cache) +{ + if (mail->body_fetched) + return; + + if (cache->fd != -1) { + mail->fd = cache->fd; + mail->imail.data.stream = + i_stream_create_fd(mail->fd, 0, FALSE); + cache->fd = -1; + } else if (cache->buf != NULL) { + mail->body = cache->buf; + mail->imail.data.stream = + i_stream_create_from_data(mail->body->data, + mail->body->used); + cache->buf = NULL; + } else { + return; + } + mail->body_fetched = TRUE; + imapc_mail_init_stream(mail, TRUE); +} + bool imapc_mail_prefetch(struct mail *_mail) { struct imapc_mail *mail = (struct imapc_mail *)_mail; + struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; struct index_mail_data *data = &mail->imail.data; enum mail_fetch_field fields = 0; + if (mbox->prev_mail_cache.uid == _mail->uid) + imapc_mail_cache_get(mail, &mbox->prev_mail_cache); + if ((mail->imail.wanted_fields & MAIL_FETCH_RECEIVED_DATE) != 0 && data->received_date == (time_t)-1) fields |= MAIL_FETCH_RECEIVED_DATE; @@ -256,6 +284,11 @@ return; /* maybe the existing stream has no body. replace it. */ i_stream_unref(&imail->data.stream); + if (mail->fd != -1) { + if (close(mail->fd) < 0) + i_error("close(imapc mail) failed: %m"); + mail->fd = -1; + } } if (arg->type == IMAP_ARG_LITERAL_SIZE) { @@ -265,7 +298,8 @@ i_error("dup() failed: %m"); return; } - imail->data.stream = i_stream_create_fd(fd, 0, TRUE); + mail->fd = fd; + imail->data.stream = i_stream_create_fd(fd, 0, FALSE); } else { if (!imap_arg_get_nstring(arg, &value)) return; @@ -282,6 +316,7 @@ imail->data.stream = i_stream_create_from_data(mail->body->data, mail->body->used); } + mail->body_fetched = body; imapc_mail_init_stream(mail, body); } diff -r 690f60827f59 -r 5726f89486a0 src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Fri Sep 30 18:19:17 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Fri Sep 30 18:53:09 2011 +0300 @@ -20,6 +20,7 @@ pool = pool_alloconly_create("mail", 2048); mail = p_new(pool, struct imapc_mail, 1); mail->imail.mail.pool = pool; + mail->fd = -1; index_mail_init(&mail->imail, t, wanted_fields, wanted_headers); return &mail->imail.mail.mail; @@ -28,9 +29,27 @@ static void imapc_mail_free(struct mail *_mail) { struct imapc_mail *mail = (struct imapc_mail *)_mail; + struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box; + struct imapc_mail_cache *cache = &mbox->prev_mail_cache; + if (mail->body_fetched) { + imapc_mail_cache_free(cache); + cache->uid = _mail->uid; + if (cache->fd != -1) { + cache->fd = mail->fd; + mail->fd = -1; + } else { + cache->buf = mail->body; + mail->body = NULL; + } + } + if (mail->fd != -1) { + if (close(mail->fd) < 0) + i_error("close(imapc mail) failed: %m"); + } if (mail->body != NULL) buffer_free(&mail->body); + index_mail_free(_mail); } diff -r 690f60827f59 -r 5726f89486a0 src/lib-storage/index/imapc/imapc-mail.h --- a/src/lib-storage/index/imapc/imapc-mail.h Fri Sep 30 18:19:17 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.h Fri Sep 30 18:53:09 2011 +0300 @@ -12,7 +12,9 @@ enum mail_fetch_field fetching_fields; unsigned int fetch_count; + int fd; buffer_t *body; + bool body_fetched; }; extern struct mail_vfuncs imapc_mail_vfuncs; diff -r 690f60827f59 -r 5726f89486a0 src/lib-storage/index/imapc/imapc-mailbox.c --- a/src/lib-storage/index/imapc/imapc-mailbox.c Fri Sep 30 18:19:17 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Fri Sep 30 18:53:09 2011 +0300 @@ -403,7 +403,10 @@ str_to_uint32(reply->resp_text_value, &uid_validity) < 0) return; - mbox->sync_uid_validity = uid_validity; + if (mbox->sync_uid_validity != uid_validity) { + mbox->sync_uid_validity = uid_validity; + imapc_mail_cache_free(&mbox->prev_mail_cache); + } } static void diff -r 690f60827f59 -r 5726f89486a0 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Fri Sep 30 18:19:17 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Fri Sep 30 18:53:09 2011 +0300 @@ -340,6 +340,7 @@ p_array_init(&mbox->fetch_mails, pool, 16); p_array_init(&mbox->permanent_keywords, pool, 32); p_array_init(&mbox->delayed_expunged_uids, pool, 16); + mbox->prev_mail_cache.fd = -1; imapc_mailbox_register_callbacks(mbox); return &mbox->box; } @@ -432,6 +433,18 @@ return 0; } +void imapc_mail_cache_free(struct imapc_mail_cache *cache) +{ + if (cache->fd != -1) { + if (close(cache->fd) < 0) + i_error("close(imapc cached mail) failed: %m"); + cache->fd = -1; + } + if (cache->buf != NULL) + buffer_free(&cache->buf); + cache->uid = 0; +} + static void imapc_mailbox_close(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; diff -r 690f60827f59 -r 5726f89486a0 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Fri Sep 30 18:19:17 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Fri Sep 30 18:53:09 2011 +0300 @@ -40,6 +40,14 @@ ARRAY_DEFINE(untagged_callbacks, struct imapc_storage_event_callback); }; +struct imapc_mail_cache { + uint32_t uid; + + /* either fd != -1 or buf != NULL */ + int fd; + buffer_t *buf; +}; + struct imapc_mailbox { struct mailbox box; struct imapc_storage *storage; @@ -66,6 +74,10 @@ uint32_t exists_count; uint32_t min_append_uid; + /* keep the previous fetched message body cached, + mainly for partial IMAP fetches */ + struct imapc_mail_cache prev_mail_cache; + uint32_t prev_skipped_rseq, prev_skipped_uid; unsigned int selecting:1; @@ -92,6 +104,7 @@ void imapc_transaction_save_rollback(struct mail_save_context *ctx); void imapc_storage_run(struct imapc_storage *storage); +void imapc_mail_cache_free(struct imapc_mail_cache *cache); void imapc_copy_error_from_reply(struct imapc_storage *storage, enum mail_error default_error, From dovecot at dovecot.org Fri Sep 30 18:54:11 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 30 Sep 2011 18:54:11 +0300 Subject: dovecot-2.1: imap: Memory leak fixes for invalid parameter handl... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1fd1321e55f4 changeset: 13565:1fd1321e55f4 user: Timo Sirainen date: Fri Sep 30 19:02:31 2011 +0300 description: imap: Memory leak fixes for invalid parameter handling. diffstat: src/imap/cmd-copy.c | 4 +++- src/imap/cmd-expunge.c | 10 ++++++---- src/imap/cmd-store.c | 5 ++++- src/imap/imap-search-args.c | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diffs (77 lines): diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/cmd-copy.c --- a/src/imap/cmd-copy.c Fri Sep 30 18:53:09 2011 +0300 +++ b/src/imap/cmd-copy.c Fri Sep 30 19:02:31 2011 +0300 @@ -106,8 +106,10 @@ if (ret <= 0) return ret < 0; - if (client_open_save_dest_box(cmd, mailbox, &destbox) < 0) + if (client_open_save_dest_box(cmd, mailbox, &destbox) < 0) { + mail_search_args_unref(&search_args); return TRUE; + } t = mailbox_transaction_begin(destbox, MAILBOX_TRANSACTION_FLAG_EXTERNAL | diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/cmd-expunge.c --- a/src/imap/cmd-expunge.c Fri Sep 30 18:53:09 2011 +0300 +++ b/src/imap/cmd-expunge.c Fri Sep 30 19:02:31 2011 +0300 @@ -23,15 +23,17 @@ struct mail_search_args *search_args) { struct client *client = cmd->client; + int ret; - if (imap_expunge(client->mailbox, search_args == NULL ? NULL : - search_args->args) < 0) { + ret = imap_expunge(client->mailbox, search_args == NULL ? NULL : + search_args->args); + if (search_args != NULL) + mail_search_args_unref(&search_args); + if (ret < 0) { client_send_storage_error(cmd, mailbox_get_storage(client->mailbox)); return TRUE; } - if (search_args != NULL) - mail_search_args_unref(&search_args); client->sync_seen_deletes = FALSE; client->sync_seen_expunges = FALSE; diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/cmd-store.c --- a/src/imap/cmd-store.c Fri Sep 30 18:53:09 2011 +0300 +++ b/src/imap/cmd-store.c Fri Sep 30 19:02:31 2011 +0300 @@ -149,10 +149,13 @@ memset(&ctx, 0, sizeof(ctx)); ctx.cmd = cmd; - if (!store_parse_args(&ctx, ++args)) + if (!store_parse_args(&ctx, ++args)) { + mail_search_args_unref(&search_args); return TRUE; + } if (client->mailbox_examined) { + mail_search_args_unref(&search_args); if (ctx.max_modseq < (uint64_t)-1) reply = "NO CONDSTORE failed: Mailbox is read-only."; else diff -r 5726f89486a0 -r 1fd1321e55f4 src/imap/imap-search-args.c --- a/src/imap/imap-search-args.c Fri Sep 30 18:53:09 2011 +0300 +++ b/src/imap/imap-search-args.c Fri Sep 30 19:02:31 2011 +0300 @@ -117,6 +117,7 @@ !msgset_is_valid(&args->args->value.seqset, cmd->client->messages_count)) { *error_r = "Invalid messageset"; + mail_search_args_unref(&args); return -1; } *args_r = args; @@ -135,6 +136,7 @@ p_array_init(&args->args->value.seqset, args->pool, 16); if (imap_seq_set_parse(uidset, &args->args->value.seqset) < 0) { *error_r = "Invalid uidset"; + mail_search_args_unref(&args); return -1; } From dovecot at dovecot.org Fri Sep 30 18:55:27 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 30 Sep 2011 18:55:27 +0300 Subject: dovecot-2.0: imap: Memory leak fixes for invalid parameter handl... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/9007d5de0e87 changeset: 12941:9007d5de0e87 user: Timo Sirainen date: Fri Sep 30 19:03:49 2011 +0300 description: imap: Memory leak fixes for invalid parameter handling. diffstat: src/imap/cmd-copy.c | 6 +++++- src/imap/cmd-expunge.c | 10 ++++++---- src/imap/cmd-store.c | 5 ++++- src/imap/imap-search-args.c | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diffs (93 lines): diff -r 3d1b4d0b5880 -r 9007d5de0e87 src/imap/cmd-copy.c --- a/src/imap/cmd-copy.c Mon Sep 26 21:55:10 2011 +0300 +++ b/src/imap/cmd-copy.c Fri Sep 30 19:03:49 2011 +0300 @@ -112,8 +112,10 @@ /* open the destination mailbox */ dest_ns = client_find_namespace(cmd, mailbox, &storage_name, &status); - if (dest_ns == NULL) + if (dest_ns == NULL) { + mail_search_args_unref(&search_args); return TRUE; + } switch (status) { case MAILBOX_NAME_EXISTS_MAILBOX: @@ -126,6 +128,7 @@ case MAILBOX_NAME_NOINFERIORS: client_fail_mailbox_name_status(cmd, mailbox, "TRYCREATE", status); + mail_search_args_unref(&search_args); return TRUE; } @@ -139,6 +142,7 @@ client_send_storage_error(cmd, mailbox_get_storage(destbox)); mailbox_free(&destbox); + mail_search_args_unref(&search_args); return TRUE; } if (client->enabled_features != 0) diff -r 3d1b4d0b5880 -r 9007d5de0e87 src/imap/cmd-expunge.c --- a/src/imap/cmd-expunge.c Mon Sep 26 21:55:10 2011 +0300 +++ b/src/imap/cmd-expunge.c Fri Sep 30 19:03:49 2011 +0300 @@ -23,15 +23,17 @@ struct mail_search_args *search_args) { struct client *client = cmd->client; + int ret; - if (imap_expunge(client->mailbox, search_args == NULL ? NULL : - search_args->args) < 0) { + ret = imap_expunge(client->mailbox, search_args == NULL ? NULL : + search_args->args); + if (search_args != NULL) + mail_search_args_unref(&search_args); + if (ret < 0) { client_send_storage_error(cmd, mailbox_get_storage(client->mailbox)); return TRUE; } - if (search_args != NULL) - mail_search_args_unref(&search_args); client->sync_seen_deletes = FALSE; client->sync_seen_expunges = FALSE; diff -r 3d1b4d0b5880 -r 9007d5de0e87 src/imap/cmd-store.c --- a/src/imap/cmd-store.c Mon Sep 26 21:55:10 2011 +0300 +++ b/src/imap/cmd-store.c Fri Sep 30 19:03:49 2011 +0300 @@ -149,10 +149,13 @@ memset(&ctx, 0, sizeof(ctx)); ctx.cmd = cmd; - if (!store_parse_args(&ctx, ++args)) + if (!store_parse_args(&ctx, ++args)) { + mail_search_args_unref(&search_args); return TRUE; + } if (client->mailbox_examined) { + mail_search_args_unref(&search_args); if (ctx.max_modseq < (uint64_t)-1) reply = "NO CONDSTORE failed: Mailbox is read-only."; else diff -r 3d1b4d0b5880 -r 9007d5de0e87 src/imap/imap-search-args.c --- a/src/imap/imap-search-args.c Mon Sep 26 21:55:10 2011 +0300 +++ b/src/imap/imap-search-args.c Fri Sep 30 19:03:49 2011 +0300 @@ -112,6 +112,7 @@ !msgset_is_valid(&args->args->value.seqset, cmd->client->messages_count)) { *error_r = "Invalid messageset"; + mail_search_args_unref(&args); return -1; } *args_r = args; @@ -130,6 +131,7 @@ p_array_init(&args->args->value.seqset, args->pool, 16); if (imap_seq_set_parse(uidset, &args->args->value.seqset) < 0) { *error_r = "Invalid uidset"; + mail_search_args_unref(&args); return -1; }