From pigeonhole at rename-it.nl Sat Jul 2 23:58:28 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 02 Jul 2011 22:58:28 +0200 Subject: dovecot-2.0-pigeonhole: Updated TODO. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/b69e1c556ad4 changeset: 1511:b69e1c556ad4 user: Stephan Bosch date: Sat Jul 02 22:58:22 2011 +0200 description: Updated TODO. diffstat: TODO | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diffs (57 lines): diff -r a720b0775fa5 -r b69e1c556ad4 TODO --- a/TODO Wed Jun 29 00:55:48 2011 +0200 +++ b/TODO Sat Jul 02 22:58:22 2011 +0200 @@ -2,16 +2,33 @@ * Build a sieve tool to filter an entire existing mailbox through a Sieve script. + > Needs to have single mail transaction for each destination folder for + all moved messages. Otherwise, partial failure cannot be prevented. + - Implement ability to group Sieve execution results of all processed messages + into one big `Sieve transaction' object, which (among other things) keeps + track of opened mailboxes and transactions. Is probably also more efficient. -Next (in order of descending priority/precedence): +Parallel plugin-based efforts: +* Implement plugin to pipe messages to external programs. Will probably be + merged with the main tree eventually. +* Implement enotify xmpp method as a plugin. +* Implement metadata and servermetadata extensions as a plugin. + - Compiles against dovecot metadata plugin, as currently developed by + Dennis Schridde. + +Next (mostly in order of descending priority/precedence): + +* Add normalize() method to comparators to normalize the string before matching + (for efficiency). * Improve error handling. - Implement dropping errors in the user's mailbox as a mail message. -* Add normalize() method to comparators to normalize the string before matching - (for efficiency). +* Implement index extension * Further develop regex extension and update it to the latest draft: - Implement the :quoteregex set modifier - Investigate the use of the TRE regexp library to gain UTF-8 capability + (posix regexes actually do support utf8, but only when locale is set + accordingly) * Finish body extension: - Implement proper :content "multipart" behavior - Implement proper :content "message/rfc822" behavior @@ -19,7 +36,6 @@ * Cleanup the test suite - Restructure test scripts - Add more comment on purpose of tests -* Implement index extension * Update include extension to latest draft (v05 currently): - Implement required ManageSieve behavior (pending IETF discussion) * Finish the ereject extension @@ -77,6 +93,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. - 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 Sun Jul 3 00:58:05 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 02 Jul 2011 23:58:05 +0200 Subject: dovecot-2.0-pigeonhole: Merged concurrent changes. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/e9bb226739cb changeset: 1513:e9bb226739cb user: Stephan Bosch date: Sat Jul 02 23:58:01 2011 +0200 description: Merged concurrent changes. diffstat: TODO | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diffs (57 lines): diff -r 278efc729dc3 -r e9bb226739cb TODO --- a/TODO Sat Jul 02 12:42:33 2011 +0200 +++ b/TODO Sat Jul 02 23:58:01 2011 +0200 @@ -2,16 +2,33 @@ * Build a sieve tool to filter an entire existing mailbox through a Sieve script. + > Needs to have single mail transaction for each destination folder for + all moved messages. Otherwise, partial failure cannot be prevented. + - Implement ability to group Sieve execution results of all processed messages + into one big `Sieve transaction' object, which (among other things) keeps + track of opened mailboxes and transactions. Is probably also more efficient. -Next (in order of descending priority/precedence): +Parallel plugin-based efforts: +* Implement plugin to pipe messages to external programs. Will probably be + merged with the main tree eventually. +* Implement enotify xmpp method as a plugin. +* Implement metadata and servermetadata extensions as a plugin. + - Compiles against dovecot metadata plugin, as currently developed by + Dennis Schridde. + +Next (mostly in order of descending priority/precedence): + +* Add normalize() method to comparators to normalize the string before matching + (for efficiency). * Improve error handling. - Implement dropping errors in the user's mailbox as a mail message. -* Add normalize() method to comparators to normalize the string before matching - (for efficiency). +* Implement index extension * Further develop regex extension and update it to the latest draft: - Implement the :quoteregex set modifier - Investigate the use of the TRE regexp library to gain UTF-8 capability + (posix regexes actually do support utf8, but only when locale is set + accordingly) * Finish body extension: - Implement proper :content "multipart" behavior - Implement proper :content "message/rfc822" behavior @@ -19,7 +36,6 @@ * Cleanup the test suite - Restructure test scripts - Add more comment on purpose of tests -* Implement index extension * Update include extension to latest draft (v05 currently): - Implement required ManageSieve behavior (pending IETF discussion) * Finish the ereject extension @@ -77,6 +93,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. - 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 Sun Jul 3 00:58:05 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sat, 02 Jul 2011 23:58:05 +0200 Subject: dovecot-2.0-pigeonhole: Updated documentation. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/278efc729dc3 changeset: 1512:278efc729dc3 user: Stephan Bosch date: Sat Jul 02 12:42:33 2011 +0200 description: Updated documentation. diffstat: NEWS | 2 +- README | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diffs (68 lines): diff -r a720b0775fa5 -r 278efc729dc3 NEWS --- a/NEWS Wed Jun 29 00:55:48 2011 +0200 +++ b/NEWS Sat Jul 02 12:42:33 2011 +0200 @@ -10,7 +10,7 @@ + Vacation extension: implemented the (draft) vacation-seconds extension. This also adds min/max period configuration settings. Refer to doc/vacation.txt for configuration information. - - ManageSieve: fixed bug in UTF-8 checking of string values. This is done + - ManageSieve: fixed bug in UTF-8 checking of string values. This is done by discarding the original implementation and migrating to the Dovecot API's UTF-8 functionality. - Sieve command line tools now avoid initializing the mail store unless diff -r a720b0775fa5 -r 278efc729dc3 README --- a/README Wed Jun 29 00:55:48 2011 +0200 +++ b/README Sat Jul 02 12:42:33 2011 +0200 @@ -100,28 +100,30 @@ copy (RFC 3894): fully supported. body (RFC 5173): almost fully supported, but the text body-transform - implementation is simple and some issues make it still not completely RFC - compliant. + implementation is simple and some issues make it still not completely + RFC compliant. environment (RFC 5183): basic support is provided (v0.1.5+). variables (RFC 5229): fully supported. vacation (RFC 5230): fully supported. + + vacation-seconds (RFC 6131): fully supported (v0.2.3+). 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. - date (RFC 5260; page 3): fully supported (v0.1.12+). - reject (RFC 5429; page 6): fully supported. - enotify (RFC 5435): fully supported (v0.1.3+). Currently, only the mailto - notification mechanism (RFC 5436) is available. The xmpp notification - mechanism (RFC 5437) is under development and will become available as a - plugin. - mailbox (RFC 5490; page 2): fully supported (v0.1.10+), but ACL permissions - are not verified for mailboxexists. + spamtest and virustest (RFC 5235): fully supported (v0.1.16+), but + currently considered experimental. + date (RFC 5260; Section 4): fully supported (v0.1.12+). + reject (RFC 5429; Section 2.2): fully supported. + enotify (RFC 5435): fully supported (v0.1.3+). + mailto method (RFC 5436): fully supported (v0.1.3+). + xmpp method (RFC 5437): is under development and will become available + as a plugin. + 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): almost fully supported, but interaction with - ManageSieve is not in accordance with specification. + ManageSieve is not in accordance with specification. regex (draft v08; not latest ietf version): almost fully supported, but - UTF-8 is not supported. + UTF-8 is not supported. The following deprecated extensions are supported for backwards compatibility: @@ -139,7 +141,6 @@ useful for Dovecot in particular, but many of them are. Currently, the author has taken notice of the following extensions: - vacation-seconds (draft): planned. index (RFC 5260; page 7): planned. editheader (RFC 5293): planned. foreverypart, mime, replace, enclose, and extracttext (RFC 5703): planned. From pigeonhole at rename-it.nl Tue Jul 5 21:32:50 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 05 Jul 2011 20:32:50 +0200 Subject: dovecot-2.0-pigeonhole: lib-sieve: include extension: forgot to ... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/08bbe5872576 changeset: 1514:08bbe5872576 user: Stephan Bosch date: Tue Jul 05 20:32:28 2011 +0200 description: lib-sieve: include extension: forgot to check variable identifier syntax. diffstat: src/lib-sieve/plugins/include/cmd-global.c | 4 +- src/lib-sieve/plugins/include/ext-include-variables.c | 9 +++ src/lib-sieve/plugins/variables/ext-variables-arguments.c | 10 +- src/lib-sieve/plugins/variables/ext-variables-name.c | 50 ++++++++++++---- src/lib-sieve/plugins/variables/sieve-ext-variables.h | 2 + tests/extensions/include/rfc-ex2-default.sieve | 2 +- 6 files changed, 57 insertions(+), 20 deletions(-) diffs (193 lines): diff -r e9bb226739cb -r 08bbe5872576 src/lib-sieve/plugins/include/cmd-global.c --- a/src/lib-sieve/plugins/include/cmd-global.c Sat Jul 02 23:58:01 2011 +0200 +++ b/src/lib-sieve/plugins/include/cmd-global.c Tue Jul 05 20:32:28 2011 +0200 @@ -174,13 +174,13 @@ sieve_ast_argument_name(arg)); return FALSE; } - + /* Join global commands with predecessors if possible */ if ( sieve_commands_equal(prev, cmd) ) { /* Join this command's string list with the previous one */ prev->first_positional = sieve_ast_stringlist_join (prev->first_positional, cmd->first_positional); - + if ( prev->first_positional == NULL ) { /* Not going to happen unless MAXINT stringlist items are specified */ sieve_command_validate_error(valdtr, cmd, diff -r e9bb226739cb -r 08bbe5872576 src/lib-sieve/plugins/include/ext-include-variables.c --- a/src/lib-sieve/plugins/include/ext-include-variables.c Sat Jul 02 23:58:01 2011 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-variables.c Tue Jul 05 20:32:28 2011 +0200 @@ -1,6 +1,9 @@ /* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file */ +#include "lib.h" +#include "str-sanitize.h" + #include "sieve-common.h" #include "sieve-error.h" #include "sieve-script.h" @@ -38,6 +41,12 @@ /* Sanity safeguard */ i_assert ( ctx->global_vars != NULL ); + if ( !sieve_variable_identifier_is_valid(variable) ) { + sieve_command_validate_error(valdtr, cmd, + "invalid variable identifier '%s'", str_sanitize(variable,80)); + return NULL; + } + /* Get/Declare the variable in the global scope */ global_var = sieve_variable_scope_get_variable(global_scope, variable, TRUE); diff -r e9bb226739cb -r 08bbe5872576 src/lib-sieve/plugins/variables/ext-variables-arguments.c --- a/src/lib-sieve/plugins/variables/ext-variables-arguments.c Sat Jul 02 23:58:01 2011 +0200 +++ b/src/lib-sieve/plugins/variables/ext-variables-arguments.c Tue Jul 05 20:32:28 2011 +0200 @@ -343,19 +343,19 @@ bool result = FALSE; string_t *variable; const char *varstr, *varend; - ARRAY_TYPE(sieve_variable_name) vname; + ARRAY_TYPE(sieve_variable_name) vname; int nelements = 0; T_BEGIN { - t_array_init(&vname, 2); - + t_array_init(&vname, 2); + variable = sieve_ast_argument_str(arg); varstr = str_c(variable); varend = PTR_OFFSET(varstr, str_len(variable)); nelements = ext_variable_name_parse(&vname, &varstr, varend); - /* Check whether name parsing succeeded */ - if ( nelements < 0 || varstr != varend ) { + /* Check whether name parsing succeeded */ + if ( nelements <= 0 || varstr != varend ) { /* Parse failed */ sieve_argument_validate_error(valdtr, arg, "invalid variable name '%s'", str_sanitize(str_c(variable),80)); diff -r e9bb226739cb -r 08bbe5872576 src/lib-sieve/plugins/variables/ext-variables-name.c --- a/src/lib-sieve/plugins/variables/ext-variables-name.c Sat Jul 02 23:58:01 2011 +0200 +++ b/src/lib-sieve/plugins/variables/ext-variables-name.c Tue Jul 05 20:32:28 2011 +0200 @@ -13,14 +13,36 @@ #include +bool sieve_variable_identifier_is_valid(const char *identifier) +{ + const char *p = identifier; + size_t plen = strlen(identifier); + const char *pend; + + if ( plen == 0 || plen >= EXT_VARIABLES_MAX_VARIABLE_NAME_LEN ) + return FALSE; + + pend = PTR_OFFSET(identifier, plen); + + if ( *p == '_' || i_isalpha(*p) ) { + p++; + + while ( p < pend && (*p == '_' || i_isalnum(*p)) ) { + p++; + } + } + + return ( p == pend ); +} + int ext_variable_name_parse (ARRAY_TYPE(sieve_variable_name) *vname, const char **str, const char *strend) { const char *p = *str; - + array_clear(vname); - for (;;) { + while ( p < strend ) { struct sieve_variable_name *cur_element; string_t *cur_ident; @@ -40,23 +62,23 @@ str_truncate(cur_ident, 0); str_append_c(cur_ident, *p); p++; - + while ( p < strend && (*p == '_' || i_isalnum(*p)) ) { if ( str_len(cur_ident) >= EXT_VARIABLES_MAX_VARIABLE_NAME_LEN ) return -1; str_append_c(cur_ident, *p); p++; } - + /* Num-variable */ } else if ( i_isdigit(*p) ) { cur_element->num_variable = *p - '0'; p++; - + while ( p < strend && i_isdigit(*p) ) { cur_element->num_variable = cur_element->num_variable*10 + (*p - '0'); p++; - } + } /* If a num-variable is first, no more elements can follow because no * namespace is specified. @@ -69,16 +91,20 @@ *str = p; return -1; } - + /* Check whether next name element is present */ - if ( p < strend && *p == '.' ) + if ( p < strend && *p == '.' ) { p++; - else + + /* It may not be empty */ + if ( p >= strend ) + return -1; + } else break; } - + *str = p; return array_count(vname); -} - +} + diff -r e9bb226739cb -r 08bbe5872576 src/lib-sieve/plugins/variables/sieve-ext-variables.h --- a/src/lib-sieve/plugins/variables/sieve-ext-variables.h Sat Jul 02 23:58:01 2011 +0200 +++ b/src/lib-sieve/plugins/variables/sieve-ext-variables.h Tue Jul 05 20:32:28 2011 +0200 @@ -46,6 +46,8 @@ ARRAY_DEFINE_TYPE(sieve_variable_name, struct sieve_variable_name); +bool sieve_variable_identifier_is_valid(const char *identifier); + /* * Variable scope */ diff -r e9bb226739cb -r 08bbe5872576 tests/extensions/include/rfc-ex2-default.sieve --- a/tests/extensions/include/rfc-ex2-default.sieve Sat Jul 02 23:58:01 2011 +0200 +++ b/tests/extensions/include/rfc-ex2-default.sieve Tue Jul 05 20:32:28 2011 +0200 @@ -1,6 +1,6 @@ require ["variables", "include", "relational", "fileinto"]; global "test"; -global "test-mailbox"; +global "test_mailbox"; # The included script may contain repetitive code that is # effectively a subroutine that can be factored out. From dovecot at dovecot.org Tue Jul 12 09:59:49 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 12 Jul 2011 09:59:49 +0300 Subject: dovecot-2.0: lib-mail: Make a mail_guid_128_t typedef. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/aaffc1bf6c65 changeset: 12867:aaffc1bf6c65 user: Timo Sirainen date: Tue Jul 12 09:58:29 2011 +0300 description: lib-mail: Make a mail_guid_128_t typedef. diffstat: src/lib-mail/mail-types.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 537d4b6d9a7a -r aaffc1bf6c65 src/lib-mail/mail-types.h --- a/src/lib-mail/mail-types.h Thu Jun 30 08:35:43 2011 +0300 +++ b/src/lib-mail/mail-types.h Tue Jul 12 09:58:29 2011 +0300 @@ -2,6 +2,7 @@ #define MAIL_TYPES_H #define MAIL_GUID_128_SIZE 16 +typedef uint8_t mail_guid_128_t[MAIL_GUID_128_SIZE]; enum mail_flags { MAIL_ANSWERED = 0x01, From dovecot at dovecot.org Tue Jul 12 09:59:49 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 12 Jul 2011 09:59:49 +0300 Subject: dovecot-2.0: lib-lda: Do INBOX GUID deduplication based on mailb... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/e6300c6a5814 changeset: 12868:e6300c6a5814 user: Timo Sirainen date: Tue Jul 12 09:59:34 2011 +0300 description: lib-lda: Do INBOX GUID deduplication based on mailbox GUID, not username. This should be a bit more reliable. diffstat: src/lib-lda/mail-deliver.c | 25 ++++++++++++++----------- src/lib-lda/mail-deliver.h | 6 ++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diffs (78 lines): diff -r aaffc1bf6c65 -r e6300c6a5814 src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Tue Jul 12 09:58:29 2011 +0300 +++ b/src/lib-lda/mail-deliver.c Tue Jul 12 09:59:34 2011 +0300 @@ -214,20 +214,25 @@ } static bool mail_deliver_check_duplicate(struct mail_deliver_session *session, - struct mail_user *user) + struct mailbox *box) { - const char *const *usernamep, *username; + uint8_t box_guid[MAIL_GUID_128_SIZE]; + const mail_guid_128_t *guid; + + if (mailbox_get_guid(box, box_guid) < 0) { + /* just play it safe and assume a duplicate */ + return TRUE; + } /* there shouldn't be all that many recipients, so just do a linear search */ - if (!array_is_created(&session->inbox_users)) - p_array_init(&session->inbox_users, session->pool, 8); - array_foreach(&session->inbox_users, usernamep) { - if (strcmp(*usernamep, user->username) == 0) + if (!array_is_created(&session->inbox_guids)) + p_array_init(&session->inbox_guids, session->pool, 8); + array_foreach(&session->inbox_guids, guid) { + if (memcmp(box_guid, guid, sizeof(box_guid)) == 0) return TRUE; } - username = p_strdup(session->pool, user->username); - array_append(&session->inbox_users, &username, 1); + array_append(&session->inbox_guids, &box_guid, 1); return FALSE; } @@ -237,8 +242,6 @@ struct mailbox_transaction_context *trans = mailbox_save_get_transaction(save_ctx); struct mailbox *box = mailbox_transaction_get_mailbox(trans); - struct mail_storage *storage = mailbox_get_storage(box); - struct mail_user *user = mail_storage_get_user(storage); uint8_t guid[MAIL_GUID_128_SIZE]; if (strcmp(mailbox_get_name(box), "INBOX") != 0) @@ -248,7 +251,7 @@ happens if mail is delivered to same user multiple times within a session. the problem with this is that if GUIDs are used as POP3 UIDLs, some clients can't handle the duplicates well. */ - if (mail_deliver_check_duplicate(session, user)) { + if (mail_deliver_check_duplicate(session, box)) { mail_generate_guid_128(guid); mailbox_save_set_guid(save_ctx, mail_guid_128_to_string(guid)); } diff -r aaffc1bf6c65 -r e6300c6a5814 src/lib-lda/mail-deliver.h --- a/src/lib-lda/mail-deliver.h Tue Jul 12 09:58:29 2011 +0300 +++ b/src/lib-lda/mail-deliver.h Tue Jul 12 09:59:34 2011 +0300 @@ -1,6 +1,8 @@ #ifndef MAIL_DELIVER_H #define MAIL_DELIVER_H +#include "mail-types.h" + enum mail_flags; enum mail_error; struct mail_storage; @@ -10,8 +12,8 @@ struct mail_deliver_session { pool_t pool; - /* List of users who have already saved this mail to their INBOX */ - ARRAY_TYPE(const_string) inbox_users; + /* List of INBOX GUIDs where this mail has already been saved to */ + ARRAY_DEFINE(inbox_guids, mail_guid_128_t); }; struct mail_deliver_context { From dovecot at dovecot.org Wed Jul 27 19:46:13 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 27 Jul 2011 19:46:13 +0300 Subject: dovecot-2.0: imap-quota: Don't crash if invalid mailbox name is ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/b383271890fe changeset: 12869:b383271890fe user: Timo Sirainen date: Wed Jul 27 19:46:01 2011 +0300 description: imap-quota: Don't crash if invalid mailbox name is given to GETQUOTAROOT. diffstat: src/plugins/imap-quota/imap-quota-plugin.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diffs (31 lines): diff -r e6300c6a5814 -r b383271890fe src/plugins/imap-quota/imap-quota-plugin.c --- a/src/plugins/imap-quota/imap-quota-plugin.c Tue Jul 12 09:59:34 2011 +0300 +++ b/src/plugins/imap-quota/imap-quota-plugin.c Wed Jul 27 19:46:01 2011 +0300 @@ -74,6 +74,7 @@ struct mailbox *box; struct quota_root_iter *iter; struct quota_root *root; + enum mailbox_name_status status; const char *mailbox, *storage_name, *name; string_t *quotaroot_reply, *quota_reply; @@ -81,7 +82,7 @@ if (!client_read_string_args(cmd, 1, &mailbox)) return FALSE; - ns = client_find_namespace(cmd, mailbox, &storage_name, NULL); + ns = client_find_namespace(cmd, mailbox, &storage_name, &status); if (ns == NULL) return TRUE; @@ -94,6 +95,10 @@ client_send_tagline(cmd, "NO Not showing other users' quota."); return TRUE; } + if (status == MAILBOX_NAME_INVALID) { + client_fail_mailbox_name_status(cmd, mailbox, NULL, status); + return TRUE; + } box = mailbox_alloc(ns->list, storage_name, MAILBOX_FLAG_READONLY | MAILBOX_FLAG_KEEP_RECENT); From dovecot at dovecot.org Thu Jul 28 12:08:28 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 28 Jul 2011 12:08:28 +0300 Subject: dovecot-2.0: imap: FETCH BODY[HEADER.FIELDS (..)] may have tried... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/a77d53d40ea3 changeset: 12870:a77d53d40ea3 user: Timo Sirainen date: Thu Jul 28 12:08:10 2011 +0300 description: imap: FETCH BODY[HEADER.FIELDS (..)] may have tried to fetch garbage field names. Such situations were quite likely to cause a crash though. diffstat: src/imap/imap-fetch-body.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r b383271890fe -r a77d53d40ea3 src/imap/imap-fetch-body.c --- a/src/imap/imap-fetch-body.c Wed Jul 27 19:46:01 2011 +0300 +++ b/src/imap/imap-fetch-body.c Thu Jul 28 12:08:10 2011 +0300 @@ -773,7 +773,7 @@ if (i != 0) str_append_c(str, ' '); - arr[i] = t_str_ucase(value); + arr[i] = p_strdup(ctx->cmd->pool, t_str_ucase(value)); if (args[i].type == IMAP_ARG_ATOM) str_append(str, arr[i]); From dovecot at dovecot.org Thu Jul 28 17:46:47 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 28 Jul 2011 17:46:47 +0300 Subject: dovecot-2.0: lib-storage: Fixed crashing on "NOT details: http://hg.dovecot.org/dovecot-2.0/rev/0e64f0217feb changeset: 12871:0e64f0217feb user: Timo Sirainen date: Thu Jul 28 17:46:37 2011 +0300 description: lib-storage: Fixed crashing on "NOT " search. diffstat: src/lib-storage/index/index-search.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diffs (23 lines): diff -r a77d53d40ea3 -r 0e64f0217feb src/lib-storage/index/index-search.c --- a/src/lib-storage/index/index-search.c Thu Jul 28 12:08:10 2011 +0300 +++ b/src/lib-storage/index/index-search.c Thu Jul 28 17:46:37 2011 +0300 @@ -745,7 +745,7 @@ else { /* if all messages are in the range, it can't match */ range = array_get_modifiable(seqset, &count); - return range[0].seq1 != 1 || + return count == 0 || range[0].seq1 != 1 || range[count-1].seq2 != messages_count; } } @@ -768,6 +768,10 @@ if (!not) { min_seq = range[0].seq1; max_seq = range[count-1].seq2; + } else if (count == 0) { + /* matches all messages */ + min_seq = 1; + max_seq = messages_count; } else { min_seq = range[0].seq1 > 1 ? 1 : range[0].seq2 + 1; max_seq = range[count-1].seq2 < messages_count ? From dovecot at dovecot.org Fri Jul 29 00:04:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 29 Jul 2011 00:04:31 +0300 Subject: dovecot-2.0: lib-storage: Removed unnecessary NULL checks. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/94c6e1cd58f1 changeset: 12872:94c6e1cd58f1 user: Timo Sirainen date: Fri Jul 29 00:04:20 2011 +0300 description: lib-storage: Removed unnecessary NULL checks. diffstat: src/lib-storage/index/index-storage.c | 3 +-- src/lib-storage/mail-namespace.c | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diffs (31 lines): diff -r 0e64f0217feb -r 94c6e1cd58f1 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Thu Jul 28 17:46:37 2011 +0300 +++ b/src/lib-storage/index/index-storage.c Fri Jul 29 00:04:20 2011 +0300 @@ -204,8 +204,7 @@ box->opened = TRUE; index_thread_mailbox_opened(box); - if (hook_mailbox_opened != NULL) - hook_mailbox_opened(box); + hook_mailbox_opened(box); if ((box->flags & MAILBOX_FLAG_OPEN_DELETED) == 0) { if (mail_index_is_deleted(box->index)) { diff -r 0e64f0217feb -r 94c6e1cd58f1 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Thu Jul 28 17:46:37 2011 +0300 +++ b/src/lib-storage/mail-namespace.c Fri Jul 29 00:04:20 2011 +0300 @@ -400,11 +400,9 @@ } user->namespaces = ns; - if (hook_mail_namespaces_created != NULL) { - T_BEGIN { - hook_mail_namespaces_created(ns); - } T_END; - } + T_BEGIN { + hook_mail_namespaces_created(ns); + } T_END; return 0; } From dovecot at dovecot.org Fri Jul 29 12:26:02 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 29 Jul 2011 12:26:02 +0300 Subject: dovecot-2.0: lib-storage: renaming mailboxes under different par... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/f42aac06a3df changeset: 12873:f42aac06a3df user: Timo Sirainen date: Fri Jul 29 12:25:52 2011 +0300 description: lib-storage: renaming mailboxes under different parent was broken in fs layout If alt storage was used with sdbox or if index or control dirs were used, renaming "foo" to "bar/foo" would result "foo" not being renamed for those directories. diffstat: src/lib-storage/list/mailbox-list-fs.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diffs (44 lines): diff -r 94c6e1cd58f1 -r f42aac06a3df src/lib-storage/list/mailbox-list-fs.c --- a/src/lib-storage/list/mailbox-list-fs.c Fri Jul 29 00:04:20 2011 +0300 +++ b/src/lib-storage/list/mailbox-list-fs.c Fri Jul 29 12:25:52 2011 +0300 @@ -466,7 +466,8 @@ struct mailbox_list *newlist, const char *newname, enum mailbox_list_path_type type, bool rmdir_parent) { - const char *oldpath, *newpath, *p; + struct stat st; + const char *oldpath, *newpath, *p, *oldparent, *newparent; oldpath = mailbox_list_get_path(oldlist, oldname, type); newpath = mailbox_list_get_path(newlist, newname, type); @@ -474,6 +475,30 @@ if (strcmp(oldpath, newpath) == 0) return 0; + p = strrchr(oldpath, '/'); + oldparent = p == NULL ? "/" : t_strdup_until(oldpath, p); + p = strrchr(newpath, '/'); + newparent = p == NULL ? "/" : t_strdup_until(newpath, p); + + if (strcmp(oldparent, newparent) != 0 && stat(oldpath, &st) == 0) { + /* make sure the newparent exists */ + mode_t mode; + gid_t gid; + const char *origin; + + mailbox_list_get_dir_permissions(newlist, NULL, &mode, + &gid, &origin); + if (mkdir_parents_chgrp(newparent, mode, gid, origin) < 0 && + errno != EEXIST) { + if (mailbox_list_set_error_from_errno(oldlist)) + return -1; + + mailbox_list_set_critical(oldlist, + "mkdir_parents(%s) failed: %m", newparent); + return -1; + } + } + if (rename(oldpath, newpath) < 0 && errno != ENOENT) { mailbox_list_set_critical(oldlist, "rename(%s, %s) failed: %m", oldpath, newpath);