From dovecot at dovecot.org Sun Sep 2 16:06:52 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 16:06:52 +0300 Subject: dovecot-2.1: Various fixes to listing mailboxes. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d079d72abb79 changeset: 14694:d079d72abb79 user: Timo Sirainen date: Sun Sep 02 16:06:45 2012 +0300 description: Various fixes to listing mailboxes. Some of these are a bit kludgy, v2.2 has a larger rewrite of the code to implement them more nicely. diffstat: src/imap/cmd-list.c | 89 +++++++++++++++++++++++----- src/lib-storage/list/mailbox-list-fs-iter.c | 7 ++ 2 files changed, 79 insertions(+), 17 deletions(-) diffs (209 lines): diff -r 5625ab0a3eed -r d079d72abb79 src/imap/cmd-list.c --- a/src/imap/cmd-list.c Fri Aug 31 16:19:21 2012 +0300 +++ b/src/imap/cmd-list.c Sun Sep 02 16:06:45 2012 +0300 @@ -35,6 +35,9 @@ unsigned int used_status:1; }; +static bool mailbox_list_match_anything(struct cmd_list_context *ctx, + struct mail_namespace *ns); + static void mailbox_flags2str(struct cmd_list_context *ctx, string_t *str, const char *special_use, enum mailbox_info_flags flags) @@ -207,7 +210,58 @@ return flags; } -static bool list_namespace_has_children(struct cmd_list_context *ctx) +static bool +ns_prefix_is_visible(struct cmd_list_context *ctx, + struct mail_namespace *ns) +{ + if ((ns->flags & NAMESPACE_FLAG_LIST_PREFIX) != 0) + return TRUE; + if ((ns->flags & NAMESPACE_FLAG_LIST_CHILDREN) != 0) { + if (mailbox_list_match_anything(ctx, ns)) + return TRUE; + } + return FALSE; +} + +static bool +ns_prefix_has_visible_child_namespace(struct cmd_list_context *ctx, + const char *prefix) +{ + struct mail_namespace *ns; + unsigned int prefix_len = strlen(prefix); + + for (ns = ctx->ns->user->namespaces; ns != NULL; ns = ns->next) { + if (ns->prefix_len > prefix_len && + strncmp(ns->prefix, prefix, prefix_len) == 0 && + ns_prefix_is_visible(ctx, ns)) + return TRUE; + } + return FALSE; +} + +static bool +mailbox_ns_prefix_is_shared_inbox(struct mail_namespace *ns) +{ + const struct mail_storage_settings *set; + struct mail_storage *storage; + + mailbox_list_get_closest_storage(ns->list, &storage); + set = mail_storage_get_settings(storage); + return ns->type == NAMESPACE_SHARED && + (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 && + !set->mail_shared_explicit_inbox; +} + +static bool +mailbox_is_shared_inbox(struct mail_namespace *ns, const char *vname) +{ + return mailbox_ns_prefix_is_shared_inbox(ns) && + strncmp(ns->prefix, vname, ns->prefix_len-1) == 0 && + vname[ns->prefix_len-1] == '\0'; +} + +static bool mailbox_list_match_anything(struct cmd_list_context *ctx, + struct mail_namespace *ns) { enum mailbox_list_iter_flags list_flags = MAILBOX_LIST_ITER_RETURN_NO_FLAGS; @@ -215,18 +269,22 @@ const struct mailbox_info *info; bool ret = FALSE; - if ((ctx->list_flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) - list_flags |= MAILBOX_LIST_ITER_SELECT_SUBSCRIBED; - - list_iter = mailbox_list_iter_init(ctx->ns->list, - t_strconcat(ctx->ns->prefix, "%", NULL), list_flags); + list_iter = mailbox_list_iter_init(ns->list, + t_strconcat(ns->prefix, "%", NULL), list_flags); info = mailbox_list_iter_next(list_iter); + if (info != NULL && mailbox_ns_prefix_is_shared_inbox(ns) && + mailbox_is_shared_inbox(ns, info->name)) { + /* we don't want to see this, try the next one */ + info = mailbox_list_iter_next(list_iter); + } if (info != NULL) ret = TRUE; if (mailbox_list_iter_deinit(&list_iter) < 0) { /* safer to answer TRUE in error conditions */ ret = TRUE; } + if (!ret && ns_prefix_has_visible_child_namespace(ctx, ns->prefix)) + ret = TRUE; return ret; } @@ -248,17 +306,14 @@ struct imap_match_glob *glob; enum imap_match_result match; const char *ns_prefix, *p; - bool inboxcase; unsigned int skip_len; skip_len = strlen(ctx->ref); if (strncmp(ctx->ns->prefix, ctx->ref, skip_len) != 0) skip_len = 0; - inboxcase = strncasecmp(ctx->ns->prefix, "INBOX", 5) == 0 && - ctx->ns->prefix[5] == mail_namespace_get_sep(ctx->ns); glob = imap_match_init_multiple(pool_datastack_create(), - ctx->patterns, inboxcase, + ctx->patterns, TRUE, mail_namespace_get_sep(ctx->ns)); ns_prefix = ctx->ns->prefix + skip_len; match = imap_match(glob, ns_prefix); @@ -344,7 +399,7 @@ } if ((flags & MAILBOX_CHILDREN) == 0) { - if (have_children || list_namespace_has_children(ctx)) { + if (have_children || mailbox_list_match_anything(ctx, ctx->ns)) { flags |= MAILBOX_CHILDREN; flags &= ~MAILBOX_NOCHILDREN; } else { @@ -471,7 +526,7 @@ ctx->inbox_found = TRUE; } if (ctx->cur_ns_send_prefix) - list_namespace_send_prefix(ctx, TRUE); + list_namespace_send_prefix(ctx, FALSE); /* if there's a list=yes namespace with this name, list it as having children */ @@ -673,10 +728,11 @@ } static bool -list_namespace_match_pattern(struct cmd_list_context *ctx, bool inboxcase, +list_namespace_match_pattern(struct cmd_list_context *ctx, const char *cur_ref, const char *cur_ns_prefix, const char *cur_pattern) { + const char *orig_cur_ns_prefix = cur_ns_prefix; const char *orig_cur_pattern = cur_pattern; struct mail_namespace *ns = ctx->ns; struct imap_match_glob *pat_glob; @@ -698,6 +754,7 @@ } return TRUE; } + cur_ns_prefix = orig_cur_ns_prefix; /* namespace prefix still wasn't completely skipped over. for example cur_ns_prefix=INBOX/, pattern=%/% or pattern=IN%. @@ -722,7 +779,7 @@ /* check if this namespace prefix matches the current pattern */ pat_glob = imap_match_init(pool_datastack_create(), orig_cur_pattern, - inboxcase, mail_namespace_get_sep(ns)); + TRUE, mail_namespace_get_sep(ns)); match = imap_match(pat_glob, cur_ns_prefix); if (match == IMAP_MATCH_YES) { if (list_want_send_prefix(ctx, orig_cur_pattern)) @@ -764,7 +821,6 @@ const char *cur_ns_prefix, *cur_ref, *const *pat, *pattern; enum imap_match_result inbox_match; ARRAY_DEFINE(used_patterns, const char *); - bool inboxcase; cur_ns_prefix = ns->prefix; cur_ref = ctx->ref; @@ -782,14 +838,13 @@ inbox_match = list_use_inboxcase(ctx); ctx->cur_ns_match_inbox = inbox_match == IMAP_MATCH_YES; - inboxcase = (inbox_match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) != 0; t_array_init(&used_patterns, 16); for (pat = ctx->patterns; *pat != NULL; pat++) { pattern = *pat; /* see if pattern even has a chance of matching the namespace prefix */ - if (list_namespace_match_pattern(ctx, inboxcase, cur_ref, + if (list_namespace_match_pattern(ctx, cur_ref, cur_ns_prefix, pattern)) { pattern = mailbox_list_join_refpattern(ns->list, ctx->ref, pattern); diff -r 5625ab0a3eed -r d079d72abb79 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Fri Aug 31 16:19:21 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Sun Sep 02 16:06:45 2012 +0300 @@ -771,6 +771,13 @@ if (ret <= 0) return NULL; + if (_ctx->list->ns->type == NAMESPACE_SHARED && + !_ctx->list->ns->list->mail_set->mail_shared_explicit_inbox && + strlen(ctx->info.name) < _ctx->list->ns->prefix_len) { + /* shared/user INBOX, IMAP code already lists it */ + return fs_list_iter_next(_ctx); + } + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_RETURN_SUBSCRIBED) != 0) { mailbox_list_set_subscription_flags(ctx->ctx.list, ctx->info.name, From dovecot at dovecot.org Sun Sep 2 16:48:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 16:48:48 +0300 Subject: dovecot-2.2: mbox: Added support for copy/move/catenate within s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9e4257061225 changeset: 15008:9e4257061225 user: Timo Sirainen date: Sun Sep 02 16:48:25 2012 +0300 description: mbox: Added support for copy/move/catenate within same mailbox. diffstat: src/lib-storage/index/mbox/mbox-lock.c | 14 +++++++++++ src/lib-storage/index/mbox/mbox-lock.h | 2 + src/lib-storage/index/mbox/mbox-mail.c | 13 +++++---- src/lib-storage/index/mbox/mbox-save.c | 13 +-------- src/lib-storage/index/mbox/mbox-storage.c | 39 +++++++++++++++++++++++++----- src/lib-storage/index/mbox/mbox-storage.h | 4 ++- 6 files changed, 60 insertions(+), 25 deletions(-) diffs (212 lines): diff -r 96716652b364 -r 9e4257061225 src/lib-storage/index/mbox/mbox-lock.c --- a/src/lib-storage/index/mbox/mbox-lock.c Fri Aug 31 15:25:20 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-lock.c Sun Sep 02 16:48:25 2012 +0300 @@ -784,6 +784,14 @@ bool fcntl_locked; int ret; + if (lock_type == F_RDLCK && mbox->external_transactions > 0) { + /* 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, + since we can't later upgrade a read lock to write lock. */ + lock_type = F_WRLCK; + } + /* allow only unlock -> shared/exclusive or exclusive -> shared */ i_assert(lock_type == F_RDLCK || lock_type == F_WRLCK); i_assert(lock_type == F_RDLCK || mbox->mbox_lock_type != F_RDLCK); @@ -878,6 +886,12 @@ return mbox_unlock_files(&ctx); } +unsigned int mbox_get_cur_lock_id(struct mbox_mailbox *mbox) +{ + return mbox->mbox_lock_id + + (mbox->mbox_excl_locks > 0 ? 1 : 0); +} + void mbox_dotlock_touch(struct mbox_mailbox *mbox) { if (mbox->mbox_dotlock == NULL) diff -r 96716652b364 -r 9e4257061225 src/lib-storage/index/mbox/mbox-lock.h --- a/src/lib-storage/index/mbox/mbox-lock.h Fri Aug 31 15:25:20 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-lock.h Sun Sep 02 16:48:25 2012 +0300 @@ -8,6 +8,8 @@ int ATTR_NOWARN_UNUSED_RESULT mbox_unlock(struct mbox_mailbox *mbox, unsigned int lock_id); +unsigned int mbox_get_cur_lock_id(struct mbox_mailbox *mbox); + void mbox_dotlock_touch(struct mbox_mailbox *mbox); #endif diff -r 96716652b364 -r 9e4257061225 src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Fri Aug 31 15:25:20 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-mail.c Sun Sep 02 16:48:25 2012 +0300 @@ -23,8 +23,8 @@ struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->box; if (mbox->mbox_lock_type == F_RDLCK) { - if (mbox->mbox_lock_id == t->mbox_lock_id) - t->mbox_lock_id = 0; + if (mbox->mbox_lock_id == t->read_lock_id) + t->read_lock_id = 0; mbox_unlock(mbox, mbox->mbox_lock_id); i_assert(mbox->mbox_lock_type == F_UNLCK); } @@ -60,11 +60,12 @@ mbox_prepare_resync(_mail); } if (mbox->mbox_lock_type == F_UNLCK) { + i_assert(t->read_lock_id == 0); sync_flags |= MBOX_SYNC_LOCK_READING; if (mbox_sync(mbox, sync_flags) < 0) return -1; - t->mbox_lock_id = mbox->mbox_lock_id; - i_assert(t->mbox_lock_id != 0); + t->read_lock_id = mbox_get_cur_lock_id(mbox); + i_assert(t->read_lock_id != 0); /* refresh index file after mbox has been locked to make sure we get only up-to-date mbox offsets. */ @@ -74,12 +75,12 @@ } i_assert(mbox->mbox_lock_type != F_UNLCK); - } else if (t->mbox_lock_id == 0) { + } else if (t->read_lock_id == 0) { /* file is already locked by another transaction, but we must keep it locked for the entire transaction, so increase the lock counter. */ if (mbox_lock(mbox, mbox->mbox_lock_type, - &t->mbox_lock_id) < 0) + &t->read_lock_id) < 0) i_unreached(); } diff -r 96716652b364 -r 9e4257061225 src/lib-storage/index/mbox/mbox-save.c --- a/src/lib-storage/index/mbox/mbox-save.c Fri Aug 31 15:25:20 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-save.c Sun Sep 02 16:48:25 2012 +0300 @@ -290,17 +290,8 @@ if (ctx->append_offset == (uoff_t)-1) { /* first appended mail in this transaction */ - if (mbox->mbox_lock_type != F_WRLCK) { - if (mbox->mbox_lock_type == F_RDLCK) { - /* FIXME: we shouldn't fail here. it's just - a locking issue that should be possible to - fix.. */ - mail_storage_set_error(storage, - MAIL_ERROR_NOTPOSSIBLE, - "Can't copy mails inside same mailbox"); - return -1; - } - if (mbox_lock(mbox, F_WRLCK, &t->mbox_lock_id) <= 0) + if (t->write_lock_id == 0) { + if (mbox_lock(mbox, F_WRLCK, &t->write_lock_id) <= 0) return -1; } diff -r 96716652b364 -r 9e4257061225 src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Fri Aug 31 15:25:20 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Sun Sep 02 16:48:25 2012 +0300 @@ -691,22 +691,33 @@ mbox_transaction_begin(struct mailbox *box, enum mailbox_transaction_flags flags) { + struct mbox_mailbox *mbox = (struct mbox_mailbox *)box; struct mbox_transaction_context *mt; + if ((flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0) + mbox->external_transactions++; + mt = i_new(struct mbox_transaction_context, 1); index_transaction_init(&mt->t, box, flags); return &mt->t; } -static void mbox_transaction_unlock(struct mailbox *box, unsigned int lock_id) +static void +mbox_transaction_unlock(struct mailbox *box, unsigned int lock_id1, + unsigned int lock_id2) { struct mbox_mailbox *mbox = (struct mbox_mailbox *)box; - if (lock_id != 0) - mbox_unlock(mbox, lock_id); + if (lock_id1 != 0) + mbox_unlock(mbox, lock_id1); + if (lock_id2 != 0) + mbox_unlock(mbox, lock_id2); if (mbox->mbox_global_lock_id == 0) { i_assert(mbox->box.transaction_count > 0 || + mbox->external_transactions > 0 || mbox->mbox_lock_type == F_UNLCK); + i_assert(mbox->external_transactions == 0 || + mbox->mbox_lock_type == F_WRLCK); } else { /* mailbox opened with MAILBOX_FLAG_KEEP_LOCKED */ i_assert(mbox->mbox_lock_type == F_WRLCK); @@ -720,11 +731,18 @@ struct mbox_transaction_context *mt = (struct mbox_transaction_context *)t; struct mailbox *box = t->box; - unsigned int lock_id = mt->mbox_lock_id; + struct mbox_mailbox *mbox = (struct mbox_mailbox *)box; + unsigned int read_lock_id = mt->read_lock_id; + unsigned int write_lock_id = mt->write_lock_id; int ret; + if ((t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0) { + i_assert(mbox->external_transactions > 0); + mbox->external_transactions--; + } + ret = index_transaction_commit(t, changes_r); - mbox_transaction_unlock(box, lock_id); + mbox_transaction_unlock(box, read_lock_id, write_lock_id); return ret; } @@ -734,10 +752,17 @@ struct mbox_transaction_context *mt = (struct mbox_transaction_context *)t; struct mailbox *box = t->box; - unsigned int lock_id = mt->mbox_lock_id; + struct mbox_mailbox *mbox = (struct mbox_mailbox *)box; + unsigned int read_lock_id = mt->read_lock_id; + unsigned int write_lock_id = mt->write_lock_id; + + if ((t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0) { + i_assert(mbox->external_transactions > 0); + mbox->external_transactions--; + } index_transaction_rollback(t); - mbox_transaction_unlock(box, lock_id); + mbox_transaction_unlock(box, read_lock_id, write_lock_id); } bool mbox_is_backend_readonly(struct mbox_mailbox *mbox) diff -r 96716652b364 -r 9e4257061225 src/lib-storage/index/mbox/mbox-storage.h --- a/src/lib-storage/index/mbox/mbox-storage.h Fri Aug 31 15:25:20 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.h Sun Sep 02 16:48:25 2012 +0300 @@ -46,6 +46,7 @@ unsigned int mbox_lock_id, mbox_global_lock_id; struct timeout *keep_lock_to; bool mbox_writeonly; + unsigned int external_transactions; uint32_t mbox_ext_idx, md5hdr_ext_idx; struct mbox_index_header mbox_hdr; @@ -69,7 +70,8 @@ struct mailbox_transaction_context t; union mail_index_transaction_module_context module_ctx; - unsigned int mbox_lock_id; + unsigned int read_lock_id; + unsigned int write_lock_id; }; extern struct mail_vfuncs mbox_mail_vfuncs; From dovecot at dovecot.org Sun Sep 2 17:19:04 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 17:19:04 +0300 Subject: dovecot-2.2: Moved mailbox_equals() to lib-storage. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e4d5c3ba305b changeset: 15009:e4d5c3ba305b user: Timo Sirainen date: Sun Sep 02 17:15:09 2012 +0300 description: Moved mailbox_equals() to lib-storage. diffstat: src/imap/imap-commands-util.c | 17 ----------------- src/imap/imap-commands-util.h | 4 ---- src/lib-storage/mail-storage.c | 17 +++++++++++++++++ src/lib-storage/mail-storage.h | 5 +++++ 4 files changed, 22 insertions(+), 21 deletions(-) diffs (83 lines): diff -r 9e4257061225 -r e4d5c3ba305b src/imap/imap-commands-util.c --- a/src/imap/imap-commands-util.c Sun Sep 02 16:48:25 2012 +0300 +++ b/src/imap/imap-commands-util.c Sun Sep 02 17:15:09 2012 +0300 @@ -313,23 +313,6 @@ return array_idx(dest, 0); } -bool mailbox_equals(const struct mailbox *box1, - const struct mail_namespace *ns2, const char *name2) -{ - struct mail_namespace *ns1 = mailbox_get_namespace(box1); - const char *name1; - - if (ns1 != ns2) - return FALSE; - - name1 = mailbox_get_vname(box1); - if (strcmp(name1, name2) == 0) - return TRUE; - - return strcasecmp(name1, "INBOX") == 0 && - strcasecmp(name2, "INBOX") == 0; -} - void msgset_generator_init(struct msgset_generator_context *ctx, string_t *str) { memset(ctx, 0, sizeof(*ctx)); diff -r 9e4257061225 -r e4d5c3ba305b src/imap/imap-commands-util.h --- a/src/imap/imap-commands-util.h Sun Sep 02 16:48:25 2012 +0300 +++ b/src/imap/imap-commands-util.h Sun Sep 02 17:15:09 2012 +0300 @@ -56,10 +56,6 @@ client_get_keyword_names(struct client *client, ARRAY_TYPE(keywords) *dest, const ARRAY_TYPE(keyword_indexes) *src); -bool mailbox_equals(const struct mailbox *box1, - const struct mail_namespace *ns2, - const char *name2) ATTR_PURE; - void msgset_generator_init(struct msgset_generator_context *ctx, string_t *str); void msgset_generator_next(struct msgset_generator_context *ctx, uint32_t uid); void msgset_generator_finish(struct msgset_generator_context *ctx); diff -r 9e4257061225 -r e4d5c3ba305b src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sun Sep 02 16:48:25 2012 +0300 +++ b/src/lib-storage/mail-storage.c Sun Sep 02 17:15:09 2012 +0300 @@ -1014,6 +1014,23 @@ pool_unref(&box->pool); } +bool mailbox_equals(const struct mailbox *box1, + const struct mail_namespace *ns2, const char *vname2) +{ + struct mail_namespace *ns1 = mailbox_get_namespace(box1); + const char *name1; + + if (ns1 != ns2) + return FALSE; + + name1 = mailbox_get_vname(box1); + if (strcmp(name1, vname2) == 0) + return TRUE; + + return strcasecmp(name1, "INBOX") == 0 && + strcasecmp(vname2, "INBOX") == 0; +} + int mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory) { diff -r 9e4257061225 -r e4d5c3ba305b src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Sun Sep 02 16:48:25 2012 +0300 +++ b/src/lib-storage/mail-storage.h Sun Sep 02 17:15:09 2012 +0300 @@ -412,6 +412,11 @@ /* Close and free the mailbox. */ void mailbox_free(struct mailbox **box); +/* Returns TRUE if box1 points to the same mailbox as ns2/vname2. */ +bool mailbox_equals(const struct mailbox *box1, + const struct mail_namespace *ns2, + const char *vname2) ATTR_PURE; + /* Create a mailbox. Returns failure if it already exists. Mailbox name is allowed to contain multiple new nonexistent hierarchy levels. If directory is TRUE, the mailbox should be created so that it can contain children. The From dovecot at dovecot.org Sun Sep 2 17:19:04 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 17:19:04 +0300 Subject: dovecot-2.2: imap-msgpart-url: Attempt to reuse selected mailbox... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dd1a04580289 changeset: 15010:dd1a04580289 user: Timo Sirainen date: Sun Sep 02 17:18:41 2012 +0300 description: imap-msgpart-url: Attempt to reuse selected mailbox instead of reallocating a new one. Besides giving slightly better performace, this also fixes CATENATE for mbox when source and destination mailboxes are the same. diffstat: src/lib-imap-storage/imap-msgpart-url.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diffs (57 lines): diff -r e4d5c3ba305b -r dd1a04580289 src/lib-imap-storage/imap-msgpart-url.c --- a/src/lib-imap-storage/imap-msgpart-url.c Sun Sep 02 17:15:09 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart-url.c Sun Sep 02 17:18:41 2012 +0300 @@ -18,6 +18,7 @@ uoff_t partial_offset, partial_size; struct mail_user *user; + struct mailbox *selected_box; struct mailbox *box; struct mailbox_transaction_context *trans; struct mail *mail; @@ -78,6 +79,7 @@ return 0; } *url_r = imap_msgpart_url_create(user, url); + (*url_r)->selected_box = selected_box; return 1; } @@ -108,11 +110,16 @@ } /* open mailbox */ - box = mailbox_alloc(ns->list, mpurl->mailbox, flags); + if (mpurl->selected_box != NULL && + mailbox_equals(mpurl->selected_box, ns, mpurl->mailbox)) + box = mpurl->selected_box; + else + box = mailbox_alloc(ns->list, mpurl->mailbox, flags); if (mailbox_open(box) < 0) { *error_r = mail_storage_get_last_error(mailbox_get_storage(box), &error_code); - mailbox_free(&box); + if (box != mpurl->selected_box) + mailbox_free(&box); return error_code == MAIL_ERROR_TEMP ? -1 : 0; } @@ -121,7 +128,8 @@ if (mpurl->uidvalidity > 0 && box_status.uidvalidity != mpurl->uidvalidity) { *error_r = "Invalid UIDVALIDITY"; - mailbox_free(&box); + if (box != mpurl->selected_box) + mailbox_free(&box); return 0; } mpurl->box = box; @@ -247,7 +255,7 @@ mail_free(&mpurl->mail); if (mpurl->trans != NULL) mailbox_transaction_rollback(&mpurl->trans); - if (mpurl->box != NULL) + if (mpurl->box != NULL && mpurl->box != mpurl->selected_box) mailbox_free(&mpurl->box); if (mpurl->section != NULL) i_free(mpurl->section); From dovecot at dovecot.org Sun Sep 2 18:16:26 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 18:16:26 +0300 Subject: dovecot-2.2: imap: MOVE didn't send EXPUNGE when delay-newmail w... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d3a9769dad2e changeset: 15011:d3a9769dad2e user: Timo Sirainen date: Sun Sep 02 18:16:06 2012 +0300 description: imap: MOVE didn't send EXPUNGE when delay-newmail workaround was enabled. diffstat: src/imap/cmd-copy.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r dd1a04580289 -r d3a9769dad2e src/imap/cmd-copy.c --- a/src/imap/cmd-copy.c Sun Sep 02 17:18:41 2012 +0300 +++ b/src/imap/cmd-copy.c Sun Sep 02 18:16:06 2012 +0300 @@ -175,6 +175,9 @@ sync_flags |= MAILBOX_SYNC_FLAG_FAST; imap_flags |= IMAP_SYNC_FLAG_SAFE; mailbox_free(&destbox); + } else if (move) { + sync_flags |= MAILBOX_SYNC_FLAG_EXPUNGE; + imap_flags |= IMAP_SYNC_FLAG_SAFE; } if (ret > 0) From dovecot at dovecot.org Sun Sep 2 19:53:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 19:53:03 +0300 Subject: dovecot-2.2: Renamed enum namespace_type to enum mail_namespace_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/368f3b2e3264 changeset: 15012:368f3b2e3264 user: Timo Sirainen date: Sun Sep 02 19:22:13 2012 +0300 description: Renamed enum namespace_type to enum mail_namespace_type diffstat: src/doveadm/doveadm-mail-altmove.c | 2 +- src/doveadm/doveadm-mail-index.c | 3 +-- src/doveadm/doveadm-mail.c | 6 +++--- src/doveadm/doveadm-mailbox-list-iter.c | 16 +++++++++------- src/imap/cmd-list.c | 3 +-- src/imap/cmd-namespace.c | 11 +++++++---- src/imap/cmd-notify.c | 2 +- src/lib-storage/index/maildir/maildir-storage.c | 2 +- src/lib-storage/index/shared/shared-storage.c | 2 +- src/lib-storage/list/mailbox-list-fs-iter.c | 2 +- src/lib-storage/list/mailbox-list-index.c | 2 +- src/lib-storage/list/mailbox-list-subscriptions.c | 2 +- src/lib-storage/mail-namespace.c | 12 ++++++------ src/lib-storage/mail-namespace.h | 13 ++++++++----- src/lib-storage/mail-storage.c | 4 ++-- src/lib-storage/mailbox-list-iter.c | 6 +++--- src/lib-storage/mailbox-list.c | 7 ++++--- src/lib-storage/mailbox-list.h | 4 ++-- src/plugins/acl/acl-mailbox-list.c | 6 +++--- src/plugins/acl/acl-shared-storage.c | 2 +- src/plugins/acl/doveadm-acl.c | 4 ++-- src/plugins/imap-acl/imap-acl-plugin.c | 8 +++++--- src/plugins/lazy-expunge/lazy-expunge-plugin.c | 2 +- src/plugins/quota/quota-maildir.c | 3 ++- src/plugins/virtual/virtual-config.c | 4 ++-- 25 files changed, 69 insertions(+), 59 deletions(-) diffs (truncated from 518 to 300 lines): diff -r d3a9769dad2e -r 368f3b2e3264 src/doveadm/doveadm-mail-altmove.c --- a/src/doveadm/doveadm-mail-altmove.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/doveadm/doveadm-mail-altmove.c Sun Sep 02 19:22:13 2012 +0300 @@ -90,7 +90,7 @@ /* make sure all private storages have been purged */ storages = array_get(&purged_storages, &count); for (ns = user->namespaces; ns != NULL; ns = ns->next) { - if (ns->type != NAMESPACE_PRIVATE) + if (ns->type != MAIL_NAMESPACE_TYPE_PRIVATE) continue; for (i = 0; i < count; i++) { diff -r d3a9769dad2e -r 368f3b2e3264 src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/doveadm/doveadm-mail-index.c Sun Sep 02 19:22:13 2012 +0300 @@ -165,8 +165,7 @@ MAILBOX_LIST_ITER_NO_AUTO_BOXES | MAILBOX_LIST_ITER_RETURN_NO_FLAGS | MAILBOX_LIST_ITER_STAR_WITHIN_NS; - const enum namespace_type ns_mask = - NAMESPACE_PRIVATE | NAMESPACE_SHARED | NAMESPACE_PUBLIC; + const enum mail_namespace_type ns_mask = MAIL_NAMESPACE_TYPE_MASK_ALL; struct mailbox_list_iterate_context *iter; const struct mailbox_info *info; unsigned int i; diff -r d3a9769dad2e -r 368f3b2e3264 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/doveadm/doveadm-mail.c Sun Sep 02 19:22:13 2012 +0300 @@ -108,7 +108,8 @@ int ret = 0; for (ns = user->namespaces; ns != NULL; ns = ns->next) { - if (ns->type != NAMESPACE_PRIVATE || ns->alias_for != NULL) + if (ns->type != MAIL_NAMESPACE_TYPE_PRIVATE || + ns->alias_for != NULL) continue; if (mail_storage_purge(ns->storage) < 0) { @@ -227,8 +228,7 @@ MAILBOX_LIST_ITER_RAW_LIST | MAILBOX_LIST_ITER_RETURN_NO_FLAGS | MAILBOX_LIST_ITER_STAR_WITHIN_NS; - const enum namespace_type ns_mask = - NAMESPACE_PRIVATE | NAMESPACE_SHARED | NAMESPACE_PUBLIC; + const enum mail_namespace_type ns_mask = MAIL_NAMESPACE_TYPE_MASK_ALL; struct mailbox_list_iterate_context *iter; const struct mailbox_info *info; int ret = 0; diff -r d3a9769dad2e -r 368f3b2e3264 src/doveadm/doveadm-mailbox-list-iter.c --- a/src/doveadm/doveadm-mailbox-list-iter.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/doveadm/doveadm-mailbox-list-iter.c Sun Sep 02 19:22:13 2012 +0300 @@ -71,7 +71,7 @@ struct mail_user *user, struct mail_search_args *search_args, enum mailbox_list_iter_flags iter_flags, - enum namespace_type ns_mask) + enum mail_namespace_type ns_mask) { static const char *all_pattern = "*"; struct doveadm_mailbox_list_iter *iter; @@ -88,12 +88,15 @@ if (array_count(&iter->patterns) == 0) { iter_flags |= MAILBOX_LIST_ITER_SKIP_ALIASES; - if (have_guid) - ns_mask |= NAMESPACE_SHARED | NAMESPACE_PUBLIC; + if (have_guid) { + ns_mask |= MAIL_NAMESPACE_TYPE_SHARED | + MAIL_NAMESPACE_TYPE_PUBLIC; + } array_append(&iter->patterns, &all_pattern, 1); } else if (have_wildcards) { iter_flags |= MAILBOX_LIST_ITER_STAR_WITHIN_NS; - ns_mask |= NAMESPACE_SHARED | NAMESPACE_PUBLIC; + ns_mask |= MAIL_NAMESPACE_TYPE_SHARED | + MAIL_NAMESPACE_TYPE_PUBLIC; } else { /* just return the listed mailboxes without actually iterating through. this also allows accessing mailboxes @@ -116,7 +119,7 @@ struct mail_search_args *search_args, enum mailbox_list_iter_flags iter_flags) { - enum namespace_type ns_mask = NAMESPACE_PRIVATE; + enum mail_namespace_type ns_mask = MAIL_NAMESPACE_TYPE_PRIVATE; return doveadm_mailbox_list_iter_init_nsmask(ctx, user, search_args, iter_flags, ns_mask); @@ -128,8 +131,7 @@ struct mail_search_args *search_args, enum mailbox_list_iter_flags iter_flags) { - enum namespace_type ns_mask = - NAMESPACE_PRIVATE | NAMESPACE_SHARED | NAMESPACE_PUBLIC; + enum mail_namespace_type ns_mask = MAIL_NAMESPACE_TYPE_MASK_ALL; struct doveadm_mailbox_list_iter *iter; iter = doveadm_mailbox_list_iter_init_nsmask(ctx, user, search_args, diff -r d3a9769dad2e -r 368f3b2e3264 src/imap/cmd-list.c --- a/src/imap/cmd-list.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/imap/cmd-list.c Sun Sep 02 19:22:13 2012 +0300 @@ -298,8 +298,7 @@ static void cmd_list_init(struct cmd_list_context *ctx, const char *const *patterns) { - enum namespace_type type_mask = - NAMESPACE_PRIVATE | NAMESPACE_SHARED | NAMESPACE_PUBLIC; + enum mail_namespace_type type_mask = MAIL_NAMESPACE_TYPE_MASK_ALL; ctx->list_iter = mailbox_list_iter_init_namespaces(ctx->user->namespaces, diff -r d3a9769dad2e -r 368f3b2e3264 src/imap/cmd-namespace.c --- a/src/imap/cmd-namespace.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/imap/cmd-namespace.c Sun Sep 02 19:22:13 2012 +0300 @@ -8,7 +8,7 @@ #include "mail-namespace.h" static void list_namespaces(struct mail_namespace *ns, - enum namespace_type type, string_t *str) + enum mail_namespace_type type, string_t *str) { string_t *mutf7_prefix = t_str_new(64); char ns_sep; @@ -55,11 +55,14 @@ str = t_str_new(256); str_append(str, "* NAMESPACE "); - list_namespaces(client->user->namespaces, NAMESPACE_PRIVATE, str); + list_namespaces(client->user->namespaces, + MAIL_NAMESPACE_TYPE_PRIVATE, str); str_append_c(str, ' '); - list_namespaces(client->user->namespaces, NAMESPACE_SHARED, str); + list_namespaces(client->user->namespaces, + MAIL_NAMESPACE_TYPE_SHARED, str); str_append_c(str, ' '); - list_namespaces(client->user->namespaces, NAMESPACE_PUBLIC, str); + list_namespaces(client->user->namespaces, + MAIL_NAMESPACE_TYPE_PUBLIC, str); client_send_line(client, str_c(str)); client_send_tagline(cmd, "OK Namespace completed."); diff -r d3a9769dad2e -r 368f3b2e3264 src/imap/cmd-notify.c --- a/src/imap/cmd-notify.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/imap/cmd-notify.c Sun Sep 02 19:22:13 2012 +0300 @@ -198,7 +198,7 @@ struct mail_namespace *ns; for (ns = ctx->client->user->namespaces; ns != NULL; ns = ns->next) { - if (ns->type == NAMESPACE_PRIVATE) { + if (ns->type == MAIL_NAMESPACE_TYPE_PRIVATE) { cmd_notify_add_mailbox(ctx, ns, "", IMAP_NOTIFY_TYPE_SUBTREE, events); } diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Sun Sep 02 19:22:13 2012 +0300 @@ -182,7 +182,7 @@ mail_storage_set_error(storage, MAIL_ERROR_NOTFOUND, "Mailbox was deleted while it was being created"); } else if (errno == EACCES) { - if (ns->type == NAMESPACE_SHARED) { + if (ns->type == MAIL_NAMESPACE_TYPE_SHARED) { /* shared namespace, don't log permission errors */ mail_storage_set_error(storage, MAIL_ERROR_PERM, MAIL_ERRSTR_NO_PERMISSION); diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/index/shared/shared-storage.c Sun Sep 02 19:22:13 2012 +0300 @@ -279,7 +279,7 @@ /* create the new namespace */ new_ns = i_new(struct mail_namespace, 1); new_ns->refcount = 1; - new_ns->type = NAMESPACE_SHARED; + new_ns->type = MAIL_NAMESPACE_TYPE_SHARED; new_ns->user = user; new_ns->prefix = i_strdup(str_c(prefix)); new_ns->owner = owner; diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Sun Sep 02 19:22:13 2012 +0300 @@ -393,7 +393,7 @@ INBOX's children). */ root = ""; } else if ((ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 && - ns->type == NAMESPACE_SHARED && + ns->type == MAIL_NAMESPACE_TYPE_SHARED && !ctx->ctx.list->mail_set->mail_shared_explicit_inbox && (prefix_vname[0] == '\0' || (strncmp(ns->prefix, prefix_vname, ns->prefix_len-1) == 0 && diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Sun Sep 02 19:22:13 2012 +0300 @@ -402,7 +402,7 @@ if (*dir == '\0') { /* in-memory indexes */ dir = NULL; - } else if (list->ns->type != NAMESPACE_PRIVATE) { + } else if (list->ns->type != MAIL_NAMESPACE_TYPE_PRIVATE) { /* don't create index files for shared/public mailboxes. their indexes may be shared between multiple users, each of which may have different ACLs */ diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Sun Sep 02 19:22:13 2012 +0300 @@ -56,7 +56,7 @@ /* When listing shared namespace's subscriptions, we need to autocreate all the visible child namespaces. their subscriptions are listed later. */ - if (ns != NULL && ns->type == NAMESPACE_SHARED && + if (ns != NULL && ns->type == MAIL_NAMESPACE_TYPE_SHARED && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) { /* we'll need to get the namespace autocreated. one easy way is to just ask if a mailbox name under diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/mail-namespace.c Sun Sep 02 19:22:13 2012 +0300 @@ -59,11 +59,11 @@ ns->user = user; if (strncmp(ns_set->type, "private", 7) == 0) { ns->owner = user; - ns->type = NAMESPACE_PRIVATE; + ns->type = MAIL_NAMESPACE_TYPE_PRIVATE; } else if (strncmp(ns_set->type, "shared", 6) == 0) - ns->type = NAMESPACE_SHARED; + ns->type = MAIL_NAMESPACE_TYPE_SHARED; else if (strncmp(ns_set->type, "public", 6) == 0) - ns->type = NAMESPACE_PUBLIC; + ns->type = MAIL_NAMESPACE_TYPE_PUBLIC; else { *error_r = t_strdup_printf("Unknown namespace type: %s", ns_set->type); @@ -111,7 +111,7 @@ ns->mail_set = mail_set; ns->prefix = i_strdup(ns_set->prefix); - if (ns->type == NAMESPACE_SHARED && + if (ns->type == MAIL_NAMESPACE_TYPE_SHARED && (strchr(ns->prefix, '%') != NULL || strchr(ns->set->location, '%') != NULL)) { /* dynamic shared namespace. the above check catches wrong @@ -342,7 +342,7 @@ ns = i_new(struct mail_namespace, 1); ns->refcount = 1; - ns->type = NAMESPACE_PRIVATE; + ns->type = MAIL_NAMESPACE_TYPE_PRIVATE; ns->flags = NAMESPACE_FLAG_INBOX_USER | NAMESPACE_FLAG_INBOX_ANY | NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_SUBSCRIPTIONS; ns->owner = user; @@ -593,7 +593,7 @@ struct mail_namespace *ns; ns = mail_namespace_find_mask(namespaces, mailbox, 0, 0); - if (ns != NULL && ns->type == NAMESPACE_SHARED && + if (ns != NULL && ns->type == MAIL_NAMESPACE_TYPE_SHARED && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) { /* see if we need to autocreate a namespace for shared user */ if (strchr(mailbox, mail_namespace_get_sep(ns)) != NULL) diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/mail-namespace.h --- a/src/lib-storage/mail-namespace.h Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/mail-namespace.h Sun Sep 02 19:22:13 2012 +0300 @@ -5,10 +5,13 @@ struct mail_storage_callbacks; -enum namespace_type { - NAMESPACE_PRIVATE = 0x01, - NAMESPACE_SHARED = 0x02, - NAMESPACE_PUBLIC = 0x04 +enum mail_namespace_type { + MAIL_NAMESPACE_TYPE_PRIVATE = 0x01, + MAIL_NAMESPACE_TYPE_SHARED = 0x02, + MAIL_NAMESPACE_TYPE_PUBLIC = 0x04 +#define MAIL_NAMESPACE_TYPE_MASK_ALL \ + (MAIL_NAMESPACE_TYPE_PRIVATE | MAIL_NAMESPACE_TYPE_SHARED | \ + MAIL_NAMESPACE_TYPE_PUBLIC) }; enum namespace_flags { @@ -46,7 +49,7 @@ struct mail_namespace *next; int refcount; - enum namespace_type type; + enum mail_namespace_type type; enum namespace_flags flags; char *prefix; diff -r d3a9769dad2e -r 368f3b2e3264 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sun Sep 02 18:16:06 2012 +0300 +++ b/src/lib-storage/mail-storage.c Sun Sep 02 19:22:13 2012 +0300 @@ -1230,8 +1230,8 @@ return -1; } if (src->list != dest->list && - (src->list->ns->type != NAMESPACE_PRIVATE || - dest->list->ns->type != NAMESPACE_PRIVATE)) { + (src->list->ns->type != MAIL_NAMESPACE_TYPE_PRIVATE || + dest->list->ns->type != MAIL_NAMESPACE_TYPE_PRIVATE)) { mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, From dovecot at dovecot.org Sun Sep 2 19:53:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 19:53:03 +0300 Subject: dovecot-2.2: Comment update. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fba15565c360 changeset: 15013:fba15565c360 user: Timo Sirainen date: Sun Sep 02 19:32:55 2012 +0300 description: Comment update. diffstat: src/lib-storage/mail-storage.h | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diffs (18 lines): diff -r 368f3b2e3264 -r fba15565c360 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Sun Sep 02 19:22:13 2012 +0300 +++ b/src/lib-storage/mail-storage.h Sun Sep 02 19:32:55 2012 +0300 @@ -459,11 +459,10 @@ const struct mailbox_settings * mailbox_settings_find(struct mail_user *user, const char *vname); -/* Returns name of given mailbox */ +/* Returns the (virtual) name of the given mailbox. */ +const char *mailbox_get_vname(const struct mailbox *box) ATTR_PURE; +/* Returns the backend name of given mailbox. */ const char *mailbox_get_name(const struct mailbox *box) ATTR_PURE; -/* Returns the virtual name of the given mailbox. This is the same as using - mail_namespace_get_vname(). */ -const char *mailbox_get_vname(const struct mailbox *box) ATTR_PURE; /* Returns TRUE if mailbox is read-only. */ bool mailbox_is_readonly(struct mailbox *box); From dovecot at dovecot.org Sun Sep 2 19:53:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 02 Sep 2012 19:53:03 +0300 Subject: dovecot-2.2: lib-storage: Added MAILBOX_METADATA_BACKEND_NAMESPACE Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5f313144c481 changeset: 15014:5f313144c481 user: Timo Sirainen date: Sun Sep 02 19:52:31 2012 +0300 description: lib-storage: Added MAILBOX_METADATA_BACKEND_NAMESPACE diffstat: src/lib-storage/index/imapc/imapc-storage.c | 97 +++++++++++++++++++++++++++++ src/lib-storage/index/imapc/imapc-storage.h | 9 ++ src/lib-storage/index/index-status.c | 7 +- src/lib-storage/mail-storage.h | 9 ++- 4 files changed, 120 insertions(+), 2 deletions(-) diffs (229 lines): diff -r fba15565c360 -r 5f313144c481 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 02 19:32:55 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Sep 02 19:52:31 2012 +0300 @@ -52,6 +52,8 @@ static void imapc_untagged_status(const struct imapc_untagged_reply *reply, struct imapc_storage *storage); +static void imapc_untagged_namespace(const struct imapc_untagged_reply *reply, + struct imapc_storage *storage); static bool imap_resp_text_code_parse(const char *str, enum mail_error *error_r) @@ -255,12 +257,15 @@ 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); 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); /* connect to imap server and get the hierarchy separator. */ if (imapc_storage_get_hierarchy_sep(storage, error_r) < 0) { imapc_client_deinit(&storage->client); @@ -600,6 +605,40 @@ } } +static void imapc_untagged_namespace(const struct imapc_untagged_reply *reply, + struct imapc_storage *storage) +{ + static enum mail_namespace_type ns_types[] = { + MAIL_NAMESPACE_TYPE_PRIVATE, + MAIL_NAMESPACE_TYPE_SHARED, + MAIL_NAMESPACE_TYPE_PUBLIC + }; + struct imapc_namespace *ns; + const struct imap_arg *list, *list2; + const char *prefix, *sep; + unsigned int i; + + array_clear(&storage->remote_namespaces); + for (i = 0; i < N_ELEMENTS(ns_types); i++) { + if (reply->args[i].type == IMAP_ARG_NIL) + continue; + if (!imap_arg_get_list(&reply->args[i], &list)) + break; + + for (; list->type != IMAP_ARG_EOL; list++) { + if (!imap_arg_get_list(list, &list2) || + !imap_arg_get_astring(&list2[0], &prefix) || + !imap_arg_get_nstring(&list2[1], &sep)) + break; + + ns = array_append_space(&storage->remote_namespaces); + ns->prefix = p_strdup(storage->storage.pool, prefix); + ns->separator = sep == NULL ? '\0' : sep[0]; + ns->type = ns_types[i]; + } + } +} + static void imapc_mailbox_get_selected_status(struct imapc_mailbox *mbox, enum mailbox_status_items items, struct mailbox_status *status_r) @@ -664,10 +703,58 @@ return sctx.ret; } +static int imapc_mailbox_get_namespaces(struct imapc_storage *storage) +{ + enum imapc_capability capa; + struct imapc_command *cmd; + struct imapc_simple_context sctx; + + if (storage->namespaces_requested) + return 0; + + capa = imapc_client_get_capabilities(storage->client); + if ((capa & IMAPC_CAPABILITY_NAMESPACE) == 0) { + /* NAMESPACE capability not supported */ + return 0; + } + + imapc_simple_context_init(&sctx, storage); + cmd = imapc_client_cmd(storage->client, + imapc_simple_callback, &sctx); + imapc_command_send(cmd, "NAMESPACE"); + imapc_simple_run(&sctx); + + if (sctx.ret < 0) + return -1; + storage->namespaces_requested = TRUE; + return 0; +} + +static const struct imapc_namespace * +imapc_namespace_find_mailbox(struct imapc_storage *storage, const char *name) +{ + const struct imapc_namespace *ns, *best_ns = NULL; + unsigned int best_len = -1U, len; + + array_foreach(&storage->remote_namespaces, ns) { + len = strlen(ns->prefix); + if (strncmp(ns->prefix, name, len) == 0) { + if (best_len > len) { + best_ns = ns; + best_len = len; + } + } + } + return best_ns; +} + static int imapc_mailbox_get_metadata(struct mailbox *box, enum mailbox_metadata_items items, struct mailbox_metadata *metadata_r) { + struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; + const struct imapc_namespace *ns; + if (index_mailbox_get_metadata(box, items, metadata_r) < 0) return -1; if ((items & MAILBOX_METADATA_GUID) != 0) { @@ -675,6 +762,16 @@ FIXME: if indexes are enabled, keep this there. */ mail_generate_guid_128_hash(box->name, metadata_r->guid); } + if ((items & MAILBOX_METADATA_BACKEND_NAMESPACE) != 0) { + if (imapc_mailbox_get_namespaces(mbox->storage) < 0) + return -1; + + ns = imapc_namespace_find_mailbox(mbox->storage, box->name); + if (ns != NULL) { + metadata_r->backend_ns_prefix = ns->prefix; + metadata_r->backend_ns_type = ns->type; + } + } return 0; } diff -r fba15565c360 -r 5f313144c481 src/lib-storage/index/imapc/imapc-storage.h --- a/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 02 19:32:55 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Sun Sep 02 19:52:31 2012 +0300 @@ -34,6 +34,12 @@ #define IMAPC_BOX_HAS_FEATURE(mbox, feature) \ (((mbox)->storage->set->parsed_features & feature) != 0) +struct imapc_namespace { + const char *prefix; + char separator; + enum mail_namespace_type type; +}; + struct imapc_storage { struct mail_storage storage; const struct imapc_settings *set; @@ -46,7 +52,10 @@ struct mailbox_status *cur_status; unsigned int reopen_count; + ARRAY(struct imapc_namespace) remote_namespaces; ARRAY(struct imapc_storage_event_callback) untagged_callbacks; + + unsigned int namespaces_requested:1; }; struct imapc_mail_cache { diff -r fba15565c360 -r 5f313144c481 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Sun Sep 02 19:32:55 2012 +0300 +++ b/src/lib-storage/index/index-status.c Sun Sep 02 19:52:31 2012 +0300 @@ -4,8 +4,8 @@ #include "array.h" #include "mail-cache.h" #include "mail-search-build.h" +#include "mail-index-modseq.h" #include "index-storage.h" -#include "mail-index-modseq.h" static void get_last_cached_seq(struct mailbox *box, uint32_t *last_cached_seq_r) @@ -365,5 +365,10 @@ get_metadata_cache_fields(box, metadata_r); if ((items & MAILBOX_METADATA_PRECACHE_FIELDS) != 0) get_metadata_precache_fields(box, metadata_r); + if ((items & MAILBOX_METADATA_BACKEND_NAMESPACE) != 0) { + metadata_r->backend_ns_prefix = ""; + metadata_r->backend_ns_type = + mailbox_list_get_namespace(box->list)->type; + } return 0; } diff -r fba15565c360 -r 5f313144c481 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Sun Sep 02 19:32:55 2012 +0300 +++ b/src/lib-storage/mail-storage.h Sun Sep 02 19:52:31 2012 +0300 @@ -8,6 +8,7 @@ #include "guid.h" #include "mail-types.h" #include "mail-error.h" +#include "mail-namespace.h" #include "mailbox-list.h" /* If some operation is taking long, call notify_ok every n seconds. */ @@ -81,7 +82,8 @@ MAILBOX_METADATA_GUID = 0x01, MAILBOX_METADATA_VIRTUAL_SIZE = 0x02, MAILBOX_METADATA_CACHE_FIELDS = 0x04, - MAILBOX_METADATA_PRECACHE_FIELDS = 0x08 + MAILBOX_METADATA_PRECACHE_FIELDS = 0x08, + MAILBOX_METADATA_BACKEND_NAMESPACE = 0x10 }; enum mailbox_search_result_flags { @@ -245,6 +247,11 @@ const ARRAY_TYPE(mailbox_cache_field) *cache_fields; /* Fields that should be precached */ enum mail_fetch_field precache_fields; + /* imapc backend returns this based on the remote NAMESPACE reply, + while currently other backends return "" and type the same as the + mailbox's real namespace type */ + const char *backend_ns_prefix; + enum mail_namespace_type backend_ns_type; }; struct mailbox_update { From pigeonhole at rename-it.nl Sun Sep 2 19:54:12 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 02 Sep 2012 18:54:12 +0200 Subject: dovecot-2.2-pigeonhole: Small compile fix. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/66adbdd89d5c changeset: 1659:66adbdd89d5c user: Stephan Bosch date: Sun Sep 02 18:54:01 2012 +0200 description: Small compile fix. diffstat: src/lib-sieve/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 061d4993b509 -r 66adbdd89d5c src/lib-sieve/Makefile.am --- a/src/lib-sieve/Makefile.am Wed Aug 29 19:35:17 2012 +0200 +++ b/src/lib-sieve/Makefile.am Sun Sep 02 18:54:01 2012 +0200 @@ -71,7 +71,7 @@ $(unfinished_plugins) libdovecot_sieve_la_DEPENDENCIES = $(plugins) $(LIBDOVECOT_LDA_DEPS) -libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT_LDA) +libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT) $(LIBDOVECOT_LDA) libdovecot_sieve_la_SOURCES = \ rfc2822.c \ From dovecot at dovecot.org Mon Sep 3 13:20:41 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 03 Sep 2012 13:20:41 +0300 Subject: dovecot-2.2: lib-imap-client: Added support for NAMESPACE capabi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dbaa7f5f82cd changeset: 15015:dbaa7f5f82cd user: Timo Sirainen date: Mon Sep 03 13:20:32 2012 +0300 description: lib-imap-client: Added support for NAMESPACE capability Required by previous imapc commit 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 5f313144c481 -r dbaa7f5f82cd src/lib-imap-client/imapc-client.c --- a/src/lib-imap-client/imapc-client.c Sun Sep 02 19:52:31 2012 +0300 +++ b/src/lib-imap-client/imapc-client.c Mon Sep 03 13:20:32 2012 +0300 @@ -22,6 +22,7 @@ { "STARTTLS", IMAPC_CAPABILITY_STARTTLS }, { "X-GM-EXT-1", IMAPC_CAPABILITY_X_GM_EXT_1 }, { "CONDSTORE", IMAPC_CAPABILITY_CONDSTORE }, + { "NAMESPACE", IMAPC_CAPABILITY_NAMESPACE }, { "IMAP4REV1", IMAPC_CAPABILITY_IMAP4REV1 }, { NULL, 0 } diff -r 5f313144c481 -r dbaa7f5f82cd src/lib-imap-client/imapc-client.h --- a/src/lib-imap-client/imapc-client.h Sun Sep 02 19:52:31 2012 +0300 +++ b/src/lib-imap-client/imapc-client.h Mon Sep 03 13:20:32 2012 +0300 @@ -18,6 +18,7 @@ IMAPC_CAPABILITY_STARTTLS = 0x40, IMAPC_CAPABILITY_X_GM_EXT_1 = 0x80, IMAPC_CAPABILITY_CONDSTORE = 0x100, + IMAPC_CAPABILITY_NAMESPACE = 0x200, IMAPC_CAPABILITY_IMAP4REV1 = 0x40000000 }; From dovecot at dovecot.org Tue Sep 4 14:56:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 14:56:24 +0300 Subject: dovecot-2.2: quota: Removed quota_ignore_save_errors setting and... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cf6f14ec3937 changeset: 15016:cf6f14ec3937 user: Timo Sirainen date: Tue Sep 04 14:56:13 2012 +0300 description: quota: Removed quota_ignore_save_errors setting and made it enabled always. diffstat: src/plugins/quota/quota-private.h | 1 - src/plugins/quota/quota-storage.c | 6 +++--- src/plugins/quota/quota.c | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diffs (46 lines): diff -r dbaa7f5f82cd -r cf6f14ec3937 src/plugins/quota/quota-private.h --- a/src/plugins/quota/quota-private.h Mon Sep 03 13:20:32 2012 +0300 +++ b/src/plugins/quota/quota-private.h Tue Sep 04 14:56:13 2012 +0300 @@ -25,7 +25,6 @@ uoff_t size, bool *too_large_r); const char *quota_exceeded_msg; - unsigned int ignore_save_errors:1; unsigned int debug:1; }; diff -r dbaa7f5f82cd -r cf6f14ec3937 src/plugins/quota/quota-storage.c --- a/src/plugins/quota/quota-storage.c Mon Sep 03 13:20:32 2012 +0300 +++ b/src/plugins/quota/quota-storage.c Tue Sep 04 14:56:13 2012 +0300 @@ -147,7 +147,8 @@ } else { mail_storage_set_critical(t->box->storage, "Internal quota calculation error"); - return qt->quota->set->ignore_save_errors ? 0 : -1; + /* allow saving anyway */ + return 0; } } @@ -213,8 +214,7 @@ } else if (ret < 0) { mail_storage_set_critical(t->box->storage, "Internal quota calculation error"); - if (!qt->quota->set->ignore_save_errors) - return -1; + /* allow saving anyway */ } } diff -r dbaa7f5f82cd -r cf6f14ec3937 src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Mon Sep 03 13:20:32 2012 +0300 +++ b/src/plugins/quota/quota.c Tue Sep 04 14:56:13 2012 +0300 @@ -195,8 +195,6 @@ quota_set->debug = user->mail_debug; quota_set->quota_exceeded_msg = mail_user_plugin_getenv(user, "quota_exceeded_message"); - quota_set->ignore_save_errors = - mail_user_plugin_getenv(user, "quota_ignore_save_errors") != NULL; if (quota_set->quota_exceeded_msg == NULL) quota_set->quota_exceeded_msg = DEFAULT_QUOTA_EXCEEDED_MSG; From dovecot at dovecot.org Tue Sep 4 15:03:28 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 15:03:28 +0300 Subject: dovecot-2.2: mailbox_list_index: Assert-crashfix when seeing a n... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1d2122f10411 changeset: 15017:1d2122f10411 user: Timo Sirainen date: Tue Sep 04 15:03:17 2012 +0300 description: mailbox_list_index: Assert-crashfix when seeing a new mailbox with children. diffstat: src/lib-storage/list/mailbox-list-index-sync.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diffs (59 lines): diff -r cf6f14ec3937 -r 1d2122f10411 src/lib-storage/list/mailbox-list-index-sync.c --- a/src/lib-storage/list/mailbox-list-index-sync.c Tue Sep 04 14:56:13 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index-sync.c Tue Sep 04 15:03:17 2012 +0300 @@ -256,6 +256,7 @@ struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list); struct mailbox_list_index_sync_context sync_ctx; struct mailbox_list_iterate_context *iter; + struct mail_index_view *view; const struct mail_index_header *hdr; const struct mailbox_info *info; const char *patterns[2]; @@ -269,19 +270,20 @@ sync_ctx.ilist = ilist; sync_ctx.sep[0] = mailbox_list_get_hierarchy_sep(list); if (mail_index_sync_begin(ilist->index, &sync_ctx.sync_ctx, - &sync_ctx.view, &sync_ctx.trans, + &view, &sync_ctx.trans, MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES) < 0) { mailbox_list_index_set_index_error(list); return -1; } + /* re-parse mailbox list now that it's refreshed and locked */ - if (mailbox_list_index_parse(ilist, sync_ctx.view, TRUE) < 0) { + if (mailbox_list_index_parse(ilist, view, TRUE) < 0) { mail_index_sync_rollback(&sync_ctx.sync_ctx); return -1; } orig_highest_name_id = ilist->highest_name_id; - hdr = mail_index_get_header(sync_ctx.view); + hdr = mail_index_get_header(view); sync_ctx.next_uid = hdr->next_uid; if (hdr->uid_validity == 0) { @@ -292,6 +294,7 @@ offsetof(struct mail_index_header, uid_validity), &uid_validity, sizeof(uid_validity), TRUE); } + sync_ctx.view = mail_index_transaction_open_updated_view(sync_ctx.trans); /* clear EXISTS-flags, so after sync we know what can be expunged */ mailbox_list_index_node_clear_exists(ilist->mailbox_tree); @@ -324,6 +327,7 @@ } if (ilist->module_ctx.super.iter_deinit(iter) < 0) { mail_index_sync_rollback(&sync_ctx.sync_ctx); + mail_index_view_close(&sync_ctx.view); ilist->syncing = FALSE; return -1; } @@ -345,6 +349,7 @@ &new_hdr.refresh_flag, sizeof(new_hdr.refresh_flag)); } ilist->syncing = FALSE; + mail_index_view_close(&sync_ctx.view); if (mail_index_sync_commit(&sync_ctx.sync_ctx) < 0) { mailbox_list_index_set_index_error(list); From dovecot at dovecot.org Tue Sep 4 16:23:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 16:23:48 +0300 Subject: dovecot-2.2: lib-storage: Moved mailbox-list-iter.c to list/ Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/72805776f84b changeset: 15018:72805776f84b user: Timo Sirainen date: Tue Sep 04 16:05:26 2012 +0300 description: lib-storage: Moved mailbox-list-iter.c to list/ diffstat: src/lib-storage/Makefile.am | 1 - src/lib-storage/list/Makefile.am | 1 + src/lib-storage/list/mailbox-list-iter.c | 1052 ++++++++++++++++++++++++++++++ src/lib-storage/mailbox-list-iter.c | 1052 ------------------------------ 4 files changed, 1053 insertions(+), 1053 deletions(-) diffs (truncated from 2134 to 300 lines): diff -r 1d2122f10411 -r 72805776f84b src/lib-storage/Makefile.am --- a/src/lib-storage/Makefile.am Tue Sep 04 15:03:17 2012 +0300 +++ b/src/lib-storage/Makefile.am Tue Sep 04 16:05:26 2012 +0300 @@ -42,7 +42,6 @@ mailbox-header.c \ mailbox-keywords.c \ mailbox-list.c \ - mailbox-list-iter.c \ mailbox-list-notify.c \ mailbox-search-result.c \ mailbox-tree.c \ diff -r 1d2122f10411 -r 72805776f84b src/lib-storage/list/Makefile.am --- a/src/lib-storage/list/Makefile.am Tue Sep 04 15:03:17 2012 +0300 +++ b/src/lib-storage/list/Makefile.am Tue Sep 04 16:05:26 2012 +0300 @@ -18,6 +18,7 @@ mailbox-list-index-notify.c \ mailbox-list-index-status.c \ mailbox-list-index-sync.c \ + mailbox-list-iter.c \ mailbox-list-maildir.c \ mailbox-list-maildir-iter.c \ mailbox-list-none.c \ diff -r 1d2122f10411 -r 72805776f84b src/lib-storage/list/mailbox-list-iter.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/list/mailbox-list-iter.c Tue Sep 04 16:05:26 2012 +0300 @@ -0,0 +1,1052 @@ +/* Copyright (c) 2006-2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "imap-match.h" +#include "mail-storage.h" +#include "mailbox-tree.h" +#include "mailbox-list-private.h" + +enum autocreate_match_result { + /* list contains the mailbox */ + AUTOCREATE_MATCH_RESULT_YES = 0x01, + /* list contains children of the mailbox */ + AUTOCREATE_MATCH_RESULT_CHILDREN = 0x02, + /* list contains parents of the mailbox */ + AUTOCREATE_MATCH_RESULT_PARENT = 0x04 +}; + +struct autocreate_box { + const char *name; + const struct mailbox_settings *set; + enum mailbox_info_flags flags; + bool child_listed; +}; + +ARRAY_DEFINE_TYPE(mailbox_settings, struct mailbox_settings *); +struct mailbox_list_autocreate_iterate_context { + unsigned int idx; + struct mailbox_info new_info; + ARRAY(struct autocreate_box) boxes; + ARRAY_TYPE(mailbox_settings) box_sets; + ARRAY_TYPE(mailbox_settings) all_ns_box_sets; +}; + +struct ns_list_iterate_context { + struct mailbox_list_iterate_context ctx; + struct mailbox_list_iterate_context *backend_ctx; + struct mail_namespace *namespaces, *cur_ns; + struct mailbox_list *error_list; + pool_t pool; + const char **patterns, **patterns_ns_match; + enum mail_namespace_type type_mask; + + struct mailbox_info ns_info; + struct mailbox_info inbox_info; + const struct mailbox_info *pending_backend_info; + + unsigned int cur_ns_prefix_sent:1; + unsigned int inbox_list:1; + unsigned int inbox_listed:1; +}; + +static bool ns_match_next(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, const char *pattern); +static int mailbox_list_match_anything(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, + const char *prefix); + +struct mailbox_list_iterate_context * +mailbox_list_iter_init(struct mailbox_list *list, const char *pattern, + enum mailbox_list_iter_flags flags) +{ + const char *patterns[2]; + + patterns[0] = pattern; + patterns[1] = NULL; + return mailbox_list_iter_init_multiple(list, patterns, flags); +} + +static int mailbox_list_subscriptions_refresh(struct mailbox_list *list) +{ + struct mail_namespace *ns = list->ns; + + if ((ns->flags & NAMESPACE_FLAG_SUBSCRIPTIONS) == 0) { + /* no subscriptions in this namespace. find where they are. */ + ns = mail_namespace_find_subscribable(ns->user->namespaces, + ns->prefix); + if (ns == NULL) { + /* no subscriptions. avoid crashes by initializing + a subscriptions tree. */ + if (list->subscriptions == NULL) { + char sep = mail_namespace_get_sep(list->ns); + list->subscriptions = mailbox_tree_init(sep); + } + return 0; + } + } + return ns->list->v.subscriptions_refresh(ns->list, list); +} + +static struct mailbox_settings * +mailbox_settings_add_ns_prefix(pool_t pool, struct mail_namespace *ns, + struct mailbox_settings *in_set) +{ + struct mailbox_settings *out_set; + + if (ns->prefix_len == 0 || strcasecmp(in_set->name, "INBOX") == 0) + return in_set; + + out_set = p_new(pool, struct mailbox_settings, 1); + *out_set = *in_set; + if (*in_set->name == '\0') { + /* namespace prefix itself */ + out_set->name = p_strndup(pool, ns->prefix, ns->prefix_len-1); + } else { + out_set->name = + p_strconcat(pool, ns->prefix, in_set->name, NULL); + } + return out_set; +} + +static void +mailbox_list_iter_init_autocreate(struct mailbox_list_iterate_context *ctx) +{ + struct mail_namespace *ns = ctx->list->ns; + struct mailbox_list_autocreate_iterate_context *actx; + struct mailbox_settings *const *box_sets, *set; + struct autocreate_box *autobox; + unsigned int i, count; + + if (!array_is_created(&ns->set->mailboxes)) + return; + box_sets = array_get(&ns->set->mailboxes, &count); + if (count == 0) + return; + + actx = p_new(ctx->pool, struct mailbox_list_autocreate_iterate_context, 1); + ctx->autocreate_ctx = actx; + + /* build the list of mailboxes we need to consider as existing */ + p_array_init(&actx->boxes, ctx->pool, 16); + p_array_init(&actx->box_sets, ctx->pool, 16); + p_array_init(&actx->all_ns_box_sets, ctx->pool, 16); + for (i = 0; i < count; i++) { + if (strcmp(box_sets[i]->autocreate, MAILBOX_SET_AUTO_NO) == 0) + continue; + + set = mailbox_settings_add_ns_prefix(ctx->pool, + ns, box_sets[i]); + + /* autocreate mailbox belongs to listed namespace */ + array_append(&actx->all_ns_box_sets, &set, 1); + if ((ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0 || + strcmp(set->autocreate, MAILBOX_SET_AUTO_SUBSCRIBE) == 0) { + array_append(&actx->box_sets, &set, 1); + autobox = array_append_space(&actx->boxes); + autobox->name = set->name; + autobox->set = set; + } + } +} + +struct mailbox_list_iterate_context * +mailbox_list_iter_init_multiple(struct mailbox_list *list, + const char *const *patterns, + enum mailbox_list_iter_flags flags) +{ + struct mailbox_list_iterate_context *ctx; + int ret = 0; + + i_assert(*patterns != NULL); + + if ((flags & (MAILBOX_LIST_ITER_SELECT_SUBSCRIBED | + MAILBOX_LIST_ITER_RETURN_SUBSCRIBED)) != 0) + ret = mailbox_list_subscriptions_refresh(list); + + ctx = list->v.iter_init(list, patterns, flags); + if (ret < 0) + ctx->failed = TRUE; + else if ((flags & MAILBOX_LIST_ITER_NO_AUTO_BOXES) == 0) + mailbox_list_iter_init_autocreate(ctx); + return ctx; +} + +static bool +ns_match_simple(struct ns_list_iterate_context *ctx, struct mail_namespace *ns) +{ + if ((ctx->type_mask & ns->type) == 0) + return FALSE; + + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SKIP_ALIASES) != 0) { + if (ns->alias_for != NULL) + return FALSE; + } + return TRUE; +} + +static bool +ns_is_match_within_ns(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, const char *prefix_without_sep, + const char *pattern, enum imap_match_result result) +{ + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_STAR_WITHIN_NS) == 0) { + switch (result) { + case IMAP_MATCH_YES: + case IMAP_MATCH_CHILDREN: + return TRUE; + case IMAP_MATCH_NO: + case IMAP_MATCH_PARENT: + break; + } + return FALSE; + } + + switch (result) { + case IMAP_MATCH_YES: + /* allow matching prefix only when it's done without + wildcards */ + if (strcmp(prefix_without_sep, pattern) == 0) + return TRUE; + break; + case IMAP_MATCH_CHILDREN: { + /* allow this only if there isn't another namespace + with longer prefix that matches this pattern + (namespaces are sorted by prefix length) */ + struct mail_namespace *tmp; + + T_BEGIN { + for (tmp = ns->next; tmp != NULL; tmp = tmp->next) { + if (ns_match_simple(ctx, tmp) && + ns_match_next(ctx, tmp, pattern)) + break; + } + } T_END; + if (tmp == NULL) + return TRUE; + break; + } + case IMAP_MATCH_NO: + case IMAP_MATCH_PARENT: + break; + } + return FALSE; +} + +static bool ns_match_next(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, const char *pattern) +{ + struct imap_match_glob *glob; + enum imap_match_result result; + const char *prefix_without_sep; + unsigned int len; + + len = ns->prefix_len; + if (len > 0 && ns->prefix[len-1] == mail_namespace_get_sep(ns)) + len--; + + if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) == 0) { + /* non-listable namespace matches only with exact prefix */ + if (strncmp(ns->prefix, pattern, ns->prefix_len) != 0) + return FALSE; + } + + prefix_without_sep = t_strndup(ns->prefix, len); + if (*prefix_without_sep == '\0') + result = IMAP_MATCH_CHILDREN; + else { + glob = imap_match_init(pool_datastack_create(), pattern, + TRUE, mail_namespace_get_sep(ns)); + result = imap_match(glob, prefix_without_sep); + } + + return ns_is_match_within_ns(ctx, ns, prefix_without_sep, + pattern, result); +} + +static bool +mailbox_list_ns_match_patterns(struct ns_list_iterate_context *ctx) +{ + struct mail_namespace *ns = ctx->cur_ns; + unsigned int i; + + if (!ns_match_simple(ctx, ns)) From dovecot at dovecot.org Tue Sep 4 16:23:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 16:23:48 +0300 Subject: dovecot-2.2: LIST: Fixes to handling subscriptions Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/46d972c228c0 changeset: 15019:46d972c228c0 user: Timo Sirainen date: Tue Sep 04 16:06:29 2012 +0300 description: LIST: Fixes to handling subscriptions diffstat: src/imap/cmd-list.c | 9 ++++--- src/lib-storage/list/mailbox-list-iter.c | 36 +++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diffs (114 lines): diff -r 72805776f84b -r 46d972c228c0 src/imap/cmd-list.c --- a/src/imap/cmd-list.c Tue Sep 04 16:05:26 2012 +0300 +++ b/src/imap/cmd-list.c Tue Sep 04 16:06:29 2012 +0300 @@ -41,14 +41,12 @@ if ((ctx->list_flags & MAILBOX_LIST_ITER_RETURN_CHILDREN) == 0) flags &= ~(MAILBOX_CHILDREN|MAILBOX_NOCHILDREN); - if ((ctx->list_flags & MAILBOX_LIST_ITER_RETURN_SUBSCRIBED) == 0) - flags &= ~MAILBOX_SUBSCRIBED; - if ((flags & MAILBOX_CHILD_SUBSCRIBED) != 0 && (flags & MAILBOX_SUBSCRIBED) == 0 && !ctx->used_listext) { /* LSUB uses \Noselect for this */ flags |= MAILBOX_NOSELECT; - } + } else if ((ctx->list_flags & MAILBOX_LIST_ITER_RETURN_SUBSCRIBED) == 0) + flags &= ~MAILBOX_SUBSCRIBED; imap_mailbox_flags2str(str, flags); if ((ctx->list_flags & MAILBOX_LIST_ITER_RETURN_SPECIALUSE) != 0 && @@ -69,6 +67,9 @@ if ((flags & MAILBOX_CHILD_SUBSCRIBED) != 0 && (ctx->list_flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0) str_append(str, " (CHILDINFO (\"SUBSCRIBED\"))"); + if ((flags & MAILBOX_CHILD_SPECIALUSE) != 0 && + (ctx->list_flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0) + str_append(str, " (CHILDINFO (\"SPECIAL-USE\"))"); } static bool diff -r 72805776f84b -r 46d972c228c0 src/lib-storage/list/mailbox-list-iter.c --- a/src/lib-storage/list/mailbox-list-iter.c Tue Sep 04 16:05:26 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-iter.c Tue Sep 04 16:06:29 2012 +0300 @@ -5,6 +5,7 @@ #include "imap-match.h" #include "mail-storage.h" #include "mailbox-tree.h" +#include "mailbox-list-subscriptions.h" #include "mailbox-list-private.h" enum autocreate_match_result { @@ -67,7 +68,7 @@ return mailbox_list_iter_init_multiple(list, patterns, flags); } -static int mailbox_list_subscriptions_refresh(struct mailbox_list *list) +static int mailbox_list_iter_subscriptions_refresh(struct mailbox_list *list) { struct mail_namespace *ns = list->ns; @@ -162,7 +163,7 @@ if ((flags & (MAILBOX_LIST_ITER_SELECT_SUBSCRIBED | MAILBOX_LIST_ITER_RETURN_SUBSCRIBED)) != 0) - ret = mailbox_list_subscriptions_refresh(list); + ret = mailbox_list_iter_subscriptions_refresh(list); ctx = list->v.iter_init(list, patterns, flags); if (ret < 0) @@ -407,9 +408,24 @@ } static bool +mailbox_ns_prefix_check_selection_criteria(struct ns_list_iterate_context *ctx) +{ + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) { + if ((ctx->ns_info.flags & MAILBOX_SUBSCRIBED) != 0) + return TRUE; + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0 && + (ctx->ns_info.flags & MAILBOX_CHILD_SUBSCRIBED) != 0) + return TRUE; + return FALSE; + } + return TRUE; +} + +static bool mailbox_list_ns_prefix_return(struct ns_list_iterate_context *ctx, struct mail_namespace *ns, bool has_children) { + struct mail_namespace *subs_ns; struct mailbox *box; enum mailbox_existence existence; int ret; @@ -435,6 +451,19 @@ ctx->ns_info.flags |= ctx->inbox_info.flags | MAILBOX_SELECT; } + if ((ctx->ctx.flags & (MAILBOX_LIST_ITER_RETURN_SUBSCRIBED | + MAILBOX_LIST_ITER_SELECT_SUBSCRIBED)) != 0) { + subs_ns = mail_namespace_find_subscribable(ctx->namespaces, + ns->prefix); + if (subs_ns != NULL) { + mailbox_list_set_subscription_flags(subs_ns->list, + ctx->ns_info.vname, + &ctx->ns_info.flags); + } + } + if (!mailbox_ns_prefix_check_selection_criteria(ctx)) + return FALSE; + /* see if the namespace has children */ if (has_children) ctx->ns_info.flags |= MAILBOX_CHILDREN; @@ -878,7 +907,8 @@ p = strrchr(actx->new_info.vname, sep); i_assert(p != NULL); actx->new_info.vname = - t_strdup_until(actx->new_info.vname, p); + p_strdup_until(ctx->pool, + actx->new_info.vname, p); match = imap_match(ctx->glob, actx->new_info.vname); } while (match != IMAP_MATCH_YES); return TRUE; From dovecot at dovecot.org Tue Sep 4 16:23:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 16:23:48 +0300 Subject: dovecot-2.2: imap: Fixed LIST (SPECIAL-USE RECURSIVEMATCH) to ac... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/169385092bae changeset: 15020:169385092bae user: Timo Sirainen date: Tue Sep 04 16:22:14 2012 +0300 description: imap: Fixed LIST (SPECIAL-USE RECURSIVEMATCH) to actually return CHILDINFOs. diffstat: src/lib-storage/list/mailbox-list-iter.c | 9 +++++++++ src/lib-storage/mail-namespace.c | 16 ++++++++++++++++ src/lib-storage/mail-namespace.h | 1 + src/lib-storage/mailbox-list.h | 1 + 4 files changed, 27 insertions(+), 0 deletions(-) diffs (81 lines): diff -r 46d972c228c0 -r 169385092bae src/lib-storage/list/mailbox-list-iter.c --- a/src/lib-storage/list/mailbox-list-iter.c Tue Sep 04 16:06:29 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-iter.c Tue Sep 04 16:22:14 2012 +0300 @@ -444,6 +444,8 @@ ctx->ns_info.ns = ns; ctx->ns_info.vname = p_strndup(ctx->pool, ns->prefix, ns->prefix_len-1); + if (ns->special_use_mailboxes) + ctx->ns_info.flags |= MAILBOX_CHILD_SPECIALUSE; if (strcasecmp(ctx->ns_info.vname, "INBOX") == 0) { i_assert(!ctx->inbox_listed); @@ -972,6 +974,13 @@ special_use_selection(struct mailbox_list_iterate_context *ctx, const struct mailbox_info *info) { + if ((ctx->flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0 && + (ctx->flags & MAILBOX_LIST_ITER_SELECT_SPECIALUSE) != 0) { + /* LIST (SPECIAL-USE RECURSIVEMATCH) used. for now we support + this only for namespace prefixes */ + if ((info->flags & MAILBOX_CHILD_SPECIALUSE) != 0) + return TRUE; + } return (ctx->flags & MAILBOX_LIST_ITER_SELECT_SPECIALUSE) == 0 || info->special_use != NULL; } diff -r 46d972c228c0 -r 169385092bae src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Tue Sep 04 16:06:29 2012 +0300 +++ b/src/lib-storage/mail-namespace.c Tue Sep 04 16:22:14 2012 +0300 @@ -44,6 +44,21 @@ i_free(ns); } +static bool +namespace_has_special_use_mailboxes(struct mail_namespace_settings *ns_set) +{ + struct mailbox_settings *const *box_set; + + if (!array_is_created(&ns_set->mailboxes)) + return FALSE; + + array_foreach(&ns_set->mailboxes, box_set) { + if ((*box_set)->special_use[0] != '\0') + return TRUE; + } + return FALSE; +} + static int namespace_add(struct mail_user *user, struct mail_namespace_settings *ns_set, @@ -110,6 +125,7 @@ ns->unexpanded_set = unexpanded_ns_set; ns->mail_set = mail_set; ns->prefix = i_strdup(ns_set->prefix); + ns->special_use_mailboxes = namespace_has_special_use_mailboxes(ns_set); if (ns->type == MAIL_NAMESPACE_TYPE_SHARED && (strchr(ns->prefix, '%') != NULL || diff -r 46d972c228c0 -r 169385092bae src/lib-storage/mail-namespace.h --- a/src/lib-storage/mail-namespace.h Tue Sep 04 16:06:29 2012 +0300 +++ b/src/lib-storage/mail-namespace.h Tue Sep 04 16:22:14 2012 +0300 @@ -73,6 +73,7 @@ struct mail_namespace_settings *set, *unexpanded_set; const struct mail_storage_settings *mail_set; + unsigned int special_use_mailboxes:1; unsigned int destroyed:1; }; diff -r 46d972c228c0 -r 169385092bae src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Tue Sep 04 16:06:29 2012 +0300 +++ b/src/lib-storage/mailbox-list.h Tue Sep 04 16:22:14 2012 +0300 @@ -47,6 +47,7 @@ MAILBOX_UNMARKED = 0x040, MAILBOX_SUBSCRIBED = 0x080, MAILBOX_CHILD_SUBSCRIBED = 0x100, + MAILBOX_CHILD_SPECIALUSE = 0x200, /* Internally used by lib-storage */ MAILBOX_SELECT = 0x20000000, From dovecot at dovecot.org Tue Sep 4 16:23:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 16:23:48 +0300 Subject: dovecot-2.2: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5420e5c93bda changeset: 15021:5420e5c93bda user: Timo Sirainen date: Tue Sep 04 16:23:12 2012 +0300 description: Minor code cleanup diffstat: src/lib-mail/istream-attachment-extractor.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diffs (51 lines): diff -r 169385092bae -r 5420e5c93bda src/lib-mail/istream-attachment-extractor.c --- a/src/lib-mail/istream-attachment-extractor.c Tue Sep 04 16:22:14 2012 +0300 +++ b/src/lib-mail/istream-attachment-extractor.c Tue Sep 04 16:23:12 2012 +0300 @@ -549,8 +549,7 @@ return ret; } -static int -i_stream_attachment_read_next(struct attachment_istream *astream, bool *retry_r) +static int astream_read_next(struct attachment_istream *astream, bool *retry_r) { struct istream_private *stream = &astream->istream; struct message_block block; @@ -612,7 +611,8 @@ return new_size - old_size; } -static ssize_t i_stream_attachment_read(struct istream_private *stream) +static ssize_t +i_stream_attachment_extractor_read(struct istream_private *stream) { struct attachment_istream *astream = (struct attachment_istream *)stream; @@ -620,14 +620,14 @@ ssize_t ret; do { - ret = i_stream_attachment_read_next(astream, &retry); + ret = astream_read_next(astream, &retry); } while (retry && astream->set.drain_parent_input); astream->retry_read = retry; return ret; } -static void i_stream_attachment_close(struct iostream_private *stream) +static void i_stream_attachment_extractor_close(struct iostream_private *stream) { struct attachment_istream *astream = (struct attachment_istream *)stream; @@ -666,8 +666,8 @@ astream->istream.max_buffer_size = input->real_stream->max_buffer_size; - astream->istream.read = i_stream_attachment_read; - astream->istream.iostream.close = i_stream_attachment_close; + astream->istream.read = i_stream_attachment_extractor_read; + astream->istream.iostream.close = i_stream_attachment_extractor_close; astream->istream.istream.readable_fd = FALSE; astream->istream.istream.blocking = input->blocking; From dovecot at dovecot.org Tue Sep 4 16:38:01 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 16:38:01 +0300 Subject: dovecot-2.2: mailbox_list_index=yes: Fixed listing nonexistent s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e3c96c74eec8 changeset: 15022:e3c96c74eec8 user: Timo Sirainen date: Tue Sep 04 16:37:55 2012 +0300 description: mailbox_list_index=yes: Fixed listing nonexistent subscribed mailboxes diffstat: src/lib-storage/list/mailbox-list-index-iter.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 5420e5c93bda -r e3c96c74eec8 src/lib-storage/list/mailbox-list-index-iter.c --- a/src/lib-storage/list/mailbox-list-index-iter.c Tue Sep 04 16:23:12 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index-iter.c Tue Sep 04 16:37:55 2012 +0300 @@ -27,7 +27,11 @@ ctx->sep = ns_sep; ctx->info_pool = pool_alloconly_create("mailbox list index iter info", 128); + /* for now we don't use indexes when listing subscriptions, because + it needs to list also the nonexistent subscribed mailboxes, which + don't exist in the index. */ if ((flags & MAILBOX_LIST_ITER_RAW_LIST) != 0 || + (flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0 || mailbox_list_index_refresh(ctx->ctx.list) < 0) { /* no indexing */ ctx->backend_ctx = ilist->module_ctx.super. From dovecot at dovecot.org Tue Sep 4 17:14:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 17:14:07 +0300 Subject: dovecot-2.2: lib-storage: Added mail_storage_service_user_get_ma... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a76f010eef4b changeset: 15023:a76f010eef4b user: Timo Sirainen date: Tue Sep 04 17:12:21 2012 +0300 description: lib-storage: Added mail_storage_service_user_get_mail_set() diffstat: src/lib-storage/mail-storage-service.c | 8 ++++++++ src/lib-storage/mail-storage-service.h | 2 ++ 2 files changed, 10 insertions(+), 0 deletions(-) diffs (30 lines): diff -r e3c96c74eec8 -r a76f010eef4b src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Sep 04 16:37:55 2012 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Sep 04 17:12:21 2012 +0300 @@ -1250,6 +1250,14 @@ MASTER_SERVICE_INTERNAL_SET_PARSERS; } +const struct mail_storage_settings * +mail_storage_service_user_get_mail_set(struct mail_storage_service_user *user) +{ + return mail_user_set_get_driver_settings( + user->user_info, user->user_set, + MAIL_STORAGE_SET_DRIVER_NAME); +} + const struct mail_storage_service_input * mail_storage_service_user_get_input(struct mail_storage_service_user *user) { diff -r e3c96c74eec8 -r a76f010eef4b src/lib-storage/mail-storage-service.h --- a/src/lib-storage/mail-storage-service.h Tue Sep 04 16:37:55 2012 +0300 +++ b/src/lib-storage/mail-storage-service.h Tue Sep 04 17:12:21 2012 +0300 @@ -106,6 +106,8 @@ /* Return the settings pointed to by set_root parameter in _init(). The settings contain all the changes done by userdb lookups. */ void **mail_storage_service_user_get_set(struct mail_storage_service_user *user); +const struct mail_storage_settings * +mail_storage_service_user_get_mail_set(struct mail_storage_service_user *user); const struct mail_storage_service_input * mail_storage_service_user_get_input(struct mail_storage_service_user *user); struct setting_parser_context * From dovecot at dovecot.org Tue Sep 4 17:14:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 17:14:07 +0300 Subject: dovecot-2.2: lmtp proxying: Don't auto-set mail_max_lock_timeout... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c6ae1551ab40 changeset: 15024:c6ae1551ab40 user: Timo Sirainen date: Tue Sep 04 17:13:47 2012 +0300 description: lmtp proxying: Don't auto-set mail_max_lock_timeout higher than it was. diffstat: src/lmtp/commands.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diffs (24 lines): diff -r a76f010eef4b -r c6ae1551ab40 src/lmtp/commands.c --- a/src/lmtp/commands.c Tue Sep 04 17:12:21 2012 +0300 +++ b/src/lmtp/commands.c Tue Sep 04 17:13:47 2012 +0300 @@ -574,6 +574,7 @@ struct mail_deliver_context dctx; struct mail_storage *storage; const struct mail_storage_service_input *input; + const struct mail_storage_settings *mail_set; struct mail_namespace *ns; struct setting_parser_context *set_parser; void **sets; @@ -584,8 +585,11 @@ input = mail_storage_service_user_get_input(rcpt->service_user); username = t_strdup(input->username); + mail_set = mail_storage_service_user_get_mail_set(rcpt->service_user); set_parser = mail_storage_service_user_get_settings_parser(rcpt->service_user); - if (client->proxy_timeout_secs > 0) { + if (client->proxy_timeout_secs > 0 && + (mail_set->mail_max_lock_timeout == 0 || + mail_set->mail_max_lock_timeout > client->proxy_timeout_secs)) { /* set lock timeout waits to be less than when proxy has advertised that it's going to timeout the connection. this avoids duplicate deliveries in case the delivery From dovecot at dovecot.org Tue Sep 4 17:19:21 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 17:19:21 +0300 Subject: dovecot-2.2: lib-storage: Added "disabled" setting for namespaces. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/57c964513a46 changeset: 15025:57c964513a46 user: Timo Sirainen date: Tue Sep 04 17:18:08 2012 +0300 description: lib-storage: Added "disabled" setting for namespaces. diffstat: src/lib-storage/mail-namespace.c | 3 +++ src/lib-storage/mail-storage-settings.c | 2 ++ src/lib-storage/mail-storage-settings.h | 1 + 3 files changed, 6 insertions(+), 0 deletions(-) diffs (43 lines): diff -r c6ae1551ab40 -r 57c964513a46 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Tue Sep 04 17:13:47 2012 +0300 +++ b/src/lib-storage/mail-namespace.c Tue Sep 04 17:18:08 2012 +0300 @@ -309,6 +309,9 @@ count = 0; } for (i = 0; i < count; i++) { + if (ns_set[i]->disabled) + continue; + if (namespace_add(user, ns_set[i], unexpanded_ns_set[i], mail_set, ns_p, error_r) < 0) { if (!ns_set[i]->ignore_on_failure) diff -r c6ae1551ab40 -r 57c964513a46 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Tue Sep 04 17:13:47 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.c Tue Sep 04 17:18:08 2012 +0300 @@ -154,6 +154,7 @@ DEF(SET_ENUM, list), DEF(SET_BOOL, subscriptions), DEF(SET_BOOL, ignore_on_failure), + DEF(SET_BOOL, disabled), DEFLIST_UNIQUE(mailboxes, "mailbox", &mailbox_setting_parser_info), @@ -173,6 +174,7 @@ .list = "yes:no:children", .subscriptions = TRUE, .ignore_on_failure = FALSE, + .disabled = FALSE, .mailboxes = ARRAY_INIT }; diff -r c6ae1551ab40 -r 57c964513a46 src/lib-storage/mail-storage-settings.h --- a/src/lib-storage/mail-storage-settings.h Tue Sep 04 17:13:47 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.h Tue Sep 04 17:18:08 2012 +0300 @@ -54,6 +54,7 @@ const char *list; bool subscriptions; bool ignore_on_failure; + bool disabled; ARRAY(struct mailbox_settings *) mailboxes; struct mail_user_settings *user_set; From dovecot at dovecot.org Tue Sep 4 17:19:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 17:19:48 +0300 Subject: dovecot-2.1: lib-storage: Added "disabled" setting for namespaces. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0ee2f712b489 changeset: 14695:0ee2f712b489 user: Timo Sirainen date: Tue Sep 04 17:18:08 2012 +0300 description: lib-storage: Added "disabled" setting for namespaces. diffstat: src/lib-storage/mail-namespace.c | 3 +++ src/lib-storage/mail-storage-settings.c | 2 ++ src/lib-storage/mail-storage-settings.h | 1 + 3 files changed, 6 insertions(+), 0 deletions(-) diffs (43 lines): diff -r d079d72abb79 -r 0ee2f712b489 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Sun Sep 02 16:06:45 2012 +0300 +++ b/src/lib-storage/mail-namespace.c Tue Sep 04 17:18:08 2012 +0300 @@ -293,6 +293,9 @@ count = 0; } for (i = 0; i < count; i++) { + if (ns_set[i]->disabled) + continue; + if (namespace_add(user, ns_set[i], unexpanded_ns_set[i], mail_set, ns_p, error_r) < 0) { if (!ns_set[i]->ignore_on_failure) diff -r d079d72abb79 -r 0ee2f712b489 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Sun Sep 02 16:06:45 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.c Tue Sep 04 17:18:08 2012 +0300 @@ -154,6 +154,7 @@ DEF(SET_ENUM, list), DEF(SET_BOOL, subscriptions), DEF(SET_BOOL, ignore_on_failure), + DEF(SET_BOOL, disabled), DEFLIST_UNIQUE(mailboxes, "mailbox", &mailbox_setting_parser_info), @@ -173,6 +174,7 @@ .list = "yes:no:children", .subscriptions = TRUE, .ignore_on_failure = FALSE, + .disabled = FALSE, .mailboxes = ARRAY_INIT }; diff -r d079d72abb79 -r 0ee2f712b489 src/lib-storage/mail-storage-settings.h --- a/src/lib-storage/mail-storage-settings.h Sun Sep 02 16:06:45 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.h Tue Sep 04 17:18:08 2012 +0300 @@ -54,6 +54,7 @@ const char *list; bool subscriptions; bool ignore_on_failure; + bool disabled; ARRAY_DEFINE(mailboxes, struct mailbox_settings *); struct mail_user_settings *user_set; From dovecot at dovecot.org Tue Sep 4 17:27:09 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 17:27:09 +0300 Subject: dovecot-2.2: lib-storage: Log mailbox directory creations to mai... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e2c85551268d changeset: 15026:e2c85551268d user: Timo Sirainen date: Tue Sep 04 17:26:37 2012 +0300 description: lib-storage: Log mailbox directory creations to mailbox log. diffstat: src/lib-index/mailbox-log.h | 3 ++- src/lib-storage/mailbox-list.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diffs (39 lines): diff -r 57c964513a46 -r e2c85551268d src/lib-index/mailbox-log.h --- a/src/lib-index/mailbox-log.h Tue Sep 04 17:18:08 2012 +0300 +++ b/src/lib-index/mailbox-log.h Tue Sep 04 17:26:37 2012 +0300 @@ -8,7 +8,8 @@ MAILBOX_LOG_RECORD_DELETE_DIR, MAILBOX_LOG_RECORD_RENAME, MAILBOX_LOG_RECORD_SUBSCRIBE, - MAILBOX_LOG_RECORD_UNSUBSCRIBE + MAILBOX_LOG_RECORD_UNSUBSCRIBE, + MAILBOX_LOG_RECORD_CREATE_DIR }; struct mailbox_log_record { diff -r 57c964513a46 -r e2c85551268d src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Sep 04 17:18:08 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Sep 04 17:26:37 2012 +0300 @@ -1207,13 +1207,20 @@ int mailbox_list_create_dir(struct mailbox_list *list, const char *name) { + guid_128_t guid; + if (!mailbox_list_is_valid_create_name(list, name) || *name == '\0') { mailbox_list_set_error(list, MAIL_ERROR_PARAMS, "Invalid mailbox name"); return -1; } - return list->v.create_mailbox_dir(list, name, - MAILBOX_DIR_CREATE_TYPE_ONLY_NOSELECT); + if (list->v.create_mailbox_dir(list, name, + MAILBOX_DIR_CREATE_TYPE_ONLY_NOSELECT) < 0) + return -1; + + mailbox_name_get_sha128(name, guid); + mailbox_list_add_change(list, MAILBOX_LOG_RECORD_CREATE_DIR, guid); + return 0; } int mailbox_list_delete_dir(struct mailbox_list *list, const char *name) From dovecot at dovecot.org Tue Sep 4 18:52:00 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 18:52:00 +0300 Subject: dovecot-2.2: NOTIFY: Implemented SubscriptionChange Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fcd480c4a0db changeset: 15027:fcd480c4a0db user: Timo Sirainen date: Tue Sep 04 18:51:43 2012 +0300 description: NOTIFY: Implemented SubscriptionChange diffstat: src/imap/imap-notify.c | 22 ++- src/lib-storage/list/mailbox-list-index-notify.c | 124 ++++++++++++++++++++++- src/lib-storage/list/mailbox-list-index.c | 40 +++++++ src/lib-storage/list/mailbox-list-index.h | 2 +- src/lib-storage/list/mailbox-list-iter.c | 2 +- src/lib-storage/mailbox-list-notify.h | 13 +- src/lib-storage/mailbox-list-private.h | 1 + src/lib-storage/mailbox-tree.c | 87 +++++++++++++++- src/lib-storage/mailbox-tree.h | 5 + 9 files changed, 280 insertions(+), 16 deletions(-) diffs (truncated from 527 to 300 lines): diff -r e2c85551268d -r fcd480c4a0db src/imap/imap-notify.c --- a/src/imap/imap-notify.c Tue Sep 04 17:26:37 2012 +0300 +++ b/src/imap/imap-notify.c Tue Sep 04 18:51:43 2012 +0300 @@ -74,7 +74,8 @@ case MAILBOX_LIST_NOTIFY_CREATE: case MAILBOX_LIST_NOTIFY_DELETE: case MAILBOX_LIST_NOTIFY_RENAME: - case MAILBOX_LIST_NOTIFY_SUBSCRIPTION_CHANGE: + case MAILBOX_LIST_NOTIFY_SUBSCRIBE: + case MAILBOX_LIST_NOTIFY_UNSUBSCRIBE: i_unreached(); } if (items.status == 0) { @@ -116,8 +117,14 @@ mailbox_flags = 0; ret = imap_notify_list(notify_ns, rec, mailbox_flags); break; - case MAILBOX_LIST_NOTIFY_SUBSCRIPTION_CHANGE: - /* FIXME: set \subscribed when needed */ + case MAILBOX_LIST_NOTIFY_SUBSCRIBE: + if (mailbox_list_mailbox(notify_ns->ns->list, rec->storage_name, + &mailbox_flags) < 0) + mailbox_flags = 0; + ret = imap_notify_list(notify_ns, rec, + mailbox_flags | MAILBOX_SUBSCRIBED); + break; + case MAILBOX_LIST_NOTIFY_UNSUBSCRIBE: if (mailbox_list_mailbox(notify_ns->ns->list, rec->storage_name, &mailbox_flags) < 0) mailbox_flags = 0; @@ -150,7 +157,8 @@ if ((wanted_events & IMAP_NOTIFY_EVENT_MAILBOX_NAME) == 0) return FALSE; break; - case MAILBOX_LIST_NOTIFY_SUBSCRIPTION_CHANGE: + case MAILBOX_LIST_NOTIFY_SUBSCRIBE: + case MAILBOX_LIST_NOTIFY_UNSUBSCRIBE: if ((wanted_events & IMAP_NOTIFY_EVENT_SUBSCRIPTION_CHANGE) == 0) return FALSE; break; @@ -378,8 +386,10 @@ MAILBOX_LIST_NOTIFY_DELETE | MAILBOX_LIST_NOTIFY_RENAME; } - if ((events & IMAP_NOTIFY_EVENT_SUBSCRIPTION_CHANGE) != 0) - ret |= MAILBOX_LIST_NOTIFY_SUBSCRIPTION_CHANGE; + if ((events & IMAP_NOTIFY_EVENT_SUBSCRIPTION_CHANGE) != 0) { + ret |= MAILBOX_LIST_NOTIFY_SUBSCRIBE | + MAILBOX_LIST_NOTIFY_UNSUBSCRIBE; + } return ret; } diff -r e2c85551268d -r fcd480c4a0db src/lib-storage/list/mailbox-list-index-notify.c --- a/src/lib-storage/list/mailbox-list-index-notify.c Tue Sep 04 17:26:37 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index-notify.c Tue Sep 04 18:51:43 2012 +0300 @@ -35,6 +35,7 @@ struct mailbox_list_notify_index { struct mailbox_list_notify notify; + struct mailbox_tree_context *subscriptions; struct mailbox_list_notify_tree *tree; struct mail_index_view *view, *old_view; struct mail_index_view_sync_ctx *sync_ctx; @@ -47,11 +48,12 @@ struct timeout *to_wait, *to_notify; ARRAY_TYPE(seq_range) new_uids, expunged_uids, changed_uids; + ARRAY_TYPE(const_string) new_subscriptions, new_unsubscriptions; ARRAY(struct mailbox_list_notify_rename) renames; struct seq_range_iter new_uids_iter, expunged_uids_iter; struct seq_range_iter changed_uids_iter; unsigned int new_uids_n, expunged_uids_n, changed_uids_n; - unsigned int rename_idx; + unsigned int rename_idx, subscription_idx, unsubscription_idx; struct mailbox_list_notify_rec notify_rec; string_t *rec_name; @@ -86,7 +88,15 @@ i_array_init(&inotify->expunged_uids, 8); i_array_init(&inotify->changed_uids, 16); i_array_init(&inotify->renames, 16); + i_array_init(&inotify->new_subscriptions, 16); + i_array_init(&inotify->new_unsubscriptions, 16); inotify->rec_name = str_new(default_pool, 64); + if ((mask & (MAILBOX_LIST_NOTIFY_SUBSCRIBE | + MAILBOX_LIST_NOTIFY_UNSUBSCRIBE)) != 0) { + (void)mailbox_list_iter_subscriptions_refresh(list); + mailbox_tree_sort(list->subscriptions); + inotify->subscriptions = mailbox_tree_dup(list->subscriptions); + } *notify_r = &inotify->notify; return 1; @@ -98,6 +108,8 @@ (struct mailbox_list_notify_index *)notify; bool b; + if (inotify->subscriptions != NULL) + mailbox_tree_deinit(&inotify->subscriptions); if (inotify->io_wait != NULL) io_remove(&inotify->io_wait); if (inotify->to_wait != NULL) @@ -109,6 +121,8 @@ mail_index_view_close(&inotify->view); mail_index_view_close(&inotify->old_view); mailbox_list_notify_tree_deinit(&inotify->tree); + array_free(&inotify->new_subscriptions); + array_free(&inotify->new_unsubscriptions); array_free(&inotify->new_uids); array_free(&inotify->expunged_uids); array_free(&inotify->changed_uids); @@ -400,6 +414,66 @@ } static void +mailbox_list_index_notify_find_subscribes(struct mailbox_list_notify_index *inotify) +{ + struct mailbox_tree_iterate_context *old_iter, *new_iter; + struct mailbox_tree_context *old_tree, *new_tree; + const char *old_path = NULL, *new_path = NULL; + pool_t pool; + int ret; + + if (mailbox_list_iter_subscriptions_refresh(inotify->notify.list) < 0) + return; + mailbox_tree_sort(inotify->notify.list->subscriptions); + + old_tree = inotify->subscriptions; + new_tree = mailbox_tree_dup(inotify->notify.list->subscriptions); + + old_iter = mailbox_tree_iterate_init(old_tree, NULL, MAILBOX_SUBSCRIBED); + new_iter = mailbox_tree_iterate_init(new_tree, NULL, MAILBOX_SUBSCRIBED); + + pool = mailbox_tree_get_pool(new_tree); + for (;;) { + if (old_path == NULL) { + if (mailbox_tree_iterate_next(old_iter, &old_path) == NULL) + old_path = NULL; + } + if (new_path == NULL) { + if (mailbox_tree_iterate_next(new_iter, &new_path) == NULL) + new_path = NULL; + } + + if (old_path == NULL) { + if (new_path == NULL) + break; + ret = 1; + } else if (new_path == NULL) + ret = -1; + else { + ret = strcmp(old_path, new_path); + } + + if (ret == 0) { + old_path = NULL; + new_path = NULL; + } else if (ret > 0) { + new_path = p_strdup(pool, new_path); + array_append(&inotify->new_subscriptions, &new_path, 1); + new_path = NULL; + } else { + old_path = p_strdup(pool, old_path); + array_append(&inotify->new_unsubscriptions, &old_path, 1); + old_path = NULL; + } + } + mailbox_tree_iterate_deinit(&old_iter); + mailbox_tree_iterate_deinit(&new_iter); + + mailbox_tree_deinit(&inotify->subscriptions); + inotify->subscriptions = new_tree; +} + +static void mailbox_list_index_notify_reset_iters(struct mailbox_list_notify_index *inotify) { seq_range_array_iter_init(&inotify->new_uids_iter, @@ -412,6 +486,8 @@ inotify->new_uids_n = 0; inotify->expunged_uids_n = 0; inotify->rename_idx = 0; + inotify->subscription_idx = 0; + inotify->unsubscription_idx = 0; } static void @@ -439,6 +515,8 @@ mailbox_list_index_notify_find_renames(inotify); mailbox_list_index_notify_reset_iters(inotify); } + if (inotify->subscriptions != NULL) + mailbox_list_index_notify_find_subscribes(inotify); inotify->initialized = TRUE; } @@ -450,6 +528,8 @@ mail_index_view_close(&inotify->old_view); inotify->old_view = mail_index_view_dup_private(inotify->view); + array_clear(&inotify->new_subscriptions); + array_clear(&inotify->new_unsubscriptions); array_clear(&inotify->new_uids); array_clear(&inotify->expunged_uids); array_clear(&inotify->changed_uids); @@ -516,6 +596,38 @@ } static bool +mailbox_list_index_notify_subscribe(struct mailbox_list_notify_index *inotify, + unsigned int idx) +{ + struct mailbox_list_notify_rec *rec = &inotify->notify_rec; + const char *const *vnamep; + + memset(rec, 0, sizeof(*rec)); + vnamep = array_idx(&inotify->new_subscriptions, idx); + rec->vname = *vnamep; + rec->storage_name = mailbox_list_get_storage_name(inotify->notify.list, + rec->vname); + rec->event = MAILBOX_LIST_NOTIFY_SUBSCRIBE; + return TRUE; +} + +static bool +mailbox_list_index_notify_unsubscribe(struct mailbox_list_notify_index *inotify, + unsigned int idx) +{ + struct mailbox_list_notify_rec *rec = &inotify->notify_rec; + const char *const *vnamep; + + memset(rec, 0, sizeof(*rec)); + vnamep = array_idx(&inotify->new_unsubscriptions, idx); + rec->vname = *vnamep; + rec->storage_name = mailbox_list_get_storage_name(inotify->notify.list, + rec->vname); + rec->event = MAILBOX_LIST_NOTIFY_UNSUBSCRIBE; + return TRUE; +} + +static bool mailbox_list_index_notify_expunge(struct mailbox_list_notify_index *inotify, uint32_t uid) { @@ -608,6 +720,16 @@ inotify->new_uids_n++, &uid)) return mailbox_list_index_notify_new(inotify, uid); + /* subscribes */ + if (inotify->subscription_idx < array_count(&inotify->new_subscriptions)) { + return mailbox_list_index_notify_subscribe(inotify, + inotify->subscription_idx++); + } + if (inotify->unsubscription_idx < array_count(&inotify->new_unsubscriptions)) { + return mailbox_list_index_notify_unsubscribe(inotify, + inotify->unsubscription_idx++); + } + /* STATUS updates */ while (seq_range_array_iter_nth(&inotify->changed_uids_iter, inotify->changed_uids_n++, &uid)) { diff -r e2c85551268d -r fcd480c4a0db src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Tue Sep 04 17:26:37 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Tue Sep 04 18:51:43 2012 +0300 @@ -386,6 +386,42 @@ newlist, newname, rename_children); } +static int +mailbox_list_index_set_subscribed(struct mailbox_list *_list, + const char *name, bool set) +{ + struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(_list); + struct mail_index_view *view; + struct mail_index_transaction *trans; + const void *data; + size_t size; + uint32_t counter; + + if (ilist->module_ctx.super.set_subscribed(_list, name, set) < 0) + return -1; + + /* update the "subscriptions changed" counter/timestamp. its purpose + is to trigger NOTIFY watcher to handle SubscriptionChange events */ + mailbox_list_index_index_open(_list); + view = mail_index_view_open(ilist->index); + mail_index_get_header_ext(view, ilist->subs_hdr_ext_id, &data, &size); + if (size != sizeof(counter)) + counter = ioloop_time; + else { + memcpy(&counter, data, size); + if (++counter < ioloop_time) + counter = ioloop_time; + } + + trans = mail_index_transaction_begin(view, + MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); + mail_index_update_header_ext(trans, ilist->subs_hdr_ext_id, + 0, &counter, sizeof(counter)); From dovecot at dovecot.org Tue Sep 4 19:05:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 19:05:57 +0300 Subject: dovecot-2.2: lib-storage: Added mailbox_is_subscribed() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c00df434bfb9 changeset: 15028:c00df434bfb9 user: Timo Sirainen date: Tue Sep 04 19:04:52 2012 +0300 description: lib-storage: Added mailbox_is_subscribed() diffstat: src/lib-storage/mail-storage.c | 11 +++++++++++ src/lib-storage/mail-storage.h | 4 ++++ 2 files changed, 15 insertions(+), 0 deletions(-) diffs (42 lines): diff -r fcd480c4a0db -r c00df434bfb9 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Tue Sep 04 18:51:43 2012 +0300 +++ b/src/lib-storage/mail-storage.c Tue Sep 04 19:04:52 2012 +0300 @@ -12,6 +12,7 @@ #include "var-expand.h" #include "mail-index-private.h" #include "mail-index-alloc-cache.h" +#include "mailbox-tree.h" #include "mailbox-list-private.h" #include "mail-storage-private.h" #include "mail-storage-settings.h" @@ -1251,6 +1252,16 @@ return box->v.set_subscribed(box, set); } +bool mailbox_is_subscribed(struct mailbox *box) +{ + struct mailbox_node *node; + + i_assert(box->list->subscriptions != NULL); + + node = mailbox_tree_lookup(box->list->subscriptions, box->vname); + return node != NULL && (node->flags & MAILBOX_SUBSCRIBED) != 0; +} + struct mail_storage *mailbox_get_storage(const struct mailbox *box) { return box->storage; diff -r fcd480c4a0db -r c00df434bfb9 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Tue Sep 04 18:51:43 2012 +0300 +++ b/src/lib-storage/mail-storage.h Tue Sep 04 19:04:52 2012 +0300 @@ -447,6 +447,10 @@ /* Subscribe/unsubscribe mailbox. Subscribing to nonexistent mailboxes is optional. */ int mailbox_set_subscribed(struct mailbox *box, bool set); +/* Returns TRUE if mailbox is subscribed, FALSE if not. This function + doesn't refresh the subscriptions list, but assumes that it's been done by + e.g. mailbox_list_iter*(). */ +bool mailbox_is_subscribed(struct mailbox *box); /* Enable the given feature for the mailbox. */ int mailbox_enable(struct mailbox *box, enum mailbox_feature features); From dovecot at dovecot.org Tue Sep 4 19:05:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 19:05:57 +0300 Subject: dovecot-2.2: NOTIFY: Fixed "subscribed" mailbox filter to actual... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/13e7c1e30c0e changeset: 15029:13e7c1e30c0e user: Timo Sirainen date: Tue Sep 04 19:05:18 2012 +0300 description: NOTIFY: Fixed "subscribed" mailbox filter to actually work. diffstat: src/imap/cmd-notify.c | 3 +++ src/imap/imap-notify.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diffs (38 lines): diff -r c00df434bfb9 -r 13e7c1e30c0e src/imap/cmd-notify.c --- a/src/imap/cmd-notify.c Tue Sep 04 19:04:52 2012 +0300 +++ b/src/imap/cmd-notify.c Tue Sep 04 19:05:18 2012 +0300 @@ -435,7 +435,10 @@ if (!imap_notify_ns_want_status(notify_ns)) return; + /* set _RETURN_SUBSCRIBED flag just in case IMAP_NOTIFY_TYPE_SUBSCRIBED + is used, which requires refreshing subscriptions */ iter = mailbox_list_iter_init(notify_ns->ns->list, "*", + MAILBOX_LIST_ITER_RETURN_SUBSCRIBED | MAILBOX_LIST_ITER_RETURN_NO_FLAGS); while ((info = mailbox_list_iter_next(iter)) != NULL) { array_foreach(¬ify_ns->mailboxes, notify_boxes) { diff -r c00df434bfb9 -r 13e7c1e30c0e src/imap/imap-notify.c --- a/src/imap/imap-notify.c Tue Sep 04 19:04:52 2012 +0300 +++ b/src/imap/imap-notify.c Tue Sep 04 19:05:18 2012 +0300 @@ -201,14 +201,18 @@ const struct imap_notify_mailboxes *notify_boxes, const char *vname) { + struct mailbox *box; const char *const *namep; unsigned int name_len; char ns_sep; + bool ret; switch (notify_boxes->type) { case IMAP_NOTIFY_TYPE_SUBSCRIBED: - // FIXME - return TRUE; + box = mailbox_alloc(notify_ns->ns->list, vname, 0); + ret = mailbox_is_subscribed(box); + mailbox_free(&box); + return ret; case IMAP_NOTIFY_TYPE_SUBTREE: ns_sep = mail_namespace_get_sep(notify_ns->ns); array_foreach(¬ify_boxes->names, namep) { From dovecot at dovecot.org Tue Sep 4 19:05:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 19:05:57 +0300 Subject: dovecot-2.2: TODO updated Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/af00d5c42ac1 changeset: 15030:af00d5c42ac1 user: Timo Sirainen date: Tue Sep 04 19:05:44 2012 +0300 description: TODO updated diffstat: TODO | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diffs (22 lines): diff -r 13e7c1e30c0e -r af00d5c42ac1 TODO --- a/TODO Tue Sep 04 19:05:18 2012 +0300 +++ b/TODO Tue Sep 04 19:05:44 2012 +0300 @@ -1,10 +1,5 @@ - - crashes: rm -rf ~/abox;printf "1 select inbox\n2 fetch 1 body[]\n"|./imap -o plugin/archive_customer_id=1 - - connection api: connected(conn, bool success) + errno - - mailbox list indexes + imaptest test=tests fails - - NOTIFY: implement SubscriptionChange - libssl-iostream read all of file input stream, no buffer limits in ssl - finish dsync rewrite - - catenate: {1234} and {1234+} error handling is wrong for both - doveadm: if running via doveadm-server and it fails, say something about error being in the log @@ -29,7 +24,6 @@ so mail_storage_settings are copied to mail_namespace_settings. use the change tracking to figure out what settings are namespace-specific. - - imap: list (special-use recursivematch) "" % doesn't work - passdb, userdb { username_format } that doesn't permanently change the username - mdbox/sdbox index rebuild -> quota rebuild? From dovecot at dovecot.org Tue Sep 4 19:59:26 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 19:59:26 +0300 Subject: dovecot-2.2: doveadm dump -t mailboxlog: Added support for MAILB... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9bc2e718392c changeset: 15031:9bc2e718392c user: Timo Sirainen date: Tue Sep 04 19:58:59 2012 +0300 description: doveadm dump -t mailboxlog: Added support for MAILBOX_LOG_RECORD_CREATE_DIR diffstat: src/doveadm/doveadm-dump-mailboxlog.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (21 lines): diff -r af00d5c42ac1 -r 9bc2e718392c src/doveadm/doveadm-dump-mailboxlog.c --- a/src/doveadm/doveadm-dump-mailboxlog.c Tue Sep 04 19:05:44 2012 +0300 +++ b/src/doveadm/doveadm-dump-mailboxlog.c Tue Sep 04 19:58:59 2012 +0300 @@ -45,6 +45,9 @@ case MAILBOX_LOG_RECORD_UNSUBSCRIBE: printf("unsubscribe"); break; + case MAILBOX_LOG_RECORD_CREATE_DIR: + printf("create-dir"); + break; } printf(" %s", binary_to_hex(rec.mailbox_guid, sizeof(rec.mailbox_guid))); @@ -96,6 +99,7 @@ case MAILBOX_LOG_RECORD_RENAME: case MAILBOX_LOG_RECORD_SUBSCRIBE: case MAILBOX_LOG_RECORD_UNSUBSCRIBE: + case MAILBOX_LOG_RECORD_CREATE_DIR: ret = TRUE; break; } From dovecot at dovecot.org Tue Sep 4 20:27:20 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 04 Sep 2012 20:27:20 +0300 Subject: dovecot-2.0: dsync: Avoid errors about duplicate GUID when INBOX... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/4c27b2418882 changeset: 13106:4c27b2418882 user: Timo Sirainen date: Tue Sep 04 20:27:10 2012 +0300 description: dsync: Avoid errors about duplicate GUID when INBOX/INBOX exists. diffstat: src/dsync/dsync-worker-local.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 13b8b90bed3e -r 4c27b2418882 src/dsync/dsync-worker-local.c --- a/src/dsync/dsync-worker-local.c Tue Jul 17 16:20:20 2012 +0300 +++ b/src/dsync/dsync-worker-local.c Tue Sep 04 20:27:10 2012 +0300 @@ -535,6 +535,13 @@ dsync_box_r->name_sep = info->ns->sep; storage_name = mail_namespace_get_storage_name(info->ns, info->name); + if (strcmp(storage_name, "INBOX") == 0 && + strcmp(info->name, "INBOX") != 0) { + /* e.g. INBOX/ namespace with INBOX/INBOX mailbox. + we can't handle this properly with v2.0 API, but since + it most likely doesn't even exist just skip it */ + return local_worker_mailbox_iter_next(_iter, dsync_box_r); + } dsync_str_sha_to_guid(storage_name, &dsync_box_r->name_sha1); /* get last change timestamp */ From dovecot at dovecot.org Thu Sep 6 01:05:28 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Sep 2012 01:05:28 +0300 Subject: dovecot-2.2: str_*printfa(): Avoid (harder!) growing underlying ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5930f7812e28 changeset: 15032:5930f7812e28 user: Timo Sirainen date: Thu Sep 06 01:04:28 2012 +0300 description: str_*printfa(): Avoid (harder!) growing underlying buffer if possible. The previous change for this didn't work properly. diffstat: src/lib/str.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (17 lines): diff -r 9bc2e718392c -r 5930f7812e28 src/lib/str.c --- a/src/lib/str.c Tue Sep 04 19:58:59 2012 +0300 +++ b/src/lib/str.c Thu Sep 06 01:04:28 2012 +0300 @@ -145,10 +145,11 @@ init_size += SNPRINTF_INITIAL_EXTRA_SIZE; /* @UNSAFE */ - if (init_size > buffer_get_size(str)) { + if (pos+init_size > buffer_get_size(str) && + pos < buffer_get_size(str)) { /* avoid growing buffer larger if possible. this is also required if buffer isn't dynamically growing. */ - init_size = buffer_get_size(str); + init_size = buffer_get_size(str)-pos; } tmp = buffer_get_space_unsafe(str, pos, init_size); ret = vsnprintf(tmp, init_size, fmt, args); From dovecot at dovecot.org Thu Sep 6 01:05:28 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Sep 2012 01:05:28 +0300 Subject: dovecot-2.2: buffer_create_data(): Clear the memory area immedia... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/34076ab28d28 changeset: 15033:34076ab28d28 user: Timo Sirainen date: Thu Sep 06 01:04:57 2012 +0300 description: buffer_create_data(): Clear the memory area immediately. diffstat: src/lib/buffer.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 5930f7812e28 -r 34076ab28d28 src/lib/buffer.c --- a/src/lib/buffer.c Thu Sep 06 01:04:28 2012 +0300 +++ b/src/lib/buffer.c Thu Sep 06 01:04:57 2012 +0300 @@ -96,6 +96,10 @@ memset(buf, 0, sizeof(*buf)); buf->alloc = size; buf->r_buffer = buf->w_buffer = data; + /* clear the whole memory area. unnecessary usually, but if the + buffer is used by e.g. str_c() it tries to access uninitialized + memory */ + memset(data, 0, size); } void buffer_create_const_data(buffer_t *buffer, const void *data, size_t size) From dovecot at dovecot.org Thu Sep 6 01:13:41 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Sep 2012 01:13:41 +0300 Subject: dovecot-2.2: Renamed buffer_create_*data() to buffer_create_from... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7efef678bca8 changeset: 15034:7efef678bca8 user: Timo Sirainen date: Thu Sep 06 01:13:03 2012 +0300 description: Renamed buffer_create_*data() to buffer_create_from_*data() for consistency. Especially i_stream_create_from_data() was a very similar function, which made it difficult to remember which one should have "from" and which one shouldn't. diffstat: src/auth/auth-master-connection.c | 2 +- src/auth/mech-digest-md5.c | 2 +- src/imap/main.c | 4 ++-- src/lib-index/mail-index-modseq.c | 6 +++--- src/lib-index/mail-index-sync-keywords.c | 4 ++-- src/lib-index/mail-index-transaction-export.c | 2 +- src/lib-index/mail-transaction-log-append.c | 2 +- src/lib-index/mail-transaction-log-file.c | 4 ++-- src/lib-index/mail-transaction-log-view.c | 8 ++++---- src/lib-mail/istream-binary-converter.c | 4 ++-- src/lib-mail/istream-qp-decoder.c | 3 ++- src/lib-mail/test-message-header-encode.c | 2 +- src/lib-otp/otp-parse.c | 4 ++-- src/lib-storage/index/index-mail.c | 2 +- src/lib-storage/index/maildir/maildir-save.c | 6 +++--- src/lib-storage/mail.c | 2 +- src/lib/askpass.c | 2 +- src/lib/buffer.c | 5 +++-- src/lib/buffer.h | 5 +++-- src/lib/guid.c | 2 +- src/lib/iostream-rawlog.c | 2 +- src/lib/istream-base64-decoder.c | 3 ++- src/lib/istream-base64-encoder.c | 3 ++- src/lib/str.c | 2 +- src/login-common/sasl-server.c | 2 +- src/plugins/fts-lucene/Snowball.cc | 2 +- src/plugins/fts-lucene/fts-backend-lucene.c | 2 +- src/plugins/fts-lucene/lucene-wrapper.cc | 6 +++--- src/plugins/fts/fts-expunge-log.c | 2 +- src/pop3-login/client.c | 2 +- src/pop3/main.c | 4 ++-- 31 files changed, 53 insertions(+), 48 deletions(-) diffs (truncated from 488 to 300 lines): diff -r 34076ab28d28 -r 7efef678bca8 src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/auth/auth-master-connection.c Thu Sep 06 01:13:03 2012 +0300 @@ -110,7 +110,7 @@ return FALSE; } - buffer_create_data(&buf, cookie, sizeof(cookie)); + buffer_create_from_data(&buf, cookie, sizeof(cookie)); if (hex_to_binary(list[3], &buf) < 0) { i_error("BUG: Master sent broken REQUEST cookie"); return FALSE; diff -r 34076ab28d28 -r 7efef678bca8 src/auth/mech-digest-md5.c --- a/src/auth/mech-digest-md5.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/auth/mech-digest-md5.c Thu Sep 06 01:13:03 2012 +0300 @@ -78,7 +78,7 @@ /* get 128bit of random data as nonce */ random_fill(nonce, sizeof(nonce)); - buffer_create_data(&buf, nonce_base64, sizeof(nonce_base64)); + buffer_create_from_data(&buf, nonce_base64, sizeof(nonce_base64)); base64_encode(nonce, sizeof(nonce), &buf); buffer_append_c(&buf, '\0'); request->nonce = p_strdup(request->pool, buf.data); diff -r 34076ab28d28 -r 7efef678bca8 src/imap/main.c --- a/src/imap/main.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/imap/main.c Thu Sep 06 01:13:03 2012 +0300 @@ -267,8 +267,8 @@ input.userdb_fields = extra_fields; input.session_id = client->session_id; - buffer_create_const_data(&input_buf, client->data, - client->auth_req.data_size); + buffer_create_from_const_data(&input_buf, client->data, + client->auth_req.data_size); if (client_create_from_input(&input, client, client->fd, client->fd, &input_buf, &error) < 0) { int fd = client->fd; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-index/mail-index-modseq.c --- a/src/lib-index/mail-index-modseq.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-index/mail-index-modseq.c Thu Sep 06 01:13:03 2012 +0300 @@ -350,7 +350,7 @@ return; } case MAIL_TRANSACTION_FLAG_UPDATE: { - buffer_create_const_data(&uid_buf, tdata, thdr->size); + buffer_create_from_const_data(&uid_buf, tdata, thdr->size); array_create_from_buffer(&uids, &uid_buf, sizeof(struct mail_transaction_flag_update)); break; @@ -363,14 +363,14 @@ if ((seqset_offset % 4) != 0) seqset_offset += 4 - (seqset_offset % 4); - buffer_create_const_data(&uid_buf, + buffer_create_from_const_data(&uid_buf, CONST_PTR_OFFSET(tdata, seqset_offset), thdr->size - seqset_offset); array_create_from_buffer(&uids, &uid_buf, sizeof(uint32_t)*2); break; } case MAIL_TRANSACTION_KEYWORD_RESET: - buffer_create_const_data(&uid_buf, tdata, thdr->size); + buffer_create_from_const_data(&uid_buf, tdata, thdr->size); array_create_from_buffer(&uids, &uid_buf, sizeof(struct mail_transaction_keyword_reset)); break; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-index/mail-index-sync-keywords.c --- a/src/lib-index/mail-index-sync-keywords.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-index/mail-index-sync-keywords.c Thu Sep 06 01:13:03 2012 +0300 @@ -83,8 +83,8 @@ i_assert(keywords_count > 0); - buffer_create_data(&ext_intro_buf, ext_intro_data, - sizeof(ext_intro_data)); + buffer_create_from_data(&ext_intro_buf, ext_intro_data, + sizeof(ext_intro_data)); u = buffer_append_space_unsafe(&ext_intro_buf, sizeof(*u)); u->ext_id = ext_map_idx; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-index/mail-index-transaction-export.c --- a/src/lib-index/mail-index-transaction-export.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-index/mail-index-transaction-export.c Thu Sep 06 01:13:03 2012 +0300 @@ -245,7 +245,7 @@ } memset(&ext_reset, 0, sizeof(ext_reset)); - buffer_create_data(&reset_buf, &ext_reset, sizeof(ext_reset)); + buffer_create_from_data(&reset_buf, &ext_reset, sizeof(ext_reset)); buffer_set_used_size(&reset_buf, sizeof(ext_reset)); for (ext_id = 0; ext_id < ext_count; ext_id++) { diff -r 34076ab28d28 -r 7efef678bca8 src/lib-index/mail-transaction-log-append.c --- a/src/lib-index/mail-transaction-log-append.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-index/mail-transaction-log-append.c Thu Sep 06 01:13:03 2012 +0300 @@ -170,7 +170,7 @@ return; i_assert(offset > file->saved_tail_offset); - buffer_create_data(&buf, update_data, sizeof(update_data)); + buffer_create_from_data(&buf, update_data, sizeof(update_data)); u = buffer_append_space_unsafe(&buf, sizeof(*u)); u->offset = offsetof(struct mail_index_header, log_file_tail_offset); u->size = sizeof(offset); diff -r 34076ab28d28 -r 7efef678bca8 src/lib-index/mail-transaction-log-file.c --- a/src/lib-index/mail-transaction-log-file.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-index/mail-transaction-log-file.c Thu Sep 06 01:13:03 2012 +0300 @@ -1564,8 +1564,8 @@ log_file_set_syscall_error(file, "madvise()"); } - buffer_create_const_data(&file->mmap_buffer, - file->mmap_base, file->mmap_size); + buffer_create_from_const_data(&file->mmap_buffer, + file->mmap_base, file->mmap_size); file->buffer = &file->mmap_buffer; file->buffer_offset = 0; return 0; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-index/mail-transaction-log-view.c --- a/src/lib-index/mail-transaction-log-view.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-index/mail-transaction-log-view.c Thu Sep 06 01:13:03 2012 +0300 @@ -528,7 +528,7 @@ } break; case MAIL_TRANSACTION_EXPUNGE: - buffer_create_const_data(&uid_buf, data, rec_size); + buffer_create_from_const_data(&uid_buf, data, rec_size); array_create_from_buffer(&uids, &uid_buf, sizeof(struct mail_transaction_expunge)); break; @@ -552,7 +552,7 @@ break; } case MAIL_TRANSACTION_FLAG_UPDATE: - buffer_create_const_data(&uid_buf, data, rec_size); + buffer_create_from_const_data(&uid_buf, data, rec_size); array_create_from_buffer(&uids, &uid_buf, sizeof(struct mail_transaction_flag_update)); break; @@ -575,7 +575,7 @@ return FALSE; } - buffer_create_const_data(&uid_buf, + buffer_create_from_const_data(&uid_buf, CONST_PTR_OFFSET(data, seqset_offset), rec_size - seqset_offset); array_create_from_buffer(&uids, &uid_buf, @@ -583,7 +583,7 @@ break; } case MAIL_TRANSACTION_KEYWORD_RESET: - buffer_create_const_data(&uid_buf, data, rec_size); + buffer_create_from_const_data(&uid_buf, data, rec_size); array_create_from_buffer(&uids, &uid_buf, sizeof(struct mail_transaction_keyword_reset)); break; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-mail/istream-binary-converter.c --- a/src/lib-mail/istream-binary-converter.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-mail/istream-binary-converter.c Thu Sep 06 01:13:03 2012 +0300 @@ -116,7 +116,7 @@ } dest = i_stream_alloc(stream, BASE64_BLOCK_SIZE); - buffer_create_data(&buf, dest, BASE64_BLOCK_SIZE); + buffer_create_from_data(&buf, dest, BASE64_BLOCK_SIZE); base64_encode(base64_block, base64_block_len, &buf); stream->pos += buf.used; bstream->base64_block_pos++; @@ -143,7 +143,7 @@ max_encoded_size = MAX_BASE64_ENCODED_SIZE(encode_size); dest = i_stream_alloc(stream, max_encoded_size); - buffer_create_data(&buf, dest, max_encoded_size); + buffer_create_from_data(&buf, dest, max_encoded_size); base64_encode(data, encode_size, &buf); stream->pos += buf.used; bstream->base64_block_pos += encode_blocks; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-mail/istream-qp-decoder.c --- a/src/lib-mail/istream-qp-decoder.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-mail/istream-qp-decoder.c Thu Sep 06 01:13:03 2012 +0300 @@ -57,7 +57,8 @@ return -2; } - buffer_create_data(&buf, stream->w_buffer + stream->pos, buffer_avail); + buffer_create_from_data(&buf, stream->w_buffer + stream->pos, + buffer_avail); quoted_printable_decode(data, size, &pos, &buf); stream->pos += buf.used; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-mail/test-message-header-encode.c --- a/src/lib-mail/test-message-header-encode.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-mail/test-message-header-encode.c Thu Sep 06 01:13:03 2012 +0300 @@ -80,7 +80,7 @@ char bufdata[1000]; buffer_t buf; - buffer_create_data(&buf, bufdata, sizeof(bufdata)); + buffer_create_from_data(&buf, bufdata, sizeof(bufdata)); if (strncmp(str+i, "\n\t", 2) == 0) { i += 2; line_start = i - 1; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-otp/otp-parse.c --- a/src/lib-otp/otp-parse.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-otp/otp-parse.c Thu Sep 06 01:13:03 2012 +0300 @@ -43,7 +43,7 @@ return -1; str = t_str_new(18); - buffer_create_data(&buf, hash, OTP_HASH_SIZE); + buffer_create_from_data(&buf, hash, OTP_HASH_SIZE); while (*data) { char c = *data; @@ -90,7 +90,7 @@ data = otp_skip_lws(data); - buffer_create_data(&buf, bits, sizeof(bits)); + buffer_create_from_data(&buf, bits, sizeof(bits)); for (; *data && (count < OTP_WORDS_NUMBER); data++) { char c = *data; diff -r 34076ab28d28 -r 7efef678bca8 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-storage/index/index-mail.c Thu Sep 06 01:13:03 2012 +0300 @@ -123,7 +123,7 @@ buffer_t buf; int ret; - buffer_create_data(&buf, data, data_size); + buffer_create_from_data(&buf, data, data_size); if (index_mail_cache_lookup_field(mail, &buf, field_idx) <= 0) ret = FALSE; else { diff -r 34076ab28d28 -r 7efef678bca8 src/lib-storage/index/maildir/maildir-save.c --- a/src/lib-storage/index/maildir/maildir-save.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-save.c Thu Sep 06 01:13:03 2012 +0300 @@ -135,7 +135,7 @@ ctx->newdir = p_strconcat(pool, path, "/new", NULL); ctx->curdir = p_strconcat(pool, path, "/cur", NULL); - buffer_create_const_data(&ctx->keywords_buffer, "", 0); + buffer_create_from_const_data(&ctx->keywords_buffer, "", 0); array_create_from_buffer(&ctx->keywords_array, &ctx->keywords_buffer, sizeof(unsigned int)); ctx->last_save_finished = TRUE; @@ -279,8 +279,8 @@ } i_assert(ctx->keywords_sync_ctx != NULL || mf->keywords_count == 0); - buffer_create_const_data(&ctx->keywords_buffer, mf + 1, - mf->keywords_count * sizeof(unsigned int)); + buffer_create_from_const_data(&ctx->keywords_buffer, mf + 1, + mf->keywords_count * sizeof(unsigned int)); *fname_r = maildir_filename_flags_kw_set(ctx->keywords_sync_ctx, basename, mf->flags & MAIL_FLAGS_MASK, diff -r 34076ab28d28 -r 7efef678bca8 src/lib-storage/mail.c --- a/src/lib-storage/mail.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib-storage/mail.c Thu Sep 06 01:13:03 2012 +0300 @@ -334,7 +334,7 @@ if (guid_128_from_string(guid, guid_128_r) < 0) { /* not 128bit hex. use a hash of it instead. */ - buffer_create_data(&buf, guid_128_r, GUID_128_SIZE); + buffer_create_from_data(&buf, guid_128_r, GUID_128_SIZE); buffer_set_used_size(&buf, 0); sha1_get_digest(guid, strlen(guid), sha1_sum); #if SHA1_RESULTLEN < DBOX_GUID_BIN_LEN diff -r 34076ab28d28 -r 7efef678bca8 src/lib/askpass.c --- a/src/lib/askpass.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib/askpass.c Thu Sep 06 01:13:03 2012 +0300 @@ -58,7 +58,7 @@ { buffer_t str; - buffer_create_data(&str, buf, buf_size); + buffer_create_from_data(&str, buf, buf_size); askpass_str(prompt, &str); buffer_append_c(&str, '\0'); } diff -r 34076ab28d28 -r 7efef678bca8 src/lib/buffer.c --- a/src/lib/buffer.c Thu Sep 06 01:04:57 2012 +0300 +++ b/src/lib/buffer.c Thu Sep 06 01:13:03 2012 +0300 @@ -86,7 +86,7 @@ i_assert(buf->used <= buf->alloc); } -void buffer_create_data(buffer_t *buffer, void *data, size_t size) +void buffer_create_from_data(buffer_t *buffer, void *data, size_t size) { struct real_buffer *buf; @@ -102,7 +102,8 @@ memset(data, 0, size); } From dovecot at dovecot.org Thu Sep 6 01:25:38 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Sep 2012 01:25:38 +0300 Subject: dovecot-2.2: dsync: Rewritten syncing for mailbox renames. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0af20585964d changeset: 15035:0af20585964d user: Timo Sirainen date: Thu Sep 06 01:25:23 2012 +0300 description: dsync: Rewritten syncing for mailbox renames. A few things didn't go as I originally intended in the algorithm, but it appears to give consistent results now. :) But the algorithm should probably be looked at more closely at some point. diffstat: src/doveadm/dsync/Makefile.am | 19 + src/doveadm/dsync/dsync-brain-mailbox-tree.c | 13 +- src/doveadm/dsync/dsync-mailbox-tree-fill.c | 30 +- src/doveadm/dsync/dsync-mailbox-tree-private.h | 16 +- src/doveadm/dsync/dsync-mailbox-tree-sync.c | 841 +++++++++++++++++----- src/doveadm/dsync/dsync-mailbox-tree.c | 151 +++- src/doveadm/dsync/dsync-mailbox-tree.h | 23 +- src/doveadm/dsync/dsync-slave-io.c | 51 +- src/doveadm/dsync/test-dsync-mailbox-tree-sync.c | 639 +++++++++++++++++ 9 files changed, 1539 insertions(+), 244 deletions(-) diffs (truncated from 2199 to 300 lines): diff -r 7efef678bca8 -r 0af20585964d src/doveadm/dsync/Makefile.am --- a/src/doveadm/dsync/Makefile.am Thu Sep 06 01:13:03 2012 +0300 +++ b/src/doveadm/dsync/Makefile.am Thu Sep 06 01:25:23 2012 +0300 @@ -49,3 +49,22 @@ dsync-slave.h \ dsync-slave-private.h \ dsync-transaction-log-scan.h + +test_programs = \ + test-dsync-mailbox-tree-sync + +noinst_PROGRAMS = $(test_programs) + +test_libs = \ + ../../lib-test/libtest.la \ + ../../lib/liblib.la + +test_dsync_mailbox_tree_sync_SOURCES = test-dsync-mailbox-tree-sync.c +test_dsync_mailbox_tree_sync_LDADD = dsync-mailbox-tree-sync.lo dsync-mailbox-tree.lo $(test_libs) +test_dsync_mailbox_tree_sync_DEPENDENCIES = dsync-mailbox-tree-sync.lo dsync-mailbox-tree.lo $(test_libs) + +check: check-am check-test +check-test: all-am + for bin in $(test_programs); do \ + if ! $(RUN_TEST) ./$$bin; then exit 1; fi; \ + done diff -r 7efef678bca8 -r 0af20585964d src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Thu Sep 06 01:13:03 2012 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Thu Sep 06 01:25:23 2012 +0300 @@ -64,10 +64,12 @@ dsync_brain_check_namespaces(brain); brain->local_mailbox_tree = - dsync_mailbox_tree_init(brain->hierarchy_sep); + dsync_mailbox_tree_init(brain->hierarchy_sep, + doveadm_settings->dsync_alt_char[0]); /* we'll convert remote mailbox names to use our own separator */ brain->remote_mailbox_tree = - dsync_mailbox_tree_init(brain->hierarchy_sep); + dsync_mailbox_tree_init(brain->hierarchy_sep, + doveadm_settings->dsync_alt_char[0]); /* fill the local mailbox tree */ if (brain->sync_ns != NULL) { @@ -329,6 +331,13 @@ if (node == NULL) return; + if (!other_del->delete_mailbox && + other_del->timestamp <= node->last_renamed_or_created) { + /* we don't want to delete this directory, we already have a + newer timestamp for it */ + return; + } + /* make a node for it in the other mailbox tree */ name = dsync_mailbox_node_get_full_name(tree, node); other_node = dsync_mailbox_tree_get(other_tree, name); diff -r 7efef678bca8 -r 0af20585964d src/doveadm/dsync/dsync-mailbox-tree-fill.c --- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Thu Sep 06 01:13:03 2012 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Thu Sep 06 01:25:23 2012 +0300 @@ -111,6 +111,7 @@ node = rec->type == MAILBOX_LOG_RECORD_DELETE_MAILBOX ? NULL : dsync_mailbox_tree_find_sha(tree, ns, rec->mailbox_guid); + timestamp = mailbox_log_record_get_timestamp(rec); switch (rec->type) { case MAILBOX_LOG_RECORD_DELETE_MAILBOX: guid_p = rec->mailbox_guid; @@ -121,26 +122,39 @@ } del = array_append_space(&tree->deletes); del->delete_mailbox = TRUE; + del->timestamp = timestamp; memcpy(del->guid, rec->mailbox_guid, sizeof(del->guid)); break; case MAILBOX_LOG_RECORD_DELETE_DIR: if (node != NULL) { - /* mailbox exists again, skip it */ + /* directory exists again, skip it */ break; } + /* we don't know what directory name was deleted, + just its hash. if the name still exists on the other + dsync side, it can match this deletion to the + name. */ del = array_append_space(&tree->deletes); + del->timestamp = timestamp; memcpy(del->guid, rec->mailbox_guid, sizeof(del->guid)); break; + case MAILBOX_LOG_RECORD_CREATE_DIR: + if (node == NULL) { + /* directory has been deleted again, skip it */ + break; + } + /* notify the remote that we want to keep this + directory created (unless remote has a newer delete + timestamp) */ + node->last_renamed_or_created = timestamp; + break; case MAILBOX_LOG_RECORD_RENAME: + if (node != NULL) + node->last_renamed_or_created = timestamp; + break; case MAILBOX_LOG_RECORD_SUBSCRIBE: case MAILBOX_LOG_RECORD_UNSUBSCRIBE: - if (node == NULL) - break; - - timestamp = mailbox_log_record_get_timestamp(rec); - if (rec->type == MAILBOX_LOG_RECORD_RENAME) - node->last_renamed = timestamp; - else + if (node != NULL) node->last_subscription_change = timestamp; break; } diff -r 7efef678bca8 -r 0af20585964d src/doveadm/dsync/dsync-mailbox-tree-private.h --- a/src/doveadm/dsync/dsync-mailbox-tree-private.h Thu Sep 06 01:13:03 2012 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-private.h Thu Sep 06 01:25:23 2012 +0300 @@ -5,7 +5,9 @@ struct dsync_mailbox_tree { pool_t pool; - char sep, sep_str[2], remote_sep; + char sep, sep_str[2], remote_sep, alt_char; + /* root node isn't part of the real mailbox tree. its name is "" and + it has no siblings */ struct dsync_mailbox_node root; unsigned int iter_count; @@ -20,4 +22,16 @@ void dsync_mailbox_tree_build_name128_hash(struct dsync_mailbox_tree *tree); +int dsync_mailbox_node_name_cmp(struct dsync_mailbox_node *const *n1, + struct dsync_mailbox_node *const *n2); + +void dsync_mailbox_tree_node_attach(struct dsync_mailbox_node *node, + struct dsync_mailbox_node *parent); +void dsync_mailbox_tree_node_detach(struct dsync_mailbox_node *node); + +struct dsync_mailbox_tree * +dsync_mailbox_tree_dup(const struct dsync_mailbox_tree *src); +bool dsync_mailbox_trees_equal(struct dsync_mailbox_tree *tree1, + struct dsync_mailbox_tree *tree2); + #endif diff -r 7efef678bca8 -r 0af20585964d src/doveadm/dsync/dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c Thu Sep 06 01:13:03 2012 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c Thu Sep 06 01:25:23 2012 +0300 @@ -2,10 +2,18 @@ #include "lib.h" #include "array.h" +#include "buffer.h" +#include "str.h" +#include "md5.h" +#include "hex-binary.h" #include "aqueue.h" #include "hash.h" #include "dsync-mailbox-tree-private.h" +#define TEMP_MAX_NAME_LEN 100 +#define TEMP_SUFFIX_MAX_LEN (sizeof("temp-")-1 + 8) +#define TEMP_SUFFIX_FORMAT "temp-%x" + struct dsync_mailbox_tree_bfs_iter { struct dsync_mailbox_tree *tree; @@ -56,12 +64,6 @@ return TRUE; } -static bool -dsync_mailbox_tree_bfs_iter_is_eob(struct dsync_mailbox_tree_bfs_iter *iter) -{ - return iter->cur == NULL; -} - static void dsync_mailbox_tree_bfs_iter_deinit(struct dsync_mailbox_tree_bfs_iter **_iter) { @@ -74,10 +76,35 @@ i_free(iter); } -static int dsync_mailbox_node_sync_cmp(struct dsync_mailbox_node *const *n1, - struct dsync_mailbox_node *const *n2) +static void +sync_add_dir_change(struct dsync_mailbox_tree_sync_ctx *ctx, + const struct dsync_mailbox_node *node, + enum dsync_mailbox_tree_sync_type type) { - return strcmp((*n1)->name, (*n2)->name); + struct dsync_mailbox_tree_sync_change *change; + const char *name; + + name = dsync_mailbox_node_get_full_name(ctx->local_tree, node); + + change = array_append_space(&ctx->changes); + change->type = type; + change->ns = node->ns; + change->full_name = p_strdup(ctx->pool, name); +} + +static void +sync_add_create_change(struct dsync_mailbox_tree_sync_ctx *ctx, + const struct dsync_mailbox_node *node, const char *name) +{ + struct dsync_mailbox_tree_sync_change *change; + + change = array_append_space(&ctx->changes); + change->type = DSYNC_MAILBOX_TREE_SYNC_TYPE_CREATE_BOX; + change->ns = node->ns; + change->full_name = p_strdup(ctx->pool, name); + memcpy(change->mailbox_guid, node->mailbox_guid, + sizeof(change->mailbox_guid)); + change->uid_validity = node->uid_validity; } static void sort_siblings(ARRAY_TYPE(dsync_mailbox_node) *siblings) @@ -85,7 +112,7 @@ struct dsync_mailbox_node *const *nodes; unsigned int i, count; - array_sort(siblings, dsync_mailbox_node_sync_cmp); + array_sort(siblings, dsync_mailbox_node_name_cmp); nodes = array_get(siblings, &count); if (count == 0) @@ -128,11 +155,13 @@ /* for the rest of this sync assume that the mailbox has already been deleted */ if (other_node != NULL) { + hash_table_remove(other_tree->guid_hash, guid_p); other_node->existence = DSYNC_MAILBOX_NODE_DELETED; memset(other_node->mailbox_guid, 0, sizeof(other_node->mailbox_guid)); } memset(node->mailbox_guid, 0, sizeof(node->mailbox_guid)); + node->uid_validity = 0; } static void @@ -153,7 +182,7 @@ parent = node->parent; } if (node->existence == DSYNC_MAILBOX_NODE_DELETED && - !guid_128_is_empty(node->mailbox_guid)) + !dsync_mailbox_node_is_dir(node)) sync_delete_mailbox(ctx, tree, node); array_append(&siblings, &node, 1); } @@ -161,44 +190,6 @@ dsync_mailbox_tree_bfs_iter_deinit(&iter); } -static struct dsync_mailbox_node * -sync_find_node(struct dsync_mailbox_tree *tree, - struct dsync_mailbox_node *other_node) -{ - struct dsync_mailbox_node *n1, *n2; - const uint8_t *guid_p; - - if (!guid_128_is_empty(other_node->mailbox_guid)) { - guid_p = other_node->mailbox_guid; - return hash_table_lookup(tree->guid_hash, guid_p); - } - /* if we can find a node that has all of the same mailboxes as children, - return it. */ - for (n1 = other_node->first_child; n1 != NULL; n1 = n1->next) { - if (!guid_128_is_empty(n1->mailbox_guid)) - break; - } - if (n1 == NULL) - return NULL; - guid_p = n1->mailbox_guid; - n2 = hash_table_lookup(tree->guid_hash, guid_p); - if (n2 == NULL) - return NULL; - - /* note that all of the nodes are sorted at this point. */ - n1 = n1->parent->first_child; - n2 = n2->parent->first_child; - for (; n1 != NULL && n2 != NULL; n1 = n1->next, n2 = n2->next) { - if (strcmp(n1->name, n2->name) != 0 || - memcmp(n1->mailbox_guid, n2->mailbox_guid, - sizeof(n1->mailbox_guid)) != 0) - break; - } - if (n1 != NULL || n2 != NULL) - return NULL; - return n2; -} - static bool node_names_equal(const struct dsync_mailbox_node *n1, const struct dsync_mailbox_node *n2) { @@ -212,18 +203,6 @@ From pigeonhole at rename-it.nl Thu Sep 6 10:01:05 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 06 Sep 2012 09:01:05 +0200 Subject: dovecot-2.2-pigeonhole: Adjusted to buffer API change in Dovecot. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/dda9e3c21214 changeset: 1660:dda9e3c21214 user: Stephan Bosch date: Thu Sep 06 09:00:59 2012 +0200 description: Adjusted to buffer API change in Dovecot. diffstat: src/managesieve/main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 66adbdd89d5c -r dda9e3c21214 src/managesieve/main.c --- a/src/managesieve/main.c Sun Sep 02 18:54:01 2012 +0200 +++ b/src/managesieve/main.c Thu Sep 06 09:00:59 2012 +0200 @@ -191,7 +191,7 @@ input.userdb_fields = extra_fields; input.session_id = client->session_id; - buffer_create_const_data(&input_buf, client->data, + buffer_create_from_const_data(&input_buf, client->data, client->auth_req.data_size); if (client_create_from_input(&input, client->fd, client->fd, &input_buf, &error) < 0) { From dovecot at dovecot.org Thu Sep 6 16:50:12 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 06 Sep 2012 16:50:12 +0300 Subject: dovecot-2.1: doveadm: Added exec command to easily execute comma... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cb3f49b649bf changeset: 14696:cb3f49b649bf user: Timo Sirainen date: Thu Sep 06 16:50:00 2012 +0300 description: doveadm: Added exec command to easily execute commands from libexec_dir. For example: doveadm exec imap -u user at domain diffstat: src/doveadm/Makefile.am | 1 + src/doveadm/doveadm-settings.c | 2 ++ src/doveadm/doveadm-settings.h | 1 + src/doveadm/doveadm.c | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 0 deletions(-) diffs (74 lines): diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/Makefile.am Thu Sep 06 16:50:00 2012 +0300 @@ -22,6 +22,7 @@ -DDOVEADM_MODULEDIR=\""$(doveadm_moduledir)"\" \ -DPKG_RUNDIR=\""$(rundir)"\" \ -DPKG_STATEDIR=\""$(statedir)"\" \ + -DPKG_LIBEXECDIR=\""$(pkglibexecdir)"\" \ -DBINDIR=\""$(bindir)"\" \ -DMANDIR=\""$(mandir)"\" diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/doveadm-settings.c --- a/src/doveadm/doveadm-settings.c Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/doveadm-settings.c Thu Sep 06 16:50:00 2012 +0300 @@ -53,6 +53,7 @@ static const struct setting_define doveadm_setting_defines[] = { DEF(SET_STR, base_dir), + DEF(SET_STR, libexec_dir), DEF(SET_STR, mail_plugins), DEF(SET_STR, mail_plugin_dir), DEF(SET_STR, doveadm_socket_path), @@ -70,6 +71,7 @@ const struct doveadm_settings doveadm_default_settings = { .base_dir = PKG_RUNDIR, + .libexec_dir = PKG_LIBEXECDIR, .mail_plugins = "", .mail_plugin_dir = MODULEDIR, .doveadm_socket_path = "doveadm-server", diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/doveadm-settings.h --- a/src/doveadm/doveadm-settings.h Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/doveadm-settings.h Thu Sep 06 16:50:00 2012 +0300 @@ -3,6 +3,7 @@ struct doveadm_settings { const char *base_dir; + const char *libexec_dir; const char *mail_plugins; const char *mail_plugin_dir; const char *doveadm_socket_path; diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/doveadm.c --- a/src/doveadm/doveadm.c Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/doveadm.c Thu Sep 06 16:50:00 2012 +0300 @@ -174,6 +174,21 @@ cmd_config, "config", "[doveconf parameters]" }; +static void cmd_exec(int argc ATTR_UNUSED, char *argv[]) +{ + const char *path, *binary = argv[1]; + + path = t_strdup_printf("%s/%s", doveadm_settings->libexec_dir, binary); + argv++; + argv[0] = t_strdup_noconst(path); + (void)execv(argv[0], argv); + i_fatal("execv(%s) failed: %m", argv[0]); +} + +static struct doveadm_cmd doveadm_cmd_exec = { + cmd_exec, "exec", " [binary parameters]" +}; + static bool doveadm_try_run_multi_word(const struct doveadm_cmd *cmd, const char *cmdname, int argc, char *argv[]) @@ -269,6 +284,7 @@ static struct doveadm_cmd *doveadm_commands[] = { &doveadm_cmd_help, &doveadm_cmd_config, + &doveadm_cmd_exec, &doveadm_cmd_stop, &doveadm_cmd_reload, &doveadm_cmd_dump, From dovecot at dovecot.org Fri Sep 7 16:45:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 07 Sep 2012 16:45:05 +0300 Subject: dovecot-2.2: dsync: Renamed "io" slave to "stream". Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5943cace4e05 changeset: 15036:5943cace4e05 user: Timo Sirainen date: Fri Sep 07 16:19:35 2012 +0300 description: dsync: Renamed "io" slave to "stream". diffstat: src/doveadm/dsync/Makefile.am | 2 +- src/doveadm/dsync/doveadm-dsync.c | 10 +- src/doveadm/dsync/dsync-slave-io.c | 1518 ------------------------------- src/doveadm/dsync/dsync-slave-stream.c | 1522 ++++++++++++++++++++++++++++++++ src/doveadm/dsync/dsync-slave.h | 4 +- 5 files changed, 1530 insertions(+), 1526 deletions(-) diffs (truncated from 3101 to 300 lines): diff -r 0af20585964d -r 5943cace4e05 src/doveadm/dsync/Makefile.am --- a/src/doveadm/dsync/Makefile.am Thu Sep 06 01:25:23 2012 +0300 +++ b/src/doveadm/dsync/Makefile.am Fri Sep 07 16:19:35 2012 +0300 @@ -28,7 +28,7 @@ dsync-mailbox-tree-sync.c \ dsync-serializer.c \ dsync-slave.c \ - dsync-slave-io.c \ + dsync-slave-stream.c \ dsync-slave-pipe.c \ dsync-transaction-log-scan.c diff -r 0af20585964d -r 5943cace4e05 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Thu Sep 06 01:25:23 2012 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Fri Sep 07 16:19:35 2012 +0300 @@ -334,9 +334,9 @@ else { string_t *temp_prefix = t_str_new(64); mail_user_set_get_temp_prefix(temp_prefix, user->set); - slave = dsync_slave_init_io(ctx->fd_in, ctx->fd_out, - ctx->remote_name, - str_c(temp_prefix)); + slave = dsync_slave_init_stream(ctx->fd_in, ctx->fd_out, + ctx->remote_name, + str_c(temp_prefix)); } if (doveadm_debug || doveadm_verbose) { @@ -520,8 +520,8 @@ temp_prefix = t_str_new(64); mail_user_set_get_temp_prefix(temp_prefix, user->set); - slave = dsync_slave_init_io(STDIN_FILENO, STDOUT_FILENO, - "local", str_c(temp_prefix)); + slave = dsync_slave_init_stream(STDIN_FILENO, STDOUT_FILENO, + "local", str_c(temp_prefix)); brain = dsync_brain_slave_init(user, slave); io_loop_run(current_ioloop); diff -r 0af20585964d -r 5943cace4e05 src/doveadm/dsync/dsync-slave-io.c --- a/src/doveadm/dsync/dsync-slave-io.c Thu Sep 06 01:25:23 2012 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1518 +0,0 @@ -/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ - -#include "lib.h" -#include "array.h" -#include "fd-set-nonblock.h" -#include "safe-mkstemp.h" -#include "ioloop.h" -#include "istream.h" -#include "istream-seekable.h" -#include "istream-dot.h" -#include "ostream.h" -#include "str.h" -#include "strescape.h" -#include "master-service.h" -#include "mail-cache.h" -#include "mail-storage-private.h" -#include "dsync-serializer.h" -#include "dsync-deserializer.h" -#include "dsync-mail.h" -#include "dsync-mailbox.h" -#include "dsync-mailbox-state.h" -#include "dsync-mailbox-tree.h" -#include "dsync-slave-private.h" - -#include - -#define DSYNC_SLAVE_IO_TIMEOUT_MSECS (60*10*1000) -#define DSYNC_SLAVE_IO_OUTBUF_THROTTLE_SIZE (1024*128) - -#define DSYNC_PROTOCOL_VERSION_MAJOR 3 -#define DSYNC_HANDSHAKE_VERSION "VERSION\tdsync\t3\t0\n" - -enum item_type { - ITEM_NONE, - - ITEM_HANDSHAKE, - ITEM_MAILBOX_STATE, - ITEM_MAILBOX_TREE_NODE, - ITEM_MAILBOX_DELETE, - ITEM_MAILBOX, - - ITEM_MAIL_CHANGE, - ITEM_MAIL_REQUEST, - ITEM_MAIL, - - ITEM_MAILBOX_CACHE_FIELD, - - ITEM_END_OF_LIST -}; - -#define END_OF_LIST_LINE "." -static const struct { - /* full human readable name of the item */ - const char *name; - /* unique character identifying the item */ - char chr; - const char *required_keys; - const char *optional_keys; -} items[ITEM_END_OF_LIST+1] = { - { NULL, '\0', NULL, NULL }, - { .name = "handshake", - .chr = 'H', - .optional_keys = "sync_ns_prefix sync_type " - "guid_requests mails_have_guids" - }, - { .name = "mailbox_state", - .chr = 'S', - .required_keys = "mailbox_guid last_uidvalidity last_common_uid " - "last_common_modseq" - }, - { .name = "mailbox_tree_node", - .chr = 'N', - .required_keys = "name existence", - .optional_keys = "mailbox_guid uid_validity " - "last_renamed_or_created subscribed last_subscription_change" - }, - { .name = "mailbox_delete", - .chr = 'D', - .required_keys = "hierarchy_sep", - .optional_keys = "mailboxes dirs" - }, - { .name = "mailbox", - .chr = 'B', - .required_keys = "mailbox_guid uid_validity uid_next " - "messages_count first_recent_uid highest_modseq", - .optional_keys = "cache_fields" - }, - { .name = "mail_change", - .chr = 'C', - .required_keys = "type uid", - .optional_keys = "guid hdr_hash modseq save_timestamp " - "add_flags remove_flags final_flags " - "keywords_reset keyword_changes" - }, - { .name = "mail_request", - .chr = 'R', - .optional_keys = "guid uid" - }, - { .name = "mail", - .chr = 'M', - .optional_keys = "guid uid pop3_uidl pop3_order received_date stream" - }, - { .name = "mailbox_cache_field", - .chr = 'c', - .required_keys = "name decision", - .optional_keys = "last_used" - }, - - { "end_of_list", '\0', NULL, NULL } -}; - -struct dsync_slave_io { - struct dsync_slave slave; - - char *name, *temp_path_prefix; - int fd_in, fd_out; - struct istream *input; - struct ostream *output; - struct io *io; - struct timeout *to; - - struct dsync_serializer *serializers[ITEM_END_OF_LIST]; - struct dsync_deserializer *deserializers[ITEM_END_OF_LIST]; - - pool_t ret_pool; - struct dsync_deserializer_decoder *cur_decoder; - - struct istream *mail_output, *mail_input; - struct dsync_mail *cur_mail; - char mail_output_last; - - unsigned int version_received:1; - unsigned int handshake_received:1; - unsigned int has_pending_data:1; -}; - -static void dsync_slave_io_stop(struct dsync_slave_io *slave) -{ - i_stream_close(slave->input); - o_stream_close(slave->output); - io_loop_stop(current_ioloop); -} - -static int dsync_slave_io_read_mail_stream(struct dsync_slave_io *slave) -{ - if (i_stream_read(slave->mail_input) < 0) { - if (slave->mail_input->stream_errno != 0) { - errno = slave->mail_input->stream_errno; - i_error("dsync(%s): read() failed: %m", slave->name); - dsync_slave_io_stop(slave); - return -1; - } - /* finished reading the mail stream */ - i_assert(slave->mail_input->eof); - i_stream_seek(slave->mail_input, 0); - slave->mail_input = NULL; - return 1; - } - i_stream_skip(slave->mail_input, - i_stream_get_data_size(slave->mail_input)); - return 0; -} - -static void dsync_slave_io_input(struct dsync_slave_io *slave) -{ - if (slave->mail_input != NULL) { - if (dsync_slave_io_read_mail_stream(slave) == 0) - return; - } - slave->slave.io_callback(slave->slave.io_context); -} - -static int dsync_slave_io_send_mail_stream(struct dsync_slave_io *slave) -{ - const unsigned char *data; - unsigned char add; - size_t i, size; - int ret; - - while ((ret = i_stream_read_data(slave->mail_output, - &data, &size, 0)) > 0) { - add = '\0'; - for (i = 0; i < size; i++) { - if (data[i] == '\n') { - if ((i == 0 && slave->mail_output_last != '\r') || - (i > 0 && data[i-1] != '\r')) { - /* missing CR */ - add = '\r'; - break; - } - } else if (data[i] == '.' && - ((i == 0 && slave->mail_output_last == '\n') || - (i > 0 && data[i-1] == '\n'))) { - /* escape the dot */ - add = '.'; - break; - } - } - - if (i > 0) { - o_stream_nsend(slave->output, data, i); - slave->mail_output_last = data[i-1]; - i_stream_skip(slave->mail_output, i); - } - - if (o_stream_get_buffer_used_size(slave->output) >= 4096) { - if ((ret = o_stream_flush(slave->output)) < 0) { - dsync_slave_io_stop(slave); - return -1; - } - if (ret == 0) { - /* continue later */ - o_stream_set_flush_pending(slave->output, TRUE); - return 0; - } - } - - if (add != '\0') { - o_stream_nsend(slave->output, &add, 1); - slave->mail_output_last = add; - } - } - i_assert(ret == -1); - - if (slave->mail_output->stream_errno != 0) { - i_error("dsync(%s): read(%s) failed: %m", - slave->name, i_stream_get_name(slave->mail_output)); - dsync_slave_io_stop(slave); - return -1; - } - - /* finished sending the stream */ - o_stream_nsend_str(slave->output, "\r\n.\r\n"); - i_stream_unref(&slave->mail_output); - return 1; -} - -static int dsync_slave_io_output(struct dsync_slave_io *slave) -{ - struct ostream *output = slave->output; - int ret; - - if ((ret = o_stream_flush(output)) < 0) - ret = 1; - else if (slave->mail_output != NULL) { - if (dsync_slave_io_send_mail_stream(slave) < 0) - ret = 1; - } - timeout_reset(slave->to); - - if (!dsync_slave_is_send_queue_full(&slave->slave)) - slave->slave.io_callback(slave->slave.io_context); - return ret; -} - -static void dsync_slave_io_timeout(struct dsync_slave_io *slave) -{ From dovecot at dovecot.org Fri Sep 7 16:45:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 07 Sep 2012 16:45:05 +0300 Subject: dovecot-2.2: dsync: Renamed "slave" to "ibc" (= inter-brain comm... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/920756cd29b8 changeset: 15037:920756cd29b8 user: Timo Sirainen date: Fri Sep 07 16:43:44 2012 +0300 description: dsync: Renamed "slave" to "ibc" (= inter-brain communicator) diffstat: src/doveadm/dsync/Makefile.am | 10 +- src/doveadm/dsync/doveadm-dsync.c | 36 +- src/doveadm/dsync/dsync-brain-mailbox-tree.c | 28 +- src/doveadm/dsync/dsync-brain-mailbox.c | 12 +- src/doveadm/dsync/dsync-brain-mails.c | 48 +- src/doveadm/dsync/dsync-brain-private.h | 2 +- src/doveadm/dsync/dsync-brain.c | 72 +- src/doveadm/dsync/dsync-brain.h | 6 +- src/doveadm/dsync/dsync-ibc-pipe.c | 482 ++++++++ src/doveadm/dsync/dsync-ibc-private.h | 78 + src/doveadm/dsync/dsync-ibc-stream.c | 1517 +++++++++++++++++++++++++ src/doveadm/dsync/dsync-ibc.c | 200 +++ src/doveadm/dsync/dsync-ibc.h | 118 ++ src/doveadm/dsync/dsync-slave-pipe.c | 485 -------- src/doveadm/dsync/dsync-slave-private.h | 78 - src/doveadm/dsync/dsync-slave-stream.c | 1522 -------------------------- src/doveadm/dsync/dsync-slave.c | 202 --- src/doveadm/dsync/dsync-slave.h | 118 -- 18 files changed, 2502 insertions(+), 2512 deletions(-) diffs (truncated from 5526 to 300 lines): diff -r 5943cace4e05 -r 920756cd29b8 src/doveadm/dsync/Makefile.am --- a/src/doveadm/dsync/Makefile.am Fri Sep 07 16:19:35 2012 +0300 +++ b/src/doveadm/dsync/Makefile.am Fri Sep 07 16:43:44 2012 +0300 @@ -27,9 +27,9 @@ dsync-mailbox-tree-fill.c \ dsync-mailbox-tree-sync.c \ dsync-serializer.c \ - dsync-slave.c \ - dsync-slave-stream.c \ - dsync-slave-pipe.c \ + dsync-ibc.c \ + dsync-ibc-stream.c \ + dsync-ibc-pipe.c \ dsync-transaction-log-scan.c noinst_HEADERS = \ @@ -46,8 +46,8 @@ dsync-mailbox-tree-private.h \ dsync-serializer.h \ dsync-deserializer.h \ - dsync-slave.h \ - dsync-slave-private.h \ + dsync-ibc.h \ + dsync-ibc-private.h \ dsync-transaction-log-scan.h test_programs = \ diff -r 5943cace4e05 -r 920756cd29b8 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Fri Sep 07 16:19:35 2012 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Fri Sep 07 16:43:44 2012 +0300 @@ -15,7 +15,7 @@ #include "doveadm-settings.h" #include "doveadm-mail.h" #include "dsync-brain.h" -#include "dsync-slave.h" +#include "dsync-ibc.h" #include "doveadm-dsync.h" #include @@ -228,7 +228,7 @@ static int cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user, - struct dsync_brain *brain, struct dsync_slave *slave2) + struct dsync_brain *brain, struct dsync_ibc *ibc2) { struct dsync_brain *brain2; struct mail_user *user2; @@ -267,7 +267,7 @@ "points to same directory: %s", path1); } - brain2 = dsync_brain_slave_init(user2, slave2); + brain2 = dsync_brain_slave_init(user2, ibc2); brain1_running = brain2_running = TRUE; changed1 = changed2 = TRUE; @@ -312,7 +312,7 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { struct dsync_cmd_context *ctx = (struct dsync_cmd_context *)_ctx; - struct dsync_slave *slave, *slave2 = NULL; + struct dsync_ibc *ibc, *ibc2 = NULL; struct dsync_brain *brain; struct mail_namespace *sync_ns = NULL; int ret = 0; @@ -330,26 +330,26 @@ } if (!ctx->remote) - dsync_slave_init_pipe(&slave, &slave2); + dsync_ibc_init_pipe(&ibc, &ibc2); else { string_t *temp_prefix = t_str_new(64); mail_user_set_get_temp_prefix(temp_prefix, user->set); - slave = dsync_slave_init_stream(ctx->fd_in, ctx->fd_out, - ctx->remote_name, - str_c(temp_prefix)); + ibc = dsync_ibc_init_stream(ctx->fd_in, ctx->fd_out, + ctx->remote_name, + str_c(temp_prefix)); } if (doveadm_debug || doveadm_verbose) { // FIXME } - brain = dsync_brain_master_init(user, slave, sync_ns, + brain = dsync_brain_master_init(user, ibc, sync_ns, ctx->sync_type, DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS | DSYNC_BRAIN_FLAG_SEND_REQUESTS, ""); if (!ctx->remote) { - if (cmd_dsync_run_local(ctx, user, brain, slave2) < 0) + if (cmd_dsync_run_local(ctx, user, brain, ibc2) < 0) _ctx->exit_code = EX_TEMPFAIL; } else { cmd_dsync_run_remote(user); @@ -357,9 +357,9 @@ if (dsync_brain_deinit(&brain) < 0) _ctx->exit_code = EX_TEMPFAIL; - dsync_slave_deinit(&slave); - if (slave2 != NULL) - dsync_slave_deinit(&slave2); + dsync_ibc_deinit(&ibc); + if (ibc2 != NULL) + dsync_ibc_deinit(&ibc2); if (ctx->io_err != NULL) io_remove(&ctx->io_err); if (ctx->fd_err != -1) @@ -507,7 +507,7 @@ cmd_dsync_server_run(struct doveadm_mail_cmd_context *_ctx ATTR_UNUSED, struct mail_user *user) { - struct dsync_slave *slave; + struct dsync_ibc *ibc; struct dsync_brain *brain; string_t *temp_prefix; @@ -520,13 +520,13 @@ temp_prefix = t_str_new(64); mail_user_set_get_temp_prefix(temp_prefix, user->set); - slave = dsync_slave_init_stream(STDIN_FILENO, STDOUT_FILENO, - "local", str_c(temp_prefix)); - brain = dsync_brain_slave_init(user, slave); + ibc = dsync_ibc_init_stream(STDIN_FILENO, STDOUT_FILENO, + "local", str_c(temp_prefix)); + brain = dsync_brain_slave_init(user, ibc); io_loop_run(current_ioloop); - dsync_slave_deinit(&slave); + dsync_ibc_deinit(&ibc); return dsync_brain_deinit(&brain); } diff -r 5943cace4e05 -r 920756cd29b8 src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Fri Sep 07 16:19:35 2012 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Fri Sep 07 16:43:44 2012 +0300 @@ -5,7 +5,7 @@ #include "settings-parser.h" #include "mail-namespace.h" #include "doveadm-settings.h" -#include "dsync-slave.h" +#include "dsync-ibc.h" #include "dsync-mailbox-tree.h" #include "dsync-brain-private.h" @@ -94,7 +94,7 @@ void dsync_brain_send_mailbox_tree(struct dsync_brain *brain) { struct dsync_mailbox_node *node; - enum dsync_slave_send_ret ret; + enum dsync_ibc_send_ret ret; const char *full_name; char sep[2]; @@ -105,14 +105,14 @@ const char *const *parts; parts = t_strsplit(full_name, sep); - ret = dsync_slave_send_mailbox_tree_node(brain->slave, - parts, node); + ret = dsync_ibc_send_mailbox_tree_node(brain->ibc, + parts, node); } T_END; - if (ret == DSYNC_SLAVE_SEND_RET_FULL) + if (ret == DSYNC_IBC_SEND_RET_FULL) return; } dsync_mailbox_tree_iter_deinit(&brain->local_tree_iter); - dsync_slave_send_end_of_list(brain->slave); + dsync_ibc_send_end_of_list(brain->ibc); brain->state = DSYNC_STATE_SEND_MAILBOX_TREE_DELETES; } @@ -124,8 +124,8 @@ deletes = dsync_mailbox_tree_get_deletes(brain->local_mailbox_tree, &count); - dsync_slave_send_mailbox_deletes(brain->slave, deletes, count, - brain->hierarchy_sep); + dsync_ibc_send_mailbox_deletes(brain->ibc, deletes, count, + brain->hierarchy_sep); brain->state = DSYNC_STATE_RECV_MAILBOX_TREE; } @@ -289,12 +289,12 @@ struct dsync_mailbox_node *node; const char *const *parts, *name; struct mail_namespace *ns; - enum dsync_slave_recv_ret ret; + enum dsync_ibc_recv_ret ret; char sep[2]; bool changed = FALSE; - while ((ret = dsync_slave_recv_mailbox_tree_node(brain->slave, &parts, - &remote_node)) > 0) { + while ((ret = dsync_ibc_recv_mailbox_tree_node(brain->ibc, &parts, + &remote_node)) > 0) { if (dsync_get_mailbox_name(brain, parts, &name, &ns) < 0) { sep[0] = brain->hierarchy_sep; sep[1] = '\0'; i_error("Couldn't find namespace for mailbox %s", @@ -306,7 +306,7 @@ node->ns = ns; dsync_mailbox_node_copy_data(node, remote_node); } - if (ret == DSYNC_SLAVE_RECV_RET_FINISHED) { + if (ret == DSYNC_IBC_RECV_RET_FINISHED) { if (dsync_mailbox_tree_build_guid_hash(brain->remote_mailbox_tree) < 0) brain->failed = TRUE; @@ -369,8 +369,8 @@ unsigned int i, count; char sep; - if (dsync_slave_recv_mailbox_deletes(brain->slave, &deletes, &count, - &sep) == 0) + if (dsync_ibc_recv_mailbox_deletes(brain->ibc, &deletes, &count, + &sep) == 0) return FALSE; /* apply remote's mailbox deletions based on our local tree */ diff -r 5943cace4e05 -r 920756cd29b8 src/doveadm/dsync/dsync-brain-mailbox.c --- a/src/doveadm/dsync/dsync-brain-mailbox.c Fri Sep 07 16:19:35 2012 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox.c Fri Sep 07 16:43:44 2012 +0300 @@ -6,7 +6,7 @@ #include "mail-cache-private.h" #include "mail-namespace.h" #include "mail-storage-private.h" -#include "dsync-slave.h" +#include "dsync-ibc.h" #include "dsync-mailbox-tree.h" #include "dsync-mailbox-import.h" #include "dsync-mailbox-export.h" @@ -370,12 +370,12 @@ if (!dsync_brain_next_mailbox(brain, &box, &dsync_box)) { brain->state = DSYNC_STATE_DONE; - dsync_slave_send_end_of_list(brain->slave); + dsync_ibc_send_end_of_list(brain->ibc); return; } /* start exporting this mailbox (wait for remote to start importing) */ - dsync_slave_send_mailbox(brain->slave, &dsync_box); + dsync_ibc_send_mailbox(brain->ibc, &dsync_box); (void)dsync_brain_sync_mailbox_init(brain, box, &dsync_box, DSYNC_BOX_STATE_MAILBOX); brain->state = DSYNC_STATE_SYNC_MAILS; @@ -526,7 +526,7 @@ i_assert(!brain->master_brain); i_assert(brain->box == NULL); - if ((ret = dsync_slave_recv_mailbox(brain->slave, &dsync_box)) == 0) + if ((ret = dsync_ibc_recv_mailbox(brain->ibc, &dsync_box)) == 0) return FALSE; if (ret < 0) { brain->state = DSYNC_STATE_DONE; @@ -563,13 +563,13 @@ memcpy(delete_box.mailbox_guid, dsync_box->mailbox_guid, sizeof(delete_box.mailbox_guid)); delete_box.mailbox_lost = TRUE; - dsync_slave_send_mailbox(brain->slave, &delete_box); + dsync_ibc_send_mailbox(brain->ibc, &delete_box); return TRUE; } i_assert(local_dsync_box.uid_validity != 0); i_assert(memcmp(dsync_box->mailbox_guid, local_dsync_box.mailbox_guid, sizeof(dsync_box->mailbox_guid)) == 0); - dsync_slave_send_mailbox(brain->slave, &local_dsync_box); + dsync_ibc_send_mailbox(brain->ibc, &local_dsync_box); dsync_brain_mailbox_update_pre(brain, box, &local_dsync_box, dsync_box); diff -r 5943cace4e05 -r 920756cd29b8 src/doveadm/dsync/dsync-brain-mails.c --- a/src/doveadm/dsync/dsync-brain-mails.c Fri Sep 07 16:19:35 2012 +0300 +++ b/src/doveadm/dsync/dsync-brain-mails.c Fri Sep 07 16:43:44 2012 +0300 @@ -2,7 +2,7 @@ #include "lib.h" #include "istream.h" -#include "dsync-slave.h" +#include "dsync-ibc.h" #include "dsync-mail.h" #include "dsync-mailbox-import.h" #include "dsync-mailbox-export.h" @@ -11,13 +11,13 @@ static bool dsync_brain_master_sync_recv_mailbox(struct dsync_brain *brain) { const struct dsync_mailbox *dsync_box; - enum dsync_slave_recv_ret ret; + enum dsync_ibc_recv_ret ret; i_assert(brain->master_brain); - if ((ret = dsync_slave_recv_mailbox(brain->slave, &dsync_box)) == 0) From pigeonhole at rename-it.nl Sun Sep 9 11:45:57 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 09 Sep 2012 10:45:57 +0200 Subject: dovecot-2.1-pigeonhole: sieve-refilter: improved man page docume... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/b1bedb88e615 changeset: 1642:b1bedb88e615 user: Stephan Bosch date: Sun Sep 09 10:45:46 2012 +0200 description: sieve-refilter: improved man page documentation by explicitly specifying the syntax used for mailbox arguments. diffstat: doc/man/sieve-filter.1.in | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diffs (45 lines): diff -r ff55c9946366 -r b1bedb88e615 doc/man/sieve-filter.1.in --- a/doc/man/sieve-filter.1.in Thu Aug 16 22:28:06 2012 +0200 +++ b/doc/man/sieve-filter.1.in Sun Sep 09 10:45:46 2012 +0200 @@ -92,7 +92,8 @@ is equal to the \fIsource\-mailbox\fP by default. Specifying a different folder will have the effect of moving (or copying if \fB\-W\fP is omitted) all kept messages to the indicated folder, instead of just leaving them in the -\fIsource\-mailbox\fP. +\fIsource\-mailbox\fP. Refer to the explanation of the \fIsource\-mailbox\fP +argument for more information on mailbox naming. .TP .BI \-q\ output\-mailbox\ \fB[not\ implemented\ yet]\fP Store outgoing e\-mail into the indicated \fIoutput\-mailbox\fP. By default, @@ -153,9 +154,18 @@ into a new binary. .TP .I source\-mailbox -The name of the source mailbox containing the messages that the Sieve filter -will act upon. This mailbox is not modified unless the \fB\-W\fP option is -specified. +Specifies the source mailbox containing the messages that the Sieve filter will +act upon. + +This is the name of a mailbox, as visible to IMAP clients, except in UTF-8 +format. The hierarchy separator between a parent and child mailbox is commonly +.RB \(aq / \(aq +or +.RB \(aq . \(aq, +but this depends on your selected mailbox storage format and +namespace configuration. The mailbox names may also require a namespace prefix. + +This mailbox is not modified unless the \fB\-W\fP option is specified. .TP .I discard\-action Specifies what is done with messages in the \fIsource\-mailbox\fP that where not @@ -169,7 +179,8 @@ .TP .BI move\ mailbox Move discarded messages to the indicated \fImailbox\fP. This is for instance -useful to move messages to a Trash mailbox. +useful to move messages to a Trash mailbox. Refer to the explanation of +the \fIsource\-mailbox\fP argument for more information on mailbox naming. .TP .B delete Flag discarded messages as \\DELETED. From dovecot at dovecot.org Mon Sep 10 17:20:00 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 10 Sep 2012 17:20:00 +0300 Subject: dovecot-2.2: lib-storage: Removed rename_children parameter from... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/92cc78c5dc77 changeset: 15038:92cc78c5dc77 user: Timo Sirainen date: Mon Sep 10 17:19:43 2012 +0300 description: lib-storage: Removed rename_children parameter from mailbox_rename() The children are now always renamed. The only reason this feature was added in the first place was to make dsync's job easier, but this is no longer needed. diffstat: src/doveadm/doveadm-mail-mailbox.c | 2 +- src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c | 2 +- src/imap/cmd-rename.c | 2 +- src/lib-storage/fail-mailbox.c | 3 +- src/lib-storage/index/imapc/imapc-list.c | 12 +----- src/lib-storage/index/index-storage.c | 6 +-- src/lib-storage/index/index-storage.h | 3 +- src/lib-storage/index/shared/shared-list.c | 6 +-- src/lib-storage/list/mailbox-list-fs.c | 42 ++++------------------ src/lib-storage/list/mailbox-list-index.c | 6 +-- src/lib-storage/list/mailbox-list-maildir.c | 7 +-- src/lib-storage/list/mailbox-list-none.c | 3 +- src/lib-storage/mail-storage-private.h | 3 +- src/lib-storage/mail-storage.c | 5 +- src/lib-storage/mail-storage.h | 9 ++-- src/lib-storage/mailbox-list-private.h | 3 +- src/plugins/acl/acl-mailbox.c | 5 +- src/plugins/lazy-expunge/lazy-expunge-plugin.c | 5 +- src/plugins/mail-log/mail-log-plugin.c | 3 +- src/plugins/notify/notify-plugin-private.h | 3 +- src/plugins/notify/notify-plugin.c | 5 +- src/plugins/notify/notify-plugin.h | 3 +- src/plugins/notify/notify-storage.c | 7 +-- src/plugins/replication/replication-plugin.c | 3 +- 24 files changed, 45 insertions(+), 103 deletions(-) diffs (truncated from 476 to 300 lines): diff -r 920756cd29b8 -r 92cc78c5dc77 src/doveadm/doveadm-mail-mailbox.c --- a/src/doveadm/doveadm-mail-mailbox.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/doveadm/doveadm-mail-mailbox.c Mon Sep 10 17:19:43 2012 +0300 @@ -421,7 +421,7 @@ oldbox = mailbox_alloc(oldns->list, oldname, 0); newbox = mailbox_alloc(newns->list, newname, 0); - if (mailbox_rename(oldbox, newbox, TRUE) < 0) { + if (mailbox_rename(oldbox, newbox) < 0) { i_error("Can't rename mailbox %s to %s: %s", oldname, newname, mailbox_get_last_error(oldbox, NULL)); doveadm_mail_failed_mailbox(_ctx, oldbox); diff -r 920756cd29b8 -r 92cc78c5dc77 src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree-sync.c Mon Sep 10 17:19:43 2012 +0300 @@ -119,7 +119,7 @@ case DSYNC_MAILBOX_TREE_SYNC_TYPE_RENAME: destbox = mailbox_alloc(change->ns->list, change->rename_dest_name, 0); - ret = mailbox_rename(box, destbox, TRUE); + ret = mailbox_rename(box, destbox); func_name = "mailbox_rename"; mailbox_free(&destbox); break; diff -r 920756cd29b8 -r 92cc78c5dc77 src/imap/cmd-rename.c --- a/src/imap/cmd-rename.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/imap/cmd-rename.c Mon Sep 10 17:19:43 2012 +0300 @@ -37,7 +37,7 @@ old_box = mailbox_alloc(old_ns->list, oldname, 0); new_box = mailbox_alloc(new_ns->list, newname, 0); - if (mailbox_rename(old_box, new_box, TRUE) < 0) + if (mailbox_rename(old_box, new_box) < 0) client_send_storage_error(cmd, mailbox_get_storage(old_box)); else client_send_tagline(cmd, "OK Rename completed."); diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/fail-mailbox.c --- a/src/lib-storage/fail-mailbox.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/fail-mailbox.c Mon Sep 10 17:19:43 2012 +0300 @@ -70,8 +70,7 @@ } static int fail_mailbox_rename(struct mailbox *src, - struct mailbox *dest ATTR_UNUSED, - bool rename_children ATTR_UNUSED) + struct mailbox *dest ATTR_UNUSED) { mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, "Mailbox can't be renamed"); diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Mon Sep 10 17:19:43 2012 +0300 @@ -633,20 +633,13 @@ static int imapc_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname, - struct mailbox_list *newlist, const char *newname, - bool rename_children) + struct mailbox_list *newlist, const char *newname) { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)oldlist; struct mailbox_list *fs_list = imapc_list_get_fs(list); struct imapc_command *cmd; struct imapc_simple_context ctx; - if (!rename_children) { - mailbox_list_set_error(oldlist, MAIL_ERROR_NOTPOSSIBLE, - "Renaming without children not supported."); - return -1; - } - if (oldlist != newlist) { mailbox_list_set_error(oldlist, MAIL_ERROR_NOTPOSSIBLE, "Can't rename mailboxes across storages."); @@ -660,8 +653,7 @@ oldname = imapc_list_get_fs_name(list, oldname); newname = imapc_list_get_fs_name(list, newname); (void)fs_list->v.rename_mailbox(fs_list, oldname, - fs_list, newname, - rename_children); + fs_list, newname); } return ctx.ret; } diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Mon Sep 10 17:19:43 2012 +0300 @@ -584,14 +584,12 @@ return 0; } -int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest, - bool rename_children) +int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest) { guid_128_t guid; if (src->list->v.rename_mailbox(src->list, src->name, - dest->list, dest->name, - rename_children) < 0) { + dest->list, dest->name) < 0) { mail_storage_copy_list_error(src->storage, src->list); return -1; } diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/index/index-storage.h Mon Sep 10 17:19:43 2012 +0300 @@ -75,8 +75,7 @@ const struct mailbox_update *update); int index_storage_mailbox_delete(struct mailbox *box); int index_storage_mailbox_delete_dir(struct mailbox *box, bool mailbox_deleted); -int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest, - bool rename_children); +int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest); bool index_storage_is_readonly(struct mailbox *box); bool index_storage_is_inconsistent(struct mailbox *box); diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/index/shared/shared-list.c Mon Sep 10 17:19:43 2012 +0300 @@ -313,8 +313,7 @@ static int shared_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname, - struct mailbox_list *newlist, const char *newname, - bool rename_children) + struct mailbox_list *newlist, const char *newname) { struct mail_namespace *ns; int ret; @@ -323,8 +322,7 @@ newlist, &newname, &ns) < 0) return -1; - ret = ns->list->v.rename_mailbox(ns->list, oldname, ns->list, newname, - rename_children); + ret = ns->list->v.rename_mailbox(ns->list, oldname, ns->list, newname); if (ret < 0) shared_list_copy_error(oldlist, ns); return ret; diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Mon Sep 10 17:19:43 2012 +0300 @@ -482,11 +482,10 @@ static int fs_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname, struct mailbox_list *newlist, - const char *newname, bool rename_children) + const char *newname) { struct mail_storage *oldstorage; const char *oldvname, *oldpath, *newpath, *alt_newpath, *root_path, *p; - enum mailbox_list_path_type path_type, alt_path_type; struct stat st; struct mailbox_permissions old_perm, new_perm; bool rmdir_parent = FALSE; @@ -495,23 +494,12 @@ if (mailbox_list_get_storage(&oldlist, oldvname, &oldstorage) < 0) return -1; - if (rename_children) { - path_type = MAILBOX_LIST_PATH_TYPE_DIR; - alt_path_type = MAILBOX_LIST_PATH_TYPE_ALT_DIR; - } else if (mail_storage_is_mailbox_file(oldstorage) || - *oldlist->set.maildir_name != '\0') { - path_type = MAILBOX_LIST_PATH_TYPE_MAILBOX; - alt_path_type = MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX; - } else { - /* we can't do this, our children would get renamed with us */ - mailbox_list_set_error(oldlist, MAIL_ERROR_NOTPOSSIBLE, - "Can't rename mailbox without its children."); - return -1; - } - - oldpath = mailbox_list_get_path(oldlist, oldname, path_type); - newpath = mailbox_list_get_path(newlist, newname, path_type); - alt_newpath = mailbox_list_get_path(newlist, newname, alt_path_type); + oldpath = mailbox_list_get_path(oldlist, oldname, + MAILBOX_LIST_PATH_TYPE_DIR); + newpath = mailbox_list_get_path(newlist, newname, + MAILBOX_LIST_PATH_TYPE_DIR); + alt_newpath = mailbox_list_get_path(newlist, newname, + MAILBOX_LIST_PATH_TYPE_ALT_DIR); root_path = mailbox_list_get_root_path(oldlist, MAILBOX_LIST_PATH_TYPE_MAILBOX); if (strcmp(oldpath, root_path) == 0) { @@ -597,23 +585,9 @@ return -1; } - if (!rename_children) { - /* if there are no child mailboxes, get rid of the mailbox - directory entirely. */ - oldpath = mailbox_list_get_path(oldlist, oldname, - MAILBOX_LIST_PATH_TYPE_DIR); - if (rmdir(oldpath) == 0) - rmdir_parent = TRUE; - else if (errno != ENOENT && - errno != ENOTEMPTY && errno != EEXIST) { - mailbox_list_set_critical(oldlist, - "rmdir(%s) failed: %m", oldpath); - } - } - if (alt_newpath != NULL) { (void)rename_dir(oldlist, oldname, newlist, newname, - alt_path_type, rmdir_parent); + MAILBOX_LIST_PATH_TYPE_ALT_DIR, rmdir_parent); } (void)rename_dir(oldlist, oldname, newlist, newname, MAILBOX_LIST_PATH_TYPE_CONTROL, rmdir_parent); diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Mon Sep 10 17:19:43 2012 +0300 @@ -373,8 +373,7 @@ mailbox_list_index_rename_mailbox(struct mailbox_list *oldlist, const char *oldname, struct mailbox_list *newlist, - const char *newname, - bool rename_children) + const char *newname) { struct mailbox_list_index *oldilist = INDEX_LIST_CONTEXT(oldlist); @@ -382,8 +381,7 @@ if (oldlist != newlist) mailbox_list_index_refresh_later(newlist); return oldilist->module_ctx.super. - rename_mailbox(oldlist, oldname, - newlist, newname, rename_children); + rename_mailbox(oldlist, oldname, newlist, newname); } static int diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/list/mailbox-list-maildir.c --- a/src/lib-storage/list/mailbox-list-maildir.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir.c Mon Sep 10 17:19:43 2012 +0300 @@ -555,8 +555,7 @@ static int maildir_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname, - struct mailbox_list *newlist, const char *newname, - bool rename_children) + struct mailbox_list *newlist, const char *newname) { const char *oldpath, *newpath, *root_path; int ret; @@ -606,9 +605,7 @@ MAILBOX_LIST_PATH_TYPE_INDEX); found = ret == 0; - if (!rename_children) - ret = 0; - else T_BEGIN { + T_BEGIN { ret = maildir_rename_children(oldlist, oldname, newlist, newname); } T_END; diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/list/mailbox-list-none.c --- a/src/lib-storage/list/mailbox-list-none.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-none.c Mon Sep 10 17:19:43 2012 +0300 @@ -119,8 +119,7 @@ none_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname ATTR_UNUSED, struct mailbox_list *newlist ATTR_UNUSED, - const char *newname ATTR_UNUSED, - bool rename_children ATTR_UNUSED) + const char *newname ATTR_UNUSED) { mailbox_list_set_error(oldlist, MAIL_ERROR_NOTPOSSIBLE, "Not supported"); diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/mail-storage-private.h Mon Sep 10 17:19:43 2012 +0300 @@ -131,8 +131,7 @@ bool directory); int (*update)(struct mailbox *box, const struct mailbox_update *update); int (*delete)(struct mailbox *box); - int (*rename)(struct mailbox *src, struct mailbox *dest, - bool rename_children); + int (*rename)(struct mailbox *src, struct mailbox *dest); int (*get_status)(struct mailbox *box, enum mailbox_status_items items, struct mailbox_status *status_r); diff -r 920756cd29b8 -r 92cc78c5dc77 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Sep 07 16:43:44 2012 +0300 +++ b/src/lib-storage/mail-storage.c Mon Sep 10 17:19:43 2012 +0300 @@ -1206,8 +1206,7 @@ return TRUE; } -int mailbox_rename(struct mailbox *src, struct mailbox *dest, - bool rename_children) +int mailbox_rename(struct mailbox *src, struct mailbox *dest) { const char *error = NULL; @@ -1238,7 +1237,7 @@ return -1; } From dovecot at dovecot.org Tue Sep 11 17:13:58 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 11 Sep 2012 17:13:58 +0300 Subject: dovecot-2.1: acl: Don't add sameuser -> sameuser entries to ACL ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3eaeacc85b4c changeset: 14697:3eaeacc85b4c user: Timo Sirainen date: Tue Sep 11 17:13:51 2012 +0300 description: acl: Don't add sameuser -> sameuser entries to ACL dict. diffstat: src/plugins/acl/acl-lookup-dict.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diffs (29 lines): diff -r cb3f49b649bf -r 3eaeacc85b4c src/plugins/acl/acl-lookup-dict.c --- a/src/plugins/acl/acl-lookup-dict.c Thu Sep 06 16:50:00 2012 +0300 +++ b/src/plugins/acl/acl-lookup-dict.c Tue Sep 11 17:13:51 2012 +0300 @@ -92,6 +92,13 @@ } } +static bool +acl_rights_is_same_user(const struct acl_rights *right, struct mail_user *user) +{ + return right->id_type == ACL_ID_USER && + strcmp(right->identifier, user->username) == 0; +} + static int acl_lookup_dict_rebuild_add_backend(struct mail_namespace *ns, ARRAY_TYPE(const_string) *ids) { @@ -115,7 +122,10 @@ iter = acl_object_list_init(aclobj); while ((ret = acl_object_list_next(iter, &rights)) > 0) { - if (acl_rights_has_nonowner_lookup_changes(&rights)) { + /* avoid pointless user -> user entries, + which some clients do */ + if (acl_rights_has_nonowner_lookup_changes(&rights) && + !acl_rights_is_same_user(&rights, ns->owner)) { str_truncate(id, 0); acl_lookup_dict_write_rights_id(id, &rights); str_append_c(id, '/'); From dovecot at dovecot.org Tue Sep 11 18:26:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 11 Sep 2012 18:26:46 +0300 Subject: dovecot-2.1: lib-master: Decrease initial memory pool size Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f3d532a4feb6 changeset: 14698:f3d532a4feb6 user: Timo Sirainen date: Tue Sep 11 18:26:33 2012 +0300 description: lib-master: Decrease initial memory pool size diffstat: src/lib-master/master-service-settings-cache.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 3eaeacc85b4c -r f3d532a4feb6 src/lib-master/master-service-settings-cache.c --- a/src/lib-master/master-service-settings-cache.c Tue Sep 11 17:13:51 2012 +0300 +++ b/src/lib-master/master-service-settings-cache.c Tue Sep 11 18:26:33 2012 +0300 @@ -59,7 +59,8 @@ struct master_service_settings_cache *cache; pool_t pool; - pool = pool_alloconly_create("master service settings cache", 1024*32); + pool = pool_alloconly_create(MEMPOOL_GROWING"master service settings cache", + 1024*12); cache = p_new(pool, struct master_service_settings_cache, 1); cache->pool = pool; cache->service = service; From dovecot at dovecot.org Tue Sep 11 18:42:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 11 Sep 2012 18:42:23 +0300 Subject: dovecot-2.1: Decrease minimum memory allocations. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9f691edba099 changeset: 14699:9f691edba099 user: Timo Sirainen date: Tue Sep 11 18:42:05 2012 +0300 description: Decrease minimum memory allocations. This is mainly to avoid wasting settings-related memory for IMAP processes. Probably something more radical should be done at some point. diffstat: src/lib-imap/imap-parser.c | 2 +- src/lib-settings/settings-parser.c | 4 ++-- src/lib-storage/mail-storage-service.c | 2 +- src/lib/hash.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diffs (57 lines): diff -r f3d532a4feb6 -r 9f691edba099 src/lib-imap/imap-parser.c --- a/src/lib-imap/imap-parser.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib-imap/imap-parser.c Tue Sep 11 18:42:05 2012 +0300 @@ -59,7 +59,7 @@ parser = i_new(struct imap_parser, 1); parser->refcount = 1; parser->pool = pool_alloconly_create(MEMPOOL_GROWING"IMAP parser", - 1024*10); + 1024); parser->input = input; parser->output = output; parser->max_line_size = max_line_size; diff -r f3d532a4feb6 -r 9f691edba099 src/lib-settings/settings-parser.c --- a/src/lib-settings/settings-parser.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib-settings/settings-parser.c Tue Sep 11 18:42:05 2012 +0300 @@ -201,7 +201,7 @@ i_assert(count > 0); parser_pool = pool_alloconly_create(MEMPOOL_GROWING"settings parser", - 8192); + 1024); ctx = p_new(parser_pool, struct setting_parser_context, 1); ctx->set_pool = set_pool; ctx->parser_pool = parser_pool; @@ -1741,7 +1741,7 @@ pool_ref(new_pool); parser_pool = pool_alloconly_create(MEMPOOL_GROWING"dup settings parser", - 8192); + 1024); new_ctx = p_new(parser_pool, struct setting_parser_context, 1); new_ctx->set_pool = new_pool; new_ctx->parser_pool = parser_pool; diff -r f3d532a4feb6 -r 9f691edba099 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Sep 11 18:42:05 2012 +0300 @@ -945,7 +945,7 @@ pool_t user_pool, temp_pool; int ret = 1; - user_pool = pool_alloconly_create("mail storage service user", 1024*8); + user_pool = pool_alloconly_create("mail storage service user", 1024*6); if (mail_storage_service_read_settings(ctx, input, user_pool, &user_info, &set_parser, diff -r f3d532a4feb6 -r 9f691edba099 src/lib/hash.c --- a/src/lib/hash.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib/hash.c Tue Sep 11 18:42:05 2012 +0300 @@ -8,7 +8,7 @@ #include -#define HASH_TABLE_MIN_SIZE 131 +#define HASH_TABLE_MIN_SIZE 67 struct hash_node { struct hash_node *next; From dovecot at dovecot.org Tue Sep 11 18:56:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 11 Sep 2012 18:56:18 +0300 Subject: dovecot-2.2: i_get(pw|gr)(nam|uid): Use small initial buffer sizes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/349d52c4ca51 changeset: 15039:349d52c4ca51 user: Timo Sirainen date: Tue Sep 11 18:56:07 2012 +0300 description: i_get(pw|gr)(nam|uid): Use small initial buffer sizes. For processes that need to do only a single lookup there's no point in wasting a lot of memory for the maximum buffer size. diffstat: src/lib/ipwd.c | 64 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 34 insertions(+), 30 deletions(-) diffs (115 lines): diff -r 92cc78c5dc77 -r 349d52c4ca51 src/lib/ipwd.c --- a/src/lib/ipwd.c Mon Sep 10 17:19:43 2012 +0300 +++ b/src/lib/ipwd.c Tue Sep 11 18:56:07 2012 +0300 @@ -6,41 +6,33 @@ #include -#define DEFAULT_PWBUF_SIZE 16384 -#define DEFAULT_GRBUF_SIZE 16384 +#define PWBUF_MIN_SIZE 128 +#define GRBUF_MIN_SIZE 128 static void *pwbuf = NULL, *grbuf = NULL; static size_t pwbuf_size, grbuf_size; static void pw_init(void) { - long size; + size_t old_pwbuf_size = pwbuf_size; - if (pwbuf == NULL) { - size = sysconf(_SC_GETPW_R_SIZE_MAX); - if (size < 0) - size = DEFAULT_PWBUF_SIZE; - - pwbuf_size = size; - pwbuf = i_malloc(pwbuf_size); + if (pwbuf == NULL || errno == ERANGE) { + pwbuf_size = nearest_power(old_pwbuf_size + 1); + if (pwbuf_size < PWBUF_MIN_SIZE) + pwbuf_size = PWBUF_MIN_SIZE; + pwbuf = i_realloc(pwbuf, old_pwbuf_size, pwbuf_size); } } static void gr_init(void) { - long size; + size_t old_grbuf_size = grbuf_size; - if (grbuf == NULL) { - size = sysconf(_SC_GETGR_R_SIZE_MAX); - /* Some BSDs return too low value for this. instead of trying - to figure out exactly which, just make sure it's at least - a reasonable size. if the real size is smaller, it doesn't - matter much that we waste a few kilobytes of memory. */ - if (size < DEFAULT_GRBUF_SIZE) - size = DEFAULT_GRBUF_SIZE; - - grbuf_size = size; - grbuf = i_malloc(grbuf_size); + if (grbuf == NULL || errno == ERANGE) { + grbuf_size = nearest_power(old_grbuf_size + 1); + if (grbuf_size < PWBUF_MIN_SIZE) + grbuf_size = PWBUF_MIN_SIZE; + grbuf = i_realloc(grbuf, old_grbuf_size, grbuf_size); } } @@ -54,8 +46,11 @@ { struct passwd *result; - pw_init(); - errno = getpwnam_r(name, pwd_r, pwbuf, pwbuf_size, &result); + errno = 0; + do { + pw_init(); + errno = getpwnam_r(name, pwd_r, pwbuf, pwbuf_size, &result); + } while (errno == ERANGE); if (result != NULL) return 1; return errno == 0 ? 0 : -1; @@ -65,8 +60,11 @@ { struct passwd *result; - pw_init(); - errno = getpwuid_r(uid, pwd_r, pwbuf, pwbuf_size, &result); + errno = 0; + do { + pw_init(); + errno = getpwuid_r(uid, pwd_r, pwbuf, pwbuf_size, &result); + } while (errno == ERANGE); if (result != NULL) return 1; return errno == 0 ? 0 : -1; @@ -76,8 +74,11 @@ { struct group *result; - gr_init(); - errno = getgrnam_r(name, grp_r, grbuf, grbuf_size, &result); + errno = 0; + do { + gr_init(); + errno = getgrnam_r(name, grp_r, grbuf, grbuf_size, &result); + } while (errno == ERANGE); if (result != NULL) return 1; return errno == 0 ? 0 : -1; @@ -87,8 +88,11 @@ { struct group *result; - gr_init(); - errno = getgrgid_r(gid, grp_r, grbuf, grbuf_size, &result); + errno = 0; + do { + gr_init(); + errno = getgrgid_r(gid, grp_r, grbuf, grbuf_size, &result); + } while (errno == ERANGE); if (result != NULL) return 1; return errno == 0 ? 0 : -1; From dovecot at dovecot.org Tue Sep 11 19:14:31 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 11 Sep 2012 19:14:31 +0300 Subject: dovecot-2.1: lib-storage: Fixed memory leak getting MAILBOX_META... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3e1f1b6887c8 changeset: 14700:3e1f1b6887c8 user: Dafan Zhai date: Tue Sep 11 19:14:09 2012 +0300 description: lib-storage: Fixed memory leak getting MAILBOX_METADATA_VIRTUAL_SIZE Function virtual_size_add_new forgets to free the 'search_args' object after it searches the mails. --- src/lib-storage/index/index-status.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffstat: src/lib-storage/index/index-status.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 9f691edba099 -r 3e1f1b6887c8 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Tue Sep 11 18:42:05 2012 +0300 +++ b/src/lib-storage/index/index-status.c Tue Sep 11 19:14:09 2012 +0300 @@ -217,6 +217,7 @@ } if (mailbox_search_deinit(&search_ctx) < 0) ret = -1; + mail_search_args_unref(&search_args); if (ret == 0) { /* success, cache all */ From dovecot at dovecot.org Tue Sep 11 20:45:56 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 11 Sep 2012 20:45:56 +0300 Subject: dovecot-2.1: lib-imap: Added IMAP_PARSE_FLAG_SERVER_TEXT that fi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/382df961f290 changeset: 14701:382df961f290 user: Timo Sirainen date: Tue Sep 11 20:44:37 2012 +0300 description: lib-imap: Added IMAP_PARSE_FLAG_SERVER_TEXT that fixes parsing input from IMAP server. diffstat: src/lib-imap/imap-parser.c | 78 +++++++++++++++++++++++++++++++++++++++++++++- src/lib-imap/imap-parser.h | 6 ++- 2 files changed, 82 insertions(+), 2 deletions(-) diffs (160 lines): diff -r 3e1f1b6887c8 -r 382df961f290 src/lib-imap/imap-parser.c --- a/src/lib-imap/imap-parser.c Tue Sep 11 19:14:09 2012 +0300 +++ b/src/lib-imap/imap-parser.c Tue Sep 11 20:44:37 2012 +0300 @@ -17,7 +17,8 @@ ARG_PARSE_STRING, ARG_PARSE_LITERAL, ARG_PARSE_LITERAL_DATA, - ARG_PARSE_LITERAL_DATA_FORCED + ARG_PARSE_LITERAL_DATA_FORCED, + ARG_PARSE_TEXT }; struct imap_parser { @@ -37,6 +38,7 @@ enum arg_parse_type cur_type; size_t cur_pos; /* parser position in input buffer */ + bool cur_resp_text; /* we're parsing [resp-text-code] */ int str_first_escape; /* ARG_PARSE_STRING: index to first '\' */ uoff_t literal_size; /* ARG_PARSE_LITERAL: string size */ @@ -100,6 +102,7 @@ parser->cur_type = ARG_PARSE_NONE; parser->cur_pos = 0; + parser->cur_resp_text = FALSE; parser->str_first_escape = 0; parser->literal_size = 0; @@ -210,6 +213,7 @@ switch (parser->cur_type) { case ARG_PARSE_ATOM: + case ARG_PARSE_TEXT: if (size == 3 && memcmp(data, "NIL", 3) == 0) { /* NIL argument */ arg->type = IMAP_ARG_NIL; @@ -468,6 +472,56 @@ } } +static bool imap_parser_is_next_resp_text(struct imap_parser *parser) +{ + const struct imap_arg *arg; + + if (parser->cur_list != &parser->root_list || + array_count(parser->cur_list) != 1) + return FALSE; + + arg = array_idx(&parser->root_list, 0); + if (arg->type != IMAP_ARG_ATOM) + return FALSE; + + return strcasecmp(arg->_data.str, "OK") == 0 || + strcasecmp(arg->_data.str, "NO") == 0 || + strcasecmp(arg->_data.str, "BAD") == 0 || + strcasecmp(arg->_data.str, "BYE") == 0; +} + +static bool imap_parser_is_next_text(struct imap_parser *parser) +{ + const struct imap_arg *arg; + unsigned int len; + + if (parser->cur_list != &parser->root_list) + return FALSE; + + arg = array_idx(&parser->root_list, array_count(&parser->root_list)-1); + if (arg->type != IMAP_ARG_ATOM) + return FALSE; + + len = strlen(arg->_data.str); + return len > 0 && arg->_data.str[len-1] == ']'; +} + +static bool imap_parser_read_text(struct imap_parser *parser, + const unsigned char *data, size_t data_size) +{ + size_t i; + + /* read until end of line */ + for (i = parser->cur_pos; i < data_size; i++) { + if (is_linebreak(data[i])) { + imap_parser_save_arg(parser, data, i); + break; + } + } + parser->cur_pos = i; + return parser->cur_type == ARG_PARSE_NONE; +} + /* Returns TRUE if argument was fully processed. Also returns TRUE if an argument inside a list was processed. */ static int imap_parser_read_arg(struct imap_parser *parser) @@ -485,6 +539,13 @@ return FALSE; i_assert(parser->cur_pos == 0); + if (parser->cur_resp_text && + imap_parser_is_next_text(parser)) { + /* we just parsed [resp-text-code] */ + parser->cur_type = ARG_PARSE_TEXT; + break; + } + switch (data[0]) { case '\r': if (data_size == 1) { @@ -538,6 +599,16 @@ case ARG_PARSE_ATOM: if (!imap_parser_read_atom(parser, data, data_size)) return FALSE; + if ((parser->flags & IMAP_PARSE_FLAG_SERVER_TEXT) == 0) + break; + + if (imap_parser_is_next_resp_text(parser)) { + /* we just parsed OK/NO/BAD/BYE. after parsing the + [resp-text-code] the rest of the message can contain + pretty much any random text, which we can't parse + as if it was valid IMAP input */ + parser->cur_resp_text = TRUE; + } break; case ARG_PARSE_STRING: if (!imap_parser_read_string(parser, data, data_size)) @@ -557,6 +628,10 @@ if (!imap_parser_read_literal_data(parser, data, data_size)) return FALSE; break; + case ARG_PARSE_TEXT: + if (!imap_parser_read_text(parser, data, data_size)) + return FALSE; + break; default: i_unreached(); } @@ -579,6 +654,7 @@ parser->line_size += parser->cur_pos; i_stream_skip(parser->input, parser->cur_pos); parser->cur_pos = 0; + parser->cur_resp_text = FALSE; if (parser->list_arg != NULL && !parser->literal_size_return) { parser->error = "Missing ')'"; diff -r 3e1f1b6887c8 -r 382df961f290 src/lib-imap/imap-parser.h --- a/src/lib-imap/imap-parser.h Tue Sep 11 19:14:09 2012 +0300 +++ b/src/lib-imap/imap-parser.h Tue Sep 11 20:44:37 2012 +0300 @@ -16,7 +16,11 @@ /* Don't check if atom contains invalid characters */ IMAP_PARSE_FLAG_ATOM_ALLCHARS = 0x08, /* Allow strings to contain CRLFs */ - IMAP_PARSE_FLAG_MULTILINE_STR = 0x10 + IMAP_PARSE_FLAG_MULTILINE_STR = 0x10, + /* We're parsing IMAP server replies. Parse the "text" after + OK/NO/BAD/BYE replies as a single atom. We assume that the initial + "*" or tag was already skipped over. */ + IMAP_PARSE_FLAG_SERVER_TEXT = 0x20 }; struct imap_parser; From dovecot at dovecot.org Tue Sep 11 20:45:56 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 11 Sep 2012 20:45:56 +0300 Subject: dovecot-2.1: imapc: Fixed parsing "text" input after OK/NO/BAD/BYE. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/245fe7fd6f00 changeset: 14702:245fe7fd6f00 user: Timo Sirainen date: Tue Sep 11 20:45:38 2012 +0300 description: imapc: Fixed parsing "text" input after OK/NO/BAD/BYE. diffstat: src/lib-imap-client/imapc-connection.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diffs (51 lines): diff -r 382df961f290 -r 245fe7fd6f00 src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Tue Sep 11 20:44:37 2012 +0300 +++ b/src/lib-imap-client/imapc-connection.c Tue Sep 11 20:45:38 2012 +0300 @@ -493,7 +493,8 @@ ret = imap_parser_read_args(conn->parser, 0, IMAP_PARSE_FLAG_LITERAL_SIZE | - IMAP_PARSE_FLAG_ATOM_ALLCHARS, imap_args_r); + IMAP_PARSE_FLAG_ATOM_ALLCHARS | + IMAP_PARSE_FLAG_SERVER_TEXT, imap_args_r); if (ret == -2) { /* need more data */ return 0; @@ -813,6 +814,9 @@ if ((ret = imapc_connection_read_line(conn, &imap_args)) <= 0) return ret; + /* we already verified that the banner beigns with OK */ + i_assert(imap_arg_atom_equals(imap_args, "OK")); + imap_args++; if (imapc_connection_handle_imap_resp_text(conn, imap_args, &key, &value) < 0) @@ -836,6 +840,8 @@ static int imapc_connection_input_untagged(struct imapc_connection *conn) { const struct imap_arg *imap_args; + const unsigned char *data; + size_t size; const char *name, *value; struct imap_parser *parser; struct imapc_untagged_reply reply; @@ -843,13 +849,13 @@ if (conn->state == IMAPC_CONNECTION_STATE_CONNECTING) { /* input banner */ - name = imap_parser_read_word(conn->parser); - if (name == NULL) + data = i_stream_get_data(conn->input, &size); + if (size < 3 && memchr(data, '\n', size) == NULL) return 0; - - if (strcasecmp(name, "OK") != 0) { + if (i_memcasecmp(data, "OK ", 3) != 0) { imapc_connection_input_error(conn, - "Banner doesn't begin with OK: %s", name); + "Banner doesn't begin with OK: %s", + t_strcut(t_strndup(data, size), '\n')); return -1; } conn->input_callback = imapc_connection_input_banner; From dovecot at dovecot.org Wed Sep 12 00:04:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Sep 2012 00:04:44 +0300 Subject: dovecot-2.1: director: Already seen USER-WEAK command caused dir... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/24e791bbcf69 changeset: 14703:24e791bbcf69 user: Timo Sirainen date: Wed Sep 12 00:04:34 2012 +0300 description: director: Already seen USER-WEAK command caused director to disconnect. diffstat: src/director/director-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 245fe7fd6f00 -r 24e791bbcf69 src/director/director-connection.c --- a/src/director/director-connection.c Tue Sep 11 20:45:38 2012 +0300 +++ b/src/director/director-connection.c Wed Sep 12 00:04:34 2012 +0300 @@ -712,7 +712,7 @@ int ret; if ((ret = director_cmd_is_seen(conn, &args, &dir_host)) != 0) - return FALSE; + return ret > 0; if (str_array_length(args) != 2 || str_to_uint(args[0], &username_hash) < 0 || From dovecot at dovecot.org Wed Sep 12 00:20:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 12 Sep 2012 00:20:57 +0300 Subject: dovecot-2.1: director: Improved logging related to disconnections. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/27d3289e1f5c changeset: 14704:27d3289e1f5c user: Timo Sirainen date: Wed Sep 12 00:20:47 2012 +0300 description: director: Improved logging related to disconnections. diffstat: src/director/director-connection.c | 135 ++++++++++++++++++++++++++---------- src/director/director-connection.h | 3 +- src/director/director.c | 9 +- src/director/director.h | 4 +- 4 files changed, 109 insertions(+), 42 deletions(-) diffs (truncated from 359 to 300 lines): diff -r 24e791bbcf69 -r 27d3289e1f5c src/director/director-connection.c --- a/src/director/director-connection.c Wed Sep 12 00:04:34 2012 +0300 +++ b/src/director/director-connection.c Wed Sep 12 00:20:47 2012 +0300 @@ -71,6 +71,8 @@ mark the host as failed so we won't try to reconnect to it immediately */ #define DIRECTOR_SUCCESS_MIN_CONNECT_SECS 40 #define DIRECTOR_WAIT_DISCONNECT_SECS 10 +#define DIRECTOR_HANDSHAKE_WARN_SECS 29 +#define DIRECTOR_HANDSHAKE_BYTES_LOG_MIN_SECS (60*30) #if DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS <= DIRECTOR_CONNECTION_PING_TIMEOUT_MSECS # error DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS is too low @@ -92,6 +94,8 @@ /* for incoming connections the director host isn't known until ME-line is received */ struct director_host *host; + /* this is set only for wrong connections: */ + struct director_host *connect_request_to; int fd; struct io *io; @@ -118,7 +122,9 @@ }; static void director_connection_disconnected(struct director_connection **conn); -static void director_connection_reconnect(struct director_connection **conn); +static void director_connection_reconnect(struct director_connection **conn, + const char *reason); +static void director_connection_log_disconnect(struct director_connection *conn); static void ATTR_FORMAT(2, 3) director_cmd_error(struct director_connection *conn, const char *fmt, ...) @@ -169,7 +175,9 @@ static void director_connection_wait_timeout(struct director_connection *conn) { - director_connection_deinit(&conn); + director_connection_log_disconnect(conn); + director_connection_deinit(&conn, + "Timeout waiting for disconnect after CONNECT"); } static void director_connection_send_connect(struct director_connection *conn, @@ -186,6 +194,12 @@ (void)o_stream_flush(conn->output); o_stream_uncork(conn->output); + /* wait for a while for the remote to disconnect, so it will hopefully + see our CONNECT command. we'll also log the warning later to avoid + multiple log lines about it. */ + conn->connect_request_to = host; + director_host_ref(conn->connect_request_to); + conn->to_disconnect = timeout_add(DIRECTOR_WAIT_DISCONNECT_SECS*1000, director_connection_wait_timeout, conn); @@ -220,10 +234,10 @@ } else if (dir->left == NULL) { /* no conflicts yet */ } else if (dir->left->host == conn->host) { - i_info("Dropping existing connection %s " - "in favor of its new connection %s", - dir->left->host->name, conn->host->name); - director_connection_deinit(&dir->left); + i_warning("Replacing left director connection %s with %s", + dir->left->host->name, conn->host->name); + director_connection_deinit(&dir->left, t_strdup_printf( + "Replacing with %s", conn->host->name)); } else if (dir->left->verifying_left) { /* we're waiting to verify if our current left is still working. if we don't receive a PONG, the current left @@ -235,9 +249,6 @@ dir->self_host) < 0) { /* the old connection is the correct one. refer the client there (FIXME: do we ever get here?) */ - i_warning("Director connection %s tried to connect to " - "us, should use %s instead", - conn->name, dir->left->host->name); director_connection_send_connect(conn, dir->left->host); return TRUE; } else { @@ -267,7 +278,8 @@ /* either use this or disconnect it */ if (!director_connection_assign_left(conn)) { /* we don't want this */ - director_connection_deinit(&conn); + director_connection_deinit(&conn, + "Unwanted incoming connection"); director_assign_left(dir); break; } @@ -304,9 +316,10 @@ conn->wrong_host = TRUE; return FALSE; } - i_info("Replacing right director connection %s with %s", - dir->right->host->name, conn->host->name); - director_connection_deinit(&dir->right); + i_warning("Replacing right director connection %s with %s", + dir->right->host->name, conn->host->name); + director_connection_deinit(&dir->right, t_strdup_printf( + "Replacing with %s", conn->host->name)); } dir->right = conn; i_free(conn->name); @@ -410,7 +423,8 @@ } else if (dir->left->host == conn->host) { /* b) */ i_assert(dir->left != conn); - director_connection_deinit(&dir->left); + director_connection_deinit(&dir->left, + "Replacing with new incoming connection"); } else if (director_host_cmp_to_self(conn->host, dir->left->host, dir->self_host) < 0) { /* c) */ @@ -919,14 +933,19 @@ static bool director_handshake_cmd_done(struct director_connection *conn) { struct director *dir = conn->dir; + unsigned int handshake_secs = time(NULL) - conn->created; + string_t *str; - if (dir->debug) { - unsigned int secs = time(NULL)-conn->created; - - i_debug("director(%s): Handshake took %u secs, " - "bytes in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, - conn->name, secs, conn->input->v_offset, - conn->output->offset); + if (handshake_secs >= DIRECTOR_HANDSHAKE_WARN_SECS || dir->debug) { + str = t_str_new(128); + str_printfa(str, "director(%s): Handshake took %u secs, " + "bytes in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, + conn->name, handshake_secs, conn->input->v_offset, + conn->output->offset); + if (handshake_secs >= DIRECTOR_HANDSHAKE_WARN_SECS) + i_warning("%s", str_c(str)); + else + i_debug("%s", str_c(str)); } /* the host is up now, make sure we can connect to it immediately @@ -1143,12 +1162,8 @@ if (conn->in && conn != dir->left && conn->me_received && conn->to_disconnect == NULL && director_host_cmp_to_self(dir->left->host, conn->host, - dir->self_host) < 0) { - i_warning("Director connection %s tried to connect to " - "us, should use %s instead", - conn->name, dir->left->host->name); + dir->self_host) < 0) director_connection_send_connect(conn, dir->left->host); - } } } @@ -1220,6 +1235,11 @@ return director_connection_sync(conn, args); if (strcmp(cmd, "CONNECT") == 0) return director_cmd_connect(conn, args); + if (strcmp(cmd, "QUIT") == 0) { + i_warning("Director %s disconnected us with reason: %s", + conn->name, t_strarray_join(args, " ")); + return FALSE; + } director_cmd_error(conn, "Unknown command %s", cmd); return FALSE; @@ -1247,6 +1267,37 @@ return ret; } +static void +director_connection_log_disconnect(struct director_connection *conn) +{ + unsigned int secs = ioloop_time - conn->created; + string_t *str = t_str_new(128); + + i_assert(conn->connected); + + if (conn->connect_request_to != NULL) { + i_warning("Director %s tried to connect to us, " + "should use %s instead", + conn->name, conn->connect_request_to->name); + return; + } + + str_printfa(str, "Director %s disconnected: ", conn->name); + str_append(str, "Connection closed"); + if (errno != 0 && errno != EPIPE) + str_printfa(str, ": %m"); + + str_printfa(str, " (connected %u secs, " + "in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, + secs, conn->input->v_offset, conn->output->offset); + + if (!conn->me_received) + str_append(str, ", handshake ME not received"); + else if (!conn->handshake_received) + str_append(str, ", handshake DONE not received"); + i_error("%s", str_c(str)); +} + static void director_connection_input(struct director_connection *conn) { struct director *dir = conn->dir; @@ -1258,16 +1309,14 @@ return; case -1: /* disconnected */ - i_error("Director %s disconnected%s", conn->name, - conn->handshake_received ? "" : - " before handshake finished"); + director_connection_log_disconnect(conn); director_connection_disconnected(&conn); return; case -2: /* buffer full */ director_cmd_error(conn, "Director sent us more than %d bytes", MAX_INBUF_SIZE); - director_connection_reconnect(&conn); + director_connection_reconnect(&conn, "Too long input line"); return; } @@ -1289,7 +1338,8 @@ } T_END; if (!ret) { - director_connection_reconnect(&conn); + director_connection_reconnect(&conn, t_strdup_printf( + "Invalid input: %s", line)); break; } } @@ -1474,7 +1524,8 @@ return conn; } -void director_connection_deinit(struct director_connection **_conn) +void director_connection_deinit(struct director_connection **_conn, + const char *remote_reason) { struct director_connection *const *conns, *conn = *_conn; struct director *dir = conn->dir; @@ -1482,8 +1533,15 @@ *_conn = NULL; - if (dir->debug && conn->host != NULL) - i_debug("Disconnecting from %s", conn->host->name); + if (dir->debug && conn->host != NULL) { + i_debug("Disconnecting from %s: %s", + conn->host->name, remote_reason); + } + if (*remote_reason != '\0' && + conn->minor_version >= DIRECTOR_VERSION_QUIT) { + o_stream_send_str(conn->output, t_strdup_printf( + "QUIT\t%s\n", remote_reason)); + } conns = array_get(&dir->connections, &count); for (i = 0; i < count; i++) { @@ -1504,6 +1562,8 @@ if (conn->host != NULL) director_host_unref(conn->host); + if (conn->connect_request_to != NULL) + director_host_unref(conn->connect_request_to); if (conn->user_iter != NULL) user_directory_iter_deinit(&conn->user_iter); if (conn->to_disconnect != NULL) @@ -1542,17 +1602,18 @@ conn->host->last_network_failure = ioloop_time; } - director_connection_deinit(_conn); + director_connection_deinit(_conn, ""); if (dir->right == NULL) director_connect(dir); } -void director_connection_reconnect(struct director_connection **_conn) +static void director_connection_reconnect(struct director_connection **_conn, + const char *reason) { struct director_connection *conn = *_conn; struct director *dir = conn->dir; - director_connection_deinit(_conn); + director_connection_deinit(_conn, reason); if (dir->right == NULL) director_connect(dir); } diff -r 24e791bbcf69 -r 27d3289e1f5c src/director/director-connection.h --- a/src/director/director-connection.h Wed Sep 12 00:04:34 2012 +0300 +++ b/src/director/director-connection.h Wed Sep 12 00:20:47 2012 +0300 @@ -10,7 +10,8 @@ struct director_connection * director_connection_init_out(struct director *dir, int fd, From dovecot at dovecot.org Thu Sep 13 10:53:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Sep 2012 10:53:57 +0300 Subject: dovecot-2.2: lib-storage: Moved mail_storage_settings_to_index_f... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d7dd5cdf1ba7 changeset: 15040:d7dd5cdf1ba7 user: Timo Sirainen date: Thu Sep 13 10:52:52 2012 +0300 description: lib-storage: Moved mail_storage_settings_to_index_flags to mail-storage-private.h This is mainly to allow #including mail-storage-settings.h from C++ code without having to #include mail-index.h from mail-storage-settings.h diffstat: src/lib-storage/list/mailbox-list-index.c | 1 + src/lib-storage/mail-storage-private.h | 3 +++ src/lib-storage/mail-storage-settings.c | 16 ---------------- src/lib-storage/mail-storage-settings.h | 3 --- src/lib-storage/mail-storage.c | 16 ++++++++++++++++ 5 files changed, 20 insertions(+), 19 deletions(-) diffs (84 lines): diff -r 349d52c4ca51 -r d7dd5cdf1ba7 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Tue Sep 11 18:56:07 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Thu Sep 13 10:52:52 2012 +0300 @@ -6,6 +6,7 @@ #include "str.h" #include "mail-index-view-private.h" #include "mail-storage-hooks.h" +#include "mail-storage-private.h" #include "mailbox-list-index.h" #define MAILBOX_LIST_INDEX_REFRESH_DELAY_MSECS 1000 diff -r 349d52c4ca51 -r d7dd5cdf1ba7 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Tue Sep 11 18:56:07 2012 +0300 +++ b/src/lib-storage/mail-storage-private.h Thu Sep 13 10:52:52 2012 +0300 @@ -565,4 +565,7 @@ unsigned int secs); void mail_storage_free_binary_cache(struct mail_storage *storage); +enum mail_index_open_flags +mail_storage_settings_to_index_flags(const struct mail_storage_settings *set); + #endif diff -r 349d52c4ca51 -r d7dd5cdf1ba7 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Tue Sep 11 18:56:07 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.c Thu Sep 13 10:52:52 2012 +0300 @@ -298,22 +298,6 @@ storage->name); } -enum mail_index_open_flags -mail_storage_settings_to_index_flags(const struct mail_storage_settings *set) -{ - enum mail_index_open_flags index_flags = 0; - -#ifndef MMAP_CONFLICTS_WRITE - if (set->mmap_disable) -#endif - index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE; - if (set->dotlock_use_excl) - index_flags |= MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL; - if (set->mail_nfs_index) - index_flags |= MAIL_INDEX_OPEN_FLAG_NFS_FLUSH; - return index_flags; -} - const struct dynamic_settings_parser * mail_storage_get_dynamic_parsers(pool_t pool) { diff -r 349d52c4ca51 -r d7dd5cdf1ba7 src/lib-storage/mail-storage-settings.h --- a/src/lib-storage/mail-storage-settings.h Tue Sep 11 18:56:07 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.h Thu Sep 13 10:52:52 2012 +0300 @@ -110,9 +110,6 @@ mail_user_set_get_storage_set(struct mail_user *user); const void *mail_storage_get_driver_settings(struct mail_storage *storage); -enum mail_index_open_flags -mail_storage_settings_to_index_flags(const struct mail_storage_settings *set); - const struct dynamic_settings_parser * mail_storage_get_dynamic_parsers(pool_t pool); diff -r 349d52c4ca51 -r d7dd5cdf1ba7 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Tue Sep 11 18:56:07 2012 +0300 +++ b/src/lib-storage/mail-storage.c Thu Sep 13 10:52:52 2012 +0300 @@ -1896,3 +1896,19 @@ return storage->set->mail_max_lock_timeout == 0 ? secs : I_MIN(secs, storage->set->mail_max_lock_timeout); } + +enum mail_index_open_flags +mail_storage_settings_to_index_flags(const struct mail_storage_settings *set) +{ + enum mail_index_open_flags index_flags = 0; + +#ifndef MMAP_CONFLICTS_WRITE + if (set->mmap_disable) +#endif + index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE; + if (set->dotlock_use_excl) + index_flags |= MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL; + if (set->mail_nfs_index) + index_flags |= MAIL_INDEX_OPEN_FLAG_NFS_FLUSH; + return index_flags; +} From dovecot at dovecot.org Thu Sep 13 10:53:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Sep 2012 10:53:57 +0300 Subject: dovecot-2.2: lib-storage API change to allow using it from C++ code Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7c6d30280cff changeset: 15041:7c6d30280cff user: Timo Sirainen date: Thu Sep 13 10:53:38 2012 +0300 description: lib-storage API change to allow using it from C++ code diffstat: src/lib-storage/mail-storage-private.h | 11 ++++++----- src/lib-storage/mail-storage.c | 8 ++++---- src/plugins/acl/acl-mailbox.c | 16 ++++++++-------- src/plugins/lazy-expunge/lazy-expunge-plugin.c | 6 +++--- src/plugins/notify/notify-storage.c | 16 ++++++++-------- 5 files changed, 29 insertions(+), 28 deletions(-) diffs (192 lines): diff -r d7dd5cdf1ba7 -r 7c6d30280cff src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Thu Sep 13 10:52:52 2012 +0300 +++ b/src/lib-storage/mail-storage-private.h Thu Sep 13 10:53:38 2012 +0300 @@ -127,11 +127,12 @@ void (*close)(struct mailbox *box); void (*free)(struct mailbox *box); - int (*create)(struct mailbox *box, const struct mailbox_update *update, - bool directory); - int (*update)(struct mailbox *box, const struct mailbox_update *update); - int (*delete)(struct mailbox *box); - int (*rename)(struct mailbox *src, struct mailbox *dest); + int (*create_box)(struct mailbox *box, + const struct mailbox_update *update, bool directory); + int (*update_box)(struct mailbox *box, + const struct mailbox_update *update); + int (*delete_box)(struct mailbox *box); + int (*rename_box)(struct mailbox *src, struct mailbox *dest); int (*get_status)(struct mailbox *box, enum mailbox_status_items items, struct mailbox_status *status_r); diff -r d7dd5cdf1ba7 -r 7c6d30280cff src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Sep 13 10:52:52 2012 +0300 +++ b/src/lib-storage/mail-storage.c Thu Sep 13 10:53:38 2012 +0300 @@ -1056,7 +1056,7 @@ mailbox_refresh_permissions(box); box->creating = TRUE; - ret = box->v.create(box, update, directory); + ret = box->v.create_box(box, update, directory); box->creating = FALSE; return ret; } @@ -1067,7 +1067,7 @@ update->min_first_recent_uid == 0 || update->min_first_recent_uid <= update->min_next_uid); - return box->v.update(box, update); + return box->v.update_box(box, update); } int mailbox_mark_index_deleted(struct mailbox *box, bool del) @@ -1133,7 +1133,7 @@ /* \noselect mailbox */ } - ret = box->v.delete(box); + ret = box->v.delete_box(box); if (ret < 0 && box->marked_deleted) { /* deletion failed. revert the mark so it can maybe be tried again later. */ @@ -1237,7 +1237,7 @@ return -1; } - return src->v.rename(src, dest); + return src->v.rename_box(src, dest); } int mailbox_set_subscribed(struct mailbox *box, bool set) diff -r d7dd5cdf1ba7 -r 7c6d30280cff src/plugins/acl/acl-mailbox.c --- a/src/plugins/acl/acl-mailbox.c Thu Sep 13 10:52:52 2012 +0300 +++ b/src/plugins/acl/acl-mailbox.c Thu Sep 13 10:53:38 2012 +0300 @@ -129,7 +129,7 @@ super.create() may call e.g. mailbox_open() which will fail since we haven't yet copied ACLs to this mailbox. */ abox->skip_acl_checks = TRUE; - ret = abox->module_ctx.super.create(box, update, directory); + ret = abox->module_ctx.super.create_box(box, update, directory); abox->skip_acl_checks = FALSE; if (ret == 0) acl_mailbox_copy_acls_from_parent(box); @@ -145,7 +145,7 @@ ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_ADMIN); if (ret <= 0) return -1; - return abox->module_ctx.super.update(box, update); + return abox->module_ctx.super.update_box(box, update); } static void acl_mailbox_fail_not_found(struct mailbox *box) @@ -178,7 +178,7 @@ /* deletion might internally open the mailbox. let it succeed even if we don't have READ permission. */ abox->skip_acl_checks = TRUE; - ret = abox->module_ctx.super.delete(box); + ret = abox->module_ctx.super.delete_box(box); abox->skip_acl_checks = FALSE; return ret; } @@ -216,7 +216,7 @@ return -1; } - return abox->module_ctx.super.rename(src, dest); + return abox->module_ctx.super.rename_box(src, dest); } static int @@ -540,10 +540,10 @@ v->exists = acl_mailbox_exists; v->open = acl_mailbox_open; v->get_status = acl_mailbox_get_status; - v->create = acl_mailbox_create; - v->update = acl_mailbox_update; - v->delete = acl_mailbox_delete; - v->rename = acl_mailbox_rename; + v->create_box = acl_mailbox_create; + v->update_box = acl_mailbox_update; + v->delete_box = acl_mailbox_delete; + v->rename_box = acl_mailbox_rename; v->save_begin = acl_save_begin; v->copy = acl_copy; v->transaction_commit = acl_transaction_commit; diff -r d7dd5cdf1ba7 -r 7c6d30280cff src/plugins/lazy-expunge/lazy-expunge-plugin.c --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Thu Sep 13 10:52:52 2012 +0300 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Thu Sep 13 10:53:38 2012 +0300 @@ -246,7 +246,7 @@ "Can't rename mailboxes to/from expunge namespace."); return -1; } - return lbox->super.rename(src, dest); + return lbox->super.rename_box(src, dest); } static void lazy_expunge_mailbox_allocated(struct mailbox *box) @@ -268,9 +268,9 @@ v->transaction_begin = lazy_expunge_transaction_begin; v->transaction_commit = lazy_expunge_transaction_commit; v->transaction_rollback = lazy_expunge_transaction_rollback; - v->rename = lazy_expunge_mailbox_rename; + v->rename_box = lazy_expunge_mailbox_rename; } else { - v->rename = lazy_expunge_mailbox_rename; + v->rename_box = lazy_expunge_mailbox_rename; } } diff -r d7dd5cdf1ba7 -r 7c6d30280cff src/plugins/notify/notify-storage.c --- a/src/plugins/notify/notify-storage.c Thu Sep 13 10:52:52 2012 +0300 +++ b/src/plugins/notify/notify-storage.c Thu Sep 13 10:53:38 2012 +0300 @@ -201,7 +201,7 @@ { union mailbox_module_context *lbox = NOTIFY_CONTEXT(box); - if (lbox->super.create(box, update, directory) < 0) + if (lbox->super.create_box(box, update, directory) < 0) return -1; notify_contexts_mailbox_create(box); @@ -213,7 +213,7 @@ { union mailbox_module_context *lbox = NOTIFY_CONTEXT(box); - if (lbox->super.update(box, update) < 0) + if (lbox->super.update_box(box, update) < 0) return -1; notify_contexts_mailbox_update(box); @@ -226,7 +226,7 @@ union mailbox_module_context *lbox = NOTIFY_CONTEXT(box); notify_contexts_mailbox_delete_begin(box); - if (lbox->super.delete(box) < 0) { + if (lbox->super.delete_box(box) < 0) { notify_contexts_mailbox_delete_rollback(); return -1; } @@ -239,7 +239,7 @@ { union mailbox_module_context *lbox = NOTIFY_CONTEXT(src); - if (lbox->super.rename(src, dest) < 0) + if (lbox->super.rename_box(src, dest) < 0) return -1; notify_contexts_mailbox_rename(src, dest); @@ -273,10 +273,10 @@ v->transaction_begin = notify_transaction_begin; v->transaction_commit = notify_transaction_commit; v->transaction_rollback = notify_transaction_rollback; - v->create = notify_mailbox_create; - v->update = notify_mailbox_update; - v->delete = notify_mailbox_delete; - v->rename = notify_mailbox_rename; + v->create_box = notify_mailbox_create; + v->update_box = notify_mailbox_update; + v->delete_box = notify_mailbox_delete; + v->rename_box = notify_mailbox_rename; v->set_subscribed = notify_mailbox_set_subscribed; MODULE_CONTEXT_SET_SELF(box, notify_storage_module, lbox); } From dovecot at dovecot.org Thu Sep 13 11:05:20 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Sep 2012 11:05:20 +0300 Subject: dovecot-2.2: dovecot-config: Added lib-storage/list to be in LIB... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b5bf7bcd43ae changeset: 15042:b5bf7bcd43ae user: Timo Sirainen date: Thu Sep 13 11:05:10 2012 +0300 description: dovecot-config: Added lib-storage/list to be in LIBDOVECOT_STORAGE_INCLUDE diffstat: dovecot-config.in.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 7c6d30280cff -r b5bf7bcd43ae dovecot-config.in.in --- a/dovecot-config.in.in Thu Sep 13 10:53:38 2012 +0300 +++ b/dovecot-config.in.in Thu Sep 13 11:05:10 2012 +0300 @@ -23,7 +23,7 @@ LIBDOVECOT_INCLUDE="-I$(incdir) -I$(incdir)/src/lib -I$(incdir)/src/lib-dict -I$(incdir)/src/lib-dns -I$(incdir)/src/lib-mail -I$(incdir)/src/lib-imap -I$(incdir)/src/lib-fs -I$(incdir)/src/lib-charset -I$(incdir)/src/lib-auth -I$(incdir)/src/lib-master -I$(incdir)/src/lib-ssl-iostream -I$(incdir)/src/lib-compression -I$(incdir)/src/lib-settings -I$(incdir)/src/lib-test" LIBDOVECOT_LDA_INCLUDE="-I$(incdir)/src/lib-lda -I$(incdir)/src/lda" LIBDOVECOT_DOVEADM_INCLUDE="-I$(incdir)/src/doveadm" -LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw" +LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/list -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw" LIBDOVECOT_LOGIN_INCLUDE="-I$(incdir)/src/login-common" LIBDOVECOT_IMAP_INCLUDE="-I$(incdir)/src/imap" LIBDOVECOT_CONFIG_INCLUDE="-I$(incdir)/src/config" From dovecot at dovecot.org Thu Sep 13 12:01:35 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Sep 2012 12:01:35 +0300 Subject: dovecot-2.2: lib-storage: Allow #including mailbox-list-private.... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7343ccbdd985 changeset: 15043:7343ccbdd985 user: Timo Sirainen date: Thu Sep 13 12:01:08 2012 +0300 description: lib-storage: Allow #including mailbox-list-private.h from C++ code diffstat: src/lib-storage/mailbox-list-private.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r b5bf7bcd43ae -r 7343ccbdd985 src/lib-storage/mailbox-list-private.h --- a/src/lib-storage/mailbox-list-private.h Thu Sep 13 11:05:10 2012 +0300 +++ b/src/lib-storage/mailbox-list-private.h Thu Sep 13 12:01:08 2012 +0300 @@ -1,6 +1,8 @@ #ifndef MAILBOX_LIST_PRIVATE_H #define MAILBOX_LIST_PRIVATE_H +#include "mailbox-log.h" +#include "mailbox-list-notify.h" #include "mail-namespace.h" #include "mailbox-list.h" #include "mail-storage-settings.h" @@ -11,8 +13,6 @@ #define MAILBOX_LOG_FILE_NAME "dovecot.mailbox.log" -enum mailbox_log_record_type; -enum mailbox_list_notify_event; struct stat; struct dirent; struct imap_match_glob; From dovecot at dovecot.org Thu Sep 13 17:13:12 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 13 Sep 2012 17:13:12 +0300 Subject: dovecot-2.2: lib-storage: Message size/sent date could have been... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/460db6251639 changeset: 15044:460db6251639 user: Timo Sirainen date: Thu Sep 13 17:12:59 2012 +0300 description: lib-storage: Message size/sent date could have been set as 0 in some cases. It doesn't look like it ever happened with the current storage backends or use cases. diffstat: src/lib-storage/index/index-mail.c | 25 ++++++++++++++++--------- 1 files changed, 16 insertions(+), 9 deletions(-) diffs (62 lines): diff -r 7343ccbdd985 -r 460db6251639 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Thu Sep 13 12:01:08 2012 +0300 +++ b/src/lib-storage/index/index-mail.c Thu Sep 13 17:12:59 2012 +0300 @@ -330,6 +330,7 @@ { struct index_mail *mail = (struct index_mail *)_mail; struct index_mail_data *data = &mail->data; + struct mail_sent_date sentdate; data->cache_fetch_fields |= MAIL_FETCH_DATE; if (data->sent_date.time != (uint32_t)-1) { @@ -338,9 +339,9 @@ return 0; } - (void)index_mail_get_fixed_field(mail, MAIL_CACHE_SENT_DATE, - &data->sent_date, - sizeof(data->sent_date)); + if (index_mail_get_fixed_field(mail, MAIL_CACHE_SENT_DATE, + &sentdate, sizeof(sentdate))) + data->sent_date = sentdate; if (index_mail_cache_sent_date(mail) < 0) return -1; @@ -374,12 +375,15 @@ bool index_mail_get_cached_virtual_size(struct index_mail *mail, uoff_t *size_r) { struct index_mail_data *data = &mail->data; + uoff_t size; data->cache_fetch_fields |= MAIL_FETCH_VIRTUAL_SIZE; if (data->virtual_size == (uoff_t)-1) { - if (!index_mail_get_cached_uoff_t(mail, - MAIL_CACHE_VIRTUAL_FULL_SIZE, - &data->virtual_size)) { + if (index_mail_get_cached_uoff_t(mail, + MAIL_CACHE_VIRTUAL_FULL_SIZE, + &size)) + data->virtual_size = size; + else { if (!get_cached_msgpart_sizes(mail)) return FALSE; } @@ -442,12 +446,15 @@ { struct index_mail *mail = (struct index_mail *)_mail; struct index_mail_data *data = &mail->data; + uoff_t size; data->cache_fetch_fields |= MAIL_FETCH_PHYSICAL_SIZE; if (data->physical_size == (uoff_t)-1) { - if (!index_mail_get_cached_uoff_t(mail, - MAIL_CACHE_PHYSICAL_FULL_SIZE, - &data->physical_size)) + if (index_mail_get_cached_uoff_t(mail, + MAIL_CACHE_PHYSICAL_FULL_SIZE, + &size)) + data->physical_size = size; + else (void)get_cached_msgpart_sizes(mail); } *size_r = data->physical_size; From dovecot at dovecot.org Fri Sep 14 20:51:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 20:51:14 +0300 Subject: dovecot-2.1: pop3c: Fetching message size could have returned wr... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/8cec3b4c43ca changeset: 14705:8cec3b4c43ca user: Timo Sirainen date: Fri Sep 14 20:51:02 2012 +0300 description: pop3c: Fetching message size could have returned wrong value diffstat: src/lib-storage/index/pop3c/pop3c-mail.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 27d3289e1f5c -r 8cec3b4c43ca src/lib-storage/index/pop3c/pop3c-mail.c --- a/src/lib-storage/index/pop3c/pop3c-mail.c Wed Sep 12 00:20:47 2012 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-mail.c Fri Sep 14 20:51:02 2012 +0300 @@ -30,7 +30,7 @@ struct message_size hdr_size, body_size; struct istream *input; - if (mail->data.virtual_size != 0) { + if (mail->data.virtual_size != (uoff_t)-1) { /* virtual size is already known. it's the same as our (correct) physical size */ *size_r = mail->data.virtual_size; From dovecot at dovecot.org Fri Sep 14 21:03:20 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 21:03:20 +0300 Subject: dovecot-2.2: Added support for creating IMAP URLs. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/345e96ca65a2 changeset: 15045:345e96ca65a2 user: Stephan Bosch date: Fri Sep 14 21:02:23 2012 +0300 description: Added support for creating IMAP URLs. diffstat: src/lib-imap/imap-url.c | 93 +++++++++++++++++++++++++++ src/lib-imap/imap-url.h | 8 +- src/lib-imap/test-imap-url.c | 67 +++++++++++++++++++ src/lib/uri-util.c | 146 ++++++++++++++++++++++++++++++++++++++++-- src/lib/uri-util.h | 24 ++++++- 5 files changed, 325 insertions(+), 13 deletions(-) diffs (truncated from 503 to 300 lines): diff -r 460db6251639 -r 345e96ca65a2 src/lib-imap/imap-url.c --- a/src/lib-imap/imap-url.c Thu Sep 13 17:12:59 2012 +0300 +++ b/src/lib-imap/imap-url.c Fri Sep 14 21:02:23 2012 +0300 @@ -689,6 +689,8 @@ /* [ipartial] */ if (*segment != NULL && strncasecmp(*segment, ";PARTIAL=", 9) == 0) { + have_partial = TRUE; + /* ";PARTIAL=" partial-range */ value = (*segment) + 9; if ((p = strchr(value,';')) != NULL) { @@ -754,6 +756,7 @@ url->uid = uid; if (section != NULL) url->section = p_strdup(parser->pool, str_c(section)); + url->have_partial = have_partial; url->partial_offset = partial_offset; url->partial_size = partial_size; } @@ -925,6 +928,96 @@ * IMAP URL construction */ +static void +imap_url_append_mailbox(const struct imap_url *url, string_t *urlstr) +{ + uri_append_path_data(urlstr, ";", url->mailbox); + if (url->uidvalidity != 0) + str_printfa(urlstr, ";UIDVALIDITY=%u", url->uidvalidity); + if (url->uid == 0) { + /* message list */ + if (url->search_program != NULL) { + str_append_c(urlstr, '?'); + uri_append_query_data(urlstr, ";", url->search_program); + } + } else { + /* message part */ + str_printfa(urlstr, "/;UID=%u", url->uid); + if (url->section != NULL) { + str_append(urlstr, "/;SECTION="); + uri_append_path_data(urlstr, ";", url->section); + } + if (url->have_partial) { + str_append(urlstr, "/;PARTIAL="); + if (url->partial_size == 0) { + str_printfa(urlstr, "%"PRIuUOFF_T, + url->partial_offset); + } else { + str_printfa(urlstr, "%"PRIuUOFF_T".%"PRIuUOFF_T, + url->partial_offset, + url->partial_size); + } + } + + /* urlauth */ + if (url->uauth_access_application != NULL) { + if (url->uauth_expire != (time_t)-1) { + str_append(urlstr, ";EXPIRE="); + str_append(urlstr, iso8601_date_create(url->uauth_expire)); + } + str_append(urlstr, ";URLAUTH="); + str_append(urlstr, url->uauth_access_application); + if (url->uauth_access_user != NULL) { + str_append_c(urlstr, '+'); + uri_append_user_data(urlstr, ";", + url->uauth_access_user); + } + } + } +} + +const char *imap_url_create(const struct imap_url *url) +{ + string_t *urlstr = t_str_new(512); + + /* scheme */ + uri_append_scheme(urlstr, "imap"); + str_append(urlstr, "//"); + + /* user */ + if (url->userid != NULL || url->auth_type != NULL) { + if (url->userid != NULL) + uri_append_user_data(urlstr, ";", url->userid); + if (url->auth_type != NULL) { + str_append(urlstr, ";AUTH="); + uri_append_user_data(urlstr, ";", url->auth_type); + } + str_append_c(urlstr, '@'); + } + + /* server */ + if (url->host_name != NULL) { + /* assume IPv6 literal if starts with '['; avoid encoding */ + if (*url->host_name == '[') + str_append(urlstr, url->host_name); + else + uri_append_host_name(urlstr, url->host_name); + } else if (url->have_host_ip) { + uri_append_host_ip(urlstr, &url->host_ip); + } else + i_unreached(); + if (url->have_port) + uri_append_port(urlstr, url->port); + + /* Older syntax (RFC 2192) requires this slash at all times */ + str_append_c(urlstr, '/'); + + /* mailbox */ + if (url->mailbox != NULL) + imap_url_append_mailbox(url, urlstr); + return str_c(urlstr); +} + const char * imap_url_add_urlauth(const char *rumpurl, const char *mechanism, const unsigned char *token, size_t token_len) diff -r 460db6251639 -r 345e96ca65a2 src/lib-imap/imap-url.h --- a/src/lib-imap/imap-url.h Thu Sep 13 17:12:59 2012 +0300 +++ b/src/lib-imap/imap-url.h Fri Sep 14 21:02:23 2012 +0300 @@ -19,7 +19,7 @@ uint32_t uid; const char *section; uoff_t partial_offset; - uoff_t partial_size; + uoff_t partial_size; /* 0 if not set */ /* message list (uid == 0) */ const char *search_program; @@ -31,9 +31,9 @@ const char *uauth_mechanism; const unsigned char *uauth_token; size_t uauth_token_size; - time_t uauth_expire; + time_t uauth_expire; /* (time_t)-1 if not set */ - unsigned int have_host_ip:1; + unsigned int have_host_ip:1; /* url uses IP address */ unsigned int have_port:1; unsigned int have_partial:1; }; @@ -64,6 +64,8 @@ * IMAP URL construction */ +const char *imap_url_create(const struct imap_url *url); + const char *imap_url_add_urlauth(const char *rumpurl, const char *mechanism, const unsigned char *token, size_t token_len); diff -r 460db6251639 -r 345e96ca65a2 src/lib-imap/test-imap-url.c --- a/src/lib-imap/test-imap-url.c Thu Sep 13 17:12:59 2012 +0300 +++ b/src/lib-imap/test-imap-url.c Fri Sep 14 21:02:23 2012 +0300 @@ -53,12 +53,14 @@ .host_name = "127.0.0.1", .userid = "user", .have_host_ip = TRUE } +#ifdef HAVE_IPV6 },{ .url = "imap://user@[::1]", .url_parsed = { .host_name = "[::1]", .userid = "user", .have_host_ip = TRUE } +#endif },{ .url = "imap://user at 4example.com:423", .url_parsed = { @@ -738,8 +740,10 @@ .url = "imap://[]/INBOX" },{ .url = "imap://[v08.234:232:234:234:2221]/INBOX" +#ifdef HAVE_IPV6 },{ .url = "imap://[1::34a:34:234::6]/INBOX" +#endif },{ .url = "imap://example%a.com/INBOX" },{ @@ -891,11 +895,74 @@ } +const char *parse_create_url_tests[] = { + "imap://host.example.com/", + "imap://[::1]/", + "imap://10.0.0.1/", + "imap://user at host.example.com/", + "imap://user at host.example.com:993/", + "imap://user;AUTH=PLAIN at host.example.com/", + "imap://user;AUTH=PLAIN at host.example.com/INBOX", + "imap://user;AUTH=PLAIN at host.example.com/INBOX/;UID=5", + "imap://user;AUTH=PLAIN at host.example.com/INBOX;UIDVALIDITY=15/;UID=5", + "imap://user;AUTH=PLAIN at host.example.com/INBOX;UIDVALIDITY=15/;UID=5" + "/;SECTION=TEXT", + "imap://user;AUTH=PLAIN at host.example.com/INBOX;UIDVALIDITY=15/;UID=5" + "/;SECTION=TEXT/;PARTIAL=1", + "imap://user;AUTH=PLAIN at host.example.com/INBOX;UIDVALIDITY=15/;UID=5" + "/;SECTION=TEXT/;PARTIAL=1.14", + "imap://user;AUTH=PLAIN at host.example.com/INBOX;UIDVALIDITY=15/;UID=5" + "/;SECTION=TEXT/;PARTIAL=1.14;URLAUTH=anonymous", + "imap://user;AUTH=PLAIN at host.example.com/INBOX;UIDVALIDITY=15/;UID=5" + "/;SECTION=TEXT/;PARTIAL=1.14;URLAUTH=user+username", + "imap://user;AUTH=PLAIN at host.example.com/INBOX/?SUBJECT%20%22Frop?%22", + "imap://host.%23example.com/", + "imap://user%3ba at host.example.com/", + "imap://user%40example.com at host.example.com/", + "imap://user%40example.com;AUTH=STR%23ANGE at host.example.com/", + "imap://user;AUTH=PLAIN at host.example.com/INBOX/Important%3bWork", + "imap://user at host.example.com/%23shared/news", + "imap://user at host.example.com/INBOX;UIDVALIDITY=15/;UID=5" + "/;SECTION=HEADER.FIELDS%20(DATE%20FROM)", + "imap://user at host.example.com/INBOX;UIDVALIDITY=15/;UID=5" + "/;SECTION=TEXT/;PARTIAL=1.14;URLAUTH=user+user%3bname", +}; + +unsigned int parse_create_url_test_count = N_ELEMENTS(parse_create_url_tests); + +static void test_imap_url_parse_create(void) +{ + unsigned int i; + + for (i = 0; i < parse_create_url_test_count; i++) T_BEGIN { + const char *url = parse_create_url_tests[i]; + struct imap_url *urlp; + const char *error = NULL; + + test_begin(t_strdup_printf("imap url parse/create [%d]", i)); + + if (imap_url_parse + (url, NULL, IMAP_URL_PARSE_ALLOW_URLAUTH, &urlp, &error) < 0) + urlp = NULL; + test_out_reason(t_strdup_printf("parse %s", url), urlp != NULL, error); + if (urlp != NULL) { + const char *urlnew = imap_url_create(urlp); + test_out(t_strdup_printf + ("create %s", urlnew), strcmp(url, urlnew) == 0); + } + + test_end(); + } T_END; + +} + + int main(void) { static void (*test_functions[])(void) = { test_imap_url_valid, test_imap_url_invalid, + test_imap_url_parse_create, NULL }; return test_run(test_functions); diff -r 460db6251639 -r 345e96ca65a2 src/lib/uri-util.c --- a/src/lib/uri-util.c Thu Sep 13 17:12:59 2012 +0300 +++ b/src/lib/uri-util.c Fri Sep 14 21:02:23 2012 +0300 @@ -50,16 +50,25 @@ * / "*" / "+" / "," / ";" / "=" [bit1] * gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" [bit2] * pchar = unreserved / sub-delims / ":" / "@" [bit0|bit1|bit3] + * 'pfchar' = unreserved / sub-delims / ":" / "@" / "/" + * [bit0|bit1|bit3|bit5] * 'uchar' = unreserved / sub-delims / ":" [bit0|bit1|bit4] - * 'fchar' = pchar / "/" / "?" [bit0|bit1|bit3|bit5] + * 'qchar' = pchar / "/" / "?" [bit0|bit1|bit3|bit5|bit6] * */ +#define CHAR_MASK_UNRESERVED (1<<0) +#define CHAR_MASK_SUB_DELIMS (1<<1) +#define CHAR_MASK_PCHAR ((1<<0)|(1<<1)|(1<<3)) +#define CHAR_MASK_PFCHAR ((1<<0)|(1<<1)|(1<<3)|(1<<5)) +#define CHAR_MASK_UCHAR ((1<<0)|(1<<1)|(1<<4)) +#define CHAR_MASK_QCHAR ((1<<0)|(1<<1)|(1<<3)|(1<<5)|(1<<6)) + static unsigned const char _uri_char_lookup[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10 0, 2, 0, 4, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 1, 36, // 20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28, 2, 0, 2, 0, 36, // 30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28, 2, 0, 2, 0, 68, // 30 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 4, 0, 1, // 50 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60 @@ -133,7 +142,7 @@ if ((*parser->cur & 0x80) != 0) return 0; - if (_uri_char_lookup[*parser->cur] & 0x01) { + if ((_uri_char_lookup[*parser->cur] & CHAR_MASK_UNRESERVED) != 0) { *ch_r = *parser->cur; parser->cur++; return 1; @@ -344,7 +353,7 @@ /* sub-delims */ c = *parser->cur; - if ((c & 0x80) == 0 && (_uri_char_lookup[c] & 0x02) != 0) { + if ((c & 0x80) == 0 && (_uri_char_lookup[c] & CHAR_MASK_SUB_DELIMS) != 0) { From dovecot at dovecot.org Fri Sep 14 21:04:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 21:04:29 +0300 Subject: dovecot-2.2: Fixes IMAP LOGIN REFERRAL to properly encode IMAP URL. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/584681a1845c changeset: 15046:584681a1845c user: Stephan Bosch date: Fri Sep 14 21:04:01 2012 +0300 description: Fixes IMAP LOGIN REFERRAL to properly encode IMAP URL. diffstat: src/imap-login/client-authenticate.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diffs (46 lines): diff -r 345e96ca65a2 -r 584681a1845c src/imap-login/client-authenticate.c --- a/src/imap-login/client-authenticate.c Fri Sep 14 21:02:23 2012 +0300 +++ b/src/imap-login/client-authenticate.c Fri Sep 14 21:04:01 2012 +0300 @@ -9,8 +9,10 @@ #include "safe-memset.h" #include "str.h" #include "str-sanitize.h" +#include "network.h" #include "imap-resp-code.h" #include "imap-parser.h" +#include "imap-url.h" #include "auth-client.h" #include "client.h" #include "client-authenticate.h" @@ -36,6 +38,7 @@ const struct client_auth_reply *reply, const char *text) { + struct imap_url url; string_t *referral; switch (result) { @@ -54,12 +57,17 @@ .. [REFERRAL ..] (Reason from auth server) */ referral = t_str_new(128); - str_printfa(referral, "REFERRAL imap://%s;AUTH=%s@%s", - reply->destuser, client->auth_mech_name, - reply->host); - if (reply->port != 143) - str_printfa(referral, ":%u", reply->port); - str_append(referral, "/"); + + memset(&url, 0, sizeof(url)); + url.userid = reply->destuser; + url.auth_type = client->auth_mech_name; + url.host_name = reply->host; + if (reply->port != 143) { + url.have_port = TRUE; + url.port = reply->port; + } + str_append(referral, "REFERRAL "); + str_append(referral, imap_url_create(&url)); if (result == CLIENT_AUTH_RESULT_REFERRAL_SUCCESS) { client_send_reply_code(client, IMAP_CMD_REPLY_OK, From dovecot at dovecot.org Fri Sep 14 21:12:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 21:12:07 +0300 Subject: dovecot-2.2: lib-imap-storage: Changed imap_msgpart_url API. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f82dbf27ba79 changeset: 15047:f82dbf27ba79 user: Stephan Bosch date: Fri Sep 14 21:11:42 2012 +0300 description: lib-imap-storage: Changed imap_msgpart_url API. Adds enum mail_error return value to imap_msgpart_url_open_mailbox(). Now parses msgpart at the beginning and adds function to access underlying imap_msgpart object directly. diffstat: src/imap/cmd-append.c | 24 +++--- src/lib-imap-storage/imap-msgpart-url.c | 107 +++++++++++++++++-------------- src/lib-imap-storage/imap-msgpart-url.h | 21 +++++- 3 files changed, 87 insertions(+), 65 deletions(-) diffs (truncated from 368 to 300 lines): diff -r 584681a1845c -r f82dbf27ba79 src/imap/cmd-append.c --- a/src/imap/cmd-append.c Fri Sep 14 21:04:01 2012 +0300 +++ b/src/imap/cmd-append.c Fri Sep 14 21:11:42 2012 +0300 @@ -160,8 +160,8 @@ { struct cmd_append_context *ctx = cmd->context; struct imap_msgpart_url *mpurl; - struct istream *input; - uoff_t size, newsize; + struct imap_msgpart_open_result mpresult; + uoff_t newsize; const char *error; int ret; @@ -182,7 +182,7 @@ } /* catenate URL */ - ret = imap_msgpart_url_read_part(mpurl, &input, &size, &error); + ret = imap_msgpart_url_read_part(mpurl, &mpresult, &error); if (ret < 0) { client_send_storage_error(cmd, ctx->storage); return -1; @@ -193,13 +193,13 @@ t_strdup_printf("NO [BADURL %s] %s.", caturl, error)); return -1; } - if (size == 0) { + if (mpresult.size == 0) { /* empty input */ imap_msgpart_url_free(&mpurl); return 0; } - newsize = ctx->cat_msg_size + size; + newsize = ctx->cat_msg_size + mpresult.size; if (newsize < ctx->cat_msg_size) { client_send_tagline(cmd, "NO [TOOBIG] Composed message grows too big."); @@ -209,23 +209,23 @@ ctx->cat_msg_size = newsize; /* add this input stream to chain */ - i_stream_chain_append(ctx->catchain, input); + i_stream_chain_append(ctx->catchain, mpresult.input); /* save by reading the chain stream */ - while (!i_stream_is_eof(input)) { - ret = i_stream_read(input); + while (!i_stream_is_eof(mpresult.input)) { + ret = i_stream_read(mpresult.input); i_assert(ret != 0); /* we can handle only blocking input here */ if (mailbox_save_continue(ctx->save_ctx) < 0 || ret == -1) break; } - if (input->stream_errno != 0) { - errno = input->stream_errno; + if (mpresult.input->stream_errno != 0) { + errno = mpresult.input->stream_errno; mail_storage_set_critical(ctx->box->storage, "read(%s) failed: %m (for CATENATE URL %s)", - i_stream_get_name(input), caturl); + i_stream_get_name(mpresult.input), caturl); client_send_storage_error(cmd, ctx->storage); ret = -1; - } else if (!input->eof) { + } else if (!mpresult.input->eof) { /* save failed */ client_send_storage_error(cmd, ctx->storage); ret = -1; diff -r 584681a1845c -r f82dbf27ba79 src/lib-imap-storage/imap-msgpart-url.c --- a/src/lib-imap-storage/imap-msgpart-url.c Fri Sep 14 21:04:01 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart-url.c Fri Sep 14 21:11:42 2012 +0300 @@ -17,25 +17,37 @@ char *section; uoff_t partial_offset, partial_size; + struct imap_msgpart *part; + struct mail_user *user; struct mailbox *selected_box; struct mailbox *box; struct mailbox_transaction_context *trans; struct mail *mail; - struct istream *input; - uoff_t part_size; + struct imap_msgpart_open_result result; + + unsigned int decode_cte_to_binary:1; }; -struct imap_msgpart_url * -imap_msgpart_url_create(struct mail_user *user, const struct imap_url *url) +int imap_msgpart_url_create(struct mail_user *user, const struct imap_url *url, + struct imap_msgpart_url **mpurl_r, + const char **error_r) { + const char *section = url->section == NULL ? "" : url->section; struct imap_msgpart_url *mpurl; + struct imap_msgpart *msgpart; i_assert(url->mailbox != NULL && url->uid != 0 && url->search_program == NULL); + if (imap_msgpart_parse(section, &msgpart) < 0) { + *error_r = "Invalid section"; + return -1; + } + mpurl = i_new(struct imap_msgpart_url, 1); + mpurl->part = msgpart; mpurl->user = user; mpurl->mailbox = i_strdup(url->mailbox); mpurl->uidvalidity = url->uidvalidity; @@ -44,11 +56,17 @@ mpurl->section = i_strdup(url->section); mpurl->partial_offset = url->partial_offset; mpurl->partial_size = url->partial_size; - return mpurl; + + imap_msgpart_set_partial(msgpart, url->partial_offset, + url->partial_size == 0 ? + (uoff_t)-1 : url->partial_size); + + *mpurl_r = mpurl; + return 0; } int imap_msgpart_url_parse(struct mail_user *user, struct mailbox *selected_box, - const char *urlstr, struct imap_msgpart_url **url_r, + const char *urlstr, struct imap_msgpart_url **mpurl_r, const char **error_r) { struct mailbox_status box_status; @@ -78,8 +96,9 @@ *error_r = "Invalid messagepart IMAP URL"; return 0; } - *url_r = imap_msgpart_url_create(user, url); - (*url_r)->selected_box = selected_box; + if (imap_msgpart_url_create(user, url, mpurl_r, error_r) < 0) + return -1; + (*mpurl_r)->selected_box = selected_box; return 1; } @@ -89,16 +108,17 @@ } int imap_msgpart_url_open_mailbox(struct imap_msgpart_url *mpurl, - struct mailbox **box_r, const char **error_r) + struct mailbox **box_r, enum mail_error *error_code_r, + const char **error_r) { struct mailbox_status box_status; - enum mail_error error_code; enum mailbox_flags flags = MAILBOX_FLAG_READONLY; struct mail_namespace *ns; struct mailbox *box; if (mpurl->box != NULL) { *box_r = mpurl->box; + *error_code_r = MAIL_ERROR_NONE; return 1; } @@ -106,6 +126,7 @@ ns = mail_namespace_find(mpurl->user->namespaces, mpurl->mailbox); if (ns == NULL) { *error_r = "Nonexistent mailbox namespace"; + *error_code_r = MAIL_ERROR_NOTFOUND; return 0; } @@ -117,10 +138,10 @@ box = mailbox_alloc(ns->list, mpurl->mailbox, flags); if (mailbox_open(box) < 0) { *error_r = mail_storage_get_last_error(mailbox_get_storage(box), - &error_code); + error_code_r); if (box != mpurl->selected_box) mailbox_free(&box); - return error_code == MAIL_ERROR_TEMP ? -1 : 0; + return *error_code_r == MAIL_ERROR_TEMP ? -1 : 0; } /* verify UIDVALIDITY */ @@ -128,6 +149,7 @@ if (mpurl->uidvalidity > 0 && box_status.uidvalidity != mpurl->uidvalidity) { *error_r = "Invalid UIDVALIDITY"; + *error_code_r = MAIL_ERROR_EXPUNGED; if (box != mpurl->selected_box) mailbox_free(&box); return 0; @@ -142,6 +164,7 @@ { struct mailbox_transaction_context *t; struct mailbox *box; + enum mail_error error_code; struct mail *mail; int ret; @@ -151,7 +174,8 @@ } /* open mailbox if it is not yet open */ - if ((ret = imap_msgpart_url_open_mailbox(mpurl, &box, error_r)) <= 0) + if ((ret = imap_msgpart_url_open_mailbox(mpurl, &box, &error_code, + error_r)) <= 0) return ret; /* start transaction */ @@ -172,57 +196,43 @@ return 1; } -static int -imap_msgpart_url_open_part(struct imap_msgpart_url *mpurl, struct mail **mail_r, - struct imap_msgpart **msgpart_r, const char **error_r) +struct imap_msgpart * +imap_msgpart_url_get_part(struct imap_msgpart_url *mpurl) { - const char *section = mpurl->section == NULL ? "" : mpurl->section; - int ret; + return mpurl->part; +} - if ((ret = imap_msgpart_url_open_mail(mpurl, mail_r, error_r)) <= 0) - return ret; - - if (imap_msgpart_parse(section, msgpart_r) < 0) { - *error_r = "Invalid section"; - return 0; - } - imap_msgpart_set_partial(*msgpart_r, mpurl->partial_offset, - mpurl->partial_size == 0 ? (uoff_t)-1 : - mpurl->partial_size); - return 1; +void imap_msgpart_url_set_decode_to_binary(struct imap_msgpart_url *mpurl) +{ + imap_msgpart_set_decode_to_binary(mpurl->part); } int imap_msgpart_url_read_part(struct imap_msgpart_url *mpurl, - struct istream **stream_r, uoff_t *size_r, + struct imap_msgpart_open_result *result_r, const char **error_r) { struct mail *mail; - struct imap_msgpart *msgpart; - struct imap_msgpart_open_result result; int ret; - if (mpurl->input != NULL) { - i_stream_seek(mpurl->input, 0); - *stream_r = mpurl->input; - *size_r = mpurl->part_size; + if (mpurl->result.input != NULL) { + i_stream_seek(mpurl->result.input, 0); + *result_r = mpurl->result; return 1; } /* open mail if it is not yet open */ - ret = imap_msgpart_url_open_part(mpurl, &mail, &msgpart, error_r); + ret = imap_msgpart_url_open_mail(mpurl, &mail, error_r); if (ret <= 0) return ret; /* open the referenced part as a stream */ - ret = imap_msgpart_open(mail, msgpart, &result); - imap_msgpart_free(&msgpart); + ret = imap_msgpart_open(mail, mpurl->part, result_r); if (ret < 0) { - *error_r = mailbox_get_last_error(mail->box, NULL); + *error_r = mailbox_get_last_error(mpurl->box, NULL); return ret; } - *stream_r = mpurl->input = result.input; - *size_r = mpurl->part_size = result.size; + mpurl->result = *result_r; return 1; } @@ -230,16 +240,13 @@ const char **error_r) { struct mail *mail; - struct imap_msgpart *msgpart; int ret; - if (mpurl->input != NULL) + if (mpurl->result.input != NULL) return 1; /* open mail if it is not yet open */ - ret = imap_msgpart_url_open_part(mpurl, &mail, &msgpart, error_r); From dovecot at dovecot.org Fri Sep 14 21:49:58 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 21:49:58 +0300 Subject: dovecot-2.2: hmac_sha1_init(): Use void pointer for the key. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b74e8de5f3d9 changeset: 15048:b74e8de5f3d9 user: Timo Sirainen date: Fri Sep 14 21:31:45 2012 +0300 description: hmac_sha1_init(): Use void pointer for the key. diffstat: src/lib/hmac-sha1.c | 2 +- src/lib/hmac-sha1.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diffs (27 lines): diff -r f82dbf27ba79 -r b74e8de5f3d9 src/lib/hmac-sha1.c --- a/src/lib/hmac-sha1.c Fri Sep 14 21:11:42 2012 +0300 +++ b/src/lib/hmac-sha1.c Fri Sep 14 21:31:45 2012 +0300 @@ -12,7 +12,7 @@ #include "safe-memset.h" void hmac_sha1_init(struct hmac_sha1_context *ctx, - const unsigned char *key, size_t key_len) + const void *key, size_t key_len) { int i; unsigned char sha1key[20]; diff -r f82dbf27ba79 -r b74e8de5f3d9 src/lib/hmac-sha1.h --- a/src/lib/hmac-sha1.h Fri Sep 14 21:11:42 2012 +0300 +++ b/src/lib/hmac-sha1.h Fri Sep 14 21:31:45 2012 +0300 @@ -8,9 +8,9 @@ }; void hmac_sha1_init(struct hmac_sha1_context *ctx, - const unsigned char *key, size_t key_len); + const void *key, size_t key_len); void hmac_sha1_final(struct hmac_sha1_context *ctx, - unsigned char digest[SHA1_RESULTLEN]); + unsigned char digest[SHA1_RESULTLEN]); static inline void From dovecot at dovecot.org Fri Sep 14 21:49:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 21:49:59 +0300 Subject: dovecot-2.2: Added support to perform token-based service proces... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/aa6027a0a78e changeset: 15049:aa6027a0a78e user: Stephan Bosch date: Fri Sep 14 21:48:45 2012 +0300 description: Added support to perform token-based service process authentication. Creates hidden SASL method DOVECOT-TOKEN. This method is not available on the normal auth login socket and thus never presented to clients. Creates new auth socket type 'tokenlogin'. This otherwise normal login socket only offers authentication using the DOVECOT-TOKEN mechanism. Creates new token-login directory in base_dir to separate token logins from normal logins. This directory is otherwise completely identical to the normal login dir, i.e. it contains sockets for the service backends, used to chroot login processes to, etc. Makes default login socket configurable. Performs some minor changes to src/login-common to build very sparse protocols, e.g. avoid the need to implement methods that are not needed. diffstat: src/auth/Makefile.am | 3 + src/auth/auth-client-connection.c | 15 ++- src/auth/auth-client-connection.h | 3 +- src/auth/auth-master-connection.c | 7 +- src/auth/auth-request-handler.c | 95 ++++++++++++++--- src/auth/auth-request-handler.h | 12 +- src/auth/auth-request.c | 16 ++ src/auth/auth-request.h | 3 + src/auth/auth-settings.c | 4 +- src/auth/auth-token.c | 183 +++++++++++++++++++++++++++++++++ src/auth/auth-token.h | 11 + src/auth/main.c | 22 +++- src/auth/mech-dovecot-token.c | 86 +++++++++++++++ src/auth/mech.h | 2 + src/imap/main.c | 1 + src/lib-master/master-login-auth.c | 8 +- src/lib-master/master-login-auth.h | 3 +- src/lib-master/master-login.c | 3 +- src/lib-master/master-login.h | 2 + src/lib-storage/mail-storage-service.c | 5 +- src/lib-storage/mail-user.h | 2 + src/login-common/client-common-auth.c | 2 + src/login-common/client-common.c | 9 +- src/login-common/login-common.h | 6 + src/login-common/main.c | 5 +- src/master/master-settings.c | 50 +++++--- 26 files changed, 494 insertions(+), 64 deletions(-) diffs (truncated from 1091 to 300 lines): diff -r b74e8de5f3d9 -r aa6027a0a78e src/auth/Makefile.am --- a/src/auth/Makefile.am Fri Sep 14 21:31:45 2012 +0300 +++ b/src/auth/Makefile.am Fri Sep 14 21:48:45 2012 +0300 @@ -71,6 +71,7 @@ auth-request-handler.c \ auth-settings.c \ auth-stream.c \ + auth-token.c \ auth-worker-client.c \ auth-worker-server.c \ db-checkpassword.c \ @@ -93,6 +94,7 @@ mech-rpa.c \ mech-apop.c \ mech-winbind.c \ + mech-dovecot-token.c \ passdb.c \ passdb-blocking.c \ passdb-bsdauth.c \ @@ -136,6 +138,7 @@ auth-request-handler.h \ auth-settings.h \ auth-stream.h \ + auth-token.h \ auth-worker-client.h \ auth-worker-server.h \ db-dict.h \ diff -r b74e8de5f3d9 -r aa6027a0a78e src/auth/auth-client-connection.c --- a/src/auth/auth-client-connection.c Fri Sep 14 21:31:45 2012 +0300 +++ b/src/auth/auth-client-connection.c Fri Sep 14 21:48:45 2012 +0300 @@ -125,7 +125,7 @@ /* handshake complete, we can now actually start serving requests */ conn->refcount++; conn->request_handler = - auth_request_handler_create(auth_callback, conn, + auth_request_handler_create(conn->token_auth, auth_callback, conn, !conn->login_requests ? NULL : auth_master_request_callback); auth_request_handler_set(conn->request_handler, conn->connect_uid, pid); @@ -294,10 +294,11 @@ } void auth_client_connection_create(struct auth *auth, int fd, - bool login_requests) + bool login_requests, bool token_auth) { static unsigned int connect_uid_counter = 0; struct auth_client_connection *conn; + const char *mechanisms; string_t *str; conn = i_new(struct auth_client_connection, 1); @@ -305,6 +306,7 @@ conn->refcount = 1; conn->connect_uid = ++connect_uid_counter; conn->login_requests = login_requests; + conn->token_auth = token_auth; random_fill(conn->cookie, sizeof(conn->cookie)); conn->fd = fd; @@ -317,11 +319,18 @@ DLLIST_PREPEND(&auth_client_connections, conn); + if (token_auth) { + mechanisms = t_strconcat("MECH\t", + mech_dovecot_token.mech_name, "\n", NULL); + } else { + mechanisms = str_c(auth->reg->handshake); + } + str = t_str_new(128); str_printfa(str, "VERSION\t%u\t%u\n%sSPID\t%s\nCUID\t%u\nCOOKIE\t", AUTH_CLIENT_PROTOCOL_MAJOR_VERSION, AUTH_CLIENT_PROTOCOL_MINOR_VERSION, - str_c(auth->reg->handshake), my_pid, conn->connect_uid); + mechanisms, my_pid, conn->connect_uid); binary_to_hex_append(str, conn->cookie, sizeof(conn->cookie)); str_append(str, "\nDONE\n"); diff -r b74e8de5f3d9 -r aa6027a0a78e src/auth/auth-client-connection.h --- a/src/auth/auth-client-connection.h Fri Sep 14 21:31:45 2012 +0300 +++ b/src/auth/auth-client-connection.h Fri Sep 14 21:48:45 2012 +0300 @@ -20,10 +20,11 @@ unsigned int login_requests:1; unsigned int version_received:1; + unsigned int token_auth:1; }; void auth_client_connection_create(struct auth *auth, int fd, - bool login_requests); + bool login_requests, bool token_auth); void auth_client_connection_destroy(struct auth_client_connection **conn); struct auth_client_connection * diff -r b74e8de5f3d9 -r aa6027a0a78e src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Fri Sep 14 21:31:45 2012 +0300 +++ b/src/auth/auth-master-connection.c Fri Sep 14 21:48:45 2012 +0300 @@ -95,12 +95,12 @@ master_input_request(struct auth_master_connection *conn, const char *args) { struct auth_client_connection *client_conn; - const char *const *list; + const char *const *list, *const *params; unsigned int id, client_pid, client_id; uint8_t cookie[MASTER_AUTH_COOKIE_SIZE]; buffer_t buf; - /* */ + /* [] */ list = t_strsplit_tab(args); if (str_array_length(list) < 4 || str_to_uint(list[0], &id) < 0 || @@ -115,6 +115,7 @@ i_error("BUG: Master sent broken REQUEST cookie"); return FALSE; } + params = list + 4; client_conn = auth_client_connection_lookup(client_pid); if (client_conn == NULL) { @@ -128,7 +129,7 @@ o_stream_nsend_str(conn->output, t_strdup_printf("FAIL\t%u\n", id)); } else if (!auth_request_handler_master_request( - client_conn->request_handler, conn, id, client_id)) { + client_conn->request_handler, conn, id, client_id, params)) { i_error("Master requested auth for non-login client %u", client_pid); o_stream_nsend_str(conn->output, diff -r b74e8de5f3d9 -r aa6027a0a78e src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Fri Sep 14 21:31:45 2012 +0300 +++ b/src/auth/auth-request-handler.c Fri Sep 14 21:48:45 2012 +0300 @@ -6,11 +6,13 @@ #include "aqueue.h" #include "base64.h" #include "hash.h" +#include "network.h" #include "str.h" #include "str-sanitize.h" #include "master-interface.h" #include "auth-penalty.h" #include "auth-request.h" +#include "auth-token.h" #include "auth-master-connection.h" #include "auth-request-handler.h" @@ -31,6 +33,7 @@ auth_request_callback_t *master_callback; unsigned int destroyed:1; + unsigned int token_auth:1; }; static ARRAY(struct auth_request *) auth_failures_arr; @@ -41,8 +44,8 @@ #undef auth_request_handler_create struct auth_request_handler * -auth_request_handler_create(auth_request_callback_t *callback, void *context, - auth_request_callback_t *master_callback) +auth_request_handler_create(bool token_auth, auth_request_callback_t *callback, + void *context, auth_request_callback_t *master_callback) { struct auth_request_handler *handler; pool_t pool; @@ -56,6 +59,7 @@ handler->callback = callback; handler->context = context; handler->master_callback = master_callback; + handler->token_auth = token_auth; return handler; } @@ -461,13 +465,24 @@ return FALSE; } - mech = mech_module_find(list[1]); - if (mech == NULL) { - /* unsupported mechanism */ - i_error("BUG: Authentication client %u requested unsupported " - "authentication mechanism %s", handler->client_pid, - str_sanitize(list[1], MAX_MECH_NAME_LEN)); - return FALSE; + if (handler->token_auth) { + mech = &mech_dovecot_token; + if (strcmp(list[1], mech->mech_name) != 0) { + /* unsupported mechanism */ + i_error("BUG: Authentication client %u requested invalid " + "authentication mechanism %s (DOVECOT-TOKEN required)", + handler->client_pid, str_sanitize(list[1], MAX_MECH_NAME_LEN)); + return FALSE; + } + } else { + mech = mech_module_find(list[1]); + if (mech == NULL) { + /* unsupported mechanism */ + i_error("BUG: Authentication client %u requested unsupported " + "authentication mechanism %s", handler->client_pid, + str_sanitize(list[1], MAX_MECH_NAME_LEN)); + return FALSE; + } } request = auth_request_new(mech); @@ -664,8 +679,19 @@ auth_stream_reply_add(request->userdb_reply, "anonymous", NULL); } + auth_stream_reply_import(reply, auth_stream_reply_export(request->userdb_reply)); + + /* generate auth_token when master service provided session_pid */ + if (request->session_pid != (pid_t)-1) { + const char *auth_token = + auth_token_get(request->service, + dec2str(request->session_pid), + request->user, + request->session_id); + auth_stream_reply_add(reply, "auth_token", auth_token); + } break; } handler->master_callback(reply, request->master); @@ -675,13 +701,27 @@ auth_request_handler_unref(&handler); } +static bool +auth_master_request_failed(struct auth_request_handler *handler, + struct auth_master_connection *master, + struct auth_stream_reply *reply, unsigned int id) +{ + auth_stream_reply_add(reply, "FAIL", NULL); + auth_stream_reply_add(reply, NULL, dec2str(id)); + if (handler->master_callback == NULL) + return FALSE; + handler->master_callback(reply, master); + return TRUE; +} + bool auth_request_handler_master_request(struct auth_request_handler *handler, struct auth_master_connection *master, - unsigned int id, - unsigned int client_id) + unsigned int id, unsigned int client_id, + const char *const *params) { struct auth_request *request; struct auth_stream_reply *reply; + struct net_unix_cred cred; reply = auth_stream_reply_init(pool_datastack_create()); @@ -689,17 +729,38 @@ if (request == NULL) { i_error("Master request %u.%u not found", handler->client_pid, client_id); - auth_stream_reply_add(reply, "FAIL", NULL); - auth_stream_reply_add(reply, NULL, dec2str(id)); - if (handler->master_callback == NULL) - return FALSE; - handler->master_callback(reply, master); - return TRUE; + return auth_master_request_failed(handler, master, reply, id); } auth_request_ref(request); auth_request_handler_remove(handler, request); + for (; *params != NULL; params++) { + const char *name, *param = strchr(*params, '='); + + if (param == NULL) { + name = *params; + param = ""; + } else { + name = t_strdup_until(*params, param); + param++; + } + + (void)auth_request_import_master(request, name, param); + } + + /* verify session pid if specified and possible */ + if (request->session_pid != (pid_t)-1 && + net_getunixcred(master->fd, &cred) == 0 && + cred.pid != (pid_t)-1 && request->session_pid != cred.pid) { + i_error("Session pid %ld provided by master for request %u.%u " + "did not match peer credentials (pid=%ld, uid=%ld)", + (long)request->session_pid, + handler->client_pid, client_id, + (long)cred.pid, (long)cred.uid); + return auth_master_request_failed(handler, master, reply, id); + } + if (request->state != AUTH_REQUEST_STATE_FINISHED || From dovecot at dovecot.org Fri Sep 14 22:10:58 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 22:10:58 +0300 Subject: dovecot-2.2: auth: Auth workers don't need to read token secret. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/172a75b3bed8 changeset: 15050:172a75b3bed8 user: Timo Sirainen date: Fri Sep 14 22:10:49 2012 +0300 description: auth: Auth workers don't need to read token secret. diffstat: src/auth/main.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r aa6027a0a78e -r 172a75b3bed8 src/auth/main.c --- a/src/auth/main.c Fri Sep 14 21:48:45 2012 +0300 +++ b/src/auth/main.c Fri Sep 14 22:10:49 2012 +0300 @@ -205,7 +205,8 @@ mech_reg, services); listeners_init(); - auth_token_init(); + if (!worker) + auth_token_init(); /* Password lookups etc. may require roots, allow it. */ restrict_access_by_env(NULL, FALSE); From dovecot at dovecot.org Fri Sep 14 23:11:43 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 14 Sep 2012 23:11:43 +0300 Subject: dovecot-2.2: Use "tokenlogin" socket name (instead of "token-log... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9ad9a79c1747 changeset: 15051:9ad9a79c1747 user: Timo Sirainen date: Fri Sep 14 23:11:27 2012 +0300 description: Use "tokenlogin" socket name (instead of "token-login") after all. Auth code has special checks for '-', which breaks "token-login" and fixing it is rather annoying. diffstat: src/auth/auth-settings.c | 2 +- src/login-common/login-common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diffs (24 lines): diff -r 172a75b3bed8 -r 9ad9a79c1747 src/auth/auth-settings.c --- a/src/auth/auth-settings.c Fri Sep 14 22:10:49 2012 +0300 +++ b/src/auth/auth-settings.c Fri Sep 14 23:11:27 2012 +0300 @@ -17,7 +17,7 @@ /* */ static struct file_listener_settings auth_unix_listeners_array[] = { { "login/login", 0666, "", "" }, - { "token-login/token-login", 0666, "", "" }, + { "token-login/tokenlogin", 0666, "", "" }, { "auth-login", 0600, "$default_internal_user", "" }, { "auth-client", 0600, "", "" }, { "auth-userdb", 0666, "$default_internal_user", "" }, diff -r 172a75b3bed8 -r 9ad9a79c1747 src/login-common/login-common.h --- a/src/login-common/login-common.h Fri Sep 14 22:10:49 2012 +0300 +++ b/src/login-common/login-common.h Fri Sep 14 23:11:27 2012 +0300 @@ -13,7 +13,7 @@ "Plaintext authentication disallowed on non-secure (SSL/TLS) connections." #define LOGIN_DEFAULT_SOCKET "login" -#define LOGIN_TOKEN_DEFAULT_SOCKET "token-login" +#define LOGIN_TOKEN_DEFAULT_SOCKET "tokenlogin" struct login_binary { /* e.g. imap, pop3 */ From dovecot at dovecot.org Sat Sep 15 03:12:36 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 03:12:36 +0300 Subject: dovecot-2.2: uni_utf8_to_decomposed_titlecase(): Require input l... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d5ebec837bfd changeset: 15052:d5ebec837bfd user: Timo Sirainen date: Sat Sep 15 03:09:57 2012 +0300 description: uni_utf8_to_decomposed_titlecase(): Require input length to be exact now. Most of the callers did that already anyway diffstat: src/lib-storage/index/index-sort.c | 2 +- src/lib/unichar.c | 10 +++++----- src/lib/unichar.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diffs (58 lines): diff -r 9ad9a79c1747 -r d5ebec837bfd src/lib-storage/index/index-sort.c --- a/src/lib-storage/index/index-sort.c Fri Sep 14 23:11:27 2012 +0300 +++ b/src/lib-storage/index/index-sort.c Sat Sep 15 03:09:57 2012 +0300 @@ -443,7 +443,7 @@ i_unreached(); } - (void)uni_utf8_to_decomposed_titlecase(str, (size_t)-1, dest); + (void)uni_utf8_to_decomposed_titlecase(str, strlen(str), dest); return ret; } diff -r 9ad9a79c1747 -r d5ebec837bfd src/lib/unichar.c --- a/src/lib/unichar.c Fri Sep 14 23:11:27 2012 +0300 +++ b/src/lib/unichar.c Sat Sep 15 03:09:57 2012 +0300 @@ -307,7 +307,7 @@ buffer_append(output, utf8_replacement_char, UTF8_REPLACEMENT_CHAR_LEN); } -int uni_utf8_to_decomposed_titlecase(const void *_input, size_t max_len, +int uni_utf8_to_decomposed_titlecase(const void *_input, size_t size, buffer_t *output) { const unsigned char *input = _input; @@ -315,17 +315,17 @@ unichar_t chr; int ret = 0; - while (max_len > 0 && *input != '\0') { - if (uni_utf8_get_char_n(input, max_len, &chr) <= 0) { + while (size > 0) { + if (uni_utf8_get_char_n(input, size, &chr) <= 0) { /* invalid input. try the next byte. */ ret = -1; - input++; max_len--; + input++; size--; output_add_replacement_char(output); continue; } bytes = uni_utf8_char_bytes(*input); input += bytes; - max_len -= bytes; + size -= bytes; chr = uni_ucs4_to_titlecase(chr); if (chr >= HANGUL_FIRST && chr <= HANGUL_LAST) diff -r 9ad9a79c1747 -r d5ebec837bfd src/lib/unichar.h --- a/src/lib/unichar.h Fri Sep 14 23:11:27 2012 +0300 +++ b/src/lib/unichar.h Sat Sep 15 03:09:57 2012 +0300 @@ -69,7 +69,7 @@ output buffer. Returns 0 if ok, -1 if input was invalid. This generates output that's compatible with i;unicode-casemap comparator. Invalid input is replaced with unicode replacement character (0xfffd). */ -int uni_utf8_to_decomposed_titlecase(const void *input, size_t max_len, +int uni_utf8_to_decomposed_titlecase(const void *input, size_t size, buffer_t *output); /* If input contains only valid UTF-8 characters, return TRUE without updating From dovecot at dovecot.org Sat Sep 15 03:12:36 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 03:12:36 +0300 Subject: dovecot-2.2: Replaced "decomposed titlecase" conversions with mo... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c976a9c01613 changeset: 15053:c976a9c01613 user: Timo Sirainen date: Sat Sep 15 03:12:20 2012 +0300 description: Replaced "decomposed titlecase" conversions with more generic normalizer function. Plugins can now change mail_user.default_normalizer. Specific searches can also use different normalizers by changing mail_search_context.normalizer. diffstat: src/doveadm/doveadm-mail-fetch.c | 2 +- src/lib-charset/charset-iconv.c | 23 +++++++-------- src/lib-charset/charset-utf8.c | 46 ++++++++++++++++-------------- src/lib-charset/charset-utf8.h | 16 ++++------ src/lib-imap/imap-base-subject.c | 2 +- src/lib-mail/message-decoder.c | 26 +++++++---------- src/lib-mail/message-decoder.h | 8 ++-- src/lib-mail/message-header-decode.c | 15 ++++------ src/lib-mail/message-header-decode.h | 7 ++-- src/lib-mail/message-search.c | 15 ++++----- src/lib-mail/message-search.h | 8 ++--- src/lib-mail/test-message-decoder.c | 7 ++-- src/lib-mail/test-message-header-decode.c | 2 +- src/lib-storage/index/index-search.c | 25 ++++++++++------ src/lib-storage/mail-storage-private.h | 2 + src/lib-storage/mail-user.c | 1 + src/lib-storage/mail-user.h | 2 + src/lib/unichar.h | 6 ++++ src/plugins/fts-squat/fts-backend-squat.c | 6 ++-- src/plugins/fts/fts-api-private.h | 6 ++- src/plugins/fts/fts-api.c | 7 ++++- src/plugins/fts/fts-build-mail.c | 5 +-- 22 files changed, 125 insertions(+), 112 deletions(-) diffs (truncated from 764 to 300 lines): diff -r d5ebec837bfd -r c976a9c01613 src/doveadm/doveadm-mail-fetch.c --- a/src/doveadm/doveadm-mail-fetch.c Sat Sep 15 03:09:57 2012 +0300 +++ b/src/doveadm/doveadm-mail-fetch.c Sat Sep 15 03:12:20 2012 +0300 @@ -265,7 +265,7 @@ parser = message_parser_init(pool_datastack_create(), input, MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE, 0); - decoder = message_decoder_init(0); + decoder = message_decoder_init(NULL, 0); while ((ret = message_parser_parse_next_block(parser, &raw_block)) > 0) { if (!message_decoder_decode_next_block(decoder, &raw_block, diff -r d5ebec837bfd -r c976a9c01613 src/lib-charset/charset-iconv.c --- a/src/lib-charset/charset-iconv.c Sat Sep 15 03:09:57 2012 +0300 +++ b/src/lib-charset/charset-iconv.c Sat Sep 15 03:12:20 2012 +0300 @@ -12,10 +12,10 @@ struct charset_translation { iconv_t cd; - enum charset_flags flags; + normalizer_func_t *normalizer; }; -int charset_to_utf8_begin(const char *charset, enum charset_flags flags, +int charset_to_utf8_begin(const char *charset, normalizer_func_t *normalizer, struct charset_translation **t_r) { struct charset_translation *t; @@ -31,7 +31,7 @@ t = i_new(struct charset_translation, 1); t->cd = cd; - t->flags = flags; + t->normalizer = normalizer; *t_r = t; return 0; } @@ -54,12 +54,12 @@ } static int -charset_append_utf8(const void *src, size_t src_size, - buffer_t *dest, bool dtcase) +charset_append_utf8(struct charset_translation *t, + const void *src, size_t src_size, buffer_t *dest) { - if (dtcase) - return uni_utf8_to_decomposed_titlecase(src, src_size, dest); - if (!uni_utf8_get_valid_data(src, src_size, dest)) + if (t->normalizer != NULL) + return t->normalizer(src, src_size, dest); + else if (!uni_utf8_get_valid_data(src, src_size, dest)) return -1; else { buffer_append(dest, src, src_size); @@ -75,12 +75,11 @@ ICONV_CONST char *ic_srcbuf; char tmpbuf[8192], *ic_destbuf; size_t srcleft, destleft; - bool dtcase = (t->flags & CHARSET_FLAG_DECOMP_TITLECASE) != 0; bool ret = TRUE; if (t->cd == (iconv_t)-1) { /* input is already supposed to be UTF-8 */ - if (charset_append_utf8(src, *src_size, dest, dtcase) < 0) + if (charset_append_utf8(t, src, *src_size, dest) < 0) *result = CHARSET_RET_INVALID_INPUT; else *result = CHARSET_RET_OK; @@ -110,8 +109,8 @@ /* we just converted data to UTF-8. it shouldn't be invalid, but Solaris iconv appears to pass invalid data through sometimes (e.g. 8 bit characters with UTF-7) */ - if (charset_append_utf8(tmpbuf, sizeof(tmpbuf) - destleft, - dest, dtcase) < 0) + if (charset_append_utf8(t, tmpbuf, sizeof(tmpbuf) - destleft, + dest) < 0) *result = CHARSET_RET_INVALID_INPUT; return ret; } diff -r d5ebec837bfd -r c976a9c01613 src/lib-charset/charset-utf8.c --- a/src/lib-charset/charset-utf8.c Sat Sep 15 03:09:57 2012 +0300 +++ b/src/lib-charset/charset-utf8.c Sat Sep 15 03:12:20 2012 +0300 @@ -16,14 +16,14 @@ strcasecmp(charset, "UTF8") == 0; } -int charset_to_utf8_str(const char *charset, enum charset_flags flags, +int charset_to_utf8_str(const char *charset, normalizer_func_t *normalizer, const char *input, string_t *output, enum charset_result *result_r) { struct charset_translation *t; size_t len = strlen(input); - if (charset_to_utf8_begin(charset, flags, &t) < 0) + if (charset_to_utf8_begin(charset, normalizer, &t) < 0) return -1; *result_r = charset_to_utf8(t, (const unsigned char *)input, @@ -35,31 +35,31 @@ #ifndef HAVE_ICONV struct charset_translation { - enum charset_flags flags; + normalizer_func_t *normalizer; }; -static struct charset_translation raw_translation = { 0 }; -static struct charset_translation tc_translation = { - CHARSET_FLAG_DECOMP_TITLECASE -}; - -int charset_to_utf8_begin(const char *charset, enum charset_flags flags, +int charset_to_utf8_begin(const char *charset, normalizer_func_t *normalizer, struct charset_translation **t_r) { - if (charset_is_utf8(charset)) { - if ((flags & CHARSET_FLAG_DECOMP_TITLECASE) != 0) - *t_r = &tc_translation; - else - *t_r = &raw_translation; - return 0; + struct charset_translation *t; + + if (!charset_is_utf8(charset)) { + /* no support for charsets that need translation */ + return -1; } - /* no support for charsets that need translation */ - return -1; + t = i_new(struct charset_translation, 1); + t->normalizer = normalizer; + *t_r = t; + return 0; } -void charset_to_utf8_end(struct charset_translation **t ATTR_UNUSED) +void charset_to_utf8_end(struct charset_translation **_t) { + struct charset_translation *t = *_t; + + *_t = NULL; + i_free(t); } void charset_to_utf8_reset(struct charset_translation *t ATTR_UNUSED) @@ -70,11 +70,13 @@ charset_to_utf8(struct charset_translation *t, const unsigned char *src, size_t *src_size, buffer_t *dest) { - if ((t->flags & CHARSET_FLAG_DECOMP_TITLECASE) == 0) + if (t->normalizer != NULL) { + if (t->normalizer(src, *src_size, dest) < 0) + return CHARSET_RET_INVALID_INPUT; + } else if (!uni_utf8_get_valid_data(src, *src_size, dest)) { + return CHARSET_RET_INVALID_INPUT; + } else { buffer_append(dest, src, *src_size); - else { - if (uni_utf8_to_decomposed_titlecase(src, *src_size, dest) < 0) - return CHARSET_RET_INVALID_INPUT; } return CHARSET_RET_OK; } diff -r d5ebec837bfd -r c976a9c01613 src/lib-charset/charset-utf8.h --- a/src/lib-charset/charset-utf8.h Sat Sep 15 03:09:57 2012 +0300 +++ b/src/lib-charset/charset-utf8.h Sat Sep 15 03:12:20 2012 +0300 @@ -1,13 +1,10 @@ #ifndef CHARSET_UTF8_H #define CHARSET_UTF8_H +#include "unichar.h" + struct charset_translation; -enum charset_flags { - /* Translate the output to decomposed titlecase */ - CHARSET_FLAG_DECOMP_TITLECASE = 0x01 -}; - enum charset_result { CHARSET_RET_OK = 1, CHARSET_RET_INCOMPLETE_INPUT = -1, @@ -15,8 +12,9 @@ }; /* Begin translation to UTF-8. Returns -1 if charset is unknown. */ -int charset_to_utf8_begin(const char *charset, enum charset_flags flags, - struct charset_translation **t_r); +int charset_to_utf8_begin(const char *charset, normalizer_func_t *normalizer, + struct charset_translation **t_r) + ATTR_NULL(2); void charset_to_utf8_end(struct charset_translation **t); void charset_to_utf8_reset(struct charset_translation *t); @@ -30,8 +28,8 @@ const unsigned char *src, size_t *src_size, buffer_t *dest); /* Translate a single string to UTF8. */ -int charset_to_utf8_str(const char *charset, enum charset_flags flags, +int charset_to_utf8_str(const char *charset, normalizer_func_t *normalizer, const char *input, string_t *output, - enum charset_result *result_r); + enum charset_result *result_r) ATTR_NULL(2); #endif diff -r d5ebec837bfd -r c976a9c01613 src/lib-imap/imap-base-subject.c --- a/src/lib-imap/imap-base-subject.c Sat Sep 15 03:09:57 2012 +0300 +++ b/src/lib-imap/imap-base-subject.c Sat Sep 15 03:12:20 2012 +0300 @@ -210,7 +210,7 @@ UTF-8. Convert all tabs and continuations to space. Convert all multiple spaces to a single space. */ message_header_decode_utf8((const unsigned char *)subject, subject_len, - buf, TRUE); + buf, uni_utf8_to_decomposed_titlecase); buffer_append_c(buf, '\0'); pack_whitespace(buf); diff -r d5ebec837bfd -r c976a9c01613 src/lib-mail/message-decoder.c --- a/src/lib-mail/message-decoder.c Sat Sep 15 03:09:57 2012 +0300 +++ b/src/lib-mail/message-decoder.c Sat Sep 15 03:12:20 2012 +0300 @@ -22,6 +22,7 @@ struct message_decoder_context { enum message_decoder_flags flags; + normalizer_func_t *normalizer; struct message_part *prev_part; struct message_header_line hdr; @@ -46,12 +47,14 @@ struct message_part *part); struct message_decoder_context * -message_decoder_init(enum message_decoder_flags flags) +message_decoder_init(normalizer_func_t *normalizer, + enum message_decoder_flags flags) { struct message_decoder_context *ctx; ctx = i_new(struct message_decoder_context, 1); ctx->flags = flags; + ctx->normalizer = normalizer; ctx->buf = buffer_create_dynamic(default_pool, 8192); ctx->buf2 = buffer_create_dynamic(default_pool, 8192); ctx->encoding_buf = buffer_create_dynamic(default_pool, 128); @@ -149,7 +152,6 @@ struct message_header_line *hdr, struct message_block *output) { - bool dtcase = (ctx->flags & MESSAGE_DECODER_FLAG_DTCASE) != 0; size_t value_len; if (hdr->continues) { @@ -168,12 +170,11 @@ buffer_set_used_size(ctx->buf, 0); message_header_decode_utf8(hdr->full_value, hdr->full_value_len, - ctx->buf, dtcase); + ctx->buf, ctx->normalizer); value_len = ctx->buf->used; - if (dtcase) { - (void)uni_utf8_to_decomposed_titlecase(hdr->name, hdr->name_len, - ctx->buf); + if (ctx->normalizer != NULL) { + (void)ctx->normalizer(hdr->name, hdr->name_len, ctx->buf); buffer_append_c(ctx->buf, '\0'); } else { if (!uni_utf8_get_valid_data((const unsigned char *)hdr->name, @@ -229,8 +230,6 @@ message_decode_body_init_charset(struct message_decoder_context *ctx, struct message_part *part) { - enum charset_flags flags; - ctx->binary_input = ctx->content_charset == NULL && (ctx->flags & MESSAGE_DECODER_FLAG_RETURN_BINARY) != 0 && (part->flags & (MESSAGE_PART_FLAG_TEXT | @@ -249,12 +248,10 @@ charset_to_utf8_end(&ctx->charset_trans); i_free_and_null(ctx->charset_trans_charset); - flags = (ctx->flags & MESSAGE_DECODER_FLAG_DTCASE) != 0 ? - CHARSET_FLAG_DECOMP_TITLECASE : 0; ctx->charset_trans_charset = i_strdup(ctx->content_charset != NULL ? ctx->content_charset : "UTF-8"); - if (charset_to_utf8_begin(ctx->charset_trans_charset, - flags, &ctx->charset_trans) < 0) + if (charset_to_utf8_begin(ctx->charset_trans_charset, ctx->normalizer, + &ctx->charset_trans) < 0) ctx->charset_trans = NULL; } @@ -331,9 +328,8 @@ output->size = size; } else if (ctx->charset_utf8) { buffer_set_used_size(ctx->buf2, 0); - if ((ctx->flags & MESSAGE_DECODER_FLAG_DTCASE) != 0) { From dovecot at dovecot.org Sat Sep 15 03:49:37 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 03:49:37 +0300 Subject: dovecot-2.2: fts-lucene: Added "normalize" option to put data th... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/07ac1dbcc033 changeset: 15054:07ac1dbcc033 user: Timo Sirainen date: Sat Sep 15 03:49:23 2012 +0300 description: fts-lucene: Added "normalize" option to put data through normalize(). diffstat: src/plugins/fts-lucene/Snowball.cc | 30 +++++++++++++++++++++++------- src/plugins/fts-lucene/SnowballAnalyzer.h | 7 ++++++- src/plugins/fts-lucene/SnowballFilter.h | 3 ++- 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 | 12 ++++++++++-- 6 files changed, 51 insertions(+), 11 deletions(-) diffs (217 lines): diff -r c976a9c01613 -r 07ac1dbcc033 src/plugins/fts-lucene/Snowball.cc --- a/src/plugins/fts-lucene/Snowball.cc Sat Sep 15 03:12:20 2012 +0300 +++ b/src/plugins/fts-lucene/Snowball.cc Sat Sep 15 03:49:23 2012 +0300 @@ -26,8 +26,9 @@ CL_NS_DEF2(analysis,snowball) /** Builds the named analyzer with no stop words. */ - SnowballAnalyzer::SnowballAnalyzer(const char* language) { + SnowballAnalyzer::SnowballAnalyzer(normalizer_func_t *normalizer, const char* language) { this->language = strdup(language); + this->normalizer = normalizer; stopSet = NULL; prevstream = NULL; } @@ -67,7 +68,7 @@ result = _CLNEW CL_NS(analysis)::LowerCaseFilter(result, true); if (stopSet != NULL) result = _CLNEW CL_NS(analysis)::StopFilter(result, true, stopSet); - result = _CLNEW SnowballFilter(result, language, true); + result = _CLNEW SnowballFilter(result, normalizer, language, true); return result; } @@ -87,10 +88,11 @@ * @param in the input tokens to stem * @param name the name of a stemmer */ - SnowballFilter::SnowballFilter(TokenStream* in, const char* language, bool deleteTS): + SnowballFilter::SnowballFilter(TokenStream* in, normalizer_func_t *normalizer, const char* language, bool deleteTS): TokenFilter(in,deleteTS) { stemmer = sb_stemmer_new(language, NULL); //use utf8 encoding + this->normalizer = normalizer; if ( stemmer == NULL ){ _CLTHROWA(CL_ERR_IllegalArgument, "language not available for stemming\n"); //todo: richer error @@ -120,10 +122,24 @@ int stemmedLen=sb_stemmer_length(stemmer); - unsigned int tchartext_size = uni_utf8_strlen_n(stemmed, stemmedLen) + 1; - TCHAR tchartext[tchartext_size]; - lucene_utf8_n_to_tchar(stemmed,stemmedLen,tchartext,tchartext_size); - token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + if (normalizer == NULL) { + unsigned int tchartext_size = + uni_utf8_strlen_n(stemmed, stemmedLen) + 1; + TCHAR tchartext[tchartext_size]; + lucene_utf8_n_to_tchar(stemmed, stemmedLen, tchartext, tchartext_size); + token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + } else T_BEGIN { + buffer_t *norm_buf = buffer_create_dynamic(pool_datastack_create(), + stemmedLen); + normalizer(stemmed, stemmedLen, norm_buf); + + unsigned int tchartext_size = + uni_utf8_strlen_n(norm_buf->data, norm_buf->used) + 1; + TCHAR tchartext[tchartext_size]; + lucene_utf8_n_to_tchar((const unsigned char *)norm_buf->data, + norm_buf->used, tchartext, tchartext_size); + token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + } T_END; return token; } diff -r c976a9c01613 -r 07ac1dbcc033 src/plugins/fts-lucene/SnowballAnalyzer.h --- a/src/plugins/fts-lucene/SnowballAnalyzer.h Sat Sep 15 03:12:20 2012 +0300 +++ b/src/plugins/fts-lucene/SnowballAnalyzer.h Sat Sep 15 03:49:23 2012 +0300 @@ -7,6 +7,10 @@ #ifndef _lucene_analysis_snowball_analyser_ #define _lucene_analysis_snowball_analyser_ +extern "C" { +#include "lib.h" +#include "unichar.h" +}; #include "CLucene/analysis/AnalysisHeader.h" CL_CLASS_DEF(util,BufferedReader) @@ -21,12 +25,13 @@ */ class CLUCENE_CONTRIBS_EXPORT SnowballAnalyzer: public Analyzer { char* language; + normalizer_func_t *normalizer; CLTCSetList* stopSet; TokenStream *prevstream; public: /** Builds the named analyzer with no stop words. */ - SnowballAnalyzer(const char* language="english"); + SnowballAnalyzer(normalizer_func_t *normalizer, const char* language="english"); /** Builds the named analyzer with the given stop words. */ diff -r c976a9c01613 -r 07ac1dbcc033 src/plugins/fts-lucene/SnowballFilter.h --- a/src/plugins/fts-lucene/SnowballFilter.h Sat Sep 15 03:12:20 2012 +0300 +++ b/src/plugins/fts-lucene/SnowballFilter.h Sat Sep 15 03:49:23 2012 +0300 @@ -22,6 +22,7 @@ */ class CLUCENE_CONTRIBS_EXPORT SnowballFilter: public TokenFilter { struct sb_stemmer * stemmer; + normalizer_func_t *normalizer; public: /** Construct the named stemming filter. @@ -29,7 +30,7 @@ * @param in the input tokens to stem * @param name the name of a stemmer */ - SnowballFilter(TokenStream* in, const char* language, bool deleteTS); + SnowballFilter(TokenStream* in, normalizer_func_t *normalizer, const char* language, bool deleteTS); ~SnowballFilter(); diff -r c976a9c01613 -r 07ac1dbcc033 src/plugins/fts-lucene/fts-lucene-plugin.c --- a/src/plugins/fts-lucene/fts-lucene-plugin.c Sat Sep 15 03:12:20 2012 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Sat Sep 15 03:49:23 2012 +0300 @@ -28,6 +28,8 @@ set->textcat_dir = p_strdup(user->pool, *tmp + 12); } else if (strncmp(*tmp, "whitespace_chars=", 17) == 0) { set->whitespace_chars = p_strdup(user->pool, *tmp + 17); + } else if (strcmp(*tmp, "normalize") == 0) { + set->normalize = TRUE; } else { i_error("fts_lucene: Invalid setting: %s", *tmp); return -1; @@ -49,6 +51,11 @@ "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"; @@ -71,6 +78,8 @@ crc = set->default_language == NULL ? 0 : crc32_str(set->default_language); crc = crc32_str_more(crc, set->whitespace_chars); + if (set->normalize) + crc = crc32_str_more(crc, "n"); return crc; } diff -r c976a9c01613 -r 07ac1dbcc033 src/plugins/fts-lucene/fts-lucene-plugin.h --- a/src/plugins/fts-lucene/fts-lucene-plugin.h Sat Sep 15 03:12:20 2012 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.h Sat Sep 15 03:49:23 2012 +0300 @@ -12,6 +12,7 @@ const char *default_language; const char *textcat_conf, *textcat_dir; const char *whitespace_chars; + bool normalize; }; struct fts_lucene_user { diff -r c976a9c01613 -r 07ac1dbcc033 src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Sat Sep 15 03:12:20 2012 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Sat Sep 15 03:49:23 2012 +0300 @@ -10,6 +10,7 @@ #include "mail-index.h" #include "mail-search.h" #include "mail-namespace.h" +#include "mailbox-list-private.h" #include "mail-storage.h" #include "fts-expunge-log.h" #include "fts-lucene-plugin.h" @@ -58,6 +59,7 @@ char *path; struct mailbox_list *list; struct fts_lucene_settings set; + normalizer_func_t *normalizer; wchar_t mailbox_guid[MAILBOX_GUID_HEX_LENGTH + 1]; @@ -107,6 +109,8 @@ index = i_new(struct lucene_index, 1); index->path = i_strdup(path); index->list = list; + index->normalizer = !set->normalize ? NULL : + list->ns->user->default_normalizer; if (set != NULL) index->set = *set; else { @@ -115,9 +119,11 @@ } #ifdef HAVE_LUCENE_STEMMER index->default_analyzer = - _CLNEW snowball::SnowballAnalyzer(index->set.default_language); + _CLNEW snowball::SnowballAnalyzer(index->normalizer, + index->set.default_language); #else index->default_analyzer = _CLNEW standard::StandardAnalyzer(); + i_assert(index->normalizer == NULL); #endif i_array_init(&index->analyzers, 32); textcat_refcount++; @@ -397,6 +403,7 @@ #ifdef HAVE_LUCENE_TEXTCAT static Analyzer *get_analyzer(struct lucene_index *index, const char *lang) { + normalizer_func_t *normalizer = index->normalizer; const struct lucene_analyzer *a; struct lucene_analyzer new_analyzer; Analyzer *analyzer; @@ -408,7 +415,8 @@ memset(&new_analyzer, 0, sizeof(new_analyzer)); new_analyzer.lang = i_strdup(lang); - new_analyzer.analyzer = _CLNEW snowball::SnowballAnalyzer(lang); + new_analyzer.analyzer = + _CLNEW snowball::SnowballAnalyzer(normalizer, lang); array_append_i(&index->analyzers.arr, &new_analyzer, 1); return new_analyzer.analyzer; } From dovecot at dovecot.org Sat Sep 15 15:46:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 15:46:18 +0300 Subject: dovecot-2.2: lib-storage: Moved index_mail.data_pool to mail_pri... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c436a6c3f7d2 changeset: 15055:c436a6c3f7d2 user: Timo Sirainen date: Sat Sep 15 15:46:01 2012 +0300 description: lib-storage: Moved index_mail.data_pool to mail_private.data_pool diffstat: src/lib-storage/index/dbox-common/dbox-mail.c | 2 +- src/lib-storage/index/imapc/imapc-mail.c | 4 +- src/lib-storage/index/index-mail-binary.c | 6 ++-- src/lib-storage/index/index-mail-headers.c | 38 +++++++++++++------------- src/lib-storage/index/index-mail.c | 32 +++++++++++----------- src/lib-storage/index/index-mail.h | 2 - src/lib-storage/index/index-search.c | 2 +- src/lib-storage/index/maildir/maildir-mail.c | 10 +++--- src/lib-storage/index/mbox/mbox-mail.c | 2 +- src/lib-storage/mail-storage-private.h | 2 +- src/plugins/virtual/virtual-mail.c | 8 ++-- 11 files changed, 53 insertions(+), 55 deletions(-) diffs (truncated from 488 to 300 lines): diff -r 07ac1dbcc033 -r c436a6c3f7d2 src/lib-storage/index/dbox-common/dbox-mail.c --- a/src/lib-storage/index/dbox-common/dbox-mail.c Sat Sep 15 03:49:23 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-mail.c Sat Sep 15 15:46:01 2012 +0300 @@ -166,7 +166,7 @@ const char *value; string_t *str; - str = str_new(imail->data_pool, 64); + str = str_new(imail->mail.data_pool, 64); if (mail_cache_lookup_field(imail->mail.mail.transaction->cache_view, str, imail->mail.mail.seq, ibox->cache_fields[cache_field].idx) > 0) { diff -r 07ac1dbcc033 -r c436a6c3f7d2 src/lib-storage/index/imapc/imapc-mail.c --- a/src/lib-storage/index/imapc/imapc-mail.c Sat Sep 15 03:49:23 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail.c Sat Sep 15 15:46:01 2012 +0300 @@ -333,7 +333,7 @@ sha1_result(&sha1_ctx, sha1_output); sha1_str = binary_to_hex(sha1_output, sizeof(sha1_output)); - imail->data.guid = p_strdup(imail->data_pool, sha1_str); + imail->data.guid = p_strdup(imail->mail.data_pool, sha1_str); return 0; } @@ -350,7 +350,7 @@ return 0; } - str = str_new(imail->data_pool, 64); + str = str_new(imail->mail.data_pool, 64); if (mail_cache_lookup_field(_mail->transaction->cache_view, str, imail->mail.mail.seq, cache_idx) > 0) { *value_r = str_c(str); diff -r 07ac1dbcc033 -r c436a6c3f7d2 src/lib-storage/index/index-mail-binary.c --- a/src/lib-storage/index/index-mail-binary.c Sat Sep 15 03:49:23 2012 +0300 +++ b/src/lib-storage/index/index-mail-binary.c Sat Sep 15 15:46:01 2012 +0300 @@ -261,7 +261,7 @@ } if (found) { bin_part.next = *msg_bin_parts; - *msg_bin_parts = p_new(mail->data_pool, + *msg_bin_parts = p_new(mail->mail.data_pool, struct message_binary_part, 1); **msg_bin_parts = bin_part; } @@ -362,8 +362,8 @@ if (ret <= 0) return FALSE; - if (message_binary_part_deserialize(mail->data_pool, part_buf->data, - part_buf->used, + if (message_binary_part_deserialize(mail->mail.data_pool, + part_buf->data, part_buf->used, &mail->data.bin_parts) < 0) { mail_cache_set_corrupted(mail->mail.mail.box->cache, "Corrupted cached binary.parts data"); diff -r 07ac1dbcc033 -r c436a6c3f7d2 src/lib-storage/index/index-mail-headers.c --- a/src/lib-storage/index/index-mail-headers.c Sat Sep 15 03:49:23 2012 +0300 +++ b/src/lib-storage/index/index-mail-headers.c Sat Sep 15 15:46:01 2012 +0300 @@ -256,7 +256,7 @@ mail->ibox->cache_fields[MAIL_CACHE_IMAP_ENVELOPE].idx; string_t *str; - str = str_new(mail->data_pool, 256); + str = str_new(mail->mail.data_pool, 256); imap_envelope_write_part_data(mail->data.envelope_data, str); mail->data.envelope = str_c(str); @@ -280,11 +280,11 @@ if (data->save_bodystructure_header) { i_assert(part != NULL); - imap_bodystructure_parse_header(mail->data_pool, part, hdr); + imap_bodystructure_parse_header(mail->mail.data_pool, part, hdr); } if (data->save_envelope) { - imap_envelope_parse_header(mail->data_pool, + imap_envelope_parse_header(mail->mail.data_pool, &data->envelope_data, hdr); if (hdr == NULL) @@ -375,7 +375,7 @@ index_mail_parse_header_init(mail, NULL); mail->data.parser_ctx = - message_parser_init(mail->data_pool, input, + message_parser_init(mail->mail.data_pool, input, hdr_parser_flags, msg_parser_flags); i_stream_unref(&input); return input2; @@ -390,7 +390,7 @@ (void)message_parser_deinit(&data->parser_ctx, &parts); if (data->parts == NULL) { - data->parser_ctx = message_parser_init(mail->data_pool, + data->parser_ctx = message_parser_init(mail->mail.data_pool, data->stream, hdr_parser_flags, msg_parser_flags); @@ -441,7 +441,7 @@ imap_envelope_parse_callback(struct message_header_line *hdr, struct index_mail *mail) { - imap_envelope_parse_header(mail->data_pool, + imap_envelope_parse_header(mail->mail.data_pool, &mail->data.envelope_data, hdr); if (hdr == NULL) @@ -457,7 +457,7 @@ uoff_t old_offset; string_t *str; - str = str_new(mail->data_pool, 256); + str = str_new(mail->mail.data_pool, 256); if (index_mail_cache_lookup_field(mail, str, cache_field_envelope) > 0) { mail->data.envelope = str_c(str); @@ -555,7 +555,7 @@ i_assert(*line_idx != 0); first_line_idx = *line_idx - 1; - p_array_init(&header_values, mail->data_pool, 4); + p_array_init(&header_values, mail->mail.data_pool, 4); header = buffer_get_data(mail->header_data, NULL); lines = array_get(&mail->header_lines, &lines_count); @@ -569,7 +569,7 @@ if (skip_header(&value_start, value_end - value_start)) { if (value_start != value_end && value_end[-1] == '\n') value_end--; - value = p_strndup(mail->data_pool, value_start, + value = p_strndup(mail->mail.data_pool, value_start, value_end - value_start); array_append(&header_values, &value, 1); } @@ -598,11 +598,11 @@ field_idx = get_header_field_idx(_mail->box, field, MAIL_CACHE_DECISION_TEMP); - dest = str_new(mail->data_pool, 128); + dest = str_new(mail->mail.data_pool, 128); if (mail_cache_lookup_headers(_mail->transaction->cache_view, dest, _mail->seq, &field_idx, 1) <= 0) { /* not in cache / error - first see if it's already parsed */ - p_free(mail->data_pool, dest); + p_free(mail->mail.data_pool, dest); if (mail->header_seq != mail->data.seq || index_mail_header_is_parsed(mail, field_idx) < 0) { @@ -619,7 +619,7 @@ if ((ret = index_mail_header_is_parsed(mail, field_idx)) <= 0) { /* not found */ i_assert(ret != -1); - *value_r = p_new(mail->data_pool, const char *, 1); + *value_r = p_new(mail->mail.data_pool, const char *, 1); return 0; } *value_r = index_mail_get_parsed_header(mail, field_idx); @@ -630,11 +630,11 @@ if (len == 0) { /* cached as nonexistent. */ - *value_r = p_new(mail->data_pool, const char *, 1); + *value_r = p_new(mail->mail.data_pool, const char *, 1); return 0; } - p_array_init(&header_values, mail->data_pool, 4); + p_array_init(&header_values, mail->mail.data_pool, 4); /* cached. skip "header name: " parts in dest. */ for (i = 0; i < len; i++) { @@ -704,21 +704,21 @@ count = str_array_length(list); if (count > max_count) count = max_count; - decoded_list = p_new(mail->data_pool, const char *, count + 1); + decoded_list = p_new(mail->mail.data_pool, const char *, count + 1); str = t_str_new(512); for (i = 0; i < count; i++) { str_truncate(str, 0); input = list[i]; /* unfold all lines into a single line */ - if (unfold_header(mail->data_pool, &input) < 0) + if (unfold_header(mail->mail.data_pool, &input) < 0) return -1; /* decode MIME encoded-words. decoding may also add new LFs. */ message_header_decode_utf8((const unsigned char *)input, strlen(input), str, FALSE); if (strcmp(str_c(str), input) != 0) - input = p_strdup(mail->data_pool, str_c(str)); + input = p_strdup(mail->mail.data_pool, str_c(str)); decoded_list[i] = input; } *_list = decoded_list; @@ -803,7 +803,7 @@ return -1; } - dest = str_new(mail->data_pool, 256); + dest = str_new(mail->mail.data_pool, 256); if (mail_cache_lookup_headers(_mail->transaction->cache_view, dest, _mail->seq, headers->idx, headers->count) > 0) { @@ -818,7 +818,7 @@ return 0; } /* not in cache / error */ - p_free(mail->data_pool, dest); + p_free(mail->mail.data_pool, dest); if (mail_get_hdr_stream(_mail, NULL, &input) < 0) return -1; diff -r 07ac1dbcc033 -r c436a6c3f7d2 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Sat Sep 15 03:49:23 2012 +0300 +++ b/src/lib-storage/index/index-mail.c Sat Sep 15 15:46:01 2012 +0300 @@ -83,7 +83,7 @@ if (ret <= 0) return NULL; - parts = message_part_deserialize(mail->data_pool, part_buf->data, + parts = message_part_deserialize(mail->mail.data_pool, part_buf->data, part_buf->used, &error); if (parts == NULL) { mail_cache_set_corrupted(mail->mail.mail.box->cache, @@ -210,7 +210,7 @@ keyword_indexes = array_get(&data->keyword_indexes, &count); names = array_get(mail->ibox->keyword_names, &names_count); - p_array_init(&data->keywords, mail->data_pool, count + 1); + p_array_init(&data->keywords, mail->mail.data_pool, count + 1); for (i = 0; i < count; i++) { const char *name; i_assert(keyword_indexes[i] < names_count); @@ -231,7 +231,7 @@ struct index_mail_data *data = &mail->data; if (!array_is_created(&data->keyword_indexes)) { - p_array_init(&data->keyword_indexes, mail->data_pool, 32); + p_array_init(&data->keyword_indexes, mail->mail.data_pool, 32); mail_index_lookup_keywords(_mail->transaction->view, mail->data.seq, &data->keyword_indexes); @@ -654,7 +654,7 @@ _mail->seq, cache_field_bodystructure); } if (cache_bodystructure) { - str = str_new(mail->data_pool, 128); + str = str_new(mail->mail.data_pool, 128); imap_bodystructure_write(data->parts, str, TRUE); data->bodystructure = str_c(str); @@ -686,7 +686,7 @@ } if (cache_body) { - str = str_new(mail->data_pool, 128); + str = str_new(mail->mail.data_pool, 128); imap_bodystructure_write(data->parts, str, FALSE); data->body = str_c(str); @@ -841,7 +841,7 @@ i_assert(!data->save_bodystructure_header); message_parser_parse_body(data->parser_ctx, parse_bodystructure_part_header, - mail->data_pool); + mail->mail.data_pool); data->save_bodystructure_body = FALSE; data->parsed_bodystructure = TRUE; } else { @@ -1000,14 +1000,14 @@ switch (field) { case MAIL_CACHE_IMAP_BODY: if (data->body == NULL) { - str = str_new(mail->data_pool, 128); + str = str_new(mail->mail.data_pool, 128); imap_bodystructure_write(data->parts, str, FALSE); data->body = str_c(str); } break; case MAIL_CACHE_IMAP_BODYSTRUCTURE: if (data->bodystructure == NULL) { - str = str_new(mail->data_pool, 128); + str = str_new(mail->mail.data_pool, 128); imap_bodystructure_write(data->parts, str, TRUE); data->bodystructure = str_c(str); } @@ -1055,7 +1055,7 @@ 4) parse body structure, and save BODY/BODYSTRUCTURE depending on what we want cached */ - str = str_new(mail->data_pool, 128); + str = str_new(mail->mail.data_pool, 128); if ((mail->data.cache_flags & MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) != 0 && get_cached_parts(mail)) { @@ -1067,7 +1067,7 @@ From dovecot at dovecot.org Sat Sep 15 16:13:09 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 16:13:09 +0300 Subject: dovecot-2.2: imap_body_parse_from_bodystructure() now returns th... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6acd8b149709 changeset: 15056:6acd8b149709 user: Timo Sirainen date: Sat Sep 15 16:13:02 2012 +0300 description: imap_body_parse_from_bodystructure() now returns the error instead of logging it. diffstat: src/lib-imap/imap-bodystructure.c | 119 ++++++++++++++++++++++-------------- src/lib-imap/imap-bodystructure.h | 7 +- src/lib-storage/index/index-mail.c | 10 ++- 3 files changed, 82 insertions(+), 54 deletions(-) diffs (271 lines): diff -r c436a6c3f7d2 -r 6acd8b149709 src/lib-imap/imap-bodystructure.c --- a/src/lib-imap/imap-bodystructure.c Sat Sep 15 15:46:01 2012 +0300 +++ b/src/lib-imap/imap-bodystructure.c Sat Sep 15 16:13:02 2012 +0300 @@ -533,7 +533,7 @@ } } -static bool str_append_imap_arg(string_t *str, const struct imap_arg *arg) +static bool str_append_nstring(string_t *str, const struct imap_arg *arg) { const char *cstr; @@ -566,19 +566,20 @@ return TRUE; } -static bool imap_write_list(const struct imap_arg *args, string_t *str) +static void imap_write_list(const struct imap_arg *args, string_t *str) { const struct imap_arg *children; /* don't do any typechecking, just write it out */ str_append_c(str, '('); while (!IMAP_ARG_IS_EOL(args)) { - if (!str_append_imap_arg(str, args)) { - if (!imap_arg_get_list(args, &children)) - return FALSE; + if (!str_append_nstring(str, args)) { + if (!imap_arg_get_list(args, &children)) { + /* everything is either nstring or list */ + i_unreached(); + } - if (!imap_write_list(children, str)) - return FALSE; + imap_write_list(children, str); } args++; @@ -586,11 +587,10 @@ str_append_c(str, ' '); } str_append_c(str, ')'); - return TRUE; } -static bool imap_parse_bodystructure_args(const struct imap_arg *args, - string_t *str) +static int imap_parse_bodystructure_args(const struct imap_arg *args, + string_t *str, const char **error_r) { const struct imap_arg *subargs; const struct imap_arg *list_args; @@ -602,8 +602,8 @@ while (args->type == IMAP_ARG_LIST) { str_append_c(str, '('); list_args = imap_arg_as_list(args); - if (!imap_parse_bodystructure_args(list_args, str)) - return FALSE; + if (imap_parse_bodystructure_args(list_args, str, error_r) < 0) + return -1; str_append_c(str, ')'); multipart = TRUE; @@ -613,19 +613,25 @@ if (multipart) { /* next is subtype of Content-Type. rest is skipped. */ str_append_c(str, ' '); - return str_append_imap_arg(str, args); + if (!str_append_nstring(str, args)) { + *error_r = "Invalid multipart content-type"; + return -1; + } + return 0; } /* "content type" "subtype" */ if (!imap_arg_get_astring(&args[0], &content_type) || - !imap_arg_get_astring(&args[1], &subtype)) - return FALSE; + !imap_arg_get_astring(&args[1], &subtype)) { + *error_r = "Invalid content-type"; + return -1; + } - if (!str_append_imap_arg(str, &args[0])) - return FALSE; + if (!str_append_nstring(str, &args[0])) + i_unreached(); str_append_c(str, ' '); - if (!str_append_imap_arg(str, &args[1])) - return FALSE; + if (!str_append_nstring(str, &args[1])) + i_unreached(); text = strcasecmp(content_type, "text") == 0; message_rfc822 = strcasecmp(content_type, "message") == 0 && @@ -637,11 +643,15 @@ if (imap_arg_get_list(args, &subargs)) { str_append(str, " ("); while (!IMAP_ARG_IS_EOL(subargs)) { - if (!str_append_imap_arg(str, &subargs[0])) - return FALSE; + if (!str_append_nstring(str, &subargs[0])) { + *error_r = "Invalid content param key"; + return -1; + } str_append_c(str, ' '); - if (!str_append_imap_arg(str, &subargs[1])) - return FALSE; + if (!str_append_nstring(str, &subargs[1])) { + *error_r = "Invalid content param value"; + return -1; + } subargs += 2; if (IMAP_ARG_IS_EOL(subargs)) @@ -652,7 +662,8 @@ } else if (args->type == IMAP_ARG_NIL) { str_append(str, " NIL"); } else { - return FALSE; + *error_r = "list/NIL expected"; + return -1; } args++; @@ -660,14 +671,18 @@ for (i = 0; i < 4; i++, args++) { str_append_c(str, ' '); - if (!str_append_imap_arg(str, args)) - return FALSE; + if (!str_append_nstring(str, args)) { + *error_r = "nstring expected"; + return -1; + } } if (text) { /* text/xxx - text lines */ - if (!imap_arg_get_atom(args, &value)) - return FALSE; + if (!imap_arg_get_atom(args, &value)) { + *error_r = "Text lines expected"; + return -1; + } str_append_c(str, ' '); str_append(str, value); @@ -675,33 +690,37 @@ /* message/rfc822 - envelope + bodystructure + text lines */ str_append_c(str, ' '); - if (!imap_arg_get_list(&args[0], &list_args)) - return FALSE; - if (!imap_write_list(list_args, str)) - return FALSE; - + if (!imap_arg_get_list(&args[0], &list_args)) { + *error_r = "Envelope list expected"; + return -1; + } + imap_write_list(list_args, str); str_append(str, " ("); - if (!imap_arg_get_list(&args[1], &list_args)) - return FALSE; - if (!imap_parse_bodystructure_args(list_args, str)) - return FALSE; + if (!imap_arg_get_list(&args[1], &list_args)) { + *error_r = "Child bodystructure list expected"; + return -1; + } + if (imap_parse_bodystructure_args(list_args, str, error_r) < 0) + return -1; str_append(str, ") "); - if (!imap_arg_get_atom(&args[2], &value)) - return FALSE; + if (!imap_arg_get_atom(&args[2], &value)) { + *error_r = "Text lines expected"; + return -1; + } str_append(str, value); } - - return TRUE; + return 0; } -bool imap_body_parse_from_bodystructure(const char *bodystructure, - string_t *dest) +int imap_body_parse_from_bodystructure(const char *bodystructure, + string_t *dest, const char **error_r) { struct istream *input; struct imap_parser *parser; const struct imap_arg *args; + bool fatal; int ret; input = i_stream_create_from_data(bodystructure, strlen(bodystructure)); @@ -710,12 +729,16 @@ parser = imap_parser_create(input, NULL, (size_t)-1); ret = imap_parser_finish_line(parser, 0, IMAP_PARSE_FLAG_NO_UNESCAPE | IMAP_PARSE_FLAG_LITERAL_TYPE, &args); - ret = ret > 0 && imap_parse_bodystructure_args(args, dest); - - if (!ret) - i_error("Error parsing IMAP bodystructure: %s", bodystructure); + if (ret < 0) { + *error_r = t_strdup_printf("IMAP parser failed: %s", + imap_parser_get_error(parser, &fatal)); + } else if (ret == 0) { + *error_r = "Empty bodystructure"; + } else { + ret = imap_parse_bodystructure_args(args, dest, error_r); + } imap_parser_unref(&parser); i_stream_destroy(&input); - return ret; + return ret <= 0 ? -1 : 0; } diff -r c436a6c3f7d2 -r 6acd8b149709 src/lib-imap/imap-bodystructure.h --- a/src/lib-imap/imap-bodystructure.h Sat Sep 15 15:46:01 2012 +0300 +++ b/src/lib-imap/imap-bodystructure.h Sat Sep 15 16:13:02 2012 +0300 @@ -16,8 +16,9 @@ void imap_bodystructure_write(const struct message_part *part, string_t *dest, bool extended); -/* Return BODY part from BODYSTRUCTURE */ -bool imap_body_parse_from_bodystructure(const char *bodystructure, - string_t *dest); +/* Get BODY part from BODYSTRUCTURE and write it to dest. + Returns 0 if ok, -1 if bodystructure wasn't valid. */ +int imap_body_parse_from_bodystructure(const char *bodystructure, + string_t *dest, const char **error_r); #endif diff -r c436a6c3f7d2 -r 6acd8b149709 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Sat Sep 15 15:46:01 2012 +0300 +++ b/src/lib-storage/index/index-mail.c Sat Sep 15 16:13:02 2012 +0300 @@ -1035,6 +1035,7 @@ struct index_mail *mail = (struct index_mail *)_mail; struct index_mail_data *data = &mail->data; const struct mail_cache_field *cache_fields = mail->ibox->cache_fields; + const char *error; string_t *str; switch (field) { @@ -1071,12 +1072,15 @@ str_truncate(str, 0); if (imap_body_parse_from_bodystructure( - data->bodystructure, str)) - data->body = str_c(str); - else { + data->bodystructure, str, &error) < 0) { /* broken, continue.. */ + mail_storage_set_critical(_mail->box->storage, + "Invalid BODYSTRUCTURE %s: %s", + data->bodystructure, error); mail_set_cache_corrupted(_mail, MAIL_FETCH_IMAP_BODYSTRUCTURE); + } else { + data->body = str_c(str); } } From dovecot at dovecot.org Sat Sep 15 19:00:53 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:00:53 +0300 Subject: dovecot-2.2: lib-imap: Added support for parsing IMAP BODYSTRUCT... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d1f084a39708 changeset: 15057:d1f084a39708 user: Timo Sirainen date: Sat Sep 15 18:58:48 2012 +0300 description: lib-imap: Added support for parsing IMAP BODYSTRUCTURE and writing out a modified version. diffstat: src/lib-imap/Makefile.am | 5 + src/lib-imap/imap-bodystructure.c | 483 +++++++++++++++++++++++++------- src/lib-imap/imap-bodystructure.h | 28 + src/lib-imap/test-imap-bodystructure.c | 143 +++++++++ 4 files changed, 551 insertions(+), 108 deletions(-) diffs (truncated from 807 to 300 lines): diff -r 6acd8b149709 -r d1f084a39708 src/lib-imap/Makefile.am --- a/src/lib-imap/Makefile.am Sat Sep 15 16:13:02 2012 +0300 +++ b/src/lib-imap/Makefile.am Sat Sep 15 18:58:48 2012 +0300 @@ -41,6 +41,7 @@ pkginc_lib_HEADERS = $(headers) test_programs = \ + test-imap-bodystructure \ test-imap-match \ test-imap-parser \ test-imap-url \ @@ -53,6 +54,10 @@ ../lib-test/libtest.la \ ../lib/liblib.la +test_imap_bodystructure_SOURCES = test-imap-bodystructure.c +test_imap_bodystructure_LDADD = imap-bodystructure.lo imap-envelope.lo imap-quote.lo imap-parser.lo imap-arg.lo ../lib-mail/libmail.la $(test_libs) +test_imap_bodystructure_DEPENDENCIES = imap-bodystructure.lo imap-envelope.lo imap-quote.lo imap-parser.lo imap-arg.lo ../lib-mail/libmail.la $(test_libs) + test_imap_match_SOURCES = test-imap-match.c test_imap_match_LDADD = imap-match.lo $(test_libs) test_imap_match_DEPENDENCIES = imap-match.lo $(test_libs) diff -r 6acd8b149709 -r d1f084a39708 src/lib-imap/imap-bodystructure.c --- a/src/lib-imap/imap-bodystructure.c Sat Sep 15 16:13:02 2012 +0300 +++ b/src/lib-imap/imap-bodystructure.c Sat Sep 15 18:58:48 2012 +0300 @@ -18,21 +18,7 @@ #define EMPTY_BODYSTRUCTURE \ "(\"text\" \"plain\" ("DEFAULT_CHARSET") NIL NIL \"7bit\" 0 0)" -struct message_part_body_data { - pool_t pool; - const char *content_type, *content_subtype; - const char *content_type_params; - const char *content_transfer_encoding; - const char *content_id; - const char *content_description; - const char *content_disposition; - const char *content_disposition_params; - const char *content_md5; - const char *content_language; - const char *content_location; - - struct message_part_envelope_data *envelope; -}; +#define NVL(str, nullstr) ((str) != NULL ? (str) : (nullstr)) static void parse_content_type(struct message_part_body_data *data, struct message_header_line *hdr) @@ -290,39 +276,21 @@ } } -static void part_write_body_multipart(const struct message_part *part, - string_t *str, bool extended) +static void +imap_bodystructure_write_siblings(const struct message_part *part, + string_t *dest, bool extended) { - struct message_part_body_data *data = part->context; + for (; part != NULL; part = part->next) { + str_append_c(dest, '('); + imap_bodystructure_write(part, dest, extended); + str_append_c(dest, ')'); + } +} - if (part->children != NULL) - imap_bodystructure_write(part->children, str, extended); - else { - /* no parts in multipart message, - that's not allowed. write a single - 0-length text/plain structure */ - str_append(str, EMPTY_BODYSTRUCTURE); - } - - str_append_c(str, ' '); - if (data->content_subtype != NULL) - str_append(str, data->content_subtype); - else - str_append(str, "\"x-unknown\""); - - if (!extended) - return; - - /* BODYSTRUCTURE data */ - str_append_c(str, ' '); - if (data->content_type_params == NULL) - str_append(str, "NIL"); - else { - str_append_c(str, '('); - str_append(str, data->content_type_params); - str_append_c(str, ')'); - } - +static void +part_write_bodystructure_data_common(struct message_part_body_data *data, + string_t *str) +{ str_append_c(str, ' '); if (data->content_disposition == NULL) str_append(str, "NIL"); @@ -351,16 +319,48 @@ } str_append_c(str, ' '); - if (data->content_location == NULL) + str_append(str, NVL(data->content_location, "NIL")); +} + +static void part_write_body_multipart(const struct message_part *part, + string_t *str, bool extended) +{ + struct message_part_body_data *data = part->context; + + if (part->children != NULL) + imap_bodystructure_write_siblings(part->children, str, extended); + else { + /* no parts in multipart message, + that's not allowed. write a single + 0-length text/plain structure */ + str_append(str, EMPTY_BODYSTRUCTURE); + } + + str_append_c(str, ' '); + if (data->content_subtype != NULL) + str_append(str, data->content_subtype); + else + str_append(str, "\"x-unknown\""); + + if (!extended) + return; + + /* BODYSTRUCTURE data */ + str_append_c(str, ' '); + if (data->content_type_params == NULL) str_append(str, "NIL"); - else - str_append(str, data->content_location); + else { + str_append_c(str, '('); + str_append(str, data->content_type_params); + str_append_c(str, ')'); + } + + part_write_bodystructure_data_common(data, str); } static void part_write_body(const struct message_part *part, string_t *str, bool extended) { -#define NVL(str, nullstr) ((str) != NULL ? (str) : (nullstr)) struct message_part_body_data *data = part->context; bool text; @@ -410,19 +410,20 @@ } else if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) { /* message/rfc822 contains envelope + body + line count */ struct message_part_body_data *child_data; - struct message_part_envelope_data *env_data; i_assert(part->children != NULL); i_assert(part->children->next == NULL); child_data = part->children->context; - env_data = child_data->envelope; str_append(str, " ("); - imap_envelope_write_part_data(env_data, str); + if (child_data->envelope_str != NULL) + str_append(str, child_data->envelope_str); + else + imap_envelope_write_part_data(child_data->envelope, str); str_append(str, ") "); - imap_bodystructure_write(part->children, str, extended); + imap_bodystructure_write_siblings(part->children, str, extended); str_printfa(str, " %u", part->body_size.lines); } @@ -435,40 +436,7 @@ ("body" "language" "params") "location" */ str_append_c(str, ' '); str_append(str, NVL(data->content_md5, "NIL")); - - str_append_c(str, ' '); - if (data->content_disposition == NULL) - str_append(str, "NIL"); - else { - str_append_c(str, '('); - str_append(str, data->content_disposition); - str_append_c(str, ' '); - - if (data->content_disposition_params == NULL) - str_append(str, "NIL"); - else { - str_append_c(str, '('); - str_append(str, data->content_disposition_params); - str_append_c(str, ')'); - } - - str_append_c(str, ')'); - } - - str_append_c(str, ' '); - if (data->content_language == NULL) - str_append(str, "NIL"); - else { - str_append_c(str, '('); - str_append(str, data->content_language); - str_append_c(str, ')'); - } - - str_append_c(str, ' '); - if (data->content_location == NULL) - str_append(str, "NIL"); - else - str_append(str, data->content_location); + part_write_bodystructure_data_common(data, str); } bool imap_bodystructure_is_plain_7bit(const struct message_part *part) @@ -515,22 +483,10 @@ void imap_bodystructure_write(const struct message_part *part, string_t *dest, bool extended) { - i_assert(part->parent != NULL || part->next == NULL); - - while (part != NULL) { - if (part->parent != NULL) - str_append_c(dest, '('); - - if (part->flags & MESSAGE_PART_FLAG_MULTIPART) - part_write_body_multipart(part, dest, extended); - else - part_write_body(part, dest, extended); - - if (part->parent != NULL) - str_append_c(dest, ')'); - - part = part->next; - } + if (part->flags & MESSAGE_PART_FLAG_MULTIPART) + part_write_body_multipart(part, dest, extended); + else + part_write_body(part, dest, extended); } static bool str_append_nstring(string_t *str, const struct imap_arg *arg) @@ -566,12 +522,27 @@ return TRUE; } +static bool +get_nstring(const struct imap_arg *arg, pool_t pool, string_t *tmpstr, + const char **value_r) +{ + if (arg->type == IMAP_ARG_NIL) { + *value_r = NULL; + return TRUE; + } + + str_truncate(tmpstr, 0); + if (!str_append_nstring(tmpstr, arg)) + return FALSE; + *value_r = p_strdup(pool, str_c(tmpstr)); + return TRUE; +} + static void imap_write_list(const struct imap_arg *args, string_t *str) { const struct imap_arg *children; /* don't do any typechecking, just write it out */ - str_append_c(str, '('); while (!IMAP_ARG_IS_EOL(args)) { if (!str_append_nstring(str, args)) { if (!imap_arg_get_list(args, &children)) { @@ -579,14 +550,308 @@ i_unreached(); } + str_append_c(str, '('); imap_write_list(children, str); + str_append_c(str, ')'); } args++; if (!IMAP_ARG_IS_EOL(args)) str_append_c(str, ' '); } - str_append_c(str, ')'); +} + +static int imap_write_nstring_list(const struct imap_arg *args, string_t *str) +{ + str_truncate(str, 0); + while (!IMAP_ARG_IS_EOL(args)) { + if (!str_append_nstring(str, &args[0])) + return -1; + str_append_c(str, ' '); From dovecot at dovecot.org Sat Sep 15 19:00:53 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:00:53 +0300 Subject: dovecot-2.2: lib-imap-storage: Added support for getting BODYPAR... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a69c48fa4f32 changeset: 15058:a69c48fa4f32 user: Timo Sirainen date: Sat Sep 15 19:00:32 2012 +0300 description: lib-imap-storage: Added support for getting BODYPARTSTRUCTURE Based on patch by Stephan Bosch. diffstat: src/lib-imap-storage/imap-msgpart-url.c | 23 +++++++- src/lib-imap-storage/imap-msgpart-url.h | 5 + src/lib-imap-storage/imap-msgpart.c | 95 +++++++++++++++++++++++++++++++++ src/lib-imap-storage/imap-msgpart.h | 5 + 4 files changed, 127 insertions(+), 1 deletions(-) diffs (189 lines): diff -r d1f084a39708 -r a69c48fa4f32 src/lib-imap-storage/imap-msgpart-url.c --- a/src/lib-imap-storage/imap-msgpart-url.c Sat Sep 15 18:58:48 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart-url.c Sat Sep 15 19:00:32 2012 +0300 @@ -180,7 +180,8 @@ /* start transaction */ t = mailbox_transaction_begin(box, 0); - mail = mail_alloc(t, 0, NULL); + mail = mail_alloc(t, MAIL_FETCH_MESSAGE_PARTS | + MAIL_FETCH_IMAP_BODYSTRUCTURE, NULL); /* find the message */ if (!mail_set_uid(mail, mpurl->uid)) { @@ -250,6 +251,26 @@ return ret; } +int imap_msgpart_url_get_bodypartstructure(struct imap_msgpart_url *mpurl, + const char **bpstruct_r, + const char **error_r) +{ + struct mail *mail; + int ret; + + /* open mail if it is not yet open */ + ret = imap_msgpart_url_open_mail(mpurl, &mail, error_r); + if (ret <= 0) + return ret; + + ret = imap_msgpart_bodypartstructure(mail, mpurl->part, bpstruct_r); + if (ret < 0) + *error_r = mailbox_get_last_error(mpurl->box, NULL); + else if (ret == 0) + *error_r = "Message part not found"; + return ret; +} + void imap_msgpart_url_free(struct imap_msgpart_url **_mpurl) { struct imap_msgpart_url *mpurl = *_mpurl; diff -r d1f084a39708 -r a69c48fa4f32 src/lib-imap-storage/imap-msgpart-url.h --- a/src/lib-imap-storage/imap-msgpart-url.h Sat Sep 15 18:58:48 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart-url.h Sat Sep 15 19:00:32 2012 +0300 @@ -37,6 +37,11 @@ int imap_msgpart_url_read_part(struct imap_msgpart_url *mpurl, struct imap_msgpart_open_result *result_r, const char **error_r); + +int imap_msgpart_url_get_bodypartstructure(struct imap_msgpart_url *mpurl, + const char **bpstruct_r, + const char **error_r); + int imap_msgpart_url_verify(struct imap_msgpart_url *mpurl, const char **error_r); void imap_msgpart_url_free(struct imap_msgpart_url **mpurl); diff -r d1f084a39708 -r a69c48fa4f32 src/lib-imap-storage/imap-msgpart.c --- a/src/lib-imap-storage/imap-msgpart.c Sat Sep 15 18:58:48 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart.c Sat Sep 15 19:00:32 2012 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "str.h" #include "array.h" #include "istream.h" #include "istream-crlf.h" @@ -13,6 +14,7 @@ #include "message-decoder.h" #include "mail-storage-private.h" #include "mail-namespace.h" +#include "imap-bodystructure.h" #include "imap-parser.h" #include "imap-msgpart.h" @@ -734,6 +736,99 @@ return mail_get_binary_size(mail, part, include_hdr, size_r); } +static int +imap_msgpart_parse_bodystructure(struct mail *mail, + struct message_part *all_parts) +{ + struct mail_private *pmail = (struct mail_private *)mail; + const char *bodystructure, *error; + + if (mail_get_special(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE, + &bodystructure) < 0) + return -1; + if (all_parts->context != NULL) { + /* we just parsed the bodystructure */ + return 0; + } + + if (imap_bodystructure_parse(bodystructure, pmail->data_pool, + all_parts, &error) < 0) { + mail_storage_set_critical(mail->box->storage, + "Invalid message_part/BODYSTRUCTURE %s: %s", + bodystructure, error); + mail_set_cache_corrupted(mail, MAIL_FETCH_MESSAGE_PARTS); + mail_set_cache_corrupted(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE); + return -1; + } + return 0; +} + +static int +imap_msgpart_vsizes_to_binary(struct mail *mail, const struct message_part *part, + struct message_part **binpart_r) +{ + struct message_part **pos; + uoff_t size; + + if (mail_get_binary_size(mail, part, FALSE, &size) < 0) + return -1; + + *binpart_r = t_new(struct message_part, 1); + **binpart_r = *part; + (*binpart_r)->body_size.virtual_size = size; + + pos = &(*binpart_r)->children; + for (part = part->children; part != NULL; part = part->next) { + if (imap_msgpart_vsizes_to_binary(mail, part, pos) < 0) + return -1; + pos = &(*pos)->next; + } + return 0; +} + +int imap_msgpart_bodypartstructure(struct mail *mail, + struct imap_msgpart *msgpart, + const char **bpstruct_r) +{ + struct message_part *all_parts, *part; + string_t *bpstruct; + int ret; + + /* if we start parsing the body in here, make sure we also parse the + BODYSTRUCTURE */ + mail_add_temp_wanted_fields(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE, NULL); + + if ((ret = imap_msgpart_find_part(mail, msgpart, &part)) < 0) + return -1; + if (ret == 0) { + /* MIME part not found. */ + *bpstruct_r = NULL; + return 0; + } + + if (mail_get_parts(mail, &all_parts) < 0) + return -1; + if (all_parts->context == NULL) { + if (imap_msgpart_parse_bodystructure(mail, all_parts) < 0) + return -1; + } + if (part == NULL) + part = all_parts; + + T_BEGIN { + if (msgpart->decode_cte_to_binary) + ret = imap_msgpart_vsizes_to_binary(mail, part, &part); + + if (ret >= 0) { + bpstruct = t_str_new(256); + imap_bodystructure_write(part, bpstruct, TRUE); + *bpstruct_r = str_c(bpstruct); + } + } T_END; + return ret < 0 ? -1 : 1; +} + + void imap_msgpart_close_mailbox(struct imap_msgpart *msgpart) { if (msgpart->header_ctx != NULL) diff -r d1f084a39708 -r a69c48fa4f32 src/lib-imap-storage/imap-msgpart.h --- a/src/lib-imap-storage/imap-msgpart.h Sat Sep 15 18:58:48 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart.h Sat Sep 15 19:00:32 2012 +0300 @@ -45,6 +45,11 @@ int imap_msgpart_size(struct mail *mail, struct imap_msgpart *msgpart, size_t *size_r); +/* Return msgpart's IMAP BODYPARTSTRUCTURE */ +int imap_msgpart_bodypartstructure(struct mail *mail, + struct imap_msgpart *msgpart, + const char **bpstruct_r); + /* Header context is automatically created by imap_msgpart_open() and destroyed by imap_msgpart_free(), but if you want to use the same imap_msgpart across multiple mailboxes, you need to close the part before closing the mailbox. */ From dovecot at dovecot.org Sat Sep 15 19:06:50 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:06:50 +0300 Subject: dovecot-2.2: lib-imap: Updated test-imap-bodystructure Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ef1519ebfb4f changeset: 15059:ef1519ebfb4f user: Timo Sirainen date: Sat Sep 15 19:06:37 2012 +0300 description: lib-imap: Updated test-imap-bodystructure diffstat: src/lib-imap/test-imap-bodystructure.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r a69c48fa4f32 -r ef1519ebfb4f src/lib-imap/test-imap-bodystructure.c --- a/src/lib-imap/test-imap-bodystructure.c Sat Sep 15 19:00:32 2012 +0300 +++ b/src/lib-imap/test-imap-bodystructure.c Sat Sep 15 19:06:37 2012 +0300 @@ -20,7 +20,7 @@ "Content-Type: text/x-myown; charset=us-ascii; foo=\"quoted\\\"string\"\n" "Content-ID: \n" "Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==\n" -"Content-Disposition: inline\n" +"Content-Disposition: inline; foo=bar\n" "Content-Description: hellodescription\n" "Content-Language: en, fi\n" "Content-Location: http://example.com/test.txt\n" @@ -55,7 +55,7 @@ static const char testmsg_bodystructure[] = "(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" {13}\r\n" -"quoted\"string) \"\" \"hellodescription\" \"7bit\" 7 1 \"Q2hlY2sgSW50ZWdyaXR5IQ==\" (\"inline\" NIL) (\"en\" \"fi\") \"http://example.com/test.txt\")(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 331 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) NIL NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1 NIL NIL NIL NIL)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"sub1\") NIL NIL NIL) 19 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL"; +"quoted\"string) \"\" \"hellodescription\" \"7bit\" 7 1 \"Q2hlY2sgSW50ZWdyaXR5IQ==\" (\"inline\" (\"foo\" \"bar\")) (\"en\" \"fi\") \"http://example.com/test.txt\")(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 331 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) NIL NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1 NIL NIL NIL NIL)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"sub1\") NIL NIL NIL) 19 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL"; static const char testmsg_body[] = "(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" {13}\r\n" From dovecot at dovecot.org Sat Sep 15 19:08:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:08:18 +0300 Subject: dovecot-2.2: imap-bodystructure.h comment update Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ccf6399055e7 changeset: 15060:ccf6399055e7 user: Timo Sirainen date: Sat Sep 15 19:08:11 2012 +0300 description: imap-bodystructure.h comment update diffstat: src/lib-imap/imap-bodystructure.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (15 lines): diff -r ef1519ebfb4f -r ccf6399055e7 src/lib-imap/imap-bodystructure.h --- a/src/lib-imap/imap-bodystructure.h Sat Sep 15 19:06:37 2012 +0300 +++ b/src/lib-imap/imap-bodystructure.h Sat Sep 15 19:08:11 2012 +0300 @@ -11,9 +11,9 @@ const char *content_id; const char *content_description; const char *content_disposition; - const char *content_disposition_params; + const char *content_disposition_params; /* "key" "value" "key2" "value2" .. */ const char *content_md5; - const char *content_language; + const char *content_language; /* "key" "value" "key2" "value2" .. */ const char *content_location; /* either one of these is set, but not both: */ From dovecot at dovecot.org Sat Sep 15 19:09:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:09:03 +0300 Subject: dovecot-2.2: imap-bodystructure.h comment fix Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/108b28e864c4 changeset: 15061:108b28e864c4 user: Timo Sirainen date: Sat Sep 15 19:08:55 2012 +0300 description: imap-bodystructure.h comment fix diffstat: src/lib-imap/imap-bodystructure.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r ccf6399055e7 -r 108b28e864c4 src/lib-imap/imap-bodystructure.h --- a/src/lib-imap/imap-bodystructure.h Sat Sep 15 19:08:11 2012 +0300 +++ b/src/lib-imap/imap-bodystructure.h Sat Sep 15 19:08:55 2012 +0300 @@ -13,7 +13,7 @@ const char *content_disposition; const char *content_disposition_params; /* "key" "value" "key2" "value2" .. */ const char *content_md5; - const char *content_language; /* "key" "value" "key2" "value2" .. */ + const char *content_language; /* "lang1" "lang2" "lang3" .. */ const char *content_location; /* either one of these is set, but not both: */ From dovecot at dovecot.org Sat Sep 15 19:12:20 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:12:20 +0300 Subject: dovecot-2.2: lib-imap: Fixed Content-Language parsing from BODYS... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9935621836c8 changeset: 15062:9935621836c8 user: Timo Sirainen date: Sat Sep 15 19:12:04 2012 +0300 description: lib-imap: Fixed Content-Language parsing from BODYSTRUCTURE diffstat: src/lib-imap/imap-bodystructure.c | 22 +++++++++++----------- src/lib-imap/test-imap-bodystructure.c | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diffs (94 lines): diff -r 108b28e864c4 -r 9935621836c8 src/lib-imap/imap-bodystructure.c --- a/src/lib-imap/imap-bodystructure.c Sat Sep 15 19:08:55 2012 +0300 +++ b/src/lib-imap/imap-bodystructure.c Sat Sep 15 19:12:04 2012 +0300 @@ -567,11 +567,7 @@ while (!IMAP_ARG_IS_EOL(args)) { if (!str_append_nstring(str, &args[0])) return -1; - str_append_c(str, ' '); - if (!str_append_nstring(str, &args[1])) - return -1; - - args += 2; + args++; if (IMAP_ARG_IS_EOL(args)) break; str_append_c(str, ' '); @@ -580,15 +576,19 @@ } static int imap_write_params(const struct imap_arg *arg, pool_t pool, - string_t *tmpstr, const char **value_r) + string_t *tmpstr, unsigned int divisible, + const char **value_r) { const struct imap_arg *list_args; + unsigned int list_count; if (arg->type == IMAP_ARG_NIL) { *value_r = NULL; return 0; } - if (!imap_arg_get_list(arg, &list_args)) + if (!imap_arg_get_list_full(arg, &list_args, &list_count)) + return -1; + if ((list_count % divisible) != 0) return -1; if (imap_write_nstring_list(list_args, tmpstr) < 0) @@ -636,14 +636,14 @@ *error_r = "Invalid content-disposition"; return -1; } - if (imap_write_params(list_args, pool, tmpstr, + if (imap_write_params(list_args, pool, tmpstr, 2, &data->content_disposition_params) < 0) { *error_r = "Invalid content-disposition params"; return -1; } args++; } - if (imap_write_params(args++, pool, tmpstr, + if (imap_write_params(args++, pool, tmpstr, 1, &data->content_language) < 0) { *error_r = "Invalid content-language"; return -1; @@ -703,7 +703,7 @@ *error_r = "Invalid multipart content-type"; return -1; } - if (imap_write_params(args++, pool, tmpstr, + if (imap_write_params(args++, pool, tmpstr, 2, &data->content_type_params) < 0) { *error_r = "Invalid content params"; return -1; @@ -741,7 +741,7 @@ } /* ("content type param key" "value" ...) | NIL */ - if (imap_write_params(args++, pool, tmpstr, + if (imap_write_params(args++, pool, tmpstr, 2, &data->content_type_params) < 0) { *error_r = "Invalid content params"; return -1; diff -r 108b28e864c4 -r 9935621836c8 src/lib-imap/test-imap-bodystructure.c --- a/src/lib-imap/test-imap-bodystructure.c Sat Sep 15 19:08:55 2012 +0300 +++ b/src/lib-imap/test-imap-bodystructure.c Sat Sep 15 19:12:04 2012 +0300 @@ -22,7 +22,7 @@ "Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==\n" "Content-Disposition: inline; foo=bar\n" "Content-Description: hellodescription\n" -"Content-Language: en, fi\n" +"Content-Language: en, fi, se\n" "Content-Location: http://example.com/test.txt\n" "\n" "hello\n" @@ -55,7 +55,7 @@ static const char testmsg_bodystructure[] = "(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" {13}\r\n" -"quoted\"string) \"\" \"hellodescription\" \"7bit\" 7 1 \"Q2hlY2sgSW50ZWdyaXR5IQ==\" (\"inline\" (\"foo\" \"bar\")) (\"en\" \"fi\") \"http://example.com/test.txt\")(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 331 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) NIL NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1 NIL NIL NIL NIL)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"sub1\") NIL NIL NIL) 19 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL"; +"quoted\"string) \"\" \"hellodescription\" \"7bit\" 7 1 \"Q2hlY2sgSW50ZWdyaXR5IQ==\" (\"inline\" (\"foo\" \"bar\")) (\"en\" \"fi\" \"se\") \"http://example.com/test.txt\")(\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 331 (\"Sun, 12 Aug 2012 12:34:56 +0300\" \"submsg\" ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) ((NIL NIL \"sub\" \"domain.org\")) NIL NIL NIL NIL NIL) ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL \"8bit\" 20 1 NIL NIL NIL NIL)(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 21 1 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"sub1\") NIL NIL NIL) 19 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"foo bar\") NIL NIL NIL"; static const char testmsg_body[] = "(\"text\" \"x-myown\" (\"charset\" \"us-ascii\" \"foo\" {13}\r\n" From dovecot at dovecot.org Sat Sep 15 19:56:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:56:59 +0300 Subject: dovecot-2.2: lib-index: Changed mail_index_set_fsync_mode() to u... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0efc12f3eb2a changeset: 15063:0efc12f3eb2a user: Timo Sirainen date: Sat Sep 15 19:54:21 2012 +0300 description: lib-index: Changed mail_index_set_fsync_mode() to use a separate enum for the mask. diffstat: src/lib-index/mail-index-private.h | 2 +- src/lib-index/mail-index-transaction-export.c | 16 ++++++++-------- src/lib-index/mail-index.c | 2 +- src/lib-index/mail-index.h | 9 ++++++++- src/lib-storage/index/cydir/cydir-storage.c | 4 ++-- src/lib-storage/index/dbox-common/dbox-storage.c | 4 ++-- 6 files changed, 22 insertions(+), 15 deletions(-) diffs (148 lines): diff -r 9935621836c8 -r 0efc12f3eb2a src/lib-index/mail-index-private.h --- a/src/lib-index/mail-index-private.h Sat Sep 15 19:12:04 2012 +0300 +++ b/src/lib-index/mail-index-private.h Sat Sep 15 19:54:21 2012 +0300 @@ -169,7 +169,7 @@ unsigned int open_count; enum mail_index_open_flags flags; enum fsync_mode fsync_mode; - enum mail_index_sync_type fsync_mask; + enum mail_index_fsync_mask fsync_mask; mode_t mode; gid_t gid; char *gid_origin; diff -r 9935621836c8 -r 0efc12f3eb2a src/lib-index/mail-index-transaction-export.c --- a/src/lib-index/mail-index-transaction-export.c Sat Sep 15 19:12:04 2012 +0300 +++ b/src/lib-index/mail-index-transaction-export.c Sat Sep 15 19:54:21 2012 +0300 @@ -333,13 +333,13 @@ log_append_buffer(ctx, tmp_buf, MAIL_TRANSACTION_KEYWORD_UPDATE); } -static enum mail_index_sync_type +static enum mail_index_fsync_mask log_append_keyword_updates(struct mail_index_export_context *ctx) { const struct mail_index_transaction_keyword_update *updates; const char *const *keywords; buffer_t *tmp_buf; - enum mail_index_sync_type change_mask = 0; + enum mail_index_fsync_mask change_mask = 0; unsigned int i, count, keywords_count; tmp_buf = buffer_create_dynamic(pool_datastack_create(), 64); @@ -352,14 +352,14 @@ for (i = 0; i < count; i++) { if (array_is_created(&updates[i].add_seq) && array_count(&updates[i].add_seq) > 0) { - change_mask |= MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD; + change_mask |= MAIL_INDEX_FSYNC_MASK_KEYWORDS; log_append_keyword_update(ctx, tmp_buf, MODIFY_ADD, keywords[i], updates[i].add_seq.arr.buffer); } if (array_is_created(&updates[i].remove_seq) && array_count(&updates[i].remove_seq) > 0) { - change_mask |= MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE; + change_mask |= MAIL_INDEX_FSYNC_MASK_KEYWORDS; log_append_keyword_update(ctx, tmp_buf, MODIFY_REMOVE, keywords[i], updates[i].remove_seq.arr.buffer); @@ -372,7 +372,7 @@ struct mail_transaction_log_append_ctx *append_ctx) { static uint8_t null4[4] = { 0, 0, 0, 0 }; - enum mail_index_sync_type change_mask = 0; + enum mail_index_fsync_mask change_mask = 0; struct mail_index_export_context ctx; memset(&ctx, 0, sizeof(ctx)); @@ -394,13 +394,13 @@ MAIL_TRANSACTION_HEADER_UPDATE); } if (array_is_created(&t->appends)) { - change_mask |= MAIL_INDEX_SYNC_TYPE_APPEND; + change_mask |= MAIL_INDEX_FSYNC_MASK_APPENDS; log_append_buffer(&ctx, t->appends.arr.buffer, MAIL_TRANSACTION_APPEND); } if (array_is_created(&t->updates)) { - change_mask |= MAIL_INDEX_SYNC_TYPE_FLAGS; + change_mask |= MAIL_INDEX_FSYNC_MASK_FLAGS; log_append_flag_updates(&ctx, t); } @@ -425,7 +425,7 @@ /* non-external expunges are only requests, ignore them when checking fsync_mask */ if ((t->flags & MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL) != 0) - change_mask |= MAIL_INDEX_SYNC_TYPE_EXPUNGE; + change_mask |= MAIL_INDEX_FSYNC_MASK_EXPUNGES; log_append_buffer(&ctx, t->expunges.arr.buffer, MAIL_TRANSACTION_EXPUNGE_GUID); } diff -r 9935621836c8 -r 0efc12f3eb2a src/lib-index/mail-index.c --- a/src/lib-index/mail-index.c Sat Sep 15 19:12:04 2012 +0300 +++ b/src/lib-index/mail-index.c Sat Sep 15 19:54:21 2012 +0300 @@ -86,7 +86,7 @@ void mail_index_set_fsync_mode(struct mail_index *index, enum fsync_mode mode, - enum mail_index_sync_type mask) + enum mail_index_fsync_mask mask) { index->fsync_mode = mode; index->fsync_mask = mask; diff -r 9935621836c8 -r 0efc12f3eb2a src/lib-index/mail-index.h --- a/src/lib-index/mail-index.h Sat Sep 15 19:12:04 2012 +0300 +++ b/src/lib-index/mail-index.h Sat Sep 15 19:54:21 2012 +0300 @@ -136,6 +136,13 @@ MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE = 0x10 }; +enum mail_index_fsync_mask { + MAIL_INDEX_FSYNC_MASK_APPENDS = 0x01, + MAIL_INDEX_FSYNC_MASK_EXPUNGES = 0x02, + MAIL_INDEX_FSYNC_MASK_FLAGS = 0x04, + MAIL_INDEX_FSYNC_MASK_KEYWORDS = 0x08 +}; + enum mail_index_sync_flags { /* Resync all dirty messages' flags. */ MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY = 0x01, @@ -214,7 +221,7 @@ /* Specify how often to do fsyncs. If mode is FSYNC_MODE_OPTIMIZED, the mask can be used to specify which transaction types to fsync. */ void mail_index_set_fsync_mode(struct mail_index *index, enum fsync_mode mode, - enum mail_index_sync_type mask); + enum mail_index_fsync_mask mask); void mail_index_set_permissions(struct mail_index *index, mode_t mode, gid_t gid, const char *gid_origin); /* Set locking method and maximum time to wait for a lock (-1U = default). */ diff -r 9935621836c8 -r 0efc12f3eb2a src/lib-storage/index/cydir/cydir-storage.c --- a/src/lib-storage/index/cydir/cydir-storage.c Sat Sep 15 19:12:04 2012 +0300 +++ b/src/lib-storage/index/cydir/cydir-storage.c Sat Sep 15 19:54:21 2012 +0300 @@ -83,8 +83,8 @@ return -1; mail_index_set_fsync_mode(box->index, box->storage->set->parsed_fsync_mode, - MAIL_INDEX_SYNC_TYPE_APPEND | - MAIL_INDEX_SYNC_TYPE_EXPUNGE); + MAIL_INDEX_FSYNC_MASK_APPENDS | + MAIL_INDEX_FSYNC_MASK_EXPUNGES); return 0; } diff -r 9935621836c8 -r 0efc12f3eb2a src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Sat Sep 15 19:12:04 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Sat Sep 15 19:54:21 2012 +0300 @@ -190,8 +190,8 @@ return -1; mail_index_set_fsync_mode(box->index, box->storage->set->parsed_fsync_mode, - MAIL_INDEX_SYNC_TYPE_APPEND | - MAIL_INDEX_SYNC_TYPE_EXPUNGE); + MAIL_INDEX_FSYNC_MASK_APPENDS | + MAIL_INDEX_FSYNC_MASK_EXPUNGES); return 0; } From dovecot at dovecot.org Sat Sep 15 19:56:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 19:56:59 +0300 Subject: dovecot-2.2: lib-index: Removed MAIL_INDEX_SYNC_TYPE_APPEND. No ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5f483950b733 changeset: 15064:5f483950b733 user: Timo Sirainen date: Sat Sep 15 19:56:47 2012 +0300 description: lib-index: Removed MAIL_INDEX_SYNC_TYPE_APPEND. No backend cares about it. diffstat: src/lib-index/mail-index-sync.c | 31 ------------------------------ src/lib-index/mail-index.h | 1 - src/lib-storage/index/cydir/cydir-sync.c | 3 -- src/lib-storage/index/imapc/imapc-sync.c | 3 -- src/lib-storage/index/index-sync-changes.c | 7 +----- src/plugins/virtual/virtual-sync.c | 5 ---- 6 files changed, 1 insertions(+), 49 deletions(-) diffs (152 lines): diff -r 0efc12f3eb2a -r 5f483950b733 src/lib-index/mail-index-sync.c --- a/src/lib-index/mail-index-sync.c Sat Sep 15 19:54:21 2012 +0300 +++ b/src/lib-index/mail-index-sync.c Sat Sep 15 19:56:47 2012 +0300 @@ -24,10 +24,6 @@ ARRAY(struct mail_index_sync_list) sync_list; uint32_t next_uid; uint32_t last_tail_seq, last_tail_offset; - - uint32_t append_uid_first, append_uid_last; - - unsigned int sync_appends:1; }; static void mail_index_sync_add_expunge(struct mail_index_sync_ctx *ctx) @@ -123,20 +119,6 @@ mail_index_keywords_unref(&keywords); } -static void mail_index_sync_add_append(struct mail_index_sync_ctx *ctx) -{ - const struct mail_index_record *rec = ctx->data; - - if (ctx->append_uid_first == 0 || rec->uid < ctx->append_uid_first) - ctx->append_uid_first = rec->uid; - - rec = CONST_PTR_OFFSET(ctx->data, ctx->hdr->size - sizeof(*rec)); - if (rec->uid > ctx->append_uid_last) - ctx->append_uid_last = rec->uid; - - ctx->sync_appends = TRUE; -} - static bool mail_index_sync_add_transaction(struct mail_index_sync_ctx *ctx) { switch (ctx->hdr->type & MAIL_TRANSACTION_TYPE_MASK) { @@ -155,9 +137,6 @@ case MAIL_TRANSACTION_KEYWORD_RESET: mail_index_sync_add_keyword_reset(ctx); break; - case MAIL_TRANSACTION_APPEND: - mail_index_sync_add_append(ctx); - break; default: return FALSE; } @@ -686,13 +665,6 @@ if (i == count) { if (next_i == (unsigned int)-1) { /* nothing left in sync_list */ - if (ctx->sync_appends) { - ctx->sync_appends = FALSE; - sync_rec->type = MAIL_INDEX_SYNC_TYPE_APPEND; - sync_rec->uid1 = ctx->append_uid_first; - sync_rec->uid2 = ctx->append_uid_last; - return TRUE; - } return FALSE; } ctx->next_uid = next_found_uid; @@ -718,9 +690,6 @@ { const struct mail_index_sync_list *sync_list; - if (ctx->sync_appends) - return TRUE; - array_foreach(&ctx->sync_list, sync_list) { if (array_is_created(sync_list->array) && sync_list->idx != array_count(sync_list->array)) diff -r 0efc12f3eb2a -r 5f483950b733 src/lib-index/mail-index.h --- a/src/lib-index/mail-index.h Sat Sep 15 19:54:21 2012 +0300 +++ b/src/lib-index/mail-index.h Sat Sep 15 19:56:47 2012 +0300 @@ -129,7 +129,6 @@ }; enum mail_index_sync_type { - MAIL_INDEX_SYNC_TYPE_APPEND = 0x01, MAIL_INDEX_SYNC_TYPE_EXPUNGE = 0x02, MAIL_INDEX_SYNC_TYPE_FLAGS = 0x04, MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD = 0x08, diff -r 0efc12f3eb2a -r 5f483950b733 src/lib-storage/index/cydir/cydir-sync.c --- a/src/lib-storage/index/cydir/cydir-sync.c Sat Sep 15 19:54:21 2012 +0300 +++ b/src/lib-storage/index/cydir/cydir-sync.c Sat Sep 15 19:56:47 2012 +0300 @@ -87,9 +87,6 @@ } switch (sync_rec.type) { - case MAIL_INDEX_SYNC_TYPE_APPEND: - /* don't care */ - break; case MAIL_INDEX_SYNC_TYPE_EXPUNGE: cydir_sync_expunge(ctx, seq1, seq2); break; diff -r 0efc12f3eb2a -r 5f483950b733 src/lib-storage/index/imapc/imapc-sync.c --- a/src/lib-storage/index/imapc/imapc-sync.c Sat Sep 15 19:54:21 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.c Sat Sep 15 19:56:47 2012 +0300 @@ -288,9 +288,6 @@ &seq1, &seq2)) { /* already expunged, nothing to do. */ } else switch (sync_rec.type) { - case MAIL_INDEX_SYNC_TYPE_APPEND: - /* don't care */ - break; case MAIL_INDEX_SYNC_TYPE_EXPUNGE: imapc_sync_add_missing_deleted_flags(ctx, seq1, seq2); seq_range_array_add_range(&ctx->expunged_uids, diff -r 0efc12f3eb2a -r 5f483950b733 src/lib-storage/index/index-sync-changes.c --- a/src/lib-storage/index/index-sync-changes.c Sat Sep 15 19:54:21 2012 +0300 +++ b/src/lib-storage/index/index-sync-changes.c Sat Sep 15 19:56:47 2012 +0300 @@ -101,8 +101,7 @@ orig_count = array_count(&ctx->syncs); while (uid >= sync_rec->uid1) { - if (uid <= sync_rec->uid2 && - sync_rec->type != MAIL_INDEX_SYNC_TYPE_APPEND) { + if (uid <= sync_rec->uid2) { array_append(&ctx->syncs, sync_rec, 1); if (sync_rec->type == MAIL_INDEX_SYNC_TYPE_EXPUNGE) { @@ -118,10 +117,6 @@ } switch (sync_rec->type) { - case MAIL_INDEX_SYNC_TYPE_APPEND: - /* ignore */ - memset(sync_rec, 0, sizeof(*sync_rec)); - break; case MAIL_INDEX_SYNC_TYPE_EXPUNGE: break; case MAIL_INDEX_SYNC_TYPE_FLAGS: diff -r 0efc12f3eb2a -r 5f483950b733 src/plugins/virtual/virtual-sync.c --- a/src/plugins/virtual/virtual-sync.c Sat Sep 15 19:54:21 2012 +0300 +++ b/src/plugins/virtual/virtual-sync.c Sat Sep 15 19:56:47 2012 +0300 @@ -346,9 +346,6 @@ bool expunged; switch (sync_rec->type) { - case MAIL_INDEX_SYNC_TYPE_APPEND: - /* don't care */ - return; case MAIL_INDEX_SYNC_TYPE_EXPUNGE: case MAIL_INDEX_SYNC_TYPE_FLAGS: case MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD: @@ -407,8 +404,6 @@ modify_type, keywords); mailbox_keywords_unref(&keywords); break; - case MAIL_INDEX_SYNC_TYPE_APPEND: - i_unreached(); } } } From dovecot at dovecot.org Sat Sep 15 21:01:04 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 21:01:04 +0300 Subject: dovecot-2.2: lib-imap-storage: imap_msgpart_bodypartstructure() ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1b4ab06fa0e2 changeset: 15065:1b4ab06fa0e2 user: Timo Sirainen date: Sat Sep 15 21:00:54 2012 +0300 description: lib-imap-storage: imap_msgpart_bodypartstructure() returned freed data. diffstat: src/lib-imap-storage/imap-msgpart.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diffs (27 lines): diff -r 5f483950b733 -r 1b4ab06fa0e2 src/lib-imap-storage/imap-msgpart.c --- a/src/lib-imap-storage/imap-msgpart.c Sat Sep 15 19:56:47 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart.c Sat Sep 15 21:00:54 2012 +0300 @@ -815,16 +815,14 @@ if (part == NULL) part = all_parts; - T_BEGIN { - if (msgpart->decode_cte_to_binary) - ret = imap_msgpart_vsizes_to_binary(mail, part, &part); + if (msgpart->decode_cte_to_binary) + ret = imap_msgpart_vsizes_to_binary(mail, part, &part); - if (ret >= 0) { - bpstruct = t_str_new(256); - imap_bodystructure_write(part, bpstruct, TRUE); - *bpstruct_r = str_c(bpstruct); - } - } T_END; + if (ret >= 0) { + bpstruct = t_str_new(256); + imap_bodystructure_write(part, bpstruct, TRUE); + *bpstruct_r = str_c(bpstruct); + } return ret < 0 ? -1 : 1; } From dovecot at dovecot.org Sat Sep 15 23:57:26 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 15 Sep 2012 23:57:26 +0300 Subject: dovecot-2.2: Added support for IMAP URLAUTH and URLAUTH=BINARY e... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d419aac7ab31 changeset: 15066:d419aac7ab31 user: Stephan Bosch date: Sat Sep 15 23:57:08 2012 +0300 description: Added support for IMAP URLAUTH and URLAUTH=BINARY extensions Extends imap service with URLAUTH and URLAUTH=BINARY support: - Adds new commands URLFETCH, GENURLAUTH and RESETKEY. Creates imap-urlauth service in src/imap-urlauth. Functionality common to both the imap and imap-urlauth services is located in src/lib-imap-urlauth. TODO: - use mailbox GUIDs instead of names - doveadm command to delete stale urlauth entries? - add delay when attempting to access nonexistent user - create urlauth-worker queue, similar to how indexer-worker works (could we share code?..) diffstat: .hgignore | 3 + README | 2 + configure.in | 2 + src/Makefile.am | 2 + src/imap-urlauth/Makefile.am | 82 + src/imap-urlauth/imap-urlauth-client.c | 379 ++++++++ src/imap-urlauth/imap-urlauth-client.h | 48 + src/imap-urlauth/imap-urlauth-common.h | 13 + src/imap-urlauth/imap-urlauth-login-settings.c | 75 + src/imap-urlauth/imap-urlauth-login-settings.h | 6 + src/imap-urlauth/imap-urlauth-login.c | 192 ++++ src/imap-urlauth/imap-urlauth-settings.c | 95 ++ src/imap-urlauth/imap-urlauth-settings.h | 24 + src/imap-urlauth/imap-urlauth-worker-settings.c | 90 + src/imap-urlauth/imap-urlauth-worker-settings.h | 19 + src/imap-urlauth/imap-urlauth-worker.c | 1036 +++++++++++++++++++++++ src/imap-urlauth/imap-urlauth.c | 252 +++++ src/imap/Makefile.am | 6 + src/imap/cmd-genurlauth.c | 52 + src/imap/cmd-resetkey.c | 105 ++ src/imap/cmd-urlfetch.c | 387 ++++++++ src/imap/imap-client.c | 52 +- src/imap/imap-client.h | 12 +- src/imap/imap-commands.c | 7 +- src/imap/imap-commands.h | 5 + src/imap/imap-settings.c | 10 +- src/imap/imap-settings.h | 5 + src/imap/main.c | 6 +- src/lib-imap-urlauth/Makefile.am | 28 + src/lib-imap-urlauth/imap-urlauth-backend.c | 164 +++ src/lib-imap-urlauth/imap-urlauth-backend.h | 20 + src/lib-imap-urlauth/imap-urlauth-connection.c | 1016 ++++++++++++++++++++++ src/lib-imap-urlauth/imap-urlauth-connection.h | 42 + src/lib-imap-urlauth/imap-urlauth-fetch.c | 437 +++++++++ src/lib-imap-urlauth/imap-urlauth-fetch.h | 50 + src/lib-imap-urlauth/imap-urlauth-private.h | 18 + src/lib-imap-urlauth/imap-urlauth.c | 467 ++++++++++ src/lib-imap-urlauth/imap-urlauth.h | 49 + 38 files changed, 5253 insertions(+), 5 deletions(-) diffs (truncated from 5658 to 300 lines): diff -r 1b4ab06fa0e2 -r d419aac7ab31 .hgignore --- a/.hgignore Sat Sep 15 21:00:54 2012 +0300 +++ b/.hgignore Sat Sep 15 23:57:08 2012 +0300 @@ -67,6 +67,9 @@ src/doveadm/doveadm src/doveadm/doveadm-server src/imap-login/imap-login +src/imap-urlauth/imap-urlauth +src/imap-urlauth/imap-urlauth-login +src/imap-urlauth/imap-urlauth-worker src/imap/imap src/indexer/indexer src/indexer/indexer-worker diff -r 1b4ab06fa0e2 -r d419aac7ab31 README --- a/README Sat Sep 15 21:00:54 2012 +0300 +++ b/README Sat Sep 15 23:57:08 2012 +0300 @@ -40,6 +40,7 @@ 3691 - IMAP4 UNSELECT command 4314 - IMAP4 Access Control List (ACL) Extension 4315 - IMAP UIDPLUS extension + 4467 - IMAP URLAUTH Extension 4469 - IMAP CATENATE Extension 4551 - IMAP Extension for Conditional STORE Operation or Quick Flag Changes Resynchronization @@ -55,6 +56,7 @@ 5256 - IMAP SORT and THREAD Extensions 5258 - IMAP4 - LIST Command Extensions 5267 - Contexts for IMAP4 + 5524 - Extended URLFETCH for Binary and Converted Parts 5530 - IMAP Response Codes 5819 - IMAP4 Extension for Returning STATUS Information in Extended LIST 5957 - Display-Based Address Sorting for the IMAP4 SORT Extension diff -r 1b4ab06fa0e2 -r d419aac7ab31 configure.in --- a/configure.in Sat Sep 15 21:00:54 2012 +0300 +++ b/configure.in Sat Sep 15 23:57:08 2012 +0300 @@ -2757,6 +2757,7 @@ src/lib-imap/Makefile src/lib-imap-storage/Makefile src/lib-imap-client/Makefile +src/lib-imap-urlauth/Makefile src/lib-index/Makefile src/lib-lda/Makefile src/lib-mail/Makefile @@ -2796,6 +2797,7 @@ src/ipc/Makefile src/imap/Makefile src/imap-login/Makefile +src/imap-urlauth/Makefile src/login-common/Makefile src/master/Makefile src/pop3/Makefile diff -r 1b4ab06fa0e2 -r d419aac7ab31 src/Makefile.am --- a/src/Makefile.am Sat Sep 15 21:00:54 2012 +0300 +++ b/src/Makefile.am Sat Sep 15 23:57:08 2012 +0300 @@ -16,6 +16,7 @@ SUBDIRS = \ $(LIBDOVECOT_SUBDIRS) \ lib-imap-client \ + lib-imap-urlauth \ lib-compression \ lib-dovecot \ lib-index \ @@ -34,6 +35,7 @@ login-common \ imap-login \ imap \ + imap-urlauth \ pop3-login \ pop3 \ lda \ diff -r 1b4ab06fa0e2 -r d419aac7ab31 src/imap-urlauth/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/imap-urlauth/Makefile.am Sat Sep 15 23:57:08 2012 +0300 @@ -0,0 +1,82 @@ +pkglibexecdir = $(libexecdir)/dovecot + +# Refer to comment in imap-urlauth.c for info on what these binaries are for. +pkglibexec_PROGRAMS = imap-urlauth-login imap-urlauth imap-urlauth-worker + +# imap-urlauth-login + +imap_urlauth_login_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-settings \ + -I$(top_srcdir)/src/lib-auth \ + -I$(top_srcdir)/src/lib-master \ + -I$(top_srcdir)/src/login-common + +imap_urlauth_login_LDADD = \ + $(LIBDOVECOT_LOGIN) \ + $(LIBDOVECOT) \ + $(SSL_LIBS) +imap_urlauth_login_DEPENDENCIES = \ + $(LIBDOVECOT_LOGIN) \ + $(LIBDOVECOT_DEPS) + +imap_urlauth_login_SOURCES = \ + imap-urlauth-login.c \ + imap-urlauth-login-settings.c + +# imap-urlauth + +imap_urlauth_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-settings \ + -I$(top_srcdir)/src/lib-auth \ + -I$(top_srcdir)/src/lib-master \ + -I$(top_srcdir)/src/lib-dict \ + -DPKG_RUNDIR=\""$(rundir)"\" + +imap_urlauth_LDFLAGS = -export-dynamic + +imap_urlauth_LDADD = $(LIBDOVECOT) $(MODULE_LIBS) +imap_urlauth_DEPENDENCIES = $(LIBDOVECOT_DEPS) + +imap_urlauth_SOURCES = \ + imap-urlauth.c \ + imap-urlauth-client.c \ + imap-urlauth-settings.c + +# imap-urlauth-worker + +imap_urlauth_worker_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-auth \ + -I$(top_srcdir)/src/lib-settings \ + -I$(top_srcdir)/src/lib-master \ + -I$(top_srcdir)/src/lib-dict \ + -I$(top_srcdir)/src/imap \ + -I$(top_srcdir)/src/lib-imap \ + -I$(top_srcdir)/src/lib-imap-storage \ + -I$(top_srcdir)/src/lib-imap-urlauth \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-storage \ + -I$(top_srcdir)/src/login-common + +imap_urlauth_worker_LDFLAGS = -export-dynamic + +urlauth_libs = \ + $(LIBDOVECOT_STORAGE) \ + $(top_builddir)/src/lib-imap-urlauth/libimap-urlauth.la + +imap_urlauth_worker_LDADD = $(urlauth_libs) $(LIBDOVECOT) $(MODULE_LIBS) +imap_urlauth_worker_DEPENDENCIES = $(urlauth_libs) $(LIBDOVECOT_DEPS) + +imap_urlauth_worker_SOURCES = \ + imap-urlauth-worker.c \ + imap-urlauth-worker-settings.c + +noinst_HEADERS = \ + imap-urlauth-client.h \ + imap-urlauth-common.h \ + imap-urlauth-settings.h \ + imap-urlauth-login-settings.h \ + imap-urlauth-worker-settings.h + diff -r 1b4ab06fa0e2 -r d419aac7ab31 src/imap-urlauth/imap-urlauth-client.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/imap-urlauth/imap-urlauth-client.c Sat Sep 15 23:57:08 2012 +0300 @@ -0,0 +1,379 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "imap-urlauth-common.h" +#include "array.h" +#include "ioloop.h" +#include "network.h" +#include "fdpass.h" +#include "istream.h" +#include "ostream.h" +#include "str.h" +#include "strescape.h" +#include "eacces-error.h" +#include "llist.h" +#include "hostpid.h" +#include "execv-const.h" +#include "env-util.h" +#include "var-expand.h" +#include "restrict-access.h" +#include "master-service.h" +#include "master-interface.h" + +#include +#include +#include + +#define IMAP_URLAUTH_PROTOCOL_MAJOR_VERSION 1 +#define IMAP_URLAUTH_PROTOCOL_MINOR_VERSION 0 + +#define IMAP_URLAUTH_WORKER_SOCKET "imap-urlauth-worker" + +/* max. length of input lines (URLs) */ +#define MAX_INBUF_SIZE 2048 + +/* Disconnect client after idling this many milliseconds */ +#define CLIENT_IDLE_TIMEOUT_MSECS (10*60*1000) + +#define USER_EXECUTABLE "imap-urlauth-worker" + +#define IS_STANDALONE() \ + (getenv(MASTER_IS_PARENT_ENV) == NULL) + +struct client *imap_urlauth_clients; +unsigned int imap_urlauth_client_count; + +static int client_worker_connect(struct client *client); +static void client_worker_disconnect(struct client *client); +static void client_worker_input(struct client *client); + +int client_create(const char *username, int fd_in, int fd_out, + const struct imap_urlauth_settings *set, + struct client **client_r) +{ + struct client *client; + const char *app; + + /* always use nonblocking I/O */ + net_set_nonblock(fd_in, TRUE); + net_set_nonblock(fd_out, TRUE); + + client = i_new(struct client, 1); + client->fd_in = fd_in; + client->fd_out = fd_out; + client->fd_ctrl = -1; + client->set = set; + + if (client_worker_connect(client) < 0) { + i_free(client); + return -1; + } + + /* determine user's special privileges */ + i_array_init(&client->access_apps, 4); + if (username != NULL) { + if (set->imap_urlauth_submit_user != NULL && + strcmp(set->imap_urlauth_submit_user, username) == 0) { + if (set->mail_debug) + i_debug("User %s has URLAUTH submit access", username); + app = "submit+"; + array_append(&client->access_apps, &app, 1); + } + if (set->imap_urlauth_stream_user != NULL && + strcmp(set->imap_urlauth_stream_user, username) == 0) { + if (set->mail_debug) + i_debug("User %s has URLAUTH stream access", username); + app = "stream"; + array_append(&client->access_apps, &app, 1); + } + } + + if (username != NULL) + client->username = i_strdup(username); + + client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE); + + imap_urlauth_client_count++; + DLLIST_PREPEND(&imap_urlauth_clients, client); + + imap_urlauth_refresh_proctitle(); + *client_r = client; + return 0; +} + +void client_send_line(struct client *client, const char *fmt, ...) +{ + va_list va; + ssize_t ret; + + if (client->output->closed) + return; + + va_start(va, fmt); + + T_BEGIN { + string_t *str; + + str = t_str_new(256); + str_vprintfa(str, fmt, va); + str_append(str, "\n"); + + ret = o_stream_send(client->output, + str_data(str), str_len(str)); + i_assert(ret < 0 || (size_t)ret == str_len(str)); + } T_END; + + va_end(va); +} + +static int client_worker_connect(struct client *client) +{ + static const char handshake[] = "VERSION\timap-urlauth-worker\t1\t0\n"; + const char *socket_path; + ssize_t ret; + unsigned char data; + + socket_path = t_strconcat(client->set->base_dir, + "/"IMAP_URLAUTH_WORKER_SOCKET, NULL); + + if (client->set->mail_debug) + i_debug("Connecting to worker socket %s", socket_path); + From dovecot at dovecot.org Sun Sep 16 00:52:52 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 00:52:52 +0300 Subject: dovecot-2.2: dict_init() API changed to return int. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9bff478f81fd changeset: 15067:9bff478f81fd user: Timo Sirainen date: Sun Sep 16 00:52:39 2012 +0300 description: dict_init() API changed to return int. diffstat: src/auth/db-dict.c | 5 +++-- src/dict/dict-connection.c | 5 ++--- src/lib-dict/dict-client.c | 9 +++++---- src/lib-dict/dict-db.c | 14 ++++++++------ src/lib-dict/dict-file.c | 12 +++++++----- src/lib-dict/dict-memcached-ascii.c | 8 +++++--- src/lib-dict/dict-memcached.c | 7 ++++--- src/lib-dict/dict-private.h | 7 ++++--- src/lib-dict/dict-redis.c | 7 ++++--- src/lib-dict/dict-sql.c | 10 ++++++---- src/lib-dict/dict.c | 11 ++++++----- src/lib-dict/dict.h | 6 +++--- src/lib-imap-urlauth/imap-urlauth-backend.c | 5 ++--- src/plugins/acl/acl-lookup-dict.c | 5 ++--- src/plugins/expire/doveadm-expire.c | 5 ++--- src/plugins/expire/expire-plugin.c | 5 ++--- src/plugins/quota/quota-dict.c | 7 ++++--- 17 files changed, 69 insertions(+), 59 deletions(-) diffs (truncated from 403 to 300 lines): diff -r d419aac7ab31 -r 9bff478f81fd src/auth/db-dict.c --- a/src/auth/db-dict.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/auth/db-dict.c Sun Sep 16 00:52:39 2012 +0300 @@ -90,8 +90,9 @@ i_fatal("dict %s: Unsupported value_format %s in ", config_path, conn->set.value_format); } - conn->dict = dict_init(conn->set.uri, DICT_DATA_TYPE_STRING, "", - global_auth_settings->base_dir); + if (dict_init(conn->set.uri, DICT_DATA_TYPE_STRING, "", + global_auth_settings->base_dir, &conn->dict) < 0) + i_fatal("dict %s: Failed to init dict", config_path); conn->next = connections; connections = conn; diff -r d419aac7ab31 -r 9bff478f81fd src/dict/dict-connection.c --- a/src/dict/dict-connection.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/dict/dict-connection.c Sun Sep 16 00:52:39 2012 +0300 @@ -83,9 +83,8 @@ } uri = strlist[i+1]; - conn->dict = dict_init(uri, conn->value_type, conn->username, - dict_settings->base_dir); - if (conn->dict == NULL) { + if (dict_init(uri, conn->value_type, conn->username, + dict_settings->base_dir, &conn->dict) < 0) { /* dictionary initialization failed */ i_error("Failed to initialize dictionary '%s'", conn->name); return -1; diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-client.c --- a/src/lib-dict/dict-client.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-client.c Sun Sep 16 00:52:39 2012 +0300 @@ -463,10 +463,10 @@ } } -static struct dict * +static int client_dict_init(struct dict *driver, const char *uri, enum dict_data_type value_type, const char *username, - const char *base_dir) + const char *base_dir, struct dict **dict_r) { struct client_dict *dict; const char *dest_uri; @@ -476,7 +476,7 @@ dest_uri = strchr(uri, ':'); if (dest_uri == NULL) { i_error("dict-client: Invalid URI: %s", uri); - return NULL; + return -1; } pool = pool_alloconly_create("client dict", 1024); @@ -496,7 +496,8 @@ "/"DEFAULT_DICT_SERVER_SOCKET_FNAME, NULL); } dict->uri = p_strdup(pool, dest_uri + 1); - return &dict->dict; + *dict_r = &dict->dict; + return -1; } static void client_dict_deinit(struct dict *_dict) diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-db.c --- a/src/lib-dict/dict-db.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-db.c Sun Sep 16 00:52:39 2012 +0300 @@ -140,10 +140,11 @@ return 0; } -static struct dict * +static int db_dict_init(struct dict *driver, const char *uri, enum dict_data_type value_type, - const char *username, const char *base_dir ATTR_UNUSED) + const char *username, const char *base_dir ATTR_UNUSED, + struct dict **dict_r) { struct db_dict *dict; pool_t pool; @@ -156,7 +157,7 @@ "run-time linked against %d.%d.%d library", DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, major, minor, patch); - return NULL; + return -1; } pool = pool_alloconly_create("db dict", 1024); @@ -170,15 +171,16 @@ if (ret != 0) { i_error("db_env_create() failed: %s\n", db_strerror(ret)); pool_unref(&pool); - return NULL; + return -1; } if (db_dict_open(dict, uri, username) < 0) { i_error("db(%s) open failed", uri); db_dict_deinit(&dict->dict); - return NULL; + return -1; } - return &dict->dict; + *dict_r = &dict->dict; + return 0; } static void db_dict_deinit(struct dict *_dict) diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-file.c --- a/src/lib-dict/dict-file.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-file.c Sun Sep 16 00:52:39 2012 +0300 @@ -51,10 +51,11 @@ .use_io_notify = TRUE }; -static struct dict *file_dict_init(struct dict *driver, const char *uri, - enum dict_data_type value_type ATTR_UNUSED, - const char *username ATTR_UNUSED, - const char *base_dir ATTR_UNUSED) +static int +file_dict_init(struct dict *driver, const char *uri, + enum dict_data_type value_type ATTR_UNUSED, + const char *username ATTR_UNUSED, + const char *base_dir ATTR_UNUSED, struct dict **dict_r) { struct file_dict *dict; const char *p; @@ -79,7 +80,8 @@ dict->hash_pool = pool_alloconly_create("file dict", 1024); hash_table_create(&dict->hash, dict->hash_pool, 0, str_hash, strcmp); dict->fd = -1; - return &dict->dict; + *dict_r = &dict->dict; + return -1; } static void file_dict_deinit(struct dict *_dict) diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-memcached-ascii.c --- a/src/lib-dict/dict-memcached-ascii.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-memcached-ascii.c Sun Sep 16 00:52:39 2012 +0300 @@ -330,11 +330,12 @@ return str_c(str); } -static struct dict * +static int memcached_ascii_dict_init(struct dict *driver, const char *uri, enum dict_data_type value_type ATTR_UNUSED, const char *username, - const char *base_dir ATTR_UNUSED) + const char *base_dir ATTR_UNUSED, + struct dict **dict_r) { struct memcached_ascii_dict *dict; const char *const *args; @@ -388,7 +389,8 @@ dict->ioloop = io_loop_create(); current_ioloop = old_ioloop; - return &dict->dict; + *dict_r = &dict->dict; + return 0; } static void memcached_ascii_dict_deinit(struct dict *_dict) diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-memcached.c --- a/src/lib-dict/dict-memcached.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-memcached.c Sun Sep 16 00:52:39 2012 +0300 @@ -167,11 +167,11 @@ .client_connected = memcached_conn_connected }; -static struct dict * +static int memcached_dict_init(struct dict *driver, const char *uri, enum dict_data_type value_type ATTR_UNUSED, const char *username ATTR_UNUSED, - const char *base_dir ATTR_UNUSED) + const char *base_dir ATTR_UNUSED, struct dict **dict_r) { struct memcached_dict *dict; const char *const *args; @@ -213,7 +213,8 @@ dict->dict = *driver; dict->conn.cmd = buffer_create_dynamic(default_pool, 256); dict->conn.dict = dict; - return &dict->dict; + *dict_r = &dict->dict; + return 0; } static void memcached_dict_deinit(struct dict *_dict) diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-private.h --- a/src/lib-dict/dict-private.h Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-private.h Sun Sep 16 00:52:39 2012 +0300 @@ -4,9 +4,10 @@ #include "dict.h" struct dict_vfuncs { - struct dict *(*init)(struct dict *dict_driver, const char *uri, - enum dict_data_type value_type, - const char *username, const char *base_dir); + int (*init)(struct dict *dict_driver, const char *uri, + enum dict_data_type value_type, + const char *username, const char *base_dir, + struct dict **dict_r); void (*deinit)(struct dict *dict); int (*wait)(struct dict *dict); diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-redis.c --- a/src/lib-dict/dict-redis.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-redis.c Sun Sep 16 00:52:39 2012 +0300 @@ -298,11 +298,11 @@ return str_c(str); } -static struct dict * +static int redis_dict_init(struct dict *driver, const char *uri, enum dict_data_type value_type ATTR_UNUSED, const char *username, - const char *base_dir ATTR_UNUSED) + const char *base_dir ATTR_UNUSED, struct dict **dict_r) { struct redis_dict *dict; const char *const *args; @@ -352,7 +352,8 @@ dict->dict = *driver; dict->conn.last_reply = str_new(default_pool, 256); dict->conn.dict = dict; - return &dict->dict; + *dict_r = &dict->dict; + return -1; } static void redis_dict_deinit(struct dict *_dict) diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict-sql.c --- a/src/lib-dict/dict-sql.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict-sql.c Sun Sep 16 00:52:39 2012 +0300 @@ -71,10 +71,11 @@ static void sql_dict_prev_inc_flush(struct sql_dict_transaction_context *ctx); -static struct dict * +static int sql_dict_init(struct dict *driver, const char *uri, enum dict_data_type value_type ATTR_UNUSED, - const char *username, const char *base_dir ATTR_UNUSED) + const char *username, const char *base_dir ATTR_UNUSED, + struct dict **dict_r) { struct sql_dict *dict; pool_t pool; @@ -87,7 +88,7 @@ dict->set = dict_sql_settings_read(pool, uri); if (dict->set == NULL) { pool_unref(&pool); - return NULL; + return -1; } /* currently pgsql and sqlite don't support "ON DUPLICATE KEY" */ @@ -95,7 +96,8 @@ dict->db = sql_db_cache_new(dict_sql_db_cache, driver->name, dict->set->connect); - return &dict->dict; + *dict_r = &dict->dict; + return 0; } static void sql_dict_deinit(struct dict *_dict) diff -r d419aac7ab31 -r 9bff478f81fd src/lib-dict/dict.c --- a/src/lib-dict/dict.c Sat Sep 15 23:57:08 2012 +0300 +++ b/src/lib-dict/dict.c Sun Sep 16 00:52:39 2012 +0300 @@ -70,8 +70,8 @@ dict_driver_unregister(&dict_driver_redis); } -struct dict *dict_init(const char *uri, enum dict_data_type value_type, - const char *username, const char *base_dir) +int dict_init(const char *uri, enum dict_data_type value_type, + const char *username, const char *base_dir, struct dict **dict_r) { struct dict *dict; const char *p, *name; @@ -81,7 +81,7 @@ p = strchr(uri, ':'); if (p == NULL) { i_error("Dictionary URI is missing ':': %s", uri); - return NULL; + return -1; } T_BEGIN { @@ -91,8 +91,9 @@ i_error("Unknown dict module: %s", name); From dovecot at dovecot.org Sun Sep 16 00:57:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 00:57:05 +0300 Subject: dovecot-2.2: Renamed str_tabescape_write() to str_append_tabesca... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/002e0a120c2a changeset: 15068:002e0a120c2a user: Timo Sirainen date: Sun Sep 16 00:56:51 2012 +0300 description: Renamed str_tabescape_write() to str_append_tabescaped() diffstat: src/anvil/connect-limit.c | 2 +- src/anvil/penalty.c | 2 +- src/auth/auth-master-connection.c | 2 +- src/auth/auth-stream.c | 2 +- src/auth/checkpassword-reply.c | 8 ++++---- src/doveadm/doveadm-mail-index.c | 4 ++-- src/doveadm/doveadm-mail-server.c | 6 +++--- src/doveadm/doveadm-print-server.c | 4 ++-- src/doveadm/dsync/dsync-ibc-stream.c | 6 +++--- src/doveadm/dsync/dsync-serializer.c | 4 ++-- src/imap-urlauth/imap-urlauth-client.c | 4 ++-- src/indexer/worker-connection.c | 4 ++-- src/lib-auth/auth-client-request.c | 10 +++++----- src/lib-auth/auth-master.c | 2 +- src/lib-imap-urlauth/imap-urlauth-connection.c | 8 ++++---- src/lib-master/master-instance.c | 6 +++--- src/lib-master/master-login.c | 2 +- src/lib/strescape.c | 4 ++-- src/lib/strescape.h | 2 +- src/log/doveadm-connection.c | 4 ++-- src/master/service-process.c | 4 ++-- src/plugins/replication/replication-plugin.c | 4 ++-- src/plugins/stats/stats-connection.c | 4 ++-- src/replication/replicator/doveadm-connection.c | 2 +- src/replication/replicator/replicator-queue.c | 2 +- src/stats/client-export.c | 16 ++++++++-------- src/util/script-login.c | 2 +- 27 files changed, 60 insertions(+), 60 deletions(-) diffs (truncated from 527 to 300 lines): diff -r 9bff478f81fd -r 002e0a120c2a src/anvil/connect-limit.c --- a/src/anvil/connect-limit.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/anvil/connect-limit.c Sun Sep 16 00:56:51 2012 +0300 @@ -168,7 +168,7 @@ iter = hash_table_iterate_init(limit->ident_pid_hash); while (hash_table_iterate(iter, limit->ident_pid_hash, &i, &value)) { str_truncate(str, 0); - str_tabescape_write(str, i->ident); + str_append_tabescaped(str, i->ident); str_printfa(str, "\t%ld\t%u\n", (long)i->pid, i->refcount); if (o_stream_send(output, str_data(str), str_len(str)) < 0) break; diff -r 9bff478f81fd -r 002e0a120c2a src/anvil/penalty.c --- a/src/anvil/penalty.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/anvil/penalty.c Sun Sep 16 00:56:51 2012 +0300 @@ -259,7 +259,7 @@ for (rec = penalty->oldest; rec != NULL; rec = rec->next) { str_truncate(str, 0); - str_tabescape_write(str, rec->ident); + str_append_tabescaped(str, rec->ident); str_printfa(str, "\t%u\t%u\t%u\n", rec->penalty, rec->last_penalty, rec->last_penalty + rec->last_update); diff -r 9bff478f81fd -r 002e0a120c2a src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/auth/auth-master-connection.c Sun Sep 16 00:56:51 2012 +0300 @@ -324,7 +324,7 @@ switch (result) { case PASSDB_RESULT_OK: str_printfa(str, "PASS\t%u\tuser=", auth_request->id); - str_tabescape_write(str, auth_request->user); + str_append_tabescaped(str, auth_request->user); if (reply != NULL) { str_append_c(str, '\t'); str_append(str, auth_stream_reply_export(reply)); diff -r 9bff478f81fd -r 002e0a120c2a src/auth/auth-stream.c --- a/src/auth/auth-stream.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/auth/auth-stream.c Sun Sep 16 00:56:51 2012 +0300 @@ -36,7 +36,7 @@ } if (value != NULL) { /* escape dangerous characters in the value */ - str_tabescape_write(reply->str, value); + str_append_tabescaped(reply->str, value); } } diff -r 9bff478f81fd -r 002e0a120c2a src/auth/checkpassword-reply.c --- a/src/auth/checkpassword-reply.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/auth/checkpassword-reply.c Sun Sep 16 00:56:51 2012 +0300 @@ -25,7 +25,7 @@ return 1; } str_printfa(str, "user="); - str_tabescape_write(str, user); + str_append_tabescaped(str, user); str_append_c(str, '\t'); } @@ -36,7 +36,7 @@ return 1; } str_printfa(str, "userdb_home="); - str_tabescape_write(str, home); + str_append_tabescaped(str, home); str_append_c(str, '\t'); } @@ -50,9 +50,9 @@ uid_found = TRUE; else if (strcmp(key, "userdb_gid") == 0) gid_found = TRUE; - str_tabescape_write(str, key); + str_append_tabescaped(str, key); str_append_c(str, '='); - str_tabescape_write(str, value); + str_append_tabescaped(str, value); str_append_c(str, '\t'); } } diff -r 9bff478f81fd -r 002e0a120c2a src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/doveadm/doveadm-mail-index.c Sun Sep 16 00:56:51 2012 +0300 @@ -147,9 +147,9 @@ string_t *str = t_str_new(256); str_append(str, "APPEND\t0\t"); - str_tabescape_write(str, user->username); + str_append_tabescaped(str, user->username); str_append_c(str, '\t'); - str_tabescape_write(str, mailbox); + str_append_tabescaped(str, mailbox); str_printfa(str, "\t%u\n", ctx->max_recent_msgs); if (write_full(ctx->queue_fd, str_data(str), str_len(str)) < 0) i_fatal("write(indexer) failed: %m"); diff -r 9bff478f81fd -r 002e0a120c2a src/doveadm/doveadm-mail-server.c --- a/src/doveadm/doveadm-mail-server.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/doveadm/doveadm-mail-server.c Sun Sep 16 00:56:51 2012 +0300 @@ -128,12 +128,12 @@ str_append_c(cmd, 'v'); str_append_c(cmd, '\t'); - str_tabescape_write(cmd, username); + str_append_tabescaped(cmd, username); str_append_c(cmd, '\t'); - str_tabescape_write(cmd, cmd_ctx->cmd->name); + str_append_tabescaped(cmd, cmd_ctx->cmd->name); for (i = 0; cmd_ctx->full_args[i] != NULL; i++) { str_append_c(cmd, '\t'); - str_tabescape_write(cmd, cmd_ctx->full_args[i]); + str_append_tabescaped(cmd, cmd_ctx->full_args[i]); } str_append_c(cmd, '\n'); server_connection_cmd(conn, str_c(cmd), doveadm_cmd_callback, conn); diff -r 9bff478f81fd -r 002e0a120c2a src/doveadm/doveadm-print-server.c --- a/src/doveadm/doveadm-print-server.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/doveadm/doveadm-print-server.c Sun Sep 16 00:56:51 2012 +0300 @@ -39,7 +39,7 @@ static void doveadm_print_server_print(const char *value) { - str_tabescape_write(ctx.str, value); + str_append_tabescaped(ctx.str, value); str_append_c(ctx.str, '\t'); if (++ctx.header_idx == ctx.header_count) { @@ -56,7 +56,7 @@ return; } T_BEGIN { - str_tabescape_write(ctx.str, t_strndup(value, size)); + str_append_tabescaped(ctx.str, t_strndup(value, size)); } T_END; if (str_len(ctx.str) >= IO_BLOCK_SIZE) diff -r 9bff478f81fd -r 002e0a120c2a src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Sun Sep 16 00:56:51 2012 +0300 @@ -689,7 +689,7 @@ are. */ namestr = t_str_new(128); for (; *name != NULL; name++) { - str_tabescape_write(namestr, *name); + str_append_tabescaped(namestr, *name); str_append_c(namestr, '\t'); } str_truncate(namestr, str_len(namestr)-1); @@ -1166,10 +1166,10 @@ unsigned int i, count; changes = array_get(&change->keyword_changes, &count); - str_tabescape_write(kw_str, changes[0]); + str_append_tabescaped(kw_str, changes[0]); for (i = 1; i < count; i++) { str_append_c(kw_str, '\t'); - str_tabescape_write(kw_str, changes[i]); + str_append_tabescaped(kw_str, changes[i]); } dsync_serializer_encode_add(encoder, "keyword_changes", str_c(kw_str)); diff -r 9bff478f81fd -r 002e0a120c2a src/doveadm/dsync/dsync-serializer.c --- a/src/doveadm/dsync/dsync-serializer.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/doveadm/dsync/dsync-serializer.c Sun Sep 16 00:56:51 2012 +0300 @@ -56,7 +56,7 @@ for (i = 0; serializer->keys[i] != NULL; i++) { if (i > 0) str_append_c(str, '\t'); - str_tabescape_write(str, serializer->keys[i]); + str_append_tabescaped(str, serializer->keys[i]); } str_append_c(str, '\n'); return str_c(str); @@ -108,7 +108,7 @@ else { if (values[i][0] == NULL_CHR) str_append_c(output, NULL_CHR); - str_tabescape_write(output, values[i]); + str_append_tabescaped(output, values[i]); } } str_append_c(output, '\n'); diff -r 9bff478f81fd -r 002e0a120c2a src/imap-urlauth/imap-urlauth-client.c --- a/src/imap-urlauth/imap-urlauth-client.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/imap-urlauth/imap-urlauth-client.c Sun Sep 16 00:56:51 2012 +0300 @@ -225,7 +225,7 @@ str = t_str_new(256); str_append(str, "ACCESS\t"); if (client->username != NULL) - str_tabescape_write(str, client->username); + str_append_tabescaped(str, client->username); if (client->set->mail_debug) str_append(str, "\tdebug"); if (array_count(&client->access_apps) > 0) { @@ -234,7 +234,7 @@ str_append(str, apps[0]); for (i = 1; i < count; i++) { str_append_c(str, ','); - str_tabescape_write(str, apps[i]); + str_append_tabescaped(str, apps[i]); } } str_append(str, "\n"); diff -r 9bff478f81fd -r 002e0a120c2a src/indexer/worker-connection.c --- a/src/indexer/worker-connection.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/indexer/worker-connection.c Sun Sep 16 00:56:51 2012 +0300 @@ -238,9 +238,9 @@ T_BEGIN { string_t *str = t_str_new(128); - str_tabescape_write(str, request->username); + str_append_tabescaped(str, request->username); str_append_c(str, '\t'); - str_tabescape_write(str, request->mailbox); + str_append_tabescaped(str, request->mailbox); str_printfa(str, "\t%u\t", request->max_recent_msgs); if (request->index) str_append_c(str, 'i'); diff -r 9bff478f81fd -r 002e0a120c2a src/lib-auth/auth-client-request.c --- a/src/lib-auth/auth-client-request.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/lib-auth/auth-client-request.c Sun Sep 16 00:56:51 2012 +0300 @@ -31,9 +31,9 @@ str = t_str_new(512); str_printfa(str, "AUTH\t%u\t", request->id); - str_tabescape_write(str, info->mech); + str_append_tabescaped(str, info->mech); str_append(str, "\tservice="); - str_tabescape_write(str, info->service); + str_append_tabescaped(str, info->service); if ((info->flags & AUTH_REQUEST_FLAG_SUPPORT_FINAL_RESP) != 0) str_append(str, "\tfinal-resp-ok"); @@ -46,11 +46,11 @@ if (info->session_id != NULL) { str_append(str, "\tsession="); - str_tabescape_write(str, info->session_id); + str_append_tabescaped(str, info->session_id); } if (info->cert_username != NULL) { str_append(str, "\tcert_username="); - str_tabescape_write(str, info->cert_username); + str_append_tabescaped(str, info->cert_username); } if (info->local_ip.family != 0) str_printfa(str, "\tlip=%s", net_ip2addr(&info->local_ip)); @@ -62,7 +62,7 @@ str_printfa(str, "\trport=%u", info->remote_port); if (info->initial_resp_base64 != NULL) { str_append(str, "\tresp="); - str_tabescape_write(str, info->initial_resp_base64); + str_append_tabescaped(str, info->initial_resp_base64); } str_append_c(str, '\n'); diff -r 9bff478f81fd -r 002e0a120c2a src/lib-auth/auth-master.c --- a/src/lib-auth/auth-master.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/lib-auth/auth-master.c Sun Sep 16 00:56:51 2012 +0300 @@ -595,7 +595,7 @@ if (users != NULL) { for (; *users != NULL; users++) { str_append_c(str, '\t'); - str_tabescape_write(str, *users); + str_append_tabescaped(str, *users); } } str_append_c(str, '\n'); diff -r 9bff478f81fd -r 002e0a120c2a src/lib-imap-urlauth/imap-urlauth-connection.c --- a/src/lib-imap-urlauth/imap-urlauth-connection.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/lib-imap-urlauth/imap-urlauth-connection.c Sun Sep 16 00:56:51 2012 +0300 @@ -256,7 +256,7 @@ cmd = t_str_new(128); str_append(cmd, "URL\t"); - str_tabescape_write(cmd, urlreq->url); + str_append_tabescaped(cmd, urlreq->url); if ((urlreq->flags & IMAP_URLAUTH_FETCH_FLAG_BODYPARTSTRUCTURE) != 0) str_append(cmd, "\tbpstruct"); if ((urlreq->flags & IMAP_URLAUTH_FETCH_FLAG_BINARY) != 0) @@ -898,12 +898,12 @@ str = t_str_new(128); str_printfa(str, IMAP_URLAUTH_HANDSHAKE"AUTH\t%s\t", my_pid); - str_tabescape_write(str, conn->user->username); + str_append_tabescaped(str, conn->user->username); str_append_c(str, '\t'); if (conn->session_id != NULL) - str_tabescape_write(str, conn->session_id); + str_append_tabescaped(str, conn->session_id); str_append_c(str, '\t'); - str_tabescape_write(str, conn->user->auth_token); + str_append_tabescaped(str, conn->user->auth_token); str_append_c(str, '\n'); if (o_stream_send(conn->output, str_data(str), str_len(str)) < 0) { i_warning("Error sending handshake to imap-urlauth server: %m"); diff -r 9bff478f81fd -r 002e0a120c2a src/lib-master/master-instance.c --- a/src/lib-master/master-instance.c Sun Sep 16 00:52:39 2012 +0300 +++ b/src/lib-master/master-instance.c Sun Sep 16 00:56:51 2012 +0300 @@ -137,12 +137,12 @@ From dovecot at dovecot.org Sun Sep 16 01:02:19 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 01:02:19 +0300 Subject: dovecot-2.2: imap: Assert-crashfix for URLFETCH command. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9d684784de9b changeset: 15069:9d684784de9b user: Timo Sirainen date: Sun Sep 16 01:02:10 2012 +0300 description: imap: Assert-crashfix for URLFETCH command. diffstat: src/imap/imap-client.c | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diffs (40 lines): diff -r 002e0a120c2a -r 9d684784de9b src/imap/imap-client.c --- a/src/imap/imap-client.c Sun Sep 16 00:56:51 2012 +0300 +++ b/src/imap/imap-client.c Sun Sep 16 01:02:10 2012 +0300 @@ -609,6 +609,14 @@ return cmd; } +static void client_add_missing_io(struct client *client) +{ + if (client->io == NULL && !client->disconnected) { + client->io = io_add(client->fd_in, + IO_READ, client_input, client); + } +} + void client_command_free(struct client_command_context **_cmd) { struct client_command_context *cmd = *_cmd; @@ -661,15 +669,12 @@ unhandled commands since we may not be executing from client_input or client_output. */ if (state == CLIENT_COMMAND_STATE_WAIT_EXTERNAL && - !client->disconnected && client->to_delayed_input == NULL) - client->to_delayed_input = timeout_add(0, client_input, client); -} - -static void client_add_missing_io(struct client *client) -{ - if (client->io == NULL && !client->disconnected) { - client->io = io_add(client->fd_in, - IO_READ, client_input, client); + !client->disconnected) { + client_add_missing_io(client); + if (client->to_delayed_input == NULL) { + client->to_delayed_input = + timeout_add(0, client_input, client); + } } } From dovecot at dovecot.org Sun Sep 16 01:06:12 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 01:06:12 +0300 Subject: dovecot-2.2: lib-imap-storage: imap_msgpart_size() should return... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8e29272c35fa changeset: 15070:8e29272c35fa user: Timo Sirainen date: Sun Sep 16 01:06:04 2012 +0300 description: lib-imap-storage: imap_msgpart_size() should return size as uoff_t, not size_t diffstat: src/imap/imap-fetch-body.c | 2 +- src/lib-imap-storage/imap-msgpart.c | 2 +- src/lib-imap-storage/imap-msgpart.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diffs (36 lines): diff -r 9d684784de9b -r 8e29272c35fa src/imap/imap-fetch-body.c --- a/src/imap/imap-fetch-body.c Sun Sep 16 01:02:10 2012 +0300 +++ b/src/imap/imap-fetch-body.c Sun Sep 16 01:06:04 2012 +0300 @@ -155,7 +155,7 @@ struct imap_fetch_body_data *body) { string_t *str; - size_t size; + uoff_t size; if (mail == NULL) { imap_msgpart_free(&body->msgpart); diff -r 9d684784de9b -r 8e29272c35fa src/lib-imap-storage/imap-msgpart.c --- a/src/lib-imap-storage/imap-msgpart.c Sun Sep 16 01:02:10 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart.c Sun Sep 16 01:06:04 2012 +0300 @@ -701,7 +701,7 @@ } int imap_msgpart_size(struct mail *mail, struct imap_msgpart *msgpart, - size_t *size_r) + uoff_t *size_r) { struct imap_msgpart_open_result result; struct message_part *part; diff -r 9d684784de9b -r 8e29272c35fa src/lib-imap-storage/imap-msgpart.h --- a/src/lib-imap-storage/imap-msgpart.h Sun Sep 16 01:02:10 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart.h Sun Sep 16 01:06:04 2012 +0300 @@ -43,7 +43,7 @@ struct imap_msgpart_open_result *result_r); /* Return msgpart's size without actually opening the stream (if possible). */ int imap_msgpart_size(struct mail *mail, struct imap_msgpart *msgpart, - size_t *size_r); + uoff_t *size_r); /* Return msgpart's IMAP BODYPARTSTRUCTURE */ int imap_msgpart_bodypartstructure(struct mail *mail, From dovecot at dovecot.org Sun Sep 16 01:08:19 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 01:08:19 +0300 Subject: dovecot-2.2: Makefile: Fixed imap-urlauth library dependencies Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/97079269a703 changeset: 15071:97079269a703 user: Timo Sirainen date: Sun Sep 16 01:08:11 2012 +0300 description: Makefile: Fixed imap-urlauth library dependencies diffstat: src/imap-urlauth/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 8e29272c35fa -r 97079269a703 src/imap-urlauth/Makefile.am --- a/src/imap-urlauth/Makefile.am Sun Sep 16 01:06:04 2012 +0300 +++ b/src/imap-urlauth/Makefile.am Sun Sep 16 01:08:11 2012 +0300 @@ -17,7 +17,7 @@ $(LIBDOVECOT) \ $(SSL_LIBS) imap_urlauth_login_DEPENDENCIES = \ - $(LIBDOVECOT_LOGIN) \ + $(LIBDOVECOT_LOGIN_DEPS) \ $(LIBDOVECOT_DEPS) imap_urlauth_login_SOURCES = \ From dovecot at dovecot.org Sun Sep 16 04:05:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 04:05:23 +0300 Subject: dovecot-2.2: Makefile: Fixed dependencies for imap-urlauth Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2fe6d09e68d4 changeset: 15072:2fe6d09e68d4 user: Timo Sirainen date: Sun Sep 16 04:05:13 2012 +0300 description: Makefile: Fixed dependencies for imap-urlauth diffstat: src/imap-urlauth/Makefile.am | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diffs (17 lines): diff -r 97079269a703 -r 2fe6d09e68d4 src/imap-urlauth/Makefile.am --- a/src/imap-urlauth/Makefile.am Sun Sep 16 01:08:11 2012 +0300 +++ b/src/imap-urlauth/Makefile.am Sun Sep 16 04:05:13 2012 +0300 @@ -63,11 +63,10 @@ imap_urlauth_worker_LDFLAGS = -export-dynamic urlauth_libs = \ - $(LIBDOVECOT_STORAGE) \ $(top_builddir)/src/lib-imap-urlauth/libimap-urlauth.la -imap_urlauth_worker_LDADD = $(urlauth_libs) $(LIBDOVECOT) $(MODULE_LIBS) -imap_urlauth_worker_DEPENDENCIES = $(urlauth_libs) $(LIBDOVECOT_DEPS) +imap_urlauth_worker_LDADD = $(urlauth_libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT) $(MODULE_LIBS) +imap_urlauth_worker_DEPENDENCIES = $(urlauth_libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS) imap_urlauth_worker_SOURCES = \ imap-urlauth-worker.c \ From dovecot at dovecot.org Sun Sep 16 04:16:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 04:16:18 +0300 Subject: dovecot-2.2: Makefile: Link libdovecot-ssl with libdovecot. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8b0d967e61cf changeset: 15073:8b0d967e61cf user: Timo Sirainen date: Sun Sep 16 04:16:07 2012 +0300 description: Makefile: Link libdovecot-ssl with libdovecot. This fixes linking with e.g. OSX. diffstat: src/lib-dovecot/Makefile.am | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (19 lines): diff -r 2fe6d09e68d4 -r 8b0d967e61cf src/lib-dovecot/Makefile.am --- a/src/lib-dovecot/Makefile.am Sun Sep 16 04:05:13 2012 +0300 +++ b/src/lib-dovecot/Makefile.am Sun Sep 16 04:16:07 2012 +0300 @@ -26,13 +26,14 @@ $(LTLIBICONV) libdovecot_ssl_la_LIBADD = \ + libdovecot.la \ ../lib/liblib.la \ $(MODULE_LIBS) \ $(ssl_libs) \ $(SSL_LIBS) libdovecot_la_DEPENDENCIES = $(libs) -libdovecot_ssl_la_DEPENDENCIES = $(ssl_libs) +libdovecot_ssl_la_DEPENDENCIES = $(ssl_libs) libdovecot.la libdovecot_la_LDFLAGS = -export-dynamic libdovecot_ssl_la_LDFLAGS = -export-dynamic From dovecot at dovecot.org Sun Sep 16 15:40:34 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 15:40:34 +0300 Subject: dovecot-2.2: Makefile: Fixed test program dependencies Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/00df9f4192ad changeset: 15074:00df9f4192ad user: Timo Sirainen date: Sun Sep 16 15:40:10 2012 +0300 description: Makefile: Fixed test program dependencies Explicit dependencies on .o or .lo files didn't seem to work properly and with high enough make -j value the build failed. Depending on the entire library guarantees that all the individual .o files have been built. diffstat: src/anvil/Makefile.am | 2 +- src/auth/Makefile.am | 2 +- src/director/Makefile.am | 2 +- src/doveadm/dsync/Makefile.am | 4 +- src/lib-dict/Makefile.am | 4 +- src/lib-imap/Makefile.am | 26 +++++++------ src/lib-index/Makefile.am | 24 ++++++----- src/lib-mail/Makefile.am | 76 ++++++++++++++++++++------------------ src/lib-storage/Makefile.am | 4 +- src/plugins/fts-squat/Makefile.am | 4 +- src/plugins/fts/Makefile.am | 4 +- 11 files changed, 79 insertions(+), 73 deletions(-) diffs (truncated from 318 to 300 lines): diff -r 8b0d967e61cf -r 00df9f4192ad src/anvil/Makefile.am --- a/src/anvil/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/anvil/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -38,7 +38,7 @@ test_penalty_SOURCES = test-penalty.c test_penalty_LDADD = penalty.o $(test_libs) -test_penalty_DEPENDENCIES = penalty.o $(test_libs) +test_penalty_DEPENDENCIES = $(pkglibexec_PROGRAMS) $(test_libs) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/auth/Makefile.am --- a/src/auth/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/auth/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -203,7 +203,7 @@ test_auth_cache_SOURCES = test-auth-cache.c test_auth_cache_LDADD = auth-cache.o $(test_libs) -test_auth_cache_DEPENDENCIES = auth-cache.o $(test_libs) +test_auth_cache_DEPENDENCIES = $(pkglibexec_PROGRAMS) $(test_libs) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/director/Makefile.am --- a/src/director/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/director/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -58,7 +58,7 @@ test_user_directory_SOURCES = test-user-directory.c test_user_directory_LDADD = user-directory.o $(test_libs) -test_user_directory_DEPENDENCIES = user-directory.o $(test_libs) +test_user_directory_DEPENDENCIES = $(pkglibexec_PROGRAMS) $(test_libs) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/doveadm/dsync/Makefile.am --- a/src/doveadm/dsync/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/doveadm/dsync/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -60,8 +60,8 @@ ../../lib/liblib.la test_dsync_mailbox_tree_sync_SOURCES = test-dsync-mailbox-tree-sync.c -test_dsync_mailbox_tree_sync_LDADD = dsync-mailbox-tree-sync.lo dsync-mailbox-tree.lo $(test_libs) -test_dsync_mailbox_tree_sync_DEPENDENCIES = dsync-mailbox-tree-sync.lo dsync-mailbox-tree.lo $(test_libs) +test_dsync_mailbox_tree_sync_LDADD = dsync-mailbox-tree-sync.o dsync-mailbox-tree.o $(test_libs) +test_dsync_mailbox_tree_sync_DEPENDENCIES = $(noinst_LIBRARIES) $(test_libs) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/lib-dict/Makefile.am --- a/src/lib-dict/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/lib-dict/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -84,8 +84,8 @@ ../lib/liblib.la test_dict_SOURCES = test-dict.c -test_dict_LDADD = dict.lo $(test_libs) -test_dict_DEPENDENCIES = dict.lo $(test_libs) +test_dict_LDADD = dict.o $(test_libs) +test_dict_DEPENDENCIES = $(noinst_LTLIBRARIES) $(test_libs) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/lib-imap/Makefile.am --- a/src/lib-imap/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/lib-imap/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -54,29 +54,31 @@ ../lib-test/libtest.la \ ../lib/liblib.la +test_deps = $(noinst_LTLIBRARIES) $(test_libs) + test_imap_bodystructure_SOURCES = test-imap-bodystructure.c -test_imap_bodystructure_LDADD = imap-bodystructure.lo imap-envelope.lo imap-quote.lo imap-parser.lo imap-arg.lo ../lib-mail/libmail.la $(test_libs) -test_imap_bodystructure_DEPENDENCIES = imap-bodystructure.lo imap-envelope.lo imap-quote.lo imap-parser.lo imap-arg.lo ../lib-mail/libmail.la $(test_libs) +test_imap_bodystructure_LDADD = imap-bodystructure.o imap-envelope.o imap-quote.o imap-parser.o imap-arg.o ../lib-mail/libmail.la $(test_libs) +test_imap_bodystructure_DEPENDENCIES = $(test_deps) ../lib-mail/libmail.la test_imap_match_SOURCES = test-imap-match.c -test_imap_match_LDADD = imap-match.lo $(test_libs) -test_imap_match_DEPENDENCIES = imap-match.lo $(test_libs) +test_imap_match_LDADD = imap-match.o $(test_libs) +test_imap_match_DEPENDENCIES = $(test_deps) test_imap_parser_SOURCES = test-imap-parser.c -test_imap_parser_LDADD = imap-parser.lo imap-arg.lo $(test_libs) -test_imap_parser_DEPENDENCIES = imap-parser.lo imap-arg.lo $(test_libs) +test_imap_parser_LDADD = imap-parser.o imap-arg.o $(test_libs) +test_imap_parser_DEPENDENCIES = $(test_deps) test_imap_url_SOURCES = test-imap-url.c -test_imap_url_LDADD = imap-url.lo $(test_libs) -test_imap_url_DEPENDENCIES = imap-url.lo $(test_libs) +test_imap_url_LDADD = imap-url.o $(test_libs) +test_imap_url_DEPENDENCIES = $(test_deps) test_imap_utf7_SOURCES = test-imap-utf7.c -test_imap_utf7_LDADD = imap-utf7.lo $(test_libs) -test_imap_utf7_DEPENDENCIES = imap-utf7.lo $(test_libs) +test_imap_utf7_LDADD = imap-utf7.o $(test_libs) +test_imap_utf7_DEPENDENCIES = $(test_deps) test_imap_util_SOURCES = test-imap-util.c -test_imap_util_LDADD = imap-util.lo imap-arg.lo $(test_libs) -test_imap_util_DEPENDENCIES = imap-util.lo imap-arg.lo $(test_libs) +test_imap_util_LDADD = imap-util.o imap-arg.o $(test_libs) +test_imap_util_DEPENDENCIES = $(test_deps) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/lib-index/Makefile.am --- a/src/lib-index/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/lib-index/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -70,29 +70,31 @@ noinst_PROGRAMS = $(test_programs) test_libs = \ - mail-index-util.lo \ + mail-index-util.o \ ../lib-test/libtest.la \ ../lib/liblib.la +test_deps = $(noinst_LTLIBRARIES) $(test_libs) + test_mail_index_sync_ext_SOURCES = test-mail-index-sync-ext.c -test_mail_index_sync_ext_LDADD = mail-index-sync-ext.lo $(test_libs) -test_mail_index_sync_ext_DEPENDENCIES = mail-index-sync-ext.lo $(test_libs) +test_mail_index_sync_ext_LDADD = mail-index-sync-ext.o $(test_libs) +test_mail_index_sync_ext_DEPENDENCIES = $(test_deps) test_mail_index_transaction_finish_SOURCES = test-mail-index-transaction-finish.c -test_mail_index_transaction_finish_LDADD = mail-index-transaction-finish.lo $(test_libs) -test_mail_index_transaction_finish_DEPENDENCIES = mail-index-transaction-finish.lo $(test_libs) +test_mail_index_transaction_finish_LDADD = mail-index-transaction-finish.o $(test_libs) +test_mail_index_transaction_finish_DEPENDENCIES = $(test_deps) test_mail_index_transaction_update_SOURCES = test-mail-index-transaction-update.c -test_mail_index_transaction_update_LDADD = mail-index-transaction-update.lo $(test_libs) -test_mail_index_transaction_update_DEPENDENCIES = mail-index-transaction-update.lo $(test_libs) +test_mail_index_transaction_update_LDADD = mail-index-transaction-update.o $(test_libs) +test_mail_index_transaction_update_DEPENDENCIES = $(test_deps) test_mail_transaction_log_append_SOURCES = test-mail-transaction-log-append.c -test_mail_transaction_log_append_LDADD = mail-transaction-log-append.lo $(test_libs) -test_mail_transaction_log_append_DEPENDENCIES = mail-transaction-log-append.lo $(test_libs) +test_mail_transaction_log_append_LDADD = mail-transaction-log-append.o $(test_libs) +test_mail_transaction_log_append_DEPENDENCIES = $(test_deps) test_mail_transaction_log_view_SOURCES = test-mail-transaction-log-view.c -test_mail_transaction_log_view_LDADD = mail-transaction-log-view.lo $(test_libs) -test_mail_transaction_log_view_DEPENDENCIES = mail-transaction-log-view.lo $(test_libs) +test_mail_transaction_log_view_LDADD = mail-transaction-log-view.o $(test_libs) +test_mail_transaction_log_view_DEPENDENCIES = $(test_deps) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/lib-mail/Makefile.am --- a/src/lib-mail/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/lib-mail/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -87,76 +87,78 @@ ../lib-test/libtest.la \ ../lib/liblib.la +test_deps = $(noinst_LTLIBRARIES) $(test_libs) + test_istream_dot_SOURCES = test-istream-dot.c -test_istream_dot_LDADD = istream-dot.lo $(test_libs) -test_istream_dot_DEPENDENCIES = istream-dot.lo $(test_libs) +test_istream_dot_LDADD = istream-dot.o $(test_libs) +test_istream_dot_DEPENDENCIES = $(test_deps) test_istream_qp_decoder_SOURCES = test-istream-qp-decoder.c -test_istream_qp_decoder_LDADD = istream-qp-decoder.lo quoted-printable.lo $(test_libs) -test_istream_qp_decoder_DEPENDENCIES = istream-qp-decoder.lo quoted-printable.lo $(test_libs) +test_istream_qp_decoder_LDADD = istream-qp-decoder.o quoted-printable.o $(test_libs) +test_istream_qp_decoder_DEPENDENCIES = $(test_deps) message_parser_objects = \ - message-parser.lo \ - message-header-parser.lo \ - message-size.lo \ - rfc822-parser.lo \ - rfc2231-parser.lo + message-parser.o \ + message-header-parser.o \ + message-size.o \ + rfc822-parser.o \ + rfc2231-parser.o test_istream_binary_converter_SOURCES = test-istream-binary-converter.c -test_istream_binary_converter_LDADD = istream-binary-converter.lo $(message_parser_objects) $(test_libs) -test_istream_binary_converter_DEPENDENCIES = istream-binary-converter.lo $(message_parser_objects) $(test_libs) +test_istream_binary_converter_LDADD = istream-binary-converter.o $(message_parser_objects) $(test_libs) +test_istream_binary_converter_DEPENDENCIES = $(test_deps) test_istream_attachment_SOURCES = test-istream-attachment.c -test_istream_attachment_LDADD = istream-attachment-extractor.lo istream-attachment-connector.lo $(message_parser_objects) $(test_libs) -test_istream_attachment_DEPENDENCIES = istream-attachment-extractor.lo istream-attachment-connector.lo $(message_parser_objects) $(test_libs) +test_istream_attachment_LDADD = istream-attachment-extractor.o istream-attachment-connector.o $(message_parser_objects) $(test_libs) +test_istream_attachment_DEPENDENCIES = $(test_deps) test_istream_header_filter_SOURCES = test-istream-header-filter.c -test_istream_header_filter_LDADD = istream-header-filter.lo message-header-parser.lo $(test_libs) -test_istream_header_filter_DEPENDENCIES = istream-header-filter.lo message-header-parser.lo $(test_libs) +test_istream_header_filter_LDADD = istream-header-filter.o message-header-parser.o $(test_libs) +test_istream_header_filter_DEPENDENCIES = $(test_deps) test_mbox_from_SOURCES = test-mbox-from.c -test_mbox_from_LDADD = mbox-from.lo $(test_libs) -test_mbox_from_DEPENDENCIES = mbox-from.lo $(test_libs) +test_mbox_from_LDADD = mbox-from.o $(test_libs) +test_mbox_from_DEPENDENCIES = $(test_deps) test_message_address_SOURCES = test-message-address.c -test_message_address_LDADD = message-address.lo rfc822-parser.lo $(test_libs) -test_message_address_DEPENDENCIES = message-address.lo rfc822-parser.lo $(test_libs) +test_message_address_LDADD = message-address.o rfc822-parser.o $(test_libs) +test_message_address_DEPENDENCIES = $(test_deps) test_message_date_SOURCES = test-message-date.c -test_message_date_LDADD = message-date.lo rfc822-parser.lo $(test_libs) -test_message_date_DEPENDENCIES = message-date.lo rfc822-parser.lo $(test_libs) +test_message_date_LDADD = message-date.o rfc822-parser.o $(test_libs) +test_message_date_DEPENDENCIES = $(test_deps) test_message_decoder_SOURCES = test-message-decoder.c -test_message_decoder_LDADD = message-decoder.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs) -test_message_decoder_DEPENDENCIES = message-decoder.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs) +test_message_decoder_LDADD = message-decoder.o rfc822-parser.o rfc2231-parser.o $(test_libs) +test_message_decoder_DEPENDENCIES = $(test_deps) test_message_header_decode_SOURCES = test-message-header-decode.c -test_message_header_decode_LDADD = message-header-decode.lo quoted-printable.lo $(test_libs) -test_message_header_decode_DEPENDENCIES = message-header-decode.lo quoted-printable.lo $(test_libs) +test_message_header_decode_LDADD = message-header-decode.o quoted-printable.o $(test_libs) +test_message_header_decode_DEPENDENCIES = $(test_deps) test_message_header_encode_SOURCES = test-message-header-encode.c -test_message_header_encode_LDADD = message-header-encode.lo $(test_libs) -test_message_header_encode_DEPENDENCIES = message-header-encode.lo $(test_libs) +test_message_header_encode_LDADD = message-header-encode.o $(test_libs) +test_message_header_encode_DEPENDENCIES = $(test_deps) test_message_header_parser_SOURCES = test-message-header-parser.c -test_message_header_parser_LDADD = message-header-parser.lo $(test_libs) -test_message_header_parser_DEPENDENCIES = message-header-parser.lo $(test_libs) +test_message_header_parser_LDADD = message-header-parser.o $(test_libs) +test_message_header_parser_DEPENDENCIES = $(test_deps) test_message_id_SOURCES = test-message-id.c -test_message_id_LDADD = message-id.lo rfc822-parser.lo $(test_libs) -test_message_id_DEPENDENCIES = message-id.lo rfc822-parser.lo $(test_libs) +test_message_id_LDADD = message-id.o rfc822-parser.o $(test_libs) +test_message_id_DEPENDENCIES = $(test_deps) test_message_parser_SOURCES = test-message-parser.c -test_message_parser_LDADD = message-parser.lo message-header-parser.lo message-size.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs) -test_message_parser_DEPENDENCIES = message-parser.lo message-header-parser.lo message-size.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs) +test_message_parser_LDADD = message-parser.o message-header-parser.o message-size.o rfc822-parser.o rfc2231-parser.o $(test_libs) +test_message_parser_DEPENDENCIES = $(test_deps) test_quoted_printable_SOURCES = test-quoted-printable.c -test_quoted_printable_LDADD = quoted-printable.lo $(test_libs) -test_quoted_printable_DEPENDENCIES = quoted-printable.lo $(test_libs) +test_quoted_printable_LDADD = quoted-printable.o $(test_libs) +test_quoted_printable_DEPENDENCIES = $(test_deps) test_rfc2231_parser_SOURCES = test-rfc2231-parser.c -test_rfc2231_parser_LDADD = rfc2231-parser.lo rfc822-parser.lo $(test_libs) -test_rfc2231_parser_DEPENDENCIES = rfc2231-parser.lo rfc822-parser.lo $(test_libs) +test_rfc2231_parser_LDADD = rfc2231-parser.o rfc822-parser.o $(test_libs) +test_rfc2231_parser_DEPENDENCIES = $(test_deps) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/lib-storage/Makefile.am --- a/src/lib-storage/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/lib-storage/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -102,8 +102,8 @@ $(top_builddir)/src/lib/liblib.la test_mailbox_get_SOURCES = test-mailbox-get.c -test_mailbox_get_LDADD = mailbox-get.lo $(test_libs) -test_mailbox_get_DEPENDENCIES = mailbox-get.lo $(test_libs) +test_mailbox_get_LDADD = mailbox-get.o $(test_libs) +test_mailbox_get_DEPENDENCIES = $(noinst_LTLIBRARIES) $(test_libs) check: check-am check-test check-test: all-am diff -r 8b0d967e61cf -r 00df9f4192ad src/plugins/fts-squat/Makefile.am --- a/src/plugins/fts-squat/Makefile.am Sun Sep 16 04:16:07 2012 +0300 +++ b/src/plugins/fts-squat/Makefile.am Sun Sep 16 15:40:10 2012 +0300 @@ -34,8 +34,8 @@ squat-test.c common_objects = \ - squat-trie.lo \ - squat-uidlist.lo + squat-trie.o \ From dovecot at dovecot.org Sun Sep 16 16:02:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:02:59 +0300 Subject: dovecot-2.2: lib-dict: Previous API change broke dict_init() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/009d19d5f0f1 changeset: 15075:009d19d5f0f1 user: Stephan Bosch date: Sun Sep 16 16:02:11 2012 +0300 description: lib-dict: Previous API change broke dict_init() diffstat: src/lib-dict/dict-file.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 00df9f4192ad -r 009d19d5f0f1 src/lib-dict/dict-file.c --- a/src/lib-dict/dict-file.c Sun Sep 16 15:40:10 2012 +0300 +++ b/src/lib-dict/dict-file.c Sun Sep 16 16:02:11 2012 +0300 @@ -81,7 +81,7 @@ hash_table_create(&dict->hash, dict->hash_pool, 0, str_hash, strcmp); dict->fd = -1; *dict_r = &dict->dict; - return -1; + return 0; } static void file_dict_deinit(struct dict *_dict) From dovecot at dovecot.org Sun Sep 16 16:02:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:02:59 +0300 Subject: dovecot-2.2: imap-urlauth: Treat internal errors in URL fetching... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c69ee1de5f70 changeset: 15077:c69ee1de5f70 user: Stephan Bosch date: Sun Sep 16 16:02:18 2012 +0300 description: imap-urlauth: Treat internal errors in URL fetching differently from invalid URLs. diffstat: src/imap-urlauth/imap-urlauth-worker.c | 4 ++ src/lib-imap-urlauth/imap-urlauth-fetch.c | 50 +++++++++++++++++------------- 2 files changed, 33 insertions(+), 21 deletions(-) diffs (102 lines): diff -r 7e1f0146169f -r c69ee1de5f70 src/imap-urlauth/imap-urlauth-worker.c --- a/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:15 2012 +0300 +++ b/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:18 2012 +0300 @@ -377,6 +377,8 @@ if (imap_msgpart_url_get_bodypartstructure(client->url, bpstruct_r, &error) <= 0) { + if (ret < 0) + return -1; *errormsg_r = t_strdup_printf( "Failed to read URLAUTH \"%s\": %s", url, error); if (client->debug) @@ -389,6 +391,8 @@ if ((url_flags & IMAP_URLAUTH_FETCH_FLAG_BODY) != 0 || (url_flags & IMAP_URLAUTH_FETCH_FLAG_BINARY) != 0) { if (imap_msgpart_url_read_part(client->url, &mpresult, &error) <= 0) { + if (ret < 0) + return -1; *errormsg_r = t_strdup_printf( "Failed to read URLAUTH \"%s\": %s", url, error); if (client->debug) diff -r 7e1f0146169f -r c69ee1de5f70 src/lib-imap-urlauth/imap-urlauth-fetch.c --- a/src/lib-imap-urlauth/imap-urlauth-fetch.c Sun Sep 16 16:02:15 2012 +0300 +++ b/src/lib-imap-urlauth/imap-urlauth-fetch.c Sun Sep 16 16:02:18 2012 +0300 @@ -173,16 +173,13 @@ ret = imap_urlauth_fetch_parsed(ufetch->uctx, imap_url, &mpurl, &error_code, &error); } - if (ret < 0) { - (void)ufetch->callback(NULL, TRUE, ufetch->context); - imap_urlauth_fetch_fail(ufetch); - return; - } - if (ret == 0) { - errormsg = t_strdup_printf("Failed to fetch URLAUTH \"%s\": %s", - url, error); - if (debug) - i_debug("%s", errormsg); + if (ret <= 0) { + if (ret == 0) { + errormsg = t_strdup_printf("Failed to fetch URLAUTH \"%s\": %s", + url, error); + if (debug) + i_debug("%s", errormsg); + } success = FALSE; } @@ -191,12 +188,14 @@ imap_msgpart_url_set_decode_to_binary(mpurl); if (success && (url_flags & IMAP_URLAUTH_FETCH_FLAG_BODYPARTSTRUCTURE) != 0) { - if (imap_msgpart_url_get_bodypartstructure - (mpurl, &bpstruct, &error) <= 0) { - errormsg = t_strdup_printf - ("Failed to read URLAUTH \"%s\": %s", url, error); - if (debug) - i_debug("%s", errormsg); + ret = imap_msgpart_url_get_bodypartstructure(mpurl, &bpstruct, &error); + if (ret <= 0) { + if (ret == 0) { + errormsg = t_strdup_printf + ("Failed to read URLAUTH \"%s\": %s", url, error); + if (debug) + i_debug("%s", errormsg); + } success = FALSE; } } @@ -206,11 +205,14 @@ mpresult.input = NULL; if (success && ((url_flags & IMAP_URLAUTH_FETCH_FLAG_BODY) != 0 || (url_flags & IMAP_URLAUTH_FETCH_FLAG_BINARY) != 0)) { - if (imap_msgpart_url_read_part(mpurl, &mpresult, &error) <= 0) { - errormsg = t_strdup_printf - ("Failed to read URLAUTH \"%s\": %s", url, error); - if (debug) - i_debug("%s", errormsg); + ret = imap_msgpart_url_read_part(mpurl, &mpresult, &error); + if (ret <= 0) { + if (ret == 0) { + errormsg = t_strdup_printf + ("Failed to read URLAUTH \"%s\": %s", url, error); + if (debug) + i_debug("%s", errormsg); + } success = FALSE; } } @@ -227,6 +229,12 @@ } } + if (!success && ret < 0) { + (void)ufetch->callback(NULL, TRUE, ufetch->context); + imap_urlauth_fetch_fail(ufetch); + return; + } + memset(&reply, 0, sizeof(reply)); reply.url = url; reply.flags = url_flags; From dovecot at dovecot.org Sun Sep 16 16:02:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:02:59 +0300 Subject: dovecot-2.2: imap-urlauth: Fixes to handling anonymous user Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7e1f0146169f changeset: 15076:7e1f0146169f user: Stephan Bosch date: Sun Sep 16 16:02:15 2012 +0300 description: imap-urlauth: Fixes to handling anonymous user diffstat: src/imap-urlauth/imap-urlauth-worker.c | 4 +++- src/imap/imap-client.c | 4 ++-- src/lib-imap-urlauth/imap-urlauth-private.h | 2 ++ src/lib-imap-urlauth/imap-urlauth.c | 17 ++++++++++------- src/lib-imap-urlauth/imap-urlauth.h | 1 + 5 files changed, 18 insertions(+), 10 deletions(-) diffs (131 lines): diff -r 009d19d5f0f1 -r 7e1f0146169f src/imap-urlauth/imap-urlauth-worker.c --- a/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:11 2012 +0300 +++ b/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:15 2012 +0300 @@ -73,9 +73,9 @@ unsigned int debug:1; unsigned int finished:1; + unsigned int waiting_input:1; unsigned int version_received:1; unsigned int access_received:1; - unsigned int waiting_input:1; unsigned int access_anonymous:1; }; @@ -639,6 +639,7 @@ config.url_host = set->imap_urlauth_host; config.url_port = set->imap_urlauth_port; config.access_user = client->access_user; + config.access_anonymous = client->access_anonymous; config.access_applications = (const void *)array_get(&client->access_apps, &count); @@ -873,6 +874,7 @@ client->access_user = i_strdup(*args); client->access_anonymous = FALSE; } else { + client->access_user = i_strdup("anonymous"); client->access_anonymous = TRUE; } i_set_failure_prefix(t_strdup_printf("imap-urlauth[%s](%s): ", my_pid, diff -r 009d19d5f0f1 -r 7e1f0146169f src/imap/imap-client.c --- a/src/imap/imap-client.c Sun Sep 16 16:02:11 2012 +0300 +++ b/src/imap/imap-client.c Sun Sep 16 16:02:15 2012 +0300 @@ -50,8 +50,8 @@ config.socket_path = t_strconcat(client->user->set->base_dir, "/"IMAP_URLAUTH_SOCKET_NAME, NULL); config.session_id = client->session_id; - config.access_user = client->user->anonymous ? NULL : - client->user->username; + config.access_anonymous = client->user->anonymous; + config.access_user = client->user->username; return imap_urlauth_init(client->user, &config, &client->urlauth_ctx); } diff -r 009d19d5f0f1 -r 7e1f0146169f src/lib-imap-urlauth/imap-urlauth-private.h --- a/src/lib-imap-urlauth/imap-urlauth-private.h Sun Sep 16 16:02:11 2012 +0300 +++ b/src/lib-imap-urlauth/imap-urlauth-private.h Sun Sep 16 16:02:15 2012 +0300 @@ -13,6 +13,8 @@ char *access_user; const char **access_applications; + + unsigned int access_anonymous:1; }; #endif diff -r 009d19d5f0f1 -r 7e1f0146169f src/lib-imap-urlauth/imap-urlauth.c --- a/src/lib-imap-urlauth/imap-urlauth.c Sun Sep 16 16:02:11 2012 +0300 +++ b/src/lib-imap-urlauth/imap-urlauth.c Sun Sep 16 16:02:15 2012 +0300 @@ -45,8 +45,11 @@ uctx->url_host = i_strdup(my_hostdomain()); uctx->url_port = config->url_port; - if (config->access_user != NULL && *config->access_user != '\0') + if (config->access_anonymous) + uctx->access_user = i_strdup("anonymous"); + else uctx->access_user = i_strdup(config->access_user); + uctx->access_anonymous = config->access_anonymous; if (config->access_applications != NULL && *config->access_applications != NULL) { uctx->access_applications = @@ -160,9 +163,9 @@ if (strcasecmp(url->uauth_access_application, "user") == 0) { /* user+ */ - if (uctx->access_user == NULL || + if (uctx->access_anonymous || strcasecmp(url->uauth_access_user, uctx->access_user) != 0) { - if (uctx->access_user == NULL) { + if (uctx->access_anonymous) { *error_r = t_strdup_printf( "No 'user+%s' access allowed for anonymous user", url->uauth_access_user); @@ -174,7 +177,7 @@ } } else if (strcasecmp(url->uauth_access_application, "authuser") == 0) { /* authuser */ - if (uctx->access_user == NULL) { + if (uctx->access_anonymous) { *error_r = "No 'authuser' access allowed for anonymous user"; return FALSE; } @@ -185,7 +188,7 @@ const char *userid = url->uauth_access_user == NULL ? "" : t_strdup_printf("+%s", url->uauth_access_user); - if (uctx->access_user == NULL) { + if (uctx->access_anonymous) { *error_r = t_strdup_printf( "No '%s%s' access allowed for anonymous user", url->uauth_access_application, userid); @@ -269,7 +272,7 @@ *error_r = "Invalid URL: Missing user name"; return 0; } - if (strcmp(url->userid, user->username) != 0) { + if (user->anonymous || strcmp(url->userid, user->username) != 0) { *error_r = t_strdup_printf( "Not permitted to generate URLAUTH for user %s", url->userid); @@ -373,7 +376,7 @@ } /* validate target user */ - if (strcmp(url->userid, user->username) != 0) { + if (user->anonymous || strcmp(url->userid, user->username) != 0) { *error_r = t_strdup_printf("Not permitted to fetch URLAUTH for user %s", url->userid); *error_code_r = MAIL_ERROR_PARAMS; diff -r 009d19d5f0f1 -r 7e1f0146169f src/lib-imap-urlauth/imap-urlauth.h --- a/src/lib-imap-urlauth/imap-urlauth.h Sun Sep 16 16:02:11 2012 +0300 +++ b/src/lib-imap-urlauth/imap-urlauth.h Sun Sep 16 16:02:15 2012 +0300 @@ -18,6 +18,7 @@ const char *access_user; const char *const *access_applications; + bool access_anonymous; }; int imap_urlauth_init(struct mail_user *user, From dovecot at dovecot.org Sun Sep 16 16:02:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:02:59 +0300 Subject: dovecot-2.2: imap-urlauth: Fixed crashes when destroying client Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dc1db2eedbb1 changeset: 15078:dc1db2eedbb1 user: Stephan Bosch date: Sun Sep 16 16:02:22 2012 +0300 description: imap-urlauth: Fixed crashes when destroying client diffstat: src/imap-urlauth/imap-urlauth-worker.c | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-) diffs (89 lines): diff -r c69ee1de5f70 -r dc1db2eedbb1 src/imap-urlauth/imap-urlauth-worker.c --- a/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:18 2012 +0300 +++ b/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:22 2012 +0300 @@ -87,7 +87,7 @@ static void client_destroy(struct client *client); static void client_abort(struct client *client, const char *reason); -static void client_run_url(struct client *client); +static int client_run_url(struct client *client); static void client_input(struct client *client); static bool client_handle_input(struct client *client); static int client_output(struct client *client); @@ -226,7 +226,7 @@ /* deinitialize url */ i_stream_close(client->input); o_stream_close(client->output); - client_run_url(client); + (void)client_run_url(client); i_assert(client->url == NULL); } @@ -277,7 +277,7 @@ master_service_client_connection_destroyed(master_service); } -static void client_run_url(struct client *client) +static int client_run_url(struct client *client) { const unsigned char *data; size_t size; @@ -292,20 +292,21 @@ if ((ret = o_stream_flush(client->output)) < 0) break; if (ret == 0) - return; + return 0; } } if (client->output->closed || ret < 0) { imap_msgpart_url_free(&client->url); - client_destroy(client); - return; + return -1; } if (client->msg_part_input->eof) { o_stream_send(client->output, "\n", 1); imap_msgpart_url_free(&client->url); + return 1; } + return 0; } static void clients_destroy_all(void) @@ -480,7 +481,11 @@ "of %smessage data", client->msg_part_size, (binary_with_nuls ? "binary " : "")); } - client_run_url(client); + if (client_run_url(client) < 0) { + client_abort(client, + "Session aborted: Fatal failure while transfering URL"); + return 0; + } } if (client->url != NULL) { @@ -740,7 +745,10 @@ timeout_reset(client->to_idle); if (client->url != NULL) { - client_run_url(client); + if (client_run_url(client) < 0) { + client_destroy(client); + return 1; + } if (client->url == NULL && client->waiting_input) { if (!client_handle_input(client)) { @@ -782,7 +790,7 @@ if (ret == 0) { /* unexpectedly disconnected */ client_destroy(client); - return -1; + return 0; } else if (ret < 0) { if (errno == EAGAIN) return 0; From dovecot at dovecot.org Sun Sep 16 16:08:31 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:08:31 +0300 Subject: dovecot-2.2: Fixed compiling with OSes where NULL isn't defined ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/925d4a890a9b changeset: 15079:925d4a890a9b user: Timo Sirainen date: Sun Sep 16 16:08:18 2012 +0300 description: Fixed compiling with OSes where NULL isn't defined as void pointer (e.g. Solaris). diffstat: src/anvil/main.c | 2 +- src/auth/auth-request-handler.c | 2 +- src/auth/userdb-passwd.c | 4 ++-- src/director/director-test.c | 2 +- src/imap/imap-fetch-body.c | 10 ++++++---- src/lib-index/mail-index-alloc-cache.c | 2 +- src/lib-storage/index/index-search.c | 4 ++-- src/lib/lib-signals.c | 11 +++++++---- src/replication/replicator/replicator.c | 2 +- 9 files changed, 22 insertions(+), 17 deletions(-) diffs (166 lines): diff -r dc1db2eedbb1 -r 925d4a890a9b src/anvil/main.c --- a/src/anvil/main.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/anvil/main.c Sun Sep 16 16:08:18 2012 +0300 @@ -77,7 +77,7 @@ connect_limit = connect_limit_init(); penalty = penalty_init(); log_fdpass_io = io_add(MASTER_ANVIL_LOG_FDPASS_FD, IO_READ, - log_fdpass_input, NULL); + log_fdpass_input, (void *)NULL); master_service_run(master_service, client_connected); diff -r dc1db2eedbb1 -r 925d4a890a9b src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/auth/auth-request-handler.c Sun Sep 16 16:08:18 2012 +0300 @@ -236,7 +236,7 @@ if (to_auth_failures == NULL) { to_auth_failures = timeout_add_short(AUTH_FAILURE_DELAY_CHECK_MSECS, - auth_failure_timeout, NULL); + auth_failure_timeout, (void *)NULL); } } diff -r dc1db2eedbb1 -r 925d4a890a9b src/auth/userdb-passwd.c --- a/src/auth/userdb-passwd.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/auth/userdb-passwd.c Sun Sep 16 16:08:18 2012 +0300 @@ -202,8 +202,8 @@ i_free(ctx); if (cur_userdb_iter != NULL) { - cur_userdb_iter_to = - timeout_add(0, passwd_iterate_next_timeout, NULL); + cur_userdb_iter_to = timeout_add(0, passwd_iterate_next_timeout, + (void *)NULL); } return ret; } diff -r dc1db2eedbb1 -r 925d4a890a9b src/director/director-test.c --- a/src/director/director-test.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/director/director-test.c Sun Sep 16 16:08:18 2012 +0300 @@ -542,7 +542,7 @@ to_disconnect = timeout_add(1000*(1 + rand()%DIRECTOR_DISCONNECT_TIMEOUT_SECS), - director_connection_disconnect_timeout, NULL); + director_connection_disconnect_timeout, (void *)NULL); } static void main_deinit(void) diff -r dc1db2eedbb1 -r 925d4a890a9b src/imap/imap-fetch-body.c --- a/src/imap/imap-fetch-body.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/imap/imap-fetch-body.c Sun Sep 16 16:08:18 2012 +0300 @@ -523,26 +523,28 @@ ctx->fetch_ctx->fetch_data |= MAIL_FETCH_STREAM_HEADER | MAIL_FETCH_STREAM_BODY; ctx->fetch_ctx->flags_update_seen = TRUE; - imap_fetch_add_handler(ctx, 0, "NIL", fetch_rfc822, NULL); + imap_fetch_add_handler(ctx, 0, "NIL", + fetch_rfc822, (void *)NULL); return TRUE; } if (strcmp(name+6, ".SIZE") == 0) { ctx->fetch_ctx->fetch_data |= MAIL_FETCH_VIRTUAL_SIZE; imap_fetch_add_handler(ctx, IMAP_FETCH_HANDLER_FLAG_BUFFERED, - "0", fetch_rfc822_size, NULL); + "0", fetch_rfc822_size, (void *)NULL); return TRUE; } if (strcmp(name+6, ".HEADER") == 0) { ctx->fetch_ctx->fetch_data |= MAIL_FETCH_STREAM_HEADER; imap_fetch_add_handler(ctx, 0, "NIL", - fetch_rfc822_header, NULL); + fetch_rfc822_header, (void *)NULL); return TRUE; } if (strcmp(name+6, ".TEXT") == 0) { ctx->fetch_ctx->fetch_data |= MAIL_FETCH_STREAM_BODY; ctx->fetch_ctx->flags_update_seen = TRUE; - imap_fetch_add_handler(ctx, 0, "NIL", fetch_rfc822_text, NULL); + imap_fetch_add_handler(ctx, 0, "NIL", + fetch_rfc822_text, (void *)NULL); return TRUE; } diff -r dc1db2eedbb1 -r 925d4a890a9b src/lib-index/mail-index-alloc-cache.c --- a/src/lib-index/mail-index-alloc-cache.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/lib-index/mail-index-alloc-cache.c Sun Sep 16 16:08:18 2012 +0300 @@ -206,7 +206,7 @@ mail_index_alloc_cache_list_free(list); } else if (to_index == NULL) { to_index = timeout_add(INDEX_CACHE_TIMEOUT*1000/2, - index_removal_timeout, NULL); + index_removal_timeout, (void *)NULL); } } diff -r dc1db2eedbb1 -r 925d4a890a9b src/lib-storage/index/index-search.c --- a/src/lib-storage/index/index-search.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/lib-storage/index/index-search.c Sun Sep 16 16:08:18 2012 +0300 @@ -1205,7 +1205,7 @@ static void ATTR_NULL(2) search_arg_deinit(struct mail_search_arg *arg, - void *context ATTR_UNUSED) + struct index_search_context *ctx ATTR_UNUSED) { struct message_search_context *search_ctx = arg->context; @@ -1225,7 +1225,7 @@ mail_search_args_reset(ctx->mail_ctx.args->args, FALSE); (void)mail_search_args_foreach(ctx->mail_ctx.args->args, - search_arg_deinit, NULL); + search_arg_deinit, ctx); if (ctx->mail_ctx.wanted_headers != NULL) mailbox_header_lookup_unref(&ctx->mail_ctx.wanted_headers); diff -r dc1db2eedbb1 -r 925d4a890a9b src/lib/lib-signals.c --- a/src/lib/lib-signals.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/lib/lib-signals.c Sun Sep 16 16:08:18 2012 +0300 @@ -241,7 +241,7 @@ fd_close_on_exec(sig_pipe_fd[1], TRUE); if (signals_initialized) { io_sig = io_add(sig_pipe_fd[0], IO_READ, - signal_read, NULL); + signal_read, (void *)NULL); } } @@ -307,7 +307,8 @@ { if (io_sig != NULL) { io_remove(&io_sig); - io_sig = io_add(sig_pipe_fd[0], IO_READ, signal_read, NULL); + io_sig = io_add(sig_pipe_fd[0], IO_READ, + signal_read, (void *)NULL); } } @@ -323,8 +324,10 @@ lib_signals_set(i, signal_handlers[i]->flags); } - if (sig_pipe_fd[0] != -1) - io_sig = io_add(sig_pipe_fd[0], IO_READ, signal_read, NULL); + if (sig_pipe_fd[0] != -1) { + io_sig = io_add(sig_pipe_fd[0], IO_READ, + signal_read, (void *)NULL); + } } void lib_signals_deinit(void) diff -r dc1db2eedbb1 -r 925d4a890a9b src/replication/replicator/replicator.c --- a/src/replication/replicator/replicator.c Sun Sep 16 16:02:22 2012 +0300 +++ b/src/replication/replicator/replicator.c Sun Sep 16 16:08:18 2012 +0300 @@ -78,7 +78,7 @@ queue = replicator_queue_init(set->replication_full_sync_interval); replication_add_users(queue); to_dump = timeout_add(REPLICATOR_DB_DUMP_INTERVAL_MSECS, - replicator_dump_timeout, NULL); + replicator_dump_timeout, (void *)NULL); brain = replicator_brain_init(queue, set); } From dovecot at dovecot.org Sun Sep 16 16:12:11 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:12:11 +0300 Subject: dovecot-2.2: Compiler warning fixes for 32bit systems. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e708a1d691d3 changeset: 15080:e708a1d691d3 user: Timo Sirainen date: Sun Sep 16 16:12:03 2012 +0300 description: Compiler warning fixes for 32bit systems. diffstat: src/director/user-directory.c | 6 +++--- src/doveadm/dsync/dsync-mailbox-tree-sync.c | 4 ++-- src/lib-storage/index/dbox-common/dbox-storage.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-map.c | 2 +- src/lib-storage/index/maildir/maildir-storage.c | 2 +- src/lib-storage/list/mailbox-list-index.c | 2 +- src/lib/json-parser.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diffs (111 lines): diff -r 925d4a890a9b -r e708a1d691d3 src/director/user-directory.c --- a/src/director/user-directory.c Sun Sep 16 16:08:18 2012 +0300 +++ b/src/director/user-directory.c Sun Sep 16 16:12:03 2012 +0300 @@ -88,7 +88,7 @@ struct user *pos, struct user *user) { for (; pos != NULL; pos = pos->prev) { - if ((time_t)pos->timestamp <= user->timestamp) + if (pos->timestamp <= user->timestamp) break; } if (pos == NULL) @@ -109,7 +109,7 @@ struct user *pos, struct user *user) { for (; pos != NULL; pos = pos->next) { - if ((time_t)pos->timestamp >= user->timestamp) + if (pos->timestamp >= user->timestamp) break; } if (pos == NULL) @@ -152,7 +152,7 @@ if (dir->prev_insert_pos == NULL) { /* find the position starting from tail */ user_directory_insert_backwards(dir, dir->tail, user); - } else if (timestamp < dir->prev_insert_pos->timestamp) { + } else if (timestamp < (time_t)dir->prev_insert_pos->timestamp) { user_directory_insert_backwards(dir, dir->prev_insert_pos, user); } else { diff -r 925d4a890a9b -r e708a1d691d3 src/doveadm/dsync/dsync-mailbox-tree-sync.c --- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c Sun Sep 16 16:08:18 2012 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c Sun Sep 16 16:12:03 2012 +0300 @@ -326,7 +326,7 @@ - from it */ p = strrchr(node->name, '-'); i_assert(p != NULL); - if (max_prefix_len > p - node->name) + if (max_prefix_len > (size_t)(p - node->name)) max_prefix_len = p - node->name; } str_append_n(&buf, node->name, max_prefix_len); @@ -807,7 +807,7 @@ i_assert(p != NULL); p++; max_prefix_len = TEMP_MAX_NAME_LEN - strlen(new_suffix) - 1; - if (max_prefix_len > p-node->name) + if (max_prefix_len > (size_t)(p-node->name)) max_prefix_len = p-node->name; str_append_n(str, node->name, max_prefix_len); str_append(str, new_suffix); diff -r 925d4a890a9b -r e708a1d691d3 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Sun Sep 16 16:08:18 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Sun Sep 16 16:12:03 2012 +0300 @@ -155,7 +155,7 @@ } else if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) { /* there haven't been any changes to this directory since we last checked it. */ - } else if (st.st_atime < ioloop_time - interval) { + } else if (st.st_atime < ioloop_time - (time_t)interval) { /* time to scan */ const char *prefix = mailbox_list_get_global_temp_prefix(list); diff -r 925d4a890a9b -r e708a1d691d3 src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Sun Sep 16 16:08:18 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Sun Sep 16 16:12:03 2012 +0300 @@ -144,7 +144,7 @@ } else if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) { /* there haven't been any changes to this directory since we last checked it. */ - } else if (st.st_atime < ioloop_time - interval) { + } else if (st.st_atime < ioloop_time - (time_t)interval) { /* time to scan */ (void)unlink_old_files(map->path, DBOX_TEMP_FILE_PREFIX, ioloop_time - DBOX_TMP_DELETE_SECS); diff -r 925d4a890a9b -r e708a1d691d3 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Sun Sep 16 16:08:18 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Sun Sep 16 16:12:03 2012 +0300 @@ -222,7 +222,7 @@ } else if (st.st_atime > st.st_ctime + MAILDIR_TMP_DELETE_SECS) { /* the directory should be empty. we won't do anything until ctime changes. */ - } else if (st.st_atime < ioloop_time - interval) { + } else if (st.st_atime < ioloop_time - (time_t)interval) { /* time to scan */ (void)unlink_old_files(path, "", ioloop_time - MAILDIR_TMP_DELETE_SECS); diff -r 925d4a890a9b -r e708a1d691d3 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Sun Sep 16 16:08:18 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Sun Sep 16 16:12:03 2012 +0300 @@ -408,7 +408,7 @@ counter = ioloop_time; else { memcpy(&counter, data, size); - if (++counter < ioloop_time) + if (++counter < (uint32_t)ioloop_time) counter = ioloop_time; } diff -r 925d4a890a9b -r e708a1d691d3 src/lib/json-parser.c --- a/src/lib/json-parser.c Sun Sep 16 16:08:18 2012 +0300 +++ b/src/lib/json-parser.c Sun Sep 16 16:12:03 2012 +0300 @@ -185,7 +185,7 @@ { unsigned int len = strlen(atom); - if (parser->end - parser->data < len) + if ((size_t)(parser->end - parser->data) < len) return -1; if (memcmp(parser->data, atom, len) != 0) return -1; From dovecot at dovecot.org Sun Sep 16 16:31:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:31:44 +0300 Subject: dovecot-2.2: Removed all the "enum foo;" declarations. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4b0cbecf369d changeset: 15081:4b0cbecf369d user: Timo Sirainen date: Sun Sep 16 16:31:32 2012 +0300 description: Removed all the "enum foo;" declarations. They didn't seem to be very standard. Old gcc versions warn about them and C++ code doesn't like them. diffstat: src/auth/passdb-cache.h | 2 +- src/config/config-request.h | 2 +- src/config/old-set-parser.h | 3 +- src/doveadm/doveadm-mail-index.c | 1 + src/doveadm/doveadm-mail-iter.h | 2 + src/doveadm/doveadm-mail.c | 1 + src/doveadm/doveadm-mail.h | 2 +- src/doveadm/doveadm-mailbox-list-iter.h | 2 + src/doveadm/dsync/dsync-mailbox-tree-fill.c | 2 +- src/imap/cmd-list.c | 2 +- src/imap/cmd-notify.c | 1 + src/imap/imap-notify.c | 1 + src/lib-imap/imap-util.h | 2 +- src/lib-index/mail-index-modseq.h | 3 +- src/lib-lda/mail-deliver.h | 4 +- src/lib-storage/Makefile.am | 1 + src/lib-storage/index/imapc/imapc-sync.h | 1 - src/lib-storage/index/maildir/maildir-sync.h | 2 - src/lib-storage/list/mailbox-list-delete.h | 2 +- src/lib-storage/list/mailbox-list-index.h | 1 - src/lib-storage/list/mailbox-list-subscriptions.h | 4 +- src/lib-storage/mailbox-list-iter.h | 85 +++++++++++++++++++++++ src/lib-storage/mailbox-list-private.h | 1 + src/lib-storage/mailbox-list.h | 81 --------------------- src/plugins/notify/notify-plugin.h | 3 +- src/plugins/quota/quota-count.c | 1 + src/plugins/virtual/virtual-config.c | 1 + 27 files changed, 114 insertions(+), 99 deletions(-) diffs (truncated from 523 to 300 lines): diff -r e708a1d691d3 -r 4b0cbecf369d src/auth/passdb-cache.h --- a/src/auth/passdb-cache.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/auth/passdb-cache.h Sun Sep 16 16:31:32 2012 +0300 @@ -2,8 +2,8 @@ #define PASSDB_CACHE_H #include "auth-cache.h" +#include "passdb.h" -enum passdb_result; extern struct auth_cache *passdb_cache; bool passdb_cache_verify_plain(struct auth_request *request, const char *key, diff -r e708a1d691d3 -r 4b0cbecf369d src/config/config-request.h --- a/src/config/config-request.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/config/config-request.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,9 +1,9 @@ #ifndef CONFIG_REQUEST_H #define CONFIG_REQUEST_H +#include "settings-parser.h" #include "config-filter.h" -enum setting_type; struct master_service_settings_output; enum config_dump_scope { diff -r e708a1d691d3 -r 4b0cbecf369d src/config/old-set-parser.h --- a/src/config/old-set-parser.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/config/old-set-parser.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,7 +1,8 @@ #ifndef OLD_SET_PARSER_H #define OLD_SET_PARSER_H -enum config_line_type; +#include "config-parser-private.h" + struct config_parser_context; bool old_settings_handle(struct config_parser_context *ctx, diff -r e708a1d691d3 -r 4b0cbecf369d src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Sun Sep 16 16:12:03 2012 +0300 +++ b/src/doveadm/doveadm-mail-index.c Sun Sep 16 16:31:32 2012 +0300 @@ -8,6 +8,7 @@ #include "mail-namespace.h" #include "mail-storage.h" #include "mail-search-build.h" +#include "mailbox-list-iter.h" #include "doveadm-settings.h" #include "doveadm-mail.h" diff -r e708a1d691d3 -r 4b0cbecf369d src/doveadm/doveadm-mail-iter.h --- a/src/doveadm/doveadm-mail-iter.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/doveadm/doveadm-mail-iter.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,6 +1,8 @@ #ifndef DOVEADM_MAIL_ITER_H #define DOVEADM_MAIL_ITER_H +#include "mailbox-list-iter.h" + struct doveadm_mail_iter; struct doveadm_mail_cmd_context; diff -r e708a1d691d3 -r 4b0cbecf369d src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Sun Sep 16 16:12:03 2012 +0300 +++ b/src/doveadm/doveadm-mail.c Sun Sep 16 16:31:32 2012 +0300 @@ -16,6 +16,7 @@ #include "mail-storage-service.h" #include "mail-search-build.h" #include "mail-search-parser.h" +#include "mailbox-list-iter.h" #include "doveadm.h" #include "doveadm-settings.h" #include "doveadm-print.h" diff -r e708a1d691d3 -r 4b0cbecf369d src/doveadm/doveadm-mail.h --- a/src/doveadm/doveadm-mail.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/doveadm/doveadm-mail.h Sun Sep 16 16:31:32 2012 +0300 @@ -5,9 +5,9 @@ #include "doveadm.h" #include "doveadm-util.h" #include "module-context.h" +#include "mail-error.h" #include "mail-storage-service.h" -enum mail_error; struct mailbox; struct mail_storage; struct mail_user; diff -r e708a1d691d3 -r 4b0cbecf369d src/doveadm/doveadm-mailbox-list-iter.h --- a/src/doveadm/doveadm-mailbox-list-iter.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/doveadm/doveadm-mailbox-list-iter.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,6 +1,8 @@ #ifndef DOVEADM_MAILBOX_LIST_ITER_H #define DOVEADM_MAILBOX_LIST_ITER_H +#include "mailbox-list-iter.h" + struct doveadm_mail_cmd_context; /* List only selectable mailboxes */ diff -r e708a1d691d3 -r 4b0cbecf369d src/doveadm/dsync/dsync-mailbox-tree-fill.c --- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Sun Sep 16 16:12:03 2012 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Sun Sep 16 16:31:32 2012 +0300 @@ -8,7 +8,7 @@ #include "mailbox-log.h" #include "mail-namespace.h" #include "mail-storage.h" -#include "mailbox-list.h" +#include "mailbox-list-iter.h" #include "dsync-mailbox-tree-private.h" static int diff -r e708a1d691d3 -r 4b0cbecf369d src/imap/cmd-list.c --- a/src/imap/cmd-list.c Sun Sep 16 16:12:03 2012 +0300 +++ b/src/imap/cmd-list.c Sun Sep 16 16:31:32 2012 +0300 @@ -4,13 +4,13 @@ #include "array.h" #include "str.h" #include "strescape.h" +#include "mailbox-list-iter.h" #include "imap-utf7.h" #include "imap-quote.h" #include "imap-match.h" #include "imap-status.h" #include "imap-commands.h" #include "imap-list.h" -#include "mail-namespace.h" struct cmd_list_context { struct client_command_context *cmd; diff -r e708a1d691d3 -r 4b0cbecf369d src/imap/cmd-notify.c --- a/src/imap/cmd-notify.c Sun Sep 16 16:12:03 2012 +0300 +++ b/src/imap/cmd-notify.c Sun Sep 16 16:31:32 2012 +0300 @@ -2,6 +2,7 @@ #include "imap-common.h" #include "str.h" +#include "mailbox-list-iter.h" #include "imap-quote.h" #include "imap-commands.h" #include "imap-fetch.h" diff -r e708a1d691d3 -r 4b0cbecf369d src/imap/imap-notify.c --- a/src/imap/imap-notify.c Sun Sep 16 16:12:03 2012 +0300 +++ b/src/imap/imap-notify.c Sun Sep 16 16:31:32 2012 +0300 @@ -4,6 +4,7 @@ #include "str.h" #include "ostream.h" #include "imap-quote.h" +#include "mailbox-list-iter.h" #include "mailbox-list-notify.h" #include "mail-search.h" #include "mail-search-build.h" diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-imap/imap-util.h --- a/src/lib-imap/imap-util.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-imap/imap-util.h Sun Sep 16 16:31:32 2012 +0300 @@ -2,8 +2,8 @@ #define IMAP_UTIL_H #include "seq-range-array.h" +#include "mail-types.h" -enum mail_flags; struct imap_arg; /* Write flags as a space separated string. */ diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-index/mail-index-modseq.h --- a/src/lib-index/mail-index-modseq.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-index/mail-index-modseq.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,9 +1,10 @@ #ifndef MAIL_INDEX_MODSEQ_H #define MAIL_INDEX_MODSEQ_H +#include "mail-types.h" + #define MAIL_INDEX_MODSEQ_EXT_NAME "modseq" -enum mail_flags; struct mail_keywords; struct mail_index; struct mail_index_map; diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-lda/mail-deliver.h --- a/src/lib-lda/mail-deliver.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-lda/mail-deliver.h Sun Sep 16 16:31:32 2012 +0300 @@ -2,9 +2,9 @@ #define MAIL_DELIVER_H #include "guid.h" +#include "mail-types.h" +#include "mail-error.h" -enum mail_flags; -enum mail_error; struct mail_storage; struct mail_save_context; struct mailbox; diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-storage/Makefile.am --- a/src/lib-storage/Makefile.am Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-storage/Makefile.am Sun Sep 16 16:31:32 2012 +0300 @@ -69,6 +69,7 @@ mail-user.h \ mailbox-guid-cache.h \ mailbox-list.h \ + mailbox-list-iter.h \ mailbox-list-private.h \ mailbox-list-notify.h \ mailbox-search-result-private.h \ diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-storage/index/imapc/imapc-sync.h --- a/src/lib-storage/index/imapc/imapc-sync.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-sync.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,7 +1,6 @@ #ifndef CYDIR_SYNC_H #define CYDIR_SYNC_H -enum mailbox_sync_flags; struct mailbox; struct mailbox_sync_status; diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-storage/index/maildir/maildir-sync.h --- a/src/lib-storage/index/maildir/maildir-sync.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.h Sun Sep 16 16:31:32 2012 +0300 @@ -14,8 +14,6 @@ /* If syncing takes longer than this, log a warning. */ #define MAILDIR_SYNC_TIME_WARN_SECS 60 -enum maildir_uidlist_rec_flag; - struct maildir_mailbox; struct maildir_sync_context; struct maildir_keywords_sync_ctx; diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-storage/list/mailbox-list-delete.h --- a/src/lib-storage/list/mailbox-list-delete.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-delete.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,7 +1,7 @@ #ifndef MAILBOX_LIST_DELETE_H #define MAILBOX_LIST_DELETE_H -enum mailbox_list_path_type; +#include "mailbox-list.h" int mailbox_list_delete_maildir_via_trash(struct mailbox_list *list, const char *name, diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-storage/list/mailbox-list-index.h --- a/src/lib-storage/list/mailbox-list-index.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index.h Sun Sep 16 16:31:32 2012 +0300 @@ -31,7 +31,6 @@ #define INDEX_LIST_CONTEXT(obj) \ MODULE_CONTEXT(obj, mailbox_list_index_module) -enum mailbox_status_items; struct mail_index_view; struct mailbox; struct mailbox_status; diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-storage/list/mailbox-list-subscriptions.h --- a/src/lib-storage/list/mailbox-list-subscriptions.h Sun Sep 16 16:12:03 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.h Sun Sep 16 16:31:32 2012 +0300 @@ -1,8 +1,8 @@ #ifndef MAILBOX_LIST_SUBSCRIPTIONS_H #define MAILBOX_LIST_SUBSCRIPTIONS_H -enum mailbox_info_flags; -enum mailbox_list_iter_flags; +#include "mailbox-list-iter.h" + struct mailbox_tree_context; struct mailbox_list_iterate_context; diff -r e708a1d691d3 -r 4b0cbecf369d src/lib-storage/mailbox-list-iter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/mailbox-list-iter.h Sun Sep 16 16:31:32 2012 +0300 @@ -0,0 +1,85 @@ +#ifndef MAILBOX_LIST_ITER_H +#define MAILBOX_LIST_ITER_H + +#include "mail-namespace.h" +#include "mailbox-list.h" + +enum mailbox_list_iter_flags { + /* Ignore index file and ACLs (used by ACL plugin internally) */ + MAILBOX_LIST_ITER_RAW_LIST = 0x000001, + /* Don't list autocreated mailboxes (e.g. INBOX) unless they + physically exist */ + MAILBOX_LIST_ITER_NO_AUTO_BOXES = 0x000004, + + /* For mailbox_list_iter_init_namespaces(): Skip namespaces that + have alias_for set. */ + MAILBOX_LIST_ITER_SKIP_ALIASES = 0x000008, + /* For mailbox_list_iter_init_namespaces(): '*' in a pattern doesn't + match beyond namespace boundary (e.g. "foo*" or "*o" doesn't match + "foo." namespace's mailboxes, but "*.*" does). also '%' can't match + namespace prefixes, if there exists a parent namespace whose children + it matches. */ + MAILBOX_LIST_ITER_STAR_WITHIN_NS = 0x000010, + + /* List only subscribed mailboxes */ + MAILBOX_LIST_ITER_SELECT_SUBSCRIBED = 0x000100, + /* Return MAILBOX_CHILD_* if mailbox's children match selection + criteria, even if the mailbox itself wouldn't match. */ + MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH = 0x000200, + /* Return only mailboxes that have special use flags */ + MAILBOX_LIST_ITER_SELECT_SPECIALUSE = 0x000400, From dovecot at dovecot.org Sun Sep 16 16:42:39 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:42:39 +0300 Subject: dovecot-2.2: Makefile: Again changes to handling test program de... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a2159b6d1518 changeset: 15082:a2159b6d1518 user: Timo Sirainen date: Sun Sep 16 16:42:25 2012 +0300 description: Makefile: Again changes to handling test program dependencies. .la libraries need to link .lo files, .a libraries need to link .o files. Changed dsync to be .la library for consistency. diffstat: src/doveadm/Makefile.am | 2 +- src/doveadm/dsync/Makefile.am | 8 ++++---- src/lib-dict/Makefile.am | 2 +- src/lib-imap/Makefile.am | 12 ++++++------ src/lib-index/Makefile.am | 12 ++++++------ src/lib-mail/Makefile.am | 42 +++++++++++++++++++++--------------------- src/lib-storage/Makefile.am | 2 +- src/plugins/fts/Makefile.am | 2 +- 8 files changed, 41 insertions(+), 41 deletions(-) diffs (253 lines): diff -r 4b0cbecf369d -r a2159b6d1518 src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/doveadm/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -37,7 +37,7 @@ ../lib-otp/libotp.a libs = \ - dsync/libdsync.a \ + dsync/libdsync.la \ $(unused_objects) doveadm_LDADD = \ diff -r 4b0cbecf369d -r a2159b6d1518 src/doveadm/dsync/Makefile.am --- a/src/doveadm/dsync/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/doveadm/dsync/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -1,4 +1,4 @@ -noinst_LIBRARIES = libdsync.a +noinst_LTLIBRARIES = libdsync.la AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ @@ -11,7 +11,7 @@ -I$(top_srcdir)/src/lib-storage \ -I$(top_srcdir)/src/doveadm -libdsync_a_SOURCES = \ +libdsync_la_SOURCES = \ doveadm-dsync.c \ dsync-brain.c \ dsync-brain-mailbox.c \ @@ -60,8 +60,8 @@ ../../lib/liblib.la test_dsync_mailbox_tree_sync_SOURCES = test-dsync-mailbox-tree-sync.c -test_dsync_mailbox_tree_sync_LDADD = dsync-mailbox-tree-sync.o dsync-mailbox-tree.o $(test_libs) -test_dsync_mailbox_tree_sync_DEPENDENCIES = $(noinst_LIBRARIES) $(test_libs) +test_dsync_mailbox_tree_sync_LDADD = dsync-mailbox-tree-sync.lo dsync-mailbox-tree.lo $(test_libs) +test_dsync_mailbox_tree_sync_DEPENDENCIES = $(noinst_LTLIBRARIES) $(test_libs) check: check-am check-test check-test: all-am diff -r 4b0cbecf369d -r a2159b6d1518 src/lib-dict/Makefile.am --- a/src/lib-dict/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/lib-dict/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -84,7 +84,7 @@ ../lib/liblib.la test_dict_SOURCES = test-dict.c -test_dict_LDADD = dict.o $(test_libs) +test_dict_LDADD = dict.lo $(test_libs) test_dict_DEPENDENCIES = $(noinst_LTLIBRARIES) $(test_libs) check: check-am check-test diff -r 4b0cbecf369d -r a2159b6d1518 src/lib-imap/Makefile.am --- a/src/lib-imap/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/lib-imap/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -57,27 +57,27 @@ test_deps = $(noinst_LTLIBRARIES) $(test_libs) test_imap_bodystructure_SOURCES = test-imap-bodystructure.c -test_imap_bodystructure_LDADD = imap-bodystructure.o imap-envelope.o imap-quote.o imap-parser.o imap-arg.o ../lib-mail/libmail.la $(test_libs) +test_imap_bodystructure_LDADD = imap-bodystructure.lo imap-envelope.lo imap-quote.lo imap-parser.lo imap-arg.lo ../lib-mail/libmail.la $(test_libs) test_imap_bodystructure_DEPENDENCIES = $(test_deps) ../lib-mail/libmail.la test_imap_match_SOURCES = test-imap-match.c -test_imap_match_LDADD = imap-match.o $(test_libs) +test_imap_match_LDADD = imap-match.lo $(test_libs) test_imap_match_DEPENDENCIES = $(test_deps) test_imap_parser_SOURCES = test-imap-parser.c -test_imap_parser_LDADD = imap-parser.o imap-arg.o $(test_libs) +test_imap_parser_LDADD = imap-parser.lo imap-arg.lo $(test_libs) test_imap_parser_DEPENDENCIES = $(test_deps) test_imap_url_SOURCES = test-imap-url.c -test_imap_url_LDADD = imap-url.o $(test_libs) +test_imap_url_LDADD = imap-url.lo $(test_libs) test_imap_url_DEPENDENCIES = $(test_deps) test_imap_utf7_SOURCES = test-imap-utf7.c -test_imap_utf7_LDADD = imap-utf7.o $(test_libs) +test_imap_utf7_LDADD = imap-utf7.lo $(test_libs) test_imap_utf7_DEPENDENCIES = $(test_deps) test_imap_util_SOURCES = test-imap-util.c -test_imap_util_LDADD = imap-util.o imap-arg.o $(test_libs) +test_imap_util_LDADD = imap-util.lo imap-arg.lo $(test_libs) test_imap_util_DEPENDENCIES = $(test_deps) check: check-am check-test diff -r 4b0cbecf369d -r a2159b6d1518 src/lib-index/Makefile.am --- a/src/lib-index/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/lib-index/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -70,30 +70,30 @@ noinst_PROGRAMS = $(test_programs) test_libs = \ - mail-index-util.o \ + mail-index-util.lo \ ../lib-test/libtest.la \ ../lib/liblib.la test_deps = $(noinst_LTLIBRARIES) $(test_libs) test_mail_index_sync_ext_SOURCES = test-mail-index-sync-ext.c -test_mail_index_sync_ext_LDADD = mail-index-sync-ext.o $(test_libs) +test_mail_index_sync_ext_LDADD = mail-index-sync-ext.lo $(test_libs) test_mail_index_sync_ext_DEPENDENCIES = $(test_deps) test_mail_index_transaction_finish_SOURCES = test-mail-index-transaction-finish.c -test_mail_index_transaction_finish_LDADD = mail-index-transaction-finish.o $(test_libs) +test_mail_index_transaction_finish_LDADD = mail-index-transaction-finish.lo $(test_libs) test_mail_index_transaction_finish_DEPENDENCIES = $(test_deps) test_mail_index_transaction_update_SOURCES = test-mail-index-transaction-update.c -test_mail_index_transaction_update_LDADD = mail-index-transaction-update.o $(test_libs) +test_mail_index_transaction_update_LDADD = mail-index-transaction-update.lo $(test_libs) test_mail_index_transaction_update_DEPENDENCIES = $(test_deps) test_mail_transaction_log_append_SOURCES = test-mail-transaction-log-append.c -test_mail_transaction_log_append_LDADD = mail-transaction-log-append.o $(test_libs) +test_mail_transaction_log_append_LDADD = mail-transaction-log-append.lo $(test_libs) test_mail_transaction_log_append_DEPENDENCIES = $(test_deps) test_mail_transaction_log_view_SOURCES = test-mail-transaction-log-view.c -test_mail_transaction_log_view_LDADD = mail-transaction-log-view.o $(test_libs) +test_mail_transaction_log_view_LDADD = mail-transaction-log-view.lo $(test_libs) test_mail_transaction_log_view_DEPENDENCIES = $(test_deps) check: check-am check-test diff -r 4b0cbecf369d -r a2159b6d1518 src/lib-mail/Makefile.am --- a/src/lib-mail/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/lib-mail/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -90,74 +90,74 @@ test_deps = $(noinst_LTLIBRARIES) $(test_libs) test_istream_dot_SOURCES = test-istream-dot.c -test_istream_dot_LDADD = istream-dot.o $(test_libs) +test_istream_dot_LDADD = istream-dot.lo $(test_libs) test_istream_dot_DEPENDENCIES = $(test_deps) test_istream_qp_decoder_SOURCES = test-istream-qp-decoder.c -test_istream_qp_decoder_LDADD = istream-qp-decoder.o quoted-printable.o $(test_libs) +test_istream_qp_decoder_LDADD = istream-qp-decoder.lo quoted-printable.lo $(test_libs) test_istream_qp_decoder_DEPENDENCIES = $(test_deps) message_parser_objects = \ - message-parser.o \ - message-header-parser.o \ - message-size.o \ - rfc822-parser.o \ - rfc2231-parser.o + message-parser.lo \ + message-header-parser.lo \ + message-size.lo \ + rfc822-parser.lo \ + rfc2231-parser.lo test_istream_binary_converter_SOURCES = test-istream-binary-converter.c -test_istream_binary_converter_LDADD = istream-binary-converter.o $(message_parser_objects) $(test_libs) +test_istream_binary_converter_LDADD = istream-binary-converter.lo $(message_parser_objects) $(test_libs) test_istream_binary_converter_DEPENDENCIES = $(test_deps) test_istream_attachment_SOURCES = test-istream-attachment.c -test_istream_attachment_LDADD = istream-attachment-extractor.o istream-attachment-connector.o $(message_parser_objects) $(test_libs) +test_istream_attachment_LDADD = istream-attachment-extractor.lo istream-attachment-connector.lo $(message_parser_objects) $(test_libs) test_istream_attachment_DEPENDENCIES = $(test_deps) test_istream_header_filter_SOURCES = test-istream-header-filter.c -test_istream_header_filter_LDADD = istream-header-filter.o message-header-parser.o $(test_libs) +test_istream_header_filter_LDADD = istream-header-filter.lo message-header-parser.lo $(test_libs) test_istream_header_filter_DEPENDENCIES = $(test_deps) test_mbox_from_SOURCES = test-mbox-from.c -test_mbox_from_LDADD = mbox-from.o $(test_libs) +test_mbox_from_LDADD = mbox-from.lo $(test_libs) test_mbox_from_DEPENDENCIES = $(test_deps) test_message_address_SOURCES = test-message-address.c -test_message_address_LDADD = message-address.o rfc822-parser.o $(test_libs) +test_message_address_LDADD = message-address.lo rfc822-parser.lo $(test_libs) test_message_address_DEPENDENCIES = $(test_deps) test_message_date_SOURCES = test-message-date.c -test_message_date_LDADD = message-date.o rfc822-parser.o $(test_libs) +test_message_date_LDADD = message-date.lo rfc822-parser.lo $(test_libs) test_message_date_DEPENDENCIES = $(test_deps) test_message_decoder_SOURCES = test-message-decoder.c -test_message_decoder_LDADD = message-decoder.o rfc822-parser.o rfc2231-parser.o $(test_libs) +test_message_decoder_LDADD = message-decoder.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs) test_message_decoder_DEPENDENCIES = $(test_deps) test_message_header_decode_SOURCES = test-message-header-decode.c -test_message_header_decode_LDADD = message-header-decode.o quoted-printable.o $(test_libs) +test_message_header_decode_LDADD = message-header-decode.lo quoted-printable.lo $(test_libs) test_message_header_decode_DEPENDENCIES = $(test_deps) test_message_header_encode_SOURCES = test-message-header-encode.c -test_message_header_encode_LDADD = message-header-encode.o $(test_libs) +test_message_header_encode_LDADD = message-header-encode.lo $(test_libs) test_message_header_encode_DEPENDENCIES = $(test_deps) test_message_header_parser_SOURCES = test-message-header-parser.c -test_message_header_parser_LDADD = message-header-parser.o $(test_libs) +test_message_header_parser_LDADD = message-header-parser.lo $(test_libs) test_message_header_parser_DEPENDENCIES = $(test_deps) test_message_id_SOURCES = test-message-id.c -test_message_id_LDADD = message-id.o rfc822-parser.o $(test_libs) +test_message_id_LDADD = message-id.lo rfc822-parser.lo $(test_libs) test_message_id_DEPENDENCIES = $(test_deps) test_message_parser_SOURCES = test-message-parser.c -test_message_parser_LDADD = message-parser.o message-header-parser.o message-size.o rfc822-parser.o rfc2231-parser.o $(test_libs) +test_message_parser_LDADD = message-parser.lo message-header-parser.lo message-size.lo rfc822-parser.lo rfc2231-parser.lo $(test_libs) test_message_parser_DEPENDENCIES = $(test_deps) test_quoted_printable_SOURCES = test-quoted-printable.c -test_quoted_printable_LDADD = quoted-printable.o $(test_libs) +test_quoted_printable_LDADD = quoted-printable.lo $(test_libs) test_quoted_printable_DEPENDENCIES = $(test_deps) test_rfc2231_parser_SOURCES = test-rfc2231-parser.c -test_rfc2231_parser_LDADD = rfc2231-parser.o rfc822-parser.o $(test_libs) +test_rfc2231_parser_LDADD = rfc2231-parser.lo rfc822-parser.lo $(test_libs) test_rfc2231_parser_DEPENDENCIES = $(test_deps) check: check-am check-test diff -r 4b0cbecf369d -r a2159b6d1518 src/lib-storage/Makefile.am --- a/src/lib-storage/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/lib-storage/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -103,7 +103,7 @@ $(top_builddir)/src/lib/liblib.la test_mailbox_get_SOURCES = test-mailbox-get.c -test_mailbox_get_LDADD = mailbox-get.o $(test_libs) +test_mailbox_get_LDADD = mailbox-get.lo $(test_libs) test_mailbox_get_DEPENDENCIES = $(noinst_LTLIBRARIES) $(test_libs) check: check-am check-test diff -r 4b0cbecf369d -r a2159b6d1518 src/plugins/fts/Makefile.am --- a/src/plugins/fts/Makefile.am Sun Sep 16 16:31:32 2012 +0300 +++ b/src/plugins/fts/Makefile.am Sun Sep 16 16:42:25 2012 +0300 @@ -47,7 +47,7 @@ xml2text_SOURCES = xml2text.c -xml2text_LDADD = fts-parser-html.o $(LIBDOVECOT) +xml2text_LDADD = fts-parser-html.lo $(LIBDOVECOT) xml2text_DEPENDENCIES = $(module_LTLIBRARIES) $(LIBDOVECOT_DEPS) pkglibexec_SCRIPTS = decode2text.sh From dovecot at dovecot.org Sun Sep 16 16:49:01 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 16 Sep 2012 16:49:01 +0300 Subject: dovecot-2.2: Makefile: Fixed building fts-squat Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a821cce04eb7 changeset: 15083:a821cce04eb7 user: Timo Sirainen date: Sun Sep 16 16:48:48 2012 +0300 description: Makefile: Fixed building fts-squat diffstat: src/plugins/fts-squat/Makefile.am | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r a2159b6d1518 -r a821cce04eb7 src/plugins/fts-squat/Makefile.am --- a/src/plugins/fts-squat/Makefile.am Sun Sep 16 16:42:25 2012 +0300 +++ b/src/plugins/fts-squat/Makefile.am Sun Sep 16 16:48:48 2012 +0300 @@ -34,8 +34,8 @@ squat-test.c common_objects = \ - squat-trie.o \ - squat-uidlist.o + squat-trie.lo \ + squat-uidlist.lo squat_test_LDADD = \ $(common_objects) \ From dovecot at dovecot.org Mon Sep 17 17:51:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Sep 2012 17:51:16 +0300 Subject: dovecot-2.2: sdbox: Removed unnecessary code line. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/64f556e62025 changeset: 15084:64f556e62025 user: Timo Sirainen date: Mon Sep 17 17:51:03 2012 +0300 description: sdbox: Removed unnecessary code line. diffstat: src/lib-storage/index/dbox-single/sdbox-storage.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r a821cce04eb7 -r 64f556e62025 src/lib-storage/index/dbox-single/sdbox-storage.h --- a/src/lib-storage/index/dbox-single/sdbox-storage.h Sun Sep 16 16:48:48 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.h Mon Sep 17 17:51:03 2012 +0300 @@ -36,7 +36,6 @@ int sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r, struct dbox_file **file_r); -uint32_t dbox_get_uidvalidity_next(struct mailbox_list *list); int sdbox_read_header(struct sdbox_mailbox *mbox, struct sdbox_index_header *hdr, bool log_error); void sdbox_set_mailbox_corrupted(struct mailbox *box); From dovecot at dovecot.org Mon Sep 17 18:13:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 17 Sep 2012 18:13:48 +0300 Subject: dovecot-2.2: lib-fs: fs_init() API changed to allow returning an... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8f4ce0932777 changeset: 15085:8f4ce0932777 user: Timo Sirainen date: Mon Sep 17 18:13:32 2012 +0300 description: lib-fs: fs_init() API changed to allow returning an error. diffstat: src/lib-fs/fs-api-private.h | 3 +- src/lib-fs/fs-api.c | 38 +++++++++++++++---- src/lib-fs/fs-api.h | 6 ++- src/lib-fs/fs-posix.c | 44 +++++++++++++---------- src/lib-fs/fs-sis-queue.c | 30 ++++++++++------ src/lib-fs/fs-sis.c | 33 ++++++++++++------ src/lib-storage/index/dbox-common/dbox-storage.c | 14 +++++-- 7 files changed, 110 insertions(+), 58 deletions(-) diffs (truncated from 309 to 300 lines): diff -r 64f556e62025 -r 8f4ce0932777 src/lib-fs/fs-api-private.h --- a/src/lib-fs/fs-api-private.h Mon Sep 17 17:51:03 2012 +0300 +++ b/src/lib-fs/fs-api-private.h Mon Sep 17 18:13:32 2012 +0300 @@ -4,7 +4,8 @@ #include "fs-api.h" struct fs_vfuncs { - struct fs *(*init)(const char *args, const struct fs_settings *set); + int (*init)(const char *args, const struct fs_settings *set, + struct fs **fs_r, const char **error_r); void (*deinit)(struct fs *fs); int (*open)(struct fs *fs, const char *path, enum fs_open_mode mode, diff -r 64f556e62025 -r 8f4ce0932777 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Mon Sep 17 17:51:03 2012 +0300 +++ b/src/lib-fs/fs-api.c Mon Sep 17 18:13:32 2012 +0300 @@ -10,27 +10,47 @@ &fs_class_sis_queue }; -static struct fs * +static int fs_alloc(const struct fs *fs_class, const char *args, - const struct fs_settings *set) + const struct fs_settings *set, struct fs **fs_r, const char **error_r) { struct fs *fs; + char *error_dup = NULL; + int ret; - fs = fs_class->v.init(args, set); + T_BEGIN { + const char *error; + + ret = fs_class->v.init(args, set, fs_r, &error); + if (ret < 0) + error_dup = i_strdup(error); + } T_END; + if (ret < 0) { + /* a bit kludgy way to allow data stack frame usage in normal + conditions but still be able to return error message from + data stack. */ + *error_r = t_strdup_printf("%s: %s", fs_class->name, error_dup); + i_free(error_dup); + return -1; + } fs->last_error = str_new(default_pool, 64); - return fs; + return 0; } -struct fs *fs_init(const char *driver, const char *args, - const struct fs_settings *set) +int fs_init(const char *driver, const char *args, + const struct fs_settings *set, + struct fs **fs_r, const char **error_r) { unsigned int i; for (i = 0; i < N_ELEMENTS(fs_classes); i++) { - if (strcmp(fs_classes[i]->name, driver) == 0) - return fs_alloc(fs_classes[i], args, set); + if (strcmp(fs_classes[i]->name, driver) == 0) { + return fs_alloc(fs_classes[i], args, + set, fs_r, error_r); + } } - i_fatal("Unknown fs driver: %s", driver); + *error_r = t_strdup_printf("Unknown fs driver: %s", driver); + return -1; } void fs_deinit(struct fs **_fs) diff -r 64f556e62025 -r 8f4ce0932777 src/lib-fs/fs-api.h --- a/src/lib-fs/fs-api.h Mon Sep 17 17:51:03 2012 +0300 +++ b/src/lib-fs/fs-api.h Mon Sep 17 18:13:32 2012 +0300 @@ -2,6 +2,7 @@ #define FS_API_H struct stat; +struct fs; struct fs_file; struct fs_lock; @@ -31,8 +32,9 @@ const char *temp_file_prefix; }; -struct fs *fs_init(const char *driver, const char *args, - const struct fs_settings *set); +int fs_init(const char *driver, const char *args, + const struct fs_settings *set, + struct fs **fs_r, const char **error_r); void fs_deinit(struct fs **fs); /* Returns 0 if opened, -1 if error (errno is set). */ diff -r 64f556e62025 -r 8f4ce0932777 src/lib-fs/fs-posix.c --- a/src/lib-fs/fs-posix.c Mon Sep 17 17:51:03 2012 +0300 +++ b/src/lib-fs/fs-posix.c Mon Sep 17 18:13:32 2012 +0300 @@ -53,10 +53,12 @@ struct dotlock *dotlock; }; -static struct fs * -fs_posix_init(const char *args, const struct fs_settings *set) +static int +fs_posix_init(const char *args, const struct fs_settings *set, + struct fs **fs_r, const char **error_r) { struct posix_fs *fs; + const char *const *tmp; fs = i_new(struct posix_fs, 1); fs->fs = fs_class_posix; @@ -66,32 +68,34 @@ fs->lock_method = FS_POSIX_LOCK_METHOD_FLOCK; fs->mode = FS_DEFAULT_MODE; - T_BEGIN { - const char *const *tmp = t_strsplit_spaces(args, " "); - for (; *tmp != NULL; tmp++) { - const char *arg = *tmp; + tmp = t_strsplit_spaces(args, " "); + for (; *tmp != NULL; tmp++) { + const char *arg = *tmp; - if (strcmp(arg, "lock=flock") == 0) - fs->lock_method = FS_POSIX_LOCK_METHOD_FLOCK; - else if (strcmp(arg, "lock=dotlock") == 0) - fs->lock_method = FS_POSIX_LOCK_METHOD_DOTLOCK; - else if (strncmp(arg, "mode=", 5) == 0) { - fs->mode = strtoul(arg+5, NULL, 8) & 0666; - if (fs->mode == 0) { - i_fatal("fs-posix: Invalid mode: %s", - arg+5); - } - } else - i_fatal("fs-posix: Unknown arg '%s'", arg); + if (strcmp(arg, "lock=flock") == 0) + fs->lock_method = FS_POSIX_LOCK_METHOD_FLOCK; + else if (strcmp(arg, "lock=dotlock") == 0) + fs->lock_method = FS_POSIX_LOCK_METHOD_DOTLOCK; + else if (strncmp(arg, "mode=", 5) == 0) { + fs->mode = strtoul(arg+5, NULL, 8) & 0666; + if (fs->mode == 0) { + *error_r = t_strdup_printf("Invalid mode: %s", + arg+5); + return -1; + } + } else { + *error_r = t_strdup_printf("Unknown arg '%s'", arg); + return -1; } - } T_END; + } fs->dir_mode = fs->mode; if ((fs->dir_mode & 0600) != 0) fs->dir_mode |= 0100; if ((fs->dir_mode & 0060) != 0) fs->dir_mode |= 0010; if ((fs->dir_mode & 0006) != 0) fs->dir_mode |= 0001; - return &fs->fs; + *fs_r = &fs->fs; + return 0; } static void fs_posix_deinit(struct fs *_fs) diff -r 64f556e62025 -r 8f4ce0932777 src/lib-fs/fs-sis-queue.c --- a/src/lib-fs/fs-sis-queue.c Mon Sep 17 17:51:03 2012 +0300 +++ b/src/lib-fs/fs-sis-queue.c Mon Sep 17 18:13:32 2012 +0300 @@ -30,11 +30,12 @@ fs_sis_queue_copy_error(fs); } -static struct fs * -fs_sis_queue_init(const char *args, const struct fs_settings *set) +static int +fs_sis_queue_init(const char *args, const struct fs_settings *set, + struct fs **fs_r, const char **error_r) { struct sis_queue_fs *fs; - const char *p, *parent_fs; + const char *p, *parent_name, *parent_args, *error; fs = i_new(struct sis_queue_fs, 1); fs->fs = fs_class_sis_queue; @@ -42,18 +43,25 @@ /* :[:] */ p = strchr(args, ':'); - if (p == NULL || p[1] == '\0') - i_fatal("fs-sis-queue: Parent filesystem not given as parameter"); + if (p == NULL || p[1] == '\0') { + *error_r = "Parent filesystem not given as parameter"; + return -1; + } fs->queue_dir = i_strdup_until(args, p); - parent_fs = p + 1; + parent_name = p + 1; - p = strchr(parent_fs, ':'); - if (p == NULL) - fs->super = fs_init(parent_fs, "", set); + parent_args = strchr(parent_name, ':'); + if (parent_args == NULL) + parent_args = ""; else - fs->super = fs_init(t_strdup_until(parent_fs, p), p+1, set); - return &fs->fs; + parent_name = t_strdup_until(parent_name, parent_args++); + if (fs_init(parent_name, parent_args, set, &fs->super, &error) < 0) { + *error_r = t_strdup_printf("%s: %s", parent_name, error); + return -1; + } + *fs_r = &fs->fs; + return 0; } static void fs_sis_queue_deinit(struct fs *_fs) diff -r 64f556e62025 -r 8f4ce0932777 src/lib-fs/fs-sis.c --- a/src/lib-fs/fs-sis.c Mon Sep 17 17:51:03 2012 +0300 +++ b/src/lib-fs/fs-sis.c Mon Sep 17 18:13:32 2012 +0300 @@ -35,24 +35,35 @@ fs_sis_copy_error(fs); } -static struct fs * -fs_sis_init(const char *args, const struct fs_settings *set) +static int +fs_sis_init(const char *args, const struct fs_settings *set, + struct fs **fs_r, const char **error_r) { struct sis_fs *fs; - const char *p; + const char *parent_name, *parent_args, *error; fs = i_new(struct sis_fs, 1); fs->fs = fs_class_sis; - if (*args == '\0') - i_fatal("fs-sis: Parent filesystem not given as parameter"); + if (*args == '\0') { + *error_r = "Parent filesystem not given as parameter"; + return -1; + } - p = strchr(args, ':'); - if (p == NULL) - fs->super = fs_init(args, "", set); - else - fs->super = fs_init(t_strdup_until(args, p), p+1, set); - return &fs->fs; + parent_args = strchr(args, ':'); + if (parent_args == NULL) { + parent_name = args; + parent_args = ""; + } else { + parent_name = t_strdup_until(args, parent_args); + parent_args++; + } + if (fs_init(parent_name, parent_args, set, &fs->super, &error) < 0) { + *error_r = t_strdup_printf("%s: %s", parent_name, error); + return -1; + } + *fs_r = &fs->fs; + return 0; } static void fs_sis_deinit(struct fs *_fs) diff -r 64f556e62025 -r 8f4ce0932777 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Mon Sep 17 17:51:03 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Mon Sep 17 18:13:32 2012 +0300 @@ -80,16 +80,17 @@ int dbox_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, - const char **error_r ATTR_UNUSED) + const char **error_r) { struct dbox_storage *storage = (struct dbox_storage *)_storage; const struct mail_storage_settings *set = _storage->set; struct fs_settings fs_set; + const char *error; memset(&fs_set, 0, sizeof(fs_set)); fs_set.temp_file_prefix = mailbox_list_get_global_temp_prefix(ns->list); - if (*set->mail_attachment_fs != '\0') T_BEGIN { + if (*set->mail_attachment_fs != '\0') { const char *name, *args, *dir; args = strchr(set->mail_attachment_fs, ' '); @@ -102,8 +103,13 @@ dir = mail_user_home_expand(_storage->user, set->mail_attachment_dir); storage->attachment_dir = p_strdup(_storage->pool, dir); - storage->attachment_fs = fs_init(name, args, &fs_set); - } T_END; + if (fs_init(name, args, &fs_set, &storage->attachment_fs, From dovecot at dovecot.org Tue Sep 18 05:12:38 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 05:12:38 +0300 Subject: dovecot-2.2: lib-fs: Fix to previous API change Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/04580a59dc53 changeset: 15086:04580a59dc53 user: Timo Sirainen date: Tue Sep 18 05:12:28 2012 +0300 description: lib-fs: Fix to previous API change diffstat: src/lib-fs/fs-api.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 8f4ce0932777 -r 04580a59dc53 src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Mon Sep 17 18:13:32 2012 +0300 +++ b/src/lib-fs/fs-api.c Tue Sep 18 05:12:28 2012 +0300 @@ -14,7 +14,6 @@ fs_alloc(const struct fs *fs_class, const char *args, const struct fs_settings *set, struct fs **fs_r, const char **error_r) { - struct fs *fs; char *error_dup = NULL; int ret; @@ -33,7 +32,7 @@ i_free(error_dup); return -1; } - fs->last_error = str_new(default_pool, 64); + (*fs_r)->last_error = str_new(default_pool, 64); return 0; } From pigeonhole at rename-it.nl Tue Sep 18 12:59:53 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 11:59:53 +0200 Subject: dovecot-2.2-pigeonhole: Updated to recent changes in Dovecot. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/e31e89e7791b changeset: 1661:e31e89e7791b user: Stephan Bosch date: Tue Sep 18 11:59:47 2012 +0200 description: Updated to recent changes in Dovecot. diffstat: src/lib-sieve/plugins/body/ext-body-common.c | 2 +- src/lib-sieve/plugins/notify/ext-notify-common.c | 2 +- src/lib-sieve/sieve-script-dict.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diffs (40 lines): diff -r dda9e3c21214 -r e31e89e7791b src/lib-sieve/plugins/body/ext-body-common.c --- a/src/lib-sieve/plugins/body/ext-body-common.c Thu Sep 06 09:00:59 2012 +0200 +++ b/src/lib-sieve/plugins/body/ext-body-common.c Tue Sep 18 11:59:47 2012 +0200 @@ -246,7 +246,7 @@ buffer_set_used_size(ctx->tmp_buffer, 0); /* Initialize body decoder */ - decoder = decode_to_plain ? message_decoder_init(FALSE) : NULL; + decoder = decode_to_plain ? message_decoder_init(NULL, 0) : NULL; //parser = message_parser_init_from_parts(parts, input, 0, //MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS); diff -r dda9e3c21214 -r e31e89e7791b src/lib-sieve/plugins/notify/ext-notify-common.c --- a/src/lib-sieve/plugins/notify/ext-notify-common.c Thu Sep 06 09:00:59 2012 +0200 +++ b/src/lib-sieve/plugins/notify/ext-notify-common.c Tue Sep 18 11:59:47 2012 +0200 @@ -175,7 +175,7 @@ return NULL; /* Initialize body decoder */ - decoder = message_decoder_init(FALSE); + decoder = message_decoder_init(NULL, 0); parser = message_parser_init(mctx->pool, input, 0, 0); is_text = TRUE; diff -r dda9e3c21214 -r e31e89e7791b src/lib-sieve/sieve-script-dict.c --- a/src/lib-sieve/sieve-script-dict.c Thu Sep 06 09:00:59 2012 +0200 +++ b/src/lib-sieve/sieve-script-dict.c Tue Sep 18 11:59:47 2012 +0200 @@ -105,9 +105,9 @@ } script->dict_uri = p_strdup(_script->pool, data); - script->dict = dict_init - (script->dict_uri, DICT_DATA_TYPE_STRING, username, svinst->base_dir); - if ( script->dict == NULL ) { + ret = dict_init(script->dict_uri, DICT_DATA_TYPE_STRING, username, + svinst->base_dir, &script->dict); + if ( ret < 0 ) { sieve_critical(svinst, ehandler, name, "failed to open sieve script", "sieve dict backend: failed to initialize dict with data `%s' " "for user `%s'", data, username); From pigeonhole at rename-it.nl Tue Sep 18 13:11:02 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 12:11:02 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: date extension: composition o... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/fb47824079c7 changeset: 1662:fb47824079c7 user: Stephan Bosch date: Tue Sep 18 12:10:53 2012 +0200 description: lib-sieve: date extension: composition of iso8601 dates is moved to Dovecot. diffstat: src/lib-sieve/plugins/date/ext-date-common.c | 53 +++++---------------------- 1 files changed, 11 insertions(+), 42 deletions(-) diffs (79 lines): diff -r e31e89e7791b -r fb47824079c7 src/lib-sieve/plugins/date/ext-date-common.c --- a/src/lib-sieve/plugins/date/ext-date-common.c Tue Sep 18 11:59:47 2012 +0200 +++ b/src/lib-sieve/plugins/date/ext-date-common.c Tue Sep 18 12:10:53 2012 +0200 @@ -4,6 +4,7 @@ #include "lib.h" #include "utc-offset.h" #include "str.h" +#include "iso8601-date.h" #include "message-date.h" #include "sieve-common.h" @@ -345,7 +346,7 @@ int day = tm->tm_mday; int c, ya, jd; - /* Modified from RFC 5260 Appendix A */ + /* Modified from RFC 5260 Appendix A (refer to Errata) */ if ( month > 2 ) month -= 3; @@ -389,49 +390,17 @@ static const char *ext_date_iso8601_part_get (struct tm *tm, int zone_offset) { - const char *time_offset; + /* From RFC: `The restricted ISO 8601 format is specified by the date-time + * ABNF production given in [RFC3339], Section 5.6, with the added + * restrictions that the letters "T" and "Z" MUST be in upper case, and + * a time zone offset of zero MUST be represented by "Z" and not "+00:00". + */ + if ( zone_offset == 0 ) + zone_offset = INT_MAX; - /* - * RFC 3339: 5.6. Internet Date/Time Format - * - * The following profile of ISO 8601 [ISO8601] dates SHOULD be used in - * new protocols on the Internet. This is specified using the syntax - * description notation defined in [ABNF]. - * - * date-fullyear = 4DIGIT - * date-month = 2DIGIT ; 01-12 - * date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on - * ; month/year - * time-hour = 2DIGIT ; 00-23 - * time-minute = 2DIGIT ; 00-59 - * time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second - * ; rules - * time-secfrac = "." 1*DIGIT - * time-numoffset = ("+" / "-") time-hour ":" time-minute - * time-offset = "Z" / time-numoffset - * - * partial-time = time-hour ":" time-minute ":" time-second - * [time-secfrac] - * full-date = date-fullyear "-" date-month "-" date-mday - * full-time = partial-time time-offset - * - * date-time = full-date "T" full-time - * - */ + return iso8601_date_create_tm(tm, zone_offset); +} - if ( zone_offset == 0 ) - time_offset = "Z"; - else { - int offset = zone_offset > 0 ? zone_offset : -zone_offset; - - time_offset = t_strdup_printf - ("%c%02d:%02d", (zone_offset > 0 ? '+' : '-'), offset / 60, offset % 60); - } - - return t_strdup_printf("%04d-%02d-%02dT%02d:%02d:%02d%s", - tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, - tm->tm_sec, time_offset); -} static const char *ext_date_std11_part_get (struct tm *tm, int zone_offset) From pigeonhole at rename-it.nl Tue Sep 18 15:02:19 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 14:02:19 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: Changed the way Sieve extensi... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/a80af8740468 changeset: 1663:a80af8740468 user: Stephan Bosch date: Tue Sep 18 14:02:12 2012 +0200 description: lib-sieve: Changed the way Sieve extensions are defined to a more compact format. diffstat: src/lib-sieve/ext-encoded-character.c | 8 +- src/lib-sieve/ext-envelope.c | 9 +- src/lib-sieve/ext-fileinto.c | 9 +- src/lib-sieve/ext-reject.c | 18 +--- src/lib-sieve/plugins/body/ext-body.c | 9 +- src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c | 7 +- src/lib-sieve/plugins/copy/ext-copy.c | 7 +- src/lib-sieve/plugins/date/ext-date.c | 12 +-- src/lib-sieve/plugins/editheader/ext-editheader.c | 12 +- src/lib-sieve/plugins/enotify/ext-enotify.c | 9 +- src/lib-sieve/plugins/environment/ext-environment.c | 12 +- src/lib-sieve/plugins/ihave/ext-ihave.c | 14 +-- src/lib-sieve/plugins/imap4flags/ext-imap4flags.c | 9 +- src/lib-sieve/plugins/imap4flags/ext-imapflags.c | 13 +-- src/lib-sieve/plugins/include/ext-include.c | 21 ++--- src/lib-sieve/plugins/mailbox/ext-mailbox.c | 6 +- src/lib-sieve/plugins/notify/ext-notify.c | 10 +- src/lib-sieve/plugins/regex/ext-regex.c | 7 +- src/lib-sieve/plugins/relational/ext-relational.c | 7 +- src/lib-sieve/plugins/spamvirustest/ext-spamvirustest.c | 36 ++++----- src/lib-sieve/plugins/subaddress/ext-subaddress.c | 10 +- src/lib-sieve/plugins/vacation/ext-vacation-seconds.c | 10 +- src/lib-sieve/plugins/vacation/ext-vacation.c | 12 +- src/lib-sieve/plugins/variables/ext-variables.c | 12 +- src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c | 10 +- src/lib-sieve/plugins/vnd.dovecot/duplicate/ext-duplicate.c | 12 +- src/lib-sieve/sieve-address-parts.c | 8 +- src/lib-sieve/sieve-comparators.c | 8 +- src/lib-sieve/sieve-extensions.c | 10 +-- src/lib-sieve/sieve-extensions.h | 28 ++++--- src/lib-sieve/sieve-match-types.c | 8 +- src/testsuite/ext-testsuite.c | 12 +- 32 files changed, 139 insertions(+), 236 deletions(-) diffs (truncated from 726 to 300 lines): diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/ext-encoded-character.c --- a/src/lib-sieve/ext-encoded-character.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/ext-encoded-character.c Tue Sep 18 14:02:12 2012 +0200 @@ -28,12 +28,8 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); struct sieve_extension_def encoded_character_extension = { - "encoded-character", - NULL, NULL, - ext_encoded_character_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_NO_OPERATIONS, - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "encoded-character", + .validator_load = ext_encoded_character_validator_load, }; /* diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/ext-envelope.c --- a/src/lib-sieve/ext-envelope.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/ext-envelope.c Tue Sep 18 14:02:12 2012 +0200 @@ -48,12 +48,9 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def envelope_extension = { - "envelope", - NULL, NULL, - ext_envelope_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATION(envelope_operation), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "envelope", + .validator_load = ext_envelope_validator_load, + SIEVE_EXT_DEFINE_OPERATION(envelope_operation) }; static bool ext_envelope_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/ext-fileinto.c --- a/src/lib-sieve/ext-fileinto.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/ext-fileinto.c Tue Sep 18 14:02:12 2012 +0200 @@ -44,12 +44,9 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def fileinto_extension = { - "fileinto", - NULL, NULL, - ext_fileinto_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATION(fileinto_operation), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "fileinto", + .validator_load = ext_fileinto_validator_load, + SIEVE_EXT_DEFINE_OPERATION(fileinto_operation) }; static bool ext_fileinto_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/ext-reject.c --- a/src/lib-sieve/ext-reject.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/ext-reject.c Tue Sep 18 14:02:12 2012 +0200 @@ -56,12 +56,9 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def reject_extension = { - "reject", - NULL, NULL, - ext_reject_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATION(reject_operation), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "reject", + .validator_load = ext_reject_validator_load, + SIEVE_EXT_DEFINE_OPERATION(reject_operation) }; static bool ext_reject_validator_load @@ -79,12 +76,9 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def ereject_extension = { - "ereject", - NULL, NULL, - ext_ereject_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATION(ereject_operation), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "ereject", + .validator_load = ext_ereject_validator_load, + SIEVE_EXT_DEFINE_OPERATION(ereject_operation) }; static bool ext_ereject_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/body/ext-body.c --- a/src/lib-sieve/plugins/body/ext-body.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/body/ext-body.c Tue Sep 18 14:02:12 2012 +0200 @@ -53,12 +53,9 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def body_extension = { - "body", - NULL, NULL, - ext_body_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATION(body_operation), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "body", + .validator_load = ext_body_validator_load, + SIEVE_EXT_DEFINE_OPERATION(body_operation) }; static bool ext_body_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c --- a/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c Tue Sep 18 14:02:12 2012 +0200 @@ -38,11 +38,8 @@ (const struct sieve_extension *ext, struct sieve_validator *validator); const struct sieve_extension_def comparator_i_ascii_numeric_extension = { - "comparator-i;ascii-numeric", - NULL, NULL, - ext_cmp_i_ascii_numeric_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_NO_OPERATIONS, + .name = "comparator-i;ascii-numeric", + .validator_load = ext_cmp_i_ascii_numeric_validator_load, SIEVE_EXT_DEFINE_OPERAND(my_comparator_operand) }; diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/copy/ext-copy.c --- a/src/lib-sieve/plugins/copy/ext-copy.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/copy/ext-copy.c Tue Sep 18 14:02:12 2012 +0200 @@ -39,11 +39,8 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def copy_extension = { - "copy", - NULL, NULL, - ext_copy_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_NO_OPERATIONS, + .name = "copy", + .validator_load = ext_copy_validator_load, SIEVE_EXT_DEFINE_OPERAND(copy_side_effect_operand) }; diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/date/ext-date.c --- a/src/lib-sieve/plugins/date/ext-date.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/date/ext-date.c Tue Sep 18 14:02:12 2012 +0200 @@ -43,14 +43,10 @@ }; const struct sieve_extension_def date_extension = { - "date", - NULL, NULL, - ext_date_validator_load, - NULL, - ext_date_interpreter_load, - NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATIONS(ext_date_operations), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "date", + .validator_load = ext_date_validator_load, + .interpreter_load = ext_date_interpreter_load, + SIEVE_EXT_DEFINE_OPERATIONS(ext_date_operations) }; static bool ext_date_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/editheader/ext-editheader.c --- a/src/lib-sieve/plugins/editheader/ext-editheader.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/editheader/ext-editheader.c Tue Sep 18 14:02:12 2012 +0200 @@ -45,13 +45,11 @@ (const struct sieve_extension *ext, struct sieve_validator *validator); const struct sieve_extension_def editheader_extension = { - "editheader", - ext_editheader_load, - ext_editheader_unload, - ext_editheader_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATIONS(editheader_operations), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "editheader", + .load = ext_editheader_load, + .unload = ext_editheader_unload, + .validator_load = ext_editheader_validator_load, + SIEVE_EXT_DEFINE_OPERATIONS(editheader_operations) }; static bool ext_editheader_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/enotify/ext-enotify.c --- a/src/lib-sieve/plugins/enotify/ext-enotify.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/enotify/ext-enotify.c Tue Sep 18 14:02:12 2012 +0200 @@ -46,11 +46,10 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def enotify_extension = { - "enotify", - ext_enotify_load, - ext_enotify_unload, - ext_enotify_validator_load, - NULL, NULL, NULL, NULL, NULL, + .name = "enotify", + .load = ext_enotify_load, + .unload = ext_enotify_unload, + .validator_load = ext_enotify_validator_load, SIEVE_EXT_DEFINE_OPERATIONS(ext_enotify_operations), SIEVE_EXT_DEFINE_OPERAND(encodeurl_operand) }; diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/environment/ext-environment.c --- a/src/lib-sieve/plugins/environment/ext-environment.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/environment/ext-environment.c Tue Sep 18 14:02:12 2012 +0200 @@ -32,13 +32,11 @@ (const struct sieve_extension *ext, struct sieve_validator *valdtr); const struct sieve_extension_def environment_extension = { - "environment", - ext_environment_init, - ext_environment_deinit, - ext_environment_validator_load, - NULL, NULL, NULL, NULL, NULL, - SIEVE_EXT_DEFINE_OPERATION(tst_environment_operation), - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "environment", + .load = ext_environment_init, + .unload = ext_environment_deinit, + .validator_load = ext_environment_validator_load, + SIEVE_EXT_DEFINE_OPERATION(tst_environment_operation) }; static bool ext_environment_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/ihave/ext-ihave.c --- a/src/lib-sieve/plugins/ihave/ext-ihave.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/ihave/ext-ihave.c Tue Sep 18 14:02:12 2012 +0200 @@ -34,15 +34,11 @@ const struct sieve_extension_def ihave_extension = { "ihave", - NULL, NULL, - ext_ihave_validator_load, - ext_ihave_generator_load, - NULL, - ext_ihave_binary_load, - ext_ihave_binary_dump, - NULL, - SIEVE_EXT_DEFINE_OPERATION(error_operation), - SIEVE_EXT_DEFINE_NO_OPERANDS + .validator_load = ext_ihave_validator_load, + .generator_load = ext_ihave_generator_load, + .binary_load = ext_ihave_binary_load, + .binary_dump = ext_ihave_binary_dump, + SIEVE_EXT_DEFINE_OPERATION(error_operation) }; static bool ext_ihave_validator_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/imap4flags/ext-imap4flags.c --- a/src/lib-sieve/plugins/imap4flags/ext-imap4flags.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/imap4flags/ext-imap4flags.c Tue Sep 18 14:02:12 2012 +0200 @@ -49,12 +49,9 @@ sieve_size_t *address); const struct sieve_extension_def imap4flags_extension = { - "imap4flags", - NULL, NULL, - ext_imap4flags_validator_load, - NULL, - ext_imap4flags_interpreter_load, - NULL, NULL, NULL, + .name = "imap4flags", + .validator_load = ext_imap4flags_validator_load, + .interpreter_load = ext_imap4flags_interpreter_load, SIEVE_EXT_DEFINE_OPERATIONS(imap4flags_operations), SIEVE_EXT_DEFINE_OPERAND(flags_side_effect_operand) }; diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/imap4flags/ext-imapflags.c --- a/src/lib-sieve/plugins/imap4flags/ext-imapflags.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/imap4flags/ext-imapflags.c Tue Sep 18 14:02:12 2012 +0200 @@ -77,15 +77,10 @@ sieve_size_t *address); const struct sieve_extension_def imapflags_extension = { - "imapflags", - ext_imapflags_load, - NULL, - ext_imapflags_validator_load, - NULL, - ext_imapflags_interpreter_load, - NULL, NULL, NULL, - SIEVE_EXT_DEFINE_NO_OPERATIONS, - SIEVE_EXT_DEFINE_NO_OPERANDS + .name = "imapflags", + .load = ext_imapflags_load, + .validator_load = ext_imapflags_validator_load, + .interpreter_load = ext_imapflags_interpreter_load }; static bool ext_imapflags_load diff -r fb47824079c7 -r a80af8740468 src/lib-sieve/plugins/include/ext-include.c --- a/src/lib-sieve/plugins/include/ext-include.c Tue Sep 18 12:10:53 2012 +0200 +++ b/src/lib-sieve/plugins/include/ext-include.c Tue Sep 18 14:02:12 2012 +0200 @@ -63,17 +63,16 @@ /* Extension objects */ From pigeonhole at rename-it.nl Tue Sep 18 15:38:15 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 14:38:15 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: Added version numbers to Siev... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/47c3b3dd8cf4 changeset: 1664:47c3b3dd8cf4 user: Stephan Bosch date: Tue Sep 18 14:37:55 2012 +0200 description: lib-sieve: Added version numbers to Sieve extensions. Those version numbers are now also stored in the binary, making sure it is recompiled when a new version of an extension is used. This avoids updating the binary version for minor changes to extensions and also makes this work for plugins. diffstat: src/lib-sieve/sieve-binary-file.c | 47 +++++++++++++++++++++++++------------- src/lib-sieve/sieve-binary.h | 4 +- src/lib-sieve/sieve-extensions.h | 9 ++++++- 3 files changed, 41 insertions(+), 19 deletions(-) diffs (152 lines): diff -r a80af8740468 -r 47c3b3dd8cf4 src/lib-sieve/sieve-binary-file.c --- a/src/lib-sieve/sieve-binary-file.c Tue Sep 18 14:02:12 2012 +0200 +++ b/src/lib-sieve/sieve-binary-file.c Tue Sep 18 14:37:55 2012 +0200 @@ -233,11 +233,11 @@ sizeof(struct sieve_binary_block_index) * blk_count, &block_index) ) return FALSE; - /* Create block containing all used extensions - * FIXME: Per-extension this should also store binary version numbers. - */ + /* Create block containing all used extensions */ + ext_block = sieve_binary_block_get(sbin, SBIN_SYSBLOCK_EXTENSIONS); i_assert( ext_block != NULL ); + sieve_binary_block_clear(ext_block); ext_count = array_count(&sbin->linked_extensions); sieve_binary_emit_unsigned(ext_block, ext_count); @@ -248,6 +248,8 @@ sieve_binary_emit_cstring (ext_block, sieve_extension_name((*ext)->extension)); + sieve_binary_emit_unsigned + (ext_block, sieve_extension_version((*ext)->extension)); sieve_binary_emit_unsigned(ext_block, (*ext)->block_id); } @@ -719,38 +721,48 @@ return TRUE; } -static bool _read_extensions(struct sieve_binary_block *sblock) +static int _read_extensions(struct sieve_binary_block *sblock) { struct sieve_binary *sbin = sblock->sbin; sieve_size_t offset = 0; unsigned int i, count; - bool result = TRUE; + bool result = 1; if ( !sieve_binary_read_unsigned(sblock, &offset, &count) ) - return FALSE; + return -1; - for ( i = 0; result && i < count; i++ ) { + for ( i = 0; result > 0 && i < count; i++ ) { T_BEGIN { string_t *extension; const struct sieve_extension *ext; + unsigned int version; if ( sieve_binary_read_string(sblock, &offset, &extension) ) { ext = sieve_extension_get_by_name(sbin->svinst, str_c(extension)); if ( ext == NULL ) { sieve_sys_error(sbin->svinst, - "binary open: binary %s requires unknown extension '%s'", + "binary open: binary %s requires unknown extension `%s'", sbin->path, str_sanitize(str_c(extension), 128)); - result = FALSE; + result = 0; } else { struct sieve_binary_extension_reg *ereg = NULL; (void) sieve_binary_extension_register(sbin, ext, &ereg); - if ( !sieve_binary_read_unsigned(sblock, &offset, &ereg->block_id) ) - result = FALSE; + if ( !sieve_binary_read_unsigned(sblock, &offset, &version) || + !sieve_binary_read_unsigned(sblock, &offset, &ereg->block_id) ) { + result = -1; + } else if ( !sieve_extension_version_is(ext, version) ) { + sieve_sys_debug(sbin->svinst, + "binary open: binary %s was compiled with different version " + "of the `%s' extension (compiled v%d, expected v%d;" + "automatically fixed when re-compiled)", sbin->path, + sieve_extension_name(ext), version, sieve_extension_version(ext)); + result = 0; + } } } else - result = FALSE; + result = -1; } T_END; } @@ -764,6 +776,7 @@ const struct sieve_binary_header *header; struct sieve_binary_block *ext_block; unsigned int i, blk_count; + int ret; /* Verify header */ @@ -838,10 +851,12 @@ ext_block = sieve_binary_block_get(sbin, SBIN_SYSBLOCK_EXTENSIONS); if ( ext_block == NULL ) { result = FALSE; - } else if ( !_read_extensions(ext_block) ) { - sieve_sys_error(sbin->svinst, - "binary open: binary %s is corrupt: failed to load extension block", - sbin->path); + } else if ( (ret=_read_extensions(ext_block)) <= 0 ) { + if ( ret < 0 ) { + sieve_sys_error(sbin->svinst, + "binary open: binary %s is corrupt: failed to load extension block", + sbin->path); + } result = FALSE; } } T_END; diff -r a80af8740468 -r 47c3b3dd8cf4 src/lib-sieve/sieve-binary.h --- a/src/lib-sieve/sieve-binary.h Tue Sep 18 14:02:12 2012 +0200 +++ b/src/lib-sieve/sieve-binary.h Tue Sep 18 14:37:55 2012 +0200 @@ -12,8 +12,8 @@ * Config */ -#define SIEVE_BINARY_VERSION_MAJOR 0 -#define SIEVE_BINARY_VERSION_MINOR 4 +#define SIEVE_BINARY_VERSION_MAJOR 1 +#define SIEVE_BINARY_VERSION_MINOR 0 /* * Binary object diff -r a80af8740468 -r 47c3b3dd8cf4 src/lib-sieve/sieve-extensions.h --- a/src/lib-sieve/sieve-extensions.h Tue Sep 18 14:02:12 2012 +0200 +++ b/src/lib-sieve/sieve-extensions.h Tue Sep 18 14:37:55 2012 +0200 @@ -23,6 +23,9 @@ struct sieve_extension_def { const char *name; + /* Version */ + unsigned int version; + /* Registration */ bool (*load)(const struct sieve_extension *ext, void **context); void (*unload)(const struct sieve_extension *ext); @@ -97,9 +100,13 @@ #define sieve_extension_is(ext, definition) \ ( (ext)->def == &(definition) ) #define sieve_extension_name(ext) \ - (ext)->def->name + ((ext)->def->name) #define sieve_extension_name_is(ext, _name) \ ( strcmp((ext)->def->name, (_name)) == 0 ) +#define sieve_extension_version(ext) \ + ((ext)->def->version) +#define sieve_extension_version_is(ext, _version) \ + ((ext)->def->version == (_version)) /* * Extensions init/deinit From pigeonhole at rename-it.nl Tue Sep 18 15:44:49 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 14:44:49 +0200 Subject: dovecot-2.2-pigeonhole: Minor change to TODO. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/fa9411b742f6 changeset: 1665:fa9411b742f6 user: Stephan Bosch date: Tue Sep 18 14:44:44 2012 +0200 description: Minor change to TODO. diffstat: TODO | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 47c3b3dd8cf4 -r fa9411b742f6 TODO --- a/TODO Tue Sep 18 14:37:55 2012 +0200 +++ b/TODO Tue Sep 18 14:44:44 2012 +0200 @@ -89,8 +89,8 @@ * Warn during compile if using non-existent folders. * Implement IMAP plugin for IMAPSieve support: - - Requires the same Sieve transaction support as the sieve-filter tool needs. - - Requires (IMAP) metadata support in Dovecot. + - Requires some sort of Sieve transaction support. + - Requires (IMAP) METADATA support in Dovecot. - This may include support for manually running a script on a set of messages through IMAP (no specification for something like this is available; we will have to provide our own) From pigeonhole at rename-it.nl Tue Sep 18 17:14:16 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 16:14:16 +0200 Subject: dovecot-2.1-pigeonhole: Released v0.3.2 for Dovecot v2.1.9. Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/265061e0d3f4 changeset: 1644:265061e0d3f4 user: Stephan Bosch date: Tue Sep 18 16:12:44 2012 +0200 description: Released v0.3.2 for Dovecot v2.1.9. diffstat: configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (9 lines): diff -r 0505fc4b10c4 -r 265061e0d3f4 configure.in --- a/configure.in Tue Sep 18 16:01:48 2012 +0200 +++ b/configure.in Tue Sep 18 16:12:44 2012 +0200 @@ -1,4 +1,4 @@ -AC_INIT([Pigeonhole], [0.3.1], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) +AC_INIT([Pigeonhole], [0.3.2], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) From pigeonhole at rename-it.nl Tue Sep 18 17:14:16 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 16:14:16 +0200 Subject: dovecot-2.1-pigeonhole: Updated NEWS file for next release. Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/0505fc4b10c4 changeset: 1643:0505fc4b10c4 user: Stephan Bosch date: Tue Sep 18 16:01:48 2012 +0200 description: Updated NEWS file for next release. diffstat: NEWS | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diffs (25 lines): diff -r b1bedb88e615 -r 0505fc4b10c4 NEWS --- a/NEWS Sun Sep 09 10:45:46 2012 +0200 +++ b/NEWS Tue Sep 18 16:01:48 2012 +0200 @@ -1,3 +1,21 @@ +v0.3.2 18-09-2012 Stephan Bosch + + + sieve-refilter tool: improved man page documentation by explicitly + specifying the syntax used for mailbox arguments. + + Sieve: spamtest and virustest extensions: improved trace debugging of score + calculation. + + Sieve: made error messages about exceeding the maximum number of actions + more verbose. + - Sieve tools: fixed problems with running as root: sievec and sieve-dump now + ignore mail_uid and mail_gid settings when run as root. + - Sieve: fixed bug in action accounting (for limit checking): increase action + instance count only when an action is actually created. + - Sieve: include extension: fixed namespace separation of :global and + :personal scripts. + - ManageSieve: fixed segfault bug triggered by CHECKSCRIPT command. + - Fixed linking with ld.gold. + - Fixed several Clang compile warnings and a few potential bugs. + v0.3.1 25-05-2012 Stephan Bosch * Added support for retrieving Sieve scripts from dict lookup. This means that From pigeonhole at rename-it.nl Tue Sep 18 17:14:16 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 16:14:16 +0200 Subject: dovecot-2.1-pigeonhole: Added tag 0.3.2 for changeset 265061e0d3f4 Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/2dbb17d08591 changeset: 1645:2dbb17d08591 user: Stephan Bosch date: Tue Sep 18 16:13:09 2012 +0200 description: Added tag 0.3.2 for changeset 265061e0d3f4 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 265061e0d3f4 -r 2dbb17d08591 .hgtags --- a/.hgtags Tue Sep 18 16:12:44 2012 +0200 +++ b/.hgtags Tue Sep 18 16:13:09 2012 +0200 @@ -11,3 +11,4 @@ 873baa85e2202f45a9c14fa21cccedc60f3715bc 0.2.5 fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0.3.0 e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0.3.1 +265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0.3.2 From pigeonhole at rename-it.nl Tue Sep 18 17:21:01 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 16:21:01 +0200 Subject: dovecot-2.1-pigeonhole: Added signature for changeset 265061e0d3f4 Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/2347ddfd9057 changeset: 1646:2347ddfd9057 user: Stephan Bosch date: Tue Sep 18 16:20:22 2012 +0200 description: Added signature for changeset 265061e0d3f4 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 2dbb17d08591 -r 2347ddfd9057 .hgsigs --- a/.hgsigs Tue Sep 18 16:13:09 2012 +0200 +++ b/.hgsigs Tue Sep 18 16:20:22 2012 +0200 @@ -5,3 +5,4 @@ 873baa85e2202f45a9c14fa21cccedc60f3715bc 0 iQEcBAABAgAGBQJOx9MCAAoJEATWKx49+7T09aUIANIKsuzM3bGhtGJ/UPIwzpOu39lEGCmHah6dMa+bDOoCZhuhASDdTuvRKXTfGC57GMu+NzBK6I7heFiPD3E4VTI4xOCK1azJ9G4SsiDEkQThucXqWBKDjPB0RgOEf6iefAkslXIU3cprJgattwpeXbUKiHjBhoYJFJ5j/GTx1B62ndvaTfMu1zF5UppiyRG1rQD7FLY4f6kANzSI2jOOCBs4UFH7ZKhafO1AeQfLNDvxdDczZafPZxrCIF+5JCNvQ6Xue/JrvRZQ0V9sxLQat7clUJ6I6Ejl5u5l1LF+VscWldfaQKwDdOktCVux84YGH8+XqXaukMiEg6j4hceAYIM= fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0 iQEcBAABAgAGBQJPPXAPAAoJEATWKx49+7T0iqMH/3e+RKKmryOz5pak0cvdPcS/D9O9xl2l6SuoE2okTq/WOrDtZ1xDg0afg7t27D9mDfUY1hiSFS4ekN3WP620Gcb9wlL3FC+rLEYmiE8iSfZvsH+FeLa7n8NB+XdnAsXE1WdLQp5CSKEh3sXIod7Q04PL0uv/rimGS9jOGcAufW3y9QAYd+DVorPS4lV5Kz8qIqY9r/0lLqhJN1ukIJtClVkFanRljd+SfoHFFOSWbQjCKNxlOSWFhwJji7Mp091A1+N6JoZe4IMIlajMsM2Ypp726Y2LA/du+uRVFjKgta65eP9tfdrmVCJtrjIjvikowD5Zl80GuVRI5j44aQ7rJ3A= e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0 iQEcBAABAgAGBQJPwAS+AAoJEATWKx49+7T0ngIH/R+teyHN4Pdv4bFTkder85rxy4bzPDzlV9gGlhuKuRBtI8F7CKKWLEP/ESPdtZbMmsNj9k104q2U9pgUfkYrVKL4lrk3hlz44o8Smpwp/xrxyNY8/OuBof0LvyXjp7unHAvvAWFiEmeTpJMmSu77xE8wsEqZowHi8/Igh3lrQ3U129VP1xWr1mvnvQdMQk9TTMK3T38H9kUrz2CRdOWjJbxAA4rLyozGLqWUeSKepUcwAGANd35k8pNLYiONlGU8NZsQyzS2dfOl0TeolgqZn+UkmM9FZFFnD40WU8zPft0nK4g8cFZGObX4fsPyK03EAnR7BXd1BKdmr7jdppAnSvQ= +265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0 iQEcBAABAgAGBQJQWIMhAAoJEATWKx49+7T0g/IH/3qqQemBP62Y+Wzo67DruphrJ5HSlIX4Uw/O4rOjrk8dWSMrsui5jFy4LXig+CR1dfY4RS0izTxsAiNhTACuavMfGHiYBKQW6UwIDlKECVBxbQyjB7v2C3FKPj9K9QReiYACSeB1RhQBnpbcvioif9H62VI5SKE6rjXyky6fDAxtbjhySb+nPDtV4HmV7ukcfDc3bxwcZkz9XXKoNmPWw8r34Z/RwxWbbWr8xUwW3+9LDB2Oz6PRyYP5S8EcNNYjk3ai2Llh0xuJGLQbpulhmjYDJmk20TkpLCFAfsYq1qW3yed9lL88CcFH4LDb9WA0LNs+7PfbmY/m8CX7JwUmHB8= From dovecot at dovecot.org Tue Sep 18 18:45:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 18:45:16 +0300 Subject: dovecot-2.1: lib-storage: MAILBOX_LIST_ITER_SKIP_ALIASES now ski... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/eff1d11ce14b changeset: 14706:eff1d11ce14b user: Timo Sirainen date: Tue Sep 18 18:40:17 2012 +0300 description: lib-storage: MAILBOX_LIST_ITER_SKIP_ALIASES now skips also "alias symlinks" An "alias symlink" is a symlink that points to the same directory. These can safely be skipped when iterating through all mails in all mailboxes (unlike other symlinks that may point to external storages). diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 6 ++++ src/lib-storage/list/mailbox-list-maildir-iter.c | 5 +++ src/lib-storage/mailbox-guid-cache.c | 1 + src/lib-storage/mailbox-list-private.h | 3 ++ src/lib-storage/mailbox-list.c | 33 ++++++++++++++++++++++++ src/lib-storage/mailbox-list.h | 4 ++- 6 files changed, 51 insertions(+), 1 deletions(-) diffs (112 lines): diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Tue Sep 18 18:40:17 2012 +0300 @@ -183,6 +183,12 @@ /* mailbox doesn't match any patterns, we don't care about it */ return 0; } + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SKIP_ALIASES) != 0) { + ret = mailbox_list_dirent_is_alias_symlink(ctx->ctx.list, + dir_path, d); + if (ret != 0) + return ret < 0 ? -1 : 0; + } ret = ctx->ctx.list->v. get_mailbox_flags(ctx->ctx.list, dir_path, d->d_name, mailbox_list_get_file_type(d), &info_flags); diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/list/mailbox-list-maildir-iter.c --- a/src/lib-storage/list/mailbox-list-maildir-iter.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir-iter.c Tue Sep 18 18:40:17 2012 +0300 @@ -323,6 +323,11 @@ if (maildir_delete_trash_dir(ctx, fname)) return 0; + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SKIP_ALIASES) != 0) { + ret = mailbox_list_dirent_is_alias_symlink(list, ctx->dir, d); + if (ret != 0) + return ret < 0 ? -1 : 0; + } T_BEGIN { ret = list->v.get_mailbox_flags(list, ctx->dir, fname, mailbox_list_get_file_type(d), &flags); diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-guid-cache.c --- a/src/lib-storage/mailbox-guid-cache.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-guid-cache.c Tue Sep 18 18:40:17 2012 +0300 @@ -56,6 +56,7 @@ list->guid_cache_errors = FALSE; ctx = mailbox_list_iter_init(list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_NO_AUTO_BOXES); while ((info = mailbox_list_iter_next(ctx)) != NULL) { if ((info->flags & diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-list-private.h --- a/src/lib-storage/mailbox-list-private.h Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-list-private.h Tue Sep 18 18:40:17 2012 +0300 @@ -192,6 +192,9 @@ bool mailbox_list_name_is_too_large(const char *name, char sep); enum mailbox_list_file_type mailbox_list_get_file_type(const struct dirent *d); +int mailbox_list_dirent_is_alias_symlink(struct mailbox_list *list, + const char *dir_path, + const struct dirent *d); bool mailbox_list_try_get_absolute_path(struct mailbox_list *list, const char **name); int mailbox_list_create_missing_index_dir(struct mailbox_list *list, diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Sep 18 18:40:17 2012 +0300 @@ -1282,6 +1282,39 @@ return type; } +int mailbox_list_dirent_is_alias_symlink(struct mailbox_list *list, + const char *dir_path, + const struct dirent *d) +{ + struct stat st; + int ret; + + if (mailbox_list_get_file_type(d) == MAILBOX_LIST_FILE_TYPE_SYMLINK) + return 1; + + T_BEGIN { + const char *path, *readlink; + + path = t_strconcat(dir_path, "/", d->d_name, NULL); + if (lstat(path, &st) < 0) { + mailbox_list_set_critical(list, + "lstat(%s) failed: %m", path); + ret = -1; + } else if (!S_ISLNK(st.st_mode)) { + ret = 0; + } else if (t_readlink(path, &linkpath) < 0) { + i_error("readlink(%s) failed: %m", path); + ret = -1; + } else { + /* it's an alias only if it points to the same + directory */ + ret = strchr(linkpath, '/') == NULL ? 1 : 0; + } + } T_END; + return ret; +} + + static bool mailbox_list_try_get_home_path(struct mailbox_list *list, const char **name) { diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-list.h Tue Sep 18 18:40:17 2012 +0300 @@ -64,7 +64,9 @@ physically exist */ MAILBOX_LIST_ITER_NO_AUTO_BOXES = 0x000004, - /* For mailbox_list_iter_init_namespaces(): Skip namespaces that + /* Skip all kinds of mailbox aliases. This typically includes symlinks + that point to the same directory. Also when iterating with + mailbox_list_iter_init_namespaces() skip namespaces that have alias_for set. */ MAILBOX_LIST_ITER_SKIP_ALIASES = 0x000008, /* For mailbox_list_iter_init_namespaces(): '*' in a pattern doesn't From dovecot at dovecot.org Tue Sep 18 18:45:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 18:45:16 +0300 Subject: dovecot-2.1: quota: Skip alias symlinks when calculating quota Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1937b38f50f0 changeset: 14707:1937b38f50f0 user: Timo Sirainen date: Tue Sep 18 18:40:46 2012 +0300 description: quota: Skip alias symlinks when calculating quota diffstat: src/plugins/quota/quota-count.c | 1 + src/plugins/quota/quota-maildir.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diffs (22 lines): diff -r eff1d11ce14b -r 1937b38f50f0 src/plugins/quota/quota-count.c --- a/src/plugins/quota/quota-count.c Tue Sep 18 18:40:17 2012 +0300 +++ b/src/plugins/quota/quota-count.c Tue Sep 18 18:40:46 2012 +0300 @@ -71,6 +71,7 @@ int ret = 0; ctx = mailbox_list_iter_init(ns->list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_RETURN_NO_FLAGS); while ((info = mailbox_list_iter_next(ctx)) != NULL) { if ((info->flags & (MAILBOX_NONEXISTENT | diff -r eff1d11ce14b -r 1937b38f50f0 src/plugins/quota/quota-maildir.c --- a/src/plugins/quota/quota-maildir.c Tue Sep 18 18:40:17 2012 +0300 +++ b/src/plugins/quota/quota-maildir.c Tue Sep 18 18:40:46 2012 +0300 @@ -131,6 +131,7 @@ ctx->path = str_new(default_pool, 512); ctx->list = list; ctx->iter = mailbox_list_iter_init(list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_RETURN_NO_FLAGS); return ctx; } From dovecot at dovecot.org Tue Sep 18 18:45:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 18:45:16 +0300 Subject: dovecot-2.1: fts-solr: Skip alias symlinks when rescanning. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/45773a09dcf2 changeset: 14708:45773a09dcf2 user: Timo Sirainen date: Tue Sep 18 18:41:01 2012 +0300 description: fts-solr: Skip alias symlinks when rescanning. diffstat: src/plugins/fts-solr/fts-backend-solr.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 1937b38f50f0 -r 45773a09dcf2 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Tue Sep 18 18:40:46 2012 +0300 +++ b/src/plugins/fts-solr/fts-backend-solr.c Tue Sep 18 18:41:01 2012 +0300 @@ -570,6 +570,7 @@ /* FIXME: proper rescan needed. for now we'll just reset the last-uids */ iter = mailbox_list_iter_init(backend->ns->list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_NO_AUTO_BOXES); while ((info = mailbox_list_iter_next(iter)) != NULL) { if ((info->flags & From dovecot at dovecot.org Tue Sep 18 18:45:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 18:45:16 +0300 Subject: dovecot-2.1: Added mailbox-alias plugin. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f5bb9f6b304d changeset: 14709:f5bb9f6b304d user: Timo Sirainen date: Tue Sep 18 18:44:46 2012 +0300 description: Added mailbox-alias plugin. Aliases can be created like: plugin { mailbox_alias_old = Sent mailbox_alias_new = Sent Messages mailbox_alias_old2 = Sent mailbox_alias_new2 = Sent Items } When creating an alias, the original mailbox is also created. The alias itself is a symlink to the original. Deleting an alias deletes the symlink. The original mailbox can't be deleted or renamed while it has aliases. Aliases cannot be renamed. Aliases are skipped when recalculating quota. If a mailbox with the alias's name was already created before the aliasing was enabled, it's not treated as alias until it's first deleted. diffstat: configure.in | 1 + src/plugins/Makefile.am | 1 + src/plugins/mailbox-alias/Makefile.am | 18 + src/plugins/mailbox-alias/mailbox-alias-plugin.c | 335 +++++++++++++++++++++++ src/plugins/mailbox-alias/mailbox-alias-plugin.h | 7 + 5 files changed, 362 insertions(+), 0 deletions(-) diffs (truncated from 394 to 300 lines): diff -r 45773a09dcf2 -r f5bb9f6b304d configure.in --- a/configure.in Tue Sep 18 18:41:01 2012 +0300 +++ b/configure.in Tue Sep 18 18:44:46 2012 +0300 @@ -2806,6 +2806,7 @@ src/plugins/lazy-expunge/Makefile src/plugins/listescape/Makefile src/plugins/mail-log/Makefile +src/plugins/mailbox-alias/Makefile src/plugins/notify/Makefile src/plugins/pop3-migration/Makefile src/plugins/quota/Makefile diff -r 45773a09dcf2 -r f5bb9f6b304d src/plugins/Makefile.am --- a/src/plugins/Makefile.am Tue Sep 18 18:41:01 2012 +0300 +++ b/src/plugins/Makefile.am Tue Sep 18 18:44:46 2012 +0300 @@ -21,6 +21,7 @@ listescape \ notify \ mail-log \ + mailbox-alias \ quota \ imap-quota \ pop3-migration \ diff -r 45773a09dcf2 -r f5bb9f6b304d src/plugins/mailbox-alias/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins/mailbox-alias/Makefile.am Tue Sep 18 18:44:46 2012 +0300 @@ -0,0 +1,18 @@ +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-imap \ + -I$(top_srcdir)/src/lib-index \ + -I$(top_srcdir)/src/lib-storage + +NOPLUGIN_LDFLAGS = +lib20_mailbox_alias_plugin_la_LDFLAGS = -module -avoid-version + +module_LTLIBRARIES = \ + lib20_mailbox_alias_plugin.la + +lib20_mailbox_alias_plugin_la_SOURCES = \ + mailbox-alias-plugin.c + +noinst_HEADERS = \ + mailbox-alias-plugin.h diff -r 45773a09dcf2 -r f5bb9f6b304d src/plugins/mailbox-alias/mailbox-alias-plugin.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins/mailbox-alias/mailbox-alias-plugin.c Tue Sep 18 18:44:46 2012 +0300 @@ -0,0 +1,335 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "str.h" +#include "mail-storage-hooks.h" +#include "mail-storage-private.h" +#include "mailbox-list-private.h" +#include "mailbox-alias-plugin.h" + +#define MAILBOX_ALIAS_USER_CONTEXT(obj) \ + MODULE_CONTEXT(obj, mailbox_alias_user_module) +#define MAILBOX_ALIAS_CONTEXT(obj) \ + MODULE_CONTEXT(obj, mailbox_alias_storage_module) +#define MAILBOX_ALIAS_LIST_CONTEXT(obj) \ + MODULE_CONTEXT(obj, mailbox_alias_mailbox_list_module) + +struct mailbox_alias { + const char *old_vname, *new_vname; +}; + +struct mailbox_alias_user { + union mail_user_module_context module_ctx; + + ARRAY_DEFINE(aliases, struct mailbox_alias); +}; + +struct mailbox_alias_mailbox_list { + union mailbox_list_module_context module_ctx; +}; + +struct mailbox_alias_mailbox { + union mailbox_module_context module_ctx; +}; + +enum mailbox_symlink_existence { + MAILBOX_SYMLINK_EXISTENCE_NONEXISTENT, + MAILBOX_SYMLINK_EXISTENCE_SYMLINK, + MAILBOX_SYMLINK_EXISTENCE_NOT_SYMLINK +}; + +static MODULE_CONTEXT_DEFINE_INIT(mailbox_alias_user_module, + &mail_user_module_register); +static MODULE_CONTEXT_DEFINE_INIT(mailbox_alias_storage_module, + &mail_storage_module_register); +static MODULE_CONTEXT_DEFINE_INIT(mailbox_alias_mailbox_list_module, + &mailbox_list_module_register); + +const char *mailbox_alias_plugin_version = DOVECOT_VERSION; + +static const char * +mailbox_alias_find_new(struct mail_user *user, const char *new_vname) +{ + struct mailbox_alias_user *auser = MAILBOX_ALIAS_USER_CONTEXT(user); + const struct mailbox_alias *alias; + + array_foreach(&auser->aliases, alias) { + if (strcmp(alias->new_vname, new_vname) == 0) + return alias->old_vname; + } + return NULL; +} + +static int mailbox_symlink_exists(struct mailbox_list *list, const char *vname, + enum mailbox_symlink_existence *existence_r) +{ + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(list); + struct stat st; + const char *symlink_name, *symlink_path; + + symlink_name = alist->module_ctx.super.get_storage_name(list, vname); + symlink_path = mailbox_list_get_path(list, symlink_name, + MAILBOX_LIST_PATH_TYPE_DIR); + if (lstat(symlink_path, &st) < 0) { + if (errno == ENOENT) { + *existence_r = MAILBOX_SYMLINK_EXISTENCE_NONEXISTENT; + return 0; + } + mailbox_list_set_critical(list, + "lstat(%s) failed: %m", symlink_path); + return -1; + } + if (S_ISLNK(st.st_mode)) + *existence_r = MAILBOX_SYMLINK_EXISTENCE_SYMLINK; + else + *existence_r = MAILBOX_SYMLINK_EXISTENCE_NOT_SYMLINK; + return 0; +} + +static int mailbox_is_alias_symlink(struct mailbox *box) +{ + enum mailbox_symlink_existence existence; + + if (mailbox_alias_find_new(box->storage->user, box->vname) == NULL) + return 0; + if (mailbox_symlink_exists(box->list, box->vname, &existence) < 0) { + mail_storage_copy_list_error(box->storage, box->list); + return -1; + } + return existence == MAILBOX_SYMLINK_EXISTENCE_SYMLINK ? 1 : 0; +} + +static int +mailbox_has_aliases(struct mailbox_list *list, const char *old_vname) +{ + struct mailbox_alias_user *auser = + MAILBOX_ALIAS_USER_CONTEXT(list->ns->user); + const struct mailbox_alias *alias; + enum mailbox_symlink_existence existence; + int ret = 0; + + array_foreach(&auser->aliases, alias) { + if (strcmp(alias->old_vname, old_vname) == 0) { + if (mailbox_symlink_exists(list, alias->new_vname, + &existence) < 0) + ret = -1; + if (existence == MAILBOX_SYMLINK_EXISTENCE_SYMLINK) + return 1; + } + } + return ret; +} + +static int +mailbox_alias_create_symlink(struct mailbox *box, + const char *old_name, const char *new_name) +{ + const char *old_path, *new_path, *fname; + + old_path = mailbox_list_get_path(box->list, old_name, + MAILBOX_LIST_PATH_TYPE_DIR); + new_path = mailbox_list_get_path(box->list, new_name, + MAILBOX_LIST_PATH_TYPE_DIR); + fname = strrchr(old_path, '/'); + i_assert(fname != NULL); + fname++; + i_assert(strncmp(new_path, old_path, fname-old_path) == 0); + + if (symlink(fname, new_path) < 0) { + if (errno == EEXIST) { + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "Mailbox already exists"); + return -1; + } + mail_storage_set_critical(box->storage, + "symlink(%s, %s) failed: %m", fname, new_path); + return -1; + } + return 0; +} + +static const char * +mailbox_alias_get_storage_name(struct mailbox_list *list, const char *vname) +{ + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(list); + const char *old_vname; + enum mailbox_symlink_existence existence; + + /* access the old mailbox so that e.g. full text search won't + index the mailbox twice. this also means that deletion must be + careful to delete the symlink, box->name. */ + old_vname = mailbox_alias_find_new(list->ns->user, vname); + if (old_vname != NULL && + mailbox_symlink_exists(list, vname, &existence) == 0 && + existence != MAILBOX_SYMLINK_EXISTENCE_NOT_SYMLINK) + vname = old_vname; + + return alist->module_ctx.super.get_storage_name(list, vname); +} + +static int +mailbox_alias_create(struct mailbox *box, const struct mailbox_update *update, + bool directory) +{ + struct mailbox_alias_mailbox *abox = MAILBOX_ALIAS_CONTEXT(box); + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(box->list); + const char *symlink_name; + int ret; + + ret = abox->module_ctx.super.create(box, update, directory); + if (mailbox_alias_find_new(box->storage->user, box->vname) == NULL) + return ret; + if (ret < 0 && mailbox_get_last_mail_error(box) != MAIL_ERROR_EXISTS) + return ret; + + /* all the code so far has actually only created the original + mailbox. now we'll create the symlink if it's missing. */ + symlink_name = alist->module_ctx.super. + get_storage_name(box->list, box->vname); + return mailbox_alias_create_symlink(box, box->name, symlink_name); +} + +static int mailbox_alias_delete(struct mailbox *box) +{ + struct mailbox_alias_mailbox *abox = MAILBOX_ALIAS_CONTEXT(box); + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(box->list); + const char *symlink_name; + int ret; + + ret = mailbox_has_aliases(box->list, box->vname); + if (ret < 0) + return -1; + if (ret > 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't delete mailbox while it has aliases"); + return -1; + } + + if (mailbox_is_alias_symlink(box)) { + /* we're deleting an alias mailbox. we'll need to handle this + explicitly since box->name points to the original mailbox */ + symlink_name = alist->module_ctx.super. + get_storage_name(box->list, box->vname); + if (mailbox_list_delete_symlink(box->list, symlink_name) < 0) { + mail_storage_copy_list_error(box->storage, box->list); + return -1; + } + return 0; + } + + return abox->module_ctx.super.delete(box); +} + +static int mailbox_alias_rename(struct mailbox *src, struct mailbox *dest, + bool rename_children) +{ + struct mailbox_alias_mailbox *abox = MAILBOX_ALIAS_CONTEXT(src); + int ret; + + if (mailbox_is_alias_symlink(src)) { + mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't rename alias mailboxes"); + return -1; + } + if (mailbox_is_alias_symlink(dest)) { + mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't rename to mailbox alias"); + return -1; + } + ret = mailbox_has_aliases(src->list, src->vname); + if (ret < 0) + return -1; + if (ret > 0) { + mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't rename mailbox while it has aliases"); + return -1; + } + + return abox->module_ctx.super.rename(src, dest, rename_children); From dovecot at dovecot.org Tue Sep 18 19:16:21 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 19:16:21 +0300 Subject: dovecot-2.1: quota: Allow negative percentage rules up to -99% Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/74d639b2a5bf changeset: 14710:74d639b2a5bf user: Timo Sirainen date: Tue Sep 18 19:16:04 2012 +0300 description: quota: Allow negative percentage rules up to -99% diffstat: src/plugins/quota/quota-private.h | 2 +- src/plugins/quota/quota.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diffs (36 lines): diff -r f5bb9f6b304d -r 74d639b2a5bf src/plugins/quota/quota-private.h --- a/src/plugins/quota/quota-private.h Tue Sep 18 18:44:46 2012 +0300 +++ b/src/plugins/quota/quota-private.h Tue Sep 18 19:16:04 2012 +0300 @@ -34,7 +34,7 @@ int64_t bytes_limit, count_limit; /* relative to default_rule */ - unsigned int bytes_percent, count_percent; + int bytes_percent, count_percent; /* Don't include this mailbox in quota */ unsigned int ignore:1; diff -r f5bb9f6b304d -r 74d639b2a5bf src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Tue Sep 18 18:44:46 2012 +0300 +++ b/src/plugins/quota/quota.c Tue Sep 18 19:16:04 2012 +0300 @@ -361,7 +361,7 @@ { int64_t percentage = *limit; - if (percentage <= 0 || percentage >= -1U) { + if (percentage <= -100 || percentage >= -1U) { *error_r = p_strdup_printf(root_set->set->pool, "Invalid rule percentage: %lld", (long long)percentage); return -1; @@ -385,9 +385,9 @@ quota_rule_recalculate_relative_rules(struct quota_rule *rule, int64_t bytes_limit, int64_t count_limit) { - if (rule->bytes_percent > 0) + if (rule->bytes_percent != 0) rule->bytes_limit = bytes_limit * rule->bytes_percent / 100; - if (rule->count_percent > 0) + if (rule->count_percent != 0) rule->count_limit = count_limit * rule->count_percent / 100; } From dovecot at dovecot.org Tue Sep 18 19:58:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 19:58:05 +0300 Subject: dovecot-2.1: auth: userdb static used auth caching wrong when ve... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c38060f0ad58 changeset: 14711:c38060f0ad58 user: Timo Sirainen date: Tue Sep 18 19:57:48 2012 +0300 description: auth: userdb static used auth caching wrong when verifying user existence with passdb lookup. Cache entries were being looked/added for userdbs instead of passdbs. This caused problems at least with: a) Multiple userdbs (where static userdb was the last). Passdb results were added as cache entries to the first userdbs, possibly causing some confusion. b) Multiple passdbs, because the first passdb result was added to cache and used for the rest of the passdbs. diffstat: src/auth/userdb-static.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (23 lines): diff -r 74d639b2a5bf -r c38060f0ad58 src/auth/userdb-static.c --- a/src/auth/userdb-static.c Tue Sep 18 19:16:04 2012 +0300 +++ b/src/auth/userdb-static.c Tue Sep 18 19:57:48 2012 +0300 @@ -42,6 +42,8 @@ { struct static_context *ctx = auth_request->context; + auth_request->userdb_lookup = TRUE; + auth_request->private_callback.userdb = ctx->old_callback; auth_request->context = ctx->old_context; auth_request_set_state(auth_request, AUTH_REQUEST_STATE_USERDB); @@ -92,6 +94,10 @@ auth_request->context = ctx; if (auth_request->passdb != NULL) { + /* kludge: temporarily work as if we weren't doing + a userdb lookup. this is to get auth cache to use + passdb caching instead of userdb caching. */ + auth_request->userdb_lookup = FALSE; auth_request_lookup_credentials(auth_request, "", static_credentials_callback); } else { From dovecot at dovecot.org Tue Sep 18 20:07:02 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 20:07:02 +0300 Subject: dovecot-2.1: lib-storage: Compiling fix for previous alias symli... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/be5b1256bf57 changeset: 14712:be5b1256bf57 user: Timo Sirainen date: Tue Sep 18 20:06:56 2012 +0300 description: lib-storage: Compiling fix for previous alias symlink change diffstat: src/lib-storage/mailbox-list.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (20 lines): diff -r c38060f0ad58 -r be5b1256bf57 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Sep 18 19:57:48 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Sep 18 20:06:56 2012 +0300 @@ -2,6 +2,7 @@ #include "lib.h" #include "array.h" +#include "abspath.h" #include "ioloop.h" #include "mkdir-parents.h" #include "str.h" @@ -1293,7 +1294,7 @@ return 1; T_BEGIN { - const char *path, *readlink; + const char *path, *linkpath; path = t_strconcat(dir_path, "/", d->d_name, NULL); if (lstat(path, &st) < 0) { From dovecot at dovecot.org Tue Sep 18 20:09:09 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 20:09:09 +0300 Subject: dovecot-2.1: Backported parts of normalizer_func_t changes from ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/99305e4dd403 changeset: 14713:99305e4dd403 user: Timo Sirainen date: Tue Sep 18 20:07:21 2012 +0300 description: Backported parts of normalizer_func_t changes from v2.2 tree. diffstat: src/lib-storage/mail-storage-private.h | 2 ++ src/lib-storage/mail-user.c | 1 + src/lib-storage/mail-user.h | 2 ++ src/lib/unichar.h | 6 ++++++ 4 files changed, 11 insertions(+), 0 deletions(-) diffs (65 lines): diff -r be5b1256bf57 -r 99305e4dd403 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib-storage/mail-storage-private.h Tue Sep 18 20:07:21 2012 +0300 @@ -2,6 +2,7 @@ #define MAIL_STORAGE_PRIVATE_H #include "module-context.h" +#include "unichar.h" #include "file-lock.h" #include "mail-storage.h" #include "mail-storage-hooks.h" @@ -416,6 +417,7 @@ struct mail_search_sort_program *sort_program; enum mail_fetch_field wanted_fields; struct mailbox_header_lookup_ctx *wanted_headers; + normalizer_func_t *normalizer; /* if non-NULL, specifies that a search resulting is being updated. this can be used as a search optimization: if searched message diff -r be5b1256bf57 -r 99305e4dd403 src/lib-storage/mail-user.c --- a/src/lib-storage/mail-user.c Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib-storage/mail-user.c Tue Sep 18 20:07:21 2012 +0300 @@ -51,6 +51,7 @@ user->unexpanded_set = settings_dup(set_info, set, pool); user->set = settings_dup(set_info, set, pool); user->service = master_service_get_name(master_service); + user->default_normalizer = uni_utf8_to_decomposed_titlecase; /* check settings so that the duplicated structure will again contain the parsed fields */ diff -r be5b1256bf57 -r 99305e4dd403 src/lib-storage/mail-user.h --- a/src/lib-storage/mail-user.h Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib-storage/mail-user.h Tue Sep 18 20:07:21 2012 +0300 @@ -1,6 +1,7 @@ #ifndef MAIL_USER_H #define MAIL_USER_H +#include "unichar.h" #include "mail-storage-settings.h" struct module; @@ -36,6 +37,7 @@ ARRAY_DEFINE(hooks, const struct mail_storage_hooks *); struct mountpoint_list *mountpoints; + normalizer_func_t *default_normalizer; /* Module-specific contexts. See mail_storage_module_id. */ ARRAY_DEFINE(module_contexts, union mail_user_module_context *); diff -r be5b1256bf57 -r 99305e4dd403 src/lib/unichar.h --- a/src/lib/unichar.h Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib/unichar.h Tue Sep 18 20:07:21 2012 +0300 @@ -27,6 +27,12 @@ typedef uint32_t unichar_t; ARRAY_DEFINE_TYPE(unichars, unichar_t); +/* Normalize UTF8 input and append it to output buffer. + Returns 0 if ok, -1 if input was invalid. Even if input was invalid, + as much as possible should be added to output. */ +typedef int normalizer_func_t(const void *input, size_t size, + buffer_t *output); + extern const unsigned char utf8_replacement_char[UTF8_REPLACEMENT_CHAR_LEN]; extern const uint8_t *const uni_utf8_non1_bytes; From dovecot at dovecot.org Tue Sep 18 20:09:09 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 20:09:09 +0300 Subject: dovecot-2.1: fts-lucene: Added "normalize" option to put data th... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a200fdbc1fa0 changeset: 14714:a200fdbc1fa0 user: Timo Sirainen date: Tue Sep 18 20:09:03 2012 +0300 description: fts-lucene: Added "normalize" option to put data through user's normalizer function. diffstat: src/plugins/fts-lucene/Snowball.cc | 30 +++++++++++++++++++++++------- src/plugins/fts-lucene/SnowballAnalyzer.h | 7 ++++++- src/plugins/fts-lucene/SnowballFilter.h | 3 ++- 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 | 12 ++++++++++-- 6 files changed, 51 insertions(+), 11 deletions(-) diffs (217 lines): diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/Snowball.cc --- a/src/plugins/fts-lucene/Snowball.cc Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/Snowball.cc Tue Sep 18 20:09:03 2012 +0300 @@ -26,8 +26,9 @@ CL_NS_DEF2(analysis,snowball) /** Builds the named analyzer with no stop words. */ - SnowballAnalyzer::SnowballAnalyzer(const char* language) { + SnowballAnalyzer::SnowballAnalyzer(normalizer_func_t *normalizer, const char* language) { this->language = strdup(language); + this->normalizer = normalizer; stopSet = NULL; prevstream = NULL; } @@ -67,7 +68,7 @@ result = _CLNEW CL_NS(analysis)::LowerCaseFilter(result, true); if (stopSet != NULL) result = _CLNEW CL_NS(analysis)::StopFilter(result, true, stopSet); - result = _CLNEW SnowballFilter(result, language, true); + result = _CLNEW SnowballFilter(result, normalizer, language, true); return result; } @@ -87,10 +88,11 @@ * @param in the input tokens to stem * @param name the name of a stemmer */ - SnowballFilter::SnowballFilter(TokenStream* in, const char* language, bool deleteTS): + SnowballFilter::SnowballFilter(TokenStream* in, normalizer_func_t *normalizer, const char* language, bool deleteTS): TokenFilter(in,deleteTS) { stemmer = sb_stemmer_new(language, NULL); //use utf8 encoding + this->normalizer = normalizer; if ( stemmer == NULL ){ _CLTHROWA(CL_ERR_IllegalArgument, "language not available for stemming\n"); //todo: richer error @@ -120,10 +122,24 @@ int stemmedLen=sb_stemmer_length(stemmer); - unsigned int tchartext_size = uni_utf8_strlen_n(stemmed, stemmedLen) + 1; - TCHAR tchartext[tchartext_size]; - lucene_utf8_n_to_tchar(stemmed,stemmedLen,tchartext,tchartext_size); - token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + if (normalizer == NULL) { + unsigned int tchartext_size = + uni_utf8_strlen_n(stemmed, stemmedLen) + 1; + TCHAR tchartext[tchartext_size]; + lucene_utf8_n_to_tchar(stemmed, stemmedLen, tchartext, tchartext_size); + token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + } else T_BEGIN { + buffer_t *norm_buf = buffer_create_dynamic(pool_datastack_create(), + stemmedLen); + normalizer(stemmed, stemmedLen, norm_buf); + + unsigned int tchartext_size = + uni_utf8_strlen_n(norm_buf->data, norm_buf->used) + 1; + TCHAR tchartext[tchartext_size]; + lucene_utf8_n_to_tchar((const unsigned char *)norm_buf->data, + norm_buf->used, tchartext, tchartext_size); + token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + } T_END; return token; } diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/SnowballAnalyzer.h --- a/src/plugins/fts-lucene/SnowballAnalyzer.h Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/SnowballAnalyzer.h Tue Sep 18 20:09:03 2012 +0300 @@ -7,6 +7,10 @@ #ifndef _lucene_analysis_snowball_analyser_ #define _lucene_analysis_snowball_analyser_ +extern "C" { +#include "lib.h" +#include "unichar.h" +}; #include "CLucene/analysis/AnalysisHeader.h" CL_CLASS_DEF(util,BufferedReader) @@ -21,12 +25,13 @@ */ class CLUCENE_CONTRIBS_EXPORT SnowballAnalyzer: public Analyzer { char* language; + normalizer_func_t *normalizer; CLTCSetList* stopSet; TokenStream *prevstream; public: /** Builds the named analyzer with no stop words. */ - SnowballAnalyzer(const char* language="english"); + SnowballAnalyzer(normalizer_func_t *normalizer, const char* language="english"); /** Builds the named analyzer with the given stop words. */ diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/SnowballFilter.h --- a/src/plugins/fts-lucene/SnowballFilter.h Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/SnowballFilter.h Tue Sep 18 20:09:03 2012 +0300 @@ -22,6 +22,7 @@ */ class CLUCENE_CONTRIBS_EXPORT SnowballFilter: public TokenFilter { struct sb_stemmer * stemmer; + normalizer_func_t *normalizer; public: /** Construct the named stemming filter. @@ -29,7 +30,7 @@ * @param in the input tokens to stem * @param name the name of a stemmer */ - SnowballFilter(TokenStream* in, const char* language, bool deleteTS); + SnowballFilter(TokenStream* in, normalizer_func_t *normalizer, const char* language, bool deleteTS); ~SnowballFilter(); diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/fts-lucene-plugin.c --- a/src/plugins/fts-lucene/fts-lucene-plugin.c Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Tue Sep 18 20:09:03 2012 +0300 @@ -28,6 +28,8 @@ set->textcat_dir = p_strdup(user->pool, *tmp + 12); } else if (strncmp(*tmp, "whitespace_chars=", 17) == 0) { set->whitespace_chars = p_strdup(user->pool, *tmp + 17); + } else if (strcmp(*tmp, "normalize") == 0) { + set->normalize = TRUE; } else { i_error("fts_lucene: Invalid setting: %s", *tmp); return -1; @@ -49,6 +51,11 @@ "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"; @@ -71,6 +78,8 @@ crc = set->default_language == NULL ? 0 : crc32_str(set->default_language); crc = crc32_str_more(crc, set->whitespace_chars); + if (set->normalize) + crc = crc32_str_more(crc, "n"); return crc; } diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/fts-lucene-plugin.h --- a/src/plugins/fts-lucene/fts-lucene-plugin.h Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.h Tue Sep 18 20:09:03 2012 +0300 @@ -12,6 +12,7 @@ const char *default_language; const char *textcat_conf, *textcat_dir; const char *whitespace_chars; + bool normalize; }; struct fts_lucene_user { diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:09:03 2012 +0300 @@ -10,6 +10,7 @@ #include "mail-index.h" #include "mail-search.h" #include "mail-namespace.h" +#include "mailbox-list-private.h" #include "mail-storage.h" #include "fts-expunge-log.h" #include "fts-lucene-plugin.h" @@ -58,6 +59,7 @@ char *path; struct mailbox_list *list; struct fts_lucene_settings set; + normalizer_func_t *normalizer; wchar_t mailbox_guid[MAILBOX_GUID_HEX_LENGTH + 1]; @@ -107,6 +109,8 @@ index = i_new(struct lucene_index, 1); index->path = i_strdup(path); index->list = list; + index->normalizer = !set->normalize ? NULL : + list->ns->user->default_normalizer; if (set != NULL) index->set = *set; else { @@ -115,9 +119,11 @@ } #ifdef HAVE_LUCENE_STEMMER index->default_analyzer = - _CLNEW snowball::SnowballAnalyzer(index->set.default_language); + _CLNEW snowball::SnowballAnalyzer(index->normalizer, + index->set.default_language); #else index->default_analyzer = _CLNEW standard::StandardAnalyzer(); + i_assert(index->normalizer == NULL); #endif i_array_init(&index->analyzers, 32); textcat_refcount++; @@ -397,6 +403,7 @@ #ifdef HAVE_LUCENE_TEXTCAT static Analyzer *get_analyzer(struct lucene_index *index, const char *lang) { + normalizer_func_t *normalizer = index->normalizer; const struct lucene_analyzer *a; struct lucene_analyzer new_analyzer; Analyzer *analyzer; @@ -408,7 +415,8 @@ memset(&new_analyzer, 0, sizeof(new_analyzer)); new_analyzer.lang = i_strdup(lang); - new_analyzer.analyzer = _CLNEW snowball::SnowballAnalyzer(lang); + new_analyzer.analyzer = + _CLNEW snowball::SnowballAnalyzer(normalizer, lang); array_append_i(&index->analyzers.arr, &new_analyzer, 1); return new_analyzer.analyzer; } From dovecot at dovecot.org Tue Sep 18 20:48:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 20:48:30 +0300 Subject: dovecot-2.1: director: Fixed weak-user handling when there is on... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f9424b066dcb changeset: 14715:f9424b066dcb user: Timo Sirainen date: Tue Sep 18 20:48:25 2012 +0300 description: director: Fixed weak-user handling when there is only one director. diffstat: src/director/director-request.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diffs (19 lines): diff -r a200fdbc1fa0 -r f9424b066dcb src/director/director-request.c --- a/src/director/director-request.c Tue Sep 18 20:09:03 2012 +0300 +++ b/src/director/director-request.c Tue Sep 18 20:48:25 2012 +0300 @@ -136,6 +136,15 @@ its existing connections have been killed */ return FALSE; } + if (dir->right == NULL && dir->ring_synced) { + /* looks like all the other directors have died. we can do + whatever we want without breaking anything. remove the + user's weakness just in case it was set to TRUE when we + had more directors. */ + user->weak = FALSE; + return TRUE; + } + if (user->weak) { /* wait for user to become non-weak */ return FALSE; From dovecot at dovecot.org Tue Sep 18 20:54:00 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 20:54:00 +0300 Subject: dovecot-2.1: fts-lucene: Compiling fix for previous change Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a9a49a30344b changeset: 14716:a9a49a30344b user: Timo Sirainen date: Tue Sep 18 20:53:50 2012 +0300 description: fts-lucene: Compiling fix for previous change diffstat: src/plugins/fts-lucene/lucene-wrapper.cc | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r f9424b066dcb -r a9a49a30344b src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:48:25 2012 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:53:50 2012 +0300 @@ -10,7 +10,6 @@ #include "mail-index.h" #include "mail-search.h" #include "mail-namespace.h" -#include "mailbox-list-private.h" #include "mail-storage.h" #include "fts-expunge-log.h" #include "fts-lucene-plugin.h" @@ -110,7 +109,7 @@ index->path = i_strdup(path); index->list = list; index->normalizer = !set->normalize ? NULL : - list->ns->user->default_normalizer; + mailbox_list_get_namespace(list)->user->default_normalizer; if (set != NULL) index->set = *set; else { From pigeonhole at rename-it.nl Tue Sep 18 21:45:26 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 20:45:26 +0200 Subject: dovecot-2.1-pigeonhole: Fixed compile against installed Dovecot ... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/8144fb698cb3 changeset: 1647:8144fb698cb3 user: Stephan Bosch date: Tue Sep 18 20:42:25 2012 +0200 description: Fixed compile against installed Dovecot headers. This was broken by the ld.gold fix. diffstat: src/lib-sieve/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 2347ddfd9057 -r 8144fb698cb3 src/lib-sieve/Makefile.am --- a/src/lib-sieve/Makefile.am Tue Sep 18 16:20:22 2012 +0200 +++ b/src/lib-sieve/Makefile.am Tue Sep 18 20:42:25 2012 +0200 @@ -71,7 +71,7 @@ $(unfinished_plugins) libdovecot_sieve_la_DEPENDENCIES = $(plugins) $(LIBDOVECOT_LDA_DEPS) -libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT_LDA) +libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT) $(LIBDOVECOT_LDA) libdovecot_sieve_la_SOURCES = \ rfc2822.c \ From dovecot at dovecot.org Tue Sep 18 21:53:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 21:53:24 +0300 Subject: dovecot-2.1: Released v2.1.10. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1a6c3b4e92e4 changeset: 14717:1a6c3b4e92e4 user: Timo Sirainen date: Tue Sep 18 21:42:27 2012 +0300 description: Released v2.1.10. diffstat: NEWS | 26 ++++++++++++++++++++++++++ configure.in | 2 +- 2 files changed, 27 insertions(+), 1 deletions(-) diffs (43 lines): diff -r a9a49a30344b -r 1a6c3b4e92e4 NEWS --- a/NEWS Tue Sep 18 20:53:50 2012 +0300 +++ b/NEWS Tue Sep 18 21:42:27 2012 +0300 @@ -1,3 +1,29 @@ +v2.1.10 2012-09-18 Timo Sirainen + + + imap: Implemented THREAD=ORDEREDSUBJECT extension. + + Added "doveadm exec" command to easily execute commands from + libexec_dir, e.g. "doveadm exec imap -u user at domain" + + Added "doveadm copy" command. + + doveadm copy/move: Added optional user parameter to specify the + source username. This allows easily copying mails between different + users. + + Added namespace { disabled } setting to quickly enable/disable + namespaces. This is especially useful when its value is returned by + userdb. + + Added mailbox_alias plugin. It allows creating mailbox aliases using + symlinks. + + imapc storage: Added imapc_max_idle_time setting to force activity + on connection. + + fts-solr: Expunging multiple messages is now faster. + - director: In some conditions director may have disconnected from + another director (without logging about it), thinking it was sending + invalid data. + - imap: Various fixes to listing mailboxes. + - pop3-migration plugin: Avoid disconnection from POP3 server due + to idling. + - login processes crashed if there were a lot of local {} or remote {} + settings blocks. + v2.1.9 2012-08-01 Timo Sirainen * mail-log plugin: Log mailbox names with UTF-8 everywhere diff -r a9a49a30344b -r 1a6c3b4e92e4 configure.in --- a/configure.in Tue Sep 18 20:53:50 2012 +0300 +++ b/configure.in Tue Sep 18 21:42:27 2012 +0300 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.9],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.10],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Tue Sep 18 21:53:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 21:53:24 +0300 Subject: dovecot-2.1: Added tag 2.1.10 for changeset 1a6c3b4e92e4 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/abef881deed0 changeset: 14718:abef881deed0 user: Timo Sirainen date: Tue Sep 18 21:42:27 2012 +0300 description: Added tag 2.1.10 for changeset 1a6c3b4e92e4 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 1a6c3b4e92e4 -r abef881deed0 .hgtags --- a/.hgtags Tue Sep 18 21:42:27 2012 +0300 +++ b/.hgtags Tue Sep 18 21:42:27 2012 +0300 @@ -86,3 +86,4 @@ c92fb8b928f69ca01681a2c2976304b7e4bc3afc 2.1.7 7e5f36fd989d27a2fb48250adbab8fa54ddb6083 2.1.8 bc86680293d256d5a8009690caeb73ab2e34e359 2.1.9 +1a6c3b4e92e4174d3b1eb0a7c841f97e8fb9e590 2.1.10 From dovecot at dovecot.org Tue Sep 18 21:53:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 18 Sep 2012 21:53:24 +0300 Subject: dovecot-2.1: Added signature for changeset 1a6c3b4e92e4 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3c215bd49cd0 changeset: 14719:3c215bd49cd0 user: Timo Sirainen date: Tue Sep 18 21:42:34 2012 +0300 description: Added signature for changeset 1a6c3b4e92e4 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r abef881deed0 -r 3c215bd49cd0 .hgsigs --- a/.hgsigs Tue Sep 18 21:42:27 2012 +0300 +++ b/.hgsigs Tue Sep 18 21:42:34 2012 +0300 @@ -49,3 +49,4 @@ c92fb8b928f69ca01681a2c2976304b7e4bc3afc 0 iEYEABECAAYFAk/FIeIACgkQyUhSUUBVisk4IgCfUiXVXntqzPjJcALYRpqw4Zc7a/0An3HKWwgb6PBCbmvxBfTezNkqjqVK 7e5f36fd989d27a2fb48250adbab8fa54ddb6083 0 iEYEABECAAYFAk/yVakACgkQyUhSUUBVismekwCfSEVQjd6fwdChjd53LSt03b4UWKoAoIxd/IjLatTISlHm44iiQwzRKByo bc86680293d256d5a8009690caeb73ab2e34e359 0 iEYEABECAAYFAlAZaTUACgkQyUhSUUBVisnTAACfU1pB34RrXEyLnpnL4Ee/oeNBYcoAnRWxTqx870Efjwf+eBPzafO0C/NU +1a6c3b4e92e4174d3b1eb0a7c841f97e8fb9e590 0 iEYEABECAAYFAlBYwJMACgkQyUhSUUBVisn2PwCeIJxfB5ebXlAbtMcjrZBCmB8Kg1sAn39BC9rQoR/wjD2/ix1JaxH7gHOT From pigeonhole at rename-it.nl Tue Sep 18 22:29:27 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 21:29:27 +0200 Subject: dovecot-2.1-pigeonhole: Added tag 0.3.3 for changeset 64474c359678 Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/e4fe281d33e8 changeset: 1649:e4fe281d33e8 user: Stephan Bosch date: Tue Sep 18 21:29:16 2012 +0200 description: Added tag 0.3.3 for changeset 64474c359678 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 64474c359678 -r e4fe281d33e8 .hgtags --- a/.hgtags Tue Sep 18 21:29:11 2012 +0200 +++ b/.hgtags Tue Sep 18 21:29:16 2012 +0200 @@ -12,3 +12,4 @@ fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0.3.0 e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0.3.1 265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0.3.2 +64474c35967852bc452f71bc099ec3f8ded0369a 0.3.3 From pigeonhole at rename-it.nl Tue Sep 18 22:29:27 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 21:29:27 +0200 Subject: dovecot-2.1-pigeonhole: Released v0.3.3 for Dovecot v2.1.10. Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/64474c359678 changeset: 1648:64474c359678 user: Stephan Bosch date: Tue Sep 18 21:29:11 2012 +0200 description: Released v0.3.3 for Dovecot v2.1.10. diffstat: NEWS | 5 +++++ configure.in | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diffs (21 lines): diff -r 8144fb698cb3 -r 64474c359678 NEWS --- a/NEWS Tue Sep 18 20:42:25 2012 +0200 +++ b/NEWS Tue Sep 18 21:29:11 2012 +0200 @@ -1,3 +1,8 @@ +v0.3.3 18-09-2012 Stephan Bosch + + - Fixed compile against installed Dovecot headers. This was broken by the + ld.gold fix in the previous release. + v0.3.2 18-09-2012 Stephan Bosch + sieve-refilter tool: improved man page documentation by explicitly diff -r 8144fb698cb3 -r 64474c359678 configure.in --- a/configure.in Tue Sep 18 20:42:25 2012 +0200 +++ b/configure.in Tue Sep 18 21:29:11 2012 +0200 @@ -1,4 +1,4 @@ -AC_INIT([Pigeonhole], [0.3.2], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) +AC_INIT([Pigeonhole], [0.3.3], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) From pigeonhole at rename-it.nl Tue Sep 18 22:30:59 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 18 Sep 2012 21:30:59 +0200 Subject: dovecot-2.1-pigeonhole: Added signature for changeset 64474c359678 Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/1e4ecd174edf changeset: 1650:1e4ecd174edf user: Stephan Bosch date: Tue Sep 18 21:30:45 2012 +0200 description: Added signature for changeset 64474c359678 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r e4fe281d33e8 -r 1e4ecd174edf .hgsigs --- a/.hgsigs Tue Sep 18 21:29:16 2012 +0200 +++ b/.hgsigs Tue Sep 18 21:30:45 2012 +0200 @@ -6,3 +6,4 @@ fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0 iQEcBAABAgAGBQJPPXAPAAoJEATWKx49+7T0iqMH/3e+RKKmryOz5pak0cvdPcS/D9O9xl2l6SuoE2okTq/WOrDtZ1xDg0afg7t27D9mDfUY1hiSFS4ekN3WP620Gcb9wlL3FC+rLEYmiE8iSfZvsH+FeLa7n8NB+XdnAsXE1WdLQp5CSKEh3sXIod7Q04PL0uv/rimGS9jOGcAufW3y9QAYd+DVorPS4lV5Kz8qIqY9r/0lLqhJN1ukIJtClVkFanRljd+SfoHFFOSWbQjCKNxlOSWFhwJji7Mp091A1+N6JoZe4IMIlajMsM2Ypp726Y2LA/du+uRVFjKgta65eP9tfdrmVCJtrjIjvikowD5Zl80GuVRI5j44aQ7rJ3A= e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0 iQEcBAABAgAGBQJPwAS+AAoJEATWKx49+7T0ngIH/R+teyHN4Pdv4bFTkder85rxy4bzPDzlV9gGlhuKuRBtI8F7CKKWLEP/ESPdtZbMmsNj9k104q2U9pgUfkYrVKL4lrk3hlz44o8Smpwp/xrxyNY8/OuBof0LvyXjp7unHAvvAWFiEmeTpJMmSu77xE8wsEqZowHi8/Igh3lrQ3U129VP1xWr1mvnvQdMQk9TTMK3T38H9kUrz2CRdOWjJbxAA4rLyozGLqWUeSKepUcwAGANd35k8pNLYiONlGU8NZsQyzS2dfOl0TeolgqZn+UkmM9FZFFnD40WU8zPft0nK4g8cFZGObX4fsPyK03EAnR7BXd1BKdmr7jdppAnSvQ= 265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0 iQEcBAABAgAGBQJQWIMhAAoJEATWKx49+7T0g/IH/3qqQemBP62Y+Wzo67DruphrJ5HSlIX4Uw/O4rOjrk8dWSMrsui5jFy4LXig+CR1dfY4RS0izTxsAiNhTACuavMfGHiYBKQW6UwIDlKECVBxbQyjB7v2C3FKPj9K9QReiYACSeB1RhQBnpbcvioif9H62VI5SKE6rjXyky6fDAxtbjhySb+nPDtV4HmV7ukcfDc3bxwcZkz9XXKoNmPWw8r34Z/RwxWbbWr8xUwW3+9LDB2Oz6PRyYP5S8EcNNYjk3ai2Llh0xuJGLQbpulhmjYDJmk20TkpLCFAfsYq1qW3yed9lL88CcFH4LDb9WA0LNs+7PfbmY/m8CX7JwUmHB8= +64474c35967852bc452f71bc099ec3f8ded0369a 0 iQEcBAABAgAGBQJQWMvhAAoJEATWKx49+7T0NrYH/2PQuuFqzlku+NG8Iw0UN2yeDEML+2n1xG31ud7m3sNWw8lX+03gEd+LU8+LygHJJ0IAde/jBYRBbC8zj9UXDl3v5FIRwhcvGnllBCMMH7motfg+aLrCR/xs+0jV/AqpRin1VILHYFaB9UFP5PUgvJJiCUniQWoe+r41gra1hRA7OK3923YOOi9t4zJxoat7e0OMhc0IcdB7n3iQmyicbb8izKw/UvR2tR3T7fVcEl6u1LlbGaojtJA03V1L+a8QkmltiurD9VNmiHz++bGGJlA7LSmVYBq7BeC1lDnXUGO9ryZgln6aXRwUS0VaTI51F9gSMw+0UDJCwA5yBKqYyR8= From dovecot at dovecot.org Wed Sep 19 15:34:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 19 Sep 2012 15:34:25 +0300 Subject: dovecot-2.2: config: Support looking up config for multiple modu... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8c003fe6f5a6 changeset: 15087:8c003fe6f5a6 user: Timo Sirainen date: Wed Sep 19 15:33:10 2012 +0300 description: config: Support looking up config for multiple modules at the same time. diffstat: src/config/config-connection.c | 21 +++++++++++++++------ src/config/config-filter.c | 16 ++++++++-------- src/config/config-filter.h | 4 ++-- src/config/config-parser-private.h | 2 +- src/config/config-parser.c | 26 ++++++++++++-------------- src/config/config-parser.h | 10 ++++++---- src/config/config-request.c | 15 +++++++-------- src/config/config-request.h | 4 ++-- src/config/doveconf.c | 38 +++++++++++++++++++++++--------------- src/config/main.c | 2 +- 10 files changed, 77 insertions(+), 61 deletions(-) diffs (truncated from 498 to 300 lines): diff -r 04580a59dc53 -r 8c003fe6f5a6 src/config/config-connection.c --- a/src/config/config-connection.c Tue Sep 18 05:12:28 2012 +0300 +++ b/src/config/config-connection.c Wed Sep 19 15:33:10 2012 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "array.h" #include "llist.h" #include "istream.h" #include "ostream.h" @@ -69,16 +70,22 @@ struct config_export_context *ctx; struct master_service_settings_output output; struct config_filter filter; - const char *path, *error, *module = ""; + const char *path, *error, *module; + ARRAY(const char *) modules; + bool is_master = FALSE; /* [] */ + t_array_init(&modules, 4); memset(&filter, 0, sizeof(filter)); for (; *args != NULL; args++) { if (strncmp(*args, "service=", 8) == 0) filter.service = *args + 8; - else if (strncmp(*args, "module=", 7) == 0) + else if (strncmp(*args, "module=", 7) == 0) { module = *args + 7; - else if (strncmp(*args, "lname=", 6) == 0) + if (strcmp(module, "master") == 0) + is_master = TRUE; + array_append(&modules, &module, 1); + } else if (strncmp(*args, "lname=", 6) == 0) filter.local_name = *args + 6; else if (strncmp(*args, "lip=", 4) == 0) { if (net_addr2ip(*args + 4, &filter.local_net) == 0) { @@ -94,11 +101,12 @@ } } } + array_append_zero(&modules); - if (strcmp(module, "master") == 0) { + if (is_master) { /* master reads configuration only when reloading settings */ path = master_service_get_config_path(master_service); - if (config_parse_file(path, TRUE, "", &error) <= 0) { + if (config_parse_file(path, TRUE, NULL, &error) <= 0) { o_stream_nsend_str(conn->output, t_strconcat("\nERROR ", error, "\n", NULL)); config_connection_destroy(conn); @@ -108,7 +116,8 @@ o_stream_cork(conn->output); - ctx = config_export_init(module, CONFIG_DUMP_SCOPE_SET, 0, + ctx = config_export_init(array_idx(&modules, 0), + CONFIG_DUMP_SCOPE_SET, 0, config_request_output, conn->output); config_export_by_filter(ctx, &filter); config_export_get_output(ctx, &output); diff -r 04580a59dc53 -r 8c003fe6f5a6 src/config/config-filter.c --- a/src/config/config-filter.c Tue Sep 18 05:12:28 2012 +0300 +++ b/src/config/config-filter.c Wed Sep 19 15:33:10 2012 +0300 @@ -164,15 +164,14 @@ } static bool have_changed_settings(const struct config_filter_parser *parser, - const char *module) + const char *const *modules) { const unsigned char *changes; unsigned int i, j, size; for (i = 0; parser->parsers[i].root != NULL; i++) { - if (*module != '\0' && - !config_module_want_parser(config_module_parsers, - module, parser->parsers[i].root)) + if (!config_module_want_parser(config_module_parsers, + modules, parser->parsers[i].root)) continue; changes = settings_parser_get_changes(parser->parsers[i].parser); @@ -186,7 +185,8 @@ } static struct config_filter_parser *const * -config_filter_find_all(struct config_filter_context *ctx, const char *module, +config_filter_find_all(struct config_filter_context *ctx, + const char *const *modules, const struct config_filter *filter, struct master_service_settings_output *output_r) { @@ -203,7 +203,7 @@ if (!config_filter_match_service(mask, filter)) { if (!str_array_contains(&service_names, mask->service) && - have_changed_settings(ctx->parsers[i], module)) + have_changed_settings(ctx->parsers[i], modules)) array_append(&service_names, &mask->service, 1); continue; } @@ -306,7 +306,7 @@ } int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool, - const char *module, + const char *const *modules, const struct config_filter *filter, struct config_module_parser **parsers_r, struct master_service_settings_output *output_r, @@ -322,7 +322,7 @@ with an error. Merging SET_STRLIST types requires settings_parser_apply_changes() to work a bit unintuitively by letting the destination settings override the source settings. */ - src = config_filter_find_all(ctx, module, filter, output_r); + src = config_filter_find_all(ctx, modules, filter, output_r); /* all of them should have the same number of parsers. duplicate our initial parsers from the first match */ diff -r 04580a59dc53 -r 8c003fe6f5a6 src/config/config-filter.h --- a/src/config/config-filter.h Tue Sep 18 05:12:28 2012 +0300 +++ b/src/config/config-filter.h Wed Sep 19 15:33:10 2012 +0300 @@ -33,11 +33,11 @@ /* Build new parsers from all existing ones matching the given filter. */ int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool, - const char *module, + const char *const *modules, const struct config_filter *filter, struct config_module_parser **parsers_r, struct master_service_settings_output *output_r, - const char **error_r); + const char **error_r) ATTR_NULL(3); void config_filter_parsers_free(struct config_module_parser *parsers); /* Return a list of filters that are a subset of the given filter. */ diff -r 04580a59dc53 -r 8c003fe6f5a6 src/config/config-parser-private.h --- a/src/config/config-parser-private.h Tue Sep 18 05:12:28 2012 +0300 +++ b/src/config/config-parser-private.h Wed Sep 19 15:33:10 2012 +0300 @@ -39,7 +39,7 @@ struct config_parser_context { pool_t pool; const char *path; - const char *module; + const char *const *modules; ARRAY(struct config_filter_parser *) all_parsers; struct config_module_parser *root_parsers; diff -r 04580a59dc53 -r 8c003fe6f5a6 src/config/config-parser.c --- a/src/config/config-parser.c Tue Sep 18 05:12:28 2012 +0300 +++ b/src/config/config-parser.c Wed Sep 19 15:33:10 2012 +0300 @@ -334,9 +334,8 @@ { for (; p->root != NULL; p++) { /* skip checking settings we don't care about */ - if (*ctx->module != '\0' && - !config_module_want_parser(ctx->root_parsers, - ctx->module, p->root)) + if (!config_module_want_parser(ctx->root_parsers, + ctx->modules, p->root)) continue; settings_parse_var_skip(p->parser); @@ -396,7 +395,7 @@ global_ssl_set = get_str_setting(parsers[0], "ssl", ""); for (i = 0; i < count && ret == 0; i++) { - if (config_filter_parsers_get(new_filter, tmp_pool, "", + if (config_filter_parsers_get(new_filter, tmp_pool, NULL, &parsers[i]->filter, &tmp_parsers, &output, error_r) < 0) { @@ -728,12 +727,12 @@ { struct config_module_parser *l; - if (*ctx->module == '\0') + if (ctx->modules == NULL) return TRUE; for (l = ctx->cur_section->parsers; l->root != NULL; l++) { if (config_module_want_parser(ctx->root_parsers, - ctx->module, l->root) && + ctx->modules, l->root) && settings_parse_is_valid_key(l->parser, key)) return TRUE; } @@ -881,8 +880,8 @@ } } -int config_parse_file(const char *path, bool expand_values, const char *module, - const char **error_r) +int config_parse_file(const char *path, bool expand_values, + const char *const *modules, const char **error_r) { struct input_stack root; struct config_parser_context ctx; @@ -924,7 +923,7 @@ root.path = path; ctx.cur_input = &root; ctx.expand_values = expand_values; - ctx.module = module; + ctx.modules = modules; p_array_init(&ctx.all_parsers, ctx.pool, 128); ctx.cur_section = p_new(ctx.pool, struct config_section_stack, 1); @@ -1052,21 +1051,20 @@ } bool config_module_want_parser(struct config_module_parser *parsers, - const char *module, + const char *const *modules, const struct setting_parser_info *root) { struct config_module_parser *l; - if (strcmp(root->module_name, module) == 0) + if (modules == NULL) return TRUE; - if (root == &master_service_setting_parser_info || - root == &master_service_ssl_setting_parser_info) { + if (root == &master_service_setting_parser_info) { /* everyone wants master service settings */ return TRUE; } for (l = parsers; l->root != NULL; l++) { - if (strcmp(l->root->module_name, module) != 0) + if (!str_array_find(modules, l->root->module_name)) continue; /* see if we can find a way to get from the original parser diff -r 04580a59dc53 -r 8c003fe6f5a6 src/config/config-parser.h --- a/src/config/config-parser.h Tue Sep 18 05:12:28 2012 +0300 +++ b/src/config/config-parser.h Wed Sep 19 15:33:10 2012 +0300 @@ -18,13 +18,15 @@ int config_parse_net(const char *value, struct ip_addr *ip_r, unsigned int *bits_r, const char **error_r); -int config_parse_file(const char *path, bool expand_values, const char *module, - const char **error_r); +int config_parse_file(const char *path, bool expand_values, + const char *const *modules, const char **error_r) + ATTR_NULL(3); void config_parse_load_modules(void); bool config_module_want_parser(struct config_module_parser *parsers, - const char *module, - const struct setting_parser_info *root); + const char *const *modules, + const struct setting_parser_info *root) + ATTR_NULL(2); #endif diff -r 04580a59dc53 -r 8c003fe6f5a6 src/config/config-request.c --- a/src/config/config-request.c Tue Sep 18 05:12:28 2012 +0300 +++ b/src/config/config-request.c Wed Sep 19 15:33:10 2012 +0300 @@ -21,7 +21,7 @@ config_request_callback_t *callback; void *context; - const char *module; + const char *const *modules; enum config_dump_flags flags; const struct config_module_parser *parsers; struct config_module_parser *dup_parsers; @@ -341,20 +341,20 @@ } struct config_export_context * -config_export_init(const char *module, enum config_dump_scope scope, +config_export_init(const char *const *modules, enum config_dump_scope scope, enum config_dump_flags flags, config_request_callback_t *callback, void *context) { struct config_export_context *ctx; pool_t pool; - i_assert(module != NULL); + i_assert(modules != NULL); pool = pool_alloconly_create(MEMPOOL_GROWING"config export", 1024*64); ctx = p_new(pool, struct config_export_context, 1); ctx->pool = pool; - ctx->module = p_strdup(pool, module); + ctx->modules = p_strarray_dup(pool, modules); ctx->flags = flags; ctx->callback = callback; ctx->context = context; @@ -371,7 +371,7 @@ const char *error; if (config_filter_parsers_get(config_filter, ctx->pool, - ctx->module, filter, + ctx->modules, filter, From dovecot at dovecot.org Wed Sep 19 15:34:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 19 Sep 2012 15:34:25 +0300 Subject: dovecot-2.2: Read SSL settings only if service has SSL sockets o... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/14df6be0111f changeset: 15088:14df6be0111f user: Timo Sirainen date: Wed Sep 19 15:34:00 2012 +0300 description: Read SSL settings only if service has SSL sockets or MASTER_SERVICE_FLAG_USE_SSL_SETTINGS. diffstat: src/auth/auth-settings.c | 7 +++-- src/lib-master/master-service-private.h | 1 + src/lib-master/master-service-settings.c | 37 ++++++++++++++++++++------- src/lib-master/master-service-settings.h | 7 ++--- src/lib-master/master-service-ssl-settings.c | 2 +- src/lib-master/master-service.c | 2 + src/lib-master/master-service.h | 6 +++- src/lib-storage/mail-storage-service.c | 18 +++++++++--- src/lmtp/lmtp-settings.c | 4 +- src/login-common/login-settings.c | 3 +- src/login-common/main.c | 3 +- 11 files changed, 61 insertions(+), 29 deletions(-) diffs (truncated from 303 to 300 lines): diff -r 8c003fe6f5a6 -r 14df6be0111f src/auth/auth-settings.c --- a/src/auth/auth-settings.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/auth/auth-settings.c Wed Sep 19 15:34:00 2012 +0300 @@ -392,8 +392,8 @@ }; struct master_service_settings_input input; struct setting_parser_context *set_parser; - struct auth_settings *set; const char *error; + void **sets; memset(&input, 0, sizeof(input)); input.roots = set_roots; @@ -408,7 +408,8 @@ if (!settings_parser_check(set_parser, pool, &error)) i_unreached(); - set = settings_parser_get_list(set_parser)[MASTER_SERVICE_INTERNAL_SET_PARSERS]; + sets = master_service_settings_parser_get_others(master_service, + set_parser); settings_parser_deinit(&set_parser); - return set; + return sets[0]; } diff -r 8c003fe6f5a6 -r 14df6be0111f src/lib-master/master-service-private.h --- a/src/lib-master/master-service-private.h Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lib-master/master-service-private.h Wed Sep 19 15:34:00 2012 +0300 @@ -70,6 +70,7 @@ unsigned int die_with_master:1; unsigned int call_avail_overflow:1; unsigned int config_path_is_default:1; + unsigned int want_ssl_settings:1; unsigned int ssl_ctx_initialized:1; }; diff -r 8c003fe6f5a6 -r 14df6be0111f src/lib-master/master-service-settings.c --- a/src/lib-master/master-service-settings.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lib-master/master-service-settings.c Wed Sep 19 15:34:00 2012 +0300 @@ -116,7 +116,7 @@ /* @UNSAFE */ i = 0; - argv_max_count = 9 + (service->argc + 1) + 1; + argv_max_count = 11 + (service->argc + 1) + 1; conf_argv = t_new(const char *, argv_max_count); conf_argv[i++] = DOVECOT_CONFIG_BIN_PATH; conf_argv[i++] = "-f"; @@ -126,6 +126,10 @@ if (input->module != NULL) { conf_argv[i++] = "-m"; conf_argv[i++] = input->module; + if (service->want_ssl_settings) { + conf_argv[i++] = "-m"; + conf_argv[i++] = "ssl"; + } } if (input->parse_full_config) conf_argv[i++] = "-p"; @@ -216,12 +220,15 @@ } static void -config_build_request(string_t *str, +config_build_request(struct master_service *service, string_t *str, const struct master_service_settings_input *input) { str_append(str, "REQ"); - if (input->module != NULL) + if (input->module != NULL) { str_printfa(str, "\tmodule=%s", input->module); + if (service->want_ssl_settings) + str_append(str, "\tmodule=ssl"); + } if (input->service != NULL) str_printfa(str, "\tservice=%s", input->service); if (input->username != NULL) @@ -236,7 +243,8 @@ } static int -config_send_request(const struct master_service_settings_input *input, +config_send_request(struct master_service *service, + const struct master_service_settings_input *input, int fd, const char *path, const char **error_r) { int ret; @@ -246,7 +254,7 @@ str = t_str_new(128); str_append(str, CONFIG_HANDSHAKE); - config_build_request(str, input); + config_build_request(service, str, input); ret = write_full(fd, str_data(str), str_len(str)); } T_END; if (ret < 0) { @@ -352,7 +360,7 @@ if (fd == -1) return -1; - if (config_send_request(input, fd, path, error_r) < 0) { + if (config_send_request(service, input, fd, path, error_r) < 0) { i_close_fd(&fd); config_exec_fallback(service, input); return -1; @@ -371,8 +379,10 @@ p_array_init(&all_roots, service->set_pool, 8); tmp_root = &master_service_setting_parser_info; array_append(&all_roots, &tmp_root, 1); - tmp_root = &master_service_ssl_setting_parser_info; - array_append(&all_roots, &tmp_root, 1); + if (service->want_ssl_settings) { + tmp_root = &master_service_ssl_setting_parser_info; + array_append(&all_roots, &tmp_root, 1); + } if (input->roots != NULL) { for (i = 0; input->roots[i] != NULL; i++) array_append(&all_roots, &input->roots[i], 1); @@ -498,8 +508,15 @@ void **master_service_settings_get_others(struct master_service *service) { - return settings_parser_get_list(service->set_parser) + - MASTER_SERVICE_INTERNAL_SET_PARSERS; + return master_service_settings_parser_get_others(service, + service->set_parser); +} + +void **master_service_settings_parser_get_others(struct master_service *service, + const struct setting_parser_context *set_parser) +{ + return settings_parser_get_list(set_parser) + 1 + + (service->want_ssl_settings ? 1 : 0); } struct setting_parser_context * diff -r 8c003fe6f5a6 -r 14df6be0111f src/lib-master/master-service-settings.h --- a/src/lib-master/master-service-settings.h Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lib-master/master-service-settings.h Wed Sep 19 15:34:00 2012 +0300 @@ -3,11 +3,8 @@ #include "network.h" -/* Number of settings roots used by lib-master internally. Typically you should - use master_service_settings_get_others() to avoid knowing about this. */ -#define MASTER_SERVICE_INTERNAL_SET_PARSERS 2 - struct setting_parser_info; +struct setting_parser_context; struct master_service; struct master_service_settings { @@ -74,6 +71,8 @@ const struct master_service_settings * master_service_settings_get(struct master_service *service); void **master_service_settings_get_others(struct master_service *service); +void **master_service_settings_parser_get_others(struct master_service *service, + const struct setting_parser_context *set_parser); struct setting_parser_context * master_service_get_settings_parser(struct master_service *service); diff -r 8c003fe6f5a6 -r 14df6be0111f src/lib-master/master-service-ssl-settings.c --- a/src/lib-master/master-service-ssl-settings.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lib-master/master-service-ssl-settings.c Wed Sep 19 15:34:00 2012 +0300 @@ -51,7 +51,7 @@ }; const struct setting_parser_info master_service_ssl_setting_parser_info = { - .module_name = "master", + .module_name = "ssl", .defines = master_service_ssl_setting_defines, .defaults = &master_service_ssl_default_settings, diff -r 8c003fe6f5a6 -r 14df6be0111f src/lib-master/master-service.c --- a/src/lib-master/master-service.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lib-master/master-service.c Wed Sep 19 15:34:00 2012 +0300 @@ -182,6 +182,8 @@ service->listener_names_count = str_array_length((void *)service->listener_names); } + service->want_ssl_settings = service->ssl_socket_count > 0 || + (flags & MASTER_SERVICE_FLAG_USE_SSL_SETTINGS) != 0; /* set up some kind of logging until we know exactly how and where we want to log */ diff -r 8c003fe6f5a6 -r 14df6be0111f src/lib-master/master-service.h --- a/src/lib-master/master-service.h Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lib-master/master-service.h Wed Sep 19 15:34:00 2012 +0300 @@ -22,7 +22,11 @@ MASTER_SERVICE_FLAG_NO_IDLE_DIE = 0x80, /* Show number of connections in process title (only if verbose_proctitle setting is enabled) */ - MASTER_SERVICE_FLAG_UPDATE_PROCTITLE = 0x100 + MASTER_SERVICE_FLAG_UPDATE_PROCTITLE = 0x100, + /* SSL settings are always looked up when we have ssl listeners. + This flag enables looking up SSL settings even without ssl + listeners (i.e. the service does STARTTLS). */ + MASTER_SERVICE_FLAG_USE_SSL_SETTINGS = 0x200 }; struct master_service_connection { diff -r 8c003fe6f5a6 -r 14df6be0111f src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lib-storage/mail-storage-service.c Wed Sep 19 15:34:00 2012 +0300 @@ -950,6 +950,7 @@ const char *const *userdb_fields, *error; struct auth_user_reply reply; const struct setting_parser_context *set_parser; + void **sets; pool_t user_pool, temp_pool; int ret = 1; @@ -973,7 +974,9 @@ master_service_init_log(ctx->service, t_strconcat(ctx->service->name, ": ", NULL)); } - user_set = settings_parser_get_list(set_parser)[MASTER_SERVICE_INTERNAL_SET_PARSERS]; + sets = master_service_settings_parser_get_others(master_service, + set_parser); + user_set = sets[0]; if (ctx->conn == NULL) mail_storage_service_first_init(ctx, user_info, user_set); @@ -1007,7 +1010,9 @@ if (!settings_parser_check(user->set_parser, user_pool, &error)) i_panic("settings_parser_check() failed: %s", error); - user->user_set = settings_parser_get_list(user->set_parser)[MASTER_SERVICE_INTERNAL_SET_PARSERS]; + sets = master_service_settings_parser_get_others(master_service, + user->set_parser); + user->user_set = sets[0]; user->gid_source = "mail_gid setting"; user->uid_source = "mail_uid setting"; @@ -1189,6 +1194,7 @@ const struct setting_parser_context *set_parser; const char *error; pool_t temp_pool; + void **sets; if (ctx->conn != NULL) return; @@ -1198,7 +1204,9 @@ &user_info, &set_parser, &error) < 0) i_fatal("%s", error); - user_set = settings_parser_get_list(set_parser)[MASTER_SERVICE_INTERNAL_SET_PARSERS]; + sets = master_service_settings_parser_get_others(master_service, + set_parser); + user_set = sets[0]; mail_storage_service_first_init(ctx, user_info, user_set); pool_unref(&temp_pool); @@ -1249,8 +1257,8 @@ void **mail_storage_service_user_get_set(struct mail_storage_service_user *user) { - return settings_parser_get_list(user->set_parser) + - MASTER_SERVICE_INTERNAL_SET_PARSERS; + return master_service_settings_parser_get_others(master_service, + user->set_parser); } const struct mail_storage_settings * diff -r 8c003fe6f5a6 -r 14df6be0111f src/lmtp/lmtp-settings.c --- a/src/lmtp/lmtp-settings.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/lmtp/lmtp-settings.c Wed Sep 19 15:34:00 2012 +0300 @@ -99,8 +99,8 @@ { void **sets; - sets = settings_parser_get_list(set_parser) + - MASTER_SERVICE_INTERNAL_SET_PARSERS; + sets = master_service_settings_parser_get_others(master_service, + set_parser); *lda_set_r = settings_dup(&lda_setting_parser_info, sets[1], pool); *lmtp_set_r = settings_dup(&lmtp_setting_parser_info, sets[2], pool); } diff -r 8c003fe6f5a6 -r 14df6be0111f src/login-common/login-settings.c --- a/src/login-common/login-settings.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/login-common/login-settings.c Wed Sep 19 15:34:00 2012 +0300 @@ -179,8 +179,7 @@ &parser, &error) < 0) i_fatal("Error reading configuration: %s", error); - cache_sets = settings_parser_get_list(parser) + - MASTER_SERVICE_INTERNAL_SET_PARSERS; + cache_sets = master_service_settings_parser_get_others(master_service, parser); for (count = 0; input.roots[count] != NULL; count++) ; i_assert(cache_sets[count] == NULL); sets = p_new(pool, void *, count + 1); diff -r 8c003fe6f5a6 -r 14df6be0111f src/login-common/main.c --- a/src/login-common/main.c Wed Sep 19 15:33:10 2012 +0300 +++ b/src/login-common/main.c Wed Sep 19 15:34:00 2012 +0300 @@ -364,7 +364,8 @@ { enum master_service_flags service_flags = MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN | - MASTER_SERVICE_FLAG_TRACK_LOGIN_STATE; + MASTER_SERVICE_FLAG_TRACK_LOGIN_STATE | + MASTER_SERVICE_FLAG_USE_SSL_SETTINGS; From dovecot at dovecot.org Wed Sep 19 17:49:34 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 19 Sep 2012 17:49:34 +0300 Subject: dovecot-2.2: imap: Fixed crashing in QRESYNC SELECT. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/119225e4f305 changeset: 15089:119225e4f305 user: Timo Sirainen date: Wed Sep 19 17:49:28 2012 +0300 description: imap: Fixed crashing in QRESYNC SELECT. diffstat: src/imap/cmd-fetch.c | 3 ++- src/imap/cmd-select.c | 4 ++-- src/imap/imap-fetch.c | 18 ------------------ src/imap/imap-fetch.h | 4 ---- src/imap/imap-search-args.c | 15 +++++++++++++++ src/imap/imap-search-args.h | 3 +++ 6 files changed, 22 insertions(+), 25 deletions(-) diffs (116 lines): diff -r 14df6be0111f -r 119225e4f305 src/imap/cmd-fetch.c --- a/src/imap/cmd-fetch.c Wed Sep 19 15:34:00 2012 +0300 +++ b/src/imap/cmd-fetch.c Wed Sep 19 17:49:28 2012 +0300 @@ -118,7 +118,8 @@ return FALSE; } *args += 1; - imap_fetch_add_changed_since(ctx, search_args, modseq); + imap_search_add_changed_since(search_args, modseq); + imap_fetch_init_nofail_handler(ctx, imap_fetch_modseq_init); return TRUE; } if (strcmp(name, "VANISHED") == 0 && cmd->uid) { diff -r 14df6be0111f -r 119225e4f305 src/imap/cmd-select.c --- a/src/imap/cmd-select.c Wed Sep 19 15:34:00 2012 +0300 +++ b/src/imap/cmd-select.c Wed Sep 19 17:49:28 2012 +0300 @@ -4,6 +4,7 @@ #include "seq-range-array.h" #include "imap-commands.h" #include "mail-search-build.h" +#include "imap-search-args.h" #include "imap-seqset.h" #include "imap-fetch.h" #include "imap-sync.h" @@ -239,6 +240,7 @@ search_args->args = p_new(search_args->pool, struct mail_search_arg, 1); search_args->args->type = SEARCH_UIDSET; search_args->args->value.seqset = ctx->qresync_known_uids; + imap_search_add_changed_since(search_args, ctx->qresync_modseq); memset(&qresync_args, 0, sizeof(qresync_args)); qresync_args.qresync_sample_seqset = &ctx->qresync_sample_seqset; @@ -252,8 +254,6 @@ fetch_ctx = imap_fetch_alloc(ctx->cmd->client, ctx->cmd->pool); - imap_fetch_add_changed_since(fetch_ctx, search_args, - ctx->qresync_modseq); imap_fetch_init_nofail_handler(fetch_ctx, imap_fetch_uid_init); imap_fetch_init_nofail_handler(fetch_ctx, imap_fetch_flags_init); imap_fetch_init_nofail_handler(fetch_ctx, imap_fetch_modseq_init); diff -r 14df6be0111f -r 119225e4f305 src/imap/imap-fetch.c --- a/src/imap/imap-fetch.c Wed Sep 19 15:34:00 2012 +0300 +++ b/src/imap/imap-fetch.c Wed Sep 19 17:49:28 2012 +0300 @@ -129,24 +129,6 @@ return ctx; } -void imap_fetch_add_changed_since(struct imap_fetch_context *ctx, - struct mail_search_args *search_args, - uint64_t modseq) -{ - struct mail_search_arg *search_arg; - - search_arg = p_new(search_args->pool, struct mail_search_arg, 1); - search_arg->type = SEARCH_MODSEQ; - search_arg->value.modseq = - p_new(search_args->pool, struct mail_search_modseq, 1); - search_arg->value.modseq->modseq = modseq + 1; - - search_arg->next = search_args->args->next; - search_args->args->next = search_arg; - - imap_fetch_init_nofail_handler(ctx, imap_fetch_modseq_init); -} - #undef imap_fetch_add_handler void imap_fetch_add_handler(struct imap_fetch_init_context *ctx, enum imap_fetch_handler_flags flags, diff -r 14df6be0111f -r 119225e4f305 src/imap/imap-fetch.h --- a/src/imap/imap-fetch.h Wed Sep 19 15:34:00 2012 +0300 +++ b/src/imap/imap-fetch.h Wed Sep 19 17:49:28 2012 +0300 @@ -116,10 +116,6 @@ void imap_fetch_init_nofail_handler(struct imap_fetch_context *ctx, bool (*init)(struct imap_fetch_init_context *)); -void imap_fetch_add_changed_since(struct imap_fetch_context *ctx, - struct mail_search_args *search_args, - uint64_t modseq); - void imap_fetch_begin(struct imap_fetch_context *ctx, struct mailbox *box, struct mail_search_args *search_args); int imap_fetch_send_vanished(struct client *client, struct mailbox *box, diff -r 14df6be0111f -r 119225e4f305 src/imap/imap-search-args.c --- a/src/imap/imap-search-args.c Wed Sep 19 15:34:00 2012 +0300 +++ b/src/imap/imap-search-args.c Wed Sep 19 17:49:28 2012 +0300 @@ -209,3 +209,18 @@ } return 1; } + +void imap_search_add_changed_since(struct mail_search_args *search_args, + uint64_t modseq) +{ + struct mail_search_arg *search_arg; + + search_arg = p_new(search_args->pool, struct mail_search_arg, 1); + search_arg->type = SEARCH_MODSEQ; + search_arg->value.modseq = + p_new(search_args->pool, struct mail_search_modseq, 1); + search_arg->value.modseq->modseq = modseq + 1; + + search_arg->next = search_args->args->next; + search_args->args->next = search_arg; +} diff -r 14df6be0111f -r 119225e4f305 src/imap/imap-search-args.h --- a/src/imap/imap-search-args.h Wed Sep 19 15:34:00 2012 +0300 +++ b/src/imap/imap-search-args.h Wed Sep 19 17:49:28 2012 +0300 @@ -25,4 +25,7 @@ const char *set, bool uid, struct mail_search_args **search_args_r); +void imap_search_add_changed_since(struct mail_search_args *search_args, + uint64_t modseq); + #endif From dovecot at dovecot.org Wed Sep 19 18:07:55 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 19 Sep 2012 18:07:55 +0300 Subject: dovecot-2.2: lib-storage: Verify that the shared library's versi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/488c7dde19ad changeset: 15090:488c7dde19ad user: Timo Sirainen date: Wed Sep 19 18:07:46 2012 +0300 description: lib-storage: Verify that the shared library's version matches the binary's version. diffstat: src/lib-storage/mail-storage-service.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (21 lines): diff -r 119225e4f305 -r 488c7dde19ad src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Wed Sep 19 17:49:28 2012 +0300 +++ b/src/lib-storage/mail-storage-service.c Wed Sep 19 18:07:46 2012 +0300 @@ -733,9 +733,17 @@ enum mail_storage_service_flags flags) { struct mail_storage_service_ctx *ctx; + const char *version; pool_t pool; unsigned int count; + version = master_service_get_version_string(service); + if (version != NULL && strcmp(version, PACKAGE_VERSION) != 0) { + i_fatal("Version mismatch: libdovecot-storage.so is '%s', " + "while the running Dovecot binary is '%s'", + PACKAGE_VERSION, version); + } + (void)umask(0077); io_loop_set_time_moved_callback(current_ioloop, mail_storage_service_time_moved); From pigeonhole at rename-it.nl Wed Sep 19 22:59:26 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 19 Sep 2012 21:59:26 +0200 Subject: dovecot-2.2-pigeonhole: Updated to changes in Dovecot config API. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/b16a4c228dd5 changeset: 1666:b16a4c228dd5 user: Stephan Bosch date: Wed Sep 19 21:59:08 2012 +0200 description: Updated to changes in Dovecot config API. diffstat: src/managesieve-login/managesieve-login-settings-plugin.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diffs (25 lines): diff -r fa9411b742f6 -r b16a4c228dd5 src/managesieve-login/managesieve-login-settings-plugin.c --- a/src/managesieve-login/managesieve-login-settings-plugin.c Tue Sep 18 14:44:44 2012 +0200 +++ b/src/managesieve-login/managesieve-login-settings-plugin.c Wed Sep 19 21:59:08 2012 +0200 @@ -199,9 +199,18 @@ } static void managesieve_login_config_parser_begin(struct config_parser_context *ctx) -{ - if (*ctx->module != '\0' && strcmp(ctx->module, "managesieve-login") != 0) - return; +{ + const char *const *module = ctx->modules; + + if ( module != NULL ) { + while ( module != NULL ) { + if ( strcmp(*module, "managesieve-login") == 0 ) + break; + module++; + } + if ( module == NULL ) + return; + } if ( !capability_dumped ) { (void)capability_dump(); From pigeonhole at rename-it.nl Wed Sep 19 23:47:29 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 19 Sep 2012 22:47:29 +0200 Subject: dovecot-2.2-pigeonhole: Last commit was quite inadequate. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/f069f8bff55b changeset: 1667:f069f8bff55b user: Stephan Bosch date: Wed Sep 19 22:44:10 2012 +0200 description: Last commit was quite inadequate. diffstat: src/managesieve-login/managesieve-login-settings-plugin.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (20 lines): diff -r b16a4c228dd5 -r f069f8bff55b src/managesieve-login/managesieve-login-settings-plugin.c --- a/src/managesieve-login/managesieve-login-settings-plugin.c Wed Sep 19 21:59:08 2012 +0200 +++ b/src/managesieve-login/managesieve-login-settings-plugin.c Wed Sep 19 22:44:10 2012 +0200 @@ -202,13 +202,13 @@ { const char *const *module = ctx->modules; - if ( module != NULL ) { - while ( module != NULL ) { + if ( module != NULL && *module != NULL ) { + while ( *module != NULL ) { if ( strcmp(*module, "managesieve-login") == 0 ) break; module++; } - if ( module == NULL ) + if ( *module == NULL ) return; } From dovecot at dovecot.org Thu Sep 20 01:01:31 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 20 Sep 2012 01:01:31 +0300 Subject: dovecot-2.2: config: Fixes to previous module change. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a73f4d12289e changeset: 15091:a73f4d12289e user: Timo Sirainen date: Thu Sep 20 01:01:20 2012 +0300 description: config: Fixes to previous module change. diffstat: src/config/config-connection.c | 7 ++++--- src/config/config-request.c | 4 +--- src/config/doveconf.c | 15 +++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) diffs (106 lines): diff -r 488c7dde19ad -r a73f4d12289e src/config/config-connection.c --- a/src/config/config-connection.c Wed Sep 19 18:07:46 2012 +0300 +++ b/src/config/config-connection.c Thu Sep 20 01:01:20 2012 +0300 @@ -70,7 +70,7 @@ struct config_export_context *ctx; struct master_service_settings_output output; struct config_filter filter; - const char *path, *error, *module; + const char *path, *error, *module, *const *wanted_modules; ARRAY(const char *) modules; bool is_master = FALSE; @@ -102,6 +102,8 @@ } } array_append_zero(&modules); + wanted_modules = array_count(&modules) == 1 ? NULL : + array_idx(&modules, 0); if (is_master) { /* master reads configuration only when reloading settings */ @@ -116,8 +118,7 @@ o_stream_cork(conn->output); - ctx = config_export_init(array_idx(&modules, 0), - CONFIG_DUMP_SCOPE_SET, 0, + ctx = config_export_init(wanted_modules, CONFIG_DUMP_SCOPE_SET, 0, config_request_output, conn->output); config_export_by_filter(ctx, &filter); config_export_get_output(ctx, &output); diff -r 488c7dde19ad -r a73f4d12289e src/config/config-request.c --- a/src/config/config-request.c Wed Sep 19 18:07:46 2012 +0300 +++ b/src/config/config-request.c Thu Sep 20 01:01:20 2012 +0300 @@ -348,13 +348,11 @@ struct config_export_context *ctx; pool_t pool; - i_assert(modules != NULL); - pool = pool_alloconly_create(MEMPOOL_GROWING"config export", 1024*64); ctx = p_new(pool, struct config_export_context, 1); ctx->pool = pool; - ctx->modules = p_strarray_dup(pool, modules); + ctx->modules = modules == NULL ? NULL : p_strarray_dup(pool, modules); ctx->flags = flags; ctx->callback = callback; ctx->context = context; diff -r 488c7dde19ad -r a73f4d12289e src/config/doveconf.c --- a/src/config/doveconf.c Wed Sep 19 18:07:46 2012 +0300 +++ b/src/config/doveconf.c Thu Sep 20 01:01:20 2012 +0300 @@ -592,7 +592,7 @@ const char *orig_config_path, *config_path, *module; ARRAY(const char *) module_names; struct config_filter filter; - const char *error; + const char *const *wanted_modules, *error; char **exec_args = NULL, **setting_name_filters = NULL; unsigned int i; int c, ret, ret2; @@ -654,6 +654,8 @@ } } array_append_zero(&module_names); + wanted_modules = array_count(&module_names) == 1 ? NULL : + array_idx(&module_names, 0); config_path = master_service_get_config_path(master_service); /* use strcmp() instead of !=, because dovecot -n always gives us @@ -678,8 +680,7 @@ if ((ret = config_parse_file(dump_defaults ? NULL : config_path, expand_vars, - parse_full_config ? NULL : - array_idx(&module_names, 0), + parse_full_config ? NULL : wanted_modules, &error)) == 0 && access(EXAMPLE_CONFIG_DIR, X_OK) == 0) { i_fatal("%s (copy example configs from "EXAMPLE_CONFIG_DIR"/)", @@ -692,7 +693,7 @@ if (simple_output) { struct config_export_context *ctx; - ctx = config_export_init(array_idx(&module_names, 0), scope, + ctx = config_export_init(wanted_modules, scope, CONFIG_DUMP_FLAG_CHECK_SETTINGS, config_request_simple_stdout, setting_name_filters); @@ -719,14 +720,12 @@ if (!config_path_specified) check_wrong_config(config_path); fflush(stdout); - ret2 = config_dump_human(&filter, array_idx(&module_names, 0), - scope, NULL); + ret2 = config_dump_human(&filter, wanted_modules, scope, NULL); } else { struct config_export_context *ctx; env_put("DOVECONF_ENV=1"); - ctx = config_export_init(array_idx(&module_names, 0), - CONFIG_DUMP_SCOPE_SET, + ctx = config_export_init(wanted_modules, CONFIG_DUMP_SCOPE_SET, CONFIG_DUMP_FLAG_CHECK_SETTINGS, config_request_putenv, NULL); config_export_by_filter(ctx, &filter); From pigeonhole at rename-it.nl Thu Sep 20 01:22:55 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 20 Sep 2012 00:22:55 +0200 Subject: dovecot-2.2-pigeonhole: sieve-tools: The -D option wasn't enable... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/ea0eef5b5578 changeset: 1668:ea0eef5b5578 user: Stephan Bosch date: Thu Sep 20 00:18:10 2012 +0200 description: sieve-tools: The -D option wasn't enabled and documented for all tools. diffstat: doc/man/sieve-dump.1.in | 3 +++ doc/man/sievec.1.in | 3 +++ src/sieve-tools/sieve-dump.c | 4 ++-- src/sieve-tools/sievec.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diffs (59 lines): diff -r f069f8bff55b -r ea0eef5b5578 doc/man/sieve-dump.1.in --- a/doc/man/sieve-dump.1.in Wed Sep 19 22:44:10 2012 +0200 +++ b/doc/man/sieve-dump.1.in Thu Sep 20 00:18:10 2012 +0200 @@ -40,6 +40,9 @@ .BI \-c\ config\-file Alternative Dovecot configuration file path. .TP +.B \-D +Enable Sieve debugging. +.TP .B \-h Produce per\-block hexdump output of the whole binary instead of the normal human\-readable output. diff -r f069f8bff55b -r ea0eef5b5578 doc/man/sievec.1.in --- a/doc/man/sievec.1.in Wed Sep 19 22:44:10 2012 +0200 +++ b/doc/man/sievec.1.in Thu Sep 20 00:18:10 2012 +0200 @@ -57,6 +57,9 @@ for a compiled Sieve binary file. Note that this option is not allowed when the \fIout\-file\fP argument is a directory. .TP +.B \-D +Enable Sieve debugging. +.TP .BI \-x\ extensions Set the available extensions. The parameter is a space\-separated list of the active extensions. By prepending the extension identifiers with \fB+\fP or diff -r f069f8bff55b -r ea0eef5b5578 src/sieve-tools/sieve-dump.c --- a/src/sieve-tools/sieve-dump.c Wed Sep 19 22:44:10 2012 +0200 +++ b/src/sieve-tools/sieve-dump.c Thu Sep 20 00:18:10 2012 +0200 @@ -28,7 +28,7 @@ static void print_help(void) { printf( -"Usage: sieve-dump [-c ] [-h] [-P ] [-x ]\n" +"Usage: sieve-dump [-c ] [-D] [-h] [-P ] [-x ]\n" " []\n" ); } @@ -46,7 +46,7 @@ int exit_status = EXIT_SUCCESS; int c; - sieve_tool = sieve_tool_init("sieve-dump", &argc, &argv, "hP:x:", FALSE); + sieve_tool = sieve_tool_init("sieve-dump", &argc, &argv, "DhP:x:", FALSE); outfile = NULL; diff -r f069f8bff55b -r ea0eef5b5578 src/sieve-tools/sievec.c --- a/src/sieve-tools/sievec.c Wed Sep 19 22:44:10 2012 +0200 +++ b/src/sieve-tools/sievec.c Thu Sep 20 00:18:10 2012 +0200 @@ -31,7 +31,7 @@ static void print_help(void) { printf( -"Usage: sievec [-c ] [-d] [-P ] [-x ] \n" +"Usage: sievec [-c ] [-d] [-D] [-P ] [-x ] \n" " []\n" ); } From pigeonhole at rename-it.nl Thu Sep 20 01:22:55 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 20 Sep 2012 00:22:55 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: Finished implementation of in... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/7e2dbfc9206d changeset: 1669:7e2dbfc9206d user: Stephan Bosch date: Thu Sep 20 00:22:36 2012 +0200 description: lib-sieve: Finished implementation of include extension. Added support for the :optional tag of the include command. Changed Sieve script API in the process; opening the script is now available as a separate step. diffstat: Makefile.am | 1 + README | 6 +- TODO | 2 - doc/rfc/draft-ietf-sieve-include-05.txt | 784 -------------------- doc/rfc/include.rfc6609.txt | 787 +++++++++++++++++++++ src/lib-sieve/plugins/include/cmd-include.c | 87 +- src/lib-sieve/plugins/include/ext-include-binary.c | 112 ++- src/lib-sieve/plugins/include/ext-include-binary.h | 15 +- src/lib-sieve/plugins/include/ext-include-common.c | 96 +- src/lib-sieve/plugins/include/ext-include-common.h | 11 +- src/lib-sieve/plugins/include/ext-include.c | 3 + src/lib-sieve/sieve-lexer.c | 4 +- src/lib-sieve/sieve-script-dict.c | 63 +- src/lib-sieve/sieve-script-file.c | 16 +- src/lib-sieve/sieve-script-private.h | 27 +- src/lib-sieve/sieve-script.c | 189 +++- src/lib-sieve/sieve-script.h | 24 +- src/lib-sieve/sieve.c | 8 +- src/lib-sievestorage/sieve-storage-script.c | 18 +- src/managesieve/cmd-getscript.c | 5 +- src/plugins/lda-sieve/lda-sieve-plugin.c | 4 +- tests/extensions/include/execute/optional.sieve | 5 + tests/extensions/include/included/optional-1.sieve | 9 + tests/extensions/include/included/optional-2.sieve | 9 + tests/extensions/include/optional.svtest | 40 + 25 files changed, 1264 insertions(+), 1061 deletions(-) diffs (truncated from 2982 to 300 lines): diff -r ea0eef5b5578 -r 7e2dbfc9206d Makefile.am --- a/Makefile.am Thu Sep 20 00:18:10 2012 +0200 +++ b/Makefile.am Thu Sep 20 00:22:36 2012 +0200 @@ -76,6 +76,7 @@ tests/extensions/include/variables.svtest \ tests/extensions/include/once.svtest \ tests/extensions/include/twice.svtest \ + tests/extensions/include/optional.svtest \ tests/extensions/include/rfc.svtest \ tests/extensions/include/execute.svtest \ tests/extensions/imap4flags/basic.svtest \ diff -r ea0eef5b5578 -r 7e2dbfc9206d README --- a/README Thu Sep 20 00:18:10 2012 +0200 +++ b/README Thu Sep 20 00:22:36 2012 +0200 @@ -109,8 +109,7 @@ relational (RFC 5231): fully supported. imap4flags (RFC 5232): fully supported. subaddress (RFC 5233): fully supported, but with limited configurability. - spamtest and virustest (RFC 5235): fully supported (v0.1.16+), but - currently considered experimental. + spamtest and virustest (RFC 5235): fully supported (v0.1.16+). date (RFC 5260; Section 4): fully supported (v0.1.12+). editheader (RFC 5293): fully supported (v0.3.0+). reject (RFC 5429; Section 2.2): fully supported. @@ -121,8 +120,7 @@ ihave (RFC 5463): fully supported (v0.2.4+). mailbox (RFC 5490; Section 3): fully supported (v0.1.10+), but ACL permissions are not verified for mailboxexists. - include (draft v05; not latest version): almost fully supported, but - interaction with ManageSieve is not in accordance with specification. + include (RFC 6609): fully supported (v0.4.0+) regex (draft v08; not latest version): almost fully supported, but UTF-8 is not supported. diff -r ea0eef5b5578 -r 7e2dbfc9206d TODO --- a/TODO Thu Sep 20 00:18:10 2012 +0200 +++ b/TODO Thu Sep 20 00:22:36 2012 +0200 @@ -21,8 +21,6 @@ of script storage like LDAP or SQL database. - Implement read/write script storages for using ManageSieve with dict database -* Update include extension to latest draft (v13 currently): - - Implement :optional tag. * Implement index extension * Add normalize() method to comparators to normalize the string before matching (for efficiency). diff -r ea0eef5b5578 -r 7e2dbfc9206d doc/rfc/draft-ietf-sieve-include-05.txt --- a/doc/rfc/draft-ietf-sieve-include-05.txt Thu Sep 20 00:18:10 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,784 +0,0 @@ - - - -Network Working Group C. Daboo -Internet-Draft A. Stone -Intended status: Standards Track July 12, 2010 -Expires: January 13, 2011 - - - Sieve Email Filtering: Include Extension - draft-ietf-sieve-include-05 - -Abstract - - The Sieve Email Filtering "include" extension permits users to - include one Sieve script inside another. This can make managing - large scripts or multiple sets of scripts much easier, and allows a - site and its users to build up libraries of scripts. Users are able - to include their own personal scripts or site-wide scripts. - -Status of this Memo - - This Internet-Draft is submitted in full conformance with the - provisions of BCP 78 and BCP 79. - - Internet-Drafts are working documents of the Internet Engineering - Task Force (IETF). Note that other groups may also distribute - working documents as Internet-Drafts. The list of current Internet- - Drafts is at http://datatracker.ietf.org/drafts/current/. - - Internet-Drafts are draft documents valid for a maximum of six months - and may be updated, replaced, or obsoleted by other documents at any - time. It is inappropriate to use Internet-Drafts as reference - material or to cite them other than as "work in progress." - - This Internet-Draft will expire on January 13, 2011. - -Copyright Notice - - Copyright (c) 2010 IETF Trust and the persons identified as the - document authors. All rights reserved. - - This document is subject to BCP 78 and the IETF Trust's Legal - Provisions Relating to IETF Documents - (http://trustee.ietf.org/license-info) in effect on the date of - publication of this document. Please review these documents - carefully, as they describe your rights and restrictions with respect - to this document. Code Components extracted from this document must - include Simplified BSD License text as described in Section 4.e of - the Trust Legal Provisions and are provided without warranty as - described in the Simplified BSD License. - - - -Daboo & Stone Expires January 13, 2011 [Page 1] - -Internet-Draft Sieve Extension: Include July 2010 - - - This document may contain material from IETF Documents or IETF - Contributions published or made publicly available before November - 10, 2008. The person(s) controlling the copyright in some of this - material may not have granted the IETF Trust the right to allow - modifications of such material outside the IETF Standards Process. - Without obtaining an adequate license from the person(s) controlling - the copyright in such materials, this document may not be modified - outside the IETF Standards Process, and derivative works of it may - not be created outside the IETF Standards Process, except to format - it for publication as an RFC or to translate it into languages other - than English. - - -Table of Contents - - 1. Introduction and Overview . . . . . . . . . . . . . . . . . . 5 - 2. Conventions Used in This Document . . . . . . . . . . . . . . 5 - 3. Include Extension . . . . . . . . . . . . . . . . . . . . . . 5 - 3.1. General Considerations . . . . . . . . . . . . . . . . . . 5 - 3.2. Control Structure include . . . . . . . . . . . . . . . . 6 - 3.3. Control Structure return . . . . . . . . . . . . . . . . . 10 - 3.4. Interaction with Variables . . . . . . . . . . . . . . . . 10 - 3.4.1. Control Structure global . . . . . . . . . . . . . . . 10 - 3.4.2. Variables Namespace global . . . . . . . . . . . . . . 12 - 4. Security Considerations . . . . . . . . . . . . . . . . . . . 12 - 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 - 5.1. "include" Extension Registration . . . . . . . . . . . . . 13 - 6. References . . . . . . . . . . . . . . . . . . . . . . . . . . 13 - 6.1. Normative References . . . . . . . . . . . . . . . . . . . 13 - 6.2. Informative References . . . . . . . . . . . . . . . . . . 13 - Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 13 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 13 - - - - - - - - - - - - - - - - - - - -Daboo & Stone Expires January 13, 2011 [Page 2] - -Internet-Draft Sieve Extension: Include July 2010 - - -Change History (to be removed prior to publication as an RFC) - - Changes from ietf-04 to ietf-05: - - a. Integrate review from Barry Leiba. - - Changes from ietf-03 to ietf-04: - - a. No changes. - - Changes from ietf-02 to ietf-03: - - a. Setting a variable then calling global on it is an error - (something like 'use strict'). - - b. Specify that the 'global' keyword is only available when - 'variables' has also been required. - - c. Uploading a script that includes a nonexistent script is not an - error at upload time. - - Changes from ietf-01 to ietf-02: - - a. Require that script names must be constant strings, not subject - to variable expansion. - - b. Try the phrase immediate script instead of current script. - - c. Clarify that "global 'varname'" and "global.varname" refer to the - same variable. - - d. Drop the requirement the global keywords come after require and - before anything else. - - Changes from ietf-00 to ietf-01: - - a. Replaced import/export with global. - - b. Added :once modifier to include. - - c. Added global namespace to see if it holds water. - - Changes from daboo-06 to ietf-00: - - a. None - - Changes from -05 to -06: - - - - -Daboo & Stone Expires January 13, 2011 [Page 3] - -Internet-Draft Sieve Extension: Include July 2010 - - - a. Aaron Stone joins as author. - - b. Removed | characters from the script examples. - - c. Updated draft references to published RFCs. - - Changes from -04 to -05: - - a. Fixed examples. - - b. Relaxed requirement that imported/exported variables be set - before being used. - - Changes from -03 to -04: - - a. Fixed missing 2119 definitions. - - b. Defined interaction with variables through use of import and - export commands. - - Changes from -02 to -03: - - a. Refreshing expired draft (updated for nits). - - b. Syntax -> Usage. - - c. Updated to 3028bis reference. - - Changes from -01 to -02: - - a. Minor formatting changes only - refreshing expired draft. - - Changes from -00 to -01: - - a. Added IPR boiler plate. - - b. Re-ordered sections at start to conform to RFC style. - - c. Moved recursion comment into General Considerations section. - - d. Switched to using optional parameter to indicate personal vs - global. - - e. Explicitly state that an error occurs when a missing script is - included. - - - - - - -Daboo & Stone Expires January 13, 2011 [Page 4] - -Internet-Draft Sieve Extension: Include July 2010 - - -1. Introduction and Overview - - It's convenient to be able to break SIEVE [RFC5228] scripts down into - smaller components which can be reused in a variety of different - circumstances. For example, users may want to have a default script - and a special 'vacation' script, the latter being activated when the - user goes on vacation. In that case the default actions should - continue to be run, but a vacation command should be executed first. - One option is to edit the default script to add or remove the - vacation command as needed. Another is to have a vacation script - that simply has a vacation command and then includes the default - script. - - -2. Conventions Used in This Document - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in [RFC2119]. - - Conventions for notations are as in SIEVE [RFC5228] Section 1.1. - - The following key phrases are used to describe scripts and script From pigeonhole at rename-it.nl Thu Sep 20 01:51:14 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 20 Sep 2012 00:51:14 +0200 Subject: dovecot-2.2-pigeonhole: Fixed a few resource leaks caused by pre... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/3d3d8549c834 changeset: 1670:3d3d8549c834 user: Stephan Bosch date: Thu Sep 20 00:51:09 2012 +0200 description: Fixed a few resource leaks caused by previous change. diffstat: src/lib-sieve/plugins/include/ext-include-binary.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (27 lines): diff -r 7e2dbfc9206d -r 3d3d8549c834 src/lib-sieve/plugins/include/ext-include-binary.c --- a/src/lib-sieve/plugins/include/ext-include-binary.c Thu Sep 20 00:22:36 2012 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.c Thu Sep 20 00:51:09 2012 +0200 @@ -333,6 +333,7 @@ if ( sieve_script_open(script, &error) < 0 ) { if ( error != SIEVE_ERROR_NOT_FOUND ) { /* No, recompile */ + sieve_script_unref(&script); return FALSE; } @@ -344,6 +345,7 @@ "include: script '%s' contained in binary %s is now missing, " "so recompile", str_c(script_name), sieve_binary_path(sbin)); } + sieve_script_unref(&script); return FALSE; } @@ -356,6 +358,7 @@ "include: script '%s' is missing in binary %s, but is now available, " "so recompile", str_c(script_name), sieve_binary_path(sbin)); } + sieve_script_unref(&script); return FALSE; } From pigeonhole at rename-it.nl Thu Sep 20 01:57:47 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 20 Sep 2012 00:57:47 +0200 Subject: dovecot-2.1-pigeonhole: sieve-tools: The -D option wasn't enable... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/d7b06a1be3e1 changeset: 1652:d7b06a1be3e1 user: Stephan Bosch date: Thu Sep 20 00:57:02 2012 +0200 description: sieve-tools: The -D option wasn't enabled and documented for all tools. Change backported from Pigeonhole v0.4 tree, which means that this change will duplicate there upon merge. diffstat: doc/man/sieve-dump.1.in | 3 +++ doc/man/sievec.1.in | 3 +++ src/sieve-tools/sieve-dump.c | 4 ++-- src/sieve-tools/sievec.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diffs (59 lines): diff -r df4088161da0 -r d7b06a1be3e1 doc/man/sieve-dump.1.in --- a/doc/man/sieve-dump.1.in Thu Sep 20 00:54:17 2012 +0200 +++ b/doc/man/sieve-dump.1.in Thu Sep 20 00:57:02 2012 +0200 @@ -40,6 +40,9 @@ .BI \-c\ config\-file Alternative Dovecot configuration file path. .TP +.B \-D +Enable Sieve debugging. +.TP .B \-h Produce per\-block hexdump output of the whole binary instead of the normal human\-readable output. diff -r df4088161da0 -r d7b06a1be3e1 doc/man/sievec.1.in --- a/doc/man/sievec.1.in Thu Sep 20 00:54:17 2012 +0200 +++ b/doc/man/sievec.1.in Thu Sep 20 00:57:02 2012 +0200 @@ -57,6 +57,9 @@ for a compiled Sieve binary file. Note that this option is not allowed when the \fIout\-file\fP argument is a directory. .TP +.B \-D +Enable Sieve debugging. +.TP .BI \-x\ extensions Set the available extensions. The parameter is a space\-separated list of the active extensions. By prepending the extension identifiers with \fB+\fP or diff -r df4088161da0 -r d7b06a1be3e1 src/sieve-tools/sieve-dump.c --- a/src/sieve-tools/sieve-dump.c Thu Sep 20 00:54:17 2012 +0200 +++ b/src/sieve-tools/sieve-dump.c Thu Sep 20 00:57:02 2012 +0200 @@ -28,7 +28,7 @@ static void print_help(void) { printf( -"Usage: sieve-dump [-c ] [-h] [-P ] [-x ]\n" +"Usage: sieve-dump [-c ] [-D] [-h] [-P ] [-x ]\n" " []\n" ); } @@ -46,7 +46,7 @@ int exit_status = EXIT_SUCCESS; int c; - sieve_tool = sieve_tool_init("sieve-dump", &argc, &argv, "hP:x:", FALSE); + sieve_tool = sieve_tool_init("sieve-dump", &argc, &argv, "DhP:x:", FALSE); outfile = NULL; diff -r df4088161da0 -r d7b06a1be3e1 src/sieve-tools/sievec.c --- a/src/sieve-tools/sievec.c Thu Sep 20 00:54:17 2012 +0200 +++ b/src/sieve-tools/sievec.c Thu Sep 20 00:57:02 2012 +0200 @@ -31,7 +31,7 @@ static void print_help(void) { printf( -"Usage: sievec [-c ] [-d] [-P ] [-x ] \n" +"Usage: sievec [-c ] [-d] [-D] [-P ] [-x ] \n" " []\n" ); } From pigeonhole at rename-it.nl Thu Sep 20 01:57:47 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 20 Sep 2012 00:57:47 +0200 Subject: dovecot-2.1-pigeonhole: lib-sieve: include extension: fixed miss... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/df4088161da0 changeset: 1651:df4088161da0 user: Stephan Bosch date: Thu Sep 20 00:54:17 2012 +0200 description: lib-sieve: include extension: fixed missing error cleanup that caused a resource leak. diffstat: src/lib-sieve/plugins/include/ext-include-binary.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (19 lines): diff -r 1e4ecd174edf -r df4088161da0 src/lib-sieve/plugins/include/ext-include-binary.c --- a/src/lib-sieve/plugins/include/ext-include-binary.c Tue Sep 18 21:30:45 2012 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.c Thu Sep 20 00:54:17 2012 +0200 @@ -293,7 +293,6 @@ "include: failed to find block %d for included script " "from dependency block %d of binary %s", inc_block_id, block_id, sieve_binary_path(sbin)); - return FALSE; } @@ -323,6 +322,7 @@ "include: dependency block %d of binary %s " "contains invalid script metadata for script %s", block_id, sieve_binary_path(sbin), sieve_script_location(script)); + sieve_script_unref(&script); return FALSE; } From pigeonhole at rename-it.nl Thu Sep 20 02:22:40 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 20 Sep 2012 01:22:40 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: include extension: didn't get... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/ead2e76425bf changeset: 1671:ead2e76425bf user: Stephan Bosch date: Thu Sep 20 01:22:29 2012 +0200 description: lib-sieve: include extension: didn't get semantics of mixing optional and non-optional includes for the same script quite right. diffstat: src/lib-sieve/plugins/include/ext-include-binary.c | 5 ++--- src/lib-sieve/plugins/include/ext-include-common.c | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diffs (63 lines): diff -r 3d3d8549c834 -r ead2e76425bf src/lib-sieve/plugins/include/ext-include-binary.c --- a/src/lib-sieve/plugins/include/ext-include-binary.c Thu Sep 20 00:51:09 2012 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.c Thu Sep 20 01:22:29 2012 +0200 @@ -337,12 +337,11 @@ return FALSE; } - if ( (flags & EXT_INCLUDE_FLAG_OPTIONAL) == 0 && - (flags & EXT_INCLUDE_FLAG_MISSING_AT_UPLOAD) == 0) { + if ( (flags & EXT_INCLUDE_FLAG_OPTIONAL) == 0 ) { /* Not supposed to be missing, recompile */ if ( svinst->debug ) { sieve_sys_debug(svinst, - "include: script '%s' contained in binary %s is now missing, " + "include: script '%s' included in binary %s is missing, " "so recompile", str_c(script_name), sieve_binary_path(sbin)); } sieve_script_unref(&script); diff -r 3d3d8549c834 -r ead2e76425bf src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Thu Sep 20 00:51:09 2012 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Thu Sep 20 01:22:29 2012 +0200 @@ -516,11 +516,19 @@ binctx = ext_include_binary_init(this_ext, sbin, cgenv->ast); /* Is the script already compiled into the current binary? */ - if ( !ext_include_binary_script_is_included(binctx, script, &included) ) - { + if ( ext_include_binary_script_is_included(binctx, script, &included) ) { + /* Yes, only update flags */ + if ( (flags & EXT_INCLUDE_FLAG_OPTIONAL) == 0 ) + flags &= ~EXT_INCLUDE_FLAG_OPTIONAL; + if ( (flags & EXT_INCLUDE_FLAG_ONCE) == 0 ) // for consistency + flags &= ~EXT_INCLUDE_FLAG_ONCE; + + } else { const char *script_name = sieve_script_name(script); enum sieve_compile_flags cpflags = cgenv->flags; + /* No, include new script */ + /* Check whether include limit is exceeded */ if ( ext_include_binary_script_get_count(binctx) >= ext_ctx->max_includes ) { @@ -530,9 +538,10 @@ return -1; } - /* No, allocate a new block in the binary and mark the script as included. + /* Allocate a new block in the binary and mark the script as included. */ if ( !sieve_script_is_open(script) ) { + /* Just making an empty entry to mark a missing script */ i_assert((flags & EXT_INCLUDE_FLAG_MISSING_AT_UPLOAD) != 0 || (flags & EXT_INCLUDE_FLAG_OPTIONAL) != 0); included = ext_include_binary_script_include @@ -542,6 +551,7 @@ } else { struct sieve_binary_block *inc_block = sieve_binary_block_create(sbin); + /* Real include */ included = ext_include_binary_script_include (binctx, location, flags, script, inc_block); From dovecot at dovecot.org Sat Sep 22 19:13:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 22 Sep 2012 19:13:49 +0300 Subject: dovecot-2.1: config: Don't ignore invalid network/mask in local/... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/02aa054c762f changeset: 14720:02aa054c762f user: Timo Sirainen date: Fri Sep 21 09:22:54 2012 +0200 description: config: Don't ignore invalid network/mask in local/remote blocks diffstat: src/config/config-parser.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 3c215bd49cd0 -r 02aa054c762f src/config/config-parser.c --- a/src/config/config-parser.c Tue Sep 18 21:42:34 2012 +0300 +++ b/src/config/config-parser.c Fri Sep 21 09:22:54 2012 +0200 @@ -254,10 +254,14 @@ } max_bits = IPADDR_IS_V4(&ips[0]) ? 32 : 128; - if (p == NULL || str_to_uint(p, &bits) < 0 || bits > max_bits) + if (p == NULL) *bits_r = max_bits; - else + else if (str_to_uint(p, &bits) == 0 && bits <= max_bits) *bits_r = bits; + else { + *error_r = t_strdup_printf("Invalid network mask: %s", p); + return -1; + } return 0; } From dovecot at dovecot.org Sat Sep 22 19:13:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 22 Sep 2012 19:13:49 +0300 Subject: dovecot-2.1: lmtp: RSET/LHLO should reset any pending proxy conn... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2efd5eb7966d changeset: 14721:2efd5eb7966d user: Timo Sirainen date: Fri Sep 21 09:23:58 2012 +0200 description: lmtp: RSET/LHLO should reset any pending proxy connections. diffstat: src/lmtp/client.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 02aa054c762f -r 2efd5eb7966d src/lmtp/client.c --- a/src/lmtp/client.c Fri Sep 21 09:22:54 2012 +0200 +++ b/src/lmtp/client.c Fri Sep 21 09:23:58 2012 +0200 @@ -294,6 +294,9 @@ { struct mail_recipient *rcpt; + if (client->proxy != NULL) + lmtp_proxy_deinit(&client->proxy); + if (array_is_created(&client->state.rcpt_to)) { array_foreach_modifiable(&client->state.rcpt_to, rcpt) mail_storage_service_user_free(&rcpt->service_user); From dovecot at dovecot.org Sat Sep 22 19:13:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 22 Sep 2012 19:13:49 +0300 Subject: dovecot-2.1: mdbox: Delay getting permissions for map/message fi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c83c70edef35 changeset: 14723:c83c70edef35 user: Timo Sirainen date: Fri Sep 21 11:44:17 2012 +0200 description: mdbox: Delay getting permissions for map/message files. This avoids a stat() if no mailbox is opened. diffstat: src/lib-storage/index/dbox-multi/mdbox-file.c | 21 ++++++----- src/lib-storage/index/dbox-multi/mdbox-map-private.h | 10 +++- src/lib-storage/index/dbox-multi/mdbox-map.c | 36 +++++++++++++++---- 3 files changed, 47 insertions(+), 20 deletions(-) diffs (155 lines): diff -r 6908b8875720 -r c83c70edef35 src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Fri Sep 21 09:26:10 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Fri Sep 21 11:44:17 2012 +0200 @@ -302,11 +302,14 @@ { struct mdbox_file *mfile = (struct mdbox_file *)file; struct mdbox_map *map = mfile->storage->map; - mode_t old_mask; - const char *p, *dir, *error; + mode_t create_mode, old_mask; + gid_t create_gid; + const char *create_gid_origin, *p, *dir, *error; int fd; - old_mask = umask(0666 & ~map->create_mode); + mdbox_map_get_create_mode(map, &create_mode, &create_gid, + &create_gid_origin); + old_mask = umask(0666 & ~create_mode); fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); umask(old_mask); if (fd == -1 && errno == ENOENT && parents && @@ -322,25 +325,25 @@ return -1; } /* try again */ - old_mask = umask(0666 & ~map->create_mode); + old_mask = umask(0666 & ~create_mode); fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); umask(old_mask); } if (fd == -1) { mail_storage_set_critical(&file->storage->storage, "open(%s, O_CREAT) failed: %m", path); - } else if (map->create_gid == (gid_t)-1) { + } else if (create_gid == (gid_t)-1) { /* no group change */ - } else if (fchown(fd, (uid_t)-1, map->create_gid) < 0) { + } else if (fchown(fd, (uid_t)-1, create_gid) < 0) { if (errno == EPERM) { mail_storage_set_critical(&file->storage->storage, "%s", eperm_error_get_chgrp("fchown", path, - map->create_gid, - map->create_gid_origin)); + create_gid, + create_gid_origin)); } else { mail_storage_set_critical(&file->storage->storage, "fchown(%s, -1, %ld) failed: %m", - path, (long)map->create_gid); + path, (long)create_gid); } /* continue anyway */ } diff -r 6908b8875720 -r c83c70edef35 src/lib-storage/index/dbox-multi/mdbox-map-private.h --- a/src/lib-storage/index/dbox-multi/mdbox-map-private.h Fri Sep 21 09:26:10 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map-private.h Fri Sep 21 11:44:17 2012 +0200 @@ -20,11 +20,12 @@ uint32_t map_ext_id, ref_ext_id; struct mailbox_list *root_list; - mode_t create_mode; - gid_t create_gid; - const char *create_gid_origin; + mode_t _create_mode; + gid_t _create_gid; + char *_create_gid_origin; unsigned int verify_existing_file_ids:1; + unsigned int create_mode_set:1; }; struct mdbox_map_append { @@ -64,4 +65,7 @@ struct mail_index_view *view, uint32_t seq, struct dbox_mail_lookup_rec *rec_r); +void mdbox_map_get_create_mode(struct mdbox_map *map, mode_t *mode_r, gid_t *gid_r, + const char **gid_origin_r); + #endif diff -r 6908b8875720 -r c83c70edef35 src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Sep 21 09:26:10 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Sep 21 11:44:17 2012 +0200 @@ -50,7 +50,6 @@ { struct mdbox_map *map; const char *root, *index_root; - mode_t dir_mode; root = mailbox_list_get_path(root_list, NULL, MAILBOX_LIST_PATH_TYPE_DIR); @@ -77,14 +76,26 @@ sizeof(uint32_t)); map->ref_ext_id = mail_index_ext_register(map->index, "ref", 0, sizeof(uint16_t), sizeof(uint16_t)); + return map; +} - mailbox_list_get_root_permissions(root_list, - &map->create_mode, &dir_mode, - &map->create_gid, - &map->create_gid_origin); - mail_index_set_permissions(map->index, map->create_mode, - map->create_gid, map->create_gid_origin); - return map; +void mdbox_map_get_create_mode(struct mdbox_map *map, mode_t *mode_r, gid_t *gid_r, + const char **gid_origin_r) +{ + mode_t dir_mode; + const char *gid_origin; + + if (!map->create_mode_set) { + mailbox_list_get_root_permissions(map->root_list, + &map->_create_mode, &dir_mode, + &map->_create_gid, + &gid_origin); + map->_create_gid_origin = i_strdup(gid_origin); + map->create_mode_set = TRUE; + } + *mode_r = map->_create_mode; + *gid_r = map->_create_gid; + *gid_origin_r = map->_create_gid_origin; } void mdbox_map_deinit(struct mdbox_map **_map) @@ -98,6 +109,7 @@ mail_index_close(map->index); } mail_index_free(&map->index); + i_free(map->_create_gid_origin); i_free(map->index_path); i_free(map->path); i_free(map); @@ -156,6 +168,9 @@ static int mdbox_map_open_internal(struct mdbox_map *map, bool create_missing) { enum mail_index_open_flags open_flags; + mode_t create_mode; + gid_t create_gid; + const char *create_gid_origin; int ret = 0; if (map->view != NULL) { @@ -163,6 +178,11 @@ return 1; } + mdbox_map_get_create_mode(map, &create_mode, &create_gid, + &create_gid_origin); + mail_index_set_permissions(map->index, create_mode, + create_gid, create_gid_origin); + open_flags = MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY | mail_storage_settings_to_index_flags(MAP_STORAGE(map)->set); if (create_missing) { From dovecot at dovecot.org Sat Sep 22 19:13:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 22 Sep 2012 19:13:49 +0300 Subject: dovecot-2.1: lmtp: After successful proxying RCPT TO, the second... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6908b8875720 changeset: 14722:6908b8875720 user: Timo Sirainen date: Fri Sep 21 09:26:10 2012 +0200 description: lmtp: After successful proxying RCPT TO, the second one to nonexistent user gave tempfail error. Instead of "unknown user" it gave "Can't handle mixed proxy/non-proxy destinations". diffstat: src/lmtp/commands.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diffs (36 lines): diff -r 2efd5eb7966d -r 6908b8875720 src/lmtp/commands.c --- a/src/lmtp/commands.c Fri Sep 21 09:23:58 2012 +0200 +++ b/src/lmtp/commands.c Fri Sep 21 09:26:10 2012 +0200 @@ -479,16 +479,6 @@ return 0; } - if (client->proxy != NULL) { - /* NOTE: if this restriction is ever removed, we'll also need - to send different message bodies to local and proxy - (with and without Return-Path: header) */ - client_send_line(client, "451 4.3.0 <%s> " - "Can't handle mixed proxy/non-proxy destinations", - address); - return 0; - } - memset(&input, 0, sizeof(input)); input.module = input.service = "lmtp"; input.username = username; @@ -512,6 +502,15 @@ address, username); return 0; } + if (client->proxy != NULL) { + /* NOTE: if this restriction is ever removed, we'll also need + to send different message bodies to local and proxy + (with and without Return-Path: header) */ + client_send_line(client, "451 4.3.0 <%s> " + "Can't handle mixed proxy/non-proxy destinations", + address); + return 0; + } lmtp_address_translate(client, &address); From dovecot at dovecot.org Sat Sep 22 19:22:11 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 22 Sep 2012 19:22:11 +0300 Subject: dovecot-2.2: imapc: Fixed crash when saving/copying messages. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c5926a27fa2d changeset: 15092:c5926a27fa2d user: Timo Sirainen date: Sat Sep 22 19:21:58 2012 +0300 description: imapc: Fixed crash when saving/copying messages. diffstat: src/lib-storage/index/imapc/imapc-save.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (23 lines): diff -r a73f4d12289e -r c5926a27fa2d src/lib-storage/index/imapc/imapc-save.c --- a/src/lib-storage/index/imapc/imapc-save.c Thu Sep 20 01:01:20 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-save.c Sat Sep 22 19:21:58 2012 +0300 @@ -126,7 +126,8 @@ return; if (str_to_uint32(args[1], &dest_uid) == 0) { - seq_range_array_add(&ctx->dest_saved_uids, dest_uid); + seq_range_array_add_with_init(&ctx->dest_saved_uids, + 32, dest_uid); *uid_r = dest_uid; } } @@ -343,7 +344,8 @@ return; if (str_to_uint32(args[2], &dest_uid) == 0) { - seq_range_array_add(&ctx->dest_saved_uids, dest_uid); + seq_range_array_add_with_init(&ctx->dest_saved_uids, + 32, dest_uid); *uid_r = dest_uid; } } From dovecot at dovecot.org Sat Sep 22 19:23:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 22 Sep 2012 19:23:23 +0300 Subject: dovecot-2.2: lib-lda: After auto-creating mailbox only open it, ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4776fbf6d93a changeset: 15093:4776fbf6d93a user: Timo Sirainen date: Sat Sep 22 19:23:15 2012 +0300 description: lib-lda: After auto-creating mailbox only open it, don't bother syncing it. diffstat: src/lib-lda/mail-deliver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r c5926a27fa2d -r 4776fbf6d93a src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Sat Sep 22 19:21:58 2012 +0300 +++ b/src/lib-lda/mail-deliver.c Sat Sep 22 19:23:15 2012 +0300 @@ -205,7 +205,7 @@ } /* and try opening again */ - if (mailbox_sync(box, 0) < 0) { + if (mailbox_open(box) < 0) { *error_str_r = mailbox_get_last_error(box, error_r); return -1; } From dovecot at dovecot.org Sat Sep 22 19:36:41 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 22 Sep 2012 19:36:41 +0300 Subject: dovecot-2.1: lib-lda: After auto-creating mailbox only open it, ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f818f65f1a7f changeset: 14724:f818f65f1a7f user: Timo Sirainen date: Sat Sep 22 19:23:15 2012 +0300 description: lib-lda: After auto-creating mailbox only open it, don't bother syncing it. diffstat: src/lib-lda/mail-deliver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r c83c70edef35 -r f818f65f1a7f src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Fri Sep 21 11:44:17 2012 +0200 +++ b/src/lib-lda/mail-deliver.c Sat Sep 22 19:23:15 2012 +0300 @@ -205,7 +205,7 @@ } /* and try opening again */ - if (mailbox_sync(box, 0) < 0) { + if (mailbox_open(box) < 0) { *error_str_r = mailbox_get_last_error(box, error_r); return -1; } From pigeonhole at rename-it.nl Sun Sep 23 18:09:52 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:09:52 +0200 Subject: dovecot-2.1-pigeonhole: lib-sieve: mailbox extension: After crea... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/fcd5208ed8b2 changeset: 1653:fcd5208ed8b2 user: Stephan Bosch date: Sun Sep 23 17:09:26 2012 +0200 description: lib-sieve: mailbox extension: After creating mailbox only open it, don't bother syncing it. diffstat: src/lib-sieve/plugins/mailbox/tag-mailbox-create.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r d7b06a1be3e1 -r fcd5208ed8b2 src/lib-sieve/plugins/mailbox/tag-mailbox-create.c --- a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Thu Sep 20 00:57:02 2012 +0200 +++ b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Sun Sep 23 17:09:26 2012 +0200 @@ -156,7 +156,7 @@ } /* Try opening again */ - if ( mailbox_sync(trans->box, 0) < 0 ) { + if ( mailbox_open(trans->box) < 0 ) { /* Failed definitively */ sieve_act_store_get_storage_error(aenv, trans); return FALSE; From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: sieve-refilter: improved man page docume... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/b1bedb88e615 changeset: 1674:b1bedb88e615 user: Stephan Bosch date: Sun Sep 09 10:45:46 2012 +0200 description: sieve-refilter: improved man page documentation by explicitly specifying the syntax used for mailbox arguments. diffstat: doc/man/sieve-filter.1.in | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diffs (45 lines): diff -r ff55c9946366 -r b1bedb88e615 doc/man/sieve-filter.1.in --- a/doc/man/sieve-filter.1.in Thu Aug 16 22:28:06 2012 +0200 +++ b/doc/man/sieve-filter.1.in Sun Sep 09 10:45:46 2012 +0200 @@ -92,7 +92,8 @@ is equal to the \fIsource\-mailbox\fP by default. Specifying a different folder will have the effect of moving (or copying if \fB\-W\fP is omitted) all kept messages to the indicated folder, instead of just leaving them in the -\fIsource\-mailbox\fP. +\fIsource\-mailbox\fP. Refer to the explanation of the \fIsource\-mailbox\fP +argument for more information on mailbox naming. .TP .BI \-q\ output\-mailbox\ \fB[not\ implemented\ yet]\fP Store outgoing e\-mail into the indicated \fIoutput\-mailbox\fP. By default, @@ -153,9 +154,18 @@ into a new binary. .TP .I source\-mailbox -The name of the source mailbox containing the messages that the Sieve filter -will act upon. This mailbox is not modified unless the \fB\-W\fP option is -specified. +Specifies the source mailbox containing the messages that the Sieve filter will +act upon. + +This is the name of a mailbox, as visible to IMAP clients, except in UTF-8 +format. The hierarchy separator between a parent and child mailbox is commonly +.RB \(aq / \(aq +or +.RB \(aq . \(aq, +but this depends on your selected mailbox storage format and +namespace configuration. The mailbox names may also require a namespace prefix. + +This mailbox is not modified unless the \fB\-W\fP option is specified. .TP .I discard\-action Specifies what is done with messages in the \fIsource\-mailbox\fP that where not @@ -169,7 +179,8 @@ .TP .BI move\ mailbox Move discarded messages to the indicated \fImailbox\fP. This is for instance -useful to move messages to a Trash mailbox. +useful to move messages to a Trash mailbox. Refer to the explanation of +the \fIsource\-mailbox\fP argument for more information on mailbox naming. .TP .B delete Flag discarded messages as \\DELETED. From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Updated NEWS file for next release. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/0505fc4b10c4 changeset: 1675:0505fc4b10c4 user: Stephan Bosch date: Tue Sep 18 16:01:48 2012 +0200 description: Updated NEWS file for next release. diffstat: NEWS | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diffs (25 lines): diff -r b1bedb88e615 -r 0505fc4b10c4 NEWS --- a/NEWS Sun Sep 09 10:45:46 2012 +0200 +++ b/NEWS Tue Sep 18 16:01:48 2012 +0200 @@ -1,3 +1,21 @@ +v0.3.2 18-09-2012 Stephan Bosch + + + sieve-refilter tool: improved man page documentation by explicitly + specifying the syntax used for mailbox arguments. + + Sieve: spamtest and virustest extensions: improved trace debugging of score + calculation. + + Sieve: made error messages about exceeding the maximum number of actions + more verbose. + - Sieve tools: fixed problems with running as root: sievec and sieve-dump now + ignore mail_uid and mail_gid settings when run as root. + - Sieve: fixed bug in action accounting (for limit checking): increase action + instance count only when an action is actually created. + - Sieve: include extension: fixed namespace separation of :global and + :personal scripts. + - ManageSieve: fixed segfault bug triggered by CHECKSCRIPT command. + - Fixed linking with ld.gold. + - Fixed several Clang compile warnings and a few potential bugs. + v0.3.1 25-05-2012 Stephan Bosch * Added support for retrieving Sieve scripts from dict lookup. This means that From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Added signature for changeset 265061e0d3f4 Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/2347ddfd9057 changeset: 1678:2347ddfd9057 user: Stephan Bosch date: Tue Sep 18 16:20:22 2012 +0200 description: Added signature for changeset 265061e0d3f4 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 2dbb17d08591 -r 2347ddfd9057 .hgsigs --- a/.hgsigs Tue Sep 18 16:13:09 2012 +0200 +++ b/.hgsigs Tue Sep 18 16:20:22 2012 +0200 @@ -5,3 +5,4 @@ 873baa85e2202f45a9c14fa21cccedc60f3715bc 0 iQEcBAABAgAGBQJOx9MCAAoJEATWKx49+7T09aUIANIKsuzM3bGhtGJ/UPIwzpOu39lEGCmHah6dMa+bDOoCZhuhASDdTuvRKXTfGC57GMu+NzBK6I7heFiPD3E4VTI4xOCK1azJ9G4SsiDEkQThucXqWBKDjPB0RgOEf6iefAkslXIU3cprJgattwpeXbUKiHjBhoYJFJ5j/GTx1B62ndvaTfMu1zF5UppiyRG1rQD7FLY4f6kANzSI2jOOCBs4UFH7ZKhafO1AeQfLNDvxdDczZafPZxrCIF+5JCNvQ6Xue/JrvRZQ0V9sxLQat7clUJ6I6Ejl5u5l1LF+VscWldfaQKwDdOktCVux84YGH8+XqXaukMiEg6j4hceAYIM= fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0 iQEcBAABAgAGBQJPPXAPAAoJEATWKx49+7T0iqMH/3e+RKKmryOz5pak0cvdPcS/D9O9xl2l6SuoE2okTq/WOrDtZ1xDg0afg7t27D9mDfUY1hiSFS4ekN3WP620Gcb9wlL3FC+rLEYmiE8iSfZvsH+FeLa7n8NB+XdnAsXE1WdLQp5CSKEh3sXIod7Q04PL0uv/rimGS9jOGcAufW3y9QAYd+DVorPS4lV5Kz8qIqY9r/0lLqhJN1ukIJtClVkFanRljd+SfoHFFOSWbQjCKNxlOSWFhwJji7Mp091A1+N6JoZe4IMIlajMsM2Ypp726Y2LA/du+uRVFjKgta65eP9tfdrmVCJtrjIjvikowD5Zl80GuVRI5j44aQ7rJ3A= e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0 iQEcBAABAgAGBQJPwAS+AAoJEATWKx49+7T0ngIH/R+teyHN4Pdv4bFTkder85rxy4bzPDzlV9gGlhuKuRBtI8F7CKKWLEP/ESPdtZbMmsNj9k104q2U9pgUfkYrVKL4lrk3hlz44o8Smpwp/xrxyNY8/OuBof0LvyXjp7unHAvvAWFiEmeTpJMmSu77xE8wsEqZowHi8/Igh3lrQ3U129VP1xWr1mvnvQdMQk9TTMK3T38H9kUrz2CRdOWjJbxAA4rLyozGLqWUeSKepUcwAGANd35k8pNLYiONlGU8NZsQyzS2dfOl0TeolgqZn+UkmM9FZFFnD40WU8zPft0nK4g8cFZGObX4fsPyK03EAnR7BXd1BKdmr7jdppAnSvQ= +265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0 iQEcBAABAgAGBQJQWIMhAAoJEATWKx49+7T0g/IH/3qqQemBP62Y+Wzo67DruphrJ5HSlIX4Uw/O4rOjrk8dWSMrsui5jFy4LXig+CR1dfY4RS0izTxsAiNhTACuavMfGHiYBKQW6UwIDlKECVBxbQyjB7v2C3FKPj9K9QReiYACSeB1RhQBnpbcvioif9H62VI5SKE6rjXyky6fDAxtbjhySb+nPDtV4HmV7ukcfDc3bxwcZkz9XXKoNmPWw8r34Z/RwxWbbWr8xUwW3+9LDB2Oz6PRyYP5S8EcNNYjk3ai2Llh0xuJGLQbpulhmjYDJmk20TkpLCFAfsYq1qW3yed9lL88CcFH4LDb9WA0LNs+7PfbmY/m8CX7JwUmHB8= From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Released v0.3.2 for Dovecot v2.1.9. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/265061e0d3f4 changeset: 1676:265061e0d3f4 user: Stephan Bosch date: Tue Sep 18 16:12:44 2012 +0200 description: Released v0.3.2 for Dovecot v2.1.9. diffstat: configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (9 lines): diff -r 0505fc4b10c4 -r 265061e0d3f4 configure.in --- a/configure.in Tue Sep 18 16:01:48 2012 +0200 +++ b/configure.in Tue Sep 18 16:12:44 2012 +0200 @@ -1,4 +1,4 @@ -AC_INIT([Pigeonhole], [0.3.1], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) +AC_INIT([Pigeonhole], [0.3.2], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Added tag 0.3.2 for changeset 265061e0d3f4 Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/2dbb17d08591 changeset: 1677:2dbb17d08591 user: Stephan Bosch date: Tue Sep 18 16:13:09 2012 +0200 description: Added tag 0.3.2 for changeset 265061e0d3f4 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 265061e0d3f4 -r 2dbb17d08591 .hgtags --- a/.hgtags Tue Sep 18 16:12:44 2012 +0200 +++ b/.hgtags Tue Sep 18 16:13:09 2012 +0200 @@ -11,3 +11,4 @@ 873baa85e2202f45a9c14fa21cccedc60f3715bc 0.2.5 fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0.3.0 e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0.3.1 +265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0.3.2 From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: spamvirustest: improved trace... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/ff55c9946366 changeset: 1673:ff55c9946366 user: Stephan Bosch date: Thu Aug 16 22:28:06 2012 +0200 description: lib-sieve: spamvirustest: improved trace debugging of score calculation. diffstat: src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c | 47 +++++---- src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c | 2 + 2 files changed, 27 insertions(+), 22 deletions(-) diffs (159 lines): diff -r cfe8e9f49dfe -r ff55c9946366 src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c --- a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c Wed Aug 15 00:55:05 2012 +0200 +++ b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c Thu Aug 16 22:28:06 2012 +0200 @@ -457,7 +457,6 @@ const struct sieve_message_data *msgdata = renv->msgdata; struct sieve_message_context *msgctx = renv->msgctx; struct ext_spamvirustest_message_context *mctx; - const char *ext_name = sieve_extension_name(ext); regmatch_t match_values[2]; const char *header_value, *error; const char *status = NULL, *max = NULL; @@ -470,7 +469,7 @@ */ if ( ext_data == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: extension not configured", ext_name); + "error: extension not configured"); return "0"; } @@ -504,8 +503,8 @@ (msgdata->mail, max_header->header_name, &header_value) < 0 || header_value == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: header '%s' not found in message", - ext_name, max_header->header_name); + "header '%s' not found in message", + max_header->header_name); goto failed; } @@ -514,16 +513,16 @@ if ( regexec(&max_header->regexp, header_value, 2, match_values, 0) != 0 ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp for header '%s' did not match " - "on value '%s'", ext_name, max_header->header_name, header_value); + "regexp for header '%s' did not match " + "on value '%s'", max_header->header_name, header_value); goto failed; } max = _regexp_match_get_value(header_value, 1, match_values, 2); if ( max == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp did not return match value " - "for string '%s'", ext_name, header_value); + "regexp did not return match value " + "for string '%s'", header_value); goto failed; } } else { @@ -532,7 +531,7 @@ if ( !ext_spamvirustest_parse_decimal_value(max, &max_value, &error) ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: failed to parse maximum value: %s", ext_name, error); + "failed to parse maximum value: %s", error); goto failed; } } else { @@ -541,7 +540,7 @@ if ( max_value == 0 ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: max value is 0", ext_name); + "error: max value is 0"); goto failed; } } else { @@ -557,8 +556,8 @@ (msgdata->mail, status_header->header_name, &header_value) < 0 || header_value == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: header '%s' not found in message", - ext_name, status_header->header_name); + "header '%s' not found in message", + status_header->header_name); goto failed; } @@ -567,16 +566,16 @@ if ( regexec(&status_header->regexp, header_value, 2, match_values, 0) != 0 ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp for header '%s' did not match on value '%s'", - ext_name, status_header->header_name, header_value); + "regexp for header '%s' did not match on value '%s'", + status_header->header_name, header_value); goto failed; } status = _regexp_match_get_value(header_value, 1, match_values, 2); if ( status == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp did not return match value for string '%s'", - ext_name, header_value); + "regexp did not return match value for string '%s'", + header_value); goto failed; } } else { @@ -588,8 +587,8 @@ if ( !ext_spamvirustest_parse_decimal_value (status, &status_value, &error) ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: failed to parse status value '%s': %s", - ext_name, status, error); + "failed to parse status value '%s': %s", + status, error); goto failed; } break; @@ -597,8 +596,8 @@ if ( !ext_spamvirustest_parse_strlen_value (status, &status_value, &error) ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: failed to parse status value '%s': %s", - ext_name, status, error); + "failed to parse status value '%s': %s", + status, error); goto failed; } break; @@ -618,8 +617,8 @@ if ( i > max_text ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: failed to match textstatus value '%s'", - ext_name, status); + "failed to match textstatus value '%s'", + status); goto failed; } break; @@ -636,6 +635,10 @@ else mctx->score_ratio = (status_value / max_value); + sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, + "extracted score=%.3f, max=%.3f, ratio=%.0f %%", + status_value, max_value, mctx->score_ratio * 100); + return ext_spamvirustest_get_score(ext, mctx->score_ratio, percent); failed: diff -r cfe8e9f49dfe -r ff55c9946366 src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c --- a/src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c Wed Aug 15 00:55:05 2012 +0200 +++ b/src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c Thu Aug 16 22:28:06 2012 +0200 @@ -290,7 +290,9 @@ } /* Get score value */ + sieve_runtime_trace_descend(renv); score_value = ext_spamvirustest_get_value(renv, this_ext, percent); + sieve_runtime_trace_ascend(renv); /* Construct value list */ value_list = sieve_single_stringlist_create_cstr(renv, score_value, TRUE); From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Added signature for changeset 64474c359678 Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/1e4ecd174edf changeset: 1682:1e4ecd174edf user: Stephan Bosch date: Tue Sep 18 21:30:45 2012 +0200 description: Added signature for changeset 64474c359678 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r e4fe281d33e8 -r 1e4ecd174edf .hgsigs --- a/.hgsigs Tue Sep 18 21:29:16 2012 +0200 +++ b/.hgsigs Tue Sep 18 21:30:45 2012 +0200 @@ -6,3 +6,4 @@ fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0 iQEcBAABAgAGBQJPPXAPAAoJEATWKx49+7T0iqMH/3e+RKKmryOz5pak0cvdPcS/D9O9xl2l6SuoE2okTq/WOrDtZ1xDg0afg7t27D9mDfUY1hiSFS4ekN3WP620Gcb9wlL3FC+rLEYmiE8iSfZvsH+FeLa7n8NB+XdnAsXE1WdLQp5CSKEh3sXIod7Q04PL0uv/rimGS9jOGcAufW3y9QAYd+DVorPS4lV5Kz8qIqY9r/0lLqhJN1ukIJtClVkFanRljd+SfoHFFOSWbQjCKNxlOSWFhwJji7Mp091A1+N6JoZe4IMIlajMsM2Ypp726Y2LA/du+uRVFjKgta65eP9tfdrmVCJtrjIjvikowD5Zl80GuVRI5j44aQ7rJ3A= e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0 iQEcBAABAgAGBQJPwAS+AAoJEATWKx49+7T0ngIH/R+teyHN4Pdv4bFTkder85rxy4bzPDzlV9gGlhuKuRBtI8F7CKKWLEP/ESPdtZbMmsNj9k104q2U9pgUfkYrVKL4lrk3hlz44o8Smpwp/xrxyNY8/OuBof0LvyXjp7unHAvvAWFiEmeTpJMmSu77xE8wsEqZowHi8/Igh3lrQ3U129VP1xWr1mvnvQdMQk9TTMK3T38H9kUrz2CRdOWjJbxAA4rLyozGLqWUeSKepUcwAGANd35k8pNLYiONlGU8NZsQyzS2dfOl0TeolgqZn+UkmM9FZFFnD40WU8zPft0nK4g8cFZGObX4fsPyK03EAnR7BXd1BKdmr7jdppAnSvQ= 265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0 iQEcBAABAgAGBQJQWIMhAAoJEATWKx49+7T0g/IH/3qqQemBP62Y+Wzo67DruphrJ5HSlIX4Uw/O4rOjrk8dWSMrsui5jFy4LXig+CR1dfY4RS0izTxsAiNhTACuavMfGHiYBKQW6UwIDlKECVBxbQyjB7v2C3FKPj9K9QReiYACSeB1RhQBnpbcvioif9H62VI5SKE6rjXyky6fDAxtbjhySb+nPDtV4HmV7ukcfDc3bxwcZkz9XXKoNmPWw8r34Z/RwxWbbWr8xUwW3+9LDB2Oz6PRyYP5S8EcNNYjk3ai2Llh0xuJGLQbpulhmjYDJmk20TkpLCFAfsYq1qW3yed9lL88CcFH4LDb9WA0LNs+7PfbmY/m8CX7JwUmHB8= +64474c35967852bc452f71bc099ec3f8ded0369a 0 iQEcBAABAgAGBQJQWMvhAAoJEATWKx49+7T0NrYH/2PQuuFqzlku+NG8Iw0UN2yeDEML+2n1xG31ud7m3sNWw8lX+03gEd+LU8+LygHJJ0IAde/jBYRBbC8zj9UXDl3v5FIRwhcvGnllBCMMH7motfg+aLrCR/xs+0jV/AqpRin1VILHYFaB9UFP5PUgvJJiCUniQWoe+r41gra1hRA7OK3923YOOi9t4zJxoat7e0OMhc0IcdB7n3iQmyicbb8izKw/UvR2tR3T7fVcEl6u1LlbGaojtJA03V1L+a8QkmltiurD9VNmiHz++bGGJlA7LSmVYBq7BeC1lDnXUGO9ryZgln6aXRwUS0VaTI51F9gSMw+0UDJCwA5yBKqYyR8= From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Released v0.3.3 for Dovecot v2.1.10. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/64474c359678 changeset: 1680:64474c359678 user: Stephan Bosch date: Tue Sep 18 21:29:11 2012 +0200 description: Released v0.3.3 for Dovecot v2.1.10. diffstat: NEWS | 5 +++++ configure.in | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diffs (21 lines): diff -r 8144fb698cb3 -r 64474c359678 NEWS --- a/NEWS Tue Sep 18 20:42:25 2012 +0200 +++ b/NEWS Tue Sep 18 21:29:11 2012 +0200 @@ -1,3 +1,8 @@ +v0.3.3 18-09-2012 Stephan Bosch + + - Fixed compile against installed Dovecot headers. This was broken by the + ld.gold fix in the previous release. + v0.3.2 18-09-2012 Stephan Bosch + sieve-refilter tool: improved man page documentation by explicitly diff -r 8144fb698cb3 -r 64474c359678 configure.in --- a/configure.in Tue Sep 18 20:42:25 2012 +0200 +++ b/configure.in Tue Sep 18 21:29:11 2012 +0200 @@ -1,4 +1,4 @@ -AC_INIT([Pigeonhole], [0.3.2], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) +AC_INIT([Pigeonhole], [0.3.3], [dovecot at dovecot.org], [dovecot-2.1-pigeonhole]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: include extension: fixed miss... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/df4088161da0 changeset: 1683:df4088161da0 user: Stephan Bosch date: Thu Sep 20 00:54:17 2012 +0200 description: lib-sieve: include extension: fixed missing error cleanup that caused a resource leak. diffstat: src/lib-sieve/plugins/include/ext-include-binary.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (19 lines): diff -r 1e4ecd174edf -r df4088161da0 src/lib-sieve/plugins/include/ext-include-binary.c --- a/src/lib-sieve/plugins/include/ext-include-binary.c Tue Sep 18 21:30:45 2012 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.c Thu Sep 20 00:54:17 2012 +0200 @@ -293,7 +293,6 @@ "include: failed to find block %d for included script " "from dependency block %d of binary %s", inc_block_id, block_id, sieve_binary_path(sbin)); - return FALSE; } @@ -323,6 +322,7 @@ "include: dependency block %d of binary %s " "contains invalid script metadata for script %s", block_id, sieve_binary_path(sbin), sieve_script_location(script)); + sieve_script_unref(&script); return FALSE; } From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: sieve-tools: The -D option wasn't enable... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/d7b06a1be3e1 changeset: 1684:d7b06a1be3e1 user: Stephan Bosch date: Thu Sep 20 00:57:02 2012 +0200 description: sieve-tools: The -D option wasn't enabled and documented for all tools. Change backported from Pigeonhole v0.4 tree, which means that this change will duplicate there upon merge. diffstat: doc/man/sieve-dump.1.in | 3 +++ doc/man/sievec.1.in | 3 +++ src/sieve-tools/sieve-dump.c | 4 ++-- src/sieve-tools/sievec.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diffs (59 lines): diff -r df4088161da0 -r d7b06a1be3e1 doc/man/sieve-dump.1.in --- a/doc/man/sieve-dump.1.in Thu Sep 20 00:54:17 2012 +0200 +++ b/doc/man/sieve-dump.1.in Thu Sep 20 00:57:02 2012 +0200 @@ -40,6 +40,9 @@ .BI \-c\ config\-file Alternative Dovecot configuration file path. .TP +.B \-D +Enable Sieve debugging. +.TP .B \-h Produce per\-block hexdump output of the whole binary instead of the normal human\-readable output. diff -r df4088161da0 -r d7b06a1be3e1 doc/man/sievec.1.in --- a/doc/man/sievec.1.in Thu Sep 20 00:54:17 2012 +0200 +++ b/doc/man/sievec.1.in Thu Sep 20 00:57:02 2012 +0200 @@ -57,6 +57,9 @@ for a compiled Sieve binary file. Note that this option is not allowed when the \fIout\-file\fP argument is a directory. .TP +.B \-D +Enable Sieve debugging. +.TP .BI \-x\ extensions Set the available extensions. The parameter is a space\-separated list of the active extensions. By prepending the extension identifiers with \fB+\fP or diff -r df4088161da0 -r d7b06a1be3e1 src/sieve-tools/sieve-dump.c --- a/src/sieve-tools/sieve-dump.c Thu Sep 20 00:54:17 2012 +0200 +++ b/src/sieve-tools/sieve-dump.c Thu Sep 20 00:57:02 2012 +0200 @@ -28,7 +28,7 @@ static void print_help(void) { printf( -"Usage: sieve-dump [-c ] [-h] [-P ] [-x ]\n" +"Usage: sieve-dump [-c ] [-D] [-h] [-P ] [-x ]\n" " []\n" ); } @@ -46,7 +46,7 @@ int exit_status = EXIT_SUCCESS; int c; - sieve_tool = sieve_tool_init("sieve-dump", &argc, &argv, "hP:x:", FALSE); + sieve_tool = sieve_tool_init("sieve-dump", &argc, &argv, "DhP:x:", FALSE); outfile = NULL; diff -r df4088161da0 -r d7b06a1be3e1 src/sieve-tools/sievec.c --- a/src/sieve-tools/sievec.c Thu Sep 20 00:54:17 2012 +0200 +++ b/src/sieve-tools/sievec.c Thu Sep 20 00:57:02 2012 +0200 @@ -31,7 +31,7 @@ static void print_help(void) { printf( -"Usage: sievec [-c ] [-d] [-P ] [-x ] \n" +"Usage: sievec [-c ] [-d] [-D] [-P ] [-x ] \n" " []\n" ); } From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Added tag 0.3.3 for changeset 64474c359678 Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/e4fe281d33e8 changeset: 1681:e4fe281d33e8 user: Stephan Bosch date: Tue Sep 18 21:29:16 2012 +0200 description: Added tag 0.3.3 for changeset 64474c359678 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 64474c359678 -r e4fe281d33e8 .hgtags --- a/.hgtags Tue Sep 18 21:29:11 2012 +0200 +++ b/.hgtags Tue Sep 18 21:29:16 2012 +0200 @@ -12,3 +12,4 @@ fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0.3.0 e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0.3.1 265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0.3.2 +64474c35967852bc452f71bc099ec3f8ded0369a 0.3.3 From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Fixed compile against installed Dovecot ... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/8144fb698cb3 changeset: 1679:8144fb698cb3 user: Stephan Bosch date: Tue Sep 18 20:42:25 2012 +0200 description: Fixed compile against installed Dovecot headers. This was broken by the ld.gold fix. diffstat: src/lib-sieve/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 2347ddfd9057 -r 8144fb698cb3 src/lib-sieve/Makefile.am --- a/src/lib-sieve/Makefile.am Tue Sep 18 16:20:22 2012 +0200 +++ b/src/lib-sieve/Makefile.am Tue Sep 18 20:42:25 2012 +0200 @@ -71,7 +71,7 @@ $(unfinished_plugins) libdovecot_sieve_la_DEPENDENCIES = $(plugins) $(LIBDOVECOT_LDA_DEPS) -libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT_LDA) +libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT) $(LIBDOVECOT_LDA) libdovecot_sieve_la_SOURCES = \ rfc2822.c \ From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: sieve-tools: sievec and sieve-dump now i... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/cfe8e9f49dfe changeset: 1672:cfe8e9f49dfe user: Stephan Bosch date: Wed Aug 15 00:55:05 2012 +0200 description: sieve-tools: sievec and sieve-dump now ignore mail_uid and mail_gid settings when run as root. Before, sievec and sieve-dump would switch to mail_uid:mail_gid and then fail to compile/dump a root script. diffstat: src/lib-sieve-tool/sieve-tool.c | 14 ++++++++++---- src/lib-sieve-tool/sieve-tool.h | 2 +- src/sieve-tools/sieve-dump.c | 2 +- src/sieve-tools/sieve-filter.c | 2 +- src/sieve-tools/sieve-test.c | 2 +- src/sieve-tools/sievec.c | 2 +- src/testsuite/testsuite.c | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) diffs (118 lines): diff -r 7e100dcd888a -r cfe8e9f49dfe src/lib-sieve-tool/sieve-tool.c --- a/src/lib-sieve-tool/sieve-tool.c Sun Aug 12 15:50:27 2012 +0200 +++ b/src/lib-sieve-tool/sieve-tool.c Wed Aug 15 00:55:05 2012 +0200 @@ -112,14 +112,14 @@ home == NULL || *home == '\0' ) { if ((pw = getpwuid(process_euid)) != NULL) { - user = pw->pw_name; + user = pw->pw_name; home = pw->pw_dir; } } if ( username_r != NULL ) { if ( user == NULL || *user == '\0' ) { - i_fatal("couldn't lookup our username (uid=%s)", + i_fatal("couldn't lookup our username (uid=%s)", dec2str(process_euid)); } @@ -216,7 +216,7 @@ } struct sieve_instance *sieve_tool_init_finish -(struct sieve_tool *tool, bool init_mailstore) +(struct sieve_tool *tool, bool init_mailstore, bool preserve_root) { enum mail_storage_service_flags storage_service_flags = MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR | @@ -238,9 +238,15 @@ if ( tool->homedir != NULL ) i_free(tool->homedir); tool->homedir = i_strdup(homedir); - } else + + if ( preserve_root ) { + storage_service_flags |= + MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS; + } + } else { storage_service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP; + } if ( !init_mailstore ) storage_service_flags |= diff -r 7e100dcd888a -r cfe8e9f49dfe src/lib-sieve-tool/sieve-tool.h --- a/src/lib-sieve-tool/sieve-tool.h Sun Aug 12 15:50:27 2012 +0200 +++ b/src/lib-sieve-tool/sieve-tool.h Wed Aug 15 00:55:05 2012 +0200 @@ -30,7 +30,7 @@ int sieve_tool_getopt(struct sieve_tool *tool); struct sieve_instance *sieve_tool_init_finish - (struct sieve_tool *tool, bool init_mailstore); + (struct sieve_tool *tool, bool init_mailstore, bool preserve_root); void sieve_tool_deinit(struct sieve_tool **_tool); diff -r 7e100dcd888a -r cfe8e9f49dfe src/sieve-tools/sieve-dump.c --- a/src/sieve-tools/sieve-dump.c Sun Aug 12 15:50:27 2012 +0200 +++ b/src/sieve-tools/sieve-dump.c Wed Aug 15 00:55:05 2012 +0200 @@ -75,7 +75,7 @@ } /* Finish tool initialization */ - svinst = sieve_tool_init_finish(sieve_tool, FALSE); + svinst = sieve_tool_init_finish(sieve_tool, FALSE, TRUE); /* Enable debug extension */ sieve_enable_debug_extension(svinst); diff -r 7e100dcd888a -r cfe8e9f49dfe src/sieve-tools/sieve-filter.c --- a/src/sieve-tools/sieve-filter.c Sun Aug 12 15:50:27 2012 +0200 +++ b/src/sieve-tools/sieve-filter.c Wed Aug 15 00:55:05 2012 +0200 @@ -473,7 +473,7 @@ } /* Finish tool initialization */ - svinst = sieve_tool_init_finish(sieve_tool, TRUE); + svinst = sieve_tool_init_finish(sieve_tool, TRUE, FALSE); /* Enable debug extension */ sieve_enable_debug_extension(svinst); diff -r 7e100dcd888a -r cfe8e9f49dfe src/sieve-tools/sieve-test.c --- a/src/sieve-tools/sieve-test.c Sun Aug 12 15:50:27 2012 +0200 +++ b/src/sieve-tools/sieve-test.c Wed Aug 15 00:55:05 2012 +0200 @@ -207,7 +207,7 @@ } /* Finish tool initialization */ - svinst = sieve_tool_init_finish(sieve_tool, execute && mailloc == NULL); + svinst = sieve_tool_init_finish(sieve_tool, execute && mailloc == NULL, FALSE); /* Enable debug extension */ sieve_enable_debug_extension(svinst); diff -r 7e100dcd888a -r cfe8e9f49dfe src/sieve-tools/sievec.c --- a/src/sieve-tools/sievec.c Sun Aug 12 15:50:27 2012 +0200 +++ b/src/sieve-tools/sievec.c Wed Aug 15 00:55:05 2012 +0200 @@ -79,7 +79,7 @@ outfile = "-"; } - svinst = sieve_tool_init_finish(sieve_tool, FALSE); + svinst = sieve_tool_init_finish(sieve_tool, FALSE, TRUE); /* Enable debug extension */ sieve_enable_debug_extension(svinst); diff -r 7e100dcd888a -r cfe8e9f49dfe src/testsuite/testsuite.c --- a/src/testsuite/testsuite.c Sun Aug 12 15:50:27 2012 +0200 +++ b/src/testsuite/testsuite.c Wed Aug 15 00:55:05 2012 +0200 @@ -154,7 +154,7 @@ ("sieve_global_dir", t_strconcat(sieve_dir, "included-global", NULL)); /* Finish testsuite initialization */ - svinst = sieve_tool_init_finish(sieve_tool, FALSE); + svinst = sieve_tool_init_finish(sieve_tool, FALSE, FALSE); testsuite_init(svinst, sieve_dir, log_stdout); printf("Test case: %s:\n\n", scriptfile); From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: Merged changes from Pigeonhole v0.3. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/7d171ec86a4c changeset: 1686:7d171ec86a4c user: Stephan Bosch date: Sun Sep 23 17:14:58 2012 +0200 description: Merged changes from Pigeonhole v0.3. diffstat: .hgsigs | 2 + .hgtags | 2 + NEWS | 23 ++++ doc/man/sieve-filter.1.in | 21 +++- src/lib-sieve-tool/sieve-tool.c | 14 ++- src/lib-sieve-tool/sieve-tool.h | 2 +- src/lib-sieve/plugins/include/ext-include-binary.c | 1 - src/lib-sieve/plugins/mailbox/tag-mailbox-create.c | 2 +- src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c | 47 +++++---- src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c | 2 + src/sieve-tools/sieve-dump.c | 2 +- src/sieve-tools/sieve-filter.c | 2 +- src/sieve-tools/sieve-test.c | 2 +- src/sieve-tools/sievec.c | 2 +- src/testsuite/testsuite.c | 2 +- 15 files changed, 87 insertions(+), 39 deletions(-) diffs (truncated from 393 to 300 lines): diff -r ead2e76425bf -r 7d171ec86a4c .hgsigs --- a/.hgsigs Thu Sep 20 01:22:29 2012 +0200 +++ b/.hgsigs Sun Sep 23 17:14:58 2012 +0200 @@ -5,3 +5,5 @@ 873baa85e2202f45a9c14fa21cccedc60f3715bc 0 iQEcBAABAgAGBQJOx9MCAAoJEATWKx49+7T09aUIANIKsuzM3bGhtGJ/UPIwzpOu39lEGCmHah6dMa+bDOoCZhuhASDdTuvRKXTfGC57GMu+NzBK6I7heFiPD3E4VTI4xOCK1azJ9G4SsiDEkQThucXqWBKDjPB0RgOEf6iefAkslXIU3cprJgattwpeXbUKiHjBhoYJFJ5j/GTx1B62ndvaTfMu1zF5UppiyRG1rQD7FLY4f6kANzSI2jOOCBs4UFH7ZKhafO1AeQfLNDvxdDczZafPZxrCIF+5JCNvQ6Xue/JrvRZQ0V9sxLQat7clUJ6I6Ejl5u5l1LF+VscWldfaQKwDdOktCVux84YGH8+XqXaukMiEg6j4hceAYIM= fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0 iQEcBAABAgAGBQJPPXAPAAoJEATWKx49+7T0iqMH/3e+RKKmryOz5pak0cvdPcS/D9O9xl2l6SuoE2okTq/WOrDtZ1xDg0afg7t27D9mDfUY1hiSFS4ekN3WP620Gcb9wlL3FC+rLEYmiE8iSfZvsH+FeLa7n8NB+XdnAsXE1WdLQp5CSKEh3sXIod7Q04PL0uv/rimGS9jOGcAufW3y9QAYd+DVorPS4lV5Kz8qIqY9r/0lLqhJN1ukIJtClVkFanRljd+SfoHFFOSWbQjCKNxlOSWFhwJji7Mp091A1+N6JoZe4IMIlajMsM2Ypp726Y2LA/du+uRVFjKgta65eP9tfdrmVCJtrjIjvikowD5Zl80GuVRI5j44aQ7rJ3A= e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0 iQEcBAABAgAGBQJPwAS+AAoJEATWKx49+7T0ngIH/R+teyHN4Pdv4bFTkder85rxy4bzPDzlV9gGlhuKuRBtI8F7CKKWLEP/ESPdtZbMmsNj9k104q2U9pgUfkYrVKL4lrk3hlz44o8Smpwp/xrxyNY8/OuBof0LvyXjp7unHAvvAWFiEmeTpJMmSu77xE8wsEqZowHi8/Igh3lrQ3U129VP1xWr1mvnvQdMQk9TTMK3T38H9kUrz2CRdOWjJbxAA4rLyozGLqWUeSKepUcwAGANd35k8pNLYiONlGU8NZsQyzS2dfOl0TeolgqZn+UkmM9FZFFnD40WU8zPft0nK4g8cFZGObX4fsPyK03EAnR7BXd1BKdmr7jdppAnSvQ= +265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0 iQEcBAABAgAGBQJQWIMhAAoJEATWKx49+7T0g/IH/3qqQemBP62Y+Wzo67DruphrJ5HSlIX4Uw/O4rOjrk8dWSMrsui5jFy4LXig+CR1dfY4RS0izTxsAiNhTACuavMfGHiYBKQW6UwIDlKECVBxbQyjB7v2C3FKPj9K9QReiYACSeB1RhQBnpbcvioif9H62VI5SKE6rjXyky6fDAxtbjhySb+nPDtV4HmV7ukcfDc3bxwcZkz9XXKoNmPWw8r34Z/RwxWbbWr8xUwW3+9LDB2Oz6PRyYP5S8EcNNYjk3ai2Llh0xuJGLQbpulhmjYDJmk20TkpLCFAfsYq1qW3yed9lL88CcFH4LDb9WA0LNs+7PfbmY/m8CX7JwUmHB8= +64474c35967852bc452f71bc099ec3f8ded0369a 0 iQEcBAABAgAGBQJQWMvhAAoJEATWKx49+7T0NrYH/2PQuuFqzlku+NG8Iw0UN2yeDEML+2n1xG31ud7m3sNWw8lX+03gEd+LU8+LygHJJ0IAde/jBYRBbC8zj9UXDl3v5FIRwhcvGnllBCMMH7motfg+aLrCR/xs+0jV/AqpRin1VILHYFaB9UFP5PUgvJJiCUniQWoe+r41gra1hRA7OK3923YOOi9t4zJxoat7e0OMhc0IcdB7n3iQmyicbb8izKw/UvR2tR3T7fVcEl6u1LlbGaojtJA03V1L+a8QkmltiurD9VNmiHz++bGGJlA7LSmVYBq7BeC1lDnXUGO9ryZgln6aXRwUS0VaTI51F9gSMw+0UDJCwA5yBKqYyR8= diff -r ead2e76425bf -r 7d171ec86a4c .hgtags --- a/.hgtags Thu Sep 20 01:22:29 2012 +0200 +++ b/.hgtags Sun Sep 23 17:14:58 2012 +0200 @@ -11,3 +11,5 @@ 873baa85e2202f45a9c14fa21cccedc60f3715bc 0.2.5 fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0.3.0 e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0.3.1 +265061e0d3f4b3d8f9e4f0fc0b978cd51f84690d 0.3.2 +64474c35967852bc452f71bc099ec3f8ded0369a 0.3.3 diff -r ead2e76425bf -r 7d171ec86a4c NEWS --- a/NEWS Thu Sep 20 01:22:29 2012 +0200 +++ b/NEWS Sun Sep 23 17:14:58 2012 +0200 @@ -1,3 +1,26 @@ +v0.3.3 18-09-2012 Stephan Bosch + + - Fixed compile against installed Dovecot headers. This was broken by the + ld.gold fix in the previous release. + +v0.3.2 18-09-2012 Stephan Bosch + + + sieve-refilter tool: improved man page documentation by explicitly + specifying the syntax used for mailbox arguments. + + Sieve: spamtest and virustest extensions: improved trace debugging of score + calculation. + + Sieve: made error messages about exceeding the maximum number of actions + more verbose. + - Sieve tools: fixed problems with running as root: sievec and sieve-dump now + ignore mail_uid and mail_gid settings when run as root. + - Sieve: fixed bug in action accounting (for limit checking): increase action + instance count only when an action is actually created. + - Sieve: include extension: fixed namespace separation of :global and + :personal scripts. + - ManageSieve: fixed segfault bug triggered by CHECKSCRIPT command. + - Fixed linking with ld.gold. + - Fixed several Clang compile warnings and a few potential bugs. + v0.3.1 25-05-2012 Stephan Bosch * Added support for retrieving Sieve scripts from dict lookup. This means that diff -r ead2e76425bf -r 7d171ec86a4c doc/man/sieve-filter.1.in --- a/doc/man/sieve-filter.1.in Thu Sep 20 01:22:29 2012 +0200 +++ b/doc/man/sieve-filter.1.in Sun Sep 23 17:14:58 2012 +0200 @@ -92,7 +92,8 @@ is equal to the \fIsource\-mailbox\fP by default. Specifying a different folder will have the effect of moving (or copying if \fB\-W\fP is omitted) all kept messages to the indicated folder, instead of just leaving them in the -\fIsource\-mailbox\fP. +\fIsource\-mailbox\fP. Refer to the explanation of the \fIsource\-mailbox\fP +argument for more information on mailbox naming. .TP .BI \-q\ output\-mailbox\ \fB[not\ implemented\ yet]\fP Store outgoing e\-mail into the indicated \fIoutput\-mailbox\fP. By default, @@ -153,9 +154,18 @@ into a new binary. .TP .I source\-mailbox -The name of the source mailbox containing the messages that the Sieve filter -will act upon. This mailbox is not modified unless the \fB\-W\fP option is -specified. +Specifies the source mailbox containing the messages that the Sieve filter will +act upon. + +This is the name of a mailbox, as visible to IMAP clients, except in UTF-8 +format. The hierarchy separator between a parent and child mailbox is commonly +.RB \(aq / \(aq +or +.RB \(aq . \(aq, +but this depends on your selected mailbox storage format and +namespace configuration. The mailbox names may also require a namespace prefix. + +This mailbox is not modified unless the \fB\-W\fP option is specified. .TP .I discard\-action Specifies what is done with messages in the \fIsource\-mailbox\fP that where not @@ -169,7 +179,8 @@ .TP .BI move\ mailbox Move discarded messages to the indicated \fImailbox\fP. This is for instance -useful to move messages to a Trash mailbox. +useful to move messages to a Trash mailbox. Refer to the explanation of +the \fIsource\-mailbox\fP argument for more information on mailbox naming. .TP .B delete Flag discarded messages as \\DELETED. diff -r ead2e76425bf -r 7d171ec86a4c src/lib-sieve-tool/sieve-tool.c --- a/src/lib-sieve-tool/sieve-tool.c Thu Sep 20 01:22:29 2012 +0200 +++ b/src/lib-sieve-tool/sieve-tool.c Sun Sep 23 17:14:58 2012 +0200 @@ -112,14 +112,14 @@ home == NULL || *home == '\0' ) { if ((pw = getpwuid(process_euid)) != NULL) { - user = pw->pw_name; + user = pw->pw_name; home = pw->pw_dir; } } if ( username_r != NULL ) { if ( user == NULL || *user == '\0' ) { - i_fatal("couldn't lookup our username (uid=%s)", + i_fatal("couldn't lookup our username (uid=%s)", dec2str(process_euid)); } @@ -216,7 +216,7 @@ } struct sieve_instance *sieve_tool_init_finish -(struct sieve_tool *tool, bool init_mailstore) +(struct sieve_tool *tool, bool init_mailstore, bool preserve_root) { enum mail_storage_service_flags storage_service_flags = MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR | @@ -238,9 +238,15 @@ if ( tool->homedir != NULL ) i_free(tool->homedir); tool->homedir = i_strdup(homedir); - } else + + if ( preserve_root ) { + storage_service_flags |= + MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS; + } + } else { storage_service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP; + } if ( !init_mailstore ) storage_service_flags |= diff -r ead2e76425bf -r 7d171ec86a4c src/lib-sieve-tool/sieve-tool.h --- a/src/lib-sieve-tool/sieve-tool.h Thu Sep 20 01:22:29 2012 +0200 +++ b/src/lib-sieve-tool/sieve-tool.h Sun Sep 23 17:14:58 2012 +0200 @@ -30,7 +30,7 @@ int sieve_tool_getopt(struct sieve_tool *tool); struct sieve_instance *sieve_tool_init_finish - (struct sieve_tool *tool, bool init_mailstore); + (struct sieve_tool *tool, bool init_mailstore, bool preserve_root); void sieve_tool_deinit(struct sieve_tool **_tool); diff -r ead2e76425bf -r 7d171ec86a4c src/lib-sieve/plugins/include/ext-include-binary.c --- a/src/lib-sieve/plugins/include/ext-include-binary.c Thu Sep 20 01:22:29 2012 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-binary.c Sun Sep 23 17:14:58 2012 +0200 @@ -302,7 +302,6 @@ "include: failed to find block %d for included script " "from dependency block %d of binary %s", inc_block_id, block_id, sieve_binary_path(sbin)); - return FALSE; } diff -r ead2e76425bf -r 7d171ec86a4c src/lib-sieve/plugins/mailbox/tag-mailbox-create.c --- a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Thu Sep 20 01:22:29 2012 +0200 +++ b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Sun Sep 23 17:14:58 2012 +0200 @@ -156,7 +156,7 @@ } /* Try opening again */ - if ( mailbox_sync(trans->box, 0) < 0 ) { + if ( mailbox_open(trans->box) < 0 ) { /* Failed definitively */ sieve_act_store_get_storage_error(aenv, trans); return FALSE; diff -r ead2e76425bf -r 7d171ec86a4c src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c --- a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c Thu Sep 20 01:22:29 2012 +0200 +++ b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c Sun Sep 23 17:14:58 2012 +0200 @@ -457,7 +457,6 @@ const struct sieve_message_data *msgdata = renv->msgdata; struct sieve_message_context *msgctx = renv->msgctx; struct ext_spamvirustest_message_context *mctx; - const char *ext_name = sieve_extension_name(ext); regmatch_t match_values[2]; const char *header_value, *error; const char *status = NULL, *max = NULL; @@ -470,7 +469,7 @@ */ if ( ext_data == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: extension not configured", ext_name); + "error: extension not configured"); return "0"; } @@ -504,8 +503,8 @@ (msgdata->mail, max_header->header_name, &header_value) < 0 || header_value == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: header '%s' not found in message", - ext_name, max_header->header_name); + "header '%s' not found in message", + max_header->header_name); goto failed; } @@ -514,16 +513,16 @@ if ( regexec(&max_header->regexp, header_value, 2, match_values, 0) != 0 ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp for header '%s' did not match " - "on value '%s'", ext_name, max_header->header_name, header_value); + "regexp for header '%s' did not match " + "on value '%s'", max_header->header_name, header_value); goto failed; } max = _regexp_match_get_value(header_value, 1, match_values, 2); if ( max == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp did not return match value " - "for string '%s'", ext_name, header_value); + "regexp did not return match value " + "for string '%s'", header_value); goto failed; } } else { @@ -532,7 +531,7 @@ if ( !ext_spamvirustest_parse_decimal_value(max, &max_value, &error) ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: failed to parse maximum value: %s", ext_name, error); + "failed to parse maximum value: %s", error); goto failed; } } else { @@ -541,7 +540,7 @@ if ( max_value == 0 ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: max value is 0", ext_name); + "error: max value is 0"); goto failed; } } else { @@ -557,8 +556,8 @@ (msgdata->mail, status_header->header_name, &header_value) < 0 || header_value == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: header '%s' not found in message", - ext_name, status_header->header_name); + "header '%s' not found in message", + status_header->header_name); goto failed; } @@ -567,16 +566,16 @@ if ( regexec(&status_header->regexp, header_value, 2, match_values, 0) != 0 ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp for header '%s' did not match on value '%s'", - ext_name, status_header->header_name, header_value); + "regexp for header '%s' did not match on value '%s'", + status_header->header_name, header_value); goto failed; } status = _regexp_match_get_value(header_value, 1, match_values, 2); if ( status == NULL ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: regexp did not return match value for string '%s'", - ext_name, header_value); + "regexp did not return match value for string '%s'", + header_value); goto failed; } } else { @@ -588,8 +587,8 @@ if ( !ext_spamvirustest_parse_decimal_value (status, &status_value, &error) ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: failed to parse status value '%s': %s", - ext_name, status, error); + "failed to parse status value '%s': %s", + status, error); goto failed; } break; @@ -597,8 +596,8 @@ if ( !ext_spamvirustest_parse_strlen_value (status, &status_value, &error) ) { sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, - "%s: failed to parse status value '%s': %s", - ext_name, status, error); + "failed to parse status value '%s': %s", + status, error); goto failed; } break; @@ -618,8 +617,8 @@ From pigeonhole at rename-it.nl Sun Sep 23 18:15:06 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 23 Sep 2012 17:15:06 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: mailbox extension: After crea... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/fcd5208ed8b2 changeset: 1685:fcd5208ed8b2 user: Stephan Bosch date: Sun Sep 23 17:09:26 2012 +0200 description: lib-sieve: mailbox extension: After creating mailbox only open it, don't bother syncing it. diffstat: src/lib-sieve/plugins/mailbox/tag-mailbox-create.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r d7b06a1be3e1 -r fcd5208ed8b2 src/lib-sieve/plugins/mailbox/tag-mailbox-create.c --- a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Thu Sep 20 00:57:02 2012 +0200 +++ b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c Sun Sep 23 17:09:26 2012 +0200 @@ -156,7 +156,7 @@ } /* Try opening again */ - if ( mailbox_sync(trans->box, 0) < 0 ) { + if ( mailbox_open(trans->box) < 0 ) { /* Failed definitively */ sieve_act_store_get_storage_error(aenv, trans); return FALSE; From dovecot at dovecot.org Mon Sep 24 14:16:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 14:16:47 +0300 Subject: dovecot-2.1: imapc: Added IMAPC_DEFAULT_MAX_IDLE_TIME macro. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fd863826c892 changeset: 14725:fd863826c892 user: Timo Sirainen date: Mon Sep 24 14:16:32 2012 +0300 description: imapc: Added IMAPC_DEFAULT_MAX_IDLE_TIME macro. diffstat: src/lib-imap-client/imapc-client.h | 3 +++ src/lib-storage/index/imapc/imapc-settings.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletions(-) diffs (36 lines): diff -r f818f65f1a7f -r fd863826c892 src/lib-imap-client/imapc-client.h --- a/src/lib-imap-client/imapc-client.h Sat Sep 22 19:23:15 2012 +0300 +++ b/src/lib-imap-client/imapc-client.h Mon Sep 24 14:16:32 2012 +0300 @@ -1,6 +1,9 @@ #ifndef IMAPC_CLIENT_H #define IMAPC_CLIENT_H +/* IMAP RFC defines this to be at least 30 minutes. */ +#define IMAPC_DEFAULT_MAX_IDLE_TIME (60*29) + enum imapc_command_state { IMAPC_COMMAND_STATE_OK, IMAPC_COMMAND_STATE_NO, diff -r f818f65f1a7f -r fd863826c892 src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Sat Sep 22 19:23:15 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:16:32 2012 +0300 @@ -50,7 +50,7 @@ .imapc_features = "", .imapc_rawlog_dir = "", .imapc_list_prefix = "", - .imapc_max_idle_time = 60*29, + .imapc_max_idle_time = IMAPC_DEFAULT_MAX_IDLE_TIME, .ssl_crypto_device = "" }; @@ -131,6 +131,10 @@ return FALSE; } #endif + if (set->imapc_max_idle_time == 0) { + *error_r = "imapc_max_idle_time must not be 0"; + return FALSE; + } if (imapc_settings_parse_features(set, error_r) < 0) return FALSE; return TRUE; From dovecot at dovecot.org Mon Sep 24 14:16:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 14:16:47 +0300 Subject: dovecot-2.1: auth: passdb imap assert-crashed always Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/17a8f15beb8c changeset: 14726:17a8f15beb8c user: Timo Sirainen date: Mon Sep 24 14:16:41 2012 +0300 description: auth: passdb imap assert-crashed always diffstat: src/auth/passdb-imap.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r fd863826c892 -r 17a8f15beb8c src/auth/passdb-imap.c --- a/src/auth/passdb-imap.c Mon Sep 24 14:16:32 2012 +0300 +++ b/src/auth/passdb-imap.c Mon Sep 24 14:16:41 2012 +0300 @@ -85,6 +85,7 @@ t_strconcat(auth_request->set->base_dir, "/", DNS_CLIENT_SOCKET_NAME, NULL); set.password = password; + set.max_idle_time = IMAPC_DEFAULT_MAX_IDLE_TIME; if (module->set_have_vars) { str = t_str_new(128); From dovecot at dovecot.org Mon Sep 24 14:22:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 14:22:48 +0300 Subject: dovecot-2.1: imapc: Compile fix for previous change. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/bea05a64cf8b changeset: 14727:bea05a64cf8b user: Timo Sirainen date: Mon Sep 24 14:22:40 2012 +0300 description: imapc: Compile fix for previous change. diffstat: src/lib-storage/index/imapc/imapc-settings.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 17a8f15beb8c -r bea05a64cf8b src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:16:41 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:22:40 2012 +0300 @@ -3,6 +3,7 @@ #include "lib.h" #include "settings-parser.h" #include "mail-storage-settings.h" +#include "imapc-client.h" #include "imapc-settings.h" #include From dovecot at dovecot.org Mon Sep 24 14:25:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 14:25:03 +0300 Subject: dovecot-2.1: imapc: And another compile fix.. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0a5a3b760e2e changeset: 14728:0a5a3b760e2e user: Timo Sirainen date: Mon Sep 24 14:24:58 2012 +0300 description: imapc: And another compile fix.. Using the macro would have required config/all-settings.c to include imapc-client.h, which is a bit too much trouble just for this. diffstat: src/lib-storage/index/imapc/imapc-settings.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r bea05a64cf8b -r 0a5a3b760e2e src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:22:40 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:24:58 2012 +0300 @@ -3,7 +3,6 @@ #include "lib.h" #include "settings-parser.h" #include "mail-storage-settings.h" -#include "imapc-client.h" #include "imapc-settings.h" #include @@ -51,7 +50,7 @@ .imapc_features = "", .imapc_rawlog_dir = "", .imapc_list_prefix = "", - .imapc_max_idle_time = IMAPC_DEFAULT_MAX_IDLE_TIME, + .imapc_max_idle_time = 60*29, .ssl_crypto_device = "" }; From dovecot at dovecot.org Mon Sep 24 14:33:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 14:33:59 +0300 Subject: dovecot-2.1: lmtp: Added lmtp_rcpt_check_quota setting to check ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cc7906697d19 changeset: 14730:cc7906697d19 user: Timo Sirainen date: Mon Sep 24 14:33:52 2012 +0300 description: lmtp: Added lmtp_rcpt_check_quota setting to check quota already on RCPT TO. diffstat: doc/example-config/conf.d/20-lmtp.conf | 4 ++ src/lmtp/commands.c | 48 +++++++++++++++++++++++++++++++-- src/lmtp/lmtp-settings.c | 2 + src/lmtp/lmtp-settings.h | 1 + 4 files changed, 52 insertions(+), 3 deletions(-) diffs (111 lines): diff -r 94f9dfa7cbaf -r cc7906697d19 doc/example-config/conf.d/20-lmtp.conf --- a/doc/example-config/conf.d/20-lmtp.conf Mon Sep 24 14:31:16 2012 +0300 +++ b/doc/example-config/conf.d/20-lmtp.conf Mon Sep 24 14:33:52 2012 +0300 @@ -10,7 +10,11 @@ # lda_mailbox_autocreate settings. #lmtp_save_to_detail_mailbox = no +# Verify quota before replying to RCPT TO. This adds a small overhead. +#lmtp_rcpt_check_quota = no + protocol lmtp { # Space separated list of plugins to load (default is global mail_plugins). #mail_plugins = $mail_plugins } + \ No newline at end of file diff -r 94f9dfa7cbaf -r cc7906697d19 src/lmtp/commands.c --- a/src/lmtp/commands.c Mon Sep 24 14:31:16 2012 +0300 +++ b/src/lmtp/commands.c Mon Sep 24 14:33:52 2012 +0300 @@ -444,6 +444,42 @@ *address = str_c(username); } +static int +lmtp_rcpt_to_is_over_quota(struct client *client, + const struct mail_recipient *rcpt) +{ + struct mail_user *user; + struct mail_namespace *ns; + struct mailbox *box; + struct mailbox_status status; + const char *errstr; + enum mail_error error; + int ret; + + if (!client->lmtp_set->lmtp_rcpt_check_quota) + return 0; + + ret = mail_storage_service_next(storage_service, + rcpt->service_user, &user); + if (ret < 0) + return -1; + + ns = mail_namespace_find_inbox(user->namespaces); + box = mailbox_alloc(ns->list, "INBOX", 0); + ret = mailbox_get_status(box, STATUS_CHECK_OVER_QUOTA, &status); + if (ret < 0) { + errstr = mailbox_get_last_error(box, &error); + if (error == MAIL_ERROR_NOSPACE) { + client_send_line(client, "552 5.2.2 <%s> %s", + rcpt->address, errstr); + ret = 1; + } + } + mailbox_free(&box); + mail_user_unref(&user); + return ret; +} + int cmd_rcpt(struct client *client, const char *args) { struct mail_recipient rcpt; @@ -516,9 +552,15 @@ rcpt.address = p_strdup(client->state_pool, address); rcpt.detail = p_strdup(client->state_pool, detail); - array_append(&client->state.rcpt_to, &rcpt, 1); - - client_send_line(client, "250 2.1.5 OK"); + if ((ret = lmtp_rcpt_to_is_over_quota(client, &rcpt)) < 0) { + client_send_line(client, ERRSTR_TEMP_MAILBOX_FAIL, + rcpt.address); + return 0; + } + if (ret == 0) { + array_append(&client->state.rcpt_to, &rcpt, 1); + client_send_line(client, "250 2.1.5 OK"); + } return 0; } diff -r 94f9dfa7cbaf -r cc7906697d19 src/lmtp/lmtp-settings.c --- a/src/lmtp/lmtp-settings.c Mon Sep 24 14:31:16 2012 +0300 +++ b/src/lmtp/lmtp-settings.c Mon Sep 24 14:33:52 2012 +0300 @@ -59,6 +59,7 @@ static const struct setting_define lmtp_setting_defines[] = { DEF(SET_BOOL, lmtp_proxy), DEF(SET_BOOL, lmtp_save_to_detail_mailbox), + DEF(SET_BOOL, lmtp_rcpt_check_quota), DEF(SET_STR_VARS, login_greeting), DEF(SET_STR, lmtp_address_translate), @@ -68,6 +69,7 @@ static const struct lmtp_settings lmtp_default_settings = { .lmtp_proxy = FALSE, .lmtp_save_to_detail_mailbox = FALSE, + .lmtp_rcpt_check_quota = FALSE, .login_greeting = PACKAGE_NAME" ready.", .lmtp_address_translate = "" }; diff -r 94f9dfa7cbaf -r cc7906697d19 src/lmtp/lmtp-settings.h --- a/src/lmtp/lmtp-settings.h Mon Sep 24 14:31:16 2012 +0300 +++ b/src/lmtp/lmtp-settings.h Mon Sep 24 14:33:52 2012 +0300 @@ -7,6 +7,7 @@ struct lmtp_settings { bool lmtp_proxy; bool lmtp_save_to_detail_mailbox; + bool lmtp_rcpt_check_quota; const char *login_greeting; const char *lmtp_address_translate; }; From dovecot at dovecot.org Mon Sep 24 14:33:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 14:33:59 +0300 Subject: dovecot-2.1: lib-storage: Added STATUS_CHECK_OVER_QUOTA for chec... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/94f9dfa7cbaf changeset: 14729:94f9dfa7cbaf user: Timo Sirainen date: Mon Sep 24 14:31:16 2012 +0300 description: lib-storage: Added STATUS_CHECK_OVER_QUOTA for checking if user is over quota. diffstat: src/lib-storage/mail-storage.h | 3 ++- src/plugins/quota/quota-storage.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletions(-) diffs (61 lines): diff -r 0a5a3b760e2e -r 94f9dfa7cbaf src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Mon Sep 24 14:24:58 2012 +0300 +++ b/src/lib-storage/mail-storage.h Mon Sep 24 14:31:16 2012 +0300 @@ -74,7 +74,8 @@ STATUS_HIGHESTMODSEQ = 0x80, STATUS_PERMANENT_FLAGS = 0x200, STATUS_FIRST_RECENT_UID = 0x400, - STATUS_LAST_CACHED_SEQ = 0x800 + STATUS_LAST_CACHED_SEQ = 0x800, + STATUS_CHECK_OVER_QUOTA = 0x1000 /* return error if over quota */ }; enum mailbox_metadata_items { diff -r 0a5a3b760e2e -r 94f9dfa7cbaf src/plugins/quota/quota-storage.c --- a/src/plugins/quota/quota-storage.c Mon Sep 24 14:24:58 2012 +0300 +++ b/src/plugins/quota/quota-storage.c Mon Sep 24 14:31:16 2012 +0300 @@ -66,6 +66,36 @@ qmail->super.expunge(_mail); } +static int +quota_get_status(struct mailbox *box, enum mailbox_status_items items, + struct mailbox_status *status_r) +{ + struct quota_mailbox *qbox = QUOTA_CONTEXT(box); + struct quota_transaction_context *qt; + bool too_large; + int ret = 0; + + if ((items & STATUS_CHECK_OVER_QUOTA) != 0) { + qt = quota_transaction_begin(box); + if ((ret = quota_test_alloc(qt, 1, &too_large)) == 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOSPACE, + qt->quota->set->quota_exceeded_msg); + ret = -1; + } + quota_transaction_rollback(&qt); + + if ((items & ~STATUS_CHECK_OVER_QUOTA) == 0) { + /* don't bother calling parent, it may unnecessarily + try to open the mailbox */ + return ret; + } + } + + if (qbox->module_ctx.super.get_status(box, items, status_r) < 0) + ret = -1; + return ret < 0 ? -1 : 0; +} + static struct mailbox_transaction_context * quota_mailbox_transaction_begin(struct mailbox *box, enum mailbox_transaction_flags flags) @@ -376,6 +406,7 @@ qbox->module_ctx.super = *v; box->vlast = &qbox->module_ctx.super; + v->get_status = quota_get_status; v->transaction_begin = quota_mailbox_transaction_begin; v->transaction_commit = quota_mailbox_transaction_commit; v->transaction_rollback = quota_mailbox_transaction_rollback; From dovecot at dovecot.org Mon Sep 24 14:42:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 14:42:44 +0300 Subject: dovecot-2.1: lib-storage: Added ALTNOCHECK option to mail_location. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a14f1d2e2b45 changeset: 14731:a14f1d2e2b45 user: Timo Sirainen date: Mon Sep 24 14:42:38 2012 +0300 description: lib-storage: Added ALTNOCHECK option to mail_location. By default Dovecot verifies that $rootdir/dbox-alt-root symlink matches the ALT directory location, and logs an error if not. This is mainly to avoid accidents during initial configuration when for example alt dir was set in global mail_location but was forgotten to be set in userdb reply's mail_location. The ALTNOCHECK setting simply doesn't check or create this symlink, giving a (very) small performance improvement. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 3 ++- src/lib-storage/mailbox-list.c | 6 +++++- src/lib-storage/mailbox-list.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diffs (48 lines): diff -r cc7906697d19 -r a14f1d2e2b45 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Mon Sep 24 14:33:52 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Mon Sep 24 14:42:38 2012 +0300 @@ -107,7 +107,8 @@ storage->attachment_fs = fs_init(name, args, &fs_set); } T_END; - dbox_verify_alt_path(ns->list); + if (!ns->list->set.alt_dir_nocheck) + dbox_verify_alt_path(ns->list); return 0; } diff -r cc7906697d19 -r a14f1d2e2b45 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Mon Sep 24 14:33:52 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Mon Sep 24 14:42:38 2012 +0300 @@ -163,6 +163,7 @@ list->set.mailbox_dir_name = p_strdup(list->pool, set->mailbox_dir_name); list->set.alt_dir = p_strdup(list->pool, set->alt_dir); + list->set.alt_dir_nocheck = set->alt_dir_nocheck; if (*set->mailbox_dir_name == '\0') list->set.mailbox_dir_name = ""; @@ -294,7 +295,10 @@ dest = &set_r->control_dir; else if (strcmp(key, "ALT") == 0) dest = &set_r->alt_dir; - else if (strcmp(key, "LAYOUT") == 0) + else if (strcmp(key, "ALTNOCHECK") == 0) { + set_r->alt_dir_nocheck = TRUE; + continue; + } else if (strcmp(key, "LAYOUT") == 0) dest = &set_r->layout; else if (strcmp(key, "SUBSCRIPTIONS") == 0) dest = &set_r->subscription_fname; diff -r cc7906697d19 -r a14f1d2e2b45 src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Mon Sep 24 14:33:52 2012 +0300 +++ b/src/lib-storage/mailbox-list.h Mon Sep 24 14:42:38 2012 +0300 @@ -145,6 +145,8 @@ char escape_char; /* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */ bool utf8; + /* Don't check/create the alt-dir symlink. */ + bool alt_dir_nocheck; }; struct mailbox_info { From dovecot at dovecot.org Mon Sep 24 16:33:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 16:33:18 +0300 Subject: dovecot-2.2: doveadm: Install doveadm-settings.h header Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/200ec10b2314 changeset: 15094:200ec10b2314 user: Timo Sirainen date: Mon Sep 24 16:33:07 2012 +0300 description: doveadm: Install doveadm-settings.h header diffstat: src/doveadm/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (18 lines): diff -r 4776fbf6d93a -r 200ec10b2314 src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Sat Sep 22 19:23:15 2012 +0300 +++ b/src/doveadm/Makefile.am Mon Sep 24 16:33:07 2012 +0300 @@ -125,13 +125,13 @@ doveadm-mailbox-list-iter.h \ doveadm-print.h \ doveadm-print-private.h \ + doveadm-settings.h \ doveadm-util.h noinst_HEADERS = \ client-connection.h \ server-connection.h \ doveadm-server.h \ - doveadm-settings.h \ doveadm-who.h install-exec-local: From dovecot at dovecot.org Mon Sep 24 16:51:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 16:51:18 +0300 Subject: dovecot-2.1: ldap auth: Update %variables after each field update. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/18c8d840b028 changeset: 14732:18c8d840b028 user: Timo Sirainen date: Mon Sep 24 16:49:29 2012 +0300 description: ldap auth: Update %variables after each field update. The previous behavior was a bit confusing. "uid=user" at the beginning updated the %u variable, but if it was after templates it didn't update it. Also "=user=%{uid}" that was supposed to be equivalent wasn't. Now the behavior is consistent across all ways to set the fields. diffstat: src/auth/auth-request.c | 20 ++++++++++++++++---- src/auth/auth-request.h | 4 ++++ src/auth/db-ldap.c | 40 ++++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 24 deletions(-) diffs (132 lines): diff -r a14f1d2e2b45 -r 18c8d840b028 src/auth/auth-request.c --- a/src/auth/auth-request.c Mon Sep 24 14:42:38 2012 +0300 +++ b/src/auth/auth-request.c Mon Sep 24 16:49:29 2012 +0300 @@ -1794,16 +1794,18 @@ { '\0', NULL, NULL } }; -const struct var_expand_table * -auth_request_get_var_expand_table(const struct auth_request *auth_request, - auth_request_escape_func_t *escape_func) +struct var_expand_table * +auth_request_get_var_expand_table_full(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func, + unsigned int *count) { struct var_expand_table *tab; if (escape_func == NULL) escape_func = escape_none; - tab = t_malloc(sizeof(auth_request_var_expand_static_tab)); + *count += N_ELEMENTS(auth_request_var_expand_static_tab); + tab = t_malloc(*count * sizeof(struct var_expand_table)); memcpy(tab, auth_request_var_expand_static_tab, sizeof(auth_request_var_expand_static_tab)); @@ -1855,6 +1857,16 @@ return tab; } +const struct var_expand_table * +auth_request_get_var_expand_table(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func) +{ + unsigned int count = 0; + + return auth_request_get_var_expand_table_full(auth_request, escape_func, + &count); +} + static void get_log_prefix(string_t *str, struct auth_request *auth_request, const char *subsystem) { diff -r a14f1d2e2b45 -r 18c8d840b028 src/auth/auth-request.h --- a/src/auth/auth-request.h Mon Sep 24 14:42:38 2012 +0300 +++ b/src/auth/auth-request.h Mon Sep 24 16:49:29 2012 +0300 @@ -207,6 +207,10 @@ const struct var_expand_table * auth_request_get_var_expand_table(const struct auth_request *auth_request, auth_request_escape_func_t *escape_func); +struct var_expand_table * +auth_request_get_var_expand_table_full(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func, + unsigned int *count); const char *auth_request_str_escape(const char *string, const struct auth_request *request); diff -r a14f1d2e2b45 -r 18c8d840b028 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Mon Sep 24 14:42:38 2012 +0300 +++ b/src/auth/db-ldap.c Mon Sep 24 16:49:29 2012 +0300 @@ -63,7 +63,6 @@ /* ldap_attr_name => struct db_ldap_value */ struct hash_table *ldap_attrs; - struct var_expand_table *var_table; const char *val_1_arr[2]; string_t *var, *debug; @@ -1068,21 +1067,17 @@ *attr_names_r = array_idx_modifiable(&ctx.attr_names, 0); } -static struct var_expand_table * -db_ldap_value_get_var_expand_table(pool_t pool, - struct auth_request *auth_request) +static const struct var_expand_table * +db_ldap_value_get_var_expand_table(struct auth_request *auth_request, + const char *ldap_value) { - const struct var_expand_table *auth_table = NULL; struct var_expand_table *table; - unsigned int count; + unsigned int count = 1; - auth_table = auth_request_get_var_expand_table(auth_request, NULL); - for (count = 0; auth_table[count].key != '\0'; count++) ; - count++; - - table = p_new(pool, struct var_expand_table, count + 2); - table[0].key = '$'; - memcpy(table + 1, auth_table, sizeof(*table) * count); + table = auth_request_get_var_expand_table_full(auth_request, NULL, + &count); + table[count-1].key = '$'; + table[count-1].value = ldap_value; return table; } @@ -1240,6 +1235,7 @@ { "ldap", db_ldap_field_expand }, { NULL, NULL } }; + const struct var_expand_table *var_table; const char *const *values; if (ldap_value != NULL) @@ -1265,14 +1261,18 @@ "using value '%s'", field->name, values[0]); } - if (ctx->var_table == NULL) { - ctx->var_table = db_ldap_value_get_var_expand_table( - ctx->pool, ctx->auth_request); + + /* do this lookup separately for each expansion, because: + 1) the values are allocated from data stack + 2) if "user" field is updated, we want %u/%n/%d updated + (and less importantly the same for other variables) */ + var_table = db_ldap_value_get_var_expand_table(ctx->auth_request, + values[0]); + if (ctx->var == NULL) ctx->var = str_new(ctx->pool, 256); - } - ctx->var_table[0].value = values[0]; - str_truncate(ctx->var, 0); - var_expand_with_funcs(ctx->var, field->value, ctx->var_table, + else + str_truncate(ctx->var, 0); + var_expand_with_funcs(ctx->var, field->value, var_table, var_funcs_table, ctx); ctx->val_1_arr[0] = str_c(ctx->var); values = ctx->val_1_arr; From dovecot at dovecot.org Mon Sep 24 17:03:53 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 24 Sep 2012 17:03:53 +0300 Subject: dovecot-2.1: auth ldap: Previous change broke %$ variable. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4d82c74f702c changeset: 14733:4d82c74f702c user: Timo Sirainen date: Mon Sep 24 17:03:42 2012 +0300 description: auth ldap: Previous change broke %$ variable. diffstat: src/auth/auth-request.c | 17 ++++++++++++----- src/auth/db-ldap.c | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diffs (53 lines): diff -r 18c8d840b028 -r 4d82c74f702c src/auth/auth-request.c --- a/src/auth/auth-request.c Mon Sep 24 16:49:29 2012 +0300 +++ b/src/auth/auth-request.c Mon Sep 24 17:03:42 2012 +0300 @@ -1799,15 +1799,22 @@ auth_request_escape_func_t *escape_func, unsigned int *count) { - struct var_expand_table *tab; + const unsigned int auth_count = + N_ELEMENTS(auth_request_var_expand_static_tab); + struct var_expand_table *tab, *ret_tab; if (escape_func == NULL) escape_func = escape_none; - *count += N_ELEMENTS(auth_request_var_expand_static_tab); - tab = t_malloc(*count * sizeof(struct var_expand_table)); + /* keep the extra fields at the beginning. the last static_tab field + contains the ending NULL-fields. */ + tab = ret_tab = t_malloc((*count + auth_count) * sizeof(*tab)); + memset(tab, 0, *count * sizeof(*tab)); + tab += *count; + *count += auth_count; + memcpy(tab, auth_request_var_expand_static_tab, - sizeof(auth_request_var_expand_static_tab)); + auth_count * sizeof(*tab)); tab[0].value = escape_func(auth_request->user, auth_request); tab[1].value = escape_func(t_strcut(auth_request->user, '@'), @@ -1854,7 +1861,7 @@ } tab[18].value = auth_request->session_id == NULL ? NULL : escape_func(auth_request->session_id, auth_request); - return tab; + return ret_tab; } const struct var_expand_table * diff -r 18c8d840b028 -r 4d82c74f702c src/auth/db-ldap.c --- a/src/auth/db-ldap.c Mon Sep 24 16:49:29 2012 +0300 +++ b/src/auth/db-ldap.c Mon Sep 24 17:03:42 2012 +0300 @@ -1076,8 +1076,8 @@ table = auth_request_get_var_expand_table_full(auth_request, NULL, &count); - table[count-1].key = '$'; - table[count-1].value = ldap_value; + table[0].key = '$'; + table[0].value = ldap_value; return table; } From dovecot at dovecot.org Tue Sep 25 17:38:15 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 17:38:15 +0300 Subject: dovecot-2.2: dbox: Renamed dbox_sync_rebuild_verify_alt_storage(... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/89c319980584 changeset: 15095:89c319980584 user: Timo Sirainen date: Tue Sep 25 17:31:15 2012 +0300 description: dbox: Renamed dbox_sync_rebuild_verify_alt_storage() to dbox_verify_alt_storage() diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 29 ++++++++++++++++ src/lib-storage/index/dbox-common/dbox-storage.h | 1 + src/lib-storage/index/dbox-common/dbox-sync-rebuild.c | 29 ---------------- src/lib-storage/index/dbox-common/dbox-sync-rebuild.h | 1 - src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 +- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) diffs (116 lines): diff -r 200ec10b2314 -r 89c319980584 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Mon Sep 24 16:33:07 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Tue Sep 25 17:31:15 2012 +0300 @@ -286,3 +286,32 @@ return mail_index_sync_commit(&sync_ctx); } + +int dbox_verify_alt_storage(struct mailbox_list *list) +{ + const char *alt_path, *error; + struct stat st; + + alt_path = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_ALT_DIR); + if (alt_path == NULL) + return 0; + + /* make sure alt storage is mounted. if it's not, abort the rebuild. */ + if (stat(alt_path, &st) == 0) + return 0; + if (errno != ENOENT) { + i_error("stat(%s) failed: %m", alt_path); + return -1; + } + + /* try to create the alt directory. if it fails, it means alt + storage isn't mounted. */ + if (mailbox_list_mkdir_root(list, alt_path, + MAILBOX_LIST_PATH_TYPE_ALT_DIR, + &error) < 0) { + i_error("Couldn't create dbox alt root dir %s: %s", + alt_path, error); + return -1; + } + return 0; +} diff -r 200ec10b2314 -r 89c319980584 src/lib-storage/index/dbox-common/dbox-storage.h --- a/src/lib-storage/index/dbox-common/dbox-storage.h Mon Sep 24 16:33:07 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.h Tue Sep 25 17:31:15 2012 +0300 @@ -67,5 +67,6 @@ int dbox_mailbox_open(struct mailbox *box); int dbox_mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory); +int dbox_verify_alt_storage(struct mailbox_list *list); #endif diff -r 200ec10b2314 -r 89c319980584 src/lib-storage/index/dbox-common/dbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Mon Sep 24 16:33:07 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Tue Sep 25 17:31:15 2012 +0300 @@ -201,32 +201,3 @@ } i_free(ctx); } - -int dbox_sync_rebuild_verify_alt_storage(struct mailbox_list *list) -{ - const char *alt_path, *error; - struct stat st; - - alt_path = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_ALT_DIR); - if (alt_path == NULL) - return 0; - - /* make sure alt storage is mounted. if it's not, abort the rebuild. */ - if (stat(alt_path, &st) == 0) - return 0; - if (errno != ENOENT) { - i_error("stat(%s) failed: %m", alt_path); - return -1; - } - - /* try to create the alt directory. if it fails, it means alt - storage isn't mounted. */ - if (mailbox_list_mkdir_root(list, alt_path, - MAILBOX_LIST_PATH_TYPE_ALT_DIR, - &error) < 0) { - i_error("Couldn't create dbox alt root dir %s: %s", - alt_path, error); - return -1; - } - return 0; -} diff -r 200ec10b2314 -r 89c319980584 src/lib-storage/index/dbox-common/dbox-sync-rebuild.h --- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.h Mon Sep 24 16:33:07 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-sync-rebuild.h Tue Sep 25 17:31:15 2012 +0300 @@ -25,6 +25,5 @@ void dbox_sync_rebuild_index_metadata(struct dbox_sync_rebuild_context *ctx, uint32_t new_seq, uint32_t uid); -int dbox_sync_rebuild_verify_alt_storage(struct mailbox_list *list); #endif diff -r 200ec10b2314 -r 89c319980584 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Mon Sep 24 16:33:07 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Sep 25 17:31:15 2012 +0300 @@ -879,7 +879,7 @@ struct mdbox_storage_rebuild_context *ctx; int ret; - if (dbox_sync_rebuild_verify_alt_storage(storage->map->root_list) < 0) { + if (dbox_verify_alt_storage(storage->map->root_list) < 0) { mail_storage_set_critical(&storage->storage.storage, "mdbox rebuild: Alt storage %s not mounted, aborting", storage->alt_storage_dir); diff -r 200ec10b2314 -r 89c319980584 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Mon Sep 24 16:33:07 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Tue Sep 25 17:31:15 2012 +0300 @@ -197,7 +197,7 @@ } i_warning("sdbox %s: Rebuilding index", mailbox_get_path(&mbox->box)); - if (dbox_sync_rebuild_verify_alt_storage(mbox->box.list) < 0) { + if (dbox_verify_alt_storage(mbox->box.list) < 0) { mail_storage_set_critical(mbox->box.storage, "sdbox %s: Alt storage not mounted, " "aborting index rebuild", mailbox_get_path(&mbox->box)); From dovecot at dovecot.org Tue Sep 25 17:38:15 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 17:38:15 +0300 Subject: dovecot-2.2: lib-storage: Moved dbox-sync-rebuild API to more ge... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cc7650515b40 changeset: 15096:cc7650515b40 user: Timo Sirainen date: Tue Sep 25 17:37:55 2012 +0300 description: lib-storage: Moved dbox-sync-rebuild API to more generic index-rebuild. diffstat: src/lib-storage/index/Makefile.am | 2 + src/lib-storage/index/dbox-common/Makefile.am | 6 +- src/lib-storage/index/dbox-common/dbox-sync-rebuild.c | 203 -------------- src/lib-storage/index/dbox-common/dbox-sync-rebuild.h | 29 -- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 16 +- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 22 +- src/lib-storage/index/index-rebuild.c | 204 +++++++++++++++ src/lib-storage/index/index-rebuild.h | 32 ++ 8 files changed, 259 insertions(+), 255 deletions(-) diffs (truncated from 682 to 300 lines): diff -r 89c319980584 -r cc7650515b40 src/lib-storage/index/Makefile.am --- a/src/lib-storage/index/Makefile.am Tue Sep 25 17:31:15 2012 +0300 +++ b/src/lib-storage/index/Makefile.am Tue Sep 25 17:37:55 2012 +0300 @@ -18,6 +18,7 @@ index-mail-binary.c \ index-mail-headers.c \ index-mailbox-check.c \ + index-rebuild.c \ index-search.c \ index-search-result.c \ index-sort.c \ @@ -37,6 +38,7 @@ istream-mail.h \ index-attachment.h \ index-mail.h \ + index-rebuild.h \ index-search-private.h \ index-search-result.h \ index-sort.h \ diff -r 89c319980584 -r cc7650515b40 src/lib-storage/index/dbox-common/Makefile.am --- a/src/lib-storage/index/dbox-common/Makefile.am Tue Sep 25 17:31:15 2012 +0300 +++ b/src/lib-storage/index/dbox-common/Makefile.am Tue Sep 25 17:37:55 2012 +0300 @@ -16,16 +16,14 @@ dbox-file-fix.c \ dbox-mail.c \ dbox-save.c \ - dbox-storage.c \ - dbox-sync-rebuild.c + dbox-storage.c headers = \ dbox-attachment.h \ dbox-file.h \ dbox-mail.h \ dbox-save.h \ - dbox-storage.h \ - dbox-sync-rebuild.h + dbox-storage.h pkginc_libdir=$(pkgincludedir) pkginc_lib_HEADERS = $(headers) diff -r 89c319980584 -r cc7650515b40 src/lib-storage/index/dbox-common/dbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Tue Sep 25 17:31:15 2012 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ -/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */ - -#include "lib.h" -#include "array.h" -#include "mail-cache.h" -#include "mail-index-modseq.h" -#include "mailbox-list-private.h" -#include "index-storage.h" -#include "dbox-storage.h" -#include "dbox-sync-rebuild.h" - -static void -dbox_sync_index_copy_cache(struct dbox_sync_rebuild_context *ctx, - struct mail_index_view *view, - uint32_t old_seq, uint32_t new_seq) -{ - struct mail_index_map *map; - const void *data; - uint32_t reset_id; - bool expunged; - - if (ctx->cache_ext_id == (uint32_t)-1) - return; - - mail_index_lookup_ext_full(view, old_seq, ctx->cache_ext_id, - &map, &data, &expunged); - if (expunged) - return; - - if (!mail_index_ext_get_reset_id(view, map, ctx->cache_ext_id, - &reset_id) || reset_id == 0) - return; - - if (!ctx->cache_used) { - /* set reset id */ - ctx->cache_used = TRUE; - ctx->cache_reset_id = reset_id; - mail_index_ext_reset(ctx->trans, ctx->cache_ext_id, - ctx->cache_reset_id, TRUE); - } - if (ctx->cache_reset_id == reset_id) { - mail_index_update_ext(ctx->trans, new_seq, - ctx->cache_ext_id, data, NULL); - } -} - -static void -dbox_sync_index_copy_from_old(struct dbox_sync_rebuild_context *ctx, - struct mail_index_view *view, - uint32_t old_seq, uint32_t new_seq) -{ - struct mail_index *index = mail_index_view_get_index(view); - const struct mail_index_record *rec; - ARRAY_TYPE(keyword_indexes) old_keywords; - struct mail_keywords *kw; - uint64_t modseq; - - /* copy flags */ - rec = mail_index_lookup(view, old_seq); - mail_index_update_flags(ctx->trans, new_seq, - MODIFY_REPLACE, rec->flags); - - /* copy keywords */ - t_array_init(&old_keywords, 32); - mail_index_lookup_keywords(view, old_seq, &old_keywords); - kw = mail_index_keywords_create_from_indexes(index, &old_keywords); - mail_index_update_keywords(ctx->trans, new_seq, MODIFY_REPLACE, kw); - mail_index_keywords_unref(&kw); - - /* copy modseq */ - modseq = mail_index_modseq_lookup(view, old_seq); - mail_index_update_modseq(ctx->trans, new_seq, modseq); - - dbox_sync_index_copy_cache(ctx, view, old_seq, new_seq); -} - -void dbox_sync_rebuild_index_metadata(struct dbox_sync_rebuild_context *ctx, - uint32_t new_seq, uint32_t uid) -{ - uint32_t old_seq; - - if (mail_index_lookup_seq(ctx->view, uid, &old_seq)) { - /* the message exists in the old index. - copy the metadata from it. */ - dbox_sync_index_copy_from_old(ctx, ctx->view, old_seq, new_seq); - } else if (ctx->backup_view != NULL && - mail_index_lookup_seq(ctx->backup_view, uid, &old_seq)) { - /* copy the metadata from backup index. */ - dbox_sync_index_copy_from_old(ctx, ctx->backup_view, - old_seq, new_seq); - } -} - -static void dbox_sync_rebuild_header(struct dbox_sync_rebuild_context *ctx) -{ - const struct mail_index_header *hdr, *backup_hdr, *trans_hdr; - struct mail_index *index = mail_index_view_get_index(ctx->view); - struct mail_index_modseq_header modseq_hdr; - struct mail_index_view *trans_view; - uint32_t uid_validity, next_uid; - uint64_t modseq; - - hdr = mail_index_get_header(ctx->view); - backup_hdr = ctx->backup_view == NULL ? NULL : - mail_index_get_header(ctx->backup_view); - trans_view = mail_index_transaction_open_updated_view(ctx->trans); - trans_hdr = mail_index_get_header(trans_view); - - /* set uidvalidity */ - if (hdr->uid_validity != 0) - uid_validity = hdr->uid_validity; - else if (backup_hdr != NULL && backup_hdr->uid_validity != 0) - uid_validity = backup_hdr->uid_validity; - else - uid_validity = dbox_get_uidvalidity_next(ctx->box->list); - mail_index_update_header(ctx->trans, - offsetof(struct mail_index_header, uid_validity), - &uid_validity, sizeof(uid_validity), TRUE); - - /* set next-uid */ - if (hdr->next_uid != 0) - next_uid = hdr->next_uid; - else if (backup_hdr != NULL && backup_hdr->next_uid != 0) - next_uid = backup_hdr->next_uid; - else - next_uid = dbox_get_uidvalidity_next(ctx->box->list); - if (next_uid > trans_hdr->next_uid) { - mail_index_update_header(ctx->trans, - offsetof(struct mail_index_header, next_uid), - &next_uid, sizeof(next_uid), FALSE); - } - - /* set highest-modseq */ - memset(&modseq_hdr, 0, sizeof(modseq_hdr)); - modseq_hdr.highest_modseq = mail_index_modseq_get_highest(ctx->view); - if (ctx->backup_view != NULL) { - modseq = mail_index_modseq_get_highest(ctx->backup_view); - if (modseq_hdr.highest_modseq < modseq) - modseq_hdr.highest_modseq = modseq; - } - mail_index_update_header_ext(ctx->trans, index->modseq_ext_id, - 0, &modseq_hdr, sizeof(modseq_hdr)); - mail_index_view_close(&trans_view); -} - -struct dbox_sync_rebuild_context * -dbox_sync_index_rebuild_init(struct mailbox *box, - struct mail_index_view *view, - struct mail_index_transaction *trans) -{ - struct dbox_sync_rebuild_context *ctx; - const char *index_dir; - enum mail_index_open_flags open_flags = MAIL_INDEX_OPEN_FLAG_READONLY; - - ctx = i_new(struct dbox_sync_rebuild_context, 1); - ctx->box = box; - ctx->view = view; - ctx->trans = trans; - mail_index_reset(ctx->trans); - index_mailbox_reset_uidvalidity(box); - (void)mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id); - - /* open cache and read the caching decisions. we'll reset the cache in - case it contains any invalid data, but we want to preserve the - decisions. */ - (void)mail_cache_open_and_verify(ctx->box->cache); - mail_cache_reset(box->cache); - - /* if backup index file exists, try to use it */ - index_dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_INDEX); - ctx->backup_index = - mail_index_alloc(index_dir, DBOX_INDEX_PREFIX".backup"); - -#ifndef MMAP_CONFLICTS_WRITE - if (box->storage->set->mmap_disable) -#endif - open_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE; - mail_index_set_lock_method(ctx->backup_index, - box->storage->set->parsed_lock_method, -1U); - if (mail_index_open(ctx->backup_index, open_flags) <= 0) - mail_index_free(&ctx->backup_index); - else - ctx->backup_view = mail_index_view_open(ctx->backup_index); - return ctx; -} - -void dbox_sync_index_rebuild_deinit(struct dbox_sync_rebuild_context **_ctx) -{ - struct dbox_sync_rebuild_context *ctx = *_ctx; - - *_ctx = NULL; - - /* initialize cache file with the old field decisions */ - (void)mail_cache_compress(ctx->box->cache, ctx->trans); - dbox_sync_rebuild_header(ctx); - if (ctx->backup_index != NULL) { - mail_index_view_close(&ctx->backup_view); - mail_index_close(ctx->backup_index); - mail_index_free(&ctx->backup_index); - } - i_free(ctx); -} diff -r 89c319980584 -r cc7650515b40 src/lib-storage/index/dbox-common/dbox-sync-rebuild.h --- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.h Tue Sep 25 17:31:15 2012 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#ifndef DBOX_SYNC_REBUILD_H -#define DBOX_SYNC_REBUILD_H - -struct mailbox_list; - -struct dbox_sync_rebuild_context { - struct mailbox *box; - - struct mail_index_view *view; - struct mail_index_transaction *trans; - uint32_t cache_ext_id; - uint32_t cache_reset_id; - - struct mail_index *backup_index; - struct mail_index_view *backup_view; - - unsigned int cache_used:1; -}; - -struct dbox_sync_rebuild_context * -dbox_sync_index_rebuild_init(struct mailbox *box, - struct mail_index_view *view, - struct mail_index_transaction *trans); -void dbox_sync_index_rebuild_deinit(struct dbox_sync_rebuild_context **ctx); - -void dbox_sync_rebuild_index_metadata(struct dbox_sync_rebuild_context *ctx, - uint32_t new_seq, uint32_t uid); - -#endif diff -r 89c319980584 -r cc7650515b40 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Sep 25 17:31:15 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Sep 25 17:37:55 2012 +0300 @@ -7,7 +7,7 @@ #include "hash.h" #include "str.h" #include "mail-cache.h" -#include "dbox-sync-rebuild.h" +#include "index-rebuild.h" #include "mail-namespace.h" #include "mailbox-list-private.h" #include "mdbox-storage.h" @@ -363,7 +363,7 @@ static void rebuild_mailbox_multi(struct mdbox_storage_rebuild_context *ctx, - struct dbox_sync_rebuild_context *rebuild_ctx, + struct index_rebuild_context *rebuild_ctx, struct mdbox_mailbox *mbox, From dovecot at dovecot.org Tue Sep 25 17:42:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 17:42:07 +0300 Subject: dovecot-2.2: lib-index: Transaction log creation crashed if requ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d2dd659b4a4a changeset: 15097:d2dd659b4a4a user: Timo Sirainen date: Tue Sep 25 17:41:58 2012 +0300 description: lib-index: Transaction log creation crashed if required extension name length wasn't divisible by 4. diffstat: src/lib-index/mail-transaction-log-file.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r cc7650515b40 -r d2dd659b4a4a src/lib-index/mail-transaction-log-file.c --- a/src/lib-index/mail-transaction-log-file.c Tue Sep 25 17:37:55 2012 +0300 +++ b/src/lib-index/mail-transaction-log-file.c Tue Sep 25 17:41:58 2012 +0300 @@ -609,6 +609,8 @@ intro->record_align = rext->record_align; intro->name_size = strlen(rext->name); buffer_append(buf, rext->name, intro->name_size); + if (buf->used % 4 != 0) + buffer_append_zero(buf, 4 - buf->used % 4); hdr = buffer_get_space_unsafe(buf, hdr_offset, sizeof(*hdr)); hdr->size = mail_index_uint32_to_offset(buf->used - hdr_offset); From dovecot at dovecot.org Tue Sep 25 17:42:52 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 17:42:52 +0300 Subject: dovecot-2.2: lib-storage: Added mail_storage_copy_error() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3b01d09f7762 changeset: 15098:3b01d09f7762 user: Timo Sirainen date: Tue Sep 25 17:42:44 2012 +0300 description: lib-storage: Added mail_storage_copy_error() diffstat: src/lib-storage/mail-storage-private.h | 2 ++ src/lib-storage/mail-storage.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diffs (32 lines): diff -r d2dd659b4a4a -r 3b01d09f7762 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Tue Sep 25 17:41:58 2012 +0300 +++ b/src/lib-storage/mail-storage-private.h Tue Sep 25 17:42:44 2012 +0300 @@ -546,6 +546,8 @@ bool mail_storage_set_error_from_errno(struct mail_storage *storage); void mail_storage_copy_list_error(struct mail_storage *storage, struct mailbox_list *list); +void mail_storage_copy_error(struct mail_storage *dest, + struct mail_storage *src); /* Returns TRUE if everything should already be in memory after this call. */ bool mail_prefetch(struct mail *mail); diff -r d2dd659b4a4a -r 3b01d09f7762 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Tue Sep 25 17:41:58 2012 +0300 +++ b/src/lib-storage/mail-storage.c Tue Sep 25 17:42:44 2012 +0300 @@ -483,6 +483,16 @@ mail_storage_set_internal_error(storage); } +void mail_storage_copy_error(struct mail_storage *dest, + struct mail_storage *src) +{ + const char *str; + enum mail_error error; + + str = mail_storage_get_last_error(src, &error); + mail_storage_set_error(dest, error, str); +} + void mail_storage_copy_list_error(struct mail_storage *storage, struct mailbox_list *list) { From dovecot at dovecot.org Tue Sep 25 17:44:50 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 17:44:50 +0300 Subject: dovecot-2.2: lib-fs: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/89f8843be67b changeset: 15099:89f8843be67b user: Timo Sirainen date: Tue Sep 25 17:44:37 2012 +0300 description: lib-fs: Minor code cleanup diffstat: src/lib-fs/fs-api.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (27 lines): diff -r 3b01d09f7762 -r 89f8843be67b src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Tue Sep 25 17:42:44 2012 +0300 +++ b/src/lib-fs/fs-api.c Tue Sep 25 17:44:37 2012 +0300 @@ -14,13 +14,14 @@ fs_alloc(const struct fs *fs_class, const char *args, const struct fs_settings *set, struct fs **fs_r, const char **error_r) { + struct fs *fs = NULL; char *error_dup = NULL; int ret; T_BEGIN { const char *error; - ret = fs_class->v.init(args, set, fs_r, &error); + ret = fs_class->v.init(args, set, &fs, &error); if (ret < 0) error_dup = i_strdup(error); } T_END; @@ -33,6 +34,7 @@ return -1; } (*fs_r)->last_error = str_new(default_pool, 64); + *fs_r = fs; return 0; } From dovecot at dovecot.org Tue Sep 25 20:16:22 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 20:16:22 +0300 Subject: dovecot-2.2: lib-storage: Added mailbox_get_path_to() wrapper fo... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f8c1ddf55b94 changeset: 15100:f8c1ddf55b94 user: Timo Sirainen date: Tue Sep 25 20:15:58 2012 +0300 description: lib-storage: Added mailbox_get_path_to() wrapper for mailbox_list_get_path(). Changed the code to use as much of mailbox_get_path_to() and mailbox_get_path() as possible. diffstat: src/indexer/Makefile.am | 1 + src/indexer/master-connection.c | 10 ++++---- src/lib-storage/index/cydir/cydir-mail.c | 3 +- src/lib-storage/index/cydir/cydir-save.c | 6 +--- src/lib-storage/index/cydir/cydir-sync.c | 5 +--- src/lib-storage/index/dbox-common/dbox-storage.c | 6 +--- src/lib-storage/index/dbox-single/sdbox-file.c | 3 +- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 4 +- src/lib-storage/index/index-rebuild.c | 3 +- src/lib-storage/index/index-storage.c | 12 +++------- src/lib-storage/index/index-sync-pvt.c | 3 +- src/lib-storage/index/index-sync.c | 6 +--- src/lib-storage/index/maildir/maildir-keywords.c | 3 +- src/lib-storage/index/maildir/maildir-sync-index.c | 3 +- src/lib-storage/index/maildir/maildir-uidlist.c | 19 +++++------------ src/lib-storage/index/maildir/maildir-util.c | 6 +--- src/lib-storage/index/mbox/mbox-storage.c | 3 +- src/lib-storage/mail-storage-private.h | 3 ++ src/lib-storage/mail-storage.c | 9 ++++++- src/plugins/acl/doveadm-acl.c | 3 +- src/plugins/fts-squat/fts-backend-squat.c | 3 +- src/plugins/quota/quota-fs.c | 3 +- 22 files changed, 47 insertions(+), 70 deletions(-) diffs (truncated from 421 to 300 lines): diff -r 89f8843be67b -r f8c1ddf55b94 src/indexer/Makefile.am --- a/src/indexer/Makefile.am Tue Sep 25 17:44:37 2012 +0300 +++ b/src/indexer/Makefile.am Tue Sep 25 20:15:58 2012 +0300 @@ -7,6 +7,7 @@ -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-settings \ -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-index \ -I$(top_srcdir)/src/lib-storage \ -DPKG_RUNDIR=\""$(rundir)"\" diff -r 89f8843be67b -r f8c1ddf55b94 src/indexer/master-connection.c --- a/src/indexer/master-connection.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/indexer/master-connection.c Tue Sep 25 20:15:58 2012 +0300 @@ -9,7 +9,7 @@ #include "master-service.h" #include "master-service-settings.h" #include "mail-namespace.h" -#include "mail-storage.h" +#include "mail-storage-private.h" #include "mail-storage-service.h" #include "mail-search-build.h" #include "master-connection.h" @@ -130,14 +130,14 @@ return -1; } - path = mailbox_list_get_path(ns->list, mailbox, - MAILBOX_LIST_PATH_TYPE_INDEX); + box = mailbox_alloc(ns->list, mailbox, 0); + path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); if (*path == '\0') { i_info("Indexes disabled for Mailbox %s, skipping", mailbox); + mailbox_free(&box); return 0; } - - box = mailbox_alloc(ns->list, mailbox, 0); + if (max_recent_msgs != 0) { /* index only if there aren't too many recent messages. don't bother syncing the mailbox, that alone can take a diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/cydir/cydir-mail.c --- a/src/lib-storage/index/cydir/cydir-mail.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/cydir/cydir-mail.c Tue Sep 25 20:15:58 2012 +0300 @@ -13,8 +13,7 @@ { const char *dir; - dir = mailbox_list_get_path(mail->box->list, mail->box->name, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + dir = mailbox_get_path(mail->box); return t_strdup_printf("%s/%u.", dir, mail->uid); } diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/cydir/cydir-save.c --- a/src/lib-storage/index/cydir/cydir-save.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/cydir/cydir-save.c Tue Sep 25 20:15:58 2012 +0300 @@ -50,8 +50,7 @@ { const char *dir; - dir = mailbox_list_get_path(ctx->mbox->box.list, ctx->mbox->box.name, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + dir = mailbox_get_path(&ctx->mbox->box); return t_strdup_printf("%s/%s.%u", dir, ctx->tmp_basename, num); } @@ -267,8 +266,7 @@ &_t->changes->saved_uids); _t->changes->uid_validity = ctx->sync_ctx->uid_validity; - dir = mailbox_list_get_path(ctx->mbox->box.list, ctx->mbox->box.name, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + dir = mailbox_get_path(&ctx->mbox->box); src_path = t_str_new(256); str_printfa(src_path, "%s/%s.", dir, ctx->tmp_basename); diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/cydir/cydir-sync.c --- a/src/lib-storage/index/cydir/cydir-sync.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/cydir/cydir-sync.c Tue Sep 25 20:15:58 2012 +0300 @@ -19,11 +19,8 @@ static string_t *cydir_get_path_prefix(struct cydir_mailbox *mbox) { string_t *path = str_new(default_pool, 256); - const char *dir; - dir = mailbox_list_get_path(mbox->box.list, mbox->box.name, - MAILBOX_LIST_PATH_TYPE_MAILBOX); - str_append(path, dir); + str_append(path, mailbox_get_path(&mbox->box)); str_append_c(path, '/'); return path; } diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Tue Sep 25 20:15:58 2012 +0300 @@ -139,8 +139,7 @@ if (box->notify_callback == NULL) index_mailbox_check_remove_all(box); else { - dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_INDEX); + dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); path = t_strdup_printf("%s/"DBOX_INDEX_PREFIX".log", dir); index_mailbox_check_add(box, path); } @@ -252,8 +251,7 @@ /* if alt path already exists and contains files, rebuild storage so that we don't start overwriting files. */ - alt_path = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); + alt_path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); if (alt_path != NULL && stat(alt_path, &st) == 0) { ret = dir_is_empty(box->storage, alt_path); if (ret < 0) diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/dbox-single/sdbox-file.c --- a/src/lib-storage/index/dbox-single/sdbox-file.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-file.c Tue Sep 25 20:15:58 2012 +0300 @@ -25,8 +25,7 @@ file->file.primary_path = i_strdup_printf("%s/%s", mailbox_get_path(box), fname); - alt_path = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); + alt_path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); if (alt_path != NULL) file->file.alt_path = i_strdup_printf("%s/%s", alt_path, fname); } diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Tue Sep 25 20:15:58 2012 +0300 @@ -159,8 +159,8 @@ int ret = 0; path = mailbox_get_path(ctx->box); - alt_path = mailbox_list_get_path(ctx->box->list, ctx->box->name, - MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); + alt_path = mailbox_get_path_to(ctx->box, + MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); sdbox_sync_set_uidvalidity(ctx); if (sdbox_sync_index_rebuild_dir(ctx, path, TRUE) < 0) { diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/index-rebuild.c --- a/src/lib-storage/index/index-rebuild.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/index-rebuild.c Tue Sep 25 20:15:58 2012 +0300 @@ -167,8 +167,7 @@ mail_cache_reset(box->cache); /* if backup index file exists, try to use it */ - index_dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_INDEX); + index_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); backup_path = t_strconcat(box->index_prefix, "/.backup", NULL); ctx->backup_index = mail_index_alloc(index_dir, backup_path); diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Tue Sep 25 20:15:58 2012 +0300 @@ -139,11 +139,9 @@ { const char *index_dir, *mailbox_path; - mailbox_path = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + mailbox_path = mailbox_get_path(box); index_dir = (box->flags & MAILBOX_FLAG_NO_INDEX_FILES) != 0 ? "" : - mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_INDEX); + mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); if (*index_dir == '\0') index_dir = NULL; @@ -165,8 +163,7 @@ const char *path, *path2; /* see if it's selectable */ - path = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + path = mailbox_get_path(box); if (subdir != NULL) path = t_strconcat(path, "/", subdir, NULL); if (stat(path, &st) == 0) { @@ -180,8 +177,7 @@ } /* see if it's non-selectable */ - path2 = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_DIR); + path2 = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_DIR); if (strcmp(path, path2) != 0 && stat(path2, &st) == 0) { *existence_r = MAILBOX_EXISTENCE_NOSELECT; diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/index-sync-pvt.c --- a/src/lib-storage/index/index-sync-pvt.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/index-sync-pvt.c Tue Sep 25 20:15:58 2012 +0300 @@ -12,8 +12,7 @@ if (box->index_pvt != NULL) return 1; - index_dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE); + index_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE); if (index_dir == NULL) { /* no private indexes */ return 0; diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/index-sync.c Tue Sep 25 20:15:58 2012 +0300 @@ -485,8 +485,7 @@ return 1; } - dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_INDEX); + dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); path = t_strconcat(dir, "/", box->index_prefix, ".log", NULL); if (stat(path, &st) < 0) { if (errno == ENOENT) @@ -525,8 +524,7 @@ return; old_rec = data; - dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_INDEX); + dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); path = t_strconcat(dir, "/", box->index_prefix, ".log", NULL); if (stat(path, &st) < 0) { mail_storage_set_critical(box->storage, diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/maildir/maildir-keywords.c --- a/src/lib-storage/index/maildir/maildir-keywords.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-keywords.c Tue Sep 25 20:15:58 2012 +0300 @@ -66,8 +66,7 @@ struct maildir_keywords *mk; const char *dir; - dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_CONTROL); + dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL); mk = i_new(struct maildir_keywords, 1); mk->storage = box->storage; diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/maildir/maildir-sync-index.c --- a/src/lib-storage/index/maildir/maildir-sync-index.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync-index.c Tue Sep 25 20:15:58 2012 +0300 @@ -728,8 +728,7 @@ return 1; } - root_dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_MAILBOX); + root_dir = mailbox_get_path(box); /* check if new/ changed */ new_dir = t_strconcat(root_dir, "/new", NULL); diff -r 89f8843be67b -r f8c1ddf55b94 src/lib-storage/index/maildir/maildir-uidlist.c --- a/src/lib-storage/index/maildir/maildir-uidlist.c Tue Sep 25 17:44:37 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Tue Sep 25 20:15:58 2012 +0300 @@ -154,10 +154,9 @@ return 1; } - index_storage_lock_notify_reset(uidlist->box); + index_storage_lock_notify_reset(box); - control_dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_CONTROL); + control_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL); path = t_strconcat(control_dir, "/" MAILDIR_UIDLIST_NAME, NULL); for (i = 0;; i++) { @@ -265,8 +264,7 @@ struct maildir_uidlist *uidlist; const char *control_dir; - control_dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_CONTROL); + control_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL); uidlist = i_new(struct maildir_uidlist, 1); uidlist->box = box; @@ -1396,8 +1394,7 @@ maildir_uidlist_records_drop_expunges(uidlist); - control_dir = mailbox_list_get_path(box->list, box->name, - MAILBOX_LIST_PATH_TYPE_CONTROL); + control_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL); temp_path = t_strconcat(control_dir, "/" MAILDIR_UIDLIST_NAME ".tmp", NULL); @@ -1760,7 +1757,7 @@ { struct maildir_uidlist *uidlist = ctx->uidlist; struct maildir_uidlist_rec *rec, *old_rec; - const char *p, *dir; + const char *p; *rec_r = NULL; From dovecot at dovecot.org Tue Sep 25 21:45:17 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 21:45:17 +0300 Subject: dovecot-2.2: lib-storage: Added asserts to make sure mailbox_ope... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/78d9adf7c149 changeset: 15101:78d9adf7c149 user: Timo Sirainen date: Tue Sep 25 20:51:07 2012 +0300 description: lib-storage: Added asserts to make sure mailbox_open() is called early enough. diffstat: src/lib-storage/mail-storage.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diffs (48 lines): diff -r f8c1ddf55b94 -r 78d9adf7c149 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Tue Sep 25 20:15:58 2012 +0300 +++ b/src/lib-storage/mail-storage.c Tue Sep 25 20:51:07 2012 +0300 @@ -1299,6 +1299,8 @@ bool mailbox_is_readonly(struct mailbox *box) { + i_assert(box->opened); + return box->v.is_readonly(box); } @@ -1354,6 +1356,8 @@ enum mail_flags mailbox_get_private_flags_mask(struct mailbox *box) { + i_assert(box->opened); + if (box->v.get_private_flags_mask != NULL) return box->v.get_private_flags_mask(box); else if (box->list->set.index_pvt_dir != NULL) @@ -1428,6 +1432,8 @@ void mailbox_notify_changes(struct mailbox *box, mailbox_notify_callback_t *callback, void *context) { + i_assert(box->opened); + box->notify_callback = callback; box->notify_context = context; @@ -1436,6 +1442,8 @@ void mailbox_notify_changes_stop(struct mailbox *box) { + i_assert(box->opened); + box->notify_callback = NULL; box->notify_context = NULL; @@ -1525,6 +1533,8 @@ { struct mailbox_transaction_context *trans; + i_assert(box->opened); + box->transaction_count++; trans = box->v.transaction_begin(box, flags); trans->flags = flags; From dovecot at dovecot.org Tue Sep 25 21:45:17 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 21:45:17 +0300 Subject: dovecot-2.2: lib-storage: If list escape_char is set, allow ".",... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/185680508ece changeset: 15102:185680508ece user: Timo Sirainen date: Tue Sep 25 21:27:30 2012 +0300 description: lib-storage: If list escape_char is set, allow ".", ".." and "dbox-Mails" mailbox names. diffstat: src/lib-storage/mailbox-list.c | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diffs (60 lines): diff -r 78d9adf7c149 -r 185680508ece src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Sep 25 20:51:07 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Sep 25 21:27:30 2012 +0300 @@ -360,12 +360,32 @@ return mailbox_list_set_get_root_path(&set, type); } +static bool need_escape_dirstart(const char *vname, const char *maildir_name) +{ + unsigned int len; + + if (vname[0] == '.') { + if (vname[1] == '\0' || vname[1] == '/') + return TRUE; /* "." */ + if (vname[1] == '.' && (vname[2] == '\0' || vname[2] == '/')) + return TRUE; /* ".." */ + } + if (*maildir_name != '\0') { + len = strlen(maildir_name); + if (strncmp(maildir_name, vname, len) == 0 && + (vname[len] == '\0' || vname[len] == '/')) + return TRUE; /* e.g. dbox-Mails */ + } + return FALSE; +} + static const char * mailbox_list_escape_name(struct mailbox_list *list, const char *vname) { char ns_sep = mail_namespace_get_sep(list->ns); char list_sep = mailbox_list_get_hierarchy_sep(list); string_t *escaped_name = t_str_new(64); + char dirstart = TRUE; /* no escaping of namespace prefix */ if (strncmp(list->ns->prefix, vname, list->ns->prefix_len) == 0) { @@ -378,18 +398,22 @@ str_printfa(escaped_name, "%c%02x", list->set.escape_char, *vname); vname++; + dirstart = FALSE; } for (; *vname != '\0'; vname++) { if (*vname == ns_sep) str_append_c(escaped_name, *vname); else if (*vname == list_sep || *vname == list->set.escape_char || - *vname == '/') { + *vname == '/' || + (dirstart && + need_escape_dirstart(vname, list->set.maildir_name))) { str_printfa(escaped_name, "%c%02x", list->set.escape_char, *vname); } else { str_append_c(escaped_name, *vname); } + dirstart = *vname == '/'; } return str_c(escaped_name); } From dovecot at dovecot.org Tue Sep 25 21:45:17 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 21:45:17 +0300 Subject: dovecot-2.2: lib-storage: Removed unused mailbox_list_create_dir() Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fbc90337b48c changeset: 15103:fbc90337b48c user: Timo Sirainen date: Tue Sep 25 21:31:41 2012 +0300 description: lib-storage: Removed unused mailbox_list_create_dir() diffstat: src/lib-storage/mailbox-list.c | 18 ------------------ src/lib-storage/mailbox-list.h | 3 --- 2 files changed, 0 insertions(+), 21 deletions(-) diffs (41 lines): diff -r 185680508ece -r fbc90337b48c src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Sep 25 21:27:30 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Sep 25 21:31:41 2012 +0300 @@ -1229,24 +1229,6 @@ return 0; } -int mailbox_list_create_dir(struct mailbox_list *list, const char *name) -{ - guid_128_t guid; - - if (!mailbox_list_is_valid_create_name(list, name) || *name == '\0') { - mailbox_list_set_error(list, MAIL_ERROR_PARAMS, - "Invalid mailbox name"); - return -1; - } - if (list->v.create_mailbox_dir(list, name, - MAILBOX_DIR_CREATE_TYPE_ONLY_NOSELECT) < 0) - return -1; - - mailbox_name_get_sha128(name, guid); - mailbox_list_add_change(list, MAILBOX_LOG_RECORD_CREATE_DIR, guid); - return 0; -} - int mailbox_list_delete_dir(struct mailbox_list *list, const char *name) { if (!mailbox_list_is_valid_existing_name(list, name) || *name == '\0') { diff -r 185680508ece -r fbc90337b48c src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Tue Sep 25 21:27:30 2012 +0300 +++ b/src/lib-storage/mailbox-list.h Tue Sep 25 21:31:41 2012 +0300 @@ -217,9 +217,6 @@ int mailbox_list_set_subscribed(struct mailbox_list *list, const char *name, bool set); -/* Create a non-selectable mailbox. Fail with MAIL_ERROR_NOTPOSSIBLE if only - a selectable mailbox can be created. */ -int mailbox_list_create_dir(struct mailbox_list *list, const char *name); /* Delete a non-selectable mailbox. Fail if the mailbox is selectable. */ int mailbox_list_delete_dir(struct mailbox_list *list, const char *name); /* Delete a symlinked mailbox. Fail if the mailbox isn't a symlink. */ From dovecot at dovecot.org Tue Sep 25 21:45:17 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 21:45:17 +0300 Subject: dovecot-2.2: lib-storage: Removed mailbox list backend-specific ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3e6048697365 changeset: 15104:3e6048697365 user: Timo Sirainen date: Tue Sep 25 21:45:00 2012 +0300 description: lib-storage: Removed mailbox list backend-specific mailbox name/pattern validation. The virtual name validity is independent of the backend. The physical name is always used for paths in filesystem, so it can also be verified with common code. Backend's mailbox_dir and storage's internal directories can also be checked. There's nothing else left really. diffstat: src/lib-storage/index/imapc/imapc-list.c | 24 --- src/lib-storage/index/shared/shared-list.c | 33 ----- src/lib-storage/list/mailbox-list-fs.c | 98 --------------- src/lib-storage/list/mailbox-list-fs.h | 4 - src/lib-storage/list/mailbox-list-maildir.c | 91 -------------- src/lib-storage/list/mailbox-list-maildir.h | 4 - src/lib-storage/list/mailbox-list-none.c | 24 --- src/lib-storage/mail-storage.c | 181 +++++++++++++++++---------- src/lib-storage/mailbox-list-private.h | 6 - src/lib-storage/mailbox-list.c | 53 +++++++- 10 files changed, 159 insertions(+), 359 deletions(-) diffs (truncated from 754 to 300 lines): diff -r fbc90337b48c -r 3e6048697365 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Tue Sep 25 21:31:41 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Tue Sep 25 21:45:00 2012 +0300 @@ -161,27 +161,6 @@ imapc_untagged_lsub); } -static bool -imapc_is_valid_pattern(struct mailbox_list *list ATTR_UNUSED, - const char *pattern ATTR_UNUSED) -{ - return TRUE; -} - -static bool -imapc_is_valid_existing_name(struct mailbox_list *list ATTR_UNUSED, - const char *name ATTR_UNUSED) -{ - return TRUE; -} - -static bool -imapc_is_valid_create_name(struct mailbox_list *list ATTR_UNUSED, - const char *name ATTR_UNUSED) -{ - return TRUE; -} - static char imapc_list_get_hierarchy_sep(struct mailbox_list *_list) { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; @@ -700,9 +679,6 @@ imapc_list_alloc, imapc_list_deinit, NULL, - imapc_is_valid_pattern, - imapc_is_valid_existing_name, - imapc_is_valid_create_name, imapc_list_get_hierarchy_sep, imapc_list_get_vname, imapc_list_get_storage_name, diff -r fbc90337b48c -r 3e6048697365 src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Tue Sep 25 21:31:41 2012 +0300 +++ b/src/lib-storage/index/shared/shared-list.c Tue Sep 25 21:45:00 2012 +0300 @@ -54,36 +54,6 @@ return 0; } -static bool -shared_is_valid_pattern(struct mailbox_list *list, const char *pattern) -{ - struct mail_namespace *ns = list->ns; - - if (shared_storage_get_namespace(&ns, &pattern) < 0) - return FALSE; - return mailbox_list_is_valid_pattern(ns->list, pattern); -} - -static bool -shared_is_valid_existing_name(struct mailbox_list *list, const char *name) -{ - struct mail_namespace *ns = list->ns; - - if (shared_storage_get_namespace(&ns, &name) < 0) - return FALSE; - return mailbox_list_is_valid_existing_name(ns->list, name); -} - -static bool -shared_is_valid_create_name(struct mailbox_list *list, const char *name) -{ - struct mail_namespace *ns = list->ns; - - if (shared_storage_get_namespace(&ns, &name) < 0) - return FALSE; - return mailbox_list_is_valid_create_name(ns->list, name); -} - static char shared_list_get_hierarchy_sep(struct mailbox_list *list ATTR_UNUSED) { return '/'; @@ -337,9 +307,6 @@ shared_list_alloc, shared_list_deinit, shared_get_storage, - shared_is_valid_pattern, - shared_is_valid_existing_name, - shared_is_valid_create_name, shared_list_get_hierarchy_sep, mailbox_list_default_get_vname, mailbox_list_default_get_storage_name, diff -r fbc90337b48c -r 3e6048697365 src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Tue Sep 25 21:31:41 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Tue Sep 25 21:45:00 2012 +0300 @@ -41,101 +41,6 @@ pool_unref(&list->list.pool); } -static bool fs_list_is_valid_common(const char *name, size_t *len_r) -{ - *len_r = strlen(name); - - if (name[0] == '\0' || name[*len_r-1] == '/') - return FALSE; - return TRUE; -} - -static bool -fs_list_is_valid_common_nonfs(struct mailbox_list *list, const char *name) -{ - bool ret, allow_internal_dirs; - - /* make sure it's not absolute path */ - if (*name == '/' || *name == '~') - return FALSE; - - /* make sure the mailbox name doesn't contain any foolishness: - "../" could give access outside the mailbox directory. - "./" and "//" could fool ACL checks. */ - allow_internal_dirs = list->v.is_internal_name == NULL || - *list->set.maildir_name != '\0'; - T_BEGIN { - const char *const *names; - - names = t_strsplit(name, "/"); - for (; *names != NULL; names++) { - const char *n = *names; - - if (*n == '\0') - break; /* // */ - if (*n == '.') { - if (n[1] == '\0') - break; /* ./ */ - if (n[1] == '.' && n[2] == '\0') - break; /* ../ */ - } - if (*list->set.maildir_name != '\0' && - strcmp(list->set.maildir_name, n) == 0) { - /* don't allow maildir_name to be used as part - of the mailbox name */ - break; - } - if (!allow_internal_dirs && - list->v.is_internal_name(list, n)) - break; - } - ret = *names == NULL; - } T_END; - - return ret; -} - -static bool -fs_is_valid_pattern(struct mailbox_list *list, const char *pattern) -{ - if (list->mail_set->mail_full_filesystem_access) - return TRUE; - - return fs_list_is_valid_common_nonfs(list, pattern); -} - -static bool -fs_is_valid_existing_name(struct mailbox_list *list, const char *name) -{ - size_t len; - - if (!fs_list_is_valid_common(name, &len)) - return FALSE; - - if (list->mail_set->mail_full_filesystem_access) - return TRUE; - - return fs_list_is_valid_common_nonfs(list, name); -} - -static bool -fs_is_valid_create_name(struct mailbox_list *list, const char *name) -{ - size_t len; - - if (!fs_list_is_valid_common(name, &len)) - return FALSE; - if (len > FS_MAX_CREATE_MAILBOX_NAME_LENGTH) - return FALSE; - - if (list->mail_set->mail_full_filesystem_access) - return TRUE; - - if (mailbox_list_name_is_too_large(name, '/')) - return FALSE; - return fs_list_is_valid_common_nonfs(list, name); -} - static char fs_list_get_hierarchy_sep(struct mailbox_list *list ATTR_UNUSED) { return '/'; @@ -605,9 +510,6 @@ fs_list_alloc, fs_list_deinit, NULL, - fs_is_valid_pattern, - fs_is_valid_existing_name, - fs_is_valid_create_name, fs_list_get_hierarchy_sep, mailbox_list_default_get_vname, mailbox_list_default_get_storage_name, diff -r fbc90337b48c -r 3e6048697365 src/lib-storage/list/mailbox-list-fs.h --- a/src/lib-storage/list/mailbox-list-fs.h Tue Sep 25 21:31:41 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.h Tue Sep 25 21:45:00 2012 +0300 @@ -3,10 +3,6 @@ #include "mailbox-list-private.h" -/* Don't allow creating too long mailbox names. They could start causing - problems when they reach the limit. */ -#define FS_MAX_CREATE_MAILBOX_NAME_LENGTH (MAILBOX_LIST_NAME_MAX_LENGTH/2) - /* When doing deletion via renaming it first to trash directory, use this as the trash directory name */ #define MAILBOX_LIST_FS_TRASH_DIR_NAME "..DOVECOT-TrasH" diff -r fbc90337b48c -r 3e6048697365 src/lib-storage/list/mailbox-list-maildir.c --- a/src/lib-storage/list/mailbox-list-maildir.c Tue Sep 25 21:31:41 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir.c Tue Sep 25 21:45:00 2012 +0300 @@ -92,91 +92,6 @@ p+1); } -static bool -maildir_list_is_valid_common(struct maildir_mailbox_list *list, - const char *name, size_t *len_r) -{ - size_t len; - - /* check that there are no adjacent hierarchy separators */ - for (len = 0; name[len] != '\0'; len++) { - if (name[len] == list->sep && - name[len+1] == list->sep) - return FALSE; - } - - if (len == 0 || name[len-1] == '/') - return FALSE; - - if (name[0] == list->sep || - name[len-1] == list->sep) - return FALSE; - - *len_r = len; - return TRUE; -} - -static bool maildir_list_is_valid_common_nonfs(const char *name) -{ - if (*name == '~' || strchr(name, '/') != NULL) - return FALSE; - - if (name[0] == '.' && (name[1] == '\0' || - (name[1] == '.' && name[2] == '\0'))) { - /* "." and ".." aren't allowed. */ - return FALSE; - } - return TRUE; -} - -static bool -maildir_is_valid_existing_name(struct mailbox_list *_list, const char *name) -{ - struct maildir_mailbox_list *list = - (struct maildir_mailbox_list *)_list; - size_t len; - - if (!maildir_list_is_valid_common(list, name, &len)) - return FALSE; - - if (_list->mail_set->mail_full_filesystem_access) - return TRUE; - - return maildir_list_is_valid_common_nonfs(name); -} - -static bool -maildir_is_valid_pattern(struct mailbox_list *list, const char *pattern) -{ - /* maildir code itself doesn't care about this, but we may get here - from listing subscriptions to LAYOUT=fs namespace containing - entries for a subscriptions=no LAYOUT=maildir++ namespace */ - return maildir_is_valid_existing_name(list, pattern); -} - -static bool -maildir_is_valid_create_name(struct mailbox_list *_list, const char *name) -{ - struct maildir_mailbox_list *list = - (struct maildir_mailbox_list *)_list; - size_t len; - - if (!maildir_list_is_valid_common(list, name, &len)) - return FALSE; - if (len > MAILDIR_MAX_CREATE_MAILBOX_NAME_LENGTH) - return FALSE; From dovecot at dovecot.org Tue Sep 25 22:53:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 22:53:59 +0300 Subject: dovecot-2.2: lib-storage: Fixed shared namespace autocreation af... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f0d487918a2b changeset: 15106:f0d487918a2b user: Timo Sirainen date: Tue Sep 25 22:51:46 2012 +0300 description: lib-storage: Fixed shared namespace autocreation after previous mailbox list changes. mailbox_list_is_valid_existing_name() no longer goes all the way through to shared-list backend, but mailbox_list_join_refpattern() does. diffstat: src/lib-storage/index/shared/shared-list.c | 4 +++- src/lib-storage/list/mailbox-list-subscriptions.c | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diffs (48 lines): diff -r 7766229d8f3e -r f0d487918a2b src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Tue Sep 25 22:40:55 2012 +0300 +++ b/src/lib-storage/index/shared/shared-list.c Tue Sep 25 22:51:46 2012 +0300 @@ -120,6 +120,7 @@ shared_list_create_missing_namespaces(struct mailbox_list *list, const char *const *patterns) { + struct mail_namespace *ns; char sep = mail_namespace_get_sep(list->ns); const char *list_pat, *name; unsigned int i; @@ -142,8 +143,9 @@ last = p; } if (last != NULL) { + ns = list->ns; name = t_strdup_until(list_pat, last); - (void)mailbox_list_is_valid_existing_name(list, name); + (void)shared_storage_get_namespace(&ns, &name); } } } diff -r 7766229d8f3e -r f0d487918a2b src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Tue Sep 25 22:40:55 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Tue Sep 25 22:51:46 2012 +0300 @@ -27,7 +27,7 @@ struct mail_namespace *ns, *default_ns = list->ns; struct mail_namespace *namespaces = default_ns->user->namespaces; struct mailbox_node *node; - const char *vname, *ns_name, *list_name; + const char *vname, *ns_name; unsigned int len; bool created; @@ -59,10 +59,9 @@ if (ns != NULL && ns->type == MAIL_NAMESPACE_TYPE_SHARED && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) { /* we'll need to get the namespace autocreated. - one easy way is to just ask if a mailbox name under - it is valid, and it gets created */ - list_name = ns_name + ns->prefix_len; - (void)mailbox_list_is_valid_existing_name(list, list_name); + one easy way is to just ask to join a reference and + pattern */ + (void)mailbox_list_join_refpattern(ns->list, ns_name, ""); } /* When listing pub/ namespace, skip over the namespace From dovecot at dovecot.org Tue Sep 25 22:53:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 22:53:59 +0300 Subject: dovecot-2.2: lib-fs: Fix to previous change Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7766229d8f3e changeset: 15105:7766229d8f3e user: Timo Sirainen date: Tue Sep 25 22:40:55 2012 +0300 description: lib-fs: Fix to previous change diffstat: src/lib-fs/fs-api.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3e6048697365 -r 7766229d8f3e src/lib-fs/fs-api.c --- a/src/lib-fs/fs-api.c Tue Sep 25 21:45:00 2012 +0300 +++ b/src/lib-fs/fs-api.c Tue Sep 25 22:40:55 2012 +0300 @@ -33,7 +33,7 @@ i_free(error_dup); return -1; } - (*fs_r)->last_error = str_new(default_pool, 64); + fs->last_error = str_new(default_pool, 64); *fs_r = fs; return 0; } From dovecot at dovecot.org Tue Sep 25 22:53:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 22:53:59 +0300 Subject: dovecot-2.2: Various cleanups to checking if mailbox name is valid. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/20edc46254ce changeset: 15107:20edc46254ce user: Timo Sirainen date: Tue Sep 25 22:53:36 2012 +0300 description: Various cleanups to checking if mailbox name is valid. diffstat: src/doveadm/dsync/dsync-brain-mailbox-tree.c | 116 +++++++++++---------- src/lib-storage/list/mailbox-list-fs-iter.c | 6 +- src/lib-storage/list/mailbox-list-fs.c | 4 +- src/lib-storage/list/mailbox-list-subscriptions.c | 8 +- src/lib-storage/mail-storage.c | 51 +++++++-- src/lib-storage/mail-storage.h | 3 + src/lib-storage/mailbox-list.c | 76 ++++++-------- src/lib-storage/mailbox-list.h | 12 +- src/plugins/acl/acl-backend-vfile.c | 4 +- 9 files changed, 151 insertions(+), 129 deletions(-) diffs (truncated from 515 to 300 lines): diff -r f0d487918a2b -r 20edc46254ce src/doveadm/dsync/dsync-brain-mailbox-tree.c --- a/src/doveadm/dsync/dsync-brain-mailbox-tree.c Tue Sep 25 22:51:46 2012 +0300 +++ b/src/doveadm/dsync/dsync-brain-mailbox-tree.c Tue Sep 25 22:53:36 2012 +0300 @@ -173,66 +173,71 @@ return best_ns; } -static const char * -mailbox_name_cleanup(const char *input, char real_sep, char alt_char) +static bool +dsync_is_valid_name(struct mail_namespace *ns, const char *vname) { - char *output, *p; + struct mailbox *box; + bool ret; - output = t_strdup_noconst(input); - for (p = output; *p != '\0'; p++) { - if (*p == real_sep || (uint8_t)*input < 32 || - (uint8_t)*input >= 0x80) + box = mailbox_alloc(ns->list, vname, 0); + ret = mailbox_verify_create_name(box) == 0; + mailbox_free(&box); + return ret; +} + +static void +dsync_fix_mailbox_name(struct mail_namespace *ns, string_t *vname, + char alt_char) +{ + const char *old_vname; + char *p, list_sep = mailbox_list_get_hierarchy_sep(ns->list); + guid_128_t guid; + + /* replace control chars */ + for (p = str_c_modifiable(vname); *p != '\0'; p++) { + if ((unsigned char)*p < ' ') *p = alt_char; } - return output; -} + /* make it valid UTF8 */ + if (!uni_utf8_str_is_valid(str_c(vname))) { + old_vname = t_strdup(str_c(vname)); + str_truncate(vname, 0); + if (uni_utf8_get_valid_data((const void *)old_vname, + strlen(old_vname), vname)) + i_unreached(); + } + if (dsync_is_valid_name(ns, str_c(vname))) + return; -static const char *mailbox_name_force_cleanup(const char *input, char alt_char) -{ - char *output, *p; + /* 1) change any real separators to alt separators (this wouldn't + be necessary with listescape, but don't bother detecting it) */ + if (list_sep != mail_namespace_get_sep(ns)) { + for (p = str_c_modifiable(vname); *p != '\0'; p++) { + if (*p == list_sep) + *p = alt_char; + } + if (dsync_is_valid_name(ns, str_c(vname))) + return; + } + /* 2) '/' characters aren't valid without listescape */ + if (mail_namespace_get_sep(ns) != '/' && list_sep != '/') { + for (p = str_c_modifiable(vname); *p != '\0'; p++) { + if (*p == '/') + *p = alt_char; + } + if (dsync_is_valid_name(ns, str_c(vname))) + return; + } + /* 3) probably some reserved name (e.g. dbox-Mails) */ + str_insert(vname, 0, "_"); + if (dsync_is_valid_name(ns, str_c(vname))) + return; - output = t_strdup_noconst(input); - for (p = output; *p != '\0'; p++) { - if (!i_isalnum(*p)) - *p = alt_char; - } - return output; -} - -static const char * -dsync_fix_mailbox_name(struct mail_namespace *ns, const char *vname, - char alt_char) -{ - const char *name; - char list_sep; - - name = mailbox_list_get_storage_name(ns->list, vname); - - list_sep = mailbox_list_get_hierarchy_sep(ns->list); - if (!mailbox_list_is_valid_create_name(ns->list, name)) { - /* change any real separators to alt separators, - drop any potentially invalid characters */ - name = mailbox_name_cleanup(name, list_sep, alt_char); - } - if (!mailbox_list_is_valid_create_name(ns->list, name)) { - /* still not working, apparently it's not valid mUTF-7. - just drop all non-alphanumeric characters. */ - name = mailbox_name_force_cleanup(name, alt_char); - } - if (!mailbox_list_is_valid_create_name(ns->list, name)) { - /* probably some reserved name (e.g. dbox-Mails) */ - name = t_strconcat("_", name, NULL); - } - if (!mailbox_list_is_valid_create_name(ns->list, name)) { - /* name is too long? just give up and generate a - unique name */ - guid_128_t guid; - - guid_128_generate(guid); - name = guid_128_to_string(guid); - } - i_assert(mailbox_list_is_valid_create_name(ns->list, name)); - return mailbox_list_get_vname(ns->list, name); + /* 4) name is too long? just give up and generate a unique name */ + guid_128_generate(guid); + str_truncate(vname, 0); + str_append(vname, guid_128_to_string(guid)); + i_assert(dsync_is_valid_name(ns, str_c(vname))); } static int @@ -264,7 +269,8 @@ } str_truncate(vname, str_len(vname)-1); - *name_r = dsync_fix_mailbox_name(ns, str_c(vname), alt_char); + dsync_fix_mailbox_name(ns, vname, alt_char); + *name_r = str_c(vname); *ns_r = ns; return 0; } diff -r f0d487918a2b -r 20edc46254ce src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Tue Sep 25 22:51:46 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Tue Sep 25 22:53:36 2012 +0300 @@ -328,7 +328,7 @@ { struct mailbox_list *_list = ctx->ctx.list; ARRAY(const char *) valid_patterns; - const char *pattern, *test_pattern, *real_pattern; + const char *pattern, *test_pattern, *real_pattern, *error; unsigned int prefix_len; prefix_len = strlen(_list->ns->prefix); @@ -345,8 +345,8 @@ separators. */ real_pattern = mailbox_list_get_storage_name(_list, test_pattern); - if (mailbox_list_is_valid_pattern(_list, test_pattern) && - mailbox_list_is_valid_pattern(_list, real_pattern)) { + if (mailbox_list_is_valid_name(_list, test_pattern, &error) && + mailbox_list_is_valid_name(_list, real_pattern, &error)) { pattern = p_strdup(ctx->ctx.pool, *patterns); array_append(&valid_patterns, &pattern, 1); } diff -r f0d487918a2b -r 20edc46254ce src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Tue Sep 25 22:51:46 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Tue Sep 25 22:53:36 2012 +0300 @@ -51,14 +51,14 @@ enum mailbox_list_path_type type) { const struct mailbox_list_settings *set = &_list->set; - const char *root_dir; + const char *root_dir, *error; if (name == NULL) { /* return root directories */ return mailbox_list_set_get_root_path(set, type); } - i_assert(mailbox_list_is_valid_pattern(_list, name)); + i_assert(mailbox_list_is_valid_name(_list, name, &error)); if (mailbox_list_try_get_absolute_path(_list, &name)) return name; diff -r f0d487918a2b -r 20edc46254ce src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Tue Sep 25 22:51:46 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Tue Sep 25 22:53:36 2012 +0300 @@ -27,7 +27,7 @@ struct mail_namespace *ns, *default_ns = list->ns; struct mail_namespace *namespaces = default_ns->user->namespaces; struct mailbox_node *node; - const char *vname, *ns_name; + const char *vname, *ns_name, *error; unsigned int len; bool created; @@ -87,7 +87,7 @@ name = t_strndup(name, len-1); } - if (!mailbox_list_is_valid_existing_name(list, name)) { + if (!mailbox_list_is_valid_name(list, name, &error)) { /* we'll only get into trouble if we show this */ return -1; } else { @@ -246,7 +246,7 @@ struct mailbox_list *list = _ctx->list; struct mailbox_node *node; enum mailbox_info_flags subs_flags; - const char *vname, *storage_name; + const char *vname, *storage_name, *error; int ret; node = mailbox_tree_iterate_next(ctx->iter, &vname); @@ -265,7 +265,7 @@ } storage_name = mailbox_list_get_storage_name(list, vname); - if (!mailbox_list_is_valid_pattern(list, storage_name)) { + if (!mailbox_list_is_valid_name(list, storage_name, &error)) { /* broken entry in subscriptions file */ ctx->info.flags = MAILBOX_NONEXISTENT; } else if (mailbox_list_mailbox(list, storage_name, diff -r f0d487918a2b -r 20edc46254ce src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Tue Sep 25 22:51:46 2012 +0300 +++ b/src/lib-storage/mail-storage.c Tue Sep 25 22:53:36 2012 +0300 @@ -709,31 +709,42 @@ return box; } -static bool mailbox_name_verify_separators(const char *vname, char sep) +static bool +mailbox_name_verify_separators(const char *vname, char sep, + const char **error_r) { unsigned int i; - bool prev_sep = TRUE; + bool prev_sep = FALSE; + + if (vname[0] == sep) { + *error_r = "Begins with hierarchy separator"; + return FALSE; + } /* Make sure the vname is correct: non-empty, doesn't begin or end with separator and no adjacent separators */ - for (i = 0; vname[i] != '\0'; i++) { + for (i = 1; vname[i] != '\0'; i++) { if (vname[i] == sep) { - if (prev_sep) + if (prev_sep) { + *error_r = "Has adjacent hierarchy separators"; return FALSE; + } prev_sep = TRUE; } else { prev_sep = FALSE; } } - if (prev_sep) + if (prev_sep) { + *error_r = "Ends with hierarchy separator"; return FALSE; + } return TRUE; } static int mailbox_verify_name(struct mailbox *box) { struct mail_namespace *ns = box->list->ns; - const char *vname = box->vname; + const char *error, *vname = box->vname; char list_sep, ns_sep; if (box->inbox_user) { @@ -768,24 +779,40 @@ "Character not allowed in mailbox name: '%c'", list_sep)); return -1; } - if (!mailbox_name_verify_separators(box->vname, ns_sep) || - !mailbox_list_is_valid_existing_name(box->list, box->name)) { + if (!mailbox_name_verify_separators(vname, ns_sep, &error) || + !mailbox_list_is_valid_name(box->list, box->name, &error)) { mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS, - "Invalid mailbox name"); + t_strdup_printf("Invalid mailbox name: %s", error)); return -1; } return 0; } -static int mailbox_verify_create_name(struct mailbox *box) +static bool mailbox_name_has_control_chars(const char *name) +{ + const char *p; + + for (p = name; *p != '\0'; p++) { + if ((unsigned char)*p < ' ') + return TRUE; + } + return FALSE; +} From dovecot at dovecot.org Tue Sep 25 23:24:11 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 23:24:11 +0300 Subject: dovecot-2.2: lib-storage: Removed unused MAILBOX_DIR_CREATE_TYPE... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3275a9b5136a changeset: 15108:3275a9b5136a user: Timo Sirainen date: Tue Sep 25 23:23:53 2012 +0300 description: lib-storage: Removed unused MAILBOX_DIR_CREATE_TYPE_ONLY_NOSELECT diffstat: src/lib-storage/list/mailbox-list-maildir.c | 6 ------ src/lib-storage/mailbox-list-private.h | 6 +----- 2 files changed, 1 insertions(+), 11 deletions(-) diffs (39 lines): diff -r 20edc46254ce -r 3275a9b5136a src/lib-storage/list/mailbox-list-maildir.c --- a/src/lib-storage/list/mailbox-list-maildir.c Tue Sep 25 22:53:36 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir.c Tue Sep 25 23:23:53 2012 +0300 @@ -231,12 +231,6 @@ const char *path, *root_dir, *p; bool create_parent_dir; - if (type == MAILBOX_DIR_CREATE_TYPE_ONLY_NOSELECT) { - mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE, - "Can't create non-selectable mailbox"); - return -1; - } - path = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_MAILBOX); create_parent_dir = type == MAILBOX_DIR_CREATE_TYPE_MAILBOX && diff -r 20edc46254ce -r 3275a9b5136a src/lib-storage/mailbox-list-private.h --- a/src/lib-storage/mailbox-list-private.h Tue Sep 25 22:53:36 2012 +0300 +++ b/src/lib-storage/mailbox-list-private.h Tue Sep 25 23:23:53 2012 +0300 @@ -29,9 +29,7 @@ /* Creating a mailbox */ MAILBOX_DIR_CREATE_TYPE_MAILBOX, /* Create a \Noselect or a mailbox */ - MAILBOX_DIR_CREATE_TYPE_TRY_NOSELECT, - /* Create a \Noselect or fail */ - MAILBOX_DIR_CREATE_TYPE_ONLY_NOSELECT + MAILBOX_DIR_CREATE_TYPE_TRY_NOSELECT }; struct mailbox_list_vfuncs { @@ -208,8 +206,6 @@ void mailbox_list_add_change(struct mailbox_list *list, enum mailbox_log_record_type type, const guid_128_t guid_128); -int mailbox_list_get_guid_path(struct mailbox_list *list, const char *path, - guid_128_t guid_128_r); void mailbox_name_get_sha128(const char *name, guid_128_t guid_128_r); void mailbox_list_clear_error(struct mailbox_list *list); From dovecot at dovecot.org Tue Sep 25 23:38:28 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 25 Sep 2012 23:38:28 +0300 Subject: dovecot-2.2: lib-storage: Create "maildirfolder" file only with ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f6225edc2c1e changeset: 15109:f6225edc2c1e user: Timo Sirainen date: Tue Sep 25 23:38:14 2012 +0300 description: lib-storage: Create "maildirfolder" file only with maildir storage. Previously it was created for all storages, as long as they used LAYOUT=maildir++. The file is mainly meant for MDAs that want to update maildirsize quota, but that's only available for Maildir storage. diffstat: src/lib-storage/index/maildir/maildir-storage.c | 48 ++++++++++++++++++++++ src/lib-storage/list/mailbox-list-maildir.c | 53 +----------------------- 2 files changed, 51 insertions(+), 50 deletions(-) diffs (163 lines): diff -r 3275a9b5136a -r f6225edc2c1e src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Tue Sep 25 23:23:53 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Tue Sep 25 23:38:14 2012 +0300 @@ -17,6 +17,7 @@ #define MAILDIR_LIST_CONTEXT(obj) \ MODULE_CONTEXT(obj, maildir_mailbox_list_module) +#define MAILDIR_SUBFOLDER_FILENAME "maildirfolder" struct maildir_mailbox_list_context { union mailbox_list_module_context module_ctx; @@ -436,6 +437,52 @@ return ret; } +static int maildir_create_maildirfolder_file(struct mailbox *box) +{ + const struct mailbox_permissions *perm = mailbox_get_permissions(box); + const char *path; + mode_t old_mask; + int fd; + + /* Maildir++ spec wants that maildirfolder named file is created for + all subfolders. Do this only with Maildir++ layout. */ + if (strcmp(box->list->name, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) != 0) + return 0; + + path = t_strconcat(mailbox_get_path(box), + "/"MAILDIR_SUBFOLDER_FILENAME, NULL); + old_mask = umask(0); + fd = open(path, O_CREAT | O_WRONLY, perm->file_create_mode); + umask(old_mask); + if (fd != -1) { + /* ok */ + } else if (errno == ENOENT) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND, + "Mailbox was deleted while it was being created"); + return -1; + } else { + mail_storage_set_critical(box->storage, + "open(%s, O_CREAT) failed: %m", path); + return -1; + } + + if (perm->file_create_gid != (gid_t)-1) { + if (fchown(fd, (uid_t)-1, perm->file_create_gid) == 0) { + /* ok */ + } else if (errno == EPERM) { + mail_storage_set_critical(box->storage, "%s", + eperm_error_get_chgrp("fchown", path, + perm->file_create_gid, + perm->file_create_gid_origin)); + } else { + mail_storage_set_critical(box->storage, + "fchown(%s) failed: %m", path); + } + } + i_close_fd(&fd); + return 0; +} + static int maildir_mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory) @@ -459,6 +506,7 @@ if (create_maildir(box, FALSE) < 0) return -1; + maildir_create_maildirfolder_file(box); /* if dovecot-shared exists in the root dir, copy it to newly created mailboxes */ diff -r 3275a9b5136a -r f6225edc2c1e src/lib-storage/list/mailbox-list-maildir.c --- a/src/lib-storage/list/mailbox-list-maildir.c Tue Sep 25 23:23:53 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir.c Tue Sep 25 23:38:14 2012 +0300 @@ -14,7 +14,6 @@ #include #include -#define MAILDIR_SUBFOLDER_FILENAME "maildirfolder" #define MAILDIR_GLOBAL_TEMP_PREFIX "temp." #define IMAPDIR_GLOBAL_TEMP_PREFIX ".temp." @@ -181,49 +180,6 @@ } static int -maildir_list_create_maildirfolder_file(struct mailbox_list *list, - const char *dir, mode_t file_mode, - gid_t gid, const char *gid_origin) -{ - const char *path; - mode_t old_mask; - int fd; - - /* Maildir++ spec wants that maildirfolder named file is created for - all subfolders. */ - path = t_strconcat(dir, "/" MAILDIR_SUBFOLDER_FILENAME, NULL); - old_mask = umask(0); - fd = open(path, O_CREAT | O_WRONLY, file_mode); - umask(old_mask); - if (fd != -1) { - /* ok */ - } else if (errno == ENOENT) { - mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND, - "Mailbox was deleted while it was being created"); - return -1; - } else { - mailbox_list_set_critical(list, - "open(%s, O_CREAT) failed: %m", path); - return -1; - } - - if (gid != (gid_t)-1) { - if (fchown(fd, (uid_t)-1, gid) == 0) { - /* ok */ - } else if (errno == EPERM) { - mailbox_list_set_critical(list, "%s", - eperm_error_get_chgrp("fchown", path, - gid, gid_origin)); - } else { - mailbox_list_set_critical(list, - "fchown(%s) failed: %m", path); - } - } - i_close_fd(&fd); - return 0; -} - -static int maildir_list_create_mailbox_dir(struct mailbox_list *list, const char *name, enum mailbox_dir_create_type type) { @@ -243,7 +199,6 @@ path = t_strdup_until(path, p); } - root_dir = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_MAILBOX); mailbox_list_get_permissions(list, name, &perm); if (mkdir_parents_chgrp(path, perm.dir_create_mode, perm.file_create_gid, @@ -253,6 +208,8 @@ if (create_parent_dir) return 0; if (type == MAILBOX_DIR_CREATE_TYPE_MAILBOX) { + root_dir = mailbox_list_get_root_path(list, + MAILBOX_LIST_PATH_TYPE_MAILBOX); if (strcmp(path, root_dir) == 0) { /* even though the root directory exists, the mailbox might not */ @@ -269,11 +226,7 @@ mailbox_list_set_critical(list, "mkdir(%s) failed: %m", path); return -1; } - return create_parent_dir || strcmp(path, root_dir) == 0 ? 0 : - maildir_list_create_maildirfolder_file(list, path, - perm.file_create_mode, - perm.file_create_gid, - perm.file_create_gid_origin); + return 0; } static const char * From dovecot at dovecot.org Wed Sep 26 00:39:02 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 00:39:02 +0300 Subject: dovecot-2.2: lib-storage: Improved mailbox_list_mkdir() error ha... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/69b406249e47 changeset: 15110:69b406249e47 user: Timo Sirainen date: Wed Sep 26 00:23:02 2012 +0300 description: lib-storage: Improved mailbox_list_mkdir() error handling. diffstat: src/lib-storage/mailbox-list.c | 14 +++++++++++--- src/lib-storage/mailbox-list.h | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diffs (41 lines): diff -r f6225edc2c1e -r 69b406249e47 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Sep 25 23:38:14 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Wed Sep 26 00:23:02 2012 +0300 @@ -1421,13 +1421,21 @@ } if (mkdir_parents_chgrp(path, perm.dir_create_mode, perm.file_create_gid, - perm.file_create_gid_origin) < 0 && - errno != EEXIST) { + perm.file_create_gid_origin) == 0) + return 1; + else if (errno == EEXIST) + return 0; + else if (errno == ENOTDIR) { + mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE, + "Mailbox doesn't allow inferior mailboxes"); + return -1; + } else if (mailbox_list_set_error_from_errno(list)) { + return -1; + } else { mailbox_list_set_critical(list, "mkdir_parents(%s) failed: %m", path); return -1; } - return 0; } int mailbox_list_mkdir_parent(struct mailbox_list *list, diff -r f6225edc2c1e -r 69b406249e47 src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Tue Sep 25 23:38:14 2012 +0300 +++ b/src/lib-storage/mailbox-list.h Wed Sep 26 00:23:02 2012 +0300 @@ -162,7 +162,8 @@ void mailbox_list_get_root_permissions(struct mailbox_list *list, mode_t *file_mode_r, mode_t *dir_mode_r, gid_t *gid_r, const char **gid_origin_r); -/* Create path's directory with proper permissions. */ +/* Create path's directory with proper permissions. Returns 1 if created, + 0 if it already existed, -1 if error. */ int mailbox_list_mkdir(struct mailbox_list *list, const char *mailbox, const char *path) ATTR_NULL(2); /* Like mailbox_list_mkdir(), but create path's parent parent directory. From dovecot at dovecot.org Wed Sep 26 00:39:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 00:39:03 +0300 Subject: dovecot-2.2: maildir: Minor fixes and code cleanup to mailbox cr... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f5514e09fd1e changeset: 15111:f5514e09fd1e user: Timo Sirainen date: Wed Sep 26 00:25:21 2012 +0300 description: maildir: Minor fixes and code cleanup to mailbox creation. diffstat: src/lib-storage/index/maildir/maildir-storage.c | 54 +++++++++++++----------- 1 files changed, 29 insertions(+), 25 deletions(-) diffs (142 lines): diff -r 69b406249e47 -r f5514e09fd1e src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Wed Sep 26 00:23:02 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Wed Sep 26 00:25:21 2012 +0300 @@ -154,10 +154,9 @@ } static int -mkdir_verify(struct mail_storage *storage, struct mail_namespace *ns, - const char *dir, mode_t mode, gid_t gid, const char *gid_origin, - bool verify) +mkdir_verify(struct mailbox *box, const char *dir, bool verify) { + const struct mailbox_permissions *perm; struct stat st; if (verify) { @@ -165,34 +164,37 @@ return 0; if (errno != ENOENT) { - mail_storage_set_critical(storage, + mail_storage_set_critical(box->storage, "stat(%s) failed: %m", dir); return -1; } } - if (mkdir_parents_chgrp(dir, mode, gid, gid_origin) == 0) + perm = mailbox_get_permissions(box); + if (mkdir_parents_chgrp(dir, perm->file_create_mode, + perm->file_create_gid, + perm->file_create_gid_origin) == 0) return 0; if (errno == EEXIST) { if (verify) return 0; - mail_storage_set_error(storage, MAIL_ERROR_EXISTS, + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, "Mailbox already exists"); } else if (errno == ENOENT) { - mail_storage_set_error(storage, MAIL_ERROR_NOTFOUND, + mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND, "Mailbox was deleted while it was being created"); } else if (errno == EACCES) { - if (ns->type == MAIL_NAMESPACE_TYPE_SHARED) { + if (box->list->ns->type == MAIL_NAMESPACE_TYPE_SHARED) { /* shared namespace, don't log permission errors */ - mail_storage_set_error(storage, MAIL_ERROR_PERM, + mail_storage_set_error(box->storage, MAIL_ERROR_PERM, MAIL_ERRSTR_NO_PERMISSION); return -1; } - mail_storage_set_critical(storage, "%s", + mail_storage_set_critical(box->storage, "%s", mail_error_create_eacces_msg("mkdir", dir)); } else { - mail_storage_set_critical(storage, + mail_storage_set_critical(box->storage, "mkdir(%s) failed: %m", dir); } return -1; @@ -232,9 +234,8 @@ } /* create or fix maildir, ignore if it already exists */ -static int create_maildir(struct mailbox *box, bool verify) +static int create_maildir_subdirs(struct mailbox *box, bool verify) { - const struct mailbox_permissions *perm = mailbox_get_permissions(box); const char *path; unsigned int i; enum mail_error error; @@ -243,9 +244,7 @@ for (i = 0; i < N_ELEMENTS(maildir_subdirs); i++) { path = t_strconcat(mailbox_get_path(box), "/", maildir_subdirs[i], NULL); - if (mkdir_verify(box->storage, box->list->ns, path, - perm->dir_create_mode, perm->file_create_gid, - perm->file_create_gid_origin, verify) < 0) { + if (mkdir_verify(box, path, verify) < 0) { error = mailbox_get_last_mail_error(box); if (error != MAIL_ERROR_EXISTS) return -1; @@ -356,7 +355,7 @@ errno = ENOENT; } else if (stat(box_path, &st) == 0) { /* yes, we'll need to create the missing dirs */ - if (create_maildir(box, TRUE) < 0) + if (create_maildir_subdirs(box, TRUE) < 0) return -1; return maildir_mailbox_open_existing(box); @@ -439,7 +438,7 @@ static int maildir_create_maildirfolder_file(struct mailbox *box) { - const struct mailbox_permissions *perm = mailbox_get_permissions(box); + const struct mailbox_permissions *perm; const char *path; mode_t old_mask; int fd; @@ -448,6 +447,7 @@ all subfolders. Do this only with Maildir++ layout. */ if (strcmp(box->list->name, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) != 0) return 0; + perm = mailbox_get_permissions(box); path = t_strconcat(mailbox_get_path(box), "/"MAILDIR_SUBFOLDER_FILENAME, NULL); @@ -504,20 +504,24 @@ if (ret < 0) return -1; - if (create_maildir(box, FALSE) < 0) - return -1; - maildir_create_maildirfolder_file(box); - + /* the maildir is created now. finish the creation as best as we can */ + if (create_maildir_subdirs(box, FALSE) < 0) + ret = -1; + if (maildir_create_maildirfolder_file(box) < 0) + ret = -1; /* if dovecot-shared exists in the root dir, copy it to newly created mailboxes */ root_dir = mailbox_list_get_root_path(box->list, MAILBOX_LIST_PATH_TYPE_MAILBOX); shared_path = t_strconcat(root_dir, "/dovecot-shared", NULL); if (stat(shared_path, &st) == 0) { if (maildir_create_shared(box) < 0) - return -1; + ret = -1; } - - return update == NULL ? 0 : maildir_mailbox_update(box, update); + if (update != NULL) { + if (maildir_mailbox_update(box, update) < 0) + ret = -1; + } + return ret; } static int From dovecot at dovecot.org Wed Sep 26 00:39:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 00:39:03 +0300 Subject: dovecot-2.2: lib-storage: Removed mailbox_list.create_mailbox_di... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6e90fc8dfa25 changeset: 15112:6e90fc8dfa25 user: Timo Sirainen date: Wed Sep 26 00:35:10 2012 +0300 description: lib-storage: Removed mailbox_list.create_mailbox_dir() virtual function. It really didn't need to be virtual. Some storages didn't care about it, others wanted it to work basically the same. diffstat: src/lib-storage/index/cydir/cydir-storage.c | 7 +- src/lib-storage/index/dbox-common/dbox-storage.c | 6 +- src/lib-storage/index/imapc/imapc-list.c | 11 ---- src/lib-storage/index/index-storage.c | 57 ++++++++++++++++++++++++ src/lib-storage/index/index-storage.h | 1 + src/lib-storage/index/maildir/maildir-storage.c | 15 +----- src/lib-storage/index/mbox/mbox-storage.c | 5 +- src/lib-storage/index/shared/shared-list.c | 16 ------ src/lib-storage/list/mailbox-list-fs.c | 56 ----------------------- src/lib-storage/list/mailbox-list-index.c | 12 ----- src/lib-storage/list/mailbox-list-maildir.c | 52 --------------------- src/lib-storage/list/mailbox-list-none.c | 10 ---- src/lib-storage/mail-storage.c | 12 ----- src/lib-storage/mailbox-list-private.h | 9 --- src/plugins/acl/acl-mailbox-list.c | 24 ---------- 15 files changed, 68 insertions(+), 225 deletions(-) diffs (truncated from 511 to 300 lines): diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/cydir/cydir-storage.c --- a/src/lib-storage/index/cydir/cydir-storage.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/cydir/cydir-storage.c Wed Sep 26 00:35:10 2012 +0300 @@ -92,9 +92,10 @@ cydir_mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory) { - if (directory && - (box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0) - return 0; + int ret; + + if ((ret = index_storage_mailbox_create(box, directory)) <= 0) + return ret; return update == NULL ? 0 : index_storage_mailbox_update(box, update); diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Wed Sep 26 00:35:10 2012 +0300 @@ -242,10 +242,8 @@ struct stat st; int ret; - if (directory && - (box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0) - return 0; - + if ((ret = index_storage_mailbox_create(box, directory)) <= 0) + return ret; if (mailbox_open(box) < 0) return -1; diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Wed Sep 26 00:35:10 2012 +0300 @@ -561,16 +561,6 @@ } static int -imapc_list_create_mailbox_dir(struct mailbox_list *list ATTR_UNUSED, - const char *name ATTR_UNUSED, - enum mailbox_dir_create_type type ATTR_UNUSED) -{ - /* this gets called just before mailbox.create(). - we don't need to do anything. */ - return 0; -} - -static int imapc_list_delete_mailbox(struct mailbox_list *_list, const char *name) { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; @@ -692,7 +682,6 @@ NULL, imapc_list_subscriptions_refresh, imapc_list_set_subscribed, - imapc_list_create_mailbox_dir, imapc_list_delete_mailbox, imapc_list_delete_dir, imapc_list_delete_symlink, diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Wed Sep 26 00:35:10 2012 +0300 @@ -461,6 +461,63 @@ return ret; } +int index_storage_mailbox_create(struct mailbox *box, bool directory) +{ + const char *path, *p; + enum mailbox_existence existence; + bool create_parent_dir; + int ret; + + path = mailbox_list_get_path(box->list, box->name, + directory ? MAILBOX_LIST_PATH_TYPE_DIR : + MAILBOX_LIST_PATH_TYPE_MAILBOX); + if (path == NULL) { + /* layout=none */ + mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, + "Mailbox creation not supported"); + return -1; + } + create_parent_dir = !directory && + (box->list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0; + if (create_parent_dir) { + /* we only need to make sure that the parent directory exists */ + p = strrchr(path, '/'); + if (p == NULL) + return 1; + path = t_strdup_until(path, p); + } + + if ((ret = mailbox_list_mkdir(box->list, box->name, path)) < 0) { + mail_storage_copy_list_error(box->storage, box->list); + return -1; + } + if (ret == 0) { + /* directory already exists */ + if (create_parent_dir) + return 1; + if (!directory && *box->list->set.mailbox_dir_name == '\0') { + /* For example: layout=fs, path=~/Maildir/foo + might itself exist, but does it have the + cur|new|tmp subdirs? */ + if (mailbox_exists(box, TRUE, &existence) < 0) + return -1; + if (existence == MAILBOX_EXISTENCE_NONE) + return 1; + } + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "Mailbox already exists"); + return -1; + } + + if (directory && + (box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0) { + /* we only wanted to create the directory and it's done now */ + return 0; + } + /* the caller should still create the mailbox */ + return 1; +} + int index_storage_mailbox_delete_dir(struct mailbox *box, bool mailbox_deleted) { guid_128_t dir_sha128; diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/index-storage.h Wed Sep 26 00:35:10 2012 +0300 @@ -73,6 +73,7 @@ const struct mailbox_update *update); void index_storage_mailbox_update_cache(struct mailbox *box, const struct mailbox_update *update); +int index_storage_mailbox_create(struct mailbox *box, bool directory); int index_storage_mailbox_delete(struct mailbox *box); int index_storage_mailbox_delete_dir(struct mailbox *box, bool mailbox_deleted); int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest); diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Wed Sep 26 00:35:10 2012 +0300 @@ -491,19 +491,8 @@ struct stat st; int ret; - if (directory && - (box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0) - return 0; - - ret = maildir_check_tmp(box->storage, mailbox_get_path(box)); - if (ret > 0) { - mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, - "Mailbox already exists"); - return -1; - } - if (ret < 0) - return -1; - + if ((ret = index_storage_mailbox_create(box, directory)) <= 0) + return ret; /* the maildir is created now. finish the creation as best as we can */ if (create_maildir_subdirs(box, FALSE) < 0) ret = -1; diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Wed Sep 26 00:35:10 2012 +0300 @@ -534,9 +534,8 @@ { int fd, ret; - if (directory && - (box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0) - return 0; + if ((ret = index_storage_mailbox_create(box, directory)) <= 0) + return ret; if (box->inbox_any) { if (create_inbox(box) < 0) diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/index/shared/shared-list.c Wed Sep 26 00:35:10 2012 +0300 @@ -207,21 +207,6 @@ } static int -shared_list_create_mailbox_dir(struct mailbox_list *list, const char *name, - enum mailbox_dir_create_type type) -{ - struct mail_namespace *ns = list->ns; - int ret; - - if (shared_storage_get_namespace(&ns, &name) < 0) - return -1; - ret = ns->list->v.create_mailbox_dir(ns->list, name, type); - if (ret < 0) - shared_list_copy_error(list, ns); - return ret; -} - -static int shared_list_delete_mailbox(struct mailbox_list *list, const char *name) { struct mail_namespace *ns = list->ns; @@ -322,7 +307,6 @@ NULL, shared_list_subscriptions_refresh, shared_list_set_subscribed, - shared_list_create_mailbox_dir, shared_list_delete_mailbox, shared_list_delete_dir, shared_list_delete_symlink, diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Wed Sep 26 00:35:10 2012 +0300 @@ -163,61 +163,6 @@ name, set); } -static int mailbox_is_selectable(struct mailbox_list *list, const char *name) -{ - enum mailbox_info_flags flags; - - if (mailbox_list_mailbox(list, name, &flags) < 0) - return -1; - - return (flags & (MAILBOX_NOSELECT | MAILBOX_NONEXISTENT)) == 0 ? 1 : 0; -} - -static int -fs_list_create_mailbox_dir(struct mailbox_list *list, const char *name, - enum mailbox_dir_create_type type) -{ - struct mailbox_permissions perm; - const char *path, *p; - bool directory, create_parent_dir; - int ret; - - directory = type != MAILBOX_DIR_CREATE_TYPE_MAILBOX; - path = mailbox_list_get_path(list, name, - directory ? MAILBOX_LIST_PATH_TYPE_DIR : - MAILBOX_LIST_PATH_TYPE_MAILBOX); - create_parent_dir = !directory && - (list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0; - if (create_parent_dir) { - /* we only need to make sure that the parent directory exists */ - p = strrchr(path, '/'); - if (p == NULL) - return 0; - path = t_strdup_until(path, p); - } - - mailbox_list_get_permissions(list, name, &perm); - if (mkdir_parents_chgrp(path, perm.dir_create_mode, - perm.file_create_gid, - perm.file_create_gid_origin) == 0) - return 0; - else if (errno == EEXIST) { - if (create_parent_dir) - return 0; - if (!directory && *list->set.mailbox_dir_name == '\0') { - if ((ret = mailbox_is_selectable(list, name)) <= 0) - return ret; - } - mailbox_list_set_error(list, MAIL_ERROR_EXISTS, - "Mailbox already exists"); - } else if (errno == ENOTDIR) { - mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE, - "Mailbox doesn't allow inferior mailboxes"); - } else if (!mailbox_list_set_error_from_errno(list)) { - mailbox_list_set_critical(list, "mkdir(%s) failed: %m", path); - } - return -1; -} static const char *mailbox_list_fs_get_trash_dir(struct mailbox_list *list) { @@ -523,7 +468,6 @@ NULL, mailbox_list_subscriptions_refresh, fs_list_set_subscribed, - fs_list_create_mailbox_dir, fs_list_delete_mailbox, fs_list_delete_dir, mailbox_list_delete_symlink_default, diff -r f5514e09fd1e -r 6e90fc8dfa25 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Wed Sep 26 00:25:21 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Wed Sep 26 00:35:10 2012 +0300 @@ -342,17 +342,6 @@ } static int -mailbox_list_index_create_mailbox_dir(struct mailbox_list *list, - const char *name, - enum mailbox_dir_create_type type) -{ - struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list); - - mailbox_list_index_refresh_later(list); - return ilist->module_ctx.super.create_mailbox_dir(list, name, type); From dovecot at dovecot.org Wed Sep 26 00:39:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 00:39:03 +0300 Subject: dovecot-2.2: lib-storage: Allow mailbox name to begin with separ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/71fb4be2f666 changeset: 15113:71fb4be2f666 user: Timo Sirainen date: Wed Sep 26 00:38:45 2012 +0300 description: lib-storage: Allow mailbox name to begin with separator if mail_full_filesystem_access=yes diffstat: src/lib-storage/mail-storage.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diffs (42 lines): diff -r 6e90fc8dfa25 -r 71fb4be2f666 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Sep 26 00:35:10 2012 +0300 +++ b/src/lib-storage/mail-storage.c Wed Sep 26 00:38:45 2012 +0300 @@ -716,14 +716,9 @@ unsigned int i; bool prev_sep = FALSE; - if (vname[0] == sep) { - *error_r = "Begins with hierarchy separator"; - return FALSE; - } - /* Make sure the vname is correct: non-empty, doesn't begin or end with separator and no adjacent separators */ - for (i = 1; vname[i] != '\0'; i++) { + for (i = 0; vname[i] != '\0'; i++) { if (vname[i] == sep) { if (prev_sep) { *error_r = "Has adjacent hierarchy separators"; @@ -734,7 +729,7 @@ prev_sep = FALSE; } } - if (prev_sep) { + if (prev_sep && i > 0) { *error_r = "Ends with hierarchy separator"; return FALSE; } @@ -779,6 +774,13 @@ "Character not allowed in mailbox name: '%c'", list_sep)); return -1; } + if (vname[0] == ns_sep && + !box->storage->set->mail_full_filesystem_access) { + mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS, + "Invalid mailbox name: Begins with hierarchy separator"); + return -1; + } + if (!mailbox_name_verify_separators(vname, ns_sep, &error) || !mailbox_list_is_valid_name(box->list, box->name, &error)) { mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS, From dovecot at dovecot.org Wed Sep 26 01:47:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 01:47:47 +0300 Subject: dovecot-2.2: lib-storage: Invalid subscription entries weren't r... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/081b62bed2ea changeset: 15114:081b62bed2ea user: Timo Sirainen date: Wed Sep 26 00:56:08 2012 +0300 description: lib-storage: Invalid subscription entries weren't removed always with subscriptions=no namespaces. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 71fb4be2f666 -r 081b62bed2ea src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Wed Sep 26 00:38:45 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Wed Sep 26 00:56:08 2012 +0300 @@ -150,7 +150,7 @@ i_warning("Subscriptions file %s: " "Removing invalid entry: %s", path, name); - (void)subsfile_set_subscribed(dest_list, path, + (void)subsfile_set_subscribed(src_list, path, mailbox_list_get_temp_prefix(dest_list), name, FALSE); From dovecot at dovecot.org Wed Sep 26 01:47:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 01:47:47 +0300 Subject: dovecot-2.2: lib-storage: mailbox_list_get_root_permissions() no... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d0ca4c69ec76 changeset: 15115:d0ca4c69ec76 user: Timo Sirainen date: Wed Sep 26 01:38:59 2012 +0300 description: lib-storage: mailbox_list_get_root_permissions() now returns struct mailbox_permissions. diffstat: src/lib-storage/index/dbox-multi/mdbox-file.c | 14 +- src/lib-storage/index/dbox-multi/mdbox-map-private.h | 4 +- src/lib-storage/index/dbox-multi/mdbox-map.c | 11 +- src/lib-storage/list/mailbox-list-fs.c | 11 +- src/lib-storage/list/subscription-file.c | 18 ++-- src/lib-storage/mailbox-list-private.h | 7 +- src/lib-storage/mailbox-list.c | 78 +++++++------------ src/lib-storage/mailbox-list.h | 3 +- src/lib-storage/mailbox-uidvalidity.c | 18 ++-- src/plugins/acl/acl-backend-vfile-acllist.c | 16 ++- src/plugins/quota/quota-maildir.c | 25 +++-- 11 files changed, 94 insertions(+), 111 deletions(-) diffs (truncated from 488 to 300 lines): diff -r 081b62bed2ea -r d0ca4c69ec76 src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Wed Sep 26 00:56:08 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Wed Sep 26 01:38:59 2012 +0300 @@ -306,7 +306,7 @@ const char *p, *dir, *error; int fd; - old_mask = umask(0666 & ~map->create_mode); + old_mask = umask(0666 & ~map->perm.file_create_mode); fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); umask(old_mask); if (fd == -1 && errno == ENOENT && parents && @@ -322,25 +322,25 @@ return -1; } /* try again */ - old_mask = umask(0666 & ~map->create_mode); + old_mask = umask(0666 & ~map->perm.file_create_mode); fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); umask(old_mask); } if (fd == -1) { mail_storage_set_critical(&file->storage->storage, "open(%s, O_CREAT) failed: %m", path); - } else if (map->create_gid == (gid_t)-1) { + } else if (map->perm.file_create_gid == (gid_t)-1) { /* no group change */ - } else if (fchown(fd, (uid_t)-1, map->create_gid) < 0) { + } else if (fchown(fd, (uid_t)-1, map->perm.file_create_gid) < 0) { if (errno == EPERM) { mail_storage_set_critical(&file->storage->storage, "%s", eperm_error_get_chgrp("fchown", path, - map->create_gid, - map->create_gid_origin)); + map->perm.file_create_gid, + map->perm.file_create_gid_origin)); } else { mail_storage_set_critical(&file->storage->storage, "fchown(%s, -1, %ld) failed: %m", - path, (long)map->create_gid); + path, (long)map->perm.file_create_gid); } /* continue anyway */ } diff -r 081b62bed2ea -r d0ca4c69ec76 src/lib-storage/index/dbox-multi/mdbox-map-private.h --- a/src/lib-storage/index/dbox-multi/mdbox-map-private.h Wed Sep 26 00:56:08 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-map-private.h Wed Sep 26 01:38:59 2012 +0300 @@ -20,9 +20,7 @@ uint32_t map_ext_id, ref_ext_id; struct mailbox_list *root_list; - mode_t create_mode; - gid_t create_gid; - const char *create_gid_origin; + struct mailbox_permissions perm; unsigned int verify_existing_file_ids:1; }; diff -r 081b62bed2ea -r d0ca4c69ec76 src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Wed Sep 26 00:56:08 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Wed Sep 26 01:38:59 2012 +0300 @@ -50,7 +50,6 @@ { struct mdbox_map *map; const char *root, *index_root; - mode_t dir_mode; root = mailbox_list_get_root_path(root_list, MAILBOX_LIST_PATH_TYPE_DIR); index_root = mailbox_list_get_root_path(root_list, MAILBOX_LIST_PATH_TYPE_INDEX); @@ -76,12 +75,10 @@ map->ref_ext_id = mail_index_ext_register(map->index, "ref", 0, sizeof(uint16_t), sizeof(uint16_t)); - mailbox_list_get_root_permissions(root_list, - &map->create_mode, &dir_mode, - &map->create_gid, - &map->create_gid_origin); - mail_index_set_permissions(map->index, map->create_mode, - map->create_gid, map->create_gid_origin); + mailbox_list_get_root_permissions(root_list, &map->perm); + mail_index_set_permissions(map->index, map->perm.file_create_mode, + map->perm.file_create_gid, + map->perm.file_create_gid_origin); return map; } diff -r 081b62bed2ea -r d0ca4c69ec76 src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Wed Sep 26 00:56:08 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Wed Sep 26 01:38:59 2012 +0300 @@ -293,13 +293,12 @@ if (strcmp(oldparent, newparent) != 0 && stat(oldpath, &st) == 0) { /* make sure the newparent exists */ - mode_t file_mode, dir_mode; - gid_t gid; - const char *origin; + struct mailbox_permissions perm; - mailbox_list_get_root_permissions(newlist, &file_mode, - &dir_mode, &gid, &origin); - if (mkdir_parents_chgrp(newparent, dir_mode, gid, origin) < 0 && + mailbox_list_get_root_permissions(newlist, &perm); + if (mkdir_parents_chgrp(newparent, perm.dir_create_mode, + perm.file_create_gid, + perm.file_create_gid_origin) < 0 && errno != EEXIST) { if (mailbox_list_set_error_from_errno(oldlist)) return -1; diff -r 081b62bed2ea -r d0ca4c69ec76 src/lib-storage/list/subscription-file.c --- a/src/lib-storage/list/subscription-file.c Wed Sep 26 00:56:08 2012 +0300 +++ b/src/lib-storage/list/subscription-file.c Wed Sep 26 01:38:59 2012 +0300 @@ -88,12 +88,11 @@ const struct mail_storage_settings *mail_set = list->mail_set; struct dotlock_settings dotlock_set; struct dotlock *dotlock; - const char *line, *origin; + struct mailbox_permissions perm; + const char *line; struct istream *input; struct ostream *output; int fd_in, fd_out; - mode_t file_mode, dir_mode; - gid_t gid; bool found, changed = FALSE, failed = FALSE; if (strcasecmp(name, "INBOX") == 0) @@ -106,17 +105,20 @@ dotlock_set.timeout = SUBSCRIPTION_FILE_LOCK_TIMEOUT; dotlock_set.stale_timeout = SUBSCRIPTION_FILE_CHANGE_TIMEOUT; - mailbox_list_get_root_permissions(list, &file_mode, &dir_mode, - &gid, &origin); + mailbox_list_get_root_permissions(list, &perm); fd_out = file_dotlock_open_group(&dotlock_set, path, 0, - file_mode, gid, origin, &dotlock); + perm.file_create_mode, + perm.file_create_gid, + perm.file_create_gid_origin, &dotlock); if (fd_out == -1 && errno == ENOENT) { /* directory hasn't been created yet. */ if (mailbox_list_mkdir_parent(list, NULL, path) < 0) return -1; fd_out = file_dotlock_open_group(&dotlock_set, path, 0, - file_mode, gid, - origin, &dotlock); + perm.file_create_mode, + perm.file_create_gid, + perm.file_create_gid_origin, + &dotlock); } if (fd_out == -1) { if (errno == EAGAIN) { diff -r 081b62bed2ea -r d0ca4c69ec76 src/lib-storage/mailbox-list-private.h --- a/src/lib-storage/mailbox-list-private.h Wed Sep 26 00:56:08 2012 +0300 +++ b/src/lib-storage/mailbox-list-private.h Wed Sep 26 01:38:59 2012 +0300 @@ -105,11 +105,8 @@ const struct mail_storage_settings *mail_set; enum mailbox_list_flags flags; - /* -1 if not set yet. use mailbox_list_get_permissions() to set them */ - mode_t file_create_mode, dir_create_mode; - gid_t file_create_gid; - /* origin (e.g. path) where the file_create_gid was got from */ - const char *file_create_gid_origin; + /* may not be set yet, use mailbox_list_get_permissions() to access */ + struct mailbox_permissions root_permissions; struct mailbox_tree_context *subscriptions; time_t subscriptions_mtime, subscriptions_read_time; diff -r 081b62bed2ea -r d0ca4c69ec76 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Wed Sep 26 00:56:08 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Wed Sep 26 01:38:59 2012 +0300 @@ -138,9 +138,9 @@ list->ns = ns; list->mail_set = ns->mail_set; list->flags = flags; - list->file_create_mode = (mode_t)-1; - list->dir_create_mode = (mode_t)-1; - list->file_create_gid = (gid_t)-1; + list->root_permissions.file_create_mode = (mode_t)-1; + list->root_permissions.dir_create_mode = (mode_t)-1; + list->root_permissions.file_create_gid = (gid_t)-1; list->changelog_timestamp = (time_t)-1; /* copy settings */ @@ -741,10 +741,8 @@ } if (name == NULL) { - list->file_create_mode = permissions_r->file_create_mode; - list->dir_create_mode = permissions_r->dir_create_mode; - list->file_create_gid = permissions_r->file_create_gid; - list->file_create_gid_origin = + list->root_permissions = *permissions_r; + list->root_permissions.file_create_gid_origin = p_strdup(list->pool, permissions_r->file_create_gid_origin); } @@ -753,9 +751,9 @@ i_debug("Namespace %s: Using permissions from %s: " "mode=0%o gid=%ld", list->ns->prefix, path != NULL ? path : "", - (int)list->dir_create_mode, - list->file_create_gid == (gid_t)-1 ? -1L : - (long)list->file_create_gid); + (int)permissions_r->dir_create_mode, + permissions_r->file_create_gid == (gid_t)-1 ? -1L : + (long)permissions_r->file_create_gid); } } @@ -766,23 +764,13 @@ } void mailbox_list_get_root_permissions(struct mailbox_list *list, - mode_t *file_mode_r, mode_t *dir_mode_r, - gid_t *gid_r, const char **gid_origin_r) + struct mailbox_permissions *permissions_r) { - struct mailbox_permissions perm; - - if (list->file_create_mode != (mode_t)-1) { - *file_mode_r = list->file_create_mode; - *dir_mode_r = list->dir_create_mode; - *gid_r = list->file_create_gid; - *gid_origin_r = list->file_create_gid_origin; - } else { - mailbox_list_get_permissions_internal(list, NULL, &perm); - - *file_mode_r = perm.file_create_mode; - *dir_mode_r = perm.dir_create_mode; - *gid_r = perm.file_create_gid; - *gid_origin_r = perm.file_create_gid_origin; + if (list->root_permissions.file_create_mode != (mode_t)-1) + *permissions_r = list->root_permissions; + else { + mailbox_list_get_permissions_internal(list, NULL, + permissions_r); } } @@ -853,10 +841,9 @@ enum mailbox_list_path_type type, const char **error_r) { - const char *expanded, *unexpanded, *root_dir, *p, *origin, *error; + const char *expanded, *unexpanded, *root_dir, *p, *error; struct stat st; - mode_t file_mode, dir_mode; - gid_t gid; + struct mailbox_permissions perm; if (stat(path, &st) == 0) { /* looks like it already exists, don't bother checking @@ -870,8 +857,7 @@ return -1; } - mailbox_list_get_root_permissions(list, &file_mode, &dir_mode, - &gid, &origin); + mailbox_list_get_root_permissions(list, &perm); /* get the directory path up to last %variable. for example unexpanded path may be "/var/mail/%d/%2n/%n/Maildir", and we want @@ -906,15 +892,19 @@ return -1; } } - if (gid == (gid_t)-1 && (dir_mode & S_ISGID) == 0) { + if (perm.file_create_gid == (gid_t)-1 && + (perm.dir_create_mode & S_ISGID) == 0) { /* change the group for user directories */ - gid = getegid(); + perm.file_create_gid = getegid(); + perm.file_create_gid_origin = "egid"; } } /* the rest of the directories exist only for one user. create them with default directory permissions */ - if (mkdir_parents_chgrp(path, dir_mode, gid, origin) < 0 && + if (mkdir_parents_chgrp(path, perm.dir_create_mode, + perm.file_create_gid, + perm.file_create_gid_origin) < 0 && errno != EEXIST) { if (errno == EACCES) *error_r = mail_error_create_eacces_msg("mkdir", path); @@ -1187,10 +1177,8 @@ static bool mailbox_list_init_changelog(struct mailbox_list *list) { + struct mailbox_permissions perm; const char *path; - mode_t file_mode, dir_mode; - gid_t gid; - const char *gid_origin; if (list->changelog != NULL) return TRUE; @@ -1204,9 +1192,10 @@ From dovecot at dovecot.org Wed Sep 26 01:47:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 01:47:47 +0300 Subject: dovecot-2.2: lib-storage: Fixed creating selectable mailbox when... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/536b1643786e changeset: 15116:536b1643786e user: Timo Sirainen date: Wed Sep 26 01:47:21 2012 +0300 description: lib-storage: Fixed creating selectable mailbox when it was already \Noselect diffstat: src/lib-storage/index/index-storage.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (15 lines): diff -r d0ca4c69ec76 -r 536b1643786e src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed Sep 26 01:38:59 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Wed Sep 26 01:47:21 2012 +0300 @@ -499,9 +499,9 @@ /* For example: layout=fs, path=~/Maildir/foo might itself exist, but does it have the cur|new|tmp subdirs? */ - if (mailbox_exists(box, TRUE, &existence) < 0) + if (mailbox_exists(box, FALSE, &existence) < 0) return -1; - if (existence == MAILBOX_EXISTENCE_NONE) + if (existence != MAILBOX_EXISTENCE_SELECT) return 1; } mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, From dovecot at dovecot.org Wed Sep 26 02:31:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 02:31:46 +0300 Subject: dovecot-2.2: lib-storage: Make sure permissions are refreshed af... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3a694c8090a3 changeset: 15117:3a694c8090a3 user: Timo Sirainen date: Wed Sep 26 02:31:33 2012 +0300 description: lib-storage: Make sure permissions are refreshed after creating mailbox directory. diffstat: src/lib-storage/index/index-storage.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 536b1643786e -r 3a694c8090a3 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed Sep 26 01:47:21 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Wed Sep 26 02:31:33 2012 +0300 @@ -491,6 +491,7 @@ mail_storage_copy_list_error(box->storage, box->list); return -1; } + mailbox_refresh_permissions(box); if (ret == 0) { /* directory already exists */ if (create_parent_dir) From dovecot at dovecot.org Wed Sep 26 17:17:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 17:17:23 +0300 Subject: dovecot-2.2: lib-storage: Cleanups to mailbox mkdir() related fu... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/02d00843dd79 changeset: 15118:02d00843dd79 user: Timo Sirainen date: Wed Sep 26 17:11:22 2012 +0300 description: lib-storage: Cleanups to mailbox mkdir() related functions. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 8 +- src/lib-storage/index/dbox-multi/mdbox-file.c | 9 +- src/lib-storage/index/dbox-multi/mdbox-map.c | 29 +-- src/lib-storage/index/index-storage.c | 11 +- src/lib-storage/index/index-sync-pvt.c | 2 +- src/lib-storage/index/maildir/maildir-util.c | 14 +- src/lib-storage/list/subscription-file.c | 14 +- src/lib-storage/mail-storage-private.h | 10 + src/lib-storage/mail-storage.c | 65 ++++++- src/lib-storage/mailbox-list-private.h | 4 - src/lib-storage/mailbox-list.c | 205 +++++++--------------- src/lib-storage/mailbox-list.h | 21 +- src/plugins/acl/acl-backend-vfile-acllist.c | 16 +- src/plugins/fts-lucene/fts-backend-lucene.c | 7 +- 14 files changed, 199 insertions(+), 216 deletions(-) diffs (truncated from 723 to 300 lines): diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Wed Sep 26 17:11:22 2012 +0300 @@ -285,7 +285,7 @@ int dbox_verify_alt_storage(struct mailbox_list *list) { - const char *alt_path, *error; + const char *alt_path; struct stat st; alt_path = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_ALT_DIR); @@ -303,11 +303,7 @@ /* try to create the alt directory. if it fails, it means alt storage isn't mounted. */ if (mailbox_list_mkdir_root(list, alt_path, - MAILBOX_LIST_PATH_TYPE_ALT_DIR, - &error) < 0) { - i_error("Couldn't create dbox alt root dir %s: %s", - alt_path, error); + MAILBOX_LIST_PATH_TYPE_ALT_DIR) < 0) return -1; - } return 0; } diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Wed Sep 26 17:11:22 2012 +0300 @@ -303,7 +303,7 @@ struct mdbox_file *mfile = (struct mdbox_file *)file; struct mdbox_map *map = mfile->storage->map; mode_t old_mask; - const char *p, *dir, *error; + const char *p, *dir; int fd; old_mask = umask(0666 & ~map->perm.file_create_mode); @@ -315,10 +315,9 @@ if (mailbox_list_mkdir_root(map->root_list, dir, path != file->alt_path ? MAILBOX_LIST_PATH_TYPE_DIR : - MAILBOX_LIST_PATH_TYPE_ALT_DIR, - &error) < 0) { - mail_storage_set_critical(&file->storage->storage, - "Couldn't create %s: %s", dir, error); + MAILBOX_LIST_PATH_TYPE_ALT_DIR) < 0) { + mail_storage_copy_list_error(&file->storage->storage, + map->root_list); return -1; } /* try again */ diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Wed Sep 26 17:11:22 2012 +0300 @@ -98,34 +98,23 @@ i_free(map); } -static int mdbox_map_mkdir_storage_path(struct mdbox_map *map, const char *path) +static int mdbox_map_mkdir_storage(struct mdbox_map *map) { - struct stat st; + if (mailbox_list_mkdir_root(map->root_list, map->path, + MAILBOX_LIST_PATH_TYPE_DIR) < 0) { + mail_storage_copy_list_error(MAP_STORAGE(map), map->root_list); + return -1; + } - if (stat(path, &st) == 0) - return 1; - - if (mailbox_list_mkdir(map->root_list, NULL, path) < 0) { + if (strcmp(map->path, map->index_path) != 0 && + mailbox_list_mkdir_root(map->root_list, map->index_path, + MAILBOX_LIST_PATH_TYPE_INDEX) < 0) { mail_storage_copy_list_error(MAP_STORAGE(map), map->root_list); return -1; } return 0; } -static int mdbox_map_mkdir_storage(struct mdbox_map *map) -{ - int ret; - - if ((ret = mdbox_map_mkdir_storage_path(map, map->path)) < 0) - return -1; - - if (strcmp(map->path, map->index_path) != 0) { - if (mdbox_map_mkdir_storage_path(map, map->index_path) < 0) - return -1; - } - return ret; -} - static void mdbox_map_cleanup(struct mdbox_map *map) { unsigned int interval = diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Wed Sep 26 17:11:22 2012 +0300 @@ -192,7 +192,7 @@ if (box->index != NULL) return 0; - if (mailbox_list_create_missing_index_dir(box->list, box->name) < 0) { + if (mailbox_create_missing_dir(box, MAILBOX_LIST_PATH_TYPE_INDEX) < 0) { mail_storage_set_internal_error(box->storage); return -1; } @@ -464,13 +464,14 @@ int index_storage_mailbox_create(struct mailbox *box, bool directory) { const char *path, *p; + enum mailbox_list_path_type type; enum mailbox_existence existence; bool create_parent_dir; int ret; - path = mailbox_list_get_path(box->list, box->name, - directory ? MAILBOX_LIST_PATH_TYPE_DIR : - MAILBOX_LIST_PATH_TYPE_MAILBOX); + type = directory ? MAILBOX_LIST_PATH_TYPE_DIR : + MAILBOX_LIST_PATH_TYPE_MAILBOX; + path = mailbox_list_get_path(box->list, box->name, type); if (path == NULL) { /* layout=none */ mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, @@ -487,7 +488,7 @@ path = t_strdup_until(path, p); } - if ((ret = mailbox_list_mkdir(box->list, box->name, path)) < 0) { + if ((ret = mailbox_mkdir(box, path, type)) < 0) { mail_storage_copy_list_error(box->storage, box->list); return -1; } diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/index/index-sync-pvt.c --- a/src/lib-storage/index/index-sync-pvt.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/index/index-sync-pvt.c Wed Sep 26 17:11:22 2012 +0300 @@ -18,7 +18,7 @@ return 0; } - if (mailbox_list_create_missing_index_pvt_dir(box->list, box->name) < 0) { + if (mailbox_create_missing_dir(box, MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE) < 0) { mail_storage_set_internal_error(box->storage); return -1; } diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/index/maildir/maildir-util.c --- a/src/lib-storage/index/maildir/maildir-util.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-util.c Wed Sep 26 17:11:22 2012 +0300 @@ -167,7 +167,7 @@ enum mailbox_list_path_type type, bool retry) { const struct mailbox_permissions *perm = mailbox_get_permissions(box); - const char *p, *parent, *error; + const char *p, *parent; if (mkdir_chgrp(path, perm->dir_create_mode, perm->file_create_gid, perm->file_create_gid_origin) == 0) @@ -186,14 +186,12 @@ } /* create index/control root directory */ parent = t_strdup_until(path, p); - if (mailbox_list_mkdir_root(box->list, parent, type, &error) == 0) { - /* should work now, try again */ - return maildir_create_path(box, path, type, FALSE); + if (mailbox_list_mkdir_root(box->list, parent, type) < 0) { + mail_storage_copy_list_error(box->storage, box->list); + return -1; } - /* fall through */ - mail_storage_set_critical(box->storage, - "Couldn't create %s: %s", parent, error); - path = parent; + /* should work now, try again */ + return maildir_create_path(box, path, type, FALSE); default: mail_storage_set_critical(box->storage, "mkdir(%s) failed: %m", path); diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/list/subscription-file.c --- a/src/lib-storage/list/subscription-file.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/list/subscription-file.c Wed Sep 26 17:11:22 2012 +0300 @@ -89,10 +89,11 @@ struct dotlock_settings dotlock_set; struct dotlock *dotlock; struct mailbox_permissions perm; - const char *line; + const char *line, *dir, *fname; struct istream *input; struct ostream *output; int fd_in, fd_out; + enum mailbox_list_path_type type; bool found, changed = FALSE, failed = FALSE; if (strcasecmp(name, "INBOX") == 0) @@ -112,8 +113,15 @@ perm.file_create_gid_origin, &dotlock); if (fd_out == -1 && errno == ENOENT) { /* directory hasn't been created yet. */ - if (mailbox_list_mkdir_parent(list, NULL, path) < 0) - return -1; + type = list->set.control_dir != NULL ? + MAILBOX_LIST_PATH_TYPE_CONTROL : + MAILBOX_LIST_PATH_TYPE_DIR; + fname = strrchr(path, '/'); + if (fname != NULL) { + dir = t_strdup_until(path, fname); + if (mailbox_list_mkdir_root(list, dir, type) < 0) + return -1; + } fd_out = file_dotlock_open_group(&dotlock_set, path, 0, perm.file_create_mode, perm.file_create_gid, diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/mail-storage-private.h Wed Sep 26 17:11:22 2012 +0300 @@ -566,6 +566,16 @@ /* Force permissions to be refreshed on next lookup */ void mailbox_refresh_permissions(struct mailbox *box); +/* Create path's directory with proper permissions. The root directory is also + created if necessary. Returns 1 if created, 0 if it already existed, + -1 if error. */ +int mailbox_mkdir(struct mailbox *box, const char *path, + enum mailbox_list_path_type type); +/* Create a non-mailbox type directory for mailbox if it's missing (e.g. index). + Optimized for case where the directory usually exists. */ +int mailbox_create_missing_dir(struct mailbox *box, + enum mailbox_list_path_type type); + /* Returns -1 if error, 0 if failed with EEXIST, 1 if ok */ int mailbox_create_fd(struct mailbox *box, const char *path, int flags, int *fd_r); diff -r 3a694c8090a3 -r 02d00843dd79 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Sep 26 02:31:33 2012 +0300 +++ b/src/lib-storage/mail-storage.c Wed Sep 26 17:11:22 2012 +0300 @@ -257,9 +257,9 @@ autocreate = (flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) == 0; ret = mail_storage_verify_root(root_dir, autocreate, error_r); if (ret == 0) { - ret = mailbox_list_mkdir_root(list, root_dir, - MAILBOX_LIST_PATH_TYPE_MAILBOX, - error_r); + ret = mailbox_list_try_mkdir_root(list, root_dir, + MAILBOX_LIST_PATH_TYPE_MAILBOX, + error_r); } return ret < 0 ? -1 : 0; } @@ -1973,6 +1973,65 @@ return 1; } +int mailbox_mkdir(struct mailbox *box, const char *path, + enum mailbox_list_path_type type) +{ + struct mailbox_permissions perm; + const char *root_dir; + + mailbox_list_get_permissions(box->list, box->name, &perm); + if (!perm.gid_origin_is_mailbox_path) { + /* mailbox root directory doesn't exist, create it */ + root_dir = mailbox_list_get_root_path(box->list, type); + if (mailbox_list_mkdir_root(box->list, root_dir, type) < 0) { + mail_storage_copy_list_error(box->storage, box->list); + return -1; + } + } + + if (mkdir_parents_chgrp(path, perm.dir_create_mode, + perm.file_create_gid, + perm.file_create_gid_origin) == 0) + return 1; + else if (errno == EEXIST) + return 0; + else if (errno == ENOTDIR) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, + "Mailbox doesn't allow inferior mailboxes"); + return -1; + } else if (mail_storage_set_error_from_errno(box->storage)) { + return -1; + } else { + mail_storage_set_critical(box->storage, + "mkdir_parents(%s) failed: %m", path); + return -1; + } +} + +int mailbox_create_missing_dir(struct mailbox *box, + enum mailbox_list_path_type type) +{ + const char *mail_dir, *dir; + struct stat st; + + dir = mailbox_get_path_to(box, type); + mail_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX); + if (dir == NULL || *dir == '\0') + return 0; From dovecot at dovecot.org Wed Sep 26 17:17:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 17:17:23 +0300 Subject: dovecot-2.2: lib-storage: Cleanup, use the new mailbox_*() inste... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/981e0bc71742 changeset: 15119:981e0bc71742 user: Timo Sirainen date: Wed Sep 26 17:17:08 2012 +0300 description: lib-storage: Cleanup, use the new mailbox_*() instead of mailbox_list_*() when possible. diffstat: src/lib-storage/index/index-storage.c | 2 +- src/lib-storage/mail-storage.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diffs (42 lines): diff -r 02d00843dd79 -r 981e0bc71742 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed Sep 26 17:11:22 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Wed Sep 26 17:17:08 2012 +0300 @@ -471,7 +471,7 @@ type = directory ? MAILBOX_LIST_PATH_TYPE_DIR : MAILBOX_LIST_PATH_TYPE_MAILBOX; - path = mailbox_list_get_path(box->list, box->name, type); + path = mailbox_get_path_to(box, type); if (path == NULL) { /* layout=none */ mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, diff -r 02d00843dd79 -r 981e0bc71742 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Sep 26 17:11:22 2012 +0300 +++ b/src/lib-storage/mail-storage.c Wed Sep 26 17:17:08 2012 +0300 @@ -1976,11 +1976,10 @@ int mailbox_mkdir(struct mailbox *box, const char *path, enum mailbox_list_path_type type) { - struct mailbox_permissions perm; + const struct mailbox_permissions *perm = mailbox_get_permissions(box); const char *root_dir; - mailbox_list_get_permissions(box->list, box->name, &perm); - if (!perm.gid_origin_is_mailbox_path) { + if (!perm->gid_origin_is_mailbox_path) { /* mailbox root directory doesn't exist, create it */ root_dir = mailbox_list_get_root_path(box->list, type); if (mailbox_list_mkdir_root(box->list, root_dir, type) < 0) { @@ -1989,9 +1988,9 @@ } } - if (mkdir_parents_chgrp(path, perm.dir_create_mode, - perm.file_create_gid, - perm.file_create_gid_origin) == 0) + if (mkdir_parents_chgrp(path, perm->dir_create_mode, + perm->file_create_gid, + perm->file_create_gid_origin) == 0) return 1; else if (errno == EEXIST) return 0; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: lib-storage: Don't crash when trying to detect publ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6b9db780b47d changeset: 15120:6b9db780b47d user: Timo Sirainen date: Fri Aug 31 16:17:23 2012 +0300 description: lib-storage: Don't crash when trying to detect public namespace's mail_location. Public namespaces have no owner. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage.c | 3 ++- src/lib-storage/index/dbox-single/sdbox-storage.c | 3 ++- src/lib-storage/index/maildir/maildir-storage.c | 3 ++- src/lib-storage/index/mbox/mbox-storage.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diffs (52 lines): diff -r 67235781cc08 -r 6b9db780b47d src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Thu Aug 30 21:56:43 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Fri Aug 31 16:17:23 2012 +0300 @@ -87,7 +87,8 @@ bool debug = ns->mail_set->mail_debug; const char *home, *path; - if (mail_user_get_home(ns->owner, &home) > 0) { + if (ns->owner != NULL && + mail_user_get_home(ns->owner, &home) > 0) { path = t_strconcat(home, "/mdbox", NULL); if (access(path, R_OK|W_OK|X_OK) == 0) { if (debug) diff -r 67235781cc08 -r 6b9db780b47d src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Aug 30 21:56:43 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Fri Aug 31 16:17:23 2012 +0300 @@ -34,7 +34,8 @@ bool debug = ns->mail_set->mail_debug; const char *home, *path; - if (mail_user_get_home(ns->owner, &home) > 0) { + if (ns->owner != NULL && + mail_user_get_home(ns->owner, &home) > 0) { path = t_strconcat(home, "/sdbox", NULL); if (access(path, R_OK|W_OK|X_OK) == 0) { if (debug) diff -r 67235781cc08 -r 6b9db780b47d src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Thu Aug 30 21:56:43 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Fri Aug 31 16:17:23 2012 +0300 @@ -97,7 +97,8 @@ /* we'll need to figure out the maildir location ourself. It's ~/Maildir unless we are chrooted. */ - if (mail_user_get_home(ns->owner, &home) > 0) { + if (ns->owner != NULL && + mail_user_get_home(ns->owner, &home) > 0) { path = t_strconcat(home, "/Maildir", NULL); if (access(path, R_OK|W_OK|X_OK) == 0) { if (debug) diff -r 67235781cc08 -r 6b9db780b47d src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Thu Aug 30 21:56:43 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Fri Aug 31 16:17:23 2012 +0300 @@ -246,7 +246,8 @@ bool debug = ns->mail_set->mail_debug; const char *home, *path; - if (mail_user_get_home(ns->owner, &home) <= 0) { + if (ns->owner != NULL && + mail_user_get_home(ns->owner, &home) <= 0) { if (debug) i_debug("maildir: Home directory not set"); home = ""; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: mbox: Fix to previous public namespace location det... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5625ab0a3eed changeset: 15121:5625ab0a3eed user: Timo Sirainen date: Fri Aug 31 16:19:21 2012 +0300 description: mbox: Fix to previous public namespace location detection crashfix. diffstat: src/lib-storage/index/mbox/mbox-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 6b9db780b47d -r 5625ab0a3eed src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Fri Aug 31 16:17:23 2012 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Fri Aug 31 16:19:21 2012 +0300 @@ -246,7 +246,7 @@ bool debug = ns->mail_set->mail_debug; const char *home, *path; - if (ns->owner != NULL && + if (ns->owner == NULL || mail_user_get_home(ns->owner, &home) <= 0) { if (debug) i_debug("maildir: Home directory not set"); From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: Various fixes to listing mailboxes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d079d72abb79 changeset: 15122:d079d72abb79 user: Timo Sirainen date: Sun Sep 02 16:06:45 2012 +0300 description: Various fixes to listing mailboxes. Some of these are a bit kludgy, v2.2 has a larger rewrite of the code to implement them more nicely. diffstat: src/imap/cmd-list.c | 89 +++++++++++++++++++++++----- src/lib-storage/list/mailbox-list-fs-iter.c | 7 ++ 2 files changed, 79 insertions(+), 17 deletions(-) diffs (209 lines): diff -r 5625ab0a3eed -r d079d72abb79 src/imap/cmd-list.c --- a/src/imap/cmd-list.c Fri Aug 31 16:19:21 2012 +0300 +++ b/src/imap/cmd-list.c Sun Sep 02 16:06:45 2012 +0300 @@ -35,6 +35,9 @@ unsigned int used_status:1; }; +static bool mailbox_list_match_anything(struct cmd_list_context *ctx, + struct mail_namespace *ns); + static void mailbox_flags2str(struct cmd_list_context *ctx, string_t *str, const char *special_use, enum mailbox_info_flags flags) @@ -207,7 +210,58 @@ return flags; } -static bool list_namespace_has_children(struct cmd_list_context *ctx) +static bool +ns_prefix_is_visible(struct cmd_list_context *ctx, + struct mail_namespace *ns) +{ + if ((ns->flags & NAMESPACE_FLAG_LIST_PREFIX) != 0) + return TRUE; + if ((ns->flags & NAMESPACE_FLAG_LIST_CHILDREN) != 0) { + if (mailbox_list_match_anything(ctx, ns)) + return TRUE; + } + return FALSE; +} + +static bool +ns_prefix_has_visible_child_namespace(struct cmd_list_context *ctx, + const char *prefix) +{ + struct mail_namespace *ns; + unsigned int prefix_len = strlen(prefix); + + for (ns = ctx->ns->user->namespaces; ns != NULL; ns = ns->next) { + if (ns->prefix_len > prefix_len && + strncmp(ns->prefix, prefix, prefix_len) == 0 && + ns_prefix_is_visible(ctx, ns)) + return TRUE; + } + return FALSE; +} + +static bool +mailbox_ns_prefix_is_shared_inbox(struct mail_namespace *ns) +{ + const struct mail_storage_settings *set; + struct mail_storage *storage; + + mailbox_list_get_closest_storage(ns->list, &storage); + set = mail_storage_get_settings(storage); + return ns->type == NAMESPACE_SHARED && + (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 && + !set->mail_shared_explicit_inbox; +} + +static bool +mailbox_is_shared_inbox(struct mail_namespace *ns, const char *vname) +{ + return mailbox_ns_prefix_is_shared_inbox(ns) && + strncmp(ns->prefix, vname, ns->prefix_len-1) == 0 && + vname[ns->prefix_len-1] == '\0'; +} + +static bool mailbox_list_match_anything(struct cmd_list_context *ctx, + struct mail_namespace *ns) { enum mailbox_list_iter_flags list_flags = MAILBOX_LIST_ITER_RETURN_NO_FLAGS; @@ -215,18 +269,22 @@ const struct mailbox_info *info; bool ret = FALSE; - if ((ctx->list_flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) - list_flags |= MAILBOX_LIST_ITER_SELECT_SUBSCRIBED; - - list_iter = mailbox_list_iter_init(ctx->ns->list, - t_strconcat(ctx->ns->prefix, "%", NULL), list_flags); + list_iter = mailbox_list_iter_init(ns->list, + t_strconcat(ns->prefix, "%", NULL), list_flags); info = mailbox_list_iter_next(list_iter); + if (info != NULL && mailbox_ns_prefix_is_shared_inbox(ns) && + mailbox_is_shared_inbox(ns, info->name)) { + /* we don't want to see this, try the next one */ + info = mailbox_list_iter_next(list_iter); + } if (info != NULL) ret = TRUE; if (mailbox_list_iter_deinit(&list_iter) < 0) { /* safer to answer TRUE in error conditions */ ret = TRUE; } + if (!ret && ns_prefix_has_visible_child_namespace(ctx, ns->prefix)) + ret = TRUE; return ret; } @@ -248,17 +306,14 @@ struct imap_match_glob *glob; enum imap_match_result match; const char *ns_prefix, *p; - bool inboxcase; unsigned int skip_len; skip_len = strlen(ctx->ref); if (strncmp(ctx->ns->prefix, ctx->ref, skip_len) != 0) skip_len = 0; - inboxcase = strncasecmp(ctx->ns->prefix, "INBOX", 5) == 0 && - ctx->ns->prefix[5] == mail_namespace_get_sep(ctx->ns); glob = imap_match_init_multiple(pool_datastack_create(), - ctx->patterns, inboxcase, + ctx->patterns, TRUE, mail_namespace_get_sep(ctx->ns)); ns_prefix = ctx->ns->prefix + skip_len; match = imap_match(glob, ns_prefix); @@ -344,7 +399,7 @@ } if ((flags & MAILBOX_CHILDREN) == 0) { - if (have_children || list_namespace_has_children(ctx)) { + if (have_children || mailbox_list_match_anything(ctx, ctx->ns)) { flags |= MAILBOX_CHILDREN; flags &= ~MAILBOX_NOCHILDREN; } else { @@ -471,7 +526,7 @@ ctx->inbox_found = TRUE; } if (ctx->cur_ns_send_prefix) - list_namespace_send_prefix(ctx, TRUE); + list_namespace_send_prefix(ctx, FALSE); /* if there's a list=yes namespace with this name, list it as having children */ @@ -673,10 +728,11 @@ } static bool -list_namespace_match_pattern(struct cmd_list_context *ctx, bool inboxcase, +list_namespace_match_pattern(struct cmd_list_context *ctx, const char *cur_ref, const char *cur_ns_prefix, const char *cur_pattern) { + const char *orig_cur_ns_prefix = cur_ns_prefix; const char *orig_cur_pattern = cur_pattern; struct mail_namespace *ns = ctx->ns; struct imap_match_glob *pat_glob; @@ -698,6 +754,7 @@ } return TRUE; } + cur_ns_prefix = orig_cur_ns_prefix; /* namespace prefix still wasn't completely skipped over. for example cur_ns_prefix=INBOX/, pattern=%/% or pattern=IN%. @@ -722,7 +779,7 @@ /* check if this namespace prefix matches the current pattern */ pat_glob = imap_match_init(pool_datastack_create(), orig_cur_pattern, - inboxcase, mail_namespace_get_sep(ns)); + TRUE, mail_namespace_get_sep(ns)); match = imap_match(pat_glob, cur_ns_prefix); if (match == IMAP_MATCH_YES) { if (list_want_send_prefix(ctx, orig_cur_pattern)) @@ -764,7 +821,6 @@ const char *cur_ns_prefix, *cur_ref, *const *pat, *pattern; enum imap_match_result inbox_match; ARRAY_DEFINE(used_patterns, const char *); - bool inboxcase; cur_ns_prefix = ns->prefix; cur_ref = ctx->ref; @@ -782,14 +838,13 @@ inbox_match = list_use_inboxcase(ctx); ctx->cur_ns_match_inbox = inbox_match == IMAP_MATCH_YES; - inboxcase = (inbox_match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) != 0; t_array_init(&used_patterns, 16); for (pat = ctx->patterns; *pat != NULL; pat++) { pattern = *pat; /* see if pattern even has a chance of matching the namespace prefix */ - if (list_namespace_match_pattern(ctx, inboxcase, cur_ref, + if (list_namespace_match_pattern(ctx, cur_ref, cur_ns_prefix, pattern)) { pattern = mailbox_list_join_refpattern(ns->list, ctx->ref, pattern); diff -r 5625ab0a3eed -r d079d72abb79 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Fri Aug 31 16:19:21 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Sun Sep 02 16:06:45 2012 +0300 @@ -771,6 +771,13 @@ if (ret <= 0) return NULL; + if (_ctx->list->ns->type == NAMESPACE_SHARED && + !_ctx->list->ns->list->mail_set->mail_shared_explicit_inbox && + strlen(ctx->info.name) < _ctx->list->ns->prefix_len) { + /* shared/user INBOX, IMAP code already lists it */ + return fs_list_iter_next(_ctx); + } + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_RETURN_SUBSCRIBED) != 0) { mailbox_list_set_subscription_flags(ctx->ctx.list, ctx->info.name, From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: lib-storage: Added "disabled" setting for namespaces. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0ee2f712b489 changeset: 15123:0ee2f712b489 user: Timo Sirainen date: Tue Sep 04 17:18:08 2012 +0300 description: lib-storage: Added "disabled" setting for namespaces. diffstat: src/lib-storage/mail-namespace.c | 3 +++ src/lib-storage/mail-storage-settings.c | 2 ++ src/lib-storage/mail-storage-settings.h | 1 + 3 files changed, 6 insertions(+), 0 deletions(-) diffs (43 lines): diff -r d079d72abb79 -r 0ee2f712b489 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Sun Sep 02 16:06:45 2012 +0300 +++ b/src/lib-storage/mail-namespace.c Tue Sep 04 17:18:08 2012 +0300 @@ -293,6 +293,9 @@ count = 0; } for (i = 0; i < count; i++) { + if (ns_set[i]->disabled) + continue; + if (namespace_add(user, ns_set[i], unexpanded_ns_set[i], mail_set, ns_p, error_r) < 0) { if (!ns_set[i]->ignore_on_failure) diff -r d079d72abb79 -r 0ee2f712b489 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Sun Sep 02 16:06:45 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.c Tue Sep 04 17:18:08 2012 +0300 @@ -154,6 +154,7 @@ DEF(SET_ENUM, list), DEF(SET_BOOL, subscriptions), DEF(SET_BOOL, ignore_on_failure), + DEF(SET_BOOL, disabled), DEFLIST_UNIQUE(mailboxes, "mailbox", &mailbox_setting_parser_info), @@ -173,6 +174,7 @@ .list = "yes:no:children", .subscriptions = TRUE, .ignore_on_failure = FALSE, + .disabled = FALSE, .mailboxes = ARRAY_INIT }; diff -r d079d72abb79 -r 0ee2f712b489 src/lib-storage/mail-storage-settings.h --- a/src/lib-storage/mail-storage-settings.h Sun Sep 02 16:06:45 2012 +0300 +++ b/src/lib-storage/mail-storage-settings.h Tue Sep 04 17:18:08 2012 +0300 @@ -54,6 +54,7 @@ const char *list; bool subscriptions; bool ignore_on_failure; + bool disabled; ARRAY_DEFINE(mailboxes, struct mailbox_settings *); struct mail_user_settings *user_set; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: doveadm: Added exec command to easily execute comma... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cb3f49b649bf changeset: 15124:cb3f49b649bf user: Timo Sirainen date: Thu Sep 06 16:50:00 2012 +0300 description: doveadm: Added exec command to easily execute commands from libexec_dir. For example: doveadm exec imap -u user at domain diffstat: src/doveadm/Makefile.am | 1 + src/doveadm/doveadm-settings.c | 2 ++ src/doveadm/doveadm-settings.h | 1 + src/doveadm/doveadm.c | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 0 deletions(-) diffs (74 lines): diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/Makefile.am Thu Sep 06 16:50:00 2012 +0300 @@ -22,6 +22,7 @@ -DDOVEADM_MODULEDIR=\""$(doveadm_moduledir)"\" \ -DPKG_RUNDIR=\""$(rundir)"\" \ -DPKG_STATEDIR=\""$(statedir)"\" \ + -DPKG_LIBEXECDIR=\""$(pkglibexecdir)"\" \ -DBINDIR=\""$(bindir)"\" \ -DMANDIR=\""$(mandir)"\" diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/doveadm-settings.c --- a/src/doveadm/doveadm-settings.c Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/doveadm-settings.c Thu Sep 06 16:50:00 2012 +0300 @@ -53,6 +53,7 @@ static const struct setting_define doveadm_setting_defines[] = { DEF(SET_STR, base_dir), + DEF(SET_STR, libexec_dir), DEF(SET_STR, mail_plugins), DEF(SET_STR, mail_plugin_dir), DEF(SET_STR, doveadm_socket_path), @@ -70,6 +71,7 @@ const struct doveadm_settings doveadm_default_settings = { .base_dir = PKG_RUNDIR, + .libexec_dir = PKG_LIBEXECDIR, .mail_plugins = "", .mail_plugin_dir = MODULEDIR, .doveadm_socket_path = "doveadm-server", diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/doveadm-settings.h --- a/src/doveadm/doveadm-settings.h Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/doveadm-settings.h Thu Sep 06 16:50:00 2012 +0300 @@ -3,6 +3,7 @@ struct doveadm_settings { const char *base_dir; + const char *libexec_dir; const char *mail_plugins; const char *mail_plugin_dir; const char *doveadm_socket_path; diff -r 0ee2f712b489 -r cb3f49b649bf src/doveadm/doveadm.c --- a/src/doveadm/doveadm.c Tue Sep 04 17:18:08 2012 +0300 +++ b/src/doveadm/doveadm.c Thu Sep 06 16:50:00 2012 +0300 @@ -174,6 +174,21 @@ cmd_config, "config", "[doveconf parameters]" }; +static void cmd_exec(int argc ATTR_UNUSED, char *argv[]) +{ + const char *path, *binary = argv[1]; + + path = t_strdup_printf("%s/%s", doveadm_settings->libexec_dir, binary); + argv++; + argv[0] = t_strdup_noconst(path); + (void)execv(argv[0], argv); + i_fatal("execv(%s) failed: %m", argv[0]); +} + +static struct doveadm_cmd doveadm_cmd_exec = { + cmd_exec, "exec", " [binary parameters]" +}; + static bool doveadm_try_run_multi_word(const struct doveadm_cmd *cmd, const char *cmdname, int argc, char *argv[]) @@ -269,6 +284,7 @@ static struct doveadm_cmd *doveadm_commands[] = { &doveadm_cmd_help, &doveadm_cmd_config, + &doveadm_cmd_exec, &doveadm_cmd_stop, &doveadm_cmd_reload, &doveadm_cmd_dump, From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: acl: Don't add sameuser -> sameuser entries to ACL ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3eaeacc85b4c changeset: 15125:3eaeacc85b4c user: Timo Sirainen date: Tue Sep 11 17:13:51 2012 +0300 description: acl: Don't add sameuser -> sameuser entries to ACL dict. diffstat: src/plugins/acl/acl-lookup-dict.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diffs (29 lines): diff -r cb3f49b649bf -r 3eaeacc85b4c src/plugins/acl/acl-lookup-dict.c --- a/src/plugins/acl/acl-lookup-dict.c Thu Sep 06 16:50:00 2012 +0300 +++ b/src/plugins/acl/acl-lookup-dict.c Tue Sep 11 17:13:51 2012 +0300 @@ -92,6 +92,13 @@ } } +static bool +acl_rights_is_same_user(const struct acl_rights *right, struct mail_user *user) +{ + return right->id_type == ACL_ID_USER && + strcmp(right->identifier, user->username) == 0; +} + static int acl_lookup_dict_rebuild_add_backend(struct mail_namespace *ns, ARRAY_TYPE(const_string) *ids) { @@ -115,7 +122,10 @@ iter = acl_object_list_init(aclobj); while ((ret = acl_object_list_next(iter, &rights)) > 0) { - if (acl_rights_has_nonowner_lookup_changes(&rights)) { + /* avoid pointless user -> user entries, + which some clients do */ + if (acl_rights_has_nonowner_lookup_changes(&rights) && + !acl_rights_is_same_user(&rights, ns->owner)) { str_truncate(id, 0); acl_lookup_dict_write_rights_id(id, &rights); str_append_c(id, '/'); From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: lib-master: Decrease initial memory pool size Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f3d532a4feb6 changeset: 15126:f3d532a4feb6 user: Timo Sirainen date: Tue Sep 11 18:26:33 2012 +0300 description: lib-master: Decrease initial memory pool size diffstat: src/lib-master/master-service-settings-cache.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 3eaeacc85b4c -r f3d532a4feb6 src/lib-master/master-service-settings-cache.c --- a/src/lib-master/master-service-settings-cache.c Tue Sep 11 17:13:51 2012 +0300 +++ b/src/lib-master/master-service-settings-cache.c Tue Sep 11 18:26:33 2012 +0300 @@ -59,7 +59,8 @@ struct master_service_settings_cache *cache; pool_t pool; - pool = pool_alloconly_create("master service settings cache", 1024*32); + pool = pool_alloconly_create(MEMPOOL_GROWING"master service settings cache", + 1024*12); cache = p_new(pool, struct master_service_settings_cache, 1); cache->pool = pool; cache->service = service; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: Decrease minimum memory allocations. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9f691edba099 changeset: 15127:9f691edba099 user: Timo Sirainen date: Tue Sep 11 18:42:05 2012 +0300 description: Decrease minimum memory allocations. This is mainly to avoid wasting settings-related memory for IMAP processes. Probably something more radical should be done at some point. diffstat: src/lib-imap/imap-parser.c | 2 +- src/lib-settings/settings-parser.c | 4 ++-- src/lib-storage/mail-storage-service.c | 2 +- src/lib/hash.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diffs (57 lines): diff -r f3d532a4feb6 -r 9f691edba099 src/lib-imap/imap-parser.c --- a/src/lib-imap/imap-parser.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib-imap/imap-parser.c Tue Sep 11 18:42:05 2012 +0300 @@ -59,7 +59,7 @@ parser = i_new(struct imap_parser, 1); parser->refcount = 1; parser->pool = pool_alloconly_create(MEMPOOL_GROWING"IMAP parser", - 1024*10); + 1024); parser->input = input; parser->output = output; parser->max_line_size = max_line_size; diff -r f3d532a4feb6 -r 9f691edba099 src/lib-settings/settings-parser.c --- a/src/lib-settings/settings-parser.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib-settings/settings-parser.c Tue Sep 11 18:42:05 2012 +0300 @@ -201,7 +201,7 @@ i_assert(count > 0); parser_pool = pool_alloconly_create(MEMPOOL_GROWING"settings parser", - 8192); + 1024); ctx = p_new(parser_pool, struct setting_parser_context, 1); ctx->set_pool = set_pool; ctx->parser_pool = parser_pool; @@ -1741,7 +1741,7 @@ pool_ref(new_pool); parser_pool = pool_alloconly_create(MEMPOOL_GROWING"dup settings parser", - 8192); + 1024); new_ctx = p_new(parser_pool, struct setting_parser_context, 1); new_ctx->set_pool = new_pool; new_ctx->parser_pool = parser_pool; diff -r f3d532a4feb6 -r 9f691edba099 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Sep 11 18:42:05 2012 +0300 @@ -945,7 +945,7 @@ pool_t user_pool, temp_pool; int ret = 1; - user_pool = pool_alloconly_create("mail storage service user", 1024*8); + user_pool = pool_alloconly_create("mail storage service user", 1024*6); if (mail_storage_service_read_settings(ctx, input, user_pool, &user_info, &set_parser, diff -r f3d532a4feb6 -r 9f691edba099 src/lib/hash.c --- a/src/lib/hash.c Tue Sep 11 18:26:33 2012 +0300 +++ b/src/lib/hash.c Tue Sep 11 18:42:05 2012 +0300 @@ -8,7 +8,7 @@ #include -#define HASH_TABLE_MIN_SIZE 131 +#define HASH_TABLE_MIN_SIZE 67 struct hash_node { struct hash_node *next; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: lib-storage: Fixed memory leak getting MAILBOX_META... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3e1f1b6887c8 changeset: 15128:3e1f1b6887c8 user: Dafan Zhai date: Tue Sep 11 19:14:09 2012 +0300 description: lib-storage: Fixed memory leak getting MAILBOX_METADATA_VIRTUAL_SIZE Function virtual_size_add_new forgets to free the 'search_args' object after it searches the mails. --- src/lib-storage/index/index-status.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffstat: src/lib-storage/index/index-status.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 9f691edba099 -r 3e1f1b6887c8 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Tue Sep 11 18:42:05 2012 +0300 +++ b/src/lib-storage/index/index-status.c Tue Sep 11 19:14:09 2012 +0300 @@ -217,6 +217,7 @@ } if (mailbox_search_deinit(&search_ctx) < 0) ret = -1; + mail_search_args_unref(&search_args); if (ret == 0) { /* success, cache all */ From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: imapc: Fixed parsing "text" input after OK/NO/BAD/BYE. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/245fe7fd6f00 changeset: 15130:245fe7fd6f00 user: Timo Sirainen date: Tue Sep 11 20:45:38 2012 +0300 description: imapc: Fixed parsing "text" input after OK/NO/BAD/BYE. diffstat: src/lib-imap-client/imapc-connection.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diffs (51 lines): diff -r 382df961f290 -r 245fe7fd6f00 src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Tue Sep 11 20:44:37 2012 +0300 +++ b/src/lib-imap-client/imapc-connection.c Tue Sep 11 20:45:38 2012 +0300 @@ -493,7 +493,8 @@ ret = imap_parser_read_args(conn->parser, 0, IMAP_PARSE_FLAG_LITERAL_SIZE | - IMAP_PARSE_FLAG_ATOM_ALLCHARS, imap_args_r); + IMAP_PARSE_FLAG_ATOM_ALLCHARS | + IMAP_PARSE_FLAG_SERVER_TEXT, imap_args_r); if (ret == -2) { /* need more data */ return 0; @@ -813,6 +814,9 @@ if ((ret = imapc_connection_read_line(conn, &imap_args)) <= 0) return ret; + /* we already verified that the banner beigns with OK */ + i_assert(imap_arg_atom_equals(imap_args, "OK")); + imap_args++; if (imapc_connection_handle_imap_resp_text(conn, imap_args, &key, &value) < 0) @@ -836,6 +840,8 @@ static int imapc_connection_input_untagged(struct imapc_connection *conn) { const struct imap_arg *imap_args; + const unsigned char *data; + size_t size; const char *name, *value; struct imap_parser *parser; struct imapc_untagged_reply reply; @@ -843,13 +849,13 @@ if (conn->state == IMAPC_CONNECTION_STATE_CONNECTING) { /* input banner */ - name = imap_parser_read_word(conn->parser); - if (name == NULL) + data = i_stream_get_data(conn->input, &size); + if (size < 3 && memchr(data, '\n', size) == NULL) return 0; - - if (strcasecmp(name, "OK") != 0) { + if (i_memcasecmp(data, "OK ", 3) != 0) { imapc_connection_input_error(conn, - "Banner doesn't begin with OK: %s", name); + "Banner doesn't begin with OK: %s", + t_strcut(t_strndup(data, size), '\n')); return -1; } conn->input_callback = imapc_connection_input_banner; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: lib-imap: Added IMAP_PARSE_FLAG_SERVER_TEXT that fi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/382df961f290 changeset: 15129:382df961f290 user: Timo Sirainen date: Tue Sep 11 20:44:37 2012 +0300 description: lib-imap: Added IMAP_PARSE_FLAG_SERVER_TEXT that fixes parsing input from IMAP server. diffstat: src/lib-imap/imap-parser.c | 78 +++++++++++++++++++++++++++++++++++++++++++++- src/lib-imap/imap-parser.h | 6 ++- 2 files changed, 82 insertions(+), 2 deletions(-) diffs (160 lines): diff -r 3e1f1b6887c8 -r 382df961f290 src/lib-imap/imap-parser.c --- a/src/lib-imap/imap-parser.c Tue Sep 11 19:14:09 2012 +0300 +++ b/src/lib-imap/imap-parser.c Tue Sep 11 20:44:37 2012 +0300 @@ -17,7 +17,8 @@ ARG_PARSE_STRING, ARG_PARSE_LITERAL, ARG_PARSE_LITERAL_DATA, - ARG_PARSE_LITERAL_DATA_FORCED + ARG_PARSE_LITERAL_DATA_FORCED, + ARG_PARSE_TEXT }; struct imap_parser { @@ -37,6 +38,7 @@ enum arg_parse_type cur_type; size_t cur_pos; /* parser position in input buffer */ + bool cur_resp_text; /* we're parsing [resp-text-code] */ int str_first_escape; /* ARG_PARSE_STRING: index to first '\' */ uoff_t literal_size; /* ARG_PARSE_LITERAL: string size */ @@ -100,6 +102,7 @@ parser->cur_type = ARG_PARSE_NONE; parser->cur_pos = 0; + parser->cur_resp_text = FALSE; parser->str_first_escape = 0; parser->literal_size = 0; @@ -210,6 +213,7 @@ switch (parser->cur_type) { case ARG_PARSE_ATOM: + case ARG_PARSE_TEXT: if (size == 3 && memcmp(data, "NIL", 3) == 0) { /* NIL argument */ arg->type = IMAP_ARG_NIL; @@ -468,6 +472,56 @@ } } +static bool imap_parser_is_next_resp_text(struct imap_parser *parser) +{ + const struct imap_arg *arg; + + if (parser->cur_list != &parser->root_list || + array_count(parser->cur_list) != 1) + return FALSE; + + arg = array_idx(&parser->root_list, 0); + if (arg->type != IMAP_ARG_ATOM) + return FALSE; + + return strcasecmp(arg->_data.str, "OK") == 0 || + strcasecmp(arg->_data.str, "NO") == 0 || + strcasecmp(arg->_data.str, "BAD") == 0 || + strcasecmp(arg->_data.str, "BYE") == 0; +} + +static bool imap_parser_is_next_text(struct imap_parser *parser) +{ + const struct imap_arg *arg; + unsigned int len; + + if (parser->cur_list != &parser->root_list) + return FALSE; + + arg = array_idx(&parser->root_list, array_count(&parser->root_list)-1); + if (arg->type != IMAP_ARG_ATOM) + return FALSE; + + len = strlen(arg->_data.str); + return len > 0 && arg->_data.str[len-1] == ']'; +} + +static bool imap_parser_read_text(struct imap_parser *parser, + const unsigned char *data, size_t data_size) +{ + size_t i; + + /* read until end of line */ + for (i = parser->cur_pos; i < data_size; i++) { + if (is_linebreak(data[i])) { + imap_parser_save_arg(parser, data, i); + break; + } + } + parser->cur_pos = i; + return parser->cur_type == ARG_PARSE_NONE; +} + /* Returns TRUE if argument was fully processed. Also returns TRUE if an argument inside a list was processed. */ static int imap_parser_read_arg(struct imap_parser *parser) @@ -485,6 +539,13 @@ return FALSE; i_assert(parser->cur_pos == 0); + if (parser->cur_resp_text && + imap_parser_is_next_text(parser)) { + /* we just parsed [resp-text-code] */ + parser->cur_type = ARG_PARSE_TEXT; + break; + } + switch (data[0]) { case '\r': if (data_size == 1) { @@ -538,6 +599,16 @@ case ARG_PARSE_ATOM: if (!imap_parser_read_atom(parser, data, data_size)) return FALSE; + if ((parser->flags & IMAP_PARSE_FLAG_SERVER_TEXT) == 0) + break; + + if (imap_parser_is_next_resp_text(parser)) { + /* we just parsed OK/NO/BAD/BYE. after parsing the + [resp-text-code] the rest of the message can contain + pretty much any random text, which we can't parse + as if it was valid IMAP input */ + parser->cur_resp_text = TRUE; + } break; case ARG_PARSE_STRING: if (!imap_parser_read_string(parser, data, data_size)) @@ -557,6 +628,10 @@ if (!imap_parser_read_literal_data(parser, data, data_size)) return FALSE; break; + case ARG_PARSE_TEXT: + if (!imap_parser_read_text(parser, data, data_size)) + return FALSE; + break; default: i_unreached(); } @@ -579,6 +654,7 @@ parser->line_size += parser->cur_pos; i_stream_skip(parser->input, parser->cur_pos); parser->cur_pos = 0; + parser->cur_resp_text = FALSE; if (parser->list_arg != NULL && !parser->literal_size_return) { parser->error = "Missing ')'"; diff -r 3e1f1b6887c8 -r 382df961f290 src/lib-imap/imap-parser.h --- a/src/lib-imap/imap-parser.h Tue Sep 11 19:14:09 2012 +0300 +++ b/src/lib-imap/imap-parser.h Tue Sep 11 20:44:37 2012 +0300 @@ -16,7 +16,11 @@ /* Don't check if atom contains invalid characters */ IMAP_PARSE_FLAG_ATOM_ALLCHARS = 0x08, /* Allow strings to contain CRLFs */ - IMAP_PARSE_FLAG_MULTILINE_STR = 0x10 + IMAP_PARSE_FLAG_MULTILINE_STR = 0x10, + /* We're parsing IMAP server replies. Parse the "text" after + OK/NO/BAD/BYE replies as a single atom. We assume that the initial + "*" or tag was already skipped over. */ + IMAP_PARSE_FLAG_SERVER_TEXT = 0x20 }; struct imap_parser; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: director: Improved logging related to disconnections. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/27d3289e1f5c changeset: 15132:27d3289e1f5c user: Timo Sirainen date: Wed Sep 12 00:20:47 2012 +0300 description: director: Improved logging related to disconnections. diffstat: src/director/director-connection.c | 135 ++++++++++++++++++++++++++---------- src/director/director-connection.h | 3 +- src/director/director.c | 9 +- src/director/director.h | 4 +- 4 files changed, 109 insertions(+), 42 deletions(-) diffs (truncated from 359 to 300 lines): diff -r 24e791bbcf69 -r 27d3289e1f5c src/director/director-connection.c --- a/src/director/director-connection.c Wed Sep 12 00:04:34 2012 +0300 +++ b/src/director/director-connection.c Wed Sep 12 00:20:47 2012 +0300 @@ -71,6 +71,8 @@ mark the host as failed so we won't try to reconnect to it immediately */ #define DIRECTOR_SUCCESS_MIN_CONNECT_SECS 40 #define DIRECTOR_WAIT_DISCONNECT_SECS 10 +#define DIRECTOR_HANDSHAKE_WARN_SECS 29 +#define DIRECTOR_HANDSHAKE_BYTES_LOG_MIN_SECS (60*30) #if DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS <= DIRECTOR_CONNECTION_PING_TIMEOUT_MSECS # error DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS is too low @@ -92,6 +94,8 @@ /* for incoming connections the director host isn't known until ME-line is received */ struct director_host *host; + /* this is set only for wrong connections: */ + struct director_host *connect_request_to; int fd; struct io *io; @@ -118,7 +122,9 @@ }; static void director_connection_disconnected(struct director_connection **conn); -static void director_connection_reconnect(struct director_connection **conn); +static void director_connection_reconnect(struct director_connection **conn, + const char *reason); +static void director_connection_log_disconnect(struct director_connection *conn); static void ATTR_FORMAT(2, 3) director_cmd_error(struct director_connection *conn, const char *fmt, ...) @@ -169,7 +175,9 @@ static void director_connection_wait_timeout(struct director_connection *conn) { - director_connection_deinit(&conn); + director_connection_log_disconnect(conn); + director_connection_deinit(&conn, + "Timeout waiting for disconnect after CONNECT"); } static void director_connection_send_connect(struct director_connection *conn, @@ -186,6 +194,12 @@ (void)o_stream_flush(conn->output); o_stream_uncork(conn->output); + /* wait for a while for the remote to disconnect, so it will hopefully + see our CONNECT command. we'll also log the warning later to avoid + multiple log lines about it. */ + conn->connect_request_to = host; + director_host_ref(conn->connect_request_to); + conn->to_disconnect = timeout_add(DIRECTOR_WAIT_DISCONNECT_SECS*1000, director_connection_wait_timeout, conn); @@ -220,10 +234,10 @@ } else if (dir->left == NULL) { /* no conflicts yet */ } else if (dir->left->host == conn->host) { - i_info("Dropping existing connection %s " - "in favor of its new connection %s", - dir->left->host->name, conn->host->name); - director_connection_deinit(&dir->left); + i_warning("Replacing left director connection %s with %s", + dir->left->host->name, conn->host->name); + director_connection_deinit(&dir->left, t_strdup_printf( + "Replacing with %s", conn->host->name)); } else if (dir->left->verifying_left) { /* we're waiting to verify if our current left is still working. if we don't receive a PONG, the current left @@ -235,9 +249,6 @@ dir->self_host) < 0) { /* the old connection is the correct one. refer the client there (FIXME: do we ever get here?) */ - i_warning("Director connection %s tried to connect to " - "us, should use %s instead", - conn->name, dir->left->host->name); director_connection_send_connect(conn, dir->left->host); return TRUE; } else { @@ -267,7 +278,8 @@ /* either use this or disconnect it */ if (!director_connection_assign_left(conn)) { /* we don't want this */ - director_connection_deinit(&conn); + director_connection_deinit(&conn, + "Unwanted incoming connection"); director_assign_left(dir); break; } @@ -304,9 +316,10 @@ conn->wrong_host = TRUE; return FALSE; } - i_info("Replacing right director connection %s with %s", - dir->right->host->name, conn->host->name); - director_connection_deinit(&dir->right); + i_warning("Replacing right director connection %s with %s", + dir->right->host->name, conn->host->name); + director_connection_deinit(&dir->right, t_strdup_printf( + "Replacing with %s", conn->host->name)); } dir->right = conn; i_free(conn->name); @@ -410,7 +423,8 @@ } else if (dir->left->host == conn->host) { /* b) */ i_assert(dir->left != conn); - director_connection_deinit(&dir->left); + director_connection_deinit(&dir->left, + "Replacing with new incoming connection"); } else if (director_host_cmp_to_self(conn->host, dir->left->host, dir->self_host) < 0) { /* c) */ @@ -919,14 +933,19 @@ static bool director_handshake_cmd_done(struct director_connection *conn) { struct director *dir = conn->dir; + unsigned int handshake_secs = time(NULL) - conn->created; + string_t *str; - if (dir->debug) { - unsigned int secs = time(NULL)-conn->created; - - i_debug("director(%s): Handshake took %u secs, " - "bytes in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, - conn->name, secs, conn->input->v_offset, - conn->output->offset); + if (handshake_secs >= DIRECTOR_HANDSHAKE_WARN_SECS || dir->debug) { + str = t_str_new(128); + str_printfa(str, "director(%s): Handshake took %u secs, " + "bytes in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, + conn->name, handshake_secs, conn->input->v_offset, + conn->output->offset); + if (handshake_secs >= DIRECTOR_HANDSHAKE_WARN_SECS) + i_warning("%s", str_c(str)); + else + i_debug("%s", str_c(str)); } /* the host is up now, make sure we can connect to it immediately @@ -1143,12 +1162,8 @@ if (conn->in && conn != dir->left && conn->me_received && conn->to_disconnect == NULL && director_host_cmp_to_self(dir->left->host, conn->host, - dir->self_host) < 0) { - i_warning("Director connection %s tried to connect to " - "us, should use %s instead", - conn->name, dir->left->host->name); + dir->self_host) < 0) director_connection_send_connect(conn, dir->left->host); - } } } @@ -1220,6 +1235,11 @@ return director_connection_sync(conn, args); if (strcmp(cmd, "CONNECT") == 0) return director_cmd_connect(conn, args); + if (strcmp(cmd, "QUIT") == 0) { + i_warning("Director %s disconnected us with reason: %s", + conn->name, t_strarray_join(args, " ")); + return FALSE; + } director_cmd_error(conn, "Unknown command %s", cmd); return FALSE; @@ -1247,6 +1267,37 @@ return ret; } +static void +director_connection_log_disconnect(struct director_connection *conn) +{ + unsigned int secs = ioloop_time - conn->created; + string_t *str = t_str_new(128); + + i_assert(conn->connected); + + if (conn->connect_request_to != NULL) { + i_warning("Director %s tried to connect to us, " + "should use %s instead", + conn->name, conn->connect_request_to->name); + return; + } + + str_printfa(str, "Director %s disconnected: ", conn->name); + str_append(str, "Connection closed"); + if (errno != 0 && errno != EPIPE) + str_printfa(str, ": %m"); + + str_printfa(str, " (connected %u secs, " + "in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, + secs, conn->input->v_offset, conn->output->offset); + + if (!conn->me_received) + str_append(str, ", handshake ME not received"); + else if (!conn->handshake_received) + str_append(str, ", handshake DONE not received"); + i_error("%s", str_c(str)); +} + static void director_connection_input(struct director_connection *conn) { struct director *dir = conn->dir; @@ -1258,16 +1309,14 @@ return; case -1: /* disconnected */ - i_error("Director %s disconnected%s", conn->name, - conn->handshake_received ? "" : - " before handshake finished"); + director_connection_log_disconnect(conn); director_connection_disconnected(&conn); return; case -2: /* buffer full */ director_cmd_error(conn, "Director sent us more than %d bytes", MAX_INBUF_SIZE); - director_connection_reconnect(&conn); + director_connection_reconnect(&conn, "Too long input line"); return; } @@ -1289,7 +1338,8 @@ } T_END; if (!ret) { - director_connection_reconnect(&conn); + director_connection_reconnect(&conn, t_strdup_printf( + "Invalid input: %s", line)); break; } } @@ -1474,7 +1524,8 @@ return conn; } -void director_connection_deinit(struct director_connection **_conn) +void director_connection_deinit(struct director_connection **_conn, + const char *remote_reason) { struct director_connection *const *conns, *conn = *_conn; struct director *dir = conn->dir; @@ -1482,8 +1533,15 @@ *_conn = NULL; - if (dir->debug && conn->host != NULL) - i_debug("Disconnecting from %s", conn->host->name); + if (dir->debug && conn->host != NULL) { + i_debug("Disconnecting from %s: %s", + conn->host->name, remote_reason); + } + if (*remote_reason != '\0' && + conn->minor_version >= DIRECTOR_VERSION_QUIT) { + o_stream_send_str(conn->output, t_strdup_printf( + "QUIT\t%s\n", remote_reason)); + } conns = array_get(&dir->connections, &count); for (i = 0; i < count; i++) { @@ -1504,6 +1562,8 @@ if (conn->host != NULL) director_host_unref(conn->host); + if (conn->connect_request_to != NULL) + director_host_unref(conn->connect_request_to); if (conn->user_iter != NULL) user_directory_iter_deinit(&conn->user_iter); if (conn->to_disconnect != NULL) @@ -1542,17 +1602,18 @@ conn->host->last_network_failure = ioloop_time; } - director_connection_deinit(_conn); + director_connection_deinit(_conn, ""); if (dir->right == NULL) director_connect(dir); } -void director_connection_reconnect(struct director_connection **_conn) +static void director_connection_reconnect(struct director_connection **_conn, + const char *reason) { struct director_connection *conn = *_conn; struct director *dir = conn->dir; - director_connection_deinit(_conn); + director_connection_deinit(_conn, reason); if (dir->right == NULL) director_connect(dir); } diff -r 24e791bbcf69 -r 27d3289e1f5c src/director/director-connection.h --- a/src/director/director-connection.h Wed Sep 12 00:04:34 2012 +0300 +++ b/src/director/director-connection.h Wed Sep 12 00:20:47 2012 +0300 @@ -10,7 +10,8 @@ struct director_connection * director_connection_init_out(struct director *dir, int fd, From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: director: Already seen USER-WEAK command caused dir... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/24e791bbcf69 changeset: 15131:24e791bbcf69 user: Timo Sirainen date: Wed Sep 12 00:04:34 2012 +0300 description: director: Already seen USER-WEAK command caused director to disconnect. diffstat: src/director/director-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 245fe7fd6f00 -r 24e791bbcf69 src/director/director-connection.c --- a/src/director/director-connection.c Tue Sep 11 20:45:38 2012 +0300 +++ b/src/director/director-connection.c Wed Sep 12 00:04:34 2012 +0300 @@ -712,7 +712,7 @@ int ret; if ((ret = director_cmd_is_seen(conn, &args, &dir_host)) != 0) - return FALSE; + return ret > 0; if (str_array_length(args) != 2 || str_to_uint(args[0], &username_hash) < 0 || From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: pop3c: Fetching message size could have returned wr... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8cec3b4c43ca changeset: 15133:8cec3b4c43ca user: Timo Sirainen date: Fri Sep 14 20:51:02 2012 +0300 description: pop3c: Fetching message size could have returned wrong value diffstat: src/lib-storage/index/pop3c/pop3c-mail.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 27d3289e1f5c -r 8cec3b4c43ca src/lib-storage/index/pop3c/pop3c-mail.c --- a/src/lib-storage/index/pop3c/pop3c-mail.c Wed Sep 12 00:20:47 2012 +0300 +++ b/src/lib-storage/index/pop3c/pop3c-mail.c Fri Sep 14 20:51:02 2012 +0300 @@ -30,7 +30,7 @@ struct message_size hdr_size, body_size; struct istream *input; - if (mail->data.virtual_size != 0) { + if (mail->data.virtual_size != (uoff_t)-1) { /* virtual size is already known. it's the same as our (correct) physical size */ *size_r = mail->data.virtual_size; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: lib-storage: MAILBOX_LIST_ITER_SKIP_ALIASES now ski... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/eff1d11ce14b changeset: 15134:eff1d11ce14b user: Timo Sirainen date: Tue Sep 18 18:40:17 2012 +0300 description: lib-storage: MAILBOX_LIST_ITER_SKIP_ALIASES now skips also "alias symlinks" An "alias symlink" is a symlink that points to the same directory. These can safely be skipped when iterating through all mails in all mailboxes (unlike other symlinks that may point to external storages). diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 6 ++++ src/lib-storage/list/mailbox-list-maildir-iter.c | 5 +++ src/lib-storage/mailbox-guid-cache.c | 1 + src/lib-storage/mailbox-list-private.h | 3 ++ src/lib-storage/mailbox-list.c | 33 ++++++++++++++++++++++++ src/lib-storage/mailbox-list.h | 4 ++- 6 files changed, 51 insertions(+), 1 deletions(-) diffs (112 lines): diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Tue Sep 18 18:40:17 2012 +0300 @@ -183,6 +183,12 @@ /* mailbox doesn't match any patterns, we don't care about it */ return 0; } + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SKIP_ALIASES) != 0) { + ret = mailbox_list_dirent_is_alias_symlink(ctx->ctx.list, + dir_path, d); + if (ret != 0) + return ret < 0 ? -1 : 0; + } ret = ctx->ctx.list->v. get_mailbox_flags(ctx->ctx.list, dir_path, d->d_name, mailbox_list_get_file_type(d), &info_flags); diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/list/mailbox-list-maildir-iter.c --- a/src/lib-storage/list/mailbox-list-maildir-iter.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-maildir-iter.c Tue Sep 18 18:40:17 2012 +0300 @@ -323,6 +323,11 @@ if (maildir_delete_trash_dir(ctx, fname)) return 0; + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_SKIP_ALIASES) != 0) { + ret = mailbox_list_dirent_is_alias_symlink(list, ctx->dir, d); + if (ret != 0) + return ret < 0 ? -1 : 0; + } T_BEGIN { ret = list->v.get_mailbox_flags(list, ctx->dir, fname, mailbox_list_get_file_type(d), &flags); diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-guid-cache.c --- a/src/lib-storage/mailbox-guid-cache.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-guid-cache.c Tue Sep 18 18:40:17 2012 +0300 @@ -56,6 +56,7 @@ list->guid_cache_errors = FALSE; ctx = mailbox_list_iter_init(list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_NO_AUTO_BOXES); while ((info = mailbox_list_iter_next(ctx)) != NULL) { if ((info->flags & diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-list-private.h --- a/src/lib-storage/mailbox-list-private.h Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-list-private.h Tue Sep 18 18:40:17 2012 +0300 @@ -192,6 +192,9 @@ bool mailbox_list_name_is_too_large(const char *name, char sep); enum mailbox_list_file_type mailbox_list_get_file_type(const struct dirent *d); +int mailbox_list_dirent_is_alias_symlink(struct mailbox_list *list, + const char *dir_path, + const struct dirent *d); bool mailbox_list_try_get_absolute_path(struct mailbox_list *list, const char **name); int mailbox_list_create_missing_index_dir(struct mailbox_list *list, diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Sep 18 18:40:17 2012 +0300 @@ -1282,6 +1282,39 @@ return type; } +int mailbox_list_dirent_is_alias_symlink(struct mailbox_list *list, + const char *dir_path, + const struct dirent *d) +{ + struct stat st; + int ret; + + if (mailbox_list_get_file_type(d) == MAILBOX_LIST_FILE_TYPE_SYMLINK) + return 1; + + T_BEGIN { + const char *path, *readlink; + + path = t_strconcat(dir_path, "/", d->d_name, NULL); + if (lstat(path, &st) < 0) { + mailbox_list_set_critical(list, + "lstat(%s) failed: %m", path); + ret = -1; + } else if (!S_ISLNK(st.st_mode)) { + ret = 0; + } else if (t_readlink(path, &linkpath) < 0) { + i_error("readlink(%s) failed: %m", path); + ret = -1; + } else { + /* it's an alias only if it points to the same + directory */ + ret = strchr(linkpath, '/') == NULL ? 1 : 0; + } + } T_END; + return ret; +} + + static bool mailbox_list_try_get_home_path(struct mailbox_list *list, const char **name) { diff -r 8cec3b4c43ca -r eff1d11ce14b src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Fri Sep 14 20:51:02 2012 +0300 +++ b/src/lib-storage/mailbox-list.h Tue Sep 18 18:40:17 2012 +0300 @@ -64,7 +64,9 @@ physically exist */ MAILBOX_LIST_ITER_NO_AUTO_BOXES = 0x000004, - /* For mailbox_list_iter_init_namespaces(): Skip namespaces that + /* Skip all kinds of mailbox aliases. This typically includes symlinks + that point to the same directory. Also when iterating with + mailbox_list_iter_init_namespaces() skip namespaces that have alias_for set. */ MAILBOX_LIST_ITER_SKIP_ALIASES = 0x000008, /* For mailbox_list_iter_init_namespaces(): '*' in a pattern doesn't From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: quota: Skip alias symlinks when calculating quota Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1937b38f50f0 changeset: 15135:1937b38f50f0 user: Timo Sirainen date: Tue Sep 18 18:40:46 2012 +0300 description: quota: Skip alias symlinks when calculating quota diffstat: src/plugins/quota/quota-count.c | 1 + src/plugins/quota/quota-maildir.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diffs (22 lines): diff -r eff1d11ce14b -r 1937b38f50f0 src/plugins/quota/quota-count.c --- a/src/plugins/quota/quota-count.c Tue Sep 18 18:40:17 2012 +0300 +++ b/src/plugins/quota/quota-count.c Tue Sep 18 18:40:46 2012 +0300 @@ -71,6 +71,7 @@ int ret = 0; ctx = mailbox_list_iter_init(ns->list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_RETURN_NO_FLAGS); while ((info = mailbox_list_iter_next(ctx)) != NULL) { if ((info->flags & (MAILBOX_NONEXISTENT | diff -r eff1d11ce14b -r 1937b38f50f0 src/plugins/quota/quota-maildir.c --- a/src/plugins/quota/quota-maildir.c Tue Sep 18 18:40:17 2012 +0300 +++ b/src/plugins/quota/quota-maildir.c Tue Sep 18 18:40:46 2012 +0300 @@ -131,6 +131,7 @@ ctx->path = str_new(default_pool, 512); ctx->list = list; ctx->iter = mailbox_list_iter_init(list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_RETURN_NO_FLAGS); return ctx; } From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: Added mailbox-alias plugin. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f5bb9f6b304d changeset: 15137:f5bb9f6b304d user: Timo Sirainen date: Tue Sep 18 18:44:46 2012 +0300 description: Added mailbox-alias plugin. Aliases can be created like: plugin { mailbox_alias_old = Sent mailbox_alias_new = Sent Messages mailbox_alias_old2 = Sent mailbox_alias_new2 = Sent Items } When creating an alias, the original mailbox is also created. The alias itself is a symlink to the original. Deleting an alias deletes the symlink. The original mailbox can't be deleted or renamed while it has aliases. Aliases cannot be renamed. Aliases are skipped when recalculating quota. If a mailbox with the alias's name was already created before the aliasing was enabled, it's not treated as alias until it's first deleted. diffstat: configure.in | 1 + src/plugins/Makefile.am | 1 + src/plugins/mailbox-alias/Makefile.am | 18 + src/plugins/mailbox-alias/mailbox-alias-plugin.c | 335 +++++++++++++++++++++++ src/plugins/mailbox-alias/mailbox-alias-plugin.h | 7 + 5 files changed, 362 insertions(+), 0 deletions(-) diffs (truncated from 394 to 300 lines): diff -r 45773a09dcf2 -r f5bb9f6b304d configure.in --- a/configure.in Tue Sep 18 18:41:01 2012 +0300 +++ b/configure.in Tue Sep 18 18:44:46 2012 +0300 @@ -2806,6 +2806,7 @@ src/plugins/lazy-expunge/Makefile src/plugins/listescape/Makefile src/plugins/mail-log/Makefile +src/plugins/mailbox-alias/Makefile src/plugins/notify/Makefile src/plugins/pop3-migration/Makefile src/plugins/quota/Makefile diff -r 45773a09dcf2 -r f5bb9f6b304d src/plugins/Makefile.am --- a/src/plugins/Makefile.am Tue Sep 18 18:41:01 2012 +0300 +++ b/src/plugins/Makefile.am Tue Sep 18 18:44:46 2012 +0300 @@ -21,6 +21,7 @@ listescape \ notify \ mail-log \ + mailbox-alias \ quota \ imap-quota \ pop3-migration \ diff -r 45773a09dcf2 -r f5bb9f6b304d src/plugins/mailbox-alias/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins/mailbox-alias/Makefile.am Tue Sep 18 18:44:46 2012 +0300 @@ -0,0 +1,18 @@ +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-imap \ + -I$(top_srcdir)/src/lib-index \ + -I$(top_srcdir)/src/lib-storage + +NOPLUGIN_LDFLAGS = +lib20_mailbox_alias_plugin_la_LDFLAGS = -module -avoid-version + +module_LTLIBRARIES = \ + lib20_mailbox_alias_plugin.la + +lib20_mailbox_alias_plugin_la_SOURCES = \ + mailbox-alias-plugin.c + +noinst_HEADERS = \ + mailbox-alias-plugin.h diff -r 45773a09dcf2 -r f5bb9f6b304d src/plugins/mailbox-alias/mailbox-alias-plugin.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins/mailbox-alias/mailbox-alias-plugin.c Tue Sep 18 18:44:46 2012 +0300 @@ -0,0 +1,335 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "str.h" +#include "mail-storage-hooks.h" +#include "mail-storage-private.h" +#include "mailbox-list-private.h" +#include "mailbox-alias-plugin.h" + +#define MAILBOX_ALIAS_USER_CONTEXT(obj) \ + MODULE_CONTEXT(obj, mailbox_alias_user_module) +#define MAILBOX_ALIAS_CONTEXT(obj) \ + MODULE_CONTEXT(obj, mailbox_alias_storage_module) +#define MAILBOX_ALIAS_LIST_CONTEXT(obj) \ + MODULE_CONTEXT(obj, mailbox_alias_mailbox_list_module) + +struct mailbox_alias { + const char *old_vname, *new_vname; +}; + +struct mailbox_alias_user { + union mail_user_module_context module_ctx; + + ARRAY_DEFINE(aliases, struct mailbox_alias); +}; + +struct mailbox_alias_mailbox_list { + union mailbox_list_module_context module_ctx; +}; + +struct mailbox_alias_mailbox { + union mailbox_module_context module_ctx; +}; + +enum mailbox_symlink_existence { + MAILBOX_SYMLINK_EXISTENCE_NONEXISTENT, + MAILBOX_SYMLINK_EXISTENCE_SYMLINK, + MAILBOX_SYMLINK_EXISTENCE_NOT_SYMLINK +}; + +static MODULE_CONTEXT_DEFINE_INIT(mailbox_alias_user_module, + &mail_user_module_register); +static MODULE_CONTEXT_DEFINE_INIT(mailbox_alias_storage_module, + &mail_storage_module_register); +static MODULE_CONTEXT_DEFINE_INIT(mailbox_alias_mailbox_list_module, + &mailbox_list_module_register); + +const char *mailbox_alias_plugin_version = DOVECOT_VERSION; + +static const char * +mailbox_alias_find_new(struct mail_user *user, const char *new_vname) +{ + struct mailbox_alias_user *auser = MAILBOX_ALIAS_USER_CONTEXT(user); + const struct mailbox_alias *alias; + + array_foreach(&auser->aliases, alias) { + if (strcmp(alias->new_vname, new_vname) == 0) + return alias->old_vname; + } + return NULL; +} + +static int mailbox_symlink_exists(struct mailbox_list *list, const char *vname, + enum mailbox_symlink_existence *existence_r) +{ + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(list); + struct stat st; + const char *symlink_name, *symlink_path; + + symlink_name = alist->module_ctx.super.get_storage_name(list, vname); + symlink_path = mailbox_list_get_path(list, symlink_name, + MAILBOX_LIST_PATH_TYPE_DIR); + if (lstat(symlink_path, &st) < 0) { + if (errno == ENOENT) { + *existence_r = MAILBOX_SYMLINK_EXISTENCE_NONEXISTENT; + return 0; + } + mailbox_list_set_critical(list, + "lstat(%s) failed: %m", symlink_path); + return -1; + } + if (S_ISLNK(st.st_mode)) + *existence_r = MAILBOX_SYMLINK_EXISTENCE_SYMLINK; + else + *existence_r = MAILBOX_SYMLINK_EXISTENCE_NOT_SYMLINK; + return 0; +} + +static int mailbox_is_alias_symlink(struct mailbox *box) +{ + enum mailbox_symlink_existence existence; + + if (mailbox_alias_find_new(box->storage->user, box->vname) == NULL) + return 0; + if (mailbox_symlink_exists(box->list, box->vname, &existence) < 0) { + mail_storage_copy_list_error(box->storage, box->list); + return -1; + } + return existence == MAILBOX_SYMLINK_EXISTENCE_SYMLINK ? 1 : 0; +} + +static int +mailbox_has_aliases(struct mailbox_list *list, const char *old_vname) +{ + struct mailbox_alias_user *auser = + MAILBOX_ALIAS_USER_CONTEXT(list->ns->user); + const struct mailbox_alias *alias; + enum mailbox_symlink_existence existence; + int ret = 0; + + array_foreach(&auser->aliases, alias) { + if (strcmp(alias->old_vname, old_vname) == 0) { + if (mailbox_symlink_exists(list, alias->new_vname, + &existence) < 0) + ret = -1; + if (existence == MAILBOX_SYMLINK_EXISTENCE_SYMLINK) + return 1; + } + } + return ret; +} + +static int +mailbox_alias_create_symlink(struct mailbox *box, + const char *old_name, const char *new_name) +{ + const char *old_path, *new_path, *fname; + + old_path = mailbox_list_get_path(box->list, old_name, + MAILBOX_LIST_PATH_TYPE_DIR); + new_path = mailbox_list_get_path(box->list, new_name, + MAILBOX_LIST_PATH_TYPE_DIR); + fname = strrchr(old_path, '/'); + i_assert(fname != NULL); + fname++; + i_assert(strncmp(new_path, old_path, fname-old_path) == 0); + + if (symlink(fname, new_path) < 0) { + if (errno == EEXIST) { + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "Mailbox already exists"); + return -1; + } + mail_storage_set_critical(box->storage, + "symlink(%s, %s) failed: %m", fname, new_path); + return -1; + } + return 0; +} + +static const char * +mailbox_alias_get_storage_name(struct mailbox_list *list, const char *vname) +{ + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(list); + const char *old_vname; + enum mailbox_symlink_existence existence; + + /* access the old mailbox so that e.g. full text search won't + index the mailbox twice. this also means that deletion must be + careful to delete the symlink, box->name. */ + old_vname = mailbox_alias_find_new(list->ns->user, vname); + if (old_vname != NULL && + mailbox_symlink_exists(list, vname, &existence) == 0 && + existence != MAILBOX_SYMLINK_EXISTENCE_NOT_SYMLINK) + vname = old_vname; + + return alist->module_ctx.super.get_storage_name(list, vname); +} + +static int +mailbox_alias_create(struct mailbox *box, const struct mailbox_update *update, + bool directory) +{ + struct mailbox_alias_mailbox *abox = MAILBOX_ALIAS_CONTEXT(box); + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(box->list); + const char *symlink_name; + int ret; + + ret = abox->module_ctx.super.create(box, update, directory); + if (mailbox_alias_find_new(box->storage->user, box->vname) == NULL) + return ret; + if (ret < 0 && mailbox_get_last_mail_error(box) != MAIL_ERROR_EXISTS) + return ret; + + /* all the code so far has actually only created the original + mailbox. now we'll create the symlink if it's missing. */ + symlink_name = alist->module_ctx.super. + get_storage_name(box->list, box->vname); + return mailbox_alias_create_symlink(box, box->name, symlink_name); +} + +static int mailbox_alias_delete(struct mailbox *box) +{ + struct mailbox_alias_mailbox *abox = MAILBOX_ALIAS_CONTEXT(box); + struct mailbox_alias_mailbox_list *alist = + MAILBOX_ALIAS_LIST_CONTEXT(box->list); + const char *symlink_name; + int ret; + + ret = mailbox_has_aliases(box->list, box->vname); + if (ret < 0) + return -1; + if (ret > 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't delete mailbox while it has aliases"); + return -1; + } + + if (mailbox_is_alias_symlink(box)) { + /* we're deleting an alias mailbox. we'll need to handle this + explicitly since box->name points to the original mailbox */ + symlink_name = alist->module_ctx.super. + get_storage_name(box->list, box->vname); + if (mailbox_list_delete_symlink(box->list, symlink_name) < 0) { + mail_storage_copy_list_error(box->storage, box->list); + return -1; + } + return 0; + } + + return abox->module_ctx.super.delete(box); +} + +static int mailbox_alias_rename(struct mailbox *src, struct mailbox *dest, + bool rename_children) +{ + struct mailbox_alias_mailbox *abox = MAILBOX_ALIAS_CONTEXT(src); + int ret; + + if (mailbox_is_alias_symlink(src)) { + mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't rename alias mailboxes"); + return -1; + } + if (mailbox_is_alias_symlink(dest)) { + mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't rename to mailbox alias"); + return -1; + } + ret = mailbox_has_aliases(src->list, src->vname); + if (ret < 0) + return -1; + if (ret > 0) { + mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, + "Can't rename mailbox while it has aliases"); + return -1; + } + + return abox->module_ctx.super.rename(src, dest, rename_children); From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: fts-solr: Skip alias symlinks when rescanning. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/45773a09dcf2 changeset: 15136:45773a09dcf2 user: Timo Sirainen date: Tue Sep 18 18:41:01 2012 +0300 description: fts-solr: Skip alias symlinks when rescanning. diffstat: src/plugins/fts-solr/fts-backend-solr.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 1937b38f50f0 -r 45773a09dcf2 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Tue Sep 18 18:40:46 2012 +0300 +++ b/src/plugins/fts-solr/fts-backend-solr.c Tue Sep 18 18:41:01 2012 +0300 @@ -570,6 +570,7 @@ /* FIXME: proper rescan needed. for now we'll just reset the last-uids */ iter = mailbox_list_iter_init(backend->ns->list, "*", + MAILBOX_LIST_ITER_SKIP_ALIASES | MAILBOX_LIST_ITER_NO_AUTO_BOXES); while ((info = mailbox_list_iter_next(iter)) != NULL) { if ((info->flags & From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: quota: Allow negative percentage rules up to -99% Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/74d639b2a5bf changeset: 15138:74d639b2a5bf user: Timo Sirainen date: Tue Sep 18 19:16:04 2012 +0300 description: quota: Allow negative percentage rules up to -99% diffstat: src/plugins/quota/quota-private.h | 2 +- src/plugins/quota/quota.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diffs (36 lines): diff -r f5bb9f6b304d -r 74d639b2a5bf src/plugins/quota/quota-private.h --- a/src/plugins/quota/quota-private.h Tue Sep 18 18:44:46 2012 +0300 +++ b/src/plugins/quota/quota-private.h Tue Sep 18 19:16:04 2012 +0300 @@ -34,7 +34,7 @@ int64_t bytes_limit, count_limit; /* relative to default_rule */ - unsigned int bytes_percent, count_percent; + int bytes_percent, count_percent; /* Don't include this mailbox in quota */ unsigned int ignore:1; diff -r f5bb9f6b304d -r 74d639b2a5bf src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Tue Sep 18 18:44:46 2012 +0300 +++ b/src/plugins/quota/quota.c Tue Sep 18 19:16:04 2012 +0300 @@ -361,7 +361,7 @@ { int64_t percentage = *limit; - if (percentage <= 0 || percentage >= -1U) { + if (percentage <= -100 || percentage >= -1U) { *error_r = p_strdup_printf(root_set->set->pool, "Invalid rule percentage: %lld", (long long)percentage); return -1; @@ -385,9 +385,9 @@ quota_rule_recalculate_relative_rules(struct quota_rule *rule, int64_t bytes_limit, int64_t count_limit) { - if (rule->bytes_percent > 0) + if (rule->bytes_percent != 0) rule->bytes_limit = bytes_limit * rule->bytes_percent / 100; - if (rule->count_percent > 0) + if (rule->count_percent != 0) rule->count_limit = count_limit * rule->count_percent / 100; } From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: auth: userdb static used auth caching wrong when ve... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c38060f0ad58 changeset: 15139:c38060f0ad58 user: Timo Sirainen date: Tue Sep 18 19:57:48 2012 +0300 description: auth: userdb static used auth caching wrong when verifying user existence with passdb lookup. Cache entries were being looked/added for userdbs instead of passdbs. This caused problems at least with: a) Multiple userdbs (where static userdb was the last). Passdb results were added as cache entries to the first userdbs, possibly causing some confusion. b) Multiple passdbs, because the first passdb result was added to cache and used for the rest of the passdbs. diffstat: src/auth/userdb-static.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (23 lines): diff -r 74d639b2a5bf -r c38060f0ad58 src/auth/userdb-static.c --- a/src/auth/userdb-static.c Tue Sep 18 19:16:04 2012 +0300 +++ b/src/auth/userdb-static.c Tue Sep 18 19:57:48 2012 +0300 @@ -42,6 +42,8 @@ { struct static_context *ctx = auth_request->context; + auth_request->userdb_lookup = TRUE; + auth_request->private_callback.userdb = ctx->old_callback; auth_request->context = ctx->old_context; auth_request_set_state(auth_request, AUTH_REQUEST_STATE_USERDB); @@ -92,6 +94,10 @@ auth_request->context = ctx; if (auth_request->passdb != NULL) { + /* kludge: temporarily work as if we weren't doing + a userdb lookup. this is to get auth cache to use + passdb caching instead of userdb caching. */ + auth_request->userdb_lookup = FALSE; auth_request_lookup_credentials(auth_request, "", static_credentials_callback); } else { From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: lib-storage: Compiling fix for previous alias symli... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/be5b1256bf57 changeset: 15140:be5b1256bf57 user: Timo Sirainen date: Tue Sep 18 20:06:56 2012 +0300 description: lib-storage: Compiling fix for previous alias symlink change diffstat: src/lib-storage/mailbox-list.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (20 lines): diff -r c38060f0ad58 -r be5b1256bf57 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Tue Sep 18 19:57:48 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Tue Sep 18 20:06:56 2012 +0300 @@ -2,6 +2,7 @@ #include "lib.h" #include "array.h" +#include "abspath.h" #include "ioloop.h" #include "mkdir-parents.h" #include "str.h" @@ -1293,7 +1294,7 @@ return 1; T_BEGIN { - const char *path, *readlink; + const char *path, *linkpath; path = t_strconcat(dir_path, "/", d->d_name, NULL); if (lstat(path, &st) < 0) { From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: Backported parts of normalizer_func_t changes from ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/99305e4dd403 changeset: 15141:99305e4dd403 user: Timo Sirainen date: Tue Sep 18 20:07:21 2012 +0300 description: Backported parts of normalizer_func_t changes from v2.2 tree. diffstat: src/lib-storage/mail-storage-private.h | 2 ++ src/lib-storage/mail-user.c | 1 + src/lib-storage/mail-user.h | 2 ++ src/lib/unichar.h | 6 ++++++ 4 files changed, 11 insertions(+), 0 deletions(-) diffs (65 lines): diff -r be5b1256bf57 -r 99305e4dd403 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib-storage/mail-storage-private.h Tue Sep 18 20:07:21 2012 +0300 @@ -2,6 +2,7 @@ #define MAIL_STORAGE_PRIVATE_H #include "module-context.h" +#include "unichar.h" #include "file-lock.h" #include "mail-storage.h" #include "mail-storage-hooks.h" @@ -416,6 +417,7 @@ struct mail_search_sort_program *sort_program; enum mail_fetch_field wanted_fields; struct mailbox_header_lookup_ctx *wanted_headers; + normalizer_func_t *normalizer; /* if non-NULL, specifies that a search resulting is being updated. this can be used as a search optimization: if searched message diff -r be5b1256bf57 -r 99305e4dd403 src/lib-storage/mail-user.c --- a/src/lib-storage/mail-user.c Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib-storage/mail-user.c Tue Sep 18 20:07:21 2012 +0300 @@ -51,6 +51,7 @@ user->unexpanded_set = settings_dup(set_info, set, pool); user->set = settings_dup(set_info, set, pool); user->service = master_service_get_name(master_service); + user->default_normalizer = uni_utf8_to_decomposed_titlecase; /* check settings so that the duplicated structure will again contain the parsed fields */ diff -r be5b1256bf57 -r 99305e4dd403 src/lib-storage/mail-user.h --- a/src/lib-storage/mail-user.h Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib-storage/mail-user.h Tue Sep 18 20:07:21 2012 +0300 @@ -1,6 +1,7 @@ #ifndef MAIL_USER_H #define MAIL_USER_H +#include "unichar.h" #include "mail-storage-settings.h" struct module; @@ -36,6 +37,7 @@ ARRAY_DEFINE(hooks, const struct mail_storage_hooks *); struct mountpoint_list *mountpoints; + normalizer_func_t *default_normalizer; /* Module-specific contexts. See mail_storage_module_id. */ ARRAY_DEFINE(module_contexts, union mail_user_module_context *); diff -r be5b1256bf57 -r 99305e4dd403 src/lib/unichar.h --- a/src/lib/unichar.h Tue Sep 18 20:06:56 2012 +0300 +++ b/src/lib/unichar.h Tue Sep 18 20:07:21 2012 +0300 @@ -27,6 +27,12 @@ typedef uint32_t unichar_t; ARRAY_DEFINE_TYPE(unichars, unichar_t); +/* Normalize UTF8 input and append it to output buffer. + Returns 0 if ok, -1 if input was invalid. Even if input was invalid, + as much as possible should be added to output. */ +typedef int normalizer_func_t(const void *input, size_t size, + buffer_t *output); + extern const unsigned char utf8_replacement_char[UTF8_REPLACEMENT_CHAR_LEN]; extern const uint8_t *const uni_utf8_non1_bytes; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: fts-lucene: Added "normalize" option to put data th... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a200fdbc1fa0 changeset: 15142:a200fdbc1fa0 user: Timo Sirainen date: Tue Sep 18 20:09:03 2012 +0300 description: fts-lucene: Added "normalize" option to put data through user's normalizer function. diffstat: src/plugins/fts-lucene/Snowball.cc | 30 +++++++++++++++++++++++------- src/plugins/fts-lucene/SnowballAnalyzer.h | 7 ++++++- src/plugins/fts-lucene/SnowballFilter.h | 3 ++- 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 | 12 ++++++++++-- 6 files changed, 51 insertions(+), 11 deletions(-) diffs (217 lines): diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/Snowball.cc --- a/src/plugins/fts-lucene/Snowball.cc Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/Snowball.cc Tue Sep 18 20:09:03 2012 +0300 @@ -26,8 +26,9 @@ CL_NS_DEF2(analysis,snowball) /** Builds the named analyzer with no stop words. */ - SnowballAnalyzer::SnowballAnalyzer(const char* language) { + SnowballAnalyzer::SnowballAnalyzer(normalizer_func_t *normalizer, const char* language) { this->language = strdup(language); + this->normalizer = normalizer; stopSet = NULL; prevstream = NULL; } @@ -67,7 +68,7 @@ result = _CLNEW CL_NS(analysis)::LowerCaseFilter(result, true); if (stopSet != NULL) result = _CLNEW CL_NS(analysis)::StopFilter(result, true, stopSet); - result = _CLNEW SnowballFilter(result, language, true); + result = _CLNEW SnowballFilter(result, normalizer, language, true); return result; } @@ -87,10 +88,11 @@ * @param in the input tokens to stem * @param name the name of a stemmer */ - SnowballFilter::SnowballFilter(TokenStream* in, const char* language, bool deleteTS): + SnowballFilter::SnowballFilter(TokenStream* in, normalizer_func_t *normalizer, const char* language, bool deleteTS): TokenFilter(in,deleteTS) { stemmer = sb_stemmer_new(language, NULL); //use utf8 encoding + this->normalizer = normalizer; if ( stemmer == NULL ){ _CLTHROWA(CL_ERR_IllegalArgument, "language not available for stemming\n"); //todo: richer error @@ -120,10 +122,24 @@ int stemmedLen=sb_stemmer_length(stemmer); - unsigned int tchartext_size = uni_utf8_strlen_n(stemmed, stemmedLen) + 1; - TCHAR tchartext[tchartext_size]; - lucene_utf8_n_to_tchar(stemmed,stemmedLen,tchartext,tchartext_size); - token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + if (normalizer == NULL) { + unsigned int tchartext_size = + uni_utf8_strlen_n(stemmed, stemmedLen) + 1; + TCHAR tchartext[tchartext_size]; + lucene_utf8_n_to_tchar(stemmed, stemmedLen, tchartext, tchartext_size); + token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + } else T_BEGIN { + buffer_t *norm_buf = buffer_create_dynamic(pool_datastack_create(), + stemmedLen); + normalizer(stemmed, stemmedLen, norm_buf); + + unsigned int tchartext_size = + uni_utf8_strlen_n(norm_buf->data, norm_buf->used) + 1; + TCHAR tchartext[tchartext_size]; + lucene_utf8_n_to_tchar((const unsigned char *)norm_buf->data, + norm_buf->used, tchartext, tchartext_size); + token->set(tchartext,token->startOffset(), token->endOffset(), token->type()); + } T_END; return token; } diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/SnowballAnalyzer.h --- a/src/plugins/fts-lucene/SnowballAnalyzer.h Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/SnowballAnalyzer.h Tue Sep 18 20:09:03 2012 +0300 @@ -7,6 +7,10 @@ #ifndef _lucene_analysis_snowball_analyser_ #define _lucene_analysis_snowball_analyser_ +extern "C" { +#include "lib.h" +#include "unichar.h" +}; #include "CLucene/analysis/AnalysisHeader.h" CL_CLASS_DEF(util,BufferedReader) @@ -21,12 +25,13 @@ */ class CLUCENE_CONTRIBS_EXPORT SnowballAnalyzer: public Analyzer { char* language; + normalizer_func_t *normalizer; CLTCSetList* stopSet; TokenStream *prevstream; public: /** Builds the named analyzer with no stop words. */ - SnowballAnalyzer(const char* language="english"); + SnowballAnalyzer(normalizer_func_t *normalizer, const char* language="english"); /** Builds the named analyzer with the given stop words. */ diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/SnowballFilter.h --- a/src/plugins/fts-lucene/SnowballFilter.h Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/SnowballFilter.h Tue Sep 18 20:09:03 2012 +0300 @@ -22,6 +22,7 @@ */ class CLUCENE_CONTRIBS_EXPORT SnowballFilter: public TokenFilter { struct sb_stemmer * stemmer; + normalizer_func_t *normalizer; public: /** Construct the named stemming filter. @@ -29,7 +30,7 @@ * @param in the input tokens to stem * @param name the name of a stemmer */ - SnowballFilter(TokenStream* in, const char* language, bool deleteTS); + SnowballFilter(TokenStream* in, normalizer_func_t *normalizer, const char* language, bool deleteTS); ~SnowballFilter(); diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/fts-lucene-plugin.c --- a/src/plugins/fts-lucene/fts-lucene-plugin.c Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Tue Sep 18 20:09:03 2012 +0300 @@ -28,6 +28,8 @@ set->textcat_dir = p_strdup(user->pool, *tmp + 12); } else if (strncmp(*tmp, "whitespace_chars=", 17) == 0) { set->whitespace_chars = p_strdup(user->pool, *tmp + 17); + } else if (strcmp(*tmp, "normalize") == 0) { + set->normalize = TRUE; } else { i_error("fts_lucene: Invalid setting: %s", *tmp); return -1; @@ -49,6 +51,11 @@ "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"; @@ -71,6 +78,8 @@ crc = set->default_language == NULL ? 0 : crc32_str(set->default_language); crc = crc32_str_more(crc, set->whitespace_chars); + if (set->normalize) + crc = crc32_str_more(crc, "n"); return crc; } diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/fts-lucene-plugin.h --- a/src/plugins/fts-lucene/fts-lucene-plugin.h Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/fts-lucene-plugin.h Tue Sep 18 20:09:03 2012 +0300 @@ -12,6 +12,7 @@ const char *default_language; const char *textcat_conf, *textcat_dir; const char *whitespace_chars; + bool normalize; }; struct fts_lucene_user { diff -r 99305e4dd403 -r a200fdbc1fa0 src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:07:21 2012 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:09:03 2012 +0300 @@ -10,6 +10,7 @@ #include "mail-index.h" #include "mail-search.h" #include "mail-namespace.h" +#include "mailbox-list-private.h" #include "mail-storage.h" #include "fts-expunge-log.h" #include "fts-lucene-plugin.h" @@ -58,6 +59,7 @@ char *path; struct mailbox_list *list; struct fts_lucene_settings set; + normalizer_func_t *normalizer; wchar_t mailbox_guid[MAILBOX_GUID_HEX_LENGTH + 1]; @@ -107,6 +109,8 @@ index = i_new(struct lucene_index, 1); index->path = i_strdup(path); index->list = list; + index->normalizer = !set->normalize ? NULL : + list->ns->user->default_normalizer; if (set != NULL) index->set = *set; else { @@ -115,9 +119,11 @@ } #ifdef HAVE_LUCENE_STEMMER index->default_analyzer = - _CLNEW snowball::SnowballAnalyzer(index->set.default_language); + _CLNEW snowball::SnowballAnalyzer(index->normalizer, + index->set.default_language); #else index->default_analyzer = _CLNEW standard::StandardAnalyzer(); + i_assert(index->normalizer == NULL); #endif i_array_init(&index->analyzers, 32); textcat_refcount++; @@ -397,6 +403,7 @@ #ifdef HAVE_LUCENE_TEXTCAT static Analyzer *get_analyzer(struct lucene_index *index, const char *lang) { + normalizer_func_t *normalizer = index->normalizer; const struct lucene_analyzer *a; struct lucene_analyzer new_analyzer; Analyzer *analyzer; @@ -408,7 +415,8 @@ memset(&new_analyzer, 0, sizeof(new_analyzer)); new_analyzer.lang = i_strdup(lang); - new_analyzer.analyzer = _CLNEW snowball::SnowballAnalyzer(lang); + new_analyzer.analyzer = + _CLNEW snowball::SnowballAnalyzer(normalizer, lang); array_append_i(&index->analyzers.arr, &new_analyzer, 1); return new_analyzer.analyzer; } From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: fts-lucene: Compiling fix for previous change Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a9a49a30344b changeset: 15144:a9a49a30344b user: Timo Sirainen date: Tue Sep 18 20:53:50 2012 +0300 description: fts-lucene: Compiling fix for previous change diffstat: src/plugins/fts-lucene/lucene-wrapper.cc | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r f9424b066dcb -r a9a49a30344b src/plugins/fts-lucene/lucene-wrapper.cc --- a/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:48:25 2012 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Tue Sep 18 20:53:50 2012 +0300 @@ -10,7 +10,6 @@ #include "mail-index.h" #include "mail-search.h" #include "mail-namespace.h" -#include "mailbox-list-private.h" #include "mail-storage.h" #include "fts-expunge-log.h" #include "fts-lucene-plugin.h" @@ -110,7 +109,7 @@ index->path = i_strdup(path); index->list = list; index->normalizer = !set->normalize ? NULL : - list->ns->user->default_normalizer; + mailbox_list_get_namespace(list)->user->default_normalizer; if (set != NULL) index->set = *set; else { From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: director: Fixed weak-user handling when there is on... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f9424b066dcb changeset: 15143:f9424b066dcb user: Timo Sirainen date: Tue Sep 18 20:48:25 2012 +0300 description: director: Fixed weak-user handling when there is only one director. diffstat: src/director/director-request.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diffs (19 lines): diff -r a200fdbc1fa0 -r f9424b066dcb src/director/director-request.c --- a/src/director/director-request.c Tue Sep 18 20:09:03 2012 +0300 +++ b/src/director/director-request.c Tue Sep 18 20:48:25 2012 +0300 @@ -136,6 +136,15 @@ its existing connections have been killed */ return FALSE; } + if (dir->right == NULL && dir->ring_synced) { + /* looks like all the other directors have died. we can do + whatever we want without breaking anything. remove the + user's weakness just in case it was set to TRUE when we + had more directors. */ + user->weak = FALSE; + return TRUE; + } + if (user->weak) { /* wait for user to become non-weak */ return FALSE; From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: Released v2.1.10. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1a6c3b4e92e4 changeset: 15145:1a6c3b4e92e4 user: Timo Sirainen date: Tue Sep 18 21:42:27 2012 +0300 description: Released v2.1.10. diffstat: NEWS | 26 ++++++++++++++++++++++++++ configure.in | 2 +- 2 files changed, 27 insertions(+), 1 deletions(-) diffs (43 lines): diff -r a9a49a30344b -r 1a6c3b4e92e4 NEWS --- a/NEWS Tue Sep 18 20:53:50 2012 +0300 +++ b/NEWS Tue Sep 18 21:42:27 2012 +0300 @@ -1,3 +1,29 @@ +v2.1.10 2012-09-18 Timo Sirainen + + + imap: Implemented THREAD=ORDEREDSUBJECT extension. + + Added "doveadm exec" command to easily execute commands from + libexec_dir, e.g. "doveadm exec imap -u user at domain" + + Added "doveadm copy" command. + + doveadm copy/move: Added optional user parameter to specify the + source username. This allows easily copying mails between different + users. + + Added namespace { disabled } setting to quickly enable/disable + namespaces. This is especially useful when its value is returned by + userdb. + + Added mailbox_alias plugin. It allows creating mailbox aliases using + symlinks. + + imapc storage: Added imapc_max_idle_time setting to force activity + on connection. + + fts-solr: Expunging multiple messages is now faster. + - director: In some conditions director may have disconnected from + another director (without logging about it), thinking it was sending + invalid data. + - imap: Various fixes to listing mailboxes. + - pop3-migration plugin: Avoid disconnection from POP3 server due + to idling. + - login processes crashed if there were a lot of local {} or remote {} + settings blocks. + v2.1.9 2012-08-01 Timo Sirainen * mail-log plugin: Log mailbox names with UTF-8 everywhere diff -r a9a49a30344b -r 1a6c3b4e92e4 configure.in --- a/configure.in Tue Sep 18 20:53:50 2012 +0300 +++ b/configure.in Tue Sep 18 21:42:27 2012 +0300 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.9],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.10],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: Added tag 2.1.10 for changeset 1a6c3b4e92e4 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/abef881deed0 changeset: 15146:abef881deed0 user: Timo Sirainen date: Tue Sep 18 21:42:27 2012 +0300 description: Added tag 2.1.10 for changeset 1a6c3b4e92e4 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 1a6c3b4e92e4 -r abef881deed0 .hgtags --- a/.hgtags Tue Sep 18 21:42:27 2012 +0300 +++ b/.hgtags Tue Sep 18 21:42:27 2012 +0300 @@ -86,3 +86,4 @@ c92fb8b928f69ca01681a2c2976304b7e4bc3afc 2.1.7 7e5f36fd989d27a2fb48250adbab8fa54ddb6083 2.1.8 bc86680293d256d5a8009690caeb73ab2e34e359 2.1.9 +1a6c3b4e92e4174d3b1eb0a7c841f97e8fb9e590 2.1.10 From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: Added signature for changeset 1a6c3b4e92e4 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3c215bd49cd0 changeset: 15147:3c215bd49cd0 user: Timo Sirainen date: Tue Sep 18 21:42:34 2012 +0300 description: Added signature for changeset 1a6c3b4e92e4 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r abef881deed0 -r 3c215bd49cd0 .hgsigs --- a/.hgsigs Tue Sep 18 21:42:27 2012 +0300 +++ b/.hgsigs Tue Sep 18 21:42:34 2012 +0300 @@ -49,3 +49,4 @@ c92fb8b928f69ca01681a2c2976304b7e4bc3afc 0 iEYEABECAAYFAk/FIeIACgkQyUhSUUBVisk4IgCfUiXVXntqzPjJcALYRpqw4Zc7a/0An3HKWwgb6PBCbmvxBfTezNkqjqVK 7e5f36fd989d27a2fb48250adbab8fa54ddb6083 0 iEYEABECAAYFAk/yVakACgkQyUhSUUBVismekwCfSEVQjd6fwdChjd53LSt03b4UWKoAoIxd/IjLatTISlHm44iiQwzRKByo bc86680293d256d5a8009690caeb73ab2e34e359 0 iEYEABECAAYFAlAZaTUACgkQyUhSUUBVisnTAACfU1pB34RrXEyLnpnL4Ee/oeNBYcoAnRWxTqx870Efjwf+eBPzafO0C/NU +1a6c3b4e92e4174d3b1eb0a7c841f97e8fb9e590 0 iEYEABECAAYFAlBYwJMACgkQyUhSUUBVisn2PwCeIJxfB5ebXlAbtMcjrZBCmB8Kg1sAn39BC9rQoR/wjD2/ix1JaxH7gHOT From dovecot at dovecot.org Wed Sep 26 18:01:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:29 +0300 Subject: dovecot-2.2: config: Don't ignore invalid network/mask in local/... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/02aa054c762f changeset: 15148:02aa054c762f user: Timo Sirainen date: Fri Sep 21 09:22:54 2012 +0200 description: config: Don't ignore invalid network/mask in local/remote blocks diffstat: src/config/config-parser.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 3c215bd49cd0 -r 02aa054c762f src/config/config-parser.c --- a/src/config/config-parser.c Tue Sep 18 21:42:34 2012 +0300 +++ b/src/config/config-parser.c Fri Sep 21 09:22:54 2012 +0200 @@ -254,10 +254,14 @@ } max_bits = IPADDR_IS_V4(&ips[0]) ? 32 : 128; - if (p == NULL || str_to_uint(p, &bits) < 0 || bits > max_bits) + if (p == NULL) *bits_r = max_bits; - else + else if (str_to_uint(p, &bits) == 0 && bits <= max_bits) *bits_r = bits; + else { + *error_r = t_strdup_printf("Invalid network mask: %s", p); + return -1; + } return 0; } From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: lmtp: RSET/LHLO should reset any pending proxy conn... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2efd5eb7966d changeset: 15149:2efd5eb7966d user: Timo Sirainen date: Fri Sep 21 09:23:58 2012 +0200 description: lmtp: RSET/LHLO should reset any pending proxy connections. diffstat: src/lmtp/client.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 02aa054c762f -r 2efd5eb7966d src/lmtp/client.c --- a/src/lmtp/client.c Fri Sep 21 09:22:54 2012 +0200 +++ b/src/lmtp/client.c Fri Sep 21 09:23:58 2012 +0200 @@ -294,6 +294,9 @@ { struct mail_recipient *rcpt; + if (client->proxy != NULL) + lmtp_proxy_deinit(&client->proxy); + if (array_is_created(&client->state.rcpt_to)) { array_foreach_modifiable(&client->state.rcpt_to, rcpt) mail_storage_service_user_free(&rcpt->service_user); From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: lmtp: After successful proxying RCPT TO, the second... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6908b8875720 changeset: 15150:6908b8875720 user: Timo Sirainen date: Fri Sep 21 09:26:10 2012 +0200 description: lmtp: After successful proxying RCPT TO, the second one to nonexistent user gave tempfail error. Instead of "unknown user" it gave "Can't handle mixed proxy/non-proxy destinations". diffstat: src/lmtp/commands.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diffs (36 lines): diff -r 2efd5eb7966d -r 6908b8875720 src/lmtp/commands.c --- a/src/lmtp/commands.c Fri Sep 21 09:23:58 2012 +0200 +++ b/src/lmtp/commands.c Fri Sep 21 09:26:10 2012 +0200 @@ -479,16 +479,6 @@ return 0; } - if (client->proxy != NULL) { - /* NOTE: if this restriction is ever removed, we'll also need - to send different message bodies to local and proxy - (with and without Return-Path: header) */ - client_send_line(client, "451 4.3.0 <%s> " - "Can't handle mixed proxy/non-proxy destinations", - address); - return 0; - } - memset(&input, 0, sizeof(input)); input.module = input.service = "lmtp"; input.username = username; @@ -512,6 +502,15 @@ address, username); return 0; } + if (client->proxy != NULL) { + /* NOTE: if this restriction is ever removed, we'll also need + to send different message bodies to local and proxy + (with and without Return-Path: header) */ + client_send_line(client, "451 4.3.0 <%s> " + "Can't handle mixed proxy/non-proxy destinations", + address); + return 0; + } lmtp_address_translate(client, &address); From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: mdbox: Delay getting permissions for map/message fi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c83c70edef35 changeset: 15151:c83c70edef35 user: Timo Sirainen date: Fri Sep 21 11:44:17 2012 +0200 description: mdbox: Delay getting permissions for map/message files. This avoids a stat() if no mailbox is opened. diffstat: src/lib-storage/index/dbox-multi/mdbox-file.c | 21 ++++++----- src/lib-storage/index/dbox-multi/mdbox-map-private.h | 10 +++- src/lib-storage/index/dbox-multi/mdbox-map.c | 36 +++++++++++++++---- 3 files changed, 47 insertions(+), 20 deletions(-) diffs (155 lines): diff -r 6908b8875720 -r c83c70edef35 src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Fri Sep 21 09:26:10 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Fri Sep 21 11:44:17 2012 +0200 @@ -302,11 +302,14 @@ { struct mdbox_file *mfile = (struct mdbox_file *)file; struct mdbox_map *map = mfile->storage->map; - mode_t old_mask; - const char *p, *dir, *error; + mode_t create_mode, old_mask; + gid_t create_gid; + const char *create_gid_origin, *p, *dir, *error; int fd; - old_mask = umask(0666 & ~map->create_mode); + mdbox_map_get_create_mode(map, &create_mode, &create_gid, + &create_gid_origin); + old_mask = umask(0666 & ~create_mode); fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); umask(old_mask); if (fd == -1 && errno == ENOENT && parents && @@ -322,25 +325,25 @@ return -1; } /* try again */ - old_mask = umask(0666 & ~map->create_mode); + old_mask = umask(0666 & ~create_mode); fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); umask(old_mask); } if (fd == -1) { mail_storage_set_critical(&file->storage->storage, "open(%s, O_CREAT) failed: %m", path); - } else if (map->create_gid == (gid_t)-1) { + } else if (create_gid == (gid_t)-1) { /* no group change */ - } else if (fchown(fd, (uid_t)-1, map->create_gid) < 0) { + } else if (fchown(fd, (uid_t)-1, create_gid) < 0) { if (errno == EPERM) { mail_storage_set_critical(&file->storage->storage, "%s", eperm_error_get_chgrp("fchown", path, - map->create_gid, - map->create_gid_origin)); + create_gid, + create_gid_origin)); } else { mail_storage_set_critical(&file->storage->storage, "fchown(%s, -1, %ld) failed: %m", - path, (long)map->create_gid); + path, (long)create_gid); } /* continue anyway */ } diff -r 6908b8875720 -r c83c70edef35 src/lib-storage/index/dbox-multi/mdbox-map-private.h --- a/src/lib-storage/index/dbox-multi/mdbox-map-private.h Fri Sep 21 09:26:10 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map-private.h Fri Sep 21 11:44:17 2012 +0200 @@ -20,11 +20,12 @@ uint32_t map_ext_id, ref_ext_id; struct mailbox_list *root_list; - mode_t create_mode; - gid_t create_gid; - const char *create_gid_origin; + mode_t _create_mode; + gid_t _create_gid; + char *_create_gid_origin; unsigned int verify_existing_file_ids:1; + unsigned int create_mode_set:1; }; struct mdbox_map_append { @@ -64,4 +65,7 @@ struct mail_index_view *view, uint32_t seq, struct dbox_mail_lookup_rec *rec_r); +void mdbox_map_get_create_mode(struct mdbox_map *map, mode_t *mode_r, gid_t *gid_r, + const char **gid_origin_r); + #endif diff -r 6908b8875720 -r c83c70edef35 src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Sep 21 09:26:10 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Sep 21 11:44:17 2012 +0200 @@ -50,7 +50,6 @@ { struct mdbox_map *map; const char *root, *index_root; - mode_t dir_mode; root = mailbox_list_get_path(root_list, NULL, MAILBOX_LIST_PATH_TYPE_DIR); @@ -77,14 +76,26 @@ sizeof(uint32_t)); map->ref_ext_id = mail_index_ext_register(map->index, "ref", 0, sizeof(uint16_t), sizeof(uint16_t)); + return map; +} - mailbox_list_get_root_permissions(root_list, - &map->create_mode, &dir_mode, - &map->create_gid, - &map->create_gid_origin); - mail_index_set_permissions(map->index, map->create_mode, - map->create_gid, map->create_gid_origin); - return map; +void mdbox_map_get_create_mode(struct mdbox_map *map, mode_t *mode_r, gid_t *gid_r, + const char **gid_origin_r) +{ + mode_t dir_mode; + const char *gid_origin; + + if (!map->create_mode_set) { + mailbox_list_get_root_permissions(map->root_list, + &map->_create_mode, &dir_mode, + &map->_create_gid, + &gid_origin); + map->_create_gid_origin = i_strdup(gid_origin); + map->create_mode_set = TRUE; + } + *mode_r = map->_create_mode; + *gid_r = map->_create_gid; + *gid_origin_r = map->_create_gid_origin; } void mdbox_map_deinit(struct mdbox_map **_map) @@ -98,6 +109,7 @@ mail_index_close(map->index); } mail_index_free(&map->index); + i_free(map->_create_gid_origin); i_free(map->index_path); i_free(map->path); i_free(map); @@ -156,6 +168,9 @@ static int mdbox_map_open_internal(struct mdbox_map *map, bool create_missing) { enum mail_index_open_flags open_flags; + mode_t create_mode; + gid_t create_gid; + const char *create_gid_origin; int ret = 0; if (map->view != NULL) { @@ -163,6 +178,11 @@ return 1; } + mdbox_map_get_create_mode(map, &create_mode, &create_gid, + &create_gid_origin); + mail_index_set_permissions(map->index, create_mode, + create_gid, create_gid_origin); + open_flags = MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY | mail_storage_settings_to_index_flags(MAP_STORAGE(map)->set); if (create_missing) { From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: lib-lda: After auto-creating mailbox only open it, ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f818f65f1a7f changeset: 15152:f818f65f1a7f user: Timo Sirainen date: Sat Sep 22 19:23:15 2012 +0300 description: lib-lda: After auto-creating mailbox only open it, don't bother syncing it. diffstat: src/lib-lda/mail-deliver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r c83c70edef35 -r f818f65f1a7f src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Fri Sep 21 11:44:17 2012 +0200 +++ b/src/lib-lda/mail-deliver.c Sat Sep 22 19:23:15 2012 +0300 @@ -205,7 +205,7 @@ } /* and try opening again */ - if (mailbox_sync(box, 0) < 0) { + if (mailbox_open(box) < 0) { *error_str_r = mailbox_get_last_error(box, error_r); return -1; } From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: imapc: Added IMAPC_DEFAULT_MAX_IDLE_TIME macro. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fd863826c892 changeset: 15153:fd863826c892 user: Timo Sirainen date: Mon Sep 24 14:16:32 2012 +0300 description: imapc: Added IMAPC_DEFAULT_MAX_IDLE_TIME macro. diffstat: src/lib-imap-client/imapc-client.h | 3 +++ src/lib-storage/index/imapc/imapc-settings.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletions(-) diffs (36 lines): diff -r f818f65f1a7f -r fd863826c892 src/lib-imap-client/imapc-client.h --- a/src/lib-imap-client/imapc-client.h Sat Sep 22 19:23:15 2012 +0300 +++ b/src/lib-imap-client/imapc-client.h Mon Sep 24 14:16:32 2012 +0300 @@ -1,6 +1,9 @@ #ifndef IMAPC_CLIENT_H #define IMAPC_CLIENT_H +/* IMAP RFC defines this to be at least 30 minutes. */ +#define IMAPC_DEFAULT_MAX_IDLE_TIME (60*29) + enum imapc_command_state { IMAPC_COMMAND_STATE_OK, IMAPC_COMMAND_STATE_NO, diff -r f818f65f1a7f -r fd863826c892 src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Sat Sep 22 19:23:15 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:16:32 2012 +0300 @@ -50,7 +50,7 @@ .imapc_features = "", .imapc_rawlog_dir = "", .imapc_list_prefix = "", - .imapc_max_idle_time = 60*29, + .imapc_max_idle_time = IMAPC_DEFAULT_MAX_IDLE_TIME, .ssl_crypto_device = "" }; @@ -131,6 +131,10 @@ return FALSE; } #endif + if (set->imapc_max_idle_time == 0) { + *error_r = "imapc_max_idle_time must not be 0"; + return FALSE; + } if (imapc_settings_parse_features(set, error_r) < 0) return FALSE; return TRUE; From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: imapc: Compile fix for previous change. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/bea05a64cf8b changeset: 15155:bea05a64cf8b user: Timo Sirainen date: Mon Sep 24 14:22:40 2012 +0300 description: imapc: Compile fix for previous change. diffstat: src/lib-storage/index/imapc/imapc-settings.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 17a8f15beb8c -r bea05a64cf8b src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:16:41 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:22:40 2012 +0300 @@ -3,6 +3,7 @@ #include "lib.h" #include "settings-parser.h" #include "mail-storage-settings.h" +#include "imapc-client.h" #include "imapc-settings.h" #include From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: auth: passdb imap assert-crashed always Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/17a8f15beb8c changeset: 15154:17a8f15beb8c user: Timo Sirainen date: Mon Sep 24 14:16:41 2012 +0300 description: auth: passdb imap assert-crashed always diffstat: src/auth/passdb-imap.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r fd863826c892 -r 17a8f15beb8c src/auth/passdb-imap.c --- a/src/auth/passdb-imap.c Mon Sep 24 14:16:32 2012 +0300 +++ b/src/auth/passdb-imap.c Mon Sep 24 14:16:41 2012 +0300 @@ -85,6 +85,7 @@ t_strconcat(auth_request->set->base_dir, "/", DNS_CLIENT_SOCKET_NAME, NULL); set.password = password; + set.max_idle_time = IMAPC_DEFAULT_MAX_IDLE_TIME; if (module->set_have_vars) { str = t_str_new(128); From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: lib-storage: Added STATUS_CHECK_OVER_QUOTA for chec... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/94f9dfa7cbaf changeset: 15157:94f9dfa7cbaf user: Timo Sirainen date: Mon Sep 24 14:31:16 2012 +0300 description: lib-storage: Added STATUS_CHECK_OVER_QUOTA for checking if user is over quota. diffstat: src/lib-storage/mail-storage.h | 3 ++- src/plugins/quota/quota-storage.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletions(-) diffs (61 lines): diff -r 0a5a3b760e2e -r 94f9dfa7cbaf src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Mon Sep 24 14:24:58 2012 +0300 +++ b/src/lib-storage/mail-storage.h Mon Sep 24 14:31:16 2012 +0300 @@ -74,7 +74,8 @@ STATUS_HIGHESTMODSEQ = 0x80, STATUS_PERMANENT_FLAGS = 0x200, STATUS_FIRST_RECENT_UID = 0x400, - STATUS_LAST_CACHED_SEQ = 0x800 + STATUS_LAST_CACHED_SEQ = 0x800, + STATUS_CHECK_OVER_QUOTA = 0x1000 /* return error if over quota */ }; enum mailbox_metadata_items { diff -r 0a5a3b760e2e -r 94f9dfa7cbaf src/plugins/quota/quota-storage.c --- a/src/plugins/quota/quota-storage.c Mon Sep 24 14:24:58 2012 +0300 +++ b/src/plugins/quota/quota-storage.c Mon Sep 24 14:31:16 2012 +0300 @@ -66,6 +66,36 @@ qmail->super.expunge(_mail); } +static int +quota_get_status(struct mailbox *box, enum mailbox_status_items items, + struct mailbox_status *status_r) +{ + struct quota_mailbox *qbox = QUOTA_CONTEXT(box); + struct quota_transaction_context *qt; + bool too_large; + int ret = 0; + + if ((items & STATUS_CHECK_OVER_QUOTA) != 0) { + qt = quota_transaction_begin(box); + if ((ret = quota_test_alloc(qt, 1, &too_large)) == 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_NOSPACE, + qt->quota->set->quota_exceeded_msg); + ret = -1; + } + quota_transaction_rollback(&qt); + + if ((items & ~STATUS_CHECK_OVER_QUOTA) == 0) { + /* don't bother calling parent, it may unnecessarily + try to open the mailbox */ + return ret; + } + } + + if (qbox->module_ctx.super.get_status(box, items, status_r) < 0) + ret = -1; + return ret < 0 ? -1 : 0; +} + static struct mailbox_transaction_context * quota_mailbox_transaction_begin(struct mailbox *box, enum mailbox_transaction_flags flags) @@ -376,6 +406,7 @@ qbox->module_ctx.super = *v; box->vlast = &qbox->module_ctx.super; + v->get_status = quota_get_status; v->transaction_begin = quota_mailbox_transaction_begin; v->transaction_commit = quota_mailbox_transaction_commit; v->transaction_rollback = quota_mailbox_transaction_rollback; From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: imapc: And another compile fix.. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0a5a3b760e2e changeset: 15156:0a5a3b760e2e user: Timo Sirainen date: Mon Sep 24 14:24:58 2012 +0300 description: imapc: And another compile fix.. Using the macro would have required config/all-settings.c to include imapc-client.h, which is a bit too much trouble just for this. diffstat: src/lib-storage/index/imapc/imapc-settings.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (20 lines): diff -r bea05a64cf8b -r 0a5a3b760e2e src/lib-storage/index/imapc/imapc-settings.c --- a/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:22:40 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-settings.c Mon Sep 24 14:24:58 2012 +0300 @@ -3,7 +3,6 @@ #include "lib.h" #include "settings-parser.h" #include "mail-storage-settings.h" -#include "imapc-client.h" #include "imapc-settings.h" #include @@ -51,7 +50,7 @@ .imapc_features = "", .imapc_rawlog_dir = "", .imapc_list_prefix = "", - .imapc_max_idle_time = IMAPC_DEFAULT_MAX_IDLE_TIME, + .imapc_max_idle_time = 60*29, .ssl_crypto_device = "" }; From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: lmtp: Added lmtp_rcpt_check_quota setting to check ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cc7906697d19 changeset: 15158:cc7906697d19 user: Timo Sirainen date: Mon Sep 24 14:33:52 2012 +0300 description: lmtp: Added lmtp_rcpt_check_quota setting to check quota already on RCPT TO. diffstat: doc/example-config/conf.d/20-lmtp.conf | 4 ++ src/lmtp/commands.c | 48 +++++++++++++++++++++++++++++++-- src/lmtp/lmtp-settings.c | 2 + src/lmtp/lmtp-settings.h | 1 + 4 files changed, 52 insertions(+), 3 deletions(-) diffs (111 lines): diff -r 94f9dfa7cbaf -r cc7906697d19 doc/example-config/conf.d/20-lmtp.conf --- a/doc/example-config/conf.d/20-lmtp.conf Mon Sep 24 14:31:16 2012 +0300 +++ b/doc/example-config/conf.d/20-lmtp.conf Mon Sep 24 14:33:52 2012 +0300 @@ -10,7 +10,11 @@ # lda_mailbox_autocreate settings. #lmtp_save_to_detail_mailbox = no +# Verify quota before replying to RCPT TO. This adds a small overhead. +#lmtp_rcpt_check_quota = no + protocol lmtp { # Space separated list of plugins to load (default is global mail_plugins). #mail_plugins = $mail_plugins } + \ No newline at end of file diff -r 94f9dfa7cbaf -r cc7906697d19 src/lmtp/commands.c --- a/src/lmtp/commands.c Mon Sep 24 14:31:16 2012 +0300 +++ b/src/lmtp/commands.c Mon Sep 24 14:33:52 2012 +0300 @@ -444,6 +444,42 @@ *address = str_c(username); } +static int +lmtp_rcpt_to_is_over_quota(struct client *client, + const struct mail_recipient *rcpt) +{ + struct mail_user *user; + struct mail_namespace *ns; + struct mailbox *box; + struct mailbox_status status; + const char *errstr; + enum mail_error error; + int ret; + + if (!client->lmtp_set->lmtp_rcpt_check_quota) + return 0; + + ret = mail_storage_service_next(storage_service, + rcpt->service_user, &user); + if (ret < 0) + return -1; + + ns = mail_namespace_find_inbox(user->namespaces); + box = mailbox_alloc(ns->list, "INBOX", 0); + ret = mailbox_get_status(box, STATUS_CHECK_OVER_QUOTA, &status); + if (ret < 0) { + errstr = mailbox_get_last_error(box, &error); + if (error == MAIL_ERROR_NOSPACE) { + client_send_line(client, "552 5.2.2 <%s> %s", + rcpt->address, errstr); + ret = 1; + } + } + mailbox_free(&box); + mail_user_unref(&user); + return ret; +} + int cmd_rcpt(struct client *client, const char *args) { struct mail_recipient rcpt; @@ -516,9 +552,15 @@ rcpt.address = p_strdup(client->state_pool, address); rcpt.detail = p_strdup(client->state_pool, detail); - array_append(&client->state.rcpt_to, &rcpt, 1); - - client_send_line(client, "250 2.1.5 OK"); + if ((ret = lmtp_rcpt_to_is_over_quota(client, &rcpt)) < 0) { + client_send_line(client, ERRSTR_TEMP_MAILBOX_FAIL, + rcpt.address); + return 0; + } + if (ret == 0) { + array_append(&client->state.rcpt_to, &rcpt, 1); + client_send_line(client, "250 2.1.5 OK"); + } return 0; } diff -r 94f9dfa7cbaf -r cc7906697d19 src/lmtp/lmtp-settings.c --- a/src/lmtp/lmtp-settings.c Mon Sep 24 14:31:16 2012 +0300 +++ b/src/lmtp/lmtp-settings.c Mon Sep 24 14:33:52 2012 +0300 @@ -59,6 +59,7 @@ static const struct setting_define lmtp_setting_defines[] = { DEF(SET_BOOL, lmtp_proxy), DEF(SET_BOOL, lmtp_save_to_detail_mailbox), + DEF(SET_BOOL, lmtp_rcpt_check_quota), DEF(SET_STR_VARS, login_greeting), DEF(SET_STR, lmtp_address_translate), @@ -68,6 +69,7 @@ static const struct lmtp_settings lmtp_default_settings = { .lmtp_proxy = FALSE, .lmtp_save_to_detail_mailbox = FALSE, + .lmtp_rcpt_check_quota = FALSE, .login_greeting = PACKAGE_NAME" ready.", .lmtp_address_translate = "" }; diff -r 94f9dfa7cbaf -r cc7906697d19 src/lmtp/lmtp-settings.h --- a/src/lmtp/lmtp-settings.h Mon Sep 24 14:31:16 2012 +0300 +++ b/src/lmtp/lmtp-settings.h Mon Sep 24 14:33:52 2012 +0300 @@ -7,6 +7,7 @@ struct lmtp_settings { bool lmtp_proxy; bool lmtp_save_to_detail_mailbox; + bool lmtp_rcpt_check_quota; const char *login_greeting; const char *lmtp_address_translate; }; From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: lib-storage: Added ALTNOCHECK option to mail_location. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a14f1d2e2b45 changeset: 15159:a14f1d2e2b45 user: Timo Sirainen date: Mon Sep 24 14:42:38 2012 +0300 description: lib-storage: Added ALTNOCHECK option to mail_location. By default Dovecot verifies that $rootdir/dbox-alt-root symlink matches the ALT directory location, and logs an error if not. This is mainly to avoid accidents during initial configuration when for example alt dir was set in global mail_location but was forgotten to be set in userdb reply's mail_location. The ALTNOCHECK setting simply doesn't check or create this symlink, giving a (very) small performance improvement. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 3 ++- src/lib-storage/mailbox-list.c | 6 +++++- src/lib-storage/mailbox-list.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diffs (48 lines): diff -r cc7906697d19 -r a14f1d2e2b45 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Mon Sep 24 14:33:52 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Mon Sep 24 14:42:38 2012 +0300 @@ -107,7 +107,8 @@ storage->attachment_fs = fs_init(name, args, &fs_set); } T_END; - dbox_verify_alt_path(ns->list); + if (!ns->list->set.alt_dir_nocheck) + dbox_verify_alt_path(ns->list); return 0; } diff -r cc7906697d19 -r a14f1d2e2b45 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Mon Sep 24 14:33:52 2012 +0300 +++ b/src/lib-storage/mailbox-list.c Mon Sep 24 14:42:38 2012 +0300 @@ -163,6 +163,7 @@ list->set.mailbox_dir_name = p_strdup(list->pool, set->mailbox_dir_name); list->set.alt_dir = p_strdup(list->pool, set->alt_dir); + list->set.alt_dir_nocheck = set->alt_dir_nocheck; if (*set->mailbox_dir_name == '\0') list->set.mailbox_dir_name = ""; @@ -294,7 +295,10 @@ dest = &set_r->control_dir; else if (strcmp(key, "ALT") == 0) dest = &set_r->alt_dir; - else if (strcmp(key, "LAYOUT") == 0) + else if (strcmp(key, "ALTNOCHECK") == 0) { + set_r->alt_dir_nocheck = TRUE; + continue; + } else if (strcmp(key, "LAYOUT") == 0) dest = &set_r->layout; else if (strcmp(key, "SUBSCRIPTIONS") == 0) dest = &set_r->subscription_fname; diff -r cc7906697d19 -r a14f1d2e2b45 src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Mon Sep 24 14:33:52 2012 +0300 +++ b/src/lib-storage/mailbox-list.h Mon Sep 24 14:42:38 2012 +0300 @@ -145,6 +145,8 @@ char escape_char; /* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */ bool utf8; + /* Don't check/create the alt-dir symlink. */ + bool alt_dir_nocheck; }; struct mailbox_info { From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: ldap auth: Update %variables after each field update. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/18c8d840b028 changeset: 15160:18c8d840b028 user: Timo Sirainen date: Mon Sep 24 16:49:29 2012 +0300 description: ldap auth: Update %variables after each field update. The previous behavior was a bit confusing. "uid=user" at the beginning updated the %u variable, but if it was after templates it didn't update it. Also "=user=%{uid}" that was supposed to be equivalent wasn't. Now the behavior is consistent across all ways to set the fields. diffstat: src/auth/auth-request.c | 20 ++++++++++++++++---- src/auth/auth-request.h | 4 ++++ src/auth/db-ldap.c | 40 ++++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 24 deletions(-) diffs (132 lines): diff -r a14f1d2e2b45 -r 18c8d840b028 src/auth/auth-request.c --- a/src/auth/auth-request.c Mon Sep 24 14:42:38 2012 +0300 +++ b/src/auth/auth-request.c Mon Sep 24 16:49:29 2012 +0300 @@ -1794,16 +1794,18 @@ { '\0', NULL, NULL } }; -const struct var_expand_table * -auth_request_get_var_expand_table(const struct auth_request *auth_request, - auth_request_escape_func_t *escape_func) +struct var_expand_table * +auth_request_get_var_expand_table_full(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func, + unsigned int *count) { struct var_expand_table *tab; if (escape_func == NULL) escape_func = escape_none; - tab = t_malloc(sizeof(auth_request_var_expand_static_tab)); + *count += N_ELEMENTS(auth_request_var_expand_static_tab); + tab = t_malloc(*count * sizeof(struct var_expand_table)); memcpy(tab, auth_request_var_expand_static_tab, sizeof(auth_request_var_expand_static_tab)); @@ -1855,6 +1857,16 @@ return tab; } +const struct var_expand_table * +auth_request_get_var_expand_table(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func) +{ + unsigned int count = 0; + + return auth_request_get_var_expand_table_full(auth_request, escape_func, + &count); +} + static void get_log_prefix(string_t *str, struct auth_request *auth_request, const char *subsystem) { diff -r a14f1d2e2b45 -r 18c8d840b028 src/auth/auth-request.h --- a/src/auth/auth-request.h Mon Sep 24 14:42:38 2012 +0300 +++ b/src/auth/auth-request.h Mon Sep 24 16:49:29 2012 +0300 @@ -207,6 +207,10 @@ const struct var_expand_table * auth_request_get_var_expand_table(const struct auth_request *auth_request, auth_request_escape_func_t *escape_func); +struct var_expand_table * +auth_request_get_var_expand_table_full(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func, + unsigned int *count); const char *auth_request_str_escape(const char *string, const struct auth_request *request); diff -r a14f1d2e2b45 -r 18c8d840b028 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Mon Sep 24 14:42:38 2012 +0300 +++ b/src/auth/db-ldap.c Mon Sep 24 16:49:29 2012 +0300 @@ -63,7 +63,6 @@ /* ldap_attr_name => struct db_ldap_value */ struct hash_table *ldap_attrs; - struct var_expand_table *var_table; const char *val_1_arr[2]; string_t *var, *debug; @@ -1068,21 +1067,17 @@ *attr_names_r = array_idx_modifiable(&ctx.attr_names, 0); } -static struct var_expand_table * -db_ldap_value_get_var_expand_table(pool_t pool, - struct auth_request *auth_request) +static const struct var_expand_table * +db_ldap_value_get_var_expand_table(struct auth_request *auth_request, + const char *ldap_value) { - const struct var_expand_table *auth_table = NULL; struct var_expand_table *table; - unsigned int count; + unsigned int count = 1; - auth_table = auth_request_get_var_expand_table(auth_request, NULL); - for (count = 0; auth_table[count].key != '\0'; count++) ; - count++; - - table = p_new(pool, struct var_expand_table, count + 2); - table[0].key = '$'; - memcpy(table + 1, auth_table, sizeof(*table) * count); + table = auth_request_get_var_expand_table_full(auth_request, NULL, + &count); + table[count-1].key = '$'; + table[count-1].value = ldap_value; return table; } @@ -1240,6 +1235,7 @@ { "ldap", db_ldap_field_expand }, { NULL, NULL } }; + const struct var_expand_table *var_table; const char *const *values; if (ldap_value != NULL) @@ -1265,14 +1261,18 @@ "using value '%s'", field->name, values[0]); } - if (ctx->var_table == NULL) { - ctx->var_table = db_ldap_value_get_var_expand_table( - ctx->pool, ctx->auth_request); + + /* do this lookup separately for each expansion, because: + 1) the values are allocated from data stack + 2) if "user" field is updated, we want %u/%n/%d updated + (and less importantly the same for other variables) */ + var_table = db_ldap_value_get_var_expand_table(ctx->auth_request, + values[0]); + if (ctx->var == NULL) ctx->var = str_new(ctx->pool, 256); - } - ctx->var_table[0].value = values[0]; - str_truncate(ctx->var, 0); - var_expand_with_funcs(ctx->var, field->value, ctx->var_table, + else + str_truncate(ctx->var, 0); + var_expand_with_funcs(ctx->var, field->value, var_table, var_funcs_table, ctx); ctx->val_1_arr[0] = str_c(ctx->var); values = ctx->val_1_arr; From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: auth ldap: Previous change broke %$ variable. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/4d82c74f702c changeset: 15161:4d82c74f702c user: Timo Sirainen date: Mon Sep 24 17:03:42 2012 +0300 description: auth ldap: Previous change broke %$ variable. diffstat: src/auth/auth-request.c | 17 ++++++++++++----- src/auth/db-ldap.c | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diffs (53 lines): diff -r 18c8d840b028 -r 4d82c74f702c src/auth/auth-request.c --- a/src/auth/auth-request.c Mon Sep 24 16:49:29 2012 +0300 +++ b/src/auth/auth-request.c Mon Sep 24 17:03:42 2012 +0300 @@ -1799,15 +1799,22 @@ auth_request_escape_func_t *escape_func, unsigned int *count) { - struct var_expand_table *tab; + const unsigned int auth_count = + N_ELEMENTS(auth_request_var_expand_static_tab); + struct var_expand_table *tab, *ret_tab; if (escape_func == NULL) escape_func = escape_none; - *count += N_ELEMENTS(auth_request_var_expand_static_tab); - tab = t_malloc(*count * sizeof(struct var_expand_table)); + /* keep the extra fields at the beginning. the last static_tab field + contains the ending NULL-fields. */ + tab = ret_tab = t_malloc((*count + auth_count) * sizeof(*tab)); + memset(tab, 0, *count * sizeof(*tab)); + tab += *count; + *count += auth_count; + memcpy(tab, auth_request_var_expand_static_tab, - sizeof(auth_request_var_expand_static_tab)); + auth_count * sizeof(*tab)); tab[0].value = escape_func(auth_request->user, auth_request); tab[1].value = escape_func(t_strcut(auth_request->user, '@'), @@ -1854,7 +1861,7 @@ } tab[18].value = auth_request->session_id == NULL ? NULL : escape_func(auth_request->session_id, auth_request); - return tab; + return ret_tab; } const struct var_expand_table * diff -r 18c8d840b028 -r 4d82c74f702c src/auth/db-ldap.c --- a/src/auth/db-ldap.c Mon Sep 24 16:49:29 2012 +0300 +++ b/src/auth/db-ldap.c Mon Sep 24 17:03:42 2012 +0300 @@ -1076,8 +1076,8 @@ table = auth_request_get_var_expand_table_full(auth_request, NULL, &count); - table[count-1].key = '$'; - table[count-1].value = ldap_value; + table[0].key = '$'; + table[0].value = ldap_value; return table; } From dovecot at dovecot.org Wed Sep 26 18:01:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 18:01:30 +0300 Subject: dovecot-2.2: Merged changes from v2.1 tree. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e3175ee39483 changeset: 15162:e3175ee39483 user: Timo Sirainen date: Wed Sep 26 18:01:01 2012 +0300 description: Merged changes from v2.1 tree. diffstat: .hgsigs | 1 + .hgtags | 1 + NEWS | 26 + configure.in | 1 + doc/example-config/conf.d/20-lmtp.conf | 4 + src/auth/auth-request.c | 33 +- src/auth/auth-request.h | 4 + src/auth/db-ldap.c | 38 +- src/auth/passdb-imap.c | 1 + src/auth/userdb-static.c | 6 + src/config/config-parser.c | 8 +- src/director/director-connection.c | 137 +++++-- src/director/director-connection.h | 3 +- src/director/director-request.c | 9 + src/director/director.c | 9 +- src/director/director.h | 4 +- src/doveadm/Makefile.am | 1 + src/doveadm/doveadm-settings.c | 2 + src/doveadm/doveadm-settings.h | 1 + src/doveadm/doveadm.c | 16 + src/lib-imap-client/imapc-client.h | 3 + src/lib-imap-client/imapc-connection.c | 18 +- src/lib-imap/imap-parser.c | 80 ++++- src/lib-imap/imap-parser.h | 6 +- src/lib-master/master-service-settings-cache.c | 3 +- src/lib-settings/settings-parser.c | 4 +- src/lib-storage/index/dbox-common/dbox-storage.c | 3 +- src/lib-storage/index/dbox-multi/mdbox-file.c | 17 +- src/lib-storage/index/dbox-multi/mdbox-map-private.h | 1 - src/lib-storage/index/dbox-multi/mdbox-map.c | 11 +- src/lib-storage/index/dbox-multi/mdbox-storage.c | 3 +- src/lib-storage/index/dbox-single/sdbox-storage.c | 3 +- src/lib-storage/index/imapc/imapc-settings.c | 4 + src/lib-storage/index/index-status.c | 1 + src/lib-storage/index/maildir/maildir-storage.c | 3 +- src/lib-storage/index/mbox/mbox-storage.c | 3 +- src/lib-storage/index/pop3c/pop3c-mail.c | 2 +- src/lib-storage/list/mailbox-list-fs-iter.c | 13 + src/lib-storage/list/mailbox-list-maildir-iter.c | 5 + src/lib-storage/mail-storage-service.c | 2 +- src/lib-storage/mail-storage.h | 3 +- src/lib-storage/mailbox-guid-cache.c | 1 + src/lib-storage/mailbox-list-iter.h | 4 +- src/lib-storage/mailbox-list-private.h | 3 + src/lib-storage/mailbox-list.c | 40 ++- src/lib-storage/mailbox-list.h | 2 + src/lib/hash.c | 2 +- src/lmtp/client.c | 3 + src/lmtp/commands.c | 67 +++- src/lmtp/lmtp-settings.c | 2 + src/lmtp/lmtp-settings.h | 1 + src/plugins/Makefile.am | 1 + src/plugins/acl/acl-lookup-dict.c | 12 +- src/plugins/fts-lucene/lucene-wrapper.cc | 2 +- src/plugins/fts-solr/fts-backend-solr.c | 1 + src/plugins/mailbox-alias/Makefile.am | 18 + src/plugins/mailbox-alias/mailbox-alias-plugin.c | 334 +++++++++++++++++++ src/plugins/mailbox-alias/mailbox-alias-plugin.h | 7 + src/plugins/quota/quota-count.c | 1 + src/plugins/quota/quota-maildir.c | 1 + src/plugins/quota/quota-private.h | 2 +- src/plugins/quota/quota-storage.c | 31 + src/plugins/quota/quota.c | 6 +- 63 files changed, 908 insertions(+), 126 deletions(-) diffs (truncated from 2086 to 300 lines): diff -r 981e0bc71742 -r e3175ee39483 .hgsigs --- a/.hgsigs Wed Sep 26 17:17:08 2012 +0300 +++ b/.hgsigs Wed Sep 26 18:01:01 2012 +0300 @@ -49,3 +49,4 @@ c92fb8b928f69ca01681a2c2976304b7e4bc3afc 0 iEYEABECAAYFAk/FIeIACgkQyUhSUUBVisk4IgCfUiXVXntqzPjJcALYRpqw4Zc7a/0An3HKWwgb6PBCbmvxBfTezNkqjqVK 7e5f36fd989d27a2fb48250adbab8fa54ddb6083 0 iEYEABECAAYFAk/yVakACgkQyUhSUUBVismekwCfSEVQjd6fwdChjd53LSt03b4UWKoAoIxd/IjLatTISlHm44iiQwzRKByo bc86680293d256d5a8009690caeb73ab2e34e359 0 iEYEABECAAYFAlAZaTUACgkQyUhSUUBVisnTAACfU1pB34RrXEyLnpnL4Ee/oeNBYcoAnRWxTqx870Efjwf+eBPzafO0C/NU +1a6c3b4e92e4174d3b1eb0a7c841f97e8fb9e590 0 iEYEABECAAYFAlBYwJMACgkQyUhSUUBVisn2PwCeIJxfB5ebXlAbtMcjrZBCmB8Kg1sAn39BC9rQoR/wjD2/ix1JaxH7gHOT diff -r 981e0bc71742 -r e3175ee39483 .hgtags --- a/.hgtags Wed Sep 26 17:17:08 2012 +0300 +++ b/.hgtags Wed Sep 26 18:01:01 2012 +0300 @@ -86,3 +86,4 @@ c92fb8b928f69ca01681a2c2976304b7e4bc3afc 2.1.7 7e5f36fd989d27a2fb48250adbab8fa54ddb6083 2.1.8 bc86680293d256d5a8009690caeb73ab2e34e359 2.1.9 +1a6c3b4e92e4174d3b1eb0a7c841f97e8fb9e590 2.1.10 diff -r 981e0bc71742 -r e3175ee39483 NEWS --- a/NEWS Wed Sep 26 17:17:08 2012 +0300 +++ b/NEWS Wed Sep 26 18:01:01 2012 +0300 @@ -19,6 +19,32 @@ + LMTP proxy: Implemented XCLIENT extension for passing remote IP address through proxy. +v2.1.10 2012-09-18 Timo Sirainen + + + imap: Implemented THREAD=ORDEREDSUBJECT extension. + + Added "doveadm exec" command to easily execute commands from + libexec_dir, e.g. "doveadm exec imap -u user at domain" + + Added "doveadm copy" command. + + doveadm copy/move: Added optional user parameter to specify the + source username. This allows easily copying mails between different + users. + + Added namespace { disabled } setting to quickly enable/disable + namespaces. This is especially useful when its value is returned by + userdb. + + Added mailbox_alias plugin. It allows creating mailbox aliases using + symlinks. + + imapc storage: Added imapc_max_idle_time setting to force activity + on connection. + + fts-solr: Expunging multiple messages is now faster. + - director: In some conditions director may have disconnected from + another director (without logging about it), thinking it was sending + invalid data. + - imap: Various fixes to listing mailboxes. + - pop3-migration plugin: Avoid disconnection from POP3 server due + to idling. + - login processes crashed if there were a lot of local {} or remote {} + settings blocks. + v2.1.9 2012-08-01 Timo Sirainen * mail-log plugin: Log mailbox names with UTF-8 everywhere diff -r 981e0bc71742 -r e3175ee39483 configure.in --- a/configure.in Wed Sep 26 17:17:08 2012 +0300 +++ b/configure.in Wed Sep 26 18:01:01 2012 +0300 @@ -2820,6 +2820,7 @@ src/plugins/lazy-expunge/Makefile src/plugins/listescape/Makefile src/plugins/mail-log/Makefile +src/plugins/mailbox-alias/Makefile src/plugins/notify/Makefile src/plugins/pop3-migration/Makefile src/plugins/quota/Makefile diff -r 981e0bc71742 -r e3175ee39483 doc/example-config/conf.d/20-lmtp.conf --- a/doc/example-config/conf.d/20-lmtp.conf Wed Sep 26 17:17:08 2012 +0300 +++ b/doc/example-config/conf.d/20-lmtp.conf Wed Sep 26 18:01:01 2012 +0300 @@ -10,7 +10,11 @@ # lda_mailbox_autocreate settings. #lmtp_save_to_detail_mailbox = no +# Verify quota before replying to RCPT TO. This adds a small overhead. +#lmtp_rcpt_check_quota = no + protocol lmtp { # Space separated list of plugins to load (default is global mail_plugins). #mail_plugins = $mail_plugins } + \ No newline at end of file diff -r 981e0bc71742 -r e3175ee39483 src/auth/auth-request.c --- a/src/auth/auth-request.c Wed Sep 26 17:17:08 2012 +0300 +++ b/src/auth/auth-request.c Wed Sep 26 18:01:01 2012 +0300 @@ -1820,18 +1820,27 @@ { '\0', NULL, NULL } }; -const struct var_expand_table * -auth_request_get_var_expand_table(const struct auth_request *auth_request, - auth_request_escape_func_t *escape_func) +struct var_expand_table * +auth_request_get_var_expand_table_full(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func, + unsigned int *count) { - struct var_expand_table *tab; + const unsigned int auth_count = + N_ELEMENTS(auth_request_var_expand_static_tab); + struct var_expand_table *tab, *ret_tab; if (escape_func == NULL) escape_func = escape_none; - tab = t_malloc(sizeof(auth_request_var_expand_static_tab)); + /* keep the extra fields at the beginning. the last static_tab field + contains the ending NULL-fields. */ + tab = ret_tab = t_malloc((*count + auth_count) * sizeof(*tab)); + memset(tab, 0, *count * sizeof(*tab)); + tab += *count; + *count += auth_count; + memcpy(tab, auth_request_var_expand_static_tab, - sizeof(auth_request_var_expand_static_tab)); + auth_count * sizeof(*tab)); tab[0].value = escape_func(auth_request->user, auth_request); tab[1].value = escape_func(t_strcut(auth_request->user, '@'), @@ -1878,7 +1887,17 @@ } tab[18].value = auth_request->session_id == NULL ? NULL : escape_func(auth_request->session_id, auth_request); - return tab; + return ret_tab; +} + +const struct var_expand_table * +auth_request_get_var_expand_table(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func) +{ + unsigned int count = 0; + + return auth_request_get_var_expand_table_full(auth_request, escape_func, + &count); } static void get_log_prefix(string_t *str, struct auth_request *auth_request, diff -r 981e0bc71742 -r e3175ee39483 src/auth/auth-request.h --- a/src/auth/auth-request.h Wed Sep 26 17:17:08 2012 +0300 +++ b/src/auth/auth-request.h Wed Sep 26 18:01:01 2012 +0300 @@ -212,6 +212,10 @@ auth_request_get_var_expand_table(const struct auth_request *auth_request, auth_request_escape_func_t *escape_func) ATTR_NULL(2); +struct var_expand_table * +auth_request_get_var_expand_table_full(const struct auth_request *auth_request, + auth_request_escape_func_t *escape_func, + unsigned int *count) ATTR_NULL(2); const char *auth_request_str_escape(const char *string, const struct auth_request *request); diff -r 981e0bc71742 -r e3175ee39483 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Wed Sep 26 17:17:08 2012 +0300 +++ b/src/auth/db-ldap.c Wed Sep 26 18:01:01 2012 +0300 @@ -63,7 +63,6 @@ /* attribute name => value */ HASH_TABLE(char *, struct db_ldap_value *) ldap_attrs; - struct var_expand_table *var_table; const char *val_1_arr[2]; string_t *var, *debug; @@ -1068,21 +1067,17 @@ *attr_names_r = array_idx_modifiable(&ctx.attr_names, 0); } -static struct var_expand_table * -db_ldap_value_get_var_expand_table(pool_t pool, - struct auth_request *auth_request) +static const struct var_expand_table * +db_ldap_value_get_var_expand_table(struct auth_request *auth_request, + const char *ldap_value) { - const struct var_expand_table *auth_table = NULL; struct var_expand_table *table; - unsigned int count; + unsigned int count = 1; - auth_table = auth_request_get_var_expand_table(auth_request, NULL); - for (count = 0; auth_table[count].key != '\0'; count++) ; - count++; - - table = p_new(pool, struct var_expand_table, count + 2); + table = auth_request_get_var_expand_table_full(auth_request, NULL, + &count); table[0].key = '$'; - memcpy(table + 1, auth_table, sizeof(*table) * count); + table[0].value = ldap_value; return table; } @@ -1238,6 +1233,7 @@ { "ldap", db_ldap_field_expand }, { NULL, NULL } }; + const struct var_expand_table *var_table; const char *const *values; if (ldap_value != NULL) @@ -1263,14 +1259,18 @@ "using value '%s'", field->name, values[0]); } - if (ctx->var_table == NULL) { - ctx->var_table = db_ldap_value_get_var_expand_table( - ctx->pool, ctx->auth_request); + + /* do this lookup separately for each expansion, because: + 1) the values are allocated from data stack + 2) if "user" field is updated, we want %u/%n/%d updated + (and less importantly the same for other variables) */ + var_table = db_ldap_value_get_var_expand_table(ctx->auth_request, + values[0]); + if (ctx->var == NULL) ctx->var = str_new(ctx->pool, 256); - } - ctx->var_table[0].value = values[0]; - str_truncate(ctx->var, 0); - var_expand_with_funcs(ctx->var, field->value, ctx->var_table, + else + str_truncate(ctx->var, 0); + var_expand_with_funcs(ctx->var, field->value, var_table, var_funcs_table, ctx); ctx->val_1_arr[0] = str_c(ctx->var); values = ctx->val_1_arr; diff -r 981e0bc71742 -r e3175ee39483 src/auth/passdb-imap.c --- a/src/auth/passdb-imap.c Wed Sep 26 17:17:08 2012 +0300 +++ b/src/auth/passdb-imap.c Wed Sep 26 18:01:01 2012 +0300 @@ -85,6 +85,7 @@ t_strconcat(auth_request->set->base_dir, "/", DNS_CLIENT_SOCKET_NAME, NULL); set.password = password; + set.max_idle_time = IMAPC_DEFAULT_MAX_IDLE_TIME; if (module->set_have_vars) { str = t_str_new(128); diff -r 981e0bc71742 -r e3175ee39483 src/auth/userdb-static.c --- a/src/auth/userdb-static.c Wed Sep 26 17:17:08 2012 +0300 +++ b/src/auth/userdb-static.c Wed Sep 26 18:01:01 2012 +0300 @@ -42,6 +42,8 @@ { struct static_context *ctx = auth_request->context; + auth_request->userdb_lookup = TRUE; + auth_request->private_callback.userdb = ctx->old_callback; auth_request->context = ctx->old_context; auth_request_set_state(auth_request, AUTH_REQUEST_STATE_USERDB); @@ -92,6 +94,10 @@ auth_request->context = ctx; if (auth_request->passdb != NULL) { + /* kludge: temporarily work as if we weren't doing + a userdb lookup. this is to get auth cache to use + passdb caching instead of userdb caching. */ + auth_request->userdb_lookup = FALSE; auth_request_lookup_credentials(auth_request, "", static_credentials_callback); } else { diff -r 981e0bc71742 -r e3175ee39483 src/config/config-parser.c --- a/src/config/config-parser.c Wed Sep 26 17:17:08 2012 +0300 +++ b/src/config/config-parser.c Wed Sep 26 18:01:01 2012 +0300 @@ -255,10 +255,14 @@ } max_bits = IPADDR_IS_V4(&ips[0]) ? 32 : 128; - if (p == NULL || str_to_uint(p, &bits) < 0 || bits > max_bits) + if (p == NULL) *bits_r = max_bits; - else + else if (str_to_uint(p, &bits) == 0 && bits <= max_bits) *bits_r = bits; + else { + *error_r = t_strdup_printf("Invalid network mask: %s", p); + return -1; + } return 0; } diff -r 981e0bc71742 -r e3175ee39483 src/director/director-connection.c --- a/src/director/director-connection.c Wed Sep 26 17:17:08 2012 +0300 +++ b/src/director/director-connection.c Wed Sep 26 18:01:01 2012 +0300 @@ -71,6 +71,8 @@ mark the host as failed so we won't try to reconnect to it immediately */ #define DIRECTOR_SUCCESS_MIN_CONNECT_SECS 40 #define DIRECTOR_WAIT_DISCONNECT_SECS 10 +#define DIRECTOR_HANDSHAKE_WARN_SECS 29 +#define DIRECTOR_HANDSHAKE_BYTES_LOG_MIN_SECS (60*30) #if DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS <= DIRECTOR_CONNECTION_PING_TIMEOUT_MSECS # error DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS is too low @@ -92,6 +94,8 @@ /* for incoming connections the director host isn't known until ME-line is received */ struct director_host *host; + /* this is set only for wrong connections: */ + struct director_host *connect_request_to; int fd; struct io *io; @@ -118,7 +122,9 @@ }; From dovecot at dovecot.org Wed Sep 26 20:58:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 20:58:25 +0300 Subject: dovecot-2.2: lib-storage: mailbox_get_path() and friends can now... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c7a99d41e39e changeset: 15163:c7a99d41e39e user: Timo Sirainen date: Wed Sep 26 20:50:08 2012 +0300 description: lib-storage: mailbox_get_path() and friends can now return an error. An upcoming "index" mailbox_list backend uses mailbox GUIDs as the directory names. Doing a name => GUID lookup may fail, so the path lookup may fail. This is a somewhat annoying change and perhaps it can be removed in future, but for now it looks like it can't be avoided. diffstat: src/doveadm/dsync/doveadm-dsync.c | 11 +- src/indexer/master-connection.c | 21 +- src/lib-storage/index/dbox-common/dbox-storage.c | 19 +- src/lib-storage/index/dbox-multi/mdbox-map.c | 4 +- src/lib-storage/index/dbox-multi/mdbox-storage.c | 4 +- src/lib-storage/index/dbox-single/sdbox-file.c | 4 +- src/lib-storage/index/dbox-single/sdbox-storage.c | 2 + src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 5 +- src/lib-storage/index/imapc/imapc-list.c | 11 +- src/lib-storage/index/index-rebuild.c | 4 +- src/lib-storage/index/index-storage.c | 43 +++- src/lib-storage/index/index-sync-pvt.c | 10 +- src/lib-storage/index/index-sync.c | 14 +- src/lib-storage/index/maildir/maildir-keywords.c | 3 +- src/lib-storage/index/maildir/maildir-storage.c | 29 ++- src/lib-storage/index/maildir/maildir-uidlist.c | 13 +- src/lib-storage/index/maildir/maildir-util.c | 14 +- src/lib-storage/index/mbox/mbox-lock.c | 4 +- src/lib-storage/index/mbox/mbox-storage.c | 35 ++- src/lib-storage/index/mbox/mbox-sync.c | 2 +- src/lib-storage/index/shared/shared-list.c | 21 +- src/lib-storage/index/shared/shared-storage.c | 2 +- src/lib-storage/list/mailbox-list-delete.c | 32 ++- src/lib-storage/list/mailbox-list-fs-flags.c | 6 +- src/lib-storage/list/mailbox-list-fs-iter.c | 15 +- src/lib-storage/list/mailbox-list-fs.c | 118 ++++++++----- src/lib-storage/list/mailbox-list-index.c | 4 +- src/lib-storage/list/mailbox-list-maildir.c | 78 +++++--- src/lib-storage/list/mailbox-list-none.c | 9 +- src/lib-storage/mail-storage-private.h | 13 +- src/lib-storage/mail-storage.c | 83 ++++++--- src/lib-storage/mailbox-list-private.h | 10 +- src/lib-storage/mailbox-list.c | 139 +++++++++++----- src/lib-storage/mailbox-list.h | 23 +- src/plugins/acl/acl-backend-vfile-acllist.c | 10 +- src/plugins/acl/acl-backend-vfile.c | 43 ++-- src/plugins/acl/doveadm-acl.c | 6 +- src/plugins/fts-lucene/fts-backend-lucene.c | 6 +- src/plugins/fts-squat/fts-backend-squat.c | 4 +- src/plugins/fts/fts-storage.c | 3 +- src/plugins/mailbox-alias/mailbox-alias-plugin.c | 28 ++- src/plugins/quota/quota-dirsize.c | 12 +- src/plugins/quota/quota-fs.c | 12 +- src/plugins/quota/quota-maildir.c | 40 +++- src/plugins/quota/quota.c | 10 +- 45 files changed, 609 insertions(+), 370 deletions(-) diffs (truncated from 2147 to 300 lines): diff -r e3175ee39483 -r c7a99d41e39e src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Wed Sep 26 20:50:08 2012 +0300 @@ -257,11 +257,12 @@ "virtual mailbox hierarchy separator " "(specify separator for the default namespace)"); } - path1 = mailbox_list_get_root_path(user->namespaces->list, - MAILBOX_LIST_PATH_TYPE_MAILBOX); - path2 = mailbox_list_get_root_path(user2->namespaces->list, - MAILBOX_LIST_PATH_TYPE_MAILBOX); - if (path1 != NULL && path2 != NULL && + if (mailbox_list_get_root_path(user->namespaces->list, + MAILBOX_LIST_PATH_TYPE_MAILBOX, + &path1) && + mailbox_list_get_root_path(user2->namespaces->list, + MAILBOX_LIST_PATH_TYPE_MAILBOX, + &path2) && strcmp(path1, path2) == 0) { i_fatal("Both source and destination mail_location " "points to same directory: %s", path1); diff -r e3175ee39483 -r c7a99d41e39e src/indexer/master-connection.c --- a/src/indexer/master-connection.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/indexer/master-connection.c Wed Sep 26 20:50:08 2012 +0300 @@ -122,7 +122,7 @@ const char *path, *errstr; enum mail_error error; enum mailbox_sync_flags sync_flags = MAILBOX_SYNC_FLAG_FULL_READ; - int ret = 0; + int ret; ns = mail_namespace_find(user->namespaces, mailbox); if (ns == NULL) { @@ -131,20 +131,26 @@ } box = mailbox_alloc(ns->list, mailbox, 0); - path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); - if (*path == '\0') { + ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &path); + if (ret <= 0) { + mailbox_free(&box); + if (ret < 0) { + i_error("Getting path to mailbox %s failed: %s", + mailbox, mailbox_get_last_error(box, NULL)); + return -1; + } i_info("Indexes disabled for Mailbox %s, skipping", mailbox); - mailbox_free(&box); return 0; } - + ret = 0; + if (max_recent_msgs != 0) { /* index only if there aren't too many recent messages. don't bother syncing the mailbox, that alone can take a while with large maildirs. */ if (mailbox_open(box) < 0) { i_error("Opening mailbox %s failed: %s", mailbox, - mail_storage_get_last_error(mailbox_get_storage(box), NULL)); + mailbox_get_last_error(box, NULL)); ret = -1; } else { mailbox_get_open_status(box, STATUS_RECENT, &status); @@ -159,8 +165,7 @@ sync_flags |= MAILBOX_SYNC_FLAG_OPTIMIZE; if (mailbox_sync(box, sync_flags) < 0) { - errstr = mail_storage_get_last_error(mailbox_get_storage(box), - &error); + errstr = mailbox_get_last_error(box, &error); if (error != MAIL_ERROR_NOTFOUND) { i_error("Syncing mailbox %s failed: %s", mailbox, errstr); diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Wed Sep 26 20:50:08 2012 +0300 @@ -59,10 +59,11 @@ { const char *root_dir, *alt_symlink_path, *alt_path; - root_dir = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_DIR); + root_dir = mailbox_list_get_root_forced(list, MAILBOX_LIST_PATH_TYPE_DIR); alt_symlink_path = t_strconcat(root_dir, "/"DBOX_ALT_SYMLINK_NAME, NULL); - alt_path = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); + (void)mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, + &alt_path); if (!dbox_alt_path_has_changed(root_dir, alt_path, alt_symlink_path)) return; @@ -128,7 +129,7 @@ { const char *path; - path = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_CONTROL); + path = mailbox_list_get_root_forced(list, MAILBOX_LIST_PATH_TYPE_CONTROL); path = t_strconcat(path, "/"DBOX_UIDVALIDITY_FILE_NAME, NULL); return mailbox_uidvalidity_next(list, path); } @@ -140,7 +141,9 @@ if (box->notify_callback == NULL) index_mailbox_check_remove_all(box); else { - dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); + if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, + &dir) <= 0) + return; path = t_strdup_printf("%s/"DBOX_INDEX_PREFIX".log", dir); index_mailbox_check_add(box, path); } @@ -250,8 +253,8 @@ /* if alt path already exists and contains files, rebuild storage so that we don't start overwriting files. */ - alt_path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); - if (alt_path != NULL && stat(alt_path, &st) == 0) { + ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, &alt_path); + if (ret > 0 && stat(alt_path, &st) == 0) { ret = dir_is_empty(box->storage, alt_path); if (ret < 0) return -1; @@ -289,8 +292,8 @@ const char *alt_path; struct stat st; - alt_path = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_ALT_DIR); - if (alt_path == NULL) + if (!mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_ALT_DIR, + &alt_path)) return 0; /* make sure alt storage is mounted. if it's not, abort the rebuild. */ diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Wed Sep 26 20:50:08 2012 +0300 @@ -51,8 +51,8 @@ struct mdbox_map *map; const char *root, *index_root; - root = mailbox_list_get_root_path(root_list, MAILBOX_LIST_PATH_TYPE_DIR); - index_root = mailbox_list_get_root_path(root_list, MAILBOX_LIST_PATH_TYPE_INDEX); + root = mailbox_list_get_root_forced(root_list, MAILBOX_LIST_PATH_TYPE_DIR); + index_root = mailbox_list_get_root_forced(root_list, MAILBOX_LIST_PATH_TYPE_INDEX); map = i_new(struct mdbox_map, 1); map->storage = storage; diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Wed Sep 26 20:50:08 2012 +0300 @@ -52,7 +52,7 @@ _storage->unique_root_dir = p_strdup(_storage->pool, ns->list->set.root_dir); - dir = mailbox_list_get_root_path(ns->list, MAILBOX_LIST_PATH_TYPE_DIR); + dir = mailbox_list_get_root_forced(ns->list, MAILBOX_LIST_PATH_TYPE_DIR); storage->storage_dir = p_strconcat(_storage->pool, dir, "/"MDBOX_GLOBAL_DIR_NAME, NULL); storage->alt_storage_dir = p_strconcat(_storage->pool, @@ -203,6 +203,8 @@ const void *data; size_t data_size; + i_assert(mbox->box.opened); + mail_index_get_header_ext(mbox->box.view, mbox->hdr_ext_id, &data, &data_size); if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE && diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/dbox-single/sdbox-file.c --- a/src/lib-storage/index/dbox-single/sdbox-file.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-file.c Wed Sep 26 20:50:08 2012 +0300 @@ -25,8 +25,8 @@ file->file.primary_path = i_strdup_printf("%s/%s", mailbox_get_path(box), fname); - alt_path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); - if (alt_path != NULL) + if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, + &alt_path) > 0) file->file.alt_path = i_strdup_printf("%s/%s", alt_path, fname); } diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Wed Sep 26 20:50:08 2012 +0300 @@ -124,6 +124,8 @@ size_t data_size; int ret = 0; + i_assert(mbox->box.opened); + view = mail_index_view_open(mbox->box.index); mail_index_get_header_ext(view, mbox->hdr_ext_id, &data, &data_size); diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Wed Sep 26 20:50:08 2012 +0300 @@ -159,8 +159,9 @@ int ret = 0; path = mailbox_get_path(ctx->box); - alt_path = mailbox_get_path_to(ctx->box, - MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX); + if (mailbox_get_path_to(ctx->box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, + &alt_path) < 0) + return -1; sdbox_sync_set_uidvalidity(ctx); if (sdbox_sync_index_rebuild_dir(ctx, path, TRUE) < 0) { diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/imapc/imapc-list.c Wed Sep 26 20:50:08 2012 +0300 @@ -245,9 +245,9 @@ return mailbox_list_get_storage_name(fs_list, vname); } -static const char * +static int imapc_list_get_path(struct mailbox_list *_list, const char *name, - enum mailbox_list_path_type type) + enum mailbox_list_path_type type, const char **path_r) { struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list; struct mailbox_list *fs_list = imapc_list_get_fs(list); @@ -255,11 +255,10 @@ if (fs_list != NULL) { fs_name = imapc_list_get_fs_name(list, name); - return mailbox_list_get_path(fs_list, fs_name, type); + return mailbox_list_get_path(fs_list, fs_name, type, path_r); } else { - if (type == MAILBOX_LIST_PATH_TYPE_INDEX) - return ""; - return NULL; + *path_r = NULL; + return 0; } } diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/index-rebuild.c --- a/src/lib-storage/index/index-rebuild.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/index-rebuild.c Wed Sep 26 20:50:08 2012 +0300 @@ -167,7 +167,9 @@ mail_cache_reset(box->cache); /* if backup index file exists, try to use it */ - index_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); + if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, + &index_dir) <= 0) + i_unreached(); backup_path = t_strconcat(box->index_prefix, "/.backup", NULL); ctx->backup_index = mail_index_alloc(index_dir, backup_path); diff -r e3175ee39483 -r c7a99d41e39e src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed Sep 26 18:01:01 2012 +0300 +++ b/src/lib-storage/index/index-storage.c Wed Sep 26 20:50:08 2012 +0300 @@ -134,19 +134,21 @@ ibox->last_notify_type = MAILBOX_LOCK_NOTIFY_NONE; } -static struct mail_index * -index_mailbox_alloc_index(struct mailbox *box) +static int +index_mailbox_alloc_index(struct mailbox *box, struct mail_index **index_r) { const char *index_dir, *mailbox_path; - mailbox_path = mailbox_get_path(box); - index_dir = (box->flags & MAILBOX_FLAG_NO_INDEX_FILES) != 0 ? "" : - mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX); - if (*index_dir == '\0') + if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, + &mailbox_path) < 0) + return -1; + if ((box->flags & MAILBOX_FLAG_NO_INDEX_FILES) != 0 || + mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, + &index_dir) <= 0) index_dir = NULL; - - return mail_index_alloc_cache_get(mailbox_path, index_dir, - box->index_prefix); + *index_r = mail_index_alloc_cache_get(mailbox_path, index_dir, + box->index_prefix); + return 0; } int index_storage_mailbox_exists(struct mailbox *box, @@ -161,9 +163,17 @@ { struct stat st; const char *path, *path2; + int ret; /* see if it's selectable */ - path = mailbox_get_path(box); + ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &path); + if (ret < 0) + return -1; + if (ret == 0) { From dovecot at dovecot.org Wed Sep 26 21:12:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 21:12:47 +0300 Subject: dovecot-2.1: lazy-expunge: Fixed handling non-default namespace ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4e431b202cfd changeset: 14734:4e431b202cfd user: Timo Sirainen date: Wed Sep 26 21:12:37 2012 +0300 description: lazy-expunge: Fixed handling non-default namespace separator. diffstat: src/plugins/lazy-expunge/lazy-expunge-plugin.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diffs (27 lines): diff -r 4d82c74f702c -r 4e431b202cfd src/plugins/lazy-expunge/lazy-expunge-plugin.c --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Mon Sep 24 17:03:42 2012 +0300 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Wed Sep 26 21:12:37 2012 +0300 @@ -70,11 +70,11 @@ const char *name; char src_sep, dest_sep; - /* get the storage name, so it doesn't have namespace prefix */ + /* use the (canonical / unaliased) storage name */ name = src_box->name; - /* replace hierarchy separators with destination separator */ + /* replace hierarchy separators with destination virtual separator */ src_sep = mailbox_list_get_hierarchy_sep(src_box->list); - dest_sep = mailbox_list_get_hierarchy_sep(list); + dest_sep = mail_namespace_get_sep(list->ns); if (src_sep != dest_sep) { string_t *str = t_str_new(128); unsigned int i; @@ -87,7 +87,7 @@ } name = str_c(str); } - /* add expunge namespace prefix */ + /* add expunge namespace prefix. the name is now a proper vname */ name = t_strconcat(list->ns->prefix, name, NULL); box = mailbox_alloc(list, name, MAILBOX_FLAG_NO_INDEX_FILES); From dovecot at dovecot.org Wed Sep 26 21:14:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 26 Sep 2012 21:14:30 +0300 Subject: dovecot-2.1: i_getpwnam(): Ignore EINVAL errors silently. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9dcc44d8275d changeset: 14735:9dcc44d8275d user: Timo Sirainen date: Wed Sep 26 21:14:23 2012 +0300 description: i_getpwnam(): Ignore EINVAL errors silently. At least FreeBSD returns it when attempting to lookup user at domain. diffstat: src/lib/ipwd.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 4e431b202cfd -r 9dcc44d8275d src/lib/ipwd.c --- a/src/lib/ipwd.c Wed Sep 26 21:12:37 2012 +0300 +++ b/src/lib/ipwd.c Wed Sep 26 21:14:23 2012 +0300 @@ -58,6 +58,10 @@ errno = getpwnam_r(name, pwd_r, pwbuf, pwbuf_size, &result); if (result != NULL) return 1; + if (errno == EINVAL) { + /* FreeBSD fails here when name="user at domain" */ + return 0; + } return errno == 0 ? 0 : -1; } From pigeonhole at rename-it.nl Wed Sep 26 22:54:11 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 26 Sep 2012 21:54:11 +0200 Subject: dovecot-2.1-pigeonhole: testsuite: date extension: Added test fo... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/1963a329c539 changeset: 1655:1963a329c539 user: Stephan Bosch date: Wed Sep 26 21:52:32 2012 +0200 description: testsuite: date extension: Added test for date comparisons. diffstat: tests/extensions/date/basic.svtest | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diffs (40 lines): diff -r bf7b7aa7f667 -r 1963a329c539 tests/extensions/date/basic.svtest --- a/tests/extensions/date/basic.svtest Wed Sep 26 21:51:46 2012 +0200 +++ b/tests/extensions/date/basic.svtest Wed Sep 26 21:52:32 2012 +0200 @@ -39,3 +39,36 @@ test_fail "matched invalid date: ${0}"; } } + +test "Comparison" { + if not date :is "delivery-date" "date" "2009-07-22" { + if date :matches "delivery-date" "date" "*" { set "date" "${1}"; } + test_fail "date is invalid: ${date}"; + } + + if not date :value "ge" "delivery-date" "date" "2009-07-22" { + test_fail "date comparison ge failed equal"; + } + + if not date :value "ge" "delivery-date" "date" "2009-07-21" { + test_fail "date comparison ge failed greater"; + } + + if anyof (not date :value "ge" "delivery-date" "date" "2009-06-22", + not date :value "ge" "date" "date" "2006-07-22" ) { + test_fail "date comparison ge failed much greater"; + } + + if not date :value "le" "delivery-date" "date" "2009-07-22" { + test_fail "date comparison le failed equal"; + } + + if not date :value "le" "delivery-date" "date" "2009-07-23" { + test_fail "date comparison le failed less"; + } + + if anyof (not date :value "le" "delivery-date" "date" "2009-09-22", + not date :value "le" "date" "date" "2012-07-22" ) { + test_fail "date comparison ge failed much less"; + } +} From pigeonhole at rename-it.nl Wed Sep 26 22:54:11 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 26 Sep 2012 21:54:11 +0200 Subject: dovecot-2.1-pigeonhole: lib-sieve: date extension: Generate warn... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/bf7b7aa7f667 changeset: 1654:bf7b7aa7f667 user: Stephan Bosch date: Wed Sep 26 21:51:46 2012 +0200 description: lib-sieve: date extension: Generate warning when invalid date part is specified. diffstat: src/lib-sieve/plugins/date/ext-date-common.c | 23 +++++++++++++-------- src/lib-sieve/plugins/date/ext-date-common.h | 6 +++- src/lib-sieve/plugins/date/tst-date.c | 30 ++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 17 deletions(-) diffs (175 lines): diff -r fcd5208ed8b2 -r bf7b7aa7f667 src/lib-sieve/plugins/date/ext-date-common.c --- a/src/lib-sieve/plugins/date/ext-date-common.c Sun Sep 23 17:09:26 2012 +0200 +++ b/src/lib-sieve/plugins/date/ext-date-common.c Wed Sep 26 21:51:46 2012 +0200 @@ -282,23 +282,28 @@ unsigned int date_parts_count = N_ELEMENTS(date_parts); -const char *ext_date_part_extract -(const char *part, struct tm *tm, int zone_offset) +const struct ext_date_part *ext_date_part_find(const char *part) { unsigned int i; for ( i = 0; i < date_parts_count; i++ ) { if ( strcasecmp(date_parts[i]->identifier, part) == 0 ) { - if ( date_parts[i]->get_string != NULL ) - return date_parts[i]->get_string(tm, zone_offset); - - return NULL; + return date_parts[i]; } } return NULL; } +const char *ext_date_part_extract +(const struct ext_date_part *dpart, struct tm *tm, int zone_offset) +{ + if ( dpart == NULL || dpart->get_string == NULL ) + return NULL; + + return dpart->get_string(tm, zone_offset); +} + /* * Date part implementations */ @@ -486,7 +491,7 @@ struct sieve_stringlist *field_values; int time_zone; - const char *date_part; + const struct ext_date_part *date_part; time_t local_time; int local_zone; @@ -496,7 +501,7 @@ struct sieve_stringlist *ext_date_stringlist_create (const struct sieve_runtime_env *renv, struct sieve_stringlist *field_values, - int time_zone, const char *date_part) + int time_zone, const struct ext_date_part *dpart) { struct ext_date_stringlist *strlist; @@ -507,7 +512,7 @@ strlist->strlist.reset = ext_date_stringlist_reset; strlist->field_values = field_values; strlist->time_zone = time_zone; - strlist->date_part = date_part; + strlist->date_part = dpart; strlist->local_time = ext_date_get_current_date(renv, &strlist->local_zone); diff -r fcd5208ed8b2 -r bf7b7aa7f667 src/lib-sieve/plugins/date/ext-date-common.h --- a/src/lib-sieve/plugins/date/ext-date-common.h Sun Sep 23 17:09:26 2012 +0200 +++ b/src/lib-sieve/plugins/date/ext-date-common.h Wed Sep 26 21:51:46 2012 +0200 @@ -60,8 +60,10 @@ const char *(*get_string)(struct tm *tm, int zone_offset); }; +const struct ext_date_part *ext_date_part_find(const char *part); + const char *ext_date_part_extract - (const char *part, struct tm *tm, int zone_offset); + (const struct ext_date_part *dpart, struct tm *tm, int zone_offset); /* * Date stringlist @@ -74,7 +76,7 @@ struct sieve_stringlist *ext_date_stringlist_create (const struct sieve_runtime_env *renv, struct sieve_stringlist *field_values, - int time_zone, const char *date_part); + int time_zone, const struct ext_date_part *dpart); diff -r fcd5208ed8b2 -r bf7b7aa7f667 src/lib-sieve/plugins/date/tst-date.c --- a/src/lib-sieve/plugins/date/tst-date.c Sun Sep 23 17:09:26 2012 +0200 +++ b/src/lib-sieve/plugins/date/tst-date.c Wed Sep 26 21:51:46 2012 +0200 @@ -260,7 +260,7 @@ return FALSE; if ( !sieve_command_verify_headers_argument(valdtr, arg) ) - return FALSE; + return FALSE; arg = sieve_ast_argument_next(arg); } @@ -275,6 +275,16 @@ if ( !sieve_validator_argument_activate(valdtr, tst, arg, FALSE) ) return FALSE; + if ( sieve_argument_is_string_literal(arg) ) { + const char * part = sieve_ast_argument_strc(arg); + + if ( ext_date_part_find(part) == NULL ) { + sieve_argument_validate_warning + (valdtr, arg, "specified date part `%s' is not known", + str_sanitize(part, 80)); + } + } + arg = sieve_ast_argument_next(arg); /* Check key list */ @@ -349,7 +359,7 @@ if ( !sieve_opr_string_dump_ex(denv, address, "zone", "ORIGINAL") ) return FALSE; break; - default: + default: return FALSE; } } @@ -381,6 +391,7 @@ struct sieve_stringlist *hdr_list = NULL, *hdr_value_list; struct sieve_stringlist *value_list, *key_list; bool zone_specified = FALSE, zone_literal = TRUE; + const struct ext_date_part *dpart; int time_zone; int match, ret; @@ -433,11 +444,19 @@ } else if ( !ext_date_parse_timezone(str_c(zone), &time_zone) ) { if ( !zone_literal ) sieve_runtime_warning(renv, NULL, - "specified :zone argument '%s' is not a valid timezone " + "specified :zone argument `%s' is not a valid timezone " "(using local zone)", str_sanitize(str_c(zone), 40)); time_zone = EXT_DATE_TIMEZONE_LOCAL; } + if ( (dpart=ext_date_part_find(str_c(date_part))) == NULL ) { + sieve_runtime_warning(renv, NULL, + "specified date part argument `%s' is not known", + str_sanitize(str_c(date_part), 40)); + sieve_interpreter_set_test_result(renv->interp, FALSE); + return SIEVE_EXEC_OK; + } + /* * Perform test */ @@ -449,7 +468,7 @@ /* Create value stringlist */ hdr_value_list = sieve_message_header_stringlist_create(renv, hdr_list, FALSE); value_list = ext_date_stringlist_create - (renv, hdr_value_list, time_zone, str_c(date_part)); + (renv, hdr_value_list, time_zone, dpart); } else if ( sieve_operation_is(op, currentdate_operation) ) { /* Use time stamp recorded at the time the script first started */ @@ -457,8 +476,7 @@ sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, "currentdatedate test"); /* Create value stringlist */ - value_list = ext_date_stringlist_create - (renv, NULL, time_zone, str_c(date_part)); + value_list = ext_date_stringlist_create(renv, NULL, time_zone, dpart); } else { i_unreached(); } From dovecot at dovecot.org Thu Sep 27 02:55:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Sep 2012 02:55:32 +0300 Subject: dovecot-2.1: doveadm altmove: Make sure all storages get purged ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4819306a1f9f changeset: 14736:4819306a1f9f user: Timo Sirainen date: Thu Sep 27 00:19:41 2012 +0300 description: doveadm altmove: Make sure all storages get purged (and not more than once) diffstat: src/doveadm/doveadm-mail-altmove.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (24 lines): diff -r 9dcc44d8275d -r 4819306a1f9f src/doveadm/doveadm-mail-altmove.c --- a/src/doveadm/doveadm-mail-altmove.c Wed Sep 26 21:14:23 2012 +0300 +++ b/src/doveadm/doveadm-mail-altmove.c Thu Sep 27 00:19:41 2012 +0300 @@ -87,6 +87,12 @@ if (doveadm_mailbox_list_iter_deinit(&iter) < 0) ret = -1; + if (prev_ns != NULL) { + if (ns_purge(_ctx, prev_ns) < 0) + ret = -1; + array_append(&purged_storages, &prev_ns->storage, 1); + } + /* make sure all private storages have been purged */ storages = array_get(&purged_storages, &count); for (ns = user->namespaces; ns != NULL; ns = ns->next) { @@ -101,6 +107,7 @@ if (ns_purge(_ctx, ns) < 0) ret = -1; array_append(&purged_storages, &ns->storage, 1); + storages = array_get(&purged_storages, &count); } } return ret; From dovecot at dovecot.org Thu Sep 27 02:55:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 27 Sep 2012 02:55:32 +0300 Subject: dovecot-2.1: mdbox: Don't crash in storage rebuild if mail's "or... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/88a05f387743 changeset: 14737:88a05f387743 user: Timo Sirainen date: Thu Sep 27 02:55:14 2012 +0300 description: mdbox: Don't crash in storage rebuild if mail's "original mailbox" metadata is missing. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (16 lines): diff -r 4819306a1f9f -r 88a05f387743 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Sep 27 00:19:41 2012 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Sep 27 02:55:14 2012 +0300 @@ -605,8 +605,10 @@ if (ret > 0 && !deleted && dbox_file_metadata_read(file) > 0) { mailbox = dbox_file_metadata_get(file, DBOX_METADATA_ORIG_MAILBOX); - mailbox = mailbox_list_get_vname(ctx->default_list, mailbox); - mailbox = t_strdup(mailbox); + if (mailbox != NULL) { + mailbox = mailbox_list_get_vname(ctx->default_list, mailbox); + mailbox = t_strdup(mailbox); + } } dbox_file_unref(&file); if (ret <= 0 || deleted) { From dovecot at dovecot.org Fri Sep 28 00:11:34 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 00:11:34 +0300 Subject: dovecot-2.2: lib-storage: If trying to rename mailbox over itsel... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/35b9e155f03f changeset: 15165:35b9e155f03f user: Timo Sirainen date: Fri Sep 28 00:00:16 2012 +0300 description: lib-storage: If trying to rename mailbox over itself, fail early. diffstat: src/lib-storage/mail-storage.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r e3639ddbba2f -r 35b9e155f03f src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Sep 27 23:58:54 2012 +0300 +++ b/src/lib-storage/mail-storage.c Fri Sep 28 00:00:16 2012 +0300 @@ -1320,6 +1320,11 @@ "Renaming not supported across non-private namespaces."); return -1; } + if (src->list == dest->list && strcmp(src->name, dest->name) == 0) { + mail_storage_set_error(src->storage, MAIL_ERROR_EXISTS, + "Can't rename mailbox to itself."); + return -1; + } return src->v.rename_box(src, dest); } From dovecot at dovecot.org Fri Sep 28 00:11:34 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 00:11:34 +0300 Subject: dovecot-2.2: doveadm dump -t index: Added support for mailbox li... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e3639ddbba2f changeset: 15164:e3639ddbba2f user: Timo Sirainen date: Thu Sep 27 23:58:54 2012 +0300 description: doveadm dump -t index: Added support for mailbox list index records. diffstat: src/doveadm/doveadm-dump-index.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diffs (29 lines): diff -r c7a99d41e39e -r e3639ddbba2f src/doveadm/doveadm-dump-index.c --- a/src/doveadm/doveadm-dump-index.c Wed Sep 26 20:50:08 2012 +0300 +++ b/src/doveadm/doveadm-dump-index.c Thu Sep 27 23:58:54 2012 +0300 @@ -45,6 +45,12 @@ uint32_t map_uid; uint32_t save_date; }; +struct mailbox_list_index_record { + uint32_t name_id; + uint32_t parent_uid; + guid_128_t guid; + uint32_t uid_validity; +}; struct fts_index_header { uint32_t last_indexed_uid; @@ -550,6 +556,12 @@ const struct mdbox_mail_index_record *drec = data; printf(" : map_uid = %u\n", drec->map_uid); printf(" : save_date = %u (%s)\n", drec->save_date, unixdate2str(drec->save_date)); + } else if (strcmp(ext[i].name, "list") == 0) { + const struct mailbox_list_index_record *lrec = data; + printf(" : name_id = %u\n", lrec->name_id); + printf(" : parent_uid = %u\n", lrec->parent_uid); + printf(" : guid = %s\n", guid_128_to_string(lrec->guid)); + printf(" : uid_validity = %u\n", lrec->uid_validity); } } } From dovecot at dovecot.org Fri Sep 28 00:11:34 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 00:11:34 +0300 Subject: dovecot-2.2: lib-storage: Do mailbox autocreation elsewhere also... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/55ab35b0cc22 changeset: 15166:55ab35b0cc22 user: Timo Sirainen date: Fri Sep 28 00:03:12 2012 +0300 description: lib-storage: Do mailbox autocreation elsewhere also besides just mailbox_open() diffstat: src/lib-storage/mail-storage.c | 128 ++++++++++++++++++++++------------------ 1 files changed, 70 insertions(+), 58 deletions(-) diffs (172 lines): diff -r 35b9e155f03f -r 55ab35b0cc22 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Fri Sep 28 00:00:16 2012 +0300 +++ b/src/lib-storage/mail-storage.c Fri Sep 28 00:03:12 2012 +0300 @@ -709,6 +709,59 @@ return box; } +static bool mailbox_is_autocreated(struct mailbox *box) +{ + if (box->inbox_user) + return TRUE; + return box->set != NULL && + strcmp(box->set->autocreate, MAILBOX_SET_AUTO_NO) != 0; +} + +static int mailbox_autocreate(struct mailbox *box) +{ + const char *errstr; + enum mail_error error; + + if (mailbox_create(box, NULL, FALSE) < 0) { + errstr = mailbox_get_last_error(box, &error); + if (error != MAIL_ERROR_NOTFOUND) { + mail_storage_set_critical(box->storage, + "Failed to autocreate mailbox %s: %s", + box->vname, errstr); + return -1; + } + } else if (box->set != NULL && + strcmp(box->set->autocreate, + MAILBOX_SET_AUTO_SUBSCRIBE) == 0) { + if (mailbox_set_subscribed(box, TRUE) < 0) { + mail_storage_set_critical(box->storage, + "Failed to autosubscribe to mailbox %s: %s", + box->vname, mailbox_get_last_error(box, NULL)); + return -1; + } + } + return 0; +} + +static int mailbox_autocreate_and_reopen(struct mailbox *box) +{ + int ret; + + if (mailbox_autocreate(box) < 0) + return -1; + mailbox_close(box); + + ret = box->v.open(box); + if (ret < 0 && box->inbox_user && + !box->storage->user->inbox_open_error_logged) { + box->storage->user->inbox_open_error_logged = TRUE; + mail_storage_set_critical(box->storage, + "Opening INBOX failed: %s", + mailbox_get_last_error(box, NULL)); + } + return ret; +} + static bool mailbox_name_verify_separators(const char *vname, char sep, const char **error_r) @@ -794,14 +847,27 @@ { const char *path; + if (box->opened) + return 0; + if (mailbox_verify_name(box) < 0) return -1; /* Make sure box->_path is set, so mailbox_get_path() works from now on. Note that this may also fail with some backends if the mailbox doesn't exist. */ - if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &path) < 0) - return -1; + if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &path) < 0) { + if (box->storage->error != MAIL_ERROR_NOTFOUND || + !mailbox_is_autocreated(box)) + return -1; + /* if this is an autocreated mailbox, create it now */ + if (mailbox_autocreate(box) < 0) + return -1; + mailbox_close(box); + if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, + &path) < 0) + return -1; + } return 0; } @@ -862,14 +928,6 @@ return FALSE; } -static bool mailbox_is_autocreated(struct mailbox *box) -{ - if (box->inbox_user) - return TRUE; - return box->set != NULL && - strcmp(box->set->autocreate, MAILBOX_SET_AUTO_NO) != 0; -} - int mailbox_exists(struct mailbox *box, bool auto_boxes, enum mailbox_existence *existence_r) { @@ -883,9 +941,8 @@ /* unsure if this exists or not */ return -1; } - if (mailbox_verify_existing_name(box) < 0) { - /* either the name is invalid or the mailbox doesn't exist. - if it's invalid we don't currently know if the mailbox + if (mailbox_verify_name(box) < 0) { + /* the mailbox name is invalid. we don't know if it currently exists or not, but since it can never be accessed in any way report it as if it didn't exist. */ *existence_r = MAILBOX_EXISTENCE_NONE; @@ -915,51 +972,6 @@ return 0; } -static int mailbox_autocreate(struct mailbox *box) -{ - const char *errstr; - enum mail_error error; - - if (mailbox_create(box, NULL, FALSE) < 0) { - errstr = mailbox_get_last_error(box, &error); - if (error != MAIL_ERROR_NOTFOUND) { - mail_storage_set_critical(box->storage, - "Failed to autocreate mailbox %s: %s", - box->vname, errstr); - return -1; - } - } else if (box->set != NULL && - strcmp(box->set->autocreate, - MAILBOX_SET_AUTO_SUBSCRIBE) == 0) { - if (mailbox_set_subscribed(box, TRUE) < 0) { - mail_storage_set_critical(box->storage, - "Failed to autosubscribe to mailbox %s: %s", - box->vname, mailbox_get_last_error(box, NULL)); - return -1; - } - } - return 0; -} - -static int mailbox_autocreate_and_reopen(struct mailbox *box) -{ - int ret; - - if (mailbox_autocreate(box) < 0) - return -1; - mailbox_close(box); - - ret = box->v.open(box); - if (ret < 0 && box->inbox_user && - !box->storage->user->inbox_open_error_logged) { - box->storage->user->inbox_open_error_logged = TRUE; - mail_storage_set_critical(box->storage, - "Opening INBOX failed: %s", - mailbox_get_last_error(box, NULL)); - } - return ret; -} - static int ATTR_NULL(2) mailbox_open_full(struct mailbox *box, struct istream *input) { From dovecot at dovecot.org Fri Sep 28 00:11:35 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 00:11:35 +0300 Subject: dovecot-2.2: lib-storage: Added initial implementation for layou... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0fa075f2e85a changeset: 15167:0fa075f2e85a user: Timo Sirainen date: Fri Sep 28 00:11:19 2012 +0300 description: lib-storage: Added initial implementation for layout=index. The idea is that all of the mailbox names only exist in the mailbox list index. Storage directories use mailbox GUIDs. This avoids all kinds of race conditions with mailbox renames. mailbox_list_index=yes is required for this layout to work. There are probably still some race conditions within the indexing code itself. Also error recovery is missing. diffstat: configure.in | 2 +- src/lib-storage/list/Makefile.am | 3 + src/lib-storage/list/mailbox-list-delete.c | 11 +- src/lib-storage/list/mailbox-list-delete.h | 2 +- src/lib-storage/list/mailbox-list-fs.c | 9 +- src/lib-storage/list/mailbox-list-index-backend.c | 586 ++++++++++++++++++++++ src/lib-storage/list/mailbox-list-index-iter.c | 30 +- src/lib-storage/list/mailbox-list-index-notify.c | 8 +- src/lib-storage/list/mailbox-list-index-status.c | 34 +- src/lib-storage/list/mailbox-list-index-storage.h | 16 + src/lib-storage/list/mailbox-list-index-sync.c | 191 ++++--- src/lib-storage/list/mailbox-list-index-sync.h | 32 + src/lib-storage/list/mailbox-list-index.c | 159 ++++- src/lib-storage/list/mailbox-list-index.h | 14 +- src/lib-storage/list/mailbox-list-maildir.c | 9 +- 15 files changed, 936 insertions(+), 170 deletions(-) diffs (truncated from 1541 to 300 lines): diff -r 55ab35b0cc22 -r 0fa075f2e85a configure.in --- a/configure.in Fri Sep 28 00:03:12 2012 +0300 +++ b/configure.in Fri Sep 28 00:11:19 2012 +0300 @@ -2463,7 +2463,7 @@ LINKED_STORAGE_LIBS= -mailbox_list_drivers="maildir imapdir none fs shared" +mailbox_list_drivers="maildir imapdir fs index none shared" have_sdbox=no for storage in $mail_storages; do LINKED_STORAGE_LIBS="$LINKED_STORAGE_LIBS `eval echo \\$${storage}_libs`" diff -r 55ab35b0cc22 -r 0fa075f2e85a src/lib-storage/list/Makefile.am --- a/src/lib-storage/list/Makefile.am Fri Sep 28 00:03:12 2012 +0300 +++ b/src/lib-storage/list/Makefile.am Fri Sep 28 00:11:19 2012 +0300 @@ -14,6 +14,7 @@ mailbox-list-fs-flags.c \ mailbox-list-fs-iter.c \ mailbox-list-index.c \ + mailbox-list-index-backend.c \ mailbox-list-index-iter.c \ mailbox-list-index-notify.c \ mailbox-list-index-status.c \ @@ -30,6 +31,8 @@ mailbox-list-delete.h \ mailbox-list-fs.h \ mailbox-list-index.h \ + mailbox-list-index-storage.h \ + mailbox-list-index-sync.h \ mailbox-list-maildir.h \ mailbox-list-notify-tree.h \ mailbox-list-subscriptions.h \ diff -r 55ab35b0cc22 -r 0fa075f2e85a src/lib-storage/list/mailbox-list-delete.c --- a/src/lib-storage/list/mailbox-list-delete.c Fri Sep 28 00:03:12 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-delete.c Fri Sep 28 00:11:19 2012 +0300 @@ -119,17 +119,8 @@ } int mailbox_list_delete_mailbox_file(struct mailbox_list *list, - const char *name) + const char *name, const char *path) { - const char *path; - int ret; - - ret = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_MAILBOX, - &path); - if (ret < 0) - return -1; - i_assert(ret > 0); - /* we can simply unlink() the file */ if (unlink(path) == 0) return 0; diff -r 55ab35b0cc22 -r 0fa075f2e85a src/lib-storage/list/mailbox-list-delete.h --- a/src/lib-storage/list/mailbox-list-delete.h Fri Sep 28 00:03:12 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-delete.h Fri Sep 28 00:11:19 2012 +0300 @@ -7,7 +7,7 @@ const char *name, const char *trash_dir); int mailbox_list_delete_mailbox_file(struct mailbox_list *list, - const char *name); + const char *name, const char *path); int mailbox_list_delete_mailbox_nonrecursive(struct mailbox_list *list, const char *name, const char *path, bool rmdir_path); diff -r 55ab35b0cc22 -r 0fa075f2e85a src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Fri Sep 28 00:03:12 2012 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Fri Sep 28 00:11:19 2012 +0300 @@ -225,10 +225,17 @@ static int fs_list_delete_mailbox(struct mailbox_list *list, const char *name) { + const char *path; int ret; if ((list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0) { - ret = mailbox_list_delete_mailbox_file(list, name); + ret = mailbox_list_get_path(list, name, + MAILBOX_LIST_PATH_TYPE_MAILBOX, + &path); + if (ret < 0) + return -1; + i_assert(ret > 0); + ret = mailbox_list_delete_mailbox_file(list, name, path); } else { ret = fs_list_delete_maildir(list, name); } diff -r 55ab35b0cc22 -r 0fa075f2e85a src/lib-storage/list/mailbox-list-index-backend.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/list/mailbox-list-index-backend.c Fri Sep 28 00:11:19 2012 +0300 @@ -0,0 +1,586 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "hostpid.h" +#include "mail-index.h" +#include "subscription-file.h" +#include "mailbox-list-delete.h" +#include "mailbox-list-subscriptions.h" +#include "mailbox-list-index-storage.h" +#include "mailbox-list-index-sync.h" + +#define GLOBAL_TEMP_PREFIX ".temp." + +struct index_mailbox_list { + struct mailbox_list list; + const char *temp_prefix; +}; + +extern struct mailbox_list index_mailbox_list; + +static struct mailbox_list *index_list_alloc(void) +{ + struct index_mailbox_list *list; + pool_t pool; + + pool = pool_alloconly_create("index list", 2048); + + list = p_new(pool, struct index_mailbox_list, 1); + list->list = index_mailbox_list; + list->list.pool = pool; + + list->temp_prefix = p_strconcat(pool, GLOBAL_TEMP_PREFIX, + my_hostname, ".", my_pid, ".", NULL); + return &list->list; +} + +static void index_list_deinit(struct mailbox_list *_list) +{ + struct index_mailbox_list *list = (struct index_mailbox_list *)_list; + + pool_unref(&list->list.pool); +} + +static char index_list_get_hierarchy_sep(struct mailbox_list *list ATTR_UNUSED) +{ + return MAILBOX_LIST_INDEX_HIERARHCY_SEP; +} + +static int +index_list_get_node(struct index_mailbox_list *list, const char *name, + struct mailbox_list_index_node **node_r) +{ + struct mailbox_list_index_node *node; + + if (mailbox_list_index_refresh(&list->list) < 0) + return -1; + + node = mailbox_list_index_lookup(&list->list, name); + if (node == NULL) + return 0; + *node_r = node; + return 1; +} + +static int +index_list_get_path(struct mailbox_list *_list, const char *name, + enum mailbox_list_path_type type, const char **path_r) +{ + struct index_mailbox_list *list = (struct index_mailbox_list *)_list; + struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(_list); + struct mail_index_view *view; + struct mailbox_list_index_node *node; + struct mailbox_status status; + guid_128_t mailbox_guid; + const char *root_dir; + uint32_t seq; + int ret; + + if (name == NULL) { + /* return root directories */ + return mailbox_list_set_get_root_path(&_list->set, type, + path_r) ? 1 : 0; + } + /* consistently use mailbox_dir_name as part of all mailbox + directories (index/control/etc) */ + switch (type) { + case MAILBOX_LIST_PATH_TYPE_MAILBOX: + type = MAILBOX_LIST_PATH_TYPE_DIR; + break; + case MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX: + type = MAILBOX_LIST_PATH_TYPE_ALT_DIR; + break; + default: + break; + } + if (!mailbox_list_set_get_root_path(&_list->set, type, &root_dir)) + return 0; + + if ((ret = index_list_get_node(list, name, &node)) <= 0) { + if (ret == 0) { + mailbox_list_set_error(_list, MAIL_ERROR_NOTFOUND, + T_MAIL_ERR_MAILBOX_NOT_FOUND(name)); + } + return -1; + } + view = mail_index_view_open(ilist->index); + if (!mail_index_lookup_seq(view, node->uid, &seq)) + i_panic("mailbox list index: lost uid=%u", node->uid); + if (!mailbox_list_index_status(_list, view, seq, 0, + &status, mailbox_guid)) { + mailbox_list_set_error(_list, MAIL_ERROR_NOTFOUND, + T_MAIL_ERR_MAILBOX_NOT_FOUND(name)); + ret = -1; + } else if (_list->set.mailbox_dir_name == '\0') { + *path_r = t_strconcat(root_dir, "/", + guid_128_to_string(mailbox_guid), NULL); + ret = 1; + } else { + *path_r = t_strdup_printf("%s/%s%s", root_dir, + _list->set.mailbox_dir_name, + guid_128_to_string(mailbox_guid)); + ret = 1; + } + mail_index_view_close(&view); + return ret; +} + +static const char * +index_list_get_temp_prefix(struct mailbox_list *_list, bool global) +{ + struct index_mailbox_list *list = (struct index_mailbox_list *)_list; + + return global ? GLOBAL_TEMP_PREFIX : list->temp_prefix; +} + +static int index_list_set_subscribed(struct mailbox_list *_list, + const char *name, bool set) +{ + struct index_mailbox_list *list = (struct index_mailbox_list *)_list; + const char *path; + + path = t_strconcat(_list->set.control_dir != NULL ? + _list->set.control_dir : _list->set.root_dir, + "/", _list->set.subscription_fname, NULL); + return subsfile_set_subscribed(_list, path, list->temp_prefix, + name, set); +} + +static int +index_list_node_exists(struct index_mailbox_list *list, const char *name, + enum mailbox_existence *existence_r) +{ + struct mailbox_list_index_node *node; + int ret; + + *existence_r = MAILBOX_EXISTENCE_NONE; + + if ((ret = index_list_get_node(list, name, &node)) < 0) + return -1; + if (ret == 0) + return 0; + + if ((node->flags & (MAILBOX_LIST_INDEX_FLAG_NONEXISTENT | + MAILBOX_LIST_INDEX_FLAG_NOSELECT)) == 0) { + /* selectable */ + *existence_r = MAILBOX_EXISTENCE_SELECT; + } else { + /* non-selectable */ + *existence_r = MAILBOX_EXISTENCE_NOSELECT; + } + return 0; +} + +static int +index_list_mailbox_create_dir(struct index_mailbox_list *list, const char *name) +{ + struct mailbox_list_index_sync_context *sync_ctx; + struct mailbox_list_index_node *node; + uint32_t seq; + bool created; + int ret; + + if (mailbox_list_index_sync_begin(&list->list, &sync_ctx) < 0) + return -1; + + seq = mailbox_list_index_sync_name(sync_ctx, name, &node, &created); + if (created || (node->flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0) { + /* didn't already exist */ + node->flags = MAILBOX_LIST_INDEX_FLAG_NOSELECT; + mail_index_update_flags(sync_ctx->trans, seq, MODIFY_REPLACE, + (enum mail_flags)node->flags); + ret = 1; + } else { + /* already existed */ + ret = 0; + } + if (mailbox_list_index_sync_end(&sync_ctx, TRUE) < 0) + ret = -1; + return ret; +} + +static int +index_list_mailbox_create_selectable(struct index_mailbox_list *list, + const char *name, guid_128_t mailbox_guid) +{ + struct mailbox_list_index_sync_context *sync_ctx; + struct mailbox_list_index_record rec; + struct mailbox_list_index_node *node; From dovecot at dovecot.org Fri Sep 28 02:19:17 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 02:19:17 +0300 Subject: dovecot-2.2: maildir: Directories were created without execute-p... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1dafaabeb134 changeset: 15168:1dafaabeb134 user: Timo Sirainen date: Fri Sep 28 02:19:07 2012 +0300 description: maildir: Directories were created without execute-permissions Broken by recent changes. diffstat: src/lib-storage/index/maildir/maildir-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 0fa075f2e85a -r 1dafaabeb134 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Fri Sep 28 00:11:19 2012 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Fri Sep 28 02:19:07 2012 +0300 @@ -172,7 +172,7 @@ } perm = mailbox_get_permissions(box); - if (mkdir_parents_chgrp(dir, perm->file_create_mode, + if (mkdir_parents_chgrp(dir, perm->dir_create_mode, perm->file_create_gid, perm->file_create_gid_origin) == 0) return 0; From dovecot at dovecot.org Fri Sep 28 15:07:20 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 15:07:20 +0300 Subject: dovecot-2.2: Avoid using PATH_MAX. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/48ee8bad7d51 changeset: 15169:48ee8bad7d51 user: Timo Sirainen date: Fri Sep 28 15:07:11 2012 +0300 description: Avoid using PATH_MAX. diffstat: src/lib-master/master-instance.c | 2 +- src/lib-storage/index/dbox-common/dbox-storage.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diffs (46 lines): diff -r 1dafaabeb134 -r 48ee8bad7d51 src/lib-master/master-instance.c --- a/src/lib-master/master-instance.c Fri Sep 28 02:19:07 2012 +0300 +++ b/src/lib-master/master-instance.c Fri Sep 28 15:07:11 2012 +0300 @@ -110,7 +110,7 @@ i_error("open(%s) failed: %m", list->path); return -1; } - input = i_stream_create_fd(fd, PATH_MAX, TRUE); + input = i_stream_create_fd(fd, (size_t)-1, TRUE); while ((line = i_stream_read_next_line(input)) != NULL) T_BEGIN { if (master_instance_list_add_line(list, line) < 0) i_error("Invalid line in %s: %s", list->path, line); diff -r 1dafaabeb134 -r 48ee8bad7d51 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Fri Sep 28 02:19:07 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Fri Sep 28 15:07:11 2012 +0300 @@ -31,25 +31,23 @@ dbox_alt_path_has_changed(const char *root_dir, const char *alt_path, const char *alt_symlink_path) { - char buf[PATH_MAX]; + const char *linkpath; ssize_t ret; - ret = readlink(alt_symlink_path, buf, sizeof(buf)-1); - if (ret < 0) { + if (t_readlink(alt_symlink_path, &linkpath) < 0) { if (errno == ENOENT) return alt_path != NULL; i_error("readlink(%s) failed: %m", alt_symlink_path); return FALSE; } - buf[ret] = '\0'; if (alt_path == NULL) { i_warning("dbox %s: Original ALT=%s, " - "but currently no ALT path set", root_dir, buf); + "but currently no ALT path set", root_dir, linkpath); return TRUE; - } else if (strcmp(buf, alt_path) != 0) { + } else if (strcmp(linkpath, alt_path) != 0) { i_warning("dbox %s: Original ALT=%s, " - "but currently ALT=%s", root_dir, buf, alt_path); + "but currently ALT=%s", root_dir, linkpath, alt_path); return TRUE; } return FALSE; From dovecot at dovecot.org Fri Sep 28 15:12:06 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 15:12:06 +0300 Subject: dovecot-2.2: Compiler warning fix for previous change Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b6663a4f60fe changeset: 15170:b6663a4f60fe user: Timo Sirainen date: Fri Sep 28 15:11:54 2012 +0300 description: Compiler warning fix for previous change diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (19 lines): diff -r 48ee8bad7d51 -r b6663a4f60fe src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Fri Sep 28 15:07:11 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Fri Sep 28 15:11:54 2012 +0300 @@ -2,6 +2,7 @@ #include "lib.h" #include "ioloop.h" +#include "abspath.h" #include "fs-api.h" #include "mkdir-parents.h" #include "unlink-old-files.h" @@ -32,7 +33,6 @@ const char *alt_path, const char *alt_symlink_path) { const char *linkpath; - ssize_t ret; if (t_readlink(alt_symlink_path, &linkpath) < 0) { if (errno == ENOENT) From dovecot at dovecot.org Fri Sep 28 15:12:36 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 15:12:36 +0300 Subject: dovecot-2.1: Avoid using PATH_MAX. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/75aadea5c2a2 changeset: 14738:75aadea5c2a2 user: Timo Sirainen date: Fri Sep 28 15:07:11 2012 +0300 description: Avoid using PATH_MAX. diffstat: src/lib-master/master-instance.c | 2 +- src/lib-storage/index/dbox-common/dbox-storage.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diffs (46 lines): diff -r 88a05f387743 -r 75aadea5c2a2 src/lib-master/master-instance.c --- a/src/lib-master/master-instance.c Thu Sep 27 02:55:14 2012 +0300 +++ b/src/lib-master/master-instance.c Fri Sep 28 15:07:11 2012 +0300 @@ -110,7 +110,7 @@ i_error("open(%s) failed: %m", list->path); return -1; } - input = i_stream_create_fd(fd, PATH_MAX, TRUE); + input = i_stream_create_fd(fd, (size_t)-1, TRUE); while ((line = i_stream_read_next_line(input)) != NULL) T_BEGIN { if (master_instance_list_add_line(list, line) < 0) i_error("Invalid line in %s: %s", list->path, line); diff -r 88a05f387743 -r 75aadea5c2a2 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Thu Sep 27 02:55:14 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Fri Sep 28 15:07:11 2012 +0300 @@ -31,25 +31,23 @@ dbox_alt_path_has_changed(const char *root_dir, const char *alt_path, const char *alt_symlink_path) { - char buf[PATH_MAX]; + const char *linkpath; ssize_t ret; - ret = readlink(alt_symlink_path, buf, sizeof(buf)-1); - if (ret < 0) { + if (t_readlink(alt_symlink_path, &linkpath) < 0) { if (errno == ENOENT) return alt_path != NULL; i_error("readlink(%s) failed: %m", alt_symlink_path); return FALSE; } - buf[ret] = '\0'; if (alt_path == NULL) { i_warning("dbox %s: Original ALT=%s, " - "but currently no ALT path set", root_dir, buf); + "but currently no ALT path set", root_dir, linkpath); return TRUE; - } else if (strcmp(buf, alt_path) != 0) { + } else if (strcmp(linkpath, alt_path) != 0) { i_warning("dbox %s: Original ALT=%s, " - "but currently ALT=%s", root_dir, buf, alt_path); + "but currently ALT=%s", root_dir, linkpath, alt_path); return TRUE; } return FALSE; From dovecot at dovecot.org Fri Sep 28 15:12:36 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 15:12:36 +0300 Subject: dovecot-2.1: Avoid using PATH_MAX. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2a44991cbf66 changeset: 14739:2a44991cbf66 user: Timo Sirainen date: Fri Sep 28 15:11:30 2012 +0300 description: Avoid using PATH_MAX. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (19 lines): diff -r 75aadea5c2a2 -r 2a44991cbf66 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Fri Sep 28 15:07:11 2012 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Fri Sep 28 15:11:30 2012 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "abspath.h" #include "ioloop.h" #include "fs-api.h" #include "mkdir-parents.h" @@ -32,7 +33,6 @@ const char *alt_path, const char *alt_symlink_path) { const char *linkpath; - ssize_t ret; if (t_readlink(alt_symlink_path, &linkpath) < 0) { if (errno == ENOENT) From dovecot at dovecot.org Fri Sep 28 15:12:36 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 28 Sep 2012 15:12:36 +0300 Subject: dovecot-2.1: Compiling fix for HURD Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6cac808c4bd8 changeset: 14740:6cac808c4bd8 user: Timo Sirainen date: Fri Sep 28 15:12:28 2012 +0300 description: Compiling fix for HURD diffstat: src/lib/compat.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 2a44991cbf66 -r 6cac808c4bd8 src/lib/compat.h --- a/src/lib/compat.h Fri Sep 28 15:11:30 2012 +0300 +++ b/src/lib/compat.h Fri Sep 28 15:12:28 2012 +0300 @@ -270,4 +270,8 @@ # define IO_BLOCK_SIZE 8192 #endif +#if !defined(PIPE_BUF) && defined(_POSIX_PIPE_BUF) +# define PIPE_BUF (8 * _POSIX_PIPE_BUF) /* for HURD */ #endif + +#endif