From dovecot at dovecot.org Fri Jun 3 15:27:30 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 15:27:30 +0300 Subject: dovecot-2.0: doveadm -A: Crashfix for doveadm server when using ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0e1254dcf86b changeset: 12830:0e1254dcf86b user: Timo Sirainen date: Fri Jun 03 15:27:21 2011 +0300 description: doveadm -A: Crashfix for doveadm server when using commands that print nothing. diffstat: src/doveadm/doveadm-print.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (16 lines): diff -r 9ae30e5d6935 -r 0e1254dcf86b src/doveadm/doveadm-print.c --- a/src/doveadm/doveadm-print.c Tue May 31 15:38:03 2011 +0300 +++ b/src/doveadm/doveadm-print.c Fri Jun 03 15:27:21 2011 +0300 @@ -117,8 +117,10 @@ { struct doveadm_print_header_context *hdr; - array_foreach_modifiable(&ctx->headers, hdr) - hdr->sticky = FALSE; + if (ctx != NULL) { + array_foreach_modifiable(&ctx->headers, hdr) + hdr->sticky = FALSE; + } } void doveadm_print_init(const char *name) From dovecot at dovecot.org Fri Jun 3 15:49:58 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 15:49:58 +0300 Subject: dovecot-2.0: .hgignore updated Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/4bc98c94883f changeset: 12832:4bc98c94883f user: Timo Sirainen date: Fri Jun 03 15:49:50 2011 +0300 description: .hgignore updated diffstat: .hgignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 66e3cc789efb -r 4bc98c94883f .hgignore --- a/.hgignore Fri Jun 03 15:49:30 2011 +0300 +++ b/.hgignore Fri Jun 03 15:49:50 2011 +0300 @@ -69,6 +69,7 @@ src/dsync/dsync src/imap-login/imap-login src/imap/imap +src/ipc/ipc src/lib/unicodemap.c src/lib/UnicodeData.txt src/lib-dict/dict-drivers-register.c From dovecot at dovecot.org Fri Jun 3 15:49:58 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 15:49:58 +0300 Subject: dovecot-2.0: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/66e3cc789efb changeset: 12831:66e3cc789efb user: Timo Sirainen date: Fri Jun 03 15:49:30 2011 +0300 description: Compiler warning fix. diffstat: src/director/director-connection.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 0e1254dcf86b -r 66e3cc789efb src/director/director-connection.c --- a/src/director/director-connection.c Fri Jun 03 15:27:21 2011 +0300 +++ b/src/director/director-connection.c Fri Jun 03 15:49:30 2011 +0300 @@ -507,7 +507,6 @@ director_cmd_user_killed(struct director_connection *conn, const char *const *args) { - struct director_host *dir_host; unsigned int username_hash; if (str_array_length(args) != 1 || From dovecot at dovecot.org Fri Jun 3 16:33:49 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 16:33:49 +0300 Subject: dovecot-2.0: IMAP: Treat "namespace prefix/" as invalid mailbox ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/e371cb27c5b6 changeset: 12833:e371cb27c5b6 user: Timo Sirainen date: Fri Jun 03 16:33:43 2011 +0300 description: IMAP: Treat "namespace prefix/" as invalid mailbox name. diffstat: src/imap/imap-commands-util.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diffs (15 lines): diff -r 4bc98c94883f -r e371cb27c5b6 src/imap/imap-commands-util.c --- a/src/imap/imap-commands-util.c Fri Jun 03 15:49:50 2011 +0300 +++ b/src/imap/imap-commands-util.c Fri Jun 03 16:33:43 2011 +0300 @@ -59,6 +59,11 @@ storage_name = t_strndup(storage_name, storage_name_len-1); } + if (strcmp(mailbox, ns->prefix) == 0) { + client_send_tagline(cmd, "NO Invalid mailbox name."); + return NULL; + } + if (ns->real_sep != ns->sep && ns->prefix_len < strlen(mailbox)) { /* make sure there are no real separators used in the mailbox name. */ From dovecot at dovecot.org Fri Jun 3 16:40:09 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 16:40:09 +0300 Subject: dovecot-2.0: IMAP: Treat also "inbox/" case-insensitively as inv... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1c9b54de43f2 changeset: 12834:1c9b54de43f2 user: Timo Sirainen date: Fri Jun 03 16:40:03 2011 +0300 description: IMAP: Treat also "inbox/" case-insensitively as invalid mailbox name. diffstat: src/imap/imap-commands-util.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r e371cb27c5b6 -r 1c9b54de43f2 src/imap/imap-commands-util.c --- a/src/imap/imap-commands-util.c Fri Jun 03 16:33:43 2011 +0300 +++ b/src/imap/imap-commands-util.c Fri Jun 03 16:40:03 2011 +0300 @@ -59,7 +59,8 @@ storage_name = t_strndup(storage_name, storage_name_len-1); } - if (strcmp(mailbox, ns->prefix) == 0) { + if (strlen(mailbox) == ns->prefix_len) { + /* trying to open "ns prefix/" */ client_send_tagline(cmd, "NO Invalid mailbox name."); return NULL; } From dovecot at dovecot.org Fri Jun 3 17:07:44 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 17:07:44 +0300 Subject: dovecot-2.0: eaccess_get_error(): Fixes to reporting dir permiss... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/12e3e8570d77 changeset: 12835:12e3e8570d77 user: Timo Sirainen date: Fri Jun 03 17:07:37 2011 +0300 description: eaccess_get_error(): Fixes to reporting dir permissions. Also fixed an infinite loop if stat("/") fails. diffstat: src/lib/eacces-error.c | 39 +++++++++++++++++++-------------------- 1 files changed, 19 insertions(+), 20 deletions(-) diffs (89 lines): diff -r 1c9b54de43f2 -r 12e3e8570d77 src/lib/eacces-error.c --- a/src/lib/eacces-error.c Fri Jun 03 16:40:03 2011 +0300 +++ b/src/lib/eacces-error.c Fri Jun 03 17:07:37 2011 +0300 @@ -83,24 +83,21 @@ static const char * eacces_error_get_full(const char *func, const char *path, bool creating) { - const char *prev_path = path, *dir, *p; + const char *prev_path, *dir = NULL, *p; const char *pw_name = NULL, *gr_name = NULL; struct passwd pw; struct group group; string_t *errmsg; - struct stat st, dir_st; - int orig_errno, ret = -1; + struct stat st; + int orig_errno, ret; orig_errno = errno; errmsg = t_str_new(256); str_printfa(errmsg, "%s(%s)", func, path); - dir = "/"; if (*path != '/') { - if (t_get_current_dir(&dir) == 0) + if (t_get_current_dir(&dir) == 0) { str_printfa(errmsg, " in directory %s", dir); - if (strchr(path, '/') == NULL) { - /* we have no path. do the file access checks anyway. */ - ret = 0; + path = t_strconcat(dir, "/", path, NULL); } } str_printfa(errmsg, " failed: Permission denied (euid=%s", @@ -133,9 +130,12 @@ break; } - memset(&dir_st, 0, sizeof(dir_st)); - while ((p = strrchr(prev_path, '/')) != NULL) { - dir = p == prev_path ? "/" : t_strdup_until(prev_path, p); + prev_path = path; ret = -1; + while (strcmp(prev_path, "/") != 0) { + if ((p = strrchr(prev_path, '/')) == NULL) + break; + + dir = t_strdup_until(prev_path, p); ret = stat(dir, &st); if (ret == 0) break; @@ -151,8 +151,6 @@ break; } prev_path = dir; - dir = "/"; - dir_st = st; } if (ret == 0) { @@ -177,22 +175,23 @@ str_printfa(errmsg, " UNIX perms appear ok, " "some security policy wrong?"); } - if (dir_st.st_uid != geteuid()) { - if (pw_name != NULL && i_getpwuid(dir_st.st_uid, &pw) > 0 && + if (ret == 0 && st.st_uid != geteuid()) { + if (pw_name != NULL && i_getpwuid(st.st_uid, &pw) > 0 && strcmp(pw.pw_name, pw_name) == 0) { str_printfa(errmsg, ", conflicting dir uid=%s(%s)", - dec2str(dir_st.st_uid), pw_name); + dec2str(st.st_uid), pw_name); } else { - str_append(errmsg, ", euid is not dir owner"); + str_printfa(errmsg, ", dir owned by %s:%s", + dec2str(st.st_uid), dec2str(st.st_gid)); } } else { str_append(errmsg, ", euid is dir owner"); } - if (gr_name != NULL && dir_st.st_gid != getegid()) { - if (i_getgrgid(dir_st.st_gid, &group) > 0 && + if (ret == 0 && gr_name != NULL && st.st_gid != getegid()) { + if (i_getgrgid(st.st_gid, &group) > 0 && strcmp(group.gr_name, gr_name) == 0) { str_printfa(errmsg, ", conflicting dir gid=%s(%s)", - dec2str(dir_st.st_gid), gr_name); + dec2str(st.st_gid), gr_name); } } str_append_c(errmsg, ')'); From dovecot at dovecot.org Fri Jun 3 17:14:06 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 17:14:06 +0300 Subject: dovecot-2.0: eaccess_get_error(): Show also directory mode. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/17d8e1f12901 changeset: 12836:17d8e1f12901 user: Timo Sirainen date: Fri Jun 03 17:13:59 2011 +0300 description: eaccess_get_error(): Show also directory mode. diffstat: src/lib/eacces-error.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (15 lines): diff -r 12e3e8570d77 -r 17d8e1f12901 src/lib/eacces-error.c --- a/src/lib/eacces-error.c Fri Jun 03 17:07:37 2011 +0300 +++ b/src/lib/eacces-error.c Fri Jun 03 17:13:59 2011 +0300 @@ -181,8 +181,9 @@ str_printfa(errmsg, ", conflicting dir uid=%s(%s)", dec2str(st.st_uid), pw_name); } else { - str_printfa(errmsg, ", dir owned by %s:%s", - dec2str(st.st_uid), dec2str(st.st_gid)); + str_printfa(errmsg, ", dir owned by %s:%s mode=0%o", + dec2str(st.st_uid), dec2str(st.st_gid), + st.st_mode & 0777); } } else { str_append(errmsg, ", euid is dir owner"); From dovecot at dovecot.org Fri Jun 3 17:22:15 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 17:22:15 +0300 Subject: dovecot-2.0: eacces_get_error(): Give even better error message ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/d339aeb782ed changeset: 12837:d339aeb782ed user: Timo Sirainen date: Fri Jun 03 17:22:09 2011 +0300 description: eacces_get_error(): Give even better error message for directory permission errors. diffstat: src/lib/eacces-error.c | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) diffs (67 lines): diff -r 17d8e1f12901 -r d339aeb782ed src/lib/eacces-error.c --- a/src/lib/eacces-error.c Fri Jun 03 17:13:59 2011 +0300 +++ b/src/lib/eacces-error.c Fri Jun 03 17:22:09 2011 +0300 @@ -89,7 +89,7 @@ struct group group; string_t *errmsg; struct stat st; - int orig_errno, ret; + int orig_errno, ret, missing_mode = 0; orig_errno = errno; errmsg = t_str_new(256); @@ -156,11 +156,15 @@ if (ret == 0) { /* dir is the first parent directory we can stat() */ if (test_access(dir, X_OK, errmsg) < 0) { - if (errno == EACCES) + if (errno == EACCES) { str_printfa(errmsg, " missing +x perm: %s", dir); + missing_mode = 1; + } } else if (creating && test_access(dir, W_OK, errmsg) < 0) { - if (errno == EACCES) + if (errno == EACCES) { str_printfa(errmsg, " missing +w perm: %s", dir); + missing_mode = 2; + } } else if (prev_path == path && test_access(path, R_OK, errmsg) < 0) { if (errno == EACCES) @@ -169,13 +173,18 @@ /* this produces a wrong error if the operation didn't actually need write permissions, but we don't know it here.. */ - if (errno == EACCES) + if (errno == EACCES) { str_printfa(errmsg, " missing +w perm: %s", path); - } else - str_printfa(errmsg, " UNIX perms appear ok, " - "some security policy wrong?"); + missing_mode = 4; + } + } else { + str_append(errmsg, " UNIX perms appear ok " + "(ACL/MAC wrong?)"); + } } - if (ret == 0 && st.st_uid != geteuid()) { + if (ret < 0) + ; + else if (st.st_uid != geteuid()) { if (pw_name != NULL && i_getpwuid(st.st_uid, &pw) > 0 && strcmp(pw.pw_name, pw_name) == 0) { str_printfa(errmsg, ", conflicting dir uid=%s(%s)", @@ -185,8 +194,11 @@ dec2str(st.st_uid), dec2str(st.st_gid), st.st_mode & 0777); } + } else if (missing_mode != 0 && + (((st.st_mode & 0700) >> 6) & missing_mode) == 0) { + str_append(errmsg, ", dir owner missing perms"); } else { - str_append(errmsg, ", euid is dir owner"); + str_append(errmsg, ", UNIX perms appear ok (ACL/MAC wrong?)"); } if (ret == 0 && gr_name != NULL && st.st_gid != getegid()) { if (i_getgrgid(st.st_gid, &group) > 0 && From dovecot at dovecot.org Fri Jun 3 17:37:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 17:37:33 +0300 Subject: dovecot-2.0: master: Fail at startup if default_login_user or de... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/99da5f4f375d changeset: 12838:99da5f4f375d user: Timo Sirainen date: Fri Jun 03 17:37:25 2011 +0300 description: master: Fail at startup if default_login_user or default_internal_user doesn't exist. diffstat: src/config/settings-get.pl | 1 + src/master/master-settings.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diffs (48 lines): diff -r d339aeb782ed -r 99da5f4f375d src/config/settings-get.pl --- a/src/config/settings-get.pl Fri Jun 03 17:22:09 2011 +0300 +++ b/src/config/settings-get.pl Fri Jun 03 17:37:25 2011 +0300 @@ -3,6 +3,7 @@ print '#include "lib.h"'."\n"; print '#include "array.h"'."\n"; +print '#include "ipwd.h"'."\n"; print '#include "var-expand.h"'."\n"; print '#include "file-lock.h"'."\n"; print '#include "fsync-mode.h"'."\n"; diff -r d339aeb782ed -r 99da5f4f375d src/master/master-settings.c --- a/src/master/master-settings.c Fri Jun 03 17:22:09 2011 +0300 +++ b/src/master/master-settings.c Fri Jun 03 17:37:25 2011 +0300 @@ -6,6 +6,7 @@ #include "istream.h" #include "network.h" #include "str.h" +#include "ipwd.h" #include "mkdir-parents.h" #include "safe-mkdir.h" #include "settings-parser.h" @@ -407,6 +408,7 @@ struct service_settings *const *services; const char *const *strings; ARRAY_TYPE(const_string) all_listeners; + struct passwd pw; unsigned int i, j, count, len, client_limit, process_limit; unsigned int max_auth_client_processes, max_anvil_client_processes; @@ -427,6 +429,17 @@ return FALSE; } + if (i_getpwnam(set->default_login_user, &pw) == 0) { + *error_r = t_strdup_printf("default_login_user doesn't exist: %s", + set->default_login_user); + return FALSE; + } + if (i_getpwnam(set->default_internal_user, &pw) == 0) { + *error_r = t_strdup_printf("default_internal_user doesn't exist: %s", + set->default_internal_user); + return FALSE; + } + /* check that we have at least one service. the actual service structure validity is checked later while creating them. */ if (!array_is_created(&set->services) || From dovecot at dovecot.org Fri Jun 3 18:11:08 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 18:11:08 +0300 Subject: dovecot-2.0: doveadm acl debug: Show also path to mailbox if it ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/5b03ca65f4ed changeset: 12839:5b03ca65f4ed user: Timo Sirainen date: Fri Jun 03 18:11:00 2011 +0300 description: doveadm acl debug: Show also path to mailbox if it doens't exist. diffstat: src/plugins/acl/doveadm-acl.c | 47 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-) diffs (64 lines): diff -r 99da5f4f375d -r 5b03ca65f4ed src/plugins/acl/doveadm-acl.c --- a/src/plugins/acl/doveadm-acl.c Fri Jun 03 17:37:25 2011 +0300 +++ b/src/plugins/acl/doveadm-acl.c Fri Jun 03 18:11:00 2011 +0300 @@ -353,6 +353,51 @@ return ctx; } +static int +cmd_acl_debug_mailbox_open(struct mail_user *user, const char *mailbox, + struct mailbox **box_r) +{ + struct acl_user *auser = ACL_USER_CONTEXT(user); + struct mail_namespace *ns; + struct mailbox *box; + const char *storage_name, *path, *errstr; + enum mail_error error; + + storage_name = mailbox; + ns = mail_namespace_find(user->namespaces, &storage_name); + if (ns == NULL) { + i_error("No namespace found for mailbox %s", mailbox); + return -1; + } + box = mailbox_alloc(ns->list, storage_name, + MAILBOX_FLAG_READONLY | MAILBOX_FLAG_KEEP_RECENT | + MAILBOX_FLAG_IGNORE_ACLS); + if (mailbox_open(box) < 0) { + path = mailbox_list_get_path(ns->list, storage_name, + MAILBOX_LIST_PATH_TYPE_MAILBOX); + errstr = mail_storage_get_last_error(box->storage, &error); + if (error != MAIL_ERROR_NOTFOUND || + path == NULL || *path == '\0') + i_error("Can't open mailbox %s: %s", mailbox, errstr); + else { + i_error("Mailbox '%s' doesn't exist in %s", + mailbox, path); + } + mailbox_free(&box); + return -1; + } + + if (auser == NULL) { + i_info("ACL not enabled for user %s, mailbox can be accessed", + user->username); + mailbox_free(&box); + return -1; + } + + *box_r = box; + return 0; +} + static bool cmd_acl_debug_mailbox(struct mailbox *box, bool *retry_r) { struct mail_namespace *ns = mailbox_get_namespace(box); @@ -456,7 +501,7 @@ struct mailbox *box; bool ret, retry; - if (cmd_acl_mailbox_open(user, mailbox, &box) < 0) + if (cmd_acl_debug_mailbox_open(user, mailbox, &box) < 0) return; ret = cmd_acl_debug_mailbox(box, &retry); From dovecot at dovecot.org Fri Jun 3 18:54:33 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 03 Jun 2011 18:54:33 +0300 Subject: dovecot-2.0: script-login: When not using "-d" parameter, don't ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/a2d57b43ccb2 changeset: 12840:a2d57b43ccb2 user: Timo Sirainen date: Fri Jun 03 18:54:27 2011 +0300 description: script-login: When not using "-d" parameter, don't do unnecessary config lookup. diffstat: src/util/script-login.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diffs (23 lines): diff -r 5b03ca65f4ed -r a2d57b43ccb2 src/util/script-login.c --- a/src/util/script-login.c Fri Jun 03 18:11:00 2011 +0300 +++ b/src/util/script-login.c Fri Jun 03 18:54:27 2011 +0300 @@ -114,13 +114,13 @@ master_service_init_log(master_service, t_strdup_printf("script-login(%s): ", input.username)); - service_ctx = mail_storage_service_init(master_service, NULL, flags); - if (mail_storage_service_lookup(service_ctx, &input, &user, &error) <= 0) - i_fatal("%s", error); - mail_storage_service_restrict_setenv(service_ctx, user); - - if (drop_to_userdb_privileges) + if (drop_to_userdb_privileges) { + service_ctx = mail_storage_service_init(master_service, NULL, flags); + if (mail_storage_service_lookup(service_ctx, &input, &user, &error) <= 0) + i_fatal("%s", error); + mail_storage_service_restrict_setenv(service_ctx, user); restrict_access_by_env(getenv("HOME"), TRUE); + } if (dup2(fd, STDIN_FILENO) < 0) i_fatal("dup2() failed: %m"); From pigeonhole at rename-it.nl Mon Jun 6 17:59:44 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 06 Jun 2011 16:59:44 +0200 Subject: dovecot-2.0-pigeonhole: Made vnd.dovecot.debug extension availab... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/9d328e6732ff changeset: 1500:9d328e6732ff user: Stephan Bosch date: Mon Jun 06 16:59:39 2011 +0200 description: Made vnd.dovecot.debug extension available to the LDA plugin instead of only the command line tools. diffstat: Makefile.am | 1 + configure.in | 3 +- doc/man/sieve-test.1.in | 40 +++-- src/lib-sieve/Makefile.am | 1 + src/lib-sieve/plugins/Makefile.am | 1 + src/lib-sieve/plugins/vnd.dovecot/Makefile.am | 3 + src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am | 15 ++ src/lib-sieve/plugins/vnd.dovecot/debug/cmd-debug-log.c | 130 ++++++++++++++++++ src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug-common.h | 25 +++ src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c | 77 +++++++++++ src/lib-sieve/sieve-extensions.c | 29 ++- src/lib-sieve/sieve-extensions.h | 2 + src/sieve-tools/Makefile.am | 5 +- src/sieve-tools/debug/Makefile.am | 16 -- src/sieve-tools/debug/cmd-debug-print.c | 130 ------------------ src/sieve-tools/debug/ext-debug-common.h | 21 --- src/sieve-tools/debug/ext-debug.c | 56 -------- src/sieve-tools/debug/sieve-ext-debug.h | 13 - src/sieve-tools/sieve-dump.c | 8 +- src/sieve-tools/sieve-filter.c | 6 +- src/sieve-tools/sieve-test.c | 6 +- src/sieve-tools/sievec.c | 6 +- src/testsuite/testsuite-log.c | 18 +- tests/extensions/vnd.dovecot/debug/execute.svtest | 6 + 24 files changed, 324 insertions(+), 294 deletions(-) diffs (truncated from 928 to 300 lines): diff -r 560057691dac -r 9d328e6732ff Makefile.am --- a/Makefile.am Wed May 11 19:26:57 2011 +0200 +++ b/Makefile.am Mon Jun 06 16:59:39 2011 +0200 @@ -123,6 +123,7 @@ tests/extensions/spamvirustest/virustest.svtest \ tests/extensions/spamvirustest/spamtestplus.svtest \ tests/extensions/spamvirustest/errors.svtest \ + tests/extensions/vnd.dovecot/debug/execute.svtest \ tests/deprecated/notify/basic.svtest \ tests/deprecated/notify/mailto.svtest \ tests/deprecated/notify/errors.svtest \ diff -r 560057691dac -r 9d328e6732ff configure.in --- a/configure.in Wed May 11 19:26:57 2011 +0200 +++ b/configure.in Mon Jun 06 16:59:39 2011 +0200 @@ -117,13 +117,14 @@ src/lib-sieve/plugins/mailbox/Makefile src/lib-sieve/plugins/date/Makefile src/lib-sieve/plugins/spamvirustest/Makefile +src/lib-sieve/plugins/vnd.dovecot/Makefile +src/lib-sieve/plugins/vnd.dovecot/debug/Makefile src/lib-sieve-tool/Makefile src/lib-sievestorage/Makefile src/lib-managesieve/Makefile src/plugins/Makefile src/plugins/lda-sieve/Makefile src/sieve-tools/Makefile -src/sieve-tools/debug/Makefile src/managesieve/Makefile src/managesieve-login/Makefile src/testsuite/Makefile diff -r 560057691dac -r 9d328e6732ff doc/man/sieve-test.1.in --- a/doc/man/sieve-test.1.in Wed May 11 19:26:57 2011 +0200 +++ b/doc/man/sieve-test.1.in Mon Jun 06 16:59:39 2011 +0200 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Pigeonhole authors, see the included COPYING file -.TH "SIEVE\-TEST" 1 "2011-02-23" "Pigeonhole for Dovecot v2.0" "Pigeonhole" +.TH "SIEVE\-TEST" 1 "2011-06-06" "Pigeonhole for Dovecot v2.0" "Pigeonhole" .SH NAME sieve\-test \- Pigeonhole\(aqs Sieve script tester .\"------------------------------------------------------------------------ @@ -125,10 +125,10 @@ .SH USAGE .SS RUNTIME TRACE DEBUGGING .PP -Using the \fB\-t\fP option, the \fBsieve\-test\fP tool can be configured to print -detailed trace information on the Sieve script execution to a file or standard -output. For example, the encountered commands, the performed tests and the -matched values can be printed. +Using the \fB\-t\fP option, the \fBsieve\-test\fP tool can be configured to +print detailed trace information on the Sieve script execution to a file or +standard output. For example, the encountered commands, the performed tests and +the matched values can be printed. .PP The runtime trace can be configured using the \fB\-T\fP option, which can be specified multiple times. It can be used as follows: @@ -165,10 +165,9 @@ .\"------------------------------------------------------------------------ .SS DEBUG SIEVE EXTENSION .PP -To improve script debugging, the Sieve command line tools such as -\fBsieve\-test\fP support a custom Sieve language extension called -\(aqvnd.dovecot.debug\(aq. It adds the \fBdebug_print\fP command that allows -printing debug messages to \fBstdout\fP. +To improve script debugging, this Sieve implementation supports a custom Sieve +language extension called \(aqvnd.dovecot.debug\(aq. It adds the \fBdebug_log\fP +command that allows logging debug messages. .PP Example: .PP @@ -176,18 +175,21 @@ .PP if header :contains \(dqsubject\(dq \(dqhello\(dq { .PP - debug_print \(dqSubject header contains hello!\(dq; + debug_log \(dqSubject header contains hello!\(dq; .PP } .PP -Other tools like \fBsievec\fP and \fBsieve\-dump\fP also recognize the -vnd.dovecot.debug extension. In contrast, the actual Sieve plugin for the -Dovecot LDA (\fBdovecot\-lda\fR(1)) does not allow the use of the debug -extension. So, keep in mind that scripts and compiled binaries that refer to de -debug extension will fail to be run by the Sieve plugin itself. -.PP -Note that it is not necessary to enable nor possible to disable the availability -of the debug extension with the \fB\-x\fP option. +Tools such as \fBsieve\-test\fP, \fBsievec\fP and \fBsieve\-dump\fP have support +for the vnd.dovecot.debug extension enabled by default and it is not necessary +to enable nor possible to disable the availability of the debug extension with +the \fB\-x\fP option. The logged messages are written to \fBstdout\fP in this +case. + +In contrast, for the actual Sieve plugin for the Dovecot LDA +(\fBdovecot\-lda\fR(1)) the vnd.dovecot.debug extension needs to be enabled +explicitly using the \fIsieve_extensions\fP setting. The messages are then +logged to the user's private script log file. If used in a global script, the +messages are logged through the default Dovecot logging facility. .\"------------------------------------------------------------------------ .SH "EXIT STATUS" .B sieve\-test @@ -218,4 +220,4 @@ .BR dovecot\-lda (1), .BR sieve\-dump (1), .BR sievec (1), -.BR pigeonhole (7) \ No newline at end of file +.BR pigeonhole (7) diff -r 560057691dac -r 9d328e6732ff src/lib-sieve/Makefile.am --- a/src/lib-sieve/Makefile.am Wed May 11 19:26:57 2011 +0200 +++ b/src/lib-sieve/Makefile.am Mon Jun 06 16:59:39 2011 +0200 @@ -63,6 +63,7 @@ $(extdir)/mailbox/libsieve_ext_mailbox.la \ $(extdir)/date/libsieve_ext_date.la \ $(extdir)/spamvirustest/libsieve_ext_spamvirustest.la \ + $(extdir)/vnd.dovecot/debug/libsieve_ext_debug.la \ $(unfinished_plugins) libdovecot_sieve_la_DEPENDENCIES = $(plugins) diff -r 560057691dac -r 9d328e6732ff src/lib-sieve/plugins/Makefile.am --- a/src/lib-sieve/plugins/Makefile.am Wed May 11 19:26:57 2011 +0200 +++ b/src/lib-sieve/plugins/Makefile.am Mon Jun 06 16:59:39 2011 +0200 @@ -19,6 +19,7 @@ mailbox \ date \ spamvirustest \ + vnd.dovecot \ $(UNFINISHED) diff -r 560057691dac -r 9d328e6732ff src/lib-sieve/plugins/vnd.dovecot/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sieve/plugins/vnd.dovecot/Makefile.am Mon Jun 06 16:59:39 2011 +0200 @@ -0,0 +1,3 @@ +SUBDIRS = debug + + diff -r 560057691dac -r 9d328e6732ff src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am Mon Jun 06 16:59:39 2011 +0200 @@ -0,0 +1,15 @@ +noinst_LTLIBRARIES = libsieve_ext_debug.la + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib-sieve \ + $(LIBDOVECOT_INCLUDE) + +commands = \ + cmd-debug-log.c + +libsieve_ext_debug_la_SOURCES = \ + $(commands) \ + ext-debug.c + +noinst_HEADERS = \ + ext-debug-common.h diff -r 560057691dac -r 9d328e6732ff src/lib-sieve/plugins/vnd.dovecot/debug/cmd-debug-log.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sieve/plugins/vnd.dovecot/debug/cmd-debug-log.c Mon Jun 06 16:59:39 2011 +0200 @@ -0,0 +1,130 @@ +/* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file + */ + +#include "lib.h" +#include "str-sanitize.h" + +#include "sieve-extensions.h" +#include "sieve-commands.h" +#include "sieve-code.h" + +#include "sieve-validator.h" +#include "sieve-generator.h" +#include "sieve-binary.h" +#include "sieve-interpreter.h" +#include "sieve-dump.h" + +#include "ext-debug-common.h" + +/* + * Debug_log command + * + * Syntax + * debug_log + */ + +static bool cmd_debug_log_validate + (struct sieve_validator *valdtr, struct sieve_command *tst); +static bool cmd_debug_log_generate + (const struct sieve_codegen_env *cgenv, struct sieve_command *ctx); + +const struct sieve_command_def debug_log_command = { + "debug_log", + SCT_COMMAND, + 1, 0, FALSE, FALSE, + NULL, NULL, + cmd_debug_log_validate, + cmd_debug_log_generate, + NULL +}; + +/* + * Body operation + */ + +static bool cmd_debug_log_operation_dump + (const struct sieve_dumptime_env *denv, sieve_size_t *address); +static int cmd_debug_log_operation_execute + (const struct sieve_runtime_env *renv, sieve_size_t *address); + +const struct sieve_operation_def debug_log_operation = { + "debug_log", + &debug_extension, + 0, + cmd_debug_log_operation_dump, + cmd_debug_log_operation_execute +}; + +/* + * Validation + */ + +static bool cmd_debug_log_validate +(struct sieve_validator *valdtr, struct sieve_command *tst) +{ + struct sieve_ast_argument *arg = tst->first_positional; + + if ( !sieve_validate_positional_argument + (valdtr, tst, arg, "message", 1, SAAT_STRING) ) { + return FALSE; + } + + return sieve_validator_argument_activate(valdtr, tst, arg, FALSE); +} + +/* + * Code generation + */ + +static bool cmd_debug_log_generate +(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd) +{ + (void)sieve_operation_emit(cgenv->sblock, cmd->ext, &debug_log_operation); + + /* Generate arguments */ + return sieve_generate_arguments(cgenv, cmd, NULL); +} + +/* + * Code dump + */ + +static bool cmd_debug_log_operation_dump +(const struct sieve_dumptime_env *denv, sieve_size_t *address) +{ + sieve_code_dumpf(denv, "DEBUG_LOG"); + sieve_code_descend(denv); + + return sieve_opr_string_dump(denv, address, "key list"); +} + +/* + * Interpretation + */ + +static int cmd_debug_log_operation_execute +(const struct sieve_runtime_env *renv, sieve_size_t *address) +{ + string_t *message; + int ret; + + /* + * Read operands + */ + + /* Read message */ + + if ( (ret=sieve_opr_string_read(renv, address, "message", &message)) <= 0 ) + return ret; + + /* + * Perform operation + */ + + sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS, "debug_log \"%s\"", + str_sanitize(str_c(message), 80)); + + sieve_runtime_log(renv, NULL, "DEBUG: %s", str_c(message)); + + return SIEVE_EXEC_OK; +} diff -r 560057691dac -r 9d328e6732ff src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug-common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug-common.h Mon Jun 06 16:59:39 2011 +0200 @@ -0,0 +1,25 @@ +/* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file + */ + +#ifndef __EXT_DEBUG_COMMON_H +#define __EXT_DEBUG_COMMON_H + +/* From dovecot at dovecot.org Mon Jun 6 18:06:40 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Jun 2011 18:06:40 +0300 Subject: dovecot-2.0: lib-signals: Removed unnecessary code. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0c6a9b907656 changeset: 12841:0c6a9b907656 user: Timo Sirainen date: Mon Jun 06 18:06:22 2011 +0300 description: lib-signals: Removed unnecessary code. diffstat: src/lib/lib-signals.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diffs (43 lines): diff -r a2d57b43ccb2 -r 0c6a9b907656 src/lib/lib-signals.c --- a/src/lib/lib-signals.c Fri Jun 03 18:54:27 2011 +0300 +++ b/src/lib/lib-signals.c Mon Jun 06 18:06:22 2011 +0300 @@ -196,7 +196,7 @@ } } -static void lib_signals_set(int signo, bool ignore) +static void lib_signals_set(int signo) { struct sigaction act; @@ -204,10 +204,10 @@ i_fatal("sigemptyset(): %m"); #ifdef SA_SIGINFO act.sa_flags = SA_SIGINFO; - act.sa_sigaction = ignore ? sig_ignore : sig_handler; + act.sa_sigaction = sig_handler; #else act.sa_flags = 0; - act.sa_handler = ignore ? sig_ignore : sig_handler; + act.sa_handler = sig_handler; #endif if (sigaction(signo, &act, NULL) < 0) i_fatal("sigaction(%d): %m", signo); @@ -226,7 +226,7 @@ } if (signal_handlers[signo] == NULL && signals_initialized) - lib_signals_set(signo, FALSE); + lib_signals_set(signo); if (delayed && sig_pipe_fd[0] == -1) { /* first delayed handler */ @@ -317,7 +317,7 @@ /* add signals that were already registered */ for (i = 0; i < MAX_SIGNAL_VALUE; i++) { if (signal_handlers[i] != NULL) - lib_signals_set(i, FALSE); + lib_signals_set(i); } if (sig_pipe_fd[0] != -1) From dovecot at dovecot.org Mon Jun 6 18:26:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Jun 2011 18:26:55 +0300 Subject: dovecot-2.0: lib_signals_set_handler(): Changed API to take flag... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/86e4023d08e4 changeset: 12842:86e4023d08e4 user: Timo Sirainen date: Mon Jun 06 18:25:52 2011 +0300 description: lib_signals_set_handler(): Changed API to take flags instead of boolean. This is still compatible with the old API, because using FALSE/TRUE as the flags still maps to the same behavior. diffstat: src/lib/lib-signals.c | 20 +++++++++++--------- src/lib/lib-signals.h | 14 +++++++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diffs (113 lines): diff -r 0c6a9b907656 -r 86e4023d08e4 src/lib/lib-signals.c --- a/src/lib/lib-signals.c Mon Jun 06 18:06:22 2011 +0300 +++ b/src/lib/lib-signals.c Mon Jun 06 18:25:52 2011 +0300 @@ -24,7 +24,7 @@ signal_handler_t *handler; void *context; - bool delayed; + enum libsig_flags flags; struct signal_handler *next; }; @@ -124,7 +124,7 @@ called at any time. don't do anything that's unsafe. we might also get interrupted by another signal while inside this handler. */ for (h = signal_handlers[signo]; h != NULL; h = h->next) { - if (!h->delayed) + if ((h->flags & LIBSIG_FLAG_DELAYED) == 0) h->handler(si, h->context); else if (pending_signals[signo].si_signo == 0) { pending_signals[signo] = *si; @@ -190,13 +190,13 @@ continue; for (h = signal_handlers[signo]; h != NULL; h = h->next) { - if (h->delayed) + if ((h->flags & LIBSIG_FLAG_DELAYED) != 0) h->handler(&signals[signo], h->context); } } } -static void lib_signals_set(int signo) +static void lib_signals_set(int signo, enum libsig_flags flags) { struct sigaction act; @@ -209,11 +209,13 @@ act.sa_flags = 0; act.sa_handler = sig_handler; #endif + if ((flags & LIBSIG_FLAG_RESTART) != 0) + act.sa_flags |= SA_RESTART; if (sigaction(signo, &act, NULL) < 0) i_fatal("sigaction(%d): %m", signo); } -void lib_signals_set_handler(int signo, bool delayed, +void lib_signals_set_handler(int signo, enum libsig_flags flags, signal_handler_t *handler, void *context) { struct signal_handler *h; @@ -226,9 +228,9 @@ } if (signal_handlers[signo] == NULL && signals_initialized) - lib_signals_set(signo); + lib_signals_set(signo, flags); - if (delayed && sig_pipe_fd[0] == -1) { + if ((flags & LIBSIG_FLAG_DELAYED) != 0 && sig_pipe_fd[0] == -1) { /* first delayed handler */ if (pipe(sig_pipe_fd) < 0) i_fatal("pipe() failed: %m"); @@ -245,7 +247,7 @@ h = i_new(struct signal_handler, 1); h->handler = handler; h->context = context; - h->delayed = delayed; + h->flags = flags; /* atomically set to signal_handlers[] list */ h->next = signal_handlers[signo]; @@ -317,7 +319,7 @@ /* add signals that were already registered */ for (i = 0; i < MAX_SIGNAL_VALUE; i++) { if (signal_handlers[i] != NULL) - lib_signals_set(i); + lib_signals_set(i, signal_handlers[i]->flags); } if (sig_pipe_fd[0] != -1) diff -r 0c6a9b907656 -r 86e4023d08e4 src/lib/lib-signals.h --- a/src/lib/lib-signals.h Mon Jun 06 18:06:22 2011 +0300 +++ b/src/lib/lib-signals.h Mon Jun 06 18:25:52 2011 +0300 @@ -3,6 +3,15 @@ #include +enum libsig_flags { + /* Signal handler will be called later from IO loop when it's safe to + do any kind of work */ + LIBSIG_FLAG_DELAYED = 0x01, + /* Restart syscalls instead of having them fail with EINTR */ + LIBSIG_FLAG_RESTART = 0x02 +}; +#define LIBSIG_FLAGS_SAFE (LIBSIG_FLAG_DELAYED | LIBSIG_FLAG_RESTART) + typedef void signal_handler_t(const siginfo_t *si, void *context); /* Number of times a "termination signal" has been received. @@ -19,9 +28,8 @@ /* Convert si_code to string */ const char *lib_signal_code_to_str(int signo, int sicode); -/* Set signal handler for specific signal. If delayed is TRUE, the handler - will be called later, ie. not as a real signal handler. */ -void lib_signals_set_handler(int signo, bool delayed, +/* Set signal handler for specific signal. */ +void lib_signals_set_handler(int signo, enum libsig_flags flags, signal_handler_t *handler, void *context); /* Ignore given signal. */ void lib_signals_ignore(int signo, bool restart_syscalls); From dovecot at dovecot.org Mon Jun 6 18:26:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Jun 2011 18:26:55 +0300 Subject: dovecot-2.0: Use SA_RESTART flag for signals wherever possible. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/6fdee880c5dc changeset: 12843:6fdee880c5dc user: Timo Sirainen date: Mon Jun 06 18:26:45 2011 +0300 description: Use SA_RESTART flag for signals wherever possible. Only SIGTERM (and SIGINT for standalone programs) shouldn't use it. diffstat: src/auth/auth-cache.c | 6 ++++-- src/auth/mech-winbind.c | 3 ++- src/doveadm/doveadm-mail.c | 4 ++-- src/lib-master/master-service.c | 9 ++++++--- src/lib/child-wait.c | 3 ++- src/log/main.c | 3 ++- src/master/main.c | 13 ++++++++----- src/ssl-params/main.c | 2 +- src/util/maildirlock.c | 4 ++-- 9 files changed, 29 insertions(+), 18 deletions(-) diffs (145 lines): diff -r 86e4023d08e4 -r 6fdee880c5dc src/auth/auth-cache.c --- a/src/auth/auth-cache.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/auth/auth-cache.c Mon Jun 06 18:26:45 2011 +0300 @@ -134,8 +134,10 @@ cache->ttl_secs = ttl_secs; cache->neg_ttl_secs = neg_ttl_secs; - lib_signals_set_handler(SIGHUP, TRUE, sig_auth_cache_clear, cache); - lib_signals_set_handler(SIGUSR2, TRUE, sig_auth_cache_stats, cache); + lib_signals_set_handler(SIGHUP, LIBSIG_FLAGS_SAFE, + sig_auth_cache_clear, cache); + lib_signals_set_handler(SIGUSR2, LIBSIG_FLAGS_SAFE, + sig_auth_cache_stats, cache); return cache; } diff -r 86e4023d08e4 -r 6fdee880c5dc src/auth/mech-winbind.c --- a/src/auth/mech-winbind.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/auth/mech-winbind.c Mon Jun 06 18:26:45 2011 +0300 @@ -152,7 +152,8 @@ if (!sigchld_handler_set) { sigchld_handler_set = TRUE; - lib_signals_set_handler(SIGCHLD, TRUE, sigchld_handler, NULL); + lib_signals_set_handler(SIGCHLD, LIBSIG_FLAGS_SAFE, + sigchld_handler, NULL); } } diff -r 86e4023d08e4 -r 6fdee880c5dc src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/doveadm/doveadm-mail.c Mon Jun 06 18:26:45 2011 +0300 @@ -267,8 +267,8 @@ ctx->storage_service = mail_storage_service_init(master_service, NULL, service_flags); - lib_signals_set_handler(SIGINT, FALSE, sig_die, NULL); - lib_signals_set_handler(SIGTERM, FALSE, sig_die, NULL); + lib_signals_set_handler(SIGINT, 0, sig_die, NULL); + lib_signals_set_handler(SIGTERM, 0, sig_die, NULL); ctx->v.init(ctx, (const void *)argv); if (hook_doveadm_mail_init != NULL) diff -r 86e4023d08e4 -r 6fdee880c5dc src/lib-master/master-service.c --- a/src/lib-master/master-service.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/lib-master/master-service.c Mon Jun 06 18:26:45 2011 +0300 @@ -334,6 +334,7 @@ void master_service_init_finish(struct master_service *service) { + enum libsig_flags sigint_flags = LIBSIG_FLAG_DELAYED; struct stat st; const char *value; unsigned int count; @@ -343,10 +344,12 @@ /* set default signal handlers */ lib_signals_init(); - lib_signals_set_handler(SIGINT, TRUE, sig_die, service); - lib_signals_set_handler(SIGTERM, TRUE, sig_die, service); + if ((service->flags & MASTER_SERVICE_FLAG_STANDALONE) == 0) + sigint_flags |= LIBSIG_FLAG_RESTART; + lib_signals_set_handler(SIGINT, sigint_flags, sig_die, service); + lib_signals_set_handler(SIGTERM, LIBSIG_FLAG_DELAYED, sig_die, service); if ((service->flags & MASTER_SERVICE_FLAG_TRACK_LOGIN_STATE) != 0) { - lib_signals_set_handler(SIGUSR1, TRUE, + lib_signals_set_handler(SIGUSR1, LIBSIG_FLAGS_SAFE, sig_state_changed, service); } diff -r 86e4023d08e4 -r 6fdee880c5dc src/lib/child-wait.c --- a/src/lib/child-wait.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/lib/child-wait.c Mon Jun 06 18:26:45 2011 +0300 @@ -91,7 +91,8 @@ child_pids = hash_table_create(default_pool, default_pool, 0, NULL, NULL); - lib_signals_set_handler(SIGCHLD, TRUE, sigchld_handler, NULL); + lib_signals_set_handler(SIGCHLD, LIBSIG_FLAGS_SAFE, + sigchld_handler, NULL); } void child_wait_deinit(void) diff -r 86e4023d08e4 -r 6fdee880c5dc src/log/main.c --- a/src/log/main.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/log/main.c Mon Jun 06 18:26:45 2011 +0300 @@ -18,7 +18,8 @@ static void main_init(void) { - lib_signals_set_handler(SIGUSR1, TRUE, sig_reopen_logs, NULL); + lib_signals_set_handler(SIGUSR1, LIBSIG_FLAGS_SAFE, + sig_reopen_logs, NULL); log_connections_init(); } diff -r 86e4023d08e4 -r 6fdee880c5dc src/master/main.c --- a/src/master/main.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/master/main.c Mon Jun 06 18:26:45 2011 +0300 @@ -440,11 +440,14 @@ lib_signals_init(); lib_signals_ignore(SIGPIPE, TRUE); lib_signals_ignore(SIGALRM, FALSE); - lib_signals_set_handler(SIGHUP, TRUE, sig_settings_reload, NULL); - lib_signals_set_handler(SIGUSR1, TRUE, sig_log_reopen, NULL); - lib_signals_set_handler(SIGCHLD, TRUE, sig_reap_children, NULL); - lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL); - lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL); + lib_signals_set_handler(SIGHUP, LIBSIG_FLAGS_SAFE, + sig_settings_reload, NULL); + lib_signals_set_handler(SIGUSR1, LIBSIG_FLAGS_SAFE, + sig_log_reopen, NULL); + lib_signals_set_handler(SIGCHLD, LIBSIG_FLAGS_SAFE, + sig_reap_children, NULL); + lib_signals_set_handler(SIGINT, LIBSIG_FLAGS_SAFE, sig_die, NULL); + lib_signals_set_handler(SIGTERM, LIBSIG_FLAGS_SAFE, sig_die, NULL); create_pid_file(pidfile_path); create_config_symlink(set); diff -r 86e4023d08e4 -r 6fdee880c5dc src/ssl-params/main.c --- a/src/ssl-params/main.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/ssl-params/main.c Mon Jun 06 18:26:45 2011 +0300 @@ -109,7 +109,7 @@ static void main_init(const struct ssl_params_settings *set) { - lib_signals_set_handler(SIGCHLD, TRUE, sig_chld, NULL); + lib_signals_set_handler(SIGCHLD, LIBSIG_FLAGS_SAFE, sig_chld, NULL); ssl_params = buffer_create_dynamic(default_pool, 1024); param = ssl_params_init(PKG_STATEDIR"/"SSL_BUILD_PARAM_FNAME, diff -r 86e4023d08e4 -r 6fdee880c5dc src/util/maildirlock.c --- a/src/util/maildirlock.c Mon Jun 06 18:25:52 2011 +0300 +++ b/src/util/maildirlock.c Mon Jun 06 18:26:45 2011 +0300 @@ -63,8 +63,8 @@ lib_init(); lib_signals_init(); ioloop = io_loop_create(); - lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL); - lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL); + lib_signals_set_handler(SIGINT, LIBSIG_FLAG_DELAYED, sig_die, NULL); + lib_signals_set_handler(SIGTERM, LIBSIG_FLAG_DELAYED, sig_die, NULL); if (pid != 0) { close(fd[1]); From dovecot at dovecot.org Tue Jun 7 15:18:26 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 07 Jun 2011 15:18:26 +0300 Subject: dovecot-2.0: ldap: Fixed random assert-crashing with with sasl_b... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/c0734f08b3f3 changeset: 12844:c0734f08b3f3 user: Timo Sirainen date: Tue Jun 07 15:18:19 2011 +0300 description: ldap: Fixed random assert-crashing with with sasl_bind=yes. diffstat: src/auth/db-ldap.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diffs (25 lines): diff -r 6fdee880c5dc -r c0734f08b3f3 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Mon Jun 06 18:26:45 2011 +0300 +++ b/src/auth/db-ldap.c Tue Jun 07 15:18:19 2011 +0300 @@ -328,7 +328,10 @@ struct ldap_request *const *requestp, *request; int ret = -1; - i_assert(conn->pending_count <= aqueue_count(conn->request_queue)); + /* connecting may call db_ldap_connect_finish(), which gets us back + here. so do the connection before checking the request queue. */ + if (db_ldap_connect(conn) < 0) + return FALSE; if (conn->pending_count == aqueue_count(conn->request_queue)) { /* no non-pending requests */ @@ -339,9 +342,6 @@ return FALSE; } - if (db_ldap_connect(conn) < 0) - return FALSE; - requestp = array_idx(&conn->request_array, aqueue_idx(conn->request_queue, conn->pending_count)); From dovecot at dovecot.org Tue Jun 7 16:12:20 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 07 Jun 2011 16:12:20 +0300 Subject: dovecot-2.0: lib-storage: Fixed mail_chroot to work when process... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/ed05316ed441 changeset: 12845:ed05316ed441 user: Timo Sirainen date: Tue Jun 07 16:12:13 2011 +0300 description: lib-storage: Fixed mail_chroot to work when process was already chrooted there. diffstat: src/lib-storage/mail-storage-service.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diffs (61 lines): diff -r c0734f08b3f3 -r ed05316ed441 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Jun 07 15:18:19 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Jun 07 16:12:13 2011 +0300 @@ -382,13 +382,12 @@ rset.first_valid_gid = set->first_valid_gid; rset.last_valid_gid = set->last_valid_gid; - /* we can't chroot if we want to switch between users. there's not - much point either (from security point of view) */ - rset.chroot_dir = *chroot == '\0' || keep_setuid_root ? NULL : chroot; + rset.chroot_dir = *chroot == '\0' ? NULL : chroot; rset.system_groups_user = user->system_groups_user; cur_chroot = restrict_access_get_current_chroot(); if (cur_chroot != NULL) { + /* we're already chrooted. make sure the chroots are equal. */ if (rset.chroot_dir == NULL) { *error_r = "Process is already chrooted, " "can't un-chroot for this user"; @@ -903,6 +902,7 @@ (user->flags & MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT) != 0; bool temp_priv_drop = (user->flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0; + bool use_chroot; /* variable strings are expanded in mail_user_init(), but we need the home and chroot sooner so do them separately here. */ @@ -918,12 +918,19 @@ return -2; } + /* we can't chroot if we want to switch between users. there's + not much point either (from security point of view). but if we're + already chrooted, we'll just have to continue and hope that the + current chroot is the same as the wanted chroot */ + use_chroot = !temp_priv_drop || + restrict_access_get_current_chroot() != NULL; + len = strlen(chroot); if (len > 2 && strcmp(chroot + len - 2, "/.") == 0 && strncmp(home, chroot, len - 2) == 0) { /* mail_chroot = /chroot/. means that the home dir already contains the chroot dir. remove it from home. */ - if (!temp_priv_drop) { + if (use_chroot) { home += len - 2; if (*home == '\0') home = "/"; @@ -932,9 +939,9 @@ set_keyval(ctx, user, "mail_home", home); set_keyval(ctx, user, "mail_chroot", chroot); } - } else if (len > 0 && temp_priv_drop) { - /* we're dropping privileges only temporarily, so we can't - chroot. fix home directory so we can access it. */ + } else if (len > 0 && !use_chroot) { + /* we're not going to chroot. fix home directory so we can + access it. */ if (*home == '\0' || strcmp(home, "/") == 0) home = chroot; else From dovecot at dovecot.org Wed Jun 8 16:04:45 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 08 Jun 2011 16:04:45 +0300 Subject: dovecot-2.0: vpopmail: Fixed opening SMTP relays. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8e5d8c4b103d changeset: 12846:8e5d8c4b103d user: Timo Sirainen date: Wed Jun 08 16:04:35 2011 +0300 description: vpopmail: Fixed opening SMTP relays. Also don't even try to open IPv6 relays, since vpopmail becomes an open relay then. Based on patch by Matt Brookings. diffstat: src/auth/passdb-vpopmail.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (18 lines): diff -r ed05316ed441 -r 8e5d8c4b103d src/auth/passdb-vpopmail.c --- a/src/auth/passdb-vpopmail.c Tue Jun 07 16:12:13 2011 +0300 +++ b/src/auth/passdb-vpopmail.c Wed Jun 08 16:04:35 2011 +0300 @@ -136,11 +136,12 @@ return; } -#ifdef HAVE_VPOPMAIL_OPEN_SMTP_RELAY +#ifdef POP_AUTH_OPEN_RELAY if (strcasecmp(request->service, "POP3") == 0 || strcasecmp(request->service, "IMAP") == 0) { const char *host = net_ip2addr(&request->remote_ip); - if (host != NULL) { + /* vpopmail 5.4 does not understand IPv6 */ + if (host != NULL && 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 From dovecot at dovecot.org Wed Jun 8 16:05:39 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 08 Jun 2011 16:05:39 +0300 Subject: dovecot-2.0: lib-storage: Allow appending to existing settings v... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/778067e9ccc2 changeset: 12847:778067e9ccc2 user: Timo Sirainen date: Wed Jun 08 16:05:32 2011 +0300 description: lib-storage: Allow appending to existing settings via userdb extra fields. "foo=bar" replaces the setting, while "+foo=bar" appends to the setting. diffstat: src/lib-storage/mail-storage-service.c | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) diffs (46 lines): diff -r 8e5d8c4b103d -r 778067e9ccc2 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Wed Jun 08 16:04:35 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Wed Jun 08 16:05:32 2011 +0300 @@ -107,14 +107,20 @@ { struct setting_parser_context *set_parser = user->set_parser; bool mail_debug; - const char *key; + const char *key, *orig_key; + bool append = FALSE; int ret; mail_debug = mail_user_set_get_mail_debug(user->user_info, user->user_set); if (strchr(line, '=') == NULL) line = t_strconcat(line, "=yes", NULL); - key = t_strcut(line, '='); + orig_key = key = t_strcut(line, '='); + + if (*key == '+') { + key++; + append = TRUE; + } if (!settings_parse_is_valid_key(set_parser, key)) { /* assume it's a plugin setting */ @@ -131,6 +137,19 @@ return 1; } + if (append) { + const void *value; + enum setting_type type; + + value = settings_parse_get_value(set_parser, key, &type); + if (type == SET_STR) + line = t_strconcat(line, value, NULL); + else { + i_error("Ignoring %s userdb setting. " + "'+' can only be used for strings.", orig_key); + } + } + ret = settings_parse_line(set_parser, line); if (mail_debug && ret >= 0) { i_debug(ret == 0 ? From dovecot at dovecot.org Fri Jun 10 19:11:08 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 10 Jun 2011 19:11:08 +0300 Subject: dovecot-2.0: lib-storage: When "Recent flags state corrupted" ha... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/3e1ee816271d changeset: 12848:3e1ee816271d user: Timo Sirainen date: Fri Jun 10 19:11:00 2011 +0300 description: lib-storage: When "Recent flags state corrupted" happens, avoid assert-crashing afterwards. diffstat: src/lib-storage/index/index-sync.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 778067e9ccc2 -r 3e1ee816271d src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Wed Jun 08 16:05:32 2011 +0300 +++ b/src/lib-storage/index/index-sync.c Fri Jun 10 19:11:00 2011 +0300 @@ -44,6 +44,7 @@ "Recent flags state corrupted for mailbox %s", box->vname); array_clear(&ibox->recent_flags); + ibox->recent_flags_count = 0; } ibox->recent_flags_prev_uid = uid; From dovecot at dovecot.org Mon Jun 13 17:18:15 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Jun 2011 17:18:15 +0300 Subject: dovecot-2.0: lmtp: Fixed parsing quoted strings with spaces as l... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/09b8701362a4 changeset: 12849:09b8701362a4 user: Timo Sirainen date: Mon Jun 13 17:17:59 2011 +0300 description: lmtp: Fixed parsing quoted strings with spaces as local-part for MAIL FROM and RCPT TO. diffstat: src/lmtp/commands.c | 61 ++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 44 insertions(+), 17 deletions(-) diffs (111 lines): diff -r 3e1ee816271d -r 09b8701362a4 src/lmtp/commands.c --- a/src/lmtp/commands.c Fri Jun 10 19:11:00 2011 +0300 +++ b/src/lmtp/commands.c Mon Jun 13 17:17:59 2011 +0300 @@ -76,25 +76,57 @@ return 0; } +static int parse_address(const char *str, const char **address_r, + const char **rest_r) +{ + const char *start; + + if (*str++ != '<') + return -1; + start = str; + if (*str == '"') { + /* "quoted-string"@domain */ + for (str++; *str != '"'; str++) { + if (*str == '\\') + str++; + if (*str == '\0') + return -1; + } + str++; + } + for (; *str != '>'; str++) { + if (*str == '\0' || *str == ' ') + return -1; + } + *address_r = t_strdup_until(start, str); + if (*str++ != '>') + return -1; + + if (*str == ' ') + str++; + else if (*str != '\0') + return -1; + *rest_r = str; + return 0; +} + int cmd_mail(struct client *client, const char *args) { const char *addr, *const *argv; - unsigned int len; if (client->state.mail_from != NULL) { client_send_line(client, "503 5.5.1 MAIL already given"); return 0; } - argv = t_strsplit(args, " "); - addr = argv[0] == NULL ? "" : argv[0]; - len = strlen(addr); - if (strncasecmp(addr, "FROM:<", 6) != 0 || addr[len-1] != '>') { + if (strncasecmp(args, "FROM:", 5) != 0 || + parse_address(args + 5, &addr, &args) < 0) { client_send_line(client, "501 5.5.4 Invalid parameters"); return 0; } - for (argv++; *argv != NULL; argv++) { + argv = t_strsplit(args, " "); + for (; *argv != NULL; argv++) { if (strcasecmp(*argv, "BODY=7BIT") == 0) client->state.mail_body_7bit = TRUE; else if (strcasecmp(*argv, "BODY=8BITMIME") == 0) @@ -106,8 +138,7 @@ } } - client->state.mail_from = - p_strndup(client->state_pool, addr + 6, len - 7); + client->state.mail_from = p_strdup(client->state_pool, addr); p_array_init(&client->state.rcpt_to, client->state_pool, 64); client_send_line(client, "250 2.1.0 OK"); return 0; @@ -351,8 +382,7 @@ struct mail_recipient rcpt; struct mail_storage_service_input input; const char *address, *username, *detail, *prefix; - const char *error = NULL, *arg, *const *argv; - unsigned int len; + const char *error = NULL; int ret = 0; if (client->state.mail_from == NULL) { @@ -360,19 +390,16 @@ return 0; } - argv = t_strsplit(args, " "); - arg = argv[0] == NULL ? "" : argv[0]; - len = strlen(arg); - if (strncasecmp(arg, "TO:<", 4) != 0 || arg[len-1] != '>') { + if (strncasecmp(args, "TO:", 3) != 0 || + parse_address(args + 3, &address, &args) < 0) { client_send_line(client, "501 5.5.4 Invalid parameters"); return 0; } - argv++; memset(&rcpt, 0, sizeof(rcpt)); - address = lmtp_unescape_address(t_strndup(arg + 4, len - 5)); + address = lmtp_unescape_address(address); - if (*argv != NULL) { + if (*args != '\0') { client_send_line(client, "501 5.5.4 Unsupported options"); return 0; } From dovecot at dovecot.org Tue Jun 14 17:00:07 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 14 Jun 2011 17:00:07 +0300 Subject: dovecot-2.0: Moved the main functionality from "doveadm index" t... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8c76426a9e53 changeset: 12850:8c76426a9e53 user: Timo Sirainen date: Tue Jun 14 16:59:57 2011 +0300 description: Moved the main functionality from "doveadm index" to MAILBOX_SYNC_FLAG_PRECACHE This also allows plugins to hook into the sync and implement their own precaching easily. fts indexing is now done this way rather than kludging. diffstat: src/doveadm/doveadm-mail-index.c | 174 +-------------------------------- src/lib-storage/index/index-sync.c | 132 +++++++++++++++++++++++++ src/lib-storage/mail-storage-private.h | 1 + src/lib-storage/mail-storage.h | 4 +- src/plugins/fts/fts-storage.c | 90 +++++++++++++--- 5 files changed, 210 insertions(+), 191 deletions(-) diffs (truncated from 523 to 300 lines): diff -r 09b8701362a4 -r 8c76426a9e53 src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Mon Jun 13 17:17:59 2011 +0300 +++ b/src/doveadm/doveadm-mail-index.c Tue Jun 14 16:59:57 2011 +0300 @@ -6,165 +6,11 @@ #include "mail-search-build.h" #include "doveadm-mail.h" -enum cache_mask { - CACHE_HDR = 0x01, - CACHE_BODY = 0x02, - CACHE_RECEIVED_DATE = 0x04, - CACHE_SAVE_DATE = 0x08, - CACHE_VIRTUAL_SIZE = 0x10, - CACHE_PHYSICAL_SIZE = 0x20, - CACHE_POP3_UIDL = 0x40, - CACHE_GUID = 0x80 -}; - -static bool fts_is_enabled = FALSE; - -static enum cache_mask cache_fields_get(const struct mailbox_status *status) -{ - const char *const *cache_fields; - unsigned int i, count; - enum cache_mask cache = 0; - - cache_fields = array_get(status->cache_fields, &count); - for (i = 0; i < count; i++) { - if (strncmp(cache_fields[i], "hdr.", 4) == 0 || - strcmp(cache_fields[i], "date.sent") == 0 || - strcmp(cache_fields[i], "imap.envelope") == 0) - cache |= CACHE_HDR; - else if (strcmp(cache_fields[i], "mime.parts") == 0 || - strcmp(cache_fields[i], "imap.body") == 0 || - strcmp(cache_fields[i], "imap.bodystructure") == 0) - cache |= CACHE_BODY; - else if (strcmp(cache_fields[i], "date.received") == 0) - cache |= CACHE_RECEIVED_DATE; - else if (strcmp(cache_fields[i], "date.save") == 0) - cache |= CACHE_SAVE_DATE; - else if (strcmp(cache_fields[i], "size.virtual") == 0) - cache |= CACHE_VIRTUAL_SIZE; - else if (strcmp(cache_fields[i], "size.physical") == 0) - cache |= CACHE_PHYSICAL_SIZE; - else if (strcmp(cache_fields[i], "pop3.uidl") == 0) - cache |= CACHE_POP3_UIDL; - else if (strcmp(cache_fields[i], "guid") == 0) - cache |= CACHE_GUID; - else if (doveadm_debug) { - i_debug("Ignoring unknown cache field: %s", - cache_fields[i]); - } - } - return cache; -} - -static int cache_add(struct mailbox *box, const struct mailbox_status *status, - enum cache_mask cache) -{ - struct mailbox_transaction_context *trans; - struct mail *mail; - uint32_t seq; - time_t date; - uoff_t size; - const char *str; - - if (doveadm_debug) { - i_debug("%s: Nothing in mailbox cache, skipping", - mailbox_get_vname(box)); - return 0; - } - - /* find the first message we need to index */ - trans = mailbox_transaction_begin(box, 0); - mail = mail_alloc(trans, 0, NULL); - for (seq = status->messages; seq > 0; seq--) { - mail_set_seq(mail, seq); - if (mail_is_cached(mail)) - break; - } - seq++; - - if (doveadm_debug) { - if (seq > status->messages) { - i_debug("%s: Cache is already up to date", - mailbox_get_vname(box)); - } else { - i_debug("%s: Caching mails seq=%u..%u cache=0x%x", - mailbox_get_vname(box), - seq, status->messages, cache); - } - } - - for (; seq <= status->messages; seq++) { - mail_set_seq(mail, seq); - - if ((cache & (CACHE_HDR | CACHE_BODY)) != 0) - mail_parse(mail, (cache & CACHE_BODY) != 0); - if ((cache & CACHE_RECEIVED_DATE) != 0) - (void)mail_get_received_date(mail, &date); - if ((cache & CACHE_SAVE_DATE) != 0) - (void)mail_get_save_date(mail, &date); - if ((cache & CACHE_VIRTUAL_SIZE) != 0) - (void)mail_get_virtual_size(mail, &size); - if ((cache & CACHE_PHYSICAL_SIZE) != 0) - (void)mail_get_physical_size(mail, &size); - if ((cache & CACHE_POP3_UIDL) != 0) { - (void)mail_get_special(mail, MAIL_FETCH_UIDL_BACKEND, - &str); - } - if ((cache & CACHE_GUID) != 0) - (void)mail_get_special(mail, MAIL_FETCH_GUID, &str); - } - mail_free(&mail); - if (mailbox_transaction_commit(&trans) < 0) { - i_error("Commiting mailbox %s failed: %s", - mailbox_get_vname(box), - mail_storage_get_last_error(mailbox_get_storage(box), NULL)); - return -1; - } - return 0; -} - -static int fts_update(struct mailbox *box, const struct mailbox_status *status) -{ - struct mailbox_transaction_context *t; - struct mail_search_args *search_args; - struct mail_search_arg *arg; - struct mail_search_context *ctx; - struct mail *mail; - int ret; - - if (!fts_is_enabled) - return 0; - - /* a bit kludgy way to trigger the full text search update: - search for a string in the last message */ - t = mailbox_transaction_begin(box, 0); - search_args = mail_search_build_init(); - search_args->charset = "UTF-8"; - mail_search_build_add_seqset(search_args, - status->messages, status->messages); - arg = mail_search_build_add(search_args, SEARCH_BODY_FAST); - arg->value.str = "xyzzy"; - - ctx = mailbox_search_init(t, search_args, NULL); - mail_search_args_unref(&search_args); - - mail = mail_alloc(t, 0, NULL); - while (mailbox_search_next(ctx, mail)) { - } - mail_free(&mail); - - ret = mailbox_search_deinit(&ctx); - if (mailbox_transaction_commit(&t) < 0) - ret = -1; - return ret; -} - static int cmd_index_box(const struct mailbox_info *info) { struct mailbox *box; - struct mailbox_status status; const char *storage_name; - enum cache_mask cache; int ret = 0; storage_name = mail_namespace_get_storage_name(info->ns, info->name); @@ -172,19 +18,13 @@ MAILBOX_FLAG_KEEP_RECENT | MAILBOX_FLAG_IGNORE_ACLS); - if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { + if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ | + MAILBOX_SYNC_FLAG_PRECACHE) < 0) { i_error("Syncing mailbox %s failed: %s", info->name, mail_storage_get_last_error(mailbox_get_storage(box), NULL)); mailbox_free(&box); return -1; } - mailbox_get_status(box, STATUS_MESSAGES | STATUS_CACHE_FIELDS, &status); - - cache = cache_fields_get(&status); - ret = cache_add(box, &status, cache); - - if (fts_update(box, &status) < 0) - ret = -1; mailbox_free(&box); return ret; @@ -203,16 +43,6 @@ struct mailbox_list_iterate_context *iter; const struct mailbox_info *info; - if (mail_user_plugin_getenv(user, "fts") != NULL) T_BEGIN { - const char *const *plugins; - - plugins = t_strsplit(user->set->mail_plugins, " "); - for (; *plugins != NULL; plugins++) { - if (strncmp(*plugins, "fts", 3) == 0) - fts_is_enabled = TRUE; - } - } T_END; - iter = mailbox_list_iter_init_namespaces(user->namespaces, ctx->args, ns_mask, iter_flags); while ((info = mailbox_list_iter_next(iter)) != NULL) { diff -r 09b8701362a4 -r 8c76426a9e53 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Mon Jun 13 17:17:59 2011 +0300 +++ b/src/lib-storage/index/index-sync.c Tue Jun 14 16:59:57 2011 +0300 @@ -6,6 +6,17 @@ #include "array.h" #include "index-sync-private.h" +enum cache_mask { + CACHE_HDR = 0x01, + CACHE_BODY = 0x02, + CACHE_RECEIVED_DATE = 0x04, + CACHE_SAVE_DATE = 0x08, + CACHE_VIRTUAL_SIZE = 0x10, + CACHE_PHYSICAL_SIZE = 0x20, + CACHE_POP3_UIDL = 0x40, + CACHE_GUID = 0x80 +}; + enum mail_index_sync_flags index_storage_get_sync_flags(struct mailbox *box) { enum mail_index_sync_flags sync_flags = 0; @@ -177,6 +188,7 @@ ctx = i_new(struct index_mailbox_sync_context, 1); ctx->ctx.box = box; + ctx->ctx.flags = flags; if (failed) { ctx->failed = TRUE; @@ -324,6 +336,121 @@ #endif } +static enum cache_mask +cache_fields_get(const struct mailbox_status *status, bool debug) +{ + const char *const *cache_fields; + unsigned int i, count; + enum cache_mask cache = 0; + + cache_fields = array_get(status->cache_fields, &count); + for (i = 0; i < count; i++) { + if (strncmp(cache_fields[i], "hdr.", 4) == 0 || + strcmp(cache_fields[i], "date.sent") == 0 || + strcmp(cache_fields[i], "imap.envelope") == 0) + cache |= CACHE_HDR; + else if (strcmp(cache_fields[i], "mime.parts") == 0 || + strcmp(cache_fields[i], "imap.body") == 0 || + strcmp(cache_fields[i], "imap.bodystructure") == 0) + cache |= CACHE_BODY; + else if (strcmp(cache_fields[i], "date.received") == 0) + cache |= CACHE_RECEIVED_DATE; + else if (strcmp(cache_fields[i], "date.save") == 0) + cache |= CACHE_SAVE_DATE; + else if (strcmp(cache_fields[i], "size.virtual") == 0) + cache |= CACHE_VIRTUAL_SIZE; + else if (strcmp(cache_fields[i], "size.physical") == 0) + cache |= CACHE_PHYSICAL_SIZE; + else if (strcmp(cache_fields[i], "pop3.uidl") == 0) + cache |= CACHE_POP3_UIDL; + else if (strcmp(cache_fields[i], "guid") == 0) + cache |= CACHE_GUID; + else if (debug) { + i_debug("Ignoring unknown cache field: %s", + cache_fields[i]); + } + } + return cache; +} + +static int cache_add(struct mailbox *box, const struct mailbox_status *status, + enum cache_mask cache) +{ + struct mailbox_transaction_context *trans; + struct mail *mail; + uint32_t seq; + time_t date; + uoff_t size; + const char *str; + + if (box->storage->set->mail_debug) { + i_debug("%s: Nothing in mailbox cache, skipping", + mailbox_get_vname(box)); + return 0; + } + + /* find the first message we need to index */ + trans = mailbox_transaction_begin(box, 0); + mail = mail_alloc(trans, 0, NULL); + for (seq = status->messages; seq > 0; seq--) { + mail_set_seq(mail, seq); + if (mail_is_cached(mail)) From dovecot at dovecot.org Thu Jun 16 16:37:50 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Jun 2011 16:37:50 +0300 Subject: dovecot-2.0: ssl-params: Make sure we don't leak a timeout. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/327486d79620 changeset: 12851:327486d79620 user: Timo Sirainen date: Thu Jun 16 16:37:42 2011 +0300 description: ssl-params: Make sure we don't leak a timeout. diffstat: src/ssl-params/main.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (17 lines): diff -r 8c76426a9e53 -r 327486d79620 src/ssl-params/main.c --- a/src/ssl-params/main.c Tue Jun 14 16:59:57 2011 +0300 +++ b/src/ssl-params/main.c Thu Jun 16 16:37:42 2011 +0300 @@ -83,8 +83,11 @@ ran us at startup to make sure ssl parameters are generated asap. if we're here because of that, don't bother hanging around to see if we get any client connections. */ - to_startup = timeout_add(STARTUP_IDLE_TIMEOUT_MSECS, - master_service_stop, master_service); + if (to_startup == NULL) { + to_startup = timeout_add(STARTUP_IDLE_TIMEOUT_MSECS, + master_service_stop, + master_service); + } return; } From pigeonhole at rename-it.nl Tue Jun 21 17:10:38 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Tue, 21 Jun 2011 16:10:38 +0200 Subject: dovecot-2.0-pigeonhole: Fixed a few minor textual problems in th... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/de8753dad82f changeset: 1501:de8753dad82f user: Stephan Bosch date: Tue Jun 21 17:18:58 2011 +0200 description: Fixed a few minor textual problems in the manual pages. diffstat: doc/man/sieve-dump.1.in | 6 +++--- doc/man/sieve-filter.1.in | 2 +- doc/man/sieve-test.1.in | 4 ++-- doc/man/sievec.1.in | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diffs (99 lines): diff -r 9d328e6732ff -r de8753dad82f doc/man/sieve-dump.1.in --- a/doc/man/sieve-dump.1.in Mon Jun 06 16:59:39 2011 +0200 +++ b/doc/man/sieve-dump.1.in Tue Jun 21 17:18:58 2011 +0200 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Pigeonhole authors, see the included COPYING file -.TH "SIEVE\-DUMP" 1 "2011-02-23" "Pigeonhole for Dovecot v2.0" "Pigeonhole" +.TH "SIEVE\-DUMP" 1 "2011-06-21" "Pigeonhole for Dovecot v2.0" "Pigeonhole" .\"------------------------------------------------------------------------ .SH NAME sieve\-dump \- Pigeonhole\(aqs Sieve script binary dump tool @@ -72,7 +72,7 @@ will exit with one of the following values: .TP 4 .B 0 -Delivery was successful. (EX_OK, EXIT_SUCCES) +Dump was successful. (EX_OK, EXIT_SUCCES) .TP .B 1 Operation failed. This is returned for almost all failures. @@ -96,4 +96,4 @@ .BR dovecot\-lda (1), .BR sieve\-test (1), .BR sievec (1), -.BR pigeonhole (7) \ No newline at end of file +.BR pigeonhole (7) diff -r 9d328e6732ff -r de8753dad82f doc/man/sieve-filter.1.in --- a/doc/man/sieve-filter.1.in Mon Jun 06 16:59:39 2011 +0200 +++ b/doc/man/sieve-filter.1.in Tue Jun 21 17:18:58 2011 +0200 @@ -221,4 +221,4 @@ .BR sieve\-dump (1), .BR sieve\-test (1), .BR sievec (1), -.BR pigeonhole (7) \ No newline at end of file +.BR pigeonhole (7) diff -r 9d328e6732ff -r de8753dad82f doc/man/sieve-test.1.in --- a/doc/man/sieve-test.1.in Mon Jun 06 16:59:39 2011 +0200 +++ b/doc/man/sieve-test.1.in Tue Jun 21 17:18:58 2011 +0200 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Pigeonhole authors, see the included COPYING file -.TH "SIEVE\-TEST" 1 "2011-06-06" "Pigeonhole for Dovecot v2.0" "Pigeonhole" +.TH "SIEVE\-TEST" 1 "2011-06-21" "Pigeonhole for Dovecot v2.0" "Pigeonhole" .SH NAME sieve\-test \- Pigeonhole\(aqs Sieve script tester .\"------------------------------------------------------------------------ @@ -196,7 +196,7 @@ will exit with one of the following values: .TP 4 .B 0 -Delivery was successful. (EX_OK, EXIT_SUCCES) +Execution was successful. (EX_OK, EXIT_SUCCES) .TP .B 1 Operation failed. This is returned for almost all failures. diff -r 9d328e6732ff -r de8753dad82f doc/man/sievec.1.in --- a/doc/man/sievec.1.in Mon Jun 06 16:59:39 2011 +0200 +++ b/doc/man/sievec.1.in Tue Jun 21 17:18:58 2011 +0200 @@ -1,5 +1,5 @@ .\" Copyright (c) 2010-2011 Pigeonhole authors, see the included COPYING file -.TH "SIEVEC" 1 "2011-02-23" "Pigeonhole for Dovecot v2.0" "Pigeonhole" +.TH "SIEVEC" 1 "2011-06-21" "Pigeonhole for Dovecot v2.0" "Pigeonhole" .\"------------------------------------------------------------------------ .SH NAME sievec \- Pigeonhole\(aqs Sieve script compiler @@ -12,7 +12,7 @@ .\"------------------------------------------------------------------------ .SH DESCRIPTION .PP -The \fBsieve\-dump\fP command is part of the Pigeonhole Project +The \fBsievec\fP command is part of the Pigeonhole Project (\fBpigeonhole\fR(7)), which adds Sieve (RFC 5228) support to the Dovecot secure IMAP and POP3 server (\fBdovecot\fR(1)). .PP @@ -21,7 +21,7 @@ messages during the delivery process. The delivery of mail messages and \- by means of the LDA Sieve plugin \- also the execution of Sieve scripts is performed by Dovecot\(aqs local delivery agent (LDA) called \fBdovecot\-lda\fP(1). -Usually, it is not necessaryto compile the Sieve script manually using +Usually, it is not necessary to compile the Sieve script manually using \fBsievec\fP, because \fBdovecot\-lda\fP will do this automatically if the binary is missing. However, in some cases \fBdovecot\-lda\fP does not have permission to write the compiled binary to disk, forcing it to recompile the script every time @@ -91,7 +91,7 @@ will exit with one of the following values: .TP 4 .B 0 -Delivery was successful. (EX_OK, EXIT_SUCCES) +Compile was successful. (EX_OK, EXIT_SUCCES) .TP .B 1 Operation failed. This is returned for almost all failures. @@ -115,4 +115,4 @@ .BR dovecot\-lda (1), .BR sieve\-dump (1), .BR sieve\-test (1), -.BR pigeonhole (7) \ No newline at end of file +.BR pigeonhole (7) From dovecot at dovecot.org Wed Jun 22 20:16:26 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 22 Jun 2011 20:16:26 +0300 Subject: dovecot-2.0: lib-storage: MAILBOX_SYNC_FLAG_PRECACHE did nothing... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/fcc4ff5b83c4 changeset: 12852:fcc4ff5b83c4 user: Timo Sirainen date: Wed Jun 22 20:16:16 2011 +0300 description: lib-storage: MAILBOX_SYNC_FLAG_PRECACHE did nothing when mail_debug=yes diffstat: src/lib-storage/index/index-sync.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diffs (18 lines): diff -r 327486d79620 -r fcc4ff5b83c4 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Thu Jun 16 16:37:42 2011 +0300 +++ b/src/lib-storage/index/index-sync.c Wed Jun 22 20:16:16 2011 +0300 @@ -383,9 +383,11 @@ uoff_t size; const char *str; - if (box->storage->set->mail_debug) { - i_debug("%s: Nothing in mailbox cache, skipping", - mailbox_get_vname(box)); + if (cache == 0) { + if (box->storage->set->mail_debug) { + i_debug("%s: Nothing in mailbox cache, skipping", + mailbox_get_vname(box)); + } return 0; } From dovecot at dovecot.org Wed Jun 22 20:26:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 22 Jun 2011 20:26:31 +0300 Subject: dovecot-2.0: lib-storage: Fixed +key=value support to actually w... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/3d07ab746a67 changeset: 12853:3d07ab746a67 user: Timo Sirainen date: Wed Jun 22 20:26:24 2011 +0300 description: lib-storage: Fixed +key=value support to actually work. diffstat: src/lib-storage/mail-storage-service.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diffs (46 lines): diff -r fcc4ff5b83c4 -r 3d07ab746a67 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Wed Jun 22 20:16:16 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Wed Jun 22 20:26:24 2011 +0300 @@ -107,8 +107,7 @@ { struct setting_parser_context *set_parser = user->set_parser; bool mail_debug; - const char *key, *orig_key; - bool append = FALSE; + const char *key, *orig_key, *append_value = NULL; int ret; mail_debug = mail_user_set_get_mail_debug(user->user_info, @@ -118,8 +117,9 @@ orig_key = key = t_strcut(line, '='); if (*key == '+') { + append_value = line + strlen(key) + 1; key++; - append = TRUE; + line++; } if (!settings_parse_is_valid_key(set_parser, key)) { @@ -137,14 +137,17 @@ return 1; } - if (append) { + if (append_value != NULL) { const void *value; enum setting_type type; value = settings_parse_get_value(set_parser, key, &type); - if (type == SET_STR) - line = t_strconcat(line, value, NULL); - else { + if (type == SET_STR) { + const char *const *strp = value; + + line = t_strdup_printf("%s=%s%s", + key, *strp, append_value); + } else { i_error("Ignoring %s userdb setting. " "'+' can only be used for strings.", orig_key); } From pigeonhole at rename-it.nl Wed Jun 22 19:25:22 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 22 Jun 2011 18:25:22 +0200 Subject: dovecot-2.0-pigeonhole: Finished testsuite item for the imap4fla... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/9b3368611f32 changeset: 1502:9b3368611f32 user: Stephan Bosch date: Wed Jun 22 19:33:49 2011 +0200 description: Finished testsuite item for the imap4flags extension. diffstat: tests/extensions/imap4flags/execute.svtest | 48 +++++++++++++++++++++++- 1 files changed, 47 insertions(+), 1 deletions(-) diffs (63 lines): diff -r de8753dad82f -r 9b3368611f32 tests/extensions/imap4flags/execute.svtest --- a/tests/extensions/imap4flags/execute.svtest Tue Jun 21 17:18:58 2011 +0200 +++ b/tests/extensions/imap4flags/execute.svtest Wed Jun 22 19:33:49 2011 +0200 @@ -1,7 +1,10 @@ require "vnd.dovecot.testsuite"; +require "imap4flags"; +require "relational"; + /* - * Execution testing (currently just meant to trigger any segfaults) + * Execution testing */ test_mailbox_create "INBOX.Junk"; @@ -19,4 +22,47 @@ if not test_result_execute { test_fail "result execute failed"; } + + test_result_reset; + + if not test_message :folder "INBOX.Junk" 0 { + test_fail "message not stored in INBOX.Junk"; + } + + if not hasflag :count "eq" "1" { + test_fail "invalid number of flags for message in INBOX.Junk"; + } + + if not hasflag :is "NONSENSE" { + test_fail "invalid flag set for message in INBOX.Junk"; + } + + test_result_reset; + + if not test_message :folder "INBOX" 0 { + test_fail "message not stored in INBOX"; + } + + if not hasflag :count "eq" "1" { + test_fail "invalid number of flags for message in INBOX"; + } + + if not hasflag :is "\\seen" { + test_fail "invalid flag set for message in INBOX"; + } + + test_result_reset; + + if not test_message :folder "INBOX.Nonsense" 0 { + test_fail "message not stored in INBOX.Nonsense"; + } + + if not hasflag :count "eq" "1" { + test_fail "invalid number of flags for message in Inbox.Nonsense"; + } + + if not hasflag :is "IMPLICIT" { + test_fail "invalid flag set for message in Inbox.Nonsene"; + } + } From pigeonhole at rename-it.nl Wed Jun 22 19:48:10 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 22 Jun 2011 18:48:10 +0200 Subject: dovecot-2.0-pigeonhole: lib-sieve: made sure that flags and keyw... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/850d5748a115 changeset: 1503:850d5748a115 user: Stephan Bosch date: Wed Jun 22 19:56:29 2011 +0200 description: lib-sieve: made sure that flags and keywords are only checked when the mailbox is actually opened. diffstat: src/lib-sieve/sieve-actions.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 9b3368611f32 -r 850d5748a115 src/lib-sieve/sieve-actions.c --- a/src/lib-sieve/sieve-actions.c Wed Jun 22 19:33:49 2011 +0200 +++ b/src/lib-sieve/sieve-actions.c Wed Jun 22 19:56:29 2011 +0200 @@ -256,7 +256,7 @@ const char *kw_error; - if ( trans->box != NULL ) { + if ( trans->box != NULL && trans->error_code == MAIL_ERROR_NONE ) { if ( mailbox_keyword_is_valid(trans->box, *kw, &kw_error) ) array_append(&trans->keywords, kw, 1); else { From pigeonhole at rename-it.nl Wed Jun 22 22:09:07 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 22 Jun 2011 21:09:07 +0200 Subject: dovecot-2.0-pigeonhole: Sieve tools: started using mail_namespac... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/b9050c63a238 changeset: 1504:b9050c63a238 user: Stephan Bosch date: Wed Jun 22 22:17:28 2011 +0200 description: Sieve tools: started using mail_namespaces_init_location instead of mail_namespaces_init_empty. diffstat: src/lib-sieve-tool/sieve-tool.c | 16 ++++------------ src/sieve-tools/sieve-test.c | 2 +- src/testsuite/testsuite.c | 6 +----- 3 files changed, 6 insertions(+), 18 deletions(-) diffs (65 lines): diff -r 850d5748a115 -r b9050c63a238 src/lib-sieve-tool/sieve-tool.c --- a/src/lib-sieve-tool/sieve-tool.c Wed Jun 22 19:56:29 2011 +0200 +++ b/src/lib-sieve-tool/sieve-tool.c Wed Jun 22 22:17:28 2011 +0200 @@ -337,10 +337,7 @@ { struct mail_user *mail_user_dovecot = tool->mail_user_dovecot; const char *username = tool->username; - struct mail_namespace_settings ns_set; struct mail_namespace *ns = NULL; - enum mail_storage_flags storage_flags = - MAIL_STORAGE_FLAG_NO_AUTOCREATE; const char *home = NULL, *errstr = NULL; tool->mail_user = mail_user_alloc @@ -353,17 +350,12 @@ if ( mail_user_init(tool->mail_user, &errstr) < 0 ) i_fatal("Test user initialization failed: %s", errstr); - memset(&ns_set, 0, sizeof(ns_set)); - ns_set.location = mail_location; - ns_set.inbox = TRUE; - ns_set.subscriptions = TRUE; + if ( mail_namespaces_init_location + (tool->mail_user, mail_location, &errstr) < 0 ) + i_fatal("Test storage creation failed: %s", errstr); - ns = mail_namespaces_init_empty(tool->mail_user); + ns = tool->mail_user->namespaces; ns->flags |= NAMESPACE_FLAG_NOQUOTA | NAMESPACE_FLAG_NOACL; - ns->set = &ns_set; - - if ( mail_storage_create(ns, NULL, storage_flags, &errstr) < 0 ) - i_fatal("Test storage creation failed: %s", errstr); } struct mail *sieve_tool_open_file_as_mail diff -r 850d5748a115 -r b9050c63a238 src/sieve-tools/sieve-test.c --- a/src/sieve-tools/sieve-test.c Wed Jun 22 19:56:29 2011 +0200 +++ b/src/sieve-tools/sieve-test.c Wed Jun 22 22:17:28 2011 +0200 @@ -207,7 +207,7 @@ } /* Finish tool initialization */ - svinst = sieve_tool_init_finish(sieve_tool, TRUE); + svinst = sieve_tool_init_finish(sieve_tool, execute && mailloc == NULL); /* Enable debug extension */ sieve_enable_debug_extension(svinst); diff -r 850d5748a115 -r b9050c63a238 src/testsuite/testsuite.c --- a/src/testsuite/testsuite.c Wed Jun 22 19:56:29 2011 +0200 +++ b/src/testsuite/testsuite.c Wed Jun 22 22:17:28 2011 +0200 @@ -136,12 +136,8 @@ /* Initialize mail user */ sieve_tool_set_homedir(sieve_tool, t_abspath("")); - /* Set dummy mail environment */ - env_put(t_strdup_printf("MAIL=maildir:/tmp/dovecot-test-%s", - sieve_tool_get_username(sieve_tool))); - /* Finish tool initialization */ - svinst = sieve_tool_init_finish(sieve_tool, TRUE); + svinst = sieve_tool_init_finish(sieve_tool, FALSE); testsuite_init(svinst, log_stdout); testsuite_settings_init(); From pigeonhole at rename-it.nl Sun Jun 26 22:25:51 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 26 Jun 2011 21:25:51 +0200 Subject: dovecot-2.0-pigeonhole: lib-sieve: implemented ihave extension. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/d6c207acbc8d changeset: 1506:d6c207acbc8d user: Stephan Bosch date: Sun Jun 26 22:34:09 2011 +0200 description: lib-sieve: implemented ihave extension. diffstat: Makefile.am | 1 + configure.in | 1 + src/lib-sieve/Makefile.am | 1 + src/lib-sieve/cmd-require.c | 8 +- src/lib-sieve/plugins/Makefile.am | 1 + src/lib-sieve/plugins/ihave/Makefile.am | 18 ++ src/lib-sieve/plugins/ihave/ext-ihave-binary.c | 242 ++++++++++++++++++++++++++++++ src/lib-sieve/plugins/ihave/ext-ihave-binary.h | 36 ++++ src/lib-sieve/plugins/ihave/ext-ihave-common.c | 52 ++++++ src/lib-sieve/plugins/ihave/ext-ihave-common.h | 49 ++++++ src/lib-sieve/plugins/ihave/ext-ihave.c | 65 ++++++++ src/lib-sieve/plugins/ihave/tst-ihave.c | 154 +++++++++++++++++++ src/lib-sieve/sieve-ast.c | 18 +- src/lib-sieve/sieve-ast.h | 4 +- src/lib-sieve/sieve-extensions.c | 6 +- src/lib-sieve/sieve-extensions.h | 6 +- src/lib-sieve/sieve-validator.c | 99 ++++++------ src/lib-sieve/sieve-validator.h | 7 +- tests/extensions/ihave/execute.svtest | 23 ++ tests/extensions/ihave/execute/ihave.sieve | 7 + 20 files changed, 735 insertions(+), 63 deletions(-) diffs (truncated from 1052 to 300 lines): diff -r cf3b58e583ec -r d6c207acbc8d Makefile.am --- a/Makefile.am Sun Jun 26 17:07:53 2011 +0200 +++ b/Makefile.am Sun Jun 26 22:34:09 2011 +0200 @@ -123,6 +123,7 @@ tests/extensions/spamvirustest/virustest.svtest \ tests/extensions/spamvirustest/spamtestplus.svtest \ tests/extensions/spamvirustest/errors.svtest \ + tests/extensions/ihave/execute.svtest \ tests/extensions/vnd.dovecot/debug/execute.svtest \ tests/deprecated/notify/basic.svtest \ tests/deprecated/notify/mailto.svtest \ diff -r cf3b58e583ec -r d6c207acbc8d configure.in --- a/configure.in Sun Jun 26 17:07:53 2011 +0200 +++ b/configure.in Sun Jun 26 22:34:09 2011 +0200 @@ -117,6 +117,7 @@ src/lib-sieve/plugins/mailbox/Makefile src/lib-sieve/plugins/date/Makefile src/lib-sieve/plugins/spamvirustest/Makefile +src/lib-sieve/plugins/ihave/Makefile src/lib-sieve/plugins/vnd.dovecot/Makefile src/lib-sieve/plugins/vnd.dovecot/debug/Makefile src/lib-sieve-tool/Makefile diff -r cf3b58e583ec -r d6c207acbc8d src/lib-sieve/Makefile.am --- a/src/lib-sieve/Makefile.am Sun Jun 26 17:07:53 2011 +0200 +++ b/src/lib-sieve/Makefile.am Sun Jun 26 22:34:09 2011 +0200 @@ -63,6 +63,7 @@ $(extdir)/mailbox/libsieve_ext_mailbox.la \ $(extdir)/date/libsieve_ext_date.la \ $(extdir)/spamvirustest/libsieve_ext_spamvirustest.la \ + $(extdir)/ihave/libsieve_ext_ihave.la \ $(extdir)/vnd.dovecot/debug/libsieve_ext_debug.la \ $(unfinished_plugins) diff -r cf3b58e583ec -r d6c207acbc8d src/lib-sieve/cmd-require.c --- a/src/lib-sieve/cmd-require.c Sun Jun 26 17:07:53 2011 +0200 +++ b/src/lib-sieve/cmd-require.c Sun Jun 26 22:34:09 2011 +0200 @@ -55,8 +55,8 @@ arg = cmd->first_positional; if ( sieve_ast_argument_type(arg) == SAAT_STRING ) { /* Single string */ - const struct sieve_extension *ext = sieve_validator_extension_load - (valdtr, cmd, arg, sieve_ast_argument_str(arg)); + const struct sieve_extension *ext = sieve_validator_extension_load_by_name + (valdtr, cmd, arg, sieve_ast_argument_strc(arg)); if ( ext == NULL ) result = FALSE; @@ -65,8 +65,8 @@ struct sieve_ast_argument *stritem = sieve_ast_strlist_first(arg); while ( stritem != NULL ) { - const struct sieve_extension *ext = sieve_validator_extension_load - (valdtr, cmd, stritem, sieve_ast_strlist_str(stritem)); + const struct sieve_extension *ext = sieve_validator_extension_load_by_name + (valdtr, cmd, stritem, sieve_ast_strlist_strc(stritem)); if ( ext == NULL ) result = FALSE; diff -r cf3b58e583ec -r d6c207acbc8d src/lib-sieve/plugins/Makefile.am --- a/src/lib-sieve/plugins/Makefile.am Sun Jun 26 17:07:53 2011 +0200 +++ b/src/lib-sieve/plugins/Makefile.am Sun Jun 26 22:34:09 2011 +0200 @@ -19,6 +19,7 @@ mailbox \ date \ spamvirustest \ + ihave \ vnd.dovecot \ $(UNFINISHED) diff -r cf3b58e583ec -r d6c207acbc8d src/lib-sieve/plugins/ihave/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sieve/plugins/ihave/Makefile.am Sun Jun 26 22:34:09 2011 +0200 @@ -0,0 +1,18 @@ +noinst_LTLIBRARIES = libsieve_ext_ihave.la + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib-sieve \ + $(LIBDOVECOT_INCLUDE) + +tests = \ + tst-ihave.c + +libsieve_ext_ihave_la_SOURCES = \ + $(tests) \ + ext-ihave-binary.c \ + ext-ihave-common.c \ + ext-ihave.c + +noinst_HEADERS = \ + ext-ihave-binary.h \ + ext-ihave-common.h diff -r cf3b58e583ec -r d6c207acbc8d src/lib-sieve/plugins/ihave/ext-ihave-binary.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sieve/plugins/ihave/ext-ihave-binary.c Sun Jun 26 22:34:09 2011 +0200 @@ -0,0 +1,242 @@ +/* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file + */ + +#include "lib.h" +#include "str.h" + +#include "sieve-common.h" +#include "sieve-extensions.h" +#include "sieve-error.h" +#include "sieve-script.h" +#include "sieve-binary.h" +#include "sieve-generator.h" +#include "sieve-interpreter.h" +#include "sieve-dump.h" + +#include "ext-ihave-common.h" +#include "ext-ihave-binary.h" + +/* + * Forward declarations + */ + +static bool ext_ihave_binary_save + (const struct sieve_extension *ext, struct sieve_binary *sbin, void *context); +static bool ext_ihave_binary_open + (const struct sieve_extension *ext, struct sieve_binary *sbin, void *context); +static bool ext_ihave_binary_up_to_date + (const struct sieve_extension *ext, struct sieve_binary *sbin, void *context); + +/* + * Binary include extension + */ + +const struct sieve_binary_extension ihave_binary_ext = { + &ihave_extension, + ext_ihave_binary_save, + ext_ihave_binary_open, + NULL, + ext_ihave_binary_up_to_date +}; + +/* + * Binary context management + */ + +struct ext_ihave_binary_context { + struct sieve_binary *binary; + struct sieve_binary_block *block; + + ARRAY_DEFINE(missing_extensions, const char *); +}; + +static struct ext_ihave_binary_context *ext_ihave_binary_create_context +(const struct sieve_extension *this_ext, struct sieve_binary *sbin) +{ + pool_t pool = sieve_binary_pool(sbin); + + struct ext_ihave_binary_context *ctx = + p_new(pool, struct ext_ihave_binary_context, 1); + + ctx->binary = sbin; + p_array_init(&ctx->missing_extensions, pool, 64); + + sieve_binary_extension_set(sbin, this_ext, &ihave_binary_ext, ctx); + return ctx; +} + +struct ext_ihave_binary_context *ext_ihave_binary_get_context +(const struct sieve_extension *this_ext, struct sieve_binary *sbin) +{ + struct ext_ihave_binary_context *ctx = (struct ext_ihave_binary_context *) + sieve_binary_extension_get_context(sbin, this_ext); + + if ( ctx == NULL ) + ctx = ext_ihave_binary_create_context(this_ext, sbin); + + return ctx; +} + +struct ext_ihave_binary_context *ext_ihave_binary_init +(const struct sieve_extension *this_ext, struct sieve_binary *sbin, + struct sieve_ast *ast) +{ + struct ext_ihave_ast_context *ast_ctx = + ext_ihave_get_ast_context(this_ext, ast); + struct ext_ihave_binary_context *binctx; + const char *const *exts; + unsigned int i, count; + + binctx = ext_ihave_binary_get_context(this_ext, sbin); + + exts = array_get(&ast_ctx->missing_extensions, &count); + + if ( count > 0 ) { + pool_t pool = sieve_binary_pool(sbin); + + if ( binctx->block == NULL ) + binctx->block = sieve_binary_extension_create_block(sbin, this_ext); + + for ( i = 0; i < count; i++ ) { + const char *ext_name = p_strdup(pool, exts[i]); + + array_append(&binctx->missing_extensions, &ext_name, 1); + } + } + + return binctx; +} + +/* + * Binary extension + */ + +static bool ext_ihave_binary_save +(const struct sieve_extension *ext, struct sieve_binary *sbin, void *context) +{ + struct ext_ihave_binary_context *binctx = + (struct ext_ihave_binary_context *) context; + const char *const *exts; + unsigned int count, i; + + exts = array_get(&binctx->missing_extensions, &count); + + if ( binctx->block != NULL ) + sieve_binary_block_clear(binctx->block); + + if ( count > 0 ) { + if ( binctx->block == NULL ) + binctx->block = sieve_binary_extension_create_block(sbin, ext); + + sieve_binary_emit_unsigned(binctx->block, count); + + for ( i = 0; i < count; i++ ) { + sieve_binary_emit_cstring(binctx->block, exts[i]); + } + } + + return TRUE; +} + +static bool ext_ihave_binary_open +(const struct sieve_extension *ext, struct sieve_binary *sbin, void *context) +{ + struct sieve_instance *svinst = ext->svinst; + struct ext_ihave_binary_context *binctx = + (struct ext_ihave_binary_context *) context; + struct sieve_binary_block *sblock; + unsigned int i, count, block_id; + sieve_size_t offset; + + sblock = sieve_binary_extension_get_block(sbin, ext); + + if ( sblock != NULL ) { + binctx->block = sblock; + block_id = sieve_binary_block_get_id(sblock); + + offset = 0; + + /* Read number of missing extensions to read subsequently */ + if ( !sieve_binary_read_unsigned(sblock, &offset, &count) ) { + sieve_sys_error(svinst, + "ihave: failed to read missing extension count " + "from block %d of binary %s", block_id, sieve_binary_path(sbin)); + return FALSE; + } + + /* Read dependencies */ + for ( i = 0; i < count; i++ ) { + string_t *ext_name; + const char *name; + + if ( !sieve_binary_read_string(sblock, &offset, &ext_name) ) { + /* Binary is corrupt, recompile */ + sieve_sys_error(svinst, + "ihave: failed to read missing extension name " + "from block %d of binary %s", block_id, sieve_binary_path(sbin)); + return FALSE; + } + + name = str_c(ext_name); + array_append(&binctx->missing_extensions, &name, 1); + } + } + + return TRUE; +} + +static bool ext_ihave_binary_up_to_date +(const struct sieve_extension *ext, struct sieve_binary *sbin ATTR_UNUSED, + void *context) +{ + struct ext_ihave_binary_context *binctx = + (struct ext_ihave_binary_context *) context; + const char *const *exts; + unsigned int count, i; + + exts = array_get(&binctx->missing_extensions, &count); + for ( i = 0; i < count; i++ ) { + if ( sieve_extension_get_by_name(ext->svinst, exts[i]) != NULL ) + return FALSE; + } + + return TRUE; +} + From pigeonhole at rename-it.nl Sun Jun 26 22:25:50 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 26 Jun 2011 21:25:50 +0200 Subject: dovecot-2.0-pigeonhole: lib-sieve: optimized compilation of test... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/cf3b58e583ec changeset: 1505:cf3b58e583ec user: Stephan Bosch date: Sun Jun 26 17:07:53 2011 +0200 description: lib-sieve: optimized compilation of tests that yield constant results (i.e. known at compile tme), such as true and false. If the result of a test is known at compile time, it is optimized away. If an if-command depends on an entirely constant test, it is optimized away as well, causing only the 'true' sub-block to be compiled. diffstat: TODO | 2 - src/lib-sieve/cmd-discard.c | 2 +- src/lib-sieve/cmd-if.c | 121 ++++-- src/lib-sieve/cmd-keep.c | 2 +- src/lib-sieve/cmd-redirect.c | 3 +- src/lib-sieve/cmd-require.c | 2 +- src/lib-sieve/cmd-stop.c | 3 +- src/lib-sieve/ext-envelope.c | 3 +- src/lib-sieve/ext-fileinto.c | 3 +- src/lib-sieve/ext-reject.c | 6 +- src/lib-sieve/plugins/body/tst-body.c | 3 +- src/lib-sieve/plugins/date/tst-date.c | 6 +- src/lib-sieve/plugins/enotify/cmd-notify.c | 3 +- src/lib-sieve/plugins/enotify/tst-notify-method-capability.c | 3 +- src/lib-sieve/plugins/enotify/tst-valid-notify-method.c | 3 +- src/lib-sieve/plugins/environment/tst-environment.c | 3 +- src/lib-sieve/plugins/imap4flags/cmd-flag.c | 9 +- src/lib-sieve/plugins/imap4flags/ext-imapflags.c | 4 +- src/lib-sieve/plugins/imap4flags/tst-hasflag.c | 3 +- src/lib-sieve/plugins/include/cmd-global.c | 21 +- src/lib-sieve/plugins/include/cmd-include.c | 3 +- src/lib-sieve/plugins/include/cmd-return.c | 2 +- src/lib-sieve/plugins/mailbox/tst-mailboxexists.c | 3 +- src/lib-sieve/plugins/notify/cmd-denotify.c | 3 +- src/lib-sieve/plugins/notify/cmd-notify.c | 1 + src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c | 8 +- src/lib-sieve/plugins/vacation/cmd-vacation.c | 3 +- src/lib-sieve/plugins/variables/cmd-set.c | 3 +- src/lib-sieve/plugins/variables/tst-string.c | 3 +- src/lib-sieve/plugins/vnd.dovecot/debug/cmd-debug-log.c | 1 + src/lib-sieve/sieve-commands.h | 5 +- src/lib-sieve/sieve-validator.c | 73 +++- src/lib-sieve/tst-address.c | 3 +- src/lib-sieve/tst-allof.c | 25 +- src/lib-sieve/tst-anyof.c | 31 +- src/lib-sieve/tst-exists.c | 3 +- src/lib-sieve/tst-header.c | 3 +- src/lib-sieve/tst-not.c | 25 +- src/lib-sieve/tst-size.c | 1 + src/lib-sieve/tst-truefalse.c | 47 ++- src/testsuite/cmd-test-binary.c | 6 +- src/testsuite/cmd-test-config.c | 8 +- src/testsuite/cmd-test-fail.c | 3 +- src/testsuite/cmd-test-mailbox.c | 6 +- src/testsuite/cmd-test-message.c | 3 +- src/testsuite/cmd-test-result.c | 4 +- src/testsuite/cmd-test-set.c | 3 +- src/testsuite/cmd-test.c | 3 +- src/testsuite/tst-test-error.c | 3 +- src/testsuite/tst-test-multiscript.c | 3 +- src/testsuite/tst-test-result-action.c | 3 +- src/testsuite/tst-test-result-execute.c | 2 +- src/testsuite/tst-test-script-compile.c | 3 +- src/testsuite/tst-test-script-run.c | 2 +- tests/control-if.svtest | 146 ++++++++- tests/test-allof.svtest | 288 ++++++++++++++++ tests/test-anyof.svtest | 289 +++++++++++++++++ 57 files changed, 1085 insertions(+), 141 deletions(-) diffs (truncated from 2130 to 300 lines): diff -r b9050c63a238 -r cf3b58e583ec TODO --- a/TODO Wed Jun 22 22:17:28 2011 +0200 +++ b/TODO Sun Jun 26 17:07:53 2011 +0200 @@ -27,8 +27,6 @@ - Implement configurable sender exclusion list. - Implement mechanism for implicitly including an account's aliases in the vacation command's :addresses list. -* Optimize code containing true/false tests to omit explicit JMP opcodes - (i.e. optimize the test away and any code that negatively depends on it) * Implement ihave extension. * Fix remaining RFC deviations: - Fix issues listed in doc/rfc/RFC-questions.txt based on answers diff -r b9050c63a238 -r cf3b58e583ec src/lib-sieve/cmd-discard.c --- a/src/lib-sieve/cmd-discard.c Wed Jun 22 22:17:28 2011 +0200 +++ b/src/lib-sieve/cmd-discard.c Sun Jun 26 17:07:53 2011 +0200 @@ -29,7 +29,7 @@ "discard", SCT_COMMAND, 0, 0, FALSE, FALSE, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, cmd_discard_generate, NULL }; diff -r b9050c63a238 -r cf3b58e583ec src/lib-sieve/cmd-if.c --- a/src/lib-sieve/cmd-if.c Wed Jun 22 22:17:28 2011 +0200 +++ b/src/lib-sieve/cmd-if.c Sun Jun 26 17:07:53 2011 +0200 @@ -12,23 +12,31 @@ * Commands */ +static bool cmd_if_validate + (struct sieve_validator *valdtr, struct sieve_command *cmd); +static bool cmd_elsif_validate + (struct sieve_validator *valdtr, struct sieve_command *cmd); +static bool cmd_if_validate_const + (struct sieve_validator *valdtr, struct sieve_command *cmd, + int *const_current, int const_next); +static bool cmd_if_generate + (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd); +static bool cmd_else_generate + (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd); + /* If command * * Syntax: * if */ -static bool cmd_if_validate - (struct sieve_validator *valdtr, struct sieve_command *cmd); -static bool cmd_if_generate - (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd); - const struct sieve_command_def cmd_if = { "if", SCT_COMMAND, 0, 1, TRUE, TRUE, NULL, NULL, - cmd_if_validate, + cmd_if_validate, + cmd_if_validate_const, cmd_if_generate, NULL }; @@ -39,15 +47,13 @@ * elsif */ -static bool cmd_elsif_validate - (struct sieve_validator *valdtr, struct sieve_command *cmd); - const struct sieve_command_def cmd_elsif = { "elsif", SCT_COMMAND, 0, 1, TRUE, TRUE, NULL, NULL, - cmd_elsif_validate, + cmd_elsif_validate, + cmd_if_validate_const, cmd_if_generate, NULL }; @@ -58,15 +64,14 @@ * else */ -static bool cmd_else_generate - (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd); const struct sieve_command_def cmd_else = { "else", SCT_COMMAND, 0, 0, TRUE, TRUE, NULL, NULL, - cmd_elsif_validate, + cmd_elsif_validate, + cmd_if_validate_const, cmd_else_generate, NULL }; @@ -79,6 +84,8 @@ struct cmd_if_context_data *previous; struct cmd_if_context_data *next; + int const_condition; + bool jump_generated; sieve_size_t exit_jump; }; @@ -91,13 +98,23 @@ /* Assign context */ cmd_data = p_new(sieve_command_pool(cmd), struct cmd_if_context_data, 1); cmd_data->exit_jump = 0; - cmd_data->jump_generated = FALSE; + cmd_data->jump_generated = FALSE; /* Update linked list of contexts */ cmd_data->previous = previous; cmd_data->next = NULL; if ( previous != NULL ) previous->next = cmd_data; + + /* Check const status */ + cmd_data->const_condition = -1; + while ( previous != NULL ) { + if ( previous->const_condition > 0 ) { + cmd_data->const_condition = 0; + break; + } + previous = previous->previous; + } /* Assign to command context */ cmd->data = cmd_data; @@ -139,6 +156,27 @@ return TRUE; } +static bool cmd_if_validate_const +(struct sieve_validator *valdtr ATTR_UNUSED, struct sieve_command *cmd, + int *const_current, int const_next) +{ + struct cmd_if_context_data *cmd_data = + (struct cmd_if_context_data *) cmd->data; + + if ( cmd_data != NULL ) { + if ( cmd_data->const_condition == 0 ) { + *const_current = cmd_data->const_condition; + return FALSE; + } + + cmd_data->const_condition = const_next; + } + + *const_current = const_next; + + return ( const_next < 0 ); +} + /* * Code generation */ @@ -171,21 +209,29 @@ (struct cmd_if_context_data *) cmd->data; struct sieve_ast_node *test; struct sieve_jumplist jmplist; - - /* Prepare jumplist */ - sieve_jumplist_init_temp(&jmplist, sblock); - + /* Generate test condition */ - test = sieve_ast_test_first(cmd->ast_node); - if ( !sieve_generate_test(cgenv, test, &jmplist, FALSE) ) - return FALSE; + if ( cmd_data->const_condition < 0 ) { + /* Prepare jumplist */ + sieve_jumplist_init_temp(&jmplist, sblock); + + test = sieve_ast_test_first(cmd->ast_node); + if ( !sieve_generate_test(cgenv, test, &jmplist, FALSE) ) + return FALSE; + } /* Case true { */ - if ( !sieve_generate_block(cgenv, cmd->ast_node) ) - return FALSE; - + if ( cmd_data->const_condition != 0 ) { + if ( !sieve_generate_block(cgenv, cmd->ast_node) ) + return FALSE; + } + /* Are we the final command in this if-elsif-else structure? */ - if ( cmd_data->next != NULL ) { + if ( cmd_data->next == NULL || cmd_data->const_condition == 1 ) { + /* Yes, Resolve previous exit jumps to this point */ + cmd_if_resolve_exit_jumps(sblock, cmd_data); + + } else if ( cmd_data->const_condition < 0 ) { /* No, generate jump to end of if-elsif-else structure (resolved later) * This of course is not necessary if the {} block contains a command * like stop at top level that unconditionally exits the block already @@ -196,13 +242,12 @@ cmd_data->exit_jump = sieve_binary_emit_offset(sblock, 0); cmd_data->jump_generated = TRUE; } - } else { - /* Yes, Resolve previous exit jumps to this point */ - cmd_if_resolve_exit_jumps(sblock, cmd_data); } - - /* Case false ... (subsequent elsif/else commands might generate more) */ - sieve_jumplist_resolve(&jmplist); + + if ( cmd_data->const_condition < 0 ) { + /* Case false ... (subsequent elsif/else commands might generate more) */ + sieve_jumplist_resolve(&jmplist); + } return TRUE; } @@ -214,12 +259,14 @@ (struct cmd_if_context_data *) cmd->data; /* Else { */ - if ( !sieve_generate_block(cgenv, cmd->ast_node) ) - return FALSE; - - /* } End: resolve all exit blocks */ - cmd_if_resolve_exit_jumps(cgenv->sblock, cmd_data); - + if ( cmd_data->const_condition != 0 ) { + if ( !sieve_generate_block(cgenv, cmd->ast_node) ) + return FALSE; + + /* } End: resolve all exit blocks */ + cmd_if_resolve_exit_jumps(cgenv->sblock, cmd_data); + } + return TRUE; } diff -r b9050c63a238 -r cf3b58e583ec src/lib-sieve/cmd-keep.c --- a/src/lib-sieve/cmd-keep.c Wed Jun 22 22:17:28 2011 +0200 +++ b/src/lib-sieve/cmd-keep.c Sun Jun 26 17:07:53 2011 +0200 @@ -27,7 +27,7 @@ "keep", SCT_COMMAND, 0, 0, FALSE, FALSE, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, cmd_keep_generate, NULL }; diff -r b9050c63a238 -r cf3b58e583ec src/lib-sieve/cmd-redirect.c --- a/src/lib-sieve/cmd-redirect.c Wed Jun 22 22:17:28 2011 +0200 +++ b/src/lib-sieve/cmd-redirect.c Sun Jun 26 17:07:53 2011 +0200 @@ -49,7 +49,8 @@ SCT_COMMAND, 1, 0, FALSE, FALSE, NULL, NULL, - cmd_redirect_validate, + cmd_redirect_validate, + NULL, cmd_redirect_generate, NULL }; diff -r b9050c63a238 -r cf3b58e583ec src/lib-sieve/cmd-require.c --- a/src/lib-sieve/cmd-require.c Wed Jun 22 22:17:28 2011 +0200 +++ b/src/lib-sieve/cmd-require.c Sun Jun 26 17:07:53 2011 +0200 @@ -25,7 +25,7 @@ 1, 0, FALSE, FALSE, NULL, NULL, cmd_require_validate, - NULL, NULL + NULL, NULL, NULL }; /* diff -r b9050c63a238 -r cf3b58e583ec src/lib-sieve/cmd-stop.c --- a/src/lib-sieve/cmd-stop.c Wed Jun 22 22:17:28 2011 +0200 +++ b/src/lib-sieve/cmd-stop.c Sun Jun 26 17:07:53 2011 +0200 @@ -25,7 +25,8 @@ SCT_COMMAND, 0, 0, FALSE, FALSE, NULL, NULL, - cmd_stop_validate, + cmd_stop_validate, + NULL, cmd_stop_generate, NULL }; diff -r b9050c63a238 -r cf3b58e583ec src/lib-sieve/ext-envelope.c --- a/src/lib-sieve/ext-envelope.c Wed Jun 22 22:17:28 2011 +0200 +++ b/src/lib-sieve/ext-envelope.c Sun Jun 26 17:07:53 2011 +0200 @@ -87,7 +87,8 @@ 2, 0, FALSE, FALSE, tst_envelope_registered, From pigeonhole at rename-it.nl Sun Jun 26 22:26:53 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 26 Jun 2011 21:26:53 +0200 Subject: dovecot-2.0-pigeonhole: Updated TODO list. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/2eec49242135 changeset: 1507:2eec49242135 user: Stephan Bosch date: Sun Jun 26 22:35:31 2011 +0200 description: Updated TODO list. diffstat: TODO | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r d6c207acbc8d -r 2eec49242135 TODO --- a/TODO Sun Jun 26 22:34:09 2011 +0200 +++ b/TODO Sun Jun 26 22:35:31 2011 +0200 @@ -27,7 +27,6 @@ - Implement configurable sender exclusion list. - Implement mechanism for implicitly including an account's aliases in the vacation command's :addresses list. -* Implement ihave extension. * Fix remaining RFC deviations: - Fix issues listed in doc/rfc/RFC-questions.txt based on answers - Allow for the existence of dynamic comparators (i.e. specified by From pigeonhole at rename-it.nl Sun Jun 26 22:59:06 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 26 Jun 2011 21:59:06 +0200 Subject: dovecot-2.0-pigeonhole: lib-sieve: finished ihave extension. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/bdb94146c89c changeset: 1508:bdb94146c89c user: Stephan Bosch date: Sun Jun 26 23:07:33 2011 +0200 description: lib-sieve: finished ihave extension. diffstat: Makefile.am | 2 + src/lib-sieve/plugins/ihave/Makefile.am | 4 + src/lib-sieve/plugins/ihave/cmd-error.c | 131 ++++++++++++++++++++++++++ src/lib-sieve/plugins/ihave/ext-ihave-common.h | 4 +- src/lib-sieve/plugins/ihave/ext-ihave.c | 5 +- src/lib-sieve/plugins/ihave/tst-ihave.c | 12 +- tests/extensions/ihave/errors.svtest | 19 +++ tests/extensions/ihave/errors/error.sieve | 3 + tests/extensions/ihave/restrictions.svtest | 14 ++ 9 files changed, 183 insertions(+), 11 deletions(-) diffs (274 lines): diff -r 2eec49242135 -r bdb94146c89c Makefile.am --- a/Makefile.am Sun Jun 26 22:35:31 2011 +0200 +++ b/Makefile.am Sun Jun 26 23:07:33 2011 +0200 @@ -124,6 +124,8 @@ tests/extensions/spamvirustest/spamtestplus.svtest \ tests/extensions/spamvirustest/errors.svtest \ tests/extensions/ihave/execute.svtest \ + tests/extensions/ihave/errors.svtest \ + tests/extensions/ihave/restrictions.svtest \ tests/extensions/vnd.dovecot/debug/execute.svtest \ tests/deprecated/notify/basic.svtest \ tests/deprecated/notify/mailto.svtest \ diff -r 2eec49242135 -r bdb94146c89c src/lib-sieve/plugins/ihave/Makefile.am --- a/src/lib-sieve/plugins/ihave/Makefile.am Sun Jun 26 22:35:31 2011 +0200 +++ b/src/lib-sieve/plugins/ihave/Makefile.am Sun Jun 26 23:07:33 2011 +0200 @@ -7,8 +7,12 @@ tests = \ tst-ihave.c +commands = \ + cmd-error.c + libsieve_ext_ihave_la_SOURCES = \ $(tests) \ + $(commands) \ ext-ihave-binary.c \ ext-ihave-common.c \ ext-ihave.c diff -r 2eec49242135 -r bdb94146c89c src/lib-sieve/plugins/ihave/cmd-error.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-sieve/plugins/ihave/cmd-error.c Sun Jun 26 23:07:33 2011 +0200 @@ -0,0 +1,131 @@ +/* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file + */ + +#include "lib.h" +#include "str-sanitize.h" + +#include "sieve-extensions.h" +#include "sieve-commands.h" +#include "sieve-code.h" + +#include "sieve-validator.h" +#include "sieve-generator.h" +#include "sieve-binary.h" +#include "sieve-interpreter.h" +#include "sieve-dump.h" + +#include "ext-ihave-common.h" + +/* + * Error command + * + * Syntax + * error + */ + +static bool cmd_error_validate + (struct sieve_validator *valdtr, struct sieve_command *tst); +static bool cmd_error_generate + (const struct sieve_codegen_env *cgenv, struct sieve_command *ctx); + +const struct sieve_command_def error_command = { + "error", + SCT_COMMAND, + 1, 0, FALSE, FALSE, + NULL, NULL, + cmd_error_validate, + NULL, + cmd_error_generate, + NULL +}; + +/* + * Body operation + */ + +static bool cmd_error_operation_dump + (const struct sieve_dumptime_env *denv, sieve_size_t *address); +static int cmd_error_operation_execute + (const struct sieve_runtime_env *renv, sieve_size_t *address); + +const struct sieve_operation_def error_operation = { + "ERROR", + &ihave_extension, + 0, + cmd_error_operation_dump, + cmd_error_operation_execute +}; + +/* + * Validation + */ + +static bool cmd_error_validate +(struct sieve_validator *valdtr, struct sieve_command *tst) +{ + struct sieve_ast_argument *arg = tst->first_positional; + + if ( !sieve_validate_positional_argument + (valdtr, tst, arg, "message", 1, SAAT_STRING) ) { + return FALSE; + } + + return sieve_validator_argument_activate(valdtr, tst, arg, FALSE); +} + +/* + * Code generation + */ + +static bool cmd_error_generate +(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd) +{ + (void)sieve_operation_emit(cgenv->sblock, cmd->ext, &error_operation); + + /* Generate arguments */ + return sieve_generate_arguments(cgenv, cmd, NULL); +} + +/* + * Code dump + */ + +static bool cmd_error_operation_dump +(const struct sieve_dumptime_env *denv, sieve_size_t *address) +{ + sieve_code_dumpf(denv, "ERROR"); + sieve_code_descend(denv); + + return sieve_opr_string_dump(denv, address, "message"); +} + +/* + * Interpretation + */ + +static int cmd_error_operation_execute +(const struct sieve_runtime_env *renv, sieve_size_t *address) +{ + string_t *message; + int ret; + + /* + * Read operands + */ + + /* Read message */ + + if ( (ret=sieve_opr_string_read(renv, address, "message", &message)) <= 0 ) + return ret; + + /* + * Perform operation + */ + + sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS, "error \"%s\"", + str_sanitize(str_c(message), 80)); + + sieve_runtime_error(renv, NULL, "%s", str_c(message)); + + return SIEVE_EXEC_FAILURE; +} diff -r 2eec49242135 -r bdb94146c89c src/lib-sieve/plugins/ihave/ext-ihave-common.h --- a/src/lib-sieve/plugins/ihave/ext-ihave-common.h Sun Jun 26 22:35:31 2011 +0200 +++ b/src/lib-sieve/plugins/ihave/ext-ihave-common.h Sun Jun 26 23:07:33 2011 +0200 @@ -22,13 +22,13 @@ * Commands */ -//extern const struct sieve_command_def error_command; +extern const struct sieve_command_def error_command; /* * Operations */ -//extern const struct sieve_operation_def error_operation; +extern const struct sieve_operation_def error_operation; /* * AST context diff -r 2eec49242135 -r bdb94146c89c src/lib-sieve/plugins/ihave/ext-ihave.c --- a/src/lib-sieve/plugins/ihave/ext-ihave.c Sun Jun 26 22:35:31 2011 +0200 +++ b/src/lib-sieve/plugins/ihave/ext-ihave.c Sun Jun 26 23:07:33 2011 +0200 @@ -41,16 +41,15 @@ ext_ihave_binary_load, ext_ihave_binary_dump, NULL, -// SIEVE_EXT_DEFINE_OPERATION(error_operation), - SIEVE_EXT_DEFINE_NO_OPERATIONS, + SIEVE_EXT_DEFINE_OPERATION(error_operation), SIEVE_EXT_DEFINE_NO_OPERANDS }; static bool ext_ihave_validator_load (const struct sieve_extension *ext, struct sieve_validator *validator) { - /* Register new test */ sieve_validator_register_command(validator, ext, &ihave_test); + sieve_validator_register_command(validator, ext, &error_command); return TRUE; } diff -r 2eec49242135 -r bdb94146c89c src/lib-sieve/plugins/ihave/tst-ihave.c --- a/src/lib-sieve/plugins/ihave/tst-ihave.c Sun Jun 26 22:35:31 2011 +0200 +++ b/src/lib-sieve/plugins/ihave/tst-ihave.c Sun Jun 26 23:07:33 2011 +0200 @@ -113,12 +113,12 @@ /* RFC 5463, Section 4, page 4: * * The "ihave" extension is designed to be used with other extensions - * that add tests, actions, comparators, or arguments. Implementations - * MUST NOT allow it to be used with extensions that change the - * underlying Sieve grammar, or extensions like encoded-character - * [RFC5228], or variables [RFC5229] that change how the content of - * Sieve scripts are interpreted. The test MUST fail and the extension - * MUST NOT be enabled if such usage is attempted. + * that add tests, actions, comparators, or arguments. Implementations + * MUST NOT allow it to be used with extensions that change the + * underlying Sieve grammar, or extensions like encoded-character + * [RFC5228], or variables [RFC5229] that change how the content of + * Sieve scripts are interpreted. The test MUST fail and the extension + * MUST NOT be enabled if such usage is attempted. * * FIXME: current implementation of this restriction is hardcoded and * therefore highly inflexible diff -r 2eec49242135 -r bdb94146c89c tests/extensions/ihave/errors.svtest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/extensions/ihave/errors.svtest Sun Jun 26 23:07:33 2011 +0200 @@ -0,0 +1,19 @@ +require "vnd.dovecot.testsuite"; + +require "relational"; +require "comparator-i;ascii-numeric"; + +test "Error command" { + if not test_script_compile "errors/error.sieve" { + test_fail "compile failed"; + } + + if test_script_run { + test_fail "execution should have failed"; + } + + if test_error :count "gt" :comparator "i;ascii-numeric" "1" { + test_fail "too many runtime errors reported"; + } +} + diff -r 2eec49242135 -r bdb94146c89c tests/extensions/ihave/errors/error.sieve --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/extensions/ihave/errors/error.sieve Sun Jun 26 23:07:33 2011 +0200 @@ -0,0 +1,3 @@ +require "ihave"; + +error "Something failed."; diff -r 2eec49242135 -r bdb94146c89c tests/extensions/ihave/restrictions.svtest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/extensions/ihave/restrictions.svtest Sun Jun 26 23:07:33 2011 +0200 @@ -0,0 +1,14 @@ +require "vnd.dovecot.testsuite"; +require "ihave"; + +test "Restricted: encoded-character" { + if ihave "encoded-character" { + test_fail "encoded-character extension is incompatible with ihave"; + } +} + +test "Restricted: variables" { + if ihave "variables" { + test_fail "variables extension is incompatible with ihave"; + } +} From pigeonhole at rename-it.nl Sun Jun 26 23:14:56 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Sun, 26 Jun 2011 22:14:56 +0200 Subject: dovecot-2.0-pigeonhole: Added ihave RFC to repository. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/ac0870035061 changeset: 1509:ac0870035061 user: Stephan Bosch date: Sun Jun 26 23:23:33 2011 +0200 description: Added ihave RFC to repository. diffstat: doc/rfc/ihave.rfc5463.txt | 339 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 339 insertions(+), 0 deletions(-) diffs (truncated from 343 to 300 lines): diff -r bdb94146c89c -r ac0870035061 doc/rfc/ihave.rfc5463.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/rfc/ihave.rfc5463.txt Sun Jun 26 23:23:33 2011 +0200 @@ -0,0 +1,339 @@ + + + + + + +Network Working Group N. Freed +Request for Comments: 5463 Sun Microsystems +Category: Standards Track March 2009 + + + Sieve Email Filtering: Ihave Extension + +Status of This Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (c) 2009 IETF Trust and the persons identified as the + document authors. All rights reserved. + + This document is subject to BCP 78 and the IETF Trust's Legal + Provisions Relating to IETF Documents in effect on the date of + publication of this document (http://trustee.ietf.org/license-info). + Please review these documents carefully, as they describe your rights + and restrictions with respect to this document. + +Abstract + + This document describes the "ihave" extension to the Sieve email + filtering language. The "ihave" extension provides a means to write + scripts that can take advantage of optional Sieve features but can + still run when those optional features are not available. The + extension also defines a new error control command intended to be + used to report situations where no combination of available + extensions satisfies the needs of the script. + +1. Introduction + + Sieve [RFC5228] is a language for filtering email messages at or + around the time of final delivery. It is designed to be + implementable on either a mail client or mail server. It is suitable + for running on a mail server where users may not be allowed to + execute arbitrary programs, such as on black-box Internet Message + Access Protocol [RFC3501] servers, as it has no user-controlled loops + or the ability to run external programs. + + + + + + +Freed Standards Track [Page 1] + +RFC 5463 Sieve Ihave Extension March 2009 + + + Various sieve extensions have already been defined, e.g., [RFC5229], + [RFC5230], [RFC5231], [RFC5232], [RFC5233], [RFC5235], and many more + are sure to be created over time. Sieve's require clause is used to + specify the extensions a particular sieve needs; an error results if + the script's require clause calls for an extension that isn't + available. This mechanism is sufficient in most situations. + However, there can be cases where a script may be able to take + advantage of an extension if it is available but can still operate if + it is not, possibly with some degradation of functionality. Cases + can also arise where a script would prefer one extension but can + employ a different one if the first one is not available. + + The "ihave" extension provides a means to write scripts that make use + of extensions only when they are actually available. It defines a + new "ihave" test that takes a list of capability names as an argument + and succeeds if and only if all of those capabilities are present. + Additionally, specification of the "ihave" extension in the require + clause disables parse-time checking of extension use in scripts; run- + time checking must be used instead. This makes it possible to write + portable scripts that can operate in multiple environments making + effective use of whatever extensions are available even though + differing sets of extensions are provided in different places. + + The "ihave" extension also defines a new error control command. An + error causes script execution to terminate with the error message + given as the argument to the error control. + +2. Conventions Used in This Document + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in [RFC2119]. + + The terms used to describe the various components of the Sieve + language are taken from Section 1.1 of [RFC5228]. + +3. Capability Identifiers + + The capability string associated with the extension defined in this + document is "ihave". + +4. Ihave Test + + Usage: ihave + + The "ihave" test provides a means for Sieve scripts to test for the + existence of a given extension prior to actually using it. The + capabilities argument to "ihave" is the same as the similarly-named + + + +Freed Standards Track [Page 2] + +RFC 5463 Sieve Ihave Extension March 2009 + + + argument to the require control statement: It specifies the names of + one or more Sieve extensions or comparators. The "ihave" test + succeeds if all the extensions specified in the capabilities list are + available to the script. + + Unlike most Sieve tests, "ihave" accepts no match or comparator + arguments. The type of match for "ihave" is always ":is" and the + comparator is always "i;octet". + + The strings in the capabilities list are constant strings in the + context of Sieve variables [RFC5229]. It is an error to pass a non- + constant string as an argument to "ihave". + + The Sieve base specification demands that all Sieve extensions used + in a given script be specified in the initial require control + statement. It is an error for a script to call for extensions the + interpreter doesn't support or to attempt to use extensions that have + not been listed in the script's require clause. Using "ihave" + changes Sieve interpreter behavior and the underlying requirements in + the following ways: + + 1. Use of a given extension is allowed subsequent to the successful + evaluation of an "ihave" test on that extension all the way to + the end of the script, even outside the block enclosed by the + "ihave" test. In other words, subsequent to a successful + "ihave", things operate just as if the extension had been + specified in the script's require clause. The extension cannot + be used prior to the evaluation of such a test and a run-time + error MUST be generated if such usage is attempted. However, + subsequent use of that extension may still need to be + conditionally handled via an "ihave" test to deal with the case + where it is not supported. + + 2. Sieve interpreters normally have the option of checking extension + use at either parse time or execution time. The specification of + "ihave" in a script's require clause changes this behavior: + Scripts MUST either defer extension checking to run time or else + take the presence of "ihave" tests into account at parse time. + Note that since "ihave" can be used inside of "anyof", "allof", + and "not" tests, full parse-time checking of "ihave" may be very + difficult to implement. + + 3. Although it makes little sense to do so, an extension can be + specified in both the require control statement and in an "ihave" + test. If this is done and the extension has been implemented, + the extension can be used anywhere in the script and an "ihave" + test of that extension will always return true. + + + + +Freed Standards Track [Page 3] + +RFC 5463 Sieve Ihave Extension March 2009 + + + 4. The "ihave" test accepts a list of capabilities. If any of the + specified capabilities are unavailable, the test fails and none + of the capabilities are enabled. + + 5. The Sieve base specification does not require that interpreters + evaluate arguments in any particular order or that test + evaluation be short-circuited. If "ihave" is enabled, the + interpreter MUST short-circuit tests, i.e., not perform more + tests than necessary to find the result. Additionally, + evaluation order MUST be left to right if "ihave" is enabled. + + The "ihave" extension is designed to be used with other extensions + that add tests, actions, comparators, or arguments. Implementations + MUST NOT allow it to be used with extensions that change the + underlying Sieve grammar, or extensions like encoded-character + [RFC5228], or variables [RFC5229] that change how the content of + Sieve scripts are interpreted. The test MUST fail and the extension + MUST NOT be enabled if such usage is attempted. + +5. Error Control + + Usage: error + + The error control causes script execution to terminate with a run- + time error. The message argument provides a text description of the + error condition that SHOULD be included in any generated report + regarding the error. Section 2.10.6 of [RFC5228] describes how run- + time errors are handled in Sieve. + + Note that the message argument, like all Sieve strings, employs the + UTF-8 charset and can contain non-US-ASCII characters. This must be + taken into consideration when reporting script errors. + + The error control is included as part of the "ihave" extension so + that it is unconditionally available to scripts using ihave. + +6. Security Considerations + + A potential security issue with Sieve scripts is that when a script + fails to run due to the lack of some extension, it may fail to block + dangerous email. The "ihave" extension makes it possible to improve + script portability and generality, which may improve the overall + security provided by Sieve. + + Script robustness aside, ihave is essentially a more flexible variant + of Sieve's existing require mechanism. As such, it does not add any + additional capabilities to a Sieve implementation that could create + + + + +Freed Standards Track [Page 4] + +RFC 5463 Sieve Ihave Extension March 2009 + + + security issues. Of course, all of the security considerations given + in the base Sieve specification and in any extensions that are + employed are still relevant. + +7. IANA Considerations + + The following template specifies the IANA registration of the Sieve + extension specified in this document: + + To: iana at iana.org + Subject: Registration of new Sieve extension + + Capability name: ihave + Description: The "ihave" extension provides a means to write + scripts that make use of other extensions only + when they are actually available. + RFC number: RFC 5463 + Contact address: Sieve discussion list + +8. References + +8.1. Normative References + + [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [RFC5228] Guenther, P. and T. Showalter, "Sieve: An Email Filtering + Language", RFC 5228, January 2008. + +8.2. Informative References + + [RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION + 4rev1", RFC 3501, March 2003. + + [RFC5229] Homme, K., "Sieve Email Filtering: Variables Extension", + RFC 5229, January 2008. + + [RFC5230] Showalter, T. and N. Freed, "Sieve Email Filtering: + Vacation Extension", RFC 5230, January 2008. + + [RFC5231] Segmuller, W. and B. Leiba, "Sieve Email Filtering: + Relational Extension", RFC 5231, January 2008. + + [RFC5232] Melnikov, A., "Sieve Email Filtering: Imap4flags + Extension", RFC 5232, January 2008. + + [RFC5233] Murchison, K., "Sieve Email Filtering: Subaddress + Extension", RFC 5233, January 2008. + + + +Freed Standards Track [Page 5] + +RFC 5463 Sieve Ihave Extension March 2009 + + + [RFC5235] Daboo, C., "Sieve Email Filtering: Spamtest and Virustest + Extensions", RFC 5235, January 2008. + +9. Acknowledgments + + Stephan Bosch, Cyrus Daboo, Arnt Gulbrandsen, Andrew McKeon, and + Alexey Melnikov provided helpful suggestions and corrections. + +Author's Address + From dovecot at dovecot.org Tue Jun 28 02:23:17 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 02:23:17 +0300 Subject: dovecot-2.0: doveadm: Minor code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0adf8c1731e6 changeset: 12854:0adf8c1731e6 user: Timo Sirainen date: Sun Jun 26 19:11:52 2011 +0300 description: doveadm: Minor code cleanup diffstat: src/doveadm/doveadm-mail-index.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diffs (13 lines): diff -r 3d07ab746a67 -r 0adf8c1731e6 src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Wed Jun 22 20:26:24 2011 +0300 +++ b/src/doveadm/doveadm-mail-index.c Sun Jun 26 19:11:52 2011 +0300 @@ -22,8 +22,7 @@ MAILBOX_SYNC_FLAG_PRECACHE) < 0) { i_error("Syncing mailbox %s failed: %s", info->name, mail_storage_get_last_error(mailbox_get_storage(box), NULL)); - mailbox_free(&box); - return -1; + ret = -1; } mailbox_free(&box); From dovecot at dovecot.org Tue Jun 28 02:23:17 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 02:23:17 +0300 Subject: dovecot-2.0: mdbox: Log an error if uidvalidity=0 unexpectedly. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/028b953e7040 changeset: 12855:028b953e7040 user: Timo Sirainen date: Tue Jun 28 02:22:58 2011 +0300 description: mdbox: Log an error if uidvalidity=0 unexpectedly. diffstat: src/lib-storage/index/dbox-multi/mdbox-sync.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r 0adf8c1731e6 -r 028b953e7040 src/lib-storage/index/dbox-multi/mdbox-sync.c --- a/src/lib-storage/index/dbox-multi/mdbox-sync.c Sun Jun 26 19:11:52 2011 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c Tue Jun 28 02:22:58 2011 +0300 @@ -137,6 +137,9 @@ hdr = mail_index_get_header(ctx->sync_view); if (hdr->uid_validity == 0) { /* newly created index file */ + mail_storage_set_critical(box->storage, + "Mailbox %s: Corrupted index, uidvalidity=0", + box->vname); return 0; } From dovecot at dovecot.org Tue Jun 28 02:23:17 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 02:23:17 +0300 Subject: dovecot-2.0: mdbox: Minor code cleanup. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/01d43e0b2420 changeset: 12856:01d43e0b2420 user: Timo Sirainen date: Tue Jun 28 02:23:10 2011 +0300 description: mdbox: Minor code cleanup. diffstat: src/lib-storage/index/dbox-multi/mdbox-mail.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diffs (15 lines): diff -r 028b953e7040 -r 01d43e0b2420 src/lib-storage/index/dbox-multi/mdbox-mail.c --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c Tue Jun 28 02:22:58 2011 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c Tue Jun 28 02:23:10 2011 +0300 @@ -35,10 +35,8 @@ } if (mbox->map_uid_validity == 0) { - if (mdbox_read_header(mbox, &hdr) < 0) { - mdbox_storage_set_corrupted(mbox->storage); + if (mdbox_read_header(mbox, &hdr) < 0) return -1; - } mbox->map_uid_validity = hdr.map_uid_validity; } if (mdbox_map_open_or_create(mbox->storage->map) < 0) From dovecot at dovecot.org Tue Jun 28 02:41:20 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 02:41:20 +0300 Subject: dovecot-2.0: imap: Don't crash if mailbox UIDVALIDITY is zero wh... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0535d79ea686 changeset: 12857:0535d79ea686 user: Timo Sirainen date: Tue Jun 28 02:31:12 2011 +0300 description: imap: Don't crash if mailbox UIDVALIDITY is zero when SELECTing a mailbox. diffstat: src/imap/cmd-select.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 01d43e0b2420 -r 0535d79ea686 src/imap/cmd-select.c --- a/src/imap/cmd-select.c Tue Jun 28 02:23:10 2011 +0300 +++ b/src/imap/cmd-select.c Tue Jun 28 02:31:12 2011 +0300 @@ -339,7 +339,8 @@ client->sync_last_full_modseq = status.highest_modseq; } - if (ctx->qresync_uid_validity == status.uidvalidity) { + if (ctx->qresync_uid_validity == status.uidvalidity && + status.uidvalidity != 0) { if ((ret = select_qresync(ctx)) < 0) { client_send_storage_error(ctx->cmd, mailbox_get_storage(ctx->box)); From dovecot at dovecot.org Tue Jun 28 02:41:20 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 02:41:20 +0300 Subject: dovecot-2.0: lib-lda: waitpid() for executed sendmail binary was... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/748b0fd169d1 changeset: 12858:748b0fd169d1 user: Timo Sirainen date: Tue Jun 28 02:41:06 2011 +0300 description: lib-lda: waitpid() for executed sendmail binary wasn't called correctly. It may have failed with -ECHILD, if the sendmail binary itself forked other processes. diffstat: src/lib-lda/smtp-client.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 0535d79ea686 -r 748b0fd169d1 src/lib-lda/smtp-client.c --- a/src/lib-lda/smtp-client.c Tue Jun 28 02:31:12 2011 +0300 +++ b/src/lib-lda/smtp-client.c Tue Jun 28 02:41:06 2011 +0300 @@ -101,6 +101,7 @@ client = i_new(struct smtp_client, 1); client->f = *file_r = fdopen(fd[1], "w"); + client->pid = pid; if (client->f == NULL) i_fatal("fdopen() failed: %m"); return client; From dovecot at dovecot.org Tue Jun 28 02:49:55 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 02:49:55 +0300 Subject: dovecot-2.0: lib-storage: Changed userdb +key=value to key+=value Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/4285147ed694 changeset: 12859:4285147ed694 user: Timo Sirainen date: Tue Jun 28 02:49:46 2011 +0300 description: lib-storage: Changed userdb +key=value to key+=value diffstat: src/lib-storage/mail-storage-service.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (26 lines): diff -r 748b0fd169d1 -r 4285147ed694 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Tue Jun 28 02:41:06 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Tue Jun 28 02:49:46 2011 +0300 @@ -108,6 +108,7 @@ struct setting_parser_context *set_parser = user->set_parser; bool mail_debug; const char *key, *orig_key, *append_value = NULL; + unsigned int len; int ret; mail_debug = mail_user_set_get_mail_debug(user->user_info, @@ -116,9 +117,11 @@ line = t_strconcat(line, "=yes", NULL); orig_key = key = t_strcut(line, '='); - if (*key == '+') { - append_value = line + strlen(key) + 1; - key++; + len = strlen(key); + if (len > 0 && key[len-1] == '+') { + /* key+=value */ + append_value = line + len + 1; + key = t_strndup(key, len-1); line++; } From dovecot at dovecot.org Tue Jun 28 03:31:31 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 03:31:31 +0300 Subject: dovecot-2.0: doveadm acl: Updated usage string. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/aa9b50f6a92b changeset: 12860:aa9b50f6a92b user: Timo Sirainen date: Tue Jun 28 03:31:22 2011 +0300 description: doveadm acl: Updated usage string. diffstat: src/plugins/acl/doveadm-acl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 4285147ed694 -r aa9b50f6a92b src/plugins/acl/doveadm-acl.c --- a/src/plugins/acl/doveadm-acl.c Tue Jun 28 02:49:46 2011 +0300 +++ b/src/plugins/acl/doveadm-acl.c Tue Jun 28 03:31:22 2011 +0300 @@ -537,7 +537,7 @@ static struct doveadm_mail_cmd acl_commands[] = { { cmd_acl_get_alloc, "acl get", "[-m] " }, { cmd_acl_rights_alloc, "acl rights", "" }, - { cmd_acl_set_alloc, "acl set", " " }, + { cmd_acl_set_alloc, "acl set", " [ ...]" }, { cmd_acl_delete_alloc, "acl delete", " " }, { cmd_acl_debug_alloc, "acl debug", "" } }; From dovecot at dovecot.org Tue Jun 28 03:59:35 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Jun 2011 03:59:35 +0300 Subject: dovecot-2.0: doveadm: Fixed displaying output when using -A or -... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/02d97fb66047 changeset: 12861:02d97fb66047 user: Timo Sirainen date: Tue Jun 28 03:59:26 2011 +0300 description: doveadm: Fixed displaying output when using -A or -u wildcards. diffstat: src/doveadm/doveadm-mail-server.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diffs (25 lines): diff -r aa9b50f6a92b -r 02d97fb66047 src/doveadm/doveadm-mail-server.c --- a/src/doveadm/doveadm-mail-server.c Tue Jun 28 03:31:22 2011 +0300 +++ b/src/doveadm/doveadm-mail-server.c Tue Jun 28 03:59:26 2011 +0300 @@ -214,10 +214,6 @@ i_assert(cmd_ctx == ctx || cmd_ctx == NULL); cmd_ctx = ctx; - /* server sends the sticky headers for each row as well, - so undo any sticks we might have added already */ - doveadm_print_unstick_headers(); - ret = doveadm_mail_server_user_get_host(ctx, input, &host, error_r); if (ret < 0) return -1; @@ -227,6 +223,10 @@ return 0; } + /* server sends the sticky headers for each row as well, + so undo any sticks we might have added already */ + doveadm_print_unstick_headers(); + server = doveadm_server_get(ctx, host); conn = doveadm_server_find_unused_conn(server); if (conn != NULL) From pigeonhole at rename-it.nl Wed Jun 29 01:56:01 2011 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 29 Jun 2011 00:56:01 +0200 Subject: dovecot-2.0-pigeonhole: lib-sieve: variables extension: fixed -W... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/a720b0775fa5 changeset: 1510:a720b0775fa5 user: Stephan Bosch date: Wed Jun 29 00:55:48 2011 +0200 description: lib-sieve: variables extension: fixed -Wunused-but-set-variable compiler warning. diffstat: src/lib-sieve/plugins/variables/ext-variables-common.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diffs (22 lines): diff -r ac0870035061 -r a720b0775fa5 src/lib-sieve/plugins/variables/ext-variables-common.c --- a/src/lib-sieve/plugins/variables/ext-variables-common.c Sun Jun 26 23:23:33 2011 +0200 +++ b/src/lib-sieve/plugins/variables/ext-variables-common.c Wed Jun 29 00:55:48 2011 +0200 @@ -715,16 +715,15 @@ (const struct sieve_extension *ext, const struct sieve_runtime_env *renv, sieve_size_t *address) { - struct ext_variables_interpreter_context *ctx; struct sieve_variable_scope_binary *scpbin; scpbin = sieve_variable_scope_binary_read (renv->svinst, NULL, renv->sblock, address); if ( scpbin == NULL ) return FALSE; - + /* Create our context */ - ctx = ext_variables_interpreter_context_create + (void)ext_variables_interpreter_context_create (ext, renv->interp, scpbin); /* Enable support for match values */ From dovecot at dovecot.org Thu Jun 30 07:26:11 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 30 Jun 2011 07:26:11 +0300 Subject: dovecot-2.0: liblib: Don't try to send a log prefix to log proce... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/ed0688858e59 changeset: 12862:ed0688858e59 user: Timo Sirainen date: Thu Jun 30 07:26:01 2011 +0300 description: liblib: Don't try to send a log prefix to log process if there is none. diffstat: src/lib/failures.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 02d97fb66047 -r ed0688858e59 src/lib/failures.c --- a/src/lib/failures.c Tue Jun 28 03:59:26 2011 +0300 +++ b/src/lib/failures.c Thu Jun 30 07:26:01 2011 +0300 @@ -565,7 +565,7 @@ string_t *str; unsigned int prefix_len; - if (!log_prefix_sent) { + if (!log_prefix_sent && log_prefix != NULL) { log_prefix_sent = TRUE; i_failure_send_option("prefix", log_prefix); } From dovecot at dovecot.org Thu Jun 30 08:00:17 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 30 Jun 2011 08:00:17 +0300 Subject: dovecot-2.0: lib-storage: Fixed /chroot/./home style chrooting f... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1d78d2a4e8d1 changeset: 12863:1d78d2a4e8d1 user: Timo Sirainen date: Thu Jun 30 08:00:07 2011 +0300 description: lib-storage: Fixed /chroot/./home style chrooting from userdb home. diffstat: src/lib-storage/mail-storage-service.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r ed0688858e59 -r 1d78d2a4e8d1 src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Thu Jun 30 07:26:01 2011 +0300 +++ b/src/lib-storage/mail-storage-service.c Thu Jun 30 08:00:07 2011 +0300 @@ -221,7 +221,7 @@ } if (home != NULL) - set_keyval(ctx, user, "mail_home", reply->home); + set_keyval(ctx, user, "mail_home", home); if (chroot != NULL) { if (!validate_chroot(user->user_set, chroot)) { From dovecot at dovecot.org Thu Jun 30 08:27:40 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 30 Jun 2011 08:27:40 +0300 Subject: dovecot-2.0: lmtp: Log the current state in disconnect message. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/1b1fc681a277 changeset: 12864:1b1fc681a277 user: Timo Sirainen date: Thu Jun 30 08:27:32 2011 +0300 description: lmtp: Log the current state in disconnect message. diffstat: src/lmtp/client.c | 5 ++++- src/lmtp/client.h | 1 + src/lmtp/commands.c | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletions(-) diffs (83 lines): diff -r 1d78d2a4e8d1 -r 1b1fc681a277 src/lmtp/client.c --- a/src/lmtp/client.c Thu Jun 30 08:00:07 2011 +0300 +++ b/src/lmtp/client.c Thu Jun 30 08:27:32 2011 +0300 @@ -226,6 +226,7 @@ client_io_reset(client); client->state_pool = pool_alloconly_create("client state", 4096); client->state.mail_data_fd = -1; + client->state.name = "banner"; client_read_settings(client); client_raw_user_create(client); client_generate_session_id(client); @@ -290,7 +291,8 @@ client_send_line(client, "%s %s", prefix, reason); else reason = client_get_disconnect_reason(client); - i_info("Disconnect from %s: %s", client_remote_id(client), reason); + i_info("Disconnect from %s: %s (in %s)", client_remote_id(client), + reason, client->state.name); client->disconnected = TRUE; } @@ -325,6 +327,7 @@ client->state.mail_data_fd = -1; client_generate_session_id(client); + client->state.name = "reset"; } void client_send_line(struct client *client, const char *fmt, ...) diff -r 1d78d2a4e8d1 -r 1b1fc681a277 src/lmtp/client.h --- a/src/lmtp/client.h Thu Jun 30 08:00:07 2011 +0300 +++ b/src/lmtp/client.h Thu Jun 30 08:27:32 2011 +0300 @@ -12,6 +12,7 @@ }; struct client_state { + const char *name; const char *session_id; const char *mail_from; ARRAY_DEFINE(rcpt_to, struct mail_recipient); diff -r 1d78d2a4e8d1 -r 1b1fc681a277 src/lmtp/commands.c --- a/src/lmtp/commands.c Thu Jun 30 08:00:07 2011 +0300 +++ b/src/lmtp/commands.c Thu Jun 30 08:27:32 2011 +0300 @@ -73,6 +73,7 @@ i_free(client->lhlo); client->lhlo = i_strdup(str_c(domain)); + client->state.name = "LHLO"; return 0; } @@ -141,6 +142,7 @@ client->state.mail_from = p_strdup(client->state_pool, addr); p_array_init(&client->state.rcpt_to, client->state_pool, 64); client_send_line(client, "250 2.1.0 OK"); + client->state.name = "MAIL FROM"; return 0; } @@ -385,6 +387,8 @@ const char *error = NULL; int ret = 0; + client->state.name = "RCPT TO"; + if (client->state.mail_from == NULL) { client_send_line(client, "503 5.5.1 MAIL needed first"); return 0; @@ -897,12 +901,14 @@ io_remove(&client->io); if (array_count(&client->state.rcpt_to) == 0) { + client->state.name = "DATA (proxy)"; timeout_remove(&client->to_idle); lmtp_proxy_start(client->proxy, client->dot_input, client->state.added_headers, client_proxy_finish, client); i_stream_unref(&client->dot_input); } else { + client->state.name = "DATA"; client->io = io_add(client->fd_in, IO_READ, client_input_data, client); client_input_data_handle(client); From dovecot at dovecot.org Thu Jun 30 08:34:35 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 30 Jun 2011 08:34:35 +0300 Subject: dovecot-2.0: lmtp client: Do corking when sending message data. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/36e7ded2ef0b changeset: 12865:36e7ded2ef0b user: Timo Sirainen date: Thu Jun 30 08:34:28 2011 +0300 description: lmtp client: Do corking when sending message data. diffstat: src/lib-lda/lmtp-client.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (16 lines): diff -r 1b1fc681a277 -r 36e7ded2ef0b src/lib-lda/lmtp-client.c --- a/src/lib-lda/lmtp-client.c Thu Jun 30 08:27:32 2011 +0300 +++ b/src/lib-lda/lmtp-client.c Thu Jun 30 08:34:28 2011 +0300 @@ -592,8 +592,11 @@ void lmtp_client_send_more(struct lmtp_client *client) { - if (client->input_state == LMTP_INPUT_STATE_DATA) + if (client->input_state == LMTP_INPUT_STATE_DATA) { + o_stream_cork(client->output); lmtp_client_send_data(client); + o_stream_uncork(client->output); + } } void lmtp_client_set_data_output_callback(struct lmtp_client *client, From dovecot at dovecot.org Thu Jun 30 08:35:56 2011 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 30 Jun 2011 08:35:56 +0300 Subject: dovecot-2.0: lmtp: Error message update Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/537d4b6d9a7a changeset: 12866:537d4b6d9a7a user: Timo Sirainen date: Thu Jun 30 08:35:43 2011 +0300 description: lmtp: Error message update diffstat: src/lmtp/client.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 36e7ded2ef0b -r 537d4b6d9a7a src/lmtp/client.c --- a/src/lmtp/client.c Thu Jun 30 08:34:28 2011 +0300 +++ b/src/lmtp/client.c Thu Jun 30 08:35:43 2011 +0300 @@ -32,7 +32,7 @@ { client_destroy(client, t_strdup_printf("421 4.4.2 %s", client->my_domain), - "Disconnected for inactivity"); + "Disconnected client for inactivity"); } static int client_input_line(struct client *client, const char *line)