From dovecot at dovecot.org Thu Aug 1 13:31:36 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 13:31:36 +0300 Subject: dovecot-2.2: lib-storage: Ignore MAIL_STORAGE_SERVICE_FLAG_TEMP_... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/43488e1044c9 changeset: 16626:43488e1044c9 user: Timo Sirainen date: Thu Aug 01 13:31:25 2013 +0300 description: lib-storage: Ignore MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP if service user isn't root. diffstat: src/lib-storage/mail-storage-service.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 51b8020b29f6 -r 43488e1044c9 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Jul 30 13:26:40 2013 +0300 +++ b/src/lib-storage/mail-storage-service.c Thu Aug 01 13:31:25 2013 +0300 @@ -748,6 +748,13 @@ PACKAGE_VERSION, version); } + if ((flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0 && + geteuid() != 0) { + /* service { user } isn't root. the permission drop can't be + temporary. */ + flags &= ~MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP; + } + (void)umask(0077); io_loop_set_time_moved_callback(current_ioloop, mail_storage_service_time_moved); From dovecot at dovecot.org Thu Aug 1 13:43:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 13:43:14 +0300 Subject: dovecot-2.2: lib-master: If MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/eb63eca74471 changeset: 16627:eb63eca74471 user: Timo Sirainen date: Thu Aug 01 13:42:51 2013 +0300 description: lib-master: If MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN is set, open the config socket before dropping privileges. diffstat: src/lib-master/master-service-settings.c | 17 +++++++++++++++++ src/lib-master/master-service-settings.h | 3 +++ src/lib-master/master-service.c | 6 ++++++ src/lib-master/master-service.h | 3 ++- 4 files changed, 28 insertions(+), 1 deletions(-) diffs (69 lines): diff -r 43488e1044c9 -r eb63eca74471 src/lib-master/master-service-settings.c --- a/src/lib-master/master-service-settings.c Thu Aug 01 13:31:25 2013 +0300 +++ b/src/lib-master/master-service-settings.c Thu Aug 01 13:42:51 2013 +0300 @@ -336,6 +336,23 @@ return 0; } +void master_service_config_socket_try_open(struct master_service *service) +{ + struct master_service_settings_input input; + const char *path, *error; + int fd; + + if (getenv("DOVECONF_ENV") != NULL || + (service->flags & MASTER_SERVICE_FLAG_NO_CONFIG_SETTINGS) != 0) + return; + + memset(&input, 0, sizeof(input)); + input.never_exec = TRUE; + fd = master_service_open_config(service, &input, &path, &error); + if (fd != -1) + service->config_fd = fd; +} + int master_service_settings_read(struct master_service *service, const struct master_service_settings_input *input, struct master_service_settings_output *output_r, diff -r 43488e1044c9 -r eb63eca74471 src/lib-master/master-service-settings.h --- a/src/lib-master/master-service-settings.h Thu Aug 01 13:31:25 2013 +0300 +++ b/src/lib-master/master-service-settings.h Thu Aug 01 13:42:51 2013 +0300 @@ -56,6 +56,9 @@ extern const struct setting_parser_info master_service_setting_parser_info; +/* Try to open the config socket if it's going to be needed later by + master_service_settings_read*() */ +void master_service_config_socket_try_open(struct master_service *service); int master_service_settings_read(struct master_service *service, const struct master_service_settings_input *input, struct master_service_settings_output *output_r, diff -r 43488e1044c9 -r eb63eca74471 src/lib-master/master-service.c --- a/src/lib-master/master-service.c Thu Aug 01 13:31:25 2013 +0300 +++ b/src/lib-master/master-service.c Thu Aug 01 13:42:51 2013 +0300 @@ -236,6 +236,12 @@ master_service_set_client_limit(service, 1); master_service_set_service_count(service, 1); } + if ((flags & MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN) != 0) { + /* since we're going to keep the config socket open anyway, + open it now so we can read settings even after privileges + are dropped. */ + master_service_config_socket_try_open(service); + } master_service_verify_version_string(service); return service; diff -r 43488e1044c9 -r eb63eca74471 src/lib-master/master-service.h --- a/src/lib-master/master-service.h Thu Aug 01 13:31:25 2013 +0300 +++ b/src/lib-master/master-service.h Thu Aug 01 13:42:51 2013 +0300 @@ -15,7 +15,8 @@ _FLAG_STANDALONE is set, logging is done to stderr. */ MASTER_SERVICE_FLAG_DONT_LOG_TO_STDERR = 0x04, /* Service is going to do multiple configuration lookups, - keep the connection to config service open. */ + keep the connection to config service open. Also opens the config + socket before dropping privileges. */ MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN = 0x08, /* Don't read settings, but use whatever is in environment */ MASTER_SERVICE_FLAG_NO_CONFIG_SETTINGS = 0x10, From dovecot at dovecot.org Thu Aug 1 13:52:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 13:52:12 +0300 Subject: dovecot-2.2: lib-master: If config socket closes, retry connecti... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/96ea65bf653c changeset: 16628:96ea65bf653c user: Timo Sirainen date: Thu Aug 01 13:51:57 2013 +0300 description: lib-master: If config socket closes, retry connecting to it automatically. diffstat: src/lib-master/master-service-settings.c | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) diffs (41 lines): diff -r eb63eca74471 -r 96ea65bf653c src/lib-master/master-service-settings.c --- a/src/lib-master/master-service-settings.c Thu Aug 01 13:42:51 2013 +0300 +++ b/src/lib-master/master-service-settings.c Thu Aug 01 13:51:57 2013 +0300 @@ -367,20 +367,29 @@ unsigned int i; int ret, fd = -1; time_t now, timeout; - bool use_environment; + bool use_environment, retry; memset(output_r, 0, sizeof(*output_r)); if (getenv("DOVECONF_ENV") == NULL && (service->flags & MASTER_SERVICE_FLAG_NO_CONFIG_SETTINGS) == 0) { - fd = master_service_open_config(service, input, &path, error_r); - if (fd == -1) - return -1; + retry = service->config_fd != -1; + for (;;) { + fd = master_service_open_config(service, input, + &path, error_r); + if (fd == -1) + return -1; - if (config_send_request(service, input, fd, path, error_r) < 0) { - i_close_fd(&fd); - config_exec_fallback(service, input); - return -1; + if (config_send_request(service, input, fd, + path, error_r) == 0) + break; + if (!retry) { + i_close_fd(&fd); + config_exec_fallback(service, input); + return -1; + } + /* config process died, retry connecting */ + retry = FALSE; } } From dovecot at dovecot.org Thu Aug 1 14:18:29 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 14:18:29 +0300 Subject: dovecot-2.2: lib-master: Added master_service_settings_output.pe... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5696b0162527 changeset: 16629:5696b0162527 user: Timo Sirainen date: Thu Aug 01 14:18:00 2013 +0300 description: lib-master: Added master_service_settings_output.permission_denied error flag. diffstat: src/lib-master/master-service-settings.c | 7 ++++++- src/lib-master/master-service-settings.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletions(-) diffs (46 lines): diff -r 96ea65bf653c -r 5696b0162527 src/lib-master/master-service-settings.c --- a/src/lib-master/master-service-settings.c Thu Aug 01 13:51:57 2013 +0300 +++ b/src/lib-master/master-service-settings.c Thu Aug 01 14:18:00 2013 +0300 @@ -150,6 +150,7 @@ { const char *path; struct stat st; + int saved_errno = errno; if (input->never_exec) return; @@ -161,6 +162,7 @@ /* it's a file, not a socket/pipe */ master_service_exec_config(service, input); } + errno = saved_errno; } static int @@ -377,8 +379,11 @@ for (;;) { fd = master_service_open_config(service, input, &path, error_r); - if (fd == -1) + if (fd == -1) { + if (errno == EACCES) + output_r->permission_denied = TRUE; return -1; + } if (config_send_request(service, input, fd, path, error_r) == 0) diff -r 96ea65bf653c -r 5696b0162527 src/lib-master/master-service-settings.h --- a/src/lib-master/master-service-settings.h Thu Aug 01 13:51:57 2013 +0300 +++ b/src/lib-master/master-service-settings.h Thu Aug 01 14:18:00 2013 +0300 @@ -52,6 +52,10 @@ local/remote ip/host */ unsigned int used_local:1; unsigned int used_remote:1; + /* Config couldn't be read because we don't have enough permissions. + The process probably should be restarted and the settings read + before dropping privileges. */ + unsigned int permission_denied:1; }; extern const struct setting_parser_info master_service_setting_parser_info; From dovecot at dovecot.org Thu Aug 1 14:18:29 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 14:18:29 +0300 Subject: dovecot-2.2: lib-storage: If settings can't be read because of p... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2bccde4027ea changeset: 16630:2bccde4027ea user: Timo Sirainen date: Thu Aug 01 14:18:24 2013 +0300 description: lib-storage: If settings can't be read because of permission denied, restart process. diffstat: src/lib-storage/mail-storage-service.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diffs (41 lines): diff -r 5696b0162527 -r 2bccde4027ea src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Thu Aug 01 14:18:00 2013 +0300 +++ b/src/lib-storage/mail-storage-service.c Thu Aug 01 14:18:24 2013 +0300 @@ -65,6 +65,7 @@ unsigned int debug:1; unsigned int log_initialized:1; + unsigned int config_permission_denied:1; }; struct mail_storage_service_user { @@ -831,6 +832,8 @@ enum mail_storage_service_flags flags; unsigned int i; + ctx->config_permission_denied = FALSE; + flags = input == NULL ? ctx->flags : mail_storage_service_input_get_flags(ctx, input); @@ -879,6 +882,8 @@ &set_output, error_r) < 0) { *error_r = t_strdup_printf( "Error reading configuration: %s", *error_r); + ctx->config_permission_denied = + set_output.permission_denied; return -1; } *parser_r = ctx->service->set_parser; @@ -988,6 +993,11 @@ if (mail_storage_service_read_settings(ctx, input, user_pool, &user_info, &set_parser, &error) < 0) { + if (ctx->config_permission_denied) { + /* just restart and maybe next time we will open the + config socket before dropping privileges */ + i_fatal("user %s: %s", username, error); + } i_error("user %s: %s", username, error); pool_unref(&user_pool); *error_r = MAIL_ERRSTR_CRITICAL_MSG; From dovecot at dovecot.org Thu Aug 1 14:23:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 14:23:48 +0300 Subject: dovecot-2.2: lib-storage: Improved seteuid() error messages a bit. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f7f3ea4cb6df changeset: 16631:f7f3ea4cb6df user: Timo Sirainen date: Thu Aug 01 14:23:33 2013 +0300 description: lib-storage: Improved seteuid() error messages a bit. diffstat: src/lib-storage/mail-storage-service.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diffs (49 lines): diff -r 2bccde4027ea -r f7f3ea4cb6df src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Thu Aug 01 14:18:24 2013 +0300 +++ b/src/lib-storage/mail-storage-service.c Thu Aug 01 14:23:33 2013 +0300 @@ -495,6 +495,15 @@ return 0; } +static void mail_storage_service_seteuid_root(void) +{ + if (seteuid(0) < 0) { + i_fatal("mail-storage-service: " + "Failed to restore temporarily dropped root privileges: " + "seteuid(0) failed: %m"); + } +} + static int service_drop_privileges(struct mail_storage_service_user *user, struct mail_storage_service_privileges *priv, @@ -572,8 +581,7 @@ if (current_euid != 0) { /* we're changing the UID, switch back to root first */ - if (seteuid(0) < 0) - i_fatal("seteuid(0) failed: %m"); + mail_storage_service_seteuid_root(); } setuid_uid = rset.uid; } @@ -588,7 +596,8 @@ } if (setuid_uid != 0 && !setenv_only) { if (seteuid(setuid_uid) < 0) - i_fatal("seteuid(%s) failed: %m", dec2str(setuid_uid)); + i_fatal("mail-storage-service: seteuid(%s) failed: %m", + dec2str(setuid_uid)); } return 0; } @@ -986,8 +995,7 @@ /* we dropped privileges only temporarily. switch back to root before reading settings, so we'll definitely have enough permissions to connect to the config socket. */ - if (seteuid(0) < 0) - i_fatal("seteuid(0) failed: %m"); + mail_storage_service_seteuid_root(); } if (mail_storage_service_read_settings(ctx, input, user_pool, From dovecot at dovecot.org Thu Aug 1 15:01:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 15:01:05 +0300 Subject: dovecot-2.2: quota: Don't log errors about missing namespaces fo... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1705bf7bf484 changeset: 16632:1705bf7bf484 user: Timo Sirainen date: Thu Aug 01 15:00:59 2013 +0300 description: quota: Don't log errors about missing namespaces for autocreated shared mail_users. diffstat: src/plugins/quota/quota-storage.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (28 lines): diff -r f7f3ea4cb6df -r 1705bf7bf484 src/plugins/quota/quota-storage.c --- a/src/plugins/quota/quota-storage.c Thu Aug 01 14:23:33 2013 +0300 +++ b/src/plugins/quota/quota-storage.c Thu Aug 01 15:00:59 2013 +0300 @@ -597,11 +597,13 @@ const struct quota_rule *rule; const char *name; struct mail_namespace *ns; + /* silence errors for autocreated (shared) users */ + bool silent_errors = namespaces->user->autocreated; if (root->ns_prefix != NULL && root->ns == NULL) { root->ns = mail_namespace_find_prefix(namespaces, root->ns_prefix); - if (root->ns == NULL) { + if (root->ns == NULL && !silent_errors) { i_error("quota: Unknown namespace: %s", root->ns_prefix); } @@ -610,7 +612,8 @@ array_foreach(&root->set->rules, rule) { name = rule->mailbox_name; ns = mail_namespace_find(namespaces, name); - if ((ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) + if ((ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0 && + !silent_errors) i_error("quota: Unknown namespace: %s", name); } } From dovecot at dovecot.org Thu Aug 1 15:35:40 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 01 Aug 2013 15:35:40 +0300 Subject: dovecot-2.2: ssl: Log SSL "close notify" alerts as debug message... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2714f51e2355 changeset: 16633:2714f51e2355 user: Timo Sirainen date: Thu Aug 01 15:35:35 2013 +0300 description: ssl: Log SSL "close notify" alerts as debug messages, not warnings. They are clean shutdown messages after all. diffstat: src/lib-ssl-iostream/iostream-openssl.c | 17 +++++++++++++---- src/login-common/ssl-proxy-openssl.c | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diffs (54 lines): diff -r 1705bf7bf484 -r 2714f51e2355 src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Thu Aug 01 15:00:59 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Thu Aug 01 15:35:35 2013 +0300 @@ -22,10 +22,19 @@ ssl_io = SSL_get_ex_data(ssl, dovecot_ssl_extdata_index); if ((where & SSL_CB_ALERT) != 0) { - i_warning("%sSSL alert: where=0x%x, ret=%d: %s %s", - ssl_io->log_prefix, where, ret, - SSL_alert_type_string_long(ret), - SSL_alert_desc_string_long(ret)); + switch (ret & 0xff) { + case SSL_AD_CLOSE_NOTIFY: + i_debug("%sSSL alert: %s", + ssl_io->log_prefix, + SSL_alert_desc_string_long(ret)); + break; + default: + i_warning("%sSSL alert: where=0x%x, ret=%d: %s %s", + ssl_io->log_prefix, where, ret, + SSL_alert_type_string_long(ret), + SSL_alert_desc_string_long(ret)); + break; + } } else if (ret == 0) { i_warning("%sSSL failed: where=0x%x: %s", ssl_io->log_prefix, where, SSL_state_string_long(ssl)); diff -r 1705bf7bf484 -r 2714f51e2355 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Thu Aug 01 15:00:59 2013 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Thu Aug 01 15:35:35 2013 +0300 @@ -850,10 +850,19 @@ return; if ((where & SSL_CB_ALERT) != 0) { - i_warning("SSL alert: where=0x%x, ret=%d: %s %s [%s]", - where, ret, SSL_alert_type_string_long(ret), - SSL_alert_desc_string_long(ret), - net_ip2addr(&proxy->ip)); + switch (ret & 0xff) { + case SSL_AD_CLOSE_NOTIFY: + i_debug("SSL alert: %s [%s]", + SSL_alert_desc_string_long(ret), + net_ip2addr(&proxy->ip)); + break; + default: + i_warning("SSL alert: where=0x%x, ret=%d: %s %s [%s]", + where, ret, SSL_alert_type_string_long(ret), + SSL_alert_desc_string_long(ret), + net_ip2addr(&proxy->ip)); + break; + } } else if (ret == 0) { i_warning("SSL failed: where=0x%x: %s [%s]", where, SSL_state_string_long(ssl), From dovecot at dovecot.org Fri Aug 2 15:14:51 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 Aug 2013 15:14:51 +0300 Subject: dovecot-2.1: quota-status: Removed extra newlines from default q... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b73639f92610 changeset: 14989:b73639f92610 user: Timo Sirainen date: Fri Aug 02 15:14:39 2013 +0300 description: quota-status: Removed extra newlines from default quota_status_overquota message. Patch by Ulrich Zehl diffstat: src/plugins/quota/quota-status.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r c9d7586d01ae -r b73639f92610 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Mon Jul 29 23:21:38 2013 +0300 +++ b/src/plugins/quota/quota-status.c Fri Aug 02 15:14:39 2013 +0300 @@ -111,7 +111,7 @@ /* over quota */ value = mail_user_plugin_getenv(user, "quota_status_overquota"); if (value == NULL) - value = t_strdup_printf("554 5.2.2 %s\n\n", error); + value = t_strdup_printf("554 5.2.2 %s", error); } value = t_strdup(value); /* user's pool is being freed */ mail_user_unref(&user); From dovecot at dovecot.org Fri Aug 2 15:14:52 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 Aug 2013 15:14:52 +0300 Subject: dovecot-2.2: quota-status: Removed extra newlines from default q... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3e98654cbb54 changeset: 16634:3e98654cbb54 user: Timo Sirainen date: Fri Aug 02 15:14:39 2013 +0300 description: quota-status: Removed extra newlines from default quota_status_overquota message. Patch by Ulrich Zehl diffstat: src/plugins/quota/quota-status.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 2714f51e2355 -r 3e98654cbb54 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Thu Aug 01 15:35:35 2013 +0300 +++ b/src/plugins/quota/quota-status.c Fri Aug 02 15:14:39 2013 +0300 @@ -107,7 +107,7 @@ /* over quota */ value = mail_user_plugin_getenv(user, "quota_status_overquota"); if (value == NULL) - value = t_strdup_printf("554 5.2.2 %s\n\n", error); + value = t_strdup_printf("554 5.2.2 %s", error); } value = t_strdup(value); /* user's pool is being freed */ mail_user_unref(&user); From dovecot at dovecot.org Fri Aug 2 15:19:30 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 Aug 2013 15:19:30 +0300 Subject: dovecot-2.2: quota-status: Added quota_status_toolarge message f... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/78225937a030 changeset: 16635:78225937a030 user: Timo Sirainen date: Fri Aug 02 15:19:22 2013 +0300 description: quota-status: Added quota_status_toolarge message for mails larger than user's quota limit. Based on patch by Ulrich Zehl diffstat: src/plugins/quota/quota-status.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diffs (58 lines): diff -r 3e98654cbb54 -r 78225937a030 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Fri Aug 02 15:14:39 2013 +0300 +++ b/src/plugins/quota/quota-status.c Fri Aug 02 15:19:22 2013 +0300 @@ -46,13 +46,13 @@ } static int -quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r) +quota_check(struct mail_user *user, uoff_t mail_size, + const char **error_r, bool *too_large_r) { struct quota_user *quser = QUOTA_USER_CONTEXT(user); struct mail_namespace *ns; struct mailbox *box; struct quota_transaction_context *ctx; - bool too_large; int ret; if (quser == NULL) { @@ -64,7 +64,7 @@ box = mailbox_alloc(ns->list, "INBOX", 0); ctx = quota_transaction_begin(box); - ret = quota_test_alloc(ctx, I_MAX(1, mail_size), &too_large); + ret = quota_test_alloc(ctx, I_MAX(1, mail_size), too_large_r); quota_transaction_rollback(&ctx); mailbox_free(&box); @@ -82,6 +82,7 @@ struct mail_storage_service_user *service_user; struct mail_user *user; const char *value = NULL, *error; + bool too_large; int ret; if (client->recipient == NULL) { @@ -98,14 +99,18 @@ if (ret == 0) { value = nouser_reply; } else if (ret > 0) { - if ((ret = quota_check(user, client->size, &error)) > 0) { + if ((ret = quota_check(user, client->size, &error, &too_large)) > 0) { /* under quota */ value = mail_user_plugin_getenv(user, "quota_status_success"); if (value == NULL) value = "OK"; } else if (ret == 0) { - /* over quota */ - value = mail_user_plugin_getenv(user, "quota_status_overquota"); + if (too_large) { + /* even over maximum quota */ + value = mail_user_plugin_getenv(user, "quota_status_toolarge"); + } + if (value == NULL) + value = mail_user_plugin_getenv(user, "quota_status_overquota"); if (value == NULL) value = t_strdup_printf("554 5.2.2 %s", error); } From dovecot at dovecot.org Fri Aug 2 15:20:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 Aug 2013 15:20:57 +0300 Subject: dovecot-2.1: quota-status: Added quota_status_toolarge message f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/578b911f355b changeset: 14990:578b911f355b user: Timo Sirainen date: Fri Aug 02 15:19:22 2013 +0300 description: quota-status: Added quota_status_toolarge message for mails larger than user's quota limit. Based on patch by Ulrich Zehl diffstat: src/plugins/quota/quota-status.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diffs (58 lines): diff -r b73639f92610 -r 578b911f355b src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Fri Aug 02 15:14:39 2013 +0300 +++ b/src/plugins/quota/quota-status.c Fri Aug 02 15:19:22 2013 +0300 @@ -50,13 +50,13 @@ } static int -quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r) +quota_check(struct mail_user *user, uoff_t mail_size, + const char **error_r, bool *too_large_r) { struct quota_user *quser = QUOTA_USER_CONTEXT(user); struct mail_namespace *ns; struct mailbox *box; struct quota_transaction_context *ctx; - bool too_large; int ret; if (quser == NULL) { @@ -68,7 +68,7 @@ box = mailbox_alloc(ns->list, "INBOX", 0); ctx = quota_transaction_begin(box); - ret = quota_test_alloc(ctx, I_MAX(1, mail_size), &too_large); + ret = quota_test_alloc(ctx, I_MAX(1, mail_size), too_large_r); quota_transaction_rollback(&ctx); mailbox_free(&box); @@ -86,6 +86,7 @@ struct mail_storage_service_user *service_user; struct mail_user *user; const char *value = NULL, *error; + bool too_large; int ret; if (client->recipient == NULL) { @@ -102,14 +103,18 @@ if (ret == 0) { value = nouser_reply; } else if (ret > 0) { - if ((ret = quota_check(user, client->size, &error)) > 0) { + if ((ret = quota_check(user, client->size, &error, &too_large)) > 0) { /* under quota */ value = mail_user_plugin_getenv(user, "quota_status_success"); if (value == NULL) value = "OK"; } else if (ret == 0) { - /* over quota */ - value = mail_user_plugin_getenv(user, "quota_status_overquota"); + if (too_large) { + /* even over maximum quota */ + value = mail_user_plugin_getenv(user, "quota_status_toolarge"); + } + if (value == NULL) + value = mail_user_plugin_getenv(user, "quota_status_overquota"); if (value == NULL) value = t_strdup_printf("554 5.2.2 %s", error); } From dovecot at dovecot.org Fri Aug 2 15:21:08 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 Aug 2013 15:21:08 +0300 Subject: dovecot-2.1: quota-status: Keep the config connection open. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b986ac5e1d98 changeset: 14991:b986ac5e1d98 user: Timo Sirainen date: Tue Jul 30 13:26:40 2013 +0300 description: quota-status: Keep the config connection open. diffstat: src/plugins/quota/quota-status.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (17 lines): diff -r 578b911f355b -r b986ac5e1d98 src/plugins/quota/quota-status.c --- a/src/plugins/quota/quota-status.c Fri Aug 02 15:19:22 2013 +0300 +++ b/src/plugins/quota/quota-status.c Tue Jul 30 13:26:40 2013 +0300 @@ -223,10 +223,12 @@ int main(int argc, char *argv[]) { + enum master_service_flags service_flags = + MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN; int c; protocol = QUOTA_PROTOCOL_UNKNOWN; - master_service = master_service_init("quota-status", 0, + master_service = master_service_init("quota-status", service_flags, &argc, &argv, "p:"); while ((c = master_getopt(master_service)) > 0) { switch (c) { From dovecot at dovecot.org Fri Aug 2 16:20:17 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 02 Aug 2013 16:20:17 +0300 Subject: dovecot-2.2: doveadm flags: Fixed help text for subcommands. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f16816a69130 changeset: 16636:f16816a69130 user: Timo Sirainen date: Fri Aug 02 16:20:08 2013 +0300 description: doveadm flags: Fixed help text for subcommands. diffstat: src/doveadm/doveadm-mail-flags.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diffs (23 lines): diff -r 78225937a030 -r f16816a69130 src/doveadm/doveadm-mail-flags.c --- a/src/doveadm/doveadm-mail-flags.c Fri Aug 02 15:19:22 2013 +0300 +++ b/src/doveadm/doveadm-mail-flags.c Fri Aug 02 16:20:08 2013 +0300 @@ -80,8 +80,17 @@ enum mail_flags flag; ARRAY_TYPE(const_string) keywords; - if (args[0] == NULL || args[1] == NULL) - doveadm_mail_help_name("flags"); + if (args[0] == NULL || args[1] == NULL) { + switch (ctx->modify_type) { + case MODIFY_ADD: + doveadm_mail_help_name("flags add"); + case MODIFY_REMOVE: + doveadm_mail_help_name("flags remove"); + case MODIFY_REPLACE: + doveadm_mail_help_name("flags replace"); + } + i_unreached(); + } p_array_init(&keywords, _ctx->pool, 8); for (tmp = t_strsplit(args[0], " "); *tmp != NULL; tmp++) { From dovecot at dovecot.org Sat Aug 3 01:19:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 03 Aug 2013 01:19:38 +0300 Subject: dovecot-2.2: man: Added doveadm-deduplicate.1 and doveadm-flags.1. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/78a3b43af482 changeset: 16637:78a3b43af482 user: Pascal Volk date: Fri Aug 02 19:03:32 2013 +0000 description: man: Added doveadm-deduplicate.1 and doveadm-flags.1. diffstat: .hgignore | 2 +- doc/man/Makefile.am | 4 + doc/man/doveadm-deduplicate.1.in | 87 ++++++++++++++++++++++++++++++++ doc/man/doveadm-flags.1.in | 103 +++++++++++++++++++++++++++++++++++++++ doc/man/doveadm.1.in | 14 ++++- 5 files changed, 207 insertions(+), 3 deletions(-) diffs (274 lines): diff -r f16816a69130 -r 78a3b43af482 .hgignore --- a/.hgignore Fri Aug 02 16:20:08 2013 +0300 +++ b/.hgignore Fri Aug 02 19:03:32 2013 +0000 @@ -105,5 +105,5 @@ syntax: regexp src/.*/test-[^\.]*$ -doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|instance|index|force-resync|help|kick|log|mailbox|mount|move|penalty|purge|pw|quota|search|user|who)\.1$ +doc/man/doveadm-(altmove|auth|deduplicate|director|dump|expunge|fetch|flags|import|instance|index|force-resync|help|kick|log|mailbox|mount|move|penalty|purge|pw|quota|search|user|who)\.1$ doc/man/(doveadm|doveconf|dovecot-lda|dovecot|dsync)\.1$ diff -r f16816a69130 -r 78a3b43af482 doc/man/Makefile.am --- a/doc/man/Makefile.am Fri Aug 02 16:20:08 2013 +0300 +++ b/doc/man/Makefile.am Fri Aug 02 19:03:32 2013 +0000 @@ -15,10 +15,12 @@ doveadm.1 \ doveadm-altmove.1 \ doveadm-auth.1 \ + doveadm-deduplicate.1 \ doveadm-director.1 \ doveadm-dump.1 \ doveadm-expunge.1 \ doveadm-fetch.1 \ + doveadm-flags.1 \ doveadm-import.1 \ doveadm-instance.1 \ doveadm-index.1 \ @@ -53,10 +55,12 @@ doveadm.1.in \ doveadm-altmove.1.in \ doveadm-auth.1.in \ + doveadm-deduplicate.1.in \ doveadm-director.1.in \ doveadm-dump.1.in \ doveadm-expunge.1.in \ doveadm-fetch.1.in \ + doveadm-flags.1.in doveadm-import.1.in \ doveadm-instance.1.in \ doveadm-index.1.in \ diff -r f16816a69130 -r 78a3b43af482 doc/man/doveadm-deduplicate.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-deduplicate.1.in Fri Aug 02 19:03:32 2013 +0000 @@ -0,0 +1,87 @@ +.\" Copyright (c) 2013 Dovecot authors, see the included COPYING file +.TH DOVEADM\-DEDUPLICATE 1 "2013-08-02" "Dovecot v2.2" "Dovecot" +.SH NAME +doveadm\-deduplicate \- expunge duplicate messages +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] " deduplicate " [" \-u +.IR user |\c +.BR \-A "] [" \-S +.IR socket_path "] ["\c +.BR \-m ] +.I search_query +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +This command is used to expunge duplicated messages in mailboxes. +.B doveadm deduplicate +is mainly useful to revert some (more or less) accidental duplication of +messages, e.g. after +.BR "doveadm copy" " or " "doveadm import" . +.BR doveadm (1) +will delete the newest duplicated messages from the mailbox and keep the +oldest. +.br +Deduplication across multiple mailboxes is not supported. +.\"------------------------------------------------------------------------ + at INCLUDE:global-options@ +.\"------------------------------------- +.PP +Command specific +.IR options : +.\"------------------------------------- + at INCLUDE:option-A@ +.\"------------------------------------- + at INCLUDE:option-S-socket@ +.\"------------------------------------- +.TP +.B \-m +if the +.B \-m +option is given, +.BR doveadm (1) +will deduplicate by Message\-Id header. +By default deduplication will be done by message GUIDs. +.\"------------------------------------- + at INCLUDE:option-u-user@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I search_query +expunge duplicates found from messages matching the given search query. +Typically a search query like \(aq\c +.BI "mailbox " mailbox_name " OR mailbox " other_box\c +\(aq will be sufficient. +See +.BR doveadm\-search\-query (7) +for details. + +.\"------------------------------------------------------------------------ +.SH EXAMPLE +This example shows how to list and expunge duplicate messages from a +mailbox. +.sp +.nf +.B doveadm \-f table fetch \-u jane \(aqguid uid\(aq mailbox a_Box | sort +guid uid +8aad0f0a30169f4bea620000ca356bad 18751 +8aad0f0a30169f4bea620000ca356bad 18756 +923e301ab9219b4b4f440000ca356bad 18748 +923e301ab9219b4b4f440000ca356bad 18753 +\&... +.B doveadm deduplicate \-u jane mailbox a_Box +.B doveadm \-f table fetch \-u jane \(aqguid uid\(aq mailbox a_Box | sort +guid uid +8aad0f0a30169f4bea620000ca356bad 18751 +923e301ab9219b4b4f440000ca356bad 18748 +a7999e1530739c4bd26d0000ca356bad 18749 +\&... +.fi +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1), +.BR doveadm\-copy (1), +.BR doveadm\-fetch (1), +.BR doveadm\-import (1), +.BR doveadm\-search\-query (7) \ No newline at end of file diff -r f16816a69130 -r 78a3b43af482 doc/man/doveadm-flags.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-flags.1.in Fri Aug 02 19:03:32 2013 +0000 @@ -0,0 +1,103 @@ +.\" Copyright (c) 2013 Dovecot authors, see the included COPYING file +.TH DOVEADM\-FLAGS 1 "2013-08-02" "Dovecot v2.2" "Dovecot" +.SH NAME +doveadm\-flags \- add, remove or replace messages\(aq flags +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] " flags " [" \-S +.IR socket_path "] " "command flags search_query" +.\"------------------------------------- +.br +.BR doveadm " [" \-Dv "] " flags " [" \-S +.IR socket_path "] " "command flags search_query" +.B \-A +.\"------------------------------------- +.br +.BR doveadm " [" \-Dv "] " flags " [" \-S +.IR socket_path "] " "command flags search_query" +.BI "\-u " user +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +This command is used to manipulate flags of messages. +.\"------------------------------------------------------------------------ + at INCLUDE:global-options@ +.\"------------------------------------- +.PP +Command specific +.IR options : +.\"------------------------------------- + at INCLUDE:option-A@ +.\"------------------------------------- + at INCLUDE:option-S-socket@ +.\"------------------------------------- + at INCLUDE:option-u-user@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I flags +Message flags as described in RFC 3501, section 2.3.2 (Flags Message +Attribute): +.BR \(rsAnswered ", " \(rsDeleted ", " \(rsDraft ", " \(rsFlagged ", " +.BR \(rsRecent " and " \(rsSeen . +And the IMAP keywords +.BR \(DoForwarded ", " \(DoMDNSent ", " \(DoSubmitPending " and " +.B \(DoSubmitted +or user\-defined keywords, e.g. Junk, \(DoNonSpam or \(DoLabel1. +.br +One or multiple flags and/or keywords can be specified. +.\"------------------------------------- +.TP +.I search_query +Manipulate the flags of messages matching the given search query. +See +.BR doveadm\-search\-query (7) +for details. +.\"------------------------------------------------------------------------ +.SH COMMANDS +.SS flags add +.BR "doveadm flags add" " [" \-u +.IR user |\c +.BR \-A "] [" \-S +.IR socket_path "] " "flags search_query" +.PP +This command is used to extend the current set of flags with the given +.IR flags . +.\"------------------------------------- +.SS flags remove +.BR "doveadm flags remove" " [" \-u +.IR user |\c +.BR \-A "] [" \-S +.IR socket_path "] " "flags search_query" +.PP +In order to remove the given +.I flags +from the current set of flags, use this command. +.\"------------------------------------- +.SS flags replace +.BR "doveadm flags replace" " [" \-u +.IR user |\c +.BR \-A "] [" \-S +.IR socket_path "] " "flags search_query" +.PP +This command is used to replace ALL current flags with the given +.IR flags . +.\"------------------------------------------------------------------------ +.SH EXAMPLE +List and manipulate the message flags of the message with uid 81563 +.sp +.nf +.B doveadm fetch \-u bob \(aquid flags\(aq mailbox dovecot uid 81563 +uid: 81563 +flags: \(rsAnswered \(rsSeen NonJunk + +.B doveadm flags \-u bob remove NonJunk mailbox dovecot uid 81563 +.B doveadm flags \-u bob add \(aq\(rsFlagged \(DoForwarded\(aq \ +mailbox dovecot uid 81563 +.fi +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1), +.BR doveadm\-fetch (1), +.BR doveadm\-search\-query (7) \ No newline at end of file diff -r f16816a69130 -r 78a3b43af482 doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Fri Aug 02 16:20:08 2013 +0300 +++ b/doc/man/doveadm.1.in Fri Aug 02 19:03:32 2013 +0000 @@ -1,5 +1,5 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM 1 "2011-05-11" "Dovecot v2.2" "Dovecot" +.\" Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file +.TH DOVEADM 1 "2013-08-02" "Dovecot v2.2" "Dovecot" .SH NAME doveadm \- Dovecot\(aqs administration utility .\"------------------------------------------------------------------------ @@ -97,6 +97,11 @@ Move matching mails to the alternative storage. .\"------------------------------------- .TP +.B doveadm deduplicate +.BR doveadm\-deduplicate (1), +Expunge duplicate messages. +.\"------------------------------------- +.TP .B doveadm dump .BR doveadm\-dump (1), Dump the content of Dovecot\(aqs binary mailbox index/log. @@ -112,6 +117,11 @@ Fetch messages matching given search query. .\"------------------------------------- .TP +.B doveadm flags +.BR doveadm\-flags (1), +Add, remove or replace messages\(aq flags. +.\"------------------------------------- +.TP .B doveadm force\-resync .BR doveadm\-force\-resync (1), Repair broken mailboxes, in case Dovecot doesn\(aqt automatically do that. From dovecot at dovecot.org Sat Aug 3 15:27:13 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 03 Aug 2013 15:27:13 +0300 Subject: dovecot-2.2: Makefile: Fixed previous commit. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0e38ca2aa8d6 changeset: 16638:0e38ca2aa8d6 user: Timo Sirainen date: Sat Aug 03 15:26:58 2013 +0300 description: Makefile: Fixed previous commit. diffstat: doc/man/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 78a3b43af482 -r 0e38ca2aa8d6 doc/man/Makefile.am --- a/doc/man/Makefile.am Fri Aug 02 19:03:32 2013 +0000 +++ b/doc/man/Makefile.am Sat Aug 03 15:26:58 2013 +0300 @@ -60,7 +60,7 @@ doveadm-dump.1.in \ doveadm-expunge.1.in \ doveadm-fetch.1.in \ - doveadm-flags.1.in + doveadm-flags.1.in \ doveadm-import.1.in \ doveadm-instance.1.in \ doveadm-index.1.in \ From dovecot at dovecot.org Sat Aug 3 21:33:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 03 Aug 2013 21:33:38 +0300 Subject: dovecot-2.2: man: Fixed doveadm-deduplicate.1 Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/292991f2d504 changeset: 16639:292991f2d504 user: Timo Sirainen date: Sat Aug 03 21:33:25 2013 +0300 description: man: Fixed doveadm-deduplicate.1 Patch by Pascal Volk diffstat: doc/man/doveadm-deduplicate.1.in | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diffs (26 lines): diff -r 0e38ca2aa8d6 -r 292991f2d504 doc/man/doveadm-deduplicate.1.in --- a/doc/man/doveadm-deduplicate.1.in Sat Aug 03 15:26:58 2013 +0300 +++ b/doc/man/doveadm-deduplicate.1.in Sat Aug 03 21:33:25 2013 +0300 @@ -1,5 +1,5 @@ .\" Copyright (c) 2013 Dovecot authors, see the included COPYING file -.TH DOVEADM\-DEDUPLICATE 1 "2013-08-02" "Dovecot v2.2" "Dovecot" +.TH DOVEADM\-DEDUPLICATE 1 "2013-08-03" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-deduplicate \- expunge duplicate messages .\"------------------------------------------------------------------------ @@ -48,13 +48,11 @@ .TP .I search_query expunge duplicates found from messages matching the given search query. -Typically a search query like \(aq\c -.BI "mailbox " mailbox_name " OR mailbox " other_box\c -\(aq will be sufficient. +Typically a search query like \(aq\fBmailbox\fP \fImailbox_name\fP +\fBOR mailbox\fP \fIother_box\fP\(aq will be sufficient. See .BR doveadm\-search\-query (7) for details. - .\"------------------------------------------------------------------------ .SH EXAMPLE This example shows how to list and expunge duplicate messages from a From dovecot at dovecot.org Sun Aug 4 12:16:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Aug 2013 12:16:21 +0300 Subject: dovecot-2.2: lib-http: Don't crash when receiving 304 or a redir... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/97fcb2904b22 changeset: 16640:97fcb2904b22 user: Timo Sirainen date: Sun Aug 04 12:16:09 2013 +0300 description: lib-http: Don't crash when receiving 304 or a redirect without Location: header. Patch by Stephan Bosch diffstat: src/lib-http/http-client-connection.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (15 lines): diff -r 292991f2d504 -r 97fcb2904b22 src/lib-http/http-client-connection.c --- a/src/lib-http/http-client-connection.c Sat Aug 03 21:33:25 2013 +0300 +++ b/src/lib-http/http-client-connection.c Sun Aug 04 12:16:09 2013 +0300 @@ -590,8 +590,9 @@ req->payload_sync = FALSE; conn->peer->no_payload_sync = TRUE; http_client_request_retry(req, response->status, response->reason); - return; - } else if (response->status / 100 == 3) { + return; + } else if (response->status / 100 == 3 && response->status != 304 && + response->location != NULL) { /* redirect */ http_client_request_redirect(req, response->status, response->location); } else { From dovecot at dovecot.org Sun Aug 4 14:04:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Aug 2013 14:04:09 +0300 Subject: dovecot-2.2: lib-http: Ignore trailing whitespace in headers. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2d6497a4f124 changeset: 16641:2d6497a4f124 user: Timo Sirainen date: Sun Aug 04 14:03:54 2013 +0300 description: lib-http: Ignore trailing whitespace in headers. Patch by Stephan Bosch. diffstat: src/lib-http/http-header-parser.c | 13 +++++++++++-- src/lib-http/test-http-header-parser.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diffs (91 lines): diff -r 97fcb2904b22 -r 2d6497a4f124 src/lib-http/http-header-parser.c --- a/src/lib-http/http-header-parser.c Sun Aug 04 12:16:09 2013 +0300 +++ b/src/lib-http/http-header-parser.c Sun Aug 04 14:03:54 2013 +0300 @@ -124,7 +124,7 @@ int ret; /* 'header' = *( header-field CRLF ) CRLF - header-field = field-name ":" OWS field-value BWS + header-field = field-name ":" OWS field-value OWS field-name = token field-value = *( field-content / obs-fold ) field-content = *( HTAB / SP / VCHAR / obs-text ) @@ -247,6 +247,7 @@ const char **name_r, const unsigned char **data_r, size_t *size_r, const char **error_r) { + const unsigned char *data; size_t size; int ret; @@ -264,8 +265,16 @@ if (ret == 1) { if (parser->state != HTTP_HEADER_PARSE_STATE_EOH) { + data = buffer_get_data(parser->value_buf, &size); + + /* trim trailing OWS */ + while (size > 0 && + (data[size-1] == ' ' || data[size-1] == '\t')) + size--; + *name_r = str_c(parser->name); - *data_r = buffer_get_data(parser->value_buf, size_r); + *data_r = data; + *size_r = size; parser->state = HTTP_HEADER_PARSE_STATE_INIT; } else { *name_r = NULL; diff -r 97fcb2904b22 -r 2d6497a4f124 src/lib-http/test-http-header-parser.c --- a/src/lib-http/test-http-header-parser.c Sun Aug 04 12:16:09 2013 +0300 +++ b/src/lib-http/test-http-header-parser.c Sun Aug 04 14:03:54 2013 +0300 @@ -62,6 +62,22 @@ }; static struct http_header_parse_result valid_header_parse_result4[] = { + { "Age", "58" }, + { "Date", "Sun, 04 Aug 2013 09:33:09 GMT" }, + { "Expires", "Sun, 04 Aug 2013 09:34:08 GMT" }, + { "Cache-Control", "max-age=60" }, + { "Content-Length", "17336" }, + { "Connection", "Keep-Alive" }, + { "Via", "NS-CACHE-9.3" }, + { "Server", "Apache" }, + { "Vary", "Host" }, + { "Last-Modified", "Sun, 04 Aug 2013 09:33:07 GMT" }, + { "Content-Type", "text/html; charset=utf-8" }, + { "Content-Encoding", "gzip" }, + { NULL, NULL } +}; + +static struct http_header_parse_result valid_header_parse_result5[] = { { NULL, NULL } }; @@ -108,9 +124,25 @@ "\r\n", .fields = valid_header_parse_result3 },{ + .header = + "Age: 58 \r\n" + "Date: Sun, 04 Aug 2013 09:33:09 GMT\r\n" + "Expires: Sun, 04 Aug 2013 09:34:08 GMT\r\n" + "Cache-Control: max-age=60 \r\n" + "Content-Length: 17336 \r\n" + "Connection: Keep-Alive\r\n" + "Via: NS-CACHE-9.3\r\n" + "Server: Apache\r\n" + "Vary: Host\r\n" + "Last-Modified: Sun, 04 Aug 2013 09:33:07 GMT\r\n" + "Content-Type: text/html; charset=utf-8\r\n" + "Content-Encoding: gzip\r\n" + "\r\n", + .fields = valid_header_parse_result4 + },{ .header = "\r\n", - .fields = valid_header_parse_result4 + .fields = valid_header_parse_result5 } }; From dovecot at dovecot.org Sun Aug 4 18:34:59 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Aug 2013 18:34:59 +0300 Subject: dovecot-2.2: imap: Various APPEND/CATENATE error handling bugfixes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3c2e1879fdf6 changeset: 16642:3c2e1879fdf6 user: Timo Sirainen date: Sun Aug 04 18:34:43 2013 +0300 description: imap: Various APPEND/CATENATE error handling bugfixes. Found using Apple's catenate.pl test script. diffstat: src/imap/cmd-append.c | 84 ++++++++++++++++++++++++++++++-------------------- 1 files changed, 51 insertions(+), 33 deletions(-) diffs (204 lines): diff -r 2d6497a4f124 -r 3c2e1879fdf6 src/imap/cmd-append.c --- a/src/imap/cmd-append.c Sun Aug 04 14:03:54 2013 +0300 +++ b/src/imap/cmd-append.c Sun Aug 04 18:34:43 2013 +0300 @@ -102,7 +102,8 @@ until newline is found. */ client->input_skip_line = TRUE; - client_send_command_error(cmd, "Too long argument."); + if (!ctx->failed) + client_send_command_error(cmd, "Too long argument."); cmd->param_error = TRUE; client_command_free(&cmd); return; @@ -125,11 +126,13 @@ static void cmd_append_finish(struct cmd_append_context *ctx) { - imap_parser_unref(&ctx->save_parser); + if (ctx->save_parser != NULL) + imap_parser_unref(&ctx->save_parser); i_assert(ctx->client->input_lock == ctx->cmd); - io_remove(&ctx->client->io); + if (ctx->client->io != NULL) + io_remove(&ctx->client->io); /* we must put back the original flush callback before beginning to sync (the command is still unfinished at that point) */ o_stream_set_flush_callback(ctx->client->output, @@ -147,12 +150,18 @@ mailbox_free(&ctx->box); } -static void cmd_append_send_literal_continue(struct client *client) +static bool cmd_append_send_literal_continue(struct cmd_append_context *ctx) { - o_stream_nsend(client->output, "+ OK\r\n", 6); - o_stream_nflush(client->output); - o_stream_uncork(client->output); - o_stream_cork(client->output); + if (ctx->failed) { + /* tagline was already sent, we can abort here */ + return FALSE; + } + + o_stream_nsend(ctx->client->output, "+ OK\r\n", 6); + o_stream_nflush(ctx->client->output); + o_stream_uncork(ctx->client->output); + o_stream_cork(ctx->client->output); + return TRUE; } static int @@ -362,8 +371,10 @@ args++; if (args->type == IMAP_ARG_LITERAL_SIZE || args->type == IMAP_ARG_LITERAL_SIZE_NONSYNC) { - if (args->type == IMAP_ARG_LITERAL_SIZE) - cmd_append_send_literal_continue(ctx->client); + if (args->type == IMAP_ARG_LITERAL_SIZE) { + if (!cmd_append_send_literal_continue(ctx)) + return TRUE; + } imap_parser_read_last_literal(ctx->save_parser); return FALSE; } @@ -431,12 +442,10 @@ /* TEXT */ if (!nonsync) { - if (ctx->failed) { - /* tagline was already sent, we can abort here */ + if (!cmd_append_send_literal_continue(ctx)) { cmd_append_finish(ctx); return TRUE; } - cmd_append_send_literal_continue(client); } i_assert(ctx->litinput != NULL); @@ -549,8 +558,13 @@ if (!ctx->failed) { client_send_tagline(cmd, "NO Can't save a zero byte message."); + ctx->failed = TRUE; } - return -1; + if (!*nonsync_r) + return -1; + /* {0+} used. although there isn't any point in using + MULTIAPPEND here and adding more messages, it is + technically valid so we'll continue parsing.. */ } ctx->litinput = i_stream_create_limit(client->input, ctx->literal_size); ctx->input = ctx->litinput; @@ -583,7 +597,9 @@ return 1; } else if (cat_list->type == IMAP_ARG_EOL) { /* zero parts */ - client_send_command_error(cmd, "Empty CATENATE list."); + if (!ctx->failed) + client_send_command_error(cmd, "Empty CATENATE list."); + client->input_skip_line = TRUE; return -1; } else if ((ret = cmd_append_catenate(cmd, cat_list, nonsync_r)) < 0) { /* invalid parameters, abort immediately */ @@ -599,7 +615,6 @@ static bool cmd_append_finish_parsing(struct client_command_context *cmd) { - struct client *client = cmd->client; struct cmd_append_context *ctx = cmd->context; enum mailbox_sync_flags sync_flags; enum imap_sync_flags imap_flags; @@ -609,7 +624,7 @@ int ret; /* eat away the trailing CRLF */ - client->input_skip_line = TRUE; + cmd->client->input_skip_line = TRUE; if (ctx->failed) { /* we failed earlier, error message is sent */ @@ -656,10 +671,12 @@ } static bool cmd_append_args_can_stop(struct cmd_append_context *ctx, - const struct imap_arg *args) + const struct imap_arg *args, + bool *last_literal_r) { const struct imap_arg *cat_list; + *last_literal_r = FALSE; if (args->type == IMAP_ARG_EOL) return TRUE; @@ -673,8 +690,11 @@ args->type == IMAP_ARG_LITERAL_SIZE_NONSYNC) return TRUE; if (imap_arg_atom_equals(args, "CATENATE") && - imap_arg_get_list(&args[1], &cat_list)) - return catenate_args_can_stop(ctx, cat_list); + imap_arg_get_list(&args[1], &cat_list)) { + if (catenate_args_can_stop(ctx, cat_list)) + return TRUE; + *last_literal_r = TRUE; + } return FALSE; } @@ -685,7 +705,7 @@ const struct imap_arg *args; const char *msg; unsigned int arg_min_count; - bool fatal, nonsync; + bool fatal, nonsync, last_literal; int ret; /* this function gets called 1) after parsing APPEND and @@ -703,13 +723,19 @@ /* parse the entire line up to the first message literal, or in case the input buffer is full of MULTIAPPEND CATENATE URLs, parse at least until the beginning of the next message */ - arg_min_count = 0; + arg_min_count = 0; last_literal = FALSE; do { - ret = imap_parser_read_args(ctx->save_parser, ++arg_min_count, + if (!last_literal) + arg_min_count++; + else { + /* we only read the literal size. now we read the + literal itself. */ + } + ret = imap_parser_read_args(ctx->save_parser, arg_min_count, IMAP_PARSE_FLAG_LITERAL_SIZE | IMAP_PARSE_FLAG_LITERAL8, &args); } while (ret >= (int)arg_min_count && - !cmd_append_args_can_stop(ctx, args)); + !cmd_append_args_can_stop(ctx, args, &last_literal)); if (ret == -1) { if (!ctx->failed) { msg = imap_parser_get_error(ctx->save_parser, &fatal); @@ -745,19 +771,11 @@ return cmd_append_parse_new_msg(cmd); } - if (!ctx->catenate) { - /* after literal comes CRLF, if we fail make sure - we eat it away */ - client->input_skip_line = TRUE; - } - if (!nonsync) { - if (ctx->failed) { - /* tagline was already sent, we can abort here */ + if (!cmd_append_send_literal_continue(ctx)) { cmd_append_finish(ctx); return TRUE; } - cmd_append_send_literal_continue(client); } i_assert(ctx->litinput != NULL); From dovecot at dovecot.org Sun Aug 4 20:33:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 04 Aug 2013 20:33:16 +0300 Subject: dovecot-2.2: lib-http: Fixed redirect request target encoding an... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3af0ae411b37 changeset: 16643:3af0ae411b37 user: Timo Sirainen date: Sun Aug 04 20:33:05 2013 +0300 description: lib-http: Fixed redirect request target encoding and NULL target. Patch by Stephan Bosch. diffstat: src/lib-http/http-client-request.c | 11 +++++---- src/lib-http/http-url.c | 42 +++++++++++++++++++++++++------------ src/lib-http/http-url.h | 2 + 3 files changed, 36 insertions(+), 19 deletions(-) diffs (120 lines): diff -r 3c2e1879fdf6 -r 3af0ae411b37 src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Sun Aug 04 18:34:43 2013 +0300 +++ b/src/lib-http/http-client-request.c Sun Aug 04 20:33:05 2013 +0300 @@ -68,7 +68,7 @@ req->method = p_strdup(pool, method); req->hostname = p_strdup(pool, host); req->port = HTTP_DEFAULT_PORT; - req->target = p_strdup(pool, target); + req->target = (target == NULL ? "/" : p_strdup(pool, target)); req->callback = callback; req->context = context; req->headers = str_new(default_pool, 256); @@ -555,7 +555,7 @@ unsigned int status, const char *location) { struct http_url *url; - const char *error; + const char *error, *target; unsigned int newport; /* parse URL */ @@ -607,16 +607,17 @@ } newport = (url->have_port ? url->port : (url->have_ssl ? 443 : 80)); + target = http_url_create_target(url); - http_client_request_debug(req, "Redirecting to http://%s:%u%s", - url->host_name, newport, url->path); + http_client_request_debug(req, "Redirecting to http%s://%s:%u%s", + (url->have_ssl ? "s" : ""), url->host_name, newport, target); // FIXME: handle literal IP specially (avoid duplicate parsing) req->host = NULL; req->conn = NULL; req->hostname = p_strdup(req->pool, url->host_name); req->port = newport; - req->target = p_strdup(req->pool, url->path); + req->target = p_strdup(req->pool, target); req->ssl = url->have_ssl; /* https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21 diff -r 3c2e1879fdf6 -r 3af0ae411b37 src/lib-http/http-url.c --- a/src/lib-http/http-url.c Sun Aug 04 18:34:43 2013 +0300 +++ b/src/lib-http/http-url.c Sun Aug 04 20:33:05 2013 +0300 @@ -237,6 +237,24 @@ * HTTP URL construction */ +static void http_url_add_target(string_t *urlstr, const struct http_url *url) +{ + if (url->path == NULL || *url->path == '\0') { + /* Older syntax of RFC 2616 requires this slash at all times for an + absolute URL + */ + str_append_c(urlstr, '/'); + } else { + uri_append_path_data(urlstr, "", url->path); + } + + /* query (pre-encoded) */ + if (url->enc_query != NULL) { + str_append_c(urlstr, '?'); + str_append(urlstr, url->enc_query); + } +} + const char *http_url_create(const struct http_url *url) { string_t *urlstr = t_str_new(512); @@ -259,20 +277,7 @@ if (url->have_port) uri_append_port(urlstr, url->port); - if (url->path == NULL || *url->path == '\0') { - /* Older syntax of RFC 2616 requires this slash at all times for an - absolute URL - */ - str_append_c(urlstr, '/'); - } else { - uri_append_path_data(urlstr, "", url->path); - } - - /* query (pre-encoded) */ - if (url->enc_query != NULL) { - str_append_c(urlstr, '?'); - str_append(urlstr, url->enc_query); - } + http_url_add_target(urlstr, url); /* fragment */ if (url->enc_fragment != NULL) { @@ -283,6 +288,15 @@ return str_c(urlstr); } +const char *http_url_create_target(const struct http_url *url) +{ + string_t *urlstr = t_str_new(256); + + http_url_add_target(urlstr, url); + + return str_c(urlstr); +} + void http_url_escape_param(string_t *out, const char *data) { uri_append_query_data(out, "&;/?=+", data); diff -r 3c2e1879fdf6 -r 3af0ae411b37 src/lib-http/http-url.h --- a/src/lib-http/http-url.h Sun Aug 04 18:34:43 2013 +0300 +++ b/src/lib-http/http-url.h Sun Aug 04 20:33:05 2013 +0300 @@ -45,6 +45,8 @@ const char *http_url_create(const struct http_url *url); +const char *http_url_create_target(const struct http_url *url); + void http_url_escape_param(string_t *out, const char *data); #endif From dovecot at dovecot.org Mon Aug 5 13:46:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 13:46:47 +0300 Subject: dovecot-2.2: lib-index: Silently ignore next_uid shrinking witho... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/374e338bb3d6 changeset: 16644:374e338bb3d6 user: Timo Sirainen date: Mon Aug 05 13:46:37 2013 +0300 description: lib-index: Silently ignore next_uid shrinking without treating them as errors. diffstat: src/lib-index/mail-index-sync-update.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diffs (18 lines): diff -r 3af0ae411b37 -r 374e338bb3d6 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Sun Aug 04 20:33:05 2013 +0300 +++ b/src/lib-index/mail-index-sync-update.c Mon Aug 05 13:46:37 2013 +0300 @@ -473,11 +473,10 @@ } if (map->hdr.next_uid < orig_next_uid) { - mail_index_sync_set_corrupted(ctx, - "next_uid shrank ignored: %u -> %u", - orig_next_uid, map->hdr.next_uid); + /* next_uid update tried to shrink its value. this can happen + in some race conditions with e.g. with dsync, so just + silently ignore it. */ map->hdr.next_uid = orig_next_uid; - return -1; } /* the tail offset updates are intended for internal transaction From dovecot at dovecot.org Mon Aug 5 14:06:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 14:06:38 +0300 Subject: dovecot-2.2: lib-index: Replaced assert-crash with "index corrup... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d6290bd28253 changeset: 16645:d6290bd28253 user: Timo Sirainen date: Mon Aug 05 14:06:23 2013 +0300 description: lib-index: Replaced assert-crash with "index corrupted" error. diffstat: src/lib-index/mail-index-sync-update.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 374e338bb3d6 -r d6290bd28253 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Mon Aug 05 13:46:37 2013 +0300 +++ b/src/lib-index/mail-index-sync-update.c Mon Aug 05 14:06:23 2013 +0300 @@ -172,8 +172,10 @@ if (all) { mail_index_sync_header_update_counts_all(ctx, uid, old_flags, new_flags); + } else if (uid >= ctx->view->map->hdr.next_uid) { + mail_index_sync_set_corrupted(ctx, "uid %u >= next_uid %u", + uid, ctx->view->map->hdr.next_uid); } else { - i_assert(uid < ctx->view->map->hdr.next_uid); if (mail_index_header_update_counts(&ctx->view->map->hdr, old_flags, new_flags, &error) < 0) From dovecot at dovecot.org Mon Aug 5 16:59:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 16:59:34 +0300 Subject: dovecot-2.2: lib-dns, dns: Don't use IPv4-only error codes Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f69e08188622 changeset: 16646:f69e08188622 user: Timo Sirainen date: Mon Aug 05 16:58:01 2013 +0300 description: lib-dns, dns: Don't use IPv4-only error codes diffstat: src/dns/dns-client.c | 2 +- src/lib-dns/dns-lookup.c | 4 ++-- src/lib/net.h | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diffs (50 lines): diff -r d6290bd28253 -r f69e08188622 src/dns/dns-client.c --- a/src/dns/dns-client.c Mon Aug 05 14:06:23 2013 +0300 +++ b/src/dns/dns-client.c Mon Aug 05 16:58:01 2013 +0300 @@ -36,7 +36,7 @@ ret = net_gethostbyname(line + 3, &ips, &ips_count); if (ret == 0 && ips_count == 0) { /* shouldn't happen, but fix it anyway.. */ - ret = NO_ADDRESS; + ret = EAI_ADDRFAMILY; } if (ret != 0) { o_stream_nsend_str(client->output, diff -r d6290bd28253 -r f69e08188622 src/lib-dns/dns-lookup.c --- a/src/lib-dns/dns-lookup.c Mon Aug 05 14:06:23 2013 +0300 +++ b/src/lib-dns/dns-lookup.c Mon Aug 05 16:58:01 2013 +0300 @@ -146,7 +146,7 @@ int fd; memset(&result, 0, sizeof(result)); - result.ret = NO_RECOVERY; + result.ret = EAI_FAIL; fd = net_connect_unix(set->dns_client_socket_path); if (fd == -1) { @@ -174,7 +174,7 @@ lookup->to = timeout_add(set->timeout_msecs, dns_lookup_timeout, lookup); } - lookup->result.ret = NO_RECOVERY; + lookup->result.ret = EAI_FAIL; lookup->callback = callback; lookup->context = context; if (gettimeofday(&lookup->start_time, NULL) < 0) diff -r d6290bd28253 -r f69e08188622 src/lib/net.h --- a/src/lib/net.h Mon Aug 05 14:06:23 2013 +0300 +++ b/src/lib/net.h Mon Aug 05 16:58:01 2013 +0300 @@ -44,6 +44,13 @@ # define MAX_IP_LEN 20 #endif +#ifndef HAVE_IPV6 +# undef EAI_ADDRFAMILY +# define EAI_ADDRFAMILY NO_ADDRESS +# undef EAI_FAIL +# define EAI_FAIL NO_RECOVERY +#endif + #define IPADDR_IS_V4(ip) ((ip)->family == AF_INET) #define IPADDR_IS_V6(ip) ((ip)->family == AF_INET6) #define IPADDR_BITS(ip) (IPADDR_IS_V4(ip) ? 32 : 128) From dovecot at dovecot.org Mon Aug 5 16:59:34 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 16:59:34 +0300 Subject: dovecot-2.2: net_gethosterror(): Never return NULL. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/dc60e46f0cb5 changeset: 16647:dc60e46f0cb5 user: Timo Sirainen date: Mon Aug 05 16:59:21 2013 +0300 description: net_gethosterror(): Never return NULL. diffstat: src/lib/net.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diffs (16 lines): diff -r f69e08188622 -r dc60e46f0cb5 src/lib/net.c --- a/src/lib/net.c Mon Aug 05 16:58:01 2013 +0300 +++ b/src/lib/net.c Mon Aug 05 16:59:21 2013 +0300 @@ -967,10 +967,9 @@ return "A non-recoverable name server error occurred"; case TRY_AGAIN: return "A temporary error on an authoritative name server"; + default: + return t_strdup_printf("Unknown error %d", error); } - - /* unknown error */ - return NULL; #endif } From dovecot at dovecot.org Mon Aug 5 17:38:31 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 17:38:31 +0300 Subject: dovecot-2.2: lib-storage: Fixed listing INBOX's children with LA... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/692c1797a8c9 changeset: 16648:692c1797a8c9 user: Timo Sirainen date: Mon Aug 05 17:38:13 2013 +0300 description: lib-storage: Fixed listing INBOX's children with LAYOUT=fs and non-mbox format. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diffs (23 lines): diff -r dc60e46f0cb5 -r 692c1797a8c9 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Mon Aug 05 16:59:21 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Mon Aug 05 17:38:13 2013 +0300 @@ -671,9 +671,16 @@ /* no children */ } else if ((ctx->ctx.list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) == 0) { - /* skip its children also */ - ctx->dir = dir; - pool_unref(&subdir->pool); + if (strcmp(storage_name, "INBOX") == 0) { + /* INBOX and its children are in + different paths */ + ctx->inbox_has_children = TRUE; + } else { + /* naming conflict, skip its + children also */ + ctx->dir = dir; + pool_unref(&subdir->pool); + } } else if ((ctx->info.flags & MAILBOX_NOINFERIORS) == 0) { /* INBOX itself is \NoInferiors, but this INBOX is a directory, and we can make INBOX have From dovecot at dovecot.org Mon Aug 5 17:38:49 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 17:38:49 +0300 Subject: dovecot-2.1: lib-storage: Fixed listing INBOX's children with LA... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/589d2f485a6e changeset: 14992:589d2f485a6e user: Timo Sirainen date: Mon Aug 05 17:38:13 2013 +0300 description: lib-storage: Fixed listing INBOX's children with LAYOUT=fs and non-mbox format. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diffs (23 lines): diff -r b986ac5e1d98 -r 589d2f485a6e src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Tue Jul 30 13:26:40 2013 +0300 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Mon Aug 05 17:38:13 2013 +0300 @@ -680,9 +680,16 @@ /* no children */ } else if ((ctx->ctx.list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) == 0) { - /* skip its children also */ - ctx->dir = dir; - pool_unref(&subdir->pool); + if (strcmp(storage_name, "INBOX") == 0) { + /* INBOX and its children are in + different paths */ + ctx->inbox_has_children = TRUE; + } else { + /* naming conflict, skip its + children also */ + ctx->dir = dir; + pool_unref(&subdir->pool); + } } else if ((ctx->info.flags & MAILBOX_NOINFERIORS) == 0) { /* INBOX itself is \NoInferiors, but this INBOX is a directory, and we can make INBOX have From dovecot at dovecot.org Mon Aug 5 19:08:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 19:08:38 +0300 Subject: dovecot-2.2: man: Added doveadm-exec.1. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/d3e554bccf68 changeset: 16649:d3e554bccf68 user: Pascal Volk date: Mon Aug 05 15:52:52 2013 +0000 description: man: Added doveadm-exec.1. diffstat: .hgignore | 2 +- doc/man/Makefile.am | 4 +++- doc/man/doveadm-exec.1.in | 47 +++++++++++++++++++++++++++++++++++++++++++++++ doc/man/doveadm.1.in | 7 ++++++- doc/man/sed.sh | 5 ++++- 5 files changed, 61 insertions(+), 4 deletions(-) diffs (129 lines): diff -r 692c1797a8c9 -r d3e554bccf68 .hgignore --- a/.hgignore Mon Aug 05 17:38:13 2013 +0300 +++ b/.hgignore Mon Aug 05 15:52:52 2013 +0000 @@ -105,5 +105,5 @@ syntax: regexp src/.*/test-[^\.]*$ -doc/man/doveadm-(altmove|auth|deduplicate|director|dump|expunge|fetch|flags|import|instance|index|force-resync|help|kick|log|mailbox|mount|move|penalty|purge|pw|quota|search|user|who)\.1$ +doc/man/doveadm-(altmove|auth|deduplicate|director|dump|exec|expunge|fetch|flags|import|instance|index|force-resync|help|kick|log|mailbox|mount|move|penalty|purge|pw|quota|search|user|who)\.1$ doc/man/(doveadm|doveconf|dovecot-lda|dovecot|dsync)\.1$ diff -r 692c1797a8c9 -r d3e554bccf68 doc/man/Makefile.am --- a/doc/man/Makefile.am Mon Aug 05 17:38:13 2013 +0300 +++ b/doc/man/Makefile.am Mon Aug 05 15:52:52 2013 +0000 @@ -18,6 +18,7 @@ doveadm-deduplicate.1 \ doveadm-director.1 \ doveadm-dump.1 \ + doveadm-exec.1 \ doveadm-expunge.1 \ doveadm-fetch.1 \ doveadm-flags.1 \ @@ -58,6 +59,7 @@ doveadm-deduplicate.1.in \ doveadm-director.1.in \ doveadm-dump.1.in \ + doveadm-exec.1.in \ doveadm-expunge.1.in \ doveadm-fetch.1.in \ doveadm-flags.1.in \ @@ -89,4 +91,4 @@ .1.in.1: $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $< > $@ + $(pkglibexecdir) < $< > $@ diff -r 692c1797a8c9 -r d3e554bccf68 doc/man/doveadm-exec.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-exec.1.in Mon Aug 05 15:52:52 2013 +0000 @@ -0,0 +1,47 @@ +.\" Copyright (c) 2013 Dovecot authors, see the included COPYING file +.TH DOVEADM\-EXEC 1 "2013-08-05" "Dovecot v2.2" "Dovecot" +.SH NAME +doveadm\-exec \- easily execute commands from Dovecot\(aqs libexec_dir +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] " exec +.IR binary " [" "binary arguments" ] +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +This command allows administrators and local users to simply execute +commands from within +.IR libexec_dir . +So for example a logged in system user could start a pre\-authenticated +imap session, using the command: +.BR "doveadm exec imap" . +An administrator would use the command: +.B "doveadm exec imap \-u" +.IR username . +.\"------------------------------------------------------------------------ + at INCLUDE:global-options@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I binary +the name of an executable located in +.IR @pkglibexecdir@ . +.\"------------------------------------- +.TP +.I binary arguments +options and arguments, wich will be passed through to the +.IR binary . +.\"------------------------------------------------------------------------ +.SH EXAMPLE +This example demonstrates how to deliver a message from a file to a +user\(aqs mailbox. +.sp +.nf +.B doveadm exec dovecot\-lda \-d user at example.net \(rs +.B \-f admin at example.net < \(ti/stuff/welcome.msg +.fi +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1), +.BR dovecot\-lda (1) \ No newline at end of file diff -r 692c1797a8c9 -r d3e554bccf68 doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Mon Aug 05 17:38:13 2013 +0300 +++ b/doc/man/doveadm.1.in Mon Aug 05 15:52:52 2013 +0000 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file -.TH DOVEADM 1 "2013-08-02" "Dovecot v2.2" "Dovecot" +.TH DOVEADM 1 "2013-08-05" "Dovecot v2.2" "Dovecot" .SH NAME doveadm \- Dovecot\(aqs administration utility .\"------------------------------------------------------------------------ @@ -44,6 +44,11 @@ Manage Dovecot directors (if used by proxy servers). .\"------------------------------------- .TP +.B doveadm exec +.BR doveadm\-exec (1), +Easily execute commands from Dovecot\(aqs libexec_dir. +.\"------------------------------------- +.TP .B doveadm instance .BR doveadm\-instance (1), Manage the list of running Dovecot instances. diff -r 692c1797a8c9 -r d3e554bccf68 doc/man/sed.sh --- a/doc/man/sed.sh Mon Aug 05 17:38:13 2013 +0300 +++ b/doc/man/sed.sh Mon Aug 05 15:52:52 2013 +0000 @@ -3,6 +3,7 @@ SRCDIR="${1:-`pwd`}" RUNDIR="${2:-/usr/local/var/run/dovecot}" PKGSYSCONFDIR="${3:-/usr/local/etc/dovecot}" +PKGLIBEXECDIR="${4:-/usr/local/libexec/dovecot}" sed -e "/^@INCLUDE:global-options@$/{ r ${SRCDIR}/global-options.inc @@ -27,5 +28,7 @@ -e "/^@INCLUDE:reporting-bugs@$/{ r ${SRCDIR}/reporting-bugs.inc d - }" | sed -e "s|@pkgsysconfdir@|${PKGSYSCONFDIR}|" -e "s|@rundir@|${RUNDIR}|" + }" | sed -e "s|@pkgsysconfdir@|${PKGSYSCONFDIR}|" \ + -e "s|@rundir@|${RUNDIR}|" \ + -e "s|@pkglibexecdir@|${PKGLIBEXECDIR}|" From dovecot at dovecot.org Mon Aug 5 20:12:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 20:12:22 +0300 Subject: dovecot-2.2: lib-auth: Another crashfix to auth_master_user_list... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1adb8998c2a6 changeset: 16650:1adb8998c2a6 user: Timo Sirainen date: Mon Aug 05 20:12:10 2013 +0300 description: lib-auth: Another crashfix to auth_master_user_list_*() diffstat: src/lib-auth/auth-master.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r d3e554bccf68 -r 1adb8998c2a6 src/lib-auth/auth-master.c --- a/src/lib-auth/auth-master.c Mon Aug 05 15:52:52 2013 +0000 +++ b/src/lib-auth/auth-master.c Mon Aug 05 20:12:10 2013 +0300 @@ -687,7 +687,7 @@ { const char *line; - if (ctx->failed) + if (ctx->conn->input == NULL) return NULL; /* try to read already buffered input */ From dovecot at dovecot.org Mon Aug 5 20:27:17 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 20:27:17 +0300 Subject: dovecot-2.2: mbox: Don't use file_set_size() to grow mbox file s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/42b2736f146b changeset: 16651:42b2736f146b user: Timo Sirainen date: Mon Aug 05 20:27:09 2013 +0300 description: mbox: Don't use file_set_size() to grow mbox file size. posix_fallocate() apparently grows file size in 4kB blocks in GFS2 causing extra NULs to be written. The mbox file rarely needs to grow so much that there's any point in using any optimizations for it. Besides, this was the last place where file_set_size() was used. If no further use can be found for it, it could be removed entirely. diffstat: src/lib-storage/index/mbox/mbox-sync.c | 37 +++++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 9 deletions(-) diffs (55 lines): diff -r 1adb8998c2a6 -r 42b2736f146b src/lib-storage/index/mbox/mbox-sync.c --- a/src/lib-storage/index/mbox/mbox-sync.c Mon Aug 05 20:12:10 2013 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Mon Aug 05 20:27:09 2013 +0300 @@ -1254,6 +1254,32 @@ return 0; } +static int mbox_append_zero(struct mbox_sync_context *sync_ctx, + uoff_t orig_file_size, uoff_t count) +{ + char block[IO_BLOCK_SIZE]; + uoff_t offset = orig_file_size; + ssize_t ret = 0; + + memset(block, 0, I_MIN(sizeof(block), count)); + while (count > 0) { + ret = pwrite(sync_ctx->write_fd, block, + I_MIN(sizeof(block), count), offset); + if (ret < 0) + break; + offset += ret; + count -= ret; + } + + if (ret < 0) { + mbox_set_syscall_error(sync_ctx->mbox, "pwrite()"); + if (ftruncate(sync_ctx->write_fd, orig_file_size) < 0) + mbox_set_syscall_error(sync_ctx->mbox, "ftruncate()"); + return -1; + } + return 0; +} + static int mbox_sync_handle_eof_updates(struct mbox_sync_context *sync_ctx, struct mbox_sync_mail_context *mail_ctx) { @@ -1303,16 +1329,9 @@ i_assert(sync_ctx->space_diff < 0); - if (file_set_size(sync_ctx->write_fd, - file_size + -sync_ctx->space_diff) < 0) { - mbox_set_syscall_error(sync_ctx->mbox, - "file_set_size()"); - if (ftruncate(sync_ctx->write_fd, file_size) < 0) { - mbox_set_syscall_error(sync_ctx->mbox, - "ftruncate()"); - } + if (mbox_append_zero(sync_ctx, file_size, + -sync_ctx->space_diff) < 0) return -1; - } mbox_sync_file_updated(sync_ctx, FALSE); if (mbox_sync_rewrite(sync_ctx, mail_ctx, file_size, From dovecot at dovecot.org Mon Aug 5 20:33:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 20:33:18 +0300 Subject: dovecot-2.2: dns: Use EAI_NONAME, not EAI_ADDRFAMILY to indicate... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/556475a5c1be changeset: 16652:556475a5c1be user: Timo Sirainen date: Mon Aug 05 20:33:01 2013 +0300 description: dns: Use EAI_NONAME, not EAI_ADDRFAMILY to indicate "no addresses". diffstat: src/dns/dns-client.c | 2 +- src/lib/net.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diffs (26 lines): diff -r 42b2736f146b -r 556475a5c1be src/dns/dns-client.c --- a/src/dns/dns-client.c Mon Aug 05 20:27:09 2013 +0300 +++ b/src/dns/dns-client.c Mon Aug 05 20:33:01 2013 +0300 @@ -36,7 +36,7 @@ ret = net_gethostbyname(line + 3, &ips, &ips_count); if (ret == 0 && ips_count == 0) { /* shouldn't happen, but fix it anyway.. */ - ret = EAI_ADDRFAMILY; + ret = EAI_NONAME; } if (ret != 0) { o_stream_nsend_str(client->output, diff -r 42b2736f146b -r 556475a5c1be src/lib/net.h --- a/src/lib/net.h Mon Aug 05 20:27:09 2013 +0300 +++ b/src/lib/net.h Mon Aug 05 20:33:01 2013 +0300 @@ -45,8 +45,8 @@ #endif #ifndef HAVE_IPV6 -# undef EAI_ADDRFAMILY -# define EAI_ADDRFAMILY NO_ADDRESS +# undef EAI_NONAME +# define EAI_NONAME NO_ADDRESS # undef EAI_FAIL # define EAI_FAIL NO_RECOVERY #endif From dovecot at dovecot.org Mon Aug 5 20:45:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 20:45:47 +0300 Subject: dovecot-2.2: maildir: mailbox_create() was returning 1 instead o... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a3f645bc5195 changeset: 16653:a3f645bc5195 user: Timo Sirainen date: Mon Aug 05 20:45:42 2013 +0300 description: maildir: mailbox_create() was returning 1 instead of 0 on success. This broke acl plugin's check to copy the ACLs to the newly created mailbox. diffstat: src/lib-storage/index/maildir/maildir-storage.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 556475a5c1be -r a3f645bc5195 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Mon Aug 05 20:33:01 2013 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Mon Aug 05 20:45:42 2013 +0300 @@ -509,6 +509,7 @@ if ((ret = index_storage_mailbox_create(box, directory)) <= 0) return ret; + ret = 0; /* the maildir is created now. finish the creation as best as we can */ if (create_maildir_subdirs(box, FALSE) < 0) ret = -1; From dovecot at dovecot.org Mon Aug 5 20:53:05 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 20:53:05 +0300 Subject: dovecot-2.1: lib-dict: Error handling fixes to asynchronous tran... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c7832e75d2a8 changeset: 14993:c7832e75d2a8 user: Timo Sirainen date: Wed Jun 12 22:03:07 2013 +0300 description: lib-dict: Error handling fixes to asynchronous transactions. diffstat: src/lib-dict/dict-client.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diffs (55 lines): diff -r 589d2f485a6e -r c7832e75d2a8 src/lib-dict/dict-client.c --- a/src/lib-dict/dict-client.c Mon Aug 05 17:38:13 2013 +0300 +++ b/src/lib-dict/dict-client.c Wed Jun 12 22:03:07 2013 +0300 @@ -73,6 +73,7 @@ unsigned int failed:1; unsigned int sent_begin:1; unsigned int async:1; + unsigned int committed:1; }; static int client_dict_connect(struct client_dict *dict); @@ -262,6 +263,9 @@ i_error("dict-client: Unknown transaction id %u", id); return; } + ctx->failed = TRUE; + if (!ctx->committed) + return; /* the callback may call the dict code again, so remove this transaction before calling it */ @@ -402,8 +406,6 @@ { const char *query; - i_assert(dict->fd == -1); - if (dict->last_failed_connect == ioloop_time) { /* Try again later */ return -1; @@ -427,8 +429,6 @@ dict->input = i_stream_create_fd(dict->fd, (size_t)-1, FALSE); dict->output = o_stream_create_fd(dict->fd, 4096, FALSE); - dict->transaction_id_counter = 0; - dict->async_commits = 0; query = t_strdup_printf("%c%u\t%u\t%d\t%s\t%s\n", DICT_PROTOCOL_CMD_HELLO, @@ -516,6 +516,7 @@ struct client_dict *dict = (struct client_dict *)_dict; client_dict_disconnect(dict); + i_assert(dict->transactions == NULL); pool_unref(&dict->pool); } @@ -706,6 +707,7 @@ struct client_dict *dict = (struct client_dict *)_ctx->dict; int ret = ctx->failed ? -1 : 1; + ctx->committed = TRUE; if (ctx->sent_begin && !ctx->failed) T_BEGIN { const char *query, *line; From dovecot at dovecot.org Mon Aug 5 22:13:43 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 22:13:43 +0300 Subject: dovecot-2.2: lib-auth: auth_master_user_list_*() shouldn't creat... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f7dc5389ab0a changeset: 16654:f7dc5389ab0a user: Timo Sirainen date: Mon Aug 05 21:47:11 2013 +0300 description: lib-auth: auth_master_user_list_*() shouldn't create ioloop if it already exists. diffstat: src/lib-auth/auth-master.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r a3f645bc5195 -r f7dc5389ab0a src/lib-auth/auth-master.c --- a/src/lib-auth/auth-master.c Mon Aug 05 20:45:42 2013 +0300 +++ b/src/lib-auth/auth-master.c Mon Aug 05 21:47:11 2013 +0300 @@ -333,6 +333,9 @@ static void auth_master_set_io(struct auth_master_connection *conn) { + if (conn->ioloop != NULL) + return; + if (conn->to != NULL) timeout_remove(&conn->to); From dovecot at dovecot.org Mon Aug 5 22:13:43 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 22:13:43 +0300 Subject: dovecot-2.2: doveadm: Minor memory leak fixes at deinit. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/647ef2264398 changeset: 16655:647ef2264398 user: Timo Sirainen date: Mon Aug 05 22:13:28 2013 +0300 description: doveadm: Minor memory leak fixes at deinit. diffstat: src/doveadm/doveadm-mail-mailbox-status.c | 9 +++++++++ src/doveadm/doveadm-mail-mailbox.c | 8 ++++++++ 2 files changed, 17 insertions(+), 0 deletions(-) diffs (57 lines): diff -r f7dc5389ab0a -r 647ef2264398 src/doveadm/doveadm-mail-mailbox-status.c --- a/src/doveadm/doveadm-mail-mailbox-status.c Mon Aug 05 21:47:11 2013 +0300 +++ b/src/doveadm/doveadm-mail-mailbox-status.c Mon Aug 05 22:13:28 2013 +0300 @@ -4,6 +4,7 @@ #include "str.h" #include "mail-namespace.h" #include "mail-storage.h" +#include "mail-search.h" #include "doveadm-print.h" #include "doveadm-mail.h" #include "doveadm-mailbox-list-iter.h" @@ -207,6 +208,13 @@ doveadm_print_header_simple("guid"); } +static void cmd_mailbox_status_deinit(struct doveadm_mail_cmd_context *_ctx) +{ + struct status_cmd_context *ctx = (struct status_cmd_context *)_ctx; + + mail_search_args_unref(&ctx->search_args); +} + static bool cmd_mailbox_status_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) { @@ -230,6 +238,7 @@ ctx->ctx.getopt_args = "t"; ctx->ctx.v.parse_arg = cmd_mailbox_status_parse_arg; ctx->ctx.v.init = cmd_mailbox_status_init; + ctx->ctx.v.deinit = cmd_mailbox_status_deinit; ctx->ctx.v.run = cmd_mailbox_status_run; doveadm_print_init(DOVEADM_PRINT_TYPE_FLOW); return &ctx->ctx; diff -r f7dc5389ab0a -r 647ef2264398 src/doveadm/doveadm-mail-mailbox.c --- a/src/doveadm/doveadm-mail-mailbox.c Mon Aug 05 21:47:11 2013 +0300 +++ b/src/doveadm/doveadm-mail-mailbox.c Mon Aug 05 22:13:28 2013 +0300 @@ -172,12 +172,20 @@ ctx->search_args = doveadm_mail_mailbox_search_args_build(args); } +static void cmd_mailbox_list_deinit(struct doveadm_mail_cmd_context *_ctx) +{ + struct list_cmd_context *ctx = (struct list_cmd_context *)_ctx; + + mail_search_args_unref(&ctx->search_args); +} + static struct doveadm_mail_cmd_context *cmd_mailbox_list_alloc(void) { struct list_cmd_context *ctx; ctx = doveadm_mailbox_cmd_alloc(struct list_cmd_context); ctx->ctx.ctx.v.init = cmd_mailbox_list_init; + ctx->ctx.ctx.v.deinit = cmd_mailbox_list_deinit; ctx->ctx.ctx.v.run = cmd_mailbox_list_run; ctx->ctx.ctx.v.parse_arg = cmd_mailbox_list_parse_arg; ctx->ctx.ctx.getopt_args = "78s"; From dovecot at dovecot.org Mon Aug 5 22:16:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 22:16:15 +0300 Subject: dovecot-2.2: lib-auth: Previous changes didn't set the current i... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/19719ea2cddb changeset: 16656:19719ea2cddb user: Timo Sirainen date: Mon Aug 05 22:15:08 2013 +0300 description: lib-auth: Previous changes didn't set the current ioloop correctly, causing problems. diffstat: src/lib-auth/auth-master.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diffs (39 lines): diff -r 647ef2264398 -r 19719ea2cddb src/lib-auth/auth-master.c --- a/src/lib-auth/auth-master.c Mon Aug 05 22:13:28 2013 +0300 +++ b/src/lib-auth/auth-master.c Mon Aug 05 22:15:08 2013 +0300 @@ -287,7 +287,9 @@ while ((line = i_stream_next_line(conn->input)) != NULL) { T_BEGIN { + io_loop_set_current(conn->prev_ioloop); ret = auth_handle_line(conn, line); + io_loop_set_current(conn->ioloop); } T_END; if (!ret) return; @@ -369,6 +371,7 @@ if (conn->prev_ioloop == NULL) auth_connection_close(conn); else { + i_assert(conn->to == NULL); conn->to = timeout_add(1000*AUTH_MASTER_IDLE_SECS, auth_idle_timeout, conn); } @@ -682,6 +685,7 @@ if (auth_master_run_cmd_pre(conn, str_c(str)) < 0) ctx->failed = TRUE; + io_loop_set_current(conn->prev_ioloop); conn->prefix = DEFAULT_USERDB_LOOKUP_PREFIX; return ctx; } @@ -701,7 +705,9 @@ } T_END; } else { /* wait for more data */ + io_loop_set_current(ctx->conn->ioloop); io_loop_run(ctx->conn->ioloop); + io_loop_set_current(ctx->conn->prev_ioloop); } if (ctx->finished || ctx->failed) From dovecot at dovecot.org Mon Aug 5 22:16:15 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 22:16:15 +0300 Subject: dovecot-2.2: lib-storage: Use a separate auth-userdb connection ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c41eab7d5d05 changeset: 16657:c41eab7d5d05 user: Timo Sirainen date: Mon Aug 05 22:16:02 2013 +0300 description: lib-storage: Use a separate auth-userdb connection for iterating through users. This is required because the auth-userdb connection is also wanted in the middle of the iteration to do USER lookups. diffstat: src/lib-storage/mail-storage-service.c | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diffs (68 lines): diff -r 19719ea2cddb -r c41eab7d5d05 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Mon Aug 05 22:15:08 2013 +0300 +++ b/src/lib-storage/mail-storage-service.c Mon Aug 05 22:16:02 2013 +0300 @@ -52,7 +52,7 @@ struct master_service *service; const char *default_log_prefix; - struct auth_master_connection *conn; + struct auth_master_connection *conn, *iter_conn; struct auth_master_user_list_ctx *auth_list; const struct setting_parser_info **set_roots; enum mail_storage_service_flags flags; @@ -1277,13 +1277,33 @@ pool_unref(&temp_pool); } +static int +mail_storage_service_all_iter_deinit(struct mail_storage_service_ctx *ctx) +{ + int ret = 0; + + if (ctx->auth_list != NULL) { + ret = auth_master_user_list_deinit(&ctx->auth_list); + auth_master_deinit(&ctx->iter_conn); + } + return ret; +} + void mail_storage_service_all_init(struct mail_storage_service_ctx *ctx) { - if (ctx->auth_list != NULL) - (void)auth_master_user_list_deinit(&ctx->auth_list); + enum auth_master_flags flags = 0; + + (void)mail_storage_service_all_iter_deinit(ctx); mail_storage_service_init_settings(ctx, NULL); - ctx->auth_list = auth_master_user_list_init(ctx->conn, "", NULL); + /* create a new connection, because the iteration might take a while + and we might want to do USER lookups during it, which don't mix + well in the same connection. */ + if (ctx->debug) + flags |= AUTH_MASTER_FLAG_DEBUG; + ctx->iter_conn = auth_master_init(auth_master_get_socket_path(ctx->conn), + flags); + ctx->auth_list = auth_master_user_list_init(ctx->iter_conn, "", NULL); } int mail_storage_service_all_next(struct mail_storage_service_ctx *ctx, @@ -1294,7 +1314,7 @@ *username_r = auth_master_user_list_next(ctx->auth_list); if (*username_r != NULL) return 1; - return auth_master_user_list_deinit(&ctx->auth_list); + return mail_storage_service_all_iter_deinit(ctx); } void mail_storage_service_deinit(struct mail_storage_service_ctx **_ctx) @@ -1302,8 +1322,7 @@ struct mail_storage_service_ctx *ctx = *_ctx; *_ctx = NULL; - if (ctx->auth_list != NULL) - (void)auth_master_user_list_deinit(&ctx->auth_list); + (void)mail_storage_service_all_iter_deinit(ctx); if (ctx->conn != NULL) { if (mail_user_auth_master_conn == ctx->conn) mail_user_auth_master_conn = NULL; From dovecot at dovecot.org Mon Aug 5 22:21:42 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 22:21:42 +0300 Subject: dovecot-2.2: Make static analyzer happier. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c3901ac774cb changeset: 16658:c3901ac774cb user: Timo Sirainen date: Mon Aug 05 22:21:29 2013 +0300 description: Make static analyzer happier. diffstat: src/director/user-directory.c | 3 ++- src/lib-http/test-http-response-parser.c | 1 + 2 files changed, 3 insertions(+), 1 deletions(-) diffs (24 lines): diff -r c41eab7d5d05 -r c3901ac774cb src/director/user-directory.c --- a/src/director/user-directory.c Mon Aug 05 22:16:02 2013 +0300 +++ b/src/director/user-directory.c Mon Aug 05 22:21:29 2013 +0300 @@ -243,7 +243,8 @@ dir->head = dir->tail = NULL; array_foreach(&users, userp) DLLIST2_APPEND(&dir->head, &dir->tail, *userp); - i_assert(dir->head->timestamp <= dir->tail->timestamp); + i_assert(dir->head != NULL && + dir->head->timestamp <= dir->tail->timestamp); array_free(&users); } diff -r c41eab7d5d05 -r c3901ac774cb src/lib-http/test-http-response-parser.c --- a/src/lib-http/test-http-response-parser.c Mon Aug 05 22:16:02 2013 +0300 +++ b/src/lib-http/test-http-response-parser.c Mon Aug 05 22:21:29 2013 +0300 @@ -136,6 +136,7 @@ if (ret == 0) { /* verify last response only */ + i_assert(response != NULL); test_out(t_strdup_printf("response->status = %d",test->status), response->status == test->status); if (payload == NULL || test->payload == NULL) { From dovecot at dovecot.org Mon Aug 5 23:03:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 23:03:18 +0300 Subject: dovecot-2.2: Added tag 2.2.5 for changeset 71f0696749ab Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/20e7fab87ad8 changeset: 16660:20e7fab87ad8 user: Timo Sirainen date: Mon Aug 05 22:22:47 2013 +0300 description: Added tag 2.2.5 for changeset 71f0696749ab diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 71f0696749ab -r 20e7fab87ad8 .hgtags --- a/.hgtags Mon Aug 05 22:22:47 2013 +0300 +++ b/.hgtags Mon Aug 05 22:22:47 2013 +0300 @@ -108,3 +108,4 @@ 7aa929edd551e3d3bd9405643341129c7a805554 2.2.2 5d9f52c9a2871245097c725b9a4163a8789512fd 2.2.3 4b3c9c3e4fb8499ca7133a4d229e5eef349995e0 2.2.4 +71f0696749ab347119278d7f68a01f81ed584c53 2.2.5 From dovecot at dovecot.org Mon Aug 5 23:03:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 23:03:18 +0300 Subject: dovecot-2.2: Released v2.2.5. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/71f0696749ab changeset: 16659:71f0696749ab user: Timo Sirainen date: Mon Aug 05 22:22:47 2013 +0300 description: Released v2.2.5. diffstat: NEWS | 15 +++++++++++++++ configure.ac | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diffs (36 lines): diff -r c3901ac774cb -r 71f0696749ab NEWS --- a/NEWS Mon Aug 05 22:21:29 2013 +0300 +++ b/NEWS Mon Aug 05 22:22:47 2013 +0300 @@ -1,3 +1,18 @@ +v2.2.5 2013-08-05 Timo Sirainen + + + SSL: Added support for ECDH/ECDHE cipher suites (by David Hicks) + + Added some missing man pages (by Pascal Volk) + + quota-status: Added quota_status_toolarge setting (by Ulrich Zehl) + - director: Users near expiration could have been redirected to + different servers at the same time. + - pop3: Avoid assert-crash if client disconnects during LIST. + - mdbox: Corrupted index header still wasn't automatically fixed. + - dsync: Various fixes to work better with imapc and pop3c storages. + - ldap: sasl_bind=yes caused crashes, because Dovecot's lib-sasl + symbols conflicted with Cyrus SASL library. + - imap: Various error handling fixes to CATENATE. (Found using + Apple's stress test script.) + v2.2.4 2013-06-25 Timo Sirainen + doveadm: Added "flags" command to modify message flags. diff -r c3901ac774cb -r 71f0696749ab configure.ac --- a/configure.ac Mon Aug 05 22:21:29 2013 +0300 +++ b/configure.ac Mon Aug 05 22:22:47 2013 +0300 @@ -2,8 +2,8 @@ # Be sure to update ABI version also if anything changes that might require # recompiling plugins. Most importantly that means if any structs are changed. -AC_INIT([Dovecot],[2.2.4],[dovecot at dovecot.org]) -AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv3($PACKAGE_VERSION)", [Dovecot ABI version]) +AC_INIT([Dovecot],[2.2.5],[dovecot at dovecot.org]) +AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv5($PACKAGE_VERSION)", [Dovecot ABI version]) AC_CONFIG_SRCDIR([src]) From dovecot at dovecot.org Mon Aug 5 23:03:18 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 05 Aug 2013 23:03:18 +0300 Subject: dovecot-2.2: Added signature for changeset 71f0696749ab Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/b846a046d978 changeset: 16661:b846a046d978 user: Timo Sirainen date: Mon Aug 05 22:22:51 2013 +0300 description: Added signature for changeset 71f0696749ab diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 20e7fab87ad8 -r b846a046d978 .hgsigs --- a/.hgsigs Mon Aug 05 22:22:47 2013 +0300 +++ b/.hgsigs Mon Aug 05 22:22:51 2013 +0300 @@ -71,3 +71,4 @@ 7aa929edd551e3d3bd9405643341129c7a805554 0 iEYEABECAAYFAlGZX2MACgkQyUhSUUBVisn2LACfWc8QwBvF31mYx3iv9ePvShCRcH4AnjZkbQEmcvaFQrfCy5YIIrstNBzx 5d9f52c9a2871245097c725b9a4163a8789512fd 0 iEYEABECAAYFAlG+LqYACgkQyUhSUUBVisn45wCgiEnDSrMoa5hZHRv+0eovGQJJ4g8An1Q8kms24rovLF/PGaani8Ap6VXR 4b3c9c3e4fb8499ca7133a4d229e5eef349995e0 0 iEYEABECAAYFAlHI1NMACgkQyUhSUUBVismCOQCbB/qdjOfUBvm0AUGBudvg2TaKbJ0AnRmr8JEV1QnowwA0g0vGF8Hkm6ib +71f0696749ab347119278d7f68a01f81ed584c53 0 iEYEABECAAYFAlH/+4cACgkQyUhSUUBVislEUwCfc7GeL9I5US5yJltYpWe8ZU7MAIkAnRlUGvhpFMBnehwSlUDRsssRCJ+a From dovecot at dovecot.org Tue Aug 6 12:48:28 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 12:48:28 +0300 Subject: dovecot-2.2: replicator: Fixed assert-crash if dsync server disc... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/820f4dbaebdd changeset: 16662:820f4dbaebdd user: Timo Sirainen date: Tue Aug 06 12:48:15 2013 +0300 description: replicator: Fixed assert-crash if dsync server disconnected. diffstat: src/replication/replicator/dsync-client.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diffs (24 lines): diff -r b846a046d978 -r 820f4dbaebdd src/replication/replicator/dsync-client.c --- a/src/replication/replicator/dsync-client.c Mon Aug 05 22:22:51 2013 +0300 +++ b/src/replication/replicator/dsync-client.c Tue Aug 06 12:48:15 2013 +0300 @@ -68,6 +68,10 @@ static void dsync_close(struct dsync_client *client) { + client->cmd_sent = FALSE; + client->handshaked = FALSE; + i_free_and_null(client->state); + if (client->fd == -1) return; @@ -77,9 +81,6 @@ if (close(client->fd) < 0) i_error("close(dsync) failed: %m"); client->fd = -1; - i_free_and_null(client->state); - client->cmd_sent = FALSE; - client->handshaked = FALSE; } static void dsync_disconnect(struct dsync_client *client) From dovecot at dovecot.org Tue Aug 6 14:26:11 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 14:26:11 +0300 Subject: dovecot-2.2: dsync: Name remote connections better. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ef5518ee5ab2 changeset: 16663:ef5518ee5ab2 user: Timo Sirainen date: Tue Aug 06 14:25:49 2013 +0300 description: dsync: Name remote connections better. diffstat: src/doveadm/client-connection.c | 3 +++ src/doveadm/dsync/doveadm-dsync.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diffs (49 lines): diff -r 820f4dbaebdd -r ef5518ee5ab2 src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Tue Aug 06 12:48:15 2013 +0300 +++ b/src/doveadm/client-connection.c Tue Aug 06 14:25:49 2013 +0300 @@ -411,6 +411,9 @@ (void)net_getsockname(fd, &conn->local_ip, &conn->local_port); (void)net_getpeername(fd, &conn->remote_ip, &conn->remote_port); + i_stream_set_name(conn->input, net_ip2addr(&conn->remote_ip)); + o_stream_set_name(conn->output, net_ip2addr(&conn->remote_ip)); + if (client_connection_read_settings(conn) < 0) { client_connection_destroy(&conn); return NULL; diff -r 820f4dbaebdd -r ef5518ee5ab2 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Tue Aug 06 12:48:15 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Tue Aug 06 14:25:49 2013 +0300 @@ -958,6 +958,7 @@ struct dsync_brain *brain; string_t *temp_prefix, *state_str = NULL; enum dsync_brain_sync_type sync_type; + const char *name; if (_ctx->conn != NULL) { /* doveadm-server connection. start with a success reply. @@ -966,15 +967,21 @@ ctx->input = _ctx->conn->input; ctx->output = _ctx->conn->output; o_stream_nsend(ctx->output, "\n+\n", 3); + i_set_failure_prefix("dsync-server(%s): ", user->username); + name = i_stream_get_name(ctx->input); + } else { + /* the log messages go via stderr to the remote dsync, + so the names are reversed */ + i_set_failure_prefix("dsync-remote(%s): ", user->username); + name = "local"; } + doveadm_user_init_dsync(user); - i_set_failure_prefix("dsync-remote(%s): ", user->username); - temp_prefix = t_str_new(64); mail_user_set_get_temp_prefix(temp_prefix, user->set); - ibc = cmd_dsync_icb_stream_init(ctx, "local", str_c(temp_prefix)); + ibc = cmd_dsync_icb_stream_init(ctx, name, str_c(temp_prefix)); brain = dsync_brain_slave_init(user, ibc, FALSE); io_loop_run(current_ioloop); From dovecot at dovecot.org Tue Aug 6 14:36:31 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 14:36:31 +0300 Subject: dovecot-2.2: master: Added --hostdomain setting to show the curr... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5a3821097f3c changeset: 16664:5a3821097f3c user: Timo Sirainen date: Tue Aug 06 14:36:25 2013 +0300 description: master: Added --hostdomain setting to show the current hostdomain. diffstat: src/master/main.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r ef5518ee5ab2 -r 5a3821097f3c src/master/main.c --- a/src/master/main.c Tue Aug 06 14:25:49 2013 +0300 +++ b/src/master/main.c Tue Aug 06 14:36:25 2013 +0300 @@ -823,6 +823,9 @@ } else if (strcmp(argv[optind], "version") == 0) { printf("%s\n", DOVECOT_VERSION_FULL); return 0; + } else if (strcmp(argv[optind], "hostdomain") == 0) { + printf("%s\n", my_hostdomain()); + return 0; } else if (strcmp(argv[optind], "build-options") == 0) { print_build_options(); return 0; From dovecot at dovecot.org Tue Aug 6 14:46:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 14:46:50 +0300 Subject: dovecot-2.2: dsync: After reading remote hostname, use it for th... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7057d4ad8891 changeset: 16665:7057d4ad8891 user: Timo Sirainen date: Tue Aug 06 14:46:36 2013 +0300 description: dsync: After reading remote hostname, use it for the log messages instead of IP. diffstat: src/doveadm/dsync/dsync-ibc-stream.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 5a3821097f3c -r 7057d4ad8891 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Tue Aug 06 14:36:25 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Tue Aug 06 14:46:36 2013 +0300 @@ -677,6 +677,11 @@ value = dsync_deserializer_decode_get(decoder, "hostname"); set->hostname = p_strdup(pool, value); + /* now that we know the remote's hostname, use it for the + stream's name */ + i_free(ibc->name); + ibc->name = i_strdup(set->hostname); + if (dsync_deserializer_decode_try(decoder, "sync_ns_prefix", &value)) set->sync_ns_prefix = p_strdup(pool, value); if (dsync_deserializer_decode_try(decoder, "sync_box", &value)) From dovecot at dovecot.org Tue Aug 6 14:54:38 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 14:54:38 +0300 Subject: dovecot-2.2: net_ip2addr() changed to return "" instead of NULL ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/58be84a381e5 changeset: 16666:58be84a381e5 user: Timo Sirainen date: Tue Aug 06 14:53:23 2013 +0300 description: net_ip2addr() changed to return "" instead of NULL on failure. Pretty much everything in the code assumed that it would never fail, which it normally doesn't except if the ip_addr was created for UNIX sockets. diffstat: src/auth/auth-request.c | 2 +- src/auth/passdb-pam.c | 2 +- src/auth/passdb-vpopmail.c | 2 +- src/lib/net.c | 4 ++-- src/lib/net.h | 2 +- src/lib/uri-util.c | 2 -- src/lmtp/client.c | 2 +- src/login-common/main.c | 11 +++++++---- 8 files changed, 14 insertions(+), 13 deletions(-) diffs (114 lines): diff -r 7057d4ad8891 -r 58be84a381e5 src/auth/auth-request.c --- a/src/auth/auth-request.c Tue Aug 06 14:46:36 2013 +0300 +++ b/src/auth/auth-request.c Tue Aug 06 14:53:23 2013 +0300 @@ -2021,7 +2021,7 @@ } ip = net_ip2addr(&auth_request->remote_ip); - if (ip != NULL) { + if (ip[0] != '\0') { str_append_c(str, ','); str_append(str, ip); } diff -r 7057d4ad8891 -r 58be84a381e5 src/auth/passdb-pam.c --- a/src/auth/passdb-pam.c Tue Aug 06 14:46:36 2013 +0300 +++ b/src/auth/passdb-pam.c Tue Aug 06 14:53:23 2013 +0300 @@ -238,7 +238,7 @@ /* These shouldn't fail, and we don't really care if they do. */ host = net_ip2addr(&request->remote_ip); - if (host != NULL) + if (host[0] != '\0') (void)pam_set_item(pamh, PAM_RHOST, host); (void)pam_set_item(pamh, PAM_RUSER, request->user); /* TTY is needed by eg. pam_access module */ diff -r 7057d4ad8891 -r 58be84a381e5 src/auth/passdb-vpopmail.c --- a/src/auth/passdb-vpopmail.c Tue Aug 06 14:46:36 2013 +0300 +++ b/src/auth/passdb-vpopmail.c Tue Aug 06 14:53:23 2013 +0300 @@ -153,7 +153,7 @@ strcasecmp(request->service, "IMAP") == 0) { const char *host = net_ip2addr(&request->remote_ip); /* vpopmail 5.4 does not understand IPv6 */ - if (host != NULL && IPADDR_IS_V4(&request->remote_ip)) { + if (host[0] != '\0' && IPADDR_IS_V4(&request->remote_ip)) { /* use putenv() directly rather than env_put() which would leak memory every time we got here. use a static buffer for putenv() as SUSv2 requirements diff -r 7057d4ad8891 -r 58be84a381e5 src/lib/net.c --- a/src/lib/net.c Tue Aug 06 14:46:36 2013 +0300 +++ b/src/lib/net.c Tue Aug 06 14:53:23 2013 +0300 @@ -870,14 +870,14 @@ addr[MAX_IP_LEN] = '\0'; if (inet_ntop(ip->family, &ip->u.ip6, addr, MAX_IP_LEN) == NULL) - return NULL; + return ""; return t_strdup(addr); #else unsigned long ip4; if (ip->family != AF_INET) - return NULL; + return ""; ip4 = ntohl(ip->u.ip4.s_addr); return t_strdup_printf("%lu.%lu.%lu.%lu", diff -r 7057d4ad8891 -r 58be84a381e5 src/lib/net.h --- a/src/lib/net.h Tue Aug 06 14:46:36 2013 +0300 +++ b/src/lib/net.h Tue Aug 06 14:53:23 2013 +0300 @@ -133,7 +133,7 @@ unavailable. */ int net_getunixcred(int fd, struct net_unix_cred *cred_r); -/* Returns ip_addr as string, or NULL if ip is invalid. */ +/* Returns ip_addr as string, or "" if ip isn't valid IPv4 or IPv6 address. */ const char *net_ip2addr(const struct ip_addr *ip); /* char* -> struct ip_addr translation. */ int net_addr2ip(const char *addr, struct ip_addr *ip); diff -r 7057d4ad8891 -r 58be84a381e5 src/lib/uri-util.c --- a/src/lib/uri-util.c Tue Aug 06 14:46:36 2013 +0300 +++ b/src/lib/uri-util.c Tue Aug 06 14:53:23 2013 +0300 @@ -799,8 +799,6 @@ { const char *addr = net_ip2addr(host_ip); - i_assert(addr != NULL); - if (host_ip->family == AF_INET) { str_append(out, addr); return; diff -r 7057d4ad8891 -r 58be84a381e5 src/lmtp/client.c --- a/src/lmtp/client.c Tue Aug 06 14:46:36 2013 +0300 +++ b/src/lmtp/client.c Tue Aug 06 14:53:23 2013 +0300 @@ -195,7 +195,7 @@ const char *addr; addr = net_ip2addr(&client->remote_ip); - if (addr == NULL) + if (addr[0] == '\0') addr = "local"; return addr; } diff -r 7057d4ad8891 -r 58be84a381e5 src/login-common/main.c --- a/src/login-common/main.c Tue Aug 06 14:46:36 2013 +0300 +++ b/src/login-common/main.c Tue Aug 06 14:53:23 2013 +0300 @@ -64,11 +64,14 @@ } else if (clients_get_count() > 1 || client == NULL) { process_title_set(t_strdup_printf("[%u connections (%u TLS)]", clients_get_count(), ssl_proxy_get_count())); - } else if ((addr = net_ip2addr(&client->ip)) != NULL) { - process_title_set(t_strdup_printf(client->tls ? - "[%s TLS]" : "[%s]", addr)); } else { - process_title_set(client->tls ? "[TLS]" : ""); + addr = net_ip2addr(&client->ip); + if (addr[0] != '\0') { + process_title_set(t_strdup_printf(client->tls ? + "[%s TLS]" : "[%s]", addr)); + } else { + process_title_set(client->tls ? "[TLS]" : ""); + } } } From dovecot at dovecot.org Tue Aug 6 15:11:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 15:11:24 +0300 Subject: dovecot-2.2: doveadm: If we get disconnected from server, log th... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/07557a9c59b1 changeset: 16667:07557a9c59b1 user: Timo Sirainen date: Tue Aug 06 15:11:14 2013 +0300 description: doveadm: If we get disconnected from server, log the reason. diffstat: src/doveadm/doveadm-mail-server.c | 6 ++++-- src/doveadm/dsync/doveadm-dsync.c | 6 ++++-- src/doveadm/server-connection.c | 22 ++++++++++++++++------ src/doveadm/server-connection.h | 3 ++- 4 files changed, 26 insertions(+), 11 deletions(-) diffs (123 lines): diff -r 58be84a381e5 -r 07557a9c59b1 src/doveadm/doveadm-mail-server.c --- a/src/doveadm/doveadm-mail-server.c Tue Aug 06 14:53:23 2013 +0300 +++ b/src/doveadm/doveadm-mail-server.c Tue Aug 06 15:11:14 2013 +0300 @@ -81,7 +81,8 @@ return FALSE; } -static void doveadm_cmd_callback(int exit_code, void *context) +static void doveadm_cmd_callback(int exit_code, const char *error, + void *context) { struct doveadm_mail_server_cmd *servercmd = context; struct doveadm_server *server = @@ -95,7 +96,8 @@ case 0: break; case SERVER_EXIT_CODE_DISCONNECTED: - i_error("%s: Internal failure for %s", server->name, username); + i_error("%s: Internal failure for %s: %s", + server->name, username, error); internal_failure = TRUE; master_service_stop(master_service); return; diff -r 58be84a381e5 -r 07557a9c59b1 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Tue Aug 06 14:53:23 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Tue Aug 06 15:11:14 2013 +0300 @@ -621,7 +621,8 @@ return ret; } -static void dsync_connected_callback(int exit_code, void *context) +static void dsync_connected_callback(int exit_code, const char *error, + void *context) { struct dsync_cmd_context *ctx = context; @@ -632,7 +633,8 @@ &ctx->output, &ctx->ssl_iostream); break; case SERVER_EXIT_CODE_DISCONNECTED: - ctx->error = "Disconnected from remote"; + ctx->error = p_strdup_printf(ctx->ctx.pool, + "Disconnected from remote: %s", error); break; case EX_NOUSER: ctx->error = "Unknown user in remote"; diff -r 58be84a381e5 -r 07557a9c59b1 src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Tue Aug 06 14:53:23 2013 +0300 +++ b/src/doveadm/server-connection.c Tue Aug 06 15:11:14 2013 +0300 @@ -79,12 +79,13 @@ } static void -server_connection_callback(struct server_connection *conn, int exit_code) +server_connection_callback(struct server_connection *conn, + int exit_code, const char *error) { server_cmd_callback_t *callback = conn->callback; conn->callback = NULL; - callback(exit_code, conn->context); + callback(exit_code, error, conn->context); } static void stream_data(string_t *str, const unsigned char *data, size_t size) @@ -266,7 +267,7 @@ if (line == NULL) return; if (line[0] == '+') - server_connection_callback(conn, 0); + server_connection_callback(conn, 0, ""); else if (line[0] == '-') { line++; if (strcmp(line, "NOUSER") == 0) @@ -275,7 +276,7 @@ /* old doveadm-server */ exit_code = EX_TEMPFAIL; } - server_connection_callback(conn, exit_code); + server_connection_callback(conn, exit_code, line); } else { i_error("doveadm server sent broken input " "(expected cmd reply): %s", line); @@ -405,6 +406,7 @@ { struct server_connection *conn = *_conn; struct server_connection *const *conns; + const char *error; unsigned int i, count; *_conn = NULL; @@ -417,8 +419,16 @@ } } - if (conn->callback != NULL) - server_connection_callback(conn, SERVER_EXIT_CODE_DISCONNECTED); + if (conn->callback != NULL) { + error = conn->ssl_iostream == NULL ? NULL : + ssl_iostream_get_last_error(conn->ssl_iostream); + if (error == NULL) { + error = conn->input->stream_errno == 0 ? "EOF" : + strerror(conn->input->stream_errno); + } + server_connection_callback(conn, SERVER_EXIT_CODE_DISCONNECTED, + error); + } if (printing_conn == conn) print_connection_released(); diff -r 58be84a381e5 -r 07557a9c59b1 src/doveadm/server-connection.h --- a/src/doveadm/server-connection.h Tue Aug 06 14:53:23 2013 +0300 +++ b/src/doveadm/server-connection.h Tue Aug 06 15:11:14 2013 +0300 @@ -7,7 +7,8 @@ struct server_connection; struct ssl_iostream; -typedef void server_cmd_callback_t(int exit_code, void *context); +typedef void server_cmd_callback_t(int exit_code, const char *error, + void *context); int server_connection_create(struct doveadm_server *server, struct server_connection **conn_r); From dovecot at dovecot.org Tue Aug 6 16:08:19 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 16:08:19 +0300 Subject: dovecot-2.2: lib-ssl-iostream: Deinitialization fixes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a53caa140f3d changeset: 16668:a53caa140f3d user: Timo Sirainen date: Tue Aug 06 16:07:50 2013 +0300 description: lib-ssl-iostream: Deinitialization fixes. diffstat: src/lib-ssl-iostream/iostream-openssl-context.c | 5 ++--- src/lib-ssl-iostream/iostream-openssl.c | 2 ++ src/lib-ssl-iostream/iostream-openssl.h | 1 + src/lib-ssl-iostream/iostream-ssl-private.h | 1 + src/lib-ssl-iostream/iostream-ssl.c | 4 +++- 5 files changed, 9 insertions(+), 4 deletions(-) diffs (84 lines): diff -r 07557a9c59b1 -r a53caa140f3d src/lib-ssl-iostream/iostream-openssl-context.c --- a/src/lib-ssl-iostream/iostream-openssl-context.c Tue Aug 06 15:11:14 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl-context.c Tue Aug 06 16:07:50 2013 +0300 @@ -561,7 +561,7 @@ i_free(ctx); } -static void ssl_iostream_deinit_global(void) +void openssl_iostream_global_deinit(void) { if (ssl_iostream_engine != NULL) ENGINE_finish(ssl_iostream_engine); @@ -581,7 +581,6 @@ if (ssl_global_initialized) return 0; - atexit(ssl_iostream_deinit_global); ssl_global_initialized = TRUE; SSL_library_init(); SSL_load_error_strings(); @@ -603,7 +602,7 @@ *error_r = t_strdup_printf( "Unknown ssl_crypto_device: %s", set->crypto_device); - ssl_iostream_deinit_global(); + /* we'll deinit at exit in any case */ return -1; } ENGINE_init(ssl_iostream_engine); diff -r 07557a9c59b1 -r a53caa140f3d src/lib-ssl-iostream/iostream-openssl.c --- a/src/lib-ssl-iostream/iostream-openssl.c Tue Aug 06 15:11:14 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.c Tue Aug 06 16:07:50 2013 +0300 @@ -687,6 +687,8 @@ } const struct iostream_ssl_vfuncs ssl_vfuncs = { + openssl_iostream_global_deinit, + openssl_iostream_context_init_client, openssl_iostream_context_init_server, openssl_iostream_context_deinit, diff -r 07557a9c59b1 -r a53caa140f3d src/lib-ssl-iostream/iostream-openssl.h --- a/src/lib-ssl-iostream/iostream-openssl.h Tue Aug 06 15:11:14 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl.h Tue Aug 06 16:07:50 2013 +0300 @@ -62,6 +62,7 @@ struct ssl_iostream_context **ctx_r, const char **error_r); void openssl_iostream_context_deinit(struct ssl_iostream_context *ctx); +void openssl_iostream_global_deinit(void); int openssl_iostream_load_key(const struct ssl_iostream_settings *set, EVP_PKEY **pkey_r, const char **error_r); diff -r 07557a9c59b1 -r a53caa140f3d src/lib-ssl-iostream/iostream-ssl-private.h --- a/src/lib-ssl-iostream/iostream-ssl-private.h Tue Aug 06 15:11:14 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-ssl-private.h Tue Aug 06 16:07:50 2013 +0300 @@ -4,6 +4,7 @@ #include "iostream-ssl.h" struct iostream_ssl_vfuncs { + void (*global_deinit)(void); int (*context_init_client)(const struct ssl_iostream_settings *set, struct ssl_iostream_context **ctx_r, const char **error_r); diff -r 07557a9c59b1 -r a53caa140f3d src/lib-ssl-iostream/iostream-ssl.c --- a/src/lib-ssl-iostream/iostream-ssl.c Tue Aug 06 15:11:14 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-ssl.c Tue Aug 06 16:07:50 2013 +0300 @@ -15,6 +15,8 @@ #ifdef HAVE_SSL static void ssl_module_unload(void) { + module_dir_deinit(ssl_module); + ssl_vfuncs->global_deinit(); module_dir_unload(&ssl_module); } #endif @@ -38,7 +40,7 @@ return -1; } - atexit(ssl_module_unload); + lib_atexit(ssl_module_unload); ssl_module_loaded = TRUE; return 0; #else From dovecot at dovecot.org Tue Aug 6 16:28:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 16:28:24 +0300 Subject: dovecot-2.2: dsync: Memory leak fix at deinit. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/960f827b7579 changeset: 16669:960f827b7579 user: Timo Sirainen date: Tue Aug 06 16:28:08 2013 +0300 description: dsync: Memory leak fix at deinit. diffstat: src/doveadm/dsync/dsync-ibc-stream.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (18 lines): diff -r a53caa140f3d -r 960f827b7579 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Tue Aug 06 16:07:50 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Tue Aug 06 16:28:08 2013 +0300 @@ -323,7 +323,14 @@ static void dsync_ibc_stream_deinit(struct dsync_ibc *_ibc) { struct dsync_ibc_stream *ibc = (struct dsync_ibc_stream *)_ibc; + unsigned int i; + for (i = ITEM_DONE + 1; i < ITEM_END_OF_LIST; i++) { + if (ibc->serializers[i] != NULL) + dsync_serializer_deinit(&ibc->serializers[i]); + if (ibc->deserializers[i] != NULL) + dsync_deserializer_deinit(&ibc->deserializers[i]); + } if (ibc->cur_decoder != NULL) dsync_deserializer_decode_finish(&ibc->cur_decoder); if (ibc->value_output != NULL) From dovecot at dovecot.org Tue Aug 6 16:32:14 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 16:32:14 +0300 Subject: dovecot-2.2: dsync: Don't leak iostreams when running via dovead... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0cf837972a32 changeset: 16670:0cf837972a32 user: Timo Sirainen date: Tue Aug 06 16:32:03 2013 +0300 description: dsync: Don't leak iostreams when running via doveadm-server diffstat: src/doveadm/dsync/doveadm-dsync.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diffs (36 lines): diff -r 960f827b7579 -r 0cf837972a32 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Tue Aug 06 16:28:08 2013 +0300 +++ b/src/doveadm/dsync/doveadm-dsync.c Tue Aug 06 16:32:03 2013 +0300 @@ -452,10 +452,9 @@ fd_set_nonblock(ctx->fd_out, TRUE); ctx->input = i_stream_create_fd(ctx->fd_in, (size_t)-1, FALSE); ctx->output = o_stream_create_fd(ctx->fd_out, (size_t)-1, FALSE); - } else { - i_stream_ref(ctx->input); - o_stream_ref(ctx->output); } + i_stream_ref(ctx->input); + o_stream_ref(ctx->output); if (ctx->rawlog_path != NULL) { iostream_rawlog_create_path(ctx->rawlog_path, &ctx->input, &ctx->output); @@ -592,6 +591,10 @@ ssl_iostream_destroy(&ctx->ssl_iostream); if (ctx->ssl_ctx != NULL) ssl_iostream_context_deinit(&ctx->ssl_ctx); + if (ctx->input != NULL) + i_stream_unref(&ctx->input); + if (ctx->output != NULL) + o_stream_unref(&ctx->output); if (ctx->fd_in != -1) { if (ctx->fd_out != ctx->fd_in) i_close_fd(&ctx->fd_out); @@ -615,8 +618,6 @@ io_remove(&ctx->io_err); if (ctx->fd_err != -1) i_close_fd(&ctx->fd_err); - ctx->input = NULL; - ctx->output = NULL; return ret; } From dovecot at dovecot.org Tue Aug 6 16:54:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 16:54:46 +0300 Subject: dovecot-2.2: doveadm-server: Include client's IP address in logs. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/6c4917396b0d changeset: 16671:6c4917396b0d user: Timo Sirainen date: Tue Aug 06 16:54:33 2013 +0300 description: doveadm-server: Include client's IP address in logs. diffstat: src/doveadm/client-connection.c | 5 +++++ src/doveadm/doveadm-mail.c | 17 +++++++++++++---- src/doveadm/doveadm-mail.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diffs (83 lines): diff -r 0cf837972a32 -r 6c4917396b0d src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Tue Aug 06 16:32:03 2013 +0300 +++ b/src/doveadm/client-connection.c Tue Aug 06 16:54:33 2013 +0300 @@ -397,6 +397,7 @@ client_connection_create(int fd, int listen_fd, bool ssl) { struct client_connection *conn; + const char *ip; pool_t pool; pool = pool_alloconly_create("doveadm client", 1024*16); @@ -414,6 +415,10 @@ i_stream_set_name(conn->input, net_ip2addr(&conn->remote_ip)); o_stream_set_name(conn->output, net_ip2addr(&conn->remote_ip)); + ip = net_ip2addr(&conn->remote_ip); + if (ip[0] != '\0') + i_set_failure_prefix("doveadm(%s): ", ip); + if (client_connection_read_settings(conn) < 0) { client_connection_destroy(&conn); return NULL; diff -r 0cf837972a32 -r 6c4917396b0d src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Tue Aug 06 16:32:03 2013 +0300 +++ b/src/doveadm/doveadm-mail.c Tue Aug 06 16:54:33 2013 +0300 @@ -270,10 +270,14 @@ const struct mail_storage_service_input *input, const char **error_r) { - const char *error; + const char *error, *ip; int ret; - i_set_failure_prefix("doveadm(%s): ", input->username); + ip = net_ip2addr(&input->remote_ip); + if (ip[0] == '\0') + i_set_failure_prefix("doveadm(%s): ", input->username); + else + i_set_failure_prefix("doveadm(%s,%s): ", ip, input->username); /* see if we want to execute this command via (another) doveadm server */ @@ -321,6 +325,7 @@ { i_assert(input->username != NULL); + ctx->cur_client_ip = input->remote_ip; ctx->cur_username = input->username; ctx->storage_service_input = *input; ctx->storage_service = mail_storage_service_init(master_service, NULL, @@ -343,7 +348,7 @@ { struct mail_storage_service_input input; unsigned int user_idx; - const char *user, *error; + const char *ip, *user, *error; int ret; ctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP; @@ -396,7 +401,11 @@ } if (doveadm_verbose) printf("\n"); - i_set_failure_prefix("doveadm: "); + ip = net_ip2addr(&ctx->cur_client_ip); + if (ip[0] == '\0') + i_set_failure_prefix("doveadm: "); + else + i_set_failure_prefix("doveadm(%s): ", ip); if (ret < 0) { i_error("Failed to iterate through some users"); ctx->exit_code = EX_TEMPFAIL; diff -r 0cf837972a32 -r 6c4917396b0d src/doveadm/doveadm-mail.h --- a/src/doveadm/doveadm-mail.h Tue Aug 06 16:32:03 2013 +0300 +++ b/src/doveadm/doveadm-mail.h Tue Aug 06 16:54:33 2013 +0300 @@ -54,6 +54,7 @@ /* search args aren't set for all mail commands */ struct mail_search_args *search_args; + struct ip_addr cur_client_ip; const char *cur_username; struct mail_storage_service_user *cur_service_user; struct mail_user *cur_mail_user; From dovecot at dovecot.org Tue Aug 6 17:06:57 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 17:06:57 +0300 Subject: dovecot-2.2: doveadm-server: Error message logging improvements. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e52284d3cc76 changeset: 16672:e52284d3cc76 user: Timo Sirainen date: Tue Aug 06 17:06:50 2013 +0300 description: doveadm-server: Error message logging improvements. diffstat: src/doveadm/client-connection.c | 17 ++++++++++++++++- src/doveadm/doveadm-mail-server.c | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diffs (49 lines): diff -r 6c4917396b0d -r e52284d3cc76 src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Tue Aug 06 16:54:33 2013 +0300 +++ b/src/doveadm/client-connection.c Tue Aug 06 17:06:50 2013 +0300 @@ -281,6 +281,19 @@ return 1; } +static void client_log_disconnect_error(struct client_connection *conn) +{ + const char *error; + + error = conn->ssl_iostream == NULL ? NULL : + ssl_iostream_get_last_error(conn->ssl_iostream); + if (error == NULL) { + error = conn->input->stream_errno == 0 ? "EOF" : + strerror(conn->input->stream_errno); + } + i_error("doveadm client disconnected before handshake: %s", error); +} + static void client_connection_input(struct client_connection *conn) { const char *line; @@ -289,8 +302,10 @@ if (!conn->handshaked) { if ((line = i_stream_read_next_line(conn->input)) == NULL) { - if (conn->input->eof || conn->input->stream_errno != 0) + if (conn->input->eof || conn->input->stream_errno != 0) { + client_log_disconnect_error(conn); client_connection_destroy(&conn); + } return; } diff -r 6c4917396b0d -r e52284d3cc76 src/doveadm/doveadm-mail-server.c --- a/src/doveadm/doveadm-mail-server.c Tue Aug 06 16:54:33 2013 +0300 +++ b/src/doveadm/doveadm-mail-server.c Tue Aug 06 17:06:50 2013 +0300 @@ -96,8 +96,8 @@ case 0: break; case SERVER_EXIT_CODE_DISCONNECTED: - i_error("%s: Internal failure for %s: %s", - server->name, username, error); + i_error("%s: Command %s failed for %s: %s", + server->name, cmd_ctx->cmd->name, username, error); internal_failure = TRUE; master_service_stop(master_service); return; From dovecot at dovecot.org Tue Aug 6 17:17:10 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 17:17:10 +0300 Subject: dovecot-2.2: dsync: Stream disconnection error message improvement Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/64464646c020 changeset: 16673:64464646c020 user: Timo Sirainen date: Tue Aug 06 17:16:58 2013 +0300 description: dsync: Stream disconnection error message improvement diffstat: src/doveadm/dsync/dsync-ibc-stream.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diffs (33 lines): diff -r e52284d3cc76 -r 64464646c020 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Tue Aug 06 17:06:50 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Tue Aug 06 17:16:58 2013 +0300 @@ -357,6 +357,7 @@ static int dsync_ibc_stream_next_line(struct dsync_ibc_stream *ibc, const char **line_r) { + string_t *error; const char *line; line = i_stream_next_line(ibc->input); @@ -368,13 +369,19 @@ if (i_stream_read(ibc->input) == -1) { if (ibc->stopped) return -1; + error = t_str_new(128); if (ibc->input->stream_errno != 0) { errno = ibc->input->stream_errno; - i_error("read(%s) failed: %m", ibc->name); + str_printfa(error, "read(%s) failed: %m", ibc->name); } else { i_assert(ibc->input->eof); - i_error("read(%s) failed: EOF", ibc->name); + str_printfa(error, "read(%s) failed: EOF", ibc->name); } + if (!ibc->version_received) + str_append(error, " (version not received)"); + else if (!ibc->handshake_received) + str_append(error, " (handshake not received)"); + i_error("%s", str_c(error)); dsync_ibc_stream_stop(ibc); return -1; } From dovecot at dovecot.org Tue Aug 6 18:28:51 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 18:28:51 +0300 Subject: dovecot-2.2: doveadm: If server connection gets disconnected, lo... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c5c3eba6ae14 changeset: 16674:c5c3eba6ae14 user: Timo Sirainen date: Tue Aug 06 18:28:31 2013 +0300 description: doveadm: If server connection gets disconnected, log the reason. diffstat: src/doveadm/server-connection.c | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diffs (43 lines): diff -r 64464646c020 -r c5c3eba6ae14 src/doveadm/server-connection.c --- a/src/doveadm/server-connection.c Tue Aug 06 17:16:58 2013 +0300 +++ b/src/doveadm/server-connection.c Tue Aug 06 18:28:31 2013 +0300 @@ -199,6 +199,19 @@ return 0; } +static void server_log_disconnect_error(struct server_connection *conn) +{ + const char *error; + + error = conn->ssl_iostream == NULL ? NULL : + ssl_iostream_get_last_error(conn->ssl_iostream); + if (error == NULL) { + error = conn->input->stream_errno == 0 ? "EOF" : + strerror(conn->input->stream_errno); + } + i_error("doveadm server disconnected before handshake: %s", error); +} + static void server_connection_input(struct server_connection *conn) { const unsigned char *data; @@ -208,8 +221,10 @@ if (!conn->handshaked) { if ((line = i_stream_read_next_line(conn->input)) == NULL) { - if (conn->input->eof || conn->input->stream_errno != 0) + if (conn->input->eof || conn->input->stream_errno != 0) { + server_log_disconnect_error(conn); server_connection_destroy(&conn); + } return; } @@ -232,6 +247,7 @@ if (i_stream_read(conn->input) < 0) { /* disconnected */ + server_log_disconnect_error(conn); server_connection_destroy(&conn); return; } From dovecot at dovecot.org Tue Aug 6 21:45:55 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 21:45:55 +0300 Subject: dovecot-2.2: man: dovecot.1: Added description of option --hostd... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/94d547439e73 changeset: 16675:94d547439e73 user: Pascal Volk date: Tue Aug 06 18:35:02 2013 +0000 description: man: dovecot.1: Added description of option --hostdomain. diffstat: doc/man/dovecot.1.in | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diffs (41 lines): diff -r c5c3eba6ae14 -r 94d547439e73 doc/man/dovecot.1.in --- a/doc/man/dovecot.1.in Tue Aug 06 18:28:31 2013 +0300 +++ b/doc/man/dovecot.1.in Tue Aug 06 18:35:02 2013 +0000 @@ -1,5 +1,5 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVECOT 1 "2010-07-02" "Dovecot v2.2" "Dovecot" +.\" Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file +.TH DOVECOT 1 "2013-08-06" "Dovecot v2.2" "Dovecot" .SH NAME dovecot \- a secure and highly configurable IMAP and POP3 server .\"------------------------------------------------------------------------ @@ -16,6 +16,8 @@ .br .B dovecot \-\-help .br +.B dovecot \-\-hostdomain +.br .B dovecot \-\-version .br .B dovecot reload @@ -62,6 +64,13 @@ .B \-\-help Print a usage message to stdout and exit successfully. .TP +.B \-\-hostdomain +Shows the current +.IR host . domain +name of the system. +If the domain lookup should fail for some reason, only the hostname will +be shown. +.TP .B \-\-version Show Dovecot\(aqs version and exit successfully. .\"------------------------------------------------------------------------ @@ -155,4 +164,4 @@ .BR doveadm (1), .BR doveconf (1), .BR dovecot\-lda (1), -.BR dsync (1) +.BR dsync (1) \ No newline at end of file From dovecot at dovecot.org Tue Aug 6 21:46:12 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 06 Aug 2013 21:46:12 +0300 Subject: dovecot-2.2: master: Added --hostdomain to the help message. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/cecaa7b85f65 changeset: 16676:cecaa7b85f65 user: Pascal Volk date: Tue Aug 06 18:44:37 2013 +0000 description: master: Added --hostdomain to the help message. diffstat: src/master/main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 94d547439e73 -r cecaa7b85f65 src/master/main.c --- a/src/master/main.c Tue Aug 06 18:35:02 2013 +0000 +++ b/src/master/main.c Tue Aug 06 18:44:37 2013 +0000 @@ -627,7 +627,7 @@ { fprintf(stderr, "Usage: dovecot [-F] [-c ] [-p] [-n] [-a] [--help] [--version]\n" -" [--build-options] [reload] [stop]\n"); +" [--build-options] [--hostdomain] [reload] [stop]\n"); } static void print_build_options(void) From dovecot at dovecot.org Wed Aug 7 16:09:37 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Aug 2013 16:09:37 +0300 Subject: dovecot-2.2: quota: Improved init() failure error logging. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/a07ab0c638d2 changeset: 16677:a07ab0c638d2 user: Timo Sirainen date: Wed Aug 07 16:09:29 2013 +0300 description: quota: Improved init() failure error logging. diffstat: src/plugins/quota/quota-dict.c | 7 ++++--- src/plugins/quota/quota-fs.c | 5 +++-- src/plugins/quota/quota-maildir.c | 5 +++-- src/plugins/quota/quota-private.h | 3 ++- src/plugins/quota/quota.c | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diffs (102 lines): diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-dict.c --- a/src/plugins/quota/quota-dict.c Tue Aug 06 18:44:37 2013 +0000 +++ b/src/plugins/quota/quota-dict.c Wed Aug 07 16:09:29 2013 +0300 @@ -28,14 +28,15 @@ return &root->root; } -static int dict_quota_init(struct quota_root *_root, const char *args) +static int dict_quota_init(struct quota_root *_root, const char *args, + const char **error_r) { struct dict_quota_root *root = (struct dict_quota_root *)_root; const char *username, *p, *error; p = args == NULL ? NULL : strchr(args, ':'); if (p == NULL) { - i_error("dict quota: URI missing from parameters"); + *error_r = "URI missing from parameters"; return -1; } @@ -80,7 +81,7 @@ if (dict_init(args, DICT_DATA_TYPE_STRING, username, _root->quota->user->set->base_dir, &root->dict, &error) < 0) { - i_error("dict quota: dict_init(%s) failed: %s", args, error); + *error_r = t_strdup_printf("dict_init(%s) failed: %s", args, error); return -1; } return 0; diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-fs.c --- a/src/plugins/quota/quota-fs.c Tue Aug 06 18:44:37 2013 +0000 +++ b/src/plugins/quota/quota-fs.c Wed Aug 07 16:09:29 2013 +0300 @@ -95,7 +95,8 @@ return &root->root; } -static int fs_quota_init(struct quota_root *_root, const char *args) +static int fs_quota_init(struct quota_root *_root, const char *args, + const char **error_r) { struct fs_quota_root *root = (struct fs_quota_root *)_root; const char *const *tmp; @@ -116,7 +117,7 @@ i_free(root->storage_mount_path); root->storage_mount_path = i_strdup(*tmp + 6); } else { - i_error("fs quota: Invalid parameter: %s", *tmp); + *error_r = t_strdup_printf("Invalid parameter: %s", *tmp); return -1; } } diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-maildir.c --- a/src/plugins/quota/quota-maildir.c Tue Aug 06 18:44:37 2013 +0000 +++ b/src/plugins/quota/quota-maildir.c Wed Aug 07 16:09:29 2013 +0300 @@ -753,7 +753,8 @@ return &root->root; } -static int maildir_quota_init(struct quota_root *_root, const char *args) +static int maildir_quota_init(struct quota_root *_root, const char *args, + const char **error_r) { const char *const *tmp; @@ -768,7 +769,7 @@ else if (strncmp(*tmp, "ns=", 3) == 0) _root->ns_prefix = p_strdup(_root->pool, *tmp + 3); else { - i_error("maildir quota: Invalid parameter: %s", *tmp); + *error_r = t_strdup_printf("Invalid parameter: %s", *tmp); return -1; } } diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota-private.h --- a/src/plugins/quota/quota-private.h Tue Aug 06 18:44:37 2013 +0000 +++ b/src/plugins/quota/quota-private.h Wed Aug 07 16:09:29 2013 +0300 @@ -48,7 +48,8 @@ struct quota_backend_vfuncs { struct quota_root *(*alloc)(void); - int (*init)(struct quota_root *root, const char *args); + int (*init)(struct quota_root *root, const char *args, + const char **error_r); void (*deinit)(struct quota_root *root); bool (*parse_rule)(struct quota_root_settings *root_set, diff -r cecaa7b85f65 -r a07ab0c638d2 src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Tue Aug 06 18:44:37 2013 +0000 +++ b/src/plugins/quota/quota.c Wed Aug 07 16:09:29 2013 +0300 @@ -270,8 +270,9 @@ sizeof(void *), 10); if (root->backend.v.init != NULL) { - if (root->backend.v.init(root, root_set->args) < 0) { - *error_r = "init() failed"; + if (root->backend.v.init(root, root_set->args, error_r) < 0) { + *error_r = t_strdup_printf("%s quota init failed: %s", + root->backend.name, *error_r); return -1; } } else if (root_set->args != NULL) { From dovecot at dovecot.org Wed Aug 7 17:21:16 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Aug 2013 17:21:16 +0300 Subject: dovecot-2.2: Compiler warning fixes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/17e43eda8f22 changeset: 16678:17e43eda8f22 user: Timo Sirainen date: Wed Aug 07 17:20:10 2013 +0300 description: Compiler warning fixes. diffstat: src/director/director-connection.c | 2 +- src/lib-ssl-iostream/iostream-openssl-context.c | 4 ++-- src/login-common/ssl-proxy-openssl.c | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diffs (48 lines): diff -r a07ab0c638d2 -r 17e43eda8f22 src/director/director-connection.c --- a/src/director/director-connection.c Wed Aug 07 16:09:29 2013 +0300 +++ b/src/director/director-connection.c Wed Aug 07 17:20:10 2013 +0300 @@ -1175,7 +1175,7 @@ } if ((host == NULL || !host->self) && - dir->self_host->last_sync_timestamp != ioloop_time) + (time_t)dir->self_host->last_sync_timestamp != ioloop_time) (void)director_resend_sync(dir); return TRUE; } diff -r a07ab0c638d2 -r 17e43eda8f22 src/lib-ssl-iostream/iostream-openssl-context.c --- a/src/lib-ssl-iostream/iostream-openssl-context.c Wed Aug 07 16:09:29 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl-context.c Wed Aug 07 17:20:10 2013 +0300 @@ -433,8 +433,8 @@ static int ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx, - const struct ssl_iostream_settings *set, - const char **error_r) + const struct ssl_iostream_settings *set ATTR_UNUSED, + const char **error_r ATTR_UNUSED) { #if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L EC_KEY *ecdh; diff -r a07ab0c638d2 -r 17e43eda8f22 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Wed Aug 07 16:09:29 2013 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Wed Aug 07 17:20:10 2013 +0300 @@ -121,7 +121,9 @@ static void ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx, const struct master_service_ssl_settings *set); +#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L static int ssl_proxy_ctx_get_pkey_ec_curve_name(const struct master_service_ssl_settings *set); +#endif static unsigned int ssl_server_context_hash(const struct ssl_server_context *ctx) { @@ -1013,7 +1015,7 @@ static void ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx, - const struct master_service_ssl_settings *set) + const struct master_service_ssl_settings *set ATTR_UNUSED) { #if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L EC_KEY *ecdh; From dovecot at dovecot.org Wed Aug 7 18:00:48 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Aug 2013 18:00:48 +0300 Subject: dovecot-2.2: ssl: Fixed compiling with older OpenSSL libraries. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/27ebd9552471 changeset: 16679:27ebd9552471 user: Timo Sirainen date: Wed Aug 07 18:00:32 2013 +0300 description: ssl: Fixed compiling with older OpenSSL libraries. diffstat: src/lib-ssl-iostream/iostream-openssl-context.c | 16 ++++++++++------ src/login-common/ssl-proxy-openssl.c | 18 +++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diffs (131 lines): diff -r 17e43eda8f22 -r 27ebd9552471 src/lib-ssl-iostream/iostream-openssl-context.c --- a/src/lib-ssl-iostream/iostream-openssl-context.c Wed Aug 07 17:20:10 2013 +0300 +++ b/src/lib-ssl-iostream/iostream-openssl-context.c Wed Aug 07 18:00:32 2013 +0300 @@ -12,6 +12,10 @@ #include #include +#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L +# define HAVE_ECDH +#endif + struct ssl_iostream_password_context { const char *password; const char *error; @@ -406,7 +410,7 @@ return 0; } -#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L +#if defined(HAVE_ECDH) && OPENSSL_VERSION_NUMBER < 0x10002000L static int ssl_proxy_ctx_get_pkey_ec_curve_name(const struct ssl_iostream_settings *set, int *nid_r, const char **error_r) @@ -436,7 +440,7 @@ const struct ssl_iostream_settings *set ATTR_UNUSED, const char **error_r ATTR_UNUSED) { -#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L +#if defined(HAVE_ECDH) && OPENSSL_VERSION_NUMBER < 0x10002000L EC_KEY *ecdh; int nid; const char *curve_name; @@ -444,17 +448,16 @@ if (SSL_CTX_need_tmp_RSA(ssl_ctx)) SSL_CTX_set_tmp_rsa_callback(ssl_ctx, ssl_gen_rsa_key); SSL_CTX_set_tmp_dh_callback(ssl_ctx, ssl_tmp_dh_callback); -#if !defined(OPENSSL_NO_ECDH) +#ifdef HAVE_ECDH /* In the non-recommended situation where ECDH cipher suites are being used instead of ECDHE, do not reuse the same ECDH key pair for different sessions. This option improves forward secrecy. */ SSL_CTX_set_options(ssl_ctx, SSL_OP_SINGLE_ECDH_USE); -#endif -#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10002000L +#if OPENSSL_VERSION_NUMBER >= 0x10002000L /* OpenSSL >= 1.0.2 automatically handles ECDH temporary key parameter selection. */ SSL_CTX_set_ecdh_auto(ssl_ctx, 1); -#elif !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L +#else /* For OpenSSL < 1.0.2, ECDH temporary key parameter selection must be performed manually. Attempt to select the same curve as that used in the server's private EC key file. Otherwise fall back to the @@ -481,6 +484,7 @@ EC_KEY_free(ecdh); } #endif +#endif return 0; } diff -r 17e43eda8f22 -r 27ebd9552471 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Wed Aug 07 17:20:10 2013 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Wed Aug 07 18:00:32 2013 +0300 @@ -29,6 +29,10 @@ #include #include +#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L +# define HAVE_ECDH +#endif + /* Check every 30 minutes if parameters file has been updated */ #define SSL_PARAMFILE_CHECK_INTERVAL (60*30) @@ -121,7 +125,7 @@ static void ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx, const struct master_service_ssl_settings *set); -#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L +#if defined(HAVE_ECDH) && OPENSSL_VERSION_NUMBER < 0x10002000L static int ssl_proxy_ctx_get_pkey_ec_curve_name(const struct master_service_ssl_settings *set); #endif @@ -1017,7 +1021,7 @@ ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx, const struct master_service_ssl_settings *set ATTR_UNUSED) { -#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L +#if defined(HAVE_ECDH) && OPENSSL_VERSION_NUMBER < 0x10002000L EC_KEY *ecdh; int nid; const char *curve_name; @@ -1025,17 +1029,16 @@ if (SSL_CTX_need_tmp_RSA(ssl_ctx)) SSL_CTX_set_tmp_rsa_callback(ssl_ctx, ssl_gen_rsa_key); SSL_CTX_set_tmp_dh_callback(ssl_ctx, ssl_tmp_dh_callback); -#if !defined(OPENSSL_NO_ECDH) +#ifdef HAVE_ECDH /* In the non-recommended situation where ECDH cipher suites are being used instead of ECDHE, do not reuse the same ECDH key pair for different sessions. This option improves forward secrecy. */ SSL_CTX_set_options(ssl_ctx, SSL_OP_SINGLE_ECDH_USE); -#endif -#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10002000L +#if OPENSSL_VERSION_NUMBER >= 0x10002000L /* OpenSSL >= 1.0.2 automatically handles ECDH temporary key parameter selection. */ SSL_CTX_set_ecdh_auto(ssl_ctx, 1); -#elif !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L +#else /* For OpenSSL < 1.0.2, ECDH temporary key parameter selection must be performed manually. Attempt to select the same curve as that used in the server's private EC key file. Otherwise fall back to the @@ -1060,6 +1063,7 @@ EC_KEY_free(ecdh); } #endif +#endif } static void @@ -1145,7 +1149,7 @@ EVP_PKEY_free(pkey); } -#if !defined(OPENSSL_NO_ECDH) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L +#if defined(HAVE_ECDH) && OPENSSL_VERSION_NUMBER < 0x10002000L static int ssl_proxy_ctx_get_pkey_ec_curve_name(const struct master_service_ssl_settings *set) { From dovecot at dovecot.org Wed Aug 7 19:26:40 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Aug 2013 19:26:40 +0300 Subject: dovecot-2.2: dsync: Avoid assert-crash after an error. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/225655115265 changeset: 16680:225655115265 user: Timo Sirainen date: Wed Aug 07 19:26:29 2013 +0300 description: dsync: Avoid assert-crash after an error. diffstat: src/doveadm/dsync/dsync-mailbox-import.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (16 lines): diff -r 27ebd9552471 -r 225655115265 src/doveadm/dsync/dsync-mailbox-import.c --- a/src/doveadm/dsync/dsync-mailbox-import.c Wed Aug 07 18:00:32 2013 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Wed Aug 07 19:26:29 2013 +0300 @@ -1395,8 +1395,11 @@ if (importer->failed) return -1; - if (!importer->last_common_uid_found) + if (!importer->last_common_uid_found) { dsync_mailbox_find_common_uid(importer, change); + if (importer->failed) + return -1; + } if (importer->last_common_uid_found) { /* a) uid <= last_common_uid for flag changes and expunges. From dovecot at dovecot.org Wed Aug 7 19:40:26 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Aug 2013 19:40:26 +0300 Subject: dovecot-2.2: dsync: We didn't send the new protocol version in h... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/044ec0204873 changeset: 16681:044ec0204873 user: Timo Sirainen date: Wed Aug 07 19:40:16 2013 +0300 description: dsync: We didn't send the new protocol version in handshake. This caused problems when syncing mailbox formats that didn't support saving GUIDs. diffstat: src/doveadm/dsync/dsync-ibc-stream.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 225655115265 -r 044ec0204873 src/doveadm/dsync/dsync-ibc-stream.c --- a/src/doveadm/dsync/dsync-ibc-stream.c Wed Aug 07 19:26:29 2013 +0300 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Wed Aug 07 19:40:16 2013 +0300 @@ -29,7 +29,7 @@ #define DSYNC_PROTOCOL_VERSION_MAJOR 3 #define DSYNC_PROTOCOL_VERSION_MINOR 2 -#define DSYNC_HANDSHAKE_VERSION "VERSION\tdsync\t3\t1\n" +#define DSYNC_HANDSHAKE_VERSION "VERSION\tdsync\t3\t2\n" #define DSYNC_PROTOCOL_MINOR_HAVE_ATTRIBUTES 1 #define DSYNC_PROTOCOL_MINOR_HAVE_SAVE_GUID 2 From dovecot at dovecot.org Wed Aug 7 19:47:28 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 07 Aug 2013 19:47:28 +0300 Subject: dovecot-2.2: imap: Fixed memory leak on APPEND error conditions. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5dbea45eecb8 changeset: 16682:5dbea45eecb8 user: Timo Sirainen date: Wed Aug 07 19:47:17 2013 +0300 description: imap: Fixed memory leak on APPEND error conditions. diffstat: src/imap/cmd-append.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diffs (43 lines): diff -r 044ec0204873 -r 5dbea45eecb8 src/imap/cmd-append.c --- a/src/imap/cmd-append.c Wed Aug 07 19:40:16 2013 +0300 +++ b/src/imap/cmd-append.c Wed Aug 07 19:47:17 2013 +0300 @@ -539,6 +539,8 @@ } else if (!imap_parse_datetime(internal_date_str, &internal_date, &timezone_offset)) { client_send_command_error(cmd, "Invalid internal date."); + if (keywords != NULL) + mailbox_keywords_unref(&keywords); return -1; } @@ -560,8 +562,11 @@ "NO Can't save a zero byte message."); ctx->failed = TRUE; } - if (!*nonsync_r) + if (!*nonsync_r) { + if (keywords != NULL) + mailbox_keywords_unref(&keywords); return -1; + } /* {0+} used. although there isn't any point in using MULTIAPPEND here and adding more messages, it is technically valid so we'll continue parsing.. */ @@ -580,8 +585,6 @@ /* save the mail */ ctx->save_ctx = mailbox_save_alloc(ctx->t); mailbox_save_set_flags(ctx->save_ctx, flags, keywords); - if (keywords != NULL) - mailbox_keywords_unref(&keywords); mailbox_save_set_received_date(ctx->save_ctx, internal_date, timezone_offset); if (mailbox_save_begin(&ctx->save_ctx, ctx->input) < 0) { @@ -590,6 +593,8 @@ ctx->failed = TRUE; } } + if (keywords != NULL) + mailbox_keywords_unref(&keywords); ctx->count++; if (cat_list == NULL) { From dovecot at dovecot.org Thu Aug 8 22:37:53 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 08 Aug 2013 22:37:53 +0300 Subject: dovecot-2.2: lmtp: Don't write extra ([]) to Received: line for ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9aa9944bd96e changeset: 16683:9aa9944bd96e user: Timo Sirainen date: Thu Aug 08 22:37:35 2013 +0300 description: lmtp: Don't write extra ([]) to Received: line for mails via UNIX socket. diffstat: src/lmtp/commands.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 5dbea45eecb8 -r 9aa9944bd96e src/lmtp/commands.c --- a/src/lmtp/commands.c Wed Aug 07 19:47:17 2013 +0300 +++ b/src/lmtp/commands.c Thu Aug 08 22:37:35 2013 +0300 @@ -910,7 +910,8 @@ } str_printfa(str, "Received: from %s", client->lhlo); - if ((host = net_ip2addr(&client->remote_ip)) != NULL) + host = net_ip2addr(&client->remote_ip); + if (host[0] != '\0') str_printfa(str, " ([%s])", host); str_printfa(str, "\r\n\tby %s ("PACKAGE_NAME") with LMTP id %s", client->my_domain, client->state.session_id); From dovecot at dovecot.org Sat Aug 10 15:00:46 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 10 Aug 2013 15:00:46 +0300 Subject: dovecot-2.2: lib-http: Removed duplicated code Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/7fe7cb56b4a6 changeset: 16684:7fe7cb56b4a6 user: Timo Sirainen date: Sat Aug 10 15:00:36 2013 +0300 description: lib-http: Removed duplicated code diffstat: src/lib-http/http-client-request.c | 13 ------------- 1 files changed, 0 insertions(+), 13 deletions(-) diffs (23 lines): diff -r 9aa9944bd96e -r 7fe7cb56b4a6 src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Thu Aug 08 22:37:35 2013 +0300 +++ b/src/lib-http/http-client-request.c Sat Aug 10 15:00:36 2013 +0300 @@ -593,19 +593,6 @@ } } - /* rewind payload stream */ - if (req->payload_input != NULL && req->payload_size > 0 && status != 303) { - if (req->payload_input->v_offset != req->payload_offset && - !req->payload_input->seekable) { - http_client_request_error(req, - HTTP_CLIENT_REQUEST_ERROR_ABORTED, - "Redirect failed: Cannot resend payload; stream is not seekable"); - return; - } else { - i_stream_seek(req->payload_input, req->payload_offset); - } - } - newport = (url->have_port ? url->port : (url->have_ssl ? 443 : 80)); target = http_url_create_target(url); From dovecot at dovecot.org Sat Aug 10 16:31:39 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 10 Aug 2013 16:31:39 +0300 Subject: dovecot-2.2: lib-http: Removed more code duplication Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1f6059b5c774 changeset: 16685:1f6059b5c774 user: Timo Sirainen date: Sat Aug 10 16:31:27 2013 +0300 description: lib-http: Removed more code duplication diffstat: src/lib-http/http-client-request.c | 20 -------------------- 1 files changed, 0 insertions(+), 20 deletions(-) diffs (30 lines): diff -r 7fe7cb56b4a6 -r 1f6059b5c774 src/lib-http/http-client-request.c --- a/src/lib-http/http-client-request.c Sat Aug 10 15:00:36 2013 +0300 +++ b/src/lib-http/http-client-request.c Sat Aug 10 16:31:27 2013 +0300 @@ -627,26 +627,6 @@ req->payload_offset = 0; } - /* https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21 - Section-7.4.4 - - -> A 303 `See Other' redirect status response is handled a bit differently. - Basically, the response content is located elsewhere, but the original - (POST) request is handled already. - */ - if (status == 303 && strcasecmp(req->method, "HEAD") != 0 && - strcasecmp(req->method, "GET") != 0) { - // FIXME: should we provide the means to skip this step? The original - // request was already handled at this point. - req->method = p_strdup(req->pool, "GET"); - - /* drop payload */ - if (req->payload_input != NULL) - i_stream_unref(&req->payload_input); - req->payload_size = 0; - req->payload_offset = 0; - } - /* resubmit */ req->state = HTTP_REQUEST_STATE_NEW; http_client_request_do_submit(req); From dovecot at dovecot.org Sun Aug 11 22:54:41 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 11 Aug 2013 22:54:41 +0300 Subject: dovecot-2.2: lib-storage: Improved error message in threading co... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5de1e4fdb758 changeset: 16686:5de1e4fdb758 user: Timo Sirainen date: Sun Aug 11 22:54:32 2013 +0300 description: lib-storage: Improved error message in threading code's lost message-id. diffstat: src/lib-storage/index/index-thread.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 1f6059b5c774 -r 5de1e4fdb758 src/lib-storage/index/index-thread.c --- a/src/lib-storage/index/index-thread.c Sat Aug 10 16:31:27 2013 +0300 +++ b/src/lib-storage/index/index-thread.c Sun Aug 11 22:54:32 2013 +0300 @@ -98,7 +98,8 @@ if (msgid == NULL) { /* shouldn't have happened */ mail_storage_set_critical(mail->box->storage, - "Threading lost Message ID"); + "Threading in %s UID %u lost Message ID %u", + mail->box->vname, mail->uid, rec->ref_index); return -1; } *msgid_r = msgid; From dovecot at dovecot.org Mon Aug 12 15:45:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Aug 2013 15:45:09 +0300 Subject: dovecot-2.2: lib-lda: submission_host, sendmail_path and hostnam... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/07b41fd29a6e changeset: 16688:07b41fd29a6e user: Timo Sirainen date: Mon Aug 12 15:44:51 2013 +0300 description: lib-lda: submission_host, sendmail_path and hostname settings can now contain %variables diffstat: src/lib-lda/lda-settings.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (16 lines): diff -r ca4628975fde -r 07b41fd29a6e src/lib-lda/lda-settings.c --- a/src/lib-lda/lda-settings.c Mon Aug 12 15:44:39 2013 +0300 +++ b/src/lib-lda/lda-settings.c Mon Aug 12 15:44:51 2013 +0300 @@ -19,9 +19,9 @@ static const struct setting_define lda_setting_defines[] = { DEF(SET_STR_VARS, postmaster_address), - DEF(SET_STR, hostname), - DEF(SET_STR, submission_host), - DEF(SET_STR, sendmail_path), + DEF(SET_STR_VARS, hostname), + DEF(SET_STR_VARS, submission_host), + DEF(SET_STR_VARS, sendmail_path), DEF(SET_STR, rejection_subject), DEF(SET_STR, rejection_reason), DEF(SET_STR, deliver_log_format), From dovecot at dovecot.org Mon Aug 12 15:45:09 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Aug 2013 15:45:09 +0300 Subject: dovecot-2.2: lib-lda: sendmail_path setting can contain paramete... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ca4628975fde changeset: 16687:ca4628975fde user: Timo Sirainen date: Mon Aug 12 15:44:39 2013 +0300 description: lib-lda: sendmail_path setting can contain parameters now. diffstat: src/lib-lda/smtp-client.c | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-) diffs (57 lines): diff -r 5de1e4fdb758 -r ca4628975fde src/lib-lda/smtp-client.c --- a/src/lib-lda/smtp-client.c Sun Aug 11 22:54:32 2013 +0300 +++ b/src/lib-lda/smtp-client.c Mon Aug 12 15:44:39 2013 +0300 @@ -2,7 +2,7 @@ #include "lib.h" #include "ioloop.h" -#include "buffer.h" +#include "array.h" #include "str.h" #include "safe-mkstemp.h" #include "execv-const.h" @@ -55,27 +55,32 @@ const char *destination, const char *return_path, int fd) { - const char *argv[7], *sendmail_path; + const char *const *sendmail_args, *const *argv, *str; + ARRAY_TYPE(const_string) args; + unsigned int i; - /* deliver_set's contents may point to environment variables. - deliver_env_clean() cleans them up, so they have to be copied. */ - sendmail_path = t_strdup(set->sendmail_path); + sendmail_args = t_strsplit(set->sendmail_path, " "); + t_array_init(&args, 16); + for (i = 0; sendmail_args[i] != NULL; i++) + array_append(&args, &sendmail_args[i], 1); - argv[0] = sendmail_path; - argv[1] = "-i"; /* ignore dots */ - argv[2] = "-f"; - argv[3] = return_path != NULL && *return_path != '\0' ? + str = "-i"; array_append(&args, &str, 1); /* ignore dots */ + str = "-f"; array_append(&args, &str, 1); + str = return_path != NULL && *return_path != '\0' ? return_path : "<>"; - argv[4] = "--"; - argv[5] = destination; - argv[6] = NULL; + array_append(&args, &str, 1); + + str = "--"; array_append(&args, &str, 1); + array_append(&args, &destination, 1); + array_append_zero(&args); + argv = array_idx(&args, 0); if (dup2(fd, STDIN_FILENO) < 0) i_fatal("dup2() failed: %m"); master_service_env_clean(); - execv_const(sendmail_path, argv); + execv_const(argv[0], argv); } static struct smtp_client * From dovecot at dovecot.org Mon Aug 12 17:24:24 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Aug 2013 17:24:24 +0300 Subject: dovecot-2.2: lib-storage: If dovecot.index.thread corruption is ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e6c2a1344f86 changeset: 16689:e6c2a1344f86 user: Timo Sirainen date: Mon Aug 12 17:24:05 2013 +0300 description: lib-storage: If dovecot.index.thread corruption is noticed, delete the file. diffstat: src/lib-index/mail-index-strmap.c | 3 +-- src/lib-index/mail-index-strmap.h | 1 + src/lib-storage/index/index-thread.c | 26 +++++++++++++++++--------- 3 files changed, 19 insertions(+), 11 deletions(-) diffs (106 lines): diff -r 07b41fd29a6e -r e6c2a1344f86 src/lib-index/mail-index-strmap.c --- a/src/lib-index/mail-index-strmap.c Mon Aug 12 15:44:51 2013 +0300 +++ b/src/lib-index/mail-index-strmap.c Mon Aug 12 17:24:05 2013 +0300 @@ -238,8 +238,7 @@ view->desynced = FALSE; } -static void -mail_index_strmap_view_set_corrupted(struct mail_index_strmap_view *view) +void mail_index_strmap_view_set_corrupted(struct mail_index_strmap_view *view) { mail_index_set_error(view->strmap->index, "Corrupted strmap index file: %s", diff -r 07b41fd29a6e -r e6c2a1344f86 src/lib-index/mail-index-strmap.h --- a/src/lib-index/mail-index-strmap.h Mon Aug 12 15:44:51 2013 +0300 +++ b/src/lib-index/mail-index-strmap.h Mon Aug 12 17:24:05 2013 +0300 @@ -56,6 +56,7 @@ const ARRAY_TYPE(mail_index_strmap_rec) **recs_r, const struct hash2_table **hash_r); void mail_index_strmap_view_close(struct mail_index_strmap_view **view); +void mail_index_strmap_view_set_corrupted(struct mail_index_strmap_view *view); /* Return the highest used string index. */ uint32_t mail_index_strmap_view_get_highest_idx(struct mail_index_strmap_view *view); diff -r 07b41fd29a6e -r e6c2a1344f86 src/lib-storage/index/index-thread.c --- a/src/lib-storage/index/index-thread.c Mon Aug 12 15:44:51 2013 +0300 +++ b/src/lib-storage/index/index-thread.c Mon Aug 12 17:24:05 2013 +0300 @@ -28,6 +28,7 @@ ARRAY_TYPE(seq_range) added_uids; unsigned int failed:1; + unsigned int corrupted:1; }; struct mail_thread_mailbox { @@ -52,10 +53,11 @@ static void mail_thread_clear(struct mail_thread_context *ctx); static int -mail_strmap_rec_get_msgid(struct mail *mail, +mail_strmap_rec_get_msgid(struct mail_thread_context *ctx, const struct mail_index_strmap_rec *rec, const char **msgid_r) { + struct mail *mail = ctx->tmp_mail; const char *msgids = NULL, *msgid; unsigned int n = 0; int ret; @@ -91,15 +93,18 @@ /* get the nth message-id */ msgid = message_id_get_next(&msgids); if (msgid != NULL) { - for (; n > 0 && *msgids != '\0'; n--) + for (; n > 0; n--) msgid = message_id_get_next(&msgids); } if (msgid == NULL) { - /* shouldn't have happened */ + /* shouldn't have happened, probably corrupted */ mail_storage_set_critical(mail->box->storage, - "Threading in %s UID %u lost Message ID %u", + "Corrupted thread index for mailbox %s: " + "UID %u lost Message ID %u", mail->box->vname, mail->uid, rec->ref_index); + ctx->failed = TRUE; + ctx->corrupted = TRUE; return -1; } *msgid_r = msgid; @@ -119,7 +124,7 @@ /* either a match or a collision, need to look closer */ T_BEGIN { - ret = mail_strmap_rec_get_msgid(ctx->tmp_mail, rec, &msgid); + ret = mail_strmap_rec_get_msgid(ctx, rec, &msgid); if (ret <= 0) { if (ret < 0) ctx->failed = TRUE; @@ -142,11 +147,10 @@ int ret; T_BEGIN { - ret = mail_strmap_rec_get_msgid(ctx->tmp_mail, rec1, &msgid1); + ret = mail_strmap_rec_get_msgid(ctx, rec1, &msgid1); if (ret > 0) { msgid1 = t_strdup(msgid1); - ret = mail_strmap_rec_get_msgid(ctx->tmp_mail, rec2, - &msgid2); + ret = mail_strmap_rec_get_msgid(ctx, rec2, &msgid2); } ret = ret <= 0 ? -1 : strcmp(msgid1, msgid2) == 0; @@ -567,7 +571,11 @@ mail_thread_cache_sync_add(tbox, ctx, search_ctx); if (mailbox_search_deinit(&search_ctx) < 0) ret = -1; - + if (ctx->failed) { + ret = -1; + if (ctx->corrupted) + mail_index_strmap_view_set_corrupted(tbox->strmap_view); + } if (ret < 0) { mail_thread_deinit(&ctx); return -1; From dovecot at dovecot.org Mon Aug 12 19:02:23 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Aug 2013 19:02:23 +0300 Subject: dovecot-2.2: auth: Added %{domain_first} and %{domain_last} vari... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/179f90dc0b1c changeset: 16690:179f90dc0b1c user: Timo Sirainen date: Mon Aug 12 19:02:07 2013 +0300 description: auth: Added %{domain_first} and %{domain_last} variables. They are both equal to %d normally, but differ when there are multiple '@' characters in the domain. diffstat: src/auth/auth-request.c | 11 +++++++++++ src/auth/auth-request.h | 2 +- 2 files changed, 12 insertions(+), 1 deletions(-) diffs (40 lines): diff -r e6c2a1344f86 -r 179f90dc0b1c src/auth/auth-request.c --- a/src/auth/auth-request.c Mon Aug 12 17:24:05 2013 +0300 +++ b/src/auth/auth-request.c Mon Aug 12 19:02:07 2013 +0300 @@ -1915,6 +1915,9 @@ { '\0', NULL, "real_rip" }, { '\0', NULL, "real_lport" }, { '\0', NULL, "real_rport" }, + { '\0', NULL, "domain_first" }, + { '\0', NULL, "domain_last" }, + /* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */ { '\0', NULL, NULL } }; @@ -1991,6 +1994,14 @@ tab[20].value = net_ip2addr(&auth_request->real_remote_ip); tab[21].value = dec2str(auth_request->real_local_port); tab[22].value = dec2str(auth_request->real_remote_port); + tab[23].value = strchr(auth_request->user, '@'); + if (tab[23].value != NULL) { + tab[23].value = escape_func(t_strcut(tab[23].value+1, '@'), + auth_request); + } + tab[24].value = strrchr(auth_request->user, '@'); + if (tab[24].value != NULL) + tab[24].value = escape_func(tab[24].value+1, auth_request); return ret_tab; } diff -r e6c2a1344f86 -r 179f90dc0b1c src/auth/auth-request.h --- a/src/auth/auth-request.h Mon Aug 12 17:24:05 2013 +0300 +++ b/src/auth/auth-request.h Mon Aug 12 19:02:07 2013 +0300 @@ -143,7 +143,7 @@ #define AUTH_REQUEST_VAR_TAB_USER_IDX 0 #define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1 #define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2 -#define AUTH_REQUEST_VAR_TAB_COUNT 23 +#define AUTH_REQUEST_VAR_TAB_COUNT 25 extern const struct var_expand_table auth_request_var_expand_static_tab[]; struct auth_request * From dovecot at dovecot.org Mon Aug 12 20:09:22 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 12 Aug 2013 20:09:22 +0300 Subject: dovecot-2.1: auth: Added %{domain_first} and %{domain_last} vari... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3029df20febc changeset: 14994:3029df20febc user: Timo Sirainen date: Mon Aug 12 20:09:09 2013 +0300 description: auth: Added %{domain_first} and %{domain_last} variables. They are both equal to %d normally, but differ when there are multiple '@' characters in the domain. diffstat: src/auth/auth-request.c | 11 +++++++++++ src/auth/auth-request.h | 2 +- 2 files changed, 12 insertions(+), 1 deletions(-) diffs (40 lines): diff -r c7832e75d2a8 -r 3029df20febc src/auth/auth-request.c --- a/src/auth/auth-request.c Wed Jun 12 22:03:07 2013 +0300 +++ b/src/auth/auth-request.c Mon Aug 12 20:09:09 2013 +0300 @@ -1831,6 +1831,9 @@ { '\0', NULL, "login_username" }, { '\0', NULL, "login_domain" }, { '\0', NULL, "session" }, + { '\0', NULL, "domain_first" }, + { '\0', NULL, "domain_last" }, + /* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */ { '\0', NULL, NULL } }; @@ -1901,6 +1904,14 @@ } tab[18].value = auth_request->session_id == NULL ? NULL : escape_func(auth_request->session_id, auth_request); + tab[19].value = strchr(auth_request->user, '@'); + if (tab[19].value != NULL) { + tab[19].value = escape_func(t_strcut(tab[19].value+1, '@'), + auth_request); + } + tab[20].value = strrchr(auth_request->user, '@'); + if (tab[20].value != NULL) + tab[20].value = escape_func(tab[20].value+1, auth_request); return ret_tab; } diff -r c7832e75d2a8 -r 3029df20febc src/auth/auth-request.h --- a/src/auth/auth-request.h Wed Jun 12 22:03:07 2013 +0300 +++ b/src/auth/auth-request.h Mon Aug 12 20:09:09 2013 +0300 @@ -128,7 +128,7 @@ #define AUTH_REQUEST_VAR_TAB_USER_IDX 0 #define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1 #define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2 -#define AUTH_REQUEST_VAR_TAB_COUNT 19 +#define AUTH_REQUEST_VAR_TAB_COUNT 21 extern const struct var_expand_table auth_request_var_expand_static_tab[]; struct auth_request * From dovecot at dovecot.org Tue Aug 13 21:00:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Aug 2013 21:00:07 +0300 Subject: dovecot-2.2: lib-lda: Don't alow %variables for hostname setting... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/72ce58d50d2c changeset: 16691:72ce58d50d2c user: Timo Sirainen date: Tue Aug 13 20:57:41 2013 +0300 description: lib-lda: Don't alow %variables for hostname setting after all. I was thinking maybe %d could be used there, but with LMTP the hostname is used already in the greeting message before any RCPT TO is even done. diffstat: src/lib-lda/lda-settings.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 179f90dc0b1c -r 72ce58d50d2c src/lib-lda/lda-settings.c --- a/src/lib-lda/lda-settings.c Mon Aug 12 19:02:07 2013 +0300 +++ b/src/lib-lda/lda-settings.c Tue Aug 13 20:57:41 2013 +0300 @@ -19,7 +19,7 @@ static const struct setting_define lda_setting_defines[] = { DEF(SET_STR_VARS, postmaster_address), - DEF(SET_STR_VARS, hostname), + DEF(SET_STR, hostname), DEF(SET_STR_VARS, submission_host), DEF(SET_STR_VARS, sendmail_path), DEF(SET_STR, rejection_subject), From dovecot at dovecot.org Tue Aug 13 21:00:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Aug 2013 21:00:07 +0300 Subject: dovecot-2.2: lib-lda: Default postmaster_address wasn't being set. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/40110f35ca64 changeset: 16692:40110f35ca64 user: Timo Sirainen date: Tue Aug 13 20:58:56 2013 +0300 description: lib-lda: Default postmaster_address wasn't being set. This broke after it was set to allow %variables. diffstat: src/lib-lda/lda-settings.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (23 lines): diff -r 72ce58d50d2c -r 40110f35ca64 src/lib-lda/lda-settings.c --- a/src/lib-lda/lda-settings.c Tue Aug 13 20:57:41 2013 +0300 +++ b/src/lib-lda/lda-settings.c Tue Aug 13 20:58:56 2013 +0300 @@ -77,14 +77,16 @@ if (*set->hostname == '\0') set->hostname = p_strdup(pool, my_hostdomain()); - if (*set->postmaster_address == '\0') { + i_assert(set->postmaster_address[0] == SETTING_STRVAR_UNEXPANDED[0]); + if (set->postmaster_address[1] == '\0') { /* check for valid looking fqdn in hostname */ if (strchr(set->hostname, '.') == NULL) { *error_r = "postmaster_address setting not given"; return FALSE; } - set->postmaster_address = p_strconcat(pool, "postmaster@", - set->hostname, NULL); + set->postmaster_address = + p_strconcat(pool, SETTING_STRVAR_UNEXPANDED, + "postmaster@", set->hostname, NULL); } return TRUE; } From dovecot at dovecot.org Tue Aug 13 21:00:07 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Aug 2013 21:00:07 +0300 Subject: dovecot-2.2: Minor change to prevent invalid code changes. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/2cbf5d7c7e4c changeset: 16693:2cbf5d7c7e4c user: Timo Sirainen date: Tue Aug 13 20:59:39 2013 +0300 description: Minor change to prevent invalid code changes. diffstat: src/auth/auth-request.c | 3 ++- src/auth/auth-request.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diffs (26 lines): diff -r 40110f35ca64 -r 2cbf5d7c7e4c src/auth/auth-request.c --- a/src/auth/auth-request.c Tue Aug 13 20:58:56 2013 +0300 +++ b/src/auth/auth-request.c Tue Aug 13 20:59:39 2013 +0300 @@ -1891,7 +1891,8 @@ return str_escape(string); } -const struct var_expand_table auth_request_var_expand_static_tab[] = { +const struct var_expand_table +auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1] = { { 'u', NULL, "user" }, { 'n', NULL, "username" }, { 'd', NULL, "domain" }, diff -r 40110f35ca64 -r 2cbf5d7c7e4c src/auth/auth-request.h --- a/src/auth/auth-request.h Tue Aug 13 20:58:56 2013 +0300 +++ b/src/auth/auth-request.h Tue Aug 13 20:59:39 2013 +0300 @@ -144,7 +144,8 @@ #define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1 #define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2 #define AUTH_REQUEST_VAR_TAB_COUNT 25 -extern const struct var_expand_table auth_request_var_expand_static_tab[]; +extern const struct var_expand_table +auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1]; struct auth_request * auth_request_new(const struct mech_module *mech); From dovecot at dovecot.org Tue Aug 13 21:02:13 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 13 Aug 2013 21:02:13 +0300 Subject: dovecot-2.2: lmtp: Make it clear that the lda_settings is unexpa... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ec62ea3c940e changeset: 16694:ec62ea3c940e user: Timo Sirainen date: Tue Aug 13 21:02:04 2013 +0300 description: lmtp: Make it clear that the lda_settings is unexpanded in struct client. diffstat: src/lmtp/client.c | 4 ++-- src/lmtp/client.h | 2 +- src/lmtp/commands.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diffs (68 lines): diff -r 2cbf5d7c7e4c -r ec62ea3c940e src/lmtp/client.c --- a/src/lmtp/client.c Tue Aug 13 20:59:39 2013 +0300 +++ b/src/lmtp/client.c Tue Aug 13 21:02:04 2013 +0300 @@ -175,7 +175,7 @@ mail_storage_service_get_var_expand_table(storage_service, &input)); client->service_set = master_service_settings_get(master_service); client->lmtp_set = lmtp_set; - client->set = lda_set; + client->unexpanded_lda_set = lda_set; } static void client_generate_session_id(struct client *client) @@ -241,7 +241,7 @@ client_read_settings(client); client_raw_user_create(client); client_generate_session_id(client); - client->my_domain = client->set->hostname; + client->my_domain = client->unexpanded_lda_set->hostname; client->lhlo = i_strdup("missing"); client->proxy_ttl = LMTP_PROXY_DEFAULT_TTL; diff -r 2cbf5d7c7e4c -r ec62ea3c940e src/lmtp/client.h --- a/src/lmtp/client.h Tue Aug 13 20:59:39 2013 +0300 +++ b/src/lmtp/client.h Tue Aug 13 21:02:04 2013 +0300 @@ -41,7 +41,7 @@ pool_t pool; const struct setting_parser_info *user_set_info; - const struct lda_settings *set; + const struct lda_settings *unexpanded_lda_set; const struct lmtp_settings *lmtp_set; const struct master_service_settings *service_set; int fd_in, fd_out; diff -r 2cbf5d7c7e4c -r ec62ea3c940e src/lmtp/commands.c --- a/src/lmtp/commands.c Tue Aug 13 20:59:39 2013 +0300 +++ b/src/lmtp/commands.c Tue Aug 13 21:02:04 2013 +0300 @@ -222,7 +222,7 @@ address_add_detail(struct client *client, const char *username, const char *detail) { - const char *delim = client->set->recipient_delimiter; + const char *delim = client->unexpanded_lda_set->recipient_delimiter; const char *domain; domain = strchr(username, '@'); @@ -317,7 +317,7 @@ struct lmtp_proxy_settings proxy_set; memset(&proxy_set, 0, sizeof(proxy_set)); - proxy_set.my_hostname = client->set->hostname; + proxy_set.my_hostname = client->my_domain; proxy_set.dns_client_socket_path = dns_client_socket_path; proxy_set.session_id = client->state.session_id; proxy_set.source_ip = client->remote_ip; @@ -383,11 +383,11 @@ *username_r = address; *detail_r = ""; - if (*client->set->recipient_delimiter == '\0') + if (*client->unexpanded_lda_set->recipient_delimiter == '\0') return; domain = strchr(address, '@'); - p = strstr(address, client->set->recipient_delimiter); + p = strstr(address, client->unexpanded_lda_set->recipient_delimiter); if (p != NULL && (domain == NULL || p < domain)) { /* user+detail at domain */ *username_r = t_strdup_until(*username_r, p); From dovecot at dovecot.org Thu Aug 15 20:25:27 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Aug 2013 20:25:27 +0300 Subject: dovecot-2.1: director: Previous change caused legitimate SYNC re... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d463fab6db95 changeset: 14995:d463fab6db95 user: Timo Sirainen date: Thu Aug 15 20:25:12 2013 +0300 description: director: Previous change caused legitimate SYNC resends to be ignored. diffstat: src/director/director-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3029df20febc -r d463fab6db95 src/director/director-connection.c --- a/src/director/director-connection.c Mon Aug 12 20:09:09 2013 +0300 +++ b/src/director/director-connection.c Thu Aug 15 20:25:12 2013 +0300 @@ -1124,7 +1124,7 @@ /* stale SYNC event */ return FALSE; } else if (host->last_sync_seq != seq || - timestamp < host->last_sync_timestamp) { + timestamp > host->last_sync_timestamp) { host->last_sync_seq = seq; host->last_sync_timestamp = timestamp; host->last_sync_seq_counter = 1; From dovecot at dovecot.org Thu Aug 15 20:25:47 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 15 Aug 2013 20:25:47 +0300 Subject: dovecot-2.2: director: Previous change caused legitimate SYNC re... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f7a37b169f4a changeset: 16695:f7a37b169f4a user: Timo Sirainen date: Thu Aug 15 20:25:12 2013 +0300 description: director: Previous change caused legitimate SYNC resends to be ignored. diffstat: src/director/director-connection.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r ec62ea3c940e -r f7a37b169f4a src/director/director-connection.c --- a/src/director/director-connection.c Tue Aug 13 21:02:04 2013 +0300 +++ b/src/director/director-connection.c Thu Aug 15 20:25:12 2013 +0300 @@ -1124,7 +1124,7 @@ /* stale SYNC event */ return FALSE; } else if (host->last_sync_seq != seq || - timestamp < host->last_sync_timestamp) { + timestamp > host->last_sync_timestamp) { host->last_sync_seq = seq; host->last_sync_timestamp = timestamp; host->last_sync_seq_counter = 1; From pigeonhole at rename-it.nl Thu Aug 15 22:04:31 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 15 Aug 2013 21:04:31 +0200 Subject: dovecot-2.1-pigeonhole: Various fixes for CLang warnings. Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/e57214510465 changeset: 1694:e57214510465 user: Stephan Bosch date: Thu Aug 15 21:02:37 2013 +0200 description: Various fixes for CLang warnings. Patch by Timo Sirainen (modified). diffstat: src/lib-sieve/ext-envelope.c | 3 ++- src/lib-sieve/sieve-address.c | 3 ++- src/lib-sieve/sieve-validator.c | 12 +++++++----- src/managesieve-login/client-authenticate.c | 5 ++--- src/testsuite/testsuite-objects.c | 4 ++-- src/testsuite/testsuite.c | 1 + 6 files changed, 16 insertions(+), 12 deletions(-) diffs (116 lines): diff -r 53ee9655e78e -r e57214510465 src/lib-sieve/ext-envelope.c --- a/src/lib-sieve/ext-envelope.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/lib-sieve/ext-envelope.c Thu Aug 15 21:02:37 2013 +0200 @@ -411,7 +411,8 @@ if ( addr.local_part != NULL ) { const char *addr_str = sieve_address_to_string(&addr); - *str_r = t_str_new_const(addr_str, strlen(addr_str)); + if (str_r != NULL) + *str_r = t_str_new_const(addr_str, strlen(addr_str)); } return 1; diff -r 53ee9655e78e -r e57214510465 src/lib-sieve/sieve-address.c --- a/src/lib-sieve/sieve-address.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/lib-sieve/sieve-address.c Thu Aug 15 21:02:37 2013 +0200 @@ -144,7 +144,8 @@ if ( addr.local_part != NULL ) { const char *addr_str = sieve_address_to_string(&addr); - *str_r = t_str_new_const(addr_str, strlen(addr_str)); + if ( str_r != NULL ) + *str_r = t_str_new_const(addr_str, strlen(addr_str)); } return 1; diff -r 53ee9655e78e -r e57214510465 src/lib-sieve/sieve-validator.c --- a/src/lib-sieve/sieve-validator.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/lib-sieve/sieve-validator.c Thu Aug 15 21:02:37 2013 +0200 @@ -547,11 +547,13 @@ struct sieve_validator_extension_reg *reg; if ( ext->global && (valdtr->flags & SIEVE_COMPILE_FLAG_NOGLOBAL) != 0 ) { - sieve_argument_validate_error(valdtr, ext_arg, - "%s %s: failed to load Sieve capability `%s': " - "its use is restricted to global scripts", - sieve_command_identifier(cmd), sieve_command_type_name(cmd), - sieve_extension_name(ext)); + if ( cmd != NULL && ext_arg != NULL ) { + sieve_argument_validate_error(valdtr, ext_arg, + "%s %s: failed to load Sieve capability `%s': " + "its use is restricted to global scripts", + sieve_command_identifier(cmd), sieve_command_type_name(cmd), + sieve_extension_name(ext)); + } return FALSE; } diff -r 53ee9655e78e -r e57214510465 src/managesieve-login/client-authenticate.c --- a/src/managesieve-login/client-authenticate.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/managesieve-login/client-authenticate.c Thu Aug 15 21:02:37 2013 +0200 @@ -152,6 +152,8 @@ uoff_t resp_size; int ret; + *error_r = NULL; + if ( i_stream_read(client->input) == -1 ) { /* disconnected */ client_destroy(client, "Disconnected"); @@ -175,7 +177,6 @@ client_send_bye(client, error); client_destroy(client, t_strconcat ("Disconnected: parse error during auth: ", error, NULL)); - *error_r = NULL; } else { *error_r = error; } @@ -224,7 +225,6 @@ if (str_len(client->auth_response) + size > LOGIN_MAX_AUTH_BUF_SIZE) { client_destroy(client, "Authentication response too large"); - *error_r = NULL; return -1; } @@ -242,7 +242,6 @@ client_send_bye(client, error); client_destroy(client, t_strconcat ("Disconnected: parse error during auth: ", error, NULL)); - *error_r = NULL; } else { msieve_client->skip_line = TRUE; *error_r = t_strconcat diff -r 53ee9655e78e -r e57214510465 src/testsuite/testsuite-objects.c --- a/src/testsuite/testsuite-objects.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/testsuite/testsuite-objects.c Thu Aug 15 21:02:37 2013 +0200 @@ -135,7 +135,7 @@ return FALSE; tobj->def = (const struct testsuite_object_def *) tobj->object.def; - + i_assert(tobj->def != NULL); return TRUE; } @@ -147,7 +147,7 @@ return FALSE; *member_id_r = -1; - if ( tobj->def != NULL && tobj->def->get_member_id != NULL ) { + if ( tobj->def->get_member_id != NULL ) { if ( !sieve_binary_read_code(sblock, address, member_id_r) ) return FALSE; } diff -r 53ee9655e78e -r e57214510465 src/testsuite/testsuite.c --- a/src/testsuite/testsuite.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/testsuite/testsuite.c Thu Aug 15 21:02:37 2013 +0200 @@ -216,6 +216,7 @@ if ( tracestream != NULL ) o_stream_unref(&tracestream); + testsuite_scriptenv = NULL; } else { testsuite_testcase_fail("failed to compile testcase script"); } From pigeonhole at rename-it.nl Thu Aug 15 22:08:47 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 15 Aug 2013 21:08:47 +0200 Subject: dovecot-2.2-pigeonhole: lib-sieve: include extension: Fixed impl... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/bb5fa32f87bc changeset: 1791:bb5fa32f87bc user: Stephan Bosch date: Thu Aug 15 20:48:54 2013 +0200 description: lib-sieve: include extension: Fixed implementation of new :options flag. Mixed up pre-existing boolean once parameter with new flags parameter. This probably means that :optional partially implied :once for previous revisions. diffstat: src/lib-sieve/plugins/include/cmd-include.c | 5 +++-- src/lib-sieve/plugins/include/ext-include-common.c | 7 ++++--- src/lib-sieve/plugins/include/ext-include-common.h | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diffs (61 lines): diff -r 0e7b22c65147 -r bb5fa32f87bc src/lib-sieve/plugins/include/cmd-include.c --- a/src/lib-sieve/plugins/include/cmd-include.c Thu Aug 15 20:15:08 2013 +0200 +++ b/src/lib-sieve/plugins/include/cmd-include.c Thu Aug 15 20:48:54 2013 +0200 @@ -364,9 +364,10 @@ return FALSE; sieve_code_descend(denv); - sieve_code_dumpf(denv, "script: `%s' from %s %s[ID: %d, BLOCK: %d]", + sieve_code_dumpf(denv, "script: `%s' from %s %s%s[ID: %d, BLOCK: %d]", sieve_script_name(included->script), sieve_script_location(included->script), - (flags & 0x01 ? "(once) " : ""), include_id, + (flags & EXT_INCLUDE_FLAG_ONCE ? "(once) " : ""), + (flags & EXT_INCLUDE_FLAG_OPTIONAL ? "(optional) " : ""), include_id, sieve_binary_block_get_id(included->block)); return TRUE; diff -r 0e7b22c65147 -r bb5fa32f87bc src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Thu Aug 15 20:15:08 2013 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Thu Aug 15 20:48:54 2013 +0200 @@ -520,9 +520,8 @@ /* 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 + if ( (flags & EXT_INCLUDE_FLAG_ONCE) == 0 ) flags &= ~EXT_INCLUDE_FLAG_ONCE; - } else { const char *script_name = sieve_script_name(script); enum sieve_compile_flags cpflags = cgenv->flags; @@ -648,7 +647,8 @@ } int ext_include_execute_include -(const struct sieve_runtime_env *renv, unsigned int include_id, bool once) +(const struct sieve_runtime_env *renv, unsigned int include_id, + enum ext_include_flags flags) { const struct sieve_extension *this_ext = renv->oprtn->ext; int result = SIEVE_EXEC_OK; @@ -656,6 +656,7 @@ const struct ext_include_script_info *included; struct ext_include_binary_context *binctx = ext_include_binary_get_context(this_ext, renv->sbin); + bool once = ( (flags & EXT_INCLUDE_FLAG_ONCE) != 0 ); unsigned int block_id; /* Check for invalid include id (== corrupt binary) */ diff -r 0e7b22c65147 -r bb5fa32f87bc src/lib-sieve/plugins/include/ext-include-common.h --- a/src/lib-sieve/plugins/include/ext-include-common.h Thu Aug 15 20:15:08 2013 +0200 +++ b/src/lib-sieve/plugins/include/ext-include-common.h Thu Aug 15 20:48:54 2013 +0200 @@ -160,7 +160,8 @@ (const struct sieve_extension *this_ext, struct sieve_interpreter *interp); int ext_include_execute_include - (const struct sieve_runtime_env *renv, unsigned int block_id, bool once); + (const struct sieve_runtime_env *renv, unsigned int block_id, + enum ext_include_flags flags); void ext_include_execute_return(const struct sieve_runtime_env *renv); struct sieve_variable_storage *ext_include_interpreter_get_global_variables From pigeonhole at rename-it.nl Thu Aug 15 22:08:47 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 15 Aug 2013 21:08:47 +0200 Subject: dovecot-2.2-pigeonhole: Various fixes for CLang warnings. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/e57214510465 changeset: 1792:e57214510465 user: Stephan Bosch date: Thu Aug 15 21:02:37 2013 +0200 description: Various fixes for CLang warnings. Patch by Timo Sirainen (modified). diffstat: src/lib-sieve/ext-envelope.c | 3 ++- src/lib-sieve/sieve-address.c | 3 ++- src/lib-sieve/sieve-validator.c | 12 +++++++----- src/managesieve-login/client-authenticate.c | 5 ++--- src/testsuite/testsuite-objects.c | 4 ++-- src/testsuite/testsuite.c | 1 + 6 files changed, 16 insertions(+), 12 deletions(-) diffs (116 lines): diff -r 53ee9655e78e -r e57214510465 src/lib-sieve/ext-envelope.c --- a/src/lib-sieve/ext-envelope.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/lib-sieve/ext-envelope.c Thu Aug 15 21:02:37 2013 +0200 @@ -411,7 +411,8 @@ if ( addr.local_part != NULL ) { const char *addr_str = sieve_address_to_string(&addr); - *str_r = t_str_new_const(addr_str, strlen(addr_str)); + if (str_r != NULL) + *str_r = t_str_new_const(addr_str, strlen(addr_str)); } return 1; diff -r 53ee9655e78e -r e57214510465 src/lib-sieve/sieve-address.c --- a/src/lib-sieve/sieve-address.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/lib-sieve/sieve-address.c Thu Aug 15 21:02:37 2013 +0200 @@ -144,7 +144,8 @@ if ( addr.local_part != NULL ) { const char *addr_str = sieve_address_to_string(&addr); - *str_r = t_str_new_const(addr_str, strlen(addr_str)); + if ( str_r != NULL ) + *str_r = t_str_new_const(addr_str, strlen(addr_str)); } return 1; diff -r 53ee9655e78e -r e57214510465 src/lib-sieve/sieve-validator.c --- a/src/lib-sieve/sieve-validator.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/lib-sieve/sieve-validator.c Thu Aug 15 21:02:37 2013 +0200 @@ -547,11 +547,13 @@ struct sieve_validator_extension_reg *reg; if ( ext->global && (valdtr->flags & SIEVE_COMPILE_FLAG_NOGLOBAL) != 0 ) { - sieve_argument_validate_error(valdtr, ext_arg, - "%s %s: failed to load Sieve capability `%s': " - "its use is restricted to global scripts", - sieve_command_identifier(cmd), sieve_command_type_name(cmd), - sieve_extension_name(ext)); + if ( cmd != NULL && ext_arg != NULL ) { + sieve_argument_validate_error(valdtr, ext_arg, + "%s %s: failed to load Sieve capability `%s': " + "its use is restricted to global scripts", + sieve_command_identifier(cmd), sieve_command_type_name(cmd), + sieve_extension_name(ext)); + } return FALSE; } diff -r 53ee9655e78e -r e57214510465 src/managesieve-login/client-authenticate.c --- a/src/managesieve-login/client-authenticate.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/managesieve-login/client-authenticate.c Thu Aug 15 21:02:37 2013 +0200 @@ -152,6 +152,8 @@ uoff_t resp_size; int ret; + *error_r = NULL; + if ( i_stream_read(client->input) == -1 ) { /* disconnected */ client_destroy(client, "Disconnected"); @@ -175,7 +177,6 @@ client_send_bye(client, error); client_destroy(client, t_strconcat ("Disconnected: parse error during auth: ", error, NULL)); - *error_r = NULL; } else { *error_r = error; } @@ -224,7 +225,6 @@ if (str_len(client->auth_response) + size > LOGIN_MAX_AUTH_BUF_SIZE) { client_destroy(client, "Authentication response too large"); - *error_r = NULL; return -1; } @@ -242,7 +242,6 @@ client_send_bye(client, error); client_destroy(client, t_strconcat ("Disconnected: parse error during auth: ", error, NULL)); - *error_r = NULL; } else { msieve_client->skip_line = TRUE; *error_r = t_strconcat diff -r 53ee9655e78e -r e57214510465 src/testsuite/testsuite-objects.c --- a/src/testsuite/testsuite-objects.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/testsuite/testsuite-objects.c Thu Aug 15 21:02:37 2013 +0200 @@ -135,7 +135,7 @@ return FALSE; tobj->def = (const struct testsuite_object_def *) tobj->object.def; - + i_assert(tobj->def != NULL); return TRUE; } @@ -147,7 +147,7 @@ return FALSE; *member_id_r = -1; - if ( tobj->def != NULL && tobj->def->get_member_id != NULL ) { + if ( tobj->def->get_member_id != NULL ) { if ( !sieve_binary_read_code(sblock, address, member_id_r) ) return FALSE; } diff -r 53ee9655e78e -r e57214510465 src/testsuite/testsuite.c --- a/src/testsuite/testsuite.c Tue Jun 18 22:04:50 2013 +0200 +++ b/src/testsuite/testsuite.c Thu Aug 15 21:02:37 2013 +0200 @@ -216,6 +216,7 @@ if ( tracestream != NULL ) o_stream_unref(&tracestream); + testsuite_scriptenv = NULL; } else { testsuite_testcase_fail("failed to compile testcase script"); } From pigeonhole at rename-it.nl Thu Aug 15 22:08:47 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 15 Aug 2013 21:08:47 +0200 Subject: dovecot-2.2-pigeonhole: Merged changes from Pigeonhole v0.3 tree. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/09ce20eaa1c2 changeset: 1793:09ce20eaa1c2 user: Stephan Bosch date: Thu Aug 15 21:07:56 2013 +0200 description: Merged changes from Pigeonhole v0.3 tree. diffstat: src/lib-sieve/ext-envelope.c | 3 ++- src/lib-sieve/sieve-address.c | 3 ++- src/lib-sieve/sieve-validator.c | 12 +++++++----- src/managesieve-login/client-authenticate.c | 5 ++--- src/testsuite/testsuite-objects.c | 4 ++-- src/testsuite/testsuite.c | 1 + 6 files changed, 16 insertions(+), 12 deletions(-) diffs (116 lines): diff -r bb5fa32f87bc -r 09ce20eaa1c2 src/lib-sieve/ext-envelope.c --- a/src/lib-sieve/ext-envelope.c Thu Aug 15 20:48:54 2013 +0200 +++ b/src/lib-sieve/ext-envelope.c Thu Aug 15 21:07:56 2013 +0200 @@ -408,7 +408,8 @@ if ( addr.local_part != NULL ) { const char *addr_str = sieve_address_to_string(&addr); - *str_r = t_str_new_const(addr_str, strlen(addr_str)); + if (str_r != NULL) + *str_r = t_str_new_const(addr_str, strlen(addr_str)); } return 1; diff -r bb5fa32f87bc -r 09ce20eaa1c2 src/lib-sieve/sieve-address.c --- a/src/lib-sieve/sieve-address.c Thu Aug 15 20:48:54 2013 +0200 +++ b/src/lib-sieve/sieve-address.c Thu Aug 15 21:07:56 2013 +0200 @@ -144,7 +144,8 @@ if ( addr.local_part != NULL ) { const char *addr_str = sieve_address_to_string(&addr); - *str_r = t_str_new_const(addr_str, strlen(addr_str)); + if ( str_r != NULL ) + *str_r = t_str_new_const(addr_str, strlen(addr_str)); } return 1; diff -r bb5fa32f87bc -r 09ce20eaa1c2 src/lib-sieve/sieve-validator.c --- a/src/lib-sieve/sieve-validator.c Thu Aug 15 20:48:54 2013 +0200 +++ b/src/lib-sieve/sieve-validator.c Thu Aug 15 21:07:56 2013 +0200 @@ -546,11 +546,13 @@ struct sieve_validator_extension_reg *reg; if ( ext->global && (valdtr->flags & SIEVE_COMPILE_FLAG_NOGLOBAL) != 0 ) { - sieve_argument_validate_error(valdtr, ext_arg, - "%s %s: failed to load Sieve capability `%s': " - "its use is restricted to global scripts", - sieve_command_identifier(cmd), sieve_command_type_name(cmd), - sieve_extension_name(ext)); + if ( cmd != NULL && ext_arg != NULL ) { + sieve_argument_validate_error(valdtr, ext_arg, + "%s %s: failed to load Sieve capability `%s': " + "its use is restricted to global scripts", + sieve_command_identifier(cmd), sieve_command_type_name(cmd), + sieve_extension_name(ext)); + } return FALSE; } diff -r bb5fa32f87bc -r 09ce20eaa1c2 src/managesieve-login/client-authenticate.c --- a/src/managesieve-login/client-authenticate.c Thu Aug 15 20:48:54 2013 +0200 +++ b/src/managesieve-login/client-authenticate.c Thu Aug 15 21:07:56 2013 +0200 @@ -138,6 +138,8 @@ uoff_t resp_size; int ret; + *error_r = NULL; + if ( i_stream_read(client->input) == -1 ) { /* disconnected */ client_destroy(client, "Disconnected"); @@ -161,7 +163,6 @@ client_send_bye(client, error); client_destroy(client, t_strconcat ("Disconnected: parse error during auth: ", error, NULL)); - *error_r = NULL; } else { *error_r = error; } @@ -210,7 +211,6 @@ if (str_len(client->auth_response) + size > LOGIN_MAX_AUTH_BUF_SIZE) { client_destroy(client, "Authentication response too large"); - *error_r = NULL; return -1; } @@ -228,7 +228,6 @@ client_send_bye(client, error); client_destroy(client, t_strconcat ("Disconnected: parse error during auth: ", error, NULL)); - *error_r = NULL; } else { msieve_client->skip_line = TRUE; *error_r = t_strconcat diff -r bb5fa32f87bc -r 09ce20eaa1c2 src/testsuite/testsuite-objects.c --- a/src/testsuite/testsuite-objects.c Thu Aug 15 20:48:54 2013 +0200 +++ b/src/testsuite/testsuite-objects.c Thu Aug 15 21:07:56 2013 +0200 @@ -135,7 +135,7 @@ return FALSE; tobj->def = (const struct testsuite_object_def *) tobj->object.def; - + i_assert(tobj->def != NULL); return TRUE; } @@ -147,7 +147,7 @@ return FALSE; *member_id_r = -1; - if ( tobj->def != NULL && tobj->def->get_member_id != NULL ) { + if ( tobj->def->get_member_id != NULL ) { if ( !sieve_binary_read_code(sblock, address, member_id_r) ) return FALSE; } diff -r bb5fa32f87bc -r 09ce20eaa1c2 src/testsuite/testsuite.c --- a/src/testsuite/testsuite.c Thu Aug 15 20:48:54 2013 +0200 +++ b/src/testsuite/testsuite.c Thu Aug 15 21:07:56 2013 +0200 @@ -215,6 +215,7 @@ if ( tracestream != NULL ) o_stream_unref(&tracestream); + testsuite_scriptenv = NULL; } else { testsuite_testcase_fail("failed to compile testcase script"); } From pigeonhole at rename-it.nl Thu Aug 15 22:08:47 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 15 Aug 2013 21:08:47 +0200 Subject: dovecot-2.2-pigeonhole: extprograms plugin: Compiler warning fix... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/2452dae5792f changeset: 1789:2452dae5792f user: Stephan Bosch date: Thu Aug 15 19:59:18 2013 +0200 description: extprograms plugin: Compiler warning fix for 32bit systems. Patch by Timo Sirainen. diffstat: src/plugins/sieve-extprograms/script-client-local.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r a6a1c041c209 -r 2452dae5792f src/plugins/sieve-extprograms/script-client-local.c --- a/src/plugins/sieve-extprograms/script-client-local.c Wed Jul 10 23:34:34 2013 +0200 +++ b/src/plugins/sieve-extprograms/script-client-local.c Thu Aug 15 19:59:18 2013 +0200 @@ -158,7 +158,7 @@ /* Calculate timeout */ runtime = ioloop_time - sclient->start_time; if ( !force && sclient->set->input_idle_timeout_secs > 0 && - runtime < sclient->set->input_idle_timeout_secs ) + runtime < (time_t)sclient->set->input_idle_timeout_secs ) timeout = sclient->set->input_idle_timeout_secs - runtime; if ( sclient->debug ) { From pigeonhole at rename-it.nl Thu Aug 15 22:08:47 2013 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 15 Aug 2013 21:08:47 +0200 Subject: dovecot-2.2-pigeonhole: lda-sieve plugin: Don't access already f... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/0e7b22c65147 changeset: 1790:0e7b22c65147 user: Stephan Bosch date: Thu Aug 15 20:15:08 2013 +0200 description: lda-sieve plugin: Don't access already freed memory when deinitializing. Patch by Timo Sirainen (modified). diffstat: src/plugins/lda-sieve/lda-sieve-plugin.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (19 lines): diff -r 2452dae5792f -r 0e7b22c65147 src/plugins/lda-sieve/lda-sieve-plugin.c --- a/src/plugins/lda-sieve/lda-sieve-plugin.c Thu Aug 15 19:59:18 2013 +0200 +++ b/src/plugins/lda-sieve/lda-sieve-plugin.c Thu Aug 15 20:15:08 2013 +0200 @@ -935,12 +935,13 @@ ret = -1; else ret = lda_sieve_execute(&srctx, storage_r); + + for ( i = 0; i < srctx.script_count; i++ ) + sieve_script_unref(&srctx.scripts[i]); } T_END; /* Clean up */ - for ( i = 0; i < srctx.script_count; i++ ) - sieve_script_unref(&srctx.scripts[i]); if ( srctx.user_ehandler != NULL ) sieve_error_handler_unref(&srctx.user_ehandler); sieve_error_handler_unref(&srctx.master_ehandler); From dovecot at dovecot.org Sat Aug 17 18:29:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 17 Aug 2013 18:29:25 +0300 Subject: dovecot-2.2: man: doveadm-pw.1: Option -p can also be used with -t. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/c4f754d6967e changeset: 16696:c4f754d6967e user: Pascal Volk date: Sat Aug 17 15:01:25 2013 +0000 description: man: doveadm-pw.1: Option -p can also be used with -t. diffstat: doc/man/doveadm-pw.1.in | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diffs (31 lines): diff -r f7a37b169f4a -r c4f754d6967e doc/man/doveadm-pw.1.in --- a/doc/man/doveadm-pw.1.in Thu Aug 15 20:25:12 2013 +0300 +++ b/doc/man/doveadm-pw.1.in Sat Aug 17 15:01:25 2013 +0000 @@ -1,5 +1,5 @@ -.\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file -.TH DOVEADM\-PW 1 "2012-02-13" "Dovecot v2.2" "Dovecot" +.\" Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file +.TH DOVEADM\-PW 1 "2013-08-17" "Dovecot v2.2" "Dovecot" .SH NAME doveadm\-pw \- Dovecot\(aqs password hash generator .\"------------------------------------------------------------------------ @@ -17,6 +17,7 @@ .br .BR doveadm " [" \-Dv "] " "pw \-t" .I hash +[\fB\-p\fP \fIpassword\fP] [\fB\-u\fP \fIuser\fP] .\"------------------------------------------------------------------------ .SH DESCRIPTION @@ -115,6 +116,11 @@ Test if the given password .IR hash matches a given plain text password. +The plain text password may be passed using the +.BR \-p " option." +When no password was specified, +.BR doveadm (1) +will prompt interactively for one. .\"------------------------------------- .TP .BI \-u\ user From dovecot at dovecot.org Wed Aug 21 19:41:04 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Aug 2013 19:41:04 +0300 Subject: dovecot-2.2: imap: Fixed potential assert crash in APPEND. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/0d966f8d53be changeset: 16697:0d966f8d53be user: Timo Sirainen date: Wed Aug 21 19:40:54 2013 +0300 description: imap: Fixed potential assert crash in APPEND. diffstat: src/imap/cmd-append.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (14 lines): diff -r c4f754d6967e -r 0d966f8d53be src/imap/cmd-append.c --- a/src/imap/cmd-append.c Sat Aug 17 15:01:25 2013 +0000 +++ b/src/imap/cmd-append.c Wed Aug 21 19:40:54 2013 +0300 @@ -829,7 +829,9 @@ /* finished - do one more read, to make sure istream-chain unreferences its stream, which is needed for litinput's unreferencing to seek the client->input to correct - position */ + position. the seek is needed to avoid trying to seek + backwards in the ctx->input's parent stream. */ + i_stream_seek(ctx->input, ctx->input->v_offset); (void)i_stream_read(ctx->input); i_stream_unref(&ctx->litinput); From dovecot at dovecot.org Wed Aug 21 20:03:21 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Aug 2013 20:03:21 +0300 Subject: dovecot-2.2: lib-storage: When doing a fast sync, refresh index ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/60b8746e6cfe changeset: 16698:60b8746e6cfe user: Timo Sirainen date: Wed Aug 21 20:03:13 2013 +0300 description: lib-storage: When doing a fast sync, refresh index to see if it had any changes. I'm pretty sure this used to be done earlier, but probably some optimizations dropped it at some point. diffstat: src/lib-storage/index/index-sync.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 0d966f8d53be -r 60b8746e6cfe src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Wed Aug 21 19:40:54 2013 +0300 +++ b/src/lib-storage/index/index-sync.c Wed Aug 21 20:03:13 2013 +0300 @@ -218,6 +218,11 @@ mail_index_view_get_messages_count(box->view); } + if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0) { + /* we most likely did a fast sync. refresh the index anyway in + case there were some new changes. */ + (void)mail_index_refresh(box->index); + } ctx->sync_ctx = mail_index_view_sync_begin(box->view, sync_flags); if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) { mail_index_view_sync_get_expunges(ctx->sync_ctx, From dovecot at dovecot.org Wed Aug 21 23:30:13 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Aug 2013 23:30:13 +0300 Subject: dovecot-2.1: director: Reset last-seen-sync-sequence after remot... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5d6cc3d03eee changeset: 14996:5d6cc3d03eee user: Timo Sirainen date: Wed Aug 21 23:30:07 2013 +0300 description: director: Reset last-seen-sync-sequence after remote director restarts. diffstat: src/director/director-connection.c | 6 +++--- src/director/director-host.c | 8 ++++++++ src/director/director-host.h | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diffs (60 lines): diff -r d463fab6db95 -r 5d6cc3d03eee src/director/director-connection.c --- a/src/director/director-connection.c Thu Aug 15 20:25:12 2013 +0300 +++ b/src/director/director-connection.c Wed Aug 21 23:30:07 2013 +0300 @@ -406,7 +406,7 @@ conn->host->removed = FALSE; director_host_ref(conn->host); /* make sure we don't keep old sequence values across restarts */ - conn->host->last_seq = 0; + director_host_restarted(conn->host); next_comm_attempt = conn->host->last_protocol_failure + DIRECTOR_PROTOCOL_FAILURE_RETRY_SECS; @@ -646,7 +646,7 @@ host->last_network_failure = 0; if (host->last_seq != 0) { /* it also may have been restarted, reset last_seq */ - host->last_seq = 0; + director_host_restarted(host); forward = TRUE; } } else { @@ -1593,7 +1593,7 @@ i_assert(!host->removed); /* make sure we don't keep old sequence values across restarts */ - host->last_seq = 0; + director_host_restarted(host); conn = director_connection_init_common(dir, fd); conn->name = i_strdup_printf("%s/out", host->name); diff -r d463fab6db95 -r 5d6cc3d03eee src/director/director-host.c --- a/src/director/director-host.c Thu Aug 15 20:25:12 2013 +0300 +++ b/src/director/director-host.c Wed Aug 21 23:30:07 2013 +0300 @@ -80,6 +80,14 @@ i_free(host); } +void director_host_restarted(struct director_host *host) +{ + host->last_seq = 0; + host->last_sync_seq = 0; + host->last_sync_seq_counter = 0; + host->last_sync_timestamp = 0; +} + struct director_host * director_host_get(struct director *dir, const struct ip_addr *ip, unsigned int port) diff -r d463fab6db95 -r 5d6cc3d03eee src/director/director-host.h --- a/src/director/director-host.h Thu Aug 15 20:25:12 2013 +0300 +++ b/src/director/director-host.h Wed Aug 21 23:30:07 2013 +0300 @@ -39,6 +39,8 @@ void director_host_ref(struct director_host *host); void director_host_unref(struct director_host *host); +void director_host_restarted(struct director_host *host); + struct director_host * director_host_get(struct director *dir, const struct ip_addr *ip, unsigned int port); From dovecot at dovecot.org Wed Aug 21 23:30:32 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 21 Aug 2013 23:30:32 +0300 Subject: dovecot-2.2: director: Reset last-seen-sync-sequence after remot... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9531ec8afe8b changeset: 16699:9531ec8afe8b user: Timo Sirainen date: Wed Aug 21 23:30:07 2013 +0300 description: director: Reset last-seen-sync-sequence after remote director restarts. diffstat: src/director/director-connection.c | 6 +++--- src/director/director-host.c | 8 ++++++++ src/director/director-host.h | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diffs (60 lines): diff -r 60b8746e6cfe -r 9531ec8afe8b src/director/director-connection.c --- a/src/director/director-connection.c Wed Aug 21 20:03:13 2013 +0300 +++ b/src/director/director-connection.c Wed Aug 21 23:30:07 2013 +0300 @@ -405,7 +405,7 @@ conn->host->removed = FALSE; director_host_ref(conn->host); /* make sure we don't keep old sequence values across restarts */ - conn->host->last_seq = 0; + director_host_restarted(conn->host); next_comm_attempt = conn->host->last_protocol_failure + DIRECTOR_PROTOCOL_FAILURE_RETRY_SECS; @@ -646,7 +646,7 @@ host->last_network_failure = 0; if (host->last_seq != 0) { /* it also may have been restarted, reset last_seq */ - host->last_seq = 0; + director_host_restarted(host); forward = TRUE; } } else { @@ -1591,7 +1591,7 @@ i_assert(!host->removed); /* make sure we don't keep old sequence values across restarts */ - host->last_seq = 0; + director_host_restarted(host); conn = director_connection_init_common(dir, fd); conn->name = i_strdup_printf("%s/out", host->name); diff -r 60b8746e6cfe -r 9531ec8afe8b src/director/director-host.c --- a/src/director/director-host.c Wed Aug 21 20:03:13 2013 +0300 +++ b/src/director/director-host.c Wed Aug 21 23:30:07 2013 +0300 @@ -80,6 +80,14 @@ i_free(host); } +void director_host_restarted(struct director_host *host) +{ + host->last_seq = 0; + host->last_sync_seq = 0; + host->last_sync_seq_counter = 0; + host->last_sync_timestamp = 0; +} + struct director_host * director_host_get(struct director *dir, const struct ip_addr *ip, unsigned int port) diff -r 60b8746e6cfe -r 9531ec8afe8b src/director/director-host.h --- a/src/director/director-host.h Wed Aug 21 20:03:13 2013 +0300 +++ b/src/director/director-host.h Wed Aug 21 23:30:07 2013 +0300 @@ -39,6 +39,8 @@ void director_host_ref(struct director_host *host); void director_host_unref(struct director_host *host); +void director_host_restarted(struct director_host *host); + struct director_host * director_host_get(struct director *dir, const struct ip_addr *ip, unsigned int port); From dovecot at dovecot.org Tue Aug 27 04:06:50 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 Aug 2013 04:06:50 +0300 Subject: dovecot-2.2: dbox: When fixing a broken file, try harder to find... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f965670a7b69 changeset: 16700:f965670a7b69 user: Timo Sirainen date: Tue Aug 27 04:06:43 2013 +0300 description: dbox: When fixing a broken file, try harder to find only valid message/metadata positions. The previous method sometime broke with compressed mail content, because the magic blocks were so short. diffstat: src/lib-storage/index/dbox-common/dbox-file-fix.c | 206 ++++++++++++++++++--- src/lib-storage/index/dbox-common/dbox-file.h | 2 + 2 files changed, 177 insertions(+), 31 deletions(-) diffs (264 lines): diff -r 9531ec8afe8b -r f965670a7b69 src/lib-storage/index/dbox-common/dbox-file-fix.c --- a/src/lib-storage/index/dbox-common/dbox-file-fix.c Wed Aug 21 23:30:07 2013 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c Tue Aug 27 04:06:43 2013 +0300 @@ -1,9 +1,9 @@ /* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "hex-dec.h" #include "istream.h" #include "ostream.h" -#include "str-find.h" #include "message-size.h" #include "dbox-storage.h" #include "dbox-file.h" @@ -13,38 +13,187 @@ #define DBOX_MAIL_FILE_BROKEN_COPY_SUFFIX ".broken" static int +dbox_file_match_pre_magic(struct istream *input, + uoff_t *pre_offset, size_t *need_bytes) +{ + const struct dbox_message_header *hdr; + const unsigned char *data; + size_t size; + uoff_t offset = input->v_offset; + + data = i_stream_get_data(input, &size); + if (data[0] == '\n') { + data++; size--; offset++; + } + i_assert(data[0] == DBOX_MAGIC_PRE[0]); + if (size < sizeof(*hdr)) { + *need_bytes = sizeof(*hdr); + return -1; + } + hdr = (const void *)data; + if (memcmp(hdr->magic_pre, DBOX_MAGIC_PRE, strlen(DBOX_MAGIC_PRE)) != 0) + return 0; + if (hdr->type != DBOX_MESSAGE_TYPE_NORMAL) + return 0; + if (hdr->space1 != ' ' || hdr->space2 != ' ') + return 0; + if (hex2dec(hdr->message_size_hex, sizeof(hdr->message_size_hex)) == 0 && + memcmp(hdr->message_size_hex, "0000000000000000", sizeof(hdr->message_size_hex)) != 0) + return 0; + + *pre_offset = offset; + return 1; +} + +static bool memchr_nocontrol(const unsigned char *data, char chr, + unsigned int len, const unsigned char **pos_r) +{ + unsigned int i; + + for (i = 0; i < len; i++) { + if (data[i] == chr) { + *pos_r = data+i; + return TRUE; + } + if (data[i] < ' ') + return FALSE; + } + *pos_r = NULL; + return TRUE; +} + +static int +dbox_file_match_post_magic(struct istream *input, bool input_full, + size_t *need_bytes) +{ + const unsigned char *data, *p; + size_t i, size; + bool allow_control; + + data = i_stream_get_data(input, &size); + if (size < strlen(DBOX_MAGIC_POST)) { + *need_bytes = strlen(DBOX_MAGIC_POST); + return -1; + } + if (memcmp(data, DBOX_MAGIC_POST, strlen(DBOX_MAGIC_POST)) != 0) + return 0; + + /* see if the metadata block looks valid */ + for (i = strlen(DBOX_MAGIC_POST); i < size; ) { + switch (data[i]) { + case '\n': + return 1; + case DBOX_METADATA_GUID: + case DBOX_METADATA_POP3_UIDL: + case DBOX_METADATA_ORIG_MAILBOX: + case DBOX_METADATA_OLDV1_KEYWORDS: + /* these could contain anything */ + allow_control = TRUE; + break; + case DBOX_METADATA_POP3_ORDER: + case DBOX_METADATA_RECEIVED_TIME: + case DBOX_METADATA_PHYSICAL_SIZE: + case DBOX_METADATA_VIRTUAL_SIZE: + case DBOX_METADATA_EXT_REF: + case DBOX_METADATA_OLDV1_EXPUNGED: + case DBOX_METADATA_OLDV1_FLAGS: + case DBOX_METADATA_OLDV1_SAVE_TIME: + case DBOX_METADATA_OLDV1_SPACE: + /* no control chars */ + allow_control = FALSE; + break; + default: + if (data[i] < 'A' || data[i] > 'Z') + return 0; + /* unknown */ + allow_control = TRUE; + break; + } + if (allow_control) { + p = memchr(data+i, '\n', size-i); + } else { + if (!memchr_nocontrol(data+i, '\n', size-i, &p)) + return 0; + } + if (p == NULL) { + /* LF not found - try to find the end-of-metadata LF */ + if (input_full) { + /* can't look any further - assume it's ok */ + return 1; + } + *need_bytes = size+1; + return -1; + } + i = p - data+1; + } + *need_bytes = size+1; + return -1; +} + +static int dbox_file_find_next_magic(struct dbox_file *file, uoff_t *offset_r, bool *pre_r) { + /* We're scanning message bodies here, trying to find the beginning of + the next message. Although our magic strings are very unlikely to + be found in regular emails, they are much more likely when emails + are stored compressed.. So try to be sure we find the correct + magic markers. */ + struct istream *input = file->input; - struct str_find_context *pre_ctx, *post_ctx; uoff_t orig_offset, pre_offset, post_offset; - const unsigned char *data; - size_t size; - int ret; + const unsigned char *data, *magic; + size_t size, need_bytes; + int ret, match; *pre_r = FALSE; - pre_ctx = str_find_init(default_pool, "\n"DBOX_MAGIC_PRE); - post_ctx = str_find_init(default_pool, DBOX_MAGIC_POST); + orig_offset = input->v_offset; + need_bytes = strlen(DBOX_MAGIC_POST); + while ((ret = i_stream_read_data(input, &data, &size, need_bytes-1)) > 0 || + ret == -2) { + /* search for the beginning of a potential pre/post magic */ + i_assert(size > 1); + magic = memchr(data, DBOX_MAGIC_PRE[0], size); + if (magic == NULL) { + i_stream_skip(input, size-1); + need_bytes = strlen(DBOX_MAGIC_POST); + continue; + } + if (magic == data && input->v_offset == orig_offset) { + /* beginning of the file */ + } else if (magic != data && magic[-1] == '\n') { + /* PRE/POST block? leave \n */ + i_stream_skip(input, magic-data-1); + } else { + i_stream_skip(input, magic-data+1); + need_bytes = strlen(DBOX_MAGIC_POST); + continue; + } - /* \n isn't part of the DBOX_MAGIC_PRE, but it always preceds it. - assume that at this point we've already just read the \n. when - scanning for it later we'll need to find the \n though. */ - (void)str_find_more(pre_ctx, (const unsigned char *)"\n", 1); + pre_offset = (uoff_t)-1; + match = dbox_file_match_pre_magic(input, &pre_offset, &need_bytes); + if (match < 0) { + /* more data needed */ + if (ret == -2) { + i_stream_skip(input, 2); + need_bytes = strlen(DBOX_MAGIC_POST); + } + continue; + } + if (match > 0) + *pre_r = TRUE; - orig_offset = input->v_offset; - while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) { - pre_offset = (uoff_t)-1; - if (str_find_more(pre_ctx, data, size)) { - pre_offset = input->v_offset + - str_find_get_match_end_pos(pre_ctx) - - (strlen(DBOX_MAGIC_PRE) + 1); - *pre_r = TRUE; + match = dbox_file_match_post_magic(input, ret == -2, &need_bytes); + if (match < 0) { + /* more data needed */ + if (ret == -2) { + i_stream_skip(input, 2); + need_bytes = strlen(DBOX_MAGIC_POST); + } + continue; } - if (str_find_more(post_ctx, data, size)) { - post_offset = input->v_offset + - str_find_get_match_end_pos(post_ctx) - - strlen(DBOX_MAGIC_POST); + if (match > 0) { + post_offset = input->v_offset; if (pre_offset == (uoff_t)-1 || post_offset < pre_offset) { pre_offset = post_offset; @@ -53,14 +202,11 @@ } if (pre_offset != (uoff_t)-1) { - if (*pre_r) { - /* LF isn't part of the magic */ - pre_offset++; - } *offset_r = pre_offset; + ret = 1; break; } - i_stream_skip(input, size); + i_stream_skip(input, size-1); } if (ret <= 0) { i_assert(ret == -1); @@ -72,9 +218,7 @@ } } i_stream_seek(input, orig_offset); - str_find_deinit(&pre_ctx); - str_find_deinit(&post_ctx); - return ret; + return ret <= 0 ? ret : 1; } static int diff -r 9531ec8afe8b -r f965670a7b69 src/lib-storage/index/dbox-common/dbox-file.h --- a/src/lib-storage/index/dbox-common/dbox-file.h Wed Aug 21 23:30:07 2013 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-file.h Tue Aug 27 04:06:43 2013 +0300 @@ -39,6 +39,8 @@ DBOX_HEADER_OLDV1_APPEND_OFFSET = 'A' }; +/* NOTE: all valid keys are uppercase characters. if this changes, change + dbox-file-fix.c:dbox_file_match_post_magic() to recognize them */ enum dbox_metadata_key { /* Globally unique identifier for the message. Preserved when copying. */ From dovecot at dovecot.org Tue Aug 27 04:11:35 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 27 Aug 2013 04:11:35 +0300 Subject: dovecot-2.1: dbox: When fixing a broken file, try harder to find... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9efbc0731929 changeset: 14997:9efbc0731929 user: Timo Sirainen date: Tue Aug 27 04:11:24 2013 +0300 description: dbox: When fixing a broken file, try harder to find only valid message/metadata positions. The previous method sometime broke with compressed mail content, because the magic blocks were so short. diffstat: src/lib-storage/index/dbox-common/dbox-file-fix.c | 204 ++++++++++++++++++--- src/lib-storage/index/dbox-common/dbox-file.h | 2 + 2 files changed, 176 insertions(+), 30 deletions(-) diffs (260 lines): diff -r 5d6cc3d03eee -r 9efbc0731929 src/lib-storage/index/dbox-common/dbox-file-fix.c --- a/src/lib-storage/index/dbox-common/dbox-file-fix.c Wed Aug 21 23:30:07 2013 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c Tue Aug 27 04:11:24 2013 +0300 @@ -1,6 +1,7 @@ /* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "hex-dec.h" #include "istream.h" #include "ostream.h" #include "str-find.h" @@ -13,38 +14,186 @@ #define DBOX_MAIL_FILE_BROKEN_COPY_SUFFIX ".broken" static int +dbox_file_match_pre_magic(struct istream *input, + uoff_t *pre_offset, size_t *need_bytes) +{ + const struct dbox_message_header *hdr; + const unsigned char *data; + size_t size; + uoff_t offset = input->v_offset; + + data = i_stream_get_data(input, &size); + if (data[0] == '\n') { + data++; size--; offset++; + } + i_assert(data[0] == DBOX_MAGIC_PRE[0]); + if (size < sizeof(*hdr)) { + *need_bytes = sizeof(*hdr); + return -1; + } + hdr = (const void *)data; + if (memcmp(hdr->magic_pre, DBOX_MAGIC_PRE, strlen(DBOX_MAGIC_PRE)) != 0) + return 0; + if (hdr->type != DBOX_MESSAGE_TYPE_NORMAL) + return 0; + if (hdr->space1 != ' ' || hdr->space2 != ' ') + return 0; + if (hex2dec(hdr->message_size_hex, sizeof(hdr->message_size_hex)) == 0 && + memcmp(hdr->message_size_hex, "0000000000000000", sizeof(hdr->message_size_hex)) != 0) + return 0; + + *pre_offset = offset; + return 1; +} + +static bool memchr_nocontrol(const unsigned char *data, char chr, + unsigned int len, const unsigned char **pos_r) +{ + unsigned int i; + + for (i = 0; i < len; i++) { + if (data[i] == chr) { + *pos_r = data+i; + return TRUE; + } + if (data[i] < ' ') + return FALSE; + } + *pos_r = NULL; + return TRUE; +} + +static int +dbox_file_match_post_magic(struct istream *input, bool input_full, + size_t *need_bytes) +{ + const unsigned char *data, *p; + size_t i, size; + bool allow_control; + + data = i_stream_get_data(input, &size); + if (size < strlen(DBOX_MAGIC_POST)) { + *need_bytes = strlen(DBOX_MAGIC_POST); + return -1; + } + if (memcmp(data, DBOX_MAGIC_POST, strlen(DBOX_MAGIC_POST)) != 0) + return 0; + + /* see if the metadata block looks valid */ + for (i = strlen(DBOX_MAGIC_POST); i < size; ) { + switch (data[i]) { + case '\n': + return 1; + case DBOX_METADATA_GUID: + case DBOX_METADATA_POP3_UIDL: + case DBOX_METADATA_ORIG_MAILBOX: + case DBOX_METADATA_OLDV1_KEYWORDS: + /* these could contain anything */ + allow_control = TRUE; + break; + case DBOX_METADATA_RECEIVED_TIME: + case DBOX_METADATA_PHYSICAL_SIZE: + case DBOX_METADATA_VIRTUAL_SIZE: + case DBOX_METADATA_EXT_REF: + case DBOX_METADATA_OLDV1_EXPUNGED: + case DBOX_METADATA_OLDV1_FLAGS: + case DBOX_METADATA_OLDV1_SAVE_TIME: + case DBOX_METADATA_OLDV1_SPACE: + /* no control chars */ + allow_control = FALSE; + break; + default: + if (data[i] < 'A' || data[i] > 'Z') + return 0; + /* unknown */ + allow_control = TRUE; + break; + } + if (allow_control) { + p = memchr(data+i, '\n', size-i); + } else { + if (!memchr_nocontrol(data+i, '\n', size-i, &p)) + return 0; + } + if (p == NULL) { + /* LF not found - try to find the end-of-metadata LF */ + if (input_full) { + /* can't look any further - assume it's ok */ + return 1; + } + *need_bytes = size+1; + return -1; + } + i = p - data+1; + } + *need_bytes = size+1; + return -1; +} + +static int dbox_file_find_next_magic(struct dbox_file *file, uoff_t *offset_r, bool *pre_r) { + /* We're scanning message bodies here, trying to find the beginning of + the next message. Although our magic strings are very unlikely to + be found in regular emails, they are much more likely when emails + are stored compressed.. So try to be sure we find the correct + magic markers. */ + struct istream *input = file->input; - struct str_find_context *pre_ctx, *post_ctx; uoff_t orig_offset, pre_offset, post_offset; - const unsigned char *data; - size_t size; - int ret; + const unsigned char *data, *magic; + size_t size, need_bytes; + int ret, match; *pre_r = FALSE; - pre_ctx = str_find_init(default_pool, "\n"DBOX_MAGIC_PRE); - post_ctx = str_find_init(default_pool, DBOX_MAGIC_POST); + orig_offset = input->v_offset; + need_bytes = strlen(DBOX_MAGIC_POST); + while ((ret = i_stream_read_data(input, &data, &size, need_bytes-1)) > 0 || + ret == -2) { + /* search for the beginning of a potential pre/post magic */ + i_assert(size > 1); + magic = memchr(data, DBOX_MAGIC_PRE[0], size); + if (magic == NULL) { + i_stream_skip(input, size-1); + need_bytes = strlen(DBOX_MAGIC_POST); + continue; + } + if (magic == data && input->v_offset == orig_offset) { + /* beginning of the file */ + } else if (magic != data && magic[-1] == '\n') { + /* PRE/POST block? leave \n */ + i_stream_skip(input, magic-data-1); + } else { + i_stream_skip(input, magic-data+1); + need_bytes = strlen(DBOX_MAGIC_POST); + continue; + } - /* \n isn't part of the DBOX_MAGIC_PRE, but it always preceds it. - assume that at this point we've already just read the \n. when - scanning for it later we'll need to find the \n though. */ - str_find_more(pre_ctx, (const unsigned char *)"\n", 1); + pre_offset = (uoff_t)-1; + match = dbox_file_match_pre_magic(input, &pre_offset, &need_bytes); + if (match < 0) { + /* more data needed */ + if (ret == -2) { + i_stream_skip(input, 2); + need_bytes = strlen(DBOX_MAGIC_POST); + } + continue; + } + if (match > 0) + *pre_r = TRUE; - orig_offset = input->v_offset; - while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) { - pre_offset = (uoff_t)-1; - if (str_find_more(pre_ctx, data, size)) { - pre_offset = input->v_offset + - str_find_get_match_end_pos(pre_ctx) - - (strlen(DBOX_MAGIC_PRE) + 1); - *pre_r = TRUE; + match = dbox_file_match_post_magic(input, ret == -2, &need_bytes); + if (match < 0) { + /* more data needed */ + if (ret == -2) { + i_stream_skip(input, 2); + need_bytes = strlen(DBOX_MAGIC_POST); + } + continue; } - if (str_find_more(post_ctx, data, size)) { - post_offset = input->v_offset + - str_find_get_match_end_pos(post_ctx) - - strlen(DBOX_MAGIC_POST); + if (match > 0) { + post_offset = input->v_offset; if (pre_offset == (uoff_t)-1 || post_offset < pre_offset) { pre_offset = post_offset; @@ -53,14 +202,11 @@ } if (pre_offset != (uoff_t)-1) { - if (*pre_r) { - /* LF isn't part of the magic */ - pre_offset++; - } *offset_r = pre_offset; + ret = 1; break; } - i_stream_skip(input, size); + i_stream_skip(input, size-1); } if (ret <= 0) { i_assert(ret == -1); @@ -72,9 +218,7 @@ } } i_stream_seek(input, orig_offset); - str_find_deinit(&pre_ctx); - str_find_deinit(&post_ctx); - return ret; + return ret <= 0 ? ret : 1; } static int diff -r 5d6cc3d03eee -r 9efbc0731929 src/lib-storage/index/dbox-common/dbox-file.h --- a/src/lib-storage/index/dbox-common/dbox-file.h Wed Aug 21 23:30:07 2013 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-file.h Tue Aug 27 04:11:24 2013 +0300 @@ -39,6 +39,8 @@ DBOX_HEADER_OLDV1_APPEND_OFFSET = 'A' }; +/* NOTE: all valid keys are uppercase characters. if this changes, change + dbox-file-fix.c:dbox_file_match_post_magic() to recognize them */ enum dbox_metadata_key { /* Globally unique identifier for the message. Preserved when copying. */ From dovecot at dovecot.org Thu Aug 29 00:57:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 29 Aug 2013 00:57:25 +0300 Subject: dovecot-2.2: Fixed compiling with old gcc. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5d22d0c0b233 changeset: 16701:5d22d0c0b233 user: Timo Sirainen date: Thu Aug 29 00:53:30 2013 +0300 description: Fixed compiling with old gcc. diffstat: src/log/log-error-buffer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r f965670a7b69 -r 5d22d0c0b233 src/log/log-error-buffer.c --- a/src/log/log-error-buffer.c Tue Aug 27 04:06:43 2013 +0300 +++ b/src/log/log-error-buffer.c Thu Aug 29 00:53:30 2013 +0300 @@ -10,7 +10,7 @@ enum log_type type; time_t timestamp; - unsigned char prefix_text[]; + unsigned char prefix_text[FLEXIBLE_ARRAY_MEMBER]; }; struct log_error_buffer { From dovecot at dovecot.org Thu Aug 29 00:57:25 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 29 Aug 2013 00:57:25 +0300 Subject: dovecot-2.2: lib-storage: Auto-create dovecot-uidvalidity's miss... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5e01ab977406 changeset: 16702:5e01ab977406 user: Timo Sirainen date: Thu Aug 29 00:57:13 2013 +0300 description: lib-storage: Auto-create dovecot-uidvalidity's missing parent directory diffstat: src/lib-storage/mailbox-uidvalidity.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (18 lines): diff -r 5d22d0c0b233 -r 5e01ab977406 src/lib-storage/mailbox-uidvalidity.c --- a/src/lib-storage/mailbox-uidvalidity.c Thu Aug 29 00:53:30 2013 +0300 +++ b/src/lib-storage/mailbox-uidvalidity.c Thu Aug 29 00:57:13 2013 +0300 @@ -124,6 +124,14 @@ } d = opendir(dir); + if (d == NULL && errno == ENOENT) { + /* FIXME: the PATH_TYPE_CONTROL should come as a parameter, but + that's an API change, do it in v2.3. it's not really a + problem though, since currently all backends use control + dirs for the uidvalidity file. */ + (void)mailbox_list_mkdir_root(list, dir, MAILBOX_LIST_PATH_TYPE_CONTROL); + d = opendir(dir); + } if (d == NULL) { i_error("opendir(%s) failed: %m", dir); return mailbox_uidvalidity_next_fallback(); From dovecot at dovecot.org Thu Aug 29 16:43:08 2013 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 29 Aug 2013 16:43:08 +0300 Subject: dovecot-2.2: lib-ssl-iostream: Don't assert-crash if stream buff... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/470153d92662 changeset: 16703:470153d92662 user: Timo Sirainen date: Thu Aug 29 16:42:55 2013 +0300 description: lib-ssl-iostream: Don't assert-crash if stream buffer gets full. diffstat: src/lib-ssl-iostream/istream-openssl.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diffs (14 lines): diff -r 5e01ab977406 -r 470153d92662 src/lib-ssl-iostream/istream-openssl.c --- a/src/lib-ssl-iostream/istream-openssl.c Thu Aug 29 00:57:13 2013 +0300 +++ b/src/lib-ssl-iostream/istream-openssl.c Thu Aug 29 16:42:55 2013 +0300 @@ -101,9 +101,7 @@ ssize_t ret; sstream->ssl_io->input_handler = TRUE; - if ((ret = i_stream_ssl_read_real(stream)) < 0) - ret = -1; - else { + if ((ret = i_stream_ssl_read_real(stream)) >= 0) { i_assert(i_stream_get_data_size(sstream->ssl_io->plain_input) == 0); } sstream->ssl_io->input_handler = FALSE;