From dovecot at dovecot.org Sat Jun 1 02:27:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 02:27:11 +0300 Subject: dovecot-2.2: Make sure errno is preserved in non-delayed signal ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fbeac7272069 changeset: 16436:fbeac7272069 user: Timo Sirainen date: Sat Jun 01 02:25:54 2013 +0300 description: Make sure errno is preserved in non-delayed signal handlers. The current code didn't have any signal handlers that modified errno, so this doesn't fix any bugs. diffstat: src/lib/lib-signals.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (35 lines): diff -r 199769f2979f -r fbeac7272069 src/lib/lib-signals.c --- a/src/lib/lib-signals.c Fri May 31 17:36:45 2013 +0300 +++ b/src/lib/lib-signals.c Sat Jun 01 02:25:54 2013 +0300 @@ -97,6 +97,7 @@ #endif { struct signal_handler *h; + int saved_errno; char c = 0; #if defined(SI_NOINFO) || !defined(SA_SIGINFO) @@ -123,21 +124,20 @@ /* remember that we're inside a signal handler which might have been called at any time. don't do anything that's unsafe. we might also get interrupted by another signal while inside this handler. */ + saved_errno = errno; for (h = signal_handlers[signo]; h != NULL; h = h->next) { if ((h->flags & LIBSIG_FLAG_DELAYED) == 0) h->handler(si, h->context); else if (pending_signals[signo].si_signo == 0) { pending_signals[signo] = *si; if (!have_pending_signals) { - int saved_errno = errno; - if (write(sig_pipe_fd[1], &c, 1) != 1) i_error("write(sigpipe) failed: %m"); have_pending_signals = TRUE; - errno = saved_errno; } } } + errno = saved_errno; } #ifdef SA_SIGINFO From dovecot at dovecot.org Sat Jun 1 02:56:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 02:56:35 +0300 Subject: dovecot-2.2: lib-storage: Empty mailbox name isn't valid. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c4a85c9df948 changeset: 16437:c4a85c9df948 user: Timo Sirainen date: Sat Jun 01 02:56:25 2013 +0300 description: lib-storage: Empty mailbox name isn't valid. diffstat: src/lib-storage/mailbox-list.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diffs (22 lines): diff -r fbeac7272069 -r c4a85c9df948 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Sat Jun 01 02:25:54 2013 +0300 +++ b/src/lib-storage/mailbox-list.c Sat Jun 01 02:56:25 2013 +0300 @@ -1188,10 +1188,14 @@ bool mailbox_list_is_valid_name(struct mailbox_list *list, const char *name, const char **error_r) { - if (*name == '\0' && *list->ns->prefix != '\0') { - /* an ugly way to get to mailbox root (e.g. Maildir/ when - it's not the INBOX) */ - return TRUE; + if (*name == '\0') { + if (*list->ns->prefix != '\0') { + /* an ugly way to get to mailbox root (e.g. Maildir/ + when it's not the INBOX) */ + return TRUE; + } + *error_r = "Name is empty"; + return FALSE; } return mailbox_list_is_valid_fs_name(list, name, error_r); From dovecot at dovecot.org Sat Jun 1 02:57:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 02:57:01 +0300 Subject: dovecot-2.2: lib-imap-client: Ask CAPABILITY again after STARTTLS Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3ed452837a8d changeset: 16438:3ed452837a8d user: Timo Sirainen date: Sat Jun 01 02:56:57 2013 +0300 description: lib-imap-client: Ask CAPABILITY again after STARTTLS diffstat: src/lib-imap-client/imapc-connection.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diffs (36 lines): diff -r c4a85c9df948 -r 3ed452837a8d src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Sat Jun 01 02:56:25 2013 +0300 +++ b/src/lib-imap-client/imapc-connection.c Sat Jun 01 02:56:57 2013 +0300 @@ -115,6 +115,8 @@ unsigned int idle_plus_waiting:1; }; +static void imapc_connection_capability_cb(const struct imapc_command_reply *reply, + void *context); static int imapc_connection_output(struct imapc_connection *conn); static int imapc_connection_ssl_init(struct imapc_connection *conn); static void imapc_command_free(struct imapc_command *cmd); @@ -752,6 +754,7 @@ void *context) { struct imapc_connection *conn = context; + struct imapc_command *cmd; if (reply->state != IMAPC_COMMAND_STATE_OK) { imapc_connection_input_error(conn, "STARTTLS failed: %s", @@ -761,8 +764,13 @@ if (imapc_connection_ssl_init(conn) < 0) imapc_connection_disconnect(conn); - else - imapc_connection_authenticate(conn); + else { + /* get updated capabilities */ + cmd = imapc_connection_cmd(conn, imapc_connection_capability_cb, + conn); + imapc_command_set_flags(cmd, IMAPC_COMMAND_FLAG_PRELOGIN); + imapc_command_send(cmd, "CAPABILITY"); + } } static void imapc_connection_starttls(struct imapc_connection *conn) From dovecot at dovecot.org Sat Jun 1 02:57:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 02:57:35 +0300 Subject: dovecot-2.1: lib-imap-client: Ask CAPABILITY again after STARTTLS Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7d34543189c6 changeset: 14976:7d34543189c6 user: Timo Sirainen date: Sat Jun 01 02:56:57 2013 +0300 description: lib-imap-client: Ask CAPABILITY again after STARTTLS diffstat: src/lib-imap-client/imapc-connection.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diffs (36 lines): diff -r e4b66c2912da -r 7d34543189c6 src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Thu May 30 22:27:38 2013 +0300 +++ b/src/lib-imap-client/imapc-connection.c Sat Jun 01 02:56:57 2013 +0300 @@ -118,6 +118,8 @@ unsigned int handshake_failed:1; }; +static void imapc_connection_capability_cb(const struct imapc_command_reply *reply, + void *context); static int imapc_connection_output(struct imapc_connection *conn); static int imapc_connection_ssl_init(struct imapc_connection *conn); static void imapc_command_free(struct imapc_command *cmd); @@ -753,6 +755,7 @@ void *context) { struct imapc_connection *conn = context; + struct imapc_command *cmd; if (reply->state != IMAPC_COMMAND_STATE_OK) { imapc_connection_input_error(conn, "STARTTLS failed: %s", @@ -762,8 +765,13 @@ if (imapc_connection_ssl_init(conn) < 0) imapc_connection_disconnect(conn); - else - imapc_connection_authenticate(conn); + else { + /* get updated capabilities */ + cmd = imapc_connection_cmd(conn, imapc_connection_capability_cb, + conn); + imapc_command_set_flags(cmd, IMAPC_COMMAND_FLAG_PRELOGIN); + imapc_command_send(cmd, "CAPABILITY"); + } } static void imapc_connection_starttls(struct imapc_connection *conn) From dovecot at dovecot.org Sat Jun 1 03:06:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 03:06:59 +0300 Subject: dovecot-2.2: imapc: Don't assert-crash when trying to access ima... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cd314aa81805 changeset: 16439:cd314aa81805 user: Timo Sirainen date: Sat Jun 01 03:06:54 2013 +0300 description: imapc: Don't assert-crash when trying to access imapc_list_prefix itself. diffstat: src/lib-storage/index/imapc/imapc-list.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diffs (21 lines): diff -r 3ed452837a8d -r cd314aa81805 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 02:56:57 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 03:06:54 2013 +0300 @@ -225,9 +225,14 @@ /* ACL plugin does these lookups */ } else if (*prefix != '\0' && strcasecmp(storage_name, "INBOX") != 0) { prefix_len = strlen(prefix); - i_assert(strncmp(prefix, storage_name, prefix_len) == 0 && - storage_name[prefix_len] == list->sep); - storage_name += prefix_len+1; + i_assert(strncmp(prefix, storage_name, prefix_len) == 0); + storage_name += prefix_len; + if (storage_name[0] == '\0') { + /* we're looking up the prefix itself */ + } else { + i_assert(storage_name[0] == list->sep); + storage_name++; + } } return mailbox_list_default_get_vname(_list, storage_name); } From dovecot at dovecot.org Sat Jun 1 03:20:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 03:20:25 +0300 Subject: dovecot-2.2: imapc: Fixed mailbox deletion. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7af6795f40ed changeset: 16440:7af6795f40ed user: Timo Sirainen date: Sat Jun 01 03:20:15 2013 +0300 description: imapc: Fixed mailbox deletion. diffstat: src/lib-storage/index/imapc/imapc-storage.c | 8 +++++++- src/lib-storage/index/index-storage.c | 16 +++++++++------- src/lib-storage/mail-storage-private.h | 3 +++ 3 files changed, 19 insertions(+), 8 deletions(-) diffs (64 lines): diff -r cd314aa81805 -r 7af6795f40ed src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sat Jun 01 03:06:54 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sat Jun 01 03:20:15 2013 +0300 @@ -666,6 +666,12 @@ status_r->permanent_flags = mbox->permanent_flags; } +static int imapc_mailbox_delete(struct mailbox *box) +{ + box->delete_skip_empty_check = TRUE; + return index_storage_mailbox_delete(box); +} + static int imapc_mailbox_get_status(struct mailbox *box, enum mailbox_status_items items, struct mailbox_status *status_r) @@ -906,7 +912,7 @@ index_storage_mailbox_free, imapc_mailbox_create, imapc_mailbox_update, - index_storage_mailbox_delete, + imapc_mailbox_delete, index_storage_mailbox_rename, imapc_mailbox_get_status, imapc_mailbox_get_metadata, diff -r cd314aa81805 -r 7af6795f40ed src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Sat Jun 01 03:06:54 2013 +0300 +++ b/src/lib-storage/index/index-storage.c Sat Jun 01 03:20:15 2013 +0300 @@ -691,13 +691,15 @@ if (mailbox_mark_index_deleted(box, TRUE) < 0) return -1; - if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) - return -1; - mailbox_get_open_status(box, STATUS_MESSAGES, &status); - if (status.messages != 0) { - mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, - "New mails were added to mailbox during deletion"); - return -1; + if (!box->delete_skip_empty_check || box->deleting_must_be_empty) { + if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) + return -1; + mailbox_get_open_status(box, STATUS_MESSAGES, &status); + if (status.messages != 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "New mails were added to mailbox during deletion"); + return -1; + } } ret_guid = mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata); diff -r cd314aa81805 -r 7af6795f40ed src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Sat Jun 01 03:06:54 2013 +0300 +++ b/src/lib-storage/mail-storage-private.h Sat Jun 01 03:20:15 2013 +0300 @@ -320,6 +320,9 @@ unsigned int deleting:1; /* Delete mailbox only if it's empty */ unsigned int deleting_must_be_empty:1; + /* The backend wants to skip checking if there are 0 messages before + calling mailbox_list.delete_mailbox() */ + unsigned int delete_skip_empty_check:1; /* Mailbox was already marked as deleted within this allocation. */ unsigned int marked_deleted:1; /* TRUE if this is an INBOX for this user */ From dovecot at dovecot.org Sat Jun 1 03:37:32 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 03:37:32 +0300 Subject: dovecot-2.2: imapc: Allow accessing the imapc_list_prefix itself. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/92b4183ede17 changeset: 16441:92b4183ede17 user: Timo Sirainen date: Sat Jun 01 03:37:21 2013 +0300 description: imapc: Allow accessing the imapc_list_prefix itself. diffstat: src/lib-storage/index/imapc/imapc-list.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 7af6795f40ed -r 92b4183ede17 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 03:20:15 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 03:37:21 2013 +0300 @@ -208,8 +208,8 @@ storage_name = mailbox_list_default_get_storage_name(_list, vname); if (*prefix != '\0' && strcasecmp(storage_name, "INBOX") != 0) { - storage_name = t_strdup_printf("%s%c%s", prefix, list->sep, - storage_name); + storage_name = storage_name[0] == '\0' ? prefix : + t_strdup_printf("%s%c%s", prefix, list->sep, storage_name); } return storage_name; } From dovecot at dovecot.org Sat Jun 1 03:48:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 03:48:14 +0300 Subject: dovecot-2.2: imapc: Return correct mailbox list flags for the im... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9e50919d7e8b changeset: 16442:9e50919d7e8b user: Timo Sirainen date: Sat Jun 01 03:48:07 2013 +0300 description: imapc: Return correct mailbox list flags for the imapc prefix mailbox itself. diffstat: src/lib-storage/index/imapc/imapc-list.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (17 lines): diff -r 92b4183ede17 -r 9e50919d7e8b src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 03:37:21 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 03:48:07 2013 +0300 @@ -370,8 +370,11 @@ if (*list->storage->set->imapc_list_prefix == '\0') pattern = "*"; else { - pattern = t_strdup_printf("%s%c*", - list->storage->set->imapc_list_prefix, list->sep); + /* list "prefix*" instead of "prefix.*". this may return a bit + more than we want, but we're also interested in the flags + of the prefix itself. */ + pattern = t_strdup_printf("%s*", + list->storage->set->imapc_list_prefix); } cmd = imapc_list_simple_context_init(&ctx, list); From dovecot at dovecot.org Sat Jun 1 04:06:53 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 04:06:53 +0300 Subject: dovecot-2.2: lib-storage: If mailbox autocreate fails with "alre... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0faaee4060c5 changeset: 16443:0faaee4060c5 user: Timo Sirainen date: Sat Jun 01 04:06:48 2013 +0300 description: lib-storage: If mailbox autocreate fails with "already exists", ignore the error. This check was supposed to have been already there, but it was checking for the wrong error. diffstat: src/lib-storage/mail-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 9e50919d7e8b -r 0faaee4060c5 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sat Jun 01 03:48:07 2013 +0300 +++ b/src/lib-storage/mail-storage.c Sat Jun 01 04:06:48 2013 +0300 @@ -731,7 +731,7 @@ if (mailbox_create(box, NULL, FALSE) < 0) { errstr = mailbox_get_last_error(box, &error); - if (error != MAIL_ERROR_NOTFOUND) { + if (error != MAIL_ERROR_EXISTS) { mail_storage_set_critical(box->storage, "Failed to autocreate mailbox %s: %s", box->vname, errstr); From dovecot at dovecot.org Sat Jun 1 04:17:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 04:17:50 +0300 Subject: dovecot-2.2: imapc: If imapc_list_prefix is set, don't skip it i... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7b1152c83e3e changeset: 16444:7b1152c83e3e user: Timo Sirainen date: Sat Jun 01 04:17:40 2013 +0300 description: imapc: If imapc_list_prefix is set, don't skip it in filesystem paths. Most importantly this fixes the index path when accessing the imapc_list_prefix mailbox itself (so the indexes won't be in the mail root dir, where they don't get deleted when mailbox is deleted). diffstat: src/lib-storage/index/imapc/imapc-list.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diffs (42 lines): diff -r 0faaee4060c5 -r 7b1152c83e3e src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 04:06:48 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Sat Jun 01 04:17:40 2013 +0300 @@ -272,12 +272,37 @@ imapc_list_get_fs_name(struct imapc_mailbox_list *list, const char *name) { struct mailbox_list *fs_list = imapc_list_get_fs(list); + struct mail_namespace *ns = list->list.ns; const char *vname; + char ns_sep = mail_namespace_get_sep(ns); if (name == NULL) - return name; + return NULL; vname = mailbox_list_get_vname(&list->list, name); + if (list->storage->set->imapc_list_prefix[0] != '\0') { + /* put back the prefix, so it gets included in the filesystem. */ + unsigned int vname_len = strlen(vname); + + if (ns->prefix_len > 0) { + /* skip over the namespace prefix */ + i_assert(strncmp(vname, ns->prefix, ns->prefix_len-1) == 0); + if (vname_len == ns->prefix_len-1) + vname = ""; + else { + i_assert(vname[ns->prefix_len-1] == ns_sep); + vname += ns->prefix_len; + } + } + if (vname[0] == '\0') { + vname = t_strconcat(ns->prefix, + list->storage->set->imapc_list_prefix, NULL); + } else { + vname = t_strdup_printf("%s%s%c%s", ns->prefix, + list->storage->set->imapc_list_prefix, + ns_sep, vname); + } + } return mailbox_list_get_storage_name(fs_list, vname); } From dovecot at dovecot.org Sat Jun 1 15:34:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 15:34:07 +0300 Subject: dovecot-2.2: lmtp: Give the DATA input stream a name, so the raw... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/05b6cd9220de changeset: 16445:05b6cd9220de user: Timo Sirainen date: Sat Jun 01 15:33:58 2013 +0300 description: lmtp: Give the DATA input stream a name, so the raw mailbox gets a name and doesn't fail. diffstat: src/lmtp/commands.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 7b1152c83e3e -r 05b6cd9220de src/lmtp/commands.c --- a/src/lmtp/commands.c Sat Jun 01 04:17:40 2013 +0300 +++ b/src/lmtp/commands.c Sat Jun 01 15:33:58 2013 +0300 @@ -771,6 +771,7 @@ inputs[2] = NULL; cinput = i_stream_create_concat(inputs); + i_stream_set_name(cinput, ""); i_stream_unref(&inputs[0]); i_stream_unref(&inputs[1]); return cinput; From dovecot at dovecot.org Sat Jun 1 17:09:00 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 17:09:00 +0300 Subject: dovecot-2.2: lib-fs: If fs_default_copy() fails, close the copy ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/09a57e2f07df changeset: 16446:09a57e2f07df user: Timo Sirainen date: Sat Jun 01 17:08:19 2013 +0300 description: lib-fs: If fs_default_copy() fails, close the copy stream immediately. The stream's origin may already be freed by the time the fs_file_close() is trying to close the stream. diffstat: src/lib-fs/fs-api.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (20 lines): diff -r 05b6cd9220de -r 09a57e2f07df src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Sat Jun 01 15:33:58 2013 +0300 +++ b/src/lib-fs/fs-api.c Sat Jun 01 17:08:19 2013 +0300 @@ -552,12 +552,16 @@ errno = dest->copy_input->stream_errno; fs_set_error(dest->fs, "read(%s) failed: %m", i_stream_get_name(dest->copy_input)); + i_stream_unref(&dest->copy_input); + fs_write_stream_abort(dest, &dest->copy_output); return -1; } if (dest->copy_output->stream_errno != 0) { errno = dest->copy_output->stream_errno; fs_set_error(dest->fs, "write(%s) failed: %m", o_stream_get_name(dest->copy_output)); + i_stream_unref(&dest->copy_input); + fs_write_stream_abort(dest, &dest->copy_output); return -1; } if (!dest->copy_input->eof) { From dovecot at dovecot.org Sat Jun 1 17:12:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 17:12:06 +0300 Subject: dovecot-2.2: lib-index: Avoid memcpy()ing data over itself. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/74875424373d changeset: 16447:74875424373d user: Timo Sirainen date: Sat Jun 01 17:11:55 2013 +0300 description: lib-index: Avoid memcpy()ing data over itself. diffstat: src/lib-index/mail-index-transaction-finish.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (16 lines): diff -r 09a57e2f07df -r 74875424373d src/lib-index/mail-index-transaction-finish.c --- a/src/lib-index/mail-index-transaction-finish.c Sat Jun 01 17:08:19 2013 +0300 +++ b/src/lib-index/mail-index-transaction-finish.c Sat Jun 01 17:11:55 2013 +0300 @@ -293,8 +293,10 @@ expunges[dest].uid = mail_index_transaction_get_uid(t, expunges[src].uid); if (expunges[dest-1].uid != expunges[dest].uid) { - memcpy(expunges[dest].guid_128, expunges[src].guid_128, - sizeof(expunges[dest].guid_128)); + if (dest != src) { + memcpy(expunges[dest].guid_128, expunges[src].guid_128, + sizeof(expunges[dest].guid_128)); + } dest++; } } From dovecot at dovecot.org Sat Jun 1 17:17:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 01 Jun 2013 17:17:57 +0300 Subject: dovecot-2.2: lda/lmtp: If mail delivery fails with tempfail, don... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fa87cd91a11a changeset: 16448:fa87cd91a11a user: Timo Sirainen date: Sat Jun 01 17:17:47 2013 +0300 description: lda/lmtp: If mail delivery fails with tempfail, don't fallback to saving to INBOX. diffstat: src/lda/main.c | 9 ++++++--- src/lib-lda/mail-deliver.c | 18 ++++++++++++++++++ src/lib-lda/mail-deliver.h | 4 ++++ src/lmtp/commands.c | 18 +++++++++++------- 4 files changed, 39 insertions(+), 10 deletions(-) diffs (114 lines): diff -r 74875424373d -r fa87cd91a11a src/lda/main.c --- a/src/lda/main.c Sat Jun 01 17:11:55 2013 +0300 +++ b/src/lda/main.c Sat Jun 01 17:17:47 2013 +0300 @@ -436,14 +436,17 @@ lda_set_dest_addr(&ctx, user, destaddr_source); if (mail_deliver(&ctx, &storage) < 0) { - if (storage == NULL) { + if (storage != NULL) { + errstr = mail_storage_get_last_error(storage, &error); + } else if (ctx.tempfail_error != NULL) { + errstr = ctx.tempfail_error; + error = MAIL_ERROR_TEMP; + } else { /* This shouldn't happen */ i_error("BUG: Saving failed to unknown storage"); return EX_TEMPFAIL; } - errstr = mail_storage_get_last_error(storage, &error); - if (stderr_rejection) { /* write to stderr also for tempfails so that MTA can log the reason if it wants to. */ diff -r 74875424373d -r fa87cd91a11a src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Sat Jun 01 17:11:55 2013 +0300 +++ b/src/lib-lda/mail-deliver.c Sat Jun 01 17:17:47 2013 +0300 @@ -371,6 +371,20 @@ count++, ctx->set->hostname); } +static bool mail_deliver_is_tempfailed(struct mail_deliver_context *ctx, + struct mail_storage *storage) +{ + enum mail_error error; + + if (ctx->tempfail_error != NULL) + return TRUE; + if (storage != NULL) { + (void)mail_storage_get_last_error(storage, &error); + return error == MAIL_ERROR_TEMP; + } + return FALSE; +} + int mail_deliver(struct mail_deliver_context *ctx, struct mail_storage **storage_r) { @@ -390,12 +404,16 @@ ret = 0; } duplicate_deinit(&ctx->dup_ctx); + if (ret < 0 && mail_deliver_is_tempfailed(ctx, *storage_r)) + return -1; } if (ret < 0 && !ctx->tried_default_save) { /* plugins didn't handle this. save into the default mailbox. */ ret = mail_deliver_save(ctx, ctx->dest_mailbox_name, 0, NULL, storage_r); + if (ret < 0 && mail_deliver_is_tempfailed(ctx, *storage_r)) + return -1; } if (ret < 0 && strcasecmp(ctx->dest_mailbox_name, "INBOX") != 0) { /* still didn't work. try once more to save it diff -r 74875424373d -r fa87cd91a11a src/lib-lda/mail-deliver.h --- a/src/lib-lda/mail-deliver.h Sat Jun 01 17:11:55 2013 +0300 +++ b/src/lib-lda/mail-deliver.h Sat Jun 01 17:17:47 2013 +0300 @@ -48,6 +48,10 @@ /* mail_deliver_log() caches the var expand table here */ struct var_expand_table *var_expand_table; + /* Error message for a temporary failure. This is necessary only when + there is no storage where to get the error message from. */ + const char *tempfail_error; + bool tried_default_save; bool saved_mail; bool save_dest_mail; diff -r 74875424373d -r fa87cd91a11a src/lmtp/commands.c --- a/src/lmtp/commands.c Sat Jun 01 17:11:55 2013 +0300 +++ b/src/lmtp/commands.c Sat Jun 01 17:17:47 2013 +0300 @@ -694,13 +694,7 @@ client_send_line(client, "250 2.0.0 <%s> %s Saved", rcpt->address, client->state.session_id); ret = 0; - } else if (storage == NULL) { - /* This shouldn't happen */ - i_error("BUG: Saving failed to unknown storage"); - client_send_line(client, ERRSTR_TEMP_MAILBOX_FAIL, - rcpt->address); - ret = -1; - } else { + } else if (storage != NULL) { error = mail_storage_get_last_error(storage, &mail_error); if (mail_error == MAIL_ERROR_NOSPACE) { client_send_line(client, "%s <%s> %s", @@ -712,6 +706,16 @@ rcpt->address, error); } ret = -1; + } else if (dctx.tempfail_error != NULL) { + client_send_line(client, "451 4.2.0 <%s> %s", + rcpt->address, dctx.tempfail_error); + ret = -1; + } else { + /* This shouldn't happen */ + i_error("BUG: Saving failed to unknown storage"); + client_send_line(client, ERRSTR_TEMP_MAILBOX_FAIL, + rcpt->address); + ret = -1; } return ret; } From pigeonhole at rename-it.nl Sun Jun 2 17:08:30 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 02 Jun 2013 16:08:30 +0200 Subject: dovecot-2.2-pigeonhole: Finished support for temporary failures. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/ca6735be7bba changeset: 1779:ca6735be7bba user: Stephan Bosch date: Sun Jun 02 16:08:22 2013 +0200 description: Finished support for temporary failures. This change is bigger than I would have liked, so this needs to be tested more. diffstat: src/lib-sieve/cmd-discard.c | 6 +- src/lib-sieve/cmd-redirect.c | 23 +- src/lib-sieve/ext-reject.c | 14 +- src/lib-sieve/plugins/enotify/cmd-notify.c | 6 +- src/lib-sieve/plugins/imap4flags/tag-flags.c | 6 +- src/lib-sieve/plugins/mailbox/tag-mailbox-create.c | 27 +- src/lib-sieve/plugins/notify/cmd-notify.c | 6 +- src/lib-sieve/plugins/vacation/cmd-vacation.c | 26 +- src/lib-sieve/plugins/vnd.dovecot/duplicate/ext-duplicate-common.c | 6 +- src/lib-sieve/sieve-actions.c | 99 +- src/lib-sieve/sieve-actions.h | 10 +- src/lib-sieve/sieve-binary-file.c | 14 +- src/lib-sieve/sieve-result.c | 139 +- src/lib-sieve/sieve-result.h | 4 +- src/lib-sieve/sieve-script-dict.c | 12 +- src/lib-sieve/sieve-script-file.c | 16 +- src/lib-sieve/sieve-script.c | 4 +- src/lib-sieve/sieve-types.h | 13 +- src/lib-sieve/sieve.c | 74 +- src/lib-sieve/sieve.h | 2 + src/lib-sievestorage/sieve-storage.c | 4 +- src/managesieve/managesieve-client.c | 2 +- src/plugins/lda-sieve/lda-sieve-plugin.c | 660 +++++---- src/plugins/sieve-extprograms/cmd-pipe.c | 13 +- src/plugins/sieve-extprograms/sieve-extprograms-common.c | 10 +- src/sieve-tools/sieve-filter.c | 5 +- src/sieve-tools/sieve-test.c | 8 +- src/testsuite/testsuite.c | 3 +- 28 files changed, 702 insertions(+), 510 deletions(-) diffs (truncated from 2598 to 300 lines): diff -r eff46ace3456 -r ca6735be7bba src/lib-sieve/cmd-discard.c --- a/src/lib-sieve/cmd-discard.c Fri May 24 13:12:24 2013 +0200 +++ b/src/lib-sieve/cmd-discard.c Sun Jun 02 16:08:22 2013 +0200 @@ -58,7 +58,7 @@ static void act_discard_print (const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); -static bool act_discard_commit +static int act_discard_commit (const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); @@ -128,7 +128,7 @@ *keep = FALSE; } -static bool act_discard_commit +static int act_discard_commit (const struct sieve_action *action ATTR_UNUSED, const struct sieve_action_exec_env *aenv, void *tr_context ATTR_UNUSED, bool *keep) @@ -138,6 +138,6 @@ "(discard action)"); *keep = FALSE; - return TRUE; + return SIEVE_EXEC_OK; } diff -r eff46ace3456 -r ca6735be7bba src/lib-sieve/cmd-redirect.c --- a/src/lib-sieve/cmd-redirect.c Fri May 24 13:12:24 2013 +0200 +++ b/src/lib-sieve/cmd-redirect.c Sun Jun 02 16:08:22 2013 +0200 @@ -87,7 +87,7 @@ static void act_redirect_print (const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); -static bool act_redirect_commit +static int act_redirect_commit (const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); @@ -307,7 +307,7 @@ *keep = FALSE; } -static bool act_redirect_send +static int act_redirect_send (const struct sieve_action_exec_env *aenv, struct mail *mail, struct act_redirect_context *ctx) { @@ -326,11 +326,11 @@ if ( !sieve_smtp_available(senv) ) { sieve_result_global_warning (aenv, "redirect action has no means to send mail."); - return TRUE; + return SIEVE_EXEC_FAILURE; } if (mail_get_stream(mail, NULL, NULL, &input) < 0) - return FALSE; + return SIEVE_EXEC_TEMP_FAILURE; /* Open SMTP transport */ smtp_handle = sieve_smtp_open(senv, ctx->to_address, sender, &output); @@ -359,13 +359,13 @@ "failed to redirect message to <%s> " "(refer to server log for more information)", str_sanitize(ctx->to_address, 80)); - return FALSE; + return SIEVE_EXEC_FAILURE; } - return TRUE; + return SIEVE_EXEC_OK; } -static bool act_redirect_commit +static int act_redirect_commit (const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void *tr_context ATTR_UNUSED, bool *keep) @@ -378,6 +378,7 @@ const struct sieve_script_env *senv = aenv->scriptenv; const char *orig_recipient = sieve_message_get_orig_recipient(aenv->msgctx); const char *dupeid; + int ret; /* Prevent mail loops if possible */ dupeid = msgdata->id == NULL ? NULL : t_strdup_printf @@ -388,12 +389,12 @@ sieve_result_global_log(aenv, "discarded duplicate forward to <%s>", str_sanitize(ctx->to_address, 128)); *keep = FALSE; - return TRUE; + return SIEVE_EXEC_OK; } } /* Try to forward the message */ - if ( act_redirect_send(aenv, mail, ctx) ) { + if ( (ret=act_redirect_send(aenv, mail, ctx)) == SIEVE_EXEC_OK) { /* Mark this message id as forwarded to the specified destination */ if (dupeid != NULL) { @@ -410,10 +411,10 @@ /* Cancel implicit keep */ *keep = FALSE; - return TRUE; + return SIEVE_EXEC_OK; } - return FALSE; + return ret; } diff -r eff46ace3456 -r ca6735be7bba src/lib-sieve/ext-reject.c --- a/src/lib-sieve/ext-reject.c Fri May 24 13:12:24 2013 +0200 +++ b/src/lib-sieve/ext-reject.c Sun Jun 02 16:08:22 2013 +0200 @@ -181,7 +181,7 @@ static void act_reject_print (const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); -static bool act_reject_commit +static int act_reject_commit (const struct sieve_action *action ATTR_UNUSED, const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); @@ -379,7 +379,7 @@ *keep = FALSE; } -static bool act_reject_commit +static int act_reject_commit (const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void *tr_context ATTR_UNUSED, bool *keep) { @@ -391,7 +391,7 @@ if ( recipient == NULL ) { sieve_result_global_warning(aenv, "reject action aborted: envelope recipient is <>"); - return TRUE; + return SIEVE_EXEC_OK; } if ( rj_ctx->reason == NULL ) { @@ -399,14 +399,14 @@ "not sending reject message (would cause second response to sender)"); *keep = FALSE; - return TRUE; + return SIEVE_EXEC_OK; } if ( sender == NULL ) { sieve_result_global_log(aenv, "not sending reject message to <>"); *keep = FALSE; - return TRUE; + return SIEVE_EXEC_OK; } if ( sieve_action_reject_mail(aenv, sender, recipient, rj_ctx->reason) ) { @@ -415,10 +415,10 @@ ( rj_ctx->ereject ? "ereject" : "reject" )); *keep = FALSE; - return TRUE; + return SIEVE_EXEC_OK; } - return FALSE; + return SIEVE_EXEC_FAILURE; } diff -r eff46ace3456 -r ca6735be7bba src/lib-sieve/plugins/enotify/cmd-notify.c --- a/src/lib-sieve/plugins/enotify/cmd-notify.c Fri May 24 13:12:24 2013 +0200 +++ b/src/lib-sieve/plugins/enotify/cmd-notify.c Sun Jun 02 16:08:22 2013 +0200 @@ -136,7 +136,7 @@ static void act_notify_print (const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); -static bool act_notify_commit +static int act_notify_commit (const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep); @@ -566,7 +566,7 @@ /* Result execution */ -static bool act_notify_commit +static int act_notify_commit (const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void *tr_context ATTR_UNUSED, bool *keep ATTR_UNUSED) { @@ -593,7 +593,7 @@ sieve_error_handler_unref(&nenv.ehandler); } - return result; + return ( result ? SIEVE_EXEC_OK : SIEVE_EXEC_FAILURE ); } diff -r eff46ace3456 -r ca6735be7bba src/lib-sieve/plugins/imap4flags/tag-flags.c --- a/src/lib-sieve/plugins/imap4flags/tag-flags.c Fri May 24 13:12:24 2013 +0200 +++ b/src/lib-sieve/plugins/imap4flags/tag-flags.c Sun Jun 02 16:08:22 2013 +0200 @@ -70,7 +70,7 @@ static void seff_flags_print (const struct sieve_side_effect *seffect, const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); -static bool seff_flags_pre_execute +static int seff_flags_pre_execute (const struct sieve_side_effect *seffect, const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void **context, void *tr_context); @@ -383,7 +383,7 @@ /* Result execution */ -static bool seff_flags_pre_execute +static int seff_flags_pre_execute (const struct sieve_side_effect *seffect, const struct sieve_action *action ATTR_UNUSED, const struct sieve_action_exec_env *aenv, void **context, void *tr_context) @@ -402,7 +402,7 @@ sieve_act_store_add_flags(aenv, tr_context, keywords, ctx->flags); - return TRUE; + return SIEVE_EXEC_OK; } diff -r eff46ace3456 -r ca6735be7bba src/lib-sieve/plugins/mailbox/tag-mailbox-create.c --- a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Fri May 24 13:12:24 2013 +0200 +++ b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Sun Jun 02 16:08:22 2013 +0200 @@ -41,7 +41,7 @@ static void seff_mailbox_create_print (const struct sieve_side_effect *seffect, const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); -static bool seff_mailbox_create_pre_execute +static int seff_mailbox_create_pre_execute (const struct sieve_side_effect *seffect, const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void **se_context, void *tr_context); @@ -113,7 +113,7 @@ sieve_result_seffect_printf(rpenv, "create mailbox if it does not exist"); } -static bool seff_mailbox_create_pre_execute +static int seff_mailbox_create_pre_execute (const struct sieve_side_effect *seffect ATTR_UNUSED, const struct sieve_action *action ATTR_UNUSED, const struct sieve_action_exec_env *aenv ATTR_UNUSED, @@ -126,17 +126,22 @@ /* Check whether creation is necessary */ if ( trans->box == NULL || trans->disabled ) - return TRUE; + return SIEVE_EXEC_OK; /* Check whether creation has a chance of working */ - if ( trans->error_code != MAIL_ERROR_NONE && - trans->error_code != MAIL_ERROR_NOTFOUND ) - return FALSE; + switch ( trans->error_code ) { + case MAIL_ERROR_NONE: + case MAIL_ERROR_NOTFOUND: + break; + case MAIL_ERROR_TEMP: + return SIEVE_EXEC_TEMP_FAILURE; + default: + return SIEVE_EXEC_FAILURE; + } trans->error = NULL; trans->error_code = MAIL_ERROR_NONE; - *storage = mailbox_get_storage(trans->box); /* Create mailbox */ @@ -144,7 +149,8 @@ (void)mail_storage_get_last_error(*storage, &error); if ( error != MAIL_ERROR_EXISTS ) { sieve_act_store_get_storage_error(aenv, trans); - return FALSE; + return ( trans->error_code == MAIL_ERROR_TEMP ? + SIEVE_EXEC_TEMP_FAILURE : SIEVE_EXEC_FAILURE ); } } @@ -159,10 +165,11 @@ if ( mailbox_open(trans->box) < 0 ) { /* Failed definitively */ sieve_act_store_get_storage_error(aenv, trans); From dovecot at dovecot.org Wed Jun 5 15:09:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 15:09:11 +0300 Subject: dovecot-2.2: lib-http: Don't create a new HTTP connection when t... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/686d2dc1d8dd changeset: 16449:686d2dc1d8dd user: Timo Sirainen date: Wed Jun 05 15:08:59 2013 +0300 description: lib-http: Don't create a new HTTP connection when there is already one connecting. diffstat: src/lib-http/http-client-peer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r fa87cd91a11a -r 686d2dc1d8dd src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Sat Jun 01 17:17:47 2013 +0300 +++ b/src/lib-http/http-client-peer.c Wed Jun 05 15:08:59 2013 +0300 @@ -147,7 +147,7 @@ finished connecting successfully. */ new_connections = 0; } else if (num_urgent == 0) { - new_connections = 1; + new_connections = connecting == 0 ? 1 : 0; } else { new_connections = (num_urgent > connecting ? num_urgent - connecting : 0); } From dovecot at dovecot.org Wed Jun 5 15:43:54 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 15:43:54 +0300 Subject: dovecot-2.2: lib-http: Mark the HTTP connection connected only a... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/20b065a5299d changeset: 16450:20b065a5299d user: Timo Sirainen date: Wed Jun 05 15:43:42 2013 +0300 description: lib-http: Mark the HTTP connection connected only after SSL handshake is finished. diffstat: src/lib-http/http-client-connection.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 686d2dc1d8dd -r 20b065a5299d src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Wed Jun 05 15:08:59 2013 +0300 +++ b/src/lib-http/http-client-connection.c Wed Jun 05 15:43:42 2013 +0300 @@ -665,6 +665,7 @@ *error_r = error; return -1; } + http_client_connection_ready(conn); return 0; } @@ -703,8 +704,6 @@ conn->conn.name, ssl_iostream_get_last_error(conn->ssl_iostream)); return -1; } - - http_client_connection_ready(conn); return 0; } From dovecot at dovecot.org Wed Jun 5 16:19:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 16:19:56 +0300 Subject: dovecot-2.2: lib-http: Added connect and request timeout settings. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a551409911f9 changeset: 16451:a551409911f9 user: Timo Sirainen date: Wed Jun 05 16:19:38 2013 +0300 description: lib-http: Added connect and request timeout settings. diffstat: src/lib-http/http-client-connection.c | 72 ++++++++++++++++++++++++++++++++++- src/lib-http/http-client-private.h | 5 +- src/lib-http/http-client.c | 2 + src/lib-http/http-client.h | 7 +++ 4 files changed, 83 insertions(+), 3 deletions(-) diffs (218 lines): diff -r 20b065a5299d -r a551409911f9 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Wed Jun 05 15:43:42 2013 +0300 +++ b/src/lib-http/http-client-connection.c Wed Jun 05 16:19:38 2013 +0300 @@ -8,6 +8,7 @@ #include "ioloop.h" #include "istream.h" #include "ostream.h" +#include "time-util.h" #include "iostream-rawlog.h" #include "iostream-ssl.h" #include "http-response-parser.h" @@ -202,6 +203,17 @@ } static void +http_client_connection_request_timeout(struct http_client_connection *conn) +{ + unsigned int msecs = conn->client->set.request_timeout_msecs; + + http_client_connection_abort_temp_error(&conn, + HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT, t_strdup_printf( + "No response for request in %u.%03u secs", + msecs/1000, msecs%1000)); +} + +static void http_client_connection_continue_timeout(struct http_client_connection *conn) { struct http_client_request *const *req_idx; @@ -249,6 +261,11 @@ if (conn->to_idle != NULL) timeout_remove(&conn->to_idle); + if (conn->client->set.request_timeout_msecs > 0 && + conn->to_requests == NULL) { + conn->to_requests = timeout_add(conn->client->set.request_timeout_msecs, + http_client_connection_request_timeout, conn); + } req->conn = conn; conn->payload_continue = FALSE; if (conn->peer->no_payload_sync) @@ -293,14 +310,26 @@ struct http_client_connection *conn = (struct http_client_connection *)_conn; const char *error; + unsigned int msecs; conn->closing = TRUE; conn->connected = FALSE; switch (_conn->disconnect_reason) { case CONNECTION_DISCONNECT_CONNECT_TIMEOUT: - http_client_peer_connection_failure(conn->peer, t_strdup_printf( - "connect(%s) failed: Connection timed out", _conn->name)); + if (conn->connected_timestamp.tv_sec == 0) { + msecs = timeval_diff_msecs(&ioloop_timeval, + &conn->connect_start_timestamp); + http_client_peer_connection_failure(conn->peer, t_strdup_printf( + "connect(%s) failed: Connection timed out in %u.%03u secs", + _conn->name, msecs/1000, msecs%1000)); + } else { + msecs = timeval_diff_msecs(&ioloop_timeval, + &conn->connected_timestamp); + http_client_peer_connection_failure(conn->peer, t_strdup_printf( + "SSL handshaking to %s failed: Connection timed out in %u.%03u secs", + _conn->name, msecs/1000, msecs%1000)); + } break; case CONNECTION_DISCONNECT_CONN_CLOSED: /* retry pending requests if possible */ @@ -453,6 +482,8 @@ http_client_payload_finished(conn); finished++; } + if (conn->to_requests != NULL) + timeout_reset(conn->to_requests); /* get first waiting request */ if (array_count(&conn->request_wait_list) > 0) { @@ -560,6 +591,9 @@ req = req_idx[0]; no_payload = (strcmp(req->method, "HEAD") == 0); } else { + /* no more requests waiting for the connection */ + if (conn->to_requests != NULL) + timeout_remove(&conn->to_requests); req = NULL; no_payload = FALSE; } @@ -597,6 +631,9 @@ const char *error; int ret; + if (conn->to_requests != NULL) + timeout_reset(conn->to_requests); + if ((ret = o_stream_flush(output)) <= 0) { if (ret < 0) { http_client_connection_abort_temp_error(&conn, @@ -635,6 +672,8 @@ conn->connected = TRUE; conn->peer->last_connect_failed = FALSE; + if (conn->to_connect != NULL) + timeout_remove(&conn->to_connect); if (conn->client->set.rawlog_dir != NULL && stat(conn->client->set.rawlog_dir, &st) == 0) { @@ -718,6 +757,7 @@ http_client_peer_connection_failure(conn->peer, t_strdup_printf( "connect(%s) failed: %m", _conn->name)); } else { + conn->connected_timestamp = ioloop_timeval; http_client_connection_debug(conn, "Connected"); if (conn->peer->addr.https_name != NULL) { if (http_client_connection_ssl_init(conn, &error) < 0) { @@ -758,12 +798,32 @@ http_client_connection_unref(&conn); } +static void http_client_connect_timeout(struct http_client_connection *conn) +{ + conn->conn.disconnect_reason = CONNECTION_DISCONNECT_CONNECT_TIMEOUT; + http_client_connection_destroy(&conn->conn); +} + static void http_client_connection_connect(struct http_client_connection *conn) { + unsigned int msecs; + + conn->connect_start_timestamp = ioloop_timeval; if (connection_client_connect(&conn->conn) < 0) { conn->connect_errno = errno; conn->to_input = timeout_add_short(0, http_client_connection_delayed_connect_error, conn); + return; + } + + /* don't use connection.h timeout because we want this timeout + to include also the SSL handshake */ + msecs = conn->client->set.connect_timeout_msecs; + if (msecs == 0) + msecs = conn->client->set.request_timeout_msecs; + if (msecs > 0) { + conn->to_connect = + timeout_add(msecs, http_client_connect_timeout, conn); } } @@ -831,6 +891,10 @@ ssl_iostream_unref(&conn->ssl_iostream); connection_deinit(&conn->conn); + if (conn->to_requests != NULL) + timeout_remove(&conn->to_requests); + if (conn->to_connect != NULL) + timeout_remove(&conn->to_connect); if (conn->to_input != NULL) timeout_remove(&conn->to_input); if (conn->to_idle != NULL) @@ -855,6 +919,10 @@ void http_client_connection_switch_ioloop(struct http_client_connection *conn) { + if (conn->to_requests != NULL) + conn->to_requests = io_loop_move_timeout(&conn->to_requests); + if (conn->to_connect != NULL) + conn->to_requests = io_loop_move_timeout(&conn->to_connect); if (conn->to_input != NULL) conn->to_input = io_loop_move_timeout(&conn->to_input); if (conn->to_idle != NULL) diff -r 20b065a5299d -r a551409911f9 src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Wed Jun 05 15:43:42 2013 +0300 +++ b/src/lib-http/http-client-private.h Wed Jun 05 16:19:38 2013 +0300 @@ -134,10 +134,13 @@ unsigned int id; // DEBUG: identify parallel connections int connect_errno; + struct timeval connect_start_timestamp; + struct timeval connected_timestamp; struct ssl_iostream *ssl_iostream; struct http_response_parser *http_parser; - struct timeout *to_input, *to_idle, *to_response; + struct timeout *to_connect, *to_input, *to_idle, *to_response; + struct timeout *to_requests; struct http_client_request *pending_request; struct istream *incoming_payload; diff -r 20b065a5299d -r a551409911f9 src/lib-http/http-client.c --- a/src/lib-http/http-client.c Wed Jun 05 15:43:42 2013 +0300 +++ b/src/lib-http/http-client.c Wed Jun 05 16:19:38 2013 +0300 @@ -96,6 +96,8 @@ (set->max_pipelined_requests > 0 ? set->max_pipelined_requests : 1); client->set.max_attempts = set->max_attempts; client->set.max_redirects = set->max_redirects; + client->set.request_timeout_msecs = set->request_timeout_msecs; + client->set.connect_timeout_msecs = set->connect_timeout_msecs; client->set.debug = set->debug; client->conn_list = http_client_connection_list_init(); diff -r 20b065a5299d -r a551409911f9 src/lib-http/http-client.h --- a/src/lib-http/http-client.h Wed Jun 05 15:43:42 2013 +0300 +++ b/src/lib-http/http-client.h Wed Jun 05 16:19:38 2013 +0300 @@ -57,6 +57,13 @@ /* maximum number of attempts for a request */ unsigned int max_attempts; + /* max time to wait for HTTP request to finish before retrying + (default = unlimited) */ + unsigned int request_timeout_msecs; + /* max time to wait for connect() (and SSL handshake) to finish before + retrying (default = request_timeout_msecs) */ + unsigned int connect_timeout_msecs; + bool debug; }; From dovecot at dovecot.org Wed Jun 5 16:28:28 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 16:28:28 +0300 Subject: dovecot-2.2: lib-http: When receiving 1xx response while waiting... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/49e7a1c206f1 changeset: 16452:49e7a1c206f1 user: Timo Sirainen date: Wed Jun 05 16:28:16 2013 +0300 description: lib-http: When receiving 1xx response while waiting for 100, don't restart timeout. The 100 response is missing only from HTTP/1.0 requests, which also didn't allow any 1xx responses. So if a 1xx response is returned, a 100 response is definitely also coming. diffstat: src/lib-http/http-client-connection.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diffs (13 lines): diff -r a551409911f9 -r 49e7a1c206f1 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Wed Jun 05 16:19:38 2013 +0300 +++ b/src/lib-http/http-client-connection.c Wed Jun 05 16:28:16 2013 +0300 @@ -542,9 +542,6 @@ /* ignore them for now */ http_client_connection_debug(conn, "Got unexpected %u response; ignoring", response->status); - /* restart timeout */ - conn->to_response = timeout_add(HTTP_CLIENT_CONTINUE_TIMEOUT_MSECS, - http_client_connection_continue_timeout, conn); continue; } From dovecot at dovecot.org Wed Jun 5 16:40:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 16:40:14 +0300 Subject: dovecot-2.2: lib-http: After peer has received 100 response, don... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/bcf93c30a500 changeset: 16453:bcf93c30a500 user: Timo Sirainen date: Wed Jun 05 16:40:01 2013 +0300 description: lib-http: After peer has received 100 response, don't add ambiguity timeout anymore. The server should be sending the 100 responses then, and long delays shouldn't be confused with them being missing. diffstat: src/lib-http/http-client-connection.c | 4 +++- src/lib-http/http-client-private.h | 1 + 2 files changed, 4 insertions(+), 1 deletions(-) diffs (32 lines): diff -r 49e7a1c206f1 -r bcf93c30a500 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Wed Jun 05 16:28:16 2013 +0300 +++ b/src/lib-http/http-client-connection.c Wed Jun 05 16:40:01 2013 +0300 @@ -295,7 +295,7 @@ (Continue) status code, the client SHOULD NOT wait for an indefinite period before sending the payload body. */ - if (req->payload_sync) { + if (req->payload_sync && !conn->peer->seen_100_response) { i_assert(req->payload_chunked || req->payload_size > 0); i_assert(conn->to_response == NULL); conn->to_response = timeout_add(HTTP_CLIENT_CONTINUE_TIMEOUT_MSECS, @@ -529,6 +529,8 @@ "Got 100-continue response after timeout"); return; } + conn->peer->no_payload_sync = FALSE; + conn->peer->seen_100_response = TRUE; conn->payload_continue = TRUE; http_client_connection_debug(conn, "Got expected 100-continue response"); diff -r 49e7a1c206f1 -r bcf93c30a500 src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Wed Jun 05 16:28:16 2013 +0300 +++ b/src/lib-http/http-client-private.h Wed Jun 05 16:40:01 2013 +0300 @@ -121,6 +121,7 @@ unsigned int destroyed:1; /* peer is being destroyed */ unsigned int no_payload_sync:1; /* expect: 100-continue failed before */ + unsigned int seen_100_response:1;/* expect: 100-continue succeeded before */ unsigned int last_connect_failed:1; }; From dovecot at dovecot.org Wed Jun 5 17:15:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 17:15:06 +0300 Subject: dovecot-2.2: dsync: If unexpected changes happened during sync, ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5593d6129712 changeset: 16454:5593d6129712 user: Timo Sirainen date: Wed Jun 05 17:14:49 2013 +0300 description: dsync: If unexpected changes happened during sync, log a warning and exit with code 2. This was done by v2.1 dsync, but the code got temporarily lost in v2.2. diffstat: src/doveadm/dsync/doveadm-dsync.c | 13 +++++++++++-- src/doveadm/dsync/dsync-brain.c | 5 +++++ src/doveadm/dsync/dsync-brain.h | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diffs (74 lines): diff -r bcf93c30a500 -r 5593d6129712 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Wed Jun 05 16:40:01 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Wed Jun 05 17:14:49 2013 +0300 @@ -291,7 +291,8 @@ static int cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user, - struct dsync_brain *brain, struct dsync_ibc *ibc2) + struct dsync_brain *brain, struct dsync_ibc *ibc2, + bool *changes_during_sync_r) { struct dsync_brain *brain2; struct mail_user *user2; @@ -357,6 +358,7 @@ brain2_running = dsync_brain_run(brain2, &changed2); } mail_user_unref(&user2); + *changes_during_sync_r = dsync_brain_has_unexpected_changes(brain2); if (dsync_brain_deinit(&brain2) < 0) { ctx->ctx.exit_code = EX_TEMPFAIL; return -1; @@ -490,6 +492,7 @@ struct dsync_brain_settings set; enum dsync_brain_flags brain_flags; bool remote_errors_logged = FALSE; + bool changes_during_sync = FALSE; int status = 0, ret = 0; memset(&set, 0, sizeof(set)); @@ -540,7 +543,8 @@ brain_flags, &set); if (ctx->run_type == DSYNC_RUN_TYPE_LOCAL) { - if (cmd_dsync_run_local(ctx, user, brain, ibc2) < 0) + if (cmd_dsync_run_local(ctx, user, brain, ibc2, + &changes_during_sync) < 0) ret = -1; } else { cmd_dsync_run_remote(user); @@ -552,6 +556,11 @@ doveadm_print(str_c(state_str)); } + if (dsync_brain_has_unexpected_changes(brain) || changes_during_sync) { + i_warning("Mailbox changes caused a desync. " + "You may want to run dsync again."); + ctx->ctx.exit_code = 2; + } if (dsync_brain_deinit(&brain) < 0) { ctx->ctx.exit_code = EX_TEMPFAIL; ret = -1; diff -r bcf93c30a500 -r 5593d6129712 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Wed Jun 05 16:40:01 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Wed Jun 05 17:14:49 2013 +0300 @@ -513,3 +513,8 @@ { return brain->failed; } + +bool dsync_brain_has_unexpected_changes(struct dsync_brain *brain) +{ + return brain->changes_during_sync; +} diff -r bcf93c30a500 -r 5593d6129712 src/doveadm/dsync/dsync-brain.h --- a/src/doveadm/dsync/dsync-brain.h Wed Jun 05 16:40:01 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.h Wed Jun 05 17:14:49 2013 +0300 @@ -67,5 +67,7 @@ void dsync_brain_get_state(struct dsync_brain *brain, string_t *output); /* Returns the sync type that was used. Mainly useful with slave brain. */ enum dsync_brain_sync_type dsync_brain_get_sync_type(struct dsync_brain *brain); +/* Returns TRUE if there were any unexpected changes during the sync. */ +bool dsync_brain_has_unexpected_changes(struct dsync_brain *brain); #endif From dovecot at dovecot.org Wed Jun 5 17:50:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 17:50:10 +0300 Subject: dovecot-2.2: lib-imap: Added imap_utf7_is_valid() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a38a7b5fb195 changeset: 16455:a38a7b5fb195 user: Timo Sirainen date: Wed Jun 05 17:48:48 2013 +0300 description: lib-imap: Added imap_utf7_is_valid() diffstat: src/lib-imap/imap-utf7.c | 19 +++++++++ src/lib-imap/imap-utf7.h | 2 + src/lib-imap/test-imap-utf7.c | 83 +++++++++++++++--------------------------- 3 files changed, 51 insertions(+), 53 deletions(-) diffs (153 lines): diff -r 5593d6129712 -r a38a7b5fb195 src/lib-imap/imap-utf7.c --- a/src/lib-imap/imap-utf7.c Wed Jun 05 17:14:49 2013 +0300 +++ b/src/lib-imap/imap-utf7.c Wed Jun 05 17:48:48 2013 +0300 @@ -271,3 +271,22 @@ } return 0; } + +bool imap_utf7_is_valid(const char *src) +{ + const char *p; + int ret; + + for (p = src; *p != '\0'; p++) { + if (*p == '&' || (unsigned char)*p >= 0x80) { + /* slow scan */ + T_BEGIN { + string_t *tmp = t_str_new(128); + ret = imap_utf7_to_utf8(p, tmp); + } T_END; + if (ret < 0) + return FALSE; + } + } + return TRUE; +} diff -r 5593d6129712 -r a38a7b5fb195 src/lib-imap/imap-utf7.h --- a/src/lib-imap/imap-utf7.h Wed Jun 05 17:14:49 2013 +0300 +++ b/src/lib-imap/imap-utf7.h Wed Jun 05 17:48:48 2013 +0300 @@ -8,5 +8,7 @@ /* Convert IMAP-UTF-7 string to UTF-8. Returns 0 if ok, -1 if src isn't valid IMAP-UTF-7. */ int imap_utf7_to_utf8(const char *src, string_t *dest); +/* Returns TRUE if the string is valid IMAP-UTF-7 string. */ +bool imap_utf7_is_valid(const char *src); #endif diff -r 5593d6129712 -r a38a7b5fb195 src/lib-imap/test-imap-utf7.c --- a/src/lib-imap/test-imap-utf7.c Wed Jun 05 17:14:49 2013 +0300 +++ b/src/lib-imap/test-imap-utf7.c Wed Jun 05 17:48:48 2013 +0300 @@ -8,53 +8,46 @@ static void test_imap_utf7(void) { - static const char *to_utf7[] = { - "&&x&&", "&-&-x&-&-", - "~peter/mail/??/???", "~peter/mail/&U,BTFw-/&ZeVnLIqe-", - "tiet?j?", "tiet&AOQ-j&AOQ-", - "p\xe4\xe4", NULL, - NULL - }; - static const char *invalid_utf7[] = { - "&Jjo!", - "&U,BTFw-&ZeVnLIqe-", - NULL + static struct test { + const char *utf8; + const char *mutf7; + } tests[] = { + { "&&x&&", "&-&-x&-&-" }, + { "~peter/mail/??/???", "~peter/mail/&U,BTFw-/&ZeVnLIqe-" }, + { "tiet?j?", "tiet&AOQ-j&AOQ-" }, + { "p\xe4\xe4", NULL }, + { NULL, "&" }, + { NULL, "&Jjo" }, + { NULL, "&Jjo!" }, + { NULL, "&U,BTFw-&ZeVnLIqe-" } }; string_t *src, *dest; const char *orig_src; unsigned int i, j; unichar_t chr; - bool success, all_success = TRUE; src = t_str_new(256); dest = t_str_new(256); - for (i = 0; to_utf7[i] != NULL; i += 2) { - str_truncate(dest, 0); - if (imap_utf8_to_utf7(to_utf7[i], dest) < 0) - success = to_utf7[i+1] == NULL; - else { - success = to_utf7[i+1] != NULL && - strcmp(to_utf7[i+1], str_c(dest)) == 0; + test_begin("imap mutf7"); + for (i = 0; i < N_ELEMENTS(tests); i++) { + if (tests[i].utf8 != NULL) { + str_truncate(dest, 0); + if (imap_utf8_to_utf7(tests[i].utf8, dest) < 0) + test_assert(tests[i].mutf7 == NULL); + else + test_assert(null_strcmp(tests[i].mutf7, str_c(dest)) == 0); } - if (!success) { - test_out(t_strdup_printf("imap_utf8_to_utf7(%d)", i/2), - FALSE); - all_success = FALSE; - } else if (to_utf7[i+1] != NULL) { + if (tests[i].mutf7 != NULL) { str_truncate(dest, 0); - if (imap_utf7_to_utf8(to_utf7[i+1], dest) < 0 || - strcmp(to_utf7[i], str_c(dest)) != 0) { - test_out(t_strdup_printf("imap_utf7_to_utf8(%d)", i/2), - FALSE); - all_success = FALSE; - } + if (imap_utf7_to_utf8(tests[i].mutf7, dest) < 0) + test_assert(tests[i].utf8 == NULL); + else + test_assert(null_strcmp(tests[i].utf8, str_c(dest)) == 0); + test_assert(imap_utf7_is_valid(tests[i].mutf7) != (tests[i].utf8 == NULL)); } } - if (all_success) - test_out("imap_utf8_to_utf7()", TRUE); - success = TRUE; for (chr = 0xffff; chr <= 0x10010; chr++) { for (i = 1; i <= 10; i++) { str_truncate(src, 0); @@ -70,28 +63,12 @@ orig_src = t_strdup(str_c(src)); str_truncate(src, 0); - if (imap_utf8_to_utf7(orig_src, dest) < 0) - success = FALSE; - else if (imap_utf7_to_utf8(str_c(dest), src) < 0) - success = FALSE; - else - success = strcmp(str_c(src), orig_src) == 0; - if (!success) - goto end; + test_assert(imap_utf8_to_utf7(orig_src, dest) == 0); + test_assert(imap_utf7_to_utf8(str_c(dest), src) == 0); + test_assert(strcmp(str_c(src), orig_src) == 0); } } -end: - test_out("imap_utf7_to_utf8(reverse)", success); - for (i = 0; invalid_utf7[i] != NULL; i++) { - str_truncate(dest, 0); - if (imap_utf7_to_utf8(invalid_utf7[i], dest) == 0) { - test_out(t_strdup_printf("imap_utf7_to_utf8(invalid.%d)", i), - FALSE); - all_success = FALSE; - } - } - if (all_success) - test_out("imap_utf7_to_utf8(invalid)", TRUE); + test_end(); } int main(void) From dovecot at dovecot.org Wed Jun 5 17:50:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 17:50:10 +0300 Subject: dovecot-2.2: lib-imap: Make sure imap_utf7_to_utf8() doesn't acc... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b3c6f97ad3ac changeset: 16456:b3c6f97ad3ac user: Timo Sirainen date: Wed Jun 05 17:49:46 2013 +0300 description: lib-imap: Make sure imap_utf7_to_utf8() doesn't access invalid input string out of bounds. diffstat: src/lib-imap/imap-utf7.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (15 lines): diff -r a38a7b5fb195 -r b3c6f97ad3ac src/lib-imap/imap-utf7.c --- a/src/lib-imap/imap-utf7.c Wed Jun 05 17:48:48 2013 +0300 +++ b/src/lib-imap/imap-utf7.c Wed Jun 05 17:49:46 2013 +0300 @@ -179,8 +179,10 @@ while (*src != '-') { input[0] = imap_b64dec[(uint8_t)src[0]]; + if (input[0] == 0xff) + return -1; input[1] = imap_b64dec[(uint8_t)src[1]]; - if (input[0] == 0xff || input[1] == 0xff) + if (input[1] == 0xff) return -1; output[outpos % 4] = (input[0] << 2) | (input[1] >> 4); From dovecot at dovecot.org Wed Jun 5 18:22:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 18:22:04 +0300 Subject: dovecot-2.2: lib-storage: mailbox_list_settings.broken_char wasn... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/66a6ff2fdee9 changeset: 16457:66a6ff2fdee9 user: Timo Sirainen date: Wed Jun 05 18:15:22 2013 +0300 description: lib-storage: mailbox_list_settings.broken_char wasn't escaping 8bit chars correctly. diffstat: src/lib-storage/mailbox-list.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r b3c6f97ad3ac -r 66a6ff2fdee9 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Wed Jun 05 17:49:46 2013 +0300 +++ b/src/lib-storage/mailbox-list.c Wed Jun 05 18:15:22 2013 +0300 @@ -637,7 +637,7 @@ for (; *vname != '\0'; vname++) { if (*vname == '&' || (unsigned char)*vname >= 0x80) { str_printfa(str, "%c%02x", list->set.broken_char, - *vname); + (unsigned char)*vname); } else { str_append_c(str, *vname); } From dovecot at dovecot.org Wed Jun 5 18:22:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 18:22:04 +0300 Subject: dovecot-2.2: dsync: Set broken_char to a control char, so invali... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/12a0c383703e changeset: 16458:12a0c383703e user: Timo Sirainen date: Wed Jun 05 18:21:55 2013 +0300 description: dsync: Set broken_char to a control char, so invalid mailbox names are handled properly. The dsync will now fail if there are invalid mailbox names (e.g. valid UTF8 when they should have been mUTF7), instead of simply printing "mailbox doesn't exist" error and exiting with 0. diffstat: src/doveadm/dsync/doveadm-dsync.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diffs (69 lines): diff -r 66a6ff2fdee9 -r 12a0c383703e src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Wed Jun 05 18:15:22 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Wed Jun 05 18:21:55 2013 +0300 @@ -19,7 +19,7 @@ #include "mail-storage-service.h" #include "mail-user.h" #include "mail-namespace.h" -#include "mailbox-list.h" +#include "mailbox-list-private.h" #include "doveadm-settings.h" #include "doveadm-mail.h" #include "doveadm-print.h" @@ -38,6 +38,12 @@ #define DSYNC_COMMON_GETOPT_ARGS "+dEfg:l:m:n:Nr:Rs:Ux:" #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30 +/* The broken_char is mainly set to get a proper error message when trying to + convert a mailbox with a name that can't be used properly translated between + vname/storage_name and would otherwise be mixed up with a normal "mailbox + doesn't exist" error message. This could be any control character, since + none of them are allowed to be created in regular mailbox names. */ +#define DSYNC_LIST_BROKEN_CHAR '\003' enum dsync_run_type { DSYNC_RUN_TYPE_LOCAL, @@ -279,6 +285,15 @@ return TRUE; } +static void doveadm_user_init_dsync(struct mail_user *user) +{ + struct mail_namespace *ns; + + user->dsyncing = TRUE; + for (ns = user->namespaces; ns != NULL; ns = ns->next) + ns->list->set.broken_char = DSYNC_LIST_BROKEN_CHAR; +} + static bool paths_are_equal(struct mail_user *user1, struct mail_user *user2, enum mailbox_list_path_type type) { @@ -322,7 +337,7 @@ ctx->ctx.exit_code = ret == -1 ? EX_TEMPFAIL : EX_CONFIG; return -1; } - user2->dsyncing = TRUE; + doveadm_user_init_dsync(user2); if (mail_namespaces_get_root_sep(user->namespaces) != mail_namespaces_get_root_sep(user2->namespaces)) { @@ -504,8 +519,7 @@ /* array is NULL-terminated in init() */ set.exclude_mailboxes = array_idx(&ctx->exclude_mailboxes, 0); } - - user->dsyncing = TRUE; + doveadm_user_init_dsync(user); if (ctx->namespace_prefix != NULL) { set.sync_ns = mail_namespace_find(user->namespaces, @@ -946,7 +960,7 @@ ctx->output = _ctx->conn->output; o_stream_nsend(ctx->output, "\n+\n", 3); } - user->dsyncing = TRUE; + doveadm_user_init_dsync(user); i_set_failure_prefix("dsync-remote(%s): ", user->username); From dovecot at dovecot.org Wed Jun 5 18:25:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 05 Jun 2013 18:25:36 +0300 Subject: dovecot-2.1: dsync: Added workaround to fail if there are UTF8 m... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a88aca17a92c changeset: 14977:a88aca17a92c user: Timo Sirainen date: Wed Jun 05 18:25:32 2013 +0300 description: dsync: Added workaround to fail if there are UTF8 mailbox names in filesystem. diffstat: src/doveadm/dsync/dsync-worker-local.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diffs (18 lines): diff -r 7d34543189c6 -r a88aca17a92c src/doveadm/dsync/dsync-worker-local.c --- a/src/doveadm/dsync/dsync-worker-local.c Sat Jun 01 02:56:57 2013 +0300 +++ b/src/doveadm/dsync/dsync-worker-local.c Wed Jun 05 18:25:32 2013 +0300 @@ -556,7 +556,13 @@ i_error("Failed to sync mailbox %s: %s", info->name, mailbox_get_last_error(box, &error)); mailbox_free(&box); - if (error == MAIL_ERROR_NOTFOUND || + /* don't check for NOTFOUND in here anymore. if it happens + because of a race condition it's pretty bad luck. more + importantly it happens if there's a UTF8 mailbox name in + filesystem while it should have been mUTF7 and we can't + easily detect this in another way. this has been fixed + properly in v2.2. */ + 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 From dovecot at dovecot.org Thu Jun 6 05:58:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 05:58:26 +0300 Subject: dovecot-2.2: lib-http: Fixed previous patch setting connection c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/554774a328b9 changeset: 16459:554774a328b9 user: Timo Sirainen date: Thu Jun 06 05:58:16 2013 +0300 description: lib-http: Fixed previous patch setting connection connected only after SSL handshake. This just caused crashes. The main point was anyway to include the SSL handshake as part of the connect_timeout_msecs. Apparently the easiest way is to set it immediately connected and delay removing the timeout. diffstat: src/lib-http/http-client-connection.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diffs (34 lines): diff -r 12a0c383703e -r 554774a328b9 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Wed Jun 05 18:21:55 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 06 05:58:16 2013 +0300 @@ -671,7 +671,10 @@ conn->connected = TRUE; conn->peer->last_connect_failed = FALSE; - if (conn->to_connect != NULL) + + if (conn->to_connect != NULL && + (conn->ssl_iostream == NULL || + ssl_iostream_is_handshaked(conn->ssl_iostream))) timeout_remove(&conn->to_connect); if (conn->client->set.rawlog_dir != NULL && @@ -703,7 +706,8 @@ *error_r = error; return -1; } - http_client_connection_ready(conn); + if (conn->to_connect != NULL) + timeout_remove(&conn->to_connect); return 0; } @@ -742,6 +746,8 @@ conn->conn.name, ssl_iostream_get_last_error(conn->ssl_iostream)); return -1; } + + http_client_connection_ready(conn); return 0; } From dovecot at dovecot.org Thu Jun 6 06:33:13 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 06:33:13 +0300 Subject: dovecot-2.2: lib-http: Treat connect() timeouts as retryable err... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/452cecc7e708 changeset: 16460:452cecc7e708 user: Timo Sirainen date: Thu Jun 06 06:32:58 2013 +0300 description: lib-http: Treat connect() timeouts as retryable errors. diffstat: src/lib-http/http-client-connection.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diffs (26 lines): diff -r 554774a328b9 -r 452cecc7e708 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 06 05:58:16 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 06 06:32:58 2013 +0300 @@ -320,16 +320,18 @@ if (conn->connected_timestamp.tv_sec == 0) { msecs = timeval_diff_msecs(&ioloop_timeval, &conn->connect_start_timestamp); - http_client_peer_connection_failure(conn->peer, t_strdup_printf( + error = t_strdup_printf( "connect(%s) failed: Connection timed out in %u.%03u secs", - _conn->name, msecs/1000, msecs%1000)); + _conn->name, msecs/1000, msecs%1000); } else { msecs = timeval_diff_msecs(&ioloop_timeval, &conn->connected_timestamp); - http_client_peer_connection_failure(conn->peer, t_strdup_printf( + error = t_strdup_printf( "SSL handshaking to %s failed: Connection timed out in %u.%03u secs", - _conn->name, msecs/1000, msecs%1000)); + _conn->name, msecs/1000, msecs%1000); } + http_client_connection_retry_requests(conn, + HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT, error); break; case CONNECTION_DISCONNECT_CONN_CLOSED: /* retry pending requests if possible */ From dovecot at dovecot.org Thu Jun 6 06:55:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 06:55:56 +0300 Subject: dovecot-2.2: imapc: Index dirs were being wrongly deleted when i... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0a88c358cf82 changeset: 16461:0a88c358cf82 user: Timo Sirainen date: Thu Jun 06 06:55:34 2013 +0300 description: imapc: Index dirs were being wrongly deleted when imapc_list_prefix was set. diffstat: src/lib-storage/index/imapc/imapc-list.c | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diffs (51 lines): diff -r 452cecc7e708 -r 0a88c358cf82 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 06:32:58 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 06:55:34 2013 +0300 @@ -361,7 +361,9 @@ struct mailbox_list *fs_list = imapc_list_get_fs(list); struct mailbox_list_iterate_context *iter; const struct mailbox_info *info; - const char *fs_name; + const char *imapc_list_prefix = list->storage->set->imapc_list_prefix; + unsigned int imapc_list_prefix_len = strlen(imapc_list_prefix); + const char *fs_name, *vname; if (fs_list == NULL) return; @@ -370,13 +372,33 @@ MAILBOX_LIST_ITER_RAW_LIST | MAILBOX_LIST_ITER_NO_AUTO_BOXES | MAILBOX_LIST_ITER_RETURN_NO_FLAGS); - while ((info = mailbox_list_iter_next(iter)) != NULL) { - if (mailbox_tree_lookup(list->mailboxes, info->vname) == NULL) { + while ((info = mailbox_list_iter_next(iter)) != NULL) T_BEGIN { + vname = info->vname; + if (imapc_list_prefix_len > 0) { + /* skip over the namespace prefix */ + i_assert(strncmp(vname, fs_list->ns->prefix, + fs_list->ns->prefix_len) == 0); + vname += fs_list->ns->prefix_len; + /* skip over the imapc list prefix */ + i_assert(strncmp(vname, imapc_list_prefix, + imapc_list_prefix_len) == 0); + vname += imapc_list_prefix_len; + if (vname[0] != '\0') { + i_assert(vname[0] == mail_namespace_get_sep(fs_list->ns)); + vname++; + } + /* put back the namespace prefix */ + if (fs_list->ns->prefix_len > 0) { + vname = t_strconcat(fs_list->ns->prefix, + vname, NULL); + } + } + if (mailbox_tree_lookup(list->mailboxes, vname) == NULL) { fs_name = mailbox_list_get_storage_name(fs_list, info->vname); (void)fs_list->v.delete_mailbox(fs_list, fs_name); } - } + } T_END; (void)mailbox_list_iter_deinit(&iter); } From dovecot at dovecot.org Thu Jun 6 08:57:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 08:57:26 +0300 Subject: dovecot-2.2: lib-imap-client: If SELECT/EXAMINE fails, set the c... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/375becde3b42 changeset: 16462:375becde3b42 user: Timo Sirainen date: Thu Jun 06 08:56:07 2013 +0300 description: lib-imap-client: If SELECT/EXAMINE fails, set the connection as not being selected. diffstat: src/lib-imap-client/imapc-connection.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 0a88c358cf82 -r 375becde3b42 src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Thu Jun 06 06:55:34 2013 +0300 +++ b/src/lib-imap-client/imapc-connection.c Thu Jun 06 08:56:07 2013 +0300 @@ -1047,6 +1047,13 @@ imapc_connection_disconnect(conn); } + if (reply.state == IMAPC_COMMAND_STATE_NO && + (cmd->flags & IMAPC_COMMAND_FLAG_SELECT) != 0 && + conn->selected_box != NULL) { + /* EXAMINE/SELECT failed: mailbox is no longer selected */ + imapc_connection_unselect(conn->selected_box); + } + imapc_connection_input_reset(conn); imapc_command_reply_free(cmd, &reply); imapc_command_send_more(conn); From dovecot at dovecot.org Thu Jun 6 08:57:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 08:57:26 +0300 Subject: dovecot-2.2: lib-imap-client: Added support for UNSELECT capabil... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2690bcbd37d0 changeset: 16463:2690bcbd37d0 user: Timo Sirainen date: Thu Jun 06 08:56:19 2013 +0300 description: lib-imap-client: Added support for UNSELECT capability. diffstat: src/lib-imap-client/imapc-client.c | 1 + src/lib-imap-client/imapc-client.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diffs (22 lines): diff -r 375becde3b42 -r 2690bcbd37d0 src/lib-imap-client/imapc-client.c --- a/src/lib-imap-client/imapc-client.c Thu Jun 06 08:56:07 2013 +0300 +++ b/src/lib-imap-client/imapc-client.c Thu Jun 06 08:56:19 2013 +0300 @@ -23,6 +23,7 @@ { "X-GM-EXT-1", IMAPC_CAPABILITY_X_GM_EXT_1 }, { "CONDSTORE", IMAPC_CAPABILITY_CONDSTORE }, { "NAMESPACE", IMAPC_CAPABILITY_NAMESPACE }, + { "UNSELECT", IMAPC_CAPABILITY_UNSELECT }, { "IMAP4REV1", IMAPC_CAPABILITY_IMAP4REV1 }, { NULL, 0 } diff -r 375becde3b42 -r 2690bcbd37d0 src/lib-imap-client/imapc-client.h --- a/src/lib-imap-client/imapc-client.h Thu Jun 06 08:56:07 2013 +0300 +++ b/src/lib-imap-client/imapc-client.h Thu Jun 06 08:56:19 2013 +0300 @@ -22,6 +22,7 @@ IMAPC_CAPABILITY_X_GM_EXT_1 = 0x80, IMAPC_CAPABILITY_CONDSTORE = 0x100, IMAPC_CAPABILITY_NAMESPACE = 0x200, + IMAPC_CAPABILITY_UNSELECT = 0x400, IMAPC_CAPABILITY_IMAP4REV1 = 0x40000000 }; From dovecot at dovecot.org Thu Jun 6 08:57:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 08:57:26 +0300 Subject: dovecot-2.2: imapc: When deleting a mailbox, unselect the curren... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cc243b748a1c changeset: 16464:cc243b748a1c user: Timo Sirainen date: Thu Jun 06 08:57:13 2013 +0300 description: imapc: When deleting a mailbox, unselect the current one just in case they're the same. diffstat: src/lib-storage/index/imapc/imapc-list.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diffs (24 lines): diff -r 2690bcbd37d0 -r cc243b748a1c src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 08:56:19 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 08:57:13 2013 +0300 @@ -682,9 +682,20 @@ { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; struct mailbox_list *fs_list = imapc_list_get_fs(list); + enum imapc_capability capa; struct imapc_command *cmd; struct imapc_simple_context ctx; + capa = imapc_client_get_capabilities(list->storage->client); + + cmd = imapc_list_simple_context_init(&ctx, list); + imapc_command_set_flags(cmd, IMAPC_COMMAND_FLAG_SELECT); + if ((capa & IMAPC_CAPABILITY_UNSELECT) != 0) + imapc_command_sendf(cmd, "UNSELECT"); + else + imapc_command_sendf(cmd, "SELECT \"~~~\""); + imapc_simple_run(&ctx); + cmd = imapc_list_simple_context_init(&ctx, list); imapc_command_sendf(cmd, "DELETE %s", name); imapc_simple_run(&ctx); From dovecot at dovecot.org Thu Jun 6 09:47:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 09:47:50 +0300 Subject: dovecot-2.2: lib-imap-client: When server sends BYE before disco... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/55624c42bfb8 changeset: 16465:55624c42bfb8 user: Timo Sirainen date: Thu Jun 06 09:47:39 2013 +0300 description: lib-imap-client: When server sends BYE before disconnection, log it as the reason. diffstat: src/lib-imap-client/imapc-connection.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diffs (58 lines): diff -r cc243b748a1c -r 55624c42bfb8 src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Thu Jun 06 08:57:13 2013 +0300 +++ b/src/lib-imap-client/imapc-connection.c Thu Jun 06 09:47:39 2013 +0300 @@ -92,6 +92,7 @@ struct imapc_client_mailbox *selecting_box, *selected_box; enum imapc_connection_state state; + char *disconnect_reason; enum imapc_capability capabilities; char **capabilities_list; @@ -159,6 +160,8 @@ if (--conn->refcount > 0) return; + i_assert(conn->disconnect_reason == NULL); + if (conn->capabilities_list != NULL) p_strsplit_free(default_pool, conn->capabilities_list); array_free(&conn->cmd_send_queue); @@ -299,8 +302,13 @@ case IMAPC_CONNECTION_STATE_DISCONNECTED: memset(&reply, 0, sizeof(reply)); reply.state = IMAPC_COMMAND_STATE_DISCONNECTED; - reply.text_without_resp = reply.text_full = - "Disconnected from server"; + reply.text_full = "Disconnected from server"; + if (conn->disconnect_reason != NULL) { + reply.text_full = t_strdup_printf("%s: %s", + reply.text_full, conn->disconnect_reason); + i_free_and_null(conn->disconnect_reason); + } + reply.text_without_resp = reply.text_full; imapc_login_callback(conn, &reply); conn->idling = FALSE; @@ -899,6 +907,9 @@ value = imap_args_to_str(imap_args); if (imapc_connection_parse_capability(conn, value) < 0) return -1; + } else if (strcasecmp(name, "BYE") == 0) { + i_free(conn->disconnect_reason); + conn->disconnect_reason = i_strdup(imap_args_to_str(imap_args)); } reply.name = name; @@ -1120,7 +1131,10 @@ if (ret < 0) { /* disconnected */ - if (conn->ssl_iostream == NULL) { + if (conn->disconnect_reason != NULL) { + i_error("imapc(%s): Server disconnected with message: %s", + conn->name, conn->disconnect_reason); + } else if (conn->ssl_iostream == NULL) { i_error("imapc(%s): Server disconnected unexpectedly", conn->name); } else { From dovecot at dovecot.org Thu Jun 6 10:52:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 10:52:26 +0300 Subject: dovecot-2.2: imapc: If imapc isn't the inbox=yes namespace, do t... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cdb0e127f010 changeset: 16466:cdb0e127f010 user: Timo Sirainen date: Thu Jun 06 10:52:14 2013 +0300 description: imapc: If imapc isn't the inbox=yes namespace, do the login and initial LIST in background. diffstat: src/lib-storage/index/imapc/imapc-list.c | 61 ++++++++++++------ src/lib-storage/index/imapc/imapc-list.h | 1 - src/lib-storage/index/imapc/imapc-storage.c | 94 +++++++++++++++++++--------- src/lib-storage/index/imapc/imapc-storage.h | 3 + 4 files changed, 106 insertions(+), 53 deletions(-) diffs (truncated from 332 to 300 lines): diff -r 55624c42bfb8 -r cdb0e127f010 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 09:47:39 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 10:52:14 2013 +0300 @@ -140,7 +140,7 @@ const struct imap_arg *args = reply->args; const char *sep, *name; - if (list->sep == '\0') { + if (storage->root_sep == '\0') { /* we haven't asked for the separator yet. lets see if this is the reply for its request. */ if (args[0].type == IMAP_ARG_EOL || @@ -149,8 +149,8 @@ return; /* we can't handle NIL separator yet */ - list->sep = sep == NULL ? '/' : sep[0]; - mailbox_tree_set_separator(list->mailboxes, list->sep); + storage->root_sep = sep == NULL ? '/' : sep[0]; + mailbox_tree_set_separator(list->mailboxes, storage->root_sep); } else { (void)imapc_list_update_tree(list, list->mailboxes, args); } @@ -163,7 +163,7 @@ const struct imap_arg *args = reply->args; struct mailbox_node *node; - if (list->sep == '\0') { + if (storage->root_sep == '\0') { /* we haven't asked for the separator yet */ return; } @@ -192,11 +192,14 @@ static char imapc_list_get_hierarchy_sep(struct mailbox_list *_list) { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; + char sep; - /* storage should have looked this up when it was created */ - i_assert(list->sep != '\0'); - - return list->sep; + if (imapc_storage_try_get_root_sep(list->storage, &sep) < 0) { + /* we can't really fail here. just return a common separator + and keep failing all list commands until it succeeds. */ + return '/'; + } + return sep; } static const char * @@ -209,7 +212,9 @@ storage_name = mailbox_list_default_get_storage_name(_list, vname); if (*prefix != '\0' && strcasecmp(storage_name, "INBOX") != 0) { storage_name = storage_name[0] == '\0' ? prefix : - t_strdup_printf("%s%c%s", prefix, list->sep, storage_name); + t_strdup_printf("%s%c%s", prefix, + mailbox_list_get_hierarchy_sep(_list), + storage_name); } return storage_name; } @@ -230,7 +235,8 @@ if (storage_name[0] == '\0') { /* we're looking up the prefix itself */ } else { - i_assert(storage_name[0] == list->sep); + i_assert(storage_name[0] == + mailbox_list_get_hierarchy_sep(_list)); storage_name++; } } @@ -408,8 +414,12 @@ struct imapc_simple_context ctx; struct mailbox_node *node; const char *pattern; + char sep; - i_assert(list->sep != '\0'); + if (imapc_storage_try_get_root_sep(list->storage, &sep) < 0) { + mailbox_list_set_internal_error(&list->list); + return -1; + } if (list->refreshed_mailboxes) return 0; @@ -427,7 +437,7 @@ cmd = imapc_list_simple_context_init(&ctx, list); imapc_command_sendf(cmd, "LIST \"\" %s", pattern); mailbox_tree_deinit(&list->mailboxes); - list->mailboxes = mailbox_tree_init(list->sep); + list->mailboxes = mailbox_tree_init(sep); mailbox_tree_set_parents_nonexistent(list->mailboxes); imapc_simple_run(&ctx); @@ -505,7 +515,10 @@ return _ctx; } - sep = mailbox_list_get_hierarchy_sep(_list); + if (imapc_storage_try_get_root_sep(list->storage, &sep) < 0) { + mailbox_list_set_internal_error(_list); + ret = -1; + } pool = pool_alloconly_create("mailbox list imapc iter", 1024); ctx = p_new(pool, struct imapc_mailbox_list_iterate_context, 1); @@ -623,23 +636,25 @@ struct imapc_simple_context ctx; struct imapc_command *cmd; const char *pattern; - char sep; + char src_sep, dest_sep; i_assert(src_list->tmp_subscriptions == NULL); if (src_list->refreshed_subscriptions) { if (dest_list->subscriptions == NULL) { - sep = mailbox_list_get_hierarchy_sep(dest_list); + dest_sep = mailbox_list_get_hierarchy_sep(dest_list); dest_list->subscriptions = - mailbox_tree_init(sep); + mailbox_tree_init(dest_sep); } return 0; } - if (src_list->sep == '\0') - (void)mailbox_list_get_hierarchy_sep(_src_list); + if (imapc_storage_try_get_root_sep(src_list->storage, &src_sep) < 0) { + mailbox_list_set_internal_error(dest_list); + return -1; + } - src_list->tmp_subscriptions = mailbox_tree_init(src_list->sep); + src_list->tmp_subscriptions = mailbox_tree_init(src_sep); cmd = imapc_list_simple_context_init(&ctx, src_list); if (*src_list->storage->set->imapc_list_prefix == '\0') @@ -647,7 +662,7 @@ else { pattern = t_strdup_printf("%s%c*", src_list->storage->set->imapc_list_prefix, - src_list->sep); + src_sep); } imapc_command_sendf(cmd, "LSUB \"\" %s", pattern); imapc_simple_run(&ctx); @@ -763,8 +778,12 @@ struct imapc_simple_context sctx; struct mailbox_node *node; const char *vname; + char sep; - i_assert(list->sep != '\0'); + if (imapc_storage_try_get_root_sep(list->storage, &sep) < 0) { + mailbox_list_set_internal_error(_list); + return -1; + } vname = mailbox_list_get_vname(_list, name); if (!list->refreshed_mailboxes) { diff -r 55624c42bfb8 -r cdb0e127f010 src/lib-storage/index/imapc/imapc-list.h --- a/src/lib-storage/index/imapc/imapc-list.h Thu Jun 06 09:47:39 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.h Thu Jun 06 10:52:14 2013 +0300 @@ -13,7 +13,6 @@ struct mailbox_list *index_list; struct mailbox_tree_context *mailboxes, *tmp_subscriptions; - char sep; unsigned int iter_count; diff -r 55624c42bfb8 -r cdb0e127f010 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Thu Jun 06 09:47:39 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Thu Jun 06 10:52:14 2013 +0300 @@ -180,36 +180,61 @@ } } -static int -imapc_storage_get_hierarchy_sep(struct imapc_storage *storage, - const char **error_r) +static void imapc_storage_sep_verify(struct imapc_storage *storage) +{ + const char *imapc_list_prefix = storage->set->imapc_list_prefix; + + if (storage->root_sep == '\0') { + mail_storage_set_critical(&storage->storage, + "imapc: LIST didn't return hierarchy separator"); + } else if (imapc_list_prefix[0] != '\0' && + imapc_list_prefix[strlen(imapc_list_prefix)-1] == storage->root_sep) { + mail_storage_set_critical(&storage->storage, + "imapc_list_prefix must not end with hierarchy separator"); + } +} + +static void imapc_storage_sep_callback(const struct imapc_command_reply *reply, + void *context) +{ + struct imapc_storage *storage = context; + + storage->root_sep_pending = FALSE; + if (reply->state == IMAPC_COMMAND_STATE_OK) + imapc_storage_sep_verify(storage); + else if (reply->state == IMAPC_COMMAND_STATE_NO) + imapc_copy_error_from_reply(storage, MAIL_ERROR_PARAMS, reply); + else { + mail_storage_set_critical(&storage->storage, + "imapc: Command failed: %s", reply->text_full); + } + imapc_client_stop(storage->client); +} + +static void imapc_storage_send_hierarcy_sep_lookup(struct imapc_storage *storage) { struct imapc_command *cmd; - struct imapc_simple_context sctx; - const char *imapc_list_prefix = storage->set->imapc_list_prefix; - imapc_simple_context_init(&sctx, storage); - cmd = imapc_client_cmd(storage->client, imapc_simple_callback, &sctx); + if (storage->root_sep_pending) + return; + storage->root_sep_pending = TRUE; + + cmd = imapc_client_cmd(storage->client, + imapc_storage_sep_callback, storage); imapc_command_send(cmd, "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; +int imapc_storage_try_get_root_sep(struct imapc_storage *storage, char *sep_r) +{ + if (storage->root_sep == '\0') { + imapc_storage_send_hierarcy_sep_lookup(storage); + while (storage->root_sep_pending) + imapc_client_run(storage->client); + if (storage->root_sep == '\0') + return -1; } - - if (storage->list->sep == '\0') { - *error_r = "LIST didn't return hierarchy separator"; - return -1; - } - - if (imapc_list_prefix[0] != '\0' && - imapc_list_prefix[strlen(imapc_list_prefix)-1] == storage->list->sep) { - *error_r = "imapc_list_prefix must not end with hierarchy separator"; - return -1; - } - return sctx.ret; + *sep_r = storage->root_sep; + return 0; } static int @@ -220,6 +245,7 @@ struct imapc_storage *storage = (struct imapc_storage *)_storage; struct imapc_client_settings set; string_t *str; + char sep; storage->set = mail_storage_get_driver_settings(_storage); @@ -279,10 +305,19 @@ imapc_untagged_status); imapc_storage_register_untagged(storage, "NAMESPACE", imapc_untagged_namespace); - /* 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; + /* start connecting to imap server and get the hierarchy separator. */ + imapc_client_login(storage->client, NULL, NULL); + imapc_storage_send_hierarcy_sep_lookup(storage); + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { + /* we're using imapc for the INBOX namespace. wait and make + sure we can successfully access the IMAP server (so if the + username is invalid we don't just keep failing every + command). */ + if (imapc_storage_try_get_root_sep(storage, &sep) < 0) { + imapc_client_deinit(&storage->client); + *error_r = "Failed to access imapc backend"; + return -1; + } } return 0; } @@ -302,10 +337,7 @@ struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; i_assert(storage->list != NULL); - i_assert(storage->list->sep != '\0'); - From dovecot at dovecot.org Thu Jun 6 10:55:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 10:55:42 +0300 Subject: dovecot-2.2: imapc: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/34babd1e2858 changeset: 16467:34babd1e2858 user: Timo Sirainen date: Thu Jun 06 10:55:27 2013 +0300 description: imapc: Minor code cleanup diffstat: src/lib-storage/index/imapc/imapc-list.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r cdb0e127f010 -r 34babd1e2858 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 10:52:14 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Thu Jun 06 10:55:27 2013 +0300 @@ -29,7 +29,6 @@ { "\\NonExistent", MAILBOX_NONEXISTENT }, { "\\NoInferiors", MAILBOX_NOINFERIORS }, { "\\Subscribed", MAILBOX_SUBSCRIBED }, - { "\\Subscribed", MAILBOX_SUBSCRIBED }, { "\\All", MAILBOX_SPECIALUSE_ALL }, { "\\Archive", MAILBOX_SPECIALUSE_ARCHIVE }, { "\\Drafts", MAILBOX_SPECIALUSE_DRAFTS }, From dovecot at dovecot.org Thu Jun 6 11:16:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 11:16:11 +0300 Subject: dovecot-2.2: lib-storage: Renamed mailbox_list_get_closest_stora... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3467c60014ec changeset: 16468:3467c60014ec user: Timo Sirainen date: Thu Jun 06 11:16:05 2013 +0300 description: lib-storage: Renamed mailbox_list_get_closest_storage() to ..._get_default_storage() This function wasn't previously used by anyone. diffstat: src/lib-storage/mailbox-list.c | 2 +- src/lib-storage/mailbox-list.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diffs (24 lines): diff -r 34babd1e2858 -r 3467c60014ec src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Thu Jun 06 10:55:27 2013 +0300 +++ b/src/lib-storage/mailbox-list.c Thu Jun 06 11:16:05 2013 +0300 @@ -781,7 +781,7 @@ } } -void mailbox_list_get_closest_storage(struct mailbox_list *list, +void mailbox_list_get_default_storage(struct mailbox_list *list, struct mail_storage **storage) { *storage = list->ns->storage; diff -r 34babd1e2858 -r 3467c60014ec src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Thu Jun 06 10:55:27 2013 +0300 +++ b/src/lib-storage/mailbox-list.h Thu Jun 06 11:16:05 2013 +0300 @@ -171,7 +171,7 @@ mailbox_list_get_user(const struct mailbox_list *list) ATTR_PURE; int mailbox_list_get_storage(struct mailbox_list **list, const char *vname, struct mail_storage **storage_r); -void mailbox_list_get_closest_storage(struct mailbox_list *list, +void mailbox_list_get_default_storage(struct mailbox_list *list, struct mail_storage **storage); char mailbox_list_get_hierarchy_sep(struct mailbox_list *list); From dovecot at dovecot.org Thu Jun 6 11:41:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 11:41:56 +0300 Subject: dovecot-2.2: Avoid using mail_namespace.storage directly. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5ba3d95aba9d changeset: 16469:5ba3d95aba9d user: Timo Sirainen date: Thu Jun 06 11:40:27 2013 +0300 description: Avoid using mail_namespace.storage directly. diffstat: src/doveadm/doveadm-mail-altmove.c | 34 ++++++++++++--------- src/doveadm/doveadm-mail.c | 8 +++- src/lib-storage/index/shared/shared-list.c | 6 +- src/lib-storage/index/shared/shared-storage.c | 3 +- src/lib-storage/mail-storage.c | 4 +- src/lib-storage/mailbox-list.c | 4 +- src/plugins/acl/acl-backend-vfile.c | 42 ++++++++++++++++---------- src/plugins/acl/acl-shared-storage.c | 2 +- 8 files changed, 60 insertions(+), 43 deletions(-) diffs (273 lines): diff -r 3467c60014ec -r 5ba3d95aba9d src/doveadm/doveadm-mail-altmove.c --- a/src/doveadm/doveadm-mail-altmove.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/doveadm/doveadm-mail-altmove.c Thu Jun 06 11:40:27 2013 +0300 @@ -40,12 +40,13 @@ } static int -ns_purge(struct doveadm_mail_cmd_context *ctx, struct mail_namespace *ns) +ns_purge(struct doveadm_mail_cmd_context *ctx, struct mail_namespace *ns, + struct mail_storage *storage) { - if (mail_storage_purge(ns->storage) < 0) { + if (mail_storage_purge(storage) < 0) { i_error("Purging namespace '%s' failed: %s", ns->prefix, - mail_storage_get_last_error(ns->storage, NULL)); - doveadm_mail_failed_storage(ctx, ns->storage); + mail_storage_get_last_error(storage, NULL)); + doveadm_mail_failed_storage(ctx, storage); return -1; } return 0; @@ -62,7 +63,7 @@ const struct mailbox_info *info; struct mail_namespace *ns, *prev_ns = NULL; ARRAY(struct mail_storage *) purged_storages; - struct mail_storage *const *storages; + struct mail_storage *const *storages, *ns_storage, *prev_storage = NULL; unsigned int i, count; int ret = 0; @@ -70,13 +71,15 @@ iter = doveadm_mailbox_list_iter_init(_ctx, user, _ctx->search_args, iter_flags); while ((info = doveadm_mailbox_list_iter_next(iter)) != NULL) T_BEGIN { - if (info->ns != prev_ns) { - if (prev_ns != NULL) { - if (ns_purge(_ctx, prev_ns) < 0) + ns_storage = mail_namespace_get_default_storage(info->ns); + if (ns_storage != prev_storage) { + if (prev_storage != NULL) { + if (ns_purge(_ctx, prev_ns, prev_storage) < 0) ret = -1; array_append(&purged_storages, - &prev_ns->storage, 1); + &prev_storage, 1); } + prev_storage = ns_storage; prev_ns = info->ns; } if (cmd_altmove_box(_ctx, info, _ctx->search_args, ctx->reverse) < 0) @@ -85,10 +88,10 @@ if (doveadm_mailbox_list_iter_deinit(&iter) < 0) ret = -1; - if (prev_ns != NULL) { - if (ns_purge(_ctx, prev_ns) < 0) + if (prev_storage != NULL) { + if (ns_purge(_ctx, prev_ns, prev_storage) < 0) ret = -1; - array_append(&purged_storages, &prev_ns->storage, 1); + array_append(&purged_storages, &prev_storage, 1); } /* make sure all private storages have been purged */ @@ -97,14 +100,15 @@ if (ns->type != MAIL_NAMESPACE_TYPE_PRIVATE) continue; + ns_storage = mail_namespace_get_default_storage(ns); for (i = 0; i < count; i++) { - if (ns->storage == storages[i]) + if (ns_storage == storages[i]) break; } if (i == count) { - if (ns_purge(_ctx, ns) < 0) + if (ns_purge(_ctx, ns, ns_storage) < 0) ret = -1; - array_append(&purged_storages, &ns->storage, 1); + array_append(&purged_storages, &ns_storage, 1); storages = array_get(&purged_storages, &count); } } diff -r 3467c60014ec -r 5ba3d95aba9d src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/doveadm/doveadm-mail.c Thu Jun 06 11:40:27 2013 +0300 @@ -107,6 +107,7 @@ cmd_purge_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) { struct mail_namespace *ns; + struct mail_storage *storage; int ret = 0; for (ns = user->namespaces; ns != NULL; ns = ns->next) { @@ -114,10 +115,11 @@ ns->alias_for != NULL) continue; - if (mail_storage_purge(ns->storage) < 0) { + storage = mail_namespace_get_default_storage(ns); + if (mail_storage_purge(storage) < 0) { i_error("Purging namespace '%s' failed: %s", ns->prefix, - mail_storage_get_last_error(ns->storage, NULL)); - doveadm_mail_failed_storage(ctx, ns->storage); + mail_storage_get_last_error(storage, NULL)); + doveadm_mail_failed_storage(ctx, storage); ret = -1; } } diff -r 3467c60014ec -r 5ba3d95aba9d src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/lib-storage/index/shared/shared-list.c Thu Jun 06 11:40:27 2013 +0300 @@ -51,8 +51,7 @@ return -1; } *list = ns->list; - *storage_r = ns->storage; - return 0; + return mailbox_list_get_storage(list, vname, storage_r); } static char shared_list_get_hierarchy_sep(struct mailbox_list *list ATTR_UNUSED) @@ -66,7 +65,8 @@ { struct mail_namespace *ns = list->ns; - if (list->ns->storage == NULL || name == NULL || + if (mail_namespace_get_default_storage(list->ns) == NULL || + name == NULL || shared_storage_get_namespace(&ns, &name) < 0) { /* we don't have a directory we can use. */ *path_r = NULL; diff -r 3467c60014ec -r 5ba3d95aba9d src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/lib-storage/index/shared/shared-storage.c Thu Jun 06 11:40:27 2013 +0300 @@ -346,7 +346,8 @@ *_ns = new_ns; if (_storage->class_flags == 0) { /* flags are unset if we were using "auto" storage */ - _storage->class_flags = new_ns->storage->class_flags; + _storage->class_flags = + mail_namespace_get_default_storage(new_ns)->class_flags; } mail_user_add_namespace(user, &new_ns); diff -r 3467c60014ec -r 5ba3d95aba9d src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/lib-storage/mail-storage.c Thu Jun 06 11:40:27 2013 +0300 @@ -655,8 +655,8 @@ } if (mailbox_list_get_storage(&new_list, vname, &storage) < 0) { - /* just use the first storage. FIXME: does this break? */ - storage = list->ns->storage; + /* just use the default storage. FIXME: does this break? */ + storage = mail_namespace_get_default_storage(list->ns); } T_BEGIN { diff -r 3467c60014ec -r 5ba3d95aba9d src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/lib-storage/mailbox-list.c Thu Jun 06 11:40:27 2013 +0300 @@ -776,7 +776,7 @@ if ((*list)->v.get_storage != NULL) return (*list)->v.get_storage(list, vname, storage_r); else { - *storage_r = (*list)->ns->storage; + *storage_r = mail_namespace_get_default_storage((*list)->ns); return 0; } } @@ -784,7 +784,7 @@ void mailbox_list_get_default_storage(struct mailbox_list *list, struct mail_storage **storage) { - *storage = list->ns->storage; + *storage = mail_namespace_get_default_storage(list->ns); } char mailbox_list_get_hierarchy_sep(struct mailbox_list *list) diff -r 3467c60014ec -r 5ba3d95aba9d src/plugins/acl/acl-backend-vfile.c --- a/src/plugins/acl/acl-backend-vfile.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/plugins/acl/acl-backend-vfile.c Thu Jun 06 11:40:27 2013 +0300 @@ -127,35 +127,43 @@ } static const char * -acl_backend_vfile_get_local_dir(struct acl_backend *backend, const char *name) +acl_backend_vfile_get_local_dir(struct acl_backend *backend, + const char *name) { struct mail_namespace *ns = mailbox_list_get_namespace(backend->list); + struct mailbox_list *list = ns->list; + struct mail_storage *storage; enum mailbox_list_path_type type; - const char *dir, *inbox, *error; + const char *dir, *inbox, *vname, *error; if (*name == '\0') name = NULL; - else if (!mailbox_list_is_valid_name(ns->list, name, &error)) + else if (!mailbox_list_is_valid_name(list, name, &error)) return NULL; /* ACL files are very important. try to keep them among the main mail files. that's not possible though with a) if the mailbox is a file or b) if the mailbox path doesn't point to filesystem. */ - type = mail_storage_is_mailbox_file(ns->storage) || - (ns->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) != 0 ? + vname = mailbox_list_get_vname(backend->list, name); + if (mailbox_list_get_storage(&list, vname, &storage) < 0) + return NULL; + i_assert(list == ns->list); + + type = mail_storage_is_mailbox_file(storage) || + (storage->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) != 0 ? MAILBOX_LIST_PATH_TYPE_CONTROL : MAILBOX_LIST_PATH_TYPE_MAILBOX; if (name == NULL) { - if (!mailbox_list_get_root_path(ns->list, type, &dir)) + if (!mailbox_list_get_root_path(list, type, &dir)) return FALSE; } else { - if (mailbox_list_get_path(ns->list, name, type, &dir) <= 0) + if (mailbox_list_get_path(list, name, type, &dir) <= 0) return NULL; } /* verify that the directory isn't same as INBOX's directory. this is mainly for Maildir. */ if (name == NULL && - mailbox_list_get_path(ns->list, "INBOX", + mailbox_list_get_path(list, "INBOX", MAILBOX_LIST_PATH_TYPE_MAILBOX, &inbox) > 0 && strcmp(inbox, dir) == 0) { /* can't have default ACLs with this setup */ @@ -177,15 +185,17 @@ aclobj->aclobj.backend = _backend; aclobj->aclobj.name = i_strdup(name); - if (backend->global_dir != NULL) T_BEGIN { - vname = mailbox_list_get_vname(backend->backend.list, name); - aclobj->global_path = i_strconcat(backend->global_dir, "/", - vname, NULL); + T_BEGIN { + if (backend->global_dir != NULL) { + vname = mailbox_list_get_vname(backend->backend.list, name); + aclobj->global_path = + i_strconcat(backend->global_dir, "/", vname, NULL); + } + + dir = acl_backend_vfile_get_local_dir(_backend, name); + aclobj->local_path = dir == NULL ? NULL : + i_strconcat(dir, "/"ACL_FILENAME, NULL); } T_END; - - dir = acl_backend_vfile_get_local_dir(_backend, name); - aclobj->local_path = dir == NULL ? NULL : - i_strconcat(dir, "/"ACL_FILENAME, NULL); return &aclobj->aclobj; } diff -r 3467c60014ec -r 5ba3d95aba9d src/plugins/acl/acl-shared-storage.c --- a/src/plugins/acl/acl-shared-storage.c Thu Jun 06 11:16:05 2013 +0300 +++ b/src/plugins/acl/acl-shared-storage.c Thu Jun 06 11:40:27 2013 +0300 @@ -84,7 +84,7 @@ { 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 mail_storage *storage = mail_namespace_get_default_storage(ns); struct acl_lookup_dict_iter *iter; const char *name; From dovecot at dovecot.org Thu Jun 6 12:21:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 12:21:23 +0300 Subject: dovecot-2.2: lib-imap-client: Don't start another DNS lookup if ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d2756f3edb9c changeset: 16470:d2756f3edb9c user: Timo Sirainen date: Thu Jun 06 12:20:54 2013 +0300 description: lib-imap-client: Don't start another DNS lookup if there's already one ongoing. diffstat: src/lib-imap-client/imapc-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 5ba3d95aba9d -r d2756f3edb9c src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Thu Jun 06 11:40:27 2013 +0300 +++ b/src/lib-imap-client/imapc-connection.c Thu Jun 06 12:20:54 2013 +0300 @@ -1374,7 +1374,7 @@ unsigned int ips_count; int ret; - if (conn->fd != -1) { + if (conn->fd != -1 || conn->dns_lookup != NULL) { i_assert(login_callback == NULL); return; } From dovecot at dovecot.org Thu Jun 6 12:21:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 12:21:23 +0300 Subject: dovecot-2.2: lib-imap-client: Make sure DNS lookups get aborted ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/612a679aeb03 changeset: 16471:612a679aeb03 user: Timo Sirainen date: Thu Jun 06 12:21:14 2013 +0300 description: lib-imap-client: Make sure DNS lookups get aborted at disconnect. diffstat: src/lib-imap-client/imapc-connection.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diffs (37 lines): diff -r d2756f3edb9c -r 612a679aeb03 src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Thu Jun 06 12:20:54 2013 +0300 +++ b/src/lib-imap-client/imapc-connection.c Thu Jun 06 12:21:14 2013 +0300 @@ -352,7 +352,7 @@ bool reconnecting = conn->selected_box != NULL && conn->selected_box->reconnecting; - if (conn->fd == -1) + if (conn->state == IMAPC_CONNECTION_STATE_DISCONNECTED) return; if (conn->client->set.debug) @@ -366,14 +366,18 @@ timeout_remove(&conn->to); if (conn->to_output != NULL) timeout_remove(&conn->to_output); - imap_parser_unref(&conn->parser); - io_remove(&conn->io); + if (conn->parser != NULL) + imap_parser_unref(&conn->parser); + if (conn->io != NULL) + io_remove(&conn->io); if (conn->ssl_iostream != NULL) ssl_iostream_unref(&conn->ssl_iostream); - i_stream_destroy(&conn->input); - o_stream_destroy(&conn->output); - net_disconnect(conn->fd); - conn->fd = -1; + if (conn->fd != -1) { + i_stream_destroy(&conn->input); + o_stream_destroy(&conn->output); + net_disconnect(conn->fd); + conn->fd = -1; + } imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_DISCONNECTED); imapc_connection_abort_commands(conn, NULL, reconnecting); From dovecot at dovecot.org Thu Jun 6 12:24:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 12:24:37 +0300 Subject: dovecot-2.2: lib-imap-client: When switching ioloops, do it also... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8f192f64fd98 changeset: 16472:8f192f64fd98 user: Timo Sirainen date: Thu Jun 06 12:24:27 2013 +0300 description: lib-imap-client: When switching ioloops, do it also for the DNS lookup. diffstat: src/lib-imap-client/imapc-connection.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 612a679aeb03 -r 8f192f64fd98 src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Thu Jun 06 12:21:14 2013 +0300 +++ b/src/lib-imap-client/imapc-connection.c Thu Jun 06 12:24:27 2013 +0300 @@ -187,6 +187,8 @@ conn->to = io_loop_move_timeout(&conn->to); if (conn->output != NULL) o_stream_switch_ioloop(conn->output); + if (conn->dns_lookup != NULL) + dns_lookup_switch_ioloop(conn->dns_lookup); if (conn->client->ioloop == NULL && conn->to_output != NULL) { /* we're only once moving the to_output to the main ioloop, From dovecot at dovecot.org Thu Jun 6 12:36:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 12:36:47 +0300 Subject: dovecot-2.2: var_expand*(): Fixed %N to work the same with littl... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/956324a5fc86 changeset: 16473:956324a5fc86 user: Timo Sirainen date: Thu Jun 06 12:36:30 2013 +0300 description: var_expand*(): Fixed %N to work the same with little and big endian CPUs. Also use 64bit integer to do the MOD from, which should give somewhat better value distribution than with 32bit. diffstat: src/lib/var-expand.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diffs (28 lines): diff -r 8f192f64fd98 -r 956324a5fc86 src/lib/var-expand.c --- a/src/lib/var-expand.c Thu Jun 06 12:24:27 2013 +0300 +++ b/src/lib/var-expand.c Thu Jun 06 12:36:30 2013 +0300 @@ -92,17 +92,21 @@ { string_t *hash = t_str_new(20); unsigned char result[MD5_RESULTLEN]; - unsigned int value; + unsigned int i; + uint64_t value; md5_get_digest(str, strlen(str), result); - memcpy(&value, result, sizeof(value)); + for (i = 0; i < sizeof(value); i++) { + value <<= 8; + value |= result[i]; + } if (ctx->width != 0) { value %= ctx->width; ctx->width = 0; } - str_printfa(hash, "%x", value); + str_printfa(hash, "%x", (unsigned int)value); while ((int)str_len(hash) < ctx->offset) str_insert(hash, 0, "0"); ctx->offset = 0; From dovecot at dovecot.org Thu Jun 6 12:43:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 12:43:04 +0300 Subject: dovecot-2.2: var_expand*(): Added small unit tests for %H and %N Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/561f36451dc2 changeset: 16474:561f36451dc2 user: Timo Sirainen date: Thu Jun 06 12:42:34 2013 +0300 description: var_expand*(): Added small unit tests for %H and %N diffstat: src/lib/test-var-expand.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diffs (20 lines): diff -r 956324a5fc86 -r 561f36451dc2 src/lib/test-var-expand.c --- a/src/lib/test-var-expand.c Thu Jun 06 12:36:30 2013 +0300 +++ b/src/lib/test-var-expand.c Thu Jun 06 12:42:34 2013 +0300 @@ -21,9 +21,15 @@ static struct var_expand_test tests[] = { { "%{hostname}", NULL }, { "%{pid}", NULL }, - { "a%{env:FOO}b", "abaRb" } + { "a%{env:FOO}b", "abaRb" }, + { "%50Hv", "1f" }, + { "%50Hw", "2e" }, + { "%50Nv", "25" }, + { "%50Nw", "e" } }; static struct var_expand_table table[] = { + { 'v', "value", NULL }, + { 'w', "value2", NULL }, { '\0', NULL, NULL } }; string_t *str = t_str_new(128); From dovecot at dovecot.org Thu Jun 6 16:43:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Jun 2013 16:43:06 +0300 Subject: dovecot-2.2: var_expand(): Fixed initializing variable to %N Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e5bd0a7c6a1e changeset: 16475:e5bd0a7c6a1e user: Timo Sirainen date: Thu Jun 06 16:43:01 2013 +0300 description: var_expand(): Fixed initializing variable to %N diffstat: src/lib/var-expand.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 561f36451dc2 -r e5bd0a7c6a1e src/lib/var-expand.c --- a/src/lib/var-expand.c Thu Jun 06 12:42:34 2013 +0300 +++ b/src/lib/var-expand.c Thu Jun 06 16:43:01 2013 +0300 @@ -93,7 +93,7 @@ string_t *hash = t_str_new(20); unsigned char result[MD5_RESULTLEN]; unsigned int i; - uint64_t value; + uint64_t value = 0; md5_get_digest(str, strlen(str), result); for (i = 0; i < sizeof(value); i++) { From dovecot at dovecot.org Fri Jun 7 20:12:29 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 07 Jun 2013 20:12:29 +0300 Subject: dovecot-2.2: imap-login: If PLAIN mechanism is disabled, adverti... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/bee2dfd00ac5 changeset: 16476:bee2dfd00ac5 user: Timo Sirainen date: Fri Jun 07 20:12:15 2013 +0300 description: imap-login: If PLAIN mechanism is disabled, advertise LOGINDISABLED always. diffstat: src/imap-login/client.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diffs (36 lines): diff -r e5bd0a7c6a1e -r bee2dfd00ac5 src/imap-login/client.c --- a/src/imap-login/client.c Thu Jun 06 16:43:01 2013 +0300 +++ b/src/imap-login/client.c Fri Jun 07 20:12:15 2013 +0300 @@ -48,6 +48,22 @@ return FALSE; } +static bool is_login_cmd_disabled(struct client *client) +{ + if (client->secured) { + if (auth_client_find_mech(auth_client, "PLAIN") == NULL) { + /* no PLAIN authentication, can't use LOGIN command */ + return TRUE; + } + return FALSE; + } + if (client->set->disable_plaintext_auth) + return TRUE; + if (strcmp(client->ssl_set->ssl, "required") == 0) + return TRUE; + return FALSE; +} + static const char *get_capability(struct client *client) { struct imap_client *imap_client = (struct imap_client *)client; @@ -65,8 +81,7 @@ if (client_is_tls_enabled(client) && !client->tls) str_append(cap_str, " STARTTLS"); - if (!client->secured & (client->set->disable_plaintext_auth || - strcmp(client->ssl_set->ssl, "required") == 0)) + if (is_login_cmd_disabled(client)) str_append(cap_str, " LOGINDISABLED"); client_authenticate_get_capabilities(client, cap_str); From dovecot at dovecot.org Fri Jun 7 22:06:32 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 07 Jun 2013 22:06:32 +0300 Subject: dovecot-2.1: auth: Don't crash in non-plaintext auth if master u... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/98f8fd0b8d1c changeset: 14978:98f8fd0b8d1c user: Timo Sirainen date: Fri Jun 07 22:06:24 2013 +0300 description: auth: Don't crash in non-plaintext auth if master user login is tried without master passdbs. diffstat: src/auth/auth-request.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (20 lines): diff -r a88aca17a92c -r 98f8fd0b8d1c src/auth/auth-request.c --- a/src/auth/auth-request.c Wed Jun 05 18:25:32 2013 +0300 +++ b/src/auth/auth-request.c Fri Jun 07 22:06:24 2013 +0300 @@ -747,7 +747,7 @@ const char *scheme, lookup_credentials_callback_t *callback) { - struct passdb_module *passdb = request->passdb->passdb; + struct passdb_module *passdb; const char *cache_key, *cache_cred, *cache_scheme; enum passdb_result result; @@ -757,6 +757,7 @@ callback(PASSDB_RESULT_USER_UNKNOWN, NULL, 0, request); return; } + passdb = request->passdb->passdb; request->credentials_scheme = p_strdup(request->pool, scheme); request->private_callback.lookup_credentials = callback; From dovecot at dovecot.org Fri Jun 7 22:07:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 07 Jun 2013 22:07:25 +0300 Subject: dovecot-2.2: auth: Don't crash in non-plaintext auth if master u... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ee2a3cf464f4 changeset: 16477:ee2a3cf464f4 user: Timo Sirainen date: Fri Jun 07 22:06:24 2013 +0300 description: auth: Don't crash in non-plaintext auth if master user login is tried without master passdbs. diffstat: src/auth/auth-request.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (20 lines): diff -r bee2dfd00ac5 -r ee2a3cf464f4 src/auth/auth-request.c --- a/src/auth/auth-request.c Fri Jun 07 20:12:15 2013 +0300 +++ b/src/auth/auth-request.c Fri Jun 07 22:06:24 2013 +0300 @@ -836,7 +836,7 @@ const char *scheme, lookup_credentials_callback_t *callback) { - struct passdb_module *passdb = request->passdb->passdb; + struct passdb_module *passdb; const char *cache_key, *cache_cred, *cache_scheme; enum passdb_result result; @@ -846,6 +846,7 @@ callback(PASSDB_RESULT_USER_UNKNOWN, NULL, 0, request); return; } + passdb = request->passdb->passdb; request->credentials_scheme = p_strdup(request->pool, scheme); request->private_callback.lookup_credentials = callback; From dovecot at dovecot.org Sun Jun 9 00:06:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 00:06:49 +0300 Subject: dovecot-2.2: auth: If worker request has been queued for 60 secs... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dbf8bbb7e51e changeset: 16478:dbf8bbb7e51e user: Timo Sirainen date: Sun Jun 09 00:06:42 2013 +0300 description: auth: If worker request has been queued for 60 secs, abort it. diffstat: src/auth/auth-worker-server.c | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-) diffs (89 lines): diff -r ee2a3cf464f4 -r dbf8bbb7e51e src/auth/auth-worker-server.c --- a/src/auth/auth-worker-server.c Fri Jun 07 22:06:24 2013 +0300 +++ b/src/auth/auth-worker-server.c Sun Jun 09 00:06:42 2013 +0300 @@ -19,6 +19,7 @@ #define AUTH_WORKER_LOOKUP_TIMEOUT_SECS 60 #define AUTH_WORKER_MAX_IDLE_SECS (60*5) +#define AUTH_WORKER_ABORT_SECS 60 #define AUTH_WORKER_DELAY_WARN_SECS 3 #define AUTH_WORKER_DELAY_WARN_MIN_INTERVAL_SECS 300 @@ -76,20 +77,29 @@ auth_worker_destroy(&conn, "Lookup timed out", TRUE); } -static void auth_worker_request_send(struct auth_worker_connection *conn, +static bool auth_worker_request_send(struct auth_worker_connection *conn, struct auth_worker_request *request) { struct const_iovec iov[3]; + unsigned int age_secs = ioloop_time - request->created; - if (ioloop_time - request->created > AUTH_WORKER_DELAY_WARN_SECS && + if (age_secs >= AUTH_WORKER_ABORT_SECS) { + i_error("Aborting auth request that was queued for %d secs, " + "%d left in queue", + age_secs, aqueue_count(worker_request_queue)); + request->callback(t_strdup_printf( + "FAIL\t%d", PASSDB_RESULT_INTERNAL_FAILURE), + request->context); + return FALSE; + } + if (age_secs >= AUTH_WORKER_DELAY_WARN_SECS && ioloop_time - auth_worker_last_warn > AUTH_WORKER_DELAY_WARN_MIN_INTERVAL_SECS) { auth_worker_last_warn = ioloop_time; i_warning("auth workers: Auth request was queued for %d " "seconds, %d left in queue " "(see auth_worker_max_count)", - (int)(ioloop_time - request->created), - aqueue_count(worker_request_queue)); + age_secs, aqueue_count(worker_request_queue)); } request->id = ++conn->id_counter; @@ -110,20 +120,22 @@ conn->to = timeout_add(AUTH_WORKER_LOOKUP_TIMEOUT_SECS * 1000, auth_worker_call_timeout, conn); idle_count--; + return TRUE; } static void auth_worker_request_send_next(struct auth_worker_connection *conn) { struct auth_worker_request *request, *const *requestp; - if (aqueue_count(worker_request_queue) == 0) - return; + do { + if (aqueue_count(worker_request_queue) == 0) + return; - requestp = array_idx(&worker_request_array, - aqueue_idx(worker_request_queue, 0)); - request = *requestp; - aqueue_delete_tail(worker_request_queue); - auth_worker_request_send(conn, request); + requestp = array_idx(&worker_request_array, + aqueue_idx(worker_request_queue, 0)); + request = *requestp; + aqueue_delete_tail(worker_request_queue); + } while (!auth_worker_request_send(conn, request)); } static void auth_worker_send_handshake(struct auth_worker_connection *conn) @@ -410,9 +422,10 @@ conn = auth_worker_create(); } } - if (conn != NULL) - auth_worker_request_send(conn, request); - else { + if (conn != NULL) { + if (!auth_worker_request_send(conn, request)) + i_unreached(); + } else { /* reached the limit, queue the request */ aqueue_append(worker_request_queue, &request); } From dovecot at dovecot.org Sun Jun 9 00:42:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 00:42:47 +0300 Subject: dovecot-2.2: imapc: imapc_storage no longer requires imapc_mailb... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7ea508f36ca changeset: 16479:e7ea508f36ca user: Timo Sirainen date: Sun Jun 09 00:42:36 2013 +0300 description: imapc: imapc_storage no longer requires imapc_mailbox_list. diffstat: src/lib-storage/index/imapc/imapc-storage.c | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diffs (59 lines): diff -r dbf8bbb7e51e -r e7ea508f36ca src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Jun 09 00:06:42 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Jun 09 00:42:36 2013 +0300 @@ -226,6 +226,8 @@ int imapc_storage_try_get_root_sep(struct imapc_storage *storage, char *sep_r) { + i_assert(storage->list != NULL); + if (storage->root_sep == '\0') { imapc_storage_send_hierarcy_sep_lookup(storage); while (storage->root_sep_pending) @@ -292,23 +294,28 @@ set.ssl_mode = IMAPC_CLIENT_SSL_MODE_NONE; set.ssl_crypto_device = _storage->set->ssl_crypto_device; - storage->list = (struct imapc_mailbox_list *)ns->list; - storage->list->storage = storage; storage->client = imapc_client_init(&set); p_array_init(&storage->remote_namespaces, _storage->pool, 4); p_array_init(&storage->untagged_callbacks, _storage->pool, 16); + if (strcmp(ns->list->name, MAILBOX_LIST_NAME_IMAPC) == 0) { + storage->list = (struct imapc_mailbox_list *)ns->list; + storage->list->storage = storage; + imapc_list_register_callbacks(storage->list); + } + imapc_client_register_untagged(storage->client, imapc_storage_untagged_cb, storage); - imapc_list_register_callbacks(storage->list); imapc_storage_register_untagged(storage, "STATUS", imapc_untagged_status); imapc_storage_register_untagged(storage, "NAMESPACE", imapc_untagged_namespace); /* start connecting to imap server and get the hierarchy separator. */ imapc_client_login(storage->client, NULL, NULL); - imapc_storage_send_hierarcy_sep_lookup(storage); - if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { + if (storage->list != NULL) + imapc_storage_send_hierarcy_sep_lookup(storage); + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && + storage->list != NULL) { /* we're using imapc for the INBOX namespace. wait and make sure we can successfully access the IMAP server (so if the username is invalid we don't just keep failing every @@ -336,8 +343,10 @@ struct imapc_storage *storage = (struct imapc_storage *)_storage; struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; - i_assert(storage->list != NULL); - list->storage = storage; + if (strcmp(_list->name, MAILBOX_LIST_NAME_IMAPC) == 0) { + i_assert(storage->list != NULL); + list->storage = storage; + } } void imapc_storage_register_untagged(struct imapc_storage *storage, From dovecot at dovecot.org Sun Jun 9 00:46:17 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 00:46:17 +0300 Subject: dovecot-2.2: lib-storage: Added support for multiple storages pe... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d952b4091425 changeset: 16480:d952b4091425 user: Timo Sirainen date: Sun Jun 09 00:46:06 2013 +0300 description: lib-storage: Added support for multiple storages per namespace. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 6 ++- src/lib-storage/mail-namespace.c | 22 ++++++--- src/lib-storage/mail-namespace.h | 4 +- src/lib-storage/mail-storage.c | 37 ++++++++++++--- src/lib-storage/mail-storage.h | 4 + 5 files changed, 53 insertions(+), 20 deletions(-) diffs (191 lines): diff -r e7ea508f36ca -r d952b4091425 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sun Jun 09 00:42:36 2013 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sun Jun 09 00:46:06 2013 +0300 @@ -541,7 +541,11 @@ box = mailbox_alloc(ns->list, vname, MAILBOX_FLAG_READONLY | MAILBOX_FLAG_IGNORE_ACLS); - i_assert(box->storage == &ctx->storage->storage.storage); + if (box->storage != &ctx->storage->storage.storage) { + /* the namespace has multiple storages. */ + mailbox_free(&box); + return 0; + } if (mailbox_open(box) < 0) { error = mailbox_get_last_mail_error(box); i_error("Couldn't open mailbox '%s': %s", diff -r e7ea508f36ca -r d952b4091425 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Sun Jun 09 00:42:36 2013 +0300 +++ b/src/lib-storage/mail-namespace.c Sun Jun 09 00:46:06 2013 +0300 @@ -34,9 +34,9 @@ void mail_namespace_add_storage(struct mail_namespace *ns, struct mail_storage *storage) { - /* currently we support only a single storage */ - i_assert(ns->storage == NULL); - ns->storage = storage; + if (ns->storage == NULL) + ns->storage = storage; + array_append(&ns->all_storages, &storage, 1); if (storage->v.add_list != NULL) storage->v.add_list(storage, ns->list); @@ -52,8 +52,11 @@ static void mail_namespace_free(struct mail_namespace *ns) { - if (ns->storage != NULL) - mail_storage_unref(&ns->storage); + struct mail_storage **storagep; + + array_foreach_modifiable(&ns->all_storages, storagep) + mail_storage_unref(storagep); + array_free(&ns->all_storages); if (ns->list != NULL) mailbox_list_destroy(&ns->list); @@ -150,6 +153,7 @@ ns->mail_set = mail_set; ns->prefix = i_strdup(ns_set->prefix); ns->special_use_mailboxes = namespace_has_special_use_mailboxes(ns_set); + i_array_init(&ns->all_storages, 2); if (ns->type == MAIL_NAMESPACE_TYPE_SHARED && (strchr(ns->prefix, '%') != NULL || @@ -510,9 +514,12 @@ void *context) { struct mail_namespace *ns; + struct mail_storage *const *storagep; - for (ns = namespaces; ns != NULL; ns = ns->next) - mail_storage_set_callbacks(ns->storage, callbacks, context); + for (ns = namespaces; ns != NULL; ns = ns->next) { + array_foreach(&ns->all_storages, storagep) + mail_storage_set_callbacks(*storagep, callbacks, context); + } } void mail_namespace_ref(struct mail_namespace *ns) @@ -558,7 +565,6 @@ struct mail_storage * mail_namespace_get_default_storage(struct mail_namespace *ns) { - /* currently we don't support more than one storage per namespace */ return ns->storage; } diff -r e7ea508f36ca -r d952b4091425 src/lib-storage/mail-namespace.h --- a/src/lib-storage/mail-namespace.h Sun Jun 09 00:42:36 2013 +0300 +++ b/src/lib-storage/mail-namespace.h Sun Jun 09 00:46:06 2013 +0300 @@ -67,8 +67,8 @@ struct mail_user *user, *owner; struct mailbox_list *list; - /* FIXME: we should support multiple storages in one namespace */ - struct mail_storage *storage; + struct mail_storage *storage; /* default storage */ + ARRAY(struct mail_storage *) all_storages; const struct mail_namespace_settings *set, *unexpanded_set; const struct mail_storage_settings *mail_set; diff -r e7ea508f36ca -r d952b4091425 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sun Jun 09 00:42:36 2013 +0300 +++ b/src/lib-storage/mail-storage.c Sun Jun 09 00:46:06 2013 +0300 @@ -298,14 +298,15 @@ return NULL; } -int mail_storage_create(struct mail_namespace *ns, const char *driver, - enum mail_storage_flags flags, const char **error_r) +int mail_storage_create_full(struct mail_namespace *ns, const char *driver, + const char *data, enum mail_storage_flags flags, + struct mail_storage **storage_r, + const char **error_r) { struct mail_storage *storage_class, *storage = NULL; struct mailbox_list *list; struct mailbox_list_settings list_set; enum mailbox_list_flags list_flags = 0; - const char *data = ns->set->location; const char *p; if ((flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) == 0 && @@ -369,6 +370,7 @@ /* using an existing storage */ storage->refcount++; mail_namespace_add_storage(ns, storage); + *storage_r = storage; return 0; } @@ -392,10 +394,20 @@ } T_END; DLLIST_PREPEND(&ns->user->storages, storage); - mail_namespace_add_storage(ns, storage); + mail_namespace_add_storage(ns, storage); + *storage_r = storage; return 0; } +int mail_storage_create(struct mail_namespace *ns, const char *driver, + enum mail_storage_flags flags, const char **error_r) +{ + struct mail_storage *storage; + + return mail_storage_create_full(ns, driver, ns->set->location, + flags, &storage, error_r); +} + void mail_storage_unref(struct mail_storage **_storage) { struct mail_storage *storage = *_storage; @@ -639,6 +651,8 @@ struct mailbox_list *new_list = list; struct mail_storage *storage; struct mailbox *box; + enum mail_error open_error = 0; + const char *errstr = NULL; i_assert(uni_utf8_str_is_valid(vname)); @@ -654,14 +668,19 @@ vname = t_strconcat("INBOX", vname + 5, NULL); } - if (mailbox_list_get_storage(&new_list, vname, &storage) < 0) { - /* just use the default storage. FIXME: does this break? */ - storage = mail_namespace_get_default_storage(list->ns); - } + T_BEGIN { + if (mailbox_list_get_storage(&new_list, vname, &storage) < 0) { + /* do a delayed failure at mailbox_open() */ + storage = mail_namespace_get_default_storage(list->ns); + errstr = mailbox_list_get_last_error(new_list, &open_error); + errstr = t_strdup(errstr); + } - T_BEGIN { box = storage->v.mailbox_alloc(storage, new_list, vname, flags); box->set = mailbox_settings_find(storage->user, vname); + box->open_error = open_error; + if (open_error != 0) + mail_storage_set_error(storage, open_error, errstr); hook_mailbox_allocated(box); } T_END; diff -r e7ea508f36ca -r d952b4091425 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Sun Jun 09 00:42:36 2013 +0300 +++ b/src/lib-storage/mail-storage.h Sun Jun 09 00:46:06 2013 +0300 @@ -419,6 +419,10 @@ int mail_storage_create(struct mail_namespace *ns, const char *driver, enum mail_storage_flags flags, const char **error_r) ATTR_NULL(2); +int mail_storage_create_full(struct mail_namespace *ns, const char *driver, + const char *data, enum mail_storage_flags flags, + struct mail_storage **storage_r, + const char **error_r) ATTR_NULL(2); void mail_storage_unref(struct mail_storage **storage); /* Returns the mail storage settings. */ From dovecot at dovecot.org Sun Jun 9 00:48:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 00:48:19 +0300 Subject: dovecot-2.2: lib-storage: Added mailbox { driver } setting to sp... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7e91b0709f06 changeset: 16481:7e91b0709f06 user: Timo Sirainen date: Sun Jun 09 00:48:14 2013 +0300 description: lib-storage: Added mailbox { driver } setting to specify which storage to use. diffstat: src/lib-storage/mail-storage-settings.c | 4 ++- src/lib-storage/mail-storage-settings.h | 1 + src/lib-storage/mailbox-list.c | 43 +++++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diffs (98 lines): diff -r d952b4091425 -r 7e91b0709f06 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Sun Jun 09 00:46:06 2013 +0300 +++ b/src/lib-storage/mail-storage-settings.c Sun Jun 09 00:48:14 2013 +0300 @@ -118,6 +118,7 @@ DEF(SET_STR, name), { SET_ENUM, "auto", offsetof(struct mailbox_settings, autocreate), NULL } , DEF(SET_STR, special_use), + DEF(SET_STR, driver), SETTING_DEFINE_LIST_END }; @@ -127,7 +128,8 @@ .autocreate = MAILBOX_SET_AUTO_NO":" MAILBOX_SET_AUTO_CREATE":" MAILBOX_SET_AUTO_SUBSCRIBE, - .special_use = "" + .special_use = "", + .driver = "" }; const struct setting_parser_info mailbox_setting_parser_info = { diff -r d952b4091425 -r 7e91b0709f06 src/lib-storage/mail-storage-settings.h --- a/src/lib-storage/mail-storage-settings.h Sun Jun 09 00:46:06 2013 +0300 +++ b/src/lib-storage/mail-storage-settings.h Sun Jun 09 00:48:14 2013 +0300 @@ -75,6 +75,7 @@ const char *name; const char *autocreate; const char *special_use; + const char *driver; }; struct mail_user_settings { diff -r d952b4091425 -r 7e91b0709f06 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Sun Jun 09 00:46:06 2013 +0300 +++ b/src/lib-storage/mailbox-list.c Sun Jun 09 00:48:14 2013 +0300 @@ -15,7 +15,7 @@ #include "imap-utf7.h" #include "mailbox-log.h" #include "mailbox-tree.h" -#include "mail-storage.h" +#include "mail-storage-private.h" #include "mail-storage-hooks.h" #include "mailbox-list-private.h" @@ -770,15 +770,50 @@ return list->ns->user; } +static int +mailbox_list_get_storage_driver(struct mailbox_list *list, const char *driver, + struct mail_storage **storage_r) +{ + struct mail_storage *const *storagep; + const char *error, *data; + + array_foreach(&list->ns->all_storages, storagep) { + if (strcmp((*storagep)->name, driver) == 0) { + *storage_r = *storagep; + return 0; + } + } + + data = strchr(list->ns->set->location, ':'); + if (data == NULL) + data = ""; + else + data++; + if (mail_storage_create_full(list->ns, driver, data, 0, + storage_r, &error) < 0) { + mailbox_list_set_critical(list, + "Namespace %s: Failed to create storage '%s': %s", + list->ns->prefix, driver, error); + return -1; + } + return 0; +} + int mailbox_list_get_storage(struct mailbox_list **list, const char *vname, struct mail_storage **storage_r) { + const struct mailbox_settings *set; + if ((*list)->v.get_storage != NULL) return (*list)->v.get_storage(list, vname, storage_r); - else { - *storage_r = mail_namespace_get_default_storage((*list)->ns); - return 0; + + set = mailbox_settings_find((*list)->ns->user, vname); + if (set != NULL && set->driver[0] != '\0') { + return mailbox_list_get_storage_driver(*list, set->driver, + storage_r); } + *storage_r = mail_namespace_get_default_storage((*list)->ns); + return 0; } void mailbox_list_get_default_storage(struct mailbox_list *list, From dovecot at dovecot.org Sun Jun 9 02:08:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 02:08:34 +0300 Subject: dovecot-2.2: lib-http: If connect to peer failed, don't recreate... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ac78c4c88ba9 changeset: 16482:ac78c4c88ba9 user: Timo Sirainen date: Sun Jun 09 02:08:24 2013 +0300 description: lib-http: If connect to peer failed, don't recreate a new connection to handle pending requests. The new connection would very likely fail as well. Another peer for the host should pick up the requests. diffstat: src/lib-http/http-client-peer.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (31 lines): diff -r 7e91b0709f06 -r ac78c4c88ba9 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Sun Jun 09 00:48:14 2013 +0300 +++ b/src/lib-http/http-client-peer.c Sun Jun 09 02:08:24 2013 +0300 @@ -277,12 +277,12 @@ http_client_peer_debug(peer, "Failed to make connection"); + peer->last_connect_failed = TRUE; if (array_count(&peer->conns) > 1) { /* if there are other connections attempting to connect, wait for them before failing the requests. remember that we had trouble with connecting so in future we don't try to create more than one connection until connects work again. */ - peer->last_connect_failed = TRUE; } else { /* this was the only/last connection and connecting to it failed. a second connect will probably also fail, so just @@ -306,8 +306,11 @@ http_client_peer_debug(peer, "Lost a connection (%d connections left)", array_count(&peer->conns)); - /* if there are pending requests, create a new connection for them. */ - http_client_peer_handle_requests(peer); + if (!peer->last_connect_failed) { + /* if there are pending requests, create a new + connection for them. */ + http_client_peer_handle_requests(peer); + } if (array_count(&peer->conns) == 0 && http_client_peer_requests_pending(peer, &num_urgent) == 0) http_client_peer_free(&peer); From dovecot at dovecot.org Sun Jun 9 02:47:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 02:47:06 +0300 Subject: dovecot-2.2: lib-http: Added soft_connect_timeout_msecs setting ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/07f72970bf61 changeset: 16483:07f72970bf61 user: Timo Sirainen date: Sun Jun 09 02:46:50 2013 +0300 description: lib-http: Added soft_connect_timeout_msecs setting to connect to multiple IPs in parallel. Based on patch by Stephan Bosch. diffstat: src/lib-http/http-client-connection.c | 4 +- src/lib-http/http-client-host.c | 152 ++++++++++++++++++++++++++++++--- src/lib-http/http-client-peer.c | 32 +++++-- src/lib-http/http-client-private.h | 12 ++- src/lib-http/http-client.c | 1 + src/lib-http/http-client.h | 4 + 6 files changed, 177 insertions(+), 28 deletions(-) diffs (truncated from 368 to 300 lines): diff -r ac78c4c88ba9 -r 07f72970bf61 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Sun Jun 09 02:08:24 2013 +0300 +++ b/src/lib-http/http-client-connection.c Sun Jun 09 02:46:50 2013 +0300 @@ -672,13 +672,13 @@ struct stat st; conn->connected = TRUE; - conn->peer->last_connect_failed = FALSE; - if (conn->to_connect != NULL && (conn->ssl_iostream == NULL || ssl_iostream_is_handshaked(conn->ssl_iostream))) timeout_remove(&conn->to_connect); + http_client_peer_connection_success(conn->peer); + if (conn->client->set.rawlog_dir != NULL && stat(conn->client->set.rawlog_dir, &st) == 0) { iostream_rawlog_create(conn->client->set.rawlog_dir, diff -r ac78c4c88ba9 -r 07f72970bf61 src/lib-http/http-client-host.c --- a/src/lib-http/http-client-host.c Sun Jun 09 02:08:24 2013 +0300 +++ b/src/lib-http/http-client-host.c Sun Jun 09 02:46:50 2013 +0300 @@ -41,6 +41,9 @@ * Host:port */ +static void +http_client_host_port_connection_setup(struct http_client_host_port *hport); + static struct http_client_host_port * http_client_host_port_find(struct http_client_host *host, unsigned int port, const char *https_name) @@ -65,6 +68,7 @@ hport = http_client_host_port_find(host, port, https_name); if (hport == NULL) { hport = array_append_space(&host->ports); + hport->host = host; hport->port = port; hport->https_name = i_strdup(https_name); hport->ips_connect_idx = 0; @@ -110,16 +114,38 @@ } } -/* - * Host - */ +static void +http_client_host_port_soft_connect_timeout(struct http_client_host_port *hport) +{ + struct http_client_host *host = hport->host; + + if (hport->to_connect != NULL) + timeout_remove(&hport->to_connect); + + if (hport->ips_connect_idx + 1 >= host->ips_count) + return; + + /* if our our previous connection attempt takes longer than the + soft_connect_timeout we start a connection attempt to the next IP in + parallel */ + + http_client_host_debug(host, "Connection to %s:%u%s is taking a long time; " + "starting parallel connection attempt to next IP", + net_ip2addr(&host->ips[hport->ips_connect_idx]), hport->port, + hport->https_name == NULL ? "" : + t_strdup_printf(" (SSL=%s)", hport->https_name)); + + hport->ips_connect_idx++; + http_client_host_port_connection_setup(hport); +} static void -http_client_host_connection_setup(struct http_client_host *host, - struct http_client_host_port *hport) +http_client_host_port_connection_setup(struct http_client_host_port *hport) { + struct http_client_host *host = hport->host; struct http_client_peer *peer = NULL; struct http_client_peer_addr addr; + unsigned int msecs; addr.ip = host->ips[hport->ips_connect_idx]; addr.port = hport->port; @@ -131,6 +157,107 @@ peer = http_client_peer_get(host->client, &addr); http_client_peer_add_host(peer, host); + hport->pending_connection_count++; + + /* start soft connect time-out (but only if we have another IP left) */ + msecs = host->client->set.soft_connect_timeout_msecs; + if (host->ips_count - hport->ips_connect_idx > 1 && msecs > 0 && + hport->to_connect == NULL) { + hport->to_connect = + timeout_add(msecs, http_client_host_port_soft_connect_timeout, hport); + } +} + +static void +http_client_host_drop_pending_connections(struct http_client_host_port *hport) +{ + struct http_client_peer *peer; + struct http_client_connection *const *conns, *conn; + unsigned int i, count; + + for (peer = hport->host->client->peers_list; peer != NULL; peer = peer->next) { + if (!http_client_peer_have_host(peer, hport->host)) + continue; + + conns = array_get(&peer->conns, &count); + for (i = count; i > 0; i--) { + conn = conns[i-1]; + if (!conn->connected) { + i_assert(conn->refcount == 1); + /* avoid recreating the connection */ + peer->last_connect_failed = TRUE; + http_client_connection_unref(&conn); + } + } + } +} + +static void +http_client_host_port_connection_success(struct http_client_host_port *hport) +{ + /* we achieved at least one connection the the addr->ip */ + + /* stop soft connect time-out */ + if (hport->to_connect != NULL) + timeout_remove(&hport->to_connect); + + /* drop all other attempts. note that we get here whenever a connection + is successfully created, so pending_connection_count may be 0. */ + if (hport->pending_connection_count > 1) + http_client_host_drop_pending_connections(hport); + /* since this hport is now successfully connected, we won't be + getting any connection failures to it anymore. so we need + to reset the pending_connection_count count here. */ + hport->pending_connection_count = 0; +} + +static bool +http_client_host_port_connection_failure(struct http_client_host_port *hport, + const char *reason) +{ + struct http_client_host *host = hport->host; + + i_assert(hport->pending_connection_count > 0); + if (--hport->pending_connection_count > 0) + return TRUE; + + /* one of the connections failed. if we're not using soft timeouts, + we need to try to connect to the next IP. if we are using soft + timeouts, we've already tried all of the IPs by now. */ + if (hport->to_connect != NULL) + timeout_remove(&hport->to_connect); + + i_assert(hport->ips_connect_idx < host->ips_count); + if (++hport->ips_connect_idx == host->ips_count) { + /* all IPs failed, but retry all of them again on the + next request. */ + hport->ips_connect_idx = 0; + http_client_host_port_error(hport, + HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED, reason); + return FALSE; + } + + http_client_host_port_connection_setup(hport); + return TRUE; +} + +/* + * Host + */ + +void http_client_host_connection_success(struct http_client_host *host, + const struct http_client_peer_addr *addr) +{ + struct http_client_host_port *hport; + + http_client_host_debug(host, "Successfully connected to %s:%u", + net_ip2addr(&addr->ip), addr->port); + + hport = http_client_host_port_find(host, addr->port, addr->https_name); + if (hport == NULL) + return; + + http_client_host_port_connection_success(hport); } void http_client_host_connection_failure(struct http_client_host *host, @@ -145,18 +272,11 @@ if (hport == NULL) return; - i_assert(hport->ips_connect_idx < host->ips_count); - if (++hport->ips_connect_idx == host->ips_count) { - /* all IPs failed, but retry all of them again on the - next request. */ - hport->ips_connect_idx = 0; - http_client_host_port_error(hport, - HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED, reason); + if (!http_client_host_port_connection_failure(hport, reason)) { + /* failed definitively for currently queued requests */ if (host->client->ioloop != NULL) io_loop_stop(host->client->ioloop); - return; } - http_client_host_connection_setup(host, hport); } static void @@ -201,7 +321,7 @@ unsigned int count = array_count(&hport->request_queue); hport->ips_connect_idx = 0; if (count > 0) - http_client_host_connection_setup(host, hport); + http_client_host_port_connection_setup(hport); requests += count; } @@ -306,7 +426,7 @@ if (host->ips_count == 0) return; i_assert(hport->ips_connect_idx < host->ips_count); - http_client_host_connection_setup(host, hport); + http_client_host_port_connection_setup(hport); } struct http_client_request * diff -r ac78c4c88ba9 -r 07f72970bf61 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Sun Jun 09 02:08:24 2013 +0300 +++ b/src/lib-http/http-client-peer.c Sun Jun 09 02:46:50 2013 +0300 @@ -76,7 +76,8 @@ } static unsigned int -http_client_peer_requests_pending(struct http_client_peer *peer, unsigned int *num_urgent_r) +http_client_peer_requests_pending(struct http_client_peer *peer, + unsigned int *num_urgent_r) { struct http_client_host *const *host; unsigned int num_requests = 0, num_urgent = 0, requests, urgent; @@ -232,20 +233,22 @@ return peer; } -void http_client_peer_add_host(struct http_client_peer *peer, - struct http_client_host *host) +bool http_client_peer_have_host(struct http_client_peer *peer, + struct http_client_host *host) { struct http_client_host *const *host_idx; - bool exists = FALSE; array_foreach(&peer->hosts, host_idx) { - if (*host_idx == host) { - exists = TRUE; - break; - } + if (*host_idx == host) + return TRUE; } + return FALSE; +} - if (!exists) +void http_client_peer_add_host(struct http_client_peer *peer, + struct http_client_host *host) +{ + if (!http_client_peer_have_host(peer, host)) array_append(&peer->hosts, &host, 1); http_client_peer_handle_requests(peer); } @@ -267,6 +270,17 @@ return NULL; } +void http_client_peer_connection_success(struct http_client_peer *peer) +{ + struct http_client_host *const *host; + + peer->last_connect_failed = FALSE; + + array_foreach(&peer->hosts, host) { + http_client_host_connection_success(*host, &peer->addr); + } +} + void http_client_peer_connection_failure(struct http_client_peer *peer, const char *reason) { diff -r ac78c4c88ba9 -r 07f72970bf61 src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Sun Jun 09 02:08:24 2013 +0300 +++ b/src/lib-http/http-client-private.h Sun Jun 09 02:46:50 2013 +0300 @@ -71,15 +71,20 @@ }; struct http_client_host_port { From dovecot at dovecot.org Sun Jun 9 02:50:00 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 02:50:00 +0300 Subject: dovecot-2.2: man pages: Updated v2.1 -> v2.2 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1f3f21081ee5 changeset: 16484:1f3f21081ee5 user: Timo Sirainen date: Sun Jun 09 02:49:48 2013 +0300 description: man pages: Updated v2.1 -> v2.2 diffstat: doc/man/doveadm-altmove.1.in | 2 +- doc/man/doveadm-auth.1.in | 2 +- doc/man/doveadm-director.1.in | 2 +- doc/man/doveadm-dump.1.in | 2 +- doc/man/doveadm-expunge.1.in | 2 +- doc/man/doveadm-fetch.1.in | 2 +- doc/man/doveadm-force-resync.1.in | 2 +- doc/man/doveadm-help.1.in | 2 +- doc/man/doveadm-import.1.in | 2 +- doc/man/doveadm-index.1.in | 2 +- doc/man/doveadm-instance.1.in | 2 +- doc/man/doveadm-kick.1.in | 2 +- doc/man/doveadm-log.1.in | 2 +- doc/man/doveadm-mailbox.1.in | 2 +- doc/man/doveadm-mount.1.in | 2 +- doc/man/doveadm-move.1.in | 2 +- doc/man/doveadm-penalty.1.in | 2 +- doc/man/doveadm-purge.1.in | 2 +- doc/man/doveadm-pw.1.in | 2 +- doc/man/doveadm-quota.1.in | 2 +- doc/man/doveadm-search-query.7 | 2 +- doc/man/doveadm-search.1.in | 2 +- doc/man/doveadm-user.1.in | 2 +- doc/man/doveadm-who.1.in | 2 +- doc/man/doveadm.1.in | 2 +- doc/man/doveconf.1.in | 2 +- doc/man/dovecot-lda.1.in | 2 +- doc/man/dovecot.1.in | 4 ++-- doc/man/dsync.1.in | 2 +- 29 files changed, 30 insertions(+), 30 deletions(-) diffs (299 lines): diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-altmove.1.in --- a/doc/man/doveadm-altmove.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-altmove.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file -.TH DOVEADM\-ALTMOVE 1 "2011-09-15" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-ALTMOVE 1 "2011-09-15" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-altmove \- Move matching mails to the alternative storage (dbox\-only) .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-auth.1.in --- a/doc/man/doveadm-auth.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-auth.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-AUTH 1 "2010-06-09" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-AUTH 1 "2010-06-09" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-auth \- Test authentication for a user .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-director.1.in --- a/doc/man/doveadm-director.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-director.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-DIRECTOR 1 "2011-05-11" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-DIRECTOR 1 "2011-05-11" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-director \- Manage Dovecot directors .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-dump.1.in --- a/doc/man/doveadm-dump.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-dump.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-DUMP 1 "2012-02-21" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-DUMP 1 "2012-02-21" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-dump \- Dump the content of Dovecot\(aqs binary mailbox index/log .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-expunge.1.in --- a/doc/man/doveadm-expunge.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-expunge.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-EXPUNGE 1 "2012-11-27" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-EXPUNGE 1 "2012-11-27" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-expunge \- Expunge messages matching given search query .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-fetch.1.in --- a/doc/man/doveadm-fetch.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-fetch.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-FETCH 1 "2012-02-13" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-FETCH 1 "2012-02-13" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-fetch \- Fetch partial/full messages or message information .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-force-resync.1.in --- a/doc/man/doveadm-force-resync.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-force-resync.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-FORCE\-RESYNC 1 "2010-11-25" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-FORCE\-RESYNC 1 "2010-11-25" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-force\-resync \- Repair broken mailboxes .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-help.1.in --- a/doc/man/doveadm-help.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-help.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-HELP 1 "2010-06-22" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-HELP 1 "2010-06-22" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-help \- Show information about doveadm commands .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-import.1.in --- a/doc/man/doveadm-import.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-import.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-IMPORT 1 "2010-11-26" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-IMPORT 1 "2010-11-26" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-import \- Import messages matching given search query .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-index.1.in --- a/doc/man/doveadm-index.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-index.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file -.TH DOVEADM\-INDEX 1 "2011-05-11" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-INDEX 1 "2011-05-11" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-index \- Index mailboxes .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-instance.1.in --- a/doc/man/doveadm-instance.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-instance.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-INSTANCE 1 "2012-02-16" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-INSTANCE 1 "2012-02-16" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-instance \- Manage the list of running Dovecot instances .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-kick.1.in --- a/doc/man/doveadm-kick.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-kick.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-KICK 1 "2010-06-12" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-KICK 1 "2010-06-12" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-kick \- Disconnect users by user name and/or IP address .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-log.1.in --- a/doc/man/doveadm-log.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-log.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-LOG 1 "2012-02-22" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-LOG 1 "2012-02-22" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-log \- Locate, test or reopen Dovecot\(aqs log files .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-mailbox.1.in --- a/doc/man/doveadm-mailbox.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-mailbox.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-MAILBOX 1 "2010-11-25" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-MAILBOX 1 "2010-11-25" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-mailbox \- Commands related to handling mailboxes .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-mount.1.in --- a/doc/man/doveadm-mount.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-mount.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-MOUNT 1 "2012-02-16" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-MOUNT 1 "2012-02-16" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-mount \- Manage the list of mountpoints where mails are stored .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-move.1.in --- a/doc/man/doveadm-move.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-move.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2011 Dovecot authors, see the included COPYING file -.TH DOVEADM\-MOVE 1 "2011-09-25" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-MOVE 1 "2011-09-25" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-move \- Move messages matching the given search query into another mailbox diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-penalty.1.in --- a/doc/man/doveadm-penalty.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-penalty.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-PENALTY 1 "2010-07-12" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-PENALTY 1 "2010-07-12" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-penalty \- Show current penalties .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-purge.1.in --- a/doc/man/doveadm-purge.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-purge.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-PURGE 1 "2010-11-25" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-PURGE 1 "2010-11-25" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-purge \- Remove messages with refcount=0 from mdbox files .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-pw.1.in --- a/doc/man/doveadm-pw.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-pw.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-PW 1 "2012-02-13" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-PW 1 "2012-02-13" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-pw \- Dovecot\(aqs password hash generator .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-quota.1.in --- a/doc/man/doveadm-quota.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-quota.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file -.TH DOVEADM\-QUOTA 1 "2011-02-17" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-QUOTA 1 "2011-02-17" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-quota \- Initialize/recalculate or show current quota usage .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-search-query.7 --- a/doc/man/doveadm-search-query.7 Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-search-query.7 Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-SEARCH\-QUERY 7 "2011-11-24" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-SEARCH\-QUERY 7 "2011-11-24" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-search\-query \- Overview of search queries for doveadm mailbox \ commands diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-search.1.in --- a/doc/man/doveadm-search.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-search.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-SEARCH 1 "2010-11-25" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-SEARCH 1 "2010-11-25" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-search \- Show a list of mailbox GUIDs and message UIDs matching \ given search query. diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-user.1.in --- a/doc/man/doveadm-user.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-user.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file -.TH DOVEADM\-USER 1 "2011-11-04" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-USER 1 "2011-11-04" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-user \- Perform a user lookup in Dovecot\(aqs userdbs .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm-who.1.in --- a/doc/man/doveadm-who.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm-who.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-WHO 1 "2010-07-12" "Dovecot v2.1" "Dovecot" +.TH DOVEADM\-WHO 1 "2010-07-12" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-who \- Show who is logged in to the Dovecot server .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveadm.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM 1 "2011-05-11" "Dovecot v2.1" "Dovecot" +.TH DOVEADM 1 "2011-05-11" "Dovecot v2.2" "Dovecot" .SH NAME doveadm \- Dovecot\(aqs administration utility .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/doveconf.1.in --- a/doc/man/doveconf.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/doveconf.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file -.TH DOVECONF 1 "2012-01-29" "Dovecot v2.1" "Dovecot" +.TH DOVECONF 1 "2012-01-29" "Dovecot v2.2" "Dovecot" .SH NAME doveconf \- Dovecot\(aqs configuration dumping utility .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/dovecot-lda.1.in --- a/doc/man/dovecot-lda.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/dovecot-lda.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVECOT\-LDA 1 "2011-01-16" "Dovecot v2.1" "Dovecot" +.TH DOVECOT\-LDA 1 "2011-01-16" "Dovecot v2.2" "Dovecot" .SH NAME dovecot\-lda \- Dovecot\(aqs local mail delivery agent .\"------------------------------------------------------------------------ diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/dovecot.1.in --- a/doc/man/dovecot.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/dovecot.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVECOT 1 "2010-07-02" "Dovecot v2.1" "Dovecot" +.TH DOVECOT 1 "2010-07-02" "Dovecot v2.2" "Dovecot" .SH NAME dovecot \- a secure and highly configurable IMAP and POP3 server .\"------------------------------------------------------------------------ @@ -148,7 +148,7 @@ .SH AUTHOR Dovecot and its manual pages were written by the Dovecot authors , mainly Timo Sirainen , and are licensed under the terms of the MIT and LGPLv2.1 +at iki.fi>, and are licensed under the terms of the MIT and LGPLv2.2 licenses, see for details. .\"------------------------------------------------------------------------ .SH SEE ALSO diff -r 07f72970bf61 -r 1f3f21081ee5 doc/man/dsync.1.in --- a/doc/man/dsync.1.in Sun Jun 09 02:46:50 2013 +0300 +++ b/doc/man/dsync.1.in Sun Jun 09 02:49:48 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DSYNC 1 "2011-01-16" "Dovecot v2.1" "Dovecot" +.TH DSYNC 1 "2011-01-16" "Dovecot v2.2" "Dovecot" .SH NAME dsync \- Dovecot\(aqs mailbox synchronization utility .\"------------------------------------------------------------------------ From dovecot at dovecot.org Sun Jun 9 03:10:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 03:10:55 +0300 Subject: dovecot-2.2: fts-lucene: Support normalize setting also without ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7e54af474ea4 changeset: 16485:7e54af474ea4 user: Timo Sirainen date: Sun Jun 09 03:10:43 2013 +0300 description: fts-lucene: Support normalize setting also without snowball. Added no_snowball setting. Snowball seems to be converting / breaking words down rather annoyingly. diffstat: src/plugins/fts-lucene/fts-lucene-plugin.c | 9 ++--- src/plugins/fts-lucene/fts-lucene-plugin.h | 1 + src/plugins/fts-lucene/lucene-wrapper.cc | 43 ++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 13 deletions(-) diffs (126 lines): diff -r 1f3f21081ee5 -r 7e54af474ea4 src/plugins/fts-lucene/fts-lucene-plugin.c --- a/src/plugins/fts-lucene/fts-lucene-plugin.c Sun Jun 09 02:49:48 2013 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Sun Jun 09 03:10:43 2013 +0300 @@ -30,6 +30,8 @@ set->whitespace_chars = p_strdup(user->pool, *tmp + 17); } else if (strcmp(*tmp, "normalize") == 0) { set->normalize = TRUE; + } else if (strcmp(*tmp, "no_snowball") == 0) { + set->no_snowball = TRUE; } else { i_error("fts_lucene: Invalid setting: %s", *tmp); return -1; @@ -51,11 +53,6 @@ "but Dovecot built without stemmer support"); return -1; } - if (set->normalize) { - i_error("fts_lucene: normalize not currently supported " - "without stemmer support"); - return -1; - } #else if (set->default_language == NULL) set->default_language = "english"; @@ -80,6 +77,8 @@ crc = crc32_str_more(crc, set->whitespace_chars); if (set->normalize) crc = crc32_str_more(crc, "n"); + if (set->no_snowball) + crc = crc32_str_more(crc, "s"); return crc; } diff -r 1f3f21081ee5 -r 7e54af474ea4 src/plugins/fts-lucene/fts-lucene-plugin.h --- a/src/plugins/fts-lucene/fts-lucene-plugin.h Sun Jun 09 02:49:48 2013 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.h Sun Jun 09 03:10:43 2013 +0300 @@ -13,6 +13,7 @@ const char *textcat_conf, *textcat_dir; const char *whitespace_chars; bool normalize; + bool no_snowball; }; struct fts_lucene_user { diff -r 1f3f21081ee5 -r 7e54af474ea4 src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Sun Jun 09 02:49:48 2013 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Sun Jun 09 03:10:43 2013 +0300 @@ -67,6 +67,7 @@ IndexWriter *writer; IndexSearcher *searcher; + buffer_t *normalizer_buf; Analyzer *default_analyzer, *cur_analyzer; ARRAY(struct lucene_analyzer) analyzers; @@ -118,13 +119,20 @@ index->set.default_language = ""; } #ifdef HAVE_LUCENE_STEMMER - index->default_analyzer = - _CLNEW snowball::SnowballAnalyzer(index->normalizer, - index->set.default_language); -#else - index->default_analyzer = _CLNEW standard::StandardAnalyzer(); - i_assert(index->normalizer == NULL); + if (!set->no_snowball) { + index->default_analyzer = + _CLNEW snowball::SnowballAnalyzer(index->normalizer, + index->set.default_language); + } #endif + else { + index->default_analyzer = _CLNEW standard::StandardAnalyzer(); + if (index->normalizer != NULL) { + index->normalizer_buf = + buffer_create_dynamic(default_pool, 1024); + } + } + i_array_init(&index->analyzers, 32); textcat_refcount++; @@ -155,6 +163,8 @@ textcat = NULL; } _CLDELETE(index->default_analyzer); + if (index->normalizer_buf != NULL) + buffer_free(&index->normalizer_buf); i_free(index->path); i_free(index); } @@ -517,6 +527,13 @@ index->doc->add(*_CLNEW Field(_T("box"), index->mailbox_guid, Field::STORE_YES | Field::INDEX_UNTOKENIZED)); } + if (index->normalizer_buf != NULL) { + buffer_set_used_size(index->normalizer_buf, 0); + index->normalizer(data, size, index->normalizer_buf); + data = (const unsigned char *)index->normalizer_buf->data; + size = index->normalizer_buf->used; + } + datasize = uni_utf8_strlen_n(data, size) + 1; wchar_t dest[datasize]; lucene_utf8_n_to_tchar(data, size, dest, datasize); @@ -1055,8 +1072,18 @@ lucene_get_query_str(struct lucene_index *index, const TCHAR *key, const char *str, bool fuzzy) { - const TCHAR *wvalue = t_lucene_utf8_to_tchar(index, str, TRUE); - Analyzer *analyzer = guess_analyzer(index, str, strlen(str)); + const TCHAR *wvalue; + Analyzer *analyzer; + + if (index->normalizer_buf != NULL) { + buffer_set_used_size(index->normalizer_buf, 0); + index->normalizer(str, strlen(str), index->normalizer_buf); + buffer_append_c(index->normalizer_buf, '\0'); + str = (const char *)index->normalizer_buf->data; + } + + wvalue = t_lucene_utf8_to_tchar(index, str, TRUE); + analyzer = guess_analyzer(index, str, strlen(str)); if (analyzer == NULL) analyzer = index->default_analyzer; From dovecot at dovecot.org Sun Jun 9 06:03:51 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 06:03:51 +0300 Subject: dovecot-2.2: Added initial libsasl for implementing client side ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1cbff0a8a849 changeset: 16486:1cbff0a8a849 user: Timo Sirainen date: Sun Jun 09 06:02:14 2013 +0300 description: Added initial libsasl for implementing client side SASL library. Initially supports PLAIN and LOGIN mechanisms. diffstat: configure.ac | 3 +- src/Makefile.am | 1 + src/lib-dovecot/Makefile.am | 1 + src/lib-sasl/Makefile.am | 16 +++++ src/lib-sasl/mech-login.c | 73 +++++++++++++++++++++++++ src/lib-sasl/mech-plain.c | 68 ++++++++++++++++++++++++ src/lib-sasl/sasl-client-private.h | 33 +++++++++++ src/lib-sasl/sasl-client.c | 104 +++++++++++++++++++++++++++++++++++++ src/lib-sasl/sasl-client.h | 38 +++++++++++++ 9 files changed, 336 insertions(+), 1 deletions(-) diffs (truncated from 398 to 300 lines): diff -r 7e54af474ea4 -r 1cbff0a8a849 configure.ac --- a/configure.ac Sun Jun 09 03:10:43 2013 +0300 +++ b/configure.ac Sun Jun 09 06:02:14 2013 +0300 @@ -2559,7 +2559,7 @@ LIBDOVECOT_COMPRESS='$(top_builddir)/src/lib-compression/libcompression.la' LIBDOVECOT_LDA='$(top_builddir)/src/lib-lda/libdovecot-lda.la' else - LIBDOVECOT_DEPS='$(top_builddir)/src/lib-master/libmaster.la $(top_builddir)/src/lib-settings/libsettings.la $(top_builddir)/src/lib-http/libhttp.la $(top_builddir)/src/lib-dict/libdict.la $(top_builddir)/src/lib-dns/libdns.la $(top_builddir)/src/lib-fs/libfs.la $(top_builddir)/src/lib-imap/libimap.la $(top_builddir)/src/lib-mail/libmail.la $(top_builddir)/src/lib-auth/libauth.la $(top_builddir)/src/lib-charset/libcharset.la $(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la $(top_builddir)/src/lib-test/libtest.la $(top_builddir)/src/lib/liblib.la' + LIBDOVECOT_DEPS='$(top_builddir)/src/lib-master/libmaster.la $(top_builddir)/src/lib-settings/libsettings.la $(top_builddir)/src/lib-http/libhttp.la $(top_builddir)/src/lib-dict/libdict.la $(top_builddir)/src/lib-dns/libdns.la $(top_builddir)/src/lib-fs/libfs.la $(top_builddir)/src/lib-imap/libimap.la $(top_builddir)/src/lib-mail/libmail.la $(top_builddir)/src/lib-sasl/libsasl.la $(top_builddir)/src/lib-auth/libauth.la $(top_builddir)/src/lib-charset/libcharset.la $(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la $(top_builddir)/src/lib-test/libtest.la $(top_builddir)/src/lib/liblib.la' LIBDOVECOT="$LIBDOVECOT_DEPS \$(LIBICONV) \$(MODULE_LIBS)" LIBDOVECOT_STORAGE_LAST='$(top_builddir)/src/lib-storage/list/libstorage_list.la $(top_builddir)/src/lib-storage/index/libstorage_index.la $(top_builddir)/src/lib-storage/libstorage.la $(top_builddir)/src/lib-index/libindex.la $(top_builddir)/src/lib-imap-storage/libimap-storage.la' LIBDOVECOT_STORAGE_FIRST='$(top_builddir)/src/lib-storage/libstorage_service.la $(top_builddir)/src/lib-storage/register/libstorage_register.la' @@ -2822,6 +2822,7 @@ src/lib-ntlm/Makefile src/lib-otp/Makefile src/lib-dovecot/Makefile +src/lib-sasl/Makefile src/lib-settings/Makefile src/lib-ssl-iostream/Makefile src/lib-test/Makefile diff -r 7e54af474ea4 -r 1cbff0a8a849 src/Makefile.am --- a/src/Makefile.am Sun Jun 09 03:10:43 2013 +0300 +++ b/src/Makefile.am Sun Jun 09 06:02:14 2013 +0300 @@ -7,6 +7,7 @@ lib-charset \ lib-dns \ lib-dict \ + lib-sasl \ lib-ssl-iostream \ lib-http \ lib-fs \ diff -r 7e54af474ea4 -r 1cbff0a8a849 src/lib-dovecot/Makefile.am --- a/src/lib-dovecot/Makefile.am Sun Jun 09 03:10:43 2013 +0300 +++ b/src/lib-dovecot/Makefile.am Sun Jun 09 06:02:14 2013 +0300 @@ -7,6 +7,7 @@ ../lib-dict/libdict.la \ ../lib-imap/libimap.la \ ../lib-mail/libmail.la \ + ../lib-sasl/libsasl.la \ ../lib-auth/libauth.la \ ../lib-dns/libdns.la \ ../lib-charset/libcharset.la \ diff -r 7e54af474ea4 -r 1cbff0a8a849 src/lib-sasl/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/Makefile.am Sun Jun 09 06:02:14 2013 +0300 @@ -0,0 +1,16 @@ +noinst_LTLIBRARIES = libsasl.la + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib + +libsasl_la_SOURCES = \ + mech-login.c \ + mech-plain.c \ + sasl-client.c + +headers = \ + sasl-client.h \ + sasl-client-private.h + +pkginc_libdir=$(pkgincludedir) +pkginc_lib_HEADERS = $(headers) diff -r 7e54af474ea4 -r 1cbff0a8a849 src/lib-sasl/mech-login.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/mech-login.c Sun Jun 09 06:02:14 2013 +0300 @@ -0,0 +1,73 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "str.h" +#include "sasl-client-private.h" + +enum login_state { + STATE_INIT = 0, + STATE_USER, + STATE_PASS +}; + +struct login_sasl_client { + struct sasl_client client; + enum login_state state; +}; + +static int +mech_login_input(struct sasl_client *_client, + const unsigned char *input ATTR_UNUSED, + unsigned int input_len ATTR_UNUSED, + const char **error_r) +{ + struct login_sasl_client *client = (struct login_sasl_client *)_client; + + if (client->state == STATE_PASS) { + *error_r = "Server didn't finish authentication"; + return -1; + } + client->state++; + return 0; +} + +static int +mech_login_output(struct sasl_client *_client, + const unsigned char **output_r, unsigned int *output_len_r, + const char **error_r) +{ + struct login_sasl_client *client = (struct login_sasl_client *)_client; + + if (_client->set.authid == NULL) { + *error_r = "authid not set"; + return -1; + } + if (_client->password == NULL) { + *error_r = "password not set"; + return -1; + } + + switch (client->state) { + case STATE_INIT: + *output_r = &uchar_nul; + *output_len_r = 0; + return 0; + case STATE_USER: + *output_r = (const unsigned char *)_client->set.authid; + *output_len_r = strlen(_client->set.authid); + return 0; + case STATE_PASS: + *output_r = (const unsigned char *)_client->set.password; + *output_len_r = strlen(_client->set.password); + return 0; + } + i_unreached(); +} + +const struct sasl_client_mech sasl_client_mech_login = { + .name = "LOGIN", + .struct_size = sizeof(struct login_sasl_client), + + .input = mech_login_input, + .output = mech_login_output +}; diff -r 7e54af474ea4 -r 1cbff0a8a849 src/lib-sasl/mech-plain.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/mech-plain.c Sun Jun 09 06:02:14 2013 +0300 @@ -0,0 +1,68 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "str.h" +#include "sasl-client-private.h" + +struct plain_sasl_client { + struct sasl_client client; + bool output_sent; +}; + +static int +mech_plain_input(struct sasl_client *_client, + const unsigned char *input ATTR_UNUSED, unsigned int input_len, + const char **error_r) +{ + struct plain_sasl_client *client = (struct plain_sasl_client *)_client; + + if (!client->output_sent) { + if (input_len > 0) { + *error_r = "Server sent non-empty initial response"; + return -1; + } + } else { + *error_r = "Server didn't finish authentication"; + return -1; + } + return 0; +} + +static int +mech_plain_output(struct sasl_client *_client, + const unsigned char **output_r, unsigned int *output_len_r, + const char **error_r) +{ + struct plain_sasl_client *client = (struct plain_sasl_client *)_client; + string_t *str; + + if (_client->set.authid == NULL) { + *error_r = "authid not set"; + return -1; + } + if (_client->password == NULL) { + *error_r = "password not set"; + return -1; + } + + str = str_new(_client->pool, 64); + if (_client->set.authzid != NULL) + str_append(str, _client->set.authzid); + str_append_c(str, '\0'); + str_append(str, _client->set.authid); + str_append_c(str, '\0'); + str_append(str, _client->password); + + *output_r = str_data(str); + *output_len_r = str_len(str); + client->output_sent = TRUE; + return 0; +} + +const struct sasl_client_mech sasl_client_mech_plain = { + .name = "PLAIN", + .struct_size = sizeof(struct plain_sasl_client), + + .input = mech_plain_input, + .output = mech_plain_output +}; diff -r 7e54af474ea4 -r 1cbff0a8a849 src/lib-sasl/sasl-client-private.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/sasl-client-private.h Sun Jun 09 06:02:14 2013 +0300 @@ -0,0 +1,33 @@ +#ifndef SASL_CLIENT_PRIVATE_H +#define SASL_CLIENT_PRIVATE_H + +#include "sasl-client.h" + +struct sasl_client { + pool_t pool; + struct sasl_client_settings set; + char *password; + const struct sasl_client_mech *mech; +}; + +struct sasl_client_mech { + const char *name; + size_t struct_size; + + int (*input)(struct sasl_client *client, + const unsigned char *input, + unsigned int input_len, + const char **error_r); + int (*output)(struct sasl_client *client, + const unsigned char **output_r, + unsigned int *output_len_r, + const char **error_r); + void (*free)(struct sasl_client *client); +}; + +extern const struct sasl_client_mech sasl_client_mech_login; + +void sasl_client_mech_register(const struct sasl_client_mech *mech); +void sasl_client_mech_unregister(const struct sasl_client_mech *mech); + +#endif diff -r 7e54af474ea4 -r 1cbff0a8a849 src/lib-sasl/sasl-client.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/sasl-client.c Sun Jun 09 06:02:14 2013 +0300 @@ -0,0 +1,104 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "safe-memset.h" +#include "sasl-client-private.h" + +static ARRAY(const struct sasl_client_mech *) sasl_mechanisms = ARRAY_INIT; + +static const struct sasl_client_mech * +sasl_client_mech_find_idx(const char *name, unsigned int *idx_r) +{ + const struct sasl_client_mech *const *mechp; + + array_foreach(&sasl_mechanisms, mechp) { + if (strcasecmp((*mechp)->name, name) == 0) { + *idx_r = array_foreach_idx(&sasl_mechanisms, mechp); + return *mechp; + } + } + return NULL; +} + +const struct sasl_client_mech *sasl_client_mech_find(const char *name) +{ + unsigned int idx; + + return sasl_client_mech_find_idx(name, &idx); +} + +const char *sasl_client_mech_get_name(const struct sasl_client_mech *mech) +{ + return mech->name; +} + +void sasl_client_mech_register(const struct sasl_client_mech *mech) +{ + array_append(&sasl_mechanisms, &mech, 1); +} + +void sasl_client_mech_unregister(const struct sasl_client_mech *mech) +{ + unsigned int idx; + + if (sasl_client_mech_find_idx(mech->name, &idx) == NULL) + i_panic("SASL mechanism not registered: %s", mech->name); + array_delete(&sasl_mechanisms, idx, 1); +} From dovecot at dovecot.org Sun Jun 9 06:03:51 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 06:03:51 +0300 Subject: dovecot-2.2: imap/pop3-login: Use libsasl for authenticating to ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/266101990d63 changeset: 16487:266101990d63 user: Timo Sirainen date: Sun Jun 09 06:03:34 2013 +0300 description: imap/pop3-login: Use libsasl for authenticating to remote IMAP/POP3 server. Also passdb lookup can return "proxy_mech" extra field to specify which SASL mechanism to use. diffstat: src/imap-login/Makefile.am | 1 + src/imap-login/client.h | 1 - src/imap-login/imap-proxy.c | 101 +++++++++++++++++------- src/login-common/Makefile.am | 1 + src/login-common/client-common-auth.c | 23 +++++ src/login-common/client-common.c | 3 + src/login-common/client-common.h | 4 +- src/login-common/main.c | 3 + src/pop3-login/Makefile.am | 1 + src/pop3-login/pop3-proxy.c | 137 ++++++++++++++++++++++++--------- 10 files changed, 205 insertions(+), 70 deletions(-) diffs (truncated from 560 to 300 lines): diff -r 1cbff0a8a849 -r 266101990d63 src/imap-login/Makefile.am --- a/src/imap-login/Makefile.am Sun Jun 09 06:02:14 2013 +0300 +++ b/src/imap-login/Makefile.am Sun Jun 09 06:03:34 2013 +0300 @@ -6,6 +6,7 @@ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-settings \ -I$(top_srcdir)/src/lib-auth \ + -I$(top_srcdir)/src/lib-sasl \ -I$(top_srcdir)/src/lib-imap \ -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/login-common diff -r 1cbff0a8a849 -r 266101990d63 src/imap-login/client.h --- a/src/imap-login/client.h Sun Jun 09 06:02:14 2013 +0300 +++ b/src/imap-login/client.h Sun Jun 09 06:03:34 2013 +0300 @@ -19,7 +19,6 @@ unsigned int cmd_finished:1; unsigned int proxy_sasl_ir:1; unsigned int proxy_seen_banner:1; - unsigned int proxy_wait_auth_continue:1; unsigned int skip_line:1; unsigned int id_logged:1; unsigned int client_ignores_capability_resp_code:1; diff -r 1cbff0a8a849 -r 266101990d63 src/imap-login/imap-proxy.c --- a/src/imap-login/imap-proxy.c Sun Jun 09 06:02:14 2013 +0300 +++ b/src/imap-login/imap-proxy.c Sun Jun 09 06:03:34 2013 +0300 @@ -9,6 +9,7 @@ #include "str.h" #include "str-sanitize.h" #include "safe-memset.h" +#include "sasl-client.h" #include "client.h" #include "client-authenticate.h" #include "imap-resp-code.h" @@ -55,42 +56,55 @@ i_free_and_null(client->proxy_password); } -static void get_plain_auth(struct client *client, string_t *dest) +static int proxy_write_login(struct imap_client *client, string_t *str) { - string_t *str; + struct sasl_client_settings sasl_set; + const unsigned char *output; + unsigned int len; + const char *mech_name, *error; - str = t_str_new(128); - str_append(str, client->proxy_user); - str_append_c(str, '\0'); - str_append(str, client->proxy_master_user); - str_append_c(str, '\0'); - str_append(str, client->proxy_password); - base64_encode(str_data(str), str_len(str), dest); -} - -static void proxy_write_login(struct imap_client *client, string_t *str) -{ str_append(str, "C CAPABILITY\r\n"); - if (client->common.proxy_master_user == NULL) { + if (client->common.proxy_mech == NULL) { /* logging in normally - use LOGIN command */ str_append(str, "L LOGIN "); imap_append_string(str, client->common.proxy_user); str_append_c(str, ' '); imap_append_string(str, client->common.proxy_password); + str_append(str, "\r\n"); proxy_free_password(&client->common); - } else if (client->proxy_sasl_ir) { - /* master user login with SASL initial response support */ - str_append(str, "L AUTHENTICATE PLAIN "); - get_plain_auth(&client->common, str); - proxy_free_password(&client->common); - } else { - /* master user login without SASL initial response */ - str_append(str, "L AUTHENTICATE PLAIN"); - client->proxy_wait_auth_continue = TRUE; + return 0; + } + + i_assert(client->common.proxy_sasl_client == NULL); + memset(&sasl_set, 0, sizeof(sasl_set)); + sasl_set.authid = client->common.proxy_user; + sasl_set.authzid = client->common.proxy_master_user; + sasl_set.password = client->common.proxy_password; + client->common.proxy_sasl_client = + sasl_client_new(client->common.proxy_mech, &sasl_set); + mech_name = sasl_client_mech_get_name(client->common.proxy_mech); + + str_append(str, "L AUTHENTICATE "); + str_append(str, mech_name); + if (client->proxy_sasl_ir) { + if (sasl_client_output(client->common.proxy_sasl_client, + &output, &len, &error) < 0) { + client_log_err(&client->common, t_strdup_printf( + "proxy: SASL mechanism %s init failed: %s", + mech_name, error)); + return -1; + } + str_append_c(str, ' '); + if (len == 0) + str_append_c(str, '='); + else + base64_encode(output, len, str); } str_append(str, "\r\n"); + proxy_free_password(&client->common); + return 0; } static int proxy_input_banner(struct imap_client *client, @@ -126,7 +140,8 @@ } str_append(str, "S STARTTLS\r\n"); } else { - proxy_write_login(client, str); + if (proxy_write_login(client, str) < 0) + return -1; } o_stream_nsend(output, str_data(str), str_len(str)); @@ -173,6 +188,10 @@ struct imap_client *imap_client = (struct imap_client *)client; struct ostream *output; string_t *str; + const unsigned char *data; + unsigned int data_len; + const char *error; + int ret; i_assert(!client->destroyed); @@ -188,17 +207,37 @@ return 0; } else if (*line == '+') { /* AUTHENTICATE started. finish it. */ - if (!imap_client->proxy_wait_auth_continue) { + if (client->proxy_sasl_client == NULL) { /* used literals with LOGIN command, just ignore. */ return 0; } client->proxy_state = IMAP_PROXY_STATE_AUTH_CONTINUE; - imap_client->proxy_wait_auth_continue = FALSE; str = t_str_new(128); - get_plain_auth(client, str); + if (line[1] != ' ' || + base64_decode(line+2, strlen(line+2), NULL, str) < 0) { + client_log_err(client, + "proxy: Server sent invalid base64 data in AUTHENTICATE response"); + client_proxy_failed(client, TRUE); + return -1; + } + ret = sasl_client_input(client->proxy_sasl_client, + str_data(str), str_len(str), &error); + if (ret == 0) { + ret = sasl_client_output(client->proxy_sasl_client, + &data, &data_len, &error); + } + if (ret < 0) { + client_log_err(client, t_strdup_printf( + "proxy: Server sent invalid authentication data: %s", + error)); + client_proxy_failed(client, TRUE); + return -1; + } + + str_truncate(str, 0); + base64_encode(data, data_len, str); str_append(str, "\r\n"); - proxy_free_password(client); o_stream_nsend(output, str_data(str), str_len(str)); return 0; @@ -220,7 +259,10 @@ /* i/ostreams changed. */ output = login_proxy_get_ostream(client->login_proxy); str = t_str_new(128); - proxy_write_login(imap_client, str); + if (proxy_write_login(imap_client, str) < 0) { + client_proxy_failed(client, TRUE); + return -1; + } o_stream_nsend(output, str_data(str), str_len(str)); return 1; } else if (strncmp(line, "L OK ", 5) == 0) { @@ -305,7 +347,6 @@ imap_client->proxy_sasl_ir = FALSE; imap_client->proxy_seen_banner = FALSE; - imap_client->proxy_wait_auth_continue = FALSE; client->proxy_state = IMAP_PROXY_STATE_NONE; } diff -r 1cbff0a8a849 -r 266101990d63 src/login-common/Makefile.am --- a/src/login-common/Makefile.am Sun Jun 09 06:02:14 2013 +0300 +++ b/src/login-common/Makefile.am Sun Jun 09 06:03:34 2013 +0300 @@ -4,6 +4,7 @@ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-settings \ -I$(top_srcdir)/src/lib-auth \ + -I$(top_srcdir)/src/lib-sasl \ -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-ssl-iostream \ -I$(top_srcdir)/src/lib-mail \ diff -r 1cbff0a8a849 -r 266101990d63 src/login-common/client-common-auth.c --- a/src/login-common/client-common-auth.c Sun Jun 09 06:02:14 2013 +0300 +++ b/src/login-common/client-common-auth.c Sun Jun 09 06:03:34 2013 +0300 @@ -9,6 +9,7 @@ #include "time-util.h" #include "login-proxy.h" #include "auth-client.h" +#include "sasl-client.h" #include "master-service-ssl-settings.h" #include "client-common.h" @@ -104,6 +105,8 @@ reply_r->proxy_timeout_msecs = 1000*atoi(value); else if (strcmp(key, "proxy_refresh") == 0) reply_r->proxy_refresh_secs = atoi(value); + else if (strcmp(key, "proxy_mech") == 0) + reply_r->proxy_mech = value; else if (strcmp(key, "master") == 0) reply_r->master_user = value; else if (strcmp(key, "ssl") == 0) { @@ -198,6 +201,8 @@ client_proxy_error(client, PROXY_FAILURE_MSG); } + if (client->proxy_sasl_client != NULL) + sasl_client_free(&client->proxy_sasl_client); login_proxy_free(&client->login_proxy); proxy_free_password(client); i_free_and_null(client->proxy_user); @@ -270,10 +275,13 @@ const struct client_auth_reply *reply) { struct login_proxy_settings proxy_set; + const struct sasl_client_mech *sasl_mech = NULL; i_assert(reply->destuser != NULL); i_assert(!client->destroyed); + i_assert(client->proxy_sasl_client == NULL); + client->proxy_mech = NULL; client->v.proxy_reset(client); if (reply->password == NULL) { @@ -287,6 +295,20 @@ return -1; } + if (reply->proxy_mech != NULL) { + sasl_mech = sasl_client_mech_find(reply->proxy_mech); + if (sasl_mech == NULL) { + client_log_err(client, t_strdup_printf( + "proxy: Unsupported SASL mechanism %s", + reply->proxy_mech)); + client_proxy_error(client, PROXY_FAILURE_MSG); + return -1; + } + } else if (reply->master_user != NULL) { + /* have to use PLAIN authentication with master user logins */ + sasl_mech = &sasl_client_mech_plain; + } + i_assert(client->refcount > 1); if (client->destroyed) { @@ -318,6 +340,7 @@ return -1; } + client->proxy_mech = sasl_mech; client->proxy_user = i_strdup(reply->destuser); client->proxy_master_user = i_strdup(reply->master_user); client->proxy_password = i_strdup(reply->password); diff -r 1cbff0a8a849 -r 266101990d63 src/login-common/client-common.c --- a/src/login-common/client-common.c Sun Jun 09 06:02:14 2013 +0300 +++ b/src/login-common/client-common.c Sun Jun 09 06:03:34 2013 +0300 @@ -18,6 +18,7 @@ #include "master-service-ssl-settings.h" #include "master-auth.h" #include "auth-client.h" +#include "sasl-client.h" #include "login-proxy.h" #include "ssl-proxy.h" #include "client-common.h" @@ -209,6 +210,8 @@ i_free_and_null(client->proxy_password); } + if (client->proxy_sasl_client != NULL) + sasl_client_free(&client->proxy_sasl_client); if (client->login_proxy != NULL) login_proxy_free(&client->login_proxy); if (client->v.destroy != NULL) diff -r 1cbff0a8a849 -r 266101990d63 src/login-common/client-common.h --- a/src/login-common/client-common.h Sun Jun 09 06:02:14 2013 +0300 From dovecot at dovecot.org Sun Jun 9 14:54:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 14:54:25 +0300 Subject: dovecot-2.2: lib-storage: Fixed crashes caused by recent "multip... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/73b7fce1643e changeset: 16488:73b7fce1643e user: Timo Sirainen date: Sun Jun 09 14:53:31 2013 +0300 description: lib-storage: Fixed crashes caused by recent "multiple storages per namespace" change. diffstat: src/lib-storage/index/shared/shared-storage.c | 1 + src/lib-storage/mail-namespace.c | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-) diffs (30 lines): diff -r 266101990d63 -r 73b7fce1643e src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Sun Jun 09 06:03:34 2013 +0300 +++ b/src/lib-storage/index/shared/shared-storage.c Sun Jun 09 14:53:31 2013 +0300 @@ -289,6 +289,7 @@ NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_HIDDEN | NAMESPACE_FLAG_AUTOCREATED | NAMESPACE_FLAG_INBOX_ANY; new_ns->mail_set = _storage->set; + i_array_init(&new_ns->all_storages, 2); location = t_str_new(256); if (ret > 0) diff -r 266101990d63 -r 73b7fce1643e src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Sun Jun 09 06:03:34 2013 +0300 +++ b/src/lib-storage/mail-namespace.c Sun Jun 09 14:53:31 2013 +0300 @@ -408,6 +408,7 @@ ns->flags = NAMESPACE_FLAG_INBOX_USER | NAMESPACE_FLAG_INBOX_ANY | NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_SUBSCRIPTIONS; ns->owner = user; + i_array_init(&ns->all_storages, 2); inbox_set = p_new(user->pool, struct mail_namespace_settings, 1); *inbox_set = mail_namespace_default_settings; @@ -489,6 +490,7 @@ ns->flags = NAMESPACE_FLAG_INBOX_USER | NAMESPACE_FLAG_INBOX_ANY | NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_SUBSCRIPTIONS; ns->mail_set = mail_user_set_get_storage_set(user); + i_array_init(&ns->all_storages, 2); user->namespaces = ns; return ns; } From dovecot at dovecot.org Sun Jun 9 14:57:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 14:57:06 +0300 Subject: dovecot-2.2: acl: Crashfix Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/921017adcb7b changeset: 16489:921017adcb7b user: Timo Sirainen date: Sun Jun 09 14:56:36 2013 +0300 description: acl: Crashfix diffstat: src/plugins/acl/acl-backend-vfile.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 73b7fce1643e -r 921017adcb7b src/plugins/acl/acl-backend-vfile.c --- a/src/plugins/acl/acl-backend-vfile.c Sun Jun 09 14:53:31 2013 +0300 +++ b/src/plugins/acl/acl-backend-vfile.c Sun Jun 09 14:56:36 2013 +0300 @@ -144,7 +144,7 @@ /* ACL files are very important. try to keep them among the main mail files. that's not possible though with a) if the mailbox is a file or b) if the mailbox path doesn't point to filesystem. */ - vname = mailbox_list_get_vname(backend->list, name); + vname = name == NULL ? "" : mailbox_list_get_vname(backend->list, name); if (mailbox_list_get_storage(&list, vname, &storage) < 0) return NULL; i_assert(list == ns->list); From dovecot at dovecot.org Sun Jun 9 21:07:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 09 Jun 2013 21:07:18 +0300 Subject: dovecot-2.2: man: Recent change accidentally changed LGPLv2.1 ->... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/45399357008a changeset: 16490:45399357008a user: Timo Sirainen date: Sun Jun 09 21:06:49 2013 +0300 description: man: Recent change accidentally changed LGPLv2.1 -> LGPLv2.2, reverted. diffstat: doc/man/dovecot.1.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 921017adcb7b -r 45399357008a doc/man/dovecot.1.in --- a/doc/man/dovecot.1.in Sun Jun 09 14:56:36 2013 +0300 +++ b/doc/man/dovecot.1.in Sun Jun 09 21:06:49 2013 +0300 @@ -148,7 +148,7 @@ .SH AUTHOR Dovecot and its manual pages were written by the Dovecot authors , mainly Timo Sirainen , and are licensed under the terms of the MIT and LGPLv2.2 +at iki.fi>, and are licensed under the terms of the MIT and LGPLv2.1 licenses, see for details. .\"------------------------------------------------------------------------ .SH SEE ALSO From dovecot at dovecot.org Wed Jun 12 04:44:43 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 04:44:43 +0300 Subject: dovecot-2.2: zlib plugin: Removed explicit checks for maildir/sd... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d212cfb92ce9 changeset: 16491:d212cfb92ce9 user: Timo Sirainen date: Wed Jun 12 04:44:11 2013 +0300 description: zlib plugin: Removed explicit checks for maildir/sdbox/mdbox. diffstat: src/plugins/zlib/zlib-plugin.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diffs (25 lines): diff -r 45399357008a -r d212cfb92ce9 src/plugins/zlib/zlib-plugin.c --- a/src/plugins/zlib/zlib-plugin.c Sun Jun 09 21:06:49 2013 +0300 +++ b/src/plugins/zlib/zlib-plugin.c Wed Jun 12 04:44:11 2013 +0300 @@ -7,9 +7,6 @@ #include "ostream.h" #include "str.h" #include "mail-user.h" -#include "dbox-single/sdbox-storage.h" -#include "dbox-multi/mdbox-storage.h" -#include "maildir/maildir-storage.h" #include "index-storage.h" #include "index-mail.h" #include "compression.h" @@ -361,9 +358,8 @@ MODULE_CONTEXT_SET_SELF(box, zlib_storage_module, zbox); - if (strcmp(box->storage->name, MAILDIR_STORAGE_NAME) == 0 || - strcmp(box->storage->name, MDBOX_STORAGE_NAME) == 0 || - strcmp(box->storage->name, SDBOX_STORAGE_NAME) == 0) + if ((box->storage->class_flags & + MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0) zlib_permail_alloc_init(box, v); } From dovecot at dovecot.org Wed Jun 12 16:20:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 16:20:30 +0300 Subject: dovecot-2.2: pop3c: Give GUID to the INBOX to avoid crashes with... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7a7d4d8123d5 changeset: 16492:7a7d4d8123d5 user: Timo Sirainen date: Wed Jun 12 16:20:19 2013 +0300 description: pop3c: Give GUID to the INBOX to avoid crashes with dsync. diffstat: src/lib-storage/index/pop3c/pop3c-storage.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diffs (36 lines): diff -r d212cfb92ce9 -r 7a7d4d8123d5 src/lib-storage/index/pop3c/pop3c-storage.c --- a/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 12 04:44:11 2013 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 12 16:20:19 2013 +0300 @@ -209,6 +209,23 @@ return -1; } +static int pop3c_mailbox_get_metadata(struct mailbox *box, + enum mailbox_metadata_items items, + struct mailbox_metadata *metadata_r) +{ + if ((items & MAILBOX_METADATA_GUID) != 0) { + /* a bit ugly way to do this, but better than nothing for now. + FIXME: if indexes are enabled, keep this there. */ + mail_generate_guid_128_hash(box->name, metadata_r->guid); + items &= ~MAILBOX_METADATA_GUID; + } + if (items != 0) { + if (index_mailbox_get_metadata(box, items, metadata_r) < 0) + return -1; + } + return 0; +} + static void pop3c_notify_changes(struct mailbox *box ATTR_UNUSED) { } @@ -251,7 +268,7 @@ index_storage_mailbox_delete, index_storage_mailbox_rename, index_storage_get_status, - index_mailbox_get_metadata, + pop3c_mailbox_get_metadata, index_storage_set_subscribed, index_storage_attribute_set, index_storage_attribute_get, From dovecot at dovecot.org Wed Jun 12 16:27:54 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 16:27:54 +0300 Subject: dovecot-2.2: pop3c: Don't assert-crash when trying to list subsc... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/09ac72cdfa8e changeset: 16493:09ac72cdfa8e user: Timo Sirainen date: Wed Jun 12 16:27:47 2013 +0300 description: pop3c: Don't assert-crash when trying to list subscriptions. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (17 lines): diff -r 7a7d4d8123d5 -r 09ac72cdfa8e src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Wed Jun 12 16:20:19 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Wed Jun 12 16:27:47 2013 +0300 @@ -126,8 +126,11 @@ type = src_list->set.control_dir != NULL ? MAILBOX_LIST_PATH_TYPE_CONTROL : MAILBOX_LIST_PATH_TYPE_DIR; - path = t_strconcat(mailbox_list_get_root_forced(src_list, type), - "/", src_list->set.subscription_fname, NULL); + if (!mailbox_list_get_root_path(src_list, type, &path)) { + /* no subscriptions (e.g. pop3c) */ + return 0; + } + path = t_strconcat(path, "/", src_list->set.subscription_fname, NULL); if (stat(path, &st) < 0) { if (errno == ENOENT) { /* no subscriptions */ From dovecot at dovecot.org Wed Jun 12 16:29:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 16:29:22 +0300 Subject: dovecot-2.2: pop3c: Allow mailbox_update() for Dovecot's interna... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8cf22cba16d4 changeset: 16494:8cf22cba16d4 user: Timo Sirainen date: Wed Jun 12 16:29:17 2013 +0300 description: pop3c: Allow mailbox_update() for Dovecot's internal fields. diffstat: src/lib-storage/index/pop3c/pop3c-storage.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diffs (20 lines): diff -r 09ac72cdfa8e -r 8cf22cba16d4 src/lib-storage/index/pop3c/pop3c-storage.c --- a/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 12 16:27:47 2013 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 12 16:29:17 2013 +0300 @@ -204,9 +204,13 @@ pop3c_mailbox_update(struct mailbox *box, const struct mailbox_update *update ATTR_UNUSED) { - mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, - "POP3 mailbox update isn't supported"); - return -1; + if (!guid_128_is_empty(update->mailbox_guid) || + update->uid_validity != 0 || update->min_next_uid != 0 || + update->min_first_recent_uid != 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, + "POP3 mailbox update isn't supported"); + } + return index_storage_mailbox_update(box, update); } static int pop3c_mailbox_get_metadata(struct mailbox *box, From dovecot at dovecot.org Wed Jun 12 16:43:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 16:43:48 +0300 Subject: dovecot-2.2: pop3c: Return Date: header's date also as received ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d447dcc6b611 changeset: 16495:d447dcc6b611 user: Timo Sirainen date: Wed Jun 12 16:43:41 2013 +0300 description: pop3c: Return Date: header's date also as received and saved date. Mainly to get dsync to not fail. diffstat: src/lib-storage/index/pop3c/pop3c-mail.c | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) diffs (37 lines): diff -r 8cf22cba16d4 -r d447dcc6b611 src/lib-storage/index/pop3c/pop3c-mail.c --- a/src/lib-storage/index/pop3c/pop3c-mail.c Wed Jun 12 16:29:17 2013 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-mail.c Wed Jun 12 16:43:41 2013 +0300 @@ -9,18 +9,25 @@ static int pop3c_mail_get_received_date(struct mail *_mail, time_t *date_r) { - mail_storage_set_error(_mail->box->storage, MAIL_ERROR_NOTPOSSIBLE, - "POP3 has no received date"); - *date_r = (time_t)-1; - return -1; + int tz; + + /* FIXME: we could also parse the first Received: header and get + the date from there, but since this code is unlikely to be called + except during migration, I don't think it really matters. */ + return index_mail_get_date(_mail, date_r, &tz); } static int pop3c_mail_get_save_date(struct mail *_mail, time_t *date_r) { - mail_storage_set_error(_mail->box->storage, MAIL_ERROR_NOTPOSSIBLE, - "POP3 has no save date"); - *date_r = (time_t)-1; - return -1; + struct index_mail *mail = (struct index_mail *)_mail; + struct index_mail_data *data = &mail->data; + + if (data->save_date == (time_t)-1) { + /* FIXME: we could use a value stored in cache */ + return pop3c_mail_get_received_date(_mail, date_r); + } + *date_r = data->save_date; + return 0; } static int pop3c_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) From dovecot at dovecot.org Wed Jun 12 21:16:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 21:16:16 +0300 Subject: dovecot-2.2: pop3c: Don't assert-crash if we can't do DNS lookup. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7057dfeaeb1a changeset: 16496:7057dfeaeb1a user: Timo Sirainen date: Wed Jun 12 21:16:06 2013 +0300 description: pop3c: Don't assert-crash if we can't do DNS lookup. diffstat: src/lib-storage/index/pop3c/pop3c-client.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diffs (40 lines): diff -r d447dcc6b611 -r 7057dfeaeb1a src/lib-storage/index/pop3c/pop3c-client.c --- a/src/lib-storage/index/pop3c/pop3c-client.c Wed Jun 12 16:43:41 2013 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-client.c Wed Jun 12 21:16:06 2013 +0300 @@ -199,7 +199,7 @@ void pop3c_client_run(struct pop3c_client *client) { struct ioloop *ioloop, *prev_ioloop = current_ioloop; - bool timeout_added = FALSE; + bool timeout_added = FALSE, failed = FALSE; i_assert(client->fd != -1 || client->state == POP3C_CLIENT_STATE_CONNECTING); @@ -217,18 +217,21 @@ dns_set.dns_client_socket_path = client->set.dns_client_socket_path; dns_set.timeout_msecs = POP3C_DNS_LOOKUP_TIMEOUT_MSECS; - (void)dns_lookup(client->set.host, &dns_set, - pop3c_dns_callback, client, - &client->dns_lookup); + if (dns_lookup(client->set.host, &dns_set, + pop3c_dns_callback, client, + &client->dns_lookup) < 0) + failed = TRUE; } else if (client->to == NULL) { client->to = timeout_add(POP3C_COMMAND_TIMEOUT_MSECS, pop3c_client_timeout, client); timeout_added = TRUE; } - client->running = TRUE; - io_loop_run(ioloop); - client->running = FALSE; + if (!failed) { + client->running = TRUE; + io_loop_run(ioloop); + client->running = FALSE; + } if (timeout_added && client->to != NULL) timeout_remove(&client->to); From dovecot at dovecot.org Wed Jun 12 21:25:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 21:25:21 +0300 Subject: dovecot-2.2: lib-storage: Don't crash if backend doesn't have su... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4b9a43201a71 changeset: 16497:4b9a43201a71 user: Timo Sirainen date: Wed Jun 12 21:25:09 2013 +0300 description: lib-storage: Don't crash if backend doesn't have subscriptions file. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 3 ++- src/lib-storage/list/mailbox-list-fs.c | 6 ++++++ src/lib-storage/list/mailbox-list-index-backend.c | 6 ++++++ src/lib-storage/list/mailbox-list-maildir.c | 6 ++++++ src/lib-storage/list/mailbox-list-subscriptions.c | 3 ++- 5 files changed, 22 insertions(+), 2 deletions(-) diffs (74 lines): diff -r 7057dfeaeb1a -r 4b9a43201a71 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Wed Jun 12 21:16:06 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Wed Jun 12 21:25:09 2013 +0300 @@ -153,7 +153,8 @@ dir->info_flags |= MAILBOX_SELECT; return 0; } - if (strcmp(d->d_name, ctx->ctx.list->set.subscription_fname) == 0) { + if (ctx->ctx.list->set.subscription_fname != NULL && + strcmp(d->d_name, ctx->ctx.list->set.subscription_fname) == 0) { /* if this is the subscriptions file, skip it */ root_dir = mailbox_list_get_root_forced(ctx->ctx.list, MAILBOX_LIST_PATH_TYPE_DIR); diff -r 7057dfeaeb1a -r 4b9a43201a71 src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Wed Jun 12 21:16:06 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Wed Jun 12 21:25:09 2013 +0300 @@ -170,6 +170,12 @@ enum mailbox_list_path_type type; const char *path; + if (_list->set.subscription_fname == NULL) { + mailbox_list_set_error(_list, MAIL_ERROR_NOTPOSSIBLE, + "Subscriptions not supported"); + return -1; + } + type = _list->set.control_dir != NULL ? MAILBOX_LIST_PATH_TYPE_CONTROL : MAILBOX_LIST_PATH_TYPE_DIR; diff -r 7057dfeaeb1a -r 4b9a43201a71 src/lib-storage/list/mailbox-list-index-backend.c --- a/src/lib-storage/list/mailbox-list-index-backend.c Wed Jun 12 21:16:06 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-index-backend.c Wed Jun 12 21:25:09 2013 +0300 @@ -167,6 +167,12 @@ struct index_mailbox_list *list = (struct index_mailbox_list *)_list; const char *path; + if (_list->set.subscription_fname == NULL) { + mailbox_list_set_error(_list, MAIL_ERROR_NOTPOSSIBLE, + "Subscriptions not supported"); + return -1; + } + path = t_strconcat(_list->set.control_dir != NULL ? _list->set.control_dir : _list->set.root_dir, "/", _list->set.subscription_fname, NULL); diff -r 7057dfeaeb1a -r 4b9a43201a71 src/lib-storage/list/mailbox-list-maildir.c --- a/src/lib-storage/list/mailbox-list-maildir.c Wed Jun 12 21:16:06 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir.c Wed Jun 12 21:25:09 2013 +0300 @@ -180,6 +180,12 @@ (struct maildir_mailbox_list *)_list; const char *path; + if (_list->set.subscription_fname == NULL) { + mailbox_list_set_error(_list, MAIL_ERROR_NOTPOSSIBLE, + "Subscriptions not supported"); + return -1; + } + path = t_strconcat(_list->set.control_dir != NULL ? _list->set.control_dir : _list->set.root_dir, "/", _list->set.subscription_fname, NULL); diff -r 7057dfeaeb1a -r 4b9a43201a71 src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Wed Jun 12 21:16:06 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Wed Jun 12 21:25:09 2013 +0300 @@ -126,7 +126,8 @@ type = src_list->set.control_dir != NULL ? MAILBOX_LIST_PATH_TYPE_CONTROL : MAILBOX_LIST_PATH_TYPE_DIR; - if (!mailbox_list_get_root_path(src_list, type, &path)) { + if (!mailbox_list_get_root_path(src_list, type, &path) || + src_list->set.subscription_fname == NULL) { /* no subscriptions (e.g. pop3c) */ return 0; } From dovecot at dovecot.org Wed Jun 12 21:41:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 21:41:36 +0300 Subject: dovecot-2.2: Moved "INBOX can't be deleted" check from lib-stora... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/db5d4c5164b3 changeset: 16498:db5d4c5164b3 user: Timo Sirainen date: Wed Jun 12 21:41:09 2013 +0300 description: Moved "INBOX can't be deleted" check from lib-storage to IMAP-specific code. Especially "doveadm backup" should be able to delete the INBOX if needed. diffstat: src/imap/cmd-delete.c | 13 +++++++------ src/lib-storage/mail-storage.c | 10 +++++----- src/lib-storage/mail-storage.h | 2 ++ 3 files changed, 14 insertions(+), 11 deletions(-) diffs (67 lines): diff -r 4b9a43201a71 -r db5d4c5164b3 src/imap/cmd-delete.c --- a/src/imap/cmd-delete.c Wed Jun 12 21:25:09 2013 +0300 +++ b/src/imap/cmd-delete.c Wed Jun 12 21:41:09 2013 +0300 @@ -16,17 +16,18 @@ if (!client_read_string_args(cmd, 1, &name)) return FALSE; - if (strcasecmp(name, "INBOX") == 0) { - /* INBOX can't be deleted */ - client_send_tagline(cmd, "NO INBOX can't be deleted."); - return TRUE; - } - ns = client_find_namespace(cmd, &name); if (ns == NULL) return TRUE; box = mailbox_alloc(ns->list, name, 0); + if (mailbox_is_any_inbox(box)) { + /* IMAP protocol allows this, but I think it's safer to + not allow it. */ + mailbox_free(&box); + client_send_tagline(cmd, "NO INBOX can't be deleted."); + return TRUE; + } if (client->mailbox != NULL && mailbox_backends_equal(box, client->mailbox)) { /* deleting selected mailbox. close it first */ diff -r 4b9a43201a71 -r db5d4c5164b3 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Jun 12 21:25:09 2013 +0300 +++ b/src/lib-storage/mail-storage.c Wed Jun 12 21:41:09 2013 +0300 @@ -1213,6 +1213,11 @@ strcasecmp(vname2, "INBOX") == 0; } +bool mailbox_is_any_inbox(struct mailbox *box) +{ + return box->inbox_any; +} + int mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory) { @@ -1288,11 +1293,6 @@ "Storage root can't be deleted"); return -1; } - if (box->inbox_any) { - mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, - "INBOX can't be deleted."); - return -1; - } box->deleting = TRUE; if (mailbox_open(box) < 0) { diff -r 4b9a43201a71 -r db5d4c5164b3 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Wed Jun 12 21:25:09 2013 +0300 +++ b/src/lib-storage/mail-storage.h Wed Jun 12 21:41:09 2013 +0300 @@ -481,6 +481,8 @@ bool mailbox_equals(const struct mailbox *box1, const struct mail_namespace *ns2, const char *vname2) ATTR_PURE; +/* Returns TRUE if the mailbox is user's INBOX or another user's shared INBOX */ +bool mailbox_is_any_inbox(struct mailbox *box); /* Returns -1 if mailbox_create() is guaranteed to fail because the mailbox name is invalid, 0 not. The error message contains a reason. */ From dovecot at dovecot.org Wed Jun 12 22:03:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 22:03:19 +0300 Subject: dovecot-2.2: lib-dict: Error handling fixes to asynchronous tran... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/db1f217e53b3 changeset: 16499:db1f217e53b3 user: Timo Sirainen date: Wed Jun 12 22:03:07 2013 +0300 description: lib-dict: Error handling fixes to asynchronous transactions. diffstat: src/lib-dict/dict-client.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diffs (55 lines): diff -r db5d4c5164b3 -r db1f217e53b3 src/lib-dict/dict-client.c --- a/src/lib-dict/dict-client.c Wed Jun 12 21:41:09 2013 +0300 +++ b/src/lib-dict/dict-client.c Wed Jun 12 22:03:07 2013 +0300 @@ -73,6 +73,7 @@ unsigned int failed:1; unsigned int sent_begin:1; unsigned int async:1; + unsigned int committed:1; }; static int client_dict_connect(struct client_dict *dict); @@ -262,6 +263,9 @@ i_error("dict-client: Unknown transaction id %u", id); return; } + ctx->failed = TRUE; + if (!ctx->committed) + return; /* the callback may call the dict code again, so remove this transaction before calling it */ @@ -402,8 +406,6 @@ { const char *query; - i_assert(dict->fd == -1); - if (dict->last_failed_connect == ioloop_time) { /* Try again later */ return -1; @@ -427,8 +429,6 @@ dict->input = i_stream_create_fd(dict->fd, (size_t)-1, FALSE); dict->output = o_stream_create_fd(dict->fd, 4096, FALSE); - dict->transaction_id_counter = 0; - dict->async_commits = 0; query = t_strdup_printf("%c%u\t%u\t%d\t%s\t%s\n", DICT_PROTOCOL_CMD_HELLO, @@ -518,6 +518,7 @@ struct client_dict *dict = (struct client_dict *)_dict; client_dict_disconnect(dict); + i_assert(dict->transactions == NULL); pool_unref(&dict->pool); } @@ -706,6 +707,7 @@ struct client_dict *dict = (struct client_dict *)_ctx->dict; int ret = ctx->failed ? -1 : 1; + ctx->committed = TRUE; if (ctx->sent_begin && !ctx->failed) T_BEGIN { const char *query, *line; From dovecot at dovecot.org Wed Jun 12 22:45:53 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Jun 2013 22:45:53 +0300 Subject: dovecot-2.2: pop3-migration: struct mailbox must be freed before... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c903fbcbf5d2 changeset: 16500:c903fbcbf5d2 user: Timo Sirainen date: Wed Jun 12 22:45:43 2013 +0300 description: pop3-migration: struct mailbox must be freed before mail_storage is destroyed. Fixes a memory leak where the user wasn't destroyed at all because the mailbox still caused the user to be referenced. diffstat: src/plugins/pop3-migration/pop3-migration-plugin.c | 53 ++++++++++----------- 1 files changed, 25 insertions(+), 28 deletions(-) diffs (154 lines): diff -r db1f217e53b3 -r c903fbcbf5d2 src/plugins/pop3-migration/pop3-migration-plugin.c --- a/src/plugins/pop3-migration/pop3-migration-plugin.c Wed Jun 12 22:03:07 2013 +0300 +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c Wed Jun 12 22:45:43 2013 +0300 @@ -43,7 +43,6 @@ union mail_storage_module_context module_ctx; const char *pop3_box_vname; - struct mailbox *pop3_box; ARRAY(struct pop3_uidl_map) pop3_uidl_map; unsigned int all_mailboxes:1; @@ -149,31 +148,23 @@ return 0; } -static int pop3_mailbox_open(struct mail_storage *storage) +static struct mailbox *pop3_mailbox_alloc(struct mail_storage *storage) { struct pop3_migration_mail_storage *mstorage = POP3_MIGRATION_CONTEXT(storage); struct mail_namespace *ns; - if (mstorage->pop3_box != NULL) - return 0; - ns = mail_namespace_find(storage->user->namespaces, mstorage->pop3_box_vname); - mstorage->pop3_box = mailbox_alloc(ns->list, mstorage->pop3_box_vname, - MAILBOX_FLAG_READONLY | - MAILBOX_FLAG_POP3_SESSION); - mstorage->all_mailboxes = - mail_user_plugin_getenv(storage->user, - "pop3_migration_all_mailboxes") != NULL; - return 0; + i_assert(ns != NULL); + return mailbox_alloc(ns->list, mstorage->pop3_box_vname, + MAILBOX_FLAG_READONLY | MAILBOX_FLAG_POP3_SESSION); } -static int pop3_map_read(struct mail_storage *storage) +static int pop3_map_read(struct mail_storage *storage, struct mailbox *pop3_box) { struct pop3_migration_mail_storage *mstorage = POP3_MIGRATION_CONTEXT(storage); - struct mailbox *pop3_box = mstorage->pop3_box; struct mailbox_transaction_context *t; struct mail_search_args *search_args; struct mail_search_context *ctx; @@ -237,8 +228,9 @@ return ret; } -static int pop3_map_read_hdr_hashes(struct mail_storage *storage, - unsigned first_seq) +static int +pop3_map_read_hdr_hashes(struct mail_storage *storage, struct mailbox *pop3_box, + unsigned first_seq) { struct pop3_migration_mail_storage *mstorage = POP3_MIGRATION_CONTEXT(storage); @@ -257,7 +249,7 @@ first_seq = 1; } - t = mailbox_transaction_begin(mstorage->pop3_box, 0); + t = mailbox_transaction_begin(pop3_box, 0); search_args = mail_search_build_init(); mail_search_build_add_seqset(search_args, first_seq, array_count(&mstorage->pop3_uidl_map)+1); @@ -390,7 +382,8 @@ return i == count; } -static int pop3_uidl_assign_by_hdr_hash(struct mailbox *box) +static int +pop3_uidl_assign_by_hdr_hash(struct mailbox *box, struct mailbox *pop3_box) { struct pop3_migration_mail_storage *mstorage = POP3_MIGRATION_CONTEXT(box->storage); @@ -402,7 +395,7 @@ int ret; first_seq = mbox->first_unfound_idx+1; - if (pop3_map_read_hdr_hashes(box->storage, first_seq) < 0 || + if (pop3_map_read_hdr_hashes(box->storage, pop3_box, first_seq) < 0 || imap_map_read_hdr_hashes(box) < 0) return -1; @@ -458,6 +451,7 @@ struct pop3_migration_mailbox *mbox = POP3_MIGRATION_CONTEXT(box); struct pop3_migration_mail_storage *mstorage = POP3_MIGRATION_CONTEXT(box->storage); + struct mailbox *pop3_box; const struct pop3_uidl_map *pop3_map; unsigned int i, count; uint32_t prev_uid; @@ -465,22 +459,23 @@ if (mbox->uidl_synced) return 0; - if (pop3_mailbox_open(box->storage) < 0) - return -1; + pop3_box = pop3_mailbox_alloc(box->storage); /* the POP3 server isn't connected to yet. handle all IMAP traffic first before connecting, so POP3 server won't disconnect us due to idling. */ - if (imap_map_read(box) < 0) + if (imap_map_read(box) < 0 || + pop3_map_read(box->storage, pop3_box) < 0) { + mailbox_free(&pop3_box); return -1; - - if (pop3_map_read(box->storage) < 0) - return -1; + } if (!pop3_uidl_assign_by_size(box)) { /* everything wasn't assigned, figure out the rest with header hashes */ - if (pop3_uidl_assign_by_hdr_hash(box) < 0) + if (pop3_uidl_assign_by_hdr_hash(box, pop3_box) < 0) { + mailbox_free(&pop3_box); return -1; + } } /* see if the POP3 UIDL order is the same as IMAP UID order */ @@ -499,6 +494,7 @@ } mbox->uidl_synced = TRUE; + mailbox_free(&pop3_box); return 0; } @@ -585,8 +581,6 @@ struct pop3_migration_mail_storage *mstorage = POP3_MIGRATION_CONTEXT(storage); - if (mstorage->pop3_box != NULL) - mailbox_free(&mstorage->pop3_box); if (array_is_created(&mstorage->pop3_uidl_map)) array_free(&mstorage->pop3_uidl_map); @@ -610,6 +604,9 @@ v->destroy = pop3_migration_mail_storage_destroy; mstorage->pop3_box_vname = p_strdup(storage->pool, pop3_box_vname); + mstorage->all_mailboxes = + mail_user_plugin_getenv(storage->user, + "pop3_migration_all_mailboxes") != NULL; MODULE_CONTEXT_SET(storage, pop3_migration_storage_module, mstorage); } From dovecot at dovecot.org Thu Jun 13 03:26:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 03:26:34 +0300 Subject: dovecot-2.2: lib-storage: Added MAIL_STORAGE_CLASS_FLAG_BINARY_D... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/102d8a59eeda changeset: 16501:102d8a59eeda user: Timo Sirainen date: Wed Jun 12 22:58:42 2013 +0300 description: lib-storage: Added MAIL_STORAGE_CLASS_FLAG_BINARY_DATA flag for classes. diffstat: src/lib-storage/index/cydir/cydir-storage.c | 3 ++- src/lib-storage/index/dbox-multi/mdbox-storage.c | 3 ++- src/lib-storage/index/dbox-single/sdbox-storage.c | 3 ++- src/lib-storage/index/maildir/maildir-storage.c | 3 ++- src/lib-storage/index/raw/raw-storage.c | 3 ++- src/lib-storage/mail-storage-private.h | 5 ++++- 6 files changed, 14 insertions(+), 6 deletions(-) diffs (80 lines): diff -r c903fbcbf5d2 -r 102d8a59eeda src/lib-storage/index/cydir/cydir-storage.c --- a/src/lib-storage/index/cydir/cydir-storage.c Wed Jun 12 22:45:43 2013 +0300 +++ b/src/lib-storage/index/cydir/cydir-storage.c Wed Jun 12 22:58:42 2013 +0300 @@ -110,7 +110,8 @@ struct mail_storage cydir_storage = { .name = CYDIR_STORAGE_NAME, - .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG, + .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG | + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA, .v = { NULL, diff -r c903fbcbf5d2 -r 102d8a59eeda src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Wed Jun 12 22:45:43 2013 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Wed Jun 12 22:58:42 2013 +0300 @@ -418,7 +418,8 @@ .name = MDBOX_STORAGE_NAME, .class_flags = MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT | MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS | - MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS, + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS | + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA, .v = { mdbox_get_setting_parser_info, diff -r c903fbcbf5d2 -r 102d8a59eeda src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Wed Jun 12 22:45:43 2013 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Wed Jun 12 22:58:42 2013 +0300 @@ -401,7 +401,8 @@ .name = SDBOX_STORAGE_NAME, .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG | MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS | - MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS, + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS | + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA, .v = { NULL, diff -r c903fbcbf5d2 -r 102d8a59eeda src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Wed Jun 12 22:45:43 2013 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Wed Jun 12 22:58:42 2013 +0300 @@ -658,7 +658,8 @@ .name = MAILDIR_STORAGE_NAME, .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG | MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS | - MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS, + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS | + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA, .v = { maildir_get_setting_parser_info, diff -r c903fbcbf5d2 -r 102d8a59eeda src/lib-storage/index/raw/raw-storage.c --- a/src/lib-storage/index/raw/raw-storage.c Wed Jun 12 22:45:43 2013 +0300 +++ b/src/lib-storage/index/raw/raw-storage.c Wed Jun 12 22:58:42 2013 +0300 @@ -200,7 +200,8 @@ struct mail_storage raw_storage = { .name = RAW_STORAGE_NAME, .class_flags = MAIL_STORAGE_CLASS_FLAG_MAILBOX_IS_FILE | - MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS, + MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS | + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA, .v = { NULL, diff -r c903fbcbf5d2 -r 102d8a59eeda src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Wed Jun 12 22:45:43 2013 +0300 +++ b/src/lib-storage/mail-storage-private.h Wed Jun 12 22:58:42 2013 +0300 @@ -69,7 +69,10 @@ MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS = 0x40, /* mailbox_save_set_guid() works (always set mailbox_status.have_save_guids=TRUE) */ - MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS = 0x80 + MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS = 0x80, + /* message content can be unstructured binary data + (e.g. zlib plugin is allowed to compress/decompress mails) */ + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA = 0x100 }; struct mail_binary_cache { From dovecot at dovecot.org Thu Jun 13 03:26:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 03:26:34 +0300 Subject: dovecot-2.2: zlib: Enable only for storages that support MAIL_ST... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/235be95cb378 changeset: 16502:235be95cb378 user: Timo Sirainen date: Wed Jun 12 23:01:26 2013 +0300 description: zlib: Enable only for storages that support MAIL_STORAGE_CLASS_FLAG_BINARY_DATA diffstat: src/plugins/zlib/zlib-plugin.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (22 lines): diff -r 102d8a59eeda -r 235be95cb378 src/plugins/zlib/zlib-plugin.c --- a/src/plugins/zlib/zlib-plugin.c Wed Jun 12 22:58:42 2013 +0300 +++ b/src/plugins/zlib/zlib-plugin.c Wed Jun 12 23:01:26 2013 +0300 @@ -349,6 +349,7 @@ { struct mailbox_vfuncs *v = box->vlast; union mailbox_module_context *zbox; + enum mail_storage_class_flags class_flags = box->storage->class_flags; zbox = p_new(box->pool, union mailbox_module_context, 1); zbox->super = *v; @@ -358,8 +359,8 @@ MODULE_CONTEXT_SET_SELF(box, zlib_storage_module, zbox); - if ((box->storage->class_flags & - MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0) + if ((class_flags & MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0 && + (class_flags & MAIL_STORAGE_CLASS_FLAG_BINARY_DATA) != 0) zlib_permail_alloc_init(box, v); } From dovecot at dovecot.org Thu Jun 13 03:26:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 03:26:34 +0300 Subject: dovecot-2.2: Memory leak fixes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5ed2f41431c4 changeset: 16503:5ed2f41431c4 user: Timo Sirainen date: Thu Jun 13 03:26:22 2013 +0300 description: Memory leak fixes. diffstat: src/doveadm/client-connection.c | 2 ++ src/doveadm/dsync/dsync-brain-mailbox.c | 1 + src/doveadm/dsync/dsync-brain.c | 2 ++ src/doveadm/dsync/dsync-ibc-pipe.c | 5 +++++ src/doveadm/dsync/dsync-mailbox-export.c | 1 + src/doveadm/main.c | 1 + src/lib-fs/fs-api.c | 6 ++++++ 7 files changed, 18 insertions(+), 0 deletions(-) diffs (109 lines): diff -r 235be95cb378 -r 5ed2f41431c4 src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Wed Jun 12 23:01:26 2013 +0300 +++ b/src/doveadm/client-connection.c Thu Jun 13 03:26:22 2013 +0300 @@ -74,6 +74,7 @@ "Client sent unknown parameter: %c", cmd->name, c); ctx->v.deinit(ctx); + pool_unref(&ctx->pool); return NULL; } } @@ -86,6 +87,7 @@ i_error("doveadm %s: Client sent unknown parameter: %s", cmd->name, argv[0]); ctx->v.deinit(ctx); + pool_unref(&ctx->pool); return NULL; } ctx->args = (const void *)argv; diff -r 235be95cb378 -r 5ed2f41431c4 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Wed Jun 12 23:01:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Thu Jun 13 03:26:22 2013 +0300 @@ -197,6 +197,7 @@ uint64_t last_common_modseq, last_common_pvt_modseq; i_assert(brain->log_scan == NULL); + i_assert(brain->box_exporter == NULL); last_common_uid = brain->mailbox_state.last_common_uid; last_common_modseq = brain->mailbox_state.last_common_modseq; diff -r 235be95cb378 -r 5ed2f41431c4 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Wed Jun 12 23:01:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Thu Jun 13 03:26:22 2013 +0300 @@ -186,6 +186,8 @@ dsync_brain_sync_mailbox_deinit(brain); if (brain->local_tree_iter != NULL) dsync_mailbox_tree_iter_deinit(&brain->local_tree_iter); + dsync_mailbox_tree_deinit(&brain->local_mailbox_tree); + dsync_mailbox_tree_deinit(&brain->remote_mailbox_tree); if (brain->mailbox_states_iter != NULL) hash_table_iterate_deinit(&brain->mailbox_states_iter); hash_table_destroy(&brain->mailbox_states); diff -r 235be95cb378 -r 5ed2f41431c4 src/doveadm/dsync/dsync-ibc-pipe.c --- a/src/doveadm/dsync/dsync-ibc-pipe.c Wed Jun 12 23:01:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-pipe.c Thu Jun 13 03:26:22 2013 +0300 @@ -134,6 +134,7 @@ static void dsync_ibc_pipe_deinit(struct dsync_ibc *ibc) { struct dsync_ibc_pipe *pipe = (struct dsync_ibc_pipe *)ibc; + struct item *item; pool_t *poolp; if (pipe->remote != NULL) { @@ -143,6 +144,10 @@ if (pipe->pop_pool != NULL) pool_unref(&pipe->pop_pool); + array_foreach_modifiable(&pipe->item_queue, item) { + if (item->pool != NULL) + pool_unref(&item->pool); + } array_foreach_modifiable(&pipe->pools, poolp) pool_unref(poolp); array_free(&pipe->pools); diff -r 235be95cb378 -r 5ed2f41431c4 src/doveadm/dsync/dsync-mailbox-export.c --- a/src/doveadm/dsync/dsync-mailbox-export.c Wed Jun 12 23:01:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-export.c Thu Jun 13 03:26:22 2013 +0300 @@ -844,6 +844,7 @@ if (exporter->attr.value_stream != NULL) i_stream_unref(&exporter->attr.value_stream); hash_table_destroy(&exporter->export_guids); + hash_table_destroy(&exporter->changes); *error_r = t_strdup(exporter->error); pool_unref(&exporter->pool); diff -r 235be95cb378 -r 5ed2f41431c4 src/doveadm/main.c --- a/src/doveadm/main.c Wed Jun 12 23:01:26 2013 +0300 +++ b/src/doveadm/main.c Thu Jun 13 03:26:22 2013 +0300 @@ -61,6 +61,7 @@ client_connection_destroy(&doveadm_client); doveadm_mail_deinit(); doveadm_unload_modules(); + doveadm_print_deinit(); } int main(int argc, char *argv[]) diff -r 235be95cb378 -r 5ed2f41431c4 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Wed Jun 12 23:01:26 2013 +0300 +++ b/src/lib-fs/fs-api.c Thu Jun 13 03:26:22 2013 +0300 @@ -43,6 +43,11 @@ array_append(&fs_classes, &fs_class, 1); } +static void fs_classes_deinit(void) +{ + array_free(&fs_classes); +} + static void fs_classes_init(void) { i_array_init(&fs_classes, 8); @@ -50,6 +55,7 @@ fs_class_register(&fs_class_metawrap); fs_class_register(&fs_class_sis); fs_class_register(&fs_class_sis_queue); + lib_atexit(fs_classes_deinit); } static const struct fs *fs_class_find(const char *driver) From dovecot at dovecot.org Thu Jun 13 04:35:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 04:35:25 +0300 Subject: dovecot-2.2: dsync: Don't try to access mailboxes with no_mail_s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d8fc9bba98ab changeset: 16504:d8fc9bba98ab user: Timo Sirainen date: Thu Jun 13 04:33:41 2013 +0300 description: dsync: Don't try to access mailboxes with no_mail_sync flag enabled. diffstat: src/doveadm/dsync/dsync-brain-mailbox.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 5ed2f41431c4 -r d8fc9bba98ab src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Thu Jun 13 03:26:22 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Thu Jun 13 04:33:41 2013 +0300 @@ -401,6 +401,9 @@ { int ret; + if (brain->no_mail_sync) + return FALSE; + while ((ret = dsync_brain_try_next_mailbox(brain, box_r, dsync_box_r)) == 0) ; return ret > 0; From dovecot at dovecot.org Thu Jun 13 04:35:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 04:35:25 +0300 Subject: dovecot-2.2: doveadm: Pass through the exit code from doveadm-se... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/63092465c522 changeset: 16505:63092465c522 user: Timo Sirainen date: Thu Jun 13 04:35:06 2013 +0300 description: doveadm: Pass through the exit code from doveadm-server to client. diffstat: src/doveadm/client-connection.c | 3 ++- src/doveadm/doveadm-mail-server.c | 17 +++++++++-------- src/doveadm/dsync/doveadm-dsync.c | 23 +++++++++++------------ src/doveadm/server-connection.c | 28 +++++++++++++++------------- src/doveadm/server-connection.h | 9 ++------- 5 files changed, 39 insertions(+), 41 deletions(-) diffs (192 lines): diff -r d8fc9bba98ab -r 63092465c522 src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Thu Jun 13 04:33:41 2013 +0300 +++ b/src/doveadm/client-connection.c Thu Jun 13 04:35:06 2013 +0300 @@ -127,7 +127,8 @@ o_stream_nsend_str(conn->output, "\n-NOUSER\n"); } else if (ctx->exit_code != 0) { /* maybe not an error, but not a full success either */ - o_stream_nsend(conn->output, "\n-\n", 3); + o_stream_nsend_str(conn->output, + t_strdup_printf("\n-%u\n", ctx->exit_code)); } else { o_stream_nsend(conn->output, "\n+\n", 3); } diff -r d8fc9bba98ab -r 63092465c522 src/doveadm/doveadm-mail-server.c --- a/src/doveadm/doveadm-mail-server.c Thu Jun 13 04:33:41 2013 +0300 +++ b/src/doveadm/doveadm-mail-server.c Thu Jun 13 04:35:06 2013 +0300 @@ -81,7 +81,7 @@ return FALSE; } -static void doveadm_cmd_callback(enum server_cmd_reply reply, void *context) +static void doveadm_cmd_callback(int exit_code, void *context) { struct doveadm_mail_server_cmd *servercmd = context; struct doveadm_server *server = @@ -91,21 +91,22 @@ i_free(servercmd->username); i_free(servercmd); - switch (reply) { - case SERVER_CMD_REPLY_INTERNAL_FAILURE: + switch (exit_code) { + case 0: + break; + case SERVER_EXIT_CODE_DISCONNECTED: i_error("%s: Internal failure for %s", server->name, username); internal_failure = TRUE; master_service_stop(master_service); return; - case SERVER_CMD_REPLY_UNKNOWN_USER: + case EX_NOUSER: i_error("%s: No such user: %s", server->name, username); if (cmd_ctx->exit_code == 0) cmd_ctx->exit_code = EX_NOUSER; break; - case SERVER_CMD_REPLY_FAIL: - doveadm_mail_failed_error(cmd_ctx, MAIL_ERROR_TEMP); - break; - case SERVER_CMD_REPLY_OK: + default: + if (cmd_ctx->exit_code == 0 || exit_code == EX_TEMPFAIL) + cmd_ctx->exit_code = exit_code; break; } diff -r d8fc9bba98ab -r 63092465c522 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Thu Jun 13 04:33:41 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Thu Jun 13 04:35:06 2013 +0300 @@ -615,27 +615,26 @@ return ret; } -static void dsync_connected_callback(enum server_cmd_reply reply, void *context) +static void dsync_connected_callback(int exit_code, void *context) { struct dsync_cmd_context *ctx = context; - switch (reply) { - case SERVER_CMD_REPLY_UNKNOWN_USER: - ctx->error = "Unknown user in remote"; - ctx->ctx.exit_code = EX_NOUSER; - break; - case SERVER_CMD_REPLY_FAIL: - ctx->error = "Failed to start dsync-server command"; - break; - case SERVER_CMD_REPLY_OK: + ctx->ctx.exit_code = exit_code; + switch (exit_code) { + case 0: server_connection_extract(ctx->tcp_conn, &ctx->input, &ctx->output, &ctx->ssl_iostream); break; - case SERVER_CMD_REPLY_INTERNAL_FAILURE: + case SERVER_EXIT_CODE_DISCONNECTED: ctx->error = "Disconnected from remote"; break; + case EX_NOUSER: + ctx->error = "Unknown user in remote"; + break; default: - i_unreached(); + ctx->error = p_strdup_printf(ctx->ctx.pool, + "Failed to start dsync-server command: %u", exit_code); + break; } io_loop_stop(current_ioloop); } diff -r d8fc9bba98ab -r 63092465c522 src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Thu Jun 13 04:33:41 2013 +0300 +++ b/src/doveadm/server-connection.c Thu Jun 13 04:35:06 2013 +0300 @@ -19,6 +19,7 @@ #include "doveadm-settings.h" #include "server-connection.h" +#include #include #define MAX_INBUF_SIZE (1024*32) @@ -78,13 +79,12 @@ } static void -server_connection_callback(struct server_connection *conn, - enum server_cmd_reply reply) +server_connection_callback(struct server_connection *conn, int exit_code) { server_cmd_callback_t *callback = conn->callback; conn->callback = NULL; - callback(reply, conn->context); + callback(exit_code, conn->context); } static void stream_data(string_t *str, const unsigned char *data, size_t size) @@ -203,7 +203,7 @@ const unsigned char *data; size_t size; const char *line; - enum server_cmd_reply reply; + int exit_code; if (!conn->handshaked) { if ((line = i_stream_read_next_line(conn->input)) == NULL) { @@ -266,12 +266,16 @@ if (line == NULL) return; if (line[0] == '+') - server_connection_callback(conn, SERVER_CMD_REPLY_OK); + server_connection_callback(conn, 0); else if (line[0] == '-') { - reply = strcmp(line+1, "NOUSER") == 0 ? - SERVER_CMD_REPLY_UNKNOWN_USER : - SERVER_CMD_REPLY_FAIL; - server_connection_callback(conn, reply); + line++; + if (strcmp(line, "NOUSER") == 0) + exit_code = EX_NOUSER; + else if (str_to_int(line, &exit_code) < 0) { + /* old doveadm-server */ + exit_code = EX_TEMPFAIL; + } + server_connection_callback(conn, exit_code); } else { i_error("doveadm server sent broken input " "(expected cmd reply): %s", line); @@ -413,10 +417,8 @@ } } - if (conn->callback != NULL) { - server_connection_callback(conn, - SERVER_CMD_REPLY_INTERNAL_FAILURE); - } + if (conn->callback != NULL) + server_connection_callback(conn, SERVER_EXIT_CODE_DISCONNECTED); if (printing_conn == conn) print_connection_released(); diff -r d8fc9bba98ab -r 63092465c522 src/doveadm/server-connection.h --- a/src/doveadm/server-connection.h Thu Jun 13 04:33:41 2013 +0300 +++ b/src/doveadm/server-connection.h Thu Jun 13 04:35:06 2013 +0300 @@ -1,18 +1,13 @@ #ifndef SERVER_CONNECTION_H #define SERVER_CONNECTION_H -enum server_cmd_reply { - SERVER_CMD_REPLY_INTERNAL_FAILURE, - SERVER_CMD_REPLY_UNKNOWN_USER, - SERVER_CMD_REPLY_FAIL, - SERVER_CMD_REPLY_OK -}; +#define SERVER_EXIT_CODE_DISCONNECTED 1000 struct doveadm_server; struct server_connection; struct ssl_iostream; -typedef void server_cmd_callback_t(enum server_cmd_reply reply, void *context); +typedef void server_cmd_callback_t(int exit_code, void *context); int server_connection_create(struct doveadm_server *server, struct server_connection **conn_r); From dovecot at dovecot.org Thu Jun 13 05:29:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 05:29:24 +0300 Subject: dovecot-2.2: mailbox_list_index=yes: Fixed list iteration when n... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/949ef3625aa2 changeset: 16506:949ef3625aa2 user: Timo Sirainen date: Thu Jun 13 05:27:30 2013 +0300 description: mailbox_list_index=yes: Fixed list iteration when namespace and backend separators differed. diffstat: src/lib-storage/list/mailbox-list-index-iter.c | 7 ++++--- src/lib-storage/list/mailbox-list-index.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diffs (35 lines): diff -r 63092465c522 -r 949ef3625aa2 src/lib-storage/list/mailbox-list-index-iter.c --- a/src/lib-storage/list/mailbox-list-index-iter.c Thu Jun 13 04:35:06 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-index-iter.c Thu Jun 13 05:27:30 2013 +0300 @@ -47,7 +47,6 @@ ctx->ctx.flags = flags; ctx->ctx.glob = imap_match_init_multiple(pool, patterns, TRUE, ns_sep); array_create(&ctx->ctx.module_contexts, pool, sizeof(void *), 5); - ctx->sep = ns_sep; ctx->info_pool = pool_alloconly_create("mailbox list index iter info", 128); if (!iter_use_index(ctx)) { @@ -74,8 +73,10 @@ p_clear(ctx->info_pool); str_truncate(ctx->path, ctx->parent_len); - if (str_len(ctx->path) > 0) - str_append_c(ctx->path, ctx->sep); + if (str_len(ctx->path) > 0) { + str_append_c(ctx->path, + mailbox_list_get_hierarchy_sep(ctx->ctx.list)); + } str_append(ctx->path, node->name); ctx->info.vname = mailbox_list_get_vname(ctx->ctx.list, str_c(ctx->path)); diff -r 63092465c522 -r 949ef3625aa2 src/lib-storage/list/mailbox-list-index.h --- a/src/lib-storage/list/mailbox-list-index.h Thu Jun 13 04:35:06 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-index.h Thu Jun 13 05:27:30 2013 +0300 @@ -119,7 +119,6 @@ unsigned int parent_len; string_t *path; struct mailbox_list_index_node *next_node; - char sep; unsigned int failed:1; }; From dovecot at dovecot.org Thu Jun 13 05:29:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 05:29:24 +0300 Subject: dovecot-2.2: imapc: Fixed list iteration when namespace and back... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c012f8df87f9 changeset: 16507:c012f8df87f9 user: Timo Sirainen date: Thu Jun 13 05:29:07 2013 +0300 description: imapc: Fixed list iteration when namespace and backend separators differed. diffstat: src/lib-storage/index/imapc/imapc-list.c | 50 ++++++++----------------------- 1 files changed, 13 insertions(+), 37 deletions(-) diffs (126 lines): diff -r 949ef3625aa2 -r c012f8df87f9 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Thu Jun 13 05:27:30 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Thu Jun 13 05:29:07 2013 +0300 @@ -413,12 +413,6 @@ struct imapc_simple_context ctx; struct mailbox_node *node; const char *pattern; - char sep; - - if (imapc_storage_try_get_root_sep(list->storage, &sep) < 0) { - mailbox_list_set_internal_error(&list->list); - return -1; - } if (list->refreshed_mailboxes) return 0; @@ -436,7 +430,7 @@ cmd = imapc_list_simple_context_init(&ctx, list); imapc_command_sendf(cmd, "LIST \"\" %s", pattern); mailbox_tree_deinit(&list->mailboxes); - list->mailboxes = mailbox_tree_init(sep); + list->mailboxes = mailbox_tree_init(mail_namespace_get_sep(list->list.ns)); mailbox_tree_set_parents_nonexistent(list->mailboxes); imapc_simple_run(&ctx); @@ -495,7 +489,7 @@ struct imapc_mailbox_list_iterate_context *ctx; pool_t pool; const char *ns_root_name; - char sep; + char ns_sep; int ret = 0; if ((flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0 || @@ -514,22 +508,19 @@ return _ctx; } - if (imapc_storage_try_get_root_sep(list->storage, &sep) < 0) { - mailbox_list_set_internal_error(_list); - ret = -1; - } + ns_sep = mail_namespace_get_sep(_list->ns); pool = pool_alloconly_create("mailbox list imapc iter", 1024); ctx = p_new(pool, struct imapc_mailbox_list_iterate_context, 1); ctx->ctx.pool = pool; ctx->ctx.list = _list; ctx->ctx.flags = flags; - ctx->ctx.glob = imap_match_init_multiple(pool, patterns, FALSE, sep); + ctx->ctx.glob = imap_match_init_multiple(pool, patterns, FALSE, ns_sep); array_create(&ctx->ctx.module_contexts, pool, sizeof(void *), 5); ctx->info.ns = _list->ns; - ctx->tree = mailbox_tree_init(sep); + ctx->tree = mailbox_tree_init(ns_sep); mailbox_tree_set_parents_nonexistent(ctx->tree); imapc_list_build_match_tree(ctx); @@ -635,44 +626,35 @@ struct imapc_simple_context ctx; struct imapc_command *cmd; const char *pattern; - char src_sep, dest_sep; + char dest_sep = mail_namespace_get_sep(dest_list->ns); i_assert(src_list->tmp_subscriptions == NULL); if (src_list->refreshed_subscriptions) { - if (dest_list->subscriptions == NULL) { - dest_sep = mailbox_list_get_hierarchy_sep(dest_list); - dest_list->subscriptions = - mailbox_tree_init(dest_sep); - } + if (dest_list->subscriptions == NULL) + dest_list->subscriptions = mailbox_tree_init(dest_sep); return 0; } - if (imapc_storage_try_get_root_sep(src_list->storage, &src_sep) < 0) { - mailbox_list_set_internal_error(dest_list); - return -1; - } - - src_list->tmp_subscriptions = mailbox_tree_init(src_sep); + src_list->tmp_subscriptions = + mailbox_tree_init(mail_namespace_get_sep(_src_list->ns)); cmd = imapc_list_simple_context_init(&ctx, src_list); if (*src_list->storage->set->imapc_list_prefix == '\0') pattern = "*"; else { - pattern = t_strdup_printf("%s%c*", - src_list->storage->set->imapc_list_prefix, - src_sep); + pattern = t_strdup_printf("%s*", + src_list->storage->set->imapc_list_prefix); } imapc_command_sendf(cmd, "LSUB \"\" %s", pattern); imapc_simple_run(&ctx); /* replace subscriptions tree in destination */ - mailbox_tree_set_separator(src_list->tmp_subscriptions, - mailbox_list_get_hierarchy_sep(dest_list)); if (dest_list->subscriptions != NULL) mailbox_tree_deinit(&dest_list->subscriptions); dest_list->subscriptions = src_list->tmp_subscriptions; src_list->tmp_subscriptions = NULL; + mailbox_tree_set_separator(dest_list->subscriptions, dest_sep); src_list->refreshed_subscriptions = TRUE; return 0; @@ -777,12 +759,6 @@ struct imapc_simple_context sctx; struct mailbox_node *node; const char *vname; - char sep; - - if (imapc_storage_try_get_root_sep(list->storage, &sep) < 0) { - mailbox_list_set_internal_error(_list); - return -1; - } vname = mailbox_list_get_vname(_list, name); if (!list->refreshed_mailboxes) { From dovecot at dovecot.org Thu Jun 13 06:09:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 06:09:25 +0300 Subject: dovecot-2.2: Call master_service_init_finish() only after all of... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/754d244b8249 changeset: 16508:754d244b8249 user: Timo Sirainen date: Thu Jun 13 06:07:54 2013 +0300 description: Call master_service_init_finish() only after all of the initialization is done. This way if the init crashes, the master process will throttle a buggy service. diffstat: src/anvil/main.c | 2 +- src/auth/main.c | 2 +- src/dict/main.c | 2 +- src/director/director-test.c | 2 +- src/director/main.c | 2 +- src/doveadm/main.c | 2 +- src/imap-urlauth/imap-urlauth-worker.c | 3 +-- src/imap/main.c | 2 +- src/indexer/indexer-worker.c | 2 +- src/indexer/indexer.c | 2 +- src/ipc/main.c | 2 +- src/lib-master/master-service.c | 2 +- src/lib-master/master-service.h | 5 ++++- src/lmtp/main.c | 2 +- src/log/main.c | 3 +-- src/plugins/quota/quota-status.c | 2 +- src/pop3/main.c | 2 +- src/replication/replicator/replicator.c | 2 +- src/ssl-params/main.c | 3 +-- src/stats/main.c | 2 +- src/util/script.c | 5 ++--- 21 files changed, 25 insertions(+), 26 deletions(-) diffs (truncated from 349 to 300 lines): diff -r c012f8df87f9 -r 754d244b8249 src/anvil/main.c --- a/src/anvil/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/anvil/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -73,11 +73,11 @@ /* delay dying until all of our clients are gone */ master_service_set_die_with_master(master_service, FALSE); - master_service_init_finish(master_service); connect_limit = connect_limit_init(); penalty = penalty_init(); log_fdpass_io = io_add(MASTER_ANVIL_LOG_FDPASS_FD, IO_READ, log_fdpass_input, (void *)NULL); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); diff -r c012f8df87f9 -r 754d244b8249 src/auth/main.c --- a/src/auth/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/auth/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -387,9 +387,9 @@ } main_preinit(); - master_service_init_finish(master_service); master_service_set_die_callback(master_service, auth_die); main_init(); + master_service_init_finish(master_service); master_service_run(master_service, worker ? worker_connected : client_connected); main_deinit(); diff -r c012f8df87f9 -r 754d244b8249 src/dict/main.c --- a/src/dict/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/dict/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -98,10 +98,10 @@ master_service_init_log(master_service, "dict: "); main_preinit(); - master_service_init_finish(master_service); master_service_set_die_callback(master_service, dict_die); main_init(); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); diff -r c012f8df87f9 -r 754d244b8249 src/director/director-test.c --- a/src/director/director-test.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/director/director-test.c Thu Jun 13 06:07:54 2013 +0300 @@ -594,9 +594,9 @@ i_fatal("director-doveadm socket path missing"); master_service_init_log(master_service, "director-test: "); - master_service_init_finish(master_service); main_init(admin_path); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); diff -r c012f8df87f9 -r 754d244b8249 src/director/main.c --- a/src/director/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/director/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -213,7 +213,6 @@ master_service_init_log(master_service, "director: "); main_preinit(); - master_service_init_finish(master_service); director->test_port = test_port; director_debug = debug; director_connect(director); @@ -225,6 +224,7 @@ t_strdup_printf("director(%s): ", net_ip2addr(&director->self_ip))); } + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); diff -r c012f8df87f9 -r 754d244b8249 src/doveadm/main.c --- a/src/doveadm/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/doveadm/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -85,10 +85,10 @@ master_service_init_log(master_service, "doveadm: "); main_preinit(); - master_service_init_finish(master_service); master_service_set_die_callback(master_service, doveadm_die); main_init(); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); diff -r c012f8df87f9 -r 754d244b8249 src/imap-urlauth/imap-urlauth-worker.c --- a/src/imap-urlauth/imap-urlauth-worker.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/imap-urlauth/imap-urlauth-worker.c Thu Jun 13 06:07:54 2013 +0300 @@ -1005,14 +1005,13 @@ master_service_init_log(master_service, t_strdup_printf("imap-urlauth[%s]: ", my_pid)); - - master_service_init_finish(master_service); master_service_set_die_callback(master_service, imap_urlauth_worker_die); random_init(); storage_service = mail_storage_service_init(master_service, set_roots, storage_service_flags); + master_service_init_finish(master_service); /* fake that we're running, so we know if client was destroyed while handling its initial input */ diff -r c012f8df87f9 -r 754d244b8249 src/imap/main.c --- a/src/imap/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/imap/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -363,7 +363,6 @@ } } - master_service_init_finish(master_service); master_service_set_die_callback(master_service, imap_die); /* plugins may want to add commands, so this needs to be called early */ @@ -374,6 +373,7 @@ storage_service = mail_storage_service_init(master_service, set_roots, storage_service_flags); + master_service_init_finish(master_service); /* fake that we're running, so we know if client was destroyed while handling its initial input */ diff -r c012f8df87f9 -r 754d244b8249 src/indexer/indexer-worker.c --- a/src/indexer/indexer-worker.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/indexer/indexer-worker.c Thu Jun 13 06:07:54 2013 +0300 @@ -69,11 +69,11 @@ drop_privileges(); master_service_init_log(master_service, "indexer-worker: "); - master_service_init_finish(master_service); storage_service = mail_storage_service_init(master_service, NULL, storage_service_flags); restrict_access_allow_coredumps(TRUE); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); diff -r c012f8df87f9 -r 754d244b8249 src/indexer/indexer.c --- a/src/indexer/indexer.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/indexer/indexer.c Thu Jun 13 06:07:54 2013 +0300 @@ -134,11 +134,11 @@ restrict_access_allow_coredumps(TRUE); master_service_set_idle_die_callback(master_service, idle_die); - master_service_init_finish(master_service); queue = indexer_queue_init(indexer_client_status_callback); indexer_queue_set_listen_callback(queue, queue_listen_callback); worker_pool = worker_pool_init("indexer-worker", worker_status_callback); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); diff -r c012f8df87f9 -r 754d244b8249 src/ipc/main.c --- a/src/ipc/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/ipc/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -48,8 +48,8 @@ restrict_access_by_env(NULL, FALSE); restrict_access_allow_coredumps(TRUE); + ipc_groups_init(); master_service_init_finish(master_service); - ipc_groups_init(); master_service_run(master_service, client_connected); diff -r c012f8df87f9 -r 754d244b8249 src/lib-master/master-service.c --- a/src/lib-master/master-service.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/lib-master/master-service.c Thu Jun 13 06:07:54 2013 +0300 @@ -137,6 +137,7 @@ i_set_failure_prefix("%s(init): ", name); /* ignore these signals as early as possible */ + lib_signals_init(); lib_signals_ignore(SIGPIPE, TRUE); lib_signals_ignore(SIGALRM, FALSE); @@ -428,7 +429,6 @@ struct stat st; /* set default signal handlers */ - lib_signals_init(); if ((service->flags & MASTER_SERVICE_FLAG_STANDALONE) == 0) sigint_flags |= LIBSIG_FLAG_RESTART; lib_signals_set_handler(SIGINT, sigint_flags, sig_die, service); diff -r c012f8df87f9 -r 754d244b8249 src/lib-master/master-service.h --- a/src/lib-master/master-service.h Thu Jun 13 05:29:07 2013 +0300 +++ b/src/lib-master/master-service.h Thu Jun 13 06:07:54 2013 +0300 @@ -66,7 +66,10 @@ bool master_service_parse_option(struct master_service *service, int opt, const char *arg); /* Finish service initialization. The caller should drop privileges - before calling this. */ + before calling this. This also notifies the master that the service was + successfully started and there shouldn't be any service throttling even if + it crashes afterwards, so this should be called after all of the + initialization code is finished. */ void master_service_init_finish(struct master_service *service); /* Clean environment from everything except the ones listed in diff -r c012f8df87f9 -r 754d244b8249 src/lmtp/main.c --- a/src/lmtp/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/lmtp/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -110,7 +110,6 @@ if (t_get_current_dir(&base_dir) < 0) i_fatal("getcwd() failed: %m"); drop_privileges(); - master_service_init_finish(master_service); master_service_init_log(master_service, t_strdup_printf("lmtp(%s): ", my_pid)); @@ -119,6 +118,7 @@ restrict_access_allow_coredumps(TRUE); main_init(); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); diff -r c012f8df87f9 -r 754d244b8249 src/log/main.c --- a/src/log/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/log/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -74,12 +74,11 @@ restrict_access_by_env(NULL, FALSE); restrict_access_allow_coredumps(TRUE); - master_service_init_finish(master_service); - /* logging should never die if there are some clients */ master_service_set_die_with_master(master_service, FALSE); main_init(); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); master_service_deinit(&master_service); diff -r c012f8df87f9 -r 754d244b8249 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/plugins/quota/quota-status.c Thu Jun 13 06:07:54 2013 +0300 @@ -237,9 +237,9 @@ master_service_init_log(master_service, "doveadm: "); main_preinit(); - master_service_init_finish(master_service); main_init(); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); master_service_deinit(&master_service); diff -r c012f8df87f9 -r 754d244b8249 src/pop3/main.c --- a/src/pop3/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/pop3/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -253,12 +253,12 @@ login_set.callback = login_client_connected; login_set.failure_callback = login_client_failed; - master_service_init_finish(master_service); master_service_set_die_callback(master_service, pop3_die); storage_service = mail_storage_service_init(master_service, set_roots, storage_service_flags); + master_service_init_finish(master_service); /* fake that we're running, so we know if client was destroyed while handling its initial input */ diff -r c012f8df87f9 -r 754d244b8249 src/replication/replicator/replicator.c --- a/src/replication/replicator/replicator.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/replication/replicator/replicator.c Thu Jun 13 06:07:54 2013 +0300 @@ -125,9 +125,9 @@ restrict_access_by_env(NULL, FALSE); restrict_access_allow_coredumps(TRUE); - master_service_init_finish(master_service); main_init(); + master_service_init_finish(master_service); master_service_run(master_service, client_connected); main_deinit(); diff -r c012f8df87f9 -r 754d244b8249 src/ssl-params/main.c --- a/src/ssl-params/main.c Thu Jun 13 05:29:07 2013 +0300 +++ b/src/ssl-params/main.c Thu Jun 13 06:07:54 2013 +0300 @@ -147,13 +147,12 @@ restrict_access_by_env(NULL, FALSE); restrict_access_allow_coredumps(TRUE); - master_service_init_finish(master_service); - From dovecot at dovecot.org Thu Jun 13 17:55:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 17:55:37 +0300 Subject: dovecot-2.2: solr-schema.xml: Replaced EnglishPorterFilterFactor... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cfd442fcc672 changeset: 16509:cfd442fcc672 user: Timo Sirainen date: Thu Jun 13 17:55:24 2013 +0300 description: solr-schema.xml: Replaced EnglishPorterFilterFactory with SnowballPorterFilterFactory diffstat: doc/solr-schema.xml | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 754d244b8249 -r cfd442fcc672 doc/solr-schema.xml --- a/doc/solr-schema.xml Thu Jun 13 06:07:54 2013 +0300 +++ b/doc/solr-schema.xml Thu Jun 13 17:55:24 2013 +0300 @@ -21,7 +21,7 @@ - + @@ -30,7 +30,7 @@ - + From dovecot at dovecot.org Thu Jun 13 18:53:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 18:53:38 +0300 Subject: dovecot-2.2: solr-schema.xml: More updates for Solr v4.x and hop... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0e56484c665a changeset: 16510:0e56484c665a user: Timo Sirainen date: Thu Jun 13 18:53:22 2013 +0300 description: solr-schema.xml: More updates for Solr v4.x and hopefully with better filters. diffstat: doc/solr-schema.xml | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-) diffs (74 lines): diff -r cfd442fcc672 -r 0e56484c665a doc/solr-schema.xml --- a/doc/solr-schema.xml Thu Jun 13 17:55:24 2013 +0300 +++ b/doc/solr-schema.xml Thu Jun 13 18:53:22 2013 +0300 @@ -6,32 +6,32 @@ This is the Solr schema file, place it into solr/conf/schema.xml. You may want to modify the tokenizers and filters. --> - + - - - - - + + + - - - + + + - - + + + - + - - + + - - + + + @@ -39,7 +39,7 @@ - + @@ -51,9 +51,10 @@ + + + id - body - From dovecot at dovecot.org Thu Jun 13 18:54:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 18:54:14 +0300 Subject: dovecot-2.2: fts-solr: Do only soft commits. Use a cronjob to do... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/91765ba4d534 changeset: 16511:91765ba4d534 user: Timo Sirainen date: Thu Jun 13 18:54:07 2013 +0300 description: fts-solr: Do only soft commits. Use a cronjob to do hard commits. diffstat: src/plugins/fts-solr/fts-backend-solr.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 0e56484c665a -r 91765ba4d534 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Thu Jun 13 18:53:22 2013 +0300 +++ b/src/plugins/fts-solr/fts-backend-solr.c Thu Jun 13 18:54:07 2013 +0300 @@ -361,7 +361,7 @@ visible to the following search */ if (ctx->expunges) fts_backend_solr_expunge_flush(ctx); - str = t_strdup_printf("", + str = t_strdup_printf("", ctx->documents_added ? "true" : "false"); if (solr_connection_post(solr_conn, str) < 0) ret = -1; From dovecot at dovecot.org Thu Jun 13 23:22:33 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 23:22:33 +0300 Subject: dovecot-2.2: lib-storage: Fixed crash with listing shared mailbo... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/04ee59c96fc9 changeset: 16512:04ee59c96fc9 user: Timo Sirainen date: Thu Jun 13 23:22:20 2013 +0300 description: lib-storage: Fixed crash with listing shared mailboxes. diffstat: src/lib-storage/index/shared/shared-list.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (19 lines): diff -r 91765ba4d534 -r 04ee59c96fc9 src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Thu Jun 13 18:54:07 2013 +0300 +++ b/src/lib-storage/index/shared/shared-list.c Thu Jun 13 23:22:20 2013 +0300 @@ -46,10 +46,12 @@ name = mailbox_list_get_storage_name(*list, vname); if (*name == '\0' && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) { /* trying to access the shared/ prefix itself */ - } else { - if (shared_storage_get_namespace(&ns, &name) < 0) - return -1; + *storage_r = ns->storage; + return 0; } + + if (shared_storage_get_namespace(&ns, &name) < 0) + return -1; *list = ns->list; return mailbox_list_get_storage(list, vname, storage_r); } From dovecot at dovecot.org Thu Jun 13 23:31:06 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Jun 2013 23:31:06 +0300 Subject: dovecot-2.2: quota-status: Fixed log prefix. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e6aa668477d8 changeset: 16513:e6aa668477d8 user: Timo Sirainen date: Thu Jun 13 23:31:00 2013 +0300 description: quota-status: Fixed log prefix. diffstat: src/plugins/quota/quota-status.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 04ee59c96fc9 -r e6aa668477d8 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Thu Jun 13 23:22:20 2013 +0300 +++ b/src/plugins/quota/quota-status.c Thu Jun 13 23:31:00 2013 +0300 @@ -235,7 +235,7 @@ if (protocol == QUOTA_PROTOCOL_UNKNOWN) i_fatal("Missing -p parameter"); - master_service_init_log(master_service, "doveadm: "); + master_service_init_log(master_service, "quota-status: "); main_preinit(); main_init(); From dovecot at dovecot.org Fri Jun 14 00:24:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Jun 2013 00:24:01 +0300 Subject: dovecot-2.2: dsync: Avoid wasting data stack on larger renames. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1c657812991b changeset: 16514:1c657812991b user: Timo Sirainen date: Fri Jun 14 00:16:14 2013 +0300 description: dsync: Avoid wasting data stack on larger renames. diffstat: src/doveadm/dsync/dsync-mailbox-tree-sync.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diffs (33 lines): diff -r e6aa668477d8 -r 1c657812991b src/doveadm/dsync/dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c Thu Jun 13 23:31:00 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c Fri Jun 14 00:16:14 2013 +0300 @@ -717,6 +717,7 @@ struct dsync_mailbox_node **local_nodep = &local_parent->first_child; struct dsync_mailbox_node **remote_nodep = &remote_parent->first_child; struct dsync_mailbox_node *local_node, *remote_node; + bool changed; /* the nodes are sorted by their names. */ while (*local_nodep != NULL || *remote_nodep != NULL) { @@ -750,11 +751,19 @@ /* mailboxes are equal, no need to rename */ } else { /* mailbox naming conflict */ - if (sync_rename_conflict(ctx, local_node, remote_node)) + T_BEGIN { + changed = sync_rename_conflict(ctx, local_node, + remote_node); + } T_END; + if (changed) return TRUE; } /* handle children, if there are any */ - if (sync_rename_mailboxes(ctx, local_node, remote_node)) + T_BEGIN { + changed = sync_rename_mailboxes(ctx, local_node, + remote_node); + } T_END; + if (changed) return TRUE; local_nodep = &local_node->next; From dovecot at dovecot.org Fri Jun 14 00:24:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Jun 2013 00:24:01 +0300 Subject: dovecot-2.2: dsync: Don't try to delete nonexistent mailbox dire... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3ef37c649d27 changeset: 16515:3ef37c649d27 user: Timo Sirainen date: Fri Jun 14 00:16:58 2013 +0300 description: dsync: Don't try to delete nonexistent mailbox directories. diffstat: src/doveadm/dsync/dsync-mailbox-tree-sync.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diffs (21 lines): diff -r 1c657812991b -r 3ef37c649d27 src/doveadm/dsync/dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c Fri Jun 14 00:16:14 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c Fri Jun 14 00:16:58 2013 +0300 @@ -868,13 +868,14 @@ for (child = node->first_child; child != NULL; child = child->next) sync_rename_delete_node_dirs(ctx, tree, child); - node->existence = DSYNC_MAILBOX_NODE_NONEXISTENT; - node->sync_temporary_name = FALSE; if (tree == ctx->local_tree && - ctx->sync_type != DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_LOCAL) { + ctx->sync_type != DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_LOCAL && + node->existence != DSYNC_MAILBOX_NODE_NONEXISTENT) { sync_add_dir_change(ctx, node, DSYNC_MAILBOX_TREE_SYNC_TYPE_DELETE_DIR); } + node->existence = DSYNC_MAILBOX_NODE_NONEXISTENT; + node->sync_temporary_name = FALSE; } static bool From dovecot at dovecot.org Fri Jun 14 00:24:01 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Jun 2013 00:24:01 +0300 Subject: dovecot-2.2: dsync: Fixed syncing renaming mailboxes with children. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d36f6b256bc0 changeset: 16516:d36f6b256bc0 user: Timo Sirainen date: Fri Jun 14 00:23:45 2013 +0300 description: dsync: Fixed syncing renaming mailboxes with children. So that the childrens' rename timestamps are at least as high as their parents'. diffstat: src/doveadm/dsync/dsync-mailbox-tree-sync.c | 16 +++++++++ src/doveadm/dsync/test-dsync-mailbox-tree-sync.c | 39 +++++++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diffs (111 lines): diff -r 3ef37c649d27 -r d36f6b256bc0 src/doveadm/dsync/dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c Fri Jun 14 00:16:58 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c Fri Jun 14 00:23:45 2013 +0300 @@ -1140,6 +1140,20 @@ &ctx->remote_tree->root); } +static void +dsync_mailbox_tree_update_child_timestamps(struct dsync_mailbox_node *node, + time_t parent_timestamp) +{ + time_t ts; + + if (node->last_renamed_or_created < parent_timestamp) + node->last_renamed_or_created = parent_timestamp; + ts = node->last_renamed_or_created; + + for (node = node->first_child; node != NULL; node = node->next) + dsync_mailbox_tree_update_child_timestamps(node, ts); +} + struct dsync_mailbox_tree_sync_ctx * dsync_mailbox_trees_sync_init(struct dsync_mailbox_tree *local_tree, struct dsync_mailbox_tree *remote_tree, @@ -1166,6 +1180,8 @@ ignore_deletes = sync_type == DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_REMOTE; sync_tree_sort_and_delete_mailboxes(ctx, local_tree, ignore_deletes); + dsync_mailbox_tree_update_child_timestamps(&local_tree->root, 0); + dsync_mailbox_tree_update_child_timestamps(&remote_tree->root, 0); while (sync_rename_mailboxes(ctx, &local_tree->root, &remote_tree->root)) ; while (sync_rename_temp_mailboxes(ctx, local_tree, &local_tree->root)) ; while (sync_rename_temp_mailboxes(ctx, remote_tree, &remote_tree->root)) ; diff -r 3ef37c649d27 -r d36f6b256bc0 src/doveadm/dsync/test-dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Fri Jun 14 00:16:58 2013 +0300 +++ b/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Fri Jun 14 00:23:45 2013 +0300 @@ -154,9 +154,10 @@ nodes_dump(tree2->root.first_child, 1); } -static void test_trees(struct dsync_mailbox_tree *tree1, - struct dsync_mailbox_tree *tree2) +static void test_trees_nofree(struct dsync_mailbox_tree *tree1, + struct dsync_mailbox_tree **_tree2) { + struct dsync_mailbox_tree *tree2 = *_tree2; struct dsync_mailbox_tree *orig_tree1, *orig_tree2; struct dsync_mailbox_tree_sync_ctx *ctx; struct dsync_mailbox_node *dup_node1, *dup_node2; @@ -201,12 +202,18 @@ trees_dump(tree1, orig_tree1); } - dsync_mailbox_tree_deinit(&tree1); - dsync_mailbox_tree_deinit(&tree2); + dsync_mailbox_tree_deinit(_tree2); dsync_mailbox_tree_deinit(&orig_tree1); dsync_mailbox_tree_deinit(&orig_tree2); } +static void test_trees(struct dsync_mailbox_tree *tree1, + struct dsync_mailbox_tree *tree2) +{ + test_trees_nofree(tree1, &tree2); + dsync_mailbox_tree_deinit(&tree1); +} + static void test_dsync_mailbox_tree_sync_creates(void) { static const char *common_nodes[] = { "foo", "foo/bar", NULL }; @@ -600,9 +607,32 @@ test_end(); } +static void test_dsync_mailbox_tree_sync_renames20(void) +{ + struct dsync_mailbox_tree *tree1, *tree2; + + test_begin("dsync mailbox tree sync renames 20"); + tree1 = dsync_mailbox_tree_init('/', '_'); + tree2 = dsync_mailbox_tree_init('/', '_'); + + node_create(tree1, 1, "1", 0); + node_create(tree1, 2, "0", 0); + node_create(tree1, 3, "0/2", 0); + /* rename 0 -> 1/0 */ + node_create(tree2, 1, "1", 0); + node_create(tree2, 2, "1/0", 1); + node_create(tree2, 3, "1/0/2", 0); + + test_trees_nofree(tree1, &tree2); + test_assert(tree1->root.first_child->next == NULL); + dsync_mailbox_tree_deinit(&tree1); + test_end(); +} + static void test_dsync_mailbox_tree_sync_random(void) { struct dsync_mailbox_tree *tree1, *tree2; + unsigned int i; test_begin("dsync mailbox tree sync random"); tree1 = create_random_tree(); @@ -635,6 +665,7 @@ test_dsync_mailbox_tree_sync_renames17, test_dsync_mailbox_tree_sync_renames18, test_dsync_mailbox_tree_sync_renames19, + test_dsync_mailbox_tree_sync_renames20, test_dsync_mailbox_tree_sync_random, NULL }; From dovecot at dovecot.org Fri Jun 14 02:14:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Jun 2013 02:14:14 +0300 Subject: dovecot-2.2: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/30f00db1a8b0 changeset: 16517:30f00db1a8b0 user: Timo Sirainen date: Fri Jun 14 02:14:09 2013 +0300 description: Compiler warning fix. diffstat: src/doveadm/dsync/test-dsync-mailbox-tree-sync.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r d36f6b256bc0 -r 30f00db1a8b0 src/doveadm/dsync/test-dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Fri Jun 14 00:23:45 2013 +0300 +++ b/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Fri Jun 14 02:14:09 2013 +0300 @@ -632,7 +632,6 @@ static void test_dsync_mailbox_tree_sync_random(void) { struct dsync_mailbox_tree *tree1, *tree2; - unsigned int i; test_begin("dsync mailbox tree sync random"); tree1 = create_random_tree(); From dovecot at dovecot.org Sun Jun 16 20:15:52 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Jun 2013 20:15:52 +0300 Subject: dovecot-2.2: lib-storage: mail_storage_service_lookup() ignored ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c290383e60da changeset: 16518:c290383e60da user: Timo Sirainen date: Sun Jun 16 20:15:42 2013 +0300 description: lib-storage: mail_storage_service_lookup() ignored input->service. diffstat: src/lib-storage/mail-storage-service.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 30f00db1a8b0 -r c290383e60da src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Fri Jun 14 02:14:09 2013 +0300 +++ b/src/lib-storage/mail-storage-service.c Sun Jun 16 20:15:42 2013 +0300 @@ -302,7 +302,8 @@ int ret; memset(&info, 0, sizeof(info)); - info.service = ctx->service->name; + info.service = input->service != NULL ? input->service : + ctx->service->name; info.local_ip = input->local_ip; info.remote_ip = input->remote_ip; info.local_port = input->local_port; From dovecot at dovecot.org Sun Jun 16 21:08:52 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Jun 2013 21:08:52 +0300 Subject: dovecot-2.2: istream-attachment-extractor: Fixed handling attach... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9dcbcc0871f0 changeset: 16519:9dcbcc0871f0 user: Timo Sirainen date: Sun Jun 16 21:08:40 2013 +0300 description: istream-attachment-extractor: Fixed handling attachment as the message body without MIME. Don't crash at the end after parsing the base64 data. diffstat: src/lib-mail/istream-attachment-extractor.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (27 lines): diff -r c290383e60da -r 9dcbcc0871f0 src/lib-mail/istream-attachment-extractor.c --- a/src/lib-mail/istream-attachment-extractor.c Sun Jun 16 20:15:42 2013 +0300 +++ b/src/lib-mail/istream-attachment-extractor.c Sun Jun 16 21:08:40 2013 +0300 @@ -524,6 +524,7 @@ astream_end_of_part(struct attachment_istream *astream) { struct attachment_istream_part *part = &astream->part; + size_t old_size; int ret = 0; /* MIME part changed. we're now parsing the end of a boundary, @@ -540,8 +541,15 @@ } break; case MAIL_ATTACHMENT_STATE_YES: + old_size = astream->istream.pos - astream->istream.skip; if (astream_part_finish(astream) < 0) ret = -1; + else { + /* finished base64 may have added a few more trailing + bytes to the stream */ + ret = astream->istream.pos - + astream->istream.skip - old_size; + } break; } part->state = MAIL_ATTACHMENT_STATE_NO; From dovecot at dovecot.org Sun Jun 16 21:15:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Jun 2013 21:15:49 +0300 Subject: dovecot-2.2: lib-imap: Fixed parsing literal8 in some situations. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dd04b4ef530d changeset: 16520:dd04b4ef530d user: Timo Sirainen date: Sun Jun 16 21:15:42 2013 +0300 description: lib-imap: Fixed parsing literal8 in some situations. diffstat: src/lib-imap/imap-parser.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 9dcbcc0871f0 -r dd04b4ef530d src/lib-imap/imap-parser.c --- a/src/lib-imap/imap-parser.c Sun Jun 16 21:08:40 2013 +0300 +++ b/src/lib-imap/imap-parser.c Sun Jun 16 21:15:42 2013 +0300 @@ -658,7 +658,7 @@ parser->error = "Expected '{'"; return FALSE; } - parser->cur_type = ARG_PARSE_LITERAL8; + parser->cur_type = ARG_PARSE_LITERAL; parser->cur_pos++; /* fall through */ case ARG_PARSE_LITERAL: From dovecot at dovecot.org Sun Jun 16 21:25:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Jun 2013 21:25:56 +0300 Subject: dovecot-2.2: fts-lucene: Fixed building without libstemmer Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3c9bb07ea92e changeset: 16521:3c9bb07ea92e user: Timo Sirainen date: Sun Jun 16 21:25:39 2013 +0300 description: fts-lucene: Fixed building without libstemmer diffstat: src/plugins/fts-lucene/lucene-wrapper.cc | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (15 lines): diff -r dd04b4ef530d -r 3c9bb07ea92e src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Sun Jun 16 21:15:42 2013 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Sun Jun 16 21:25:39 2013 +0300 @@ -123,9 +123,9 @@ index->default_analyzer = _CLNEW snowball::SnowballAnalyzer(index->normalizer, index->set.default_language); - } + } else #endif - else { + { index->default_analyzer = _CLNEW standard::StandardAnalyzer(); if (index->normalizer != NULL) { index->normalizer_buf = From dovecot at dovecot.org Sun Jun 16 23:56:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Jun 2013 23:56:42 +0300 Subject: dovecot-2.2: mdbox: Minor fix to handling corrupted mdbox header. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5a429604923c changeset: 16522:5a429604923c user: Timo Sirainen date: Sun Jun 16 23:56:28 2013 +0300 description: mdbox: Minor fix to handling corrupted mdbox header. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 3c9bb07ea92e -r 5a429604923c src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Sun Jun 16 21:25:39 2013 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Sun Jun 16 23:56:28 2013 +0300 @@ -227,8 +227,10 @@ struct mdbox_index_header hdr, new_hdr; bool need_resize; - if (mdbox_read_header(mbox, &hdr, &need_resize) < 0) + if (mdbox_read_header(mbox, &hdr, &need_resize) < 0) { memset(&hdr, 0, sizeof(hdr)); + need_resize = FALSE; + } new_hdr = hdr; From dovecot at dovecot.org Mon Jun 17 00:42:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Jun 2013 00:42:16 +0300 Subject: dovecot-2.2: Released v2.2.3. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5d9f52c9a287 changeset: 16523:5d9f52c9a287 user: Timo Sirainen date: Mon Jun 17 00:31:18 2013 +0300 description: Released v2.2.3. diffstat: NEWS | 28 ++++++++++++++++++++++++++++ TODO | 12 ++++++++++++ configure.ac | 4 ++-- 3 files changed, 42 insertions(+), 2 deletions(-) diffs (71 lines): diff -r 5a429604923c -r 5d9f52c9a287 NEWS --- a/NEWS Sun Jun 16 23:56:28 2013 +0300 +++ b/NEWS Mon Jun 17 00:31:18 2013 +0300 @@ -1,3 +1,31 @@ +v2.2.3 2013-06-17 Timo Sirainen + + * LDA/LMTP: If new mail delivery first fails with "temporary + failure", tempfail the whole delivery instead of falling back to + delivering the mail to INBOX. (Requires new Pigeonhole as well.) + * doc/solr-schema.xml was updated to Solr v4.x format. Also the + default analyzers were changed, hopefully for the better. Note that + the schema can't be changed for existing Solr indexes without + rebuilding everything. + * Solr plugin does only soft commits from now on. You'll need a + cronjob to send a hard commit command to it every few minutes. + + + Added %N modifier for variables as %H-like "new hash" + + sdbox, mdbox: Support POP3 message order field (for migrations) + + Added mailbox { driver } to specify a different mail storage + format for the mailbox than generally used within the namespace. + + Added initial lib-sasl library for client side SASL support. + Currently supports only PLAIN, LOGIN and plugins. Used currently + by IMAP and POP3 proxying when authenticating to the remote server. + - IMAP: If subject contained only whitespace, Dovecot returned an + ENVELOPE reply with a huge literal value, effectively causing the + IMAP client to wait for more data forever. + - IMAP: Various URLAUTH fixes. + - imapc: Various bugfixes and improvements + - pop3c: Various fixes to make it work in dsync (without imapc) + - dsync: Fixes to syncing subscriptions. Fixes to syncing mailbox + renames. + v2.2.2 2013-05-20 Timo Sirainen + zlib: Keep the last mail cached uncompressed in a temp file. This diff -r 5a429604923c -r 5d9f52c9a287 TODO --- a/TODO Sun Jun 16 23:56:28 2013 +0300 +++ b/TODO Mon Jun 17 00:31:18 2013 +0300 @@ -10,6 +10,18 @@ to match messages. - why does it use separate FETCH INTERNALDATE + FETCH BODY[HEADER] + - virtual plugin doesn't verify the index file's data, crashes if broken. + - imapc {} groups + - libsasl: use it in imapc, pop3c, managesieve-login, doveadm auth + - nonblocking passdb + blocking passdb -> deinit -> nonblocking passdb gets + aborted -> calls auth_worker_call() which crashes because deinit is + already done? + - ldap lookups should be done via auth worker processes? maybe automatically + if the lookups are queuing start creating workers? although multiple LDAP + connections within the same process would work too.. + - per-msg checksums? per-cache-msg checksums? per-log record checksums? + - lazy_expunge_only_last_instance=yes + mdbox doesn't work, because refcounts + don't update immediately - lib-ssl-iostream: ssl_get_last_error() should return also syscall errors instead of being NULL. most importantly handle handshake code. - if transaction log file corruption is noticed, make sure new dovecot.index diff -r 5a429604923c -r 5d9f52c9a287 configure.ac --- a/configure.ac Sun Jun 16 23:56:28 2013 +0300 +++ b/configure.ac Mon Jun 17 00:31:18 2013 +0300 @@ -2,8 +2,8 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.2],[dovecot at dovecot.org]) -AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv2($PACKAGE_VERSION)", [Dovecot ABI version]) +AC_INIT([Dovecot],[2.2.3],[dovecot at dovecot.org]) +AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv3($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) From dovecot at dovecot.org Mon Jun 17 00:42:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Jun 2013 00:42:16 +0300 Subject: dovecot-2.2: Added tag 2.2.3 for changeset 5d9f52c9a287 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c3c923724276 changeset: 16524:c3c923724276 user: Timo Sirainen date: Mon Jun 17 00:31:18 2013 +0300 description: Added tag 2.2.3 for changeset 5d9f52c9a287 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 5d9f52c9a287 -r c3c923724276 .hgtags --- a/.hgtags Mon Jun 17 00:31:18 2013 +0300 +++ b/.hgtags Mon Jun 17 00:31:18 2013 +0300 @@ -106,3 +106,4 @@ 1c8e7a295d4bd167a2b0a7243a3ec4d1e161360d 2.2.0 6fcf060b50f183549909f0fee17307e646edcbc6 2.2.1 7aa929edd551e3d3bd9405643341129c7a805554 2.2.2 +5d9f52c9a2871245097c725b9a4163a8789512fd 2.2.3 From dovecot at dovecot.org Mon Jun 17 00:42:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Jun 2013 00:42:16 +0300 Subject: dovecot-2.2: Added signature for changeset 5d9f52c9a287 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5a137e3eb51e changeset: 16525:5a137e3eb51e user: Timo Sirainen date: Mon Jun 17 00:31:22 2013 +0300 description: Added signature for changeset 5d9f52c9a287 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r c3c923724276 -r 5a137e3eb51e .hgsigs --- a/.hgsigs Mon Jun 17 00:31:18 2013 +0300 +++ b/.hgsigs Mon Jun 17 00:31:22 2013 +0300 @@ -69,3 +69,4 @@ e2cd03cc9c690c4989fb53a1871b7109c547388a 0 iEYEABECAAYFAlFnEVAACgkQyUhSUUBVismWBgCgit90C+1stGSchsVzJGghBs9278UAnj0vB6BETfOU9tNjViyCR18aEdUH 6fcf060b50f183549909f0fee17307e646edcbc6 0 iEYEABECAAYFAlFwZ7oACgkQyUhSUUBVismG6wCeI05eVDC++LqgfF9sOkoT3qRp9xYAn3pRDGYKPx7DhcTp+0RX/I9TXUmB 7aa929edd551e3d3bd9405643341129c7a805554 0 iEYEABECAAYFAlGZX2MACgkQyUhSUUBVisn2LACfWc8QwBvF31mYx3iv9ePvShCRcH4AnjZkbQEmcvaFQrfCy5YIIrstNBzx +5d9f52c9a2871245097c725b9a4163a8789512fd 0 iEYEABECAAYFAlG+LqYACgkQyUhSUUBVisn45wCgiEnDSrMoa5hZHRv+0eovGQJJ4g8An1Q8kms24rovLF/PGaani8Ap6VXR From dovecot at dovecot.org Mon Jun 17 00:44:20 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Jun 2013 00:44:20 +0300 Subject: dovecot-2.2: Make static analyzer happier. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/178fe5bf943b changeset: 16526:178fe5bf943b user: Timo Sirainen date: Mon Jun 17 00:03:16 2013 +0300 description: Make static analyzer happier. diffstat: src/doveadm/dsync/doveadm-dsync.c | 3 +++ src/doveadm/dsync/test-dsync-mailbox-tree-sync.c | 3 ++- src/imap-login/imap-proxy.c | 1 + src/pop3-login/pop3-proxy.c | 1 + 4 files changed, 7 insertions(+), 1 deletions(-) diffs (48 lines): diff -r 5a137e3eb51e -r 178fe5bf943b src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Jun 17 00:31:22 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Jun 17 00:03:16 2013 +0300 @@ -299,6 +299,9 @@ { const char *path1, *path2; + i_assert(user1->namespaces != NULL); + i_assert(user2->namespaces != NULL); + return mailbox_list_get_root_path(user1->namespaces->list, type, &path1) && mailbox_list_get_root_path(user2->namespaces->list, type, &path2) && strcmp(path1, path2) == 0; diff -r 5a137e3eb51e -r 178fe5bf943b src/doveadm/dsync/test-dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Mon Jun 17 00:31:22 2013 +0300 +++ b/src/doveadm/dsync/test-dsync-mailbox-tree-sync.c Mon Jun 17 00:03:16 2013 +0300 @@ -624,7 +624,8 @@ node_create(tree2, 3, "1/0/2", 0); test_trees_nofree(tree1, &tree2); - test_assert(tree1->root.first_child->next == NULL); + test_assert(tree1->root.first_child != NULL && + tree1->root.first_child->next == NULL); dsync_mailbox_tree_deinit(&tree1); test_end(); } diff -r 5a137e3eb51e -r 178fe5bf943b src/imap-login/imap-proxy.c --- a/src/imap-login/imap-proxy.c Mon Jun 17 00:31:22 2013 +0300 +++ b/src/imap-login/imap-proxy.c Mon Jun 17 00:03:16 2013 +0300 @@ -234,6 +234,7 @@ client_proxy_failed(client, TRUE); return -1; } + i_assert(ret == 0); str_truncate(str, 0); base64_encode(data, data_len, str); diff -r 5a137e3eb51e -r 178fe5bf943b src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Mon Jun 17 00:31:22 2013 +0300 +++ b/src/pop3-login/pop3-proxy.c Mon Jun 17 00:03:16 2013 +0300 @@ -110,6 +110,7 @@ error)); return -1; } + i_assert(ret == 0); str_truncate(str, 0); base64_encode(data, data_len, str); From dovecot at dovecot.org Mon Jun 17 14:40:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Jun 2013 14:40:10 +0300 Subject: dovecot-2.2: dsync: Minor fixes to checking if namespace is want... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/014003da870e changeset: 16527:014003da870e user: Timo Sirainen date: Mon Jun 17 14:39:59 2013 +0300 description: dsync: Minor fixes to checking if namespace is wanted to be synced. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diffs (30 lines): diff -r 178fe5bf943b -r 014003da870e src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Mon Jun 17 00:03:16 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Mon Jun 17 14:39:59 2013 +0300 @@ -14,8 +14,8 @@ static bool dsync_brain_want_namespace(struct dsync_brain *brain, struct mail_namespace *ns) { - if (brain->sync_ns == ns) - return TRUE; + if (brain->sync_ns != NULL) + return brain->sync_ns == ns; if (ns->alias_for != NULL) { /* always skip aliases */ return FALSE; @@ -26,11 +26,11 @@ if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_LIST_CHILDREN)) != 0) return TRUE; + return FALSE; + } else { + return strcmp(ns->unexpanded_set->location, + SETTING_STRVAR_UNEXPANDED) == 0; } - - return brain->sync_ns == NULL && - strcmp(ns->unexpanded_set->location, - SETTING_STRVAR_UNEXPANDED) == 0; } static void dsync_brain_check_namespaces(struct dsync_brain *brain) From dovecot at dovecot.org Mon Jun 17 16:37:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Jun 2013 16:37:57 +0300 Subject: dovecot-2.2: pop3: Fixed crash at deinit Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1352949265cc changeset: 16528:1352949265cc user: Timo Sirainen date: Mon Jun 17 16:37:46 2013 +0300 description: pop3: Fixed crash at deinit diffstat: src/pop3/pop3-client.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 014003da870e -r 1352949265cc src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Mon Jun 17 14:39:59 2013 +0300 +++ b/src/pop3/pop3-client.c Mon Jun 17 16:37:46 2013 +0300 @@ -593,7 +593,8 @@ message sizes. */ (void)mailbox_transaction_commit(&client->trans); } - array_free(&client->all_seqs); + if (array_is_created(&client->all_seqs)) + array_free(&client->all_seqs); if (client->deleted_kw != NULL) mailbox_keywords_unref(&client->deleted_kw); if (client->mailbox != NULL) From pigeonhole at rename-it.nl Tue Jun 18 09:35:10 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Jun 2013 08:35:10 +0200 Subject: dovecot-2.2-pigeonhole: lib-sievestorage: Removed PATH_MAX limit... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/1b1a0c271383 changeset: 1782:1b1a0c271383 user: Stephan Bosch date: Tue Jun 18 08:34:26 2013 +0200 description: lib-sievestorage: Removed PATH_MAX limitation for active symlink. Fixes issue for GNU/Hurd. diffstat: src/lib-sievestorage/sieve-storage-script.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diffs (38 lines): diff -r e439789e3211 -r 1b1a0c271383 src/lib-sievestorage/sieve-storage-script.c --- a/src/lib-sievestorage/sieve-storage-script.c Tue Jun 18 08:24:40 2013 +0200 +++ b/src/lib-sievestorage/sieve-storage-script.c Tue Jun 18 08:34:26 2013 +0200 @@ -2,6 +2,7 @@ */ #include "lib.h" +#include "abspath.h" #include "mempool.h" #include "hostpid.h" #include "ioloop.h" @@ -118,14 +119,13 @@ static int sieve_storage_read_active_link (struct sieve_storage *storage, const char **link_r) { - char linkbuf[PATH_MAX]; - int ret; + int ret; - *link_r = NULL; - - ret = readlink(storage->active_path, linkbuf, sizeof(linkbuf)); + ret = t_readlink(storage->active_path, link_r); if ( ret < 0 ) { + *link_r = NULL; + if ( errno == EINVAL ) { /* Our symlink is no symlink. Report 'no active script'. * Activating a script will automatically resolve this, so @@ -152,7 +152,6 @@ } /* ret is now assured to be valid, i.e. > 0 */ - *link_r = t_strndup(linkbuf, ret); return 1; } From pigeonhole at rename-it.nl Tue Jun 18 09:35:10 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Jun 2013 08:35:10 +0200 Subject: dovecot-2.2-pigeonhole: Don't access ns->storage. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/204d48dc7529 changeset: 1780:204d48dc7529 user: Stephan Bosch date: Tue Jun 18 08:11:37 2013 +0200 description: Don't access ns->storage. Patch by Timo Sirainen. diffstat: src/sieve-tools/sieve-filter.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r ca6735be7bba -r 204d48dc7529 src/sieve-tools/sieve-filter.c --- a/src/sieve-tools/sieve-filter.c Sun Jun 02 16:08:22 2013 +0200 +++ b/src/sieve-tools/sieve-filter.c Tue Jun 18 08:11:37 2013 +0200 @@ -505,7 +505,7 @@ src_box = mailbox_alloc(ns->list, src_mailbox, open_flags); if ( mailbox_open(src_box) < 0 ) { i_fatal("Couldn't open source mailbox '%s': %s", - src_mailbox, mail_storage_get_last_error(ns->storage, &error)); + src_mailbox, mailbox_get_last_error(src_box, &error)); } /* Open move box if necessary */ @@ -520,7 +520,7 @@ move_box = mailbox_alloc(ns->list, move_mailbox, open_flags); if ( mailbox_open(move_box) < 0 ) { i_fatal("Couldn't open mailbox '%s': %s", - move_mailbox, mail_storage_get_last_error(ns->storage, &error)); + move_mailbox, mailbox_get_last_error(move_box, &error)); } if ( mailbox_backends_equal(src_box, move_box) ) { From pigeonhole at rename-it.nl Tue Jun 18 09:35:10 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Jun 2013 08:35:10 +0200 Subject: dovecot-2.2-pigeonhole: Fixed line endings in X-Sieve headers ad... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/e439789e3211 changeset: 1781:e439789e3211 user: Stephan Bosch date: Tue Jun 18 08:24:40 2013 +0200 description: Fixed line endings in X-Sieve headers added by redirect command. Modified patch by Andriy Syrovenko. diffstat: src/lib-sieve/cmd-redirect.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diffs (20 lines): diff -r 204d48dc7529 -r e439789e3211 src/lib-sieve/cmd-redirect.c --- a/src/lib-sieve/cmd-redirect.c Tue Jun 18 08:11:37 2013 +0200 +++ b/src/lib-sieve/cmd-redirect.c Tue Jun 18 08:24:40 2013 +0200 @@ -344,10 +344,12 @@ string_t *hdr = t_str_new(256); /* Prepend sieve headers (should not affect signatures) */ - rfc2822_header_write(hdr, "X-Sieve", SIEVE_IMPLEMENTATION); - if ( recipient != NULL ) - rfc2822_header_write(hdr, "X-Sieve-Redirected-From", recipient); - o_stream_send(output, str_data(hdr), str_len(hdr)); + rfc2822_header_append(hdr, "X-Sieve", SIEVE_IMPLEMENTATION, FALSE, NULL); + if ( recipient != NULL ) { + rfc2822_header_append + (hdr, "X-Sieve-Redirected-From", recipient, FALSE, NULL); + } + o_stream_send(output, str_data(hdr), str_len(hdr)); } T_END; o_stream_send_istream(output, input); From dovecot at dovecot.org Tue Jun 18 11:59:32 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 11:59:32 +0300 Subject: dovecot-2.2: imap/pop3 proxy: Master user logins were broken by ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ba720ff91a75 changeset: 16529:ba720ff91a75 user: Timo Sirainen date: Tue Jun 18 11:59:21 2013 +0300 description: imap/pop3 proxy: Master user logins were broken by lib-sasl change. diffstat: src/imap-login/imap-proxy.c | 5 +++-- src/pop3-login/pop3-proxy.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diffs (30 lines): diff -r 1352949265cc -r ba720ff91a75 src/imap-login/imap-proxy.c --- a/src/imap-login/imap-proxy.c Mon Jun 17 16:37:46 2013 +0300 +++ b/src/imap-login/imap-proxy.c Tue Jun 18 11:59:21 2013 +0300 @@ -79,8 +79,9 @@ i_assert(client->common.proxy_sasl_client == NULL); memset(&sasl_set, 0, sizeof(sasl_set)); - sasl_set.authid = client->common.proxy_user; - sasl_set.authzid = client->common.proxy_master_user; + sasl_set.authid = client->common.proxy_master_user != NULL ? + client->common.proxy_master_user : client->common.proxy_user; + sasl_set.authzid = client->common.proxy_user; sasl_set.password = client->common.proxy_password; client->common.proxy_sasl_client = sasl_client_new(client->common.proxy_mech, &sasl_set); diff -r 1352949265cc -r ba720ff91a75 src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Mon Jun 17 16:37:46 2013 +0300 +++ b/src/pop3-login/pop3-proxy.c Tue Jun 18 11:59:21 2013 +0300 @@ -55,8 +55,9 @@ i_assert(client->common.proxy_sasl_client == NULL); memset(&sasl_set, 0, sizeof(sasl_set)); - sasl_set.authid = client->common.proxy_user; - sasl_set.authzid = client->common.proxy_master_user; + sasl_set.authid = client->common.proxy_master_user != NULL ? + client->common.proxy_master_user : client->common.proxy_user; + sasl_set.authzid = client->common.proxy_user; sasl_set.password = client->common.proxy_password; client->common.proxy_sasl_client = sasl_client_new(client->common.proxy_mech, &sasl_set); From dovecot at dovecot.org Tue Jun 18 12:16:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 12:16:07 +0300 Subject: dovecot-2.2: lib-sasl: API usage comment update Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3dc92ec58aef changeset: 16530:3dc92ec58aef user: Timo Sirainen date: Tue Jun 18 12:15:50 2013 +0300 description: lib-sasl: API usage comment update diffstat: src/lib-sasl/sasl-client.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r ba720ff91a75 -r 3dc92ec58aef src/lib-sasl/sasl-client.h --- a/src/lib-sasl/sasl-client.h Tue Jun 18 11:59:21 2013 +0300 +++ b/src/lib-sasl/sasl-client.h Tue Jun 18 12:15:50 2013 +0300 @@ -4,7 +4,8 @@ struct sasl_client_settings { /* authentication ID - must be set with most mechanisms */ const char *authid; - /* authorization ID ("master user") */ + /* authorization ID (who to log in as, if authentication ID is a + master user) */ const char *authzid; /* password - must be set with most mechanisms */ const char *password; From dovecot at dovecot.org Tue Jun 18 12:59:31 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 12:59:31 +0300 Subject: dovecot-2.2: lib-index: If error is found from transaction log, ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3794e6cb0da8 changeset: 16531:3794e6cb0da8 user: Timo Sirainen date: Tue Jun 18 12:56:27 2013 +0300 description: lib-index: If error is found from transaction log, update dovecot.index so it won't be read again. diffstat: src/lib-index/mail-index-sync.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 3dc92ec58aef -r 3794e6cb0da8 src/lib-index/mail-index-sync.c --- a/src/lib-index/mail-index-sync.c Tue Jun 18 12:15:50 2013 +0300 +++ b/src/lib-index/mail-index-sync.c Tue Jun 18 12:56:27 2013 +0300 @@ -895,6 +895,9 @@ uoff_t offset; ctx->errors = TRUE; + /* make sure we don't get to this same error again by updating the + dovecot.index */ + ctx->view->index->need_recreate = TRUE; mail_transaction_log_view_get_prev_pos(ctx->view->log_view, &seq, &offset); From dovecot at dovecot.org Tue Jun 18 12:59:31 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 12:59:31 +0300 Subject: dovecot-2.2: lib-index: Don't bother tracking if header/records ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/37bd40e27b67 changeset: 16532:37bd40e27b67 user: Timo Sirainen date: Tue Jun 18 12:59:17 2013 +0300 description: lib-index: Don't bother tracking if header/records were changed. They aren't really needed. When mail_index_write() is called, we already know we want to update the index. diffstat: src/lib-index/mail-index-fsck.c | 1 - src/lib-index/mail-index-map.c | 4 ---- src/lib-index/mail-index-modseq.c | 2 -- src/lib-index/mail-index-private.h | 5 ----- src/lib-index/mail-index-sync-ext.c | 13 +++++-------- src/lib-index/mail-index-sync-keywords.c | 2 -- src/lib-index/mail-index-sync-update.c | 7 +------ src/lib-index/mail-index-write.c | 8 +------- 8 files changed, 7 insertions(+), 35 deletions(-) diffs (223 lines): diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-fsck.c --- a/src/lib-index/mail-index-fsck.c Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-fsck.c Tue Jun 18 12:59:17 2013 +0300 @@ -454,7 +454,6 @@ mail_index_fsck_map(index, map); } T_END; - map->header_changed = TRUE; mail_index_write(index, FALSE); if (!orig_locked) diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-map.c --- a/src/lib-index/mail-index-map.c Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-map.c Tue Jun 18 12:59:17 2013 +0300 @@ -332,8 +332,6 @@ dest->records = buffer_get_modifiable_data(dest->buffer, NULL); dest->records_count = src->records_count; - - dest->records_changed = src->records_changed; } static void mail_index_map_copy_header(struct mail_index_map *dest, @@ -396,8 +394,6 @@ mail_index_map_copy_header(mem_map, map); - mem_map->header_changed = map->header_changed; - /* copy extensions */ if (array_is_created(&map->ext_id_map)) { count = array_count(&map->ext_id_map); diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-modseq.c --- a/src/lib-index/mail-index-modseq.c Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-modseq.c Tue Jun 18 12:59:17 2013 +0300 @@ -470,7 +470,6 @@ } T_END; } } - map->rec_map->records_changed = TRUE; mail_transaction_log_view_close(&ctx->log_view); } @@ -521,7 +520,6 @@ buffer_write(map->hdr_copy_buf, ext->hdr_offset, &new_modseq_hdr, sizeof(new_modseq_hdr)); map->hdr_base = map->hdr_copy_buf->data; - map->header_changed = TRUE; } } diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-private.h --- a/src/lib-index/mail-index-private.h Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-private.h Tue Jun 18 12:59:17 2013 +0300 @@ -127,9 +127,6 @@ struct mail_index_map_modseq *modseq; uint32_t last_appended_uid; - - /* The records have changed since it was read */ - bool records_changed; }; struct mail_index_map { @@ -147,8 +144,6 @@ ARRAY(unsigned int) keyword_idx_map; /* file -> index */ struct mail_index_record_map *rec_map; - - unsigned int header_changed:1; }; struct mail_index_module_register { diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-sync-ext.c --- a/src/lib-index/mail-index-sync-ext.c Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-sync-ext.c Tue Jun 18 12:59:17 2013 +0300 @@ -317,7 +317,6 @@ i_assert((map->hdr_copy_buf->used % sizeof(uint64_t)) == 0); map->hdr_base = map->hdr_copy_buf->data; map->hdr.header_size = map->hdr_copy_buf->used; - map->header_changed = TRUE; ext_hdr = get_ext_header(map, ext); ext_hdr->reset_id = ext->reset_id; @@ -577,7 +576,6 @@ memset(PTR_OFFSET(rec, ext->record_offset), 0, ext->record_size); } - map->rec_map->records_changed = TRUE; } int mail_index_sync_ext_reset(struct mail_index_sync_map_ctx *ctx, @@ -630,9 +628,14 @@ ext = array_idx(&map->extensions, ctx->cur_ext_map_idx); if (offset + size > ext->hdr_size) { +#if 1 mail_index_sync_set_corrupted(ctx, "Extension header update points outside header size"); return -1; +#else + size = offset > ext->hdr_size ? 0 : + ext->hdr_size - offset; +#endif } buffer_write(map->hdr_copy_buf, ext->hdr_offset + offset, data, size); @@ -640,8 +643,6 @@ if (ext->index_idx == ctx->view->index->modseq_ext_id) mail_index_modseq_hdr_update(ctx->modseq_ctx); - - map->header_changed = TRUE; return 1; } @@ -690,8 +691,6 @@ return ret; } - view->map->rec_map->records_changed = TRUE; - /* @UNSAFE */ memcpy(old_data, u + 1, ext->record_size); return 1; @@ -791,7 +790,5 @@ u->uid, u->diff, (unsigned long long)orig_num); return -1; } - - view->map->rec_map->records_changed = TRUE; return 1; } diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-sync-keywords.c --- a/src/lib-index/mail-index-sync-keywords.c Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-sync-keywords.c Tue Jun 18 12:59:17 2013 +0300 @@ -215,7 +215,6 @@ if (!mail_index_lookup_seq_range(view, uid1, uid2, &seq1, &seq2)) return 1; - view->map->rec_map->records_changed = TRUE; mail_index_modseq_update_keyword(ctx->modseq_ctx, keyword_idx, seq1, seq2); @@ -337,7 +336,6 @@ &seq1, &seq2)) continue; - map->rec_map->records_changed = TRUE; mail_index_modseq_reset_keywords(ctx->modseq_ctx, seq1, seq2); for (seq1--; seq1 < seq2; seq1++) { rec = MAIL_INDEX_MAP_IDX(map, seq1); diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-sync-update.c Tue Jun 18 12:59:17 2013 +0300 @@ -380,7 +380,6 @@ map->rec_map->last_appended_uid = rec->uid; new_flags = rec->flags; - map->rec_map->records_changed = TRUE; mail_index_modseq_append(ctx->modseq_ctx, map->rec_map->records_count); } @@ -408,7 +407,6 @@ if (!mail_index_lookup_seq_range(view, u->uid1, u->uid2, &seq1, &seq2)) return 1; - view->map->rec_map->records_changed = TRUE; if (!MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL(u)) { mail_index_modseq_update_flags(ctx->modseq_ctx, u->add_flags | u->remove_flags, @@ -464,7 +462,6 @@ buffer_write(map->hdr_copy_buf, u->offset, u + 1, u->size); map->hdr_base = map->hdr_copy_buf->data; - map->header_changed = TRUE; /* @UNSAFE */ if ((uint32_t)(u->offset + u->size) <= sizeof(map->hdr)) { @@ -945,10 +942,8 @@ map->refcount--; had_dirty = (map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0; - if (had_dirty) { + if (had_dirty) map->hdr.flags &= ~MAIL_INDEX_HDR_FLAG_HAVE_DIRTY; - map->header_changed = TRUE; - } if (map->hdr_base != map->hdr_copy_buf->data) { /* if syncing updates the header, it updates hdr_copy_buf diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-write.c --- a/src/lib-index/mail-index-write.c Tue Jun 18 12:56:27 2013 +0300 +++ b/src/lib-index/mail-index-write.c Tue Jun 18 12:59:17 2013 +0300 @@ -119,9 +119,6 @@ return ret; } -#define mail_index_map_has_changed(map) \ - ((map)->header_changed || (map)->rec_map->records_changed) - void mail_index_write(struct mail_index *index, bool want_rotate) { struct mail_index_map *map = index->map; @@ -129,7 +126,7 @@ i_assert(index->log_sync_locked); - if (!mail_index_map_has_changed(map) || index->readonly) + if (index->readonly) return; if (!MAIL_INDEX_IS_IN_MEMORY(index)) { @@ -143,9 +140,6 @@ index->last_read_log_file_head_offset = hdr->log_file_head_offset; index->last_read_log_file_tail_offset = hdr->log_file_tail_offset; - map->rec_map->records_changed = FALSE; - map->header_changed = FALSE; - if (want_rotate && hdr->log_file_seq == index->log->head->hdr.file_seq && hdr->log_file_tail_offset == hdr->log_file_head_offset) From dovecot at dovecot.org Tue Jun 18 15:15:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 15:15:07 +0300 Subject: dovecot-2.2: mdbox: If mdbox header is corrupted, resize it to m... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3056feb418b1 changeset: 16533:3056feb418b1 user: Timo Sirainen date: Tue Jun 18 13:00:23 2013 +0300 description: mdbox: If mdbox header is corrupted, resize it to make sure its size is correct. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 37bd40e27b67 -r 3056feb418b1 src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Tue Jun 18 12:59:17 2013 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Tue Jun 18 13:00:23 2013 +0300 @@ -229,7 +229,7 @@ if (mdbox_read_header(mbox, &hdr, &need_resize) < 0) { memset(&hdr, 0, sizeof(hdr)); - need_resize = FALSE; + need_resize = TRUE; } new_hdr = hdr; From dovecot at dovecot.org Tue Jun 18 15:15:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 15:15:07 +0300 Subject: dovecot-2.2: doveadm: Added "flags" command to modify messages' ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5e51c5545029 changeset: 16534:5e51c5545029 user: Timo Sirainen date: Tue Jun 18 15:14:42 2013 +0300 description: doveadm: Added "flags" command to modify messages' flags. diffstat: src/doveadm/Makefile.am | 1 + src/doveadm/doveadm-mail-flags.c | 143 +++++++++++++++++++++++++++++++++++++++ src/doveadm/doveadm-mail.c | 3 + src/doveadm/doveadm-mail.h | 3 + 4 files changed, 150 insertions(+), 0 deletions(-) diffs (184 lines): diff -r 3056feb418b1 -r 5e51c5545029 src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Tue Jun 18 13:00:23 2013 +0300 +++ b/src/doveadm/Makefile.am Tue Jun 18 15:14:42 2013 +0300 @@ -64,6 +64,7 @@ doveadm-mail-batch.c \ doveadm-mail-expunge.c \ doveadm-mail-fetch.c \ + doveadm-mail-flags.c \ doveadm-mail-import.c \ doveadm-mail-index.c \ doveadm-mail-iter.c \ diff -r 3056feb418b1 -r 5e51c5545029 src/doveadm/doveadm-mail-flags.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/doveadm/doveadm-mail-flags.c Tue Jun 18 15:14:42 2013 +0300 @@ -0,0 +1,143 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "imap-util.h" +#include "mail-storage.h" +#include "doveadm-mailbox-list-iter.h" +#include "doveadm-mail-iter.h" +#include "doveadm-mail.h" + +#include + +struct flags_cmd_context { + struct doveadm_mail_cmd_context ctx; + enum modify_type modify_type; + enum mail_flags flags; + const char *const *keywords; +}; + +static int +cmd_flags_run_box(struct flags_cmd_context *ctx, + const struct mailbox_info *info) +{ + struct doveadm_mail_iter *iter; + struct mailbox *box; + struct mail *mail; + struct mail_keywords *kw = NULL; + + if (doveadm_mail_iter_init(&ctx->ctx, info, ctx->ctx.search_args, + 0, NULL, &iter) < 0) + return -1; + box = doveadm_mail_iter_get_mailbox(iter); + + if (ctx->keywords != NULL) { + if (mailbox_keywords_create(box, ctx->keywords, &kw) < 0) { + i_error("Invalid keywords: %s", + mailbox_get_last_error(box, NULL)); + (void)doveadm_mail_iter_deinit(&iter); + ctx->ctx.exit_code = DOVEADM_EX_NOTPOSSIBLE; + return -1; + } + } + + while (doveadm_mail_iter_next(iter, &mail)) { + mail_update_flags(mail, ctx->modify_type, ctx->flags); + if (kw != NULL) + mail_update_keywords(mail, ctx->modify_type, kw); + } + if (kw != NULL) + mailbox_keywords_unref(&kw); + return doveadm_mail_iter_deinit(&iter); +} + +static int +cmd_flags_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) +{ + struct flags_cmd_context *ctx = (struct flags_cmd_context *)_ctx; + const enum mailbox_list_iter_flags iter_flags = + MAILBOX_LIST_ITER_NO_AUTO_BOXES | + MAILBOX_LIST_ITER_RETURN_NO_FLAGS; + struct doveadm_mailbox_list_iter *iter; + const struct mailbox_info *info; + int ret = 0; + + iter = doveadm_mailbox_list_iter_init(_ctx, user, _ctx->search_args, + iter_flags); + while ((info = doveadm_mailbox_list_iter_next(iter)) != NULL) T_BEGIN { + if (cmd_flags_run_box(ctx, info) < 0) + ret = -1; + } T_END; + if (doveadm_mailbox_list_iter_deinit(&iter) < 0) + ret = -1; + return ret; +} + +static void cmd_flags_init(struct doveadm_mail_cmd_context *_ctx, + const char *const args[]) +{ + struct flags_cmd_context *ctx = (struct flags_cmd_context *)_ctx; + const char *const *tmp; + enum mail_flags flag; + ARRAY_TYPE(const_string) keywords; + + if (args[0] == NULL || args[1] == NULL) + doveadm_mail_help_name("flags"); + + p_array_init(&keywords, _ctx->pool, 8); + for (tmp = t_strsplit(args[0], " "); *tmp != NULL; tmp++) { + const char *str = *tmp; + + if (str[0] == '\\') { + flag = imap_parse_system_flag(str); + if (flag == 0) + i_fatal("Invalid system flag: %s", str); + ctx->flags |= flag; + } else { + str = p_strdup(_ctx->pool, str); + array_append(&keywords, &str, 1); + } + } + if (array_count(&keywords) > 0 || ctx->modify_type == MODIFY_REPLACE) { + array_append_zero(&keywords); + ctx->keywords = array_idx(&keywords, 0); + } + + _ctx->search_args = doveadm_mail_build_search_args(args+1); +} + +static struct doveadm_mail_cmd_context * +cmd_flag_alloc(enum modify_type modify_type) +{ + struct flags_cmd_context *ctx; + + ctx = doveadm_mail_cmd_alloc(struct flags_cmd_context); + ctx->modify_type = modify_type; + ctx->ctx.v.init = cmd_flags_init; + ctx->ctx.v.run = cmd_flags_run; + return &ctx->ctx; +} + +static struct doveadm_mail_cmd_context *cmd_flags_add_alloc(void) +{ + return cmd_flag_alloc(MODIFY_ADD); +} + +static struct doveadm_mail_cmd_context *cmd_flags_remove_alloc(void) +{ + return cmd_flag_alloc(MODIFY_REMOVE); +} + +static struct doveadm_mail_cmd_context *cmd_flags_replace_alloc(void) +{ + return cmd_flag_alloc(MODIFY_REPLACE); +} + +struct doveadm_mail_cmd cmd_flags_add = { + cmd_flags_add_alloc, "flags add", " " +}; +struct doveadm_mail_cmd cmd_flags_remove = { + cmd_flags_remove_alloc, "flags remove", " " +}; +struct doveadm_mail_cmd cmd_flags_replace = { + cmd_flags_replace_alloc, "flags replace", " " +}; diff -r 3056feb418b1 -r 5e51c5545029 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Tue Jun 18 13:00:23 2013 +0300 +++ b/src/doveadm/doveadm-mail.c Tue Jun 18 15:14:42 2013 +0300 @@ -692,6 +692,9 @@ &cmd_expunge, &cmd_search, &cmd_fetch, + &cmd_flags_add, + &cmd_flags_remove, + &cmd_flags_replace, &cmd_import, &cmd_index, &cmd_altmove, diff -r 3056feb418b1 -r 5e51c5545029 src/doveadm/doveadm-mail.h --- a/src/doveadm/doveadm-mail.h Tue Jun 18 13:00:23 2013 +0300 +++ b/src/doveadm/doveadm-mail.h Tue Jun 18 15:14:42 2013 +0300 @@ -138,6 +138,9 @@ extern struct doveadm_mail_cmd cmd_expunge; extern struct doveadm_mail_cmd cmd_search; extern struct doveadm_mail_cmd cmd_fetch; +extern struct doveadm_mail_cmd cmd_flags_add; +extern struct doveadm_mail_cmd cmd_flags_remove; +extern struct doveadm_mail_cmd cmd_flags_replace; extern struct doveadm_mail_cmd cmd_import; extern struct doveadm_mail_cmd cmd_index; extern struct doveadm_mail_cmd cmd_altmove; From dovecot at dovecot.org Tue Jun 18 17:05:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 17:05:36 +0300 Subject: dovecot-2.2: doveadm: Added deduplicate command. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3683d7bff095 changeset: 16535:3683d7bff095 user: Timo Sirainen date: Tue Jun 18 17:05:20 2013 +0300 description: doveadm: Added deduplicate command. By default it deduplicates only by GUIDs. With -m parameter it deduplicates by Message-Id: header. diffstat: src/doveadm/Makefile.am | 1 + src/doveadm/doveadm-mail-deduplicate.c | 203 +++++++++++++++++++++++++++++++++ src/doveadm/doveadm-mail.c | 1 + src/doveadm/doveadm-mail.h | 1 + 4 files changed, 206 insertions(+), 0 deletions(-) diffs (240 lines): diff -r 5e51c5545029 -r 3683d7bff095 src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Tue Jun 18 15:14:42 2013 +0300 +++ b/src/doveadm/Makefile.am Tue Jun 18 17:05:20 2013 +0300 @@ -62,6 +62,7 @@ doveadm-mail.c \ doveadm-mail-altmove.c \ doveadm-mail-batch.c \ + doveadm-mail-deduplicate.c \ doveadm-mail-expunge.c \ doveadm-mail-fetch.c \ doveadm-mail-flags.c \ diff -r 5e51c5545029 -r 3683d7bff095 src/doveadm/doveadm-mail-deduplicate.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/doveadm/doveadm-mail-deduplicate.c Tue Jun 18 17:05:20 2013 +0300 @@ -0,0 +1,203 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "hash.h" +#include "mail-storage.h" +#include "mail-search-build.h" +#include "doveadm-mailbox-list-iter.h" +#include "doveadm-mail-iter.h" +#include "doveadm-mail.h" + +struct uidlist { + struct uidlist *next; + uint32_t uid; +}; + +struct deduplicate_cmd_context { + struct doveadm_mail_cmd_context ctx; + bool by_msgid; +}; + +static int cmd_deduplicate_uidlist(struct mailbox *box, struct uidlist *uidlist) +{ + struct mailbox_transaction_context *trans; + struct mail_search_context *search_ctx; + struct mail_search_args *search_args; + struct mail_search_arg *arg; + struct mail *mail; + ARRAY_TYPE(seq_range) uids; + int ret = 0; + + /* the uidlist is reversed with oldest mails at the end. + we'll delete everything but the oldest mail. */ + if (uidlist->next == NULL) + return 0; + + t_array_init(&uids, 8); + for (; uidlist->next != NULL; uidlist = uidlist->next) + seq_range_array_add(&uids, uidlist->uid); + + search_args = mail_search_build_init(); + arg = mail_search_build_add(search_args, SEARCH_UIDSET); + arg->value.seqset = uids; + + trans = mailbox_transaction_begin(box, 0); + search_ctx = mailbox_search_init(trans, search_args, NULL, 0, NULL); + mail_search_args_unref(&search_args); + + while (mailbox_search_next(search_ctx, &mail)) + mail_expunge(mail); + if (mailbox_search_deinit(&search_ctx) < 0) + ret = -1; + if (mailbox_transaction_commit(&trans) < 0) + ret = -1; + return ret; +} + +static int +cmd_deduplicate_box(struct doveadm_mail_cmd_context *_ctx, + const struct mailbox_info *info, + struct mail_search_args *search_args) +{ + struct deduplicate_cmd_context *ctx = + (struct deduplicate_cmd_context *)_ctx; + struct doveadm_mail_iter *iter; + struct mailbox *box; + struct mail *mail; + enum mail_error error; + pool_t pool; + HASH_TABLE(const char *, struct uidlist *) hash; + const char *key, *errstr; + struct uidlist *value; + int ret = 0; + + if (doveadm_mail_iter_init(_ctx, info, search_args, 0, NULL, + &iter) < 0) + return -1; + + pool = pool_alloconly_create("deduplicate", 10240); + hash_table_create(&hash, pool, 0, str_hash, strcmp); + while (doveadm_mail_iter_next(iter, &mail)) { + if (ctx->by_msgid) { + if (mail_get_first_header(mail, "Message-ID", &key) < 0) { + errstr = mailbox_get_last_error(box, &error); + if (error == MAIL_ERROR_NOTFOUND) + continue; + i_error("Couldn't lookup Message-ID: for UID=%u: %s", + mail->uid, errstr); + ret = -1; + break; + } + } else { + if (mail_get_special(mail, MAIL_FETCH_GUID, &key) < 0) { + errstr = mailbox_get_last_error(box, &error); + if (error == MAIL_ERROR_NOTFOUND) + continue; + i_error("Couldn't lookup GUID: for UID=%u: %s", + mail->uid, errstr); + ret = -1; + break; + } + } + if (key != NULL && *key != '\0') { + value = p_new(pool, struct uidlist, 1); + value->uid = mail->uid; + value->next = hash_table_lookup(hash, key); + + if (value->next == NULL) { + key = p_strdup(pool, key); + hash_table_insert(hash, key, value); + } else { + hash_table_update(hash, key, value); + } + } + } + + if (doveadm_mail_iter_deinit_keep_box(&iter, &box) < 0) + ret = -1; + + if (ret == 0) { + struct hash_iterate_context *iter; + + iter = hash_table_iterate_init(hash); + while (hash_table_iterate(iter, hash, &key, &value)) { + T_BEGIN { + if (cmd_deduplicate_uidlist(box, value) < 0) + ret = -1; + } T_END; + } + hash_table_iterate_deinit(&iter); + } + + hash_table_destroy(&hash); + pool_unref(&pool); + + if (mailbox_sync(box, 0) < 0) { + doveadm_mail_failed_mailbox(_ctx, box); + ret = -1; + } + mailbox_free(&box); + return ret; +} + +static int +cmd_deduplicate_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) +{ + const enum mailbox_list_iter_flags iter_flags = + MAILBOX_LIST_ITER_NO_AUTO_BOXES | + MAILBOX_LIST_ITER_RETURN_NO_FLAGS; + struct doveadm_mailbox_list_iter *iter; + const struct mailbox_info *info; + int ret = 0; + + iter = doveadm_mailbox_list_iter_init(ctx, user, ctx->search_args, + iter_flags); + while ((info = doveadm_mailbox_list_iter_next(iter)) != NULL) T_BEGIN { + if (cmd_deduplicate_box(ctx, info, ctx->search_args) < 0) + ret = -1; + } T_END; + if (doveadm_mailbox_list_iter_deinit(&iter) < 0) + ret = -1; + return ret; +} + +static void cmd_deduplicate_init(struct doveadm_mail_cmd_context *ctx, + const char *const args[]) +{ + if (args[0] == NULL) + doveadm_mail_help_name("deduplicate"); + + ctx->search_args = doveadm_mail_build_search_args(args); +} + +static bool +cmd_deduplicate_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +{ + struct deduplicate_cmd_context *ctx = + (struct deduplicate_cmd_context *)_ctx; + + switch (c) { + case 'm': + ctx->by_msgid = TRUE; + break; + default: + return FALSE; + } + return TRUE; +} + +static struct doveadm_mail_cmd_context *cmd_deduplicate_alloc(void) +{ + struct deduplicate_cmd_context *ctx; + + ctx = doveadm_mail_cmd_alloc(struct deduplicate_cmd_context); + ctx->ctx.getopt_args = "m"; + ctx->ctx.v.parse_arg = cmd_deduplicate_parse_arg; + ctx->ctx.v.init = cmd_deduplicate_init; + ctx->ctx.v.run = cmd_deduplicate_run; + return &ctx->ctx; +} + +struct doveadm_mail_cmd cmd_deduplicate = { + cmd_deduplicate_alloc, "deduplicate", "[-m] " +}; diff -r 5e51c5545029 -r 3683d7bff095 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Tue Jun 18 15:14:42 2013 +0300 +++ b/src/doveadm/doveadm-mail.c Tue Jun 18 17:05:20 2013 +0300 @@ -699,6 +699,7 @@ &cmd_index, &cmd_altmove, &cmd_copy, + &cmd_deduplicate, &cmd_move, &cmd_mailbox_list, &cmd_mailbox_create, diff -r 5e51c5545029 -r 3683d7bff095 src/doveadm/doveadm-mail.h --- a/src/doveadm/doveadm-mail.h Tue Jun 18 15:14:42 2013 +0300 +++ b/src/doveadm/doveadm-mail.h Tue Jun 18 17:05:20 2013 +0300 @@ -145,6 +145,7 @@ extern struct doveadm_mail_cmd cmd_index; extern struct doveadm_mail_cmd cmd_altmove; extern struct doveadm_mail_cmd cmd_copy; +extern struct doveadm_mail_cmd cmd_deduplicate; extern struct doveadm_mail_cmd cmd_move; extern struct doveadm_mail_cmd cmd_mailbox_list; extern struct doveadm_mail_cmd cmd_mailbox_create; From dovecot at dovecot.org Tue Jun 18 18:54:32 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 18:54:32 +0300 Subject: dovecot-2.2: sdbox: If sdbox header is corrupted, resize it to m... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/07642120b6ea changeset: 16536:07642120b6ea user: Timo Sirainen date: Tue Jun 18 18:54:20 2013 +0300 description: sdbox: If sdbox header is corrupted, resize it to make sure its size is correct. diffstat: src/lib-storage/index/dbox-single/sdbox-storage.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 3683d7bff095 -r 07642120b6ea src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Tue Jun 18 17:05:20 2013 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Tue Jun 18 18:54:20 2013 +0300 @@ -185,8 +185,10 @@ struct sdbox_index_header hdr, new_hdr; bool need_resize; - if (sdbox_read_header(mbox, &hdr, TRUE, &need_resize) < 0) + if (sdbox_read_header(mbox, &hdr, TRUE, &need_resize) < 0) { memset(&hdr, 0, sizeof(hdr)); + need_resize = TRUE; + } new_hdr = hdr; From dovecot at dovecot.org Tue Jun 18 18:56:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Jun 2013 18:56:37 +0300 Subject: dovecot-2.2: lib-storage: Fixed crash with some autocreated (e.g... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8a81c5a1b60f changeset: 16537:8a81c5a1b60f user: Timo Sirainen date: Tue Jun 18 18:56:15 2013 +0300 description: lib-storage: Fixed crash with some autocreated (e.g. shared) namespaces. diffstat: src/lib-storage/mailbox-list.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 07642120b6ea -r 8a81c5a1b60f src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Jun 18 18:54:20 2013 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Jun 18 18:56:15 2013 +0300 @@ -808,7 +808,7 @@ return (*list)->v.get_storage(list, vname, storage_r); set = mailbox_settings_find((*list)->ns->user, vname); - if (set != NULL && set->driver[0] != '\0') { + if (set != NULL && set->driver != NULL && set->driver[0] != '\0') { return mailbox_list_get_storage_driver(*list, set->driver, storage_r); } From pigeonhole at rename-it.nl Tue Jun 18 23:04:56 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Jun 2013 22:04:56 +0200 Subject: dovecot-2.1-pigeonhole: Fixed deprecated INCLUDE= assignment in ... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/53ee9655e78e changeset: 1693:53ee9655e78e user: Stephan Bosch date: Tue Jun 18 22:04:50 2013 +0200 description: Fixed deprecated INCLUDE= assignment in Makefile.am diffstat: src/lib-sievestorage/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (11 lines): diff -r d4ae981567e1 -r 53ee9655e78e src/lib-sievestorage/Makefile.am --- a/src/lib-sievestorage/Makefile.am Fri May 24 13:07:23 2013 +0200 +++ b/src/lib-sievestorage/Makefile.am Tue Jun 18 22:04:50 2013 +0200 @@ -1,6 +1,6 @@ noinst_LIBRARIES = libsievestorage.a -INCLUDES = \ +AM_CPPFLAGS = \ $(LIBDOVECOT_INCLUDE) \ -I$(top_srcdir) \ -I$(top_srcdir)/src/lib-sieve From dovecot at dovecot.org Mon Jun 24 16:36:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Jun 2013 16:36:39 +0300 Subject: dovecot-2.2: dsync: State names were wrong in debug/error messages. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/83bea7e1f136 changeset: 16538:83bea7e1f136 user: Timo Sirainen date: Mon Jun 24 16:36:32 2013 +0300 description: dsync: State names were wrong in debug/error messages. diffstat: src/doveadm/dsync/dsync-brain.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diffs (27 lines): diff -r 8a81c5a1b60f -r 83bea7e1f136 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Tue Jun 18 18:56:15 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Mon Jun 24 16:36:32 2013 +0300 @@ -11,10 +11,11 @@ #include -static const char *dsync_state_names[DSYNC_STATE_DONE+1] = { - "recv_handshake", - "send_last_common", - "recv_last_common", +static const char *dsync_state_names[] = { + "master_recv_handshake", + "slave_recv_handshake", + "master_send_last_common", + "slave_recv_last_common", "send_mailbox_tree", "send_mailbox_tree_deletes", "recv_mailbox_tree", @@ -97,6 +98,7 @@ i_assert(sync_type != DSYNC_BRAIN_SYNC_TYPE_UNKNOWN); i_assert(sync_type != DSYNC_BRAIN_SYNC_TYPE_STATE || (set->state != NULL && *set->state != '\0')); + i_assert(N_ELEMENTS(dsync_state_names) == DSYNC_STATE_DONE+1); brain = dsync_brain_common_init(user, ibc); brain->sync_type = sync_type; From dovecot at dovecot.org Mon Jun 24 16:37:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Jun 2013 16:37:59 +0300 Subject: dovecot-2.2: dsync: If verbose_proctitle=yes, show the current s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b5876fa03b0e changeset: 16539:b5876fa03b0e user: Timo Sirainen date: Mon Jun 24 16:37:48 2013 +0300 description: dsync: If verbose_proctitle=yes, show the current state in it. diffstat: src/doveadm/dsync/doveadm-dsync.c | 4 +- src/doveadm/dsync/dsync-brain-private.h | 2 + src/doveadm/dsync/dsync-brain.c | 66 +++++++++++++++++++++++++++++++- src/doveadm/dsync/dsync-brain.h | 3 +- src/doveadm/dsync/dsync-mailbox-export.c | 11 +++++ src/doveadm/dsync/dsync-mailbox-export.h | 2 + src/doveadm/dsync/dsync-mailbox-import.c | 13 ++++++ src/doveadm/dsync/dsync-mailbox-import.h | 2 + 8 files changed, 98 insertions(+), 5 deletions(-) diffs (291 lines): diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Jun 24 16:37:48 2013 +0300 @@ -362,7 +362,7 @@ return -1; } - brain2 = dsync_brain_slave_init(user2, ibc2); + brain2 = dsync_brain_slave_init(user2, ibc2, TRUE); brain1_running = brain2_running = TRUE; changed1 = changed2 = TRUE; @@ -970,7 +970,7 @@ mail_user_set_get_temp_prefix(temp_prefix, user->set); ibc = cmd_dsync_icb_stream_init(ctx, "local", str_c(temp_prefix)); - brain = dsync_brain_slave_init(user, ibc); + brain = dsync_brain_slave_init(user, ibc, FALSE); io_loop_run(current_ioloop); diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-private.h Mon Jun 24 16:37:48 2013 +0300 @@ -68,6 +68,7 @@ enum dsync_state state, pre_box_state; enum dsync_box_state box_recv_state; enum dsync_box_state box_send_state; + unsigned int proctitle_update_counter; struct dsync_transaction_log_scan *log_scan; struct dsync_mailbox_importer *box_importer; @@ -95,6 +96,7 @@ unsigned int sync_visible_namespaces:1; unsigned int no_mail_sync:1; unsigned int changes_during_sync:1; + unsigned int verbose_proctitle:1; unsigned int failed:1; }; diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Mon Jun 24 16:37:48 2013 +0300 @@ -4,10 +4,16 @@ #include "array.h" #include "hash.h" #include "hostpid.h" +#include "str.h" +#include "process-title.h" +#include "master-service.h" +#include "master-service-settings.h" #include "mail-namespace.h" #include "dsync-mailbox-tree.h" #include "dsync-ibc.h" #include "dsync-brain-private.h" +#include "dsync-mailbox-import.h" +#include "dsync-mailbox-export.h" #include @@ -26,6 +32,42 @@ "done" }; +static const char *dsync_brain_get_proctitle(struct dsync_brain *brain) +{ + string_t *str = t_str_new(128); + const char *import_title, *export_title; + + str_append_c(str, '['); + str_append(str, brain->user->username); + if (brain->box == NULL) { + str_append_c(str, ' '); + str_append(str, dsync_state_names[brain->state]); + } else { + str_append_c(str, ' '); + str_append(str, mailbox_get_vname(brain->box)); + import_title = brain->box_importer == NULL ? "" : + dsync_mailbox_import_get_proctitle(brain->box_importer); + export_title = brain->box_exporter == NULL ? "" : + dsync_mailbox_export_get_proctitle(brain->box_exporter); + if (import_title[0] == '\0' && export_title[0] == '\0') { + str_printfa(str, " send:%s recv:%s", + dsync_box_state_names[brain->box_send_state], + dsync_box_state_names[brain->box_recv_state]); + } else { + if (import_title[0] != '\0') { + str_append(str, " import:"); + str_append(str, import_title); + } + if (export_title[0] != '\0') { + str_append(str, " export:"); + str_append(str, export_title); + } + } + } + str_append_c(str, ']'); + return str_c(str); +} + static void dsync_brain_run_io(void *context) { struct dsync_brain *brain = context; @@ -57,8 +99,11 @@ dsync_brain_common_init(struct mail_user *user, struct dsync_ibc *ibc) { struct dsync_brain *brain; + const struct master_service_settings *service_set; pool_t pool; + service_set = master_service_settings_get(master_service); + pool = pool_alloconly_create("dsync brain", 10240); brain = p_new(pool, struct dsync_brain, 1); brain->pool = pool; @@ -66,6 +111,7 @@ brain->ibc = ibc; brain->sync_type = DSYNC_BRAIN_SYNC_TYPE_UNKNOWN; brain->lock_fd = -1; + brain->verbose_proctitle = service_set->verbose_proctitle; hash_table_create(&brain->mailbox_states, pool, 0, guid_128_hash, guid_128_cmp); p_array_init(&brain->remote_mailbox_states, pool, 64); @@ -148,7 +194,8 @@ } struct dsync_brain * -dsync_brain_slave_init(struct mail_user *user, struct dsync_ibc *ibc) +dsync_brain_slave_init(struct mail_user *user, struct dsync_ibc *ibc, + bool local) { struct dsync_ibc_settings ibc_set; struct dsync_brain *brain; @@ -156,6 +203,12 @@ brain = dsync_brain_common_init(user, ibc); brain->state = DSYNC_STATE_SLAVE_RECV_HANDSHAKE; + if (local) { + /* both master and slave are running within the same process, + update the proctitle only for master. */ + brain->verbose_proctitle = FALSE; + } + memset(&ibc_set, 0, sizeof(ibc_set)); ibc_set.hostname = my_hostdomain(); dsync_ibc_send_handshake(ibc, &ibc_set); @@ -396,6 +449,9 @@ static bool dsync_brain_run_real(struct dsync_brain *brain, bool *changed_r) { + enum dsync_state orig_state = brain->state; + enum dsync_box_state orig_box_recv_state = brain->box_recv_state; + enum dsync_box_state orig_box_send_state = brain->box_send_state; bool changed = FALSE, ret = TRUE; if (brain->failed) @@ -453,7 +509,13 @@ brain->master_brain ? 'M' : 'S', dsync_state_names[brain->state], changed); } - + if (brain->verbose_proctitle) { + if (orig_state != brain->state || + orig_box_recv_state != brain->box_recv_state || + orig_box_send_state != brain->box_send_state || + ++brain->proctitle_update_counter % 100 == 0) + process_title_set(dsync_brain_get_proctitle(brain)); + } *changed_r = changed; return brain->failed ? FALSE : ret; } diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/dsync-brain.h --- a/src/doveadm/dsync/dsync-brain.h Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.h Mon Jun 24 16:37:48 2013 +0300 @@ -53,7 +53,8 @@ enum dsync_brain_flags flags, const struct dsync_brain_settings *set); struct dsync_brain * -dsync_brain_slave_init(struct mail_user *user, struct dsync_ibc *ibc); +dsync_brain_slave_init(struct mail_user *user, struct dsync_ibc *ibc, + bool local); /* Returns 0 if everything was successful, -1 if syncing failed in some way */ int dsync_brain_deinit(struct dsync_brain **brain); diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/dsync-mailbox-export.c --- a/src/doveadm/dsync/dsync-mailbox-export.c Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-export.c Mon Jun 24 16:37:48 2013 +0300 @@ -26,6 +26,7 @@ struct mailbox_transaction_context *trans; struct mail_search_context *search_ctx; + unsigned int search_pos, search_count; /* GUID => instances */ HASH_TABLE(char *, struct dsync_mail_guid_instances *) export_guids; @@ -698,6 +699,7 @@ array_append_array(&exporter->search_uids, &exporter->requested_uids); array_clear(&exporter->requested_uids); + exporter->search_count = seq_range_count(&exporter->search_uids); exporter->search_ctx = mailbox_search_init(exporter->trans, search_args, NULL, MAIL_FETCH_GUID | @@ -797,6 +799,7 @@ } while (mailbox_search_next(exporter->search_ctx, &mail)) { + exporter->search_pos++; if ((ret = dsync_mailbox_export_mail(exporter, mail)) > 0) return &exporter->dsync_mail; if (ret < 0) { @@ -850,3 +853,11 @@ pool_unref(&exporter->pool); return *error_r != NULL ? -1 : 0; } + +const char *dsync_mailbox_export_get_proctitle(struct dsync_mailbox_exporter *exporter) +{ + if (exporter->search_ctx == NULL) + return ""; + return t_strdup_printf("%u/%u", exporter->search_pos, + exporter->search_count); +} diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/dsync-mailbox-export.h --- a/src/doveadm/dsync/dsync-mailbox-export.h Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-export.h Mon Jun 24 16:37:48 2013 +0300 @@ -23,4 +23,6 @@ int dsync_mailbox_export_deinit(struct dsync_mailbox_exporter **exporter, const char **error_r); +const char *dsync_mailbox_export_get_proctitle(struct dsync_mailbox_exporter *exporter); + #endif diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Mon Jun 24 16:37:48 2013 +0300 @@ -89,6 +89,7 @@ uint32_t prev_uid, next_local_seq, local_uid_next; uint64_t local_initial_highestmodseq, local_initial_highestpvtmodseq; + unsigned int import_pos, import_count; unsigned int failed:1; unsigned int debug:1; @@ -1712,6 +1713,7 @@ return FALSE; } /* successfully handled all the mails locally */ + importer->import_pos++; return TRUE; } @@ -1764,6 +1766,8 @@ importer->failed = TRUE; } } + importer->import_count = hash_table_count(importer->import_guids) + + hash_table_count(importer->import_uids); dsync_mailbox_import_assign_new_uids(importer); /* save mails from local sources where possible, @@ -2002,6 +2006,7 @@ hash_table_remove(importer->import_uids, POINTER_CAST(mail->uid)); } + importer->import_pos++; dsync_mailbox_save_newmails(importer, mail, all_newmails); } @@ -2310,3 +2315,11 @@ pool_unref(&importer->pool); return ret; } + +const char *dsync_mailbox_import_get_proctitle(struct dsync_mailbox_importer *importer) +{ + if (importer->search_ctx != NULL) + return ""; + return t_strdup_printf("%u/%u", importer->import_pos, + importer->import_count); +} diff -r 83bea7e1f136 -r b5876fa03b0e src/doveadm/dsync/dsync-mailbox-import.h --- a/src/doveadm/dsync/dsync-mailbox-import.h Mon Jun 24 16:36:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-import.h Mon Jun 24 16:37:48 2013 +0300 @@ -42,4 +42,6 @@ uint64_t *last_common_pvt_modseq_r, bool *changes_during_sync_r); +const char *dsync_mailbox_import_get_proctitle(struct dsync_mailbox_importer *importer); + #endif From dovecot at dovecot.org Mon Jun 24 22:26:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Jun 2013 22:26:05 +0300 Subject: dovecot-2.2: dsync: Don't try to find mailboxes from unwanted na... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/84014270ee37 changeset: 16540:84014270ee37 user: Timo Sirainen date: Mon Jun 24 22:25:47 2013 +0300 description: dsync: Don't try to find mailboxes from unwanted namespaces. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree.c | 23 ----------------------- src/doveadm/dsync/dsync-brain-mailbox.c | 2 ++ src/doveadm/dsync/dsync-brain.c | 23 +++++++++++++++++++++++ src/doveadm/dsync/dsync-brain.h | 3 +++ 4 files changed, 28 insertions(+), 23 deletions(-) diffs (101 lines): diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Mon Jun 24 16:37:48 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Mon Jun 24 22:25:47 2013 +0300 @@ -2,7 +2,6 @@ #include "lib.h" #include "str.h" -#include "settings-parser.h" #include "mail-namespace.h" #include "doveadm-settings.h" #include "dsync-ibc.h" @@ -11,28 +10,6 @@ #include -static bool dsync_brain_want_namespace(struct dsync_brain *brain, - struct mail_namespace *ns) -{ - if (brain->sync_ns != NULL) - return brain->sync_ns == ns; - if (ns->alias_for != NULL) { - /* always skip aliases */ - return FALSE; - } - if (brain->sync_visible_namespaces) { - if ((ns->flags & NAMESPACE_FLAG_HIDDEN) == 0) - return TRUE; - if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | - NAMESPACE_FLAG_LIST_CHILDREN)) != 0) - return TRUE; - return FALSE; - } else { - return strcmp(ns->unexpanded_set->location, - SETTING_STRVAR_UNEXPANDED) == 0; - } -} - static void dsync_brain_check_namespaces(struct dsync_brain *brain) { struct mail_namespace *ns, *first_ns = NULL; diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Mon Jun 24 16:37:48 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Mon Jun 24 22:25:47 2013 +0300 @@ -50,6 +50,8 @@ } for (ns = brain->user->namespaces; ns != NULL; ns = ns->next) { + if (!dsync_brain_want_namespace(brain, ns)) + continue; if ((ret = ns_mailbox_try_alloc(ns, guid, box_r)) != 0) { if (ret < 0) brain->failed = TRUE; diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Mon Jun 24 16:37:48 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Mon Jun 24 22:25:47 2013 +0300 @@ -6,6 +6,7 @@ #include "hostpid.h" #include "str.h" #include "process-title.h" +#include "settings-parser.h" #include "master-service.h" #include "master-service-settings.h" #include "mail-namespace.h" @@ -584,3 +585,25 @@ { return brain->changes_during_sync; } + +bool dsync_brain_want_namespace(struct dsync_brain *brain, + struct mail_namespace *ns) +{ + if (brain->sync_ns != NULL) + return brain->sync_ns == ns; + if (ns->alias_for != NULL) { + /* always skip aliases */ + return FALSE; + } + if (brain->sync_visible_namespaces) { + if ((ns->flags & NAMESPACE_FLAG_HIDDEN) == 0) + return TRUE; + if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) != 0) + return TRUE; + return FALSE; + } else { + return strcmp(ns->unexpanded_set->location, + SETTING_STRVAR_UNEXPANDED) == 0; + } +} diff -r b5876fa03b0e -r 84014270ee37 src/doveadm/dsync/dsync-brain.h --- a/src/doveadm/dsync/dsync-brain.h Mon Jun 24 16:37:48 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.h Mon Jun 24 22:25:47 2013 +0300 @@ -70,5 +70,8 @@ enum dsync_brain_sync_type dsync_brain_get_sync_type(struct dsync_brain *brain); /* Returns TRUE if there were any unexpected changes during the sync. */ bool dsync_brain_has_unexpected_changes(struct dsync_brain *brain); +/* Returns TRUE if we want to sync this namespace. */ +bool dsync_brain_want_namespace(struct dsync_brain *brain, + struct mail_namespace *ns); #endif From dovecot at dovecot.org Mon Jun 24 23:06:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Jun 2013 23:06:59 +0300 Subject: dovecot-2.2: dsync: Don't crash at deinit when dsync fails early. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/07e314199f56 changeset: 16541:07e314199f56 user: Timo Sirainen date: Mon Jun 24 23:06:45 2013 +0300 description: dsync: Don't crash at deinit when dsync fails early. diffstat: src/doveadm/dsync/dsync-brain.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (16 lines): diff -r 84014270ee37 -r 07e314199f56 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Mon Jun 24 22:25:47 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Mon Jun 24 23:06:45 2013 +0300 @@ -242,8 +242,10 @@ dsync_brain_sync_mailbox_deinit(brain); if (brain->local_tree_iter != NULL) dsync_mailbox_tree_iter_deinit(&brain->local_tree_iter); - dsync_mailbox_tree_deinit(&brain->local_mailbox_tree); - dsync_mailbox_tree_deinit(&brain->remote_mailbox_tree); + if (brain->local_mailbox_tree != NULL) + dsync_mailbox_tree_deinit(&brain->local_mailbox_tree); + if (brain->remote_mailbox_tree != NULL) + dsync_mailbox_tree_deinit(&brain->remote_mailbox_tree); if (brain->mailbox_states_iter != NULL) hash_table_iterate_deinit(&brain->mailbox_states_iter); hash_table_destroy(&brain->mailbox_states); From dovecot at dovecot.org Mon Jun 24 23:14:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Jun 2013 23:14:55 +0300 Subject: dovecot-2.2: mbox: Avoid assert-crashing by too optimistically u... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/04c7cf45a597 changeset: 16542:04c7cf45a597 user: Timo Sirainen date: Mon Jun 24 23:10:20 2013 +0300 description: mbox: Avoid assert-crashing by too optimistically upgrading a lock to write-lock. diffstat: src/lib-storage/index/mbox/mbox-lock.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 07e314199f56 -r 04c7cf45a597 src/lib-storage/index/mbox/mbox-lock.c --- a/src/lib-storage/index/mbox/mbox-lock.c Mon Jun 24 23:06:45 2013 +0300 +++ b/src/lib-storage/index/mbox/mbox-lock.c Mon Jun 24 23:10:20 2013 +0300 @@ -784,7 +784,8 @@ bool fcntl_locked; int ret; - if (lock_type == F_RDLCK && mbox->external_transactions > 0) { + if (lock_type == F_RDLCK && mbox->external_transactions > 0 && + mbox->mbox_lock_type != F_RDLCK) { /* we have a transaction open that is going to save mails and apparently also wants to read from the same mailbox (copy, move, catenate). we need to write lock the mailbox, From dovecot at dovecot.org Mon Jun 24 23:14:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Jun 2013 23:14:55 +0300 Subject: dovecot-2.2: dsync: Fixed "export:/count" value in verbose_proct... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/082fe68e38c9 changeset: 16543:082fe68e38c9 user: Timo Sirainen date: Mon Jun 24 23:14:35 2013 +0300 description: dsync: Fixed "export:/count" value in verbose_proctitle=yes diffstat: src/doveadm/dsync/dsync-mailbox-export.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 04c7cf45a597 -r 082fe68e38c9 src/doveadm/dsync/dsync-mailbox-export.c --- a/src/doveadm/dsync/dsync-mailbox-export.c Mon Jun 24 23:10:20 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-export.c Mon Jun 24 23:14:35 2013 +0300 @@ -699,7 +699,7 @@ array_append_array(&exporter->search_uids, &exporter->requested_uids); array_clear(&exporter->requested_uids); - exporter->search_count = seq_range_count(&exporter->search_uids); + exporter->search_count += seq_range_count(&sarg->value.seqset); exporter->search_ctx = mailbox_search_init(exporter->trans, search_args, NULL, MAIL_FETCH_GUID | From dovecot at dovecot.org Mon Jun 24 23:39:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Jun 2013 23:39:38 +0300 Subject: dovecot-2.2: imap-login: If CAPABILITY is already in server bann... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6e8bbc150fa9 changeset: 16544:6e8bbc150fa9 user: Timo Sirainen date: Mon Jun 24 23:33:59 2013 +0300 description: imap-login: If CAPABILITY is already in server banner, don't ask for it again. diffstat: src/imap-login/imap-proxy.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diffs (23 lines): diff -r 082fe68e38c9 -r 6e8bbc150fa9 src/imap-login/imap-proxy.c --- a/src/imap-login/imap-proxy.c Mon Jun 24 23:14:35 2013 +0300 +++ b/src/imap-login/imap-proxy.c Mon Jun 24 23:33:59 2013 +0300 @@ -63,7 +63,8 @@ unsigned int len; const char *mech_name, *error; - str_append(str, "C CAPABILITY\r\n"); + if (client->proxy_backend_capability == NULL) + str_append(str, "C CAPABILITY\r\n"); if (client->common.proxy_mech == NULL) { /* logging in normally - use LOGIN command */ @@ -129,6 +130,9 @@ proxy_write_id(client, str); if (str_array_icase_find(capabilities, "SASL-IR")) client->proxy_sasl_ir = TRUE; + i_free(client->proxy_backend_capability); + client->proxy_backend_capability = + i_strdup(t_strcut(line + 5 + 12, ']')); } ssl_flags = login_proxy_get_ssl_flags(client->common.login_proxy); From dovecot at dovecot.org Tue Jun 25 00:18:43 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 00:18:43 +0300 Subject: dovecot-2.2: quota: Fixed quota_rule with non-uppercase INBOX. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f68a955f4c5c changeset: 16545:f68a955f4c5c user: Timo Sirainen date: Tue Jun 25 00:10:39 2013 +0300 description: quota: Fixed quota_rule with non-uppercase INBOX. diffstat: src/plugins/quota/quota.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 6e8bbc150fa9 -r f68a955f4c5c src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Mon Jun 24 23:33:59 2013 +0300 +++ b/src/plugins/quota/quota.c Tue Jun 25 00:10:39 2013 +0300 @@ -564,7 +564,7 @@ root_set->force_default_rule = TRUE; } else { rule = array_append_space(&root_set->rules); - rule->mailbox_name = + rule->mailbox_name = strcasecmp(mailbox_name, "INBOX") == 0 ? "INBOX" : p_strdup(root_set->set->pool, mailbox_name); } } From dovecot at dovecot.org Tue Jun 25 01:23:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 01:23:49 +0300 Subject: dovecot-2.2: doveadm deduplicate: Fixed error handling. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/09b278416493 changeset: 16546:09b278416493 user: Timo Sirainen date: Tue Jun 25 01:23:17 2013 +0300 description: doveadm deduplicate: Fixed error handling. diffstat: src/doveadm/doveadm-mail-deduplicate.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r f68a955f4c5c -r 09b278416493 src/doveadm/doveadm-mail-deduplicate.c --- a/src/doveadm/doveadm-mail-deduplicate.c Tue Jun 25 00:10:39 2013 +0300 +++ b/src/doveadm/doveadm-mail-deduplicate.c Tue Jun 25 01:23:17 2013 +0300 @@ -80,7 +80,7 @@ while (doveadm_mail_iter_next(iter, &mail)) { if (ctx->by_msgid) { if (mail_get_first_header(mail, "Message-ID", &key) < 0) { - errstr = mailbox_get_last_error(box, &error); + errstr = mailbox_get_last_error(mail->box, &error); if (error == MAIL_ERROR_NOTFOUND) continue; i_error("Couldn't lookup Message-ID: for UID=%u: %s", @@ -90,7 +90,7 @@ } } else { if (mail_get_special(mail, MAIL_FETCH_GUID, &key) < 0) { - errstr = mailbox_get_last_error(box, &error); + errstr = mailbox_get_last_error(mail->box, &error); if (error == MAIL_ERROR_NOTFOUND) continue; i_error("Couldn't lookup GUID: for UID=%u: %s", From dovecot at dovecot.org Tue Jun 25 01:25:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 01:25:49 +0300 Subject: dovecot-2.2: Make static analyzer happier. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b5e8aed1bf61 changeset: 16547:b5e8aed1bf61 user: Timo Sirainen date: Tue Jun 25 01:24:51 2013 +0300 description: Make static analyzer happier. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 09b278416493 -r b5e8aed1bf61 src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Tue Jun 25 01:23:17 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Tue Jun 25 01:24:51 2013 +0300 @@ -27,7 +27,7 @@ continue; sep = mail_namespace_get_sep(ns); - if (brain->hierarchy_sep == '\0') { + if (first_ns == NULL) { brain->hierarchy_sep = sep; first_ns = ns; } else if (brain->hierarchy_sep != sep) { From dovecot at dovecot.org Tue Jun 25 02:57:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 02:57:23 +0300 Subject: dovecot-2.2: Released v2.2.4. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4b3c9c3e4fb8 changeset: 16548:4b3c9c3e4fb8 user: Timo Sirainen date: Tue Jun 25 02:22:58 2013 +0300 description: Released v2.2.4. diffstat: NEWS | 10 ++++++++++ configure.ac | 2 +- 2 files changed, 11 insertions(+), 1 deletions(-) diffs (29 lines): diff -r b5e8aed1bf61 -r 4b3c9c3e4fb8 NEWS --- a/NEWS Tue Jun 25 01:24:51 2013 +0300 +++ b/NEWS Tue Jun 25 02:22:58 2013 +0300 @@ -1,3 +1,13 @@ +v2.2.4 2013-06-25 Timo Sirainen + + + doveadm: Added "flags" command to modify message flags. + + doveadm: Added "deduplicate" command to expunge message duplicates. + + dsync: Show the state in process title with verbose_proctitle=yes. + - imap/pop3 proxy: Master user logins were broken in v2.2.3 + - sdbox/mdbox: A corrupted index header with wrong size was never + automatically fixed in v2.2.3. + - mbox: Fixed assert-crashes related to locking. + v2.2.3 2013-06-17 Timo Sirainen * LDA/LMTP: If new mail delivery first fails with "temporary diff -r b5e8aed1bf61 -r 4b3c9c3e4fb8 configure.ac --- a/configure.ac Tue Jun 25 01:24:51 2013 +0300 +++ b/configure.ac Tue Jun 25 02:22:58 2013 +0300 @@ -2,7 +2,7 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.3],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.2.4],[dovecot at dovecot.org]) AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv3($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) From dovecot at dovecot.org Tue Jun 25 02:57:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 02:57:23 +0300 Subject: dovecot-2.2: Added tag 2.2.4 for changeset 4b3c9c3e4fb8 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7f3acd34e7b changeset: 16549:e7f3acd34e7b user: Timo Sirainen date: Tue Jun 25 02:22:59 2013 +0300 description: Added tag 2.2.4 for changeset 4b3c9c3e4fb8 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 4b3c9c3e4fb8 -r e7f3acd34e7b .hgtags --- a/.hgtags Tue Jun 25 02:22:58 2013 +0300 +++ b/.hgtags Tue Jun 25 02:22:59 2013 +0300 @@ -107,3 +107,4 @@ 6fcf060b50f183549909f0fee17307e646edcbc6 2.2.1 7aa929edd551e3d3bd9405643341129c7a805554 2.2.2 5d9f52c9a2871245097c725b9a4163a8789512fd 2.2.3 +4b3c9c3e4fb8499ca7133a4d229e5eef349995e0 2.2.4 From dovecot at dovecot.org Tue Jun 25 02:57:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 02:57:23 +0300 Subject: dovecot-2.2: Added signature for changeset 4b3c9c3e4fb8 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a2555de348a7 changeset: 16550:a2555de348a7 user: Timo Sirainen date: Tue Jun 25 02:23:02 2013 +0300 description: Added signature for changeset 4b3c9c3e4fb8 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r e7f3acd34e7b -r a2555de348a7 .hgsigs --- a/.hgsigs Tue Jun 25 02:22:59 2013 +0300 +++ b/.hgsigs Tue Jun 25 02:23:02 2013 +0300 @@ -70,3 +70,4 @@ 6fcf060b50f183549909f0fee17307e646edcbc6 0 iEYEABECAAYFAlFwZ7oACgkQyUhSUUBVismG6wCeI05eVDC++LqgfF9sOkoT3qRp9xYAn3pRDGYKPx7DhcTp+0RX/I9TXUmB 7aa929edd551e3d3bd9405643341129c7a805554 0 iEYEABECAAYFAlGZX2MACgkQyUhSUUBVisn2LACfWc8QwBvF31mYx3iv9ePvShCRcH4AnjZkbQEmcvaFQrfCy5YIIrstNBzx 5d9f52c9a2871245097c725b9a4163a8789512fd 0 iEYEABECAAYFAlG+LqYACgkQyUhSUUBVisn45wCgiEnDSrMoa5hZHRv+0eovGQJJ4g8An1Q8kms24rovLF/PGaani8Ap6VXR +4b3c9c3e4fb8499ca7133a4d229e5eef349995e0 0 iEYEABECAAYFAlHI1NMACgkQyUhSUUBVismCOQCbB/qdjOfUBvm0AUGBudvg2TaKbJ0AnRmr8JEV1QnowwA0g0vGF8Hkm6ib From dovecot at dovecot.org Tue Jun 25 15:47:02 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 15:47:02 +0300 Subject: dovecot-2.2: lib-index: Don't write a broken transaction if exte... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/04c64300f81f changeset: 16551:04c64300f81f user: Timo Sirainen date: Tue Jun 25 15:46:50 2013 +0300 description: lib-index: Don't write a broken transaction if extension resize is done at first use. diffstat: src/lib-index/mail-index-transaction-export.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (18 lines): diff -r a2555de348a7 -r 04c64300f81f src/lib-index/mail-index-transaction-export.c --- a/src/lib-index/mail-index-transaction-export.c Tue Jun 25 02:23:02 2013 +0300 +++ b/src/lib-index/mail-index-transaction-export.c Tue Jun 25 15:46:50 2013 +0300 @@ -114,8 +114,12 @@ intro = &resizes[ext_id]; i_assert(intro->ext_id == idx || idx == (uint32_t)-1); - intro->name_size = idx != (uint32_t)-1 ? 0 : - strlen(rext->name); + if (idx != (uint32_t)-1) + intro->name_size = 0; + else { + intro->ext_id = (uint32_t)-1; + intro->name_size = strlen(rext->name); + } buffer_append(buf, intro, sizeof(*intro)); } else { /* generate a new intro structure */ From dovecot at dovecot.org Tue Jun 25 15:48:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 15:48:30 +0300 Subject: dovecot-2.2: lib-index: Assert-crash instead of writing a broken... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8cf482b749e2 changeset: 16552:8cf482b749e2 user: Timo Sirainen date: Tue Jun 25 15:47:48 2013 +0300 description: lib-index: Assert-crash instead of writing a broken transaction with too large ext header update. diffstat: src/lib-index/mail-index-transaction-export.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diffs (84 lines): diff -r 04c64300f81f -r 8cf482b749e2 src/lib-index/mail-index-transaction-export.c --- a/src/lib-index/mail-index-transaction-export.c Tue Jun 25 15:46:50 2013 +0300 +++ b/src/lib-index/mail-index-transaction-export.c Tue Jun 25 15:47:48 2013 +0300 @@ -82,7 +82,8 @@ } static void log_append_ext_intro(struct mail_index_export_context *ctx, - uint32_t ext_id, uint32_t reset_id) + uint32_t ext_id, uint32_t reset_id, + unsigned int *hdr_size_r) { struct mail_index_transaction *t = ctx->trans; const struct mail_index_registered_ext *rext; @@ -161,11 +162,13 @@ } log_append_buffer(ctx, buf, MAIL_TRANSACTION_EXT_INTRO); + *hdr_size_r = intro->hdr_size; } static void log_append_ext_hdr_update(struct mail_index_export_context *ctx, - const struct mail_index_transaction_ext_hdr_update *hdr) + const struct mail_index_transaction_ext_hdr_update *hdr, + unsigned int ext_hdr_size) { buffer_t *buf; const unsigned char *data, *mask; @@ -197,6 +200,7 @@ u.size = u32.size; buffer_append(buf, &u, sizeof(u)); } + i_assert(u32.offset + u32.size <= ext_hdr_size); buffer_append(buf, data + u32.offset, u32.size); started = FALSE; } @@ -216,7 +220,7 @@ const struct mail_index_transaction_ext_hdr_update *hdrs; struct mail_transaction_ext_reset ext_reset; unsigned int resize_count, ext_count = 0; - unsigned int hdrs_count, reset_id_count, reset_count; + unsigned int hdrs_count, reset_id_count, reset_count, hdr_size; uint32_t ext_id, reset_id; const struct mail_transaction_ext_reset *reset; const uint32_t *reset_ids; @@ -276,7 +280,9 @@ reset_id = ext_id < reset_id_count ? reset_ids[ext_id] : 0; } - log_append_ext_intro(ctx, ext_id, reset_id); + log_append_ext_intro(ctx, ext_id, reset_id, &hdr_size); + } else { + hdr_size = 0; } if (ext_reset.new_reset_id != 0) { i_assert(ext_id < reset_id_count && @@ -286,7 +292,8 @@ } if (ext_id < hdrs_count && hdrs[ext_id].alloc_size > 0) { T_BEGIN { - log_append_ext_hdr_update(ctx, &hdrs[ext_id]); + log_append_ext_hdr_update(ctx, &hdrs[ext_id], + hdr_size); } T_END; } } @@ -299,7 +306,7 @@ struct mail_index_transaction *t = ctx->trans; const ARRAY_TYPE(seq_array) *updates; const uint32_t *reset_ids; - unsigned int ext_id, count, reset_id_count; + unsigned int ext_id, count, reset_id_count, hdr_size; uint32_t reset_id; if (!array_is_created(&t->ext_reset_ids)) { @@ -316,7 +323,7 @@ continue; reset_id = ext_id < reset_id_count ? reset_ids[ext_id] : 0; - log_append_ext_intro(ctx, ext_id, reset_id); + log_append_ext_intro(ctx, ext_id, reset_id, &hdr_size); log_append_buffer(ctx, updates[ext_id].arr.buffer, type); } From dovecot at dovecot.org Tue Jun 25 15:48:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 15:48:30 +0300 Subject: dovecot-2.2: mdbox: Resize mdbox index header if necessary also ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/be970e7928eb changeset: 16553:be970e7928eb user: Timo Sirainen date: Tue Jun 25 15:48:24 2013 +0300 description: mdbox: Resize mdbox index header if necessary also when rebuilding indexes. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 19 +++++++++++---- 1 files changed, 14 insertions(+), 5 deletions(-) diffs (53 lines): diff -r 8cf482b749e2 -r be970e7928eb src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Jun 25 15:47:48 2013 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Jun 25 15:48:24 2013 +0300 @@ -479,7 +479,7 @@ static void mdbox_rebuild_get_header(struct mail_index_view *view, uint32_t hdr_ext_id, - struct mdbox_index_header *hdr_r) + struct mdbox_index_header *hdr_r, bool *need_resize_r) { const void *data; size_t data_size; @@ -487,6 +487,7 @@ mail_index_get_header_ext(view, hdr_ext_id, &data, &data_size); memset(hdr_r, 0, sizeof(*hdr_r)); memcpy(hdr_r, data, I_MIN(data_size, sizeof(*hdr_r))); + *need_resize_r = data_size < sizeof(*hdr_r); } static void mdbox_header_update(struct mdbox_storage_rebuild_context *ctx, @@ -494,13 +495,17 @@ struct mdbox_mailbox *mbox) { struct mdbox_index_header hdr, backup_hdr; + bool need_resize, need_resize_backup; - mdbox_rebuild_get_header(rebuild_ctx->view, mbox->hdr_ext_id, &hdr); - if (rebuild_ctx->backup_view == NULL) + mdbox_rebuild_get_header(rebuild_ctx->view, mbox->hdr_ext_id, + &hdr, &need_resize); + if (rebuild_ctx->backup_view == NULL) { memset(&backup_hdr, 0, sizeof(backup_hdr)); - else { + need_resize = TRUE; + } else { mdbox_rebuild_get_header(rebuild_ctx->backup_view, - mbox->hdr_ext_id, &backup_hdr); + mbox->hdr_ext_id, &backup_hdr, + &need_resize_backup); } /* make sure we have valid mailbox guid */ @@ -522,6 +527,10 @@ hdr.flags |= DBOX_INDEX_HEADER_FLAG_HAVE_POP3_ORDERS; /* and write changes */ + if (need_resize) { + mail_index_ext_resize_hdr(rebuild_ctx->trans, mbox->hdr_ext_id, + sizeof(hdr)); + } mail_index_update_header_ext(rebuild_ctx->trans, mbox->hdr_ext_id, 0, &hdr, sizeof(hdr)); } From dovecot at dovecot.org Tue Jun 25 16:03:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Jun 2013 16:03:18 +0300 Subject: dovecot-2.2: dsync: Don't log index errors if modseq points beyo... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d6b18c237be5 changeset: 16554:d6b18c237be5 user: Timo Sirainen date: Tue Jun 25 16:03:04 2013 +0300 description: dsync: Don't log index errors if modseq points beyond the current view. diffstat: src/doveadm/dsync/dsync-transaction-log-scan.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diffs (37 lines): diff -r be970e7928eb -r d6b18c237be5 src/doveadm/dsync/dsync-transaction-log-scan.c --- a/src/doveadm/dsync/dsync-transaction-log-scan.c Tue Jun 25 15:48:24 2013 +0300 +++ b/src/doveadm/dsync/dsync-transaction-log-scan.c Tue Jun 25 16:03:04 2013 +0300 @@ -348,8 +348,8 @@ struct mail_index_view *view, bool pvt_scan, struct mail_transaction_log_view *log_view, uint64_t modseq) { - uint32_t log_seq; - uoff_t log_offset; + uint32_t log_seq, end_seq; + uoff_t log_offset, end_offset; bool reset; int ret; @@ -358,10 +358,20 @@ &log_seq, &log_offset)) ret = 0; else { + /* scan the view only up to end of the current view. + if there are more changes, we don't care about them until + the next sync. the modseq may however already point to + beyond the current view's end (FIXME: why?) */ + end_seq = view->log_file_head_seq; + end_offset = view->log_file_head_offset; + if (log_seq > end_seq || + (log_seq == end_seq && log_offset > end_offset)) { + end_seq = log_seq; + end_offset = log_offset; + } ret = mail_transaction_log_view_set(log_view, log_seq, log_offset, - view->log_file_head_seq, - view->log_file_head_offset, + end_seq, end_offset, &reset); } if (ret == 0) { From dovecot at dovecot.org Wed Jun 26 14:38:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 14:38:11 +0300 Subject: dovecot-2.2: lib-sasl: Use dsasl_ prefix so we don't conflict wi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2dd27b0e7e49 changeset: 16555:2dd27b0e7e49 user: Timo Sirainen date: Wed Jun 26 14:37:34 2013 +0300 description: lib-sasl: Use dsasl_ prefix so we don't conflict with Cyrus SASL library. diffstat: src/imap-login/imap-proxy.c | 20 +++--- src/lib-sasl/Makefile.am | 6 +- src/lib-sasl/dsasl-client-private.h | 33 ++++++++++ src/lib-sasl/dsasl-client.c | 104 ++++++++++++++++++++++++++++++++++ src/lib-sasl/dsasl-client.h | 39 ++++++++++++ src/lib-sasl/mech-login.c | 20 +++-- src/lib-sasl/mech-plain.c | 20 +++-- src/lib-sasl/sasl-client-private.h | 33 ---------- src/lib-sasl/sasl-client.c | 104 ---------------------------------- src/lib-sasl/sasl-client.h | 39 ------------ src/login-common/client-common-auth.c | 10 +- src/login-common/client-common.c | 4 +- src/login-common/client-common.h | 4 +- src/login-common/main.c | 6 +- src/pop3-login/pop3-proxy.c | 20 +++--- 15 files changed, 233 insertions(+), 229 deletions(-) diffs (truncated from 736 to 300 lines): diff -r d6b18c237be5 -r 2dd27b0e7e49 src/imap-login/imap-proxy.c --- a/src/imap-login/imap-proxy.c Tue Jun 25 16:03:04 2013 +0300 +++ b/src/imap-login/imap-proxy.c Wed Jun 26 14:37:34 2013 +0300 @@ -9,7 +9,7 @@ #include "str.h" #include "str-sanitize.h" #include "safe-memset.h" -#include "sasl-client.h" +#include "dsasl-client.h" #include "client.h" #include "client-authenticate.h" #include "imap-resp-code.h" @@ -58,7 +58,7 @@ static int proxy_write_login(struct imap_client *client, string_t *str) { - struct sasl_client_settings sasl_set; + struct dsasl_client_settings sasl_set; const unsigned char *output; unsigned int len; const char *mech_name, *error; @@ -85,14 +85,14 @@ sasl_set.authzid = client->common.proxy_user; sasl_set.password = client->common.proxy_password; client->common.proxy_sasl_client = - sasl_client_new(client->common.proxy_mech, &sasl_set); - mech_name = sasl_client_mech_get_name(client->common.proxy_mech); + dsasl_client_new(client->common.proxy_mech, &sasl_set); + mech_name = dsasl_client_mech_get_name(client->common.proxy_mech); str_append(str, "L AUTHENTICATE "); str_append(str, mech_name); if (client->proxy_sasl_ir) { - if (sasl_client_output(client->common.proxy_sasl_client, - &output, &len, &error) < 0) { + if (dsasl_client_output(client->common.proxy_sasl_client, + &output, &len, &error) < 0) { client_log_err(&client->common, t_strdup_printf( "proxy: SASL mechanism %s init failed: %s", mech_name, error)); @@ -226,11 +226,11 @@ client_proxy_failed(client, TRUE); return -1; } - ret = sasl_client_input(client->proxy_sasl_client, - str_data(str), str_len(str), &error); + ret = dsasl_client_input(client->proxy_sasl_client, + str_data(str), str_len(str), &error); if (ret == 0) { - ret = sasl_client_output(client->proxy_sasl_client, - &data, &data_len, &error); + ret = dsasl_client_output(client->proxy_sasl_client, + &data, &data_len, &error); } if (ret < 0) { client_log_err(client, t_strdup_printf( diff -r d6b18c237be5 -r 2dd27b0e7e49 src/lib-sasl/Makefile.am --- a/src/lib-sasl/Makefile.am Tue Jun 25 16:03:04 2013 +0300 +++ b/src/lib-sasl/Makefile.am Wed Jun 26 14:37:34 2013 +0300 @@ -6,11 +6,11 @@ libsasl_la_SOURCES = \ mech-login.c \ mech-plain.c \ - sasl-client.c + dsasl-client.c headers = \ - sasl-client.h \ - sasl-client-private.h + dsasl-client.h \ + dsasl-client-private.h pkginc_libdir=$(pkgincludedir) pkginc_lib_HEADERS = $(headers) diff -r d6b18c237be5 -r 2dd27b0e7e49 src/lib-sasl/dsasl-client-private.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/dsasl-client-private.h Wed Jun 26 14:37:34 2013 +0300 @@ -0,0 +1,33 @@ +#ifndef DSASL_CLIENT_PRIVATE_H +#define DSASL_CLIENT_PRIVATE_H + +#include "dsasl-client.h" + +struct dsasl_client { + pool_t pool; + struct dsasl_client_settings set; + char *password; + const struct dsasl_client_mech *mech; +}; + +struct dsasl_client_mech { + const char *name; + size_t struct_size; + + int (*input)(struct dsasl_client *client, + const unsigned char *input, + unsigned int input_len, + const char **error_r); + int (*output)(struct dsasl_client *client, + const unsigned char **output_r, + unsigned int *output_len_r, + const char **error_r); + void (*free)(struct dsasl_client *client); +}; + +extern const struct dsasl_client_mech dsasl_client_mech_login; + +void dsasl_client_mech_register(const struct dsasl_client_mech *mech); +void dsasl_client_mech_unregister(const struct dsasl_client_mech *mech); + +#endif diff -r d6b18c237be5 -r 2dd27b0e7e49 src/lib-sasl/dsasl-client.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/dsasl-client.c Wed Jun 26 14:37:34 2013 +0300 @@ -0,0 +1,104 @@ +/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "safe-memset.h" +#include "dsasl-client-private.h" + +static ARRAY(const struct dsasl_client_mech *) dsasl_mechanisms = ARRAY_INIT; + +static const struct dsasl_client_mech * +dsasl_client_mech_find_idx(const char *name, unsigned int *idx_r) +{ + const struct dsasl_client_mech *const *mechp; + + array_foreach(&dsasl_mechanisms, mechp) { + if (strcasecmp((*mechp)->name, name) == 0) { + *idx_r = array_foreach_idx(&dsasl_mechanisms, mechp); + return *mechp; + } + } + return NULL; +} + +const struct dsasl_client_mech *dsasl_client_mech_find(const char *name) +{ + unsigned int idx; + + return dsasl_client_mech_find_idx(name, &idx); +} + +const char *dsasl_client_mech_get_name(const struct dsasl_client_mech *mech) +{ + return mech->name; +} + +void dsasl_client_mech_register(const struct dsasl_client_mech *mech) +{ + array_append(&dsasl_mechanisms, &mech, 1); +} + +void dsasl_client_mech_unregister(const struct dsasl_client_mech *mech) +{ + unsigned int idx; + + if (dsasl_client_mech_find_idx(mech->name, &idx) == NULL) + i_panic("SASL mechanism not registered: %s", mech->name); + array_delete(&dsasl_mechanisms, idx, 1); +} + +struct dsasl_client *dsasl_client_new(const struct dsasl_client_mech *mech, + const struct dsasl_client_settings *set) +{ + struct dsasl_client *client; + pool_t pool = pool_alloconly_create("sasl client", 512); + + client = p_malloc(pool, mech->struct_size); + client->pool = pool; + client->mech = mech; + client->set.authid = p_strdup(pool, set->authid); + client->set.authzid = p_strdup(pool, set->authzid); + client->password = p_strdup(pool, set->password); + client->set.password = client->password; + return client; +} + +void dsasl_client_free(struct dsasl_client **_client) +{ + struct dsasl_client *client = *_client; + + *_client = NULL; + + if (client->mech->free != NULL) + client->mech->free(client); + safe_memset(client->password, 0, strlen(client->password)); + pool_unref(&client->pool); +} + +int dsasl_client_input(struct dsasl_client *client, + const unsigned char *input, + unsigned int input_len, + const char **error_r) +{ + return client->mech->input(client, input, input_len, error_r); +} + +int dsasl_client_output(struct dsasl_client *client, + const unsigned char **output_r, + unsigned int *output_len_r, + const char **error_r) +{ + return client->mech->output(client, output_r, output_len_r, error_r); +} + +void dsasl_clients_init(void) +{ + i_array_init(&dsasl_mechanisms, 8); + dsasl_client_mech_register(&dsasl_client_mech_plain); + dsasl_client_mech_register(&dsasl_client_mech_login); +} + +void dsasl_clients_deinit(void) +{ + array_free(&dsasl_mechanisms); +} diff -r d6b18c237be5 -r 2dd27b0e7e49 src/lib-sasl/dsasl-client.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sasl/dsasl-client.h Wed Jun 26 14:37:34 2013 +0300 @@ -0,0 +1,39 @@ +#ifndef DSASL_CLIENT_H +#define DSASL_CLIENT_H + +struct dsasl_client_settings { + /* authentication ID - must be set with most mechanisms */ + const char *authid; + /* authorization ID (who to log in as, if authentication ID is a + master user) */ + const char *authzid; + /* password - must be set with most mechanisms */ + const char *password; +}; + +/* PLAIN mechanism always exists and can be accessed directly via this. */ +extern const struct dsasl_client_mech dsasl_client_mech_plain; + +const struct dsasl_client_mech *dsasl_client_mech_find(const char *name); +const char *dsasl_client_mech_get_name(const struct dsasl_client_mech *mech); + +struct dsasl_client *dsasl_client_new(const struct dsasl_client_mech *mech, + const struct dsasl_client_settings *set); +void dsasl_client_free(struct dsasl_client **client); + +/* Call for server input. */ +int dsasl_client_input(struct dsasl_client *client, + const unsigned char *input, + unsigned int input_len, + const char **error_r); +/* Call for getting server output. Also used to get the initial SASL response + if supported by the protocol. */ +int dsasl_client_output(struct dsasl_client *client, + const unsigned char **output_r, + unsigned int *output_len_r, + const char **error_r); + +void dsasl_clients_init(void); +void dsasl_clients_deinit(void); + +#endif diff -r d6b18c237be5 -r 2dd27b0e7e49 src/lib-sasl/mech-login.c --- a/src/lib-sasl/mech-login.c Tue Jun 25 16:03:04 2013 +0300 +++ b/src/lib-sasl/mech-login.c Wed Jun 26 14:37:34 2013 +0300 @@ -2,7 +2,7 @@ #include "lib.h" #include "str.h" -#include "sasl-client-private.h" +#include "dsasl-client-private.h" enum login_state { STATE_INIT = 0, @@ -10,18 +10,19 @@ STATE_PASS }; -struct login_sasl_client { - struct sasl_client client; +struct login_dsasl_client { + struct dsasl_client client; enum login_state state; }; static int -mech_login_input(struct sasl_client *_client, +mech_login_input(struct dsasl_client *_client, const unsigned char *input ATTR_UNUSED, unsigned int input_len ATTR_UNUSED, const char **error_r) { - struct login_sasl_client *client = (struct login_sasl_client *)_client; + struct login_dsasl_client *client = + (struct login_dsasl_client *)_client; if (client->state == STATE_PASS) { *error_r = "Server didn't finish authentication"; @@ -32,11 +33,12 @@ } From dovecot at dovecot.org Wed Jun 26 15:29:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 15:29:57 +0300 Subject: dovecot-2.2: dsync: Fixed handling expunges when GUIDs aren't su... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/af8ce0a84bb5 changeset: 16556:af8ce0a84bb5 user: Timo Sirainen date: Wed Jun 26 15:29:43 2013 +0300 description: dsync: Fixed handling expunges when GUIDs aren't supported by the backend(s). diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 2dd27b0e7e49 -r af8ce0a84bb5 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Wed Jun 26 14:37:34 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Wed Jun 26 15:29:43 2013 +0300 @@ -1283,6 +1283,11 @@ /* verify hdr_hash if it exists */ if (change->hdr_hash == NULL) { i_assert(*importer->cur_guid == '\0'); + if (change->type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) { + /* the message was already expunged, so we don't know + its header. return "unknown". */ + return -1; + } i_error("Mailbox %s: GUIDs not supported, " "sync with header hashes instead", mailbox_get_vname(importer->box)); From dovecot at dovecot.org Wed Jun 26 15:44:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 15:44:22 +0300 Subject: dovecot-2.2: pop3c: Return error instead of crashing when trying... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/230f111056b4 changeset: 16557:230f111056b4 user: Timo Sirainen date: Wed Jun 26 15:44:08 2013 +0300 description: pop3c: Return error instead of crashing when trying to save a mail. diffstat: src/lib-storage/index/pop3c/pop3c-storage.c | 44 +++++++++++++++++++++++++--- 1 files changed, 39 insertions(+), 5 deletions(-) diffs (61 lines): diff -r af8ce0a84bb5 -r 230f111056b4 src/lib-storage/index/pop3c/pop3c-storage.c --- a/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 26 15:29:43 2013 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 26 15:44:08 2013 +0300 @@ -234,6 +234,40 @@ { } +static struct mail_save_context * +pop3c_save_alloc(struct mailbox_transaction_context *t) +{ + struct mail_save_context *ctx; + + ctx = i_new(struct mail_save_context, 1); + ctx->transaction = t; + return ctx; +} + +static int +pop3c_save_begin(struct mail_save_context *ctx ATTR_UNUSED, + struct istream *input ATTR_UNUSED) +{ + mail_storage_set_error(ctx->transaction->box->storage, + MAIL_ERROR_NOTPOSSIBLE, "POP3 doesn't support saving mails"); + return -1; +} + +static int pop3c_save_continue(struct mail_save_context *ctx ATTR_UNUSED) +{ + return -1; +} + +static int pop3c_save_finish(struct mail_save_context *ctx ATTR_UNUSED) +{ + return -1; +} + +static void +pop3c_save_cancel(struct mail_save_context *ctx ATTR_UNUSED) +{ +} + static bool pop3c_storage_is_inconsistent(struct mailbox *box) { struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box; @@ -295,11 +329,11 @@ index_storage_search_deinit, index_storage_search_next_nonblock, index_storage_search_next_update_seq, - NULL, - NULL, - NULL, - NULL, - NULL, + pop3c_save_alloc, + pop3c_save_begin, + pop3c_save_continue, + pop3c_save_finish, + pop3c_save_cancel, mail_storage_copy, NULL, NULL, From dovecot at dovecot.org Wed Jun 26 19:33:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 19:33:49 +0300 Subject: dovecot-2.2: dsync: Fixed syncing when one of the backends suppo... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f3b9325509fd changeset: 16558:f3b9325509fd user: Timo Sirainen date: Wed Jun 26 19:33:38 2013 +0300 description: dsync: Fixed syncing when one of the backends supported GUIDs. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 230f111056b4 -r f3b9325509fd src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Wed Jun 26 15:44:08 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Wed Jun 26 19:33:38 2013 +0300 @@ -758,7 +758,8 @@ { const char *cmp_guid; - if (change->guid == NULL || *change->guid == '\0') + if (change->guid == NULL || change->guid[0] == '\0' || + importer->cur_guid[0] == '\0') return TRUE; if (!dsync_mail_change_guid_equals(change, importer->cur_guid, &cmp_guid)) { dsync_import_unexpected_state(importer, t_strdup_printf( From dovecot at dovecot.org Wed Jun 26 19:47:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 19:47:49 +0300 Subject: dovecot-2.2: pop3c: Fixed mail saving to fail nicely, not assert... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/42a5acba17e5 changeset: 16559:42a5acba17e5 user: Timo Sirainen date: Wed Jun 26 19:47:40 2013 +0300 description: pop3c: Fixed mail saving to fail nicely, not assert-crash. diffstat: src/lib-storage/index/pop3c/pop3c-storage.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (31 lines): diff -r f3b9325509fd -r 42a5acba17e5 src/lib-storage/index/pop3c/pop3c-storage.c --- a/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 26 19:33:38 2013 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-storage.c Wed Jun 26 19:47:40 2013 +0300 @@ -245,7 +245,7 @@ } static int -pop3c_save_begin(struct mail_save_context *ctx ATTR_UNUSED, +pop3c_save_begin(struct mail_save_context *ctx, struct istream *input ATTR_UNUSED) { mail_storage_set_error(ctx->transaction->box->storage, @@ -258,14 +258,16 @@ return -1; } -static int pop3c_save_finish(struct mail_save_context *ctx ATTR_UNUSED) +static int pop3c_save_finish(struct mail_save_context *ctx) { + index_save_context_free(ctx); return -1; } static void -pop3c_save_cancel(struct mail_save_context *ctx ATTR_UNUSED) +pop3c_save_cancel(struct mail_save_context *ctx) { + index_save_context_free(ctx); } static bool pop3c_storage_is_inconsistent(struct mailbox *box) From dovecot at dovecot.org Wed Jun 26 20:03:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 20:03:36 +0300 Subject: dovecot-2.2: dsync: Send DSYNC_BRAIN_FLAG_NO_MAIL_SYNC via ibc-s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2e6829462405 changeset: 16560:2e6829462405 user: Timo Sirainen date: Wed Jun 26 20:03:26 2013 +0300 description: dsync: Send DSYNC_BRAIN_FLAG_NO_MAIL_SYNC via ibc-stream to slave brain. diffstat: src/doveadm/dsync/dsync-ibc-stream.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (29 lines): diff -r 42a5acba17e5 -r 2e6829462405 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Wed Jun 26 19:47:40 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Wed Jun 26 20:03:26 2013 +0300 @@ -75,6 +75,7 @@ .optional_keys = "sync_ns_prefix sync_box sync_box_guid sync_type " "debug sync_visible_namespaces exclude_mailboxes " "send_mail_requests backup_send backup_recv lock_timeout" + "no_mail_sync" }, { .name = "mailbox_state", .chr = 'S', @@ -641,6 +642,8 @@ dsync_serializer_encode_add(encoder, "debug", ""); if ((set->brain_flags & DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES) != 0) dsync_serializer_encode_add(encoder, "sync_visible_namespaces", ""); + if ((set->brain_flags & DSYNC_BRAIN_FLAG_NO_MAIL_SYNC) != 0) + dsync_serializer_encode_add(encoder, "no_mail_sync", ""); dsync_serializer_encode_finish(&encoder, str); dsync_ibc_stream_send_string(ibc, str); @@ -722,6 +725,8 @@ set->brain_flags |= DSYNC_BRAIN_FLAG_DEBUG; if (dsync_deserializer_decode_try(decoder, "sync_visible_namespaces", &value)) set->brain_flags |= DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES; + if (dsync_deserializer_decode_try(decoder, "no_mail_sync", &value)) + set->brain_flags |= DSYNC_BRAIN_FLAG_NO_MAIL_SYNC; *set_r = set; return DSYNC_IBC_RECV_RET_OK; From dovecot at dovecot.org Wed Jun 26 20:53:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 20:53:07 +0300 Subject: dovecot-2.2: dsync: Added -1 parameter to do a "one way sync" wi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0144704e1b99 changeset: 16561:0144704e1b99 user: Timo Sirainen date: Wed Jun 26 20:53:01 2013 +0300 description: dsync: Added -1 parameter to do a "one way sync" without reverting changes. This can be useful during migration when you don't want to delete any mails, but you also don't want to send changes to the old server either. diffstat: src/doveadm/dsync/doveadm-dsync.c | 15 ++++++++++----- src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c | 5 ++++- src/doveadm/dsync/dsync-brain-mailbox-tree.c | 4 +++- src/doveadm/dsync/dsync-brain-mailbox.c | 2 +- src/doveadm/dsync/dsync-brain-private.h | 1 + src/doveadm/dsync/dsync-brain.c | 2 ++ src/doveadm/dsync/dsync-brain.h | 6 +++++- src/doveadm/dsync/dsync-ibc-stream.c | 6 +++++- 8 files changed, 31 insertions(+), 10 deletions(-) diffs (173 lines): diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Wed Jun 26 20:53:01 2013 +0300 @@ -36,7 +36,7 @@ #include #include -#define DSYNC_COMMON_GETOPT_ARGS "+dEfg:l:m:n:Nr:Rs:Ux:" +#define DSYNC_COMMON_GETOPT_ARGS "+1dEfg:l:m:n:Nr:Rs:Ux:" #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30 /* The broken_char is mainly set to get a proper error message when trying to convert a mailbox with a name that can't be used properly translated between @@ -80,6 +80,7 @@ unsigned int lock:1; unsigned int sync_visible_namespaces:1; unsigned int default_replica_location:1; + unsigned int oneway:1; unsigned int backup:1; unsigned int reverse_backup:1; unsigned int remote_user_prefix:1; @@ -553,6 +554,8 @@ if (ctx->no_mail_sync) brain_flags |= DSYNC_BRAIN_FLAG_NO_MAIL_SYNC; + if (ctx->oneway) + brain_flags |= DSYNC_BRAIN_FLAG_NO_BACKUP_OVERWRITE; if (doveadm_debug) brain_flags |= DSYNC_BRAIN_FLAG_DEBUG; @@ -852,6 +855,10 @@ const char *str; switch (c) { + case '1': + ctx->oneway = TRUE; + ctx->backup = TRUE; + break; case 'd': ctx->default_replica_location = TRUE; break; @@ -894,8 +901,6 @@ ctx->rawlog_path = optarg; break; case 'R': - if (!ctx->backup) - return FALSE; ctx->reverse_backup = TRUE; break; case 's': @@ -1033,11 +1038,11 @@ struct doveadm_mail_cmd cmd_dsync_mirror = { cmd_dsync_alloc, "sync", - "[-dfR] [-l ] [-m ] [-n ] [-x ] [-s ] " + "[-1dfR] [-l ] [-r ] [-m ] [-n | -N] [-x ] [-s ] " }; struct doveadm_mail_cmd cmd_dsync_backup = { cmd_dsync_backup_alloc, "backup", - "[-dfR] [-l ] [-m ] [-n ] [-x ] [-s ] " + "[-dfR] [-l ] [-r ] [-m ] [-n | -N] [-x ] [-s ] " }; struct doveadm_mail_cmd cmd_dsync_server = { cmd_dsync_server_alloc, "dsync-server", &doveadm_mail_cmd_hide diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Wed Jun 26 20:53:01 2013 +0300 @@ -102,7 +102,10 @@ enum mail_error error; int ret = -1; - i_assert(!brain->backup_send); + if (brain->backup_send) { + i_assert(brain->no_backup_overwrite); + return 0; + } switch (change->type) { case DSYNC_MAILBOX_TREE_SYNC_TYPE_DELETE_BOX: diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Wed Jun 26 20:53:01 2013 +0300 @@ -269,7 +269,9 @@ const struct dsync_mailbox_tree_sync_change *change; enum dsync_mailbox_trees_sync_type sync_type; - if (brain->backup_send) + if (brain->no_backup_overwrite) + sync_type = DSYNC_MAILBOX_TREES_SYNC_TYPE_TWOWAY; + else if (brain->backup_send) sync_type = DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_LOCAL; else if (brain->backup_recv) sync_type = DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_REMOTE; diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Wed Jun 26 20:53:01 2013 +0300 @@ -171,7 +171,7 @@ import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_WANT_MAIL_REQUESTS; if (brain->master_brain) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN; - if (brain->backup_recv) + if (brain->backup_recv && !brain->no_backup_overwrite) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES; if (brain->debug) import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_DEBUG; diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain-private.h Wed Jun 26 20:53:01 2013 +0300 @@ -95,6 +95,7 @@ unsigned int debug:1; unsigned int sync_visible_namespaces:1; unsigned int no_mail_sync:1; + unsigned int no_backup_overwrite:1; unsigned int changes_during_sync:1; unsigned int verbose_proctitle:1; unsigned int failed:1; diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/dsync-brain.c --- a/src/doveadm/dsync/dsync-brain.c Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.c Wed Jun 26 20:53:01 2013 +0300 @@ -130,6 +130,8 @@ brain->sync_visible_namespaces = (flags & DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES) != 0; brain->no_mail_sync = (flags & DSYNC_BRAIN_FLAG_NO_MAIL_SYNC) != 0; + brain->no_backup_overwrite = + (flags & DSYNC_BRAIN_FLAG_NO_BACKUP_OVERWRITE) != 0; } struct dsync_brain * diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/dsync-brain.h --- a/src/doveadm/dsync/dsync-brain.h Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-brain.h Wed Jun 26 20:53:01 2013 +0300 @@ -15,7 +15,11 @@ DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES= 0x10, /* Sync everything but the actual mails (e.g. mailbox creates, deletes) */ - DSYNC_BRAIN_FLAG_NO_MAIL_SYNC = 0x20 + DSYNC_BRAIN_FLAG_NO_MAIL_SYNC = 0x20, + /* Used with BACKUP_SEND/RECV: Don't force the + Use the two-way syncing algorithm, but don't actually modify + anything locally. (Useful during migration.) */ + DSYNC_BRAIN_FLAG_NO_BACKUP_OVERWRITE = 0x40 }; enum dsync_brain_sync_type { diff -r 2e6829462405 -r 0144704e1b99 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Wed Jun 26 20:03:26 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Wed Jun 26 20:53:01 2013 +0300 @@ -75,7 +75,7 @@ .optional_keys = "sync_ns_prefix sync_box sync_box_guid sync_type " "debug sync_visible_namespaces exclude_mailboxes " "send_mail_requests backup_send backup_recv lock_timeout" - "no_mail_sync" + "no_mail_sync no_backup_overwrite" }, { .name = "mailbox_state", .chr = 'S', @@ -644,6 +644,8 @@ dsync_serializer_encode_add(encoder, "sync_visible_namespaces", ""); if ((set->brain_flags & DSYNC_BRAIN_FLAG_NO_MAIL_SYNC) != 0) dsync_serializer_encode_add(encoder, "no_mail_sync", ""); + if ((set->brain_flags & DSYNC_BRAIN_FLAG_NO_BACKUP_OVERWRITE) != 0) + dsync_serializer_encode_add(encoder, "no_backup_overwrite", ""); dsync_serializer_encode_finish(&encoder, str); dsync_ibc_stream_send_string(ibc, str); @@ -727,6 +729,8 @@ set->brain_flags |= DSYNC_BRAIN_FLAG_SYNC_VISIBLE_NAMESPACES; if (dsync_deserializer_decode_try(decoder, "no_mail_sync", &value)) set->brain_flags |= DSYNC_BRAIN_FLAG_NO_MAIL_SYNC; + if (dsync_deserializer_decode_try(decoder, "no_backup_overwrite", &value)) + set->brain_flags |= DSYNC_BRAIN_FLAG_NO_BACKUP_OVERWRITE; *set_r = set; return DSYNC_IBC_RECV_RET_OK; From dovecot at dovecot.org Wed Jun 26 21:35:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 21:35:47 +0300 Subject: dovecot-2.2: config: Give a somewhat better warning for when usi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e8cba978850d changeset: 16562:e8cba978850d user: Timo Sirainen date: Wed Jun 26 21:35:37 2013 +0300 description: config: Give a somewhat better warning for when using protocols=imaps or pop3s. diffstat: src/config/old-set-parser.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 0144704e1b99 -r e8cba978850d src/config/old-set-parser.c --- a/src/config/old-set-parser.c Wed Jun 26 20:53:01 2013 +0300 +++ b/src/config/old-set-parser.c Wed Jun 26 21:35:37 2013 +0300 @@ -104,14 +104,14 @@ value = t_strarray_join((const char *const *)protos, " "); if (have_imaps && !have_imap) { - obsolete(ctx, "'imaps' protocol is no longer supported. to disable non-ssl imap, use service imap-login { inet_listener imap { port=0 } }"); + obsolete(ctx, "'imaps' protocol can no longer be specified (use protocols=imap). to disable non-ssl imap, use service imap-login { inet_listener imap { port=0 } }"); value = t_strconcat(value, " imap", NULL); config_apply_line(ctx, "port", "service/imap-login/inet_listener/imap/port=0", NULL); } else if (have_imaps) obsolete(ctx, "'imaps' protocol is no longer necessary, remove it"); if (have_pop3s && !have_pop3) { - obsolete(ctx, "'pop3s' protocol is no longer supported. to disable non-ssl pop3, use service pop3-login { inet_listener pop3 { port=0 } }"); + obsolete(ctx, "'pop3s' protocol can no longer be specified (use protocols=pop3). to disable non-ssl pop3, use service pop3-login { inet_listener pop3 { port=0 } }"); value = t_strconcat(value, " pop3", NULL); config_apply_line(ctx, "port", "service/pop3-login/inet_listener/pop3/port=0", NULL); From dovecot at dovecot.org Wed Jun 26 22:09:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 22:09:37 +0300 Subject: dovecot-2.1: Released v2.1.17. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/300a3a81c2cb changeset: 14979:300a3a81c2cb user: Timo Sirainen date: Wed Jun 26 22:04:44 2013 +0300 description: Released v2.1.17. diffstat: NEWS | 13 +++++++++++++ configure.in | 2 +- 2 files changed, 14 insertions(+), 1 deletions(-) diffs (30 lines): diff -r 98f8fd0b8d1c -r 300a3a81c2cb NEWS --- a/NEWS Fri Jun 07 22:06:24 2013 +0300 +++ b/NEWS Wed Jun 26 22:04:44 2013 +0300 @@ -1,3 +1,16 @@ +v2.1.17 2013-06-25 Timo Sirainen + + + zlib: Keep the last read mail uncompressed in a temporary file. + This significantly improves performance when IMAP client does + small partial fetches for a large mail. + + acl: Optionally get default ACL's for private/shared namespaces + from user's INBOX (plugin { acl_defaults_from_inbox = yes } + - Case-insensitive unicode character comparisons weren't all working + as they should. + - maildir: Fixed handling over 26 keywords in a mailbox. + - auth: Don't crash in non-PLAIN/LOGIN auth mechanism if master user + login is attempted without any master passdbs configured. + v2.1.16 2013-04-04 Timo Sirainen + Added quota-status policy service for Postfix diff -r 98f8fd0b8d1c -r 300a3a81c2cb configure.in --- a/configure.in Fri Jun 07 22:06:24 2013 +0300 +++ b/configure.in Wed Jun 26 22:04:44 2013 +0300 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.16],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.17],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Wed Jun 26 22:09:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 22:09:37 +0300 Subject: dovecot-2.1: Added tag 2.1.17 for changeset 300a3a81c2cb Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/97f4e09a8663 changeset: 14980:97f4e09a8663 user: Timo Sirainen date: Wed Jun 26 22:04:44 2013 +0300 description: Added tag 2.1.17 for changeset 300a3a81c2cb diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 300a3a81c2cb -r 97f4e09a8663 .hgtags --- a/.hgtags Wed Jun 26 22:04:44 2013 +0300 +++ b/.hgtags Wed Jun 26 22:04:44 2013 +0300 @@ -93,3 +93,4 @@ b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14 fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15 582108c190f88597c5215279cb66f74673144c9b 2.1.16 +300a3a81c2cbcb62e73c13728caf910f7f94f2fe 2.1.17 From dovecot at dovecot.org Wed Jun 26 22:09:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 22:09:37 +0300 Subject: dovecot-2.1: Added signature for changeset 300a3a81c2cb Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/edc20123f658 changeset: 14981:edc20123f658 user: Timo Sirainen date: Wed Jun 26 22:04:48 2013 +0300 description: Added signature for changeset 300a3a81c2cb diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 97f4e09a8663 -r edc20123f658 .hgsigs --- a/.hgsigs Wed Jun 26 22:04:44 2013 +0300 +++ b/.hgsigs Wed Jun 26 22:04:48 2013 +0300 @@ -56,3 +56,4 @@ b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3 582108c190f88597c5215279cb66f74673144c9b 0 iEUEABECAAYFAlFd69UACgkQyUhSUUBVisk/aQCYyYU9JcDM3SrTZu1oJuS26IAnZACeM400zLRROTaM6QYBVKTqTnfpuBY= +300a3a81c2cbcb62e73c13728caf910f7f94f2fe 0 iEYEABECAAYFAlHLO0wACgkQyUhSUUBVisk62ACfd37uysxihK82/Q6F4+l2CDUu2gQAoKA6FS5JM1s5+towUMxznujhWUPV From dovecot at dovecot.org Wed Jun 26 22:23:31 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Jun 2013 22:23:31 +0300 Subject: dovecot-2.2: dsync: Recent changes broke remote dsync Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c2c09416d8a4 changeset: 16563:c2c09416d8a4 user: Timo Sirainen date: Wed Jun 26 22:23:20 2013 +0300 description: dsync: Recent changes broke remote dsync diffstat: src/doveadm/dsync/dsync-ibc-stream.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r e8cba978850d -r c2c09416d8a4 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Wed Jun 26 21:35:37 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Wed Jun 26 22:23:20 2013 +0300 @@ -74,7 +74,7 @@ .required_keys = "hostname", .optional_keys = "sync_ns_prefix sync_box sync_box_guid sync_type " "debug sync_visible_namespaces exclude_mailboxes " - "send_mail_requests backup_send backup_recv lock_timeout" + "send_mail_requests backup_send backup_recv lock_timeout " "no_mail_sync no_backup_overwrite" }, { .name = "mailbox_state", From dovecot at dovecot.org Thu Jun 27 18:04:17 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 18:04:17 +0300 Subject: dovecot-2.2: lib-http: Added http_client_get_pending_request_cou... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/185dfd05b57a changeset: 16564:185dfd05b57a user: Timo Sirainen date: Thu Jun 27 18:03:38 2013 +0300 description: lib-http: Added http_client_get_pending_request_count() diffstat: src/lib-http/http-client.c | 5 +++++ src/lib-http/http-client.h | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diffs (26 lines): diff -r c2c09416d8a4 -r 185dfd05b57a src/lib-http/http-client.c --- a/src/lib-http/http-client.c Wed Jun 26 22:23:20 2013 +0300 +++ b/src/lib-http/http-client.c Thu Jun 27 18:03:38 2013 +0300 @@ -189,6 +189,11 @@ io_loop_destroy(&client->ioloop); } +unsigned int http_client_get_pending_request_count(struct http_client *client) +{ + return client->pending_requests; +} + int http_client_init_ssl_ctx(struct http_client *client, const char **error_r) { struct ssl_iostream_settings ssl_set; diff -r c2c09416d8a4 -r 185dfd05b57a src/lib-http/http-client.h --- a/src/lib-http/http-client.h Wed Jun 26 22:23:20 2013 +0300 +++ b/src/lib-http/http-client.h Thu Jun 27 18:03:38 2013 +0300 @@ -121,5 +121,7 @@ /* blocks until all currently submitted requests are handled */ void http_client_wait(struct http_client *client); +/* Returns number of pending HTTP requests. */ +unsigned int http_client_get_pending_request_count(struct http_client *client); #endif From dovecot at dovecot.org Thu Jun 27 18:04:17 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 18:04:17 +0300 Subject: dovecot-2.2: lib-http: Fixed hang when many connections were bei... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/af23c7a899a9 changeset: 16565:af23c7a899a9 user: Timo Sirainen date: Thu Jun 27 18:04:04 2013 +0300 description: lib-http: Fixed hang when many connections were being created and closed. diffstat: src/lib-http/http-client-peer.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diffs (42 lines): diff -r 185dfd05b57a -r af23c7a899a9 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Thu Jun 27 18:03:38 2013 +0300 +++ b/src/lib-http/http-client-peer.c Thu Jun 27 18:04:04 2013 +0300 @@ -98,7 +98,7 @@ struct http_client_connection *const *conn_idx; struct http_client_connection *conn = NULL; unsigned int connecting = 0, closing = 0, min_waiting = UINT_MAX; - unsigned int num_urgent, new_connections; + unsigned int num_urgent, new_connections, working_conn_count; if (http_client_peer_requests_pending(peer, &num_urgent) == 0) return FALSE; @@ -124,6 +124,7 @@ else if (!(*conn_idx)->connected) connecting++; } + working_conn_count = array_count(&peer->conns) - closing; /* did we find an idle connection? */ if (conn != NULL && min_waiting == 0) { @@ -132,8 +133,8 @@ } /* no, but can we create a new connection? */ - if (num_urgent == 0 && (array_count(&peer->conns) - closing) >= - peer->client->set.max_parallel_connections) { + if (num_urgent == 0 && + working_conn_count >= peer->client->set.max_parallel_connections) { /* no */ if (conn == NULL) return FALSE; @@ -142,8 +143,8 @@ } /* yes, determine how many connections to set up */ - if (peer->last_connect_failed && array_count(&peer->conns) > 0 && - array_count(&peer->conns) == connecting+closing) { + if (peer->last_connect_failed && working_conn_count > 0 && + working_conn_count == connecting) { /* don't create new connections until the existing ones have finished connecting successfully. */ new_connections = 0; From dovecot at dovecot.org Thu Jun 27 20:28:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 20:28:11 +0300 Subject: dovecot-2.2: lib-http: Minor code cleanup. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cf9024b01720 changeset: 16566:cf9024b01720 user: Timo Sirainen date: Thu Jun 27 20:24:45 2013 +0300 description: lib-http: Minor code cleanup. diffstat: src/lib-http/http-client-connection.c | 11 +++++++++-- src/lib-http/http-client-peer.c | 5 ++--- src/lib-http/http-client-private.h | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diffs (55 lines): diff -r af23c7a899a9 -r cf9024b01720 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 27 18:04:04 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 27 20:24:45 2013 +0300 @@ -44,15 +44,22 @@ static void http_client_connection_input(struct connection *_conn); -bool http_client_connection_is_ready(struct http_client_connection *conn) +unsigned int +http_client_connection_count_pending(struct http_client_connection *conn) { unsigned int pending_count = array_count(&conn->request_wait_list); if (conn->pending_request != NULL) pending_count++; + return pending_count; +} + +bool http_client_connection_is_ready(struct http_client_connection *conn) +{ return (conn->connected && !conn->output_locked && !conn->close_indicated && - pending_count < conn->client->set.max_pipelined_requests); + http_client_connection_count_pending(conn) < + conn->client->set.max_pipelined_requests); } bool http_client_connection_is_idle(struct http_client_connection *conn) diff -r af23c7a899a9 -r cf9024b01720 src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Thu Jun 27 18:04:04 2013 +0300 +++ b/src/lib-http/http-client-peer.c Thu Jun 27 20:24:45 2013 +0300 @@ -106,9 +106,8 @@ /* find the least busy connection */ array_foreach(&peer->conns, conn_idx) { if (http_client_connection_is_ready(*conn_idx)) { - unsigned int waiting = array_count(&(*conn_idx)->request_wait_list); - if ((*conn_idx)->pending_request != NULL) - waiting++; + unsigned int waiting = http_client_connection_count_pending(*conn_idx); + if (waiting < min_waiting) { min_waiting = waiting; conn = *conn_idx; diff -r af23c7a899a9 -r cf9024b01720 src/lib-http/http-client-private.h --- a/src/lib-http/http-client-private.h Thu Jun 27 18:04:04 2013 +0300 +++ b/src/lib-http/http-client-private.h Thu Jun 27 20:24:45 2013 +0300 @@ -218,6 +218,8 @@ http_client_connection_create(struct http_client_peer *peer); void http_client_connection_ref(struct http_client_connection *conn); void http_client_connection_unref(struct http_client_connection **_conn); +unsigned int +http_client_connection_count_pending(struct http_client_connection *conn); bool http_client_connection_is_ready(struct http_client_connection *conn); bool http_client_connection_is_idle(struct http_client_connection *conn); bool http_client_connection_next_request(struct http_client_connection *conn); From dovecot at dovecot.org Thu Jun 27 20:28:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 20:28:11 +0300 Subject: dovecot-2.2: lib-http: Timeouts were being handled wrong/leaked ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/975fdf5a6987 changeset: 16567:975fdf5a6987 user: Timo Sirainen date: Thu Jun 27 20:26:13 2013 +0300 description: lib-http: Timeouts were being handled wrong/leaked by ioloop switching. diffstat: src/lib-http/http-client-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r cf9024b01720 -r 975fdf5a6987 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 27 20:24:45 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 27 20:26:13 2013 +0300 @@ -936,7 +936,7 @@ if (conn->to_requests != NULL) conn->to_requests = io_loop_move_timeout(&conn->to_requests); if (conn->to_connect != NULL) - conn->to_requests = io_loop_move_timeout(&conn->to_connect); + conn->to_connect = io_loop_move_timeout(&conn->to_connect); if (conn->to_input != NULL) conn->to_input = io_loop_move_timeout(&conn->to_input); if (conn->to_idle != NULL) From dovecot at dovecot.org Thu Jun 27 20:28:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 20:28:11 +0300 Subject: dovecot-2.2: lib-http: When connection is freed, abort also the ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/110d18bf9e30 changeset: 16568:110d18bf9e30 user: Timo Sirainen date: Thu Jun 27 20:26:50 2013 +0300 description: lib-http: When connection is freed, abort also the pending request. diffstat: src/lib-http/http-client-connection.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 975fdf5a6987 -r 110d18bf9e30 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 27 20:26:13 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 27 20:26:50 2013 +0300 @@ -896,6 +896,10 @@ http_client_request_error(*req, HTTP_CLIENT_REQUEST_ERROR_ABORTED, "Aborting"); } + if (conn->pending_request != NULL) { + http_client_request_error(conn->pending_request, + HTTP_CLIENT_REQUEST_ERROR_ABORTED, "Aborting"); + } array_free(&conn->request_wait_list); if (conn->http_parser != NULL) From dovecot at dovecot.org Thu Jun 27 20:28:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 20:28:11 +0300 Subject: dovecot-2.2: lib-http: If connection times out, set the stream's... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3fdfbabf3dcf changeset: 16569:3fdfbabf3dcf user: Timo Sirainen date: Thu Jun 27 20:27:57 2013 +0300 description: lib-http: If connection times out, set the stream's errno to ETIMEDOUT in case it's used. diffstat: src/lib-http/http-client-connection.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 110d18bf9e30 -r 3fdfbabf3dcf src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 27 20:26:50 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 27 20:27:57 2013 +0300 @@ -214,6 +214,7 @@ { unsigned int msecs = conn->client->set.request_timeout_msecs; + conn->conn.input->stream_errno = ETIMEDOUT; http_client_connection_abort_temp_error(&conn, HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT, t_strdup_printf( "No response for request in %u.%03u secs", From dovecot at dovecot.org Thu Jun 27 20:28:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 20:28:59 +0300 Subject: dovecot-2.2: lib-http: Call request's destroy callback always, n... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/eb63569f0f73 changeset: 16570:eb63569f0f73 user: Timo Sirainen date: Thu Jun 27 20:28:51 2013 +0300 description: lib-http: Call request's destroy callback always, not just on success. diffstat: src/lib-http/http-client-request.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (25 lines): diff -r 3fdfbabf3dcf -r eb63569f0f73 src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Thu Jun 27 20:27:57 2013 +0300 +++ b/src/lib-http/http-client-request.c Thu Jun 27 20:28:51 2013 +0300 @@ -92,6 +92,11 @@ if (--req->refcount > 0) return; + if (req->destroy_callback != NULL) { + req->destroy_callback(req->destroy_context); + req->destroy_callback = NULL; + } + /* only decrease pending request counter if this request was submitted */ if (req->state > HTTP_REQUEST_STATE_NEW) req->client->pending_requests--; @@ -541,9 +546,6 @@ req->callback = NULL; req->state = HTTP_REQUEST_STATE_FINISHED; - if (req->destroy_callback != NULL) - req->destroy_callback(req->destroy_context); - if (req->payload_wait && req->client->ioloop != NULL) io_loop_stop(req->client->ioloop); http_client_request_unref(_req); From dovecot at dovecot.org Thu Jun 27 20:32:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 20:32:12 +0300 Subject: dovecot-2.2: lib-http: Remove request timeout from being used du... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9fd54d123e22 changeset: 16571:9fd54d123e22 user: Timo Sirainen date: Thu Jun 27 20:32:01 2013 +0300 description: lib-http: Remove request timeout from being used during payload read. The reading is done by the lib-http caller, which should have its own timeouts. diffstat: src/lib-http/http-client-connection.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diffs (28 lines): diff -r eb63569f0f73 -r 9fd54d123e22 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 27 20:28:51 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 27 20:32:01 2013 +0300 @@ -269,8 +269,11 @@ if (conn->to_idle != NULL) timeout_remove(&conn->to_idle); - if (conn->client->set.request_timeout_msecs > 0 && - conn->to_requests == NULL) { + if (conn->client->set.request_timeout_msecs == 0) + ; + else if (conn->to_requests != NULL) + timeout_reset(conn->to_requests); + else { conn->to_requests = timeout_add(conn->client->set.request_timeout_msecs, http_client_connection_request_timeout, conn); } @@ -423,6 +426,10 @@ /* the callback may add its own I/O, so we need to remove our one before calling it */ io_remove(&conn->conn.io); + /* we've received the request itself, and we can't reset the + timeout during the payload reading. */ + if (conn->to_requests != NULL) + timeout_remove(&conn->to_requests); } http_client_connection_ref(conn); From dovecot at dovecot.org Thu Jun 27 20:37:56 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 20:37:56 +0300 Subject: dovecot-2.2: lib-http: Don't crash if payload stream is referenc... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/20a0595e6e5d changeset: 16572:20a0595e6e5d user: Timo Sirainen date: Thu Jun 27 20:37:46 2013 +0300 description: lib-http: Don't crash if payload stream is referenced by caller after its connection is freed. diffstat: src/lib-http/http-client-connection.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (16 lines): diff -r 9fd54d123e22 -r 20a0595e6e5d src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 27 20:32:01 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 27 20:37:46 2013 +0300 @@ -896,6 +896,12 @@ conn->closing = TRUE; conn->connected = FALSE; + if (conn->incoming_payload != NULL) { + /* the stream is still accessed by lib-http caller. */ + i_stream_remove_destroy_callback(conn->incoming_payload, + http_client_payload_destroyed); + } + connection_disconnect(&conn->conn); /* abort all pending requests */ From dovecot at dovecot.org Thu Jun 27 22:59:29 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 22:59:29 +0300 Subject: dovecot-2.2: lib-http: When successfully connected to a peer, do... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e405105a0c24 changeset: 16573:e405105a0c24 user: Timo Sirainen date: Thu Jun 27 22:49:50 2013 +0300 description: lib-http: When successfully connected to a peer, don't drop the peer's pending connections. They could have been intentionally created for other urgent requests. diffstat: src/lib-http/http-client-host.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diffs (60 lines): diff -r 20a0595e6e5d -r e405105a0c24 src/lib-http/http-client-host.c --- a/src/lib-http/http-client-host.c Thu Jun 27 20:37:46 2013 +0300 +++ b/src/lib-http/http-client-host.c Thu Jun 27 22:49:50 2013 +0300 @@ -169,13 +169,21 @@ } static void -http_client_host_drop_pending_connections(struct http_client_host_port *hport) +http_client_host_drop_pending_connections(struct http_client_host_port *hport, + const struct http_client_peer_addr *addr) { struct http_client_peer *peer; struct http_client_connection *const *conns, *conn; unsigned int i, count; for (peer = hport->host->client->peers_list; peer != NULL; peer = peer->next) { + if (http_client_peer_addr_cmp(&peer->addr, addr) == 0) { + /* don't drop any connections to the successfully + connected peer, even if some of the connections + are pending. they may be intended for urgent + requests. */ + continue; + } if (!http_client_peer_have_host(peer, hport->host)) continue; @@ -193,7 +201,8 @@ } static void -http_client_host_port_connection_success(struct http_client_host_port *hport) +http_client_host_port_connection_success(struct http_client_host_port *hport, + const struct http_client_peer_addr *addr) { /* we achieved at least one connection the the addr->ip */ @@ -201,10 +210,11 @@ if (hport->to_connect != NULL) timeout_remove(&hport->to_connect); - /* drop all other attempts. note that we get here whenever a connection - is successfully created, so pending_connection_count may be 0. */ + /* drop all other attempts to the hport. note that we get here whenever + a connection is successfully created, so pending_connection_count + may be 0. */ if (hport->pending_connection_count > 1) - http_client_host_drop_pending_connections(hport); + http_client_host_drop_pending_connections(hport, addr); /* since this hport is now successfully connected, we won't be getting any connection failures to it anymore. so we need to reset the pending_connection_count count here. */ @@ -257,7 +267,7 @@ if (hport == NULL) return; - http_client_host_port_connection_success(hport); + http_client_host_port_connection_success(hport, addr); } void http_client_host_connection_failure(struct http_client_host *host, From dovecot at dovecot.org Thu Jun 27 23:07:31 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Jun 2013 23:07:31 +0300 Subject: dovecot-2.2: lib-http: Added more debug messages. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a6b00756ab2c changeset: 16574:a6b00756ab2c user: Timo Sirainen date: Thu Jun 27 23:07:20 2013 +0300 description: lib-http: Added more debug messages. diffstat: src/lib-http/http-client-connection.c | 9 +++++++++ src/lib-http/http-client-peer.c | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletions(-) diffs (83 lines): diff -r e405105a0c24 -r a6b00756ab2c src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Thu Jun 27 22:49:50 2013 +0300 +++ b/src/lib-http/http-client-connection.c Thu Jun 27 23:07:20 2013 +0300 @@ -111,6 +111,8 @@ struct http_client_connection *conn = *_conn; struct http_client_request **req; + http_client_connection_debug(conn, "Aborting connection: %s", error); + conn->connected = FALSE; conn->closing = TRUE; @@ -146,6 +148,9 @@ } } + http_client_connection_debug(conn, + "Aborting connection with temporary error: %s", error); + conn->connected = FALSE; conn->closing = TRUE; @@ -341,6 +346,7 @@ "SSL handshaking to %s failed: Connection timed out in %u.%03u secs", _conn->name, msecs/1000, msecs%1000); } + http_client_connection_debug(conn, "%s", error); http_client_connection_retry_requests(conn, HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT, error); break; @@ -349,6 +355,7 @@ error = _conn->input == NULL ? "Connection lost" : t_strdup_printf("Connection lost: %s", strerror(_conn->input->stream_errno)); + http_client_connection_debug(conn, "%s", error); http_client_connection_retry_requests(conn, HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST, error); default: @@ -784,6 +791,7 @@ if (conn->peer->addr.https_name != NULL) { if (http_client_connection_ssl_init(conn, &error) < 0) { http_client_peer_connection_failure(conn->peer, error); + http_client_connection_debug(conn, "%s", error); http_client_connection_unref(&conn); } return; @@ -833,6 +841,7 @@ conn->connect_start_timestamp = ioloop_timeval; if (connection_client_connect(&conn->conn) < 0) { conn->connect_errno = errno; + http_client_connection_debug(conn, "Connect failed: %m"); conn->to_input = timeout_add_short(0, http_client_connection_delayed_connect_error, conn); return; diff -r e405105a0c24 -r a6b00756ab2c src/lib-http/http-client-peer.c --- a/src/lib-http/http-client-peer.c Thu Jun 27 22:49:50 2013 +0300 +++ b/src/lib-http/http-client-peer.c Thu Jun 27 23:07:20 2013 +0300 @@ -135,8 +135,12 @@ if (num_urgent == 0 && working_conn_count >= peer->client->set.max_parallel_connections) { /* no */ - if (conn == NULL) + if (conn == NULL) { + http_client_peer_debug(peer, + "Only non-urgent requests, and we already have " + "%u pending connections", working_conn_count); return FALSE; + } /* pipeline it */ return http_client_connection_next_request(conn); } @@ -152,6 +156,11 @@ } else { new_connections = (num_urgent > connecting ? num_urgent - connecting : 0); } + http_client_peer_debug(peer, + "Creating %u new connections to handle requests " + "(already %u usable, connecting to %u, closing %u)", + new_connections, working_conn_count - connecting, + connecting, closing); http_client_peer_connect(peer, new_connections); /* now we wait until it is connected */ From dovecot at dovecot.org Fri Jun 28 19:48:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Jun 2013 19:48:48 +0300 Subject: dovecot-2.2: Added net_gethostbyaddr() for DNS PTR lookups. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/eaa712530f3f changeset: 16575:eaa712530f3f user: Timo Sirainen date: Fri Jun 28 19:48:15 2013 +0300 description: Added net_gethostbyaddr() for DNS PTR lookups. This code assumes we have IPv6 capability. Perhaps we should just require it everywhere already.. diffstat: src/lib/net.c | 18 ++++++++++++++++++ src/lib/net.h | 3 +++ 2 files changed, 21 insertions(+), 0 deletions(-) diffs (41 lines): diff -r a6b00756ab2c -r eaa712530f3f src/lib/net.c --- a/src/lib/net.c Thu Jun 27 23:07:20 2013 +0300 +++ b/src/lib/net.c Fri Jun 28 19:48:15 2013 +0300 @@ -663,6 +663,24 @@ return 0; } +int net_gethostbyaddr(const struct ip_addr *ip, const char **name_r) +{ + union sockaddr_union so; + socklen_t addrlen = sizeof(so); + char hbuf[NI_MAXHOST]; + int ret; + + memset(&so, 0, sizeof(so)); + sin_set_ip(&so, ip); + ret = getnameinfo(&so.sa, addrlen, hbuf, sizeof(hbuf), NULL, 0, + NI_NAMEREQD); + if (ret != 0) + return ret; + + *name_r = t_strdup(hbuf); + return 0; +} + int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port) { union sockaddr_union so; diff -r a6b00756ab2c -r eaa712530f3f src/lib/net.h --- a/src/lib/net.h Thu Jun 27 23:07:20 2013 +0300 +++ b/src/lib/net.h Fri Jun 28 19:48:15 2013 +0300 @@ -105,6 +105,9 @@ to be free'd. Returns 0 = ok, others = error code for net_gethosterror() */ int net_gethostbyname(const char *addr, struct ip_addr **ips, unsigned int *ips_count); +/* Return host for the IP address. Returns 0 = ok, others = error code for + net_gethosterror(). */ +int net_gethostbyaddr(const struct ip_addr *ip, const char **name_r); /* get error of net_gethostname() */ const char *net_gethosterror(int error) ATTR_CONST; /* return TRUE if host lookup failed because it didn't exist (ie. not From dovecot at dovecot.org Fri Jun 28 19:48:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Jun 2013 19:48:48 +0300 Subject: dovecot-2.2: dns, lib-dns: Added support for async DNS PTR lookups. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1fbac590b9d4 changeset: 16576:1fbac590b9d4 user: Timo Sirainen date: Fri Jun 28 19:48:37 2013 +0300 description: dns, lib-dns: Added support for async DNS PTR lookups. diffstat: src/dns/dns-client.c | 13 ++++++++++++- src/lib-dns/dns-lookup.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ src/lib-dns/dns-lookup.h | 12 ++++++++++++ 3 files changed, 66 insertions(+), 7 deletions(-) diffs (171 lines): diff -r eaa712530f3f -r 1fbac590b9d4 src/dns/dns-client.c --- a/src/dns/dns-client.c Fri Jun 28 19:48:15 2013 +0300 +++ b/src/dns/dns-client.c Fri Jun 28 19:48:37 2013 +0300 @@ -27,7 +27,8 @@ static int dns_client_input_line(struct dns_client *client, const char *line) { - struct ip_addr *ips; + struct ip_addr *ips, ip; + const char *name; unsigned int i, ips_count; int ret; @@ -48,6 +49,16 @@ net_ip2addr(&ips[i]), "\n", NULL)); } } + } else if (strncmp(line, "NAME\t", 5) == 0) { + if (net_addr2ip(line+5, &ip) < 0) + o_stream_nsend_str(client->output, "-1\n"); + else if ((ret = net_gethostbyaddr(&ip, &name)) != 0) { + o_stream_nsend_str(client->output, + t_strdup_printf("%d\n", ret)); + } else { + o_stream_nsend_str(client->output, + t_strdup_printf("0 %s\n", name)); + } } else if (strcmp(line, "QUIT") == 0) { return -1; } else { diff -r eaa712530f3f -r 1fbac590b9d4 src/lib-dns/dns-lookup.c --- a/src/lib-dns/dns-lookup.c Fri Jun 28 19:48:15 2013 +0300 +++ b/src/lib-dns/dns-lookup.c Fri Jun 28 19:48:37 2013 +0300 @@ -16,6 +16,7 @@ struct dns_lookup { int fd; char *path; + bool ptr_lookup; struct istream *input; struct io *io; @@ -27,6 +28,7 @@ struct dns_lookup_result result; struct ip_addr *ips; unsigned int ip_idx; + char *name; dns_lookup_callback_t *callback; void *context; @@ -39,6 +41,20 @@ struct dns_lookup_result *result = &lookup->result; if (result->ips_count == 0) { + if (lookup->ptr_lookup) { + /* [] */ + if (strncmp(line, "0 ", 2) == 0) { + result->name = lookup->name = + i_strdup(line + 2); + result->ret = 0; + } else { + if (str_to_int(line, &result->ret) < 0) { + return -1; + } + result->error = net_gethosterror(result->ret); + } + return 1; + } /* first line: */ if (sscanf(line, "%d %u", &result->ret, &result->ips_count) == 0) @@ -119,14 +135,14 @@ dns_lookup_free(&lookup); } -#undef dns_lookup -int dns_lookup(const char *host, const struct dns_lookup_settings *set, - dns_lookup_callback_t *callback, void *context, - struct dns_lookup **lookup_r) +static int +dns_lookup_common(const char *cmd, bool ptr_lookup, + const struct dns_lookup_settings *set, + dns_lookup_callback_t *callback, void *context, + struct dns_lookup **lookup_r) { struct dns_lookup *lookup; struct dns_lookup_result result; - const char *cmd; int fd; memset(&result, 0, sizeof(result)); @@ -140,7 +156,6 @@ return -1; } - cmd = t_strconcat("IP\t", host, "\n", NULL); if (write_full(fd, cmd, strlen(cmd)) < 0) { result.error = t_strdup_printf("write(%s) failed: %m", set->dns_client_socket_path); @@ -150,6 +165,7 @@ } lookup = i_new(struct dns_lookup, 1); + lookup->ptr_lookup = ptr_lookup; lookup->fd = fd; lookup->path = i_strdup(set->dns_client_socket_path); lookup->input = i_stream_create_fd(fd, MAX_INBUF_SIZE, FALSE); @@ -168,6 +184,25 @@ return 0; } +#undef dns_lookup +int dns_lookup(const char *host, const struct dns_lookup_settings *set, + dns_lookup_callback_t *callback, void *context, + struct dns_lookup **lookup_r) +{ + return dns_lookup_common(t_strconcat("IP\t", host, "\n", NULL), FALSE, + set, callback, context, lookup_r); +} + +#undef dns_lookup_ptr +int dns_lookup_ptr(const struct ip_addr *ip, + const struct dns_lookup_settings *set, + dns_lookup_callback_t *callback, void *context, + struct dns_lookup **lookup_r) +{ + const char *cmd = t_strconcat("NAME\t", net_ip2addr(ip), "\n", NULL); + return dns_lookup_common(cmd, TRUE, set, callback, context, lookup_r); +} + static void dns_lookup_free(struct dns_lookup **_lookup) { struct dns_lookup *lookup = *_lookup; @@ -181,6 +216,7 @@ if (close(lookup->fd) < 0) i_error("close(%s) failed: %m", lookup->path); + i_free(lookup->name); i_free(lookup->ips); i_free(lookup->path); i_free(lookup); diff -r eaa712530f3f -r 1fbac590b9d4 src/lib-dns/dns-lookup.h --- a/src/lib-dns/dns-lookup.h Fri Jun 28 19:48:15 2013 +0300 +++ b/src/lib-dns/dns-lookup.h Fri Jun 28 19:48:37 2013 +0300 @@ -19,8 +19,11 @@ /* how many milliseconds the lookup took. */ unsigned int msecs; + /* for IP lookup: */ unsigned int ips_count; const struct ip_addr *ips; + /* for PTR lookup: */ + const char *name; }; typedef void dns_lookup_callback_t(const struct dns_lookup_result *result, @@ -38,6 +41,15 @@ CALLBACK_TYPECHECK(callback, void (*)( \ const struct dns_lookup_result *, typeof(context))), \ set, (dns_lookup_callback_t *)callback, context, lookup_r) +int dns_lookup_ptr(const struct ip_addr *ip, + const struct dns_lookup_settings *set, + dns_lookup_callback_t *callback, void *context, + struct dns_lookup **lookup_r) ATTR_NULL(4); +#define dns_lookup_ptr(host, set, callback, context, lookup_r) \ + dns_lookup_ptr(host + \ + CALLBACK_TYPECHECK(callback, void (*)( \ + const struct dns_lookup_result *, typeof(context))), \ + set, (dns_lookup_callback_t *)callback, context, lookup_r) /* Abort the DNS lookup without calling the callback. */ void dns_lookup_abort(struct dns_lookup **lookup);