From dovecot at dovecot.org Wed Feb 1 18:56:02 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 18:56:02 +0200 Subject: dovecot-2.1: guid_128_generate(): Use 32bit sha1(host@domain) in... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/acc60bd684fb changeset: 14036:acc60bd684fb user: Timo Sirainen date: Wed Feb 01 18:55:54 2012 +0200 description: guid_128_generate(): Use 32bit sha1(host at domain) instead of crc32(hostname) diffstat: src/lib/guid.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diffs (45 lines): diff -r 8be75a2ea2dd -r acc60bd684fb src/lib/guid.c --- a/src/lib/guid.c Mon Jan 30 20:09:04 2012 +0200 +++ b/src/lib/guid.c Wed Feb 01 18:55:54 2012 +0200 @@ -2,7 +2,7 @@ #include "lib.h" #include "buffer.h" -#include "crc32.h" +#include "sha1.h" #include "hash.h" #include "hex-binary.h" #include "hostpid.h" @@ -38,7 +38,9 @@ { static struct timespec ts = { 0, 0 }; static uint8_t guid_static[8]; - uint32_t pid, host_crc; + unsigned char hostdomain_hash[SHA1_RESULTLEN]; + const char *hostdomain; + uint32_t pid; /* we'll use the current time in nanoseconds as the initial 64bit counter. */ @@ -46,16 +48,16 @@ if (clock_gettime(CLOCK_REALTIME, &ts) < 0) i_fatal("clock_gettime() failed: %m"); pid = getpid(); - host_crc = crc32_str(my_hostname); + hostdomain = my_hostdomain(); + sha1_get_digest(hostdomain, strlen(hostdomain), + hostdomain_hash); guid_static[0] = (pid & 0x000000ff); guid_static[1] = (pid & 0x0000ff00) >> 8; guid_static[2] = (pid & 0x00ff0000) >> 16; guid_static[3] = (pid & 0xff000000) >> 24; - guid_static[4] = (host_crc & 0x000000ff); - guid_static[5] = (host_crc & 0x0000ff00) >> 8; - guid_static[6] = (host_crc & 0x00ff0000) >> 16; - guid_static[7] = (host_crc & 0xff000000) >> 24; + memcpy(guid_static+4, + hostdomain_hash+sizeof(hostdomain_hash)-4, 4); } else if ((uint32_t)ts.tv_nsec < (uint32_t)-1) { ts.tv_nsec++; } else { From dovecot at dovecot.org Wed Feb 1 20:10:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 20:10:49 +0200 Subject: dovecot-2.1: lib-storage: mailbox_list_mkdir_root() API changed.... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/aed3379df476 changeset: 14037:aed3379df476 user: Timo Sirainen date: Wed Feb 01 20:10:42 2012 +0200 description: lib-storage: mailbox_list_mkdir_root() API changed. Use it now for creating mail root dir. It was supposed to be used for it previously, but wasn't.. diffstat: src/lib-storage/index/dbox-common/dbox-sync-rebuild.c | 8 ++- src/lib-storage/index/dbox-multi/mdbox-file.c | 9 ++- src/lib-storage/index/maildir/maildir-util.c | 6 +- src/lib-storage/mail-storage.c | 22 ++------- src/lib-storage/mailbox-list.c | 41 ++++++++++++------ src/lib-storage/mailbox-list.h | 3 +- src/plugins/fts-lucene/fts-backend-lucene.c | 13 ++++- 7 files changed, 61 insertions(+), 41 deletions(-) diffs (262 lines): diff -r acc60bd684fb -r aed3379df476 src/lib-storage/index/dbox-common/dbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Wed Feb 01 18:55:54 2012 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Wed Feb 01 20:10:42 2012 +0200 @@ -194,7 +194,7 @@ int dbox_sync_rebuild_verify_alt_storage(struct mailbox_list *list) { - const char *alt_path; + const char *alt_path, *error; struct stat st; alt_path = mailbox_list_get_path(list, NULL, @@ -213,7 +213,11 @@ /* try to create the alt directory. if it fails, it means alt storage isn't mounted. */ if (mailbox_list_mkdir_root(list, alt_path, - MAILBOX_LIST_PATH_TYPE_ALT_DIR) < 0) + MAILBOX_LIST_PATH_TYPE_ALT_DIR, + &error) < 0) { + i_error("Couldn't create dbox alt root dir %s: %s", + alt_path, error); return -1; + } return 0; } diff -r acc60bd684fb -r aed3379df476 src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Wed Feb 01 18:55:54 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Wed Feb 01 20:10:42 2012 +0200 @@ -292,7 +292,7 @@ struct mdbox_file *mfile = (struct mdbox_file *)file; struct mdbox_map *map = mfile->storage->map; mode_t old_mask; - const char *p, *dir; + const char *p, *dir, *error; int fd; old_mask = umask(0666 & ~map->create_mode); @@ -304,9 +304,10 @@ if (mailbox_list_mkdir_root(map->root_list, dir, path != file->alt_path ? MAILBOX_LIST_PATH_TYPE_DIR : - MAILBOX_LIST_PATH_TYPE_ALT_DIR) < 0) { - mail_storage_copy_list_error(&file->storage->storage, - map->root_list); + MAILBOX_LIST_PATH_TYPE_ALT_DIR, + &error) < 0) { + mail_storage_set_critical(&file->storage->storage, + "Couldn't create %s: %s", dir, error); return -1; } /* try again */ diff -r acc60bd684fb -r aed3379df476 src/lib-storage/index/maildir/maildir-util.c --- a/src/lib-storage/index/maildir/maildir-util.c Wed Feb 01 18:55:54 2012 +0200 +++ b/src/lib-storage/index/maildir/maildir-util.c Wed Feb 01 20:10:42 2012 +0200 @@ -156,7 +156,7 @@ enum mailbox_list_path_type type, bool retry) { const struct mailbox_permissions *perm = mailbox_get_permissions(box); - const char *p, *parent; + const char *p, *parent, *error; if (mkdir_chgrp(path, perm->dir_create_mode, perm->file_create_gid, perm->file_create_gid_origin) == 0) @@ -175,11 +175,13 @@ } /* create index/control root directory */ parent = t_strdup_until(path, p); - if (mailbox_list_mkdir_root(box->list, parent, type) == 0) { + if (mailbox_list_mkdir_root(box->list, parent, type, &error) == 0) { /* should work now, try again */ return maildir_create_path(box, path, type, FALSE); } /* fall through */ + mail_storage_set_critical(box->storage, + "Couldn't create %s: %s", parent, error); path = parent; default: mail_storage_set_critical(box->storage, diff -r acc60bd684fb -r aed3379df476 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Wed Feb 01 18:55:54 2012 +0200 +++ b/src/lib-storage/mail-storage.c Wed Feb 01 20:10:42 2012 +0200 @@ -230,9 +230,7 @@ mail_storage_create_root(struct mailbox_list *list, enum mail_storage_flags flags, const char **error_r) { - const char *root_dir, *origin, *error; - mode_t file_mode, dir_mode; - gid_t gid; + const char *root_dir, *error; bool autocreate; int ret; @@ -258,20 +256,12 @@ autocreate = (flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) == 0; ret = mail_storage_verify_root(root_dir, autocreate, error_r); - if (ret != 0) - return ret; - - /* we need to create the root directory. */ - mailbox_list_get_root_permissions(list, &file_mode, &dir_mode, - &gid, &origin); - if (mkdir_parents_chgrp(root_dir, dir_mode, gid, origin) < 0 && - errno != EEXIST) { - *error_r = mail_error_create_eacces_msg("mkdir", root_dir); - return -1; - } else { - /* created */ - return 0; + if (ret == 0) { + ret = mailbox_list_mkdir_root(list, root_dir, + MAILBOX_LIST_PATH_TYPE_MAILBOX, + error_r); } + return ret < 0 ? -1 : 0; } static bool diff -r acc60bd684fb -r aed3379df476 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Wed Feb 01 18:55:54 2012 +0200 +++ b/src/lib-storage/mailbox-list.c Wed Feb 01 20:10:42 2012 +0200 @@ -723,15 +723,14 @@ } static int -mailbox_list_stat_parent(struct mailbox_list *list, const char *path, - const char **root_dir_r, struct stat *st_r) +mailbox_list_stat_parent(const char *path, const char **root_dir_r, + struct stat *st_r, const char **error_r) { const char *p; while (stat(path, st_r) < 0) { if (errno != ENOENT || strcmp(path, "/") == 0) { - mailbox_list_set_critical(list, "stat(%s) failed: %m", - path); + *error_r = t_strdup_printf("stat(%s) failed: %m", path); return -1; } p = strrchr(path, '/'); @@ -787,7 +786,8 @@ } int mailbox_list_mkdir_root(struct mailbox_list *list, const char *path, - enum mailbox_list_path_type type) + enum mailbox_list_path_type type, + const char **error_r) { const char *expanded, *unexpanded, *root_dir, *p, *origin; struct stat st; @@ -818,14 +818,14 @@ /* up to this directory get the permissions from the first parent directory that exists, if it has setgid bit enabled. */ - if (mailbox_list_stat_parent(list, expanded, - &root_dir, &st) < 0) + if (mailbox_list_stat_parent(expanded, &root_dir, &st, + error_r) < 0) return -1; if ((st.st_mode & S_ISGID) != 0 && root_dir != expanded) { if (mkdir_parents_chgrp(expanded, st.st_mode, (gid_t)-1, root_dir) < 0 && errno != EEXIST) { - mailbox_list_set_critical(list, + *error_r = t_strdup_printf( "mkdir(%s) failed: %m", expanded); return -1; } @@ -840,7 +840,10 @@ with default directory permissions */ if (mkdir_parents_chgrp(path, dir_mode, gid, origin) < 0 && errno != EEXIST) { - mailbox_list_set_critical(list, "mkdir(%s) failed: %m", path); + if (errno == EACCES) + *error_r = mail_error_create_eacces_msg("mkdir", path); + else + *error_r = t_strdup_printf("mkdir(%s) failed: %m", path); return -1; } return 0; @@ -1330,7 +1333,7 @@ int mailbox_list_create_missing_index_dir(struct mailbox_list *list, const char *name) { - const char *root_dir, *index_dir, *parent_dir, *p; + const char *root_dir, *index_dir, *parent_dir, *p, *error; struct mailbox_permissions perm; unsigned int n = 0; @@ -1348,8 +1351,15 @@ } if (name == NULL) { - return mailbox_list_mkdir_root(list, index_dir, - MAILBOX_LIST_PATH_TYPE_INDEX); + if (mailbox_list_mkdir_root(list, index_dir, + MAILBOX_LIST_PATH_TYPE_INDEX, + &error) < 0) { + mailbox_list_set_critical(list, + "Couldn't create index root dir %s: %s", + index_dir, error); + return -1; + } + return 0; } mailbox_list_get_permissions(list, name, &perm); @@ -1368,8 +1378,13 @@ /* create the parent directory first */ parent_dir = t_strdup_until(index_dir, p); if (mailbox_list_mkdir_root(list, parent_dir, - MAILBOX_LIST_PATH_TYPE_INDEX) < 0) + MAILBOX_LIST_PATH_TYPE_INDEX, + &error) < 0) { + mailbox_list_set_critical(list, + "Couldn't create index dir %s: %s", + parent_dir, error); return -1; + } } return 0; } diff -r acc60bd684fb -r aed3379df476 src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Wed Feb 01 18:55:54 2012 +0200 +++ b/src/lib-storage/mailbox-list.h Wed Feb 01 20:10:42 2012 +0200 @@ -218,7 +218,8 @@ const char *mailbox, const char *path); /* mkdir() a root directory of given type with proper permissions. */ int mailbox_list_mkdir_root(struct mailbox_list *list, const char *path, - enum mailbox_list_path_type type); + enum mailbox_list_path_type type, + const char **error_r); /* Returns TRUE if the name doesn't contain any invalid characters. The create name check can be more strict. */ diff -r acc60bd684fb -r aed3379df476 src/plugins/fts-lucene/fts-backend-lucene.c --- a/src/plugins/fts-lucene/fts-backend-lucene.c Wed Feb 01 18:55:54 2012 +0200 +++ b/src/plugins/fts-lucene/fts-backend-lucene.c Wed Feb 01 20:10:42 2012 +0200 @@ -53,13 +53,20 @@ static int fts_backend_lucene_mkdir(struct lucene_fts_backend *backend) { + const char *error; + if (backend->dir_created) return 0; backend->dir_created = TRUE; - return mailbox_list_mkdir_root(backend->backend.ns->list, - backend->dir_path, - MAILBOX_LIST_PATH_TYPE_INDEX); + if (mailbox_list_mkdir_root(backend->backend.ns->list, + backend->dir_path, + MAILBOX_LIST_PATH_TYPE_INDEX, &error) < 0) { + i_error("lucene: Couldn't create root dir %s: %s", + backend->dir_path, error); + return -1; + } + return 0; } static int From dovecot at dovecot.org Wed Feb 1 20:12:10 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 20:12:10 +0200 Subject: dovecot-2.1: configure: Added getmntinfo() check for BSD mountpo... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4b783711a22e changeset: 14038:4b783711a22e user: Timo Sirainen date: Wed Feb 01 18:57:14 2012 +0200 description: configure: Added getmntinfo() check for BSD mountpoint iteration. diffstat: configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r aed3379df476 -r 4b783711a22e configure.in --- a/configure.in Wed Feb 01 20:10:42 2012 +0200 +++ b/configure.in Wed Feb 01 18:57:14 2012 +0200 @@ -395,7 +395,7 @@ AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \ strcasecmp stricmp vsyslog writev pread uname unsetenv \ setrlimit setproctitle seteuid setreuid setegid setresgid \ - strtoull strtoll strtouq strtoq \ + strtoull strtoll strtouq strtoq getmntinfo \ setpriority quotactl getmntent kqueue kevent backtrace_symbols \ walkcontext dirfd clearenv malloc_usable_size glob fallocate \ posix_fadvise getpeereid getpeerucred) From dovecot at dovecot.org Wed Feb 1 20:12:10 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 20:12:10 +0200 Subject: dovecot-2.1: doveadm: Added flag to specify which column table f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/56ff22125b7d changeset: 14039:56ff22125b7d user: Timo Sirainen date: Wed Feb 01 19:13:04 2012 +0200 description: doveadm: Added flag to specify which column table formatter expands. The default also was changed to last column, not first. diffstat: src/doveadm/doveadm-director.c | 2 +- src/doveadm/doveadm-print-table.c | 11 +++++++++-- src/doveadm/doveadm-print.h | 3 ++- src/doveadm/doveadm-proxy.c | 2 +- src/doveadm/doveadm-stats.c | 2 +- src/doveadm/doveadm-who.c | 3 ++- 6 files changed, 16 insertions(+), 7 deletions(-) diffs (83 lines): diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-director.c --- a/src/doveadm/doveadm-director.c Wed Feb 01 18:57:14 2012 +0200 +++ b/src/doveadm/doveadm-director.c Wed Feb 01 19:13:04 2012 +0200 @@ -290,7 +290,7 @@ user_file_get_user_list(ctx->users_path, pool, users); doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE); - doveadm_print_header_simple("user"); + doveadm_print_header("user", "user", DOVEADM_PRINT_HEADER_FLAG_EXPAND); doveadm_print_header_simple("mail server ip"); doveadm_print_header_simple("expire time"); diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-print-table.c --- a/src/doveadm/doveadm-print-table.c Wed Feb 01 18:57:14 2012 +0200 +++ b/src/doveadm/doveadm-print-table.c Wed Feb 01 19:13:04 2012 +0200 @@ -103,8 +103,15 @@ break; } } - if (max_length < ctx->columns) - headers[0].length += (ctx->columns - max_length) / 2; + if (max_length < ctx->columns) { + for (i = 0; i < hdr_count; i++) { + if ((headers[i].flags & DOVEADM_PRINT_HEADER_FLAG_EXPAND) != 0) { + i++; + break; + } + } + headers[i-1].length += (ctx->columns - max_length) / 2; + } } static void doveadm_print_next(const char *value) diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-print.h --- a/src/doveadm/doveadm-print.h Wed Feb 01 18:57:14 2012 +0200 +++ b/src/doveadm/doveadm-print.h Wed Feb 01 19:13:04 2012 +0200 @@ -8,7 +8,8 @@ enum doveadm_print_header_flags { DOVEADM_PRINT_HEADER_FLAG_RIGHT_JUSTIFY = 0x01, DOVEADM_PRINT_HEADER_FLAG_STICKY = 0x02, - DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE = 0x04 + DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE = 0x04, + DOVEADM_PRINT_HEADER_FLAG_EXPAND = 0x08 }; extern const struct doveadm_print_vfuncs *doveadm_print_vfuncs_all[]; diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-proxy.c --- a/src/doveadm/doveadm-proxy.c Wed Feb 01 18:57:14 2012 +0200 +++ b/src/doveadm/doveadm-proxy.c Wed Feb 01 19:13:04 2012 +0200 @@ -68,7 +68,7 @@ ctx = cmd_proxy_init(argc, argv, "a:", cmd_proxy_list); doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE); - doveadm_print_header_simple("username"); + doveadm_print_header("username", "username", DOVEADM_PRINT_HEADER_FLAG_EXPAND); doveadm_print_header("service", "proto", 0); doveadm_print_header("src-ip", "src ip", 0); doveadm_print_header("dest-ip", "dest ip", 0); diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-stats.c --- a/src/doveadm/doveadm-stats.c Wed Feb 01 18:57:14 2012 +0200 +++ b/src/doveadm/doveadm-stats.c Wed Feb 01 19:13:04 2012 +0200 @@ -423,7 +423,7 @@ doveadm_print_deinit(); doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE); - doveadm_print_header_simple("USER"); + doveadm_print_header("USER", "USER", DOVEADM_PRINT_HEADER_FLAG_EXPAND); doveadm_print_header_simple("SERVICE"); doveadm_print_header_simple("%CPU"); doveadm_print_header_simple("%SYS"); diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-who.c --- a/src/doveadm/doveadm-who.c Wed Feb 01 18:57:14 2012 +0200 +++ b/src/doveadm/doveadm-who.c Wed Feb 01 19:13:04 2012 +0200 @@ -298,7 +298,8 @@ who_lookup(&ctx, who_aggregate_line); who_print(&ctx); } else { - doveadm_print_header_simple("username"); + doveadm_print_header("username", "username", + DOVEADM_PRINT_HEADER_FLAG_EXPAND); doveadm_print_header("service", "proto", 0); doveadm_print_header_simple("pid"); doveadm_print_header_simple("ip"); From dovecot at dovecot.org Wed Feb 1 20:12:10 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 20:12:10 +0200 Subject: dovecot-2.1: Keep track of seen mountpoints and warn at startup ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/51324056af4f changeset: 14040:51324056af4f user: Timo Sirainen date: Wed Feb 01 19:29:31 2012 +0200 description: Keep track of seen mountpoints and warn at startup if one is missing. doveadm mount commands can be used to manipulate the list. The list is kept in $rundir/mounts, but since it may be deleted after a reboot a copy is kept also in $statedir/mounts. If it's not found from $rundir at startup, it's copied there from $statedir. (The reason why only $statedir isn't used is because it's often not world-readable.) diffstat: src/doveadm/Makefile.am | 2 + src/doveadm/doveadm-mount.c | 125 +++++++++++++++ src/doveadm/doveadm.c | 1 + src/doveadm/doveadm.h | 1 + src/lib-master/Makefile.am | 2 + src/lib-master/mountpoint-list.c | 313 +++++++++++++++++++++++++++++++++++++++ src/lib-master/mountpoint-list.h | 60 +++++++ src/master/main.c | 40 ++++- 8 files changed, 543 insertions(+), 1 deletions(-) diffs (truncated from 640 to 300 lines): diff -r 56ff22125b7d -r 51324056af4f src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Wed Feb 01 19:13:04 2012 +0200 +++ b/src/doveadm/Makefile.am Wed Feb 01 19:29:31 2012 +0200 @@ -21,6 +21,7 @@ -DMODULEDIR=\""$(moduledir)"\" \ -DDOVEADM_MODULEDIR=\""$(doveadm_moduledir)"\" \ -DPKG_RUNDIR=\""$(rundir)"\" \ + -DPKG_STATEDIR=\""$(statedir)"\" \ -DBINDIR=\""$(bindir)"\" \ -DMANDIR=\""$(mandir)"\" @@ -93,6 +94,7 @@ doveadm-kick.c \ doveadm-log.c \ doveadm-master.c \ + doveadm-mount.c \ doveadm-mutf7.c \ doveadm-penalty.c \ doveadm-print-flow.c \ diff -r 56ff22125b7d -r 51324056af4f src/doveadm/doveadm-mount.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/doveadm/doveadm-mount.c Wed Feb 01 19:29:31 2012 +0200 @@ -0,0 +1,125 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "mountpoint-list.h" +#include "doveadm.h" +#include "doveadm-print.h" + +extern struct doveadm_cmd doveadm_cmd_mount[]; + +static void mount_cmd_help(doveadm_command_t *cmd) ATTR_NORETURN; + +static struct mountpoint_list *mountpoint_list_get(void) +{ + const char *perm_path, *state_path; + + perm_path = t_strconcat(PKG_STATEDIR"/"MOUNTPOINT_LIST_FNAME, NULL); + state_path = t_strconcat(doveadm_settings->base_dir, + "/"MOUNTPOINT_LIST_FNAME, NULL); + return mountpoint_list_init(perm_path, state_path); +} + +static void cmd_mount_status(int argc, char *argv[]) +{ + struct mountpoint_list *mountpoints; + struct mountpoint_list_iter *iter; + struct mountpoint_list_rec *rec; + bool mounts_known; + + if (argc > 2) + mount_cmd_help(cmd_mount_status); + + doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE); + doveadm_print_header_simple(" "); + doveadm_print_header("path", "path", DOVEADM_PRINT_HEADER_FLAG_EXPAND); + doveadm_print_header_simple("state"); + + mountpoints = mountpoint_list_get(); + mounts_known = mountpoint_list_update_mounted(mountpoints) == 0; + iter = mountpoint_list_iter_init(mountpoints); + while ((rec = mountpoint_list_iter_next(iter)) != NULL) { + if (argv[1] != NULL && strcmp(argv[1], rec->mount_path) != 0) + continue; + + if (mounts_known && MOUNTPOINT_WRONGLY_NOT_MOUNTED(rec)) + doveadm_print("!"); + else + doveadm_print(" "); + doveadm_print(!rec->wildcard ? rec->mount_path : + t_strconcat(rec->mount_path, "*", NULL)); + + doveadm_print(rec->state); + } + mountpoint_list_iter_deinit(&iter); + mountpoint_list_deinit(&mountpoints); +} + +static void cmd_mount_add(int argc, char *argv[]) +{ + struct mountpoint_list *mountpoints; + struct mountpoint_list_rec rec; + unsigned int len; + + if (argc > 3) + mount_cmd_help(cmd_mount_add); + + mountpoints = mountpoint_list_get(); + if (argv[1] == NULL) { + mountpoint_list_add_missing(mountpoints, MOUNTPOINT_STATE_DEFAULT, + mountpoint_list_default_ignore_types); + } else { + memset(&rec, 0, sizeof(rec)); + rec.mount_path = argv[1]; + rec.state = argv[2] != NULL ? argv[2] : + MOUNTPOINT_STATE_DEFAULT; + + len = strlen(rec.mount_path); + if (len > 0 && rec.mount_path[len-1] == '*') { + rec.wildcard = TRUE; + rec.mount_path = t_strndup(rec.mount_path, len-1); + } + mountpoint_list_add(mountpoints, &rec); + } + (void)mountpoint_list_save(mountpoints); + mountpoint_list_deinit(&mountpoints); +} + +static void cmd_mount_remove(int argc, char *argv[]) +{ + struct mountpoint_list *mountpoints; + + if (argc != 2) + mount_cmd_help(cmd_mount_remove); + + mountpoints = mountpoint_list_get(); + if (!mountpoint_list_remove(mountpoints, argv[1])) + i_error("Mountpoint not found: %s", argv[1]); + else + (void)mountpoint_list_save(mountpoints); + mountpoint_list_deinit(&mountpoints); +} + +struct doveadm_cmd doveadm_cmd_mount[] = { + { cmd_mount_status, "mount status", "[]" }, + { cmd_mount_add, "mount add", "[ []]" }, + { cmd_mount_remove, "mount remove", "" } +}; + +static void mount_cmd_help(doveadm_command_t *cmd) +{ + unsigned int i; + + for (i = 0; i < N_ELEMENTS(doveadm_cmd_mount); i++) { + if (doveadm_cmd_mount[i].cmd == cmd) + help(&doveadm_cmd_mount[i]); + } + i_unreached(); +} + +void doveadm_register_mount_commands(void) +{ + unsigned int i; + + for (i = 0; i < N_ELEMENTS(doveadm_cmd_mount); i++) + doveadm_register_cmd(&doveadm_cmd_mount[i]); +} diff -r 56ff22125b7d -r 51324056af4f src/doveadm/doveadm.c --- a/src/doveadm/doveadm.c Wed Feb 01 19:13:04 2012 +0200 +++ b/src/doveadm/doveadm.c Wed Feb 01 19:29:31 2012 +0200 @@ -321,6 +321,7 @@ } else { quick_init = FALSE; doveadm_register_director_commands(); + doveadm_register_mount_commands(); doveadm_register_proxy_commands(); doveadm_register_log_commands(); doveadm_dump_init(); diff -r 56ff22125b7d -r 51324056af4f src/doveadm/doveadm.h --- a/src/doveadm/doveadm.h Wed Feb 01 19:13:04 2012 +0200 +++ b/src/doveadm/doveadm.h Wed Feb 01 19:29:31 2012 +0200 @@ -38,5 +38,6 @@ void doveadm_register_director_commands(void); void doveadm_register_proxy_commands(void); void doveadm_register_log_commands(void); +void doveadm_register_mount_commands(void); #endif diff -r 56ff22125b7d -r 51324056af4f src/lib-master/Makefile.am --- a/src/lib-master/Makefile.am Wed Feb 01 19:13:04 2012 +0200 +++ b/src/lib-master/Makefile.am Wed Feb 01 19:29:31 2012 +0200 @@ -19,6 +19,7 @@ master-service.c \ master-service-settings.c \ master-service-settings-cache.c \ + mountpoint-list.c \ syslog-util.c headers = \ @@ -34,6 +35,7 @@ master-service-settings.h \ master-service-settings-cache.h \ service-settings.h \ + mountpoint-list.h \ syslog-util.h pkginc_libdir=$(pkgincludedir) diff -r 56ff22125b7d -r 51324056af4f src/lib-master/mountpoint-list.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-master/mountpoint-list.c Wed Feb 01 19:29:31 2012 +0200 @@ -0,0 +1,313 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "istream.h" +#include "file-copy.h" +#include "safe-mkstemp.h" +#include "str.h" +#include "write-full.h" +#include "mountpoint.h" +#include "mountpoint-list.h" + +#include +#include +#include + +struct mountpoint_list { + pool_t pool; + const char *perm_path, *state_path; + ARRAY_DEFINE(recs, struct mountpoint_list_rec *); + bool load_failed; +}; + +struct mountpoint_list_iter { + struct mountpoint_list *list; + unsigned int idx; +}; + +const char *const mountpoint_list_default_ignore_types[] = { + "proc", /* Linux, Solaris */ + "procfs", /* AIX, BSD */ + "tmpfs", /* Linux */ + "sysfs", /* Linux */ + "debugfs", /* Linux */ + "securityfs", /* Linux */ + "devpts", /* Linux */ + "devtmpfs", /* Linux */ + "rpc_pipefs", /* Linux */ + "fusectl", /* Linux */ + "nfsd", /* Linux */ + "binfmt_misc", /* Linux */ + "devfs", /* Solaris, OSX, BSD */ + "ctfs", /* Solaris */ + "mntfs", /* Solaris */ + "objfs", /* Solaris */ + "sharefs", /* Solaris */ + "lofs", /* Solaris */ + "fd", /* Solaris */ + NULL +}; + +static int mountpoint_list_load(struct mountpoint_list *list); + +struct mountpoint_list * +mountpoint_list_init(const char *perm_path, const char *state_path) +{ + struct mountpoint_list *list; + pool_t pool; + + pool = pool_alloconly_create("mountpoint list", 512); + list = p_new(pool, struct mountpoint_list, 1); + list->pool = pool; + list->perm_path = p_strdup(pool, perm_path); + list->state_path = p_strdup(pool, state_path); + p_array_init(&list->recs, pool, 16); + + (void)mountpoint_list_load(list); + return list; +} + +void mountpoint_list_deinit(struct mountpoint_list **_list) +{ + struct mountpoint_list *list = *_list; + + *_list = NULL; + pool_unref(&list->pool); +} + +static int mountpoint_list_load(struct mountpoint_list *list) +{ + struct mountpoint_list_rec rec; + struct istream *input; + char *p, *line; + unsigned int len; + int fd, ret = 0; + + memset(&rec, 0, sizeof(rec)); + + fd = open(list->state_path, O_RDONLY); + if (fd == -1) { + if (errno != ENOENT) { + i_error("open(%s) failed: %m", list->state_path); + return -1; + } + if (file_copy(list->perm_path, list->state_path, FALSE) < 0) + return -1; + fd = open(list->perm_path, O_RDONLY); + if (fd == -1) { + if (errno == ENOENT) { + /* perm_path didn't exist either */ + return 0; + } + i_error("open(%s) failed: %m", list->state_path); + return -1; + } + } + input = i_stream_create_fd(fd, (size_t)-1, TRUE); + while ((line = i_stream_read_next_line(input)) != NULL) { From dovecot at dovecot.org Wed Feb 1 20:21:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 20:21:49 +0200 Subject: dovecot-2.1: doveadm mount remove: Allow removing a wildcard pat... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f9a4404f2316 changeset: 14041:f9a4404f2316 user: Timo Sirainen date: Wed Feb 01 20:21:06 2012 +0200 description: doveadm mount remove: Allow removing a wildcard path with the '*' suffix. diffstat: src/doveadm/doveadm-mount.c | 27 ++++++++++++++++++++------- 1 files changed, 20 insertions(+), 7 deletions(-) diffs (61 lines): diff -r 51324056af4f -r f9a4404f2316 src/doveadm/doveadm-mount.c --- a/src/doveadm/doveadm-mount.c Wed Feb 01 19:29:31 2012 +0200 +++ b/src/doveadm/doveadm-mount.c Wed Feb 01 20:21:06 2012 +0200 @@ -54,11 +54,23 @@ mountpoint_list_deinit(&mountpoints); } +static bool mount_path_get_wildcard(const char **path) +{ + unsigned int len; + + len = strlen(*path); + if (len > 0 && (*path)[len-1] == '*') { + *path = t_strndup(*path, len-1); + return TRUE; + } else { + return FALSE; + } +} + static void cmd_mount_add(int argc, char *argv[]) { struct mountpoint_list *mountpoints; struct mountpoint_list_rec rec; - unsigned int len; if (argc > 3) mount_cmd_help(cmd_mount_add); @@ -73,11 +85,8 @@ rec.state = argv[2] != NULL ? argv[2] : MOUNTPOINT_STATE_DEFAULT; - len = strlen(rec.mount_path); - if (len > 0 && rec.mount_path[len-1] == '*') { + if (mount_path_get_wildcard(&rec.mount_path)) rec.wildcard = TRUE; - rec.mount_path = t_strndup(rec.mount_path, len-1); - } mountpoint_list_add(mountpoints, &rec); } (void)mountpoint_list_save(mountpoints); @@ -87,13 +96,17 @@ static void cmd_mount_remove(int argc, char *argv[]) { struct mountpoint_list *mountpoints; + const char *mount_path; if (argc != 2) mount_cmd_help(cmd_mount_remove); + mount_path = argv[1]; + (void)mount_path_get_wildcard(&mount_path); + mountpoints = mountpoint_list_get(); - if (!mountpoint_list_remove(mountpoints, argv[1])) - i_error("Mountpoint not found: %s", argv[1]); + if (!mountpoint_list_remove(mountpoints, mount_path)) + i_error("Mountpoint not found: %s", mount_path); else (void)mountpoint_list_save(mountpoints); mountpoint_list_deinit(&mountpoints); From dovecot at dovecot.org Wed Feb 1 20:21:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 20:21:49 +0200 Subject: dovecot-2.1: doveadm mount: Renamed "status" command to "list". Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cf34d9fc5cec changeset: 14042:cf34d9fc5cec user: Timo Sirainen date: Wed Feb 01 20:21:38 2012 +0200 description: doveadm mount: Renamed "status" command to "list". diffstat: src/doveadm/doveadm-mount.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (30 lines): diff -r f9a4404f2316 -r cf34d9fc5cec src/doveadm/doveadm-mount.c --- a/src/doveadm/doveadm-mount.c Wed Feb 01 20:21:06 2012 +0200 +++ b/src/doveadm/doveadm-mount.c Wed Feb 01 20:21:38 2012 +0200 @@ -19,7 +19,7 @@ return mountpoint_list_init(perm_path, state_path); } -static void cmd_mount_status(int argc, char *argv[]) +static void cmd_mount_list(int argc, char *argv[]) { struct mountpoint_list *mountpoints; struct mountpoint_list_iter *iter; @@ -27,7 +27,7 @@ bool mounts_known; if (argc > 2) - mount_cmd_help(cmd_mount_status); + mount_cmd_help(cmd_mount_list); doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE); doveadm_print_header_simple(" "); @@ -113,7 +113,7 @@ } struct doveadm_cmd doveadm_cmd_mount[] = { - { cmd_mount_status, "mount status", "[]" }, + { cmd_mount_list, "mount list", "[]" }, { cmd_mount_add, "mount add", "[ []]" }, { cmd_mount_remove, "mount remove", "" } }; From dovecot at dovecot.org Wed Feb 1 20:30:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 20:30:32 +0200 Subject: dovecot-2.1: lib-storage: Abort index/control/alt root dir creat... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d01932c7828a changeset: 14043:d01932c7828a user: Timo Sirainen date: Wed Feb 01 20:30:18 2012 +0200 description: lib-storage: Abort index/control/alt root dir creation if mountpoint isn't mounted. diffstat: src/lib-master/mountpoint-list.c | 41 +++++++++++++++++++++++++++++++++++++-- src/lib-master/mountpoint-list.h | 5 ++++ src/lib-storage/mail-user.c | 35 ++++++++++++++++++++++++++++++++++ src/lib-storage/mail-user.h | 8 +++++++ src/lib-storage/mailbox-list.c | 14 ++++++++++++- 5 files changed, 99 insertions(+), 4 deletions(-) diffs (221 lines): diff -r cf34d9fc5cec -r d01932c7828a src/lib-master/mountpoint-list.c --- a/src/lib-master/mountpoint-list.c Wed Feb 01 20:21:38 2012 +0200 +++ b/src/lib-master/mountpoint-list.c Wed Feb 01 20:30:18 2012 +0200 @@ -18,6 +18,7 @@ pool_t pool; const char *perm_path, *state_path; ARRAY_DEFINE(recs, struct mountpoint_list_rec *); + struct stat load_st; bool load_failed; }; @@ -49,8 +50,6 @@ NULL }; -static int mountpoint_list_load(struct mountpoint_list *list); - struct mountpoint_list * mountpoint_list_init(const char *perm_path, const char *state_path) { @@ -64,10 +63,16 @@ list->state_path = p_strdup(pool, state_path); p_array_init(&list->recs, pool, 16); - (void)mountpoint_list_load(list); + (void)mountpoint_list_refresh(list); return list; } +struct mountpoint_list * +mountpoint_list_init_readonly(const char *state_path) +{ + return mountpoint_list_init(NULL, state_path); +} + void mountpoint_list_deinit(struct mountpoint_list **_list) { struct mountpoint_list *list = *_list; @@ -92,6 +97,10 @@ i_error("open(%s) failed: %m", list->state_path); return -1; } + if (list->perm_path == NULL) { + /* we're in read-only mode */ + return 0; + } if (file_copy(list->perm_path, list->state_path, FALSE) < 0) return -1; fd = open(list->perm_path, O_RDONLY); @@ -104,6 +113,8 @@ return -1; } } + if (fstat(fd, &list->load_st) < 0) + i_error("fstat(%s) failed: %m", list->state_path); input = i_stream_create_fd(fd, (size_t)-1, TRUE); while ((line = i_stream_read_next_line(input)) != NULL) { p = strchr(line, ' '); @@ -131,6 +142,28 @@ return ret; } +int mountpoint_list_refresh(struct mountpoint_list *list) +{ + struct stat st; + + if (list->load_st.st_mtime != 0) { + if (stat(list->state_path, &st) < 0) { + if (errno == ENOENT) + return 0; + i_error("stat(%s) failed: %m", list->state_path); + return -1; + } + if (st.st_mtime == list->load_st.st_mtime && + ST_MTIME_NSEC(st) == ST_MTIME_NSEC(list->load_st) && + st.st_ino == list->load_st.st_ino) { + /* unchanged */ + return 0; + } + } + array_clear(&list->recs); + return mountpoint_list_load(list); +} + static int mountpoint_list_save_to(struct mountpoint_list *list, const char *path) { @@ -175,6 +208,8 @@ { int ret; + i_assert(list->perm_path != NULL); + if (list->load_failed) return -1; diff -r cf34d9fc5cec -r d01932c7828a src/lib-master/mountpoint-list.h --- a/src/lib-master/mountpoint-list.h Wed Feb 01 20:21:38 2012 +0200 +++ b/src/lib-master/mountpoint-list.h Wed Feb 01 20:30:18 2012 +0200 @@ -24,8 +24,13 @@ struct mountpoint_list * mountpoint_list_init(const char *perm_path, const char *state_path); +struct mountpoint_list * +mountpoint_list_init_readonly(const char *state_path); void mountpoint_list_deinit(struct mountpoint_list **list); +/* Reload the mountpoints if they have changed. Returns 0 if ok, + -1 if I/O error. */ +int mountpoint_list_refresh(struct mountpoint_list *list); /* Save the current list of mountpoints. Returns 0 if successful, -1 if I/O error. */ int mountpoint_list_save(struct mountpoint_list *list); diff -r cf34d9fc5cec -r d01932c7828a src/lib-storage/mail-user.c --- a/src/lib-storage/mail-user.c Wed Feb 01 20:21:38 2012 +0200 +++ b/src/lib-storage/mail-user.c Wed Feb 01 20:30:18 2012 +0200 @@ -12,6 +12,7 @@ #include "settings-parser.h" #include "auth-master.h" #include "master-service.h" +#include "mountpoint-list.h" #include "mail-storage-settings.h" #include "mail-storage-private.h" #include "mail-namespace.h" @@ -26,6 +27,8 @@ static void mail_user_deinit_base(struct mail_user *user) { mail_namespaces_deinit(&user->namespaces); + if (user->mountpoints != NULL) + mountpoint_list_deinit(&user->mountpoints); } struct mail_user *mail_user_alloc(const char *username, @@ -365,3 +368,35 @@ return t_strconcat(net_ip2addr(user->remote_ip), "/", str_tabescape(user->username), NULL); } + +bool mail_user_is_path_mounted(struct mail_user *user, const char *path, + const char **error_r) +{ + struct mountpoint_list_rec *rec; + const char *mounts_path; + + *error_r = NULL; + + if (user->mountpoints == NULL) { + mounts_path = t_strdup_printf("%s/"MOUNTPOINT_LIST_FNAME, + user->set->base_dir); + user->mountpoints = mountpoint_list_init_readonly(mounts_path); + } else { + (void)mountpoint_list_refresh(user->mountpoints); + } + rec = mountpoint_list_find(user->mountpoints, path); + if (rec == NULL || strcmp(rec->state, MOUNTPOINT_STATE_IGNORE) == 0) { + /* we don't have any knowledge of this path's mountpoint. + assume it's fine. */ + return TRUE; + } + /* record exists for this mountpoint. see if it's mounted */ + if (mountpoint_list_update_mounted(user->mountpoints) == 0 && + !rec->mounted) { + *error_r = t_strdup_printf("Mountpoint %s isn't mounted. " + "Mount it or remove it with doveadm mount remove", + rec->mount_path); + return FALSE; + } + return TRUE; +} diff -r cf34d9fc5cec -r d01932c7828a src/lib-storage/mail-user.h --- a/src/lib-storage/mail-user.h Wed Feb 01 20:21:38 2012 +0200 +++ b/src/lib-storage/mail-user.h Wed Feb 01 20:30:18 2012 +0200 @@ -35,6 +35,8 @@ struct mail_storage *storages; ARRAY_DEFINE(hooks, const struct mail_storage_hooks *); + struct mountpoint_list *mountpoints; + /* Module-specific contexts. See mail_storage_module_id. */ ARRAY_DEFINE(module_contexts, union mail_user_module_context *); @@ -118,5 +120,11 @@ int mail_user_try_home_expand(struct mail_user *user, const char **path); /* Returns unique user+ip identifier for anvil. */ const char *mail_user_get_anvil_userip_ident(struct mail_user *user); +/* Returns FALSE if path is in a mountpoint that should be mounted, + but isn't mounted. In such a situation it's better to fail than to attempt + any kind of automatic file/dir creations. error_r gives an error about which + mountpoint should be mounted. */ +bool mail_user_is_path_mounted(struct mail_user *user, const char *path, + const char **error_r); #endif diff -r cf34d9fc5cec -r d01932c7828a src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Wed Feb 01 20:21:38 2012 +0200 +++ b/src/lib-storage/mailbox-list.c Wed Feb 01 20:30:18 2012 +0200 @@ -789,11 +789,23 @@ enum mailbox_list_path_type type, const char **error_r) { - const char *expanded, *unexpanded, *root_dir, *p, *origin; + const char *expanded, *unexpanded, *root_dir, *p, *origin, *error; struct stat st; mode_t file_mode, dir_mode; gid_t gid; + if (stat(path, &st) == 0) { + /* looks like it already exists, don't bother checking + further. */ + return 0; + } + + if (!mail_user_is_path_mounted(list->ns->user, path, &error)) { + *error_r = t_strdup_printf( + "Can't create mailbox root dir %s: %s", path, error); + return -1; + } + mailbox_list_get_root_permissions(list, &file_mode, &dir_mode, &gid, &origin); From dovecot at dovecot.org Wed Feb 1 21:28:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 21:28:14 +0200 Subject: dovecot-2.1: lib-storage: Crashfix to previous change. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e3c4a86fb63b changeset: 14044:e3c4a86fb63b user: Timo Sirainen date: Wed Feb 01 21:27:45 2012 +0200 description: lib-storage: Crashfix to previous change. diffstat: src/lib-storage/mailbox-list.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (28 lines): diff -r d01932c7828a -r e3c4a86fb63b src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Wed Feb 01 20:30:18 2012 +0200 +++ b/src/lib-storage/mailbox-list.c Wed Feb 01 21:27:45 2012 +0200 @@ -157,13 +157,13 @@ list->set.inbox_path = p_strdup(list->pool, set->inbox_path); list->set.subscription_fname = p_strdup(list->pool, set->subscription_fname); - list->set.maildir_name = set->maildir_name == NULL ? "" : + list->set.maildir_name = p_strdup(list->pool, set->maildir_name); list->set.mailbox_dir_name = p_strdup(list->pool, set->mailbox_dir_name); list->set.alt_dir = p_strdup(list->pool, set->alt_dir); - if (set->mailbox_dir_name == NULL || *set->mailbox_dir_name == '\0') + if (*set->mailbox_dir_name == '\0') list->set.mailbox_dir_name = ""; else if (set->mailbox_dir_name[strlen(set->mailbox_dir_name)-1] == '/') { list->set.mailbox_dir_name = @@ -249,6 +249,8 @@ *error_r = NULL; memset(set_r, 0, sizeof(*set_r)); + set_r->maildir_name = ""; + set_r->mailbox_dir_name = ""; if (*data == '\0') return 0; From dovecot at dovecot.org Wed Feb 1 22:04:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 22:04:32 +0200 Subject: dovecot-2.1: ioloop: I/O and timeout leak messages now include t... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0308a33d9f99 changeset: 14045:0308a33d9f99 user: Timo Sirainen date: Wed Feb 01 22:04:26 2012 +0200 description: ioloop: I/O and timeout leak messages now include the io_add()/timeout_add() source line number. This helps figuring out the leak especially when using ASLR. Also in 64bit systems there's no increased memory usage, because the line number replaces only padding. diffstat: src/lib/ioloop-private.h | 2 ++ src/lib/ioloop.c | 18 +++++++++++++----- src/lib/ioloop.h | 9 +++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diffs (123 lines): diff -r e3c4a86fb63b -r 0308a33d9f99 src/lib/ioloop-private.h --- a/src/lib/ioloop-private.h Wed Feb 01 21:27:45 2012 +0200 +++ b/src/lib/ioloop-private.h Wed Feb 01 22:04:26 2012 +0200 @@ -29,6 +29,7 @@ struct io { enum io_condition condition; + unsigned int source_linenum; io_callback_t *callback; void *context; @@ -49,6 +50,7 @@ struct timeout { struct priorityq_item item; + unsigned int source_linenum; unsigned int msecs; struct timeval next_run; diff -r e3c4a86fb63b -r 0308a33d9f99 src/lib/ioloop.c --- a/src/lib/ioloop.c Wed Feb 01 21:27:45 2012 +0200 +++ b/src/lib/ioloop.c Wed Feb 01 22:04:26 2012 +0200 @@ -29,6 +29,7 @@ #undef io_add struct io *io_add(int fd, enum io_condition condition, + unsigned int source_linenum, io_callback_t *callback, void *context) { struct io_file *io; @@ -42,6 +43,7 @@ io->io.callback = callback; io->io.context = context; io->io.ioloop = current_ioloop; + io->io.source_linenum = source_linenum; io->refcount = 1; io->fd = fd; @@ -139,12 +141,13 @@ } #undef timeout_add -struct timeout *timeout_add(unsigned int msecs, timeout_callback_t *callback, - void *context) +struct timeout *timeout_add(unsigned int msecs, unsigned int source_linenum, + timeout_callback_t *callback, void *context) { struct timeout *timeout; timeout = i_new(struct timeout, 1); + timeout->source_linenum = source_linenum; timeout->msecs = msecs; timeout->ioloop = current_ioloop; @@ -459,14 +462,17 @@ struct io_file *io = ioloop->io_files; struct io *_io = &io->io; - i_warning("I/O leak: %p (%d)", (void *)io->io.callback, io->fd); + i_warning("I/O leak: %p (line %u, fd %d)", + (void *)io->io.callback, + io->io.source_linenum, io->fd); io_remove(&_io); } while ((item = priorityq_pop(ioloop->timeouts)) != NULL) { struct timeout *to = (struct timeout *)item; - i_warning("Timeout leak: %p", (void *)to->callback); + i_warning("Timeout leak: %p (line %u)", (void *)to->callback, + to->source_linenum); timeout_free(to); } priorityq_deinit(&ioloop->timeouts); @@ -627,6 +633,7 @@ old_io_file = (struct io_file *)old_io; new_io = io_add(old_io_file->fd, old_io->condition, + old_io->source_linenum, old_io->callback, old_io->context); io_remove(_io); return new_io; @@ -639,7 +646,8 @@ if (old_to->ioloop == current_ioloop) return old_to; - new_to = timeout_add(old_to->msecs, old_to->callback, old_to->context); + new_to = timeout_add(old_to->msecs, old_to->source_linenum, + old_to->callback, old_to->context); timeout_remove(_timeout); return new_to; } diff -r e3c4a86fb63b -r 0308a33d9f99 src/lib/ioloop.h --- a/src/lib/ioloop.h Wed Feb 01 21:27:45 2012 +0200 +++ b/src/lib/ioloop.h Wed Feb 01 22:04:26 2012 +0200 @@ -46,10 +46,11 @@ Don't try to add multiple handlers for the same type. It's not checked and the behavior will be undefined. */ struct io *io_add(int fd, enum io_condition condition, + unsigned int source_linenum, io_callback_t *callback, void *context); #define io_add(fd, condition, callback, context) \ CONTEXT_CALLBACK(io_add, io_callback_t, \ - callback, context, fd, condition) + callback, context, fd, condition, __LINE__) enum io_notify_result io_add_notify(const char *path, io_callback_t *callback, void *context, struct io **io_r); #ifdef CONTEXT_TYPE_SAFETY @@ -68,11 +69,11 @@ void io_remove_closed(struct io **io); /* Timeout handlers */ -struct timeout *timeout_add(unsigned int msecs, timeout_callback_t *callback, - void *context); +struct timeout *timeout_add(unsigned int msecs, unsigned int source_linenum, + timeout_callback_t *callback, void *context); #define timeout_add(msecs, callback, context) \ CONTEXT_CALLBACK(timeout_add, timeout_callback_t, \ - callback, context, msecs) + callback, context, msecs, __LINE__) /* Remove timeout handler, and set timeout pointer to NULL. */ void timeout_remove(struct timeout **timeout); /* Reset timeout so it's next run after now+msecs. */ From dovecot at dovecot.org Wed Feb 1 22:18:42 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 22:18:42 +0200 Subject: dovecot-2.1: lib-storage: And another fix to previous maildir_na... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/db8c1dde0b41 changeset: 14046:db8c1dde0b41 user: Timo Sirainen date: Wed Feb 01 22:18:33 2012 +0200 description: lib-storage: And another fix to previous maildir_name/mailbox_dir_name changes. diffstat: src/lib-storage/index/dbox-common/dbox-storage.c | 4 ++-- src/lib-storage/index/maildir/maildir-storage.c | 2 +- src/lib-storage/mailbox-list.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diffs (39 lines): diff -r 0308a33d9f99 -r db8c1dde0b41 src/lib-storage/index/dbox-common/dbox-storage.c --- a/src/lib-storage/index/dbox-common/dbox-storage.c Wed Feb 01 22:04:26 2012 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Wed Feb 01 22:18:33 2012 +0200 @@ -21,9 +21,9 @@ set->layout = MAILBOX_LIST_NAME_FS; if (set->subscription_fname == NULL) set->subscription_fname = DBOX_SUBSCRIPTION_FILE_NAME; - if (set->maildir_name == NULL) + if (*set->maildir_name == '\0') set->maildir_name = DBOX_MAILDIR_NAME; - if (set->mailbox_dir_name == NULL) + if (*set->mailbox_dir_name == '\0') set->mailbox_dir_name = DBOX_MAILBOX_DIR_NAME; } diff -r 0308a33d9f99 -r db8c1dde0b41 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Wed Feb 01 22:04:26 2012 +0200 +++ b/src/lib-storage/index/maildir/maildir-storage.c Wed Feb 01 22:18:33 2012 +0200 @@ -80,7 +80,7 @@ if (set->subscription_fname == NULL) set->subscription_fname = MAILDIR_SUBSCRIPTION_FILE_NAME; - if (set->inbox_path == NULL && set->maildir_name == NULL && + if (set->inbox_path == NULL && *set->maildir_name == '\0' && (strcmp(set->layout, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) == 0 || strcmp(set->layout, MAILBOX_LIST_NAME_FS) == 0) && (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) { diff -r 0308a33d9f99 -r db8c1dde0b41 src/lib-storage/mailbox-list.c --- a/src/lib-storage/mailbox-list.c Wed Feb 01 22:04:26 2012 +0200 +++ b/src/lib-storage/mailbox-list.c Wed Feb 01 22:18:33 2012 +0200 @@ -119,7 +119,7 @@ class_p = array_idx(&mailbox_list_drivers, idx); if (((*class_p)->props & MAILBOX_LIST_PROP_NO_MAILDIR_NAME) != 0 && - set->maildir_name != NULL && *set->maildir_name != '\0') { + *set->maildir_name != '\0') { *error_r = "maildir_name not supported by this driver"; return -1; } From dovecot at dovecot.org Wed Feb 1 23:06:19 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 23:06:19 +0200 Subject: dovecot-2.1: stats plugin disabled calling other plugins' user.d... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b82a3149f45e changeset: 14047:b82a3149f45e user: Timo Sirainen date: Wed Feb 01 23:06:12 2012 +0200 description: stats plugin disabled calling other plugins' user.deinit() method. diffstat: src/plugins/stats/stats-plugin.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r db8c1dde0b41 -r b82a3149f45e src/plugins/stats/stats-plugin.c --- a/src/plugins/stats/stats-plugin.c Wed Feb 01 22:18:33 2012 +0200 +++ b/src/plugins/stats/stats-plugin.c Wed Feb 01 23:06:12 2012 +0200 @@ -521,7 +521,7 @@ suser = p_new(user->pool, struct stats_user, 1); suser->module_ctx.super = *v; user->vlast = &suser->module_ctx.super; - user->v.deinit = stats_user_deinit; + v->deinit = stats_user_deinit; suser->refresh_secs = refresh_secs; str = mail_user_plugin_getenv(user, "stats_track_cmds"); From dovecot at dovecot.org Wed Feb 1 23:34:00 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 23:34:00 +0200 Subject: dovecot-2.1: sdbox: Fixed moving files from alt storage to prima... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fb659472b2a2 changeset: 14048:fb659472b2a2 user: Timo Sirainen date: Wed Feb 01 23:33:51 2012 +0200 description: sdbox: Fixed moving files from alt storage to primary storage. diffstat: src/lib-storage/index/dbox-single/sdbox-sync.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (21 lines): diff -r b82a3149f45e -r fb659472b2a2 src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Wed Feb 01 23:06:12 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Wed Feb 01 23:33:51 2012 +0200 @@ -12,9 +12,17 @@ dbox_sync_file_move_if_needed(struct dbox_file *file, enum sdbox_sync_entry_type type) { + struct stat st; bool move_to_alt = type == SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT; bool deleted; + if (move_to_alt == dbox_file_is_in_alt(file) && + !move_to_alt) { + /* unopened dbox files default to primary dir. + stat the file to update its location. */ + (void)dbox_file_stat(file, &st); + + } if (move_to_alt != dbox_file_is_in_alt(file)) { /* move the file. if it fails, nothing broke so don't worry about it. */ From dovecot at dovecot.org Wed Feb 1 23:34:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 01 Feb 2012 23:34:29 +0200 Subject: dovecot-2.0: sdbox: Fixed moving files from alt storage to prima... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/dcc19b00e748 changeset: 13035:dcc19b00e748 user: Timo Sirainen date: Wed Feb 01 23:34:24 2012 +0200 description: sdbox: Fixed moving files from alt storage to primary storage. diffstat: src/lib-storage/index/dbox-single/sdbox-sync.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (21 lines): diff -r c30ea8aec902 -r dcc19b00e748 src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Sun Jan 29 00:35:40 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Wed Feb 01 23:34:24 2012 +0200 @@ -12,9 +12,17 @@ dbox_sync_file_move_if_needed(struct dbox_file *file, enum sdbox_sync_entry_type type) { + struct stat st; bool move_to_alt = type == SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT; bool deleted; + if (move_to_alt == dbox_file_is_in_alt(file) && + !move_to_alt) { + /* unopened dbox files default to primary dir. + stat the file to update its location. */ + (void)dbox_file_stat(file, &st); + + } if (move_to_alt != dbox_file_is_in_alt(file)) { /* move the file. if it fails, nothing broke so don't worry about it. */ From dovecot at dovecot.org Thu Feb 2 01:07:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 01:07:49 +0200 Subject: dovecot-2.1: ldap: Support using the same LDAP attribute in mult... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6734aa225b4f changeset: 14049:6734aa225b4f user: Timo Sirainen date: Thu Feb 02 01:07:37 2012 +0200 description: ldap: Support using the same LDAP attribute in multiple fields. diffstat: src/auth/db-ldap.c | 386 +++++++++++++++++++++++++++--------------------- src/auth/db-ldap.h | 17 +- src/auth/passdb-ldap.c | 12 +- src/auth/userdb-ldap.c | 20 +- 4 files changed, 241 insertions(+), 194 deletions(-) diffs (truncated from 641 to 300 lines): diff -r fb659472b2a2 -r 6734aa225b4f src/auth/db-ldap.c --- a/src/auth/db-ldap.c Wed Feb 01 23:33:51 2012 +0200 +++ b/src/auth/db-ldap.c Thu Feb 02 01:07:37 2012 +0200 @@ -49,19 +49,23 @@ # define LDAP_OPT_SUCCESS LDAP_SUCCESS #endif +struct db_ldap_value { + const char **values; + bool used; +}; + struct db_ldap_result_iterate_context { - struct ldap_connection *conn; - LDAPMessage *entry; + pool_t pool; + struct auth_request *auth_request; + const ARRAY_TYPE(ldap_field) *attr_map; + unsigned int attr_idx; - struct hash_table *attr_map; + /* ldap_attr_name => struct db_ldap_value */ + struct hash_table *ldap_attrs; struct var_expand_table *var_table; - char *attr, **vals; - const char *name, *template, *val_1_arr[2]; - const char *const *static_attrs; - BerElement *ber; - + const char *val_1_arr[2]; string_t *var, *debug; }; @@ -587,8 +591,9 @@ (struct ldap_request_search *)request; auth_request_log_error(request->auth_request, "ldap", - "ldap_search(%s) failed: %s", - srequest->filter, ldap_err2string(ret)); + "ldap_search(base=%s filter=%s) failed: %s", + srequest->base, srequest->filter, + ldap_err2string(ret)); res = NULL; } @@ -973,19 +978,18 @@ } void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist, - char ***attr_names_r, struct hash_table *attr_map, + char ***attr_names_r, ARRAY_TYPE(ldap_field) *attr_map, const char *skip_attr) { + struct ldap_field *field; const char *const *attr, *attr_data, *p; - string_t *static_data; - char *name, *value; + char *ldap_attr, *name, *templ; unsigned int i, j, size; if (*attrlist == '\0') return; - attr = t_strsplit(attrlist, ","); - static_data = t_str_new(128); + attr = t_strsplit_spaces(attrlist, ","); /* @UNSAFE */ for (size = 0; attr[size] != NULL; size++) ; @@ -998,32 +1002,29 @@ p = strchr(attr_data, '='); if (p == NULL) - name = value = p_strdup(conn->pool, attr_data); - else if (p != attr_data) { - name = p_strdup_until(conn->pool, attr_data, p); - value = p_strdup(conn->pool, p + 1); - } else { - /* == */ - if (str_len(static_data) > 0) - str_append_c(static_data, ','); - str_append(static_data, p + 1); - continue; + ldap_attr = name = p_strdup(conn->pool, attr_data); + else { + ldap_attr = p_strdup_until(conn->pool, attr_data, p); + name = p_strdup(conn->pool, p + 1); } - if (*name != '\0' && - (skip_attr == NULL || strcmp(skip_attr, value) != 0)) { - if (hash_table_lookup(attr_map, name) != NULL) { - i_fatal("ldap: LDAP attribute '%s' used multiple times. This is currently unsupported.", - name); - } - hash_table_insert(attr_map, name, value); - (*attr_names_r)[j++] = name; + templ = strchr(name, '='); + if (templ == NULL) + templ = ""; + else + *templ++ = '\0'; + + if (*name == '\0') + i_error("ldap: Invalid attrs entry: %s", attr_data); + else if (skip_attr == NULL || strcmp(skip_attr, name) != 0) { + field = array_append_space(attr_map); + field->name = name; + field->value = templ; + field->ldap_attr_name = ldap_attr; + if (*ldap_attr != '\0') + (*attr_names_r)[j++] = ldap_attr; } } - if (str_len(static_data) > 0) { - hash_table_insert(attr_map, "", - p_strdup(conn->pool, str_c(static_data))); - } } struct var_expand_table * @@ -1071,171 +1072,214 @@ return str_c(ret); } +static bool +ldap_field_hide_password(struct db_ldap_result_iterate_context *ctx, + const char *attr) +{ + const struct ldap_field *field; + + if (ctx->auth_request->set->debug_passwords) + return FALSE; + + array_foreach(ctx->attr_map, field) { + if (strcmp(field->ldap_attr_name, attr) == 0) { + if (strcmp(field->name, "password") == 0 || + strcmp(field->name, "password_noscheme") == 0) + return TRUE; + } + } + return FALSE; +} + +static void +get_ldap_fields(struct db_ldap_result_iterate_context *ctx, + struct ldap_connection *conn, LDAPMessage *entry) +{ + struct db_ldap_value *ldap_value; + char *attr, **vals; + unsigned int i, count; + BerElement *ber; + + attr = ldap_first_attribute(conn->ld, entry, &ber); + while (attr != NULL) { + vals = ldap_get_values(conn->ld, entry, attr); + + ldap_value = p_new(ctx->pool, struct db_ldap_value, 1); + if (vals == NULL) { + ldap_value->values = p_new(ctx->pool, const char *, 1); + count = 0; + } else { + for (count = 0; vals[count] != NULL; count++) ; + } + + ldap_value->values = p_new(ctx->pool, const char *, count + 1); + for (i = 0; i < count; i++) + ldap_value->values[i] = p_strdup(ctx->pool, vals[i]); + + if (ctx->debug != NULL) { + str_printfa(ctx->debug, " %s=", attr); + if (count == 0) + str_append(ctx->debug, ""); + else if (ldap_field_hide_password(ctx, attr)) + str_append(ctx->debug, PASSWORD_HIDDEN_STR); + else { + str_append(ctx->debug, ldap_value->values[0]); + for (i = 1; i < count; i++) { + str_printfa(ctx->debug, ",%s", + ldap_value->values[0]); + } + } + } + hash_table_insert(ctx->ldap_attrs, + p_strdup(ctx->pool, attr), ldap_value); + + ldap_value_free(vals); + ldap_memfree(attr); + attr = ldap_next_attribute(conn->ld, entry, ber); + } + ber_free(ber, 0); +} + struct db_ldap_result_iterate_context * db_ldap_result_iterate_init(struct ldap_connection *conn, LDAPMessage *entry, struct auth_request *auth_request, - struct hash_table *attr_map) + const ARRAY_TYPE(ldap_field) *attr_map) { struct db_ldap_result_iterate_context *ctx; - const char *static_data; + pool_t pool; - ctx = t_new(struct db_ldap_result_iterate_context, 1); - ctx->conn = conn; - ctx->entry = entry; + pool = pool_alloconly_create("ldap result iter", 1024); + ctx = p_new(pool, struct db_ldap_result_iterate_context, 1); + ctx->pool = pool; ctx->auth_request = auth_request; ctx->attr_map = attr_map; - - static_data = hash_table_lookup(attr_map, ""); - if (static_data != NULL) { - const struct var_expand_table *table; - string_t *str; - - table = auth_request_get_var_expand_table(auth_request, NULL); - str = t_str_new(256); - var_expand(str, static_data, table); - ctx->static_attrs = t_strsplit(str_c(str), ","); - } - + ctx->ldap_attrs = + hash_table_create(default_pool, pool, 0, strcase_hash, + (hash_cmp_callback_t *)strcasecmp); if (auth_request->set->debug) ctx->debug = t_str_new(256); - ctx->attr = ldap_first_attribute(conn->ld, entry, &ctx->ber); + get_ldap_fields(ctx, conn, entry); return ctx; } -static void -db_ldap_result_iterate_finish(struct db_ldap_result_iterate_context *ctx) +static const char *const * +db_ldap_result_return_value(struct db_ldap_result_iterate_context *ctx, + const struct ldap_field *field, + struct db_ldap_value *ldap_value) { - if (ctx->debug != NULL) { - if (str_len(ctx->debug) > 0) { - auth_request_log_debug(ctx->auth_request, "ldap", - "result: %s", str_c(ctx->debug) + 1); - } else { - auth_request_log_debug(ctx->auth_request, "ldap", - "no fields returned by the server"); + const char *const *values; + + if (*field->value == '\0') { + /* use the LDAP attribute's value */ + if (ldap_value != NULL) + values = ldap_value->values; + else { + /* LDAP attribute doesn't exist */ + ctx->val_1_arr[0] = NULL; + values = ctx->val_1_arr; } - } - - ber_free(ctx->ber, 0); -} - -static void -db_ldap_result_change_attr(struct db_ldap_result_iterate_context *ctx) -{ - i_assert(ctx->vals == NULL); - - ctx->name = hash_table_lookup(ctx->attr_map, ctx->attr); - ctx->template = NULL; - - if (ctx->debug != NULL) { - str_printfa(ctx->debug, " %s(%s)=", ctx->attr, - ctx->name != NULL ? ctx->name : "?unknown?"); - } - - if (ctx->name == NULL || *ctx->name == '\0') - return; - - if (strchr(ctx->name, '%') != NULL && - (ctx->template = strchr(ctx->name, '=')) != NULL) { - /* we want to use variables */ - ctx->name = t_strdup_until(ctx->name, ctx->template); - ctx->template++; + } else { + /* template */ + if (ldap_value->values[0] != NULL && + ldap_value->values[1] != NULL) { + auth_request_log_warning(ctx->auth_request, "ldap", + "Multiple values found for '%s', " + "using value '%s'", + field->name, ldap_value->values[0]); + } if (ctx->var_table == NULL) { ctx->var_table = db_ldap_value_get_var_expand_table( ctx->auth_request); - ctx->var = t_str_new(256); From dovecot at dovecot.org Thu Feb 2 13:12:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 13:12:25 +0200 Subject: dovecot-2.1: config: In "key= details: http://hg.dovecot.org/dovecot-2.1/rev/901ce18fbfcb changeset: 14050:901ce18fbfcb user: Timo Sirainen date: Thu Feb 02 13:12:19 2012 +0200 description: config: In "key=str; const void *var_name, *var_value, *p; enum setting_type var_type; - const char *error; + const char *error, *path; bool dump, expand_parent; switch (type) { @@ -758,10 +758,13 @@ } else { if (!config_require_key(ctx, key)) { /* don't even try to open the file */ - } else if (str_append_file(str, key, value, &error) < 0) { - /* file reading failed */ - ctx->error = p_strdup(ctx->pool, error); - return -1; + } else { + path = fix_relative_path(value, ctx->cur_input); + if (str_append_file(str, key, path, &error) < 0) { + /* file reading failed */ + ctx->error = p_strdup(ctx->pool, error); + return -1; + } } } break; From dovecot at dovecot.org Thu Feb 2 13:26:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 13:26:48 +0200 Subject: dovecot-2.1: imapc: Crashfix related to recent maildir_name/mail... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/adb1ac9a9b82 changeset: 14051:adb1ac9a9b82 user: Timo Sirainen date: Thu Feb 02 13:26:38 2012 +0200 description: imapc: Crashfix related to recent maildir_name/mailbox_dir_name changes. diffstat: src/lib-storage/index/imapc/imapc-list.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 901ce18fbfcb -r adb1ac9a9b82 src/lib-storage/index/imapc/imapc-list.c --- a/src/lib-storage/index/imapc/imapc-list.c Thu Feb 02 13:12:19 2012 +0200 +++ b/src/lib-storage/index/imapc/imapc-list.c Thu Feb 02 13:26:38 2012 +0200 @@ -207,6 +207,8 @@ list_set.layout = MAILBOX_LIST_NAME_MAILDIRPLUSPLUS; list_set.root_dir = dir; list_set.escape_char = IMAPC_LIST_ESCAPE_CHAR; + list_set.mailbox_dir_name = ""; + list_set.maildir_name = ""; if (mailbox_list_create(list_set.layout, list->list.ns, &list_set, MAILBOX_LIST_FLAG_SECONDARY, From dovecot at dovecot.org Thu Feb 2 15:25:19 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 15:25:19 +0200 Subject: dovecot-2.1: ldap: Crashfixes to previous change. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7edafe5c43da changeset: 14052:7edafe5c43da user: Timo Sirainen date: Thu Feb 02 15:25:04 2012 +0200 description: ldap: Crashfixes to previous change. diffstat: src/auth/db-ldap.c | 31 ++++++++++++++++--------------- src/auth/db-ldap.h | 3 --- 2 files changed, 16 insertions(+), 18 deletions(-) diffs (80 lines): diff -r adb1ac9a9b82 -r 7edafe5c43da src/auth/db-ldap.c --- a/src/auth/db-ldap.c Thu Feb 02 13:26:38 2012 +0200 +++ b/src/auth/db-ldap.c Thu Feb 02 15:25:04 2012 +0200 @@ -1027,8 +1027,9 @@ } } -struct var_expand_table * -db_ldap_value_get_var_expand_table(struct auth_request *auth_request) +static struct var_expand_table * +db_ldap_value_get_var_expand_table(pool_t pool, + struct auth_request *auth_request) { const struct var_expand_table *auth_table = NULL; struct var_expand_table *table; @@ -1038,7 +1039,7 @@ for (count = 0; auth_table[count].key != '\0'; count++) ; count++; - table = t_new(struct var_expand_table, count + 1); + table = p_new(pool, struct var_expand_table, count + 2); table[0].key = '$'; memcpy(table + 1, auth_table, sizeof(*table) * count); return table; @@ -1170,30 +1171,30 @@ { const char *const *values; + if (ldap_value != NULL) + values = ldap_value->values; + else { + /* LDAP attribute doesn't exist */ + ctx->val_1_arr[0] = NULL; + values = ctx->val_1_arr; + } + if (*field->value == '\0') { /* use the LDAP attribute's value */ - if (ldap_value != NULL) - values = ldap_value->values; - else { - /* LDAP attribute doesn't exist */ - ctx->val_1_arr[0] = NULL; - values = ctx->val_1_arr; - } } else { /* template */ - if (ldap_value->values[0] != NULL && - ldap_value->values[1] != NULL) { + if (values[0] != NULL && values[1] != NULL) { auth_request_log_warning(ctx->auth_request, "ldap", "Multiple values found for '%s', " "using value '%s'", - field->name, ldap_value->values[0]); + field->name, values[0]); } if (ctx->var_table == NULL) { ctx->var_table = db_ldap_value_get_var_expand_table( - ctx->auth_request); + ctx->pool, ctx->auth_request); ctx->var = str_new(ctx->pool, 256); } - ctx->var_table[0].value = ldap_value->values[0]; + ctx->var_table[0].value = values[0]; str_truncate(ctx->var, 0); var_expand(ctx->var, field->value, ctx->var_table); ctx->val_1_arr[0] = str_c(ctx->var); diff -r adb1ac9a9b82 -r 7edafe5c43da src/auth/db-ldap.h --- a/src/auth/db-ldap.h Thu Feb 02 13:26:38 2012 +0200 +++ b/src/auth/db-ldap.h Thu Feb 02 15:25:04 2012 +0200 @@ -177,9 +177,6 @@ void db_ldap_enable_input(struct ldap_connection *conn, bool enable); -struct var_expand_table * -db_ldap_value_get_var_expand_table(struct auth_request *auth_request); - const char *ldap_escape(const char *str, const struct auth_request *auth_request); const char *ldap_get_error(struct ldap_connection *conn); From dovecot at dovecot.org Thu Feb 2 15:28:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 15:28:16 +0200 Subject: dovecot-2.1: liblib: Added var_expand_with_funcs() to expand var... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ba86a60e3059 changeset: 14053:ba86a60e3059 user: Timo Sirainen date: Thu Feb 02 15:27:27 2012 +0200 description: liblib: Added var_expand_with_funcs() to expand variables with function callbacks. diffstat: src/lib/var-expand.c | 45 +++++++++++++++++++++++++++++++++++++++------ src/lib/var-expand.h | 12 ++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) diffs (107 lines): diff -r 7edafe5c43da -r ba86a60e3059 src/lib/var-expand.c --- a/src/lib/var-expand.c Thu Feb 02 15:25:04 2012 +0200 +++ b/src/lib/var-expand.c Thu Feb 02 15:27:27 2012 +0200 @@ -139,8 +139,25 @@ }; static const char * +var_expand_func(const struct var_expand_func_table *func_table, + const char *key, const char *data, void *context) +{ + if (strcmp(key, "env") == 0) + return getenv(data); + if (func_table == NULL) + return NULL; + + for (; func_table->key != NULL; func_table++) { + if (strcmp(func_table->key, key) == 0) + return func_table->func(data, context); + } + return NULL; +} + +static const char * var_expand_long(const struct var_expand_table *table, - const void *key_start, unsigned int key_len) + const struct var_expand_func_table *func_table, + const void *key_start, unsigned int key_len, void *context) { const struct var_expand_table *t; const char *value = NULL; @@ -171,14 +188,23 @@ value = my_hostname; break; } - if (strncmp(key, "env:", 4) == 0) - value = getenv(key + 4); + if (value == NULL) { + const char *data = strchr(key, ':'); + + if (data != NULL) + key = t_strdup_until(key, data++); + else + data = ""; + value = var_expand_func(func_table, key, data, context); + } } T_END; return value; } -void var_expand(string_t *dest, const char *str, - const struct var_expand_table *table) +void var_expand_with_funcs(string_t *dest, const char *str, + const struct var_expand_table *table, + const struct var_expand_func_table *func_table, + void *context) { const struct var_expand_modifier *m; const struct var_expand_table *t; @@ -257,7 +283,8 @@ if (*str == '{' && (end = strchr(str, '}')) != NULL) { /* %{long_key} */ len = end - (str + 1); - var = var_expand_long(table, str+1, len); + var = var_expand_long(table, func_table, + str+1, len, context); if (var != NULL) str = end; } else { @@ -311,6 +338,12 @@ } } +void var_expand(string_t *dest, const char *str, + const struct var_expand_table *table) +{ + var_expand_with_funcs(dest, str, table, NULL, NULL); +} + char var_get_key(const char *str) { const struct var_expand_modifier *m; diff -r 7edafe5c43da -r ba86a60e3059 src/lib/var-expand.h --- a/src/lib/var-expand.h Thu Feb 02 15:25:04 2012 +0200 +++ b/src/lib/var-expand.h Thu Feb 02 15:27:27 2012 +0200 @@ -7,10 +7,22 @@ const char *long_key; }; +struct var_expand_func_table { + const char *key; + /* %{key:data}, or data is "" with %{key}, */ + const char *(*func)(const char *data, void *context); +}; + /* Expand % variables in src and append the string in dest. table must end with key = 0. */ void var_expand(string_t *dest, const char *str, const struct var_expand_table *table); +/* Like var_expand(), but support also callback functions for + variable expansion. */ +void var_expand_with_funcs(string_t *dest, const char *str, + const struct var_expand_table *table, + const struct var_expand_func_table *func_table, + void *func_context); /* Returns the actual key character for given string, ie. skip any modifiers that are before it. The string should be the data after the '%' character. */ From dovecot at dovecot.org Thu Feb 2 15:28:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 15:28:16 +0200 Subject: dovecot-2.1: auth: LDAP fields can now access any returned LDAP ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ab58022f934f changeset: 14054:ab58022f934f user: Timo Sirainen date: Thu Feb 02 15:28:10 2012 +0200 description: auth: LDAP fields can now access any returned LDAP attribtes with %{ldap:name} diffstat: src/auth/db-ldap.c | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-) diffs (55 lines): diff -r ba86a60e3059 -r ab58022f934f src/auth/db-ldap.c --- a/src/auth/db-ldap.c Thu Feb 02 15:27:27 2012 +0200 +++ b/src/auth/db-ldap.c Thu Feb 02 15:28:10 2012 +0200 @@ -1164,11 +1164,41 @@ return ctx; } +static const char *db_ldap_field_expand(const char *data, void *context) +{ + struct db_ldap_result_iterate_context *ctx = context; + struct db_ldap_value *ldap_value; + + ldap_value = hash_table_lookup(ctx->ldap_attrs, data); + if (ldap_value == NULL) { + /* ldap attribute wasn't requested */ + if (ctx->debug) + str_printfa(ctx->debug, "; %s missing", data); + return ""; + } + ldap_value->used = TRUE; + + if (ldap_value->values[0] == NULL) { + /* no value for ldap attribute */ + return ""; + } + if (ldap_value->values[1] != NULL) { + auth_request_log_warning(ctx->auth_request, "ldap", + "Multiple values found for '%s', using value '%s'", + data, ldap_value->values[0]); + } + return ldap_value->values[0]; +} + static const char *const * db_ldap_result_return_value(struct db_ldap_result_iterate_context *ctx, const struct ldap_field *field, struct db_ldap_value *ldap_value) { + static struct var_expand_func_table var_funcs_table[] = { + { "ldap", db_ldap_field_expand }, + { NULL, NULL } + }; const char *const *values; if (ldap_value != NULL) @@ -1196,7 +1226,8 @@ } ctx->var_table[0].value = values[0]; str_truncate(ctx->var, 0); - var_expand(ctx->var, field->value, ctx->var_table); + var_expand_with_funcs(ctx->var, field->value, ctx->var_table, + var_funcs_table, ctx); ctx->val_1_arr[0] = str_c(ctx->var); values = ctx->val_1_arr; } From dovecot at dovecot.org Thu Feb 2 15:45:35 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 15:45:35 +0200 Subject: dovecot-2.1: auth: Get LDAP attribute names automatically from t... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d29d119192c1 changeset: 14056:d29d119192c1 user: Timo Sirainen date: Thu Feb 02 15:45:30 2012 +0200 description: auth: Get LDAP attribute names automatically from template's %{ldap:attr} variables. diffstat: src/auth/db-ldap.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 37 insertions(+), 8 deletions(-) diffs (85 lines): diff -r 56c3a6c1d187 -r d29d119192c1 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Thu Feb 02 15:44:51 2012 +0200 +++ b/src/auth/db-ldap.c Thu Feb 02 15:45:30 2012 +0200 @@ -977,25 +977,48 @@ } } +struct ldap_field_find_context { + ARRAY_TYPE(string) attr_names; + pool_t pool; +}; + +static const char * +db_ldap_field_find(const char *data, void *context) +{ + struct ldap_field_find_context *ctx = context; + char *ldap_attr; + + if (*data != '\0') { + ldap_attr = p_strdup(ctx->pool, data); + array_append(&ctx->attr_names, &ldap_attr, 1); + } + return NULL; +} + void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist, char ***attr_names_r, ARRAY_TYPE(ldap_field) *attr_map, const char *skip_attr) { + static struct var_expand_func_table var_funcs_table[] = { + { "ldap", db_ldap_field_find }, + { NULL, NULL } + }; + struct ldap_field_find_context ctx; struct ldap_field *field; + string_t *tmp_str; const char *const *attr, *attr_data, *p; char *ldap_attr, *name, *templ; - unsigned int i, j, size; + unsigned int i; if (*attrlist == '\0') return; attr = t_strsplit_spaces(attrlist, ","); - /* @UNSAFE */ - for (size = 0; attr[size] != NULL; size++) ; - *attr_names_r = p_new(conn->pool, char *, size + 1); - - for (i = j = 0; i < size; i++) { + tmp_str = t_str_new(128); + ctx.pool = conn->pool; + p_array_init(&ctx.attr_names, conn->pool, 16); + for (i = 0; attr[i] != NULL; i++) { /* allow spaces here so "foo=1, bar=2" works */ attr_data = attr[i]; while (*attr_data == ' ') attr_data++; @@ -1011,8 +1034,12 @@ templ = strchr(name, '='); if (templ == NULL) templ = ""; - else + else { *templ++ = '\0'; + str_truncate(tmp_str, 0); + var_expand_with_funcs(tmp_str, templ, NULL, + var_funcs_table, &ctx); + } if (*name == '\0') i_error("ldap: Invalid attrs entry: %s", attr_data); @@ -1022,9 +1049,11 @@ field->value = templ; field->ldap_attr_name = ldap_attr; if (*ldap_attr != '\0') - (*attr_names_r)[j++] = ldap_attr; + array_append(&ctx.attr_names, &ldap_attr, 1); } } + (void)array_append_space(&ctx.attr_names); + *attr_names_r = array_idx_modifiable(&ctx.attr_names, 0); } static struct var_expand_table * From dovecot at dovecot.org Thu Feb 2 15:45:35 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 15:45:35 +0200 Subject: dovecot-2.1: var_expand*(): Allow table to be NULL (when using o... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/56c3a6c1d187 changeset: 14055:56c3a6c1d187 user: Timo Sirainen date: Thu Feb 02 15:44:51 2012 +0200 description: var_expand*(): Allow table to be NULL (when using only func_table). diffstat: src/lib/var-expand.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diffs (31 lines): diff -r ab58022f934f -r 56c3a6c1d187 src/lib/var-expand.c --- a/src/lib/var-expand.c Thu Feb 02 15:28:10 2012 +0200 +++ b/src/lib/var-expand.c Thu Feb 02 15:44:51 2012 +0200 @@ -162,11 +162,13 @@ const struct var_expand_table *t; const char *value = NULL; - for (t = table; !TABLE_LAST(t); t++) { - if (t->long_key != NULL && - strncmp(t->long_key, key_start, key_len) == 0 && - t->long_key[key_len] == '\0') { - return t->value != NULL ? t->value : ""; + if (table != NULL) { + for (t = table; !TABLE_LAST(t); t++) { + if (t->long_key != NULL && + strncmp(t->long_key, key_start, key_len) == 0 && + t->long_key[key_len] == '\0') { + return t->value != NULL ? t->value : ""; + } } } @@ -287,7 +289,7 @@ str+1, len, context); if (var != NULL) str = end; - } else { + } else if (table != NULL) { for (t = table; !TABLE_LAST(t); t++) { if (t->key == *str) { var = t->value != NULL ? From dovecot at dovecot.org Thu Feb 2 16:26:43 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 16:26:43 +0200 Subject: dovecot-2.1: lib-storage: One more crashfix for recent maildir_n... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ba48de993c8e changeset: 14057:ba48de993c8e user: Timo Sirainen date: Thu Feb 02 16:26:33 2012 +0200 description: lib-storage: One more crashfix for recent maildir_name/mailbox_dir_name change. diffstat: src/lib-storage/mail-storage.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r d29d119192c1 -r ba48de993c8e src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Feb 02 15:45:30 2012 +0200 +++ b/src/lib-storage/mail-storage.c Thu Feb 02 16:26:33 2012 +0200 @@ -324,6 +324,8 @@ } memset(&list_set, 0, sizeof(list_set)); + list_set.mailbox_dir_name = ""; + list_set.maildir_name = ""; if (data == NULL) { /* autodetect */ } else if (driver != NULL && strcmp(driver, "shared") == 0) { From dovecot at dovecot.org Thu Feb 2 16:47:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 16:47:05 +0200 Subject: dovecot-2.1: doveadm fetch: Added support for hdr.*.utf8 fields. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ceadfe9009aa changeset: 14058:ceadfe9009aa user: Timo Sirainen date: Thu Feb 02 16:46:46 2012 +0200 description: doveadm fetch: Added support for hdr.*.utf8 fields. diffstat: src/doveadm/doveadm-mail-fetch.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diffs (52 lines): diff -r ba48de993c8e -r ceadfe9009aa src/doveadm/doveadm-mail-fetch.c --- a/src/doveadm/doveadm-mail-fetch.c Thu Feb 02 16:26:33 2012 +0200 +++ b/src/doveadm/doveadm-mail-fetch.c Thu Feb 02 16:46:46 2012 +0200 @@ -8,6 +8,7 @@ #include "message-address.h" #include "message-size.h" #include "message-parser.h" +#include "message-header-decode.h" #include "message-decoder.h" #include "imap-util.h" #include "mail-user.h" @@ -133,6 +134,7 @@ { const char *const *value, *filter, *name = ctx->cur_field->name; string_t *str = t_str_new(256); + unsigned int pos; bool add_lf = FALSE; filter = strchr(name, '.'); @@ -151,8 +153,14 @@ if (filter == NULL) { /* print the header as-is */ + } else if (strcmp(filter, "utf8") == 0) { + pos = str_len(str); + message_header_decode_utf8(str_data(str), str_len(str), + str, FALSE); + str_delete(str, 0, pos); } else if (strcmp(filter, "address") == 0 || - strcmp(filter, "address_name") == 0) { + strcmp(filter, "address_name") == 0 || + strcmp(filter, "address_name.utf8") == 0) { struct message_address *addr; addr = message_address_parse(pool_datastack_create(), @@ -170,9 +178,14 @@ str_append_c(str, '@'); str_append(str, addr->domain); } - } else { - if (addr->name != NULL) + } else if (addr->name != NULL) { + if (strcmp(filter, "address_name") == 0) str_append(str, addr->name); + else { + message_header_decode_utf8( + (const void *)addr->name, + strlen(addr->name), str, FALSE); + } } add_lf = TRUE; } From dovecot at dovecot.org Thu Feb 2 16:51:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 16:51:03 +0200 Subject: dovecot-2.1: lib-imap-client: If dns_client_socket_path isn't gi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9d031f0b613d changeset: 14059:9d031f0b613d user: Timo Sirainen date: Thu Feb 02 16:49:46 2012 +0200 description: lib-imap-client: If dns_client_socket_path isn't given, do a blocking lookup. diffstat: src/lib-imap-client/imapc-connection.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diffs (34 lines): diff -r ceadfe9009aa -r 9d031f0b613d src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Thu Feb 02 16:46:46 2012 +0200 +++ b/src/lib-imap-client/imapc-connection.c Thu Feb 02 16:49:46 2012 +0200 @@ -1340,7 +1340,9 @@ void *login_context) { struct dns_lookup_settings dns_set; - struct ip_addr ip; + struct ip_addr ip, *ips; + unsigned int ips_count; + int ret; if (conn->fd != -1) { i_assert(login_callback == NULL); @@ -1366,6 +1368,19 @@ conn->ips_count = 1; conn->ips = i_new(struct ip_addr, conn->ips_count); conn->ips[0] = ip; + } else if (*dns_set.dns_client_socket_path == '\0') { + ret = net_gethostbyname(conn->client->set.host, + &ips, &ips_count); + if (ret != 0) { + i_error("imapc(%s): net_gethostbyname(%s) failed: %s", + conn->name, conn->client->set.host, + net_gethosterror(ret)); + imapc_connection_set_disconnected(conn); + return; + } + conn->ips_count = ips_count; + conn->ips = i_new(struct ip_addr, ips_count); + memcpy(conn->ips, ips, ips_count * sizeof(*ips)); } if (conn->ips_count == 0) { From dovecot at dovecot.org Thu Feb 2 16:51:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 16:51:03 +0200 Subject: dovecot-2.1: imapc: If base_dir isn't set, do a blocking DNS loo... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/47072538ff11 changeset: 14060:47072538ff11 user: Timo Sirainen date: Thu Feb 02 16:50:58 2012 +0200 description: imapc: If base_dir isn't set, do a blocking DNS lookup. This is mostly a workaround for being able to run imapc from standalone programs (e.g. doveadm) without running Dovecot. diffstat: src/lib-storage/index/imapc/imapc-storage.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 9d031f0b613d -r 47072538ff11 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Thu Feb 02 16:49:46 2012 +0200 +++ b/src/lib-storage/index/imapc/imapc-storage.c Thu Feb 02 16:50:58 2012 +0200 @@ -229,6 +229,7 @@ return -1; } set.dns_client_socket_path = + *_storage->user->set->base_dir == '\0' ? "" : t_strconcat(_storage->user->set->base_dir, "/", DNS_CLIENT_SOCKET_NAME, NULL); set.debug = _storage->set->mail_debug; From dovecot at dovecot.org Thu Feb 2 17:19:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 17:19:32 +0200 Subject: dovecot-2.1: pop3c: Last message wasn't visible. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a5aac072bf38 changeset: 14061:a5aac072bf38 user: Timo Sirainen date: Thu Feb 02 17:19:22 2012 +0200 description: pop3c: Last message wasn't visible. diffstat: src/lib-storage/index/pop3c/pop3c-client.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 47072538ff11 -r a5aac072bf38 src/lib-storage/index/pop3c/pop3c-client.c --- a/src/lib-storage/index/pop3c/pop3c-client.c Thu Feb 02 16:50:58 2012 +0200 +++ b/src/lib-storage/index/pop3c/pop3c-client.c Thu Feb 02 17:19:22 2012 +0200 @@ -752,7 +752,7 @@ if (pop3c_client_cmd_line(client, cmd, error_r) < 0) return -1; /* read the stream */ - inputs[0] = i_stream_create_dot(client->input, FALSE); + inputs[0] = i_stream_create_dot(client->input, TRUE); inputs[1] = NULL; client->dot_input = i_stream_create_seekable(inputs, POP3C_MAX_INBUF_SIZE, From dovecot at dovecot.org Thu Feb 2 17:20:08 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 17:20:08 +0200 Subject: dovecot-2.1: istream-seekable: If we panic about stream not bein... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f31a227ae381 changeset: 14062:f31a227ae381 user: Timo Sirainen date: Thu Feb 02 17:20:02 2012 +0200 description: istream-seekable: If we panic about stream not being seekable, log the stream name/offset. diffstat: src/lib/istream-seekable.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (14 lines): diff -r a5aac072bf38 -r f31a227ae381 src/lib/istream-seekable.c --- a/src/lib/istream-seekable.c Thu Feb 02 17:19:22 2012 +0200 +++ b/src/lib/istream-seekable.c Thu Feb 02 17:20:02 2012 +0200 @@ -321,7 +321,9 @@ if (ret == 0) { i_panic("i_stream_stat() used for non-blocking " - "seekable stream"); + "seekable stream %s offset %"PRIuUOFF_T, + i_stream_get_name(sstream->cur_input), + sstream->cur_input->v_offset); } i_stream_skip(&stream->istream, stream->pos - stream->skip); i_stream_seek(&stream->istream, old_offset); From dovecot at dovecot.org Thu Feb 2 23:22:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 02 Feb 2012 23:22:25 +0200 Subject: dovecot-2.1: pop3c: Fixes to handling filter streams for mail. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fa7e1246e0e2 changeset: 14063:fa7e1246e0e2 user: Timo Sirainen date: Thu Feb 02 23:22:06 2012 +0200 description: pop3c: Fixes to handling filter streams for mail. diffstat: src/lib-storage/index/pop3c/pop3c-client.c | 3 +++ src/lib-storage/index/pop3c/pop3c-mail.c | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diffs (32 lines): diff -r f31a227ae381 -r fa7e1246e0e2 src/lib-storage/index/pop3c/pop3c-client.c --- a/src/lib-storage/index/pop3c/pop3c-client.c Thu Feb 02 17:20:02 2012 +0200 +++ b/src/lib-storage/index/pop3c/pop3c-client.c Thu Feb 02 23:22:06 2012 +0200 @@ -774,6 +774,9 @@ } io_remove(&client->io); i_stream_seek(client->dot_input, 0); + /* if this stream is used by some filter stream, make the filter + stream blocking */ + client->dot_input->blocking = TRUE; *input_r = client->dot_input; client->dot_input = NULL; diff -r f31a227ae381 -r fa7e1246e0e2 src/lib-storage/index/pop3c/pop3c-mail.c --- a/src/lib-storage/index/pop3c/pop3c-mail.c Thu Feb 02 17:20:02 2012 +0200 +++ b/src/lib-storage/index/pop3c/pop3c-mail.c Thu Feb 02 23:22:06 2012 +0200 @@ -121,7 +121,6 @@ MAIL_ERROR_TEMP : MAIL_ERROR_EXPUNGED, error); return -1; } - i_stream_set_name(input, t_strcut(cmd, '\r')); mail->data.stream = input; if (mail->mail.v.istream_opened != NULL) { if (mail->mail.v.istream_opened(_mail, @@ -130,6 +129,7 @@ return -1; } } + i_stream_set_name(mail->data.stream, t_strcut(cmd, '\r')); pop3c_mail_cache_size(mail); } return index_mail_init_stream(mail, hdr_size, body_size, stream_r); From pigeonhole at rename-it.nl Sat Feb 4 00:51:58 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Fri, 03 Feb 2012 23:51:58 +0100 Subject: dovecot-2.0-pigeonhole: managesieve-login: matched auth_verbose ... Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/58fc2f01c432 changeset: 1554:58fc2f01c432 user: Stephan Bosch date: Fri Feb 03 23:51:53 2012 +0100 description: managesieve-login: matched auth_verbose changes in Dovecot. diffstat: src/managesieve-login/managesieve-proxy.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diffs (21 lines): diff -r 8715c044a7ee -r 58fc2f01c432 src/managesieve-login/managesieve-proxy.c --- a/src/managesieve-login/managesieve-proxy.c Sat Jan 07 16:29:23 2012 +0100 +++ b/src/managesieve-login/managesieve-proxy.c Fri Feb 03 23:51:53 2012 +0100 @@ -325,13 +325,13 @@ (void)client_skip_line(msieve_client); client_proxy_finish_destroy_client(client); - + return 1; - } - + } + /* Login failed */ - if ( client->set->verbose_auth ) { + if ( client->set->auth_verbose ) { const char *log_line = line; if (strncasecmp(log_line, "NO ", 3) == 0) From dovecot at dovecot.org Mon Feb 6 19:30:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 19:30:24 +0200 Subject: dovecot-2.1: liblib: Added failure_log_type_names[] array. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0d224f2c3152 changeset: 14064:0d224f2c3152 user: Timo Sirainen date: Mon Feb 06 19:28:40 2012 +0200 description: liblib: Added failure_log_type_names[] array. diffstat: src/lib/failures.c | 4 ++++ src/lib/failures.h | 1 + 2 files changed, 5 insertions(+), 0 deletions(-) diffs (25 lines): diff -r fa7e1246e0e2 -r 0d224f2c3152 src/lib/failures.c --- a/src/lib/failures.c Thu Feb 02 23:22:06 2012 +0200 +++ b/src/lib/failures.c Mon Feb 06 19:28:40 2012 +0200 @@ -26,6 +26,10 @@ "Panic: " }; +const char *failure_log_type_names[LOG_TYPE_COUNT] = { + "debug", "info", "warning", "error", "fatal", "panic" +}; + /* Initialize working defaults */ static failure_callback_t *fatal_handler ATTR_NORETURN = default_fatal_handler; diff -r fa7e1246e0e2 -r 0d224f2c3152 src/lib/failures.h --- a/src/lib/failures.h Thu Feb 02 23:22:06 2012 +0200 +++ b/src/lib/failures.h Mon Feb 06 19:28:40 2012 +0200 @@ -44,6 +44,7 @@ const char *format, va_list args); extern const char *failure_log_type_prefixes[]; +extern const char *failure_log_type_names[]; void i_log_type(const struct failure_context *ctx, const char *format, ...) ATTR_FORMAT(2, 3); From dovecot at dovecot.org Mon Feb 6 19:30:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 19:30:24 +0200 Subject: dovecot-2.1: log: Keep track of last 1000 errors/warnings. "dove... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/66f875b5102b changeset: 14065:66f875b5102b user: Timo Sirainen date: Mon Feb 06 19:30:12 2012 +0200 description: log: Keep track of last 1000 errors/warnings. "doveadm log errors" shows them. diffstat: src/doveadm/doveadm-log.c | 57 +++++++++++++++++++++++++++++++++++++++++++- src/log/Makefile.am | 6 +++- src/log/log-connection.c | 60 ++++++++++++++++++++++++++++++++++++---------- src/log/log-connection.h | 3 +- src/log/log-settings.c | 19 +++++++++++++- src/log/main.c | 16 +++++++++++- 6 files changed, 140 insertions(+), 21 deletions(-) diffs (truncated from 352 to 300 lines): diff -r 0d224f2c3152 -r 66f875b5102b src/doveadm/doveadm-log.c --- a/src/doveadm/doveadm-log.c Mon Feb 06 19:28:40 2012 +0200 +++ b/src/doveadm/doveadm-log.c Mon Feb 06 19:30:12 2012 +0200 @@ -2,9 +2,11 @@ #include "lib.h" #include "ioloop.h" +#include "istream.h" #include "hash.h" #include "str.h" -#include "istream.h" +#include "strescape.h" +#include "time-util.h" #include "master-service-private.h" #include "master-service-settings.h" #include "doveadm.h" @@ -18,6 +20,8 @@ #define LAST_LOG_TYPE LOG_TYPE_PANIC #define TEST_LOG_MSG_PREFIX "This is Dovecot's " +#define LOG_ERRORS_FNAME "log-errors" +#define LOG_TIMESTAMP_FORMAT "%b %d %H:%M:%S" static void cmd_log_test(int argc ATTR_UNUSED, char *argv[] ATTR_UNUSED) { @@ -274,10 +278,59 @@ } } +static void cmd_log_error_write(const char *const *args) +{ + /* */ + const char *type_prefix = "?"; + unsigned int type; + time_t t; + + /* find type's prefix */ + for (type = 0; type < LOG_TYPE_COUNT; type++) { + if (strcmp(args[0], failure_log_type_names[type]) == 0) { + type_prefix = failure_log_type_prefixes[type]; + break; + } + } + + if (str_to_time(args[1], &t) < 0) { + i_error("Invalid timestamp: %s", args[1]); + t = 0; + } + + printf("%s %s%s%s\n", t_strflocaltime(LOG_TIMESTAMP_FORMAT, t), + args[2], type_prefix, args[3]); +} + +static void cmd_log_errors(int argc ATTR_UNUSED, char *argv[] ATTR_UNUSED) +{ + struct istream *input; + const char *path, *line, *const *args; + int fd; + + path = t_strconcat(doveadm_settings->base_dir, + "/"LOG_ERRORS_FNAME, NULL); + fd = net_connect_unix(path); + if (fd == -1) + i_fatal("net_connect_unix(%s) failed: %m", path); + net_set_nonblock(fd, FALSE); + + input = i_stream_create_fd(fd, (size_t)-1, TRUE); + while ((line = i_stream_read_next_line(input)) != NULL) T_BEGIN { + args = t_strsplit_tabescaped(line); + if (str_array_length(args) == 4) + cmd_log_error_write(args); + else + i_error("Invalid input from log: %s", line); + } T_END; + i_stream_destroy(&input); +} + struct doveadm_cmd doveadm_cmd_log[] = { { cmd_log_test, "log test", "" }, { cmd_log_reopen, "log reopen", "" }, - { cmd_log_find, "log find", "[]" } + { cmd_log_find, "log find", "[]" }, + { cmd_log_errors, "log errors", "" } }; void doveadm_register_log_commands(void) diff -r 0d224f2c3152 -r 66f875b5102b src/log/Makefile.am --- a/src/log/Makefile.am Mon Feb 06 19:28:40 2012 +0200 +++ b/src/log/Makefile.am Mon Feb 06 19:30:12 2012 +0200 @@ -11,9 +11,13 @@ log_DEPENDENCIES = $(LIBDOVECOT_DEPS) log_SOURCES = \ + doveadm-connection.c \ log-connection.c \ + log-error-buffer.c \ log-settings.c \ main.c noinst_HEADERS = \ - log-connection.h + doveadm-connection.h \ + log-connection.h \ + log-error-buffer.h diff -r 0d224f2c3152 -r 66f875b5102b src/log/log-connection.c --- a/src/log/log-connection.c Mon Feb 06 19:28:40 2012 +0200 +++ b/src/log/log-connection.c Mon Feb 06 19:30:12 2012 +0200 @@ -8,6 +8,7 @@ #include "hash.h" #include "master-interface.h" #include "master-service.h" +#include "log-error-buffer.h" #include "log-connection.h" #include @@ -25,6 +26,7 @@ struct log_connection { struct log_connection *prev, *next; + struct log_error_buffer *errorbuf; int fd; int listen_fd; struct io *io; @@ -77,8 +79,38 @@ } static void +client_log_ctx(struct log_connection *log, + const struct failure_context *ctx, time_t log_time, + const char *prefix, const char *text) +{ + struct log_error err; + + switch (ctx->type) { + case LOG_TYPE_DEBUG: + case LOG_TYPE_INFO: + case LOG_TYPE_COUNT: + case LOG_TYPE_OPTION: + break; + case LOG_TYPE_WARNING: + case LOG_TYPE_ERROR: + case LOG_TYPE_FATAL: + case LOG_TYPE_PANIC: + memset(&err, 0, sizeof(err)); + err.type = ctx->type; + err.timestamp = log_time; + err.prefix = prefix; + err.text = text; + log_error_buffer_add(log->errorbuf, &err); + break; + } + i_set_failure_prefix(prefix); + i_log_type(ctx, "%s", text); + i_set_failure_prefix("log: "); +} + +static void client_log_fatal(struct log_connection *log, struct log_client *client, - const char *line, const struct tm *tm) + const char *line, time_t log_time, const struct tm *tm) { struct failure_context failure_ctx; const char *prefix = log->default_prefix; @@ -95,13 +127,12 @@ line, net_ip2addr(&client->ip)); } } - i_set_failure_prefix(prefix); - i_log_type(&failure_ctx, "master: %s", line); - i_set_failure_prefix("log: "); + client_log_ctx(log, &failure_ctx, log_time, prefix, + t_strconcat("master: ", line, NULL)); } static void -log_parse_master_line(const char *line, const struct tm *tm) +log_parse_master_line(const char *line, time_t log_time, const struct tm *tm) { struct log_connection *const *logs, *log; struct log_client *client; @@ -136,19 +167,20 @@ } log_client_free(log, client, pid); } else if (strncmp(line, "FATAL ", 6) == 0) { - client_log_fatal(log, client, line + 6, tm); + client_log_fatal(log, client, line + 6, log_time, tm); } else if (strncmp(line, "DEFAULT-FATAL ", 14) == 0) { /* If the client has logged a fatal/panic, don't log this message. */ if (client == NULL || !client->fatal_logged) - client_log_fatal(log, client, line + 14, tm); + client_log_fatal(log, client, line + 14, log_time, tm); } else { i_error("Received unknown command from master: %s", line); } } static void -log_it(struct log_connection *log, const char *line, const struct tm *tm) +log_it(struct log_connection *log, const char *line, + time_t log_time, const struct tm *tm) { struct failure_line failure; struct failure_context failure_ctx; @@ -157,7 +189,7 @@ if (log->master) { T_BEGIN { - log_parse_master_line(line, tm); + log_parse_master_line(line, log_time, tm); } T_END; return; } @@ -185,9 +217,7 @@ prefix = client != NULL && client->prefix != NULL ? client->prefix : log->default_prefix; - i_set_failure_prefix(prefix); - i_log_type(&failure_ctx, "%s", failure.text); - i_set_failure_prefix("log: "); + client_log_ctx(log, &failure_ctx, log_time, prefix, failure.text); } static int log_connection_handshake(struct log_connection *log) @@ -256,7 +286,7 @@ tm = *localtime(&now); while ((line = i_stream_next_line(log->input)) != NULL) - log_it(log, line, &tm); + log_it(log, line, now, &tm); } if (log->input->eof) @@ -269,11 +299,13 @@ } } -struct log_connection *log_connection_create(int fd, int listen_fd) +struct log_connection * +log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd) { struct log_connection *log; log = i_new(struct log_connection, 1); + log->errorbuf = errorbuf; log->fd = fd; log->listen_fd = listen_fd; log->io = io_add(fd, IO_READ, log_connection_input, log); diff -r 0d224f2c3152 -r 66f875b5102b src/log/log-connection.h --- a/src/log/log-connection.h Mon Feb 06 19:28:40 2012 +0200 +++ b/src/log/log-connection.h Mon Feb 06 19:30:12 2012 +0200 @@ -1,7 +1,8 @@ #ifndef LOG_CONNECTION_H #define LOG_CONNECTION_H -struct log_connection *log_connection_create(int fd, int listen_fd); +struct log_connection * +log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd); void log_connection_destroy(struct log_connection *log); void log_connections_init(void); diff -r 0d224f2c3152 -r 66f875b5102b src/log/log-settings.c --- a/src/log/log-settings.c Mon Feb 06 19:28:40 2012 +0200 +++ b/src/log/log-settings.c Mon Feb 06 19:30:12 2012 +0200 @@ -1,11 +1,25 @@ /* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "buffer.h" #include "settings-parser.h" #include "service-settings.h" #include +/* */ +static struct file_listener_settings log_unix_listeners_array[] = { + { "log-errors", 0600, "", "" } +}; +static struct file_listener_settings *log_unix_listeners[] = { + &log_unix_listeners_array[0] +}; +static buffer_t log_unix_listeners_buf = { + log_unix_listeners, + sizeof(log_unix_listeners), { 0, } +}; +/* */ + struct service_settings log_service_settings = { .name = "log", .protocol = "", @@ -23,10 +37,11 @@ .process_limit = 1, .client_limit = 0, .service_count = 0, - .idle_kill = 0, + .idle_kill = -1U, .vsz_limit = (uoff_t)-1, - .unix_listeners = ARRAY_INIT, + .unix_listeners = { { &log_unix_listeners_buf, From dovecot at dovecot.org Mon Feb 6 19:34:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 19:34:30 +0200 Subject: dovecot-2.1: rawlog: Renamed -i / -o parameters to "-f in", "-f ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/664778adec21 changeset: 14066:664778adec21 user: Timo Sirainen date: Mon Feb 06 19:34:18 2012 +0200 description: rawlog: Renamed -i / -o parameters to "-f in", "-f out" This is mainly to get give the -i parameter to lib-master. diffstat: src/util/rawlog.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diffs (35 lines): diff -r 66f875b5102b -r 664778adec21 src/util/rawlog.c --- a/src/util/rawlog.c Mon Feb 06 19:30:12 2012 +0200 +++ b/src/util/rawlog.c Mon Feb 06 19:34:18 2012 +0200 @@ -362,14 +362,16 @@ int c; master_service = master_service_init("rawlog", 0, - &argc, &argv, "+iobt"); + &argc, &argv, "+f:obt"); while ((c = master_getopt(master_service)) > 0) { switch (c) { - case 'i': - flags &= ~RAWLOG_FLAG_LOG_OUTPUT; - break; - case 'o': - flags &= ~RAWLOG_FLAG_LOG_INPUT; + case 'f': + if (strcmp(optarg, "in") == 0) + flags &= ~RAWLOG_FLAG_LOG_OUTPUT; + else if (strcmp(optarg, "out") == 0) + flags &= ~RAWLOG_FLAG_LOG_INPUT; + else + i_fatal("Invalid filter: %s", optarg); break; case 'b': flags |= RAWLOG_FLAG_LOG_BOUNDARIES; @@ -385,7 +387,7 @@ argv += optind; if (argc < 1) - i_fatal("Usage: rawlog [-i | -o] [-b] [-t] "); + i_fatal("Usage: rawlog [-f in|out] [-b] [-t] "); master_service_init_log(master_service, "rawlog: "); master_service_init_finish(master_service); From dovecot at dovecot.org Mon Feb 6 21:27:08 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 21:27:08 +0200 Subject: dovecot-2.1: Keep track of what Dovecot instances have been exec... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5f60958926e1 changeset: 14068:5f60958926e1 user: Timo Sirainen date: Mon Feb 06 21:26:55 2012 +0200 description: Keep track of what Dovecot instances have been executed and their instance_name. doveadm instance command can be used to list/remove them. diffstat: src/doveadm/Makefile.am | 1 + src/doveadm/doveadm-instance.c | 110 ++++++++++++ src/doveadm/doveadm.c | 1 + src/doveadm/doveadm.h | 1 + src/lib-master/Makefile.am | 2 + src/lib-master/master-instance.c | 331 +++++++++++++++++++++++++++++++++++++++ src/lib-master/master-instance.h | 43 +++++ src/master/main.c | 31 +++ 8 files changed, 520 insertions(+), 0 deletions(-) diffs (truncated from 617 to 300 lines): diff -r 6cd1b564fcc2 -r 5f60958926e1 src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Mon Feb 06 21:25:37 2012 +0200 +++ b/src/doveadm/Makefile.am Mon Feb 06 21:26:55 2012 +0200 @@ -91,6 +91,7 @@ doveadm-dump-log.c \ doveadm-dump-mailboxlog.c \ doveadm-dump-thread.c \ + doveadm-instance.c \ doveadm-kick.c \ doveadm-log.c \ doveadm-master.c \ diff -r 6cd1b564fcc2 -r 5f60958926e1 src/doveadm/doveadm-instance.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/doveadm/doveadm-instance.c Mon Feb 06 21:26:55 2012 +0200 @@ -0,0 +1,110 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "master-instance.h" +#include "doveadm.h" +#include "doveadm-print.h" + +#include +#include +#include + +extern struct doveadm_cmd doveadm_cmd_instance[]; + +static void instance_cmd_help(doveadm_command_t *cmd) ATTR_NORETURN; + +static bool pid_file_read(const char *path) +{ + char buf[32]; + int fd; + ssize_t ret; + pid_t pid; + bool found = FALSE; + + fd = open(path, O_RDONLY); + if (fd == -1) { + if (errno != ENOENT) + i_error("open(%s) failed: %m", path); + return FALSE; + } + + ret = read(fd, buf, sizeof(buf)); + if (ret < 0) + i_error("read(%s) failed: %m", path); + else if (ret > 0 && buf[ret-1] == '\n') { + buf[ret-1] = '\0'; + if (str_to_pid(buf, &pid) == 0) { + found = !(pid == getpid() || + (kill(pid, 0) < 0 && errno == ESRCH)); + } + } + (void)close(fd); + return found; +} + +static void cmd_instance_list(int argc ATTR_UNUSED, char *argv[] ATTR_UNUSED) +{ + struct master_instance_list *list; + struct master_instance_list_iter *iter; + const struct master_instance *inst; + const char *pidfile_path; + + doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE); + doveadm_print_header("path", "path", DOVEADM_PRINT_HEADER_FLAG_EXPAND); + doveadm_print_header_simple("name"); + doveadm_print_header_simple("running"); + + list = master_instance_list_init(MASTER_INSTANCE_PATH); + iter = master_instance_list_iterate_init(list); + while ((inst = master_instance_iterate_list_next(iter)) != NULL) { + doveadm_print(inst->base_dir); + doveadm_print(inst->name); + pidfile_path = t_strconcat(inst->base_dir, "/master.pid", NULL); + if (pid_file_read(pidfile_path)) + doveadm_print("yes"); + else + doveadm_print("no"); + } + master_instance_iterate_list_deinit(&iter); + master_instance_list_deinit(&list); +} + +static void cmd_instance_remove(int argc, char *argv[]) +{ + struct master_instance_list *list; + int ret; + + if (argc != 2) + instance_cmd_help(cmd_instance_remove); + + list = master_instance_list_init(MASTER_INSTANCE_PATH); + if ((ret = master_instance_list_remove(list, argv[1])) < 0) + i_error("Failed to remove instance"); + else if (ret == 0) + i_error("Instance already didn't exist"); + master_instance_list_deinit(&list); +} + +struct doveadm_cmd doveadm_cmd_instance[] = { + { cmd_instance_list, "instance list", "" }, + { cmd_instance_remove, "instance remove", "" } +}; + +static void instance_cmd_help(doveadm_command_t *cmd) +{ + unsigned int i; + + for (i = 0; i < N_ELEMENTS(doveadm_cmd_instance); i++) { + if (doveadm_cmd_instance[i].cmd == cmd) + help(&doveadm_cmd_instance[i]); + } + i_unreached(); +} + +void doveadm_register_instance_commands(void) +{ + unsigned int i; + + for (i = 0; i < N_ELEMENTS(doveadm_cmd_instance); i++) + doveadm_register_cmd(&doveadm_cmd_instance[i]); +} diff -r 6cd1b564fcc2 -r 5f60958926e1 src/doveadm/doveadm.c --- a/src/doveadm/doveadm.c Mon Feb 06 21:25:37 2012 +0200 +++ b/src/doveadm/doveadm.c Mon Feb 06 21:26:55 2012 +0200 @@ -321,6 +321,7 @@ } else { quick_init = FALSE; doveadm_register_director_commands(); + doveadm_register_instance_commands(); doveadm_register_mount_commands(); doveadm_register_proxy_commands(); doveadm_register_log_commands(); diff -r 6cd1b564fcc2 -r 5f60958926e1 src/doveadm/doveadm.h --- a/src/doveadm/doveadm.h Mon Feb 06 21:25:37 2012 +0200 +++ b/src/doveadm/doveadm.h Mon Feb 06 21:26:55 2012 +0200 @@ -38,6 +38,7 @@ void doveadm_register_director_commands(void); void doveadm_register_proxy_commands(void); void doveadm_register_log_commands(void); +void doveadm_register_instance_commands(void); void doveadm_register_mount_commands(void); #endif diff -r 6cd1b564fcc2 -r 5f60958926e1 src/lib-master/Makefile.am --- a/src/lib-master/Makefile.am Mon Feb 06 21:25:37 2012 +0200 +++ b/src/lib-master/Makefile.am Mon Feb 06 21:26:55 2012 +0200 @@ -14,6 +14,7 @@ ipc-client.c \ ipc-server.c \ master-auth.c \ + master-instance.c \ master-login.c \ master-login-auth.c \ master-service.c \ @@ -27,6 +28,7 @@ ipc-client.h \ ipc-server.h \ master-auth.h \ + master-instance.h \ master-interface.h \ master-login.h \ master-login-auth.h \ diff -r 6cd1b564fcc2 -r 5f60958926e1 src/lib-master/master-instance.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-master/master-instance.c Mon Feb 06 21:26:55 2012 +0200 @@ -0,0 +1,331 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "istream.h" +#include "ostream.h" +#include "file-dotlock.h" +#include "str.h" +#include "strescape.h" +#include "master-instance.h" + +#include +#include + +struct master_instance_list { + pool_t pool; + const char *path; + + ARRAY_DEFINE(instances, struct master_instance); +}; + +struct master_instance_list_iter { + struct master_instance_list *list; + unsigned int idx; +}; + +static const struct dotlock_settings dotlock_set = { + .timeout = 1, + .stale_timeout = 60 +}; + +struct master_instance_list *master_instance_list_init(const char *path) +{ + struct master_instance_list *list; + pool_t pool; + + pool = pool_alloconly_create("master instances", 256); + list = p_new(pool, struct master_instance_list, 1); + list->pool = pool; + list->path = p_strdup(pool, path); + p_array_init(&list->instances, pool, 8); + return list; +} + +void master_instance_list_deinit(struct master_instance_list **_list) +{ + struct master_instance_list *list = *_list; + + *_list = NULL; + pool_unref(&list->pool); +} + +static void master_instance_list_drop_stale(struct master_instance_list *list) +{ + const struct master_instance *instances; + unsigned int i, count; + time_t stale_timestamp = time(NULL) - MASTER_INSTANCE_AUTO_STALE_SECS; + + instances = array_get(&list->instances, &count); + for (i = 0; i < count; ) { + if (instances[i].name[0] == '\0' && + instances[i].last_used < stale_timestamp) { + array_delete(&list->instances, i, 1); + instances = array_get(&list->instances, &count); + } else { + i++; + } + } +} + +static int +master_instance_list_add_line(struct master_instance_list *list, + const char *line) +{ + struct master_instance *inst; + const char *const *args; + time_t last_used; + + /* */ + args = t_strsplit_tabescaped(line); + if (str_array_length(args) != 3) + return -1; + if (str_to_time(args[0], &last_used) < 0) + return -1; + + inst = array_append_space(&list->instances); + inst->last_used = last_used; + inst->name = p_strdup(list->pool, args[1]); + inst->base_dir = p_strdup(list->pool, args[2]); + return 0; +} + +static int master_instance_list_refresh(struct master_instance_list *list) +{ + struct istream *input; + const char *line; + int fd, ret = 0; + + array_clear(&list->instances); + + fd = open(list->path, O_RDONLY); + if (fd == -1) { + if (errno == ENOENT) + return 0; + + i_error("open(%s) failed: %m", list->path); + return -1; + } + input = i_stream_create_fd(fd, PATH_MAX, TRUE); + while ((line = i_stream_read_next_line(input)) != NULL) T_BEGIN { + if (master_instance_list_add_line(list, line) < 0) + i_error("Invalid line in %s: %s", list->path, line); + } T_END; + if (input->stream_errno != 0) { + i_error("read(%s) failed: %m", line); + ret = -1; + } + i_stream_destroy(&input); + return ret; +} + +static int +master_instance_list_write(struct master_instance_list *list, + int fd, const char *path) +{ + struct ostream *output; + const struct master_instance *inst; + string_t *str = t_str_new(128); + + output = o_stream_create_fd(fd, 0, FALSE); From dovecot at dovecot.org Mon Feb 6 21:27:08 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 21:27:08 +0200 Subject: dovecot-2.1: log: Forgot to add new files to recent commit. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6cd1b564fcc2 changeset: 14067:6cd1b564fcc2 user: Timo Sirainen date: Mon Feb 06 21:25:37 2012 +0200 description: log: Forgot to add new files to recent commit. diffstat: src/log/doveadm-connection.c | 88 +++++++++++++++++++++++++++++++ src/log/doveadm-connection.h | 6 ++ src/log/log-error-buffer.c | 121 +++++++++++++++++++++++++++++++++++++++++++ src/log/log-error-buffer.h | 24 ++++++++ 4 files changed, 239 insertions(+), 0 deletions(-) diffs (255 lines): diff -r 664778adec21 -r 6cd1b564fcc2 src/log/doveadm-connection.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/log/doveadm-connection.c Mon Feb 06 21:25:37 2012 +0200 @@ -0,0 +1,88 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "ostream.h" +#include "str.h" +#include "strescape.h" +#include "master-service.h" +#include "log-error-buffer.h" +#include "doveadm-connection.h" + +#include + +struct doveadm_connection { + struct log_error_buffer *errorbuf; + + int fd; + struct ostream *output; +}; + +static void doveadm_connection_destroy(struct doveadm_connection **_conn); + +static int doveadm_connection_send_errors(struct doveadm_connection *conn) +{ + struct log_error_buffer_iter *iter; + const struct log_error *error; + string_t *str = t_str_new(256); + int ret = 0; + + iter = log_error_buffer_iter_init(conn->errorbuf); + while ((error = log_error_buffer_iter_next(iter)) != NULL) { + str_truncate(str, 0); + str_printfa(str, "%s\t%ld\t", + failure_log_type_names[error->type], + (long)error->timestamp); + str_tabescape_write(str, error->prefix); + str_append_c(str, '\t'); + str_tabescape_write(str, error->text); + str_append_c(str, '\n'); + if (o_stream_send(conn->output, + str_data(str), str_len(str)) < 0) { + ret = -1; + break; + } + } + log_error_buffer_iter_deinit(&iter); + return ret; +} + +static int doveadm_output(struct doveadm_connection *conn) +{ + int ret; + + if ((ret = o_stream_flush(conn->output)) != 0) { + /* error / finished */ + doveadm_connection_destroy(&conn); + } + return 1; +} + +void doveadm_connection_create(struct log_error_buffer *errorbuf, int fd) +{ + struct doveadm_connection *conn; + + conn = i_new(struct doveadm_connection, 1); + conn->errorbuf = errorbuf; + conn->fd = fd; + conn->output = o_stream_create_fd(conn->fd, (size_t)-1, FALSE); + if (doveadm_connection_send_errors(conn) < 0) + doveadm_connection_destroy(&conn); + else { + o_stream_set_flush_callback(conn->output, doveadm_output, conn); + o_stream_set_flush_pending(conn->output, TRUE); + } +} + +static void doveadm_connection_destroy(struct doveadm_connection **_conn) +{ + struct doveadm_connection *conn = *_conn; + + *_conn = NULL; + + o_stream_destroy(&conn->output); + if (close(conn->fd) < 0) + i_error("close(doveadm connection) failed: %m"); + i_free(conn); + + master_service_client_connection_destroyed(master_service); +} diff -r 664778adec21 -r 6cd1b564fcc2 src/log/doveadm-connection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/log/doveadm-connection.h Mon Feb 06 21:25:37 2012 +0200 @@ -0,0 +1,6 @@ +#ifndef DOVEADM_CONNECTION_H +#define DOVEADM_CONNECTION_H + +void doveadm_connection_create(struct log_error_buffer *errorbuf, int fd); + +#endif diff -r 664778adec21 -r 6cd1b564fcc2 src/log/log-error-buffer.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/log/log-error-buffer.c Mon Feb 06 21:25:37 2012 +0200 @@ -0,0 +1,121 @@ +/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "log-error-buffer.h" + +#define LOG_ERROR_BUFFER_MAX_LINES 1000 + +struct log_error_data { + struct log_error_data *next; + + enum log_type type; + time_t timestamp; + unsigned char prefix_text[]; +}; + +struct log_error_buffer { + struct log_error_data *head, *tail; + unsigned int count; +}; + +struct log_error_buffer_iter { + struct log_error_buffer *buf; + struct log_error_data *cur; + struct log_error error; +}; + +struct log_error_buffer *log_error_buffer_init(void) +{ + struct log_error_buffer *buf; + + buf = i_new(struct log_error_buffer, 1); + return buf; +} + +static void log_error_buffer_delete_head(struct log_error_buffer *buf) +{ + struct log_error_data *data; + + i_assert(buf->head != NULL); + + buf->count--; + data = buf->head; + buf->head = data->next; + if (buf->tail == data) { + /* last one */ + buf->tail = NULL; + } + i_free(data); +} + +void log_error_buffer_add(struct log_error_buffer *buf, + const struct log_error *error) +{ + unsigned int prefix_size = strlen(error->prefix)+1; + unsigned int text_size = strlen(error->text)+1; + struct log_error_data *data; + + if (buf->count == LOG_ERROR_BUFFER_MAX_LINES) + log_error_buffer_delete_head(buf); + + /* @UNSAFE */ + data = i_malloc(sizeof(*data) + prefix_size + text_size); + data->type = error->type; + data->timestamp = error->timestamp; + memcpy(data->prefix_text, error->prefix, prefix_size); + memcpy(data->prefix_text + prefix_size, error->text, text_size); + + if (buf->tail != NULL) + buf->tail->next = data; + else + buf->head = data; + buf->tail = data; + buf->count++; +} + +void log_error_buffer_deinit(struct log_error_buffer **_buf) +{ + struct log_error_buffer *buf = *_buf; + + *_buf = NULL; + while (buf->count > 0) + log_error_buffer_delete_head(buf); + i_free(buf); +} + +struct log_error_buffer_iter * +log_error_buffer_iter_init(struct log_error_buffer *buf) +{ + struct log_error_buffer_iter *iter; + + iter = i_new(struct log_error_buffer_iter, 1); + iter->buf = buf; + iter->cur = buf->head; + return iter; +} + +struct log_error * +log_error_buffer_iter_next(struct log_error_buffer_iter *iter) +{ + struct log_error_data *data = iter->cur; + + if (data == NULL) + return NULL; + iter->cur = iter->cur->next; + + iter->error.type = data->type; + iter->error.timestamp = data->timestamp; + iter->error.prefix = (const void *)data->prefix_text; + iter->error.text = (const void *)(data->prefix_text + + strlen(iter->error.prefix) + 1); + return &iter->error; +} + +void log_error_buffer_iter_deinit(struct log_error_buffer_iter **_iter) +{ + struct log_error_buffer_iter *iter = *_iter; + + *_iter = NULL; + + i_free(iter); +} diff -r 664778adec21 -r 6cd1b564fcc2 src/log/log-error-buffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/log/log-error-buffer.h Mon Feb 06 21:25:37 2012 +0200 @@ -0,0 +1,24 @@ +#ifndef LOG_ERROR_BUFFER_H +#define LOG_ERROR_BUFFER_H + +struct log_error_buffer; + +struct log_error { + enum log_type type; + time_t timestamp; + const char *prefix; + const char *text; +}; + +struct log_error_buffer *log_error_buffer_init(void); +void log_error_buffer_add(struct log_error_buffer *buf, + const struct log_error *error); +void log_error_buffer_deinit(struct log_error_buffer **buf); + +struct log_error_buffer_iter * +log_error_buffer_iter_init(struct log_error_buffer *buf); +struct log_error * +log_error_buffer_iter_next(struct log_error_buffer_iter *iter); +void log_error_buffer_iter_deinit(struct log_error_buffer_iter **iter); + +#endif From dovecot at dovecot.org Mon Feb 6 21:39:22 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 21:39:22 +0200 Subject: dovecot-2.1: lib-master: Added -i parameter to read config by in... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3fa544e4f26b changeset: 14069:3fa544e4f26b user: Timo Sirainen date: Mon Feb 06 21:39:11 2012 +0200 description: lib-master: Added -i parameter to read config by instance name rather than path. diffstat: src/lib-master/Makefile.am | 1 + src/lib-master/master-service-private.h | 2 +- src/lib-master/master-service.c | 36 +++++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 5 deletions(-) diffs (112 lines): diff -r 5f60958926e1 -r 3fa544e4f26b src/lib-master/Makefile.am --- a/src/lib-master/Makefile.am Mon Feb 06 21:26:55 2012 +0200 +++ b/src/lib-master/Makefile.am Mon Feb 06 21:39:11 2012 +0200 @@ -6,6 +6,7 @@ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-settings \ -DPKG_RUNDIR=\""$(rundir)"\" \ + -DPKG_STATEDIR=\""$(statedir)"\" \ -DSYSCONFDIR=\""$(pkgsysconfdir)"\" \ -DBINDIR=\""$(bindir)"\" diff -r 5f60958926e1 -r 3fa544e4f26b src/lib-master/master-service-private.h --- a/src/lib-master/master-service-private.h Mon Feb 06 21:26:55 2012 +0200 +++ b/src/lib-master/master-service-private.h Mon Feb 06 21:39:11 2012 +0200 @@ -23,7 +23,7 @@ char **argv; const char *version_string; - const char *config_path; + char *config_path; ARRAY_TYPE(const_string) config_overrides; int config_fd; int syslog_facility; diff -r 5f60958926e1 -r 3fa544e4f26b src/lib-master/master-service.c --- a/src/lib-master/master-service.c Mon Feb 06 21:26:55 2012 +0200 +++ b/src/lib-master/master-service.c Mon Feb 06 21:39:11 2012 +0200 @@ -3,6 +3,7 @@ #include "lib.h" #include "lib-signals.h" #include "ioloop.h" +#include "abspath.h" #include "array.h" #include "strescape.h" #include "env-util.h" @@ -12,6 +13,7 @@ #include "fd-close-on-exec.h" #include "settings-parser.h" #include "syslog-util.h" +#include "master-instance.h" #include "master-login.h" #include "master-service-private.h" #include "master-service-settings.h" @@ -45,7 +47,7 @@ const char *master_service_getopt_string(void) { - return "c:ko:Os:L"; + return "c:i:ko:Os:L"; } static void sig_die(const siginfo_t *si, void *context) @@ -155,9 +157,9 @@ service->service_count_left = (unsigned int)-1; service->config_fd = -1; - service->config_path = getenv(MASTER_CONFIG_FILE_ENV); + service->config_path = i_strdup(getenv(MASTER_CONFIG_FILE_ENV)); if (service->config_path == NULL) { - service->config_path = DEFAULT_CONFIG_FILE_PATH; + service->config_path = i_strdup(DEFAULT_CONFIG_FILE_PATH); service->config_path_is_default = TRUE; } @@ -326,14 +328,39 @@ service->idle_die_callback = callback; } +static bool get_instance_config(const char *name, const char **config_path_r) +{ + struct master_instance_list *list; + const struct master_instance *inst; + const char *path; + + list = master_instance_list_init(MASTER_INSTANCE_PATH); + inst = master_instance_list_find_by_name(list, name); + if (inst != NULL) { + path = t_strdup_printf("%s/dovecot.conf", inst->base_dir); + if (t_readlink(path, config_path_r) < 0) + i_fatal("readlink(%s) failed: %m", path); + } + master_instance_list_deinit(&list); + return inst != NULL; +} + bool master_service_parse_option(struct master_service *service, int opt, const char *arg) { + const char *path; + switch (opt) { case 'c': - service->config_path = arg; + service->config_path = i_strdup(arg); service->config_path_is_default = FALSE; break; + case 'i': + if (!get_instance_config(arg, &path)) + i_fatal("Unknown instance name: %s", arg); + service->config_path = i_strdup(path); + service->keep_environment = TRUE; + break; case 'k': service->keep_environment = TRUE; break; @@ -710,6 +737,7 @@ i_free(service->listeners); i_free(service->getopt_str); i_free(service->name); + i_free(service->config_path); i_free(service); lib_deinit(); From dovecot at dovecot.org Mon Feb 6 21:42:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 21:42:44 +0200 Subject: dovecot-2.1: master: If instance_name doesn't begin with "doveco... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/26885fe20e1f changeset: 14070:26885fe20e1f user: Timo Sirainen date: Mon Feb 06 21:42:37 2012 +0200 description: master: If instance_name doesn't begin with "dovecot", add "dovecot-" prefix to process names. diffstat: src/master/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r 3fa544e4f26b -r 26885fe20e1f src/master/main.c --- a/src/master/main.c Mon Feb 06 21:39:11 2012 +0200 +++ b/src/master/main.c Mon Feb 06 21:42:37 2012 +0200 @@ -85,6 +85,8 @@ /* prefix with dovecot/ */ argv[0] = t_strdup_printf("%s/%s", services->set->instance_name, argv[0]); + if (strncmp(argv[0], PACKAGE, strlen(PACKAGE)) != 0) + argv[0] = t_strconcat(PACKAGE"-", argv[0], NULL); (void)execv_const(executable, argv); } From dovecot at dovecot.org Mon Feb 6 21:45:55 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 21:45:55 +0200 Subject: dovecot-2.1: lib-master: Removed code to auto-drop instances fro... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/51c4e336c872 changeset: 14071:51c4e336c872 user: Timo Sirainen date: Mon Feb 06 21:45:49 2012 +0200 description: lib-master: Removed code to auto-drop instances from the list. There couldn't be any empty named instances, so it was a bit pointless. diffstat: src/lib-master/master-instance.c | 21 --------------------- src/lib-master/master-instance.h | 2 -- 2 files changed, 0 insertions(+), 23 deletions(-) diffs (57 lines): diff -r 26885fe20e1f -r 51c4e336c872 src/lib-master/master-instance.c --- a/src/lib-master/master-instance.c Mon Feb 06 21:42:37 2012 +0200 +++ b/src/lib-master/master-instance.c Mon Feb 06 21:45:49 2012 +0200 @@ -50,24 +50,6 @@ pool_unref(&list->pool); } -static void master_instance_list_drop_stale(struct master_instance_list *list) -{ - const struct master_instance *instances; - unsigned int i, count; - time_t stale_timestamp = time(NULL) - MASTER_INSTANCE_AUTO_STALE_SECS; - - instances = array_get(&list->instances, &count); - for (i = 0; i < count; ) { - if (instances[i].name[0] == '\0' && - instances[i].last_used < stale_timestamp) { - array_delete(&list->instances, i, 1); - instances = array_get(&list->instances, &count); - } else { - i++; - } - } -} - static int master_instance_list_add_line(struct master_instance_list *list, const char *line) @@ -174,8 +156,6 @@ const char *lock_path = file_dotlock_get_lock_path(*dotlock); int ret; - master_instance_list_drop_stale(list); - T_BEGIN { ret = master_instance_list_write(list, fd, lock_path); } T_END; @@ -309,7 +289,6 @@ iter = i_new(struct master_instance_list_iter, 1); iter->list = list; (void)master_instance_list_refresh(list); - master_instance_list_drop_stale(list); return iter; } diff -r 26885fe20e1f -r 51c4e336c872 src/lib-master/master-instance.h --- a/src/lib-master/master-instance.h Mon Feb 06 21:42:37 2012 +0200 +++ b/src/lib-master/master-instance.h Mon Feb 06 21:45:49 2012 +0200 @@ -2,8 +2,6 @@ #define MASTER_INSTANCE_H #define MASTER_INSTANCE_PATH PKG_STATEDIR"/instances" -/* Delete instances whose last_used is older than this and has no name. */ -#define MASTER_INSTANCE_AUTO_STALE_SECS (3600*24) struct master_instance_list; From dovecot at dovecot.org Mon Feb 6 21:48:35 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 21:48:35 +0200 Subject: dovecot-2.1: doveadm instance list: Show the last used field. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/833ac7b1d58b changeset: 14072:833ac7b1d58b user: Timo Sirainen date: Mon Feb 06 21:48:29 2012 +0200 description: doveadm instance list: Show the last used field. diffstat: src/doveadm/doveadm-instance.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (19 lines): diff -r 51c4e336c872 -r 833ac7b1d58b src/doveadm/doveadm-instance.c --- a/src/doveadm/doveadm-instance.c Mon Feb 06 21:45:49 2012 +0200 +++ b/src/doveadm/doveadm-instance.c Mon Feb 06 21:48:29 2012 +0200 @@ -52,6 +52,7 @@ doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE); doveadm_print_header("path", "path", DOVEADM_PRINT_HEADER_FLAG_EXPAND); doveadm_print_header_simple("name"); + doveadm_print_header_simple("last used"); doveadm_print_header_simple("running"); list = master_instance_list_init(MASTER_INSTANCE_PATH); @@ -59,6 +60,7 @@ while ((inst = master_instance_iterate_list_next(iter)) != NULL) { doveadm_print(inst->base_dir); doveadm_print(inst->name); + doveadm_print(unixdate2str(inst->last_used)); pidfile_path = t_strconcat(inst->base_dir, "/master.pid", NULL); if (pid_file_read(pidfile_path)) doveadm_print("yes"); From dovecot at dovecot.org Mon Feb 6 22:41:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 06 Feb 2012 22:41:30 +0200 Subject: dovecot-2.1: sdbox: Fix a corrupted mailbox when opening it, ins... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a765e0a895a9 changeset: 14073:a765e0a895a9 user: Timo Sirainen date: Mon Feb 06 22:41:18 2012 +0200 description: sdbox: Fix a corrupted mailbox when opening it, instead of losing all of its contents. diffstat: src/lib-storage/index/dbox-single/sdbox-storage.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (18 lines): diff -r 833ac7b1d58b -r a765e0a895a9 src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Mon Feb 06 21:48:29 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Mon Feb 06 22:41:18 2012 +0200 @@ -297,8 +297,12 @@ &view, &trans, 0) > 0) (void)mail_index_sync_commit(&sync_ctx); - if (sdbox_read_header(mbox, &hdr, TRUE) < 0) - memset(&hdr, 0, sizeof(hdr)); + if (sdbox_read_header(mbox, &hdr, TRUE) < 0) { + /* looks like the mailbox is corrupted */ + (void)sdbox_sync(mbox, SDBOX_SYNC_FLAG_FORCE); + if (sdbox_read_header(mbox, &hdr, TRUE) < 0) + memset(&hdr, 0, sizeof(hdr)); + } } if (guid_128_is_empty(hdr.mailbox_guid)) { From dovecot at dovecot.org Wed Feb 8 22:42:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 08 Feb 2012 22:42:44 +0200 Subject: dovecot-2.1: Removed unnecessary code. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/06c9a46f35a8 changeset: 14074:06c9a46f35a8 user: Timo Sirainen date: Wed Feb 08 22:07:01 2012 +0200 description: Removed unnecessary code. diffstat: src/imap/imap-fetch-body.c | 23 ++++++----------------- src/imap/imap-fetch.h | 1 - 2 files changed, 6 insertions(+), 18 deletions(-) diffs (55 lines): diff -r a765e0a895a9 -r 06c9a46f35a8 src/imap/imap-fetch-body.c --- a/src/imap/imap-fetch-body.c Mon Feb 06 22:41:18 2012 +0200 +++ b/src/imap/imap-fetch-body.c Wed Feb 08 22:07:01 2012 +0200 @@ -375,14 +375,6 @@ return fetch_data(ctx, body, fetch_size); } -static void header_filter_eoh(struct message_header_line *hdr, - bool *matched ATTR_UNUSED, - struct imap_fetch_context *ctx) -{ - if (hdr != NULL && hdr->eoh) - ctx->cur_have_eoh = TRUE; -} - static int fetch_header_partial_from(struct imap_fetch_context *ctx, const struct imap_fetch_body_data *body, const char *header_section) @@ -393,19 +385,16 @@ /* MIME, HEADER.FIELDS (list), HEADER.FIELDS.NOT (list) */ - ctx->cur_have_eoh = FALSE; if (strncmp(header_section, "HEADER.FIELDS ", 14) == 0) { input = i_stream_create_header_filter(ctx->cur_input, - HEADER_FILTER_INCLUDE, - body->fields, - body->fields_count, - header_filter_eoh, ctx); + HEADER_FILTER_INCLUDE, + body->fields, body->fields_count, + null_header_filter_callback, NULL); } else if (strncmp(header_section, "HEADER.FIELDS.NOT ", 18) == 0) { input = i_stream_create_header_filter(ctx->cur_input, - HEADER_FILTER_EXCLUDE, - body->fields, - body->fields_count, - header_filter_eoh, ctx); + HEADER_FILTER_EXCLUDE, + body->fields, body->fields_count, + null_header_filter_callback, NULL); } else { i_error("BUG: Accepted invalid section from user: '%s'", header_section); diff -r a765e0a895a9 -r 06c9a46f35a8 src/imap/imap-fetch.h --- a/src/imap/imap-fetch.h Mon Feb 06 22:41:18 2012 +0200 +++ b/src/imap/imap-fetch.h Wed Feb 08 22:07:01 2012 +0200 @@ -64,7 +64,6 @@ unsigned int seen_flags_changed:1; unsigned int flags_show_only_seen_changes:1; unsigned int update_partial:1; - unsigned int cur_have_eoh:1; unsigned int cur_append_eoh:1; unsigned int first:1; unsigned int line_partial:1; From dovecot at dovecot.org Wed Feb 8 22:50:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 08 Feb 2012 22:50:30 +0200 Subject: dovecot-2.1: doveadm instance remove: Allow removing using name ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/448c48968174 changeset: 14075:448c48968174 user: Timo Sirainen date: Wed Feb 08 22:50:20 2012 +0200 description: doveadm instance remove: Allow removing using name as well as base dir. diffstat: src/doveadm/doveadm-instance.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (31 lines): diff -r 06c9a46f35a8 -r 448c48968174 src/doveadm/doveadm-instance.c --- a/src/doveadm/doveadm-instance.c Wed Feb 08 22:07:01 2012 +0200 +++ b/src/doveadm/doveadm-instance.c Wed Feb 08 22:50:20 2012 +0200 @@ -74,13 +74,17 @@ static void cmd_instance_remove(int argc, char *argv[]) { struct master_instance_list *list; + const struct master_instance *inst; + const char *base_dir; int ret; if (argc != 2) instance_cmd_help(cmd_instance_remove); list = master_instance_list_init(MASTER_INSTANCE_PATH); - if ((ret = master_instance_list_remove(list, argv[1])) < 0) + inst = master_instance_list_find_by_name(list, argv[1]); + base_dir = inst != NULL ? inst->base_dir : argv[1]; + if ((ret = master_instance_list_remove(list, base_dir)) < 0) i_error("Failed to remove instance"); else if (ret == 0) i_error("Instance already didn't exist"); @@ -89,7 +93,7 @@ struct doveadm_cmd doveadm_cmd_instance[] = { { cmd_instance_list, "instance list", "" }, - { cmd_instance_remove, "instance remove", "" } + { cmd_instance_remove, "instance remove", " | " } }; static void instance_cmd_help(doveadm_command_t *cmd) From dovecot at dovecot.org Wed Feb 8 23:05:37 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 08 Feb 2012 23:05:37 +0200 Subject: dovecot-2.1: iostreams: Set errno to stream_errno when exiting f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d4e7052af42a changeset: 14076:d4e7052af42a user: Timo Sirainen date: Wed Feb 08 23:05:26 2012 +0200 description: iostreams: Set errno to stream_errno when exiting from failing functions. diffstat: src/lib/istream.c | 5 ++++- src/lib/ostream.c | 29 +++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diffs (122 lines): diff -r 448c48968174 -r d4e7052af42a src/lib/istream.c --- a/src/lib/istream.c Wed Feb 08 22:50:20 2012 +0200 +++ b/src/lib/istream.c Wed Feb 08 23:05:26 2012 +0200 @@ -115,8 +115,10 @@ size_t old_size; ssize_t ret; - if (unlikely(stream->closed)) + if (unlikely(stream->closed)) { + errno = stream->stream_errno; return -1; + } stream->eof = FALSE; stream->stream_errno = 0; @@ -135,6 +137,7 @@ /* error handling should be easier if we now just assume the stream is now at EOF */ stream->eof = TRUE; + errno = stream->stream_errno; } else { i_assert(stream->eof); } diff -r 448c48968174 -r d4e7052af42a src/lib/ostream.c --- a/src/lib/ostream.c Wed Feb 08 22:50:20 2012 +0200 +++ b/src/lib/ostream.c Wed Feb 08 23:05:26 2012 +0200 @@ -88,13 +88,16 @@ struct ostream_private *_stream = stream->real_stream; int ret = 1; - if (unlikely(stream->closed)) + if (unlikely(stream->closed)) { + errno = stream->stream_errno; return -1; + } stream->stream_errno = 0; if (unlikely((ret = _stream->flush(_stream)) < 0)) { i_assert(stream->stream_errno != 0); stream->last_failed_errno = stream->stream_errno; + errno = stream->stream_errno; } return ret; } @@ -128,13 +131,16 @@ { struct ostream_private *_stream = stream->real_stream; - if (unlikely(stream->closed)) + if (unlikely(stream->closed)) { + errno = stream->stream_errno; return -1; + } stream->stream_errno = 0; if (unlikely(_stream->seek(_stream, offset) < 0)) { i_assert(stream->stream_errno != 0); stream->last_failed_errno = stream->stream_errno; + errno = stream->stream_errno; return -1; } return 1; @@ -158,8 +164,10 @@ size_t total_size; ssize_t ret; - if (unlikely(stream->closed)) + if (unlikely(stream->closed)) { + errno = stream->stream_errno; return -1; + } stream->stream_errno = 0; for (i = 0, total_size = 0; i < iov_count; i++) @@ -172,6 +180,7 @@ if (ret < 0) { i_assert(stream->stream_errno != 0); stream->last_failed_errno = stream->stream_errno; + errno = stream->stream_errno; } else { stream->overflow = TRUE; } @@ -190,13 +199,18 @@ struct ostream_private *_outstream = outstream->real_stream; off_t ret; - if (unlikely(outstream->closed || instream->closed)) + if (unlikely(outstream->closed || instream->closed)) { + errno = outstream->stream_errno; return -1; + } outstream->stream_errno = 0; ret = _outstream->send_istream(_outstream, instream); - if (unlikely(ret < 0)) + if (unlikely(ret < 0)) { + i_assert(outstream->stream_errno != 0); + outstream->last_failed_errno = outstream->stream_errno; errno = outstream->stream_errno; + } return ret; } @@ -205,14 +219,17 @@ { int ret; - if (unlikely(stream->closed)) + if (unlikely(stream->closed)) { + errno = stream->stream_errno; return -1; + } ret = stream->real_stream->write_at(stream->real_stream, data, size, offset); if (unlikely(ret < 0)) { i_assert(stream->stream_errno != 0); stream->last_failed_errno = stream->stream_errno; + errno = stream->stream_errno; } return ret; } From dovecot at dovecot.org Wed Feb 8 23:27:35 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 08 Feb 2012 23:27:35 +0200 Subject: dovecot-2.1: director: Fixed potential assert crash when moving ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/24eec256a761 changeset: 14077:24eec256a761 user: Timo Sirainen date: Wed Feb 08 23:27:22 2012 +0200 description: director: Fixed potential assert crash when moving a user to another backend. diffstat: src/director/main.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diffs (29 lines): diff -r d4e7052af42a -r 24eec256a761 src/director/main.c --- a/src/director/main.c Wed Feb 08 23:05:26 2012 +0200 +++ b/src/director/main.c Wed Feb 08 23:27:22 2012 +0200 @@ -113,6 +113,7 @@ static void director_state_changed(struct director *dir) { struct director_request *const *requestp; + ARRAY_DEFINE(new_requests, struct director_request *); bool ret; if (!dir->ring_synced || @@ -120,11 +121,16 @@ return; /* if there are any pending client requests, finish them now */ + t_array_init(&new_requests, 8); array_foreach(&dir->pending_requests, requestp) { ret = director_request_continue(*requestp); - i_assert(ret); + if (!ret) { + /* request for a user being killed */ + array_append(&new_requests, requestp, 1); + } } array_clear(&dir->pending_requests); + array_append_array(&dir->pending_requests, &new_requests); if (dir->to_request != NULL) timeout_remove(&dir->to_request); From dovecot at dovecot.org Thu Feb 9 00:41:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 00:41:49 +0200 Subject: dovecot-2.1: Increase initial memory pool sizes. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f6102f0af71d changeset: 14078:f6102f0af71d user: Timo Sirainen date: Thu Feb 09 00:38:30 2012 +0200 description: Increase initial memory pool sizes. diffstat: src/lib-index/mail-cache.c | 2 +- src/lib-master/mountpoint-list.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diffs (24 lines): diff -r 24eec256a761 -r f6102f0af71d src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Wed Feb 08 23:27:22 2012 +0200 +++ b/src/lib-index/mail-cache.c Thu Feb 09 00:38:30 2012 +0200 @@ -409,7 +409,7 @@ cache->fd = -1; cache->filepath = i_strconcat(index->filepath, MAIL_CACHE_FILE_SUFFIX, NULL); - cache->field_pool = pool_alloconly_create("Cache fields", 1024); + cache->field_pool = pool_alloconly_create("Cache fields", 2048); cache->field_name_hash = hash_table_create(default_pool, cache->field_pool, 0, strcase_hash, (hash_cmp_callback_t *)strcasecmp); diff -r 24eec256a761 -r f6102f0af71d src/lib-master/mountpoint-list.c --- a/src/lib-master/mountpoint-list.c Wed Feb 08 23:27:22 2012 +0200 +++ b/src/lib-master/mountpoint-list.c Thu Feb 09 00:38:30 2012 +0200 @@ -56,7 +56,7 @@ struct mountpoint_list *list; pool_t pool; - pool = pool_alloconly_create("mountpoint list", 512); + pool = pool_alloconly_create("mountpoint list", 1024); list = p_new(pool, struct mountpoint_list, 1); list->pool = pool; list->perm_path = p_strdup(pool, perm_path); From dovecot at dovecot.org Thu Feb 9 00:41:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 00:41:49 +0200 Subject: dovecot-2.1: lib-index: Added mail_index_set_ext_init_data() for... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2ab26bb55346 changeset: 14079:2ab26bb55346 user: Timo Sirainen date: Thu Feb 09 00:39:52 2012 +0200 description: lib-index: Added mail_index_set_ext_init_data() for adding data to index on creation. This can be used to avoid race conditions on mailbox creation for mailbox formats that require this (sdbox). diffstat: src/lib-index/mail-index-private.h | 3 + src/lib-index/mail-index.c | 18 ++++++++++ src/lib-index/mail-index.h | 4 ++ src/lib-index/mail-transaction-log-file.c | 54 +++++++++++++++++++++++++++++- 4 files changed, 77 insertions(+), 2 deletions(-) diffs (155 lines): diff -r f6102f0af71d -r 2ab26bb55346 src/lib-index/mail-index-private.h --- a/src/lib-index/mail-index-private.h Thu Feb 09 00:38:30 2012 +0200 +++ b/src/lib-index/mail-index-private.h Thu Feb 09 00:39:52 2012 +0200 @@ -181,6 +181,9 @@ pool_t extension_pool; ARRAY_DEFINE(extensions, struct mail_index_registered_ext); + uint32_t ext_hdr_init_id; + void *ext_hdr_init_data; + ARRAY_DEFINE(sync_lost_handlers, mail_index_sync_lost_handler_t *); char *filepath; diff -r f6102f0af71d -r 2ab26bb55346 src/lib-index/mail-index.c --- a/src/lib-index/mail-index.c Thu Feb 09 00:38:30 2012 +0200 +++ b/src/lib-index/mail-index.c Thu Feb 09 00:39:52 2012 +0200 @@ -77,6 +77,7 @@ array_free(&index->keywords); array_free(&index->module_contexts); + i_free(index->ext_hdr_init_data); i_free(index->gid_origin); i_free(index->error); i_free(index->dir); @@ -110,6 +111,23 @@ index->max_lock_timeout_secs = max_timeout_secs; } +void mail_index_set_ext_init_data(struct mail_index *index, uint32_t ext_id, + const void *data, size_t size) +{ + const struct mail_index_registered_ext *rext; + + i_assert(index->ext_hdr_init_data == NULL || + index->ext_hdr_init_id == ext_id); + + rext = array_idx(&index->extensions, ext_id); + i_assert(rext->hdr_size == size); + + index->ext_hdr_init_id = ext_id; + i_free(index->ext_hdr_init_data); + index->ext_hdr_init_data = i_malloc(size); + memcpy(index->ext_hdr_init_data, data, size); +} + uint32_t mail_index_ext_register(struct mail_index *index, const char *name, uint32_t default_hdr_size, uint16_t default_record_size, diff -r f6102f0af71d -r 2ab26bb55346 src/lib-index/mail-index.h --- a/src/lib-index/mail-index.h Thu Feb 09 00:38:30 2012 +0200 +++ b/src/lib-index/mail-index.h Thu Feb 09 00:39:52 2012 +0200 @@ -217,6 +217,10 @@ void mail_index_set_lock_method(struct mail_index *index, enum file_lock_method lock_method, unsigned int max_timeout_secs); +/* When creating a new index file or reseting an existing one, add the given + extension header data immediately to it. */ +void mail_index_set_ext_init_data(struct mail_index *index, uint32_t ext_id, + const void *data, size_t size); /* Open index. Returns 1 if ok, 0 if index doesn't exist and CREATE flags wasn't given, -1 if error. */ diff -r f6102f0af71d -r 2ab26bb55346 src/lib-index/mail-transaction-log-file.c --- a/src/lib-index/mail-transaction-log-file.c Thu Feb 09 00:38:30 2012 +0200 +++ b/src/lib-index/mail-transaction-log-file.c Thu Feb 09 00:39:52 2012 +0200 @@ -1,8 +1,8 @@ /* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "array.h" #include "ioloop.h" -#include "buffer.h" #include "file-dotlock.h" #include "nfs-workarounds.h" #include "read-full.h" @@ -587,6 +587,45 @@ return FALSE; } +static void log_write_ext_hdr_init_data(struct mail_index *index, buffer_t *buf) +{ + const struct mail_index_registered_ext *rext; + struct mail_transaction_header *hdr; + struct mail_transaction_ext_intro *intro; + struct mail_transaction_ext_hdr_update *ext_hdr; + unsigned int hdr_offset; + + rext = array_idx(&index->extensions, index->ext_hdr_init_id); + + /* introduce the extension */ + hdr_offset = buf->used; + hdr = buffer_append_space_unsafe(buf, sizeof(*hdr)); + hdr->type = MAIL_TRANSACTION_EXT_INTRO; + + intro = buffer_append_space_unsafe(buf, sizeof(*intro)); + intro->ext_id = (uint32_t)-1; + intro->hdr_size = rext->hdr_size; + intro->record_size = rext->record_size; + intro->record_align = rext->record_align; + intro->name_size = strlen(rext->name); + buffer_append(buf, rext->name, intro->name_size); + + hdr = buffer_get_space_unsafe(buf, hdr_offset, sizeof(*hdr)); + hdr->size = mail_index_uint32_to_offset(buf->used - hdr_offset); + + /* add the extension header data */ + hdr_offset = buf->used; + hdr = buffer_append_space_unsafe(buf, sizeof(*hdr)); + hdr->type = MAIL_TRANSACTION_EXT_HDR_UPDATE; + + ext_hdr = buffer_append_space_unsafe(buf, sizeof(*ext_hdr)); + ext_hdr->size = rext->hdr_size; + buffer_append(buf, index->ext_hdr_init_data, rext->hdr_size); + + hdr = buffer_get_space_unsafe(buf, hdr_offset, sizeof(*hdr)); + hdr->size = mail_index_uint32_to_offset(buf->used - hdr_offset); +} + static int mail_transaction_log_file_create2(struct mail_transaction_log_file *file, int new_fd, bool reset, @@ -595,6 +634,7 @@ struct mail_index *index = file->log->index; struct stat st; const char *path2; + buffer_t *writebuf; int fd, ret; bool rename_existing; @@ -651,6 +691,11 @@ rename_existing = FALSE; } + if (index->fd == -1 && !rename_existing) { + /* creating the initial index */ + reset = TRUE; + } + if (mail_transaction_log_init_hdr(file->log, &file->hdr) < 0) return -1; @@ -662,7 +707,12 @@ file->hdr.prev_file_offset = 0; } - if (write_full(new_fd, &file->hdr, sizeof(file->hdr)) < 0) + writebuf = buffer_create_dynamic(pool_datastack_create(), 128); + buffer_append(writebuf, &file->hdr, sizeof(file->hdr)); + + if (index->ext_hdr_init_data != NULL && reset) + log_write_ext_hdr_init_data(index, writebuf); + if (write_full(new_fd, writebuf->data, writebuf->used) < 0) return log_file_set_syscall_error(file, "write_full()"); if (file->log->index->fsync_mode == FSYNC_MODE_ALWAYS) { From dovecot at dovecot.org Thu Feb 9 00:41:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 00:41:49 +0200 Subject: dovecot-2.1: sdbox: Use mail_index_set_ext_init_data() to simpli... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1e2e69ea3095 changeset: 14080:1e2e69ea3095 user: Timo Sirainen date: Thu Feb 09 00:41:25 2012 +0200 description: sdbox: Use mail_index_set_ext_init_data() to simplify opening mailboxes. Now the initial mailbox index can be created with the necessary sdbox header. If the header doesn't exist when opening a mailbox, it's guaranteed to be corrupted. diffstat: src/lib-storage/index/dbox-single/sdbox-storage.c | 61 ++++++++++------- src/lib-storage/index/dbox-single/sdbox-storage.h | 3 - src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 3 +- src/lib-storage/index/index-storage.c | 2 +- src/lib-storage/index/index-storage.h | 1 + 5 files changed, 41 insertions(+), 29 deletions(-) diffs (146 lines): diff -r 2ab26bb55346 -r 1e2e69ea3095 src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Feb 09 00:39:52 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Thu Feb 09 00:41:25 2012 +0200 @@ -138,15 +138,23 @@ } else { memset(hdr, 0, sizeof(*hdr)); memcpy(hdr, data, I_MIN(data_size, sizeof(*hdr))); - ret = 0; + if (guid_128_is_empty(hdr->mailbox_guid)) + ret = -1; + else { + /* data is valid. remember it in case mailbox + is being reset */ + mail_index_set_ext_init_data(mbox->box.index, + mbox->hdr_ext_id, + hdr, sizeof(*hdr)); + } } mail_index_view_close(&view); return ret; } -void sdbox_update_header(struct sdbox_mailbox *mbox, - struct mail_index_transaction *trans, - const struct mailbox_update *update) +static void sdbox_update_header(struct sdbox_mailbox *mbox, + struct mail_index_transaction *trans, + const struct mailbox_update *update) { struct sdbox_index_header hdr, new_hdr; @@ -263,16 +271,34 @@ sdbox_set_mailbox_corrupted(&file->mbox->box); } +static int sdbox_mailbox_alloc_index(struct sdbox_mailbox *mbox) +{ + struct sdbox_index_header hdr; + + if (index_storage_mailbox_alloc_index(&mbox->box) < 0) + return -1; + + mbox->hdr_ext_id = + mail_index_ext_register(mbox->box.index, "dbox-hdr", + sizeof(struct sdbox_index_header), 0, 0); + /* set the initialization data in case the mailbox is created */ + memset(&hdr, 0, sizeof(hdr)); + guid_128_generate(hdr.mailbox_guid); + mail_index_set_ext_init_data(mbox->box.index, mbox->hdr_ext_id, + &hdr, sizeof(hdr)); + return 0; +} + static int sdbox_mailbox_open(struct mailbox *box) { struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)box; struct sdbox_index_header hdr; + if (sdbox_mailbox_alloc_index(mbox) < 0) + return -1; + if (dbox_mailbox_open(box) < 0) return -1; - mbox->hdr_ext_id = - mail_index_ext_register(box->index, "dbox-hdr", - sizeof(struct sdbox_index_header), 0, 0); if (box->creating) { /* wait for mailbox creation to initialize the index */ @@ -286,23 +312,10 @@ /* get/generate mailbox guid */ if (sdbox_read_header(mbox, &hdr, FALSE) < 0) { - /* it's possible that this mailbox is just now being created - by another process. lock it first and see if the header is - available then. */ - struct mail_index_sync_ctx *sync_ctx; - struct mail_index_view *view; - struct mail_index_transaction *trans; - - if (mail_index_sync_begin(box->index, &sync_ctx, - &view, &trans, 0) > 0) - (void)mail_index_sync_commit(&sync_ctx); - - if (sdbox_read_header(mbox, &hdr, TRUE) < 0) { - /* looks like the mailbox is corrupted */ - (void)sdbox_sync(mbox, SDBOX_SYNC_FLAG_FORCE); - if (sdbox_read_header(mbox, &hdr, TRUE) < 0) - memset(&hdr, 0, sizeof(hdr)); - } + /* looks like the mailbox is corrupted */ + (void)sdbox_sync(mbox, SDBOX_SYNC_FLAG_FORCE); + if (sdbox_read_header(mbox, &hdr, TRUE) < 0) + memset(&hdr, 0, sizeof(hdr)); } if (guid_128_is_empty(hdr.mailbox_guid)) { diff -r 2ab26bb55346 -r 1e2e69ea3095 src/lib-storage/index/dbox-single/sdbox-storage.h --- a/src/lib-storage/index/dbox-single/sdbox-storage.h Thu Feb 09 00:39:52 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.h Thu Feb 09 00:41:25 2012 +0200 @@ -39,9 +39,6 @@ uint32_t dbox_get_uidvalidity_next(struct mailbox_list *list); int sdbox_read_header(struct sdbox_mailbox *mbox, struct sdbox_index_header *hdr, bool log_error); -void sdbox_update_header(struct sdbox_mailbox *mbox, - struct mail_index_transaction *trans, - const struct mailbox_update *update); void sdbox_set_mailbox_corrupted(struct mailbox *box); struct mail_save_context * diff -r 2ab26bb55346 -r 1e2e69ea3095 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Thu Feb 09 00:39:52 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Thu Feb 09 00:41:25 2012 +0200 @@ -139,7 +139,8 @@ guid_128_generate(hdr.mailbox_guid); if (++hdr.rebuild_count == 0) hdr.rebuild_count = 1; - mail_index_update_header_ext(ctx->trans, mbox->hdr_ext_id, 0, + /* mailbox is being reset. this gets written directly there */ + mail_index_set_ext_init_data(ctx->box->index, mbox->hdr_ext_id, &hdr, sizeof(hdr)); } diff -r 2ab26bb55346 -r 1e2e69ea3095 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Thu Feb 09 00:39:52 2012 +0200 +++ b/src/lib-storage/index/index-storage.c Thu Feb 09 00:41:25 2012 +0200 @@ -191,7 +191,7 @@ return 0; } -static int index_storage_mailbox_alloc_index(struct mailbox *box) +int index_storage_mailbox_alloc_index(struct mailbox *box) { if (box->index != NULL) return 0; diff -r 2ab26bb55346 -r 1e2e69ea3095 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Thu Feb 09 00:39:52 2012 +0200 +++ b/src/lib-storage/index/index-storage.h Thu Feb 09 00:41:25 2012 +0200 @@ -55,6 +55,7 @@ unsigned int secs_left); void index_storage_lock_notify_reset(struct mailbox *box); +int index_storage_mailbox_alloc_index(struct mailbox *box); void index_storage_mailbox_alloc(struct mailbox *box, const char *vname, enum mailbox_flags flags, const char *index_prefix); From dovecot at dovecot.org Thu Feb 9 01:00:27 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 01:00:27 +0200 Subject: dovecot-2.1: dbox: Never rename() mail files over existing files... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/09db0f7aa6ce changeset: 14082:09db0f7aa6ce user: Timo Sirainen date: Thu Feb 09 01:00:14 2012 +0200 description: dbox: Never rename() mail files over existing files. If such a file exists, rebuild indexes. diffstat: src/lib-storage/index/dbox-multi/mdbox-file.c | 8 ++++++++ src/lib-storage/index/dbox-single/sdbox-file.c | 8 ++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diffs (50 lines): diff -r 41bd2d4c013d -r 09db0f7aa6ce src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Thu Feb 09 00:59:44 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Thu Feb 09 01:00:14 2012 +0200 @@ -185,6 +185,7 @@ int mdbox_file_assign_file_id(struct mdbox_file *file, uint32_t file_id) { + struct stat st; const char *old_path; const char *new_dir, *new_fname, *new_path; @@ -196,6 +197,13 @@ new_dir = !dbox_file_is_in_alt(&file->file) ? file->storage->storage_dir : file->storage->alt_storage_dir; new_path = t_strdup_printf("%s/%s", new_dir, new_fname); + + if (stat(new_path, &st) == 0) { + mail_storage_set_critical(&file->file.storage->storage, + "mdbox: %s already exists, rebuilding index", new_path); + mdbox_storage_set_corrupted(file->storage); + return -1; + } if (rename(old_path, new_path) < 0) { mail_storage_set_critical(&file->storage->storage.storage, "rename(%s, %s) failed: %m", diff -r 41bd2d4c013d -r 09db0f7aa6ce src/lib-storage/index/dbox-single/sdbox-file.c --- a/src/lib-storage/index/dbox-single/sdbox-file.c Thu Feb 09 00:59:44 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-file.c Thu Feb 09 01:00:14 2012 +0200 @@ -146,6 +146,7 @@ int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid) { const char *old_path, *new_fname, *new_path; + struct stat st; i_assert(file->uid == 0); i_assert(uid != 0); @@ -154,6 +155,13 @@ new_fname = t_strdup_printf(SDBOX_MAIL_FILE_FORMAT, uid); new_path = t_strdup_printf("%s/%s", mailbox_get_path(&file->mbox->box), new_fname); + + if (stat(new_path, &st) == 0) { + mail_storage_set_critical(&file->file.storage->storage, + "sdbox: %s already exists, rebuilding index", new_path); + sdbox_set_mailbox_corrupted(&file->mbox->box); + return -1; + } if (rename(old_path, new_path) < 0) { mail_storage_set_critical(&file->file.storage->storage, "rename(%s, %s) failed: %m", From dovecot at dovecot.org Thu Feb 9 01:00:27 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 01:00:27 +0200 Subject: dovecot-2.1: mdbox: Fixed initial mailbox creation to work again... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/41bd2d4c013d changeset: 14081:41bd2d4c013d user: Timo Sirainen date: Thu Feb 09 00:59:44 2012 +0200 description: mdbox: Fixed initial mailbox creation to work again without errors. diffstat: src/lib-storage/index/dbox-multi/mdbox-map.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 1e2e69ea3095 -r 41bd2d4c013d src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Thu Feb 09 00:41:25 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Thu Feb 09 00:59:44 2012 +0200 @@ -195,7 +195,8 @@ mdbox_map_cleanup(map); if (mail_index_get_header(map->view)->uid_validity == 0) { - if (mdbox_map_generate_uid_validity(map) < 0) { + if (mdbox_map_generate_uid_validity(map) < 0 || + mdbox_map_refresh(map) < 0) { mail_storage_set_internal_error(MAP_STORAGE(map)); mail_index_reset_error(map->index); mail_index_close(map->index); From dovecot at dovecot.org Thu Feb 9 01:23:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 01:23:16 +0200 Subject: dovecot-2.1: dbox: Index rebuild now preserves caching decisions. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d8d214cc1936 changeset: 14084:d8d214cc1936 user: Timo Sirainen date: Thu Feb 09 01:23:00 2012 +0200 description: dbox: Index rebuild now preserves caching decisions. diffstat: src/lib-storage/index/dbox-common/dbox-sync-rebuild.c | 10 ++++++++++ src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 3 --- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 -- 3 files changed, 10 insertions(+), 5 deletions(-) diffs (59 lines): diff -r 21c3ce1b21cd -r d8d214cc1936 src/lib-storage/index/dbox-common/dbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Thu Feb 09 01:21:41 2012 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Thu Feb 09 01:23:00 2012 +0200 @@ -2,6 +2,7 @@ #include "lib.h" #include "array.h" +#include "mail-cache.h" #include "mail-index-modseq.h" #include "mailbox-list-private.h" #include "index-storage.h" @@ -159,6 +160,12 @@ index_mailbox_reset_uidvalidity(box); mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id); + /* open cache and read the caching decisions. we'll reset the cache in + case it contains any invalid data, but we want to preserve the + decisions. */ + (void)mail_cache_open_and_verify(ctx->box->cache); + mail_cache_reset(box->cache); + /* if backup index file exists, try to use it */ index_dir = mailbox_list_get_path(box->list, box->name, MAILBOX_LIST_PATH_TYPE_INDEX); @@ -183,6 +190,9 @@ struct dbox_sync_rebuild_context *ctx = *_ctx; *_ctx = NULL; + + /* initialize cache file with the old field decisions */ + (void)mail_cache_compress(ctx->box->cache, ctx->trans); dbox_sync_rebuild_header(ctx); if (ctx->backup_index != NULL) { mail_index_view_close(&ctx->backup_view); diff -r 21c3ce1b21cd -r d8d214cc1936 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 01:21:41 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 01:23:00 2012 +0200 @@ -501,9 +501,6 @@ return -1; } - /* reset cache, just in case it contains invalid data */ - mail_cache_reset(box->cache); - rebuild_ctx = dbox_sync_index_rebuild_init(&mbox->box, view, trans); mdbox_header_update(rebuild_ctx, mbox); rebuild_mailbox_multi(ctx, rebuild_ctx, mbox, view, trans); diff -r 21c3ce1b21cd -r d8d214cc1936 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Thu Feb 09 01:21:41 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Thu Feb 09 01:23:00 2012 +0200 @@ -195,8 +195,6 @@ return -1; } - mail_cache_reset(mbox->box.cache); - view = mail_index_view_open(mbox->box.index); trans = mail_index_transaction_begin(view, MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); From dovecot at dovecot.org Thu Feb 9 01:23:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 01:23:16 +0200 Subject: dovecot-2.1: lib-index: mail_cache_open_and_verify() is now public. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/21c3ce1b21cd changeset: 14083:21c3ce1b21cd user: Timo Sirainen date: Thu Feb 09 01:21:41 2012 +0200 description: lib-index: mail_cache_open_and_verify() is now public. diffstat: src/lib-index/mail-cache-private.h | 2 -- src/lib-index/mail-cache.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diffs (24 lines): diff -r 09db0f7aa6ce -r 21c3ce1b21cd src/lib-index/mail-cache-private.h --- a/src/lib-index/mail-cache-private.h Thu Feb 09 01:00:14 2012 +0200 +++ b/src/lib-index/mail-cache-private.h Thu Feb 09 01:21:41 2012 +0200 @@ -221,8 +221,6 @@ unsigned int appends_checked:1; }; -int mail_cache_open_and_verify(struct mail_cache *cache); - /* Explicitly lock the cache file. Returns -1 if error / timed out, 1 if ok, 0 if cache is broken/doesn't exist */ int mail_cache_lock(struct mail_cache *cache, bool require_same_reset_id); diff -r 09db0f7aa6ce -r 21c3ce1b21cd src/lib-index/mail-cache.h --- a/src/lib-index/mail-cache.h Thu Feb 09 01:00:14 2012 +0200 +++ b/src/lib-index/mail-cache.h Thu Feb 09 01:21:41 2012 +0200 @@ -70,6 +70,8 @@ struct mail_index_transaction *trans); /* Returns TRUE if there is at least something in the cache. */ bool mail_cache_exists(struct mail_cache *cache); +/* Open and read cache header. Returns 0 if ok, -1 if error/corrupted. */ +int mail_cache_open_and_verify(struct mail_cache *cache); struct mail_cache_view * mail_cache_view_open(struct mail_cache *cache, struct mail_index_view *iview); From dovecot at dovecot.org Thu Feb 9 02:17:02 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:17:02 +0200 Subject: dovecot-2.0: dbox: Never rename() mail files over existing files... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/550929ff244c changeset: 13036:550929ff244c user: Timo Sirainen date: Thu Feb 09 01:00:14 2012 +0200 description: dbox: Never rename() mail files over existing files. If such a file exists, rebuild indexes. diffstat: src/lib-storage/index/dbox-multi/mdbox-file.c | 8 ++++++++ src/lib-storage/index/dbox-single/sdbox-file.c | 8 ++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diffs (50 lines): diff -r dcc19b00e748 -r 550929ff244c src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Wed Feb 01 23:34:24 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Thu Feb 09 01:00:14 2012 +0200 @@ -185,6 +185,7 @@ int mdbox_file_assign_file_id(struct mdbox_file *file, uint32_t file_id) { + struct stat st; const char *old_path; const char *new_dir, *new_fname, *new_path; @@ -196,6 +197,13 @@ new_dir = !dbox_file_is_in_alt(&file->file) ? file->storage->storage_dir : file->storage->alt_storage_dir; new_path = t_strdup_printf("%s/%s", new_dir, new_fname); + + if (stat(new_path, &st) == 0) { + mail_storage_set_critical(&file->file.storage->storage, + "mdbox: %s already exists, rebuilding index", new_path); + mdbox_storage_set_corrupted(file->storage); + return -1; + } if (rename(old_path, new_path) < 0) { mail_storage_set_critical(&file->storage->storage.storage, "rename(%s, %s) failed: %m", diff -r dcc19b00e748 -r 550929ff244c src/lib-storage/index/dbox-single/sdbox-file.c --- a/src/lib-storage/index/dbox-single/sdbox-file.c Wed Feb 01 23:34:24 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-file.c Thu Feb 09 01:00:14 2012 +0200 @@ -146,6 +146,7 @@ int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid) { const char *old_path, *new_fname, *new_path; + struct stat st; i_assert(file->uid == 0); i_assert(uid != 0); @@ -154,6 +155,13 @@ new_fname = t_strdup_printf(SDBOX_MAIL_FILE_FORMAT, uid); new_path = t_strdup_printf("%s/%s", file->mbox->box.path, new_fname); + + if (stat(new_path, &st) == 0) { + mail_storage_set_critical(&file->file.storage->storage, + "sdbox: %s already exists, rebuilding index", new_path); + sdbox_set_mailbox_corrupted(&file->mbox->box); + return -1; + } if (rename(old_path, new_path) < 0) { mail_storage_set_critical(&file->file.storage->storage, "rename(%s, %s) failed: %m", From dovecot at dovecot.org Thu Feb 9 02:21:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:21:48 +0200 Subject: dovecot-2.0: mdbox: Avoid deferencing NULL pointer in specific c... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8339ffff1efe changeset: 13037:8339ffff1efe user: Timo Sirainen date: Thu Feb 09 02:21:37 2012 +0200 description: mdbox: Avoid deferencing NULL pointer in specific corrupted mailboxes. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diffs (28 lines): diff -r 550929ff244c -r 8339ffff1efe src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 01:00:14 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:21:37 2012 +0200 @@ -377,7 +377,6 @@ struct mail_index_view *view, struct mail_index_transaction *trans) { - const struct mdbox_mail_index_record *dbox_rec; struct mdbox_mail_index_record new_dbox_rec; const struct mail_index_header *hdr; struct mdbox_rebuild_msg *rec; @@ -389,9 +388,13 @@ for (seq = 1; seq <= hdr->messages_count; seq++) { mail_index_lookup_ext(view, seq, mbox->ext_id, &data, &expunged); - dbox_rec = data; - new_dbox_rec = *dbox_rec; - map_uid = dbox_rec == NULL ? 0 : dbox_rec->map_uid; + if (data == NULL) { + memset(&new_dbox_rec, 0, sizeof(new_dbox_rec)); + map_uid = 0; + } else { + memcpy(&new_dbox_rec, data, sizeof(new_dbox_rec)); + map_uid = new_dbox_rec.map_uid; + } mail_index_lookup_ext(view, seq, mbox->guid_ext_id, &data, &expunged); From dovecot at dovecot.org Thu Feb 9 02:24:17 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:24:17 +0200 Subject: dovecot-2.1: mdbox: Avoid deferencing NULL pointer in specific c... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/69bb267956a2 changeset: 14085:69bb267956a2 user: Timo Sirainen date: Thu Feb 09 02:21:37 2012 +0200 description: mdbox: Avoid deferencing NULL pointer in specific corrupted mailboxes. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diffs (28 lines): diff -r d8d214cc1936 -r 69bb267956a2 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 01:23:00 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:21:37 2012 +0200 @@ -356,7 +356,6 @@ struct mail_index_view *view, struct mail_index_transaction *trans) { - const struct mdbox_mail_index_record *dbox_rec; struct mdbox_mail_index_record new_dbox_rec; const struct mail_index_header *hdr; struct mdbox_rebuild_msg *rec; @@ -368,9 +367,13 @@ for (seq = 1; seq <= hdr->messages_count; seq++) { mail_index_lookup_ext(view, seq, mbox->ext_id, &data, &expunged); - dbox_rec = data; - new_dbox_rec = *dbox_rec; - map_uid = dbox_rec == NULL ? 0 : dbox_rec->map_uid; + if (data == NULL) { + memset(&new_dbox_rec, 0, sizeof(new_dbox_rec)); + map_uid = 0; + } else { + memcpy(&new_dbox_rec, data, sizeof(new_dbox_rec)); + map_uid = new_dbox_rec.map_uid; + } mail_index_lookup_ext(view, seq, mbox->guid_ext_id, &data, &expunged); From dovecot at dovecot.org Thu Feb 9 02:25:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:25:23 +0200 Subject: dovecot-2.0: mdbox: Small code cleanup to storage rebuild. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/a2ac502ee05f changeset: 13038:a2ac502ee05f user: Timo Sirainen date: Thu Feb 09 02:25:18 2012 +0200 description: mdbox: Small code cleanup to storage rebuild. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 42 +++++++-------- 1 files changed, 20 insertions(+), 22 deletions(-) diffs (100 lines): diff -r 8339ffff1efe -r a2ac502ee05f src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:21:37 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:25:18 2012 +0200 @@ -325,6 +325,8 @@ unsigned int count; array_sort(&ctx->msgs, mdbox_rebuild_msg_offset_cmp); + /* msgs now contains a list of all messages that exists in m.* files, + sorted by file_id,offset */ msgs = array_get_modifiable(&ctx->msgs, &count); hdr = mail_index_get_header(ctx->atomic->sync_view); @@ -333,7 +335,8 @@ seq, &rec) < 0) return -1; - /* look up the rebuild msg record for this message */ + /* look up the rebuild msg record for this message based on + the (file_id, offset, size) triplet */ search_msg.file_id = rec.rec.file_id; search_msg.offset = rec.rec.offset; search_msg.size = rec.rec.size; @@ -344,6 +347,7 @@ a duplicate message. */ mail_index_expunge(ctx->atomic->sync_trans, seq); } else { + /* remember this message's map_uid */ (*pos)->map_uid = rec.map_uid; if (rec.refcount == 0) (*pos)->seen_zero_ref_in_map = TRUE; @@ -382,11 +386,14 @@ struct mdbox_rebuild_msg *rec; const void *data; bool expunged; - uint32_t seq, uid, new_seq, map_uid; + uint32_t old_seq, new_seq, uid, map_uid; + /* Rebuild the mailbox's index. Note that index is reset at this point, + so although we can still access the old messages, we'll need to + append anything we want to keep as new messages. */ hdr = mail_index_get_header(view); - for (seq = 1; seq <= hdr->messages_count; seq++) { - mail_index_lookup_ext(view, seq, mbox->ext_id, + for (old_seq = 1; old_seq <= hdr->messages_count; old_seq++) { + mail_index_lookup_ext(view, old_seq, mbox->ext_id, &data, &expunged); if (data == NULL) { memset(&new_dbox_rec, 0, sizeof(new_dbox_rec)); @@ -396,7 +403,7 @@ map_uid = new_dbox_rec.map_uid; } - mail_index_lookup_ext(view, seq, mbox->guid_ext_id, + mail_index_lookup_ext(view, old_seq, mbox->guid_ext_id, &data, &expunged); /* see if we can find this message based on @@ -404,34 +411,25 @@ rec = data == NULL ? NULL : hash_table_lookup(ctx->guid_hash, data); if (rec == NULL) { - if (map_uid == 0) { - /* not a multi-dbox message, ignore. */ - continue; - } /* multi-dbox message that wasn't found with GUID. either it's lost or GUID has been corrupted. we can still try to look it up using map_uid. */ - rec = rebuild_lookup_map_uid(ctx, map_uid); - if (rec != NULL) { - mail_index_update_ext(trans, seq, - mbox->guid_ext_id, - rec->guid_128, NULL); - } + rec = map_uid == 0 ? NULL : + rebuild_lookup_map_uid(ctx, map_uid); } else if (map_uid != rec->map_uid) { - /* map_uid is wrong, update it */ - i_assert(rec->map_uid != 0); - new_dbox_rec.map_uid = rec->map_uid; - mail_index_update_ext(trans, seq, mbox->ext_id, - &new_dbox_rec, NULL); + /* message's GUID and map_uid point to different + physical messages. assume that GUID is correct and + map_uid is wrong. */ } else { /* everything was ok */ } if (rec != NULL) T_BEGIN { - /* keep this message */ + /* keep this message. add it to mailbox index. */ + i_assert(rec->map_uid != 0); rec->refcount++; - mail_index_lookup_uid(view, seq, &uid); + mail_index_lookup_uid(view, old_seq, &uid); mail_index_append(trans, uid, &new_seq); dbox_sync_rebuild_index_metadata(rebuild_ctx, new_seq, uid); From dovecot at dovecot.org Thu Feb 9 02:25:33 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:25:33 +0200 Subject: dovecot-2.1: mdbox: Small code cleanup to storage rebuild. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e4272971f86f changeset: 14086:e4272971f86f user: Timo Sirainen date: Thu Feb 09 02:25:18 2012 +0200 description: mdbox: Small code cleanup to storage rebuild. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 42 +++++++-------- 1 files changed, 20 insertions(+), 22 deletions(-) diffs (100 lines): diff -r 69bb267956a2 -r e4272971f86f src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:21:37 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:25:18 2012 +0200 @@ -304,6 +304,8 @@ unsigned int count; array_sort(&ctx->msgs, mdbox_rebuild_msg_offset_cmp); + /* msgs now contains a list of all messages that exists in m.* files, + sorted by file_id,offset */ msgs = array_get_modifiable(&ctx->msgs, &count); hdr = mail_index_get_header(ctx->atomic->sync_view); @@ -312,7 +314,8 @@ seq, &rec) < 0) return -1; - /* look up the rebuild msg record for this message */ + /* look up the rebuild msg record for this message based on + the (file_id, offset, size) triplet */ search_msg.file_id = rec.rec.file_id; search_msg.offset = rec.rec.offset; search_msg.size = rec.rec.size; @@ -323,6 +326,7 @@ a duplicate message. */ mail_index_expunge(ctx->atomic->sync_trans, seq); } else { + /* remember this message's map_uid */ (*pos)->map_uid = rec.map_uid; if (rec.refcount == 0) (*pos)->seen_zero_ref_in_map = TRUE; @@ -361,11 +365,14 @@ struct mdbox_rebuild_msg *rec; const void *data; bool expunged; - uint32_t seq, uid, new_seq, map_uid; + uint32_t old_seq, new_seq, uid, map_uid; + /* Rebuild the mailbox's index. Note that index is reset at this point, + so although we can still access the old messages, we'll need to + append anything we want to keep as new messages. */ hdr = mail_index_get_header(view); - for (seq = 1; seq <= hdr->messages_count; seq++) { - mail_index_lookup_ext(view, seq, mbox->ext_id, + for (old_seq = 1; old_seq <= hdr->messages_count; old_seq++) { + mail_index_lookup_ext(view, old_seq, mbox->ext_id, &data, &expunged); if (data == NULL) { memset(&new_dbox_rec, 0, sizeof(new_dbox_rec)); @@ -375,7 +382,7 @@ map_uid = new_dbox_rec.map_uid; } - mail_index_lookup_ext(view, seq, mbox->guid_ext_id, + mail_index_lookup_ext(view, old_seq, mbox->guid_ext_id, &data, &expunged); /* see if we can find this message based on @@ -383,34 +390,25 @@ rec = data == NULL ? NULL : hash_table_lookup(ctx->guid_hash, data); if (rec == NULL) { - if (map_uid == 0) { - /* not a multi-dbox message, ignore. */ - continue; - } /* multi-dbox message that wasn't found with GUID. either it's lost or GUID has been corrupted. we can still try to look it up using map_uid. */ - rec = rebuild_lookup_map_uid(ctx, map_uid); - if (rec != NULL) { - mail_index_update_ext(trans, seq, - mbox->guid_ext_id, - rec->guid_128, NULL); - } + rec = map_uid == 0 ? NULL : + rebuild_lookup_map_uid(ctx, map_uid); } else if (map_uid != rec->map_uid) { - /* map_uid is wrong, update it */ - i_assert(rec->map_uid != 0); - new_dbox_rec.map_uid = rec->map_uid; - mail_index_update_ext(trans, seq, mbox->ext_id, - &new_dbox_rec, NULL); + /* message's GUID and map_uid point to different + physical messages. assume that GUID is correct and + map_uid is wrong. */ } else { /* everything was ok */ } if (rec != NULL) T_BEGIN { - /* keep this message */ + /* keep this message. add it to mailbox index. */ + i_assert(rec->map_uid != 0); rec->refcount++; - mail_index_lookup_uid(view, seq, &uid); + mail_index_lookup_uid(view, old_seq, &uid); mail_index_append(trans, uid, &new_seq); dbox_sync_rebuild_index_metadata(rebuild_ctx, new_seq, uid); From dovecot at dovecot.org Thu Feb 9 02:34:31 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:34:31 +0200 Subject: dovecot-2.0: mdbox: Detect duplicate GUIDs for different message... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/4a0b7dec3a22 changeset: 13039:4a0b7dec3a22 user: Timo Sirainen date: Thu Feb 09 02:34:23 2012 +0200 description: mdbox: Detect duplicate GUIDs for different messages. Don't delete these duplicates. Only the message size is used for detecting if they are duplicates or not, but since this shouldn't normally happen anyway this is good enough. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diffs (35 lines): diff -r a2ac502ee05f -r 4a0b7dec3a22 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:25:18 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:34:23 2012 +0200 @@ -148,7 +148,7 @@ struct dbox_file *file, uint32_t file_id) { const char *guid; - struct mdbox_rebuild_msg *rec; + struct mdbox_rebuild_msg *rec, *old_rec; uoff_t offset, prev_offset; bool last, first, fixed = FALSE; int ret; @@ -201,12 +201,20 @@ i_assert(!mail_guid_128_is_empty(rec->guid_128)); array_append(&ctx->msgs, &rec, 1); - if (hash_table_lookup(ctx->guid_hash, rec->guid_128) != NULL) { + old_rec = hash_table_lookup(ctx->guid_hash, rec->guid_128); + if (old_rec == NULL) + hash_table_insert(ctx->guid_hash, rec->guid_128, rec); + else if (rec->size == old_rec->size) { /* duplicate. save this as a refcount=0 to map, so it will eventually be deleted. */ rec->seen_zero_ref_in_map = TRUE; } else { - hash_table_insert(ctx->guid_hash, rec->guid_128, rec); + /* duplicate GUID, but not a duplicate message. */ + i_error("mdbox %s: Duplicate GUID %s in " + "m.%u:%u and m.%u:%u", + ctx->storage->storage_dir, guid, + old_rec->file_id, old_rec->offset, + rec->file_id, rec->offset); } } if (ret < 0) From dovecot at dovecot.org Thu Feb 9 02:34:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:34:44 +0200 Subject: dovecot-2.1: mdbox: Detect duplicate GUIDs for different message... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/408350532a18 changeset: 14087:408350532a18 user: Timo Sirainen date: Thu Feb 09 02:34:23 2012 +0200 description: mdbox: Detect duplicate GUIDs for different messages. Don't delete these duplicates. Only the message size is used for detecting if they are duplicates or not, but since this shouldn't normally happen anyway this is good enough. diffstat: src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diffs (35 lines): diff -r e4272971f86f -r 408350532a18 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:25:18 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Feb 09 02:34:23 2012 +0200 @@ -127,7 +127,7 @@ struct dbox_file *file, uint32_t file_id) { const char *guid; - struct mdbox_rebuild_msg *rec; + struct mdbox_rebuild_msg *rec, *old_rec; uoff_t offset, prev_offset; bool last, first, fixed = FALSE; int ret; @@ -180,12 +180,20 @@ i_assert(!guid_128_is_empty(rec->guid_128)); array_append(&ctx->msgs, &rec, 1); - if (hash_table_lookup(ctx->guid_hash, rec->guid_128) != NULL) { + old_rec = hash_table_lookup(ctx->guid_hash, rec->guid_128); + if (old_rec == NULL) + hash_table_insert(ctx->guid_hash, rec->guid_128, rec); + else if (rec->size == old_rec->size) { /* duplicate. save this as a refcount=0 to map, so it will eventually be deleted. */ rec->seen_zero_ref_in_map = TRUE; } else { - hash_table_insert(ctx->guid_hash, rec->guid_128, rec); + /* duplicate GUID, but not a duplicate message. */ + i_error("mdbox %s: Duplicate GUID %s in " + "m.%u:%u and m.%u:%u", + ctx->storage->storage_dir, guid, + old_rec->file_id, old_rec->offset, + rec->file_id, rec->offset); } } if (ret < 0) From dovecot at dovecot.org Thu Feb 9 02:58:53 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 02:58:53 +0200 Subject: dovecot-2.1: mbox: Added mbox_md5 setting to select headers for ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2500de8f1f51 changeset: 14088:2500de8f1f51 user: Timo Sirainen date: Thu Feb 09 02:58:36 2012 +0200 description: mbox: Added mbox_md5 setting to select headers for MD5 generation. diffstat: doc/example-config/conf.d/10-mail.conf | 6 + src/lib-storage/index/mbox/Makefile.am | 3 +- src/lib-storage/index/mbox/mbox-md5-all.c | 40 +++++++++ src/lib-storage/index/mbox/mbox-md5-apop3d.c | 120 +++++++++++++++++++++++++++ src/lib-storage/index/mbox/mbox-md5.c | 114 ------------------------- src/lib-storage/index/mbox/mbox-md5.h | 17 ++- src/lib-storage/index/mbox/mbox-save.c | 8 +- src/lib-storage/index/mbox/mbox-settings.c | 4 +- src/lib-storage/index/mbox/mbox-settings.h | 1 + src/lib-storage/index/mbox/mbox-storage.c | 9 ++ src/lib-storage/index/mbox/mbox-storage.h | 3 + src/lib-storage/index/mbox/mbox-sync-parse.c | 12 +- 12 files changed, 206 insertions(+), 131 deletions(-) diffs (truncated from 500 to 300 lines): diff -r 408350532a18 -r 2500de8f1f51 doc/example-config/conf.d/10-mail.conf --- a/doc/example-config/conf.d/10-mail.conf Thu Feb 09 02:34:23 2012 +0200 +++ b/doc/example-config/conf.d/10-mail.conf Thu Feb 09 02:58:36 2012 +0200 @@ -305,6 +305,12 @@ # If an index file already exists it's still read, just not updated. #mbox_min_index_size = 0 +# Mail header selection algorithm to use for MD5 POP3 UIDLs when +# pop3_uidl_format=%m. For backwards compatibility we use apop3d inspired +# algorithm, but it fails if the first Received: header isn't unique in all +# mails. An alternative algorithm is "all" that selects all headers. +#mbox_md5 = apop3d + ## ## mdbox-specific settings ## diff -r 408350532a18 -r 2500de8f1f51 src/lib-storage/index/mbox/Makefile.am --- a/src/lib-storage/index/mbox/Makefile.am Thu Feb 09 02:34:23 2012 +0200 +++ b/src/lib-storage/index/mbox/Makefile.am Thu Feb 09 02:58:36 2012 +0200 @@ -15,7 +15,8 @@ mbox-file.c \ mbox-lock.c \ mbox-mail.c \ - mbox-md5.c \ + mbox-md5-apop3d.c \ + mbox-md5-all.c \ mbox-save.c \ mbox-settings.c \ mbox-sync-parse.c \ diff -r 408350532a18 -r 2500de8f1f51 src/lib-storage/index/mbox/mbox-md5-all.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/index/mbox/mbox-md5-all.c Thu Feb 09 02:58:36 2012 +0200 @@ -0,0 +1,40 @@ +/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "md5.h" +#include "message-parser.h" +#include "mbox-md5.h" + +#include + +struct mbox_md5_context { + struct md5_context hdr_md5_ctx; +}; + +static struct mbox_md5_context *mbox_md5_all_init(void) +{ + struct mbox_md5_context *ctx; + + ctx = i_new(struct mbox_md5_context, 1); + md5_init(&ctx->hdr_md5_ctx); + return ctx; +} + +static void mbox_md5_all_more(struct mbox_md5_context *ctx, + struct message_header_line *hdr) +{ + md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); +} + +static void mbox_md5_all_finish(struct mbox_md5_context *ctx, + unsigned char result[16]) +{ + md5_final(&ctx->hdr_md5_ctx, result); + i_free(ctx); +} + +struct mbox_md5_vfuncs mbox_md5_all = { + mbox_md5_all_init, + mbox_md5_all_more, + mbox_md5_all_finish +}; diff -r 408350532a18 -r 2500de8f1f51 src/lib-storage/index/mbox/mbox-md5-apop3d.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/index/mbox/mbox-md5-apop3d.c Thu Feb 09 02:58:36 2012 +0200 @@ -0,0 +1,120 @@ +/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "md5.h" +#include "message-parser.h" +#include "mbox-md5.h" + +#include + +struct mbox_md5_context { + struct md5_context hdr_md5_ctx; + bool seen_received_hdr; +}; + +struct mbox_md5_header_func { + const char *header; + bool (*func)(struct mbox_md5_context *ctx, + struct message_header_line *hdr); +}; + +static bool parse_date(struct mbox_md5_context *ctx, + struct message_header_line *hdr) +{ + if (!ctx->seen_received_hdr) { + /* Received-header contains date too, and more trusted one */ + md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); + } + return TRUE; +} + +static bool parse_delivered_to(struct mbox_md5_context *ctx, + struct message_header_line *hdr) +{ + md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); + return TRUE; +} + +static bool parse_message_id(struct mbox_md5_context *ctx, + struct message_header_line *hdr) +{ + if (!ctx->seen_received_hdr) { + /* Received-header contains unique ID too, + and more trusted one */ + md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); + } + return TRUE; +} + +static bool parse_received(struct mbox_md5_context *ctx, + struct message_header_line *hdr) +{ + if (!ctx->seen_received_hdr) { + /* get only the first received-header */ + md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); + if (!hdr->continues) + ctx->seen_received_hdr = TRUE; + } + return TRUE; +} + +static bool parse_x_delivery_id(struct mbox_md5_context *ctx, + struct message_header_line *hdr) +{ + /* Let the local delivery agent help generate unique ID's but don't + blindly trust this header alone as it could just as easily come from + the remote. */ + md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); + return TRUE; +} + + +static struct mbox_md5_header_func md5_header_funcs[] = { + { "Date", parse_date }, + { "Delivered-To", parse_delivered_to }, + { "Message-ID", parse_message_id }, + { "Received", parse_received }, + { "X-Delivery-ID", parse_x_delivery_id } +}; + +static int bsearch_header_func_cmp(const void *p1, const void *p2) +{ + const char *key = p1; + const struct mbox_md5_header_func *func = p2; + + return strcasecmp(key, func->header); +} + +static struct mbox_md5_context *mbox_md5_apop3d_init(void) +{ + struct mbox_md5_context *ctx; + + ctx = i_new(struct mbox_md5_context, 1); + md5_init(&ctx->hdr_md5_ctx); + return ctx; +} + +static void mbox_md5_apop3d_more(struct mbox_md5_context *ctx, + struct message_header_line *hdr) +{ + struct mbox_md5_header_func *func; + + func = bsearch(hdr->name, md5_header_funcs, + N_ELEMENTS(md5_header_funcs), sizeof(*md5_header_funcs), + bsearch_header_func_cmp); + if (func != NULL) + (void)func->func(ctx, hdr); +} + +static void mbox_md5_apop3d_finish(struct mbox_md5_context *ctx, + unsigned char result[16]) +{ + md5_final(&ctx->hdr_md5_ctx, result); + i_free(ctx); +} + +struct mbox_md5_vfuncs mbox_md5_apop3d = { + mbox_md5_apop3d_init, + mbox_md5_apop3d_more, + mbox_md5_apop3d_finish +}; diff -r 408350532a18 -r 2500de8f1f51 src/lib-storage/index/mbox/mbox-md5.c --- a/src/lib-storage/index/mbox/mbox-md5.c Thu Feb 09 02:34:23 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */ - -#include "lib.h" -#include "md5.h" -#include "message-parser.h" -#include "mbox-md5.h" - -#include - -struct mbox_md5_context { - struct md5_context hdr_md5_ctx; - bool seen_received_hdr; -}; - -struct mbox_md5_header_func { - const char *header; - bool (*func)(struct mbox_md5_context *ctx, - struct message_header_line *hdr); -}; - -static bool parse_date(struct mbox_md5_context *ctx, - struct message_header_line *hdr) -{ - if (!ctx->seen_received_hdr) { - /* Received-header contains date too, and more trusted one */ - md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); - } - return TRUE; -} - -static bool parse_delivered_to(struct mbox_md5_context *ctx, - struct message_header_line *hdr) -{ - md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); - return TRUE; -} - -static bool parse_message_id(struct mbox_md5_context *ctx, - struct message_header_line *hdr) -{ - if (!ctx->seen_received_hdr) { - /* Received-header contains unique ID too, - and more trusted one */ - md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); - } - return TRUE; -} - -static bool parse_received(struct mbox_md5_context *ctx, - struct message_header_line *hdr) -{ - if (!ctx->seen_received_hdr) { - /* get only the first received-header */ - md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); - if (!hdr->continues) - ctx->seen_received_hdr = TRUE; - } - return TRUE; -} - -static bool parse_x_delivery_id(struct mbox_md5_context *ctx, - struct message_header_line *hdr) -{ - /* Let the local delivery agent help generate unique ID's but don't - blindly trust this header alone as it could just as easily come from - the remote. */ - md5_update(&ctx->hdr_md5_ctx, hdr->value, hdr->value_len); - return TRUE; -} - - -static struct mbox_md5_header_func md5_header_funcs[] = { - { "Date", parse_date }, - { "Delivered-To", parse_delivered_to }, - { "Message-ID", parse_message_id }, - { "Received", parse_received }, - { "X-Delivery-ID", parse_x_delivery_id } -}; - -static int bsearch_header_func_cmp(const void *p1, const void *p2) -{ - const char *key = p1; - const struct mbox_md5_header_func *func = p2; - - return strcasecmp(key, func->header); -} - -struct mbox_md5_context *mbox_md5_init(void) -{ - struct mbox_md5_context *ctx; - - ctx = i_new(struct mbox_md5_context, 1); - md5_init(&ctx->hdr_md5_ctx); - return ctx; -} - -void mbox_md5_continue(struct mbox_md5_context *ctx, - struct message_header_line *hdr) -{ From dovecot at dovecot.org Thu Feb 9 03:44:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 03:44:25 +0200 Subject: dovecot-2.1: mdbox: Fixed finding appendable m.* files in alt st... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6881d8c59d9f changeset: 14089:6881d8c59d9f user: Timo Sirainen date: Thu Feb 09 03:44:09 2012 +0200 description: mdbox: Fixed finding appendable m.* files in alt storage. diffstat: src/lib-storage/index/dbox-multi/mdbox-file.c | 11 ++++-- src/lib-storage/index/dbox-multi/mdbox-map.c | 47 +++++++------------------- 2 files changed, 20 insertions(+), 38 deletions(-) diffs (139 lines): diff -r 2500de8f1f51 -r 6881d8c59d9f src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Thu Feb 09 02:58:36 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Thu Feb 09 03:44:09 2012 +0200 @@ -84,7 +84,8 @@ } } -static void mdbox_file_init_paths(struct mdbox_file *file, const char *fname) +static void +mdbox_file_init_paths(struct mdbox_file *file, const char *fname, bool alt) { i_free(file->file.primary_path); i_free(file->file.alt_path); @@ -95,7 +96,8 @@ i_strdup_printf("%s/%s", file->storage->alt_storage_dir, fname); } - file->file.cur_path = file->file.primary_path; + file->file.cur_path = !alt ? file->file.primary_path : + file->file.alt_path; } static int mdbox_file_create(struct mdbox_file *file) @@ -159,7 +161,7 @@ file->file_id = file_id; fname = file_id == 0 ? dbox_generate_tmp_filename() : t_strdup_printf(MDBOX_MAIL_FILE_FORMAT, file_id); - mdbox_file_init_paths(file, fname); + mdbox_file_init_paths(file, fname, FALSE); dbox_file_init(&file->file); if (alt_dir) file->file.cur_path = file->file.alt_path; @@ -210,7 +212,8 @@ old_path, new_path); return -1; } - mdbox_file_init_paths(file, new_fname); + mdbox_file_init_paths(file, new_fname, + dbox_file_is_in_alt(&file->file)); file->file_id = file_id; array_append(&file->storage->open_files, &file, 1); return 0; diff -r 2500de8f1f51 -r 6881d8c59d9f src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Thu Feb 09 02:58:36 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Thu Feb 09 03:44:09 2012 +0200 @@ -937,22 +937,21 @@ } static int -mdbox_map_find_first_alt(struct mdbox_map_append_context *ctx, - uint32_t *min_file_id_r, uint32_t *seq_r) +mdbox_map_find_primary_files(struct mdbox_map_append_context *ctx, + ARRAY_TYPE(seq_range) *file_ids_r) { struct mdbox_storage *dstorage = ctx->map->storage; struct mail_storage *storage = &dstorage->storage.storage; DIR *dir; struct dirent *d; - const struct mail_index_header *hdr; - const struct mdbox_map_mail_index_record *rec; - uint32_t seq, file_id, min_file_id = -1U; + uint32_t file_id; int ret = 0; /* we want to quickly find the latest alt file, but we also want to - avoid accessing the alt storage as much as possible. so we'll do - this by finding the lowest numbered file (n) from primary storage. - hopefully one of n-[1..m] is appendable in alt storage. */ + avoid accessing the alt storage as much as possible. typically most + of the older mails would be in alt storage, so we'll just put the + few m.* files in primary storage to checked_file_ids array. other + files are then known to exist in alt storage. */ dir = opendir(dstorage->storage_dir); if (dir == NULL) { mail_storage_set_critical(storage, @@ -968,8 +967,7 @@ &file_id) < 0) continue; - if (min_file_id > file_id) - min_file_id = file_id; + seq_range_array_add(file_ids_r, 0, file_id); } if (errno != 0) { mail_storage_set_critical(storage, @@ -981,22 +979,7 @@ "closedir(%s) failed: %m", dstorage->storage_dir); ret = -1; } - if (ret < 0) - return -1; - - /* find the newest message in alt storage from map view */ - hdr = mail_index_get_header(ctx->map->view); - for (seq = hdr->messages_count; seq > 0; seq--) { - if (mdbox_map_lookup_seq(ctx->map, seq, &rec) < 0) - return -1; - - if (rec->file_id < min_file_id) - break; - } - - *min_file_id_r = min_file_id; - *seq_r = seq; - return 0; + return ret; } static int @@ -1010,7 +993,7 @@ const struct mail_index_header *hdr; const struct mdbox_map_mail_index_record *rec; unsigned int backwards_lookup_count; - uint32_t seq, seq1, uid, min_file_id; + uint32_t seq, seq1, uid; time_t stamp; bool retry_later; @@ -1024,17 +1007,13 @@ backwards_lookup_count = 0; t_array_init(&checked_file_ids, 16); - if (!want_altpath) - seq = hdr->messages_count; - else { + if (want_altpath) { /* we want to save to alt storage. */ - if (mdbox_map_find_first_alt(ctx, &min_file_id, &seq) < 0) + if (mdbox_map_find_primary_files(ctx, &checked_file_ids) < 0) return -1; - seq_range_array_add_range(&checked_file_ids, - min_file_id, (uint32_t)-1); } - for (; seq > 0; seq--) { + for (seq = hdr->messages_count; seq > 0; seq--) { if (mdbox_map_lookup_seq(map, seq, &rec) < 0) return -1; From dovecot at dovecot.org Thu Feb 9 03:44:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 03:44:29 +0200 Subject: dovecot-2.0: mdbox: Fixed finding appendable m.* files in alt st... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/d83356f1fce6 changeset: 13040:d83356f1fce6 user: Timo Sirainen date: Thu Feb 09 03:44:09 2012 +0200 description: mdbox: Fixed finding appendable m.* files in alt storage. diffstat: src/lib-storage/index/dbox-multi/mdbox-file.c | 11 ++++-- src/lib-storage/index/dbox-multi/mdbox-map.c | 47 +++++++------------------- 2 files changed, 20 insertions(+), 38 deletions(-) diffs (139 lines): diff -r 4a0b7dec3a22 -r d83356f1fce6 src/lib-storage/index/dbox-multi/mdbox-file.c --- a/src/lib-storage/index/dbox-multi/mdbox-file.c Thu Feb 09 02:34:23 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c Thu Feb 09 03:44:09 2012 +0200 @@ -84,7 +84,8 @@ } } -static void mdbox_file_init_paths(struct mdbox_file *file, const char *fname) +static void +mdbox_file_init_paths(struct mdbox_file *file, const char *fname, bool alt) { i_free(file->file.primary_path); i_free(file->file.alt_path); @@ -95,7 +96,8 @@ i_strdup_printf("%s/%s", file->storage->alt_storage_dir, fname); } - file->file.cur_path = file->file.primary_path; + file->file.cur_path = !alt ? file->file.primary_path : + file->file.alt_path; } static int mdbox_file_create(struct mdbox_file *file) @@ -159,7 +161,7 @@ file->file_id = file_id; fname = file_id == 0 ? dbox_generate_tmp_filename() : t_strdup_printf(MDBOX_MAIL_FILE_FORMAT, file_id); - mdbox_file_init_paths(file, fname); + mdbox_file_init_paths(file, fname, FALSE); dbox_file_init(&file->file); if (alt_dir) file->file.cur_path = file->file.alt_path; @@ -210,7 +212,8 @@ old_path, new_path); return -1; } - mdbox_file_init_paths(file, new_fname); + mdbox_file_init_paths(file, new_fname, + dbox_file_is_in_alt(&file->file)); file->file_id = file_id; array_append(&file->storage->open_files, &file, 1); return 0; diff -r 4a0b7dec3a22 -r d83356f1fce6 src/lib-storage/index/dbox-multi/mdbox-map.c --- a/src/lib-storage/index/dbox-multi/mdbox-map.c Thu Feb 09 02:34:23 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Thu Feb 09 03:44:09 2012 +0200 @@ -893,22 +893,21 @@ } static int -mdbox_map_find_first_alt(struct mdbox_map_append_context *ctx, - uint32_t *min_file_id_r, uint32_t *seq_r) +mdbox_map_find_primary_files(struct mdbox_map_append_context *ctx, + ARRAY_TYPE(seq_range) *file_ids_r) { struct mdbox_storage *dstorage = ctx->map->storage; struct mail_storage *storage = &dstorage->storage.storage; DIR *dir; struct dirent *d; - const struct mail_index_header *hdr; - const struct mdbox_map_mail_index_record *rec; - uint32_t seq, file_id, min_file_id = -1U; + uint32_t file_id; int ret = 0; /* we want to quickly find the latest alt file, but we also want to - avoid accessing the alt storage as much as possible. so we'll do - this by finding the lowest numbered file (n) from primary storage. - hopefully one of n-[1..m] is appendable in alt storage. */ + avoid accessing the alt storage as much as possible. typically most + of the older mails would be in alt storage, so we'll just put the + few m.* files in primary storage to checked_file_ids array. other + files are then known to exist in alt storage. */ dir = opendir(dstorage->storage_dir); if (dir == NULL) { mail_storage_set_critical(storage, @@ -924,8 +923,7 @@ &file_id) < 0) continue; - if (min_file_id > file_id) - min_file_id = file_id; + seq_range_array_add(file_ids_r, 0, file_id); } if (errno != 0) { mail_storage_set_critical(storage, @@ -937,22 +935,7 @@ "closedir(%s) failed: %m", dstorage->storage_dir); ret = -1; } - if (ret < 0) - return -1; - - /* find the newest message in alt storage from map view */ - hdr = mail_index_get_header(ctx->map->view); - for (seq = hdr->messages_count; seq > 0; seq--) { - if (mdbox_map_lookup_seq(ctx->map, seq, &rec) < 0) - return -1; - - if (rec->file_id < min_file_id) - break; - } - - *min_file_id_r = min_file_id; - *seq_r = seq; - return 0; + return ret; } static int @@ -966,7 +949,7 @@ const struct mail_index_header *hdr; const struct mdbox_map_mail_index_record *rec; unsigned int backwards_lookup_count; - uint32_t seq, seq1, uid, min_file_id; + uint32_t seq, seq1, uid; time_t stamp; bool retry_later; @@ -980,17 +963,13 @@ backwards_lookup_count = 0; t_array_init(&checked_file_ids, 16); - if (!want_altpath) - seq = hdr->messages_count; - else { + if (want_altpath) { /* we want to save to alt storage. */ - if (mdbox_map_find_first_alt(ctx, &min_file_id, &seq) < 0) + if (mdbox_map_find_primary_files(ctx, &checked_file_ids) < 0) return -1; - seq_range_array_add_range(&checked_file_ids, - min_file_id, (uint32_t)-1); } - for (; seq > 0; seq--) { + for (seq = hdr->messages_count; seq > 0; seq--) { if (mdbox_map_lookup_seq(map, seq, &rec) < 0) return -1; From dovecot at dovecot.org Thu Feb 9 03:57:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 03:57:05 +0200 Subject: dovecot-2.1: doveadm mailbox list without pattern shows now all ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b600af017598 changeset: 14090:b600af017598 user: Timo Sirainen date: Thu Feb 09 03:56:50 2012 +0200 description: doveadm mailbox list without pattern shows now all shared and public mailboxes also. doveadm mailbox list '*' shows only the one matching namespace. diffstat: src/doveadm/doveadm-mail-list-iter.c | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diffs (53 lines): diff -r 6881d8c59d9f -r b600af017598 src/doveadm/doveadm-mail-list-iter.c --- a/src/doveadm/doveadm-mail-list-iter.c Thu Feb 09 03:44:09 2012 +0200 +++ b/src/doveadm/doveadm-mail-list-iter.c Thu Feb 09 03:56:50 2012 +0200 @@ -55,15 +55,15 @@ return 1; } -struct doveadm_mail_list_iter * -doveadm_mail_list_iter_init(struct mail_user *user, - struct mail_search_args *search_args, - enum mailbox_list_iter_flags iter_flags) +static struct doveadm_mail_list_iter * +doveadm_mail_list_iter_init_nsmask(struct mail_user *user, + struct mail_search_args *search_args, + enum mailbox_list_iter_flags iter_flags, + enum namespace_type ns_mask) { static const char *all_pattern = "*"; struct doveadm_mail_list_iter *iter; ARRAY_TYPE(const_string) patterns; - enum namespace_type ns_mask = NAMESPACE_PRIVATE; bool have_guid = FALSE; iter = i_new(struct doveadm_mail_list_iter, 1); @@ -92,13 +92,27 @@ } struct doveadm_mail_list_iter * +doveadm_mail_list_iter_init(struct mail_user *user, + struct mail_search_args *search_args, + enum mailbox_list_iter_flags iter_flags) +{ + enum namespace_type ns_mask = NAMESPACE_PRIVATE; + + return doveadm_mail_list_iter_init_nsmask(user, search_args, + iter_flags, ns_mask); +} + +struct doveadm_mail_list_iter * doveadm_mail_list_iter_full_init(struct mail_user *user, struct mail_search_args *search_args, enum mailbox_list_iter_flags iter_flags) { + enum namespace_type ns_mask = + NAMESPACE_PRIVATE | NAMESPACE_SHARED | NAMESPACE_PUBLIC; struct doveadm_mail_list_iter *iter; - iter = doveadm_mail_list_iter_init(user, search_args, iter_flags); + iter = doveadm_mail_list_iter_init_nsmask(user, search_args, + iter_flags, ns_mask); iter->only_selectable = FALSE; return iter; } From dovecot at dovecot.org Thu Feb 9 04:13:41 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 04:13:41 +0200 Subject: dovecot-2.1: lib-storage: Trying to access shared mailboxes of n... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f2d5a1efdda2 changeset: 14091:f2d5a1efdda2 user: Timo Sirainen date: Thu Feb 09 04:13:28 2012 +0200 description: lib-storage: Trying to access shared mailboxes of nonexistent users crashed. This was broken by commit 18078d6cce84. diffstat: src/lib-storage/index/shared/shared-storage.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r b600af017598 -r f2d5a1efdda2 src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Thu Feb 09 03:56:50 2012 +0200 +++ b/src/lib-storage/index/shared/shared-storage.c Thu Feb 09 04:13:28 2012 +0200 @@ -46,6 +46,8 @@ storage->location = p_strdup(_storage->pool, ns->set->location); storage->unexpanded_location = p_strdup(_storage->pool, ns->unexpanded_set->location); + storage->storage_class_name = p_strdup(_storage->pool, driver); + storage_class = mail_storage_find_class(driver); if (storage_class != NULL) _storage->class_flags = storage_class->class_flags; From dovecot at dovecot.org Thu Feb 9 04:13:43 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 04:13:43 +0200 Subject: dovecot-2.0: lib-storage: Trying to access shared mailboxes of n... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/09f964850245 changeset: 13041:09f964850245 user: Timo Sirainen date: Thu Feb 09 04:13:28 2012 +0200 description: lib-storage: Trying to access shared mailboxes of nonexistent users crashed. This was broken by commit 18078d6cce84. diffstat: src/lib-storage/index/shared/shared-storage.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r d83356f1fce6 -r 09f964850245 src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Thu Feb 09 03:44:09 2012 +0200 +++ b/src/lib-storage/index/shared/shared-storage.c Thu Feb 09 04:13:28 2012 +0200 @@ -46,6 +46,8 @@ storage->location = p_strdup(_storage->pool, ns->set->location); storage->unexpanded_location = p_strdup(_storage->pool, ns->unexpanded_set->location); + storage->storage_class_name = p_strdup(_storage->pool, driver); + storage_class = mail_storage_find_class(driver); if (storage_class != NULL) _storage->class_flags = storage_class->class_flags; From dovecot at dovecot.org Thu Feb 9 04:26:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 04:26:49 +0200 Subject: dovecot-2.1: doveadm force-resync: Support wildcards in mailbox ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e004b6a89869 changeset: 14092:e004b6a89869 user: Timo Sirainen date: Thu Feb 09 04:26:12 2012 +0200 description: doveadm force-resync: Support wildcards in mailbox names. diffstat: src/doveadm/doveadm-mail.c | 81 +++++++++++++++++++++++++++------------------ 1 files changed, 49 insertions(+), 32 deletions(-) diffs (113 lines): diff -r f2d5a1efdda2 -r e004b6a89869 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Thu Feb 09 04:13:28 2012 +0200 +++ b/src/doveadm/doveadm-mail.c Thu Feb 09 04:26:12 2012 +0200 @@ -135,52 +135,69 @@ return sargs; } -struct force_resync_cmd_context { - struct doveadm_mail_cmd_context ctx; - const char *mailbox; -}; +static int cmd_force_resync_box(const struct mailbox_info *info) +{ + struct mailbox *box; + int ret = 0; + + box = mailbox_alloc(info->ns->list, info->name, + MAILBOX_FLAG_IGNORE_ACLS); + if (mailbox_open(box) < 0) { + i_error("Opening mailbox %s failed: %s", info->name, + mailbox_get_last_error(box, NULL)); + ret = -1; + } else if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FORCE_RESYNC | + MAILBOX_SYNC_FLAG_FIX_INCONSISTENT) < 0) { + i_error("Forcing a resync on mailbox %s failed: %s", + info->name, mailbox_get_last_error(box, NULL)); + ret = -1; + } + mailbox_free(&box); + return ret; +} static void cmd_force_resync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { - struct force_resync_cmd_context *ctx = - (struct force_resync_cmd_context *)_ctx; - struct mailbox *box; + const enum mailbox_list_iter_flags iter_flags = + MAILBOX_LIST_ITER_RAW_LIST | + MAILBOX_LIST_ITER_NO_AUTO_BOXES | + MAILBOX_LIST_ITER_RETURN_NO_FLAGS | + MAILBOX_LIST_ITER_STAR_WITHIN_NS; + const enum namespace_type ns_mask = + NAMESPACE_PRIVATE | NAMESPACE_SHARED | NAMESPACE_PUBLIC; + struct mailbox_list_iterate_context *iter; + const struct mailbox_info *info; - if (doveadm_mailbox_find_and_open(user, ctx->mailbox, &box) < 0) { - _ctx->failed = TRUE; - return; + iter = mailbox_list_iter_init_namespaces(user->namespaces, _ctx->args, + ns_mask, iter_flags); + while ((info = mailbox_list_iter_next(iter)) != NULL) { + if ((info->flags & (MAILBOX_NOSELECT | + MAILBOX_NONEXISTENT)) == 0) T_BEGIN { + if (cmd_force_resync_box(info) < 0) + _ctx->failed = TRUE; + } T_END; } - if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FORCE_RESYNC | - MAILBOX_SYNC_FLAG_FIX_INCONSISTENT) < 0) { - i_error("Forcing a resync on mailbox %s failed: %s", - ctx->mailbox, mailbox_get_last_error(box, NULL)); - _ctx->failed = TRUE; - } - mailbox_free(&box); + if (mailbox_list_iter_deinit(&iter) < 0) + i_error("Listing mailboxes failed"); } -static void cmd_force_resync_init(struct doveadm_mail_cmd_context *_ctx, - const char *const args[]) +static void +cmd_force_resync_init(struct doveadm_mail_cmd_context *_ctx ATTR_UNUSED, + const char *const args[]) { - struct force_resync_cmd_context *ctx = - (struct force_resync_cmd_context *)_ctx; - const char *mailbox = args[0]; - - if (mailbox == NULL || args[1] != NULL) + if (args[0] == NULL) doveadm_mail_help_name("force-resync"); - - ctx->mailbox = p_strdup(ctx->ctx.pool, mailbox); } static struct doveadm_mail_cmd_context *cmd_force_resync_alloc(void) { - struct force_resync_cmd_context *ctx; + struct doveadm_mail_cmd_context *ctx; - ctx = doveadm_mail_cmd_alloc(struct force_resync_cmd_context); - ctx->ctx.v.init = cmd_force_resync_init; - ctx->ctx.v.run = cmd_force_resync_run; - return &ctx->ctx; + ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); + ctx->v.init = cmd_force_resync_init; + ctx->v.run = cmd_force_resync_run; + return ctx; } static int @@ -565,7 +582,7 @@ } static struct doveadm_mail_cmd cmd_force_resync = { - cmd_force_resync_alloc, "force-resync", "" + cmd_force_resync_alloc, "force-resync", "" }; static struct doveadm_mail_cmd cmd_purge = { cmd_purge_alloc, "purge", NULL From dovecot at dovecot.org Thu Feb 9 04:26:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 04:26:49 +0200 Subject: dovecot-2.1: doveadm index: Changed help text to make it clear t... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4ced8d2b4a3b changeset: 14093:4ced8d2b4a3b user: Timo Sirainen date: Thu Feb 09 04:26:39 2012 +0200 description: doveadm index: Changed help text to make it clear that mailbox can have wildcards. diffstat: src/doveadm/doveadm-mail-index.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (10 lines): diff -r e004b6a89869 -r 4ced8d2b4a3b src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Thu Feb 09 04:26:12 2012 +0200 +++ b/src/doveadm/doveadm-mail-index.c Thu Feb 09 04:26:39 2012 +0200 @@ -248,5 +248,5 @@ } struct doveadm_mail_cmd cmd_index = { - cmd_index_alloc, "index", "[-q] [-n ] " + cmd_index_alloc, "index", "[-q] [-n ] " }; From dovecot at dovecot.org Thu Feb 9 04:27:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 04:27:49 +0200 Subject: dovecot-2.0: doveadm index: Changed help text to make it clear t... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/77a45b0c9f68 changeset: 13042:77a45b0c9f68 user: Timo Sirainen date: Thu Feb 09 04:27:44 2012 +0200 description: doveadm index: Changed help text to make it clear that mailbox can have wildcards. diffstat: src/doveadm/doveadm-mail-index.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (10 lines): diff -r 09f964850245 -r 77a45b0c9f68 src/doveadm/doveadm-mail-index.c --- a/src/doveadm/doveadm-mail-index.c Thu Feb 09 04:13:28 2012 +0200 +++ b/src/doveadm/doveadm-mail-index.c Thu Feb 09 04:27:44 2012 +0200 @@ -72,5 +72,5 @@ } struct doveadm_mail_cmd cmd_index = { - cmd_index_alloc, "index", "" + cmd_index_alloc, "index", "" }; From dovecot at dovecot.org Thu Feb 9 05:00:59 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:00:59 +0200 Subject: dovecot-2.0: imap: Fixed potential out of bounds read. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/d406e376f8ee changeset: 13043:d406e376f8ee user: Timo Sirainen date: Thu Feb 09 05:00:49 2012 +0200 description: imap: Fixed potential out of bounds read. Found by Christoph Bussenius. diffstat: src/imap/imap-commands-util.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 77a45b0c9f68 -r d406e376f8ee src/imap/imap-commands-util.c --- a/src/imap/imap-commands-util.c Thu Feb 09 04:27:44 2012 +0200 +++ b/src/imap/imap-commands-util.c Thu Feb 09 05:00:49 2012 +0200 @@ -81,8 +81,8 @@ } /* make sure two hierarchy separators aren't next to each others */ - for (p = storage_name+1; *p != '\0'; p++) { - if (p[0] == ns->real_sep && p[-1] == ns->real_sep) { + for (p = storage_name; *p != '\0'; p++) { + if (p[0] == ns->real_sep && p[1] == ns->real_sep) { client_send_tagline(cmd, "NO Invalid mailbox name."); return NULL; } From dovecot at dovecot.org Thu Feb 9 05:04:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:04:47 +0200 Subject: dovecot-2.1: acl: Avoid assert-crashing when trying to access in... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/95a9428fe68b changeset: 14094:95a9428fe68b user: Timo Sirainen date: Thu Feb 09 05:04:42 2012 +0200 description: acl: Avoid assert-crashing when trying to access invalid mailbox names. diffstat: src/plugins/acl/acl-backend-vfile.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (20 lines): diff -r 4ced8d2b4a3b -r 95a9428fe68b src/plugins/acl/acl-backend-vfile.c --- a/src/plugins/acl/acl-backend-vfile.c Thu Feb 09 04:26:39 2012 +0200 +++ b/src/plugins/acl/acl-backend-vfile.c Thu Feb 09 05:04:42 2012 +0200 @@ -128,13 +128,14 @@ static const char * acl_backend_vfile_get_local_dir(struct acl_backend *backend, const char *name) { - struct mail_namespace *ns; + struct mail_namespace *ns = mailbox_list_get_namespace(backend->list); const char *dir, *inbox; if (*name == '\0') name = NULL; + else if (!mailbox_list_is_valid_existing_name(ns->list, name)) + return NULL; - ns = mailbox_list_get_namespace(backend->list); if (mail_storage_is_mailbox_file(ns->storage)) { dir = mailbox_list_get_path(ns->list, name, MAILBOX_LIST_PATH_TYPE_CONTROL); From dovecot at dovecot.org Thu Feb 9 05:08:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:08:05 +0200 Subject: dovecot-2.1: INSTALL: Updated outdated documentation. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5ea2e9b93fe3 changeset: 14095:5ea2e9b93fe3 user: Timo Sirainen date: Thu Feb 09 05:07:57 2012 +0200 description: INSTALL: Updated outdated documentation. diffstat: INSTALL | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-) diffs (25 lines): diff -r 95a9428fe68b -r 5ea2e9b93fe3 INSTALL --- a/INSTALL Thu Feb 09 05:04:42 2012 +0200 +++ b/INSTALL Thu Feb 09 05:07:57 2012 +0200 @@ -21,18 +21,13 @@ Running ------- -Rename configuration file: +Start with the example configuration: - mv /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf + cp -r /usr/local/share/doc/dovecot/example-config/* /usr/local/etc/dovecot/ Read through, and make needed modifications. -Once everything is configured, there's two ways to start Dovecot: - - 1) Run "dovecot" binary which does everything. - - 2) Start it via inetd or similiar by executing "imap-login" or "pop3-login" - binaries. If you're listening in SSL port, add --ssl parameter. +Once everything is configured, start Dovecot by running "dovecot" binary. See Wiki for more information about configuration. If you're in a hurry, go at least through http://wiki2.dovecot.org/QuickConfiguration From dovecot at dovecot.org Thu Feb 9 05:08:12 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:08:12 +0200 Subject: dovecot-2.0: INSTALL: Updated outdated documentation. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/77fb3606fb2b changeset: 13044:77fb3606fb2b user: Timo Sirainen date: Thu Feb 09 05:07:57 2012 +0200 description: INSTALL: Updated outdated documentation. diffstat: INSTALL | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-) diffs (25 lines): diff -r d406e376f8ee -r 77fb3606fb2b INSTALL --- a/INSTALL Thu Feb 09 05:00:49 2012 +0200 +++ b/INSTALL Thu Feb 09 05:07:57 2012 +0200 @@ -21,18 +21,13 @@ Running ------- -Rename configuration file: +Start with the example configuration: - mv /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf + cp -r /usr/local/share/doc/dovecot/example-config/* /usr/local/etc/dovecot/ Read through, and make needed modifications. -Once everything is configured, there's two ways to start Dovecot: - - 1) Run "dovecot" binary which does everything. - - 2) Start it via inetd or similiar by executing "imap-login" or "pop3-login" - binaries. If you're listening in SSL port, add --ssl parameter. +Once everything is configured, start Dovecot by running "dovecot" binary. See Wiki for more information about configuration. If you're in a hurry, go at least through http://wiki2.dovecot.org/QuickConfiguration From dovecot at dovecot.org Thu Feb 9 05:17:10 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:17:10 +0200 Subject: dovecot-2.1: lib-master no longer uses 's' option, but it wasn't... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/dd4626a996b6 changeset: 14096:dd4626a996b6 user: Timo Sirainen date: Thu Feb 09 05:16:59 2012 +0200 description: lib-master no longer uses 's' option, but it wasn't removed from getopt string. diffstat: src/lib-master/master-service.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 5ea2e9b93fe3 -r dd4626a996b6 src/lib-master/master-service.c --- a/src/lib-master/master-service.c Thu Feb 09 05:07:57 2012 +0200 +++ b/src/lib-master/master-service.c Thu Feb 09 05:16:59 2012 +0200 @@ -47,7 +47,7 @@ const char *master_service_getopt_string(void) { - return "c:i:ko:Os:L"; + return "c:i:ko:OL"; } static void sig_die(const siginfo_t *si, void *context) From dovecot at dovecot.org Thu Feb 9 05:17:54 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:17:54 +0200 Subject: dovecot-2.0: lib-master no longer uses 's' option, but it wasn't... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/750db4b4c7d3 changeset: 13045:750db4b4c7d3 user: Timo Sirainen date: Thu Feb 09 05:17:48 2012 +0200 description: lib-master no longer uses 's' option, but it wasn't removed from getopt string. diffstat: src/lib-master/master-service.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 77fb3606fb2b -r 750db4b4c7d3 src/lib-master/master-service.c --- a/src/lib-master/master-service.c Thu Feb 09 05:07:57 2012 +0200 +++ b/src/lib-master/master-service.c Thu Feb 09 05:17:48 2012 +0200 @@ -44,7 +44,7 @@ const char *master_service_getopt_string(void) { - return "c:ko:Os:L"; + return "c:ko:OL"; } static void sig_die(const siginfo_t *si, void *context) From dovecot at dovecot.org Thu Feb 9 05:21:29 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:21:29 +0200 Subject: dovecot-2.1: doveadm proxy list: Avoid hanging if we can't conne... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f2b7e8d8dcb3 changeset: 14097:f2b7e8d8dcb3 user: Timo Sirainen date: Thu Feb 09 05:21:22 2012 +0200 description: doveadm proxy list: Avoid hanging if we can't connect to ipc socket. diffstat: src/doveadm/doveadm-proxy.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (16 lines): diff -r dd4626a996b6 -r f2b7e8d8dcb3 src/doveadm/doveadm-proxy.c --- a/src/doveadm/doveadm-proxy.c Thu Feb 09 05:16:59 2012 +0200 +++ b/src/doveadm/doveadm-proxy.c Thu Feb 09 05:21:22 2012 +0200 @@ -74,9 +74,11 @@ doveadm_print_header("dest-ip", "dest ip", 0); doveadm_print_header("dest-port", "port", 0); + io_loop_set_running(current_ioloop); ipc_client_cmd(ctx->ipc, "proxy\t*\tLIST", cmd_proxy_list_callback, NULL); - io_loop_run(current_ioloop); + if (io_loop_is_running(current_ioloop)) + io_loop_run(current_ioloop); ipc_client_deinit(&ctx->ipc); } From dovecot at dovecot.org Thu Feb 9 05:25:21 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:25:21 +0200 Subject: dovecot-2.1: doveadm pw: Improved error messages. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/75d6cd91fabe changeset: 14098:75d6cd91fabe user: Timo Sirainen date: Thu Feb 09 05:25:17 2012 +0200 description: doveadm pw: Improved error messages. diffstat: src/doveadm/doveadm-pw.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (21 lines): diff -r f2b7e8d8dcb3 -r 75d6cd91fabe src/doveadm/doveadm-pw.c --- a/src/doveadm/doveadm-pw.c Thu Feb 09 05:21:22 2012 +0200 +++ b/src/doveadm/doveadm-pw.c Thu Feb 09 05:25:17 2012 +0200 @@ -97,14 +97,15 @@ if (password_decode(hash, scheme, &raw_password, &size, &error) <= 0) { - fprintf(stderr, "reverse decode check failed\n"); + fprintf(stderr, "reverse decode check failed: %s\n", + error); exit(2); } if (password_verify(plaintext, user, scheme, raw_password, size, &error) != 1) { fprintf(stderr, - "reverse password verification check failed\n"); + "reverse password verification check failed: %s\n", error); exit(2); } From dovecot at dovecot.org Thu Feb 9 05:27:37 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:27:37 +0200 Subject: dovecot-2.1: doveadm pw: Minor code cleanups. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/12579e53f575 changeset: 14099:12579e53f575 user: Timo Sirainen date: Thu Feb 09 05:27:32 2012 +0200 description: doveadm pw: Minor code cleanups. diffstat: src/doveadm/doveadm-pw.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diffs (63 lines): diff -r 75d6cd91fabe -r 12579e53f575 src/doveadm/doveadm-pw.c --- a/src/doveadm/doveadm-pw.c Thu Feb 09 05:25:17 2012 +0200 +++ b/src/doveadm/doveadm-pw.c Thu Feb 09 05:27:32 2012 +0200 @@ -21,16 +21,17 @@ const char *user = NULL; const char *scheme = NULL; const char *plaintext = NULL; - int ch, lflag = 0, Vflag = 0; + bool list_schemes = FALSE, reverse_verify = FALSE; unsigned int rounds = 0; + int c; random_init(); password_schemes_init(); - while ((ch = getopt(argc, argv, "lp:r:s:u:V")) != -1) { - switch (ch) { + while ((c = getopt(argc, argv, "lp:r:s:u:V")) > 0) { + switch (c) { case 'l': - lflag = 1; + list_schemes = 1; break; case 'p': plaintext = optarg; @@ -46,7 +47,7 @@ user = optarg; break; case 'V': - Vflag = 1; + reverse_verify = TRUE; break; case '?': default: @@ -54,7 +55,7 @@ } } - if (lflag) { + if (list_schemes) { const struct password_scheme *const *schemes; unsigned int i, count; @@ -90,7 +91,7 @@ fprintf(stderr, "Unknown scheme: %s\n", scheme); exit(1); } - if (Vflag == 1) { + if (reverse_verify) { const unsigned char *raw_password; size_t size; const char *error; @@ -110,8 +111,9 @@ } printf("{%s}%s (verified)\n", scheme, hash); - } else + } else { printf("{%s}%s\n", scheme, hash); + } password_schemes_deinit(); random_deinit(); From dovecot at dovecot.org Thu Feb 9 05:34:01 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 05:34:01 +0200 Subject: dovecot-2.1: auth: password_verify() now returns error string al... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/aea4151da8f6 changeset: 14100:aea4151da8f6 user: Timo Sirainen date: Thu Feb 09 05:33:54 2012 +0200 description: auth: password_verify() now returns error string also for password mismatches. diffstat: src/auth/password-scheme.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diffs (39 lines): diff -r 12579e53f575 -r aea4151da8f6 src/auth/password-scheme.c --- a/src/auth/password-scheme.c Thu Feb 09 05:27:32 2012 +0200 +++ b/src/auth/password-scheme.c Thu Feb 09 05:33:54 2012 +0200 @@ -81,6 +81,7 @@ enum password_encoding encoding; const unsigned char *generated; size_t generated_size; + int ret; s = password_scheme_lookup(scheme, &encoding); if (s == NULL) { @@ -89,15 +90,20 @@ } if (s->password_verify != NULL) { - return s->password_verify(plaintext, user, raw_password, size, - error_r); + ret = s->password_verify(plaintext, user, raw_password, size, + error_r); + } else { + /* generic verification handler: generate the password and + compare it to the one in database */ + s->password_generate(plaintext, user, + &generated, &generated_size); + ret = size != generated_size ? 0 : + memcmp(generated, raw_password, size) == 0 ? 1 : 0; } - /* generic verification handler: generate the password and compare it - to the one in database */ - s->password_generate(plaintext, user, &generated, &generated_size); - return size != generated_size ? 0 : - memcmp(generated, raw_password, size) == 0 ? 1 : 0; + if (ret == 0) + *error_r = "Password mismatch"; + return ret; } const char *password_get_scheme(const char **password) From dovecot at dovecot.org Thu Feb 9 16:28:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 16:28:05 +0200 Subject: dovecot-2.1: imap: Handle invalid APPEND parameters a little nicer. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/665bb4bc72ca changeset: 14102:665bb4bc72ca user: Timo Sirainen date: Thu Feb 09 16:27:54 2012 +0200 description: imap: Handle invalid APPEND parameters a little nicer. diffstat: src/imap/cmd-append.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 671b637e20db -r 665bb4bc72ca src/imap/cmd-append.c --- a/src/imap/cmd-append.c Thu Feb 09 15:53:18 2012 +0200 +++ b/src/imap/cmd-append.c Thu Feb 09 16:27:54 2012 +0200 @@ -312,6 +312,7 @@ if (!validate_args(args, &flags_list, &internal_date_str, &ctx->msg_size, &nonsync)) { client_send_command_error(cmd, "Invalid arguments."); + client->input_skip_line = TRUE; return cmd_append_cancel(ctx, nonsync); } From dovecot at dovecot.org Thu Feb 9 16:28:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 16:28:05 +0200 Subject: dovecot-2.1: configure: Avoid some unnecessary warnings with clang. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/671b637e20db changeset: 14101:671b637e20db user: Timo Sirainen date: Thu Feb 09 15:53:18 2012 +0200 description: configure: Avoid some unnecessary warnings with clang. diffstat: configure.in | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diffs (38 lines): diff -r aea4151da8f6 -r 671b637e20db configure.in --- a/configure.in Thu Feb 09 05:33:54 2012 +0200 +++ b/configure.in Thu Feb 09 15:53:18 2012 +0200 @@ -294,6 +294,12 @@ xfs/xqm.h execinfo.h ucontext.h malloc_np.h sys/utsname.h sys/vmount.h \ sys/utsname.h glob.h linux/falloc.h ucred.h) +dnl * clang check +have_clang=no +if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then + have_clang=yes +fi + dnl * gcc specific options if test "x$ac_cv_c_compiler_gnu" = "xyes"; then # -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings @@ -301,8 +307,10 @@ # -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast" - # This is simply to avoid warning when building strftime() wrappers.. - CFLAGS="$CFLAGS -fno-builtin-strftime" + if test "$have_clang" != "yes"; then + # This is simply to avoid warning when building strftime() wrappers.. + CFLAGS="$CFLAGS -fno-builtin-strftime" + fi AC_TRY_COMPILE([ #if __GNUC__ < 4 @@ -323,7 +331,7 @@ CFLAGS="$old_cflags" ]) fi -if $CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1; then +if test "$have_clang" = "yes"; then # clang specific options if test "$want_devel_checks" = "yes"; then CFLAGS="$CFLAGS -fcatch-undefined-behavior -ftrapv" From dovecot at dovecot.org Thu Feb 9 19:32:42 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 19:32:42 +0200 Subject: dovecot-2.1: snarf: Keep the mailbox locked during snarfing to a... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/28b73743c36f changeset: 14103:28b73743c36f user: Timo Sirainen date: Thu Feb 09 19:32:25 2012 +0200 description: snarf: Keep the mailbox locked during snarfing to avoid duplicates. diffstat: src/plugins/snarf/snarf-plugin.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (32 lines): diff -r 665bb4bc72ca -r 28b73743c36f src/plugins/snarf/snarf-plugin.c --- a/src/plugins/snarf/snarf-plugin.c Thu Feb 09 16:27:54 2012 +0200 +++ b/src/plugins/snarf/snarf-plugin.c Thu Feb 09 19:32:25 2012 +0200 @@ -38,7 +38,8 @@ enum mail_error error; int ret; - /* make sure the destination mailbox has been opened */ + /* make sure the destination mailbox has been opened. + note that this locks the mailbox. */ if (mailbox_open(destbox) < 0) return -1; @@ -103,6 +104,8 @@ struct snarf_mailbox *sbox = SNARF_CONTEXT(box); (void)snarf(sbox->snarf_box, box); + /* close the mailbox so that we don't have to keep it locked */ + (void)mailbox_close(sbox->snarf_box); return sbox->module_ctx.super.sync_init(box, flags); } @@ -160,7 +163,8 @@ sbox->module_ctx.super = *v; box->vlast = &sbox->module_ctx.super; - sbox->snarf_box = mailbox_alloc(snarf_list, snarf_name, 0); + sbox->snarf_box = mailbox_alloc(snarf_list, snarf_name, + MAILBOX_FLAG_KEEP_LOCKED); v->sync_init = snarf_sync_init; v->free = snarf_mailbox_free; From dovecot at dovecot.org Thu Feb 9 19:33:19 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 19:33:19 +0200 Subject: dovecot-2.0: snarf: Keep the mailbox locked during snarfing to a... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/76220f2b5966 changeset: 13046:76220f2b5966 user: Timo Sirainen date: Thu Feb 09 19:33:15 2012 +0200 description: snarf: Keep the mailbox locked during snarfing to avoid duplicates. diffstat: src/plugins/snarf/snarf-plugin.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diffs (32 lines): diff -r 750db4b4c7d3 -r 76220f2b5966 src/plugins/snarf/snarf-plugin.c --- a/src/plugins/snarf/snarf-plugin.c Thu Feb 09 05:17:48 2012 +0200 +++ b/src/plugins/snarf/snarf-plugin.c Thu Feb 09 19:33:15 2012 +0200 @@ -37,7 +37,8 @@ enum mail_error error; int ret; - /* make sure the destination mailbox has been opened */ + /* make sure the destination mailbox has been opened. + note that this locks the mailbox. */ if (mailbox_open(destbox) < 0) return -1; @@ -104,6 +105,8 @@ struct snarf_mailbox *sbox = SNARF_CONTEXT(box); (void)snarf(sbox->snarf_box, box); + /* close the mailbox so that we don't have to keep it locked */ + (void)mailbox_close(sbox->snarf_box); return sbox->module_ctx.super.sync_init(box, flags); } @@ -158,7 +161,8 @@ box->vlast = &sbox->module_ctx.super; sbox->snarf_box = mailbox_alloc(snarf_list, snarf_name, - MAILBOX_FLAG_KEEP_RECENT); + MAILBOX_FLAG_KEEP_RECENT | + MAILBOX_FLAG_KEEP_LOCKED); v->sync_init = snarf_sync_init; v->free = snarf_mailbox_free; From dovecot at dovecot.org Thu Feb 9 20:21:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 20:21:24 +0200 Subject: dovecot-2.1: quota: If "quota" setting's value is empty, assume ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/dc674f4577af changeset: 14104:dc674f4577af user: Timo Sirainen date: Thu Feb 09 20:21:14 2012 +0200 description: quota: If "quota" setting's value is empty, assume quota is wanted to be disabled. diffstat: src/plugins/quota/quota.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 28b73743c36f -r dc674f4577af src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Thu Feb 09 19:32:25 2012 +0200 +++ b/src/plugins/quota/quota.c Thu Feb 09 20:21:14 2012 +0200 @@ -202,7 +202,7 @@ i_strocpy(root_name, "quota", sizeof(root_name)); for (i = 2;; i++) { env = mail_user_plugin_getenv(user, root_name); - if (env == NULL) + if (env == NULL || *env == '\0') break; if (quota_root_add(quota_set, user, env, root_name, From dovecot at dovecot.org Thu Feb 9 20:21:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 20:21:32 +0200 Subject: dovecot-2.0: quota: If "quota" setting's value is empty, assume ... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/cca57b6f9fa1 changeset: 13047:cca57b6f9fa1 user: Timo Sirainen date: Thu Feb 09 20:21:14 2012 +0200 description: quota: If "quota" setting's value is empty, assume quota is wanted to be disabled. diffstat: src/plugins/quota/quota.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 76220f2b5966 -r cca57b6f9fa1 src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Thu Feb 09 19:33:15 2012 +0200 +++ b/src/plugins/quota/quota.c Thu Feb 09 20:21:14 2012 +0200 @@ -202,7 +202,7 @@ i_strocpy(root_name, "quota", sizeof(root_name)); for (i = 2;; i++) { env = mail_user_plugin_getenv(user, root_name); - if (env == NULL) + if (env == NULL || *env == '\0') break; if (quota_root_add(quota_set, user, env, root_name, From dovecot at dovecot.org Thu Feb 9 20:37:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 20:37:30 +0200 Subject: dovecot-2.1: dbox: If saving is aborted, don't add a broken reco... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/98a59ac1f3d0 changeset: 14105:98a59ac1f3d0 user: Timo Sirainen date: Thu Feb 09 20:37:24 2012 +0200 description: dbox: If saving is aborted, don't add a broken record about it to index. diffstat: src/lib-storage/index/dbox-multi/mdbox-save.c | 1 + src/lib-storage/index/dbox-single/sdbox-save.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diffs (27 lines): diff -r dc674f4577af -r 98a59ac1f3d0 src/lib-storage/index/dbox-multi/mdbox-save.c --- a/src/lib-storage/index/dbox-multi/mdbox-save.c Thu Feb 09 20:21:14 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Thu Feb 09 20:37:24 2012 +0200 @@ -218,6 +218,7 @@ i_stream_unref(&ctx->ctx.input); if (ctx->ctx.failed) { + mail_index_expunge(ctx->ctx.trans, ctx->ctx.seq); mdbox_map_append_abort(ctx->append_ctx); array_delete(&ctx->mails, array_count(&ctx->mails) - 1, 1); return -1; diff -r dc674f4577af -r 98a59ac1f3d0 src/lib-storage/index/dbox-single/sdbox-save.c --- a/src/lib-storage/index/dbox-single/sdbox-save.c Thu Feb 09 20:21:14 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-save.c Thu Feb 09 20:37:24 2012 +0200 @@ -184,9 +184,10 @@ ctx->ctx.failed = TRUE; } T_END; - if (ctx->ctx.failed) + if (ctx->ctx.failed) { + mail_index_expunge(ctx->ctx.trans, ctx->ctx.seq); dbox_file_append_rollback(&ctx->append_ctx); - else { + } else { dbox_file_append_checkpoint(ctx->append_ctx); if (dbox_file_append_commit(&ctx->append_ctx) < 0) ctx->ctx.failed = TRUE; From dovecot at dovecot.org Thu Feb 9 20:38:21 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 20:38:21 +0200 Subject: dovecot-2.1: dsync: Fixed a potential assert crash when saving m... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e29bc3eb0ba6 changeset: 14106:e29bc3eb0ba6 user: Timo Sirainen date: Thu Feb 09 20:38:16 2012 +0200 description: dsync: Fixed a potential assert crash when saving mails. diffstat: src/doveadm/dsync/dsync-worker-local.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 98a59ac1f3d0 -r e29bc3eb0ba6 src/doveadm/dsync/dsync-worker-local.c --- a/src/doveadm/dsync/dsync-worker-local.c Thu Feb 09 20:37:24 2012 +0200 +++ b/src/doveadm/dsync/dsync-worker-local.c Thu Feb 09 20:38:16 2012 +0200 @@ -1628,7 +1628,7 @@ dsync_worker_save_callback_t *callback; ssize_t ret; - while ((ret = i_stream_read(worker->save_input)) > 0) { + while ((ret = i_stream_read(worker->save_input)) > 0 || ret == -2) { if (mailbox_save_continue(worker->save_ctx) < 0) break; } From dovecot at dovecot.org Thu Feb 9 20:38:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 20:38:46 +0200 Subject: dovecot-2.0: dbox: If saving is aborted, don't add a broken reco... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/425b62b59405 changeset: 13048:425b62b59405 user: Timo Sirainen date: Thu Feb 09 20:37:24 2012 +0200 description: dbox: If saving is aborted, don't add a broken record about it to index. diffstat: src/lib-storage/index/dbox-multi/mdbox-save.c | 1 + src/lib-storage/index/dbox-single/sdbox-save.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diffs (27 lines): diff -r cca57b6f9fa1 -r 425b62b59405 src/lib-storage/index/dbox-multi/mdbox-save.c --- a/src/lib-storage/index/dbox-multi/mdbox-save.c Thu Feb 09 20:21:14 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Thu Feb 09 20:37:24 2012 +0200 @@ -218,6 +218,7 @@ i_stream_unref(&ctx->ctx.input); if (ctx->ctx.failed) { + mail_index_expunge(ctx->ctx.trans, ctx->ctx.seq); mdbox_map_append_abort(ctx->append_ctx); array_delete(&ctx->mails, array_count(&ctx->mails) - 1, 1); return -1; diff -r cca57b6f9fa1 -r 425b62b59405 src/lib-storage/index/dbox-single/sdbox-save.c --- a/src/lib-storage/index/dbox-single/sdbox-save.c Thu Feb 09 20:21:14 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-save.c Thu Feb 09 20:37:24 2012 +0200 @@ -184,9 +184,10 @@ ctx->ctx.failed = TRUE; } T_END; - if (ctx->ctx.failed) + if (ctx->ctx.failed) { + mail_index_expunge(ctx->ctx.trans, ctx->ctx.seq); dbox_file_append_rollback(&ctx->append_ctx); - else { + } else { dbox_file_append_checkpoint(ctx->append_ctx); if (dbox_file_append_commit(&ctx->append_ctx) < 0) ctx->ctx.failed = TRUE; From dovecot at dovecot.org Thu Feb 9 20:38:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 20:38:46 +0200 Subject: dovecot-2.0: dsync: Fixed a potential assert crash when saving m... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8228f09ab0c2 changeset: 13049:8228f09ab0c2 user: Timo Sirainen date: Thu Feb 09 20:38:42 2012 +0200 description: dsync: Fixed a potential assert crash when saving mails. diffstat: src/dsync/dsync-worker-local.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 425b62b59405 -r 8228f09ab0c2 src/dsync/dsync-worker-local.c --- a/src/dsync/dsync-worker-local.c Thu Feb 09 20:37:24 2012 +0200 +++ b/src/dsync/dsync-worker-local.c Thu Feb 09 20:38:42 2012 +0200 @@ -1682,7 +1682,7 @@ dsync_worker_save_callback_t *callback; ssize_t ret; - while ((ret = i_stream_read(worker->save_input)) > 0) { + while ((ret = i_stream_read(worker->save_input)) > 0 || ret == -2) { if (mailbox_save_continue(worker->save_ctx) < 0) break; } From dovecot at dovecot.org Thu Feb 9 21:13:22 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 21:13:22 +0200 Subject: dovecot-2.1: Increased initial memory pool size. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f9b78a17018c changeset: 14107:f9b78a17018c user: Timo Sirainen date: Thu Feb 09 21:13:12 2012 +0200 description: Increased initial memory pool size. diffstat: src/plugins/virtual/virtual-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r e29bc3eb0ba6 -r f9b78a17018c src/plugins/virtual/virtual-storage.c --- a/src/plugins/virtual/virtual-storage.c Thu Feb 09 20:38:16 2012 +0200 +++ b/src/plugins/virtual/virtual-storage.c Thu Feb 09 21:13:12 2012 +0200 @@ -220,7 +220,7 @@ struct virtual_mailbox *mbox; pool_t pool; - pool = pool_alloconly_create("virtual mailbox", 1024+512); + pool = pool_alloconly_create("virtual mailbox", 2048); mbox = p_new(pool, struct virtual_mailbox, 1); mbox->box = virtual_mailbox; mbox->box.pool = pool; From dovecot at dovecot.org Thu Feb 9 21:29:40 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 21:29:40 +0200 Subject: dovecot-2.1: lib-storage: Renamed test-mail/mailbox/storage to f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6a285db79b76 changeset: 14108:6a285db79b76 user: Timo Sirainen date: Thu Feb 09 21:28:44 2012 +0200 description: lib-storage: Renamed test-mail/mailbox/storage to fail-* diffstat: src/lib-storage/Makefile.am | 13 +- src/lib-storage/fail-mail-storage.c | 58 ++++++ src/lib-storage/fail-mail-storage.h | 15 + src/lib-storage/fail-mail.c | 254 ++++++++++++++++++++++++++++ src/lib-storage/fail-mailbox.c | 316 ++++++++++++++++++++++++++++++++++++ src/lib-storage/test-mail-storage.c | 59 ------ src/lib-storage/test-mail-storage.h | 15 - src/lib-storage/test-mail.c | 254 ---------------------------- src/lib-storage/test-mailbox.c | 306 ---------------------------------- 9 files changed, 647 insertions(+), 643 deletions(-) diffs (truncated from 1353 to 300 lines): diff -r f9b78a17018c -r 6a285db79b76 src/lib-storage/Makefile.am --- a/src/lib-storage/Makefile.am Thu Feb 09 21:13:12 2012 +0200 +++ b/src/lib-storage/Makefile.am Thu Feb 09 21:28:44 2012 +0200 @@ -1,7 +1,6 @@ SUBDIRS = list index register noinst_LTLIBRARIES = libstorage.la libstorage_service.la -noinst_LIBRARIES = libstorage_test.a AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ @@ -18,6 +17,9 @@ -DMODULEDIR=\""$(moduledir)"\" libstorage_la_SOURCES = \ + fail-mail-storage.c \ + fail-mailbox.c \ + fail-mail.c \ mail.c \ mail-copy.c \ mail-error.c \ @@ -49,6 +51,7 @@ mail-storage-service.c headers = \ + fail-mail-storage.h \ mail-copy.h \ mail-error.h \ mail-namespace.h \ @@ -86,14 +89,6 @@ libdovecot_storage_la_DEPENDENCIES = $(shlibs) libdovecot_storage_la_LDFLAGS = -export-dynamic -libstorage_test_a_SOURCES = \ - test-mail-storage.c \ - test-mailbox.c \ - test-mail.c - -test_headers = \ - test-mail-storage.h - test_programs = \ test-mailbox-get diff -r f9b78a17018c -r 6a285db79b76 src/lib-storage/fail-mail-storage.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/fail-mail-storage.c Thu Feb 09 21:28:44 2012 +0200 @@ -0,0 +1,58 @@ +/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "mail-storage-private.h" +#include "fail-mail-storage.h" + +extern struct mail_storage fail_storage; + +static struct mail_storage *fail_storage_alloc(void) +{ + struct mail_storage *storage; + pool_t pool; + + pool = pool_alloconly_create("fail mail storage", 1024); + storage = p_new(pool, struct mail_storage, 1); + *storage = fail_storage; + storage->pool = pool; + return storage; +} + +static void +fail_storage_get_list_settings(const struct mail_namespace *ns ATTR_UNUSED, + struct mailbox_list_settings *set) +{ + if (set->layout == NULL) + set->layout = "fail"; + if (set->subscription_fname == NULL) + set->subscription_fname = "subscriptions"; +} + +struct mail_storage fail_storage = { + .name = "fail", + .class_flags = 0, + + .v = { + NULL, + fail_storage_alloc, + NULL, + NULL, + NULL, + fail_storage_get_list_settings, + NULL, + fail_mailbox_alloc, + NULL + } +}; + +struct mail_storage *fail_mail_storage_create(void) +{ + struct mail_storage *storage; + + storage = fail_storage_alloc(); + storage->refcount = 1; + storage->storage_class = &fail_storage; + p_array_init(&storage->module_contexts, storage->pool, 5); + return storage; +} diff -r f9b78a17018c -r 6a285db79b76 src/lib-storage/fail-mail-storage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/fail-mail-storage.h Thu Feb 09 21:28:44 2012 +0200 @@ -0,0 +1,15 @@ +#ifndef FAIL_MAIL_STORAGE_H +#define FAIL_MAIL_STORAGE_H + +struct mail_storage *fail_mail_storage_create(void); + +struct mailbox * +fail_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list, + const char *vname, enum mailbox_flags flags); + +struct mail * +fail_mailbox_mail_alloc(struct mailbox_transaction_context *t, + enum mail_fetch_field wanted_fields, + struct mailbox_header_lookup_ctx *wanted_headers); + +#endif diff -r f9b78a17018c -r 6a285db79b76 src/lib-storage/fail-mail.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/fail-mail.c Thu Feb 09 21:28:44 2012 +0200 @@ -0,0 +1,254 @@ +/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "mail-storage-private.h" +#include "fail-mail-storage.h" + +extern struct mail_vfuncs fail_mail_vfuncs; + +struct mail * +fail_mailbox_mail_alloc(struct mailbox_transaction_context *t, + enum mail_fetch_field wanted_fields ATTR_UNUSED, + struct mailbox_header_lookup_ctx *wanted_headers ATTR_UNUSED) +{ + struct mail_private *mail; + pool_t pool; + + pool = pool_alloconly_create("fail mail", 1024); + mail = p_new(pool, struct mail_private, 1); + mail->mail.box = t->box; + mail->mail.transaction = t; + mail->v = fail_mail_vfuncs; + mail->pool = pool; + p_array_init(&mail->module_contexts, pool, 5); + return &mail->mail; +} + +static void fail_mail_free(struct mail *mail) +{ + struct mail_private *pmail = (struct mail_private *)mail; + + pool_unref(&pmail->pool); +} + +static void fail_mail_set_seq(struct mail *mail, uint32_t seq, bool saving) +{ + mail->seq = seq; + mail->uid = seq; + mail->saving = saving; + + mail->expunged = TRUE; + mail->has_nuls = FALSE; + mail->has_no_nuls = FALSE; +} + +static bool fail_mail_set_uid(struct mail *mail, uint32_t uid) +{ + fail_mail_set_seq(mail, uid, FALSE); + return TRUE; +} + +static void fail_mail_set_uid_cache_updates(struct mail *mail ATTR_UNUSED, + bool set ATTR_UNUSED) +{ +} + +static bool fail_mail_prefetch(struct mail *mail ATTR_UNUSED) +{ + return TRUE; +} + +static void fail_mail_precache(struct mail *mail ATTR_UNUSED) +{ +} + +static void +fail_mail_add_temp_wanted_fields(struct mail *mail ATTR_UNUSED, + enum mail_fetch_field fields ATTR_UNUSED, + struct mailbox_header_lookup_ctx *headers ATTR_UNUSED) +{ +} + +static enum mail_flags fail_mail_get_flags(struct mail *mail ATTR_UNUSED) +{ + return 0; +} + +static const char *const * +fail_mail_get_keywords(struct mail *mail ATTR_UNUSED) +{ + return t_new(const char *, 1); +} + +static const ARRAY_TYPE(keyword_indexes) * +fail_mail_get_keyword_indexes(struct mail *mail ATTR_UNUSED) +{ + ARRAY_TYPE(keyword_indexes) *kw_indexes; + + kw_indexes = t_new(ARRAY_TYPE(keyword_indexes), 1); + t_array_init(kw_indexes, 1); + (void)array_append_space(kw_indexes); + return kw_indexes; +} + +static uint64_t fail_mail_get_modseq(struct mail *mail ATTR_UNUSED) +{ + return 0; +} + +static int +fail_mail_get_parts(struct mail *mail ATTR_UNUSED, + struct message_part **parts_r ATTR_UNUSED) +{ + return -1; +} + +static int +fail_mail_get_date(struct mail *mail ATTR_UNUSED, + time_t *date_r ATTR_UNUSED, int *timezone_r ATTR_UNUSED) +{ + return -1; +} + +static int +fail_mail_get_received_date(struct mail *mail ATTR_UNUSED, + time_t *date_r ATTR_UNUSED) +{ + return -1; +} + +static int +fail_mail_get_save_date(struct mail *mail ATTR_UNUSED, + time_t *date_r ATTR_UNUSED) +{ + return -1; +} + +static int +fail_mail_get_fail_mail_size(struct mail *mail ATTR_UNUSED, + uoff_t *size_r ATTR_UNUSED) +{ + return -1; +} + +static int +fail_mail_get_physical_size(struct mail *mail ATTR_UNUSED, + uoff_t *size_r ATTR_UNUSED) +{ + return -1; +} + +static int +fail_mail_get_first_header(struct mail *mail ATTR_UNUSED, + const char *field ATTR_UNUSED, + bool decode_to_utf8 ATTR_UNUSED, + const char **value_r) +{ + *value_r = NULL; + return 0; +} + +static int +fail_mail_get_headers(struct mail *mail ATTR_UNUSED, + const char *field ATTR_UNUSED, + bool decode_to_utf8 ATTR_UNUSED, + const char *const **value_r) +{ + *value_r = NULL; + return 0; +} + +static int +fail_mail_get_header_stream(struct mail *mail ATTR_UNUSED, + struct mailbox_header_lookup_ctx *headers ATTR_UNUSED, + struct istream **stream_r ATTR_UNUSED) +{ + return -1; +} + +static int +fail_mail_get_stream(struct mail *mail ATTR_UNUSED, bool get_body ATTR_UNUSED, From dovecot at dovecot.org Thu Feb 9 21:29:40 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 09 Feb 2012 21:29:40 +0200 Subject: dovecot-2.1: shared: Allocate mailbox as fail_mailbox. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a927b41bf699 changeset: 14109:a927b41bf699 user: Timo Sirainen date: Thu Feb 09 21:29:25 2012 +0200 description: shared: Allocate mailbox as fail_mailbox. This fixes crashes when a mailbox is attempted to be allocated from the shared namespace itself (e.g. the "shared" prefix). diffstat: src/lib-storage/index/shared/shared-storage.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (20 lines): diff -r 6a285db79b76 -r a927b41bf699 src/lib-storage/index/shared/shared-storage.c --- a/src/lib-storage/index/shared/shared-storage.c Thu Feb 09 21:28:44 2012 +0200 +++ b/src/lib-storage/index/shared/shared-storage.c Thu Feb 09 21:29:25 2012 +0200 @@ -7,6 +7,7 @@ #include "var-expand.h" #include "index-storage.h" #include "mailbox-list-private.h" +#include "fail-mail-storage.h" #include "shared-storage.h" #include @@ -334,7 +335,7 @@ NULL, shared_storage_get_list_settings, NULL, - NULL, + fail_mailbox_alloc, NULL } }; From dovecot at dovecot.org Sun Feb 12 02:22:54 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 02:22:54 +0200 Subject: dovecot-2.1: doveadm pw: Added -t parameter to test if a ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/fffa4d53e901 changeset: 14110:fffa4d53e901 user: Timo Sirainen date: Sun Feb 12 02:22:43 2012 +0200 description: doveadm pw: Added -t parameter to test if a hash matches to given plaintext. Based on patch by Jimmy Thrasibule diffstat: src/doveadm/doveadm-pw.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diffs (65 lines): diff -r a927b41bf699 -r fffa4d53e901 src/doveadm/doveadm-pw.c --- a/src/doveadm/doveadm-pw.c Thu Feb 09 21:29:25 2012 +0200 +++ b/src/doveadm/doveadm-pw.c Sun Feb 12 02:22:43 2012 +0200 @@ -21,6 +21,7 @@ const char *user = NULL; const char *scheme = NULL; const char *plaintext = NULL; + const char *test_hash = NULL; bool list_schemes = FALSE, reverse_verify = FALSE; unsigned int rounds = 0; int c; @@ -28,7 +29,7 @@ random_init(); password_schemes_init(); - while ((c = getopt(argc, argv, "lp:r:s:u:V")) > 0) { + while ((c = getopt(argc, argv, "lp:r:s:t:u:V")) > 0) { switch (c) { case 'l': list_schemes = 1; @@ -43,6 +44,10 @@ case 's': scheme = optarg; break; + case 't': + test_hash = optarg; + reverse_verify = TRUE; + break; case 'u': user = optarg; break; @@ -73,6 +78,8 @@ if (rounds > 0) password_set_encryption_rounds(rounds); + if (test_hash != NULL) + plaintext = t_askpass("Enter password to verify: "); while (plaintext == NULL) { const char *check; static int lives = 3; @@ -96,6 +103,15 @@ size_t size; const char *error; + if (test_hash != NULL) { + scheme = password_get_scheme(&test_hash); + if (scheme == NULL) { + fprintf(stderr, "Missing {scheme} prefix from hash\n"); + exit(2); + } + hash = test_hash; + } + if (password_decode(hash, scheme, &raw_password, &size, &error) <= 0) { fprintf(stderr, "reverse decode check failed: %s\n", @@ -104,7 +120,7 @@ } if (password_verify(plaintext, user, scheme, - raw_password, size, &error) != 1) { + raw_password, size, &error) <= 0) { fprintf(stderr, "reverse password verification check failed: %s\n", error); exit(2); From dovecot at dovecot.org Sun Feb 12 02:30:48 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 02:30:48 +0200 Subject: dovecot-2.1: doveadm: Removed unnecessary code. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/53cf118fd16c changeset: 14111:53cf118fd16c user: Timo Sirainen date: Sun Feb 12 02:30:34 2012 +0200 description: doveadm: Removed unnecessary code. "mailbox/" is no longer included in listing by default. diffstat: src/doveadm/doveadm-mail-list-iter.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-) diffs (24 lines): diff -r fffa4d53e901 -r 53cf118fd16c src/doveadm/doveadm-mail-list-iter.c --- a/src/doveadm/doveadm-mail-list-iter.c Sun Feb 12 02:22:43 2012 +0200 +++ b/src/doveadm/doveadm-mail-list-iter.c Sun Feb 12 02:30:34 2012 +0200 @@ -132,7 +132,6 @@ doveadm_mail_list_iter_next(struct doveadm_mail_list_iter *iter) { const struct mailbox_info *info; - unsigned int len; while ((info = mailbox_list_iter_next(iter->iter)) != NULL) { char sep = mail_namespace_get_sep(info->ns); @@ -142,12 +141,6 @@ if (iter->only_selectable) continue; } - len = strlen(info->name); - if (len > 0 && - info->name[len-1] == sep) { - /* when listing "foo/%" it lists "foo/". skip it. */ - continue; - } if (mail_search_args_match_mailbox(iter->search_args, info->name, sep)) From dovecot at dovecot.org Sun Feb 12 02:53:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 02:53:57 +0200 Subject: dovecot-2.1: doveadm: Use MAILBOX_LIST_ITER_LIST_PREFIXES when i... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6420d63e7570 changeset: 14113:6420d63e7570 user: Timo Sirainen date: Sun Feb 12 02:53:50 2012 +0200 description: doveadm: Use MAILBOX_LIST_ITER_LIST_PREFIXES when iterating through mailboxes. This means that if there exists a mailbox in namespace prefix itself, those mailboxes can be accessed. Also "doveadm mailbox list" shows all namespace prefixes. Note that wildcards match only within namespace, so e.g. '*' will never match any namespace prefix, because it works within the prefix="" namespace. diffstat: src/doveadm/doveadm-mail-list-iter.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r f5353573d3a0 -r 6420d63e7570 src/doveadm/doveadm-mail-list-iter.c --- a/src/doveadm/doveadm-mail-list-iter.c Sun Feb 12 02:50:49 2012 +0200 +++ b/src/doveadm/doveadm-mail-list-iter.c Sun Feb 12 02:53:50 2012 +0200 @@ -66,6 +66,8 @@ ARRAY_TYPE(const_string) patterns; bool have_guid = FALSE; + iter_flags |= MAILBOX_LIST_ITER_LIST_PREFIXES; + iter = i_new(struct doveadm_mail_list_iter, 1); iter->search_args = search_args; From dovecot at dovecot.org Sun Feb 12 02:53:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 02:53:57 +0200 Subject: dovecot-2.1: lib-storage: Added MAILBOX_LIST_ITER_LIST_PREFIXES ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f5353573d3a0 changeset: 14112:f5353573d3a0 user: Timo Sirainen date: Sun Feb 12 02:50:49 2012 +0200 description: lib-storage: Added MAILBOX_LIST_ITER_LIST_PREFIXES flag. diffstat: src/lib-storage/mailbox-list-iter.c | 148 ++++++++++++++++++++++++++--------- src/lib-storage/mailbox-list.h | 3 + 2 files changed, 112 insertions(+), 39 deletions(-) diffs (209 lines): diff -r 53cf118fd16c -r f5353573d3a0 src/lib-storage/mailbox-list-iter.c --- a/src/lib-storage/mailbox-list-iter.c Sun Feb 12 02:30:34 2012 +0200 +++ b/src/lib-storage/mailbox-list-iter.c Sun Feb 12 02:50:49 2012 +0200 @@ -39,8 +39,14 @@ pool_t pool; const char **patterns, **patterns_ns_match; enum namespace_type type_mask; + + struct mail_namespace *iter_namespaces; + struct mailbox_info ns_info; }; +static bool ns_match_next(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, const char *pattern); + struct mailbox_list_iterate_context * mailbox_list_iter_init(struct mailbox_list *list, const char *pattern, enum mailbox_list_iter_flags flags) @@ -184,46 +190,10 @@ } static bool -ns_match_next(struct ns_list_iterate_context *ctx, struct mail_namespace *ns, - const char *pattern) +ns_is_match_within_ns(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, const char *prefix_without_sep, + const char *pattern, enum imap_match_result result) { - struct imap_match_glob *glob; - enum imap_match_result result; - const char *prefix_without_sep; - unsigned int len; - - len = ns->prefix_len; - if (len > 0 && ns->prefix[len-1] == mail_namespace_get_sep(ns)) - len--; - - if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | - NAMESPACE_FLAG_LIST_CHILDREN)) == 0) { - /* non-listable namespace matches only with exact prefix */ - if (strncmp(ns->prefix, pattern, ns->prefix_len) != 0) - return FALSE; - } - - prefix_without_sep = t_strndup(ns->prefix, len); - if (*prefix_without_sep == '\0') - result = IMAP_MATCH_CHILDREN; - else { - glob = imap_match_init(pool_datastack_create(), pattern, - TRUE, mail_namespace_get_sep(ns)); - result = imap_match(glob, prefix_without_sep); - } - - if ((ctx->ctx.flags & MAILBOX_LIST_ITER_STAR_WITHIN_NS) == 0) { - switch (result) { - case IMAP_MATCH_YES: - case IMAP_MATCH_CHILDREN: - return TRUE; - case IMAP_MATCH_NO: - case IMAP_MATCH_PARENT: - break; - } - return FALSE; - } - switch (result) { case IMAP_MATCH_YES: /* allow matching prefix only when it's done without @@ -255,6 +225,50 @@ return FALSE; } +static bool ns_match_next(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, const char *pattern) +{ + struct imap_match_glob *glob; + enum imap_match_result result; + const char *prefix_without_sep; + unsigned int len; + + len = ns->prefix_len; + if (len > 0 && ns->prefix[len-1] == mail_namespace_get_sep(ns)) + len--; + + if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) == 0) { + /* non-listable namespace matches only with exact prefix */ + if (strncmp(ns->prefix, pattern, ns->prefix_len) != 0) + return FALSE; + } + + prefix_without_sep = t_strndup(ns->prefix, len); + if (*prefix_without_sep == '\0') + result = IMAP_MATCH_CHILDREN; + else { + glob = imap_match_init(pool_datastack_create(), pattern, + TRUE, mail_namespace_get_sep(ns)); + result = imap_match(glob, prefix_without_sep); + } + + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_STAR_WITHIN_NS) != 0) { + return ns_is_match_within_ns(ctx, ns, prefix_without_sep, + pattern, result); + } else { + switch (result) { + case IMAP_MATCH_YES: + case IMAP_MATCH_CHILDREN: + return TRUE; + case IMAP_MATCH_NO: + case IMAP_MATCH_PARENT: + break; + } + return FALSE; + } +} + static bool ns_match(struct ns_list_iterate_context *ctx, struct mail_namespace *ns) { @@ -288,6 +302,49 @@ return ns; } +static bool +iter_next_try_prefix_pattern(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns, const char *pattern) +{ + struct imap_match_glob *glob; + enum imap_match_result result; + const char *prefix_without_sep; + + i_assert(ns->prefix_len > 0); + + if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) == 0) { + /* non-listable namespace matches only with exact prefix */ + if (strncmp(ns->prefix, pattern, ns->prefix_len) != 0) + return FALSE; + } + + prefix_without_sep = t_strndup(ns->prefix, ns->prefix_len-1); + glob = imap_match_init(pool_datastack_create(), pattern, + TRUE, mail_namespace_get_sep(ns)); + result = imap_match(glob, prefix_without_sep); + return result == IMAP_MATCH_YES && + ns_is_match_within_ns(ctx, ns, prefix_without_sep, + pattern, result); +} + +static bool iter_next_try_prefix(struct ns_list_iterate_context *ctx, + struct mail_namespace *ns) +{ + unsigned int i; + bool ret = FALSE; + + for (i = 0; ctx->patterns_ns_match[i] != NULL; i++) { + T_BEGIN { + ret = iter_next_try_prefix_pattern(ctx, ns, + ctx->patterns_ns_match[i]); + } T_END; + if (ret) + break; + } + return ret; +} + static const struct mailbox_info * mailbox_list_ns_iter_next(struct mailbox_list_iterate_context *_ctx) { @@ -295,6 +352,18 @@ (struct ns_list_iterate_context *)_ctx; const struct mailbox_info *info; + while (ctx->iter_namespaces != NULL) { + struct mail_namespace *ns = ctx->iter_namespaces; + + ctx->iter_namespaces = ns->next; + if (ns->prefix_len > 0 && iter_next_try_prefix(ctx, ns)) { + ctx->ns_info.ns = ns; + ctx->ns_info.name = p_strndup(ctx->pool, ns->prefix, + ns->prefix_len-1); + return &ctx->ns_info; + } + } + info = ctx->backend_ctx == NULL ? NULL : mailbox_list_iter_next(ctx->backend_ctx); if (info == NULL && ctx->namespaces != NULL) { @@ -368,6 +437,7 @@ ctx->ctx.list = p_new(pool, struct mailbox_list, 1); ctx->ctx.list->v.iter_next = mailbox_list_ns_iter_next; ctx->ctx.list->v.iter_deinit = mailbox_list_ns_iter_deinit; + ctx->iter_namespaces = namespaces; count = str_array_length(patterns); ctx->patterns = p_new(pool, const char *, count + 1); diff -r 53cf118fd16c -r f5353573d3a0 src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Sun Feb 12 02:30:34 2012 +0200 +++ b/src/lib-storage/mailbox-list.h Sun Feb 12 02:50:49 2012 +0200 @@ -73,6 +73,9 @@ namespace prefixes, if there exists a parent namespace whose children it matches. */ MAILBOX_LIST_ITER_STAR_WITHIN_NS = 0x000010, + /* For mailbox_list_iter_init_namespaces(): List also namespace + prefixes if they match */ + MAILBOX_LIST_ITER_LIST_PREFIXES = 0x000020, /* List only subscribed mailboxes */ MAILBOX_LIST_ITER_SELECT_SUBSCRIBED = 0x000100, From dovecot at dovecot.org Sun Feb 12 03:29:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:29:49 +0200 Subject: dovecot-2.1: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/8d90de706bd2 changeset: 14114:8d90de706bd2 user: Timo Sirainen date: Sun Feb 12 03:29:36 2012 +0200 description: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag for extra security. This is to counter the "BEAST SSL" attack, although I don't think it's practical to implement against IMAP/POP3/LMTP protocols. There's really no way for attackers to inject any evil data before authentication, so the password is safe. Post-authentication attacker could cause clients to download evil emails, but even then clients don't typically redownload some specific mail, so there's really no way to extract anything useful. diffstat: src/lib-ssl-iostream/iostream-openssl-context.c | 5 ++++- src/login-common/ssl-proxy-openssl.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diffs (31 lines): diff -r 6420d63e7570 -r 8d90de706bd2 src/lib-ssl-iostream/iostream-openssl-context.c --- a/src/lib-ssl-iostream/iostream-openssl-context.c Sun Feb 12 02:53:50 2012 +0200 +++ b/src/lib-ssl-iostream/iostream-openssl-context.c Sun Feb 12 03:29:36 2012 +0200 @@ -356,7 +356,10 @@ ctx->pool = pool_alloconly_create("ssl iostream context", 4096); ctx->source = p_strdup(ctx->pool, source); - SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_ALL | SSL_OP_NO_SSLv2); + /* enable all SSL workarounds, except empty fragments as it + makes SSL more vulnerable against attacks */ + SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_SSLv2 | + (SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); if (SSL_CTX_need_tmp_RSA(ctx->ssl_ctx)) SSL_CTX_set_tmp_rsa_callback(ctx->ssl_ctx, ssl_gen_rsa_key); SSL_CTX_set_tmp_dh_callback(ctx->ssl_ctx, ssl_tmp_dh_callback); diff -r 6420d63e7570 -r 8d90de706bd2 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Sun Feb 12 02:53:50 2012 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Sun Feb 12 03:29:36 2012 +0200 @@ -941,8 +941,10 @@ X509_STORE *store; STACK_OF(X509_NAME) *xnames = NULL; - /* enable all SSL workarounds */ - SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL); + /* enable all SSL workarounds, except empty fragments as it + makes SSL more vulnerable against attacks */ + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL & + ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS); #ifdef SSL_MODE_RELEASE_BUFFERS SSL_CTX_set_mode(ssl_ctx, SSL_MODE_RELEASE_BUFFERS); From dovecot at dovecot.org Sun Feb 12 03:31:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:31:30 +0200 Subject: dovecot-2.0: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/e3d46fd04105 changeset: 13050:e3d46fd04105 user: Timo Sirainen date: Sun Feb 12 03:31:24 2012 +0200 description: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag for extra security. This is to counter the "BEAST SSL" attack, although I don't think it's practical to implement against IMAP/POP3/LMTP protocols. There's really no way for attackers to inject any evil data before authentication, so the password is safe. Post-authentication attacker could cause clients to download evil emails, but even then clients don't typically redownload some specific mail, so there's really no way to extract anything useful. diffstat: src/login-common/ssl-proxy-openssl.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 8228f09ab0c2 -r e3d46fd04105 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Thu Feb 09 20:38:42 2012 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Sun Feb 12 03:31:24 2012 +0200 @@ -1011,7 +1011,10 @@ X509_STORE *store; STACK_OF(X509_NAME) *xnames = NULL; - SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL | SSL_OP_NO_SSLv2); + /* enable all SSL workarounds, except empty fragments as it + makes SSL more vulnerable against attacks */ + SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | + (SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); #ifdef SSL_MODE_RELEASE_BUFFERS SSL_CTX_set_mode(ssl_ctx, SSL_MODE_RELEASE_BUFFERS); #endif From dovecot at dovecot.org Sun Feb 12 03:32:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:32:25 +0200 Subject: dovecot-1.2: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag... Message-ID: details: http://hg.dovecot.org/dovecot-1.2/rev/9f3c8c59f8c4 changeset: 9653:9f3c8c59f8c4 user: Timo Sirainen date: Sun Feb 12 03:32:20 2012 +0200 description: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag for extra security. This is to counter the "BEAST SSL" attack, although I don't think it's practical to implement against IMAP/POP3/LMTP protocols. There's really no way for attackers to inject any evil data before authentication, so the password is safe. Post-authentication attacker could cause clients to download evil emails, but even then clients don't typically redownload some specific mail, so there's really no way to extract anything useful. diffstat: src/login-common/ssl-proxy-openssl.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 031a4c2fabea -r 9f3c8c59f8c4 src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Sat Jan 28 23:58:50 2012 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Sun Feb 12 03:32:20 2012 +0200 @@ -817,7 +817,10 @@ { const char *cafile; - SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL); + /* enable all SSL workarounds, except empty fragments as it + makes SSL more vulnerable against attacks */ + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL & + ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS); cafile = getenv("SSL_CA_FILE"); if (cafile != NULL) { From dovecot at dovecot.org Sun Feb 12 03:32:50 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:32:50 +0200 Subject: dovecot-1.0: autogen.sh updated to use wiki1-export.tar.gz Message-ID: details: http://hg.dovecot.org/dovecot-1.0/rev/f8f680d5ae04 changeset: 5572:f8f680d5ae04 user: Timo Sirainen date: Wed May 11 18:03:31 2011 +0300 description: autogen.sh updated to use wiki1-export.tar.gz diffstat: autogen.sh | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diffs (18 lines): diff -r 9073f25d1b94 -r f8f680d5ae04 autogen.sh --- a/autogen.sh Tue Jul 21 15:18:49 2009 -0400 +++ b/autogen.sh Wed May 11 18:03:31 2011 +0300 @@ -18,10 +18,10 @@ if test ! -f doc/wiki/Authentication.txt; then cd doc - wget http://www.dovecot.org/tmp/wiki-export.tar.gz - tar xzf wiki-export.tar.gz - mv wiki-export/*.txt wiki/ - rm -rf wiki-export wiki-export.tar.gz + wget http://www.dovecot.org/tmp/wiki1-export.tar.gz + tar xzf wiki1-export.tar.gz + mv wiki1-export/*.txt wiki/ + rm -rf wiki1-export wiki1-export.tar.gz cd .. fi From dovecot at dovecot.org Sun Feb 12 03:32:50 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:32:50 +0200 Subject: dovecot-1.0: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag... Message-ID: details: http://hg.dovecot.org/dovecot-1.0/rev/708b2c9a851c changeset: 5573:708b2c9a851c user: Timo Sirainen date: Sun Feb 12 03:32:20 2012 +0200 description: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag for extra security. This is to counter the "BEAST SSL" attack, although I don't think it's practical to implement against IMAP/POP3/LMTP protocols. There's really no way for attackers to inject any evil data before authentication, so the password is safe. Post-authentication attacker could cause clients to download evil emails, but even then clients don't typically redownload some specific mail, so there's really no way to extract anything useful. diffstat: src/login-common/ssl-proxy-openssl.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (15 lines): diff -r f8f680d5ae04 -r 708b2c9a851c src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Wed May 11 18:03:31 2011 +0300 +++ b/src/login-common/ssl-proxy-openssl.c Sun Feb 12 03:32:20 2012 +0200 @@ -697,7 +697,10 @@ if ((ssl_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) i_fatal("SSL_CTX_new() failed"); - SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL); + /* enable all SSL workarounds, except empty fragments as it + makes SSL more vulnerable against attacks */ + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL & + ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS); cipher_list = getenv("SSL_CIPHER_LIST"); if (cipher_list == NULL) From dovecot at dovecot.org Sun Feb 12 03:32:56 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:32:56 +0200 Subject: dovecot-1.1: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag... Message-ID: details: http://hg.dovecot.org/dovecot-1.1/rev/22b99f10260a changeset: 8375:22b99f10260a user: Timo Sirainen date: Sun Feb 12 03:32:20 2012 +0200 description: SSL: Enable SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS flag for extra security. This is to counter the "BEAST SSL" attack, although I don't think it's practical to implement against IMAP/POP3/LMTP protocols. There's really no way for attackers to inject any evil data before authentication, so the password is safe. Post-authentication attacker could cause clients to download evil emails, but even then clients don't typically redownload some specific mail, so there's really no way to extract anything useful. diffstat: src/login-common/ssl-proxy-openssl.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (15 lines): diff -r eadc6ecd92a8 -r 22b99f10260a src/login-common/ssl-proxy-openssl.c --- a/src/login-common/ssl-proxy-openssl.c Wed Jan 25 23:45:02 2012 +0200 +++ b/src/login-common/ssl-proxy-openssl.c Sun Feb 12 03:32:20 2012 +0200 @@ -776,7 +776,10 @@ if ((ssl_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) i_fatal("SSL_CTX_new() failed"); - SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL); + /* enable all SSL workarounds, except empty fragments as it + makes SSL more vulnerable against attacks */ + SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL & + ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS); cipher_list = getenv("SSL_CIPHER_LIST"); if (cipher_list == NULL) From dovecot at dovecot.org Sun Feb 12 03:47:21 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:47:21 +0200 Subject: dovecot-2.1: message_id_get_next(): Fixed parsing message-ids wi... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/53929042d73e changeset: 14115:53929042d73e user: Timo Sirainen date: Sun Feb 12 03:47:01 2012 +0200 description: message_id_get_next(): Fixed parsing message-ids with no-fold-quotes. diffstat: src/lib-mail/message-id.c | 7 ++++++- src/lib-mail/test-message-id.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diffs (42 lines): diff -r 8d90de706bd2 -r 53929042d73e src/lib-mail/message-id.c --- a/src/lib-mail/message-id.c Sun Feb 12 03:29:36 2012 +0200 +++ b/src/lib-mail/message-id.c Sun Feb 12 03:47:01 2012 +0200 @@ -8,6 +8,7 @@ static bool get_untokenized_msgid(const char **msgid_p, string_t *msgid) { struct rfc822_parser_context parser; + int ret; rfc822_parser_init(&parser, (const unsigned char *)*msgid_p, strlen(*msgid_p), NULL); @@ -22,7 +23,11 @@ (void)rfc822_skip_lwsp(&parser); - if (rfc822_parse_dot_atom(&parser, msgid) <= 0) + if (*parser.data == '"') + ret = rfc822_parse_quoted_string(&parser, msgid); + else + ret = rfc822_parse_dot_atom(&parser, msgid); + if (ret <= 0) return FALSE; if (*parser.data != '@') diff -r 8d90de706bd2 -r 53929042d73e src/lib-mail/test-message-id.c --- a/src/lib-mail/test-message-id.c Sun Feb 12 03:29:36 2012 +0200 +++ b/src/lib-mail/test-message-id.c Sun Feb 12 03:47:01 2012 +0200 @@ -10,11 +10,13 @@ "", ",skipped,", "(c) < (c) foo (c) @ (c) bar (c) > (c)", + "<\"foo 2\"@bar>" }; const char *output[] = { "foo at bar", NULL, "foo at bar", "foo2 at bar2", NULL, - "foo at bar", NULL + "foo at bar", NULL, + "foo 2 at bar", NULL }; const char *msgid, *next_msgid; unsigned int i, j; From dovecot at dovecot.org Sun Feb 12 03:47:31 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:47:31 +0200 Subject: dovecot-2.0: message_id_get_next(): Fixed parsing message-ids wi... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/71dbe30caedb changeset: 13051:71dbe30caedb user: Timo Sirainen date: Sun Feb 12 03:47:01 2012 +0200 description: message_id_get_next(): Fixed parsing message-ids with no-fold-quotes. diffstat: src/lib-mail/message-id.c | 7 ++++++- src/lib-mail/test-message-id.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diffs (42 lines): diff -r e3d46fd04105 -r 71dbe30caedb src/lib-mail/message-id.c --- a/src/lib-mail/message-id.c Sun Feb 12 03:31:24 2012 +0200 +++ b/src/lib-mail/message-id.c Sun Feb 12 03:47:01 2012 +0200 @@ -8,6 +8,7 @@ static bool get_untokenized_msgid(const char **msgid_p, string_t *msgid) { struct rfc822_parser_context parser; + int ret; rfc822_parser_init(&parser, (const unsigned char *)*msgid_p, strlen(*msgid_p), NULL); @@ -22,7 +23,11 @@ (void)rfc822_skip_lwsp(&parser); - if (rfc822_parse_dot_atom(&parser, msgid) <= 0) + if (*parser.data == '"') + ret = rfc822_parse_quoted_string(&parser, msgid); + else + ret = rfc822_parse_dot_atom(&parser, msgid); + if (ret <= 0) return FALSE; if (*parser.data != '@') diff -r e3d46fd04105 -r 71dbe30caedb src/lib-mail/test-message-id.c --- a/src/lib-mail/test-message-id.c Sun Feb 12 03:31:24 2012 +0200 +++ b/src/lib-mail/test-message-id.c Sun Feb 12 03:47:01 2012 +0200 @@ -10,11 +10,13 @@ "", ",skipped,", "(c) < (c) foo (c) @ (c) bar (c) > (c)", + "<\"foo 2\"@bar>" }; const char *output[] = { "foo at bar", NULL, "foo at bar", "foo2 at bar2", NULL, - "foo at bar", NULL + "foo at bar", NULL, + "foo 2 at bar", NULL }; const char *msgid, *next_msgid; unsigned int i, j; From dovecot at dovecot.org Sun Feb 12 03:51:26 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 03:51:26 +0200 Subject: dovecot-2.1: doveadm mailbox delete: Sort the mailbox parameters... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/711c122aa253 changeset: 14116:711c122aa253 user: Timo Sirainen date: Sun Feb 12 03:51:21 2012 +0200 description: doveadm mailbox delete: Sort the mailbox parameters so that children are deleted first. diffstat: src/doveadm/doveadm-mail-mailbox.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (25 lines): diff -r 53929042d73e -r 711c122aa253 src/doveadm/doveadm-mail-mailbox.c --- a/src/doveadm/doveadm-mail-mailbox.c Sun Feb 12 03:47:01 2012 +0200 +++ b/src/doveadm/doveadm-mail-mailbox.c Sun Feb 12 03:51:21 2012 +0200 @@ -272,6 +272,13 @@ } } +static int i_strcmp_reverse_p(const void *p1, const void *p2) +{ + const char *const *s1 = p1, *const *s2 = p2; + + return -strcmp(*s1, *s2); +} + static void cmd_mailbox_delete_init(struct doveadm_mail_cmd_context *_ctx, const char *const args[]) { @@ -287,6 +294,7 @@ name = p_strdup(ctx->ctx.ctx.pool, args[i]); array_append(&ctx->mailboxes, &name, 1); } + array_sort(&ctx->mailboxes, i_strcmp_reverse_p); } static struct doveadm_mail_cmd_context *cmd_mailbox_delete_alloc(void) From dovecot at dovecot.org Sun Feb 12 04:01:40 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 04:01:40 +0200 Subject: dovecot-2.1: doveadm mailbox delete: Added -r parameter to recur... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4bc781a27f54 changeset: 14117:4bc781a27f54 user: Timo Sirainen date: Sun Feb 12 04:01:34 2012 +0200 description: doveadm mailbox delete: Added -r parameter to recursively delete mailboxes. diffstat: src/doveadm/doveadm-mail-mailbox.c | 82 ++++++++++++++++++++++++++++++++----- 1 files changed, 70 insertions(+), 12 deletions(-) diffs (130 lines): diff -r 711c122aa253 -r 4bc781a27f54 src/doveadm/doveadm-mail-mailbox.c --- a/src/doveadm/doveadm-mail-mailbox.c Sun Feb 12 03:51:21 2012 +0200 +++ b/src/doveadm/doveadm-mail-mailbox.c Sun Feb 12 04:01:34 2012 +0200 @@ -24,6 +24,12 @@ ARRAY_TYPE(const_string) mailboxes; }; +struct delete_cmd_context { + struct doveadm_mailbox_cmd_context ctx; + ARRAY_TYPE(const_string) mailboxes; + bool recursive; +}; + struct rename_cmd_context { struct doveadm_mailbox_cmd_context ctx; const char *oldname, *newname; @@ -239,17 +245,59 @@ return &ctx->ctx.ctx; } +static int i_strcmp_reverse_p(const void *p1, const void *p2) +{ + const char *const *s1 = p1, *const *s2 = p2; + + return -strcmp(*s1, *s2); +} + +static void +get_child_mailboxes(struct mail_user *user, ARRAY_TYPE(const_string) *mailboxes, + const char *name) +{ + struct mailbox_list_iterate_context *iter; + struct mail_namespace *ns; + const struct mailbox_info *info; + const char *pattern, *child_name; + + ns = mail_namespace_find(user->namespaces, name); + if (ns == NULL) + return; + + pattern = t_strdup_printf("%s%c*", name, mail_namespace_get_sep(ns)); + iter = mailbox_list_iter_init(ns->list, pattern, + MAILBOX_LIST_ITER_RETURN_NO_FLAGS); + while ((info = mailbox_list_iter_next(iter)) != NULL) { + child_name = t_strdup(info->name); + array_append(mailboxes, &child_name, 1); + } + (void)mailbox_list_iter_deinit(&iter); +} + static void cmd_mailbox_delete_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { - struct mailbox_cmd_context *ctx = (struct mailbox_cmd_context *)_ctx; + struct delete_cmd_context *ctx = (struct delete_cmd_context *)_ctx; struct mail_namespace *ns; struct mailbox *box; struct mail_storage *storage; const char *const *namep; + ARRAY_TYPE(const_string) recursive_mailboxes; + const ARRAY_TYPE(const_string) *mailboxes = &ctx->mailboxes; - array_foreach(&ctx->mailboxes, namep) { + if (ctx->recursive) { + t_array_init(&recursive_mailboxes, 32); + array_foreach(&ctx->mailboxes, namep) { + get_child_mailboxes(user, &recursive_mailboxes, *namep); + array_append(&recursive_mailboxes, namep, 1); + } + array_sort(&recursive_mailboxes, i_strcmp_reverse_p); + mailboxes = &recursive_mailboxes; + } + + array_foreach(mailboxes, namep) { const char *name = *namep; ns = mail_namespace_find(user->namespaces, name); @@ -272,17 +320,10 @@ } } -static int i_strcmp_reverse_p(const void *p1, const void *p2) -{ - const char *const *s1 = p1, *const *s2 = p2; - - return -strcmp(*s1, *s2); -} - static void cmd_mailbox_delete_init(struct doveadm_mail_cmd_context *_ctx, const char *const args[]) { - struct mailbox_cmd_context *ctx = (struct mailbox_cmd_context *)_ctx; + struct delete_cmd_context *ctx = (struct delete_cmd_context *)_ctx; const char *name; unsigned int i; @@ -297,13 +338,30 @@ array_sort(&ctx->mailboxes, i_strcmp_reverse_p); } +static bool +cmd_mailbox_delete_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +{ + struct delete_cmd_context *ctx = (struct delete_cmd_context *)_ctx; + + switch (c) { + case 'r': + ctx->recursive = TRUE; + break; + default: + return FALSE; + } + return TRUE; +} + static struct doveadm_mail_cmd_context *cmd_mailbox_delete_alloc(void) { - struct mailbox_cmd_context *ctx; + struct delete_cmd_context *ctx; - ctx = doveadm_mailbox_cmd_alloc(struct mailbox_cmd_context); + ctx = doveadm_mailbox_cmd_alloc(struct delete_cmd_context); ctx->ctx.ctx.v.init = cmd_mailbox_delete_init; ctx->ctx.ctx.v.run = cmd_mailbox_delete_run; + ctx->ctx.ctx.v.parse_arg = cmd_mailbox_delete_parse_arg; + ctx->ctx.ctx.getopt_args = "r"; p_array_init(&ctx->mailboxes, ctx->ctx.ctx.pool, 16); return &ctx->ctx.ctx; } From dovecot at dovecot.org Sun Feb 12 04:12:55 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 04:12:55 +0200 Subject: dovecot-2.1: doveadm acl set: Replace both positive and negative... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/dbff71f51507 changeset: 14118:dbff71f51507 user: Timo Sirainen date: Sun Feb 12 04:12:44 2012 +0200 description: doveadm acl set: Replace both positive and negative rights, not just one of them. diffstat: src/plugins/acl/doveadm-acl.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diffs (18 lines): diff -r 4bc781a27f54 -r dbff71f51507 src/plugins/acl/doveadm-acl.c --- a/src/plugins/acl/doveadm-acl.c Sun Feb 12 04:01:34 2012 +0200 +++ b/src/plugins/acl/doveadm-acl.c Sun Feb 12 04:12:44 2012 +0200 @@ -278,10 +278,14 @@ if (array_count(&dest_rights) > 0) { (void)array_append_space(&dest_rights); update.rights.rights = array_idx(&dest_rights, 0); + } else { + update.modify_mode = ACL_MODIFY_MODE_CLEAR; } if (array_count(&dest_neg_rights) > 0) { (void)array_append_space(&dest_neg_rights); update.rights.neg_rights = array_idx(&dest_neg_rights, 0); + } else { + update.neg_modify_mode = ACL_MODIFY_MODE_CLEAR; } aclobj = acl_mailbox_get_aclobj(box); From dovecot at dovecot.org Sun Feb 12 04:19:01 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 04:19:01 +0200 Subject: dovecot-2.1: doveadm acl: Added "add" and "remove" commands. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/845c3045f45c changeset: 14119:845c3045f45c user: Timo Sirainen date: Sun Feb 12 04:18:50 2012 +0200 description: doveadm acl: Added "add" and "remove" commands. diffstat: src/plugins/acl/doveadm-acl.c | 47 +++++++++++++++++++++++++++++++----------- 1 files changed, 34 insertions(+), 13 deletions(-) diffs (100 lines): diff -r dbff71f51507 -r 845c3045f45c src/plugins/acl/doveadm-acl.c --- a/src/plugins/acl/doveadm-acl.c Sun Feb 12 04:12:44 2012 +0200 +++ b/src/plugins/acl/doveadm-acl.c Sun Feb 12 04:18:50 2012 +0200 @@ -13,6 +13,7 @@ struct doveadm_acl_cmd_context { struct doveadm_mail_cmd_context ctx; bool get_match_me; + enum acl_modify_mode modify_mode; }; const char *doveadm_acl_plugin_version = DOVECOT_VERSION; @@ -229,10 +230,12 @@ } static void -cmd_acl_set_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) +cmd_acl_set_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) { - const char *mailbox = ctx->args[0], *id = ctx->args[1]; - const char *const *rights = ctx->args + 2; + struct doveadm_acl_cmd_context *ctx = + (struct doveadm_acl_cmd_context *)_ctx; + const char *mailbox = _ctx->args[0], *id = _ctx->args[1]; + const char *const *rights = _ctx->args + 2; ARRAY_TYPE(const_string) dest_rights, dest_neg_rights, *dest; struct mailbox *box; struct acl_object *aclobj; @@ -243,8 +246,8 @@ return; memset(&update, 0, sizeof(update)); - update.modify_mode = ACL_MODIFY_MODE_REPLACE; - update.neg_modify_mode = ACL_MODIFY_MODE_REPLACE; + update.modify_mode = ctx->modify_mode; + update.neg_modify_mode = ctx->modify_mode; if (acl_identifier_parse(id, &update.rights) < 0) i_fatal("Invalid ID: %s", id); @@ -278,13 +281,13 @@ if (array_count(&dest_rights) > 0) { (void)array_append_space(&dest_rights); update.rights.rights = array_idx(&dest_rights, 0); - } else { + } else if (update.modify_mode == ACL_MODIFY_MODE_REPLACE) { update.modify_mode = ACL_MODIFY_MODE_CLEAR; } if (array_count(&dest_neg_rights) > 0) { (void)array_append_space(&dest_neg_rights); update.rights.neg_rights = array_idx(&dest_neg_rights, 0); - } else { + } else if (update.neg_modify_mode == ACL_MODIFY_MODE_REPLACE) { update.neg_modify_mode = ACL_MODIFY_MODE_CLEAR; } @@ -302,14 +305,30 @@ } static struct doveadm_mail_cmd_context * -cmd_acl_set_alloc(void) +cmd_acl_change_alloc(enum acl_modify_mode modify_mode) { - struct doveadm_mail_cmd_context *ctx; + struct doveadm_acl_cmd_context *ctx; - ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); - ctx->v.run = cmd_acl_set_run; - ctx->v.init = cmd_acl_set_init; - return ctx; + ctx = doveadm_mail_cmd_alloc(struct doveadm_acl_cmd_context); + ctx->ctx.v.run = cmd_acl_set_run; + ctx->ctx.v.init = cmd_acl_set_init; + ctx->modify_mode = modify_mode; + return &ctx->ctx; +} + +static struct doveadm_mail_cmd_context *cmd_acl_set_alloc(void) +{ + return cmd_acl_change_alloc(ACL_MODIFY_MODE_REPLACE); +} + +static struct doveadm_mail_cmd_context *cmd_acl_add_alloc(void) +{ + return cmd_acl_change_alloc(ACL_MODIFY_MODE_ADD); +} + +static struct doveadm_mail_cmd_context *cmd_acl_remove_alloc(void) +{ + return cmd_acl_change_alloc(ACL_MODIFY_MODE_REMOVE); } static void @@ -539,6 +558,8 @@ { cmd_acl_get_alloc, "acl get", "[-m] " }, { cmd_acl_rights_alloc, "acl rights", "" }, { cmd_acl_set_alloc, "acl set", " [ ...]" }, + { cmd_acl_add_alloc, "acl add", " [ ...]" }, + { cmd_acl_remove_alloc, "acl remove", " [ ...]" }, { cmd_acl_delete_alloc, "acl delete", " " }, { cmd_acl_debug_alloc, "acl debug", "" } }; From dovecot at dovecot.org Sun Feb 12 04:58:28 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 04:58:28 +0200 Subject: dovecot-2.1: expire: Only go through users listed by userdb iter... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/f889e25711a1 changeset: 14120:f889e25711a1 user: Timo Sirainen date: Sun Feb 12 04:58:17 2012 +0200 description: expire: Only go through users listed by userdb iteration. Delete dict rows for nonexistent users, unless expire_keep_nonexistent_users=yes. diffstat: src/plugins/expire/doveadm-expire.c | 73 ++++++++++++++++++++++++++---------- 1 files changed, 52 insertions(+), 21 deletions(-) diffs (164 lines): diff -r 845c3045f45c -r f889e25711a1 src/plugins/expire/doveadm-expire.c --- a/src/plugins/expire/doveadm-expire.c Sun Feb 12 04:18:50 2012 +0200 +++ b/src/plugins/expire/doveadm-expire.c Sun Feb 12 04:58:17 2012 +0200 @@ -14,6 +14,12 @@ #define DOVEADM_EXPIRE_MAIL_CMD_CONTEXT(obj) \ MODULE_CONTEXT(obj, doveadm_expire_mail_cmd_module) +enum expire_user_state { + EXPIRE_USER_STATE_NONEXISTENT = 0, + EXPIRE_USER_STATE_EXISTS = 1, + EXPIRE_USER_STATE_SEEN = 2 +}; + struct expire_query { const char *mailbox; struct imap_match_glob *glob; @@ -27,9 +33,10 @@ struct dict_transaction_context *trans; struct dict_iterate_context *iter; - struct hash_table *seen_users; + struct hash_table *users; ARRAY_DEFINE(queries, struct expire_query); time_t oldest_before_time; + bool delete_nonexistent_users; }; const char *doveadm_expire_plugin_version = DOVECOT_VERSION; @@ -62,41 +69,51 @@ return FALSE; } -static bool +static int doveadm_expire_mail_want(struct doveadm_mail_cmd_context *ctx, - const char *key, time_t oldest_savedate, + const char *dict_key, time_t oldest_savedate, const char **username_r) { struct doveadm_expire_mail_cmd_context *ectx = DOVEADM_EXPIRE_MAIL_CMD_CONTEXT(ctx); const char *username, *mailbox; - char *username_dup; + enum expire_user_state state; + void *key, *value; - /* key = DICT_EXPIRE_PREFIX/ */ - username = key + strlen(DICT_EXPIRE_PREFIX); + /* dict_key = DICT_EXPIRE_PREFIX/ */ + username = dict_key + strlen(DICT_EXPIRE_PREFIX); mailbox = strchr(username, '/'); if (mailbox == NULL) { /* invalid record, ignore */ - i_error("expire: Invalid key: %s", key); - return FALSE; + i_error("expire: Invalid key: %s", dict_key); + return -1; } username = t_strdup_until(username, mailbox++); - if (hash_table_lookup(ectx->seen_users, username) != NULL) { + if (!hash_table_lookup_full(ectx->users, username, &key, &value)) { + /* user no longer exists, delete the record */ + return -1; + } + state = POINTER_CAST_TO(value, enum expire_user_state); + switch (state) { + case EXPIRE_USER_STATE_NONEXISTENT: + i_unreached(); + case EXPIRE_USER_STATE_EXISTS: + break; + case EXPIRE_USER_STATE_SEEN: /* seen this user already, skip the record */ - return FALSE; + return 0; } if (!doveadm_expire_mail_match_mailbox(ectx, mailbox, oldest_savedate)) { /* this mailbox doesn't have any matching messages */ - return FALSE; + return 0; } - username_dup = p_strdup(ctx->pool, username); - hash_table_insert(ectx->seen_users, username_dup, username_dup); - - *username_r = username_dup; - return TRUE; + hash_table_update(ectx->users, key, + POINTER_CAST(EXPIRE_USER_STATE_SEEN)); + *username_r = key; + return 1; } static int @@ -107,7 +124,7 @@ DOVEADM_EXPIRE_MAIL_CMD_CONTEXT(ctx); const char *key, *value; unsigned long oldest_savedate; - bool ret; + int ret; while (dict_iterate(ectx->iter, &key, &value)) { if (str_to_ulong(value, &oldest_savedate) < 0) { @@ -129,8 +146,12 @@ oldest_savedate, username_r); } T_END; - if (ret) + if (ret > 0) return TRUE; + if (ret < 0 && ectx->delete_nonexistent_users) { + /* user has been deleted */ + dict_unset(ectx->trans, key); + } } /* finished */ @@ -331,7 +352,7 @@ } dict_transaction_commit(&ectx->trans); dict_deinit(&ectx->dict); - hash_table_destroy(&ectx->seen_users); + hash_table_destroy(&ectx->users); ectx->module_ctx.super.deinit(ctx); } @@ -341,7 +362,8 @@ struct doveadm_expire_mail_cmd_context *ectx; struct dict *dict; const struct expire_query *query; - const char *expire_dict; + const char *expire_dict, *username, *value; + char *username_dup; if (ctx->search_args == NULL) return; @@ -360,6 +382,9 @@ ectx = p_new(ctx->pool, struct doveadm_expire_mail_cmd_context, 1); ectx->module_ctx.super = ctx->v; + value = doveadm_plugin_getenv("expire_keep_nonexistent_users"); + ectx->delete_nonexistent_users = + value == NULL || strcmp(value, "yes") != 0; MODULE_CONTEXT_SET(ctx, doveadm_expire_mail_cmd_module, ectx); /* we can potentially optimize this query. see if the search args @@ -387,9 +412,15 @@ ctx->v.deinit = doveadm_expire_mail_cmd_deinit; ctx->v.get_next_user = doveadm_expire_mail_cmd_get_next_user; - ectx->seen_users = + ectx->users = hash_table_create(default_pool, ctx->pool, 0, str_hash, (hash_cmp_callback_t *)strcmp); + while (mail_storage_service_all_next(ctx->storage_service, &username) > 0) { + username_dup = p_strdup(ctx->pool, username); + hash_table_insert(ectx->users, username_dup, + POINTER_CAST(EXPIRE_USER_STATE_EXISTS)); + } + ectx->dict = dict; ectx->trans = dict_transaction_begin(dict); ectx->iter = dict_iterate_init(dict, DICT_EXPIRE_PREFIX, From dovecot at dovecot.org Sun Feb 12 05:18:06 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 05:18:06 +0200 Subject: dovecot-2.1: sdbox: Don't assert-crash on index rebuild if u.X f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5f96fb9f079b changeset: 14121:5f96fb9f079b user: Timo Sirainen date: Sun Feb 12 05:16:43 2012 +0200 description: sdbox: Don't assert-crash on index rebuild if u.X file exists in both primary and alt storage. diffstat: src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diffs (38 lines): diff -r f889e25711a1 -r 5f96fb9f079b src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Sun Feb 12 04:58:17 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Sun Feb 12 05:16:43 2012 +0200 @@ -25,8 +25,9 @@ &uid_validity, sizeof(uid_validity), TRUE); } -static int sdbox_sync_add_file_index(struct dbox_sync_rebuild_context *ctx, - struct dbox_file *file, uint32_t uid) +static int +sdbox_sync_add_file_index(struct dbox_sync_rebuild_context *ctx, + struct dbox_file *file, uint32_t uid, bool primary) { uint32_t seq; bool deleted; @@ -50,6 +51,13 @@ return 0; } + if (!dbox_file_is_in_alt(file) && !primary) { + /* we were supposed to open the file in alt storage, but it + exists in primary storage as well. skip it to avoid adding + it twice. */ + return 0; + } + mail_index_append(ctx->trans, uid, &seq); T_BEGIN { dbox_sync_rebuild_index_metadata(ctx, seq, uid); @@ -80,7 +88,7 @@ file = sdbox_file_init(mbox, uid); if (!primary) file->cur_path = file->alt_path; - ret = sdbox_sync_add_file_index(ctx, file, uid); + ret = sdbox_sync_add_file_index(ctx, file, uid, primary); dbox_file_unref(&file); return ret; } From dovecot at dovecot.org Sun Feb 12 05:18:06 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 05:18:06 +0200 Subject: dovecot-2.1: doveadm: Changes for previous expire plugin changes... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b77aa92e3931 changeset: 14122:b77aa92e3931 user: Timo Sirainen date: Sun Feb 12 05:17:46 2012 +0200 description: doveadm: Changes for previous expire plugin changes to actually work. diffstat: src/doveadm/doveadm-mail.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 5f96fb9f079b -r b77aa92e3931 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Sun Feb 12 05:16:43 2012 +0200 +++ b/src/doveadm/doveadm-mail.c Sun Feb 12 05:17:46 2012 +0200 @@ -288,14 +288,15 @@ lib_signals_set_handler(SIGTERM, 0, sig_die, NULL); ctx->v.init(ctx, (const void *)argv); - if (hook_doveadm_mail_init != NULL) - hook_doveadm_mail_init(ctx); user_count = mail_storage_service_all_init(ctx->storage_service); n = user_count / 10000; for (interval = 10; n > 0 && interval < 1000; interval *= 10) n /= 10; + if (hook_doveadm_mail_init != NULL) + hook_doveadm_mail_init(ctx); + user_idx = 0; while ((ret = ctx->v.get_next_user(ctx, &user)) > 0) { if (wildcard_user != NULL) { From dovecot at dovecot.org Sun Feb 12 05:36:04 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 05:36:04 +0200 Subject: dovecot-2.1: director: Log an error if auth connection disconnec... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9b70d164e974 changeset: 14123:9b70d164e974 user: Timo Sirainen date: Sun Feb 12 05:35:54 2012 +0200 description: director: Log an error if auth connection disconnects unexpectedly. diffstat: src/director/auth-connection.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r b77aa92e3931 -r 9b70d164e974 src/director/auth-connection.c --- a/src/director/auth-connection.c Sun Feb 12 05:17:46 2012 +0200 +++ b/src/director/auth-connection.c Sun Feb 12 05:35:54 2012 +0200 @@ -38,6 +38,7 @@ return; case -1: /* disconnected */ + i_error("Auth server disconnected unexpectedly"); auth_connection_disconnected(&conn); return; case -2: From dovecot at dovecot.org Sun Feb 12 05:44:52 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 05:44:52 +0200 Subject: dovecot-2.1: dsync: Don't assert-crash if saving a message fails. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/57c735865b19 changeset: 14124:57c735865b19 user: Timo Sirainen date: Sun Feb 12 05:44:13 2012 +0200 description: dsync: Don't assert-crash if saving a message fails. diffstat: src/doveadm/dsync/dsync-worker-local.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diffs (29 lines): diff -r 9b70d164e974 -r 57c735865b19 src/doveadm/dsync/dsync-worker-local.c --- a/src/doveadm/dsync/dsync-worker-local.c Sun Feb 12 05:35:54 2012 +0200 +++ b/src/doveadm/dsync/dsync-worker-local.c Sun Feb 12 05:44:13 2012 +0200 @@ -1627,10 +1627,14 @@ struct mailbox *dest_box = worker->ext_mail->box; dsync_worker_save_callback_t *callback; ssize_t ret; + bool save_failed = FALSE; while ((ret = i_stream_read(worker->save_input)) > 0 || ret == -2) { - if (mailbox_save_continue(worker->save_ctx) < 0) + if (mailbox_save_continue(worker->save_ctx) < 0) { + save_failed = TRUE; + ret = -1; break; + } } if (ret == 0) { if (worker->save_io != NULL) @@ -1651,6 +1655,9 @@ i_error("read(msg input) failed: %m"); mailbox_save_cancel(&worker->save_ctx); dsync_worker_set_failure(&worker->worker); + } else if (save_failed) { + mailbox_save_cancel(&worker->save_ctx); + dsync_worker_set_failure(&worker->worker); } else { i_assert(worker->save_input->eof); if (mailbox_save_finish(&worker->save_ctx) < 0) { From dovecot at dovecot.org Sun Feb 12 05:45:09 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 05:45:09 +0200 Subject: dovecot-2.0: dsync: Don't assert-crash if saving a message fails. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/eed2b8fb2a52 changeset: 13052:eed2b8fb2a52 user: Timo Sirainen date: Sun Feb 12 05:45:04 2012 +0200 description: dsync: Don't assert-crash if saving a message fails. diffstat: src/dsync/dsync-worker-local.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diffs (29 lines): diff -r 71dbe30caedb -r eed2b8fb2a52 src/dsync/dsync-worker-local.c --- a/src/dsync/dsync-worker-local.c Sun Feb 12 03:47:01 2012 +0200 +++ b/src/dsync/dsync-worker-local.c Sun Feb 12 05:45:04 2012 +0200 @@ -1681,10 +1681,14 @@ struct mailbox *dest_box = worker->ext_mail->box; dsync_worker_save_callback_t *callback; ssize_t ret; + bool save_failed = FALSE; while ((ret = i_stream_read(worker->save_input)) > 0 || ret == -2) { - if (mailbox_save_continue(worker->save_ctx) < 0) + if (mailbox_save_continue(worker->save_ctx) < 0) { + save_failed = TRUE; + ret = -1; break; + } } if (ret == 0) { if (worker->save_io != NULL) @@ -1705,6 +1709,9 @@ i_error("read(msg input) failed: %m"); mailbox_save_cancel(&worker->save_ctx); dsync_worker_set_failure(&worker->worker); + } else if (save_failed) { + mailbox_save_cancel(&worker->save_ctx); + dsync_worker_set_failure(&worker->worker); } else { i_assert(worker->save_input->eof); if (mailbox_save_finish(&worker->save_ctx) < 0) { From dovecot at dovecot.org Sun Feb 12 06:51:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 06:51:14 +0200 Subject: dovecot-2.1: sdbox: Fixed sdbox_read_header() randomly failing. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7517c752f2f5 changeset: 14126:7517c752f2f5 user: Timo Sirainen date: Sun Feb 12 06:51:05 2012 +0200 description: sdbox: Fixed sdbox_read_header() randomly failing. diffstat: src/lib-storage/index/dbox-single/sdbox-storage.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r e778e2c76f6f -r 7517c752f2f5 src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Sun Feb 12 06:47:22 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Sun Feb 12 06:51:05 2012 +0200 @@ -121,7 +121,7 @@ struct mail_index_view *view; const void *data; size_t data_size; - int ret; + int ret = 0; view = mail_index_view_open(mbox->box.index); mail_index_get_header_ext(view, mbox->hdr_ext_id, From dovecot at dovecot.org Sun Feb 12 06:51:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 06:51:14 +0200 Subject: dovecot-2.1: lib-storage: Error handling fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e778e2c76f6f changeset: 14125:e778e2c76f6f user: Timo Sirainen date: Sun Feb 12 06:47:22 2012 +0200 description: lib-storage: Error handling fix. diffstat: src/lib-storage/fail-mailbox.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (17 lines): diff -r 57c735865b19 -r e778e2c76f6f src/lib-storage/fail-mailbox.c --- a/src/lib-storage/fail-mailbox.c Sun Feb 12 05:44:13 2012 +0200 +++ b/src/lib-storage/fail-mailbox.c Sun Feb 12 06:47:22 2012 +0200 @@ -120,11 +120,11 @@ fail_mailbox_sync_deinit(struct mailbox_sync_context *ctx, struct mailbox_sync_status *status_r) { + mail_storage_set_error(ctx->box->storage, MAIL_ERROR_NOTFOUND, + T_MAIL_ERR_MAILBOX_NOT_FOUND(ctx->box->vname)); if (status_r != NULL) memset(status_r, 0, sizeof(*status_r)); i_free(ctx); - mail_storage_set_error(ctx->box->storage, MAIL_ERROR_NOTFOUND, - T_MAIL_ERR_MAILBOX_NOT_FOUND(ctx->box->vname)); return -1; } From dovecot at dovecot.org Sun Feb 12 07:00:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 07:00:24 +0200 Subject: dovecot-2.1: lib-lda: Send DSN instead of MDN for rejections. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/264821ba38a8 changeset: 14128:264821ba38a8 user: Timo Sirainen date: Sun Feb 12 07:00:12 2012 +0200 description: lib-lda: Send DSN instead of MDN for rejections. I had just copy&pasted the MDN sending from Cyrus.. diffstat: src/lib-lda/mail-send.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diffs (38 lines): diff -r 731d9f2cd25d -r 264821ba38a8 src/lib-lda/mail-send.c --- a/src/lib-lda/mail-send.c Sun Feb 12 06:59:32 2012 +0200 +++ b/src/lib-lda/mail-send.c Sun Feb 12 07:00:12 2012 +0200 @@ -99,7 +99,7 @@ fprintf(f, "To: <%s>\r\n", return_addr); fprintf(f, "MIME-Version: 1.0\r\n"); fprintf(f, "Content-Type: " - "multipart/report; report-type=disposition-notification;\r\n" + "multipart/report; report-type=delivery-status;\r\n" "\tboundary=\"%s\"\r\n", boundary); str = t_str_new(256); @@ -122,20 +122,18 @@ get_var_expand_table(mail, reason, recipient)); fprintf(f, "%s\r\n", str_c(str)); - /* MDN status report */ + /* DSN status report */ fprintf(f, "--%s\r\n" - "Content-Type: message/disposition-notification\r\n\r\n", + "Content-Type: message/delivery-status\r\n\r\n", boundary); - fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n", + fprintf(f, "Reporting-MTA: dns; %s\r\n", ctx->set->hostname); if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); - if (orig_msgid != NULL) - fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid); - fprintf(f, "Disposition: " - "automatic-action/MDN-sent-automatically; deleted\r\n"); + fprintf(f, "Action: failed\r\n"); + fprintf(f, "Status: 5.2.0\r\n"); fprintf(f, "\r\n"); /* original message's headers */ From dovecot at dovecot.org Sun Feb 12 07:00:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 07:00:23 +0200 Subject: dovecot-2.1: lib-storage: "Invalid userdb input" showed wrong in... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/731d9f2cd25d changeset: 14127:731d9f2cd25d user: Timo Sirainen date: Sun Feb 12 06:59:32 2012 +0200 description: lib-storage: "Invalid userdb input" showed wrong input in the error message. diffstat: src/lib-storage/mail-storage-service.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (21 lines): diff -r 7517c752f2f5 -r 731d9f2cd25d src/lib-storage/mail-storage-service.c --- a/src/lib-storage/mail-storage-service.c Sun Feb 12 06:51:05 2012 +0200 +++ b/src/lib-storage/mail-storage-service.c Sun Feb 12 06:59:32 2012 +0200 @@ -253,7 +253,7 @@ } str = array_get(&reply->extra_fields, &count); - for (i = 0; i < count && ret >= 0; i++) { + for (i = 0; i < count; i++) { line = str[i]; if (strncmp(line, "system_groups_user=", 19) == 0) { user->system_groups_user = @@ -270,6 +270,8 @@ } else T_BEGIN { ret = set_line(ctx, user, line); } T_END; + if (ret < 0) + break; } if (ret < 0) { From dovecot at dovecot.org Sun Feb 12 07:05:19 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 07:05:19 +0200 Subject: dovecot-2.1: lda: If DSN is sent because user is out of quota, s... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ee060d756630 changeset: 14129:ee060d756630 user: Timo Sirainen date: Sun Feb 12 07:05:07 2012 +0200 description: lda: If DSN is sent because user is out of quota, send 5.2.2 as Status. diffstat: src/lda/main.c | 1 + src/lib-lda/mail-deliver.h | 2 ++ src/lib-lda/mail-send.c | 2 +- 3 files changed, 4 insertions(+), 1 deletions(-) diffs (35 lines): diff -r 264821ba38a8 -r ee060d756630 src/lda/main.c --- a/src/lda/main.c Sun Feb 12 07:00:12 2012 +0200 +++ b/src/lda/main.c Sun Feb 12 07:05:07 2012 +0200 @@ -453,6 +453,7 @@ configuration problem. */ return EX_TEMPFAIL; } + ctx.mailbox_full = TRUE; /* we'll have to reply with permanent failure */ mail_deliver_log(&ctx, "rejected: %s", diff -r 264821ba38a8 -r ee060d756630 src/lib-lda/mail-deliver.h --- a/src/lib-lda/mail-deliver.h Sun Feb 12 07:00:12 2012 +0200 +++ b/src/lib-lda/mail-deliver.h Sun Feb 12 07:05:07 2012 +0200 @@ -51,6 +51,8 @@ bool tried_default_save; bool saved_mail; bool save_dest_mail; + /* Delivery failed because user is out of quota / disk space */ + bool mailbox_full; }; struct mail_deliver_save_open_context { diff -r 264821ba38a8 -r ee060d756630 src/lib-lda/mail-send.c --- a/src/lib-lda/mail-send.c Sun Feb 12 07:00:12 2012 +0200 +++ b/src/lib-lda/mail-send.c Sun Feb 12 07:05:07 2012 +0200 @@ -133,7 +133,7 @@ fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); fprintf(f, "Action: failed\r\n"); - fprintf(f, "Status: 5.2.0\r\n"); + fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0"); fprintf(f, "\r\n"); /* original message's headers */ From dovecot at dovecot.org Sun Feb 12 07:12:54 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 07:12:54 +0200 Subject: dovecot-2.1: Make static analyzer happier. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/996a03279431 changeset: 14130:996a03279431 user: Timo Sirainen date: Sun Feb 12 07:12:41 2012 +0200 description: Make static analyzer happier. diffstat: src/lib-storage/index/index-thread-finish.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diffs (18 lines): diff -r ee060d756630 -r 996a03279431 src/lib-storage/index/index-thread-finish.c --- a/src/lib-storage/index/index-thread-finish.c Sun Feb 12 07:05:07 2012 +0200 +++ b/src/lib-storage/index/index-thread-finish.c Sun Feb 12 07:12:41 2012 +0200 @@ -650,11 +650,9 @@ return NULL; child = &children[iter->next_idx++]; - if (child_iter_r != NULL) { - shadow = array_idx(&iter->ctx->shadow_nodes, child->idx); - *child_iter_r = shadow->first_child_idx == 0 ? NULL : - mail_thread_iterate_children(iter, child->idx); - } + shadow = array_idx(&iter->ctx->shadow_nodes, child->idx); + *child_iter_r = shadow->first_child_idx == 0 ? NULL : + mail_thread_iterate_children(iter, child->idx); if (child->uid == 0 && *child_iter_r == NULL) { /* this is a dummy node without children, there's no point in returning it */ From dovecot at dovecot.org Sun Feb 12 07:25:50 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 07:25:50 +0200 Subject: dovecot-2.1: example-config: Updated instance_name setting's com... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b9e74767cd39 changeset: 14131:b9e74767cd39 user: Timo Sirainen date: Sun Feb 12 07:25:40 2012 +0200 description: example-config: Updated instance_name setting's comments. diffstat: doc/example-config/dovecot.conf | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 996a03279431 -r b9e74767cd39 doc/example-config/dovecot.conf --- a/doc/example-config/dovecot.conf Sun Feb 12 07:12:41 2012 +0200 +++ b/doc/example-config/dovecot.conf Sun Feb 12 07:25:40 2012 +0200 @@ -28,7 +28,10 @@ # Base directory where to store runtime data. #base_dir = /var/run/dovecot/ -# Name of this instance. Used to prefix all Dovecot processes in ps output. +# Name of this instance. In multi-instance setup doveadm and other commands +# can use -i to select which instance is used (an alternative +# to -c ). The instance name is also added to Dovecot processes +# in ps output. #instance_name = dovecot # Greeting message for clients. From dovecot at dovecot.org Sun Feb 12 18:26:49 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 18:26:49 +0200 Subject: dovecot-2.1: lib-lda: Send DSN only for out-of-quota errors. Sen... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ad5298ba3229 changeset: 14132:ad5298ba3229 user: Timo Sirainen date: Sun Feb 12 18:26:22 2012 +0200 description: lib-lda: Send DSN only for out-of-quota errors. Send MDN for Sieve rejects. diffstat: src/lda/main.c | 1 + src/lib-lda/mail-deliver.h | 2 ++ src/lib-lda/mail-send.c | 45 ++++++++++++++++++++++++++++++++------------- 3 files changed, 35 insertions(+), 13 deletions(-) diffs (86 lines): diff -r b9e74767cd39 -r ad5298ba3229 src/lda/main.c --- a/src/lda/main.c Sun Feb 12 07:25:40 2012 +0200 +++ b/src/lda/main.c Sun Feb 12 18:26:22 2012 +0200 @@ -454,6 +454,7 @@ return EX_TEMPFAIL; } ctx.mailbox_full = TRUE; + ctx.dsn = TRUE; /* we'll have to reply with permanent failure */ mail_deliver_log(&ctx, "rejected: %s", diff -r b9e74767cd39 -r ad5298ba3229 src/lib-lda/mail-deliver.h --- a/src/lib-lda/mail-deliver.h Sun Feb 12 07:25:40 2012 +0200 +++ b/src/lib-lda/mail-deliver.h Sun Feb 12 18:26:22 2012 +0200 @@ -53,6 +53,8 @@ bool save_dest_mail; /* Delivery failed because user is out of quota / disk space */ bool mailbox_full; + /* Send DSN instead of MDN */ + bool dsn; }; struct mail_deliver_save_open_context { diff -r b9e74767cd39 -r ad5298ba3229 src/lib-lda/mail-send.c --- a/src/lib-lda/mail-send.c Sun Feb 12 07:25:40 2012 +0200 +++ b/src/lib-lda/mail-send.c Sun Feb 12 18:26:22 2012 +0200 @@ -99,8 +99,10 @@ fprintf(f, "To: <%s>\r\n", return_addr); fprintf(f, "MIME-Version: 1.0\r\n"); fprintf(f, "Content-Type: " - "multipart/report; report-type=delivery-status;\r\n" - "\tboundary=\"%s\"\r\n", boundary); + "multipart/report; report-type=%s;\r\n" + "\tboundary=\"%s\"\r\n", + ctx->dsn ? "delivery-status" : "disposition-notification", + boundary); str = t_str_new(256); var_expand(str, ctx->set->rejection_subject, @@ -122,18 +124,35 @@ get_var_expand_table(mail, reason, recipient)); fprintf(f, "%s\r\n", str_c(str)); - /* DSN status report */ - fprintf(f, "--%s\r\n" - "Content-Type: message/delivery-status\r\n\r\n", - boundary); - fprintf(f, "Reporting-MTA: dns; %s\r\n", - ctx->set->hostname); - if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) - fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); - fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); + if (ctx->dsn) { + /* DSN status report: For LDA rejects. currently only used when + user is out of quota */ + fprintf(f, "--%s\r\n" + "Content-Type: message/delivery-status\r\n\r\n", + boundary); + fprintf(f, "Reporting-MTA: dns; %s\r\n", + ctx->set->hostname); + if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) + fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); + fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); + fprintf(f, "Action: failed\r\n"); + fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0"); + } else { + /* MDN status report: For Sieve "reject" */ + fprintf(f, "--%s\r\n" + "Content-Type: message/disposition-notification\r\n\r\n", + boundary); + fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n", + ctx->set->hostname); + if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) + fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); + fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); - fprintf(f, "Action: failed\r\n"); - fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0"); + if (orig_msgid != NULL) + fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid); + fprintf(f, "Disposition: " + "automatic-action/MDN-sent-automatically; deleted\r\n"); + } fprintf(f, "\r\n"); /* original message's headers */ From dovecot at dovecot.org Sun Feb 12 18:55:42 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 18:55:42 +0200 Subject: dovecot-2.1: Updated copyright notices to include year 2012. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ba770cba5598 changeset: 14133:ba770cba5598 user: Timo Sirainen date: Sun Feb 12 18:55:28 2012 +0200 description: Updated copyright notices to include year 2012. diffstat: src/anvil/anvil-connection.c | 2 +- src/anvil/anvil-settings.c | 2 +- src/anvil/connect-limit.c | 2 +- src/anvil/main.c | 2 +- src/anvil/penalty.c | 2 +- src/anvil/test-penalty.c | 2 +- src/auth/auth-cache.c | 2 +- src/auth/auth-client-connection.c | 2 +- src/auth/auth-master-connection.c | 2 +- src/auth/auth-penalty.c | 2 +- src/auth/auth-postfix-connection.c | 2 +- src/auth/auth-request-handler.c | 2 +- src/auth/auth-request.c | 2 +- src/auth/auth-settings.c | 2 +- src/auth/auth-stream.c | 2 +- src/auth/auth-worker-client.c | 2 +- src/auth/auth-worker-server.c | 2 +- src/auth/auth.c | 2 +- src/auth/db-checkpassword.c | 2 +- src/auth/db-ldap.c | 2 +- src/auth/db-passwd-file.c | 2 +- src/auth/db-sql.c | 2 +- src/auth/main.c | 2 +- src/auth/mech-anonymous.c | 2 +- src/auth/mech-cram-md5.c | 2 +- src/auth/mech-digest-md5.c | 2 +- src/auth/mech-external.c | 2 +- src/auth/mech-plain.c | 2 +- src/auth/mech.c | 2 +- src/auth/passdb-blocking.c | 2 +- src/auth/passdb-bsdauth.c | 2 +- src/auth/passdb-cache.c | 2 +- src/auth/passdb-checkpassword.c | 2 +- src/auth/passdb-imap.c | 2 +- src/auth/passdb-ldap.c | 2 +- src/auth/passdb-passwd-file.c | 2 +- src/auth/passdb-passwd.c | 2 +- src/auth/passdb-shadow.c | 2 +- src/auth/passdb-sql.c | 2 +- src/auth/passdb-static.c | 2 +- src/auth/passdb-template.c | 2 +- src/auth/passdb-vpopmail.c | 2 +- src/auth/passdb.c | 2 +- src/auth/password-scheme-crypt.c | 2 +- src/auth/password-scheme.c | 2 +- src/auth/userdb-blocking.c | 2 +- src/auth/userdb-checkpassword.c | 2 +- src/auth/userdb-ldap.c | 2 +- src/auth/userdb-nss.c | 2 +- src/auth/userdb-passwd-file.c | 2 +- src/auth/userdb-passwd.c | 2 +- src/auth/userdb-prefetch.c | 2 +- src/auth/userdb-sql.c | 2 +- src/auth/userdb-static.c | 2 +- src/auth/userdb-template.c | 2 +- src/auth/userdb-vpopmail.c | 2 +- src/auth/userdb.c | 2 +- src/config/config-connection.c | 2 +- src/config/config-filter.c | 2 +- src/config/config-parser.c | 2 +- src/config/config-request.c | 2 +- src/config/config-settings.c | 2 +- src/config/doveconf.c | 2 +- src/config/main.c | 2 +- src/config/old-set-parser.c | 2 +- src/config/sysinfo-get.c | 2 +- src/dict/dict-commands.c | 2 +- src/dict/dict-connection.c | 2 +- src/dict/dict-settings.c | 2 +- src/dict/main.c | 2 +- src/director/auth-connection.c | 2 +- src/director/director-connection.c | 2 +- src/director/director-host.c | 2 +- src/director/director-request.c | 2 +- src/director/director-settings.c | 2 +- src/director/director-test.c | 2 +- src/director/director.c | 2 +- src/director/doveadm-connection.c | 2 +- src/director/login-connection.c | 2 +- src/director/mail-host.c | 2 +- src/director/main.c | 2 +- src/director/notify-connection.c | 2 +- src/director/user-directory.c | 2 +- src/dns/dns-client-settings.c | 2 +- src/dns/dns-client.c | 2 +- src/doveadm/client-connection.c | 2 +- src/doveadm/doveadm-auth.c | 2 +- src/doveadm/doveadm-director.c | 2 +- src/doveadm/doveadm-dump-dbox.c | 2 +- src/doveadm/doveadm-dump-index.c | 2 +- src/doveadm/doveadm-dump-log.c | 2 +- src/doveadm/doveadm-dump-mailboxlog.c | 2 +- src/doveadm/doveadm-dump-thread.c | 2 +- src/doveadm/doveadm-dump.c | 2 +- src/doveadm/doveadm-kick.c | 2 +- src/doveadm/doveadm-log.c | 2 +- src/doveadm/doveadm-mail-altmove.c | 2 +- src/doveadm/doveadm-mail-expunge.c | 2 +- src/doveadm/doveadm-mail-fetch.c | 2 +- src/doveadm/doveadm-mail-import.c | 2 +- src/doveadm/doveadm-mail-index.c | 2 +- src/doveadm/doveadm-mail-iter.c | 2 +- src/doveadm/doveadm-mail-list-iter.c | 2 +- src/doveadm/doveadm-mail-mailbox-status.c | 2 +- src/doveadm/doveadm-mail-mailbox.c | 2 +- src/doveadm/doveadm-mail-move.c | 2 +- src/doveadm/doveadm-mail-search.c | 2 +- src/doveadm/doveadm-mail-server.c | 2 +- src/doveadm/doveadm-mail.c | 2 +- src/doveadm/doveadm-master.c | 2 +- src/doveadm/doveadm-mutf7.c | 2 +- src/doveadm/doveadm-penalty.c | 2 +- src/doveadm/doveadm-print-flow.c | 2 +- src/doveadm/doveadm-print-pager.c | 2 +- src/doveadm/doveadm-print-server.c | 2 +- src/doveadm/doveadm-print-tab.c | 2 +- src/doveadm/doveadm-print-table.c | 2 +- src/doveadm/doveadm-print.c | 2 +- src/doveadm/doveadm-proxy.c | 2 +- src/doveadm/doveadm-settings.c | 2 +- src/doveadm/doveadm-sis.c | 2 +- src/doveadm/doveadm-stats.c | 2 +- src/doveadm/doveadm-util.c | 2 +- src/doveadm/doveadm-who.c | 2 +- src/doveadm/doveadm.c | 2 +- src/doveadm/dsync/doveadm-dsync.c | 2 +- src/doveadm/dsync/dsync-brain-msgs-new.c | 2 +- src/doveadm/dsync/dsync-brain-msgs.c | 2 +- src/doveadm/dsync/dsync-brain.c | 2 +- src/doveadm/dsync/dsync-data.c | 2 +- src/doveadm/dsync/dsync-proxy-client.c | 2 +- src/doveadm/dsync/dsync-proxy-server-cmd.c | 2 +- src/doveadm/dsync/dsync-proxy-server.c | 2 +- src/doveadm/dsync/dsync-proxy.c | 2 +- src/doveadm/dsync/dsync-worker-local.c | 2 +- src/doveadm/dsync/dsync-worker.c | 2 +- src/doveadm/dsync/test-dsync-brain-msgs.c | 2 +- src/doveadm/dsync/test-dsync-brain.c | 2 +- src/doveadm/dsync/test-dsync-common.c | 2 +- src/doveadm/dsync/test-dsync-proxy-server-cmd.c | 2 +- src/doveadm/dsync/test-dsync-proxy.c | 2 +- src/doveadm/dsync/test-dsync-worker.c | 2 +- src/doveadm/main.c | 2 +- src/doveadm/server-connection.c | 2 +- src/imap-login/client-authenticate.c | 2 +- src/imap-login/client.c | 2 +- src/imap-login/imap-login-settings.c | 2 +- src/imap-login/imap-proxy.c | 2 +- src/imap/cmd-append.c | 2 +- src/imap/cmd-cancelupdate.c | 2 +- src/imap/cmd-capability.c | 2 +- src/imap/cmd-check.c | 2 +- src/imap/cmd-close.c | 2 +- src/imap/cmd-copy.c | 2 +- src/imap/cmd-create.c | 2 +- src/imap/cmd-delete.c | 2 +- src/imap/cmd-enable.c | 2 +- src/imap/cmd-examine.c | 2 +- src/imap/cmd-expunge.c | 2 +- src/imap/cmd-fetch.c | 2 +- src/imap/cmd-id.c | 2 +- src/imap/cmd-idle.c | 2 +- src/imap/cmd-list.c | 2 +- src/imap/cmd-logout.c | 2 +- src/imap/cmd-lsub.c | 2 +- src/imap/cmd-namespace.c | 2 +- src/imap/cmd-noop.c | 2 +- src/imap/cmd-rename.c | 2 +- src/imap/cmd-search.c | 2 +- src/imap/cmd-select.c | 2 +- src/imap/cmd-sort.c | 2 +- src/imap/cmd-status.c | 2 +- src/imap/cmd-store.c | 2 +- src/imap/cmd-subscribe.c | 2 +- src/imap/cmd-thread.c | 2 +- src/imap/cmd-uid.c | 2 +- src/imap/cmd-unselect.c | 2 +- src/imap/cmd-unsubscribe.c | 2 +- src/imap/cmd-x-cancel.c | 2 +- src/imap/imap-client.c | 2 +- src/imap/imap-commands-util.c | 2 +- src/imap/imap-commands.c | 2 +- src/imap/imap-expunge.c | 2 +- src/imap/imap-fetch-body.c | 2 +- src/imap/imap-fetch.c | 2 +- src/imap/imap-search-args.c | 2 +- src/imap/imap-search.c | 2 +- src/imap/imap-settings.c | 2 +- src/imap/imap-status.c | 2 +- src/imap/imap-sync.c | 2 +- src/imap/mail-storage-callbacks.c | 2 +- src/imap/main.c | 2 +- src/indexer/indexer-client.c | 2 +- src/indexer/indexer-queue.c | 2 +- src/indexer/indexer-settings.c | 2 +- src/indexer/indexer-worker-settings.c | 2 +- src/indexer/indexer-worker.c | 2 +- src/indexer/indexer.c | 2 +- src/indexer/master-connection.c | 2 +- src/indexer/worker-connection.c | 2 +- src/indexer/worker-pool.c | 2 +- src/ipc/client.c | 2 +- src/ipc/ipc-connection.c | 2 +- src/ipc/ipc-group.c | 2 +- src/ipc/ipc-settings.c | 2 +- src/ipc/main.c | 2 +- src/lda/main.c | 2 +- src/lib-auth/auth-client-request.c | 2 +- src/lib-auth/auth-client.c | 2 +- src/lib-auth/auth-master.c | 2 +- src/lib-auth/auth-server-connection.c | 2 +- src/lib-charset/charset-iconv.c | 2 +- src/lib-charset/charset-utf8.c | 2 +- src/lib-dict/dict-client.c | 2 +- src/lib-dict/dict-db.c | 2 +- src/lib-dict/dict-file.c | 2 +- src/lib-dict/dict-sql-settings.c | 2 +- src/lib-dict/dict-sql.c | 2 +- src/lib-dict/dict.c | 2 +- src/lib-dict/test-dict.c | 2 +- src/lib-dns/dns-lookup.c | 2 +- src/lib-fs/fs-api.c | 2 +- src/lib-fs/fs-posix.c | 2 +- src/lib-fs/fs-sis-common.c | 2 +- src/lib-fs/fs-sis-queue.c | 2 +- src/lib-fs/fs-sis.c | 2 +- src/lib-fs/ostream-cmp.c | 2 +- src/lib-imap-client/imapc-client.c | 2 +- src/lib-imap-client/imapc-connection.c | 2 +- src/lib-imap-client/imapc-msgmap.c | 2 +- src/lib-imap/imap-arg.c | 2 +- src/lib-imap/imap-base-subject.c | 2 +- src/lib-imap/imap-bodystructure.c | 2 +- src/lib-imap/imap-date.c | 2 +- src/lib-imap/imap-envelope.c | 2 +- src/lib-imap/imap-id.c | 2 +- src/lib-imap/imap-match.c | 2 +- src/lib-imap/imap-parser.c | 2 +- src/lib-imap/imap-quote.c | 2 +- src/lib-imap/imap-seqset.c | 2 +- src/lib-imap/imap-utf7.c | 2 +- src/lib-imap/imap-util.c | 2 +- src/lib-imap/test-imap-match.c | 2 +- src/lib-imap/test-imap-parser.c | 2 +- src/lib-imap/test-imap-utf7.c | 2 +- src/lib-imap/test-imap-util.c | 2 +- src/lib-index/mail-cache-compress.c | 2 +- src/lib-index/mail-cache-decisions.c | 2 +- src/lib-index/mail-cache-fields.c | 2 +- src/lib-index/mail-cache-lookup.c | 2 +- src/lib-index/mail-cache-sync-update.c | 2 +- src/lib-index/mail-cache-transaction.c | 2 +- src/lib-index/mail-cache.c | 2 +- src/lib-index/mail-index-alloc-cache.c | 2 +- src/lib-index/mail-index-dummy-view.c | 2 +- src/lib-index/mail-index-fsck.c | 2 +- src/lib-index/mail-index-lock.c | 2 +- src/lib-index/mail-index-map-hdr.c | 2 +- src/lib-index/mail-index-map-read.c | 2 +- src/lib-index/mail-index-map.c | 2 +- src/lib-index/mail-index-modseq.c | 2 +- src/lib-index/mail-index-strmap.c | 2 +- src/lib-index/mail-index-sync-ext.c | 2 +- src/lib-index/mail-index-sync-keywords.c | 2 +- src/lib-index/mail-index-sync-update.c | 2 +- src/lib-index/mail-index-sync.c | 2 +- src/lib-index/mail-index-transaction-export.c | 2 +- src/lib-index/mail-index-transaction-finish.c | 2 +- src/lib-index/mail-index-transaction-sort-appends.c | 2 +- src/lib-index/mail-index-transaction-update.c | 2 +- src/lib-index/mail-index-transaction-view.c | 2 +- src/lib-index/mail-index-transaction.c | 2 +- src/lib-index/mail-index-util.c | 2 +- src/lib-index/mail-index-view-sync.c | 2 +- src/lib-index/mail-index-view.c | 2 +- src/lib-index/mail-index-write.c | 2 +- src/lib-index/mail-index.c | 2 +- src/lib-index/mail-transaction-log-append.c | 2 +- src/lib-index/mail-transaction-log-file.c | 2 +- src/lib-index/mail-transaction-log-view.c | 2 +- src/lib-index/mail-transaction-log.c | 2 +- src/lib-index/mailbox-log.c | 2 +- src/lib-index/test-mail-index-sync-ext.c | 2 +- src/lib-index/test-mail-index-transaction-finish.c | 2 +- src/lib-index/test-mail-index-transaction-update.c | 2 +- src/lib-index/test-mail-transaction-log-append.c | 2 +- src/lib-index/test-mail-transaction-log-view.c | 2 +- src/lib-lda/duplicate.c | 2 +- src/lib-lda/lda-settings.c | 2 +- src/lib-lda/lmtp-client.c | 2 +- src/lib-lda/mail-deliver.c | 2 +- src/lib-lda/mail-send.c | 2 +- src/lib-lda/smtp-client.c | 2 +- src/lib-mail/istream-dot.c | 2 +- src/lib-mail/istream-header-filter.c | 2 +- src/lib-mail/mbox-from.c | 2 +- src/lib-mail/message-address.c | 2 +- src/lib-mail/message-date.c | 2 +- src/lib-mail/message-decoder.c | 2 +- src/lib-mail/message-header-decode.c | 2 +- src/lib-mail/message-header-encode.c | 2 +- src/lib-mail/message-header-parser.c | 2 +- src/lib-mail/message-id.c | 2 +- src/lib-mail/message-parser.c | 2 +- src/lib-mail/message-part-serialize.c | 2 +- src/lib-mail/message-search.c | 2 +- src/lib-mail/message-send.c | 2 +- src/lib-mail/message-size.c | 2 +- src/lib-mail/quoted-printable.c | 2 +- src/lib-mail/rfc2231-parser.c | 2 +- src/lib-mail/rfc822-parser.c | 2 +- src/lib-mail/test-istream-dot.c | 2 +- src/lib-mail/test-istream-header-filter.c | 2 +- src/lib-mail/test-mbox-from.c | 2 +- src/lib-mail/test-message-address.c | 2 +- src/lib-mail/test-message-date.c | 2 +- src/lib-mail/test-message-decoder.c | 2 +- src/lib-mail/test-message-header-decode.c | 2 +- src/lib-mail/test-message-header-encode.c | 2 +- src/lib-mail/test-message-header-parser.c | 2 +- src/lib-mail/test-message-id.c | 2 +- src/lib-mail/test-message-parser.c | 2 +- src/lib-mail/test-quoted-printable.c | 2 +- src/lib-mail/test-rfc2231-parser.c | 2 +- src/lib-master/anvil-client.c | 2 +- src/lib-master/ipc-client.c | 2 +- src/lib-master/ipc-server.c | 2 +- src/lib-master/master-auth.c | 2 +- src/lib-master/master-login-auth.c | 2 +- src/lib-master/master-login.c | 2 +- src/lib-master/master-service-settings-cache.c | 2 +- src/lib-master/master-service-settings.c | 2 +- src/lib-master/master-service.c | 2 +- src/lib-master/syslog-util.c | 2 +- src/lib-settings/settings-parser.c | 2 +- src/lib-settings/settings.c | 2 +- src/lib-sql/driver-mysql.c | 2 +- src/lib-sql/driver-pgsql.c | 2 +- src/lib-sql/driver-sqlpool.c | 2 +- src/lib-sql/sql-api.c | 2 +- src/lib-sql/sql-db-cache.c | 2 +- src/lib-ssl-iostream/iostream-openssl-context.c | 2 +- src/lib-ssl-iostream/iostream-openssl-params.c | 2 +- src/lib-ssl-iostream/iostream-openssl.c | 2 +- src/lib-ssl-iostream/iostream-ssl-none.c | 2 +- src/lib-ssl-iostream/istream-openssl.c | 2 +- src/lib-ssl-iostream/ostream-openssl.c | 2 +- src/lib-storage/fail-mail-storage.c | 2 +- src/lib-storage/fail-mail.c | 2 +- src/lib-storage/fail-mailbox.c | 2 +- src/lib-storage/index/cydir/cydir-mail.c | 2 +- src/lib-storage/index/cydir/cydir-save.c | 2 +- src/lib-storage/index/cydir/cydir-storage.c | 2 +- src/lib-storage/index/cydir/cydir-sync.c | 2 +- src/lib-storage/index/dbox-common/dbox-attachment.c | 2 +- src/lib-storage/index/dbox-common/dbox-file-fix.c | 2 +- src/lib-storage/index/dbox-common/dbox-file.c | 2 +- src/lib-storage/index/dbox-common/dbox-mail.c | 2 +- src/lib-storage/index/dbox-common/dbox-save.c | 2 +- src/lib-storage/index/dbox-common/dbox-storage.c | 2 +- src/lib-storage/index/dbox-common/dbox-sync-rebuild.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-file.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-mail.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-map.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-purge.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-save.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-settings.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-storage.c | 2 +- src/lib-storage/index/dbox-multi/mdbox-sync.c | 2 +- src/lib-storage/index/dbox-single/sdbox-copy.c | 2 +- src/lib-storage/index/dbox-single/sdbox-file.c | 2 +- src/lib-storage/index/dbox-single/sdbox-mail.c | 2 +- src/lib-storage/index/dbox-single/sdbox-save.c | 2 +- src/lib-storage/index/dbox-single/sdbox-storage.c | 2 +- src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +- src/lib-storage/index/dbox-single/sdbox-sync.c | 2 +- src/lib-storage/index/imapc/imapc-list.c | 2 +- src/lib-storage/index/imapc/imapc-mail-fetch.c | 2 +- src/lib-storage/index/imapc/imapc-mail.c | 2 +- src/lib-storage/index/imapc/imapc-mailbox.c | 2 +- src/lib-storage/index/imapc/imapc-save.c | 2 +- src/lib-storage/index/imapc/imapc-settings.c | 2 +- src/lib-storage/index/imapc/imapc-storage.c | 2 +- src/lib-storage/index/imapc/imapc-sync.c | 2 +- src/lib-storage/index/index-attachment.c | 2 +- src/lib-storage/index/index-mail-headers.c | 2 +- src/lib-storage/index/index-mail.c | 2 +- src/lib-storage/index/index-mailbox-check.c | 2 +- src/lib-storage/index/index-search-result.c | 2 +- src/lib-storage/index/index-search.c | 2 +- src/lib-storage/index/index-sort-string.c | 2 +- src/lib-storage/index/index-sort.c | 2 +- src/lib-storage/index/index-status.c | 2 +- src/lib-storage/index/index-storage.c | 2 +- src/lib-storage/index/index-sync-changes.c | 2 +- src/lib-storage/index/index-sync-search.c | 2 +- src/lib-storage/index/index-sync.c | 2 +- src/lib-storage/index/index-thread-finish.c | 2 +- src/lib-storage/index/index-thread-links.c | 2 +- src/lib-storage/index/index-thread.c | 2 +- src/lib-storage/index/index-transaction.c | 2 +- src/lib-storage/index/istream-attachment.c | 2 +- src/lib-storage/index/istream-mail.c | 2 +- src/lib-storage/index/maildir/maildir-copy.c | 2 +- src/lib-storage/index/maildir/maildir-filename-flags.c | 2 +- src/lib-storage/index/maildir/maildir-filename.c | 2 +- src/lib-storage/index/maildir/maildir-keywords.c | 2 +- src/lib-storage/index/maildir/maildir-mail.c | 2 +- src/lib-storage/index/maildir/maildir-save.c | 2 +- src/lib-storage/index/maildir/maildir-settings.c | 2 +- src/lib-storage/index/maildir/maildir-storage.c | 2 +- src/lib-storage/index/maildir/maildir-sync-index.c | 2 +- src/lib-storage/index/maildir/maildir-sync.c | 2 +- src/lib-storage/index/maildir/maildir-uidlist.c | 2 +- src/lib-storage/index/maildir/maildir-util.c | 2 +- src/lib-storage/index/mbox/istream-raw-mbox.c | 2 +- src/lib-storage/index/mbox/mbox-file.c | 2 +- src/lib-storage/index/mbox/mbox-lock.c | 2 +- src/lib-storage/index/mbox/mbox-mail.c | 2 +- src/lib-storage/index/mbox/mbox-md5-all.c | 2 +- src/lib-storage/index/mbox/mbox-md5-apop3d.c | 2 +- src/lib-storage/index/mbox/mbox-save.c | 2 +- src/lib-storage/index/mbox/mbox-settings.c | 2 +- src/lib-storage/index/mbox/mbox-storage.c | 2 +- src/lib-storage/index/mbox/mbox-sync-parse.c | 2 +- src/lib-storage/index/mbox/mbox-sync-rewrite.c | 2 +- src/lib-storage/index/mbox/mbox-sync-update.c | 2 +- src/lib-storage/index/mbox/mbox-sync.c | 2 +- src/lib-storage/index/pop3c/pop3c-client.c | 2 +- src/lib-storage/index/pop3c/pop3c-mail.c | 2 +- src/lib-storage/index/pop3c/pop3c-settings.c | 2 +- src/lib-storage/index/pop3c/pop3c-storage.c | 2 +- src/lib-storage/index/pop3c/pop3c-sync.c | 2 +- src/lib-storage/index/raw/raw-mail.c | 2 +- src/lib-storage/index/raw/raw-storage.c | 2 +- src/lib-storage/index/raw/raw-sync.c | 2 +- src/lib-storage/index/shared/shared-list.c | 2 +- src/lib-storage/index/shared/shared-storage.c | 2 +- src/lib-storage/list/mailbox-list-delete.c | 2 +- src/lib-storage/list/mailbox-list-fs-flags.c | 2 +- src/lib-storage/list/mailbox-list-fs-iter.c | 2 +- src/lib-storage/list/mailbox-list-fs.c | 2 +- src/lib-storage/list/mailbox-list-index-iter.c | 2 +- src/lib-storage/list/mailbox-list-index-status.c | 2 +- src/lib-storage/list/mailbox-list-index-sync.c | 2 +- src/lib-storage/list/mailbox-list-index.c | 2 +- src/lib-storage/list/mailbox-list-maildir-iter.c | 2 +- src/lib-storage/list/mailbox-list-maildir.c | 2 +- src/lib-storage/list/mailbox-list-none.c | 2 +- src/lib-storage/list/mailbox-list-subscriptions.c | 2 +- src/lib-storage/list/subscription-file.c | 2 +- src/lib-storage/mail-copy.c | 2 +- src/lib-storage/mail-error.c | 2 +- src/lib-storage/mail-namespace.c | 2 +- src/lib-storage/mail-search-build.c | 2 +- src/lib-storage/mail-search-parser-cmdline.c | 2 +- src/lib-storage/mail-search-parser-imap.c | 2 +- src/lib-storage/mail-search-parser.c | 2 +- src/lib-storage/mail-search-register-human.c | 2 +- src/lib-storage/mail-search-register-imap.c | 2 +- src/lib-storage/mail-search-register.c | 2 +- src/lib-storage/mail-search.c | 2 +- src/lib-storage/mail-storage-hooks.c | 2 +- src/lib-storage/mail-storage-service.c | 2 +- src/lib-storage/mail-storage-settings.c | 2 +- src/lib-storage/mail-storage.c | 2 +- src/lib-storage/mail-thread.c | 2 +- src/lib-storage/mail-user.c | 2 +- src/lib-storage/mail.c | 2 +- src/lib-storage/mailbox-get.c | 2 +- src/lib-storage/mailbox-guid-cache.c | 2 +- src/lib-storage/mailbox-header.c | 2 +- src/lib-storage/mailbox-keywords.c | 2 +- src/lib-storage/mailbox-list-iter.c | 2 +- src/lib-storage/mailbox-list.c | 2 +- src/lib-storage/mailbox-search-result.c | 2 +- src/lib-storage/mailbox-tree.c | 2 +- src/lib-storage/mailbox-uidvalidity.c | 2 +- src/lib-storage/test-mailbox-get.c | 2 +- src/lib-test/test-common.c | 2 +- src/lib/abspath.c | 2 +- src/lib/aqueue.c | 2 +- src/lib/array.c | 2 +- src/lib/askpass.c | 2 +- src/lib/backtrace-string.c | 2 +- src/lib/base64.c | 2 +- src/lib/bsearch-insert-pos.c | 2 +- src/lib/buffer.c | 2 +- src/lib/child-wait.c | 2 +- src/lib/close-keep-errno.c | 2 +- src/lib/compat.c | 2 +- src/lib/crc32.c | 2 +- src/lib/data-stack.c | 2 +- src/lib/eacces-error.c | 2 +- src/lib/env-util.c | 2 +- src/lib/execv-const.c | 2 +- src/lib/failures.c | 2 +- src/lib/fd-close-on-exec.c | 2 +- src/lib/fd-set-nonblock.c | 2 +- src/lib/fdatasync-path.c | 2 +- src/lib/fdpass.c | 2 +- src/lib/file-cache.c | 2 +- src/lib/file-copy.c | 2 +- src/lib/file-dotlock.c | 2 +- src/lib/file-lock.c | 2 +- src/lib/file-set-size.c | 2 +- src/lib/guid.c | 2 +- src/lib/hash-format.c | 2 +- src/lib/hash-method.c | 2 +- src/lib/hash.c | 2 +- src/lib/hash2.c | 2 +- src/lib/hex-binary.c | 2 +- src/lib/hex-dec.c | 2 +- src/lib/home-expand.c | 2 +- src/lib/hostpid.c | 2 +- src/lib/imem.c | 2 +- src/lib/ioloop-notify-dn.c | 2 +- src/lib/ioloop-notify-fd.c | 2 +- src/lib/ioloop-notify-inotify.c | 2 +- src/lib/ioloop-notify-none.c | 2 +- src/lib/ioloop-poll.c | 2 +- src/lib/ioloop-select.c | 2 +- src/lib/ioloop.c | 2 +- src/lib/iostream-rawlog.c | 2 +- src/lib/iostream.c | 2 +- src/lib/ipwd.c | 2 +- src/lib/istream-base64-encoder.c | 2 +- src/lib/istream-concat.c | 2 +- src/lib/istream-crlf.c | 2 +- src/lib/istream-data.c | 2 +- src/lib/istream-file.c | 2 +- src/lib/istream-limit.c | 2 +- src/lib/istream-mmap.c | 2 +- src/lib/istream-rawlog.c | 2 +- src/lib/istream-seekable.c | 2 +- src/lib/istream-tee.c | 2 +- src/lib/istream.c | 2 +- src/lib/lib-signals.c | 2 +- src/lib/lib.c | 2 +- src/lib/mempool-alloconly.c | 2 +- src/lib/mempool-datastack.c | 2 +- src/lib/mempool-system.c | 2 +- src/lib/mempool-unsafe-datastack.c | 2 +- src/lib/mempool.c | 2 +- src/lib/mkdir-parents.c | 2 +- src/lib/mmap-anon.c | 2 +- src/lib/mmap-util.c | 2 +- src/lib/module-dir.c | 2 +- src/lib/mountpoint.c | 2 +- src/lib/network.c | 2 +- src/lib/nfs-workarounds.c | 2 +- src/lib/ostream-buffer.c | 2 +- src/lib/ostream-file.c | 2 +- src/lib/ostream-rawlog.c | 2 +- src/lib/ostream.c | 2 +- src/lib/printf-format-fix.c | 2 +- src/lib/priorityq.c | 2 +- src/lib/process-title.c | 2 +- src/lib/randgen.c | 2 +- src/lib/read-full.c | 2 +- src/lib/restrict-access.c | 2 +- src/lib/restrict-process-size.c | 2 +- src/lib/safe-memset.c | 2 +- src/lib/safe-mkdir.c | 2 +- src/lib/safe-mkstemp.c | 2 +- src/lib/sendfile-util.c | 2 +- src/lib/seq-range-array.c | 2 +- src/lib/str-find.c | 2 +- src/lib/str-sanitize.c | 2 +- src/lib/str.c | 2 +- src/lib/strescape.c | 2 +- src/lib/strfuncs.c | 2 +- src/lib/strnum.c | 2 +- src/lib/test-aqueue.c | 2 +- src/lib/test-array.c | 2 +- src/lib/test-base64.c | 2 +- src/lib/test-bsearch-insert-pos.c | 2 +- src/lib/test-buffer.c | 2 +- src/lib/test-crc32.c | 2 +- src/lib/test-hash-format.c | 2 +- src/lib/test-hex-binary.c | 2 +- src/lib/test-istream-base64-encoder.c | 2 +- src/lib/test-istream-concat.c | 2 +- src/lib/test-istream-crlf.c | 2 +- src/lib/test-istream-seekable.c | 2 +- src/lib/test-istream-tee.c | 2 +- src/lib/test-lib.c | 2 +- src/lib/test-llist.c | 2 +- src/lib/test-mempool-alloconly.c | 2 +- src/lib/test-network.c | 2 +- src/lib/test-ostream-file.c | 2 +- src/lib/test-primes.c | 2 +- src/lib/test-priorityq.c | 2 +- src/lib/test-seq-range-array.c | 2 +- src/lib/test-str-find.c | 2 +- src/lib/test-str-sanitize.c | 2 +- src/lib/test-strescape.c | 2 +- src/lib/test-strfuncs.c | 2 +- src/lib/test-time-util.c | 2 +- src/lib/test-utc-mktime.c | 2 +- src/lib/test-var-expand.c | 2 +- src/lib/time-util.c | 2 +- src/lib/unichar.c | 2 +- src/lib/unix-socket-create.c | 2 +- src/lib/unlink-directory.c | 2 +- src/lib/unlink-old-files.c | 2 +- src/lib/utc-mktime.c | 2 +- src/lib/utc-offset.c | 2 +- src/lib/var-expand.c | 2 +- src/lib/write-full.c | 2 +- src/lmtp/client.c | 2 +- src/lmtp/commands.c | 2 +- src/lmtp/lmtp-proxy.c | 2 +- src/lmtp/lmtp-settings.c | 2 +- src/lmtp/main.c | 2 +- src/log/log-connection.c | 2 +- src/log/log-settings.c | 2 +- src/log/main.c | 2 +- src/login-common/access-lookup.c | 2 +- src/login-common/client-common-auth.c | 2 +- src/login-common/client-common.c | 2 +- src/login-common/login-proxy-state.c | 2 +- src/login-common/login-proxy.c | 2 +- src/login-common/login-settings.c | 2 +- src/login-common/main.c | 2 +- src/login-common/sasl-server.c | 2 +- src/login-common/ssl-proxy-gnutls.c | 2 +- src/login-common/ssl-proxy-openssl.c | 2 +- src/login-common/ssl-proxy.c | 2 +- src/master/dup2-array.c | 2 +- src/master/main.c | 2 +- src/master/master-settings.c | 2 +- src/master/service-anvil.c | 2 +- src/master/service-listen.c | 2 +- src/master/service-log.c | 2 +- src/master/service-monitor.c | 2 +- src/master/service-process-notify.c | 2 +- src/master/service-process.c | 2 +- src/master/service.c | 2 +- src/plugins/acl/acl-api.c | 2 +- src/plugins/acl/acl-backend-vfile-acllist.c | 2 +- src/plugins/acl/acl-backend-vfile.c | 2 +- src/plugins/acl/acl-backend.c | 2 +- src/plugins/acl/acl-cache.c | 2 +- src/plugins/acl/acl-lookup-dict.c | 2 +- src/plugins/acl/acl-mailbox-list.c | 2 +- src/plugins/acl/acl-mailbox.c | 2 +- src/plugins/acl/acl-plugin.c | 2 +- src/plugins/acl/acl-shared-storage.c | 2 +- src/plugins/acl/acl-storage.c | 2 +- src/plugins/acl/doveadm-acl.c | 2 +- src/plugins/autocreate/autocreate-plugin.c | 2 +- src/plugins/expire/doveadm-expire.c | 2 +- src/plugins/expire/expire-plugin.c | 2 +- src/plugins/expire/expire-set.c | 2 +- src/plugins/fts-lucene/doveadm-fts-lucene.c | 2 +- src/plugins/fts-lucene/fts-backend-lucene.c | 2 +- src/plugins/fts-lucene/fts-lucene-plugin.c | 2 +- src/plugins/fts-solr/fts-backend-solr-old.c | 2 +- src/plugins/fts-solr/fts-backend-solr.c | 2 +- src/plugins/fts-solr/fts-solr-plugin.c | 2 +- src/plugins/fts-solr/solr-connection.c | 2 +- src/plugins/fts-squat/fts-backend-squat.c | 2 +- src/plugins/fts-squat/fts-squat-plugin.c | 2 +- src/plugins/fts-squat/squat-test.c | 2 +- src/plugins/fts-squat/squat-trie.c | 2 +- src/plugins/fts-squat/squat-uidlist.c | 2 +- src/plugins/fts/doveadm-dump-fts-expunge-log.c | 2 +- src/plugins/fts/doveadm-fts.c | 2 +- src/plugins/fts/fts-api.c | 2 +- src/plugins/fts/fts-build-mail.c | 2 +- src/plugins/fts/fts-expunge-log.c | 2 +- src/plugins/fts/fts-indexer.c | 2 +- src/plugins/fts/fts-parser-html.c | 2 +- src/plugins/fts/fts-parser-script.c | 2 +- src/plugins/fts/fts-parser.c | 2 +- src/plugins/fts/fts-plugin.c | 2 +- src/plugins/fts/fts-search-serialize.c | 2 +- src/plugins/fts/fts-search.c | 2 +- src/plugins/fts/fts-storage.c | 2 +- src/plugins/fts/xml2text.c | 2 +- src/plugins/imap-acl/imap-acl-plugin.c | 2 +- src/plugins/imap-quota/imap-quota-plugin.c | 2 +- src/plugins/imap-stats/imap-stats-plugin.c | 2 +- src/plugins/imap-zlib/imap-zlib-plugin.c | 2 +- src/plugins/lazy-expunge/lazy-expunge-plugin.c | 2 +- src/plugins/listescape/listescape-plugin.c | 2 +- src/plugins/mail-log/mail-log-plugin.c | 2 +- src/plugins/quota/doveadm-quota.c | 2 +- src/plugins/quota/quota-count.c | 2 +- src/plugins/quota/quota-dict.c | 2 +- src/plugins/quota/quota-dirsize.c | 2 +- src/plugins/quota/quota-fs.c | 2 +- src/plugins/quota/quota-maildir.c | 2 +- src/plugins/quota/quota-plugin.c | 2 +- src/plugins/quota/quota-storage.c | 2 +- src/plugins/quota/quota.c | 2 +- src/plugins/snarf/snarf-plugin.c | 2 +- src/plugins/stats/stats-connection.c | 2 +- src/plugins/stats/stats-plugin.c | 2 +- src/plugins/trash/trash-plugin.c | 2 +- src/plugins/virtual/virtual-config.c | 2 +- src/plugins/virtual/virtual-mail.c | 2 +- src/plugins/virtual/virtual-plugin.c | 2 +- src/plugins/virtual/virtual-save.c | 2 +- src/plugins/virtual/virtual-search.c | 2 +- src/plugins/virtual/virtual-storage.c | 2 +- src/plugins/virtual/virtual-sync.c | 2 +- src/plugins/virtual/virtual-transaction.c | 2 +- src/plugins/zlib/doveadm-zlib.c | 2 +- src/plugins/zlib/istream-bzlib.c | 2 +- src/plugins/zlib/istream-zlib.c | 2 +- src/plugins/zlib/ostream-bzlib.c | 2 +- src/plugins/zlib/ostream-zlib.c | 2 +- src/plugins/zlib/zlib-plugin.c | 2 +- src/pop3-login/client-authenticate.c | 2 +- src/pop3-login/client.c | 2 +- src/pop3-login/pop3-login-settings.c | 2 +- src/pop3-login/pop3-proxy.c | 2 +- src/pop3/main.c | 2 +- src/pop3/pop3-client.c | 2 +- src/pop3/pop3-commands.c | 2 +- src/pop3/pop3-settings.c | 2 +- src/ssl-params/main.c | 2 +- src/ssl-params/ssl-params-openssl.c | 2 +- src/ssl-params/ssl-params-settings.c | 2 +- src/ssl-params/ssl-params.c | 2 +- src/stats/client-export.c | 2 +- src/stats/client.c | 2 +- src/stats/global-memory.c | 2 +- src/stats/mail-command.c | 2 +- src/stats/mail-domain.c | 2 +- src/stats/mail-ip.c | 2 +- src/stats/mail-server-connection.c | 2 +- src/stats/mail-session.c | 2 +- src/stats/mail-stats.c | 2 +- src/stats/mail-user.c | 2 +- src/stats/main.c | 2 +- src/stats/stats-settings.c | 2 +- src/util/gdbhelper.c | 2 +- src/util/maildirlock.c | 2 +- src/util/rawlog.c | 2 +- src/util/script-login.c | 2 +- src/util/script.c | 2 +- src/util/tcpwrap-settings.c | 2 +- src/util/tcpwrap.c | 2 +- 747 files changed, 747 insertions(+), 747 deletions(-) diffs (truncated from 6723 to 300 lines): diff -r ad5298ba3229 -r ba770cba5598 src/anvil/anvil-connection.c --- a/src/anvil/anvil-connection.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/anvil/anvil-connection.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "common.h" #include "llist.h" diff -r ad5298ba3229 -r ba770cba5598 src/anvil/anvil-settings.c --- a/src/anvil/anvil-settings.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/anvil/anvil-settings.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "buffer.h" diff -r ad5298ba3229 -r ba770cba5598 src/anvil/connect-limit.c --- a/src/anvil/connect-limit.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/anvil/connect-limit.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "common.h" #include "hash.h" diff -r ad5298ba3229 -r ba770cba5598 src/anvil/main.c --- a/src/anvil/main.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/anvil/main.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "common.h" #include "array.h" diff -r ad5298ba3229 -r ba770cba5598 src/anvil/penalty.c --- a/src/anvil/penalty.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/anvil/penalty.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/anvil/test-penalty.c --- a/src/anvil/test-penalty.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/anvil/test-penalty.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-cache.c --- a/src/auth/auth-cache.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-cache.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "lib-signals.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-client-connection.c --- a/src/auth/auth-client-connection.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-client-connection.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-master-connection.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "buffer.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-penalty.c --- a/src/auth/auth-penalty.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-penalty.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-postfix-connection.c --- a/src/auth/auth-postfix-connection.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-postfix-connection.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2011-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-request-handler.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-request.c --- a/src/auth/auth-request.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-request.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-settings.c --- a/src/auth/auth-settings.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-settings.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "array.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-stream.c --- a/src/auth/auth-stream.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-stream.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "str.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-worker-client.c --- a/src/auth/auth-worker-client.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-worker-client.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "base64.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth-worker-server.c --- a/src/auth/auth-worker-server.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth-worker-server.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/auth.c --- a/src/auth/auth.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/auth.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/db-checkpassword.c --- a/src/auth/db-checkpassword.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/db-checkpassword.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/db-ldap.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2003-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/db-passwd-file.c --- a/src/auth/db-passwd-file.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/db-passwd-file.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/db-sql.c --- a/src/auth/db-sql.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/db-sql.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2003-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/main.c --- a/src/auth/main.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/main.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "array.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/mech-anonymous.c --- a/src/auth/mech-anonymous.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/mech-anonymous.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "mech.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/mech-cram-md5.c --- a/src/auth/mech-cram-md5.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/mech-cram-md5.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ /* CRAM-MD5 SASL authentication, see RFC-2195 Joshua Goodall */ diff -r ad5298ba3229 -r ba770cba5598 src/auth/mech-digest-md5.c --- a/src/auth/mech-digest-md5.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/mech-digest-md5.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ /* Digest-MD5 SASL authentication, see RFC-2831 */ diff -r ad5298ba3229 -r ba770cba5598 src/auth/mech-external.c --- a/src/auth/mech-external.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/mech-external.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "passdb.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/mech-plain.c --- a/src/auth/mech-plain.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/mech-plain.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "safe-memset.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/mech.c --- a/src/auth/mech.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/mech.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "ioloop.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/passdb-blocking.c --- a/src/auth/passdb-blocking.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/passdb-blocking.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "str.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/passdb-bsdauth.c --- a/src/auth/passdb-bsdauth.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/passdb-bsdauth.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "passdb.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/passdb-cache.c --- a/src/auth/passdb-cache.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/passdb-cache.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "password-scheme.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/passdb-checkpassword.c --- a/src/auth/passdb-checkpassword.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/passdb-checkpassword.c Sun Feb 12 18:55:28 2012 +0200 @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" #include "execv-const.h" diff -r ad5298ba3229 -r ba770cba5598 src/auth/passdb-imap.c --- a/src/auth/passdb-imap.c Sun Feb 12 18:26:22 2012 +0200 +++ b/src/auth/passdb-imap.c Sun Feb 12 18:55:28 2012 +0200 From dovecot at dovecot.org Sun Feb 12 18:59:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 18:59:30 +0200 Subject: dovecot-2.1: example-config: Updated tb-extra-mailbox-sep comment. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1a0ab868957b changeset: 14134:1a0ab868957b user: Timo Sirainen date: Sun Feb 12 18:59:20 2012 +0200 description: example-config: Updated tb-extra-mailbox-sep comment. diffstat: doc/example-config/conf.d/20-imap.conf | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (16 lines): diff -r ba770cba5598 -r 1a0ab868957b doc/example-config/conf.d/20-imap.conf --- a/doc/example-config/conf.d/20-imap.conf Sun Feb 12 18:55:28 2012 +0200 +++ b/doc/example-config/conf.d/20-imap.conf Sun Feb 12 18:59:20 2012 +0200 @@ -45,9 +45,9 @@ # breaks even with this workaround if synchronization is set to # "Headers Only". # tb-extra-mailbox-sep: - # With mbox storage a mailbox can contain either mails or submailboxes, - # but not both. Thunderbird separates these two by forcing server to - # accept '/' suffix in mailbox names in subscriptions list. + # Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and + # adds extra '/' suffixes to mailbox names. This option causes Dovecot to + # ignore the extra '/' instead of treating it as invalid mailbox name. # tb-lsub-flags: # Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox). # This makes Thunderbird realize they aren't selectable and show them From dovecot at dovecot.org Sun Feb 12 19:16:50 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 19:16:50 +0200 Subject: dovecot-2.1: acl: After checking we have rights to create mailbo... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ccad37bc242f changeset: 14135:ccad37bc242f user: Timo Sirainen date: Sun Feb 12 19:16:34 2012 +0200 description: acl: After checking we have rights to create mailbox, ignore any further ACL checks. diffstat: src/plugins/acl/acl-mailbox.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diffs (28 lines): diff -r 1a0ab868957b -r ccad37bc242f src/plugins/acl/acl-mailbox.c --- a/src/plugins/acl/acl-mailbox.c Sun Feb 12 18:59:20 2012 +0200 +++ b/src/plugins/acl/acl-mailbox.c Sun Feb 12 19:16:34 2012 +0200 @@ -122,13 +122,18 @@ bool directory) { struct acl_mailbox *abox = ACL_CONTEXT(box); + int ret; - /* we already checked permissions in list.mailbox_create_dir(). */ - if (abox->module_ctx.super.create(box, update, directory) < 0) - return -1; - - acl_mailbox_copy_acls_from_parent(box); - return 0; + /* we already checked permissions in list.mailbox_create_dir(). + ignore ACLs in this mailbox until creation is complete, because + super.create() may call e.g. mailbox_open() which will fail since + we haven't yet copied ACLs to this mailbox. */ + abox->skip_acl_checks = TRUE; + ret = abox->module_ctx.super.create(box, update, directory); + abox->skip_acl_checks = FALSE; + if (ret == 0) + acl_mailbox_copy_acls_from_parent(box); + return ret; } static int From dovecot at dovecot.org Sun Feb 12 19:20:10 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 19:20:10 +0200 Subject: dovecot-2.1: doveadm pw: Use i_error()/i_fatal() instead of fpri... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7c36dea5605a changeset: 14136:7c36dea5605a user: Timo Sirainen date: Sun Feb 12 19:20:03 2012 +0200 description: doveadm pw: Use i_error()/i_fatal() instead of fprintf(stderr) diffstat: src/doveadm/doveadm-pw.c | 26 +++++++++----------------- 1 files changed, 9 insertions(+), 17 deletions(-) diffs (56 lines): diff -r ccad37bc242f -r 7c36dea5605a src/doveadm/doveadm-pw.c --- a/src/doveadm/doveadm-pw.c Sun Feb 12 19:16:34 2012 +0200 +++ b/src/doveadm/doveadm-pw.c Sun Feb 12 19:20:03 2012 +0200 @@ -87,17 +87,15 @@ plaintext = t_askpass("Enter new password: "); check = t_askpass("Retype new password: "); if (strcmp(plaintext, check) != 0) { - fprintf(stderr, "Passwords don't match!\n"); + i_error("Passwords don't match!"); if (--lives == 0) exit(1); plaintext = NULL; } } - if (!password_generate_encoded(plaintext, user, scheme, &hash)) { - fprintf(stderr, "Unknown scheme: %s\n", scheme); - exit(1); - } + if (!password_generate_encoded(plaintext, user, scheme, &hash)) + i_fatal("Unknown scheme: %s", scheme); if (reverse_verify) { const unsigned char *raw_password; size_t size; @@ -105,25 +103,19 @@ if (test_hash != NULL) { scheme = password_get_scheme(&test_hash); - if (scheme == NULL) { - fprintf(stderr, "Missing {scheme} prefix from hash\n"); - exit(2); - } + if (scheme == NULL) + i_fatal("Missing {scheme} prefix from hash"); hash = test_hash; } if (password_decode(hash, scheme, &raw_password, &size, - &error) <= 0) { - fprintf(stderr, "reverse decode check failed: %s\n", - error); - exit(2); - } + &error) <= 0) + i_fatal("reverse decode check failed: %s", error); if (password_verify(plaintext, user, scheme, raw_password, size, &error) <= 0) { - fprintf(stderr, - "reverse password verification check failed: %s\n", error); - exit(2); + i_fatal("reverse password verification check failed: %s", + error); } printf("{%s}%s (verified)\n", scheme, hash); From dovecot at dovecot.org Sun Feb 12 21:10:42 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 21:10:42 +0200 Subject: dovecot-2.1: doveadm: Improved error handling. Failures should n... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0a5951b08478 changeset: 14137:0a5951b08478 user: Timo Sirainen date: Sun Feb 12 21:10:22 2012 +0200 description: doveadm: Improved error handling. Failures should now always have non-zero exit code. doveadm now uses sysexits.h exit codes in most places, although there are still a lot of places where it simply returns EX_TEMPFAIL even though something else might be better. diffstat: src/doveadm/Makefile.am | 4 +- src/doveadm/client-connection.c | 2 +- src/doveadm/doveadm-auth.c | 26 +-- src/doveadm/doveadm-director.c | 111 +++++++++++++------ src/doveadm/doveadm-dump.c | 8 +- src/doveadm/doveadm-instance.c | 7 +- src/doveadm/doveadm-kick.c | 7 +- src/doveadm/doveadm-log.c | 4 +- src/doveadm/doveadm-mail-altmove.c | 36 ++++-- src/doveadm/doveadm-mail-expunge.c | 33 +++-- src/doveadm/doveadm-mail-fetch.c | 35 ++++-- src/doveadm/doveadm-mail-import.c | 34 ++++-- src/doveadm/doveadm-mail-index.c | 43 +++++-- src/doveadm/doveadm-mail-iter.c | 11 +- src/doveadm/doveadm-mail-iter.h | 4 +- src/doveadm/doveadm-mail-list-iter.c | 152 ---------------------------- src/doveadm/doveadm-mail-list-iter.h | 19 --- src/doveadm/doveadm-mail-mailbox-status.c | 40 ++++-- src/doveadm/doveadm-mail-mailbox.c | 103 +++++++++++++----- src/doveadm/doveadm-mail-move.c | 50 +++++--- src/doveadm/doveadm-mail-search.c | 29 +++-- src/doveadm/doveadm-mail-server.c | 4 +- src/doveadm/doveadm-mail.c | 117 +++++++++++++++++---- src/doveadm/doveadm-mail.h | 15 ++- src/doveadm/doveadm-mailbox-list-iter.c | 162 ++++++++++++++++++++++++++++++ src/doveadm/doveadm-mailbox-list-iter.h | 23 ++++ src/doveadm/doveadm.c | 25 ++++- src/doveadm/doveadm.h | 6 + src/doveadm/dsync/doveadm-dsync.c | 13 +- src/doveadm/main.c | 1 + src/plugins/acl/doveadm-acl.c | 86 ++++++++++----- src/plugins/fts/doveadm-fts.c | 28 +++- src/plugins/quota/doveadm-quota.c | 20 ++- 33 files changed, 805 insertions(+), 453 deletions(-) diffs (truncated from 2839 to 300 lines): diff -r 7c36dea5605a -r 0a5951b08478 src/doveadm/Makefile.am --- a/src/doveadm/Makefile.am Sun Feb 12 19:20:03 2012 +0200 +++ b/src/doveadm/Makefile.am Sun Feb 12 21:10:22 2012 +0200 @@ -72,7 +72,7 @@ doveadm-mail-mailbox.c \ doveadm-mail-mailbox-status.c \ doveadm-mail-move.c \ - doveadm-mail-list-iter.c \ + doveadm-mailbox-list-iter.c \ doveadm-mail-search.c \ doveadm-mail-server.c \ doveadm-print.c \ @@ -121,7 +121,7 @@ doveadm-dump.h \ doveadm-mail.h \ doveadm-mail-iter.h \ - doveadm-mail-list-iter.h \ + doveadm-mailbox-list-iter.h \ doveadm-print.h \ doveadm-print-private.h \ doveadm-server.h \ diff -r 7c36dea5605a -r 0a5951b08478 src/doveadm/client-connection.c --- a/src/doveadm/client-connection.c Sun Feb 12 19:20:03 2012 +0200 +++ b/src/doveadm/client-connection.c Sun Feb 12 21:10:22 2012 +0200 @@ -114,7 +114,7 @@ ctx->v.deinit(ctx); doveadm_print_flush(); mail_storage_service_deinit(&ctx->storage_service); - ret = !ctx->failed; + ret = ctx->exit_code == 0; pool_unref(&ctx->pool); return ret; diff -r 7c36dea5605a -r 0a5951b08478 src/doveadm/doveadm-auth.c --- a/src/doveadm/doveadm-auth.c Sun Feb 12 19:20:03 2012 +0200 +++ b/src/doveadm/doveadm-auth.c Sun Feb 12 21:10:22 2012 +0200 @@ -44,9 +44,9 @@ pool, &username, &fields); if (ret < 0) { if (fields[0] == NULL) - i_fatal("userdb lookup failed for %s", input->username); + i_error("userdb lookup failed for %s", input->username); else { - i_fatal("userdb lookup failed for %s: %s", + i_error("userdb lookup failed for %s: %s", input->username, fields[0]); } } else if (ret == 0) { @@ -139,7 +139,7 @@ auth_callback, input); } -static int +static void cmd_auth_input(const char *auth_socket_path, struct authtest_input *input) { struct auth_client *client; @@ -157,7 +157,6 @@ auth_client_set_connect_notify(client, NULL, NULL); auth_client_deinit(&client); - return 0; } static void auth_user_info_parse(struct auth_user_info *info, const char *arg) @@ -206,10 +205,8 @@ if (users[i] != NULL) printf("%s\n", username); } - if (auth_master_user_list_deinit(&ctx) < 0) { - i_error("user listing failed"); - exit(1); - } + if (auth_master_user_list_deinit(&ctx) < 0) + i_fatal("user listing failed"); auth_master_deinit(&conn); } @@ -243,10 +240,9 @@ t_askpass("Password: "); if (argv[optind] != NULL) i_fatal("Unexpected parameter: %s", argv[optind]); - if (cmd_auth_input(auth_socket_path, &input) < 0) - exit(FATAL_DEFAULT); + cmd_auth_input(auth_socket_path, &input); if (!input.success) - exit(1); + doveadm_exit_code = EX_NOPERM; } static void cmd_user(int argc, char *argv[]) @@ -293,7 +289,6 @@ cmd_user_list(auth_socket_path, &input, argv + optind); else { bool first = TRUE; - bool notfound = FALSE; while ((input.username = argv[optind++]) != NULL) { if (first) @@ -303,14 +298,13 @@ switch (cmd_user_input(auth_socket_path, &input, show_field)) { case -1: - exit(1); + doveadm_exit_code = EX_TEMPFAIL; + break; case 0: - notfound = TRUE; + doveadm_exit_code = EX_NOUSER; break; } } - if (notfound) - exit(2); } } diff -r 7c36dea5605a -r 0a5951b08478 src/doveadm/doveadm-director.c --- a/src/doveadm/doveadm-director.c Sun Feb 12 19:20:03 2012 +0200 +++ b/src/doveadm/doveadm-director.c Sun Feb 12 21:10:22 2012 +0200 @@ -65,8 +65,9 @@ } } if (!version_string_verify(line, "director-doveadm", 1)) { - i_fatal("%s not a compatible director-doveadm socket", - ctx->socket_path); + i_fatal_status(EX_PROTOCOL, + "%s not a compatible director-doveadm socket", + ctx->socket_path); } } @@ -114,14 +115,16 @@ director_send(ctx, t_strdup_printf("USER-LOOKUP\t%s\n", user)); line = i_stream_read_next_line(ctx->input); if (line == NULL) { - printf("Lookup failed\n"); + i_error("Lookup failed"); + doveadm_exit_code = EX_TEMPFAIL; return; } args = t_strsplit(line, "\t"); if (str_array_length(args) != 4 || str_to_uint(args[1], &expires) < 0) { - printf("Invalid reply from director\n"); + i_error("Invalid reply from director"); + doveadm_exit_code = EX_PROTOCOL; return; } @@ -167,6 +170,10 @@ } } T_END; } + if (line == NULL) { + i_error("Director disconnected unexpectedly"); + doveadm_exit_code = EX_TEMPFAIL; + } director_disconnect(ctx); } @@ -216,7 +223,7 @@ user_list_add(username, pool, users); if (auth_master_user_list_deinit(&ctx) < 0) { i_error("user listing failed"); - exit(1); + doveadm_exit_code = EX_TEMPFAIL; } auth_master_deinit(&conn); } @@ -241,14 +248,18 @@ unsigned int *ips_count_r) { struct ip_addr ip; + int ret; if (net_addr2ip(host, &ip) == 0) { *ips_r = t_new(struct ip_addr, 1); **ips_r = ip; *ips_count_r = 1; } else { - if (net_gethostbyname(host, ips_r, ips_count_r) < 0) - i_fatal("gethostname(%s) failed: %m", host); + ret = net_gethostbyname(host, ips_r, ips_count_r); + if (ret != 0) { + i_fatal("gethostname(%s) failed: %s", host, + net_gethosterror(ret)); + } } } @@ -308,9 +319,10 @@ if (str_array_length(args) < 3 || str_to_uint(args[0], &user_hash) < 0 || str_to_uint(args[1], &expires) < 0 || - net_addr2ip(args[2], &user_ip) < 0) + net_addr2ip(args[2], &user_ip) < 0) { i_error("Invalid USER-LIST reply: %s", line); - else if (ips_count == 0 || + doveadm_exit_code = EX_PROTOCOL; + } else if (ips_count == 0 || ip_find(ips, ips_count, &user_ip)) { user = hash_table_lookup(users, POINTER_CAST(user_hash)); @@ -327,6 +339,10 @@ } } T_END; } + if (line == NULL) { + i_error("Director disconnected unexpectedly"); + doveadm_exit_code = EX_TEMPFAIL; + } director_disconnect(ctx); hash_table_destroy(&users); pool_unref(&pool); @@ -364,12 +380,11 @@ if (line == NULL || strcmp(line, "OK") != 0) { fprintf(stderr, "%s: %s\n", net_ip2addr(&ips[i]), line == NULL ? "failed" : line); + doveadm_exit_code = EX_TEMPFAIL; } else if (doveadm_verbose) { printf("%s: OK\n", net_ip2addr(&ips[i])); } } - if (i != ips_count) - i_fatal("director add failed"); director_disconnect(ctx); } @@ -392,17 +407,19 @@ } for (i = 0; i < ips_count; i++) { line = i_stream_read_next_line(ctx->input); - if (line == NULL || strcmp(line, "OK") != 0) { + if (line != NULL && strcmp(line, "NOTFOUND") == 0) { + fprintf(stderr, "%s: doesn't exist\n", + net_ip2addr(&ips[i])); + if (doveadm_exit_code == 0) + doveadm_exit_code = DOVEADM_EX_NOTFOUND; + } else if (line == NULL || strcmp(line, "OK") != 0) { fprintf(stderr, "%s: %s\n", net_ip2addr(&ips[i]), - line == NULL ? "failed" : - (strcmp(line, "NOTFOUND") == 0 ? - "doesn't exist" : line)); + line == NULL ? "failed" : line); + doveadm_exit_code = EX_TEMPFAIL; } else if (doveadm_verbose) { printf("%s: removed\n", net_ip2addr(&ips[i])); } } - if (i != ips_count) - i_fatal("director remove failed"); director_disconnect(ctx); } @@ -426,18 +443,22 @@ director_send(ctx, t_strdup_printf( "USER-MOVE\t%u\t%s\n", user_hash, ip_str)); line = i_stream_read_next_line(ctx->input); - if (line == NULL) - fprintf(stderr, "failed\n"); - else if (strcmp(line, "OK") == 0) { + if (line == NULL) { + i_error("failed"); + doveadm_exit_code = EX_TEMPFAIL; + } else if (strcmp(line, "OK") == 0) { if (doveadm_verbose) printf("User hash %u moved to %s\n", user_hash, ip_str); } else if (strcmp(line, "NOTFOUND") == 0) { - fprintf(stderr, "Host '%s' doesn't exist\n", ip_str); + i_error("Host '%s' doesn't exist", ip_str); + doveadm_exit_code = DOVEADM_EX_NOTFOUND; } else if (strcmp(line, "TRYAGAIN") == 0) { - fprintf(stderr, "User is already being moved, " - "wait a while for it to be finished\n"); + i_error("User is already being moved, " + "wait a while for it to be finished"); + doveadm_exit_code = EX_TEMPFAIL; } else { - fprintf(stderr, "failed: %s\n", line); + i_error("failed: %s", line); + doveadm_exit_code = EX_TEMPFAIL; } director_disconnect(ctx); } @@ -449,11 +470,13 @@ director_send(ctx, "HOST-FLUSH\n"); line = i_stream_read_next_line(ctx->input); - if (line == NULL) - fprintf(stderr, "failed\n"); - else if (strcmp(line, "OK") != 0) - fprintf(stderr, "%s\n", line); - else if (doveadm_verbose) + if (line == NULL) { + i_error("failed"); + doveadm_exit_code = EX_TEMPFAIL; + } else if (strcmp(line, "OK") != 0) { + i_error("failed: %s", line); From dovecot at dovecot.org Sun Feb 12 22:17:02 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 22:17:02 +0200 Subject: dovecot-2.1: doveadm mailbox delete: Don't crash when namespace ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/669f09337a23 changeset: 14138:669f09337a23 user: Timo Sirainen date: Sun Feb 12 22:16:51 2012 +0200 description: doveadm mailbox delete: Don't crash when namespace for mailbox isn't found. diffstat: src/doveadm/doveadm-mail-mailbox.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 0a5951b08478 -r 669f09337a23 src/doveadm/doveadm-mail-mailbox.c --- a/src/doveadm/doveadm-mail-mailbox.c Sun Feb 12 21:10:22 2012 +0200 +++ b/src/doveadm/doveadm-mail-mailbox.c Sun Feb 12 22:16:51 2012 +0200 @@ -320,6 +320,7 @@ i_error("Can't find namespace for: %s", name); doveadm_mail_failed_error(_ctx, MAIL_ERROR_NOTFOUND); ret = -1; + continue; } box = mailbox_alloc(ns->list, name, 0); From dovecot at dovecot.org Sun Feb 12 22:34:51 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 22:34:51 +0200 Subject: dovecot-2.1: IMAP capabilities: s/FUZZY/SEARCH=FUZZY/ Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e3565b3f9efe changeset: 14139:e3565b3f9efe user: Timo Sirainen date: Sun Feb 12 22:34:33 2012 +0200 description: IMAP capabilities: s/FUZZY/SEARCH=FUZZY/ I mistakenly used wrong one.. diffstat: configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 669f09337a23 -r e3565b3f9efe configure.in --- a/configure.in Sun Feb 12 22:16:51 2012 +0200 +++ b/configure.in Sun Feb 12 22:34:33 2012 +0200 @@ -2697,7 +2697,7 @@ dnl IDLE doesn't really belong to banner. It's there just to make Blackberries dnl happy, because otherwise BIS server disables push email. capability_banner="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE" -capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS FUZZY SPECIAL-USE" +capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SEARCH=FUZZY SPECIAL-USE" AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities) AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", IMAP capabilities advertised in banner) From dovecot at dovecot.org Sun Feb 12 23:02:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:02:32 +0200 Subject: dovecot-2.1: Released v2.1.rc6. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/481860782250 changeset: 14140:481860782250 user: Timo Sirainen date: Sun Feb 12 22:35:52 2012 +0200 description: Released v2.1.rc6. diffstat: NEWS | 31 +++++++++++++++++++++++++++++++ TODO | 9 ++++++--- configure.in | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) diffs (71 lines): diff -r e3565b3f9efe -r 481860782250 NEWS --- a/NEWS Sun Feb 12 22:34:33 2012 +0200 +++ b/NEWS Sun Feb 12 22:35:52 2012 +0200 @@ -1,3 +1,34 @@ +v2.1.rc6 2012-02-12 Timo Sirainen + + * Added automatic mountpoint tracking and doveadm mount commands to + manage the list. If a mountpoint is unmounted, error handling is + done by assuming that the files are only temporarily lost. This is + especially helpful if dbox alt storage becomes unmounted. + * Expire plugin: Only go through users listed by userdb iteration. + Delete dict rows for nonexistent users, unless + expire_keep_nonexistent_users=yes. + * LDA's out-of-quota and Sieve's reject mails now include DSN report + instead of MDN report. + + + LDAP: Allow building passdb/userdb extra fields from multiple LDAP + attributes by using %{ldap:attributeName} variables in the template. + + doveadm log errors shows the last 1000 warnings and errors since + Dovecot was started. + + Improved multi-instance support: Track automatically which instances + are started up and manage the list with doveadm instance commands. + All Dovecot commands now support -i parameter to + select the instance (instead of having to use -c ). + See instance_name setting. + + doveadm mailbox delete: Added -r parameter to delete recursively + + doveadm acl: Added "add" and "remove" commands. + + Updated to Unicode v6.1 + - mdbox: When saving to alt storage, Dovecot didn't append as much + data to m.* files as it could have. + - dbox: Fixed error handling when saving failed or was aborted + - IMAP: Using COMPRESS extension may have caused assert-crashes + - IMAP: THREAD REFS sometimes returned invalid (0) nodes. + - dsync: Fixed handling non-ASCII characters in mailbox names. + v2.1.rc5 2012-01-26 Timo Sirainen * Temporary authentication failures sent to IMAP/POP3 clients diff -r e3565b3f9efe -r 481860782250 TODO --- a/TODO Sun Feb 12 22:34:33 2012 +0200 +++ b/TODO Sun Feb 12 22:35:52 2012 +0200 @@ -1,3 +1,7 @@ + - lmtp client/proxy: Handle multiline replies better + - lib-ssl-iostream: Support ssl_protocols setting + - doveadm: Many commands are exiting with 0 even when they fail + - recreate mailbox -> existing sessions log "indexid changed" error - expire plugin should probably ignore users not in iterate_query - message-id normalization - mdbox index rebuild: don't lose save dates @@ -178,9 +182,8 @@ - sasl bind + auth_bind=yes should probably be doing only sasl binds.. - support multiple connections for doing auth binds - domain lookups which set the base for user lookup - - same attribute can't be used for multiple values. - - multiple attributes can't be merged to a single value. - - multiple value could be joined with specified separator (per-field) + - multiple ldap values could be joined into one field with specified + separator (e.g. mail_access_groups=%{ldap:gidNumber:,}) - implement something like: user_attrs { uid = %{ldap:uidNumber} diff -r e3565b3f9efe -r 481860782250 configure.in --- a/configure.in Sun Feb 12 22:34:33 2012 +0200 +++ b/configure.in Sun Feb 12 22:35:52 2012 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.rc5],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.rc6],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Sun Feb 12 23:02:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:02:32 +0200 Subject: dovecot-2.1: Added tag 2.1.rc6 for changeset 481860782250 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e407fea7dcbc changeset: 14141:e407fea7dcbc user: Timo Sirainen date: Sun Feb 12 22:35:52 2012 +0200 description: Added tag 2.1.rc6 for changeset 481860782250 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 481860782250 -r e407fea7dcbc .hgtags --- a/.hgtags Sun Feb 12 22:35:52 2012 +0200 +++ b/.hgtags Sun Feb 12 22:35:52 2012 +0200 @@ -74,3 +74,4 @@ 5398bdb8613fbe05f24a2c655e0408e6fa4d764f 2.1.rc3 a20a99b8815d4d0ddd176e529a8928d00473fd7f 2.1.rc4 0f10b3ed5c18eefb752d8b76a0071b10a969fdf1 2.1.rc5 +481860782250ad55ab18ca81bd606fc70c3d2ad9 2.1.rc6 From dovecot at dovecot.org Sun Feb 12 23:02:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:02:32 +0200 Subject: dovecot-2.1: Added signature for changeset 481860782250 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/90f8af1f4af7 changeset: 14142:90f8af1f4af7 user: Timo Sirainen date: Sun Feb 12 22:35:54 2012 +0200 description: Added signature for changeset 481860782250 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r e407fea7dcbc -r 90f8af1f4af7 .hgsigs --- a/.hgsigs Sun Feb 12 22:35:52 2012 +0200 +++ b/.hgsigs Sun Feb 12 22:35:54 2012 +0200 @@ -37,3 +37,4 @@ 5398bdb8613fbe05f24a2c655e0408e6fa4d764f 0 iEYEABECAAYFAk8HTMkACgkQyUhSUUBVisknigCgkg1AEAFgPq0xdyBYYDdm55+De1UAoKDSnvoGetcQRB4j86B5c968PjxV a20a99b8815d4d0ddd176e529a8928d00473fd7f 0 iEYEABECAAYFAk8ezgsACgkQyUhSUUBVismeJQCfVq1NwEBD/U0GTy6Bk5mdBBy6CAEAn1/s2UzStxTUIxy0bmBJg8d+91Jv 0f10b3ed5c18eefb752d8b76a0071b10a969fdf1 0 iEYEABECAAYFAk8ghdYACgkQyUhSUUBVism4swCdGiTY9/6R8vZmxsg7gyrMhFAutZ4AnRwLbjzBreqPbmWvbP1CYrGHQzT6 +481860782250ad55ab18ca81bd606fc70c3d2ad9 0 iEYEABECAAYFAk84IqgACgkQyUhSUUBVislPnQCfdgX9pbhqat0CCZhEjGiYu0uPXFUAn1QOG9uetBsgOM6MB4tuJc58Pl4c From dovecot at dovecot.org Sun Feb 12 23:04:20 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:04:20 +0200 Subject: dovecot-2.1: README: Added missing RFC to list. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9574963a16f7 changeset: 14144:9574963a16f7 user: Timo Sirainen date: Sun Feb 12 23:04:13 2012 +0200 description: README: Added missing RFC to list. diffstat: README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r d58b721e751b -r 9574963a16f7 README --- a/README Sun Feb 12 23:03:55 2012 +0200 +++ b/README Sun Feb 12 23:04:13 2012 +0200 @@ -56,6 +56,7 @@ 5267 - Contexts for IMAP4 5530 - IMAP Response Codes 5819 - IMAP4 Extension for Returning STATUS Information in Extended LIST + 5957 - Display-Based Address Sorting for the IMAP4 SORT Extension 6154 - IMAP LIST Extension for Special-Use Mailboxes 6203 - IMAP4 Extension for Fuzzy Search From dovecot at dovecot.org Sun Feb 12 23:04:20 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:04:20 +0200 Subject: dovecot-2.1: TODO updated Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d58b721e751b changeset: 14143:d58b721e751b user: Timo Sirainen date: Sun Feb 12 23:03:55 2012 +0200 description: TODO updated diffstat: TODO | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (10 lines): diff -r 90f8af1f4af7 -r d58b721e751b TODO --- a/TODO Sun Feb 12 22:35:54 2012 +0200 +++ b/TODO Sun Feb 12 23:03:55 2012 +0200 @@ -1,6 +1,5 @@ - lmtp client/proxy: Handle multiline replies better - lib-ssl-iostream: Support ssl_protocols setting - - doveadm: Many commands are exiting with 0 even when they fail - recreate mailbox -> existing sessions log "indexid changed" error - expire plugin should probably ignore users not in iterate_query - message-id normalization From dovecot at dovecot.org Sun Feb 12 23:06:57 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:06:57 +0200 Subject: dovecot-2.0: master: If instance_name doesn't begin with "doveco... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/0b5076a69909 changeset: 13053:0b5076a69909 user: Timo Sirainen date: Sun Feb 12 23:06:52 2012 +0200 description: master: If instance_name doesn't begin with "dovecot", add "dovecot-" prefix to process names. diffstat: src/master/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r eed2b8fb2a52 -r 0b5076a69909 src/master/main.c --- a/src/master/main.c Sun Feb 12 05:45:04 2012 +0200 +++ b/src/master/main.c Sun Feb 12 23:06:52 2012 +0200 @@ -81,6 +81,8 @@ /* prefix with dovecot/ */ argv[0] = t_strdup_printf("%s/%s", services->set->instance_name, argv[0]); + if (strncmp(argv[0], PACKAGE, strlen(PACKAGE)) != 0) + argv[0] = t_strconcat(PACKAGE"-", argv[0], NULL); (void)execv_const(executable, argv); } From dovecot at dovecot.org Sun Feb 12 23:23:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:23:32 +0200 Subject: dovecot-2.2: Updated version number to v2.2.UNSTABLE and added a... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8457e41b634b changeset: 14145:8457e41b634b user: Timo Sirainen date: Sun Feb 12 23:23:25 2012 +0200 description: Updated version number to v2.2.UNSTABLE and added a warning to configure. diffstat: configure.in | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (17 lines): diff -r 9574963a16f7 -r 8457e41b634b configure.in --- a/configure.in Sun Feb 12 23:04:13 2012 +0200 +++ b/configure.in Sun Feb 12 23:23:25 2012 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.rc6],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.2.UNSTABLE],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) @@ -2847,3 +2847,6 @@ if test "$not_fts" != ""; then echo " :$not_fts" fi + +echo +echo "NOTE: This is the UNSTABLE development branch of Dovecot v2.2." From dovecot at dovecot.org Sun Feb 12 23:30:11 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:30:11 +0200 Subject: dovecot-2.0: Make static analyzer happier. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/cb23eb573b50 changeset: 13054:cb23eb573b50 user: Timo Sirainen date: Sun Feb 12 23:29:53 2012 +0200 description: Make static analyzer happier. diffstat: src/lib-storage/index/index-thread-finish.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diffs (18 lines): diff -r 0b5076a69909 -r cb23eb573b50 src/lib-storage/index/index-thread-finish.c --- a/src/lib-storage/index/index-thread-finish.c Sun Feb 12 23:06:52 2012 +0200 +++ b/src/lib-storage/index/index-thread-finish.c Sun Feb 12 23:29:53 2012 +0200 @@ -650,11 +650,9 @@ return NULL; child = &children[iter->next_idx++]; - if (child_iter_r != NULL) { - shadow = array_idx(&iter->ctx->shadow_nodes, child->idx); - *child_iter_r = shadow->first_child_idx == 0 ? NULL : - mail_thread_iterate_children(iter, child->idx); - } + shadow = array_idx(&iter->ctx->shadow_nodes, child->idx); + *child_iter_r = shadow->first_child_idx == 0 ? NULL : + mail_thread_iterate_children(iter, child->idx); if (child->uid == 0 && *child_iter_r == NULL) { /* this is a dummy node without children, there's no point in returning it */ From dovecot at dovecot.org Sun Feb 12 23:58:13 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:58:13 +0200 Subject: dovecot-2.0: Added tag 2.0.18 for changeset 346526718aad Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/6f45de67e785 changeset: 13056:6f45de67e785 user: Timo Sirainen date: Sun Feb 12 23:31:12 2012 +0200 description: Added tag 2.0.18 for changeset 346526718aad diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 346526718aad -r 6f45de67e785 .hgtags --- a/.hgtags Sun Feb 12 23:31:12 2012 +0200 +++ b/.hgtags Sun Feb 12 23:31:12 2012 +0200 @@ -68,3 +68,4 @@ 11ef524500964054ae8e4e6150f890b1864139eb 2.0.15 7a321a6a96d9d0bd345685f822ba1751334e7402 2.0.16 53cccb1b4168f9c8322145d0e8d1636021f2efff 2.0.17 +346526718aad285ce6a055fb2472c716f49e5dda 2.0.18 From dovecot at dovecot.org Sun Feb 12 23:58:13 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:58:13 +0200 Subject: dovecot-2.0: Released v2.0.18. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/346526718aad changeset: 13055:346526718aad user: Timo Sirainen date: Sun Feb 12 23:31:12 2012 +0200 description: Released v2.0.18. diffstat: NEWS | 17 +++++++++++++++++ configure.in | 2 +- 2 files changed, 18 insertions(+), 1 deletions(-) diffs (34 lines): diff -r cb23eb573b50 -r 346526718aad NEWS --- a/NEWS Sun Feb 12 23:29:53 2012 +0200 +++ b/NEWS Sun Feb 12 23:31:12 2012 +0200 @@ -1,3 +1,20 @@ +v2.0.18 2012-02-12 Timo Sirainen + + + DIGEST-MD5 authentication supports authorization id now. + Patch by Yubao Liu + + Added instance_name setting which is used to prefix Dovecot + processes in ps output. + - LDA/LMTP: Sending a large mail via submission_host or via LMTP proxy + may have caused a hang. + - Fixed dbox + mail_attachment_dir + zlib problems. + - Login processes weren't logging all intended messages with + auth_verbose=yes + - IMAP: THREAD REFS sometimes returned invalid (0) nodes. + - IMAP: CONTEXT search return option wasn't handled at all. + - dbox: Various error handling fixes. + - snarf plugin: Keep the mailbox locked during snarfing to avoid + duplicates. + v2.0.17 2012-01-06 Timo Sirainen + Proxying now supports sending SSL client certificate to server with diff -r cb23eb573b50 -r 346526718aad configure.in --- a/configure.in Sun Feb 12 23:29:53 2012 +0200 +++ b/configure.in Sun Feb 12 23:31:12 2012 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.0.17],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.0.18],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Sun Feb 12 23:58:13 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 12 Feb 2012 23:58:13 +0200 Subject: dovecot-2.0: Added signature for changeset 346526718aad Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/b887225ff2a1 changeset: 13057:b887225ff2a1 user: Timo Sirainen date: Sun Feb 12 23:31:15 2012 +0200 description: Added signature for changeset 346526718aad diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 6f45de67e785 -r b887225ff2a1 .hgsigs --- a/.hgsigs Sun Feb 12 23:31:12 2012 +0200 +++ b/.hgsigs Sun Feb 12 23:31:15 2012 +0200 @@ -31,3 +31,4 @@ 11ef524500964054ae8e4e6150f890b1864139eb 0 iEYEABECAAYFAk5zUvIACgkQyUhSUUBVisnDTgCdHVHSwKeZjHV4KrlTmqipFoO26mkAoIMqPTna3Y1ETIGnPq6XRCB90C8p 7a321a6a96d9d0bd345685f822ba1751334e7402 0 iEYEABECAAYFAk7EQKAACgkQyUhSUUBVisld+ACbBWyJWJmyfyvb6mpvdGnHg6tl5eUAni8p1sYBzklUoFwwfe3CGUOyHiB9 53cccb1b4168f9c8322145d0e8d1636021f2efff 0 iEYEABECAAYFAk8G/18ACgkQyUhSUUBVisl6NQCgpZXFFmbO06eA0cjsUPrMxsLqlVAAn0OcG9df71+/3q/EP4TfFb5fUkgu +346526718aad285ce6a055fb2472c716f49e5dda 0 iEYEABECAAYFAk84L6AACgkQyUhSUUBViskcPACfSRM+K7pQesMLEkV0m9uiMXJYoqcAn0vTpk0vkkF15Y+C0fPdkCS47aio From dovecot at dovecot.org Mon Feb 13 00:30:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 00:30:07 +0200 Subject: dovecot-2.2: login-common API made more extensible for different... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e456e1bce47f changeset: 14146:e456e1bce47f user: Timo Sirainen date: Mon Feb 13 00:29:55 2012 +0200 description: login-common API made more extensible for different kinds of protocols. Patch by Stephan Bosch. diffstat: src/imap-login/client-authenticate.c | 98 ++++++++--------- src/imap-login/client-authenticate.h | 6 +- src/imap-login/client.c | 159 +++++++++++++++++------------ src/imap-login/client.h | 14 ++ src/imap-login/imap-proxy.c | 16 ++- src/imap-login/imap-proxy.h | 2 + src/login-common/client-common-auth.c | 181 ++++++++++++++++++++++++--------- src/login-common/client-common.c | 65 ++++++++---- src/login-common/client-common.h | 66 ++++++++---- src/pop3-login/client-authenticate.c | 54 ++++------ src/pop3-login/client-authenticate.h | 6 +- src/pop3-login/client.c | 74 ++++++++----- src/pop3-login/client.h | 9 + src/pop3-login/pop3-proxy.c | 9 +- src/pop3-login/pop3-proxy.h | 2 + 15 files changed, 471 insertions(+), 290 deletions(-) diffs (truncated from 1440 to 300 lines): diff -r 8457e41b634b -r e456e1bce47f src/imap-login/client-authenticate.c --- a/src/imap-login/client-authenticate.c Sun Feb 12 23:23:25 2012 +0200 +++ b/src/imap-login/client-authenticate.c Mon Feb 13 00:29:55 2012 +0200 @@ -3,14 +3,12 @@ #include "login-common.h" #include "base64.h" #include "buffer.h" -#include "hostpid.h" #include "ioloop.h" #include "istream.h" #include "ostream.h" #include "safe-memset.h" #include "str.h" #include "str-sanitize.h" -#include "time-util.h" #include "imap-resp-code.h" #include "imap-parser.h" #include "auth-client.h" @@ -33,14 +31,19 @@ } } -bool imap_client_auth_handle_reply(struct client *client, - const struct client_auth_reply *reply) +void imap_client_auth_result(struct client *client, + enum client_auth_result result, + const struct client_auth_reply *reply, + const char *text) { - struct imap_client *imap_client = (struct imap_client *)client; - string_t *str; - const char *timestamp, *msg; + string_t *referral; - if (reply->host != NULL) { + switch (result) { + case CLIENT_AUTH_RESULT_SUCCESS: + /* nothing to be done for IMAP */ + break; + case CLIENT_AUTH_RESULT_REFERRAL_SUCCESS: + case CLIENT_AUTH_RESULT_REFERRAL_NOLOGIN: /* IMAP referral [nologin] referral host=.. [port=..] [destuser=..] @@ -50,55 +53,46 @@ OK [...] Logged in, but you should use this server instead. .. [REFERRAL ..] (Reason from auth server) */ - str = t_str_new(128); - str_append(str, imap_client->cmd_tag); - str_append_c(str, ' '); - str_append(str, reply->nologin ? "NO " : "OK "); - str_printfa(str, "[REFERRAL imap://%s;AUTH=%s@%s", + referral = t_str_new(128); + str_printfa(referral, "REFERRAL imap://%s;AUTH=%s@%s", reply->destuser, client->auth_mech_name, reply->host); if (reply->port != 143) - str_printfa(str, ":%u", reply->port); - str_append(str, "/] "); - if (reply->reason != NULL) - str_append(str, reply->reason); - else if (reply->nologin) - str_append(str, "Try this server instead."); - else { - str_append(str, "Logged in, but you should use " - "this server instead."); + str_printfa(referral, ":%u", reply->port); + str_append(referral, "/"); + + if (result == CLIENT_AUTH_RESULT_REFERRAL_SUCCESS) { + client_send_reply_code(client, IMAP_CMD_REPLY_OK, + str_c(referral), text); + } else { + client_send_reply_code(client, IMAP_CMD_REPLY_NO, + str_c(referral), text); } - str_append(str, "\r\n"); - client_send_raw(client, str_c(str)); - if (!reply->nologin) { - client_destroy_success(client, "Login with referral"); - return TRUE; - } - } else if (!reply->nologin) { - /* normal login/failure */ - return FALSE; - } else if (reply->reason != NULL) { - client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAIL_REASON, - reply->reason); - } else if (reply->temp) { - timestamp = t_strflocaltime("%Y-%m-%d %H:%M:%S", ioloop_time); - msg = t_strdup_printf(AUTH_TEMP_FAILED_MSG" [%s:%s]", - my_hostname, timestamp); - client_send_line(client, - CLIENT_CMD_REPLY_AUTH_FAIL_TEMP, msg); - } else if (reply->authz_failure) { - client_send_line(client, CLIENT_CMD_REPLY_AUTHZ_FAILED, - "Authorization failed"); - } else { - client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAILED, - AUTH_FAILED_MSG); + break; + case CLIENT_AUTH_RESULT_ABORTED: + client_send_reply(client, IMAP_CMD_REPLY_BAD, text); + break; + case CLIENT_AUTH_RESULT_AUTHFAILED_REASON: + client_send_reply_code(client, IMAP_CMD_REPLY_NO, + "ALERT", text); + break; + case CLIENT_AUTH_RESULT_AUTHZFAILED: + client_send_reply_code(client, IMAP_CMD_REPLY_NO, + IMAP_RESP_CODE_AUTHZFAILED, text); + break; + case CLIENT_AUTH_RESULT_TEMPFAIL: + client_send_reply_code(client, IMAP_CMD_REPLY_NO, + IMAP_RESP_CODE_UNAVAILABLE, text); + break; + case CLIENT_AUTH_RESULT_SSL_REQUIRED: + client_send_reply_code(client, IMAP_CMD_REPLY_NO, + IMAP_RESP_CODE_PRIVACYREQUIRED, text); + break; + case CLIENT_AUTH_RESULT_AUTHFAILED: + client_send_reply_code(client, IMAP_CMD_REPLY_NO, + IMAP_RESP_CODE_AUTHFAILED, text); + break; } - - i_assert(reply->nologin); - - if (!client->destroyed) - client_auth_failed(client); - return TRUE; } static int diff -r 8457e41b634b -r e456e1bce47f src/imap-login/client-authenticate.h --- a/src/imap-login/client-authenticate.h Sun Feb 12 23:23:25 2012 +0200 +++ b/src/imap-login/client-authenticate.h Mon Feb 13 00:29:55 2012 +0200 @@ -5,8 +5,10 @@ void client_authenticate_get_capabilities(struct client *client, string_t *str); -bool imap_client_auth_handle_reply(struct client *client, - const struct client_auth_reply *reply); +void imap_client_auth_result(struct client *client, + enum client_auth_result result, + const struct client_auth_reply *reply, + const char *text); int cmd_login(struct imap_client *client, const struct imap_arg *args); int cmd_authenticate(struct imap_client *imap_client, bool *parsed_r); diff -r 8457e41b634b -r e456e1bce47f src/imap-login/client.c --- a/src/imap-login/client.c Sun Feb 12 23:23:25 2012 +0200 +++ b/src/imap-login/client.c Mon Feb 13 00:29:55 2012 +0200 @@ -82,8 +82,8 @@ imap_client->client_ignores_capability_resp_code = TRUE; client_send_raw(client, t_strconcat( "* CAPABILITY ", get_capability(client), "\r\n", NULL)); - client_send_line(client, CLIENT_CMD_REPLY_OK, - "Pre-login capabilities listed, post-login capabilities have more."); + client_send_reply(client, IMAP_CMD_REPLY_OK, + "Pre-login capabilities listed, post-login capabilities have more."); return 1; } @@ -94,6 +94,16 @@ } static void +imap_client_notify_starttls(struct client *client, + bool success, const char *text) +{ + if (success) + client_send_reply(client, IMAP_CMD_REPLY_OK, text); + else + client_send_reply(client, IMAP_CMD_REPLY_BAD, text); +} + +static void client_update_info(struct imap_client *client, const struct imap_arg *args) { const char *key, *value; @@ -135,22 +145,22 @@ env = getenv("IMAP_ID_SEND"); client_send_raw(&client->common, t_strdup_printf("* ID %s\r\n", imap_id_reply_generate(env))); - client_send_line(&client->common, CLIENT_CMD_REPLY_OK, "ID completed."); + client_send_reply(&client->common, IMAP_CMD_REPLY_OK, "ID completed."); return 1; } static int cmd_noop(struct imap_client *client) { - client_send_line(&client->common, CLIENT_CMD_REPLY_OK, - "NOOP completed."); + client_send_reply(&client->common, IMAP_CMD_REPLY_OK, + "NOOP completed."); return 1; } static int cmd_logout(struct imap_client *client) { - client_send_line(&client->common, CLIENT_CMD_REPLY_BYE, "Logging out"); - client_send_line(&client->common, CLIENT_CMD_REPLY_OK, - "Logout completed."); + client_send_reply(&client->common, IMAP_CMD_REPLY_BYE, "Logging out"); + client_send_reply(&client->common, IMAP_CMD_REPLY_OK, + "Logout completed."); client_destroy(&client->common, "Aborted login"); return 1; } @@ -158,8 +168,8 @@ static int cmd_enable(struct imap_client *client) { client_send_raw(&client->common, "* ENABLED\r\n"); - client_send_line(&client->common, CLIENT_CMD_REPLY_OK, - "ENABLE ignored in non-authenticated state."); + client_send_reply(&client->common, IMAP_CMD_REPLY_OK, + "ENABLE ignored in non-authenticated state."); return 1; } @@ -223,14 +233,14 @@ /* error */ msg = imap_parser_get_error(client->parser, &fatal); if (fatal) { - client_send_line(&client->common, - CLIENT_CMD_REPLY_BYE, msg); + client_send_reply(&client->common, + IMAP_CMD_REPLY_BYE, msg); client_destroy(&client->common, t_strconcat("Disconnected: ", msg, NULL)); return FALSE; } - client_send_line(&client->common, CLIENT_CMD_REPLY_BAD, msg); + client_send_reply(&client->common, IMAP_CMD_REPLY_BAD, msg); client->cmd_finished = TRUE; client->skip_line = TRUE; return -1; @@ -309,7 +319,7 @@ client->cmd_finished = TRUE; if (ret == -2 && strcasecmp(client->cmd_tag, "LOGIN") == 0) { - client_send_line(&client->common, CLIENT_CMD_REPLY_BAD, + client_send_reply(&client->common, IMAP_CMD_REPLY_BAD, "First parameter in line is IMAP's command tag, " "not the command name. Add that before the command, " "like: a login user pass"); @@ -317,13 +327,13 @@ if (*client->cmd_tag == '\0') client->cmd_tag = "*"; if (++client->common.bad_counter >= CLIENT_MAX_BAD_COMMANDS) { - client_send_line(&client->common, CLIENT_CMD_REPLY_BYE, + client_send_reply(&client->common, IMAP_CMD_REPLY_BYE, "Too many invalid IMAP commands."); client_destroy(&client->common, "Disconnected: Too many invalid commands"); return FALSE; } - client_send_line(&client->common, CLIENT_CMD_REPLY_BAD, + client_send_reply(&client->common, IMAP_CMD_REPLY_BAD, "Error in IMAP command received by server."); } @@ -343,8 +353,8 @@ if (!auth_client_is_connected(auth_client)) { /* we're not currently connected to auth process - don't allow any commands */ - client_send_line(client, CLIENT_CMD_REPLY_STATUS, - AUTH_SERVER_WAITING_MSG); + client_notify_status(client, FALSE, + AUTH_SERVER_WAITING_MSG); if (client->to_auth_waiting != NULL) timeout_remove(&client->to_auth_waiting); @@ -386,7 +396,7 @@ imap_parser_unref(&imap_client->parser); } -static void imap_client_send_greeting(struct client *client) +static void imap_client_notify_auth_ready(struct client *client) { string_t *greet; @@ -397,7 +407,6 @@ str_append(greet, "\r\n"); client_send_raw(client, str_c(greet)); - client->greeting_sent = TRUE; } static void imap_client_starttls(struct client *client) @@ -414,50 +423,11 @@ } static void -imap_client_send_line(struct client *client, enum client_cmd_reply reply, - const char *text) +client_send_reply_raw(struct client *client, From dovecot at dovecot.org Mon Feb 13 00:40:08 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 00:40:08 +0200 Subject: dovecot-2.2: message parser: Added MESSAGE_PARSER_FLAG_INCLUDE_M... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e7854f8d7213 changeset: 14147:e7854f8d7213 user: Timo Sirainen date: Mon Feb 13 00:40:03 2012 +0200 description: message parser: Added MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS. Patch by Stephan Bosch. diffstat: src/lib-mail/message-parser.c | 249 ++++++++++++++++++++++++++++++++++++++--- src/lib-mail/message-parser.h | 4 +- 2 files changed, 233 insertions(+), 20 deletions(-) diffs (truncated from 345 to 300 lines): diff -r e456e1bce47f -r e7854f8d7213 src/lib-mail/message-parser.c --- a/src/lib-mail/message-parser.c Mon Feb 13 00:29:55 2012 +0200 +++ b/src/lib-mail/message-parser.c Mon Feb 13 00:40:03 2012 +0200 @@ -54,6 +54,8 @@ struct message_block *block_r); static int parse_next_body_to_eof(struct message_parser_ctx *ctx, struct message_block *block_r); +static int preparsed_parse_epilogue_init(struct message_parser_ctx *ctx, + struct message_block *block_r); static int preparsed_parse_next_header_init(struct message_parser_ctx *ctx, struct message_block *block_r); @@ -271,9 +273,17 @@ block_r->size = (ptr - block_r->data) + 1; parse_body_add_block(ctx, block_r); - /* a new MIME part begins */ - ctx->parse_next_block = parse_next_mime_header_init; - return 1; + if (ctx->boundaries == NULL || ctx->boundaries->part != ctx->part) { + /* epilogue */ + if (ctx->boundaries != NULL) + ctx->parse_next_block = parse_next_body_to_boundary; + else + ctx->parse_next_block = parse_next_body_to_eof; + } else { + /* a new MIME part begins */ + ctx->parse_next_block = parse_next_mime_header_init; + } + return ctx->parse_next_block(ctx, block_r); } static int parse_part_finish(struct message_parser_ctx *ctx, @@ -293,28 +303,24 @@ if (boundary->epilogue_found) { /* this boundary isn't needed anymore */ ctx->boundaries = boundary->next; - - if (ctx->boundaries != NULL) - ctx->parse_next_block = parse_next_body_to_boundary; - else - ctx->parse_next_block = parse_next_body_to_eof; - return ctx->parse_next_block(ctx, block_r); + } else { + /* forget about the boundaries we possibly skipped */ + ctx->boundaries = boundary; } - /* forget about the boundaries we possibly skipped */ - ctx->boundaries = boundary; - /* the boundary itself should already be in buffer. add that. */ block_r->data = i_stream_get_data(ctx->input, &block_r->size); i_assert(block_r->size >= ctx->skip + 2 + boundary->len + (first_line ? 0 : 1)); block_r->data += ctx->skip; - /* [\n]-- */ - block_r->size = (first_line ? 0 : 1) + 2 + boundary->len; + /* [\n]--[--] */ + block_r->size = (first_line ? 0 : 1) + 2 + boundary->len + + (boundary->epilogue_found ? 2 : 0); parse_body_add_block(ctx, block_r); ctx->parse_next_block = parse_next_body_skip_boundary_line; - return 1; + + return ctx->parse_next_block(ctx, block_r); } static int parse_next_body_to_boundary(struct message_parser_ctx *ctx, @@ -392,6 +398,11 @@ } if (block_r->size != 0) { parse_body_add_block(ctx, block_r); + + if ((ctx->part->flags & MESSAGE_PART_FLAG_MULTIPART) != 0 && + (ctx->flags & MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS) == 0) + return 0; + return 1; } return ret <= 0 ? ret : @@ -408,6 +419,11 @@ return ret; parse_body_add_block(ctx, block_r); + + if ((ctx->part->flags & MESSAGE_PART_FLAG_MULTIPART) != 0 && + (ctx->flags & MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS) == 0) + return 0; + return 1; } @@ -583,6 +599,24 @@ ctx->part = ctx->part->next; break; } + + /* parse epilogue of multipart parent if requested */ + if (ctx->part->parent != NULL && + (ctx->part->parent->flags & MESSAGE_PART_FLAG_MULTIPART) != 0 && + (ctx->flags & MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS) != 0) { + /* check for presence of epilogue */ + uoff_t part_end = ctx->part->physical_pos + + ctx->part->header_size.physical_size + + ctx->part->body_size.physical_size; + uoff_t parent_end = ctx->part->parent->physical_pos + + ctx->part->parent->header_size.physical_size + + ctx->part->parent->body_size.physical_size; + + if (parent_end > part_end) { + ctx->parse_next_block = preparsed_parse_epilogue_init; + break; + } + } ctx->part = ctx->part->parent; } if (ctx->part == NULL) @@ -599,6 +633,17 @@ return ctx->parse_next_block(ctx, block_r); } +static int preparsed_parse_prologue_finish(struct message_parser_ctx *ctx, + struct message_block *block_r) +{ + i_stream_skip(ctx->input, ctx->skip); + ctx->skip = 0; + + ctx->parse_next_block = preparsed_parse_next_header_init; + ctx->part = ctx->part->children; + return ctx->parse_next_block(ctx, block_r); +} + static int preparsed_parse_body_more(struct message_parser_ctx *ctx, struct message_block *block_r) { @@ -619,6 +664,143 @@ return 1; } +static int preparsed_parse_prologue_more(struct message_parser_ctx *ctx, + struct message_block *block_r) +{ + uoff_t end_offset = ctx->part->children->physical_pos; + uoff_t boundary_min_start; + const unsigned char *cur; + bool full; + int ret; + + if ((ret = message_parser_read_more(ctx, block_r, &full)) <= 0) + return ret; + + if (ctx->input->v_offset + block_r->size >= end_offset) { + /* we've got the full prologue: clip off the initial boundary */ + block_r->size = end_offset - ctx->input->v_offset; + cur = block_r->data + block_r->size - 1; + + /* [\r]\n--boundary[\r]\n */ + if (block_r->size < 5 || *cur != '\n') { + ctx->broken = TRUE; + return -1; + } + + cur--; + if (*cur == '\r') cur--; + + /* find newline just before boundary */ + for (; cur >= block_r->data; cur--) { + if (*cur == '\n') break; + } + + if (cur[0] != '\n' || cur[1] != '-' || cur[2] != '-') { + ctx->broken = TRUE; + return -1; + } + + if (cur != block_r->data && cur[-1] == '\r') cur--; + + /* clip boundary */ + block_r->size = cur - block_r->data; + + ctx->parse_next_block = preparsed_parse_prologue_finish; + ctx->skip = block_r->size; + return 1; + } + + /* retain enough data in the stream buffer to contain initial boundary */ + if (end_offset > BOUNDARY_END_MAX_LEN) + boundary_min_start = end_offset - BOUNDARY_END_MAX_LEN; + else + boundary_min_start = 0; + + if (ctx->input->v_offset + block_r->size >= boundary_min_start) { + if (boundary_min_start <= ctx->input->v_offset) + return 0; + block_r->size = boundary_min_start - ctx->input->v_offset; + } + ctx->skip = block_r->size; + return 1; +} + +static int preparsed_parse_epilogue_more(struct message_parser_ctx *ctx, + struct message_block *block_r) +{ + uoff_t end_offset = ctx->part->physical_pos + + ctx->part->header_size.physical_size + + ctx->part->body_size.physical_size; + bool full; + int ret; + + if ((ret = message_parser_read_more(ctx, block_r, &full)) <= 0) + return ret; + + if (ctx->input->v_offset + block_r->size >= end_offset) { + block_r->size = end_offset - ctx->input->v_offset; + ctx->parse_next_block = preparsed_parse_body_finish; + } + ctx->skip = block_r->size; + return 1; +} + +static int preparsed_parse_epilogue_boundary(struct message_parser_ctx *ctx, + struct message_block *block_r) +{ + uoff_t end_offset = ctx->part->physical_pos + + ctx->part->header_size.physical_size + + ctx->part->body_size.physical_size; + const unsigned char *data, *cur; + size_t size; + bool full; + int ret; + + if (end_offset - ctx->input->v_offset < 7) { + ctx->broken = TRUE; + return -1; + } + + if ((ret = message_parser_read_more(ctx, block_r, &full)) <= 0) + return ret; + + /* [\r]\n--boundary--[\r]\n */ + if (block_r->size < 7) { + ctx->want_count = 7; + return 0; + } + + data = block_r->data; + size = block_r->size; + cur = data; + + if (*cur == '\r') cur++; + + if (cur[0] != '\n' || cur[1] != '-' || data[2] != '-') { + ctx->broken = TRUE; + return -1; + } + + /* find the end of the line */ + cur += 3; + if ((cur = memchr(cur, '\n', size - (cur-data))) == NULL) { + if (end_offset < ctx->input->v_offset + size) { + ctx->broken = TRUE; + return -1; + } else if (ctx->input->v_offset + size < end_offset && + size < BOUNDARY_END_MAX_LEN && + !ctx->input->eof && !full) { + ctx->want_count = BOUNDARY_END_MAX_LEN; + return 0; + } + } + + block_r->size = 0; + ctx->parse_next_block = preparsed_parse_epilogue_more; + ctx->skip = cur - data + 1; + return 0; +} + static int preparsed_parse_body_init(struct message_parser_ctx *ctx, struct message_block *block_r) { @@ -632,16 +814,45 @@ } i_stream_skip(ctx->input, offset - ctx->input->v_offset); - ctx->parse_next_block = preparsed_parse_body_more; - return preparsed_parse_body_more(ctx, block_r); + if ((ctx->part->flags & MESSAGE_PART_FLAG_MULTIPART) == 0) + ctx->parse_next_block = preparsed_parse_body_more; + else + ctx->parse_next_block = preparsed_parse_prologue_more; + return ctx->parse_next_block(ctx, block_r); +} + +static int preparsed_parse_epilogue_init(struct message_parser_ctx *ctx, + struct message_block *block_r) +{ + uoff_t offset = ctx->part->physical_pos + + ctx->part->header_size.physical_size + + ctx->part->body_size.physical_size; From pigeonhole at rename-it.nl Mon Feb 13 01:03:50 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 13 Feb 2012 00:03:50 +0100 Subject: dovecot-2.2-pigeonhole: Applied sieve-body-fix.patch. Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/eed6fba433f4 changeset: 1602:eed6fba433f4 user: Stephan Bosch date: Mon Feb 13 00:01:30 2012 +0100 description: Applied sieve-body-fix.patch. Fixes behavior of body test with multipart MIME body parts. Testsuite needs to be extended accordingly. diffstat: TODO | 1 - src/lib-sieve/plugins/body/ext-body-common.c | 65 +++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 8 deletions(-) diffs (123 lines): diff -r 408cc4b15640 -r eed6fba433f4 TODO --- a/TODO Sun Feb 12 23:53:31 2012 +0100 +++ b/TODO Mon Feb 13 00:01:30 2012 +0100 @@ -25,7 +25,6 @@ (posix regexes actually do support utf8, but only when locale is set accordingly) * Finish body extension: - - Implement proper :content "multipart" behavior - Build test cases for decoding MIME encodings to UTF-8 * Cleanup the test suite - Restructure test scripts diff -r 408cc4b15640 -r eed6fba433f4 src/lib-sieve/plugins/body/ext-body-common.c --- a/src/lib-sieve/plugins/body/ext-body-common.c Sun Feb 12 23:53:31 2012 +0100 +++ b/src/lib-sieve/plugins/body/ext-body-common.c Mon Feb 13 00:01:30 2012 +0100 @@ -83,6 +83,25 @@ return FALSE; } +static bool _want_multipart_content_type +(const char * const *wanted_types) +{ + for (; *wanted_types != NULL; wanted_types++) { + if (**wanted_types == '\0') { + /* empty string matches everything */ + return TRUE; + } + + /* match only main type */ + if ( strncasecmp(*wanted_types, "multipart", 9) == 0 && + ( strlen(*wanted_types) == 9 || *(*wanted_types+9) == '/' ) ) + return TRUE; + } + + return FALSE; +} + + static bool ext_body_get_return_parts (struct ext_body_message_context *ctx, const char * const *wanted_types, bool decode_to_plain) @@ -201,9 +220,10 @@ struct message_decoder_context *decoder; struct message_block block, decoded; struct message_part *parts, *prev_part = NULL; + ARRAY_DEFINE(part_index, struct message_part *); struct istream *input; unsigned int idx = 0; - bool save_body = FALSE, have_all; + bool save_body = FALSE, want_multipart, have_all; int ret; /* First check whether any are missing */ @@ -215,17 +235,23 @@ /* Get the message stream */ if ( mail_get_stream(mail, NULL, NULL, &input) < 0 ) return FALSE; - //if (mail_get_parts(mail, &parts) < 0) - // return FALSE; + + if (mail_get_parts(mail, &parts) < 0) + return FALSE; + + if ( (want_multipart=_want_multipart_content_type(content_types)) ) { + t_array_init(&part_index, 8); + } buffer_set_used_size(ctx->tmp_buffer, 0); /* Initialize body decoder */ decoder = decode_to_plain ? message_decoder_init(FALSE) : NULL; - //parser = message_parser_init_from_parts(parts, input, 0, 0); - parser = message_parser_init(ctx->pool, input, 0, 0); - + //parser = message_parser_init_from_parts(parts, input, 0, + //MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS); + parser = message_parser_init(ctx->pool, input, 0, + MESSAGE_PARSER_FLAG_INCLUDE_MULTIPART_BLOCKS); while ( (ret = message_parser_parse_next_block(parser, &block)) > 0 ) { if ( block.part != prev_part ) { @@ -238,8 +264,9 @@ strcmp(body_part->content_type, "message/rfc822") == 0 ) { message_rfc822 = TRUE; } else { - if ( save_body ) + if ( save_body ) { ext_body_part_save(ctx, body_part, decoder != NULL); + } } } @@ -247,6 +274,30 @@ body_part = array_idx_modifiable(&ctx->cached_body_parts, idx); body_part->content_type = "text/plain"; + /* Check whether this is the epilogue block of a wanted multipart part */ + if ( want_multipart ) { + array_idx_set(&part_index, idx, &block.part); + + if ( prev_part != NULL && prev_part->next != block.part && + block.part->parent != prev_part ) { + struct message_part *const *iparts; + unsigned int count, i; + + iparts = array_get(&part_index, &count); + for ( i = 0; i < count; i++ ) { + if ( iparts[i] == block.part ) { + const struct ext_body_part_cached *parent = + array_idx(&ctx->cached_body_parts, i); + body_part->content_type = parent->content_type; + body_part->have_body = TRUE; + save_body = _is_wanted_content_type + (content_types, body_part->content_type); + break; + } + } + } + } + /* If this is message/rfc822 content retain the enveloping part for * storing headers as content. */ From dovecot at dovecot.org Mon Feb 13 14:34:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 14:34:44 +0200 Subject: dovecot-2.1: lib-storage: Added namespace { ignore_on_failure } ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/71201cce97b5 changeset: 14145:71201cce97b5 user: Timo Sirainen date: Mon Feb 13 14:34:31 2012 +0200 description: lib-storage: Added namespace { ignore_on_failure } setting. If the namespace can't be created for any reason, it's simply silently skipped. diffstat: src/lib-storage/mail-namespace.c | 13 ++++++++++--- src/lib-storage/mail-storage-settings.c | 2 ++ src/lib-storage/mail-storage-settings.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diffs (53 lines): diff -r 9574963a16f7 -r 71201cce97b5 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Sun Feb 12 23:04:13 2012 +0200 +++ b/src/lib-storage/mail-namespace.c Mon Feb 13 14:34:31 2012 +0200 @@ -280,9 +280,16 @@ } for (i = 0; i < count; i++) { if (namespace_add(user, ns_set[i], unexpanded_ns_set[i], - mail_set, ns_p, error_r) < 0) - return -1; - ns_p = &(*ns_p)->next; + mail_set, ns_p, error_r) < 0) { + if (!ns_set[i]->ignore_on_failure) + return -1; + if (mail_set->mail_debug) { + i_debug("Skipping namespace %s: %s", + ns_set[i]->prefix, *error_r); + } + } else { + ns_p = &(*ns_p)->next; + } } if (namespaces != NULL) { diff -r 9574963a16f7 -r 71201cce97b5 src/lib-storage/mail-storage-settings.c --- a/src/lib-storage/mail-storage-settings.c Sun Feb 12 23:04:13 2012 +0200 +++ b/src/lib-storage/mail-storage-settings.c Mon Feb 13 14:34:31 2012 +0200 @@ -149,6 +149,7 @@ DEF(SET_BOOL, hidden), DEF(SET_ENUM, list), DEF(SET_BOOL, subscriptions), + DEF(SET_BOOL, ignore_on_failure), DEFLIST_UNIQUE(mailboxes, "mailbox", &mailbox_setting_parser_info), @@ -167,6 +168,7 @@ .hidden = FALSE, .list = "yes:no:children", .subscriptions = TRUE, + .ignore_on_failure = FALSE, .mailboxes = ARRAY_INIT }; diff -r 9574963a16f7 -r 71201cce97b5 src/lib-storage/mail-storage-settings.h --- a/src/lib-storage/mail-storage-settings.h Sun Feb 12 23:04:13 2012 +0200 +++ b/src/lib-storage/mail-storage-settings.h Mon Feb 13 14:34:31 2012 +0200 @@ -51,6 +51,7 @@ bool hidden; const char *list; bool subscriptions; + bool ignore_on_failure; ARRAY_DEFINE(mailboxes, struct mailbox_settings *); struct mail_user_settings *user_set; From dovecot at dovecot.org Mon Feb 13 18:27:56 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 18:27:56 +0200 Subject: dovecot-2.0: pop3: If UIDL using %f/%m/%g can't be fetched, ment... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8e1cab0b9374 changeset: 13058:8e1cab0b9374 user: Timo Sirainen date: Mon Feb 13 18:27:44 2012 +0200 description: pop3: If UIDL using %f/%m/%g can't be fetched, mention pop3_uidl_format in error message. diffstat: src/pop3/pop3-commands.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (33 lines): diff -r b887225ff2a1 -r 8e1cab0b9374 src/pop3/pop3-commands.c --- a/src/pop3/pop3-commands.c Sun Feb 12 23:31:15 2012 +0200 +++ b/src/pop3/pop3-commands.c Mon Feb 13 18:27:44 2012 +0200 @@ -582,7 +582,8 @@ &tab[2].value) < 0 || *tab[2].value == '\0') { /* broken */ - i_fatal("UIDL: Header MD5 not found"); + i_fatal("UIDL: Header MD5 not found " + "(pop3_uidl_format=%%m not supported by storage?)"); } } if ((client->uidl_keymask & UIDL_FILE_NAME) != 0) { @@ -591,7 +592,8 @@ &tab[3].value) < 0 || *tab[3].value == '\0') { /* broken */ - i_fatal("UIDL: File name not found"); + i_fatal("UIDL: File name not found " + "(pop3_uidl_format=%%f not supported by storage?)"); } } if ((client->uidl_keymask & UIDL_GUID) != 0) { @@ -599,7 +601,8 @@ &tab[4].value) < 0 || *tab[4].value == '\0') { /* broken */ - i_fatal("UIDL: Message GUID not found"); + i_fatal("UIDL: Message GUID not found " + "(pop3_uidl_format=%%g not supported by storage?)"); } } var_expand(str, client->mail_set->pop3_uidl_format, tab); From dovecot at dovecot.org Mon Feb 13 18:28:11 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 18:28:11 +0200 Subject: dovecot-2.1: TODO updated Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9c4cac11da15 changeset: 14146:9c4cac11da15 user: Timo Sirainen date: Mon Feb 13 18:28:01 2012 +0200 description: TODO updated diffstat: TODO | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diffs (15 lines): diff -r 71201cce97b5 -r 9c4cac11da15 TODO --- a/TODO Mon Feb 13 14:34:31 2012 +0200 +++ b/TODO Mon Feb 13 18:28:01 2012 +0200 @@ -1,11 +1,7 @@ - lmtp client/proxy: Handle multiline replies better - lib-ssl-iostream: Support ssl_protocols setting - recreate mailbox -> existing sessions log "indexid changed" error - - expire plugin should probably ignore users not in iterate_query - - message-id normalization - - mdbox index rebuild: don't lose save dates - add message/mime limits - - stephan's message-parser patch - imapc: - prefetching to THREAD and SORT - check all imap extensions and see if some don't work (condstore) From dovecot at dovecot.org Mon Feb 13 18:28:11 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 18:28:11 +0200 Subject: dovecot-2.1: pop3: If UIDL using %f/%m/%g can't be fetched, ment... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/06bb6d0f60e0 changeset: 14147:06bb6d0f60e0 user: Timo Sirainen date: Mon Feb 13 18:27:44 2012 +0200 description: pop3: If UIDL using %f/%m/%g can't be fetched, mention pop3_uidl_format in error message. diffstat: src/pop3/pop3-commands.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (33 lines): diff -r 9c4cac11da15 -r 06bb6d0f60e0 src/pop3/pop3-commands.c --- a/src/pop3/pop3-commands.c Mon Feb 13 18:28:01 2012 +0200 +++ b/src/pop3/pop3-commands.c Mon Feb 13 18:27:44 2012 +0200 @@ -578,7 +578,8 @@ &tab[2].value) < 0 || *tab[2].value == '\0') { /* broken */ - i_fatal("UIDL: Header MD5 not found"); + i_fatal("UIDL: Header MD5 not found " + "(pop3_uidl_format=%%m not supported by storage?)"); } } if ((client->uidl_keymask & UIDL_FILE_NAME) != 0) { @@ -587,7 +588,8 @@ &tab[3].value) < 0 || *tab[3].value == '\0') { /* broken */ - i_fatal("UIDL: File name not found"); + i_fatal("UIDL: File name not found " + "(pop3_uidl_format=%%f not supported by storage?)"); } } if ((client->uidl_keymask & UIDL_GUID) != 0) { @@ -595,7 +597,8 @@ &tab[4].value) < 0 || *tab[4].value == '\0') { /* broken */ - i_fatal("UIDL: Message GUID not found"); + i_fatal("UIDL: Message GUID not found " + "(pop3_uidl_format=%%g not supported by storage?)"); } } var_expand(str, client->mail_set->pop3_uidl_format, tab); From dovecot at dovecot.org Mon Feb 13 22:01:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 22:01:07 +0200 Subject: dovecot-2.1: man: Added description of fields pop3.uidl and text... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b4479e2d2d21 changeset: 14148:b4479e2d2d21 user: Pascal Volk date: Mon Feb 13 19:59:13 2012 +0000 description: man: Added description of fields pop3.uidl and text.utf8 to doveadm-fetch.1. diffstat: doc/man/doveadm-fetch.1.in | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diffs (33 lines): diff -r 06bb6d0f60e0 -r b4479e2d2d21 doc/man/doveadm-fetch.1.in --- a/doc/man/doveadm-fetch.1.in Mon Feb 13 18:27:44 2012 +0200 +++ b/doc/man/doveadm-fetch.1.in Mon Feb 13 19:59:13 2012 +0000 @@ -1,5 +1,5 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-FETCH 1 "2010-11-25" "Dovecot v2.1" "Dovecot" +.\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-FETCH 1 "2012-02-13" "Dovecot v2.1" "Dovecot" .SH NAME doveadm\-fetch \- Fetch partial/full messages or message information .\"------------------------------------------------------------------------ @@ -117,6 +117,10 @@ located. .\"----------------- .TP +.B pop3.uidl +A message\(aqs unique (POP3) identifier within a mailbox. +.\"----------------- +.TP .B seq A message\(aqs sequence number in a mailbox. .\"----------------- @@ -133,6 +137,10 @@ The entire message (header and body). .\"----------------- .TP +.B text.utf8 +The entire message (header and body) \(em UTF\-8 encoded. +.\"----------------- +.TP .B uid A message\(aqs unique (IMAP) identifier in a mailbox. .\"----------------- From dovecot at dovecot.org Mon Feb 13 22:42:41 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 22:42:41 +0200 Subject: dovecot-2.1: doveadm pw: Added -t parameter to the usage ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e6ad15862163 changeset: 14149:e6ad15862163 user: Pascal Volk date: Mon Feb 13 20:40:54 2012 +0000 description: doveadm pw: Added -t parameter to the usage message. diffstat: src/doveadm/doveadm-pw.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (10 lines): diff -r b4479e2d2d21 -r e6ad15862163 src/doveadm/doveadm-pw.c --- a/src/doveadm/doveadm-pw.c Mon Feb 13 19:59:13 2012 +0000 +++ b/src/doveadm/doveadm-pw.c Mon Feb 13 20:40:54 2012 +0000 @@ -129,5 +129,5 @@ struct doveadm_cmd doveadm_cmd_pw = { cmd_pw, "pw", - "[-l] [-p plaintext] [-r rounds] [-s scheme] [-u user] [-V]" + "[-l] [-p plaintext] [-r rounds] [-s scheme] [-t hash] [-u user] [-V]" }; From pigeonhole at rename-it.nl Mon Feb 13 22:50:47 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 13 Feb 2012 21:50:47 +0100 Subject: dovecot-2.0-pigeonhole: Added tag 0.2.6 for changeset ec0e2aa78640 Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/e290a2a4f721 changeset: 1556:e290a2a4f721 user: Stephan Bosch date: Mon Feb 13 21:50:35 2012 +0100 description: Added tag 0.2.6 for changeset ec0e2aa78640 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r ec0e2aa78640 -r e290a2a4f721 .hgtags --- a/.hgtags Mon Feb 13 21:50:22 2012 +0100 +++ b/.hgtags Mon Feb 13 21:50:35 2012 +0100 @@ -9,3 +9,4 @@ 3ab2a125e1e2d478382c07853e99a5973d06afd6 0.2.3 0d071eaa6d5e2a9f524c94ddf1686f1b3091f604 0.2.4 873baa85e2202f45a9c14fa21cccedc60f3715bc 0.2.5 +ec0e2aa786407d7a26a8f7dced80cde5d8b05760 0.2.6 From pigeonhole at rename-it.nl Mon Feb 13 22:50:47 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 13 Feb 2012 21:50:47 +0100 Subject: dovecot-2.0-pigeonhole: Released v0.2.6 for Dovecot v2.0.18. Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/ec0e2aa78640 changeset: 1555:ec0e2aa78640 user: Stephan Bosch date: Mon Feb 13 21:50:22 2012 +0100 description: Released v0.2.6 for Dovecot v2.0.18. diffstat: NEWS | 17 +++++++++++++++++ configure.in | 2 +- 2 files changed, 18 insertions(+), 1 deletions(-) diffs (33 lines): diff -r 58fc2f01c432 -r ec0e2aa78640 NEWS --- a/NEWS Fri Feb 03 23:51:53 2012 +0100 +++ b/NEWS Mon Feb 13 21:50:22 2012 +0100 @@ -1,3 +1,20 @@ +v0.2.6 13-02-2012 Stephan Bosch + + * This release fixes unintentional behavior of the include extension. Included + scriptnames with a name like "name.sieve" would implicitly map to a script + file called "name.sieve" and not "name.sieve.sieve". Keep in mind that the + .sieve file extension has no meaning from within the Sieve language. A Sieve + script is always stored with an appended .sieve file extension, also when + the name already ends with a .sieve suffix. + IMPORTANT: Some installations have relied on this unintentional feature, so + check your script includes for issues before upgrading. + * Matched changes regarding auth_verbose setting in Dovecot. This means that + this release will only compile against Dovecot v2.0.18. + - Fixed problem in ManageSieve that caused it to omit a WARNINGS response code + when the uploaded script compiled with warnings. + - Made sure that locations of Sieve error never report `line 0'. + - Fixed potential segfault occuring when interpreter initialization fails. + v0.2.5 19-11-2011 Stephan Bosch + Sieve vacation extension: made discard message for implicit delivery more diff -r 58fc2f01c432 -r ec0e2aa78640 configure.in --- a/configure.in Fri Feb 03 23:51:53 2012 +0100 +++ b/configure.in Mon Feb 13 21:50:22 2012 +0100 @@ -1,4 +1,4 @@ -AC_INIT([Pigeonhole], [0.2.5], [dovecot at dovecot.org], [dovecot-2.0-pigeonhole]) +AC_INIT([Pigeonhole], [0.2.6], [dovecot at dovecot.org], [dovecot-2.0-pigeonhole]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) From pigeonhole at rename-it.nl Mon Feb 13 22:52:50 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Mon, 13 Feb 2012 21:52:50 +0100 Subject: dovecot-2.0-pigeonhole: Added signature for changeset ec0e2aa78640 Message-ID: details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/67950c9d3675 changeset: 1557:67950c9d3675 user: Stephan Bosch date: Mon Feb 13 21:52:43 2012 +0100 description: Added signature for changeset ec0e2aa78640 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r e290a2a4f721 -r 67950c9d3675 .hgsigs --- a/.hgsigs Mon Feb 13 21:50:35 2012 +0100 +++ b/.hgsigs Mon Feb 13 21:52:43 2012 +0100 @@ -3,3 +3,4 @@ 3ab2a125e1e2d478382c07853e99a5973d06afd6 0 iQEcBAABAgAGBQJNp1ztAAoJEATWKx49+7T0CJcH/24Txa1ynS5hBUhOuWTpUTGtm+9cMpWoQ33exiMR0pm8ycxsUQcKfRtO/cRHQX1CW3PqQs3DGZ31QdEEg0CyX8OsBbP/dwdEcnLRYF5BsJMyfy+Qnbhxn+wV0k9s9AUgZTdvPKrg1hFa6XS+6SE3N33AA4Y2eYYZGzFuDiSoN7fGx7PATCrobMsmp5WtBiKoy4WyP2SwDv/VgKy0PQTF+6+0t0MMCBSurLzpHk8dDuBonWIBgbJRM/sk9f+cYbU/ESRMcryZbbau9EwMQIQJfprGH6WP/gwysF0pu47zQERMuVt3fFzXUzrfxVpMOI7EkLgnF+Tes0vA7dKh1x+vvec= 0d071eaa6d5e2a9f524c94ddf1686f1b3091f604 0 iQEcBAABAgAGBQJOb8BjAAoJEATWKx49+7T0cAcH/3coc1MhQj8zUdC+NB3N8eUkQ3AF3QQgSfP9uXs9BhvPw70Ts9MLJiO54RhhYf/k9VxptzWk7MPJF47v4NEEKHkjDDMXtPbVOxHjNa2Ny8EAuWe4dv5X0faAlH4Ks58enDchCmunX1DgQtC1f+gHqVtvTpGAROFPqkBe5RGOJ0jQd+2hTTlf1BpLl44fiBdYd6350haX0KjDGNthX9ETVc3bnbdIiXSy7DPnn0ELhvTbgkl4Zu1tA778IJy/JjsCPb2YueX7LsksvxcSZHqv80Zd3JJhs5a3ZeHijN6twpe7VZD9FO+jPOKA1rr/HYwCv0KweKgmwVHCdaT+Mq4OLPc= 873baa85e2202f45a9c14fa21cccedc60f3715bc 0 iQEcBAABAgAGBQJOx9MCAAoJEATWKx49+7T09aUIANIKsuzM3bGhtGJ/UPIwzpOu39lEGCmHah6dMa+bDOoCZhuhASDdTuvRKXTfGC57GMu+NzBK6I7heFiPD3E4VTI4xOCK1azJ9G4SsiDEkQThucXqWBKDjPB0RgOEf6iefAkslXIU3cprJgattwpeXbUKiHjBhoYJFJ5j/GTx1B62ndvaTfMu1zF5UppiyRG1rQD7FLY4f6kANzSI2jOOCBs4UFH7ZKhafO1AeQfLNDvxdDczZafPZxrCIF+5JCNvQ6Xue/JrvRZQ0V9sxLQat7clUJ6I6Ejl5u5l1LF+VscWldfaQKwDdOktCVux84YGH8+XqXaukMiEg6j4hceAYIM= +ec0e2aa786407d7a26a8f7dced80cde5d8b05760 0 iQEcBAABAgAGBQJPOXgWAAoJEATWKx49+7T0GYEH/2zZi8HQ+2BLaj2LdxU8KRiS4PzU1a0AmDXw7Szy6R367HjSCLybK4g4iq92evgkPV3WE3GAk/VyXqCG3BdfadGFDeHsXYaazLnW+5+IcEDcmLazUi+FQ1zqFU2TSC2MPykqnXUYw0XmWtjklydUx56NhBFubZ+hrBKH7DGBJejwDdV0y6k4zrI+PpSsRYGSS9NEW2zHURIHuoM1a8K6RIxkKedNprHiZhMUQYAmX++Ev1hOVVKvIQ4UhVQU0ceDCBnGn8GerwUZ2TOW9jtUzeJbcjPpEYuNsO8AfpSozUq6kLC1OZF1AwE5cvcvrwvzHtpd8uniJKGbQRQ6CIHQseo= From dovecot at dovecot.org Mon Feb 13 23:47:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 13 Feb 2012 23:47:14 +0200 Subject: dovecot-2.1: man: Added descriptions of -t option to doveadm-pw.1. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/db67d0255411 changeset: 14150:db67d0255411 user: Pascal Volk date: Mon Feb 13 21:40:02 2012 +0000 description: man: Added descriptions of -t option to doveadm-pw.1. diffstat: doc/man/doveadm-pw.1.in | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diffs (36 lines): diff -r e6ad15862163 -r db67d0255411 doc/man/doveadm-pw.1.in --- a/doc/man/doveadm-pw.1.in Mon Feb 13 20:40:54 2012 +0000 +++ b/doc/man/doveadm-pw.1.in Mon Feb 13 21:40:02 2012 +0000 @@ -1,5 +1,5 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-PW 1 "2010-06-22" "Dovecot v2.1" "Dovecot" +.\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-PW 1 "2012-02-13" "Dovecot v2.1" "Dovecot" .SH NAME doveadm\-pw \- Dovecot\(aqs password hash generator .\"------------------------------------------------------------------------ @@ -13,6 +13,11 @@ [\fB\-s\fP \fIscheme\fP] [\fB\-u\fP \fIuser\fP] .RB [ \-V ] +.\"------------------------------------- +.br +.BR doveadm " [" \-Dv "] " "pw \-t" +.I hash +[\fB\-u\fP \fIuser\fP] .\"------------------------------------------------------------------------ .SH DESCRIPTION .B doveadm pw @@ -106,6 +111,12 @@ details about password schemes. .\"------------------------------------- .TP +.BI \-t\ hash +Test if the given password +.IR hash +matches a given plain text password. +.\"------------------------------------- +.TP .BI \-u\ user When the .BI DIGEST\-MD5\ scheme From dovecot at dovecot.org Wed Feb 15 04:32:27 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 15 Feb 2012 04:32:27 +0200 Subject: dovecot-2.1: lib-master: Fixed crash on IPC client if server dis... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5ac4a8c8545f changeset: 14151:5ac4a8c8545f user: Timo Sirainen date: Wed Feb 15 04:32:14 2012 +0200 description: lib-master: Fixed crash on IPC client if server disconnected unexpectedly. diffstat: src/lib-master/ipc-client.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r db67d0255411 -r 5ac4a8c8545f src/lib-master/ipc-client.c --- a/src/lib-master/ipc-client.c Mon Feb 13 21:40:02 2012 +0000 +++ b/src/lib-master/ipc-client.c Wed Feb 15 04:32:14 2012 +0200 @@ -113,6 +113,7 @@ o_stream_destroy(&client->output); if (close(client->fd) < 0) i_error("close(%s) failed: %m", client->path); + client->fd = -1; } struct ipc_client * From dovecot at dovecot.org Wed Feb 15 04:32:34 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 15 Feb 2012 04:32:34 +0200 Subject: dovecot-2.0: lib-master: Fixed crash on IPC client if server dis... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/c402fb407501 changeset: 13059:c402fb407501 user: Timo Sirainen date: Wed Feb 15 04:32:14 2012 +0200 description: lib-master: Fixed crash on IPC client if server disconnected unexpectedly. diffstat: src/lib-master/ipc-client.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r 8e1cab0b9374 -r c402fb407501 src/lib-master/ipc-client.c --- a/src/lib-master/ipc-client.c Mon Feb 13 18:27:44 2012 +0200 +++ b/src/lib-master/ipc-client.c Wed Feb 15 04:32:14 2012 +0200 @@ -113,6 +113,7 @@ o_stream_destroy(&client->output); if (close(client->fd) < 0) i_error("close(%s) failed: %m", client->path); + client->fd = -1; } struct ipc_client * From dovecot at dovecot.org Wed Feb 15 05:12:39 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 15 Feb 2012 05:12:39 +0200 Subject: dovecot-2.1: login: If auth client disconnects without having ev... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4462ceb09c0d changeset: 14152:4462ceb09c0d user: Timo Sirainen date: Wed Feb 15 05:12:14 2012 +0200 description: login: If auth client disconnects without having ever succeeded, destroy clients. diffstat: src/login-common/client-common.c | 9 +++++++-- src/login-common/client-common.h | 1 + src/login-common/main.c | 12 ++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diffs (68 lines): diff -r 5ac4a8c8545f -r 4462ceb09c0d src/login-common/client-common.c --- a/src/login-common/client-common.c Wed Feb 15 04:32:14 2012 +0200 +++ b/src/login-common/client-common.c Wed Feb 15 05:12:14 2012 +0200 @@ -244,16 +244,21 @@ client_destroy(client, "Disconnected: Connection queue full"); } -void clients_destroy_all(void) +void clients_destroy_all_reason(const char *reason) { struct client *client, *next; for (client = clients; client != NULL; client = next) { next = client->next; - client_destroy(client, "Disconnected: Shutting down"); + client_destroy(client, reason); } } +void clients_destroy_all(void) +{ + clients_destroy_all_reason("Disconnected: Shutting down"); +} + static void client_start_tls(struct client *client) { int fd_ssl; diff -r 5ac4a8c8545f -r 4462ceb09c0d src/login-common/client-common.h --- a/src/login-common/client-common.h Wed Feb 15 04:32:14 2012 +0200 +++ b/src/login-common/client-common.h Wed Feb 15 05:12:14 2012 +0200 @@ -187,5 +187,6 @@ void clients_notify_auth_connected(void); void client_destroy_oldest(void); void clients_destroy_all(void); +void clients_destroy_all_reason(const char *reason); #endif diff -r 5ac4a8c8545f -r 4462ceb09c0d src/login-common/main.c --- a/src/login-common/main.c Wed Feb 15 04:32:14 2012 +0200 +++ b/src/login-common/main.c Wed Feb 15 05:12:14 2012 +0200 @@ -45,6 +45,7 @@ static struct timeout *auth_client_to; static bool shutting_down = FALSE; static bool ssl_connections = FALSE; +static bool auth_connected_once = FALSE; static void login_access_lookup_next(struct login_access_lookup *lookup); @@ -246,10 +247,17 @@ static void auth_connect_notify(struct auth_client *client ATTR_UNUSED, bool connected, void *context ATTR_UNUSED) { - if (connected) + if (connected) { + auth_connected_once = TRUE; clients_notify_auth_connected(); - else if (shutting_down) + } else if (shutting_down) clients_destroy_all(); + else if (!auth_connected_once) { + /* auth disconnected without having ever succeeded, so the + auth process is probably misconfigured. no point in + keeping the client connections hanging. */ + clients_destroy_all_reason("Disconnected: Auth process broken"); + } } static bool anvil_reconnect_callback(void) From dovecot at dovecot.org Wed Feb 15 06:08:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 15 Feb 2012 06:08:32 +0200 Subject: dovecot-2.1: Added tag 2.1.rc7 for changeset 736f1b7af190 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5de9a1f4ab04 changeset: 14154:5de9a1f4ab04 user: Timo Sirainen date: Wed Feb 15 05:49:17 2012 +0200 description: Added tag 2.1.rc7 for changeset 736f1b7af190 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 736f1b7af190 -r 5de9a1f4ab04 .hgtags --- a/.hgtags Wed Feb 15 05:49:17 2012 +0200 +++ b/.hgtags Wed Feb 15 05:49:17 2012 +0200 @@ -75,3 +75,4 @@ a20a99b8815d4d0ddd176e529a8928d00473fd7f 2.1.rc4 0f10b3ed5c18eefb752d8b76a0071b10a969fdf1 2.1.rc5 481860782250ad55ab18ca81bd606fc70c3d2ad9 2.1.rc6 +736f1b7af190ea68e65719277bd8d3d4682e0844 2.1.rc7 From dovecot at dovecot.org Wed Feb 15 06:08:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 15 Feb 2012 06:08:32 +0200 Subject: dovecot-2.1: Released v2.1.rc7. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/736f1b7af190 changeset: 14153:736f1b7af190 user: Timo Sirainen date: Wed Feb 15 05:49:17 2012 +0200 description: Released v2.1.rc7. diffstat: NEWS | 6 ++++++ configure.in | 2 +- 2 files changed, 7 insertions(+), 1 deletions(-) diffs (23 lines): diff -r 4462ceb09c0d -r 736f1b7af190 NEWS --- a/NEWS Wed Feb 15 05:12:14 2012 +0200 +++ b/NEWS Wed Feb 15 05:49:17 2012 +0200 @@ -1,3 +1,9 @@ +v2.1.rc7 2012-02-15 Timo Sirainen + + + Added ignore_on_failure setting for namespaces. If namespace + initialization fails with this enabled (e.g. permission denied), + the namespace is silently skipped for the user. + v2.1.rc6 2012-02-12 Timo Sirainen * Added automatic mountpoint tracking and doveadm mount commands to diff -r 4462ceb09c0d -r 736f1b7af190 configure.in --- a/configure.in Wed Feb 15 05:12:14 2012 +0200 +++ b/configure.in Wed Feb 15 05:49:17 2012 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.rc6],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.rc7],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Wed Feb 15 06:08:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 15 Feb 2012 06:08:32 +0200 Subject: dovecot-2.1: Added signature for changeset 736f1b7af190 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/908bf2312c14 changeset: 14155:908bf2312c14 user: Timo Sirainen date: Wed Feb 15 05:49:20 2012 +0200 description: Added signature for changeset 736f1b7af190 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 5de9a1f4ab04 -r 908bf2312c14 .hgsigs --- a/.hgsigs Wed Feb 15 05:49:17 2012 +0200 +++ b/.hgsigs Wed Feb 15 05:49:20 2012 +0200 @@ -38,3 +38,4 @@ a20a99b8815d4d0ddd176e529a8928d00473fd7f 0 iEYEABECAAYFAk8ezgsACgkQyUhSUUBVismeJQCfVq1NwEBD/U0GTy6Bk5mdBBy6CAEAn1/s2UzStxTUIxy0bmBJg8d+91Jv 0f10b3ed5c18eefb752d8b76a0071b10a969fdf1 0 iEYEABECAAYFAk8ghdYACgkQyUhSUUBVism4swCdGiTY9/6R8vZmxsg7gyrMhFAutZ4AnRwLbjzBreqPbmWvbP1CYrGHQzT6 481860782250ad55ab18ca81bd606fc70c3d2ad9 0 iEYEABECAAYFAk84IqgACgkQyUhSUUBVislPnQCfdgX9pbhqat0CCZhEjGiYu0uPXFUAn1QOG9uetBsgOM6MB4tuJc58Pl4c +736f1b7af190ea68e65719277bd8d3d4682e0844 0 iEYEABECAAYFAk87Kz4ACgkQyUhSUUBVismKXACeME7EBYoEuoLLELp0uX6B/lkgRWQAoJ2OAgz4mmluGbi0Db8grDDWSsTj From dovecot at dovecot.org Thu Feb 16 18:10:22 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Feb 2012 18:10:22 +0200 Subject: dovecot-2.1: fs layout: Fixed crash when autocreate mailboxes we... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/72e1e17d2e22 changeset: 14156:72e1e17d2e22 user: Timo Sirainen date: Thu Feb 16 18:10:09 2012 +0200 description: fs layout: Fixed crash when autocreate mailboxes were used and LIST had only invalid patterns. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (15 lines): diff -r 908bf2312c14 -r 72e1e17d2e22 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Wed Feb 15 05:49:20 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Thu Feb 16 18:10:09 2012 +0200 @@ -407,7 +407,10 @@ ctx->info.ns = _list->ns; if (!fs_list_get_valid_patterns(ctx, patterns)) { - /* we've only invalid patterns (or INBOX) */ + /* we've only invalid patterns (or INBOX). create a glob + anyway to avoid any crashes due to glob being accessed + elsewhere */ + ctx->ctx.glob = imap_match_init(pool, "", TRUE, ctx->sep); return &ctx->ctx; } ctx->ctx.glob = imap_match_init_multiple(pool, ctx->valid_patterns, From dovecot at dovecot.org Thu Feb 16 18:32:54 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Feb 2012 18:32:54 +0200 Subject: dovecot-2.1: man: Added doveadm-instance(1) and doveadm-mount(1) Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/b88deb09b0f4 changeset: 14157:b88deb09b0f4 user: Timo Sirainen date: Thu Feb 16 18:31:57 2012 +0200 description: man: Added doveadm-instance(1) and doveadm-mount(1) roff'ification by Pascal Volk. diffstat: .hgignore | 2 +- doc/man/Makefile.am | 12 +++++ doc/man/doveadm-instance.1.in | 63 ++++++++++++++++++++++++++++ doc/man/doveadm-mount.1.in | 94 +++++++++++++++++++++++++++++++++++++++++++ doc/man/doveadm.1.in | 10 ++++ 5 files changed, 180 insertions(+), 1 deletions(-) diffs (257 lines): diff -r 72e1e17d2e22 -r b88deb09b0f4 .hgignore --- a/.hgignore Thu Feb 16 18:10:09 2012 +0200 +++ b/.hgignore Thu Feb 16 18:31:57 2012 +0200 @@ -98,5 +98,5 @@ syntax: regexp src/.*/test-[^\.]*$ -doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|index|force-resync|help|kick|log|mailbox|move|penalty|purge|pw|quota|search|user|who)\.1$ +doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|instance|index|force-resync|help|kick|log|mailbox|mount|move|penalty|purge|pw|quota|search|user|who)\.1$ doc/man/(doveadm|doveconf|dovecot-lda|dovecot|dsync)\.1$ diff -r 72e1e17d2e22 -r b88deb09b0f4 doc/man/Makefile.am --- a/doc/man/Makefile.am Thu Feb 16 18:10:09 2012 +0200 +++ b/doc/man/Makefile.am Thu Feb 16 18:31:57 2012 +0200 @@ -18,12 +18,14 @@ doveadm-expunge.1 \ doveadm-fetch.1 \ doveadm-import.1 \ + doveadm-instance.1 \ doveadm-index.1 \ doveadm-force-resync.1 \ doveadm-help.1 \ doveadm-kick.1 \ doveadm-log.1 \ doveadm-mailbox.1 \ + doveadm-mount.1 \ doveadm-move.1 \ doveadm-penalty.1 \ doveadm-purge.1 \ @@ -54,12 +56,14 @@ doveadm-expunge.1.in \ doveadm-fetch.1.in \ doveadm-import.1.in \ + doveadm-instance.1.in \ doveadm-index.1.in \ doveadm-force-resync.1.in \ doveadm-help.1.in \ doveadm-kick.1.in \ doveadm-log.1.in \ doveadm-mailbox.1.in \ + doveadm-mount.1.in \ doveadm-move.1.in \ doveadm-penalty.1.in \ doveadm-purge.1.in \ @@ -109,6 +113,10 @@ $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-import.1.in > doveadm-import.1 +doveadm-instance.1: $(srcdir)/doveadm-instance.1.in $(man_includefiles) Makefile + $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ + < $(srcdir)/doveadm-instance.1.in > doveadm-instance.1 + doveadm-index.1: $(srcdir)/doveadm-index.1.in $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-index.1.in > doveadm-index.1 @@ -133,6 +141,10 @@ $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-mailbox.1.in > doveadm-mailbox.1 +doveadm-mount.1: $(srcdir)/doveadm-mount.1.in $(man_includefiles) Makefile + $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ + < $(srcdir)/doveadm-mount.1.in > doveadm-mount.1 + doveadm-move.1: $(srcdir)/doveadm-move.1.in $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-move.1.in > doveadm-move.1 diff -r 72e1e17d2e22 -r b88deb09b0f4 doc/man/doveadm-instance.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-instance.1.in Thu Feb 16 18:31:57 2012 +0200 @@ -0,0 +1,63 @@ +.\" Copyright (c) 2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-INSTANCE 1 "2012-02-16" "Dovecot v2.1" "Dovecot" +.SH NAME +doveadm\-instance \- Manage the list of running Dovecot instances +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] [" \-f +.IR formatter ] +.B instance list +.br +.BR doveadm " [" \-Dv "] " "instance remove" +.IR name " | " base_dir +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +The +.B doveadm instance +commands are used to manage the list of Dovecot instances running on the +server. +In most installations there is only one Dovecot instance, but in some cases +is may be useful to have more (e.g. running director proxy and backend in +the same server). +.PP +Instances are added to the list automatically when Dovecot is started. +Each instance is uniquely identified by its +.I base_dir +setting. +Instances can be named by setting +.I instance_name +in each instance\(aqs +.IR dovecot.conf . +When an instance is named, it can be accessed easily by giving +.BI \-i\ instance_name +command line parameter for Dovecot binaries (e.g. doveadm). +.\"------------------------------------------------------------------------ + at INCLUDE:global-options-formatter@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I name +The value of an instance\(aqs +.I instance_name +setting. +.\"------------------------------------- +.TP +.I base_dir +The base directory of a Dovecot instance. +.\"------------------------------------------------------------------------ +.SH COMMANDS +.SS instance list +.B doveadm instance list +.PP +This command lists the seen Dovecot instances. +.\"------------------------------------- +.SS instance remove +.B doveadm instance remove +.IR name " | " base_dir +.PP +This command removes the specified instance. +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1) \ No newline at end of file diff -r 72e1e17d2e22 -r b88deb09b0f4 doc/man/doveadm-mount.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-mount.1.in Thu Feb 16 18:31:57 2012 +0200 @@ -0,0 +1,94 @@ +.\" Copyright (c) 2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-MOUNT 1 "2012-02-16" "Dovecot v2.1" "Dovecot" +.SH NAME +doveadm\-mount \- Manage the list of mountpoints where mails are stored +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] [" \-f +.IR formatter ] +.B mount +.IR command " [" arguments ] +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +The doveadm +.B mount +.IR command s +can be used to manage the list of mountpoints where mails are stored. +This is used mainly for better error handling when a mountpoint isn\(aqt +mounted for some reason: +.TP 4 +* +If a mail directory doesn\(aqt exist, it\(aqs autocreated. +If the user\(aqs mails aren\(aqt mounted and filesystem permissions still +allow the autocreation, the user will see an empty mailbox and later will +have to redownload all mails. +If the mountpoint is known to be unmounted, Dovecot will simply fail +opening any mailboxes. +.TP +* +If dbox alternate storage isn\(aqt mounted and a mail in it is attempted to +be accessed, Dovecot normally rebuilds the indexes and notices that all the +mails in alt storage are expunged. +When the alt storage is mounted back and even if index is again rebuilt, +the mails won\(aqt necessarily become visible anymore for IMAP clients. +If the mountpoint is known to be unmounted, Dovecot won\(aqt rebuild +indexes and lose the mails. +.PP +Dovecot automatically adds mountpoints to this list at startup. +If you don\(aqt want some of the mountpoints added, you can add a wildcard +ignore for it. +.\"------------------------------------------------------------------------ + at INCLUDE:global-options-formatter@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I path +The directory name of a mountpoint +.\"------------------------------------- +.TP +.I state +The +.I state +of a mountpoint. +Either +.BR online " or " ignore . +.\"------------------------------------------------------------------------ +.SH COMMANDS +.SS mount add +.B doveadm mount add +.RI [ path " [" state ]] +.PP +If this command is run without any parameters, doveadm detects all missing +mountpoints and adds them (the same way as when Dovecot does at startup). +.PP +When a mountpoint +.I path +is given, it\(aqs added as a mountpoint. +The +.I state +can currently be either +.RB \(dq online \(dq +(default) or +.RB \(dq ignore \(dq. +The ignore state is mainly useful with path wildcards to add mountpoints +that you never want Dovecot to automatically add, such as: +.B doveadm mount add '/mnt/*' ignore +.\"------------------------------------- +.SS mount list +.BR doveadm " [" \-Dv " ] [" \-f +.IR formatter ] +.B mount list +.PP +This command lists the mountpoints known to Dovecot and their state. +.\"------------------------------------- +.SS mount remove +.BI "doveadm mount remove " path +.PP +This command removes the specified +.I path +from the mountpoint list. +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1) \ No newline at end of file diff -r 72e1e17d2e22 -r b88deb09b0f4 doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Thu Feb 16 18:10:09 2012 +0200 +++ b/doc/man/doveadm.1.in Thu Feb 16 18:31:57 2012 +0200 @@ -112,11 +112,21 @@ Import messages matching given search query. .\"------------------------------------- .TP +.B doveadm instance +.BR doveadm\-instance (1), +Various commands related to handling Dovecot instances. +.\"------------------------------------- +.TP .B doveadm index .BR doveadm\-index (1), Index messages in a given mailbox. .\"------------------------------------- .TP +.B doveadm mount +.BR doveadm\-mount (1), +Various commands related to handling mail storage mountpoints. +.\"------------------------------------- +.TP .B doveadm mailbox .BR doveadm\-mailbox (1), Various commands related to handling mailboxes. From dovecot at dovecot.org Thu Feb 16 19:17:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Feb 2012 19:17:07 +0200 Subject: dovecot-2.1: Added tag 2.1.0 for changeset e2cd03cc9c69 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c696e99a0169 changeset: 14159:c696e99a0169 user: Timo Sirainen date: Thu Feb 16 18:40:25 2012 +0200 description: Added tag 2.1.0 for changeset e2cd03cc9c69 diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r e2cd03cc9c69 -r c696e99a0169 .hgtags --- a/.hgtags Thu Feb 16 18:40:25 2012 +0200 +++ b/.hgtags Thu Feb 16 18:40:25 2012 +0200 @@ -76,3 +76,4 @@ 0f10b3ed5c18eefb752d8b76a0071b10a969fdf1 2.1.rc5 481860782250ad55ab18ca81bd606fc70c3d2ad9 2.1.rc6 736f1b7af190ea68e65719277bd8d3d4682e0844 2.1.rc7 +e2cd03cc9c690c4989fb53a1871b7109c547388a 2.1.0 From dovecot at dovecot.org Thu Feb 16 19:17:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Feb 2012 19:17:07 +0200 Subject: dovecot-2.1: Released v2.1.0. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e2cd03cc9c69 changeset: 14158:e2cd03cc9c69 user: Timo Sirainen date: Thu Feb 16 18:40:25 2012 +0200 description: Released v2.1.0. diffstat: NEWS | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 2 +- 2 files changed, 51 insertions(+), 1 deletions(-) diffs (67 lines): diff -r 908bf2312c14 -r e2cd03cc9c69 NEWS --- a/NEWS Wed Feb 15 05:49:20 2012 +0200 +++ b/NEWS Thu Feb 16 18:40:25 2012 +0200 @@ -1,3 +1,53 @@ +v2.1.0 2012-02-16 Timo Sirainen + + * Plugins now use UTF-8 mailbox names rather than mUTF-7: + acl, autocreate, expire, trash, virtual + * auth_username_format default changed to %Lu. If you really want + case sensitive usernames, set it back to empty. + * Solr full text search backend changed to use mailbox GUIDs instead of + mailbox names, requiring reindexing everything. solr_old backend can + be used with old indexes to avoid reindexing, but it doesn't support + some newer features. + * Expire plugin: Only go through users listed by userdb iteration. + Delete dict rows for nonexistent users, unless + expire_keep_nonexistent_users=yes. + * Temporary authentication failures sent to IMAP/POP3 clients + now includes the server's hostname and timestamp. This makes it + easier to find the error message from logs. + * dsync was merged into doveadm. There is still "dsync" symlink + pointing to "doveadm", which you can use the old way for now. + The preferred ways to run dsync are "doveadm sync" (for old "dsync + mirror") and "doveadm backup". + + + imapc (= IMAP client) storage allows using a remote IMAP server to + be used as storage. This allows using Dovecot as a smart (caching) + proxy or using dsync to do migration from remote IMAP server. + + Mailbox indexing via queuing indexer service (required for Lucene) + + Lucene full text search (FTS) backend rewritten with support for + different languages + + FTS finally supports "OR" search operation + + FTS supports indexing attachments via external programs + + IMAP FUZZY extension, supported by Lucene and Solr FTS backends + + IMAP SPECIAL-USE extension to describe mailboxes + + Mailbox list indexes + + Statistics tracking via stats service. Exported via doveadm stats. + + Autocreate plugin creates/subscribes mailboxes physically only when + the mailbox is opened for the first time. Mailbox listing shows the + autocreated mailboxes even if they don't physically exist. + + Password and user databases now support default_fields and + override_fields settings to specify template defaults/overrides. + + SCRAM-SHA-1 authentication mechanism by Florian Zeitz + + LDAP: Allow building passdb/userdb extra fields from multiple LDAP + attributes by using %{ldap:attributeName} variables in the template. + + Improved multi-instance support: Track automatically which instances + are started up and manage the list with doveadm instance commands. + All Dovecot commands now support -i parameter to + select the instance (instead of having to use -c ). + See instance_name setting. + + auth: Implemented support for Postfix's "TCP map" sockets for + user existence lookups. + - listescape plugin works perfectly now + v2.1.rc7 2012-02-15 Timo Sirainen + Added ignore_on_failure setting for namespaces. If namespace diff -r 908bf2312c14 -r e2cd03cc9c69 configure.in --- a/configure.in Wed Feb 15 05:49:20 2012 +0200 +++ b/configure.in Thu Feb 16 18:40:25 2012 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.rc7],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.0],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Thu Feb 16 19:17:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Feb 2012 19:17:07 +0200 Subject: dovecot-2.1: Added signature for changeset e2cd03cc9c69 Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3e0a1e5f43f3 changeset: 14160:3e0a1e5f43f3 user: Timo Sirainen date: Thu Feb 16 18:40:29 2012 +0200 description: Added signature for changeset e2cd03cc9c69 diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r c696e99a0169 -r 3e0a1e5f43f3 .hgsigs --- a/.hgsigs Thu Feb 16 18:40:25 2012 +0200 +++ b/.hgsigs Thu Feb 16 18:40:29 2012 +0200 @@ -39,3 +39,4 @@ 0f10b3ed5c18eefb752d8b76a0071b10a969fdf1 0 iEYEABECAAYFAk8ghdYACgkQyUhSUUBVism4swCdGiTY9/6R8vZmxsg7gyrMhFAutZ4AnRwLbjzBreqPbmWvbP1CYrGHQzT6 481860782250ad55ab18ca81bd606fc70c3d2ad9 0 iEYEABECAAYFAk84IqgACgkQyUhSUUBVislPnQCfdgX9pbhqat0CCZhEjGiYu0uPXFUAn1QOG9uetBsgOM6MB4tuJc58Pl4c 736f1b7af190ea68e65719277bd8d3d4682e0844 0 iEYEABECAAYFAk87Kz4ACgkQyUhSUUBVismKXACeME7EBYoEuoLLELp0uX6B/lkgRWQAoJ2OAgz4mmluGbi0Db8grDDWSsTj +e2cd03cc9c690c4989fb53a1871b7109c547388a 0 iEYEABECAAYFAk89MXsACgkQyUhSUUBVisnPmwCgiAr4OfQX1uAjhuqj5X0xbd8O1NQAn2bQW+h8QPAbqN6dQRNTm82D2hNF From dovecot at dovecot.org Thu Feb 16 19:17:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Feb 2012 19:17:07 +0200 Subject: dovecot-2.1: Messed up with v2.1 release, merging changes that w... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/aa2e89c9876b changeset: 14161:aa2e89c9876b user: Timo Sirainen date: Thu Feb 16 19:16:54 2012 +0200 description: Messed up with v2.1 release, merging changes that were supposed to be there. diffstat: .hgignore | 2 +- doc/man/Makefile.am | 12 +++ doc/man/doveadm-instance.1.in | 63 +++++++++++++++++++ doc/man/doveadm-mount.1.in | 94 +++++++++++++++++++++++++++++ doc/man/doveadm.1.in | 10 +++ src/lib-storage/list/mailbox-list-fs-iter.c | 5 +- 6 files changed, 184 insertions(+), 2 deletions(-) diffs (272 lines): diff -r 3e0a1e5f43f3 -r aa2e89c9876b .hgignore --- a/.hgignore Thu Feb 16 18:40:29 2012 +0200 +++ b/.hgignore Thu Feb 16 19:16:54 2012 +0200 @@ -98,5 +98,5 @@ syntax: regexp src/.*/test-[^\.]*$ -doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|index|force-resync|help|kick|log|mailbox|move|penalty|purge|pw|quota|search|user|who)\.1$ +doc/man/doveadm-(altmove|auth|director|dump|expunge|fetch|import|instance|index|force-resync|help|kick|log|mailbox|mount|move|penalty|purge|pw|quota|search|user|who)\.1$ doc/man/(doveadm|doveconf|dovecot-lda|dovecot|dsync)\.1$ diff -r 3e0a1e5f43f3 -r aa2e89c9876b doc/man/Makefile.am --- a/doc/man/Makefile.am Thu Feb 16 18:40:29 2012 +0200 +++ b/doc/man/Makefile.am Thu Feb 16 19:16:54 2012 +0200 @@ -18,12 +18,14 @@ doveadm-expunge.1 \ doveadm-fetch.1 \ doveadm-import.1 \ + doveadm-instance.1 \ doveadm-index.1 \ doveadm-force-resync.1 \ doveadm-help.1 \ doveadm-kick.1 \ doveadm-log.1 \ doveadm-mailbox.1 \ + doveadm-mount.1 \ doveadm-move.1 \ doveadm-penalty.1 \ doveadm-purge.1 \ @@ -54,12 +56,14 @@ doveadm-expunge.1.in \ doveadm-fetch.1.in \ doveadm-import.1.in \ + doveadm-instance.1.in \ doveadm-index.1.in \ doveadm-force-resync.1.in \ doveadm-help.1.in \ doveadm-kick.1.in \ doveadm-log.1.in \ doveadm-mailbox.1.in \ + doveadm-mount.1.in \ doveadm-move.1.in \ doveadm-penalty.1.in \ doveadm-purge.1.in \ @@ -109,6 +113,10 @@ $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-import.1.in > doveadm-import.1 +doveadm-instance.1: $(srcdir)/doveadm-instance.1.in $(man_includefiles) Makefile + $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ + < $(srcdir)/doveadm-instance.1.in > doveadm-instance.1 + doveadm-index.1: $(srcdir)/doveadm-index.1.in $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-index.1.in > doveadm-index.1 @@ -133,6 +141,10 @@ $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-mailbox.1.in > doveadm-mailbox.1 +doveadm-mount.1: $(srcdir)/doveadm-mount.1.in $(man_includefiles) Makefile + $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ + < $(srcdir)/doveadm-mount.1.in > doveadm-mount.1 + doveadm-move.1: $(srcdir)/doveadm-move.1.in $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ < $(srcdir)/doveadm-move.1.in > doveadm-move.1 diff -r 3e0a1e5f43f3 -r aa2e89c9876b doc/man/doveadm-instance.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-instance.1.in Thu Feb 16 19:16:54 2012 +0200 @@ -0,0 +1,63 @@ +.\" Copyright (c) 2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-INSTANCE 1 "2012-02-16" "Dovecot v2.1" "Dovecot" +.SH NAME +doveadm\-instance \- Manage the list of running Dovecot instances +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] [" \-f +.IR formatter ] +.B instance list +.br +.BR doveadm " [" \-Dv "] " "instance remove" +.IR name " | " base_dir +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +The +.B doveadm instance +commands are used to manage the list of Dovecot instances running on the +server. +In most installations there is only one Dovecot instance, but in some cases +is may be useful to have more (e.g. running director proxy and backend in +the same server). +.PP +Instances are added to the list automatically when Dovecot is started. +Each instance is uniquely identified by its +.I base_dir +setting. +Instances can be named by setting +.I instance_name +in each instance\(aqs +.IR dovecot.conf . +When an instance is named, it can be accessed easily by giving +.BI \-i\ instance_name +command line parameter for Dovecot binaries (e.g. doveadm). +.\"------------------------------------------------------------------------ + at INCLUDE:global-options-formatter@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I name +The value of an instance\(aqs +.I instance_name +setting. +.\"------------------------------------- +.TP +.I base_dir +The base directory of a Dovecot instance. +.\"------------------------------------------------------------------------ +.SH COMMANDS +.SS instance list +.B doveadm instance list +.PP +This command lists the seen Dovecot instances. +.\"------------------------------------- +.SS instance remove +.B doveadm instance remove +.IR name " | " base_dir +.PP +This command removes the specified instance. +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1) \ No newline at end of file diff -r 3e0a1e5f43f3 -r aa2e89c9876b doc/man/doveadm-mount.1.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/man/doveadm-mount.1.in Thu Feb 16 19:16:54 2012 +0200 @@ -0,0 +1,94 @@ +.\" Copyright (c) 2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-MOUNT 1 "2012-02-16" "Dovecot v2.1" "Dovecot" +.SH NAME +doveadm\-mount \- Manage the list of mountpoints where mails are stored +.\"------------------------------------------------------------------------ +.SH SYNOPSIS +.BR doveadm " [" \-Dv "] [" \-f +.IR formatter ] +.B mount +.IR command " [" arguments ] +.\"------------------------------------------------------------------------ +.SH DESCRIPTION +The doveadm +.B mount +.IR command s +can be used to manage the list of mountpoints where mails are stored. +This is used mainly for better error handling when a mountpoint isn\(aqt +mounted for some reason: +.TP 4 +* +If a mail directory doesn\(aqt exist, it\(aqs autocreated. +If the user\(aqs mails aren\(aqt mounted and filesystem permissions still +allow the autocreation, the user will see an empty mailbox and later will +have to redownload all mails. +If the mountpoint is known to be unmounted, Dovecot will simply fail +opening any mailboxes. +.TP +* +If dbox alternate storage isn\(aqt mounted and a mail in it is attempted to +be accessed, Dovecot normally rebuilds the indexes and notices that all the +mails in alt storage are expunged. +When the alt storage is mounted back and even if index is again rebuilt, +the mails won\(aqt necessarily become visible anymore for IMAP clients. +If the mountpoint is known to be unmounted, Dovecot won\(aqt rebuild +indexes and lose the mails. +.PP +Dovecot automatically adds mountpoints to this list at startup. +If you don\(aqt want some of the mountpoints added, you can add a wildcard +ignore for it. +.\"------------------------------------------------------------------------ + at INCLUDE:global-options-formatter@ +.\"------------------------------------------------------------------------ +.SH ARGUMENTS +.TP +.I path +The directory name of a mountpoint +.\"------------------------------------- +.TP +.I state +The +.I state +of a mountpoint. +Either +.BR online " or " ignore . +.\"------------------------------------------------------------------------ +.SH COMMANDS +.SS mount add +.B doveadm mount add +.RI [ path " [" state ]] +.PP +If this command is run without any parameters, doveadm detects all missing +mountpoints and adds them (the same way as when Dovecot does at startup). +.PP +When a mountpoint +.I path +is given, it\(aqs added as a mountpoint. +The +.I state +can currently be either +.RB \(dq online \(dq +(default) or +.RB \(dq ignore \(dq. +The ignore state is mainly useful with path wildcards to add mountpoints +that you never want Dovecot to automatically add, such as: +.B doveadm mount add '/mnt/*' ignore +.\"------------------------------------- +.SS mount list +.BR doveadm " [" \-Dv " ] [" \-f +.IR formatter ] +.B mount list +.PP +This command lists the mountpoints known to Dovecot and their state. +.\"------------------------------------- +.SS mount remove +.BI "doveadm mount remove " path +.PP +This command removes the specified +.I path +from the mountpoint list. +.\"------------------------------------------------------------------------ + at INCLUDE:reporting-bugs@ +.\"------------------------------------------------------------------------ +.SH SEE ALSO +.BR doveadm (1) \ No newline at end of file diff -r 3e0a1e5f43f3 -r aa2e89c9876b doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Thu Feb 16 18:40:29 2012 +0200 +++ b/doc/man/doveadm.1.in Thu Feb 16 19:16:54 2012 +0200 @@ -112,11 +112,21 @@ Import messages matching given search query. .\"------------------------------------- .TP +.B doveadm instance +.BR doveadm\-instance (1), +Various commands related to handling Dovecot instances. +.\"------------------------------------- +.TP .B doveadm index .BR doveadm\-index (1), Index messages in a given mailbox. .\"------------------------------------- .TP +.B doveadm mount +.BR doveadm\-mount (1), +Various commands related to handling mail storage mountpoints. +.\"------------------------------------- +.TP .B doveadm mailbox .BR doveadm\-mailbox (1), Various commands related to handling mailboxes. diff -r 3e0a1e5f43f3 -r aa2e89c9876b src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Thu Feb 16 18:40:29 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Thu Feb 16 19:16:54 2012 +0200 @@ -407,7 +407,10 @@ ctx->info.ns = _list->ns; if (!fs_list_get_valid_patterns(ctx, patterns)) { - /* we've only invalid patterns (or INBOX) */ + /* we've only invalid patterns (or INBOX). create a glob + anyway to avoid any crashes due to glob being accessed + elsewhere */ + ctx->ctx.glob = imap_match_init(pool, "", TRUE, ctx->sep); return &ctx->ctx; } ctx->ctx.glob = imap_match_init_multiple(pool, ctx->valid_patterns, From dovecot at dovecot.org Thu Feb 16 20:04:13 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 16 Feb 2012 20:04:13 +0200 Subject: dovecot-2.1: acl: Don't crash in mailbox listing when using auto... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ff117a044e20 changeset: 14162:ff117a044e20 user: Timo Sirainen date: Thu Feb 16 20:04:01 2012 +0200 description: acl: Don't crash in mailbox listing when using autocreated mailboxes. diffstat: src/plugins/acl/acl-mailbox-list.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diffs (40 lines): diff -r aa2e89c9876b -r ff117a044e20 src/plugins/acl/acl-mailbox-list.c --- a/src/plugins/acl/acl-mailbox-list.c Thu Feb 16 19:16:54 2012 +0200 +++ b/src/plugins/acl/acl-mailbox-list.c Thu Feb 16 20:04:01 2012 +0200 @@ -21,7 +21,6 @@ struct mailbox_tree_context *lookup_boxes; struct mailbox_info info; - struct imap_match_glob *glob; char sep; unsigned int simple_star_glob:1; }; @@ -175,8 +174,8 @@ inboxcase = (list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0; ctx->sep = mail_namespace_get_sep(list->ns); - ctx->glob = imap_match_init_multiple(pool, patterns, - inboxcase, ctx->sep); + ctx->ctx.glob = imap_match_init_multiple(pool, patterns, + inboxcase, ctx->sep); /* see if all patterns have only a single '*' and it's at the end. we can use it to do some optimizations. */ ctx->simple_star_glob = TRUE; @@ -249,7 +248,7 @@ this by simply checking if name/child mailbox matches. */ child = t_strdup_printf("%s%cx", ctx->info.name, ctx->sep); return ctx->simple_star_glob && - imap_match(ctx->glob, child) == IMAP_MATCH_YES; + imap_match(ctx->ctx.glob, child) == IMAP_MATCH_YES; } static bool @@ -299,7 +298,7 @@ MAILBOX_LIST_ITER_RETURN_NO_FLAGS); while ((info = mailbox_list_iter_next(iter)) != NULL) { if (only_nonpatterns && - imap_match(ctx->glob, info->name) == IMAP_MATCH_YES) { + imap_match(ctx->ctx.glob, info->name) == IMAP_MATCH_YES) { /* at least one child matches also the original list patterns. we don't need to show this mailbox. */ ret = FALSE; From pigeonhole at rename-it.nl Thu Feb 16 23:03:16 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 16 Feb 2012 22:03:16 +0100 Subject: dovecot-2.1-pigeonhole: Added tag 0.3.0 for changeset fe7bd7ee6c2e Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/abf95290dc4d changeset: 1602:abf95290dc4d user: Stephan Bosch date: Thu Feb 16 22:02:56 2012 +0100 description: Added tag 0.3.0 for changeset fe7bd7ee6c2e diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r fe7bd7ee6c2e -r abf95290dc4d .hgtags --- a/.hgtags Thu Feb 16 22:02:35 2012 +0100 +++ b/.hgtags Thu Feb 16 22:02:56 2012 +0100 @@ -9,3 +9,4 @@ 3ab2a125e1e2d478382c07853e99a5973d06afd6 0.2.3 0d071eaa6d5e2a9f524c94ddf1686f1b3091f604 0.2.4 873baa85e2202f45a9c14fa21cccedc60f3715bc 0.2.5 +fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0.3.0 From pigeonhole at rename-it.nl Thu Feb 16 23:03:16 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 16 Feb 2012 22:03:16 +0100 Subject: dovecot-2.1-pigeonhole: Released v0.3.0 for Dovecot v2.1.0. Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/fe7bd7ee6c2e changeset: 1601:fe7bd7ee6c2e user: Stephan Bosch date: Thu Feb 16 22:02:35 2012 +0100 description: Released v0.3.0 for Dovecot v2.1.0. diffstat: NEWS | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 50 insertions(+), 1 deletions(-) diffs (60 lines): diff -r b2a456e15ed5 -r fe7bd7ee6c2e NEWS --- a/NEWS Sat Jan 28 14:25:41 2012 +0100 +++ b/NEWS Thu Feb 16 22:02:35 2012 +0100 @@ -1,6 +1,55 @@ -v0.3.0 [TO BE RELEASED] Stephan Bosch +v0.3.0 16-02-2012 Stephan Bosch + * Renamed sieve_global_path setting to sieve_default for clarity. Old name is + still recognized for backwards compatibility. Support for the ancient (pre + v1.1) name for this setting "global_script_path" is now dropped. + * Added means to prohibit use of redirect action. Setting sieve_max_redirects + to 0 now means that redirect is disallowed in stead of unlimited. Default + value remains four. + * Fixed interaction of Sieve include extension with ManageSieve. It is updated + to match new requirements in the draft include specification. Missing + included scripts are no longer an error at upload time. + * Updated RFC2822 header field body verification to exclude non-printing + characters (RFC5322). Only Sieve actions that can create unstructured header + values (currently enotify/mailto and editheader) are affected by this + change. + + Completed sieve-filter tool to a useful state. The sieve-filter tool + provides a means to (re)filter messages in a mailbox through a Sieve script. + + Implemented the Sieve editheader extension. It is now possible to add and + remove message headers from within Sieve. + + ManageSieve: added support for reading quoted and literal strings as a + stream. Fixes support for handing large SASL responses (analogous to similar + changes in Dovecot). It is now also allowed to use a quoted string for the + PUTSCRIPT script argument. + + Added code to cleanup tmp directory in Sieve storage directory (sieve_dir) + every once in a while. + + Added support for substituting the entire message during Sieve processing. + This is used for the filter action provided by the new sieve_extprograms + plugin (provided separately for now). The filter action allows passing the + message through an external program. + + Added support for restricting certain Sieve language extensions to + (admin-controled) global scripts. Restricted extensions can be configured + using the new sieve_global_extensions setting. This is particularly useful + for some of the Dovecot-specific (plugin-based) Sieve extensions, that can + be somewhat hazardous when under direct control of users (e.g. + sieve_extprograms). +v0.2.6 13-02-2012 Stephan Bosch + + * This release fixes unintentional behavior of the include extension. Included + scriptnames with a name like "name.sieve" would implicitly map to a script + file called "name.sieve" and not "name.sieve.sieve". Keep in mind that the + .sieve file extension has no meaning from within the Sieve language. A Sieve + script is always stored with an appended .sieve file extension, also when + the name already ends with a .sieve suffix. + IMPORTANT: Some installations have relied on this unintentional feature, so + check your script includes for issues before upgrading. + * Matched changes regarding auth_verbose setting in Dovecot. This means that + this release will only compile against Dovecot v2.0.18. + - Fixed problem in ManageSieve that caused it to omit a WARNINGS response code + when the uploaded script compiled with warnings. + - Made sure that locations of Sieve error never report `line 0'. + - Fixed potential segfault occurring when interpreter initialization fails. v0.2.5 19-11-2011 Stephan Bosch From pigeonhole at rename-it.nl Thu Feb 16 23:08:57 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Thu, 16 Feb 2012 22:08:57 +0100 Subject: dovecot-2.1-pigeonhole: Added signature for changeset fe7bd7ee6c2e Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/6cca5f460f86 changeset: 1603:6cca5f460f86 user: Stephan Bosch date: Thu Feb 16 22:07:32 2012 +0100 description: Added signature for changeset fe7bd7ee6c2e diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r abf95290dc4d -r 6cca5f460f86 .hgsigs --- a/.hgsigs Thu Feb 16 22:02:56 2012 +0100 +++ b/.hgsigs Thu Feb 16 22:07:32 2012 +0100 @@ -3,3 +3,4 @@ 3ab2a125e1e2d478382c07853e99a5973d06afd6 0 iQEcBAABAgAGBQJNp1ztAAoJEATWKx49+7T0CJcH/24Txa1ynS5hBUhOuWTpUTGtm+9cMpWoQ33exiMR0pm8ycxsUQcKfRtO/cRHQX1CW3PqQs3DGZ31QdEEg0CyX8OsBbP/dwdEcnLRYF5BsJMyfy+Qnbhxn+wV0k9s9AUgZTdvPKrg1hFa6XS+6SE3N33AA4Y2eYYZGzFuDiSoN7fGx7PATCrobMsmp5WtBiKoy4WyP2SwDv/VgKy0PQTF+6+0t0MMCBSurLzpHk8dDuBonWIBgbJRM/sk9f+cYbU/ESRMcryZbbau9EwMQIQJfprGH6WP/gwysF0pu47zQERMuVt3fFzXUzrfxVpMOI7EkLgnF+Tes0vA7dKh1x+vvec= 0d071eaa6d5e2a9f524c94ddf1686f1b3091f604 0 iQEcBAABAgAGBQJOb8BjAAoJEATWKx49+7T0cAcH/3coc1MhQj8zUdC+NB3N8eUkQ3AF3QQgSfP9uXs9BhvPw70Ts9MLJiO54RhhYf/k9VxptzWk7MPJF47v4NEEKHkjDDMXtPbVOxHjNa2Ny8EAuWe4dv5X0faAlH4Ks58enDchCmunX1DgQtC1f+gHqVtvTpGAROFPqkBe5RGOJ0jQd+2hTTlf1BpLl44fiBdYd6350haX0KjDGNthX9ETVc3bnbdIiXSy7DPnn0ELhvTbgkl4Zu1tA778IJy/JjsCPb2YueX7LsksvxcSZHqv80Zd3JJhs5a3ZeHijN6twpe7VZD9FO+jPOKA1rr/HYwCv0KweKgmwVHCdaT+Mq4OLPc= 873baa85e2202f45a9c14fa21cccedc60f3715bc 0 iQEcBAABAgAGBQJOx9MCAAoJEATWKx49+7T09aUIANIKsuzM3bGhtGJ/UPIwzpOu39lEGCmHah6dMa+bDOoCZhuhASDdTuvRKXTfGC57GMu+NzBK6I7heFiPD3E4VTI4xOCK1azJ9G4SsiDEkQThucXqWBKDjPB0RgOEf6iefAkslXIU3cprJgattwpeXbUKiHjBhoYJFJ5j/GTx1B62ndvaTfMu1zF5UppiyRG1rQD7FLY4f6kANzSI2jOOCBs4UFH7ZKhafO1AeQfLNDvxdDczZafPZxrCIF+5JCNvQ6Xue/JrvRZQ0V9sxLQat7clUJ6I6Ejl5u5l1LF+VscWldfaQKwDdOktCVux84YGH8+XqXaukMiEg6j4hceAYIM= +fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0 iQEcBAABAgAGBQJPPXAPAAoJEATWKx49+7T0iqMH/3e+RKKmryOz5pak0cvdPcS/D9O9xl2l6SuoE2okTq/WOrDtZ1xDg0afg7t27D9mDfUY1hiSFS4ekN3WP620Gcb9wlL3FC+rLEYmiE8iSfZvsH+FeLa7n8NB+XdnAsXE1WdLQp5CSKEh3sXIod7Q04PL0uv/rimGS9jOGcAufW3y9QAYd+DVorPS4lV5Kz8qIqY9r/0lLqhJN1ukIJtClVkFanRljd+SfoHFFOSWbQjCKNxlOSWFhwJji7Mp091A1+N6JoZe4IMIlajMsM2Ypp726Y2LA/du+uRVFjKgta65eP9tfdrmVCJtrjIjvikowD5Zl80GuVRI5j44aQ7rJ3A= From dovecot at dovecot.org Fri Feb 17 00:34:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 00:34:32 +0200 Subject: dovecot-2.1: dsync: GUIDs are case-sensitive, make GUID hash tab... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/aa25bb2384ce changeset: 14164:aa25bb2384ce user: Timo Sirainen date: Fri Feb 17 00:32:06 2012 +0200 description: dsync: GUIDs are case-sensitive, make GUID hash table be as well. diffstat: src/doveadm/dsync/dsync-brain-msgs.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r edf5a4788242 -r aa25bb2384ce src/doveadm/dsync/dsync-brain-msgs.c --- a/src/doveadm/dsync/dsync-brain-msgs.c Fri Feb 17 00:30:54 2012 +0200 +++ b/src/doveadm/dsync/dsync-brain-msgs.c Fri Feb 17 00:32:06 2012 +0200 @@ -451,8 +451,8 @@ i_array_init(&iter->uid_conflicts, 128); i_array_init(&iter->new_msgs, 128); iter->guid_hash = hash_table_create(default_pool, sync->pool, 10000, - strcase_hash, - (hash_cmp_callback_t *)strcasecmp); + str_hash, + (hash_cmp_callback_t *)strcmp); iter->iter = dsync_worker_msg_iter_init(worker, mailboxes, mailbox_count); From dovecot at dovecot.org Fri Feb 17 00:34:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 00:34:32 +0200 Subject: dovecot-2.1: doveadm force-resync: Don't skip autocreated mailbo... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/edf5a4788242 changeset: 14163:edf5a4788242 user: Timo Sirainen date: Fri Feb 17 00:30:54 2012 +0200 description: doveadm force-resync: Don't skip autocreated mailboxes (especially INBOX). This fixes rebuilding indexes for mdbox that has all mailbox indexes deleted. diffstat: src/doveadm/doveadm-mail.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r ff117a044e20 -r edf5a4788242 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Thu Feb 16 20:04:01 2012 +0200 +++ b/src/doveadm/doveadm-mail.c Fri Feb 17 00:30:54 2012 +0200 @@ -224,7 +224,6 @@ { const enum mailbox_list_iter_flags iter_flags = MAILBOX_LIST_ITER_RAW_LIST | - MAILBOX_LIST_ITER_NO_AUTO_BOXES | MAILBOX_LIST_ITER_RETURN_NO_FLAGS | MAILBOX_LIST_ITER_STAR_WITHIN_NS; const enum namespace_type ns_mask = From dovecot at dovecot.org Fri Feb 17 00:34:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 00:34:32 +0200 Subject: dovecot-2.1: dsync: If message with same GUID is saved multiple ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c581f6c1eef9 changeset: 14165:c581f6c1eef9 user: Timo Sirainen date: Fri Feb 17 00:34:24 2012 +0200 description: dsync: If message with same GUID is saved multiple times in session, copy it instead of re-saving. This only works if the messages are in different mailboxes. It would be possible to fix it also for copying within same mailbox, but that's probably rare enough that it's not worth the extra code. diffstat: src/doveadm/dsync/dsync-brain-msgs-new.c | 1 + src/doveadm/dsync/dsync-brain-msgs.c | 20 ++++++++++++-------- src/doveadm/dsync/dsync-brain-private.h | 4 ++++ 3 files changed, 17 insertions(+), 8 deletions(-) diffs (69 lines): diff -r aa25bb2384ce -r c581f6c1eef9 src/doveadm/dsync/dsync-brain-msgs-new.c --- a/src/doveadm/dsync/dsync-brain-msgs-new.c Fri Feb 17 00:32:06 2012 +0200 +++ b/src/doveadm/dsync/dsync-brain-msgs-new.c Fri Feb 17 00:34:24 2012 +0200 @@ -52,6 +52,7 @@ { struct dsync_brain_msg_save_context *ctx = context; + dsync_brain_guid_add(ctx->iter, ctx->mailbox_idx, ctx->msg); if (--ctx->iter->save_results_left == 0 && !ctx->iter->adding_msgs) dsync_brain_msg_sync_add_new_msgs(ctx->iter); i_free(ctx); diff -r aa25bb2384ce -r c581f6c1eef9 src/doveadm/dsync/dsync-brain-msgs.c --- a/src/doveadm/dsync/dsync-brain-msgs.c Fri Feb 17 00:32:06 2012 +0200 +++ b/src/doveadm/dsync/dsync-brain-msgs.c Fri Feb 17 00:34:24 2012 +0200 @@ -50,21 +50,23 @@ #include "dsync-worker.h" #include "dsync-brain-private.h" -static void dsync_brain_guid_add(struct dsync_brain_msg_iter *iter) +void dsync_brain_guid_add(struct dsync_brain_msg_iter *iter, + unsigned int mailbox_idx, + const struct dsync_message *msg) { struct dsync_brain_guid_instance *inst, *prev_inst; - if ((iter->msg.flags & DSYNC_MAIL_FLAG_EXPUNGED) != 0) + if ((msg->flags & DSYNC_MAIL_FLAG_EXPUNGED) != 0) return; inst = p_new(iter->sync->pool, struct dsync_brain_guid_instance, 1); - inst->mailbox_idx = iter->mailbox_idx; - inst->uid = iter->msg.uid; + inst->mailbox_idx = mailbox_idx; + inst->uid = msg->uid; - prev_inst = hash_table_lookup(iter->guid_hash, iter->msg.guid); + prev_inst = hash_table_lookup(iter->guid_hash, msg->guid); if (prev_inst == NULL) { hash_table_insert(iter->guid_hash, - p_strdup(iter->sync->pool, iter->msg.guid), + p_strdup(iter->sync->pool, msg->guid), inst); } else { inst->next = prev_inst->next; @@ -80,8 +82,10 @@ ret = dsync_worker_msg_iter_next(iter->iter, &iter->mailbox_idx, &iter->msg); - if (ret > 0) - dsync_brain_guid_add(iter); + if (ret > 0) { + dsync_brain_guid_add(iter, iter->mailbox_idx, + &iter->msg); + } } if (iter->sync->wanted_mailbox_idx != iter->mailbox_idx) { diff -r aa25bb2384ce -r c581f6c1eef9 src/doveadm/dsync/dsync-brain-private.h --- a/src/doveadm/dsync/dsync-brain-private.h Fri Feb 17 00:32:06 2012 +0200 +++ b/src/doveadm/dsync/dsync-brain-private.h Fri Feb 17 00:34:24 2012 +0200 @@ -141,4 +141,8 @@ void dsync_brain_msg_sync_new_msgs(struct dsync_brain_mailbox_sync *sync); +void dsync_brain_guid_add(struct dsync_brain_msg_iter *iter, + unsigned int mailbox_idx, + const struct dsync_message *msg); + #endif From dovecot at dovecot.org Fri Feb 17 01:20:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 01:20:18 +0200 Subject: dovecot-2.1: login: Added comment. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/119195278272 changeset: 14166:119195278272 user: Timo Sirainen date: Fri Feb 17 00:46:46 2012 +0200 description: login: Added comment. diffstat: src/login-common/main.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r c581f6c1eef9 -r 119195278272 src/login-common/main.c --- a/src/login-common/main.c Fri Feb 17 00:34:24 2012 +0200 +++ b/src/login-common/main.c Fri Feb 17 00:46:46 2012 +0200 @@ -262,6 +262,9 @@ static bool anvil_reconnect_callback(void) { + /* we got disconnected from anvil. we can't reconnect to it since we're + chrooted, so just die after we've finished handling the current + connections. */ master_service_stop_new_connections(master_service); return FALSE; } From dovecot at dovecot.org Fri Feb 17 01:20:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 01:20:18 +0200 Subject: dovecot-2.1: master: Handle internal "out of fds" errors without... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/9a501d37af3d changeset: 14167:9a501d37af3d user: Timo Sirainen date: Fri Feb 17 01:13:51 2012 +0200 description: master: Handle internal "out of fds" errors without crashing. diffstat: src/master/service-monitor.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diffs (34 lines): diff -r 119195278272 -r 9a501d37af3d src/master/service-monitor.c --- a/src/master/service-monitor.c Fri Feb 17 00:46:46 2012 +0200 +++ b/src/master/service-monitor.c Fri Feb 17 01:13:51 2012 +0200 @@ -398,7 +398,8 @@ { struct service *const *services; - services_log_init(service_list); + if (services_log_init(service_list) < 0) + return; service_anvil_monitor_start(service_list); if (pipe(service_list->master_dead_pipe_fd) < 0) @@ -434,14 +435,17 @@ service_monitor_listen_start(service); } - if (service_process_create(service_list->log) != NULL) - service_monitor_listen_stop(service_list->log); + if (service_list->log->status_fd[0] != -1) { + if (service_process_create(service_list->log) != NULL) + service_monitor_listen_stop(service_list->log); + } /* start up a process for startup-services */ array_foreach(&service_list->services, services) { struct service *service = *services; - if (service->type == SERVICE_TYPE_STARTUP) { + if (service->type == SERVICE_TYPE_STARTUP && + service->status_fd[0] != -1) { if (service_process_create(service) != NULL) service_monitor_listen_stop(service); } From dovecot at dovecot.org Fri Feb 17 01:20:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 01:20:18 +0200 Subject: dovecot-2.1: Increased initial memory pool size. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/89eb4c204341 changeset: 14168:89eb4c204341 user: Timo Sirainen date: Fri Feb 17 01:14:02 2012 +0200 description: Increased initial memory pool size. diffstat: src/lib-storage/index/shared/shared-list.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 9a501d37af3d -r 89eb4c204341 src/lib-storage/index/shared/shared-list.c --- a/src/lib-storage/index/shared/shared-list.c Fri Feb 17 01:13:51 2012 +0200 +++ b/src/lib-storage/index/shared/shared-list.c Fri Feb 17 01:14:02 2012 +0200 @@ -13,7 +13,7 @@ struct mailbox_list *list; pool_t pool; - pool = pool_alloconly_create("shared list", 1024); + pool = pool_alloconly_create("shared list", 2048); list = p_new(pool, struct mailbox_list, 1); *list = shared_mailbox_list; list->pool = pool; From dovecot at dovecot.org Fri Feb 17 01:20:18 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 01:20:18 +0200 Subject: dovecot-2.1: lib-master: If accept() fails, stop listening only ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/701709f472e9 changeset: 14169:701709f472e9 user: Timo Sirainen date: Fri Feb 17 01:19:59 2012 +0200 description: lib-master: If accept() fails, stop listening only temporarily, not permanently. diffstat: src/lib-master/master-service.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (14 lines): diff -r 89eb4c204341 -r 701709f472e9 src/lib-master/master-service.c --- a/src/lib-master/master-service.c Fri Feb 17 01:14:02 2012 +0200 +++ b/src/lib-master/master-service.c Fri Feb 17 01:19:59 2012 +0200 @@ -779,7 +779,9 @@ } else { errno = orig_errno; i_error("net_accept() failed: %m"); - master_service_error(service); + /* try again later after one of the existing + connections has died */ + master_service_io_listeners_remove(service); return; } /* use the "listener" as the connection fd and stop the From dovecot at dovecot.org Fri Feb 17 01:21:10 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Fri, 17 Feb 2012 01:21:10 +0200 Subject: dovecot-2.2: man/Makefile: Use SUFFIXES to reduce the number of ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ac4eed7bef23 changeset: 14148:ac4eed7bef23 user: Pascal Volk date: Thu Feb 16 23:05:17 2012 +0000 description: man/Makefile: Use SUFFIXES to reduce the number of targets. diffstat: doc/man/Makefile.am | 106 +-------------------------------------------------- 1 files changed, 4 insertions(+), 102 deletions(-) diffs (120 lines): diff -r e7854f8d7213 -r ac4eed7bef23 doc/man/Makefile.am --- a/doc/man/Makefile.am Mon Feb 13 00:40:03 2012 +0200 +++ b/doc/man/Makefile.am Thu Feb 16 23:05:17 2012 +0000 @@ -1,5 +1,7 @@ pkgsysconfdir = $(sysconfdir)/dovecot +SUFFIXES = .1.in .1 + dist_man1_MANS = \ deliver.1 \ doveadm-config.1 \ @@ -77,106 +79,6 @@ CLEANFILES = $(nodist_man1_MANS) -doveadm.1: $(srcdir)/doveadm.1.in $(man_includefiles) Makefile +.1.in.1: $(man_includefiles) Makefile $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm.1.in > doveadm.1 - -doveadm-altmove.1: $(srcdir)/doveadm-altmove.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-altmove.1.in > doveadm-altmove.1 - -doveadm-auth.1: $(srcdir)/doveadm-auth.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-auth.1.in > doveadm-auth.1 - -doveadm-director.1: $(srcdir)/doveadm-director.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-director.1.in > doveadm-director.1 - -doveadm-dump.1: $(srcdir)/doveadm-dump.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-dump.1.in > doveadm-dump.1 - -doveadm-expunge.1: $(srcdir)/doveadm-expunge.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-expunge.1.in > doveadm-expunge.1 - -doveadm-fetch.1: $(srcdir)/doveadm-fetch.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-fetch.1.in > doveadm-fetch.1 - -doveadm-import.1: $(srcdir)/doveadm-import.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-import.1.in > doveadm-import.1 - -doveadm-index.1: $(srcdir)/doveadm-index.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-index.1.in > doveadm-index.1 - -doveadm-force-resync.1: $(srcdir)/doveadm-force-resync.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-force-resync.1.in > doveadm-force-resync.1 - -doveadm-help.1: $(srcdir)/doveadm-help.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-help.1.in > doveadm-help.1 - -doveadm-kick.1: $(srcdir)/doveadm-kick.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-kick.1.in > doveadm-kick.1 - -doveadm-log.1: $(srcdir)/doveadm-log.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-log.1.in > doveadm-log.1 - -doveadm-mailbox.1: $(srcdir)/doveadm-mailbox.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-mailbox.1.in > doveadm-mailbox.1 - -doveadm-move.1: $(srcdir)/doveadm-move.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-move.1.in > doveadm-move.1 - -doveadm-penalty.1: $(srcdir)/doveadm-penalty.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-penalty.1.in > doveadm-penalty.1 - -doveadm-purge.1: $(srcdir)/doveadm-purge.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-purge.1.in > doveadm-purge.1 - -doveadm-pw.1: $(srcdir)/doveadm-pw.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-pw.1.in > doveadm-pw.1 - -doveadm-quota.1: $(srcdir)/doveadm-quota.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-quota.1.in > doveadm-quota.1 - -doveadm-search.1: $(srcdir)/doveadm-search.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-search.1.in > doveadm-search.1 - -doveadm-user.1: $(srcdir)/doveadm-user.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-user.1.in > doveadm-user.1 - -doveadm-who.1: $(srcdir)/doveadm-who.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveadm-who.1.in > doveadm-who.1 - -doveconf.1: $(srcdir)/doveconf.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/doveconf.1.in > doveconf.1 - -dovecot.1: $(srcdir)/dovecot.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/dovecot.1.in > dovecot.1 - -dovecot-lda.1: $(srcdir)/dovecot-lda.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/dovecot-lda.1.in > dovecot-lda.1 - -dsync.1: $(srcdir)/dsync.1.in $(man_includefiles) Makefile - $(SHELL) $(srcdir)/sed.sh $(srcdir) $(rundir) $(pkgsysconfdir) \ - < $(srcdir)/dsync.1.in > dsync.1 + < $(srcdir)/$< > $@ From dovecot at dovecot.org Mon Feb 20 23:34:44 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 20 Feb 2012 23:34:44 +0200 Subject: dovecot-2.1: man: Move doveadm instance and mount commands to "m... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0947b28d2903 changeset: 14170:0947b28d2903 user: Timo Sirainen date: Mon Feb 20 23:34:38 2012 +0200 description: man: Move doveadm instance and mount commands to "master commands" group. diffstat: doc/man/doveadm.1.in | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diffs (49 lines): diff -r 701709f472e9 -r 0947b28d2903 doc/man/doveadm.1.in --- a/doc/man/doveadm.1.in Fri Feb 17 01:19:59 2012 +0200 +++ b/doc/man/doveadm.1.in Mon Feb 20 23:34:38 2012 +0200 @@ -44,6 +44,11 @@ Manage Dovecot directors (if used by proxy servers). .\"------------------------------------- .TP +.B doveadm instance +.BR doveadm\-instance (1), +Manage the list of running Dovecot instances. +.\"------------------------------------- +.TP .B doveadm kick .BR doveadm\-kick (1), Disconnect users by user name and/or IP address. @@ -54,6 +59,11 @@ Locate, test or reopen Dovecot\(aqs log files. .\"------------------------------------- .TP +.B doveadm mount +.BR doveadm\-mount (1), +Manage the list of mountpoints where mails are stored. +.\"------------------------------------- +.TP .B doveadm penalty .BR doveadm\-penalty (1), Show current penalties. @@ -112,21 +122,11 @@ Import messages matching given search query. .\"------------------------------------- .TP -.B doveadm instance -.BR doveadm\-instance (1), -Various commands related to handling Dovecot instances. -.\"------------------------------------- -.TP .B doveadm index .BR doveadm\-index (1), Index messages in a given mailbox. .\"------------------------------------- .TP -.B doveadm mount -.BR doveadm\-mount (1), -Various commands related to handling mail storage mountpoints. -.\"------------------------------------- -.TP .B doveadm mailbox .BR doveadm\-mailbox (1), Various commands related to handling mailboxes. From dovecot at dovecot.org Tue Feb 21 02:06:12 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 02:06:12 +0200 Subject: dovecot-2.1: doveadm dump: Show available types in case a wrong ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/bf340465cb70 changeset: 14171:bf340465cb70 user: Pascal Volk date: Mon Feb 20 23:39:20 2012 +0000 description: doveadm dump: Show available types in case a wrong one was given. diffstat: src/doveadm/doveadm-dump.c | 15 +++++++++++++-- src/doveadm/doveadm-dump.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diffs (44 lines): diff -r 0947b28d2903 -r bf340465cb70 src/doveadm/doveadm-dump.c --- a/src/doveadm/doveadm-dump.c Mon Feb 20 23:34:38 2012 +0200 +++ b/src/doveadm/doveadm-dump.c Mon Feb 20 23:39:20 2012 +0000 @@ -63,9 +63,10 @@ dump = type != NULL ? dump_find_name(type) : dump_find_test(argv[1]); if (dump == NULL) { - if (type != NULL) + if (type != NULL) { + print_dump_types(); i_fatal_status(EX_USAGE, "Unknown type: %s", type); - else { + } else { i_fatal_status(EX_DATAERR, "Can't autodetect file type: %s", argv[1]); } @@ -88,6 +89,16 @@ &doveadm_cmd_dump_thread }; +void print_dump_types(void) +{ + unsigned int i; + + fprintf(stderr, "Available dump types: %s", dumps_builtin[0]->name); + for (i = 1; i < N_ELEMENTS(dumps_builtin); i++) + fprintf(stderr, " %s", dumps_builtin[i]->name); + fprintf(stderr, "\n"); +} + void doveadm_dump_init(void) { unsigned int i; diff -r 0947b28d2903 -r bf340465cb70 src/doveadm/doveadm-dump.h --- a/src/doveadm/doveadm-dump.h Mon Feb 20 23:34:38 2012 +0200 +++ b/src/doveadm/doveadm-dump.h Mon Feb 20 23:39:20 2012 +0000 @@ -17,6 +17,7 @@ void doveadm_dump_register(const struct doveadm_cmd_dump *dump); +void print_dump_types(void); void doveadm_dump_init(void); void doveadm_dump_deinit(void); From dovecot at dovecot.org Tue Feb 21 02:16:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 02:16:07 +0200 Subject: dovecot-2.1: ldap: Support attr=name=prefix style template attri... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e8da2675da41 changeset: 14172:e8da2675da41 user: Timo Sirainen date: Tue Feb 21 02:15:54 2012 +0200 description: ldap: Support attr=name=prefix style template attributes for backwards compatibility. This was mainly used for quota, e.g. "quotaBytes=quota=*:storage=" diffstat: src/auth/db-ldap.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diffs (17 lines): diff -r bf340465cb70 -r e8da2675da41 src/auth/db-ldap.c --- a/src/auth/db-ldap.c Mon Feb 20 23:39:20 2012 +0000 +++ b/src/auth/db-ldap.c Tue Feb 21 02:15:54 2012 +0200 @@ -1039,6 +1039,13 @@ str_truncate(tmp_str, 0); var_expand_with_funcs(tmp_str, templ, NULL, var_funcs_table, &ctx); + if (strchr(templ, '%') == NULL) { + /* backwards compatibility: + attr=name=prefix means same as + attr=name=prefix%$ when %vars are missing */ + templ = p_strconcat(conn->pool, templ, + "%$", NULL); + } } if (*name == '\0') From dovecot at dovecot.org Tue Feb 21 02:17:55 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 02:17:55 +0200 Subject: dovecot-2.1: man: Added description for type `dbox' to doveadm-d... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c854f19f10e3 changeset: 14173:c854f19f10e3 user: Pascal Volk date: Tue Feb 21 00:13:36 2012 +0000 description: man: Added description for type `dbox' to doveadm-dump.1 diffstat: doc/man/doveadm-dump.1.in | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diffs (44 lines): diff -r e8da2675da41 -r c854f19f10e3 doc/man/doveadm-dump.1.in --- a/doc/man/doveadm-dump.1.in Tue Feb 21 02:15:54 2012 +0200 +++ b/doc/man/doveadm-dump.1.in Tue Feb 21 00:13:36 2012 +0000 @@ -1,5 +1,5 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-DUMP 1 "2010-06-22" "Dovecot v2.1" "Dovecot" +.\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-DUMP 1 "2012-02-21" "Dovecot v2.1" "Dovecot" .SH NAME doveadm\-dump \- Dump the content of Dovecot\(aqs binary mailbox index/log .\"------------------------------------------------------------------------ @@ -36,6 +36,11 @@ can be: .RS .TP 12 +.B dbox +\(rA m.\c +.I n +(sdbox or mdbox mailbox file) +.TP .B index \(rA dovecot.index, dovecot.map.index .TP @@ -52,10 +57,9 @@ .SH ARGUMENTS .TP .I path -The path to the corresponding index or log file. If only a directory is -specified, doveadm tries to find and dump -.B index -type file under it. +The path to the corresponding dbox storage, index or log file. +If only a directory is specified, doveadm tries to detect the type of files +under it and dumps them. .\"------------------------------------------------------------------------ .SH EXAMPLE Look at the contents of a mailbox\(aqs index: @@ -66,4 +70,4 @@ @INCLUDE:reporting-bugs@ .\"------------------------------------------------------------------------ .SH SEE ALSO -.BR doveadm (1) +.BR doveadm (1) \ No newline at end of file From dovecot at dovecot.org Tue Feb 21 02:44:12 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 02:44:12 +0200 Subject: dovecot-2.1: virtual: "*" wildcard matches now also autocreated ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/10994a5b64e1 changeset: 14174:10994a5b64e1 user: Timo Sirainen date: Tue Feb 21 02:43:52 2012 +0200 description: virtual: "*" wildcard matches now also autocreated shared namespaces. Basically this makes "shared/*" work as intended for shared namespaces. diffstat: src/plugins/virtual/virtual-config.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diffs (34 lines): diff -r c854f19f10e3 -r 10994a5b64e1 src/plugins/virtual/virtual-config.c --- a/src/plugins/virtual/virtual-config.c Tue Feb 21 00:13:36 2012 +0000 +++ b/src/plugins/virtual/virtual-config.c Tue Feb 21 02:43:52 2012 +0200 @@ -245,6 +245,20 @@ array_append(&ctx->mbox->backend_boxes, &bbox, 1); } +static bool virtual_ns_match(struct mail_namespace *config_ns, + struct mail_namespace *iter_ns) +{ + /* we match only one namespace for each pattern, except with shared + namespaces match also autocreated children */ + if (config_ns == iter_ns) + return TRUE; + if (config_ns->type == iter_ns->type && + (config_ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0 && + (iter_ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0) + return TRUE; + return FALSE; +} + static bool virtual_config_match(const struct mailbox_info *info, ARRAY_TYPE(virtual_backend_box) *boxes_arr, unsigned int *idx_r) @@ -255,8 +269,7 @@ boxes = array_get_modifiable(boxes_arr, &count); for (i = 0; i < count; i++) { if (boxes[i]->glob != NULL) { - /* we match only one namespace for each pattern. */ - if (boxes[i]->ns == info->ns && + if (virtual_ns_match(boxes[i]->ns, info->ns) && imap_match(boxes[i]->glob, info->name) == IMAP_MATCH_YES) { *idx_r = i; From dovecot at dovecot.org Tue Feb 21 02:59:40 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 02:59:40 +0200 Subject: dovecot-2.1: lib-storage: When autocreating a namespace, don't f... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/488fe9d417eb changeset: 14175:488fe9d417eb user: Timo Sirainen date: Tue Feb 21 02:59:25 2012 +0200 description: lib-storage: When autocreating a namespace, don't fill out location setting unless necessary. This fixes running dsync when there are no namespaces defined. diffstat: src/lib-storage/mail-namespace.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diffs (42 lines): diff -r 10994a5b64e1 -r 488fe9d417eb src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Tue Feb 21 02:43:52 2012 +0200 +++ b/src/lib-storage/mail-namespace.c Tue Feb 21 02:59:25 2012 +0200 @@ -320,7 +320,7 @@ { struct mail_namespace_settings *inbox_set, *unexpanded_inbox_set; struct mail_namespace *ns; - const struct mail_storage_settings *mail_set, *unexpanded_mail_set; + const struct mail_storage_settings *mail_set; const char *error, *driver, *location_source; i_assert(location == NULL || *location != '\0'); @@ -345,13 +345,8 @@ inbox_set->location = p_strdup(user->pool, location); location_source = "mail_location parameter"; } else if (*mail_set->mail_location != '\0') { - unexpanded_mail_set = mail_user_set_get_driver_settings( - user->set_info, user->unexpanded_set, - MAIL_STORAGE_SET_DRIVER_NAME); - - inbox_set->location = mail_set->mail_location; - unexpanded_inbox_set->location = - unexpanded_mail_set->mail_location; + /* don't actually set it to namespace, since we'll default to + it anyway */ location_source = "mail_location setting"; } else { location_source = "environment MAIL"; @@ -367,10 +362,12 @@ location_source = "environment MAILDIR"; } } - if (*unexpanded_inbox_set->location == '\0') { + if (*inbox_set->location != '\0') { unexpanded_inbox_set->location = p_strconcat(user->pool, SETTING_STRVAR_EXPANDED, inbox_set->location, NULL); + } else { + unexpanded_inbox_set->location = SETTING_STRVAR_UNEXPANDED; } ns->set = inbox_set; From dovecot at dovecot.org Tue Feb 21 03:08:13 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 03:08:13 +0200 Subject: dovecot-2.1: lib-storage: Avoid assert-crashing with non-mUTF7/U... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/7d0d76df719f changeset: 14176:7d0d76df719f user: Timo Sirainen date: Tue Feb 21 03:07:49 2012 +0200 description: lib-storage: Avoid assert-crashing with non-mUTF7/UTF8 entries in subscriptions file. diffstat: src/lib-storage/list/mailbox-list-subscriptions.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (20 lines): diff -r 488fe9d417eb -r 7d0d76df719f src/lib-storage/list/mailbox-list-subscriptions.c --- a/src/lib-storage/list/mailbox-list-subscriptions.c Tue Feb 21 02:59:25 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-subscriptions.c Tue Feb 21 03:07:49 2012 +0200 @@ -3,6 +3,7 @@ #include "lib.h" #include "ioloop.h" #include "array.h" +#include "unichar.h" #include "imap-match.h" #include "subscription-file.h" #include "mailbox-tree.h" @@ -92,6 +93,8 @@ return -1; } else { vname = mailbox_list_get_vname(list, name); + if (!uni_utf8_str_is_valid(vname)) + return -1; node = mailbox_tree_get(list->subscriptions, vname, &created); node->flags = MAILBOX_SUBSCRIBED; } From dovecot at dovecot.org Tue Feb 21 11:08:17 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 11:08:17 +0200 Subject: dovecot-2.1: file-dotlock: Avoid "timestamp is different than cu... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/2ea29ab6f10f changeset: 14177:2ea29ab6f10f user: Timo Sirainen date: Tue Feb 21 11:08:05 2012 +0200 description: file-dotlock: Avoid "timestamp is different than current time" errors during high disk I/O load. diffstat: src/lib/file-dotlock.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diffs (18 lines): diff -r 7d0d76df719f -r 2ea29ab6f10f src/lib/file-dotlock.c --- a/src/lib/file-dotlock.c Tue Feb 21 03:07:49 2012 +0200 +++ b/src/lib/file-dotlock.c Tue Feb 21 11:08:05 2012 +0200 @@ -534,8 +534,13 @@ try_create_lock_excl(&lock_info, write_pid) : try_create_lock_hardlink(&lock_info, write_pid, tmp_path, now); - if (ret != 0) + if (ret != 0) { + /* if we succeeded, get the current time once + more in case disk I/O usage was really high + and it took a long time to create the lock */ + now = time(NULL); break; + } } if (last_notify != now && set->callback != NULL) { From dovecot at dovecot.org Tue Feb 21 11:16:08 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 11:16:08 +0200 Subject: dovecot-2.1: auth: passdb imap crashed for non-login (non-imap/p... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/a6a58512f0df changeset: 14178:a6a58512f0df user: Timo Sirainen date: Tue Feb 21 11:15:56 2012 +0200 description: auth: passdb imap crashed for non-login (non-imap/pop3) authentication. diffstat: src/auth/passdb-imap.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (20 lines): diff -r 2ea29ab6f10f -r a6a58512f0df src/auth/passdb-imap.c --- a/src/auth/passdb-imap.c Tue Feb 21 11:08:05 2012 +0200 +++ b/src/auth/passdb-imap.c Tue Feb 21 11:15:56 2012 +0200 @@ -44,6 +44,7 @@ void *context) { struct imap_auth_request *request = context; + struct imapc_client *client = request->client; enum passdb_result result = PASSDB_RESULT_INTERNAL_FAILURE; switch (reply->state) { @@ -62,7 +63,7 @@ break; } request->verify_callback(result, request->auth_request); - imapc_client_deinit(&request->client); + imapc_client_deinit(&client); } static void From dovecot at dovecot.org Tue Feb 21 11:35:27 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 11:35:27 +0200 Subject: dovecot-2.1: Added restrict_get_process_size() Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1c1c2a1c85d7 changeset: 14179:1c1c2a1c85d7 user: Timo Sirainen date: Tue Feb 21 11:35:05 2012 +0200 description: Added restrict_get_process_size() diffstat: src/lib/restrict-process-size.c | 19 +++++++++++++++++++ src/lib/restrict-process-size.h | 2 ++ 2 files changed, 21 insertions(+), 0 deletions(-) diffs (41 lines): diff -r a6a58512f0df -r 1c1c2a1c85d7 src/lib/restrict-process-size.c --- a/src/lib/restrict-process-size.c Tue Feb 21 11:15:56 2012 +0200 +++ b/src/lib/restrict-process-size.c Tue Feb 21 11:35:05 2012 +0200 @@ -49,6 +49,25 @@ #endif } +int restrict_get_process_size(rlim_t *limit_r) +{ + struct rlimit rlim; + +#ifdef HAVE_RLIMIT_AS + if (getrlimit(RLIMIT_AS, &rlim) < 0) { + i_error("getrlimit(RLIMIT_AS): %m"); + return -1; + } +#else + if (getrlimit(RLIMIT_DATA, &rlim) < 0) { + i_error("getrlimit(RLIMIT_DATA): %m"); + return -1; + } +#endif + *limit_r = rlim.rlim_cur; + return 0; +} + int restrict_get_core_limit(rlim_t *limit_r) { #ifdef HAVE_RLIMIT_CORE diff -r a6a58512f0df -r 1c1c2a1c85d7 src/lib/restrict-process-size.h --- a/src/lib/restrict-process-size.h Tue Feb 21 11:15:56 2012 +0200 +++ b/src/lib/restrict-process-size.h Tue Feb 21 11:35:05 2012 +0200 @@ -15,6 +15,8 @@ /* Get the core dump size limit. Returns 0 if ok, -1 if lookup failed. */ int restrict_get_core_limit(rlim_t *limit_r); +/* Get the process VSZ size limit. Returns 0 if ok, -1 if lookup failed. */ +int restrict_get_process_size(rlim_t *limit_r); /* Get the process count limit. Returns 0 if ok, -1 if lookup failed. */ int restrict_get_process_limit(rlim_t *limit_r); /* Get the fd limit. Returns 0 if ok, -1 if lookup failed. */ From dovecot at dovecot.org Tue Feb 21 11:35:27 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 11:35:27 +0200 Subject: dovecot-2.1: auth: If auth_cache_size is larger than process VSZ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/242ad2a73648 changeset: 14180:242ad2a73648 user: Timo Sirainen date: Tue Feb 21 11:35:21 2012 +0200 description: auth: If auth_cache_size is larger than process VSZ limit, log a warning. diffstat: src/auth/passdb-cache.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diffs (30 lines): diff -r 1c1c2a1c85d7 -r 242ad2a73648 src/auth/passdb-cache.c --- a/src/auth/passdb-cache.c Tue Feb 21 11:35:05 2012 +0200 +++ b/src/auth/passdb-cache.c Tue Feb 21 11:35:21 2012 +0200 @@ -1,6 +1,7 @@ /* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */ #include "auth-common.h" +#include "restrict-process-size.h" #include "password-scheme.h" #include "passdb.h" #include "passdb-cache.h" @@ -128,9 +129,18 @@ void passdb_cache_init(const struct auth_settings *set) { + rlim_t limit; + if (set->cache_size == 0 || set->cache_ttl == 0) return; + if (restrict_get_process_size(&limit) == 0 && + set->cache_size > limit) { + i_warning("auth_cache_size (%luM) is higher than " + "process VSZ limit (%luM)", + (unsigned long)(set->cache_size/1024/1024), + (unsigned long)(limit/1024/1024)); + } passdb_cache = auth_cache_new(set->cache_size, set->cache_ttl, set->cache_negative_ttl); } From dovecot at dovecot.org Tue Feb 21 15:21:45 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 15:21:45 +0200 Subject: dovecot-2.0: sdbox: Altmove flag changes weren't immediately mar... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/f2e9b20e21f8 changeset: 13060:f2e9b20e21f8 user: Timo Sirainen date: Tue Feb 21 15:21:19 2012 +0200 description: sdbox: Altmove flag changes weren't immediately marked as synced. This caused the altmoves to be retried. diffstat: src/lib-storage/index/dbox-single/sdbox-sync.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (25 lines): diff -r c402fb407501 -r f2e9b20e21f8 src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Wed Feb 15 04:32:14 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Tue Feb 21 15:21:19 2012 +0200 @@ -36,6 +36,7 @@ enum sdbox_sync_entry_type type) { struct dbox_file *file; + enum modify_type modify_type; switch (type) { case SDBOX_SYNC_ENTRY_TYPE_EXPUNGE: @@ -46,6 +47,13 @@ break; case SDBOX_SYNC_ENTRY_TYPE_MOVE_FROM_ALT: case SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT: + /* update flags in the sync transaction, mainly to make + sure that these alt changes get marked as synced + and won't be retried */ + modify_type = type == SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT ? + MODIFY_ADD : MODIFY_REMOVE; + mail_index_update_flags(ctx->trans, seq, modify_type, + DBOX_INDEX_FLAG_ALT); file = sdbox_file_init(ctx->mbox, uid); dbox_sync_file_move_if_needed(file, type); dbox_file_unref(&file); From dovecot at dovecot.org Tue Feb 21 15:23:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 15:23:32 +0200 Subject: dovecot-2.1: sdbox: Altmove flag changes weren't immediately mar... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d9a6b0991f2e changeset: 14181:d9a6b0991f2e user: Timo Sirainen date: Tue Feb 21 15:21:19 2012 +0200 description: sdbox: Altmove flag changes weren't immediately marked as synced. This caused the altmoves to be retried. diffstat: src/lib-storage/index/dbox-single/sdbox-sync.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (25 lines): diff -r 242ad2a73648 -r d9a6b0991f2e src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Tue Feb 21 11:35:21 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Tue Feb 21 15:21:19 2012 +0200 @@ -36,6 +36,7 @@ enum sdbox_sync_entry_type type) { struct dbox_file *file; + enum modify_type modify_type; switch (type) { case SDBOX_SYNC_ENTRY_TYPE_EXPUNGE: @@ -46,6 +47,13 @@ break; case SDBOX_SYNC_ENTRY_TYPE_MOVE_FROM_ALT: case SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT: + /* update flags in the sync transaction, mainly to make + sure that these alt changes get marked as synced + and won't be retried */ + modify_type = type == SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT ? + MODIFY_ADD : MODIFY_REMOVE; + mail_index_update_flags(ctx->trans, seq, modify_type, + DBOX_INDEX_FLAG_ALT); file = sdbox_file_init(ctx->mbox, uid); dbox_sync_file_move_if_needed(file, type); dbox_file_unref(&file); From dovecot at dovecot.org Tue Feb 21 22:50:31 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 22:50:31 +0200 Subject: dovecot-2.1: lib-storage: Another try at correctly setting autoc... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3007994141b6 changeset: 14182:3007994141b6 user: Timo Sirainen date: Tue Feb 21 22:50:14 2012 +0200 description: lib-storage: Another try at correctly setting autocreated namespace's location strings. diffstat: src/lib-storage/mail-namespace.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diffs (42 lines): diff -r d9a6b0991f2e -r 3007994141b6 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Tue Feb 21 15:21:19 2012 +0200 +++ b/src/lib-storage/mail-namespace.c Tue Feb 21 22:50:14 2012 +0200 @@ -322,6 +322,7 @@ struct mail_namespace *ns; const struct mail_storage_settings *mail_set; const char *error, *driver, *location_source; + bool default_location = FALSE; i_assert(location == NULL || *location != '\0'); @@ -345,9 +346,9 @@ inbox_set->location = p_strdup(user->pool, location); location_source = "mail_location parameter"; } else if (*mail_set->mail_location != '\0') { - /* don't actually set it to namespace, since we'll default to - it anyway */ location_source = "mail_location setting"; + inbox_set->location = mail_set->mail_location; + default_location = TRUE; } else { location_source = "environment MAIL"; inbox_set->location = getenv("MAIL"); @@ -362,12 +363,15 @@ location_source = "environment MAILDIR"; } } - if (*inbox_set->location != '\0') { + if (default_location) { + /* treat this the same as if a namespace was created with + default settings. dsync relies on finding a namespace + without explicit location setting. */ + unexpanded_inbox_set->location = SETTING_STRVAR_UNEXPANDED; + } else { unexpanded_inbox_set->location = p_strconcat(user->pool, SETTING_STRVAR_EXPANDED, inbox_set->location, NULL); - } else { - unexpanded_inbox_set->location = SETTING_STRVAR_UNEXPANDED; } ns->set = inbox_set; From dovecot at dovecot.org Tue Feb 21 22:58:15 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 21 Feb 2012 22:58:15 +0200 Subject: dovecot-2.1: Compiler warning fix. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/6056be0a8c58 changeset: 14183:6056be0a8c58 user: Timo Sirainen date: Tue Feb 21 22:58:05 2012 +0200 description: Compiler warning fix. diffstat: src/lib-storage/index/dbox-single/sdbox-sync.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3007994141b6 -r 6056be0a8c58 src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Tue Feb 21 22:50:14 2012 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Tue Feb 21 22:58:05 2012 +0200 @@ -53,7 +53,7 @@ modify_type = type == SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT ? MODIFY_ADD : MODIFY_REMOVE; mail_index_update_flags(ctx->trans, seq, modify_type, - DBOX_INDEX_FLAG_ALT); + (enum mail_flags)DBOX_INDEX_FLAG_ALT); file = sdbox_file_init(ctx->mbox, uid); dbox_sync_file_move_if_needed(file, type); dbox_file_unref(&file); From pigeonhole at rename-it.nl Wed Feb 22 22:48:21 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 22 Feb 2012 21:48:21 +0100 Subject: dovecot-2.1-pigeonhole: lib-sieve: made error handler part of pu... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/a4ea7e3f8d9e changeset: 1604:a4ea7e3f8d9e user: Stephan Bosch date: Wed Feb 22 21:43:35 2012 +0100 description: lib-sieve: made error handler part of public runtime environment. diffstat: src/lib-sieve/plugins/enotify/ext-enotify-common.c | 9 +++------ src/lib-sieve/plugins/include/ext-include-common.c | 5 ++--- src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c | 7 ++----- src/lib-sieve/sieve-interpreter.c | 12 +++++------- src/lib-sieve/sieve-runtime.h | 1 + 5 files changed, 13 insertions(+), 21 deletions(-) diffs (134 lines): diff -r 6cca5f460f86 -r a4ea7e3f8d9e src/lib-sieve/plugins/enotify/ext-enotify-common.c --- a/src/lib-sieve/plugins/enotify/ext-enotify-common.c Thu Feb 16 22:07:32 2012 +0100 +++ b/src/lib-sieve/plugins/enotify/ext-enotify-common.c Wed Feb 22 21:43:35 2012 +0100 @@ -502,8 +502,7 @@ nenv.svinst = renv->svinst; nenv.method = method; nenv.ehandler = sieve_prefix_ehandler_create - (sieve_interpreter_get_error_handler(renv->interp), - sieve_runtime_get_full_command_location(renv), + (renv->ehandler, sieve_runtime_get_full_command_location(renv), "valid_notify_method test"); /* Use the method check function to validate the URI */ @@ -567,8 +566,7 @@ nenv.svinst = renv->svinst; nenv.method = method; nenv.ehandler = sieve_prefix_ehandler_create - (sieve_interpreter_get_error_handler(renv->interp), - sieve_runtime_get_full_command_location(renv), + (renv->ehandler, sieve_runtime_get_full_command_location(renv), "notify_method_capability test"); /* Execute method function to acquire capability value */ @@ -602,8 +600,7 @@ nenv.svinst = renv->svinst; nenv.method = method; nenv.ehandler = sieve_prefix_ehandler_create - (sieve_interpreter_get_error_handler(renv->interp), - sieve_runtime_get_full_command_location(renv), + (renv->ehandler, sieve_runtime_get_full_command_location(renv), "notify action"); /* Execute check function */ diff -r 6cca5f460f86 -r a4ea7e3f8d9e src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Thu Feb 16 22:07:32 2012 +0100 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Wed Feb 22 21:43:35 2012 +0100 @@ -688,10 +688,9 @@ if ( ctx->parent == NULL ) { struct ext_include_interpreter_context *curctx = NULL; - struct sieve_error_handler *ehandler = - sieve_interpreter_get_error_handler(renv->interp); + struct sieve_error_handler *ehandler = renv->ehandler; struct sieve_interpreter *subinterp; - bool interrupted = FALSE; + bool interrupted = FALSE; /* We are the top-level interpreter instance */ diff -r 6cca5f460f86 -r a4ea7e3f8d9e src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c --- a/src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c Thu Feb 16 22:07:32 2012 +0100 +++ b/src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c Wed Feb 22 21:43:35 2012 +0100 @@ -63,11 +63,8 @@ (const struct sieve_extension *ext ATTR_UNUSED, const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED) { - struct sieve_error_handler *ehandler = - sieve_interpreter_get_error_handler(renv->interp); - - if ( ehandler != NULL ) { - sieve_error_handler_accept_infolog(ehandler, TRUE); + if ( renv->ehandler != NULL ) { + sieve_error_handler_accept_infolog(renv->ehandler, TRUE); } return TRUE; diff -r 6cca5f460f86 -r a4ea7e3f8d9e src/lib-sieve/sieve-interpreter.c --- a/src/lib-sieve/sieve-interpreter.c Thu Feb 16 22:07:32 2012 +0100 +++ b/src/lib-sieve/sieve-interpreter.c Wed Feb 22 21:43:35 2012 +0100 @@ -43,8 +43,6 @@ struct sieve_interpreter { pool_t pool; - - struct sieve_error_handler *ehandler; /* Runtime data for extensions */ ARRAY_DEFINE(extensions, struct sieve_interpreter_extension_reg); @@ -88,7 +86,7 @@ interp = p_new(pool, struct sieve_interpreter, 1); interp->pool = pool; - interp->ehandler = ehandler; + interp->runenv.ehandler = ehandler; sieve_error_handler_ref(ehandler); interp->runenv.interp = interp; @@ -238,7 +236,7 @@ sieve_binary_debug_reader_deinit(&(*interp)->dreader); sieve_binary_unref(&(*interp)->runenv.sbin); - sieve_error_handler_unref(&(*interp)->ehandler); + sieve_error_handler_unref(&(*interp)->runenv.ehandler); pool_unref(&((*interp)->pool)); *interp = NULL; @@ -262,7 +260,7 @@ struct sieve_error_handler *sieve_interpreter_get_error_handler (struct sieve_interpreter *interp) { - return interp->ehandler; + return interp->runenv.ehandler; } struct sieve_instance *sieve_interpreter_svinst @@ -295,7 +293,7 @@ if ( location == NULL ) location = sieve_runtime_get_full_command_location(renv); - msg_func(renv->interp->ehandler, location, fmt, args); + msg_func(renv->ehandler, location, fmt, args); } T_END; } @@ -345,7 +343,7 @@ location = sieve_runtime_get_full_command_location(renv); sieve_vcritical - (renv->svinst, renv->interp->ehandler, location, user_prefix, fmt, args); + (renv->svinst, renv->ehandler, location, user_prefix, fmt, args); } T_END; va_end(args); diff -r 6cca5f460f86 -r a4ea7e3f8d9e src/lib-sieve/sieve-runtime.h --- a/src/lib-sieve/sieve-runtime.h Thu Feb 16 22:07:32 2012 +0100 +++ b/src/lib-sieve/sieve-runtime.h Wed Feb 22 21:43:35 2012 +0100 @@ -15,6 +15,7 @@ struct sieve_instance *svinst; struct sieve_interpreter *interp; enum sieve_runtime_flags flags; + struct sieve_error_handler *ehandler; /* Executing script */ struct sieve_script *script; From pigeonhole at rename-it.nl Wed Feb 22 22:51:20 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 22 Feb 2012 21:51:20 +0100 Subject: dovecot-2.2-pigeonhole: lib-sieve: made error handler part of pu... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/b4c69a7ae260 changeset: 1603:b4c69a7ae260 user: Stephan Bosch date: Wed Feb 22 21:43:35 2012 +0100 description: lib-sieve: made error handler part of public runtime environment. diffstat: src/lib-sieve/plugins/enotify/ext-enotify-common.c | 9 +++------ src/lib-sieve/plugins/include/ext-include-common.c | 5 ++--- src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c | 7 ++----- src/lib-sieve/sieve-interpreter.c | 12 +++++------- src/lib-sieve/sieve-runtime.h | 1 + 5 files changed, 13 insertions(+), 21 deletions(-) diffs (134 lines): diff -r eed6fba433f4 -r b4c69a7ae260 src/lib-sieve/plugins/enotify/ext-enotify-common.c --- a/src/lib-sieve/plugins/enotify/ext-enotify-common.c Mon Feb 13 00:01:30 2012 +0100 +++ b/src/lib-sieve/plugins/enotify/ext-enotify-common.c Wed Feb 22 21:43:35 2012 +0100 @@ -502,8 +502,7 @@ nenv.svinst = renv->svinst; nenv.method = method; nenv.ehandler = sieve_prefix_ehandler_create - (sieve_interpreter_get_error_handler(renv->interp), - sieve_runtime_get_full_command_location(renv), + (renv->ehandler, sieve_runtime_get_full_command_location(renv), "valid_notify_method test"); /* Use the method check function to validate the URI */ @@ -567,8 +566,7 @@ nenv.svinst = renv->svinst; nenv.method = method; nenv.ehandler = sieve_prefix_ehandler_create - (sieve_interpreter_get_error_handler(renv->interp), - sieve_runtime_get_full_command_location(renv), + (renv->ehandler, sieve_runtime_get_full_command_location(renv), "notify_method_capability test"); /* Execute method function to acquire capability value */ @@ -602,8 +600,7 @@ nenv.svinst = renv->svinst; nenv.method = method; nenv.ehandler = sieve_prefix_ehandler_create - (sieve_interpreter_get_error_handler(renv->interp), - sieve_runtime_get_full_command_location(renv), + (renv->ehandler, sieve_runtime_get_full_command_location(renv), "notify action"); /* Execute check function */ diff -r eed6fba433f4 -r b4c69a7ae260 src/lib-sieve/plugins/include/ext-include-common.c --- a/src/lib-sieve/plugins/include/ext-include-common.c Mon Feb 13 00:01:30 2012 +0100 +++ b/src/lib-sieve/plugins/include/ext-include-common.c Wed Feb 22 21:43:35 2012 +0100 @@ -688,10 +688,9 @@ if ( ctx->parent == NULL ) { struct ext_include_interpreter_context *curctx = NULL; - struct sieve_error_handler *ehandler = - sieve_interpreter_get_error_handler(renv->interp); + struct sieve_error_handler *ehandler = renv->ehandler; struct sieve_interpreter *subinterp; - bool interrupted = FALSE; + bool interrupted = FALSE; /* We are the top-level interpreter instance */ diff -r eed6fba433f4 -r b4c69a7ae260 src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c --- a/src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c Mon Feb 13 00:01:30 2012 +0100 +++ b/src/lib-sieve/plugins/vnd.dovecot/debug/ext-debug.c Wed Feb 22 21:43:35 2012 +0100 @@ -63,11 +63,8 @@ (const struct sieve_extension *ext ATTR_UNUSED, const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED) { - struct sieve_error_handler *ehandler = - sieve_interpreter_get_error_handler(renv->interp); - - if ( ehandler != NULL ) { - sieve_error_handler_accept_infolog(ehandler, TRUE); + if ( renv->ehandler != NULL ) { + sieve_error_handler_accept_infolog(renv->ehandler, TRUE); } return TRUE; diff -r eed6fba433f4 -r b4c69a7ae260 src/lib-sieve/sieve-interpreter.c --- a/src/lib-sieve/sieve-interpreter.c Mon Feb 13 00:01:30 2012 +0100 +++ b/src/lib-sieve/sieve-interpreter.c Wed Feb 22 21:43:35 2012 +0100 @@ -43,8 +43,6 @@ struct sieve_interpreter { pool_t pool; - - struct sieve_error_handler *ehandler; /* Runtime data for extensions */ ARRAY_DEFINE(extensions, struct sieve_interpreter_extension_reg); @@ -88,7 +86,7 @@ interp = p_new(pool, struct sieve_interpreter, 1); interp->pool = pool; - interp->ehandler = ehandler; + interp->runenv.ehandler = ehandler; sieve_error_handler_ref(ehandler); interp->runenv.interp = interp; @@ -238,7 +236,7 @@ sieve_binary_debug_reader_deinit(&(*interp)->dreader); sieve_binary_unref(&(*interp)->runenv.sbin); - sieve_error_handler_unref(&(*interp)->ehandler); + sieve_error_handler_unref(&(*interp)->runenv.ehandler); pool_unref(&((*interp)->pool)); *interp = NULL; @@ -262,7 +260,7 @@ struct sieve_error_handler *sieve_interpreter_get_error_handler (struct sieve_interpreter *interp) { - return interp->ehandler; + return interp->runenv.ehandler; } struct sieve_instance *sieve_interpreter_svinst @@ -295,7 +293,7 @@ if ( location == NULL ) location = sieve_runtime_get_full_command_location(renv); - msg_func(renv->interp->ehandler, location, fmt, args); + msg_func(renv->ehandler, location, fmt, args); } T_END; } @@ -345,7 +343,7 @@ location = sieve_runtime_get_full_command_location(renv); sieve_vcritical - (renv->svinst, renv->interp->ehandler, location, user_prefix, fmt, args); + (renv->svinst, renv->ehandler, location, user_prefix, fmt, args); } T_END; va_end(args); diff -r eed6fba433f4 -r b4c69a7ae260 src/lib-sieve/sieve-runtime.h --- a/src/lib-sieve/sieve-runtime.h Mon Feb 13 00:01:30 2012 +0100 +++ b/src/lib-sieve/sieve-runtime.h Wed Feb 22 21:43:35 2012 +0100 @@ -15,6 +15,7 @@ struct sieve_instance *svinst; struct sieve_interpreter *interp; enum sieve_runtime_flags flags; + struct sieve_error_handler *ehandler; /* Executing script */ struct sieve_script *script; From dovecot at dovecot.org Thu Feb 23 00:39:04 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 00:39:04 +0200 Subject: dovecot-2.1: man: Added description of command `log errors' to d... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/007ec1d1d995 changeset: 14184:007ec1d1d995 user: Pascal Volk date: Wed Feb 22 22:34:47 2012 +0000 description: man: Added description of command `log errors' to doveadm-log.1. diffstat: doc/man/doveadm-log.1.in | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diffs (33 lines): diff -r 6056be0a8c58 -r 007ec1d1d995 doc/man/doveadm-log.1.in --- a/doc/man/doveadm-log.1.in Tue Feb 21 22:58:05 2012 +0200 +++ b/doc/man/doveadm-log.1.in Wed Feb 22 22:34:47 2012 +0000 @@ -1,9 +1,12 @@ -.\" Copyright (c) 2010 Dovecot authors, see the included COPYING file -.TH DOVEADM\-LOG 1 "2010-06-13" "Dovecot v2.1" "Dovecot" +.\" Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file +.TH DOVEADM\-LOG 1 "2012-02-22" "Dovecot v2.1" "Dovecot" .SH NAME doveadm\-log \- Locate, test or reopen Dovecot\(aqs log files .\"------------------------------------------------------------------------ .SH SYNOPSIS +.BR doveadm " [" \-Dv "] " "log errors" +.\"------------------------------------- +.br .BR doveadm " [" \-Dv "] " "log find" .RI [ directory ] .\"------------------------------------- @@ -26,6 +29,14 @@ @INCLUDE:global-options@ .\"------------------------------------------------------------------------ .SH COMMANDS +.SS log errors +.B doveadm log errors +.PP +The +.B log errors +command is used to show the last \- up to 1,000 \- errors and warnings. +If no output is generated, no errors have occurred since the last start. +.\"------------------------------------- .SS log find .B doveadm log find .RI [ directory ] From dovecot at dovecot.org Thu Feb 23 10:55:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 10:55:25 +0200 Subject: dovecot-2.1: Added tag 2.1.1 for changeset 04b0acc03f1e Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0a034e33035b changeset: 14186:0a034e33035b user: Timo Sirainen date: Thu Feb 23 10:35:24 2012 +0200 description: Added tag 2.1.1 for changeset 04b0acc03f1e diffstat: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 04b0acc03f1e -r 0a034e33035b .hgtags --- a/.hgtags Thu Feb 23 10:35:24 2012 +0200 +++ b/.hgtags Thu Feb 23 10:35:24 2012 +0200 @@ -77,3 +77,4 @@ 481860782250ad55ab18ca81bd606fc70c3d2ad9 2.1.rc6 736f1b7af190ea68e65719277bd8d3d4682e0844 2.1.rc7 e2cd03cc9c690c4989fb53a1871b7109c547388a 2.1.0 +04b0acc03f1eaa0353888a75a452e5c8e61e4c94 2.1.1 From dovecot at dovecot.org Thu Feb 23 10:55:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 10:55:25 +0200 Subject: dovecot-2.1: Released v2.1.1. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/04b0acc03f1e changeset: 14185:04b0acc03f1e user: Timo Sirainen date: Thu Feb 23 10:35:24 2012 +0200 description: Released v2.1.1. diffstat: NEWS | 12 ++++++++++++ configure.in | 2 +- 2 files changed, 13 insertions(+), 1 deletions(-) diffs (29 lines): diff -r 007ec1d1d995 -r 04b0acc03f1e NEWS --- a/NEWS Wed Feb 22 22:34:47 2012 +0000 +++ b/NEWS Thu Feb 23 10:35:24 2012 +0200 @@ -1,3 +1,15 @@ +v2.1.1 2012-02-23 Timo Sirainen + + + dsync: If message with same GUID is saved multiple times in session, + copy it instead of re-saving. + - acl plugin + autocreated mailboxes crashed when listing mailboxes + - doveadm force-resync: Don't skip autocreated mailboxes (especially + INBOX). + - If process runs out of fds, stop listening for new connections only + temporarily, not permanently (avoids hangs with process_limit=1 + services) + - auth: passdb imap crashed for non-login authentication (e.g. smtp). + v2.1.0 2012-02-16 Timo Sirainen * Plugins now use UTF-8 mailbox names rather than mUTF-7: diff -r 007ec1d1d995 -r 04b0acc03f1e configure.in --- a/configure.in Wed Feb 22 22:34:47 2012 +0000 +++ b/configure.in Thu Feb 23 10:35:24 2012 +0200 @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([Dovecot],[2.1.0],[dovecot at dovecot.org]) +AC_INIT([Dovecot],[2.1.1],[dovecot at dovecot.org]) AC_CONFIG_SRCDIR([src]) AM_INIT_AUTOMAKE([foreign]) From dovecot at dovecot.org Thu Feb 23 10:55:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 10:55:25 +0200 Subject: dovecot-2.1: Added signature for changeset 04b0acc03f1e Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/e98143525d51 changeset: 14187:e98143525d51 user: Timo Sirainen date: Thu Feb 23 10:35:29 2012 +0200 description: Added signature for changeset 04b0acc03f1e diffstat: .hgsigs | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (8 lines): diff -r 0a034e33035b -r e98143525d51 .hgsigs --- a/.hgsigs Thu Feb 23 10:35:24 2012 +0200 +++ b/.hgsigs Thu Feb 23 10:35:29 2012 +0200 @@ -40,3 +40,4 @@ 481860782250ad55ab18ca81bd606fc70c3d2ad9 0 iEYEABECAAYFAk84IqgACgkQyUhSUUBVislPnQCfdgX9pbhqat0CCZhEjGiYu0uPXFUAn1QOG9uetBsgOM6MB4tuJc58Pl4c 736f1b7af190ea68e65719277bd8d3d4682e0844 0 iEYEABECAAYFAk87Kz4ACgkQyUhSUUBVismKXACeME7EBYoEuoLLELp0uX6B/lkgRWQAoJ2OAgz4mmluGbi0Db8grDDWSsTj e2cd03cc9c690c4989fb53a1871b7109c547388a 0 iEYEABECAAYFAk89MXsACgkQyUhSUUBVisnPmwCgiAr4OfQX1uAjhuqj5X0xbd8O1NQAn2bQW+h8QPAbqN6dQRNTm82D2hNF +04b0acc03f1eaa0353888a75a452e5c8e61e4c94 0 iEYEABECAAYFAk9F+k0ACgkQyUhSUUBViskLmwCfUt/aex6wOIEohJKnRGA4diF5WxoAn2zlMxSaPX/b0LBmV1P46GAMqZbO From dovecot at dovecot.org Thu Feb 23 11:12:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 11:12:16 +0200 Subject: dovecot-2.2: lmtp: Implemented Postfix-compatible XCLIENT extens... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1af2a0497f3f changeset: 14149:1af2a0497f3f user: Timo Sirainen date: Thu Feb 23 11:12:04 2012 +0200 description: lmtp: Implemented Postfix-compatible XCLIENT extension for changing client's ip/port. diffstat: src/lmtp/client.c | 25 +++++++++++++++++++++++++ src/lmtp/client.h | 1 + src/lmtp/commands.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/lmtp/commands.h | 1 + src/lmtp/lmtp-settings.c | 4 +++- src/lmtp/lmtp-settings.h | 1 + 6 files changed, 71 insertions(+), 1 deletions(-) diffs (149 lines): diff -r ac4eed7bef23 -r 1af2a0497f3f src/lmtp/client.c --- a/src/lmtp/client.c Thu Feb 16 23:05:17 2012 +0000 +++ b/src/lmtp/client.c Thu Feb 23 11:12:04 2012 +0200 @@ -68,6 +68,8 @@ return cmd_rset(client, args); if (strcmp(cmd, "NOOP") == 0) return cmd_noop(client, args); + if (strcmp(cmd, "XCLIENT") == 0) + return cmd_xclient(client, args); client_send_line(client, "502 5.5.2 Unknown command"); return 0; @@ -342,6 +344,29 @@ va_end(args); } +bool client_is_trusted(struct client *client) +{ + const char *const *net; + struct ip_addr net_ip; + unsigned int bits; + + if (client->lmtp_set->login_trusted_networks == NULL) + return FALSE; + + net = t_strsplit_spaces(client->lmtp_set->login_trusted_networks, ", "); + for (; *net != NULL; net++) { + if (net_parse_range(*net, &net_ip, &bits) < 0) { + i_error("login_trusted_networks: " + "Invalid network '%s'", *net); + break; + } + + if (net_is_in_network(&client->remote_ip, &net_ip, bits)) + return TRUE; + } + return FALSE; +} + void clients_destroy(void) { while (clients != NULL) { diff -r ac4eed7bef23 -r 1af2a0497f3f src/lmtp/client.h --- a/src/lmtp/client.h Thu Feb 16 23:05:17 2012 +0000 +++ b/src/lmtp/client.h Thu Feb 23 11:12:04 2012 +0200 @@ -82,6 +82,7 @@ void client_send_line(struct client *client, const char *fmt, ...) ATTR_FORMAT(2, 3); +bool client_is_trusted(struct client *client); void clients_destroy(void); diff -r ac4eed7bef23 -r 1af2a0497f3f src/lmtp/commands.c --- a/src/lmtp/commands.c Thu Feb 16 23:05:17 2012 +0000 +++ b/src/lmtp/commands.c Thu Feb 23 11:12:04 2012 +0200 @@ -68,6 +68,8 @@ client_state_reset(client); client_send_line(client, "250-%s", client->my_domain); + if (client_is_trusted(client)) + client_send_line(client, "250-XCLIENT ADDR PORT"); client_send_line(client, "250-8BITMIME"); client_send_line(client, "250-ENHANCEDSTATUSCODES"); client_send_line(client, "250 PIPELINING"); @@ -902,3 +904,41 @@ client_input_data_handle(client); return -1; } + +int cmd_xclient(struct client *client, const char *args) +{ + const char *const *tmp; + struct ip_addr remote_ip; + unsigned int remote_port = 0; + bool args_ok = TRUE; + + if (!client_is_trusted(client)) { + client_send_line(client, "550 You are not from trusted IP"); + return 0; + } + remote_ip.family = 0; + for (tmp = t_strsplit(args, " "); *tmp != NULL; tmp++) { + if (strncasecmp(*tmp, "ADDR=", 5) == 0) { + if (net_addr2ip(*tmp + 5, &remote_ip) < 0) + args_ok = FALSE; + } else if (strncasecmp(*tmp, "PORT=", 5) == 0) { + if (str_to_uint(*tmp + 5, &remote_port) < 0 || + remote_port == 0 || remote_port > 65535) + args_ok = FALSE; + } + } + if (!args_ok) { + client_send_line(client, "501 Invalid parameters"); + return 0; + } + + /* args ok, set them and reset the state */ + client_state_reset(client); + if (remote_ip.family != 0) + client->remote_ip = remote_ip; + if (remote_port != 0) + client->remote_port = remote_port; + client_send_line(client, "220 %s %s", client->my_domain, + client->lmtp_set->login_greeting); + return 0; +} diff -r ac4eed7bef23 -r 1af2a0497f3f src/lmtp/commands.h --- a/src/lmtp/commands.h Thu Feb 16 23:05:17 2012 +0000 +++ b/src/lmtp/commands.h Thu Feb 23 11:12:04 2012 +0200 @@ -11,5 +11,6 @@ int cmd_rset(struct client *client, const char *args); int cmd_noop(struct client *client, const char *args); int cmd_data(struct client *client, const char *args); +int cmd_xclient(struct client *client, const char *args); #endif diff -r ac4eed7bef23 -r 1af2a0497f3f src/lmtp/lmtp-settings.c --- a/src/lmtp/lmtp-settings.c Thu Feb 16 23:05:17 2012 +0000 +++ b/src/lmtp/lmtp-settings.c Thu Feb 23 11:12:04 2012 +0200 @@ -60,6 +60,7 @@ DEF(SET_BOOL, lmtp_proxy), DEF(SET_BOOL, lmtp_save_to_detail_mailbox), DEF(SET_STR_VARS, login_greeting), + DEF(SET_STR, login_trusted_networks), SETTING_DEFINE_LIST_END }; @@ -67,7 +68,8 @@ static const struct lmtp_settings lmtp_default_settings = { .lmtp_proxy = FALSE, .lmtp_save_to_detail_mailbox = FALSE, - .login_greeting = PACKAGE_NAME" ready." + .login_greeting = PACKAGE_NAME" ready.", + .login_trusted_networks = "" }; static const struct setting_parser_info *lmtp_setting_dependencies[] = { diff -r ac4eed7bef23 -r 1af2a0497f3f src/lmtp/lmtp-settings.h --- a/src/lmtp/lmtp-settings.h Thu Feb 16 23:05:17 2012 +0000 +++ b/src/lmtp/lmtp-settings.h Thu Feb 23 11:12:04 2012 +0200 @@ -8,6 +8,7 @@ bool lmtp_proxy; bool lmtp_save_to_detail_mailbox; const char *login_greeting; + const char *login_trusted_networks; }; extern const struct setting_parser_info lmtp_setting_parser_info; From dovecot at dovecot.org Thu Feb 23 11:59:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 11:59:23 +0200 Subject: dovecot-2.2: smtp/lmtp client: Send XCLIENT ADDR+PORT when possi... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/3144001fae84 changeset: 14150:3144001fae84 user: Timo Sirainen date: Thu Feb 23 11:58:35 2012 +0200 description: smtp/lmtp client: Send XCLIENT ADDR+PORT when possible. diffstat: src/lib-lda/lmtp-client.c | 91 +++++++++++++++++++++++++++++++++++++++++++--- src/lib-lda/lmtp-client.h | 7 +++ 2 files changed, 91 insertions(+), 7 deletions(-) diffs (234 lines): diff -r 1af2a0497f3f -r 3144001fae84 src/lib-lda/lmtp-client.c --- a/src/lib-lda/lmtp-client.c Thu Feb 23 11:12:04 2012 +0200 +++ b/src/lib-lda/lmtp-client.c Thu Feb 23 11:58:35 2012 +0200 @@ -6,6 +6,7 @@ #include "network.h" #include "istream.h" #include "ostream.h" +#include "str.h" #include "dns-lookup.h" #include "lmtp-client.h" @@ -20,7 +21,8 @@ LMTP_INPUT_STATE_MAIL_FROM, LMTP_INPUT_STATE_RCPT_TO, LMTP_INPUT_STATE_DATA_CONTINUE, - LMTP_INPUT_STATE_DATA + LMTP_INPUT_STATE_DATA, + LMTP_INPUT_STATE_XCLIENT }; struct lmtp_rcpt { @@ -44,6 +46,8 @@ enum lmtp_client_protocol protocol; enum lmtp_input_state input_state; const char *global_fail_string; + string_t *input_multiline; + const char **xclient_args; struct istream *input; struct ostream *output; @@ -64,6 +68,7 @@ struct istream *data_input; unsigned char output_last; + unsigned int xclient_sent:1; unsigned int rcpt_to_successes:1; unsigned int output_finished:1; unsigned int finish_called:1; @@ -89,9 +94,12 @@ client->set.my_hostname = p_strdup(pool, set->my_hostname); client->set.dns_client_socket_path = p_strdup(pool, set->dns_client_socket_path); + client->set.source_ip = set->source_ip; + client->set.source_port = set->source_port; client->finish_callback = finish_callback; client->finish_context = context; client->fd = -1; + client->input_multiline = str_new(default_pool, 128); p_array_init(&client->recipients, pool, 16); return client; } @@ -138,6 +146,7 @@ i_stream_unref(&client->input); if (client->output != NULL) o_stream_unref(&client->output); + str_free(&client->input_multiline); pool_unref(&client->pool); } @@ -177,6 +186,8 @@ return t_strdup_printf("DATA (%"PRIuUOFF_T"/?)", client->data_input->v_offset); } + case LMTP_INPUT_STATE_XCLIENT: + return "XCLIENT"; } return "??"; } @@ -356,7 +367,8 @@ } } -static int lmtp_input_get_reply_code(const char *line, int *reply_code_r) +static int lmtp_input_get_reply_code(const char *line, int *reply_code_r, + string_t *multiline) { if (!i_isdigit(line[0]) || !i_isdigit(line[1]) || !i_isdigit(line[2])) return -1; @@ -369,7 +381,9 @@ /* final reply */ return 1; } else if (line[3] == '-') { - /* multiline reply. just ignore it. */ + /* multiline reply. */ + str_append(multiline, line); + str_append_c(multiline, '\n'); return 0; } else { /* invalid input */ @@ -377,11 +391,58 @@ } } +static void +lmtp_client_parse_capabilities(struct lmtp_client *client, const char *lines) +{ + const char *const *linep; + + for (linep = t_strsplit(lines, "\n"); *linep != NULL; linep++) { + const char *line = *linep; + + line += 4; /* already checked this is valid */ + if (strncasecmp(line, "XCLIENT ", 8) == 0) { + client->xclient_args = + (void *)p_strsplit(client->pool, line + 8, " "); + } + } +} + +static bool lmtp_client_send_xclient(struct lmtp_client *client) +{ + string_t *str; + unsigned int empty_len; + + if (client->xclient_args == NULL) { + /* not supported */ + return FALSE; + } + if (client->xclient_sent) + return FALSE; + + str = t_str_new(64); + str_append(str, "XCLIENT"); + empty_len = str_len(str); + if (client->set.source_ip.family != 0 && + str_array_icase_find(client->xclient_args, "ADDR")) + str_printfa(str, " ADDR=%s", net_ip2addr(&client->set.source_ip)); + if (client->set.source_port != 0 && + str_array_icase_find(client->xclient_args, "PORT")) + str_printfa(str, " PORT=%u", client->set.source_port); + + if (str_len(str) == empty_len) + return FALSE; + + str_append(str, "\r\n"); + o_stream_send(client->output, str_data(str), str_len(str)); + return TRUE; +} + static int lmtp_client_input_line(struct lmtp_client *client, const char *line) { int ret, reply_code = 0; - if ((ret = lmtp_input_get_reply_code(line, &reply_code)) <= 0) { + if ((ret = lmtp_input_get_reply_code(line, &reply_code, + client->input_multiline)) <= 0) { if (ret == 0) return 0; lmtp_client_fail(client, line); @@ -390,12 +451,13 @@ switch (client->input_state) { case LMTP_INPUT_STATE_GREET: + case LMTP_INPUT_STATE_XCLIENT: if (reply_code != 220) { lmtp_client_fail(client, line); return -1; } lmtp_client_send_handshake(client); - client->input_state++; + client->input_state = LMTP_INPUT_STATE_LHLO; break; case LMTP_INPUT_STATE_LHLO: case LMTP_INPUT_STATE_MAIL_FROM: @@ -403,6 +465,15 @@ lmtp_client_fail(client, line); return -1; } + str_append(client->input_multiline, line); + lmtp_client_parse_capabilities(client, + str_c(client->input_multiline)); + if (client->input_state == LMTP_INPUT_STATE_LHLO && + lmtp_client_send_xclient(client)) { + client->input_state = LMTP_INPUT_STATE_XCLIENT; + client->xclient_sent = TRUE; + break; + } if (client->input_state == LMTP_INPUT_STATE_LHLO) { o_stream_send_str(client->output, t_strdup_printf("MAIL FROM:%s\r\n", @@ -435,21 +506,27 @@ return -1; break; } - return 0; + return 1; } static void lmtp_client_input(struct lmtp_client *client) { const char *line; + int ret; lmtp_client_ref(client); o_stream_cork(client->output); while ((line = i_stream_read_next_line(client->input)) != NULL) { - if (lmtp_client_input_line(client, line) < 0) { + T_BEGIN { + ret = lmtp_client_input_line(client, line); + } T_END; + if (ret < 0) { o_stream_uncork(client->output); lmtp_client_unref(&client); return; } + if (ret > 0) + str_truncate(client->input_multiline, 0); } if (client->input->stream_errno != 0) { diff -r 1af2a0497f3f -r 3144001fae84 src/lib-lda/lmtp-client.h --- a/src/lib-lda/lmtp-client.h Thu Feb 23 11:12:04 2012 +0200 +++ b/src/lib-lda/lmtp-client.h Thu Feb 23 11:58:35 2012 +0200 @@ -1,6 +1,8 @@ #ifndef LMTP_CLIENT_H #define LMTP_CLIENT_H +#include "network.h" + #define ERRSTR_TEMP_REMOTE_FAILURE "451 4.4.0 Remote server not answering" /* LMTP/SMTP client code. */ @@ -14,6 +16,11 @@ const char *my_hostname; const char *mail_from; const char *dns_client_socket_path; + + /* if remote server supports XCLIENT capability, + send the these as ADDR/PORT */ + struct ip_addr source_ip; + unsigned int source_port; }; /* reply contains the reply coming from remote server, or NULL From dovecot at dovecot.org Thu Feb 23 11:59:23 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 11:59:23 +0200 Subject: dovecot-2.2: lmtp proxy: Send client's IP/port to destination se... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/1bc56eec3f8e changeset: 14151:1bc56eec3f8e user: Timo Sirainen date: Thu Feb 23 11:59:10 2012 +0200 description: lmtp proxy: Send client's IP/port to destination server via XCLIENT if possible. diffstat: src/lmtp/commands.c | 18 ++++++++++++------ src/lmtp/lmtp-proxy.c | 26 ++++++++++++++++---------- src/lmtp/lmtp-proxy.h | 13 +++++++++++-- 3 files changed, 39 insertions(+), 18 deletions(-) diffs (170 lines): diff -r 3144001fae84 -r 1bc56eec3f8e src/lmtp/commands.c --- a/src/lmtp/commands.c Thu Feb 23 11:58:35 2012 +0200 +++ b/src/lmtp/commands.c Thu Feb 23 11:59:10 2012 +0200 @@ -150,7 +150,7 @@ } static bool -client_proxy_rcpt_parse_fields(struct lmtp_proxy_settings *set, +client_proxy_rcpt_parse_fields(struct lmtp_proxy_rcpt_settings *set, const char *const *args, const char **address) { const char *p, *key, *value; @@ -203,7 +203,7 @@ static bool client_proxy_is_ourself(const struct client *client, - const struct lmtp_proxy_settings *set) + const struct lmtp_proxy_rcpt_settings *set) { struct ip_addr ip; @@ -237,7 +237,7 @@ const char *username, const char *detail) { struct auth_master_connection *auth_conn; - struct lmtp_proxy_settings set; + struct lmtp_proxy_rcpt_settings set; struct auth_user_info info; struct mail_storage_service_input input; const char *args, *const *fields, *errstr, *orig_username = username; @@ -304,9 +304,15 @@ return TRUE; } if (client->proxy == NULL) { - client->proxy = lmtp_proxy_init(client->set->hostname, - dns_client_socket_path, - client->output); + struct lmtp_proxy_settings proxy_set; + + memset(&proxy_set, 0, sizeof(proxy_set)); + proxy_set.my_hostname = client->set->hostname; + proxy_set.dns_client_socket_path = dns_client_socket_path; + proxy_set.source_ip = client->remote_ip; + proxy_set.source_port = client->remote_port; + + client->proxy = lmtp_proxy_init(&proxy_set, client->output); if (client->state.mail_body_8bitmime) args = " BODY=8BITMIME"; else if (client->state.mail_body_7bit) diff -r 3144001fae84 -r 1bc56eec3f8e src/lmtp/lmtp-proxy.c --- a/src/lmtp/lmtp-proxy.c Thu Feb 23 11:58:35 2012 +0200 +++ b/src/lmtp/lmtp-proxy.c Thu Feb 23 11:59:10 2012 +0200 @@ -21,7 +21,7 @@ struct lmtp_proxy_connection { struct lmtp_proxy *proxy; - struct lmtp_proxy_settings set; + struct lmtp_proxy_rcpt_settings set; struct lmtp_client *client; struct istream *data_input; @@ -33,8 +33,8 @@ struct lmtp_proxy { pool_t pool; - const char *mail_from, *my_hostname; - const char *dns_client_socket_path; + const char *mail_from; + struct lmtp_proxy_settings set; ARRAY_DEFINE(connections, struct lmtp_proxy_connection *); ARRAY_DEFINE(rcpt_to, struct lmtp_proxy_recipient *); @@ -55,7 +55,7 @@ static void lmtp_conn_finish(void *context); struct lmtp_proxy * -lmtp_proxy_init(const char *my_hostname, const char *dns_client_socket_path, +lmtp_proxy_init(const struct lmtp_proxy_settings *set, struct ostream *client_output) { struct lmtp_proxy *proxy; @@ -66,9 +66,12 @@ pool = pool_alloconly_create("lmtp proxy", 1024); proxy = p_new(pool, struct lmtp_proxy, 1); proxy->pool = pool; - proxy->my_hostname = p_strdup(pool, my_hostname); proxy->client_output = client_output; - proxy->dns_client_socket_path = p_strdup(pool, dns_client_socket_path); + proxy->set.my_hostname = p_strdup(pool, set->my_hostname); + proxy->set.dns_client_socket_path = + p_strdup(pool, set->dns_client_socket_path); + proxy->set.source_ip = set->source_ip; + proxy->set.source_port = set->source_port; i_array_init(&proxy->rcpt_to, 32); i_array_init(&proxy->connections, 32); return proxy; @@ -110,7 +113,7 @@ static struct lmtp_proxy_connection * lmtp_proxy_get_connection(struct lmtp_proxy *proxy, - const struct lmtp_proxy_settings *set) + const struct lmtp_proxy_rcpt_settings *set) { struct lmtp_proxy_connection *const *conns, *conn; struct lmtp_client_settings client_set; @@ -127,8 +130,10 @@ memset(&client_set, 0, sizeof(client_set)); client_set.mail_from = proxy->mail_from; - client_set.my_hostname = proxy->my_hostname; - client_set.dns_client_socket_path = proxy->dns_client_socket_path; + client_set.my_hostname = proxy->set.my_hostname; + client_set.dns_client_socket_path = proxy->set.dns_client_socket_path; + client_set.source_ip = proxy->set.source_ip; + client_set.source_port = proxy->set.source_port; conn = p_new(proxy->pool, struct lmtp_proxy_connection, 1); conn->proxy = proxy; @@ -236,7 +241,7 @@ } int lmtp_proxy_add_rcpt(struct lmtp_proxy *proxy, const char *address, - const struct lmtp_proxy_settings *set) + const struct lmtp_proxy_rcpt_settings *set) { struct lmtp_proxy_connection *conn; struct lmtp_proxy_recipient *rcpt; @@ -294,4 +299,5 @@ lmtp_client_send(conn->client, conn->data_input); lmtp_client_send_more(conn->client); } + lmtp_proxy_try_finish(proxy); } diff -r 3144001fae84 -r 1bc56eec3f8e src/lmtp/lmtp-proxy.h --- a/src/lmtp/lmtp-proxy.h Thu Feb 23 11:58:35 2012 +0200 +++ b/src/lmtp/lmtp-proxy.h Thu Feb 23 11:59:10 2012 +0200 @@ -5,6 +5,15 @@ #include "lmtp-client.h" struct lmtp_proxy_settings { + const char *my_hostname; + const char *dns_client_socket_path; + + /* the original client's IP/port that connected to the proxy */ + struct ip_addr source_ip; + unsigned int source_port; +}; + +struct lmtp_proxy_rcpt_settings { const char *host; unsigned int port; unsigned int timeout_msecs; @@ -14,7 +23,7 @@ typedef void lmtp_proxy_finish_callback_t(void *context); struct lmtp_proxy * -lmtp_proxy_init(const char *my_hostname, const char *dns_client_socket_path, +lmtp_proxy_init(const struct lmtp_proxy_settings *set, struct ostream *client_output); void lmtp_proxy_deinit(struct lmtp_proxy **proxy); @@ -23,7 +32,7 @@ /* Add a new recipient. Returns -1 if we already know that the destination host can't be reached. */ int lmtp_proxy_add_rcpt(struct lmtp_proxy *proxy, const char *address, - const struct lmtp_proxy_settings *set); + const struct lmtp_proxy_rcpt_settings *set); /* Start proxying */ void lmtp_proxy_start(struct lmtp_proxy *proxy, struct istream *data_input, const char *header, From dovecot at dovecot.org Thu Feb 23 15:27:04 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Thu, 23 Feb 2012 15:27:04 +0200 Subject: dovecot-2.1: login proxy: If connect() fails, log how many secon... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c3da6b3a4a34 changeset: 14188:c3da6b3a4a34 user: Timo Sirainen date: Thu Feb 23 15:26:52 2012 +0200 description: login proxy: If connect() fails, log how many seconds it tried. diffstat: src/login-common/login-proxy.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (16 lines): diff -r e98143525d51 -r c3da6b3a4a34 src/login-common/login-proxy.c --- a/src/login-common/login-proxy.c Thu Feb 23 10:35:29 2012 +0200 +++ b/src/login-common/login-proxy.c Thu Feb 23 15:26:52 2012 +0200 @@ -199,9 +199,10 @@ err = net_geterror(proxy->server_fd); if (err != 0) { - i_error("proxy(%s): connect(%s, %u) failed: %s", + i_error("proxy(%s): connect(%s, %u) failed: %s (after %u secs)", proxy->client->virtual_user, - proxy->host, proxy->port, strerror(err)); + proxy->host, proxy->port, strerror(err), + (unsigned int)(ioloop_time - proxy->created.tv_sec)); proxy_fail_connect(proxy); login_proxy_free(&proxy); return; From dovecot at dovecot.org Sat Feb 25 03:45:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 03:45:25 +0200 Subject: dovecot-2.2: pop3-login: Implemented XCLIENT command for forward... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/eb1aecd05cea changeset: 14152:eb1aecd05cea user: Timo Sirainen date: Sat Feb 25 03:45:13 2012 +0200 description: pop3-login: Implemented XCLIENT command for forwarding client ip/port from proxy. diffstat: src/pop3-login/client.c | 54 ++++++++++++++++++++++++++++++++++++++------ src/pop3-login/client.h | 1 + src/pop3-login/pop3-proxy.c | 10 ++++++++ 3 files changed, 57 insertions(+), 8 deletions(-) diffs (120 lines): diff -r 1bc56eec3f8e -r eb1aecd05cea src/pop3-login/client.c --- a/src/pop3-login/client.c Thu Feb 23 11:59:10 2012 +0200 +++ b/src/pop3-login/client.c Sat Feb 25 03:45:13 2012 +0200 @@ -35,6 +35,40 @@ return TRUE; } +static bool cmd_xclient(struct pop3_client *client, const char *args) +{ + const char *const *tmp; + unsigned int remote_port; + bool args_ok = TRUE; + + if (!client->common.trusted) { + client_send_reply(&client->common, POP3_CMD_REPLY_ERROR, + "You are not from trusted IP"); + return TRUE; + } + for (tmp = t_strsplit(args, " "); *tmp != NULL; tmp++) { + if (strncasecmp(*tmp, "ADDR=", 5) == 0) { + if (net_addr2ip(*tmp + 5, &client->common.ip) < 0) + args_ok = FALSE; + } else if (strncasecmp(*tmp, "PORT=", 5) == 0) { + if (str_to_uint(*tmp + 5, &remote_port) < 0 || + remote_port == 0 || remote_port > 65535) + args_ok = FALSE; + else + client->common.remote_port = remote_port; + } + } + if (!args_ok) { + client_send_reply(&client->common, POP3_CMD_REPLY_ERROR, + "Invalid parameters"); + return TRUE; + } + + /* args ok, set them and reset the state */ + client_send_reply(&client->common, POP3_CMD_REPLY_OK, "Updated"); + return TRUE; +} + static bool client_command_execute(struct pop3_client *client, const char *cmd, const char *args) { @@ -53,6 +87,8 @@ return cmd_stls(client); if (strcmp(cmd, "QUIT") == 0) return cmd_quit(client); + if (strcmp(cmd, "XCLIENT") == 0) + return cmd_xclient(client, args); client_send_reply(&client->common, POP3_CMD_REPLY_ERROR, "Unknown command."); @@ -149,18 +185,20 @@ static void pop3_client_notify_auth_ready(struct client *client) { struct pop3_client *pop3_client = (struct pop3_client *)client; + string_t *str; client->io = io_add(client->fd, IO_READ, client_input, client); + str = t_str_new(128); + if (client->trusted) { + /* Dovecot extension to avoid extra roundtrip for CAPA */ + str_append(str, "[XCLIENT] "); + } + str_append(str, client->set->login_greeting); pop3_client->apop_challenge = get_apop_challenge(pop3_client); - if (pop3_client->apop_challenge == NULL) { - client_send_reply(client, POP3_CMD_REPLY_OK, - client->set->login_greeting); - } else { - client_send_reply(client, POP3_CMD_REPLY_OK, - t_strconcat(client->set->login_greeting, " ", - pop3_client->apop_challenge, NULL)); - } + if (pop3_client->apop_challenge != NULL) + str_printfa(str, " %s", pop3_client->apop_challenge); + client_send_reply(client, POP3_CMD_REPLY_OK, str_c(str)); } static void diff -r 1bc56eec3f8e -r eb1aecd05cea src/pop3-login/client.h --- a/src/pop3-login/client.h Thu Feb 23 11:59:10 2012 +0200 +++ b/src/pop3-login/client.h Sat Feb 25 03:45:13 2012 +0200 @@ -18,6 +18,7 @@ char *last_user; char *apop_challenge; unsigned int apop_server_pid, apop_connect_uid; + bool proxy_xclient; }; enum pop3_cmd_reply { diff -r 1bc56eec3f8e -r eb1aecd05cea src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Thu Feb 23 11:59:10 2012 +0200 +++ b/src/pop3-login/pop3-proxy.c Sat Feb 25 03:45:13 2012 +0200 @@ -37,6 +37,14 @@ { string_t *str; + if (client->proxy_xclient) { + /* remote supports XCLIENT, send it */ + (void)o_stream_send_str(output, t_strdup_printf( + "XCLIENT ADDR=%s PORT=%u\r\n", + net_ip2addr(&client->common.ip), + client->common.remote_port)); + } + str = t_str_new(128); if (client->common.proxy_master_user == NULL) { /* send USER command */ @@ -71,6 +79,8 @@ client_proxy_failed(client, TRUE); return -1; } + pop3_client->proxy_xclient = + strncmp(line+3, " [XCLIENT]", 10) == 0; ssl_flags = login_proxy_get_ssl_flags(client->login_proxy); if ((ssl_flags & PROXY_SSL_FLAG_STARTTLS) == 0) { From dovecot at dovecot.org Sat Feb 25 03:46:15 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 03:46:15 +0200 Subject: dovecot-2.2: login-common: Code cleanup Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ce1fd6eefeff changeset: 14153:ce1fd6eefeff user: Timo Sirainen date: Sat Feb 25 03:46:10 2012 +0200 description: login-common: Code cleanup diffstat: src/login-common/client-common.c | 46 ++++++++++++++++++++-------------------- src/login-common/client-common.h | 1 - 2 files changed, 23 insertions(+), 24 deletions(-) diffs (74 lines): diff -r eb1aecd05cea -r ce1fd6eefeff src/login-common/client-common.c --- a/src/login-common/client-common.c Sat Feb 25 03:45:13 2012 +0200 +++ b/src/login-common/client-common.c Sat Feb 25 03:46:10 2012 +0200 @@ -45,6 +45,29 @@ } } +static bool client_is_trusted(struct client *client) +{ + const char *const *net; + struct ip_addr net_ip; + unsigned int bits; + + if (client->set->login_trusted_networks == NULL) + return FALSE; + + net = t_strsplit_spaces(client->set->login_trusted_networks, ", "); + for (; *net != NULL; net++) { + if (net_parse_range(*net, &net_ip, &bits) < 0) { + i_error("login_trusted_networks: " + "Invalid network '%s'", *net); + break; + } + + if (net_is_in_network(&client->ip, &net_ip, bits)) + return TRUE; + } + return FALSE; +} + struct client * client_create(int fd, bool ssl, pool_t pool, const struct login_settings *set, void **other_sets, @@ -493,29 +516,6 @@ } T_END; } -bool client_is_trusted(struct client *client) -{ - const char *const *net; - struct ip_addr net_ip; - unsigned int bits; - - if (client->set->login_trusted_networks == NULL) - return FALSE; - - net = t_strsplit_spaces(client->set->login_trusted_networks, ", "); - for (; *net != NULL; net++) { - if (net_parse_range(*net, &net_ip, &bits) < 0) { - i_error("login_trusted_networks: " - "Invalid network '%s'", *net); - break; - } - - if (net_is_in_network(&client->ip, &net_ip, bits)) - return TRUE; - } - return FALSE; -} - const char *client_get_extra_disconnect_reason(struct client *client) { unsigned int auth_secs = client->auth_first_started == 0 ? 0 : diff -r eb1aecd05cea -r ce1fd6eefeff src/login-common/client-common.h --- a/src/login-common/client-common.h Sat Feb 25 03:45:13 2012 +0200 +++ b/src/login-common/client-common.h Sat Feb 25 03:46:10 2012 +0200 @@ -176,7 +176,6 @@ void client_log_err(struct client *client, const char *msg); void client_log_warn(struct client *client, const char *msg); const char *client_get_extra_disconnect_reason(struct client *client); -bool client_is_trusted(struct client *client); void client_auth_respond(struct client *client, const char *response); void client_auth_abort(struct client *client); From dovecot at dovecot.org Sat Feb 25 04:38:39 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 04:38:39 +0200 Subject: dovecot-2.2: auth: auth_stream_reply_remove() left extra TABs to... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/52e8a1346d2e changeset: 14154:52e8a1346d2e user: Timo Sirainen date: Sat Feb 25 04:38:01 2012 +0200 description: auth: auth_stream_reply_remove() left extra TABs to stream. Normally this wouldn't really affect anything, except log some extra debug messages. diffstat: src/auth/auth-stream.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diffs (26 lines): diff -r ce1fd6eefeff -r 52e8a1346d2e src/auth/auth-stream.c --- a/src/auth/auth-stream.c Sat Feb 25 03:46:10 2012 +0200 +++ b/src/auth/auth-stream.c Sat Feb 25 04:38:01 2012 +0200 @@ -76,15 +76,16 @@ if (!auth_stream_reply_find_area(reply, key, &idx, &len)) return; - if (str_len(reply->str) < idx + len) { - /* remove also trailing tab */ - len++; - } else if (str_len(reply->str) == idx + len && idx > 0) { - /* removing last item, remove preceding tab */ + if (idx == 0 && str_len(reply->str) == len) { + /* removing the only item */ + } else if (str_len(reply->str) == idx + len) { + /* removing the last item -> remove the preceding tab */ len++; idx--; + } else { + /* remove the trailing tab */ + len++; } - str_delete(reply->str, idx, len); } From dovecot at dovecot.org Sat Feb 25 04:38:40 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 04:38:40 +0200 Subject: dovecot-2.1: auth: auth_stream_reply_remove() left extra TABs to... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/970809a9f9bd changeset: 14189:970809a9f9bd user: Timo Sirainen date: Sat Feb 25 04:38:01 2012 +0200 description: auth: auth_stream_reply_remove() left extra TABs to stream. Normally this wouldn't really affect anything, except log some extra debug messages. diffstat: src/auth/auth-stream.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diffs (26 lines): diff -r c3da6b3a4a34 -r 970809a9f9bd src/auth/auth-stream.c --- a/src/auth/auth-stream.c Thu Feb 23 15:26:52 2012 +0200 +++ b/src/auth/auth-stream.c Sat Feb 25 04:38:01 2012 +0200 @@ -76,15 +76,16 @@ if (!auth_stream_reply_find_area(reply, key, &idx, &len)) return; - if (str_len(reply->str) < idx + len) { - /* remove also trailing tab */ - len++; - } else if (str_len(reply->str) == idx + len && idx > 0) { - /* removing last item, remove preceding tab */ + if (idx == 0 && str_len(reply->str) == len) { + /* removing the only item */ + } else if (str_len(reply->str) == idx + len) { + /* removing the last item -> remove the preceding tab */ len++; idx--; + } else { + /* remove the trailing tab */ + len++; } - str_delete(reply->str, idx, len); } From dovecot at dovecot.org Sat Feb 25 05:13:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:13:46 +0200 Subject: dovecot-2.2: auth: Use proxy_timeout as DNS lookup timeout, if a... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/8e2f395cf86c changeset: 14156:8e2f395cf86c user: Timo Sirainen date: Sat Feb 25 05:11:59 2012 +0200 description: auth: Use proxy_timeout as DNS lookup timeout, if available. Warn if lookup takes >0.5s. diffstat: src/auth/auth-request.c | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-) diffs (67 lines): diff -r da43dc494753 -r 8e2f395cf86c src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 05:04:15 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 05:11:59 2012 +0200 @@ -29,7 +29,8 @@ #include #define AUTH_DNS_SOCKET_PATH "dns-client" -#define AUTH_DNS_TIMEOUT_MSECS (1000*10) +#define AUTH_DNS_DEFAULT_TIMEOUT_MSECS (1000*10) +#define AUTH_DNS_WARN_MSECS 500 #define CACHED_PASSWORD_SCHEME "SHA1" unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX]; @@ -1473,14 +1474,20 @@ const char *host; unsigned int i; + host = auth_stream_reply_find(request->extra_fields, "host"); + i_assert(host != NULL); + if (result->ret != 0) { - host = auth_stream_reply_find(request->extra_fields, "host"); - i_assert(host != NULL); - auth_request_log_error(request, "dns", - "dns_lookup(%s) failed: %s", host, result->error); + auth_request_log_error(request, "proxy", + "DNS lookup for %s failed: %s", host, result->error); request->internal_failure = TRUE; auth_request_proxy_finish_failure(request); } else { + if (result->msecs > AUTH_DNS_WARN_MSECS) { + auth_request_log_warning(request, "proxy", + "DNS lookup for %s took %u.%03u s", + host, result->msecs/1000, result->msecs % 1000); + } auth_stream_reply_remove(request->extra_fields, "host"); auth_stream_reply_add(request->extra_fields, "host", net_ip2addr(&result->ips[0])); @@ -1503,8 +1510,9 @@ { struct auth_request_proxy_dns_lookup_ctx *ctx; struct dns_lookup_settings dns_set; - const char *host; + const char *host, *value; struct ip_addr ip; + unsigned int secs; host = auth_stream_reply_find(request->extra_fields, "host"); if (host == NULL) @@ -1518,7 +1526,16 @@ /* need to do dns lookup for the host */ memset(&dns_set, 0, sizeof(dns_set)); dns_set.dns_client_socket_path = AUTH_DNS_SOCKET_PATH; - dns_set.timeout_msecs = AUTH_DNS_TIMEOUT_MSECS; + dns_set.timeout_msecs = AUTH_DNS_DEFAULT_TIMEOUT_MSECS; + value = auth_stream_reply_find(request->extra_fields, "proxy_timeout"); + if (value != NULL) { + if (str_to_uint(value, &secs) < 0) { + auth_request_log_error(request, "proxy", + "Invalid proxy_timeout value: %s", value); + } else { + dns_set.timeout_msecs = secs*1000; + } + } ctx = i_new(struct auth_request_proxy_dns_lookup_ctx, 1); ctx->request = request; From dovecot at dovecot.org Sat Feb 25 05:13:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:13:46 +0200 Subject: dovecot-2.2: auth: Handle proxy_maybe=yes with host=hostname pro... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/da43dc494753 changeset: 14155:da43dc494753 user: Timo Sirainen date: Sat Feb 25 05:04:15 2012 +0200 description: auth: Handle proxy_maybe=yes with host=hostname properly. diffstat: src/auth/Makefile.am | 1 + src/auth/auth-master-connection.c | 37 +++++++- src/auth/auth-request-handler.c | 121 ++++++++++++++++++++----------- src/auth/auth-request.c | 143 +++++++++++++++++++++++++++++++------ src/auth/auth-request.h | 8 +- 5 files changed, 237 insertions(+), 73 deletions(-) diffs (truncated from 469 to 300 lines): diff -r 52e8a1346d2e -r da43dc494753 src/auth/Makefile.am --- a/src/auth/Makefile.am Sat Feb 25 04:38:01 2012 +0200 +++ b/src/auth/Makefile.am Sat Feb 25 05:04:15 2012 +0200 @@ -24,6 +24,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-auth \ + -I$(top_srcdir)/src/lib-dns \ -I$(top_srcdir)/src/lib-sql \ -I$(top_srcdir)/src/lib-settings \ -I$(top_srcdir)/src/lib-ntlm \ diff -r 52e8a1346d2e -r da43dc494753 src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Sat Feb 25 04:38:01 2012 +0200 +++ b/src/auth/auth-master-connection.c Sat Feb 25 05:04:15 2012 +0200 @@ -287,18 +287,13 @@ return TRUE; } -static void -pass_callback(enum passdb_result result, - const unsigned char *credentials ATTR_UNUSED, - size_t size ATTR_UNUSED, - struct auth_request *auth_request) +static void pass_callback_finish(struct auth_request *auth_request, + enum passdb_result result) { struct auth_master_connection *conn = auth_request->master; struct auth_stream_reply *reply = auth_request->extra_fields; string_t *str; - auth_request_proxy_finish(auth_request, result == PASSDB_RESULT_OK); - str = t_str_new(128); switch (result) { case PASSDB_RESULT_OK: @@ -331,6 +326,34 @@ auth_master_connection_unref(&conn); } +static void +auth_master_pass_proxy_finish(bool success, struct auth_request *auth_request) +{ + pass_callback_finish(auth_request, success ? PASSDB_RESULT_OK : + PASSDB_RESULT_INTERNAL_FAILURE); +} + +static void +pass_callback(enum passdb_result result, + const unsigned char *credentials ATTR_UNUSED, + size_t size ATTR_UNUSED, + struct auth_request *auth_request) +{ + int ret; + + if (result != PASSDB_RESULT_OK) + auth_request_proxy_finish_failure(auth_request); + else { + ret = auth_request_proxy_finish(auth_request, + auth_master_pass_proxy_finish); + if (ret == 0) + return; + if (ret < 0) + result = PASSDB_RESULT_INTERNAL_FAILURE; + } + pass_callback_finish(auth_request, result); +} + static const char *auth_restricted_reason(struct auth_master_connection *conn) { struct passwd pw; diff -r 52e8a1346d2e -r da43dc494753 src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Sat Feb 25 04:38:01 2012 +0200 +++ b/src/auth/auth-request-handler.c Sat Feb 25 05:04:15 2012 +0200 @@ -237,6 +237,72 @@ } } +static void +auth_request_handler_reply_success_finish(struct auth_request *request) +{ + struct auth_request_handler *handler = request->handler; + struct auth_stream_reply *reply; + + reply = auth_stream_reply_init(pool_datastack_create()); + + if (request->last_penalty != 0 && auth_penalty != NULL) { + /* reset penalty */ + auth_penalty_update(auth_penalty, request, 0); + } + + auth_stream_reply_add(reply, "OK", NULL); + auth_stream_reply_add(reply, NULL, dec2str(request->id)); + auth_stream_reply_add(reply, "user", request->user); + get_client_extra_fields(request, reply); + if (request->no_login || handler->master_callback == NULL) { + /* this request doesn't have to wait for master + process to pick it up. delete it */ + auth_request_handler_remove(handler, request); + } + handler->callback(reply, handler->context); +} + +static void +auth_request_handler_reply_failure_finish(struct auth_request *request) +{ + struct auth_stream_reply *reply; + + reply = auth_stream_reply_init(pool_datastack_create()); + auth_stream_reply_add(reply, "FAIL", NULL); + auth_stream_reply_add(reply, NULL, dec2str(request->id)); + if (request->user != NULL) + auth_stream_reply_add(reply, "user", request->user); + else if (request->original_username != NULL) { + auth_stream_reply_add(reply, "user", + request->original_username); + } + + if (request->internal_failure) + auth_stream_reply_add(reply, "temp", NULL); + else if (request->master_user != NULL) { + /* authentication succeeded, but we can't log in + as the wanted user */ + auth_stream_reply_add(reply, "authz", NULL); + } + if (request->no_failure_delay) + auth_stream_reply_add(reply, "nodelay", NULL); + get_client_extra_fields(request, reply); + + auth_request_handle_failure(request, reply); +} + +static void +auth_request_handler_proxy_callback(bool success, struct auth_request *request) +{ + struct auth_request_handler *handler = request->handler; + + if (success) + auth_request_handler_reply_success_finish(request); + else + auth_request_handler_reply_failure_finish(request); + auth_request_handler_unref(&handler); +} + void auth_request_handler_reply(struct auth_request *request, enum auth_client_result result, const void *auth_reply, size_t reply_size) @@ -244,6 +310,7 @@ struct auth_request_handler *handler = request->handler; struct auth_stream_reply *reply; string_t *str; + int ret; if (handler->destroyed) { /* the client connection was already closed. we can't do @@ -255,9 +322,9 @@ auth_request_set_state(request, AUTH_REQUEST_STATE_FINISHED); } - reply = auth_stream_reply_init(pool_datastack_create()); switch (result) { case AUTH_CLIENT_RESULT_CONTINUE: + reply = auth_stream_reply_init(pool_datastack_create()); auth_stream_reply_add(reply, "CONT", NULL); auth_stream_reply_add(reply, NULL, dec2str(request->id)); @@ -269,53 +336,23 @@ handler->callback(reply, handler->context); break; case AUTH_CLIENT_RESULT_SUCCESS: - auth_request_proxy_finish(request, TRUE); - - if (request->last_penalty != 0 && auth_penalty != NULL) { - /* reset penalty */ - auth_penalty_update(auth_penalty, request, 0); - } - - auth_stream_reply_add(reply, "OK", NULL); - auth_stream_reply_add(reply, NULL, dec2str(request->id)); - auth_stream_reply_add(reply, "user", request->user); if (reply_size > 0) { str = t_str_new(MAX_BASE64_ENCODED_SIZE(reply_size)); base64_encode(auth_reply, reply_size, str); - auth_stream_reply_add(reply, "resp", str_c(str)); + auth_stream_reply_add(request->extra_fields, "resp", str_c(str)); } - get_client_extra_fields(request, reply); - if (request->no_login || handler->master_callback == NULL) { - /* this request doesn't have to wait for master - process to pick it up. delete it */ - auth_request_handler_remove(handler, request); - } - handler->callback(reply, handler->context); + ret = auth_request_proxy_finish(request, + auth_request_handler_proxy_callback); + if (ret < 0) + auth_request_handler_reply_failure_finish(request); + else if (ret > 0) + auth_request_handler_reply_success_finish(request); + else + return; break; case AUTH_CLIENT_RESULT_FAILURE: - auth_request_proxy_finish(request, FALSE); - - auth_stream_reply_add(reply, "FAIL", NULL); - auth_stream_reply_add(reply, NULL, dec2str(request->id)); - if (request->user != NULL) - auth_stream_reply_add(reply, "user", request->user); - else if (request->original_username != NULL) { - auth_stream_reply_add(reply, "user", - request->original_username); - } - - if (request->internal_failure) - auth_stream_reply_add(reply, "temp", NULL); - else if (request->master_user != NULL) { - /* authentication succeeded, but we can't log in - as the wanted user */ - auth_stream_reply_add(reply, "authz", NULL); - } - if (request->no_failure_delay) - auth_stream_reply_add(reply, "nodelay", NULL); - get_client_extra_fields(request, reply); - - auth_request_handle_failure(request, reply); + auth_request_proxy_finish_failure(request); + auth_request_handler_reply_failure_finish(request); break; } /* NOTE: request may be destroyed now */ diff -r 52e8a1346d2e -r da43dc494753 src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 04:38:01 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 05:04:15 2012 +0200 @@ -11,6 +11,7 @@ #include "str-sanitize.h" #include "strescape.h" #include "var-expand.h" +#include "dns-lookup.h" #include "auth-cache.h" #include "auth-request.h" #include "auth-request-handler.h" @@ -27,6 +28,8 @@ #include #include +#define AUTH_DNS_SOCKET_PATH "dns-client" +#define AUTH_DNS_TIMEOUT_MSECS (1000*10) #define CACHED_PASSWORD_SCHEME "SHA1" unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX]; @@ -158,6 +161,11 @@ auth_request_state_count[request->state]--; auth_refresh_proctitle(); + if (request->mech_password != NULL) { + safe_memset(request->mech_password, 0, + strlen(request->mech_password)); + } + if (request->to_abort != NULL) timeout_remove(&request->to_abort); if (request->to_penalty != NULL) @@ -543,8 +551,6 @@ } else { auth_request_ref(request); request->private_callback.verify_plain(result, request); - safe_memset(request->mech_password, 0, - strlen(request->mech_password)); auth_request_unref(&request); } } @@ -1410,53 +1416,144 @@ static bool auth_request_proxy_is_self(struct auth_request *request) { - const char *const *tmp, *host = NULL, *port = NULL, *destuser = NULL; - struct ip_addr ip; + const char *const *tmp, *port = NULL, *destuser = NULL; + + if (!request->proxy_host_is_self) + return FALSE; tmp = auth_stream_split(request->extra_fields); for (; *tmp != NULL; tmp++) { - if (strncmp(*tmp, "host=", 5) == 0) - host = *tmp + 5; - else if (strncmp(*tmp, "port=", 5) == 0) + if (strncmp(*tmp, "port=", 5) == 0) port = *tmp + 5; - if (strncmp(*tmp, "destuser=", 9) == 0) + else if (strncmp(*tmp, "destuser=", 9) == 0) destuser = *tmp + 9; } - if (host == NULL || net_addr2ip(host, &ip) < 0) { - /* broken setup */ - return FALSE; - } - if (!net_ip_compare(&ip, &request->local_ip)) - return FALSE; From dovecot at dovecot.org Sat Feb 25 05:13:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:13:46 +0200 Subject: dovecot-2.2: login proxy: Removed host DNS lookup code, since au... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/da36d22ab37a changeset: 14157:da36d22ab37a user: Timo Sirainen date: Sat Feb 25 05:13:27 2012 +0200 description: login proxy: Removed host DNS lookup code, since auth does it now. diffstat: src/login-common/Makefile.am | 1 - src/login-common/client-common-auth.c | 2 -- src/login-common/login-proxy.c | 33 +++------------------------------ src/login-common/login-proxy.h | 1 - 4 files changed, 3 insertions(+), 34 deletions(-) diffs (111 lines): diff -r 8e2f395cf86c -r da36d22ab37a src/login-common/Makefile.am --- a/src/login-common/Makefile.am Sat Feb 25 05:11:59 2012 +0200 +++ b/src/login-common/Makefile.am Sat Feb 25 05:13:27 2012 +0200 @@ -4,7 +4,6 @@ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-settings \ -I$(top_srcdir)/src/lib-auth \ - -I$(top_srcdir)/src/lib-dns \ -I$(top_srcdir)/src/lib-master \ -I$(top_srcdir)/src/lib-ssl-iostream \ -DPKG_STATEDIR=\""$(statedir)"\" diff -r 8e2f395cf86c -r da36d22ab37a src/login-common/client-common-auth.c --- a/src/login-common/client-common-auth.c Sat Feb 25 05:11:59 2012 +0200 +++ b/src/login-common/client-common-auth.c Sat Feb 25 05:13:27 2012 +0200 @@ -14,7 +14,6 @@ #include #define PROXY_FAILURE_MSG "Account is temporarily unavailable." -#define LOGIN_DNS_CLIENT_SOCKET_PATH "dns-client" /* If we've been waiting auth server to respond for over this many milliseconds, send a "waiting" message. */ @@ -297,7 +296,6 @@ memset(&proxy_set, 0, sizeof(proxy_set)); proxy_set.host = reply->host; proxy_set.port = reply->port; - proxy_set.dns_client_socket_path = LOGIN_DNS_CLIENT_SOCKET_PATH; proxy_set.connect_timeout_msecs = reply->proxy_timeout_msecs; proxy_set.notify_refresh_secs = reply->proxy_refresh_secs; proxy_set.ssl_flags = reply->ssl_flags; diff -r 8e2f395cf86c -r da36d22ab37a src/login-common/login-proxy.c --- a/src/login-common/login-proxy.c Sat Feb 25 05:11:59 2012 +0200 +++ b/src/login-common/login-proxy.c Sat Feb 25 05:13:27 2012 +0200 @@ -10,7 +10,6 @@ #include "time-util.h" #include "master-service.h" #include "ipc-server.h" -#include "dns-lookup.h" #include "client-common.h" #include "ssl-proxy.h" #include "login-proxy-state.h" @@ -19,7 +18,6 @@ #define MAX_PROXY_INPUT_SIZE 4096 #define OUTBUF_THRESHOLD 1024 #define LOGIN_PROXY_DIE_IDLE_SECS 2 -#define LOGIN_PROXY_DNS_WARN_MSECS 500 #define LOGIN_PROXY_IPC_PATH "ipc-proxy" #define LOGIN_PROXY_IPC_NAME "proxy" #define KILLED_BY_ADMIN_REASON "Killed by admin" @@ -266,32 +264,11 @@ return 0; } -static void login_proxy_dns_done(const struct dns_lookup_result *result, - struct login_proxy *proxy) -{ - if (result->ret != 0) { - i_error("proxy(%s): DNS lookup of %s failed: %s", - proxy->client->virtual_user, proxy->host, - result->error); - login_proxy_free(&proxy); - } else { - if (result->msecs > LOGIN_PROXY_DNS_WARN_MSECS) { - i_warning("proxy(%s): DNS lookup for %s took %u.%03u s", - proxy->client->virtual_user, proxy->host, - result->msecs/1000, result->msecs % 1000); - } - - proxy->ip = result->ips[0]; - (void)login_proxy_connect(proxy); - } -} - int login_proxy_new(struct client *client, const struct login_proxy_settings *set, proxy_callback_t *callback) { struct login_proxy *proxy; - struct dns_lookup_settings dns_lookup_set; i_assert(client->login_proxy == NULL); @@ -312,14 +289,10 @@ proxy->ssl_flags = set->ssl_flags; client_ref(client); - memset(&dns_lookup_set, 0, sizeof(dns_lookup_set)); - dns_lookup_set.dns_client_socket_path = set->dns_client_socket_path; - dns_lookup_set.timeout_msecs = set->connect_timeout_msecs; - if (net_addr2ip(set->host, &proxy->ip) < 0) { - if (dns_lookup(set->host, &dns_lookup_set, - login_proxy_dns_done, proxy) < 0) - return -1; + i_error("proxy(%s): BUG: host %s is not an IP " + "(auth should have changed it)", + client->virtual_user, set->host); } else { if (login_proxy_connect(proxy) < 0) return -1; diff -r 8e2f395cf86c -r da36d22ab37a src/login-common/login-proxy.h --- a/src/login-common/login-proxy.h Sat Feb 25 05:11:59 2012 +0200 +++ b/src/login-common/login-proxy.h Sat Feb 25 05:13:27 2012 +0200 @@ -15,7 +15,6 @@ struct login_proxy_settings { const char *host; - const char *dns_client_socket_path; unsigned int port; unsigned int connect_timeout_msecs; /* send a notification about proxy connection to proxy-notify pipe From dovecot at dovecot.org Sat Feb 25 05:13:46 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:13:46 +0200 Subject: dovecot-2.2: dns: Removed login/dns-client socket, since it's no... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/fb972ad3213d changeset: 14158:fb972ad3213d user: Timo Sirainen date: Sat Feb 25 05:13:39 2012 +0200 description: dns: Removed login/dns-client socket, since it's no longer necessary. diffstat: src/dns/dns-client-settings.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diffs (18 lines): diff -r da36d22ab37a -r fb972ad3213d src/dns/dns-client-settings.c --- a/src/dns/dns-client-settings.c Sat Feb 25 05:13:27 2012 +0200 +++ b/src/dns/dns-client-settings.c Sat Feb 25 05:13:39 2012 +0200 @@ -9,12 +9,10 @@ /* */ static struct file_listener_settings dns_client_unix_listeners_array[] = { - { "dns-client", 0666, "", "" }, - { "login/dns-client", 0666, "", "" } + { "dns-client", 0666, "", "" } }; static struct file_listener_settings *dns_client_unix_listeners[] = { - &dns_client_unix_listeners_array[0], - &dns_client_unix_listeners_array[1] + &dns_client_unix_listeners_array[0] }; static buffer_t dns_client_unix_listeners_buf = { dns_client_unix_listeners, sizeof(dns_client_unix_listeners), { 0, } From dovecot at dovecot.org Sat Feb 25 05:21:12 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:21:12 +0200 Subject: dovecot-2.1: pop3-login: Implemented XCLIENT command for forward... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/35ed77dd500e changeset: 14190:35ed77dd500e user: Timo Sirainen date: Sat Feb 25 05:20:47 2012 +0200 description: pop3-login: Implemented XCLIENT command for forwarding client ip/port from proxy. diffstat: src/pop3-login/client.c | 54 ++++++++++++++++++++++++++++++++++++++------ src/pop3-login/client.h | 1 + src/pop3-login/pop3-proxy.c | 10 ++++++++ 3 files changed, 57 insertions(+), 8 deletions(-) diffs (120 lines): diff -r 970809a9f9bd -r 35ed77dd500e src/pop3-login/client.c --- a/src/pop3-login/client.c Sat Feb 25 04:38:01 2012 +0200 +++ b/src/pop3-login/client.c Sat Feb 25 05:20:47 2012 +0200 @@ -35,6 +35,40 @@ return TRUE; } +static bool cmd_xclient(struct pop3_client *client, const char *args) +{ + const char *const *tmp; + unsigned int remote_port; + bool args_ok = TRUE; + + if (!client->common.trusted) { + client_send_line(&client->common, CLIENT_CMD_REPLY_BAD, + "You are not from trusted IP"); + return TRUE; + } + for (tmp = t_strsplit(args, " "); *tmp != NULL; tmp++) { + if (strncasecmp(*tmp, "ADDR=", 5) == 0) { + if (net_addr2ip(*tmp + 5, &client->common.ip) < 0) + args_ok = FALSE; + } else if (strncasecmp(*tmp, "PORT=", 5) == 0) { + if (str_to_uint(*tmp + 5, &remote_port) < 0 || + remote_port == 0 || remote_port > 65535) + args_ok = FALSE; + else + client->common.remote_port = remote_port; + } + } + if (!args_ok) { + client_send_line(&client->common, CLIENT_CMD_REPLY_BAD, + "Invalid parameters"); + return TRUE; + } + + /* args ok, set them and reset the state */ + client_send_line(&client->common, CLIENT_CMD_REPLY_OK, "Updated"); + return TRUE; +} + static bool client_command_execute(struct pop3_client *client, const char *cmd, const char *args) { @@ -53,6 +87,8 @@ return cmd_stls(client); if (strcmp(cmd, "QUIT") == 0) return cmd_quit(client); + if (strcmp(cmd, "XCLIENT") == 0) + return cmd_xclient(client, args); client_send_line(&client->common, CLIENT_CMD_REPLY_BAD, "Unknown command."); @@ -149,18 +185,20 @@ static void pop3_client_send_greeting(struct client *client) { struct pop3_client *pop3_client = (struct pop3_client *)client; + string_t *str; client->io = io_add(client->fd, IO_READ, client_input, client); + str = t_str_new(128); + if (client->trusted) { + /* Dovecot extension to avoid extra roundtrip for CAPA */ + str_append(str, "[XCLIENT] "); + } + str_append(str, client->set->login_greeting); pop3_client->apop_challenge = get_apop_challenge(pop3_client); - if (pop3_client->apop_challenge == NULL) { - client_send_line(client, CLIENT_CMD_REPLY_OK, - client->set->login_greeting); - } else { - client_send_line(client, CLIENT_CMD_REPLY_OK, - t_strconcat(client->set->login_greeting, " ", - pop3_client->apop_challenge, NULL)); - } + if (pop3_client->apop_challenge != NULL) + str_printfa(str, " %s", pop3_client->apop_challenge); + client_send_line(client, CLIENT_CMD_REPLY_OK, str_c(str)); client->greeting_sent = TRUE; } diff -r 970809a9f9bd -r 35ed77dd500e src/pop3-login/client.h --- a/src/pop3-login/client.h Sat Feb 25 04:38:01 2012 +0200 +++ b/src/pop3-login/client.h Sat Feb 25 05:20:47 2012 +0200 @@ -18,6 +18,7 @@ char *last_user; char *apop_challenge; unsigned int apop_server_pid, apop_connect_uid; + bool proxy_xclient; }; #endif diff -r 970809a9f9bd -r 35ed77dd500e src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Sat Feb 25 04:38:01 2012 +0200 +++ b/src/pop3-login/pop3-proxy.c Sat Feb 25 05:20:47 2012 +0200 @@ -37,6 +37,14 @@ { string_t *str; + if (client->proxy_xclient) { + /* remote supports XCLIENT, send it */ + (void)o_stream_send_str(output, t_strdup_printf( + "XCLIENT ADDR=%s PORT=%u\r\n", + net_ip2addr(&client->common.ip), + client->common.remote_port)); + } + str = t_str_new(128); if (client->common.proxy_master_user == NULL) { /* send USER command */ @@ -71,6 +79,8 @@ client_proxy_failed(client, TRUE); return -1; } + pop3_client->proxy_xclient = + strncmp(line+3, " [XCLIENT]", 10) == 0; ssl_flags = login_proxy_get_ssl_flags(client->login_proxy); if ((ssl_flags & PROXY_SSL_FLAG_STARTTLS) == 0) { From dovecot at dovecot.org Sat Feb 25 05:23:38 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:23:38 +0200 Subject: dovecot-2.1: auth: Use proxy_timeout as DNS lookup timeout, if a... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/21c0ce019290 changeset: 14192:21c0ce019290 user: Timo Sirainen date: Sat Feb 25 05:11:59 2012 +0200 description: auth: Use proxy_timeout as DNS lookup timeout, if available. Warn if lookup takes >0.5s. diffstat: src/auth/auth-request.c | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-) diffs (67 lines): diff -r 863eac32786f -r 21c0ce019290 src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 05:04:15 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 05:11:59 2012 +0200 @@ -29,7 +29,8 @@ #include #define AUTH_DNS_SOCKET_PATH "dns-client" -#define AUTH_DNS_TIMEOUT_MSECS (1000*10) +#define AUTH_DNS_DEFAULT_TIMEOUT_MSECS (1000*10) +#define AUTH_DNS_WARN_MSECS 500 #define CACHED_PASSWORD_SCHEME "SHA1" unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX]; @@ -1473,14 +1474,20 @@ const char *host; unsigned int i; + host = auth_stream_reply_find(request->extra_fields, "host"); + i_assert(host != NULL); + if (result->ret != 0) { - host = auth_stream_reply_find(request->extra_fields, "host"); - i_assert(host != NULL); - auth_request_log_error(request, "dns", - "dns_lookup(%s) failed: %s", host, result->error); + auth_request_log_error(request, "proxy", + "DNS lookup for %s failed: %s", host, result->error); request->internal_failure = TRUE; auth_request_proxy_finish_failure(request); } else { + if (result->msecs > AUTH_DNS_WARN_MSECS) { + auth_request_log_warning(request, "proxy", + "DNS lookup for %s took %u.%03u s", + host, result->msecs/1000, result->msecs % 1000); + } auth_stream_reply_remove(request->extra_fields, "host"); auth_stream_reply_add(request->extra_fields, "host", net_ip2addr(&result->ips[0])); @@ -1503,8 +1510,9 @@ { struct auth_request_proxy_dns_lookup_ctx *ctx; struct dns_lookup_settings dns_set; - const char *host; + const char *host, *value; struct ip_addr ip; + unsigned int secs; host = auth_stream_reply_find(request->extra_fields, "host"); if (host == NULL) @@ -1518,7 +1526,16 @@ /* need to do dns lookup for the host */ memset(&dns_set, 0, sizeof(dns_set)); dns_set.dns_client_socket_path = AUTH_DNS_SOCKET_PATH; - dns_set.timeout_msecs = AUTH_DNS_TIMEOUT_MSECS; + dns_set.timeout_msecs = AUTH_DNS_DEFAULT_TIMEOUT_MSECS; + value = auth_stream_reply_find(request->extra_fields, "proxy_timeout"); + if (value != NULL) { + if (str_to_uint(value, &secs) < 0) { + auth_request_log_error(request, "proxy", + "Invalid proxy_timeout value: %s", value); + } else { + dns_set.timeout_msecs = secs*1000; + } + } ctx = i_new(struct auth_request_proxy_dns_lookup_ctx, 1); ctx->request = request; From dovecot at dovecot.org Sat Feb 25 05:23:38 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:23:38 +0200 Subject: dovecot-2.1: auth: Handle proxy_maybe=yes with host=hostname pro... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/863eac32786f changeset: 14191:863eac32786f user: Timo Sirainen date: Sat Feb 25 05:04:15 2012 +0200 description: auth: Handle proxy_maybe=yes with host=hostname properly. diffstat: src/auth/Makefile.am | 1 + src/auth/auth-master-connection.c | 37 +++++++- src/auth/auth-request-handler.c | 121 ++++++++++++++++++++----------- src/auth/auth-request.c | 143 +++++++++++++++++++++++++++++++------ src/auth/auth-request.h | 8 +- 5 files changed, 237 insertions(+), 73 deletions(-) diffs (truncated from 469 to 300 lines): diff -r 35ed77dd500e -r 863eac32786f src/auth/Makefile.am --- a/src/auth/Makefile.am Sat Feb 25 05:20:47 2012 +0200 +++ b/src/auth/Makefile.am Sat Feb 25 05:04:15 2012 +0200 @@ -24,6 +24,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-auth \ + -I$(top_srcdir)/src/lib-dns \ -I$(top_srcdir)/src/lib-sql \ -I$(top_srcdir)/src/lib-settings \ -I$(top_srcdir)/src/lib-ntlm \ diff -r 35ed77dd500e -r 863eac32786f src/auth/auth-master-connection.c --- a/src/auth/auth-master-connection.c Sat Feb 25 05:20:47 2012 +0200 +++ b/src/auth/auth-master-connection.c Sat Feb 25 05:04:15 2012 +0200 @@ -287,18 +287,13 @@ return TRUE; } -static void -pass_callback(enum passdb_result result, - const unsigned char *credentials ATTR_UNUSED, - size_t size ATTR_UNUSED, - struct auth_request *auth_request) +static void pass_callback_finish(struct auth_request *auth_request, + enum passdb_result result) { struct auth_master_connection *conn = auth_request->master; struct auth_stream_reply *reply = auth_request->extra_fields; string_t *str; - auth_request_proxy_finish(auth_request, result == PASSDB_RESULT_OK); - str = t_str_new(128); switch (result) { case PASSDB_RESULT_OK: @@ -331,6 +326,34 @@ auth_master_connection_unref(&conn); } +static void +auth_master_pass_proxy_finish(bool success, struct auth_request *auth_request) +{ + pass_callback_finish(auth_request, success ? PASSDB_RESULT_OK : + PASSDB_RESULT_INTERNAL_FAILURE); +} + +static void +pass_callback(enum passdb_result result, + const unsigned char *credentials ATTR_UNUSED, + size_t size ATTR_UNUSED, + struct auth_request *auth_request) +{ + int ret; + + if (result != PASSDB_RESULT_OK) + auth_request_proxy_finish_failure(auth_request); + else { + ret = auth_request_proxy_finish(auth_request, + auth_master_pass_proxy_finish); + if (ret == 0) + return; + if (ret < 0) + result = PASSDB_RESULT_INTERNAL_FAILURE; + } + pass_callback_finish(auth_request, result); +} + static const char *auth_restricted_reason(struct auth_master_connection *conn) { struct passwd pw; diff -r 35ed77dd500e -r 863eac32786f src/auth/auth-request-handler.c --- a/src/auth/auth-request-handler.c Sat Feb 25 05:20:47 2012 +0200 +++ b/src/auth/auth-request-handler.c Sat Feb 25 05:04:15 2012 +0200 @@ -237,6 +237,72 @@ } } +static void +auth_request_handler_reply_success_finish(struct auth_request *request) +{ + struct auth_request_handler *handler = request->handler; + struct auth_stream_reply *reply; + + reply = auth_stream_reply_init(pool_datastack_create()); + + if (request->last_penalty != 0 && auth_penalty != NULL) { + /* reset penalty */ + auth_penalty_update(auth_penalty, request, 0); + } + + auth_stream_reply_add(reply, "OK", NULL); + auth_stream_reply_add(reply, NULL, dec2str(request->id)); + auth_stream_reply_add(reply, "user", request->user); + get_client_extra_fields(request, reply); + if (request->no_login || handler->master_callback == NULL) { + /* this request doesn't have to wait for master + process to pick it up. delete it */ + auth_request_handler_remove(handler, request); + } + handler->callback(reply, handler->context); +} + +static void +auth_request_handler_reply_failure_finish(struct auth_request *request) +{ + struct auth_stream_reply *reply; + + reply = auth_stream_reply_init(pool_datastack_create()); + auth_stream_reply_add(reply, "FAIL", NULL); + auth_stream_reply_add(reply, NULL, dec2str(request->id)); + if (request->user != NULL) + auth_stream_reply_add(reply, "user", request->user); + else if (request->original_username != NULL) { + auth_stream_reply_add(reply, "user", + request->original_username); + } + + if (request->internal_failure) + auth_stream_reply_add(reply, "temp", NULL); + else if (request->master_user != NULL) { + /* authentication succeeded, but we can't log in + as the wanted user */ + auth_stream_reply_add(reply, "authz", NULL); + } + if (request->no_failure_delay) + auth_stream_reply_add(reply, "nodelay", NULL); + get_client_extra_fields(request, reply); + + auth_request_handle_failure(request, reply); +} + +static void +auth_request_handler_proxy_callback(bool success, struct auth_request *request) +{ + struct auth_request_handler *handler = request->handler; + + if (success) + auth_request_handler_reply_success_finish(request); + else + auth_request_handler_reply_failure_finish(request); + auth_request_handler_unref(&handler); +} + void auth_request_handler_reply(struct auth_request *request, enum auth_client_result result, const void *auth_reply, size_t reply_size) @@ -244,6 +310,7 @@ struct auth_request_handler *handler = request->handler; struct auth_stream_reply *reply; string_t *str; + int ret; if (handler->destroyed) { /* the client connection was already closed. we can't do @@ -255,9 +322,9 @@ auth_request_set_state(request, AUTH_REQUEST_STATE_FINISHED); } - reply = auth_stream_reply_init(pool_datastack_create()); switch (result) { case AUTH_CLIENT_RESULT_CONTINUE: + reply = auth_stream_reply_init(pool_datastack_create()); auth_stream_reply_add(reply, "CONT", NULL); auth_stream_reply_add(reply, NULL, dec2str(request->id)); @@ -269,53 +336,23 @@ handler->callback(reply, handler->context); break; case AUTH_CLIENT_RESULT_SUCCESS: - auth_request_proxy_finish(request, TRUE); - - if (request->last_penalty != 0 && auth_penalty != NULL) { - /* reset penalty */ - auth_penalty_update(auth_penalty, request, 0); - } - - auth_stream_reply_add(reply, "OK", NULL); - auth_stream_reply_add(reply, NULL, dec2str(request->id)); - auth_stream_reply_add(reply, "user", request->user); if (reply_size > 0) { str = t_str_new(MAX_BASE64_ENCODED_SIZE(reply_size)); base64_encode(auth_reply, reply_size, str); - auth_stream_reply_add(reply, "resp", str_c(str)); + auth_stream_reply_add(request->extra_fields, "resp", str_c(str)); } - get_client_extra_fields(request, reply); - if (request->no_login || handler->master_callback == NULL) { - /* this request doesn't have to wait for master - process to pick it up. delete it */ - auth_request_handler_remove(handler, request); - } - handler->callback(reply, handler->context); + ret = auth_request_proxy_finish(request, + auth_request_handler_proxy_callback); + if (ret < 0) + auth_request_handler_reply_failure_finish(request); + else if (ret > 0) + auth_request_handler_reply_success_finish(request); + else + return; break; case AUTH_CLIENT_RESULT_FAILURE: - auth_request_proxy_finish(request, FALSE); - - auth_stream_reply_add(reply, "FAIL", NULL); - auth_stream_reply_add(reply, NULL, dec2str(request->id)); - if (request->user != NULL) - auth_stream_reply_add(reply, "user", request->user); - else if (request->original_username != NULL) { - auth_stream_reply_add(reply, "user", - request->original_username); - } - - if (request->internal_failure) - auth_stream_reply_add(reply, "temp", NULL); - else if (request->master_user != NULL) { - /* authentication succeeded, but we can't log in - as the wanted user */ - auth_stream_reply_add(reply, "authz", NULL); - } - if (request->no_failure_delay) - auth_stream_reply_add(reply, "nodelay", NULL); - get_client_extra_fields(request, reply); - - auth_request_handle_failure(request, reply); + auth_request_proxy_finish_failure(request); + auth_request_handler_reply_failure_finish(request); break; } /* NOTE: request may be destroyed now */ diff -r 35ed77dd500e -r 863eac32786f src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 05:20:47 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 05:04:15 2012 +0200 @@ -11,6 +11,7 @@ #include "str-sanitize.h" #include "strescape.h" #include "var-expand.h" +#include "dns-lookup.h" #include "auth-cache.h" #include "auth-request.h" #include "auth-request-handler.h" @@ -27,6 +28,8 @@ #include #include +#define AUTH_DNS_SOCKET_PATH "dns-client" +#define AUTH_DNS_TIMEOUT_MSECS (1000*10) #define CACHED_PASSWORD_SCHEME "SHA1" unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX]; @@ -158,6 +161,11 @@ auth_request_state_count[request->state]--; auth_refresh_proctitle(); + if (request->mech_password != NULL) { + safe_memset(request->mech_password, 0, + strlen(request->mech_password)); + } + if (request->to_abort != NULL) timeout_remove(&request->to_abort); if (request->to_penalty != NULL) @@ -543,8 +551,6 @@ } else { auth_request_ref(request); request->private_callback.verify_plain(result, request); - safe_memset(request->mech_password, 0, - strlen(request->mech_password)); auth_request_unref(&request); } } @@ -1410,53 +1416,144 @@ static bool auth_request_proxy_is_self(struct auth_request *request) { - const char *const *tmp, *host = NULL, *port = NULL, *destuser = NULL; - struct ip_addr ip; + const char *const *tmp, *port = NULL, *destuser = NULL; + + if (!request->proxy_host_is_self) + return FALSE; tmp = auth_stream_split(request->extra_fields); for (; *tmp != NULL; tmp++) { - if (strncmp(*tmp, "host=", 5) == 0) - host = *tmp + 5; - else if (strncmp(*tmp, "port=", 5) == 0) + if (strncmp(*tmp, "port=", 5) == 0) port = *tmp + 5; - if (strncmp(*tmp, "destuser=", 9) == 0) + else if (strncmp(*tmp, "destuser=", 9) == 0) destuser = *tmp + 9; } - if (host == NULL || net_addr2ip(host, &ip) < 0) { - /* broken setup */ - return FALSE; - } - if (!net_ip_compare(&ip, &request->local_ip)) - return FALSE; From dovecot at dovecot.org Sat Feb 25 05:42:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:42:16 +0200 Subject: dovecot-2.2: auth: Added auth_proxy_self setting to specify IPs ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/98d696965c91 changeset: 14159:98d696965c91 user: Timo Sirainen date: Sat Feb 25 05:42:05 2012 +0200 description: auth: Added auth_proxy_self setting to specify IPs that are considered as "self" for proxy_maybe. diffstat: src/auth/auth-request.c | 11 ++++++++++- src/auth/auth-settings.c | 36 ++++++++++++++++++++++++++++++++++++ src/auth/auth-settings.h | 2 ++ src/config/settings-get.pl | 1 + 4 files changed, 49 insertions(+), 1 deletions(-) diffs (118 lines): diff -r fb972ad3213d -r 98d696965c91 src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 05:13:39 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 05:42:05 2012 +0200 @@ -1440,7 +1440,16 @@ auth_request_proxy_ip_is_self(struct auth_request *request, const struct ip_addr *ip) { - return net_ip_compare(ip, &request->local_ip); + unsigned int i; + + if (net_ip_compare(ip, &request->local_ip)) + return TRUE; + + for (i = 0; request->set->proxy_self_ips[i].family != 0; i++) { + if (net_ip_compare(ip, &request->set->proxy_self_ips[i])) + return TRUE; + } + return FALSE; } static void auth_request_proxy_finish_ip(struct auth_request *request) diff -r fb972ad3213d -r 98d696965c91 src/auth/auth-settings.c --- a/src/auth/auth-settings.c Sat Feb 25 05:13:39 2012 +0200 +++ b/src/auth/auth-settings.c Sat Feb 25 05:42:05 2012 +0200 @@ -198,6 +198,7 @@ DEF(SET_STR, krb5_keytab), DEF(SET_STR, gssapi_hostname), DEF(SET_STR, winbind_helper_path), + DEF(SET_STR, proxy_self), DEF(SET_TIME, failure_delay), DEF(SET_UINT, first_valid_uid), DEF(SET_UINT, last_valid_uid), @@ -236,6 +237,7 @@ .krb5_keytab = "", .gssapi_hostname = "", .winbind_helper_path = "/usr/bin/ntlm_auth", + .proxy_self = "", .failure_delay = 2, .first_valid_uid = 500, .last_valid_uid = 0, @@ -271,6 +273,37 @@ }; /* */ +static bool +auth_settings_set_self_ips(struct auth_settings *set, pool_t pool, + const char **error_r) +{ + const char *const *tmp; + ARRAY_DEFINE(ips_array, struct ip_addr); + struct ip_addr *ips; + unsigned int ips_count; + int ret; + + if (*set->proxy_self == '\0') { + set->proxy_self_ips = p_new(pool, struct ip_addr, 1); + return TRUE; + } + + p_array_init(&ips_array, pool, 4); + tmp = t_strsplit_spaces(set->proxy_self, " "); + for (; *tmp != NULL; tmp++) { + ret = net_gethostbyname(*tmp, &ips, &ips_count); + if (ret != 0) { + *error_r = t_strdup_printf("auth_proxy_self_ips: " + "gethostbyname(%s) failed: %s", + *tmp, net_gethosterror(ret)); + } + array_append(&ips_array, ips, ips_count); + } + (void)array_append_space(&ips_array); + set->proxy_self_ips = array_idx(&ips_array, 0); + return TRUE; +} + static bool auth_settings_check(void *_set, pool_t pool, const char **error_r) { @@ -312,6 +345,9 @@ } set->realms_arr = (const char *const *)p_strsplit_spaces(pool, set->realms, " "); + + if (!auth_settings_set_self_ips(set, pool, error_r)) + return FALSE; return TRUE; } diff -r fb972ad3213d -r 98d696965c91 src/auth/auth-settings.h --- a/src/auth/auth-settings.h Sat Feb 25 05:13:39 2012 +0200 +++ b/src/auth/auth-settings.h Sat Feb 25 05:42:05 2012 +0200 @@ -36,6 +36,7 @@ const char *krb5_keytab; const char *gssapi_hostname; const char *winbind_helper_path; + const char *proxy_self; unsigned int failure_delay; unsigned int first_valid_uid; unsigned int last_valid_uid; @@ -58,6 +59,7 @@ char username_chars_map[256]; char username_translation_map[256]; const char *const *realms_arr; + const struct ip_addr *proxy_self_ips; }; extern const struct setting_parser_info auth_setting_parser_info; diff -r fb972ad3213d -r 98d696965c91 src/config/settings-get.pl --- a/src/config/settings-get.pl Sat Feb 25 05:13:39 2012 +0200 +++ b/src/config/settings-get.pl Sat Feb 25 05:42:05 2012 +0200 @@ -8,6 +8,7 @@ print '#include "file-lock.h"'."\n"; print '#include "fsync-mode.h"'."\n"; print '#include "hash-format.h"'."\n"; +print '#include "network.h"'."\n"; print '#include "unichar.h"'."\n"; print '#include "settings-parser.h"'."\n"; print '#include "all-settings.h"'."\n"; From dovecot at dovecot.org Sat Feb 25 05:42:37 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 05:42:37 +0200 Subject: dovecot-2.1: auth: Added auth_proxy_self setting to specify IPs ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d84a9950be67 changeset: 14193:d84a9950be67 user: Timo Sirainen date: Sat Feb 25 05:42:05 2012 +0200 description: auth: Added auth_proxy_self setting to specify IPs that are considered as "self" for proxy_maybe. diffstat: src/auth/auth-request.c | 11 ++++++++++- src/auth/auth-settings.c | 36 ++++++++++++++++++++++++++++++++++++ src/auth/auth-settings.h | 2 ++ src/config/settings-get.pl | 1 + 4 files changed, 49 insertions(+), 1 deletions(-) diffs (118 lines): diff -r 21c0ce019290 -r d84a9950be67 src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 05:11:59 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 05:42:05 2012 +0200 @@ -1440,7 +1440,16 @@ auth_request_proxy_ip_is_self(struct auth_request *request, const struct ip_addr *ip) { - return net_ip_compare(ip, &request->local_ip); + unsigned int i; + + if (net_ip_compare(ip, &request->local_ip)) + return TRUE; + + for (i = 0; request->set->proxy_self_ips[i].family != 0; i++) { + if (net_ip_compare(ip, &request->set->proxy_self_ips[i])) + return TRUE; + } + return FALSE; } static void auth_request_proxy_finish_ip(struct auth_request *request) diff -r 21c0ce019290 -r d84a9950be67 src/auth/auth-settings.c --- a/src/auth/auth-settings.c Sat Feb 25 05:11:59 2012 +0200 +++ b/src/auth/auth-settings.c Sat Feb 25 05:42:05 2012 +0200 @@ -198,6 +198,7 @@ DEF(SET_STR, krb5_keytab), DEF(SET_STR, gssapi_hostname), DEF(SET_STR, winbind_helper_path), + DEF(SET_STR, proxy_self), DEF(SET_TIME, failure_delay), DEF(SET_UINT, first_valid_uid), DEF(SET_UINT, last_valid_uid), @@ -236,6 +237,7 @@ .krb5_keytab = "", .gssapi_hostname = "", .winbind_helper_path = "/usr/bin/ntlm_auth", + .proxy_self = "", .failure_delay = 2, .first_valid_uid = 500, .last_valid_uid = 0, @@ -271,6 +273,37 @@ }; /* */ +static bool +auth_settings_set_self_ips(struct auth_settings *set, pool_t pool, + const char **error_r) +{ + const char *const *tmp; + ARRAY_DEFINE(ips_array, struct ip_addr); + struct ip_addr *ips; + unsigned int ips_count; + int ret; + + if (*set->proxy_self == '\0') { + set->proxy_self_ips = p_new(pool, struct ip_addr, 1); + return TRUE; + } + + p_array_init(&ips_array, pool, 4); + tmp = t_strsplit_spaces(set->proxy_self, " "); + for (; *tmp != NULL; tmp++) { + ret = net_gethostbyname(*tmp, &ips, &ips_count); + if (ret != 0) { + *error_r = t_strdup_printf("auth_proxy_self_ips: " + "gethostbyname(%s) failed: %s", + *tmp, net_gethosterror(ret)); + } + array_append(&ips_array, ips, ips_count); + } + (void)array_append_space(&ips_array); + set->proxy_self_ips = array_idx(&ips_array, 0); + return TRUE; +} + static bool auth_settings_check(void *_set, pool_t pool, const char **error_r) { @@ -312,6 +345,9 @@ } set->realms_arr = (const char *const *)p_strsplit_spaces(pool, set->realms, " "); + + if (!auth_settings_set_self_ips(set, pool, error_r)) + return FALSE; return TRUE; } diff -r 21c0ce019290 -r d84a9950be67 src/auth/auth-settings.h --- a/src/auth/auth-settings.h Sat Feb 25 05:11:59 2012 +0200 +++ b/src/auth/auth-settings.h Sat Feb 25 05:42:05 2012 +0200 @@ -36,6 +36,7 @@ const char *krb5_keytab; const char *gssapi_hostname; const char *winbind_helper_path; + const char *proxy_self; unsigned int failure_delay; unsigned int first_valid_uid; unsigned int last_valid_uid; @@ -58,6 +59,7 @@ char username_chars_map[256]; char username_translation_map[256]; const char *const *realms_arr; + const struct ip_addr *proxy_self_ips; }; extern const struct setting_parser_info auth_setting_parser_info; diff -r 21c0ce019290 -r d84a9950be67 src/config/settings-get.pl --- a/src/config/settings-get.pl Sat Feb 25 05:11:59 2012 +0200 +++ b/src/config/settings-get.pl Sat Feb 25 05:42:05 2012 +0200 @@ -8,6 +8,7 @@ print '#include "file-lock.h"'."\n"; print '#include "fsync-mode.h"'."\n"; print '#include "hash-format.h"'."\n"; +print '#include "network.h"'."\n"; print '#include "unichar.h"'."\n"; print '#include "settings-parser.h"'."\n"; print '#include "all-settings.h"'."\n"; From dovecot at dovecot.org Sat Feb 25 06:39:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 06:39:24 +0200 Subject: dovecot-2.1: pop3 proxy: Fixed handling XCLIENT reply. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ef7518f0bdbc changeset: 14194:ef7518f0bdbc user: Timo Sirainen date: Sat Feb 25 06:39:00 2012 +0200 description: pop3 proxy: Fixed handling XCLIENT reply. diffstat: src/pop3-login/client.h | 1 + src/pop3-login/pop3-proxy.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletions(-) diffs (49 lines): diff -r d84a9950be67 -r ef7518f0bdbc src/pop3-login/client.h --- a/src/pop3-login/client.h Sat Feb 25 05:42:05 2012 +0200 +++ b/src/pop3-login/client.h Sat Feb 25 06:39:00 2012 +0200 @@ -8,6 +8,7 @@ enum pop3_proxy_state { POP3_PROXY_BANNER = 0, POP3_PROXY_STARTTLS, + POP3_PROXY_XCLIENT, POP3_PROXY_LOGIN1, POP3_PROXY_LOGIN2 }; diff -r d84a9950be67 -r ef7518f0bdbc src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Sat Feb 25 05:42:05 2012 +0200 +++ b/src/pop3-login/pop3-proxy.c Sat Feb 25 06:39:00 2012 +0200 @@ -43,6 +43,9 @@ "XCLIENT ADDR=%s PORT=%u\r\n", net_ip2addr(&client->common.ip), client->common.remote_port)); + client->common.proxy_state = POP3_PROXY_XCLIENT; + } else { + client->common.proxy_state = POP3_PROXY_LOGIN1; } str = t_str_new(128); @@ -56,7 +59,6 @@ str_append(str, "AUTH PLAIN\r\n"); } (void)o_stream_send(output, str_data(str), str_len(str)); - client->common.proxy_state = POP3_PROXY_LOGIN1; } int pop3_proxy_parse_line(struct client *client, const char *line) @@ -106,6 +108,16 @@ output = login_proxy_get_ostream(client->login_proxy); proxy_send_login(pop3_client, output); return 1; + case POP3_PROXY_XCLIENT: + if (strncmp(line, "+OK", 3) != 0) { + client_log_err(client, t_strdup_printf( + "proxy: Remote XCLIENT failed: %s", + str_sanitize(line, 160))); + client_proxy_failed(client, TRUE); + return -1; + } + client->proxy_state = POP3_PROXY_LOGIN1; + return 1; case POP3_PROXY_LOGIN1: str = t_str_new(128); if (client->proxy_master_user == NULL) { From dovecot at dovecot.org Sat Feb 25 06:39:26 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 06:39:26 +0200 Subject: dovecot-2.2: pop3 proxy: Fixed handling XCLIENT reply. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/9b79d71bff4e changeset: 14160:9b79d71bff4e user: Timo Sirainen date: Sat Feb 25 06:39:00 2012 +0200 description: pop3 proxy: Fixed handling XCLIENT reply. diffstat: src/pop3-login/client.h | 1 + src/pop3-login/pop3-proxy.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletions(-) diffs (49 lines): diff -r 98d696965c91 -r 9b79d71bff4e src/pop3-login/client.h --- a/src/pop3-login/client.h Sat Feb 25 05:42:05 2012 +0200 +++ b/src/pop3-login/client.h Sat Feb 25 06:39:00 2012 +0200 @@ -8,6 +8,7 @@ enum pop3_proxy_state { POP3_PROXY_BANNER = 0, POP3_PROXY_STARTTLS, + POP3_PROXY_XCLIENT, POP3_PROXY_LOGIN1, POP3_PROXY_LOGIN2 }; diff -r 98d696965c91 -r 9b79d71bff4e src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Sat Feb 25 05:42:05 2012 +0200 +++ b/src/pop3-login/pop3-proxy.c Sat Feb 25 06:39:00 2012 +0200 @@ -43,6 +43,9 @@ "XCLIENT ADDR=%s PORT=%u\r\n", net_ip2addr(&client->common.ip), client->common.remote_port)); + client->common.proxy_state = POP3_PROXY_XCLIENT; + } else { + client->common.proxy_state = POP3_PROXY_LOGIN1; } str = t_str_new(128); @@ -56,7 +59,6 @@ str_append(str, "AUTH PLAIN\r\n"); } (void)o_stream_send(output, str_data(str), str_len(str)); - client->common.proxy_state = POP3_PROXY_LOGIN1; } int pop3_proxy_parse_line(struct client *client, const char *line) @@ -106,6 +108,16 @@ output = login_proxy_get_ostream(client->login_proxy); proxy_send_login(pop3_client, output); return 1; + case POP3_PROXY_XCLIENT: + if (strncmp(line, "+OK", 3) != 0) { + client_log_err(client, t_strdup_printf( + "proxy: Remote XCLIENT failed: %s", + str_sanitize(line, 160))); + client_proxy_failed(client, TRUE); + return -1; + } + client->proxy_state = POP3_PROXY_LOGIN1; + return 1; case POP3_PROXY_LOGIN1: str = t_str_new(128); if (client->proxy_master_user == NULL) { From dovecot at dovecot.org Sat Feb 25 06:42:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 06:42:16 +0200 Subject: dovecot-2.2: pop3 proxy: Fixed previous change not to hang. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f534ed81bce4 changeset: 14161:f534ed81bce4 user: Timo Sirainen date: Sat Feb 25 06:41:59 2012 +0200 description: pop3 proxy: Fixed previous change not to hang. diffstat: src/pop3-login/pop3-proxy.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 9b79d71bff4e -r f534ed81bce4 src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Sat Feb 25 06:39:00 2012 +0200 +++ b/src/pop3-login/pop3-proxy.c Sat Feb 25 06:41:59 2012 +0200 @@ -117,7 +117,7 @@ return -1; } client->proxy_state = POP3_PROXY_LOGIN1; - return 1; + return 0; case POP3_PROXY_LOGIN1: str = t_str_new(128); if (client->proxy_master_user == NULL) { From dovecot at dovecot.org Sat Feb 25 06:55:06 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 06:55:06 +0200 Subject: dovecot-2.2: imap/pop3/lmtp proxy: Implemented detection of prox... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ba06ea38c722 changeset: 14162:ba06ea38c722 user: Timo Sirainen date: Sat Feb 25 06:54:52 2012 +0200 description: imap/pop3/lmtp proxy: Implemented detection of proxy loops with TTL. If proxying tries to continue after 5 forward connections, it fails. The limit of 5 is hard coded currently. diffstat: src/imap-login/client.c | 2 ++ src/imap-login/imap-proxy.c | 8 ++++++-- src/lib-lda/lmtp-client.c | 4 ++++ src/lib-lda/lmtp-client.h | 2 ++ src/lmtp/client.c | 1 + src/lmtp/client.h | 1 + src/lmtp/commands.c | 19 +++++++++++++++++-- src/lmtp/lmtp-proxy.c | 2 ++ src/lmtp/lmtp-proxy.h | 3 +++ src/login-common/client-common.c | 1 + src/login-common/client-common.h | 1 + src/login-common/login-proxy.c | 6 ++++++ src/login-common/login-proxy.h | 7 +++++++ src/pop3-login/client.c | 3 +++ src/pop3-login/pop3-proxy.c | 6 ++++-- 15 files changed, 60 insertions(+), 6 deletions(-) diffs (283 lines): diff -r f534ed81bce4 -r ba06ea38c722 src/imap-login/client.c --- a/src/imap-login/client.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/imap-login/client.c Sat Feb 25 06:54:52 2012 +0200 @@ -121,6 +121,8 @@ (void)net_addr2ip(value, &client->common.local_ip); else if (strcasecmp(key, "x-connected-port") == 0) client->common.local_port = atoi(value); + else if (strcasecmp(key, "x-proxy-ttl") == 0) + client->common.proxy_ttl = atoi(value); args += 2; } } diff -r f534ed81bce4 -r ba06ea38c722 src/imap-login/imap-proxy.c --- a/src/imap-login/imap-proxy.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/imap-login/imap-proxy.c Sat Feb 25 06:54:52 2012 +0200 @@ -29,15 +29,19 @@ static void proxy_write_id(struct imap_client *client, string_t *str) { + i_assert(client->common.proxy_ttl > 0); + str_printfa(str, "I ID (" "\"x-originating-ip\" \"%s\" " "\"x-originating-port\" \"%u\" " "\"x-connected-ip\" \"%s\" " - "\"x-connected-port\" \"%u\")\r\n", + "\"x-connected-port\" \"%u\" " + "\"x-proxy-ttl\" \"%u\")\r\n", net_ip2addr(&client->common.ip), client->common.remote_port, net_ip2addr(&client->common.local_ip), - client->common.local_port); + client->common.local_port, + client->common.proxy_ttl - 1); } static void proxy_free_password(struct client *client) diff -r f534ed81bce4 -r ba06ea38c722 src/lib-lda/lmtp-client.c --- a/src/lib-lda/lmtp-client.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/lib-lda/lmtp-client.c Sat Feb 25 06:54:52 2012 +0200 @@ -96,6 +96,7 @@ p_strdup(pool, set->dns_client_socket_path); client->set.source_ip = set->source_ip; client->set.source_port = set->source_port; + client->set.proxy_ttl_plus_1 = set->proxy_ttl_plus_1; client->finish_callback = finish_callback; client->finish_context = context; client->fd = -1; @@ -428,6 +429,9 @@ if (client->set.source_port != 0 && str_array_icase_find(client->xclient_args, "PORT")) str_printfa(str, " PORT=%u", client->set.source_port); + if (client->set.proxy_ttl_plus_1 != 0 && + str_array_icase_find(client->xclient_args, "TTL")) + str_printfa(str, " TTL=%u", client->set.proxy_ttl_plus_1-1); if (str_len(str) == empty_len) return FALSE; diff -r f534ed81bce4 -r ba06ea38c722 src/lib-lda/lmtp-client.h --- a/src/lib-lda/lmtp-client.h Sat Feb 25 06:41:59 2012 +0200 +++ b/src/lib-lda/lmtp-client.h Sat Feb 25 06:54:52 2012 +0200 @@ -21,6 +21,8 @@ send the these as ADDR/PORT */ struct ip_addr source_ip; unsigned int source_port; + /* send TTL as this -1, so the default 0 means "don't send it" */ + unsigned int proxy_ttl_plus_1; }; /* reply contains the reply coming from remote server, or NULL diff -r f534ed81bce4 -r ba06ea38c722 src/lmtp/client.c --- a/src/lmtp/client.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/lmtp/client.c Sat Feb 25 06:54:52 2012 +0200 @@ -227,6 +227,7 @@ client_generate_session_id(client); client->my_domain = client->set->hostname; client->lhlo = i_strdup("missing"); + client->proxy_ttl = LMTP_PROXY_DEFAULT_TTL; DLLIST_PREPEND(&clients, client); clients_count++; diff -r f534ed81bce4 -r ba06ea38c722 src/lmtp/client.h --- a/src/lmtp/client.h Sat Feb 25 06:41:59 2012 +0200 +++ b/src/lmtp/client.h Sat Feb 25 06:54:52 2012 +0200 @@ -62,6 +62,7 @@ struct client_state state; struct istream *dot_input; struct lmtp_proxy *proxy; + unsigned int proxy_ttl; unsigned int disconnected:1; }; diff -r f534ed81bce4 -r ba06ea38c722 src/lmtp/commands.c --- a/src/lmtp/commands.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/lmtp/commands.c Sat Feb 25 06:54:52 2012 +0200 @@ -69,7 +69,7 @@ client_state_reset(client); client_send_line(client, "250-%s", client->my_domain); if (client_is_trusted(client)) - client_send_line(client, "250-XCLIENT ADDR PORT"); + client_send_line(client, "250-XCLIENT ADDR PORT TTL"); client_send_line(client, "250-8BITMIME"); client_send_line(client, "250-ENHANCEDSTATUSCODES"); client_send_line(client, "250 PIPELINING"); @@ -296,6 +296,15 @@ return TRUE; } + if (client->proxy_ttl == 0) { + i_error("Proxying to <%s> appears to be looping (TTL=0)", + username); + client_send_line(client, "554 5.4.6 <%s> " + "Proxying appears to be looping (TTL=0)", + username); + pool_unref(&pool); + return TRUE; + } if (array_count(&client->state.rcpt_to) != 0) { client_send_line(client, "451 4.3.0 <%s> " "Can't handle mixed proxy/non-proxy destinations", @@ -311,6 +320,7 @@ proxy_set.dns_client_socket_path = dns_client_socket_path; proxy_set.source_ip = client->remote_ip; proxy_set.source_port = client->remote_port; + proxy_set.proxy_ttl = client->proxy_ttl-1; client->proxy = lmtp_proxy_init(&proxy_set, client->output); if (client->state.mail_body_8bitmime) @@ -915,7 +925,7 @@ { const char *const *tmp; struct ip_addr remote_ip; - unsigned int remote_port = 0; + unsigned int remote_port = 0, ttl = -1U; bool args_ok = TRUE; if (!client_is_trusted(client)) { @@ -931,6 +941,9 @@ if (str_to_uint(*tmp + 5, &remote_port) < 0 || remote_port == 0 || remote_port > 65535) args_ok = FALSE; + } else if (strncasecmp(*tmp, "TTL=", 4) == 0) { + if (str_to_uint(*tmp + 4, &ttl) < 0) + args_ok = FALSE; } } if (!args_ok) { @@ -944,6 +957,8 @@ client->remote_ip = remote_ip; if (remote_port != 0) client->remote_port = remote_port; + if (ttl != -1U) + client->proxy_ttl = ttl; client_send_line(client, "220 %s %s", client->my_domain, client->lmtp_set->login_greeting); return 0; diff -r f534ed81bce4 -r ba06ea38c722 src/lmtp/lmtp-proxy.c --- a/src/lmtp/lmtp-proxy.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/lmtp/lmtp-proxy.c Sat Feb 25 06:54:52 2012 +0200 @@ -72,6 +72,7 @@ p_strdup(pool, set->dns_client_socket_path); proxy->set.source_ip = set->source_ip; proxy->set.source_port = set->source_port; + proxy->set.proxy_ttl = set->proxy_ttl; i_array_init(&proxy->rcpt_to, 32); i_array_init(&proxy->connections, 32); return proxy; @@ -134,6 +135,7 @@ client_set.dns_client_socket_path = proxy->set.dns_client_socket_path; client_set.source_ip = proxy->set.source_ip; client_set.source_port = proxy->set.source_port; + client_set.proxy_ttl_plus_1 = proxy->set.proxy_ttl+1; conn = p_new(proxy->pool, struct lmtp_proxy_connection, 1); conn->proxy = proxy; diff -r f534ed81bce4 -r ba06ea38c722 src/lmtp/lmtp-proxy.h --- a/src/lmtp/lmtp-proxy.h Sat Feb 25 06:41:59 2012 +0200 +++ b/src/lmtp/lmtp-proxy.h Sat Feb 25 06:54:52 2012 +0200 @@ -4,6 +4,8 @@ #include "network.h" #include "lmtp-client.h" +#define LMTP_PROXY_DEFAULT_TTL 5 + struct lmtp_proxy_settings { const char *my_hostname; const char *dns_client_socket_path; @@ -11,6 +13,7 @@ /* the original client's IP/port that connected to the proxy */ struct ip_addr source_ip; unsigned int source_port; + unsigned int proxy_ttl; }; struct lmtp_proxy_rcpt_settings { diff -r f534ed81bce4 -r ba06ea38c722 src/login-common/client-common.c --- a/src/login-common/client-common.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/login-common/client-common.c Sat Feb 25 06:54:52 2012 +0200 @@ -96,6 +96,7 @@ client->trusted = client_is_trusted(client); client->secured = ssl || client->trusted || net_ip_compare(remote_ip, local_ip); + client->proxy_ttl = LOGIN_PROXY_TTL; if (last_client == NULL) last_client = client; diff -r f534ed81bce4 -r ba06ea38c722 src/login-common/client-common.h --- a/src/login-common/client-common.h Sat Feb 25 06:41:59 2012 +0200 +++ b/src/login-common/client-common.h Sat Feb 25 06:54:52 2012 +0200 @@ -117,6 +117,7 @@ struct login_proxy *login_proxy; char *proxy_user, *proxy_master_user, *proxy_password; unsigned int proxy_state; + unsigned int proxy_ttl; char *auth_mech_name; struct auth_client_request *auth_request; diff -r f534ed81bce4 -r ba06ea38c722 src/login-common/login-proxy.c --- a/src/login-common/login-proxy.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/login-common/login-proxy.c Sat Feb 25 06:54:52 2012 +0200 @@ -277,6 +277,12 @@ return -1; } + if (client->proxy_ttl == 0) { + i_error("proxy(%s): TTL reached zero - " + "proxies appear to be looping?", client->virtual_user); + return -1; + } + proxy = i_new(struct login_proxy, 1); proxy->client = client; proxy->client_fd = -1; diff -r f534ed81bce4 -r ba06ea38c722 src/login-common/login-proxy.h --- a/src/login-common/login-proxy.h Sat Feb 25 06:41:59 2012 +0200 +++ b/src/login-common/login-proxy.h Sat Feb 25 06:54:52 2012 +0200 @@ -1,6 +1,13 @@ #ifndef LOGIN_PROXY_H #define LOGIN_PROXY_H +/* Max. number of embedded proxying connections until proxying fails. + This is intended to avoid an accidental configuration where two proxies + keep connecting to each others, both thinking the other one is supposed to + handle the user. This only works if both proxies support the Dovecot + TTL extension feature. */ +#define LOGIN_PROXY_TTL 5 + struct client; struct login_proxy; diff -r f534ed81bce4 -r ba06ea38c722 src/pop3-login/client.c --- a/src/pop3-login/client.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/pop3-login/client.c Sat Feb 25 06:54:52 2012 +0200 @@ -56,6 +56,9 @@ args_ok = FALSE; else client->common.remote_port = remote_port; + } else if (strncasecmp(*tmp, "TTL=", 4) == 0) { + if (str_to_uint(*tmp + 4, &client->common.proxy_ttl) < 0) + args_ok = FALSE; } } if (!args_ok) { diff -r f534ed81bce4 -r ba06ea38c722 src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/pop3-login/pop3-proxy.c Sat Feb 25 06:54:52 2012 +0200 @@ -37,12 +37,14 @@ { string_t *str; + i_assert(client->common.proxy_ttl > 0); if (client->proxy_xclient) { /* remote supports XCLIENT, send it */ (void)o_stream_send_str(output, t_strdup_printf( - "XCLIENT ADDR=%s PORT=%u\r\n", + "XCLIENT ADDR=%s PORT=%u TTL=%u\r\n", net_ip2addr(&client->common.ip), - client->common.remote_port)); + client->common.remote_port, + client->common.proxy_ttl - 1)); client->common.proxy_state = POP3_PROXY_XCLIENT; } else { client->common.proxy_state = POP3_PROXY_LOGIN1; From dovecot at dovecot.org Sat Feb 25 07:08:37 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 07:08:37 +0200 Subject: dovecot-2.2: auth: Added proxy_always extra field. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/716769cfbb1d changeset: 14163:716769cfbb1d user: Timo Sirainen date: Sat Feb 25 07:08:27 2012 +0200 description: auth: Added proxy_always extra field. When used with proxy_maybe, it can be used to redirect "local" users to local backends via director. diffstat: src/auth/auth-request.c | 11 +++++++++++ src/auth/auth-request.h | 1 + 2 files changed, 12 insertions(+), 0 deletions(-) diffs (39 lines): diff -r ba06ea38c722 -r 716769cfbb1d src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 06:54:52 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 07:08:27 2012 +0200 @@ -1148,6 +1148,12 @@ password back if using plaintext authentication. */ request->proxy = TRUE; value = NULL; + } else if (strcmp(name, "proxy_always") == 0) { + /* when proxy_maybe=yes and proxying wouldn't normally be done, + with this enabled proxy=y is still returned without host. + this can be used to make director set the host. */ + request->proxy_always = TRUE; + value = NULL; } else if (strcmp(name, "proxy_maybe") == 0) { /* like "proxy", but log in normally if we're proxying to ourself */ @@ -1466,6 +1472,11 @@ /* proxying to ourself - log in without proxying by dropping all the proxying fields. */ auth_request_proxy_finish_failure(request); + if (request->proxy_always) { + /* director adds the host */ + auth_stream_reply_add(request->extra_fields, + "proxy", NULL); + } } } diff -r ba06ea38c722 -r 716769cfbb1d src/auth/auth-request.h --- a/src/auth/auth-request.h Sat Feb 25 06:54:52 2012 +0200 +++ b/src/auth/auth-request.h Sat Feb 25 07:08:27 2012 +0200 @@ -105,6 +105,7 @@ unsigned int prefer_plain_credentials:1; unsigned int proxy:1; unsigned int proxy_maybe:1; + unsigned int proxy_always:1; unsigned int proxy_host_is_self:1; unsigned int valid_client_cert:1; unsigned int no_penalty:1; From dovecot at dovecot.org Sat Feb 25 07:08:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 07:08:47 +0200 Subject: dovecot-2.1: auth: Added proxy_always extra field. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/4bd9cadae9ea changeset: 14196:4bd9cadae9ea user: Timo Sirainen date: Sat Feb 25 07:08:27 2012 +0200 description: auth: Added proxy_always extra field. When used with proxy_maybe, it can be used to redirect "local" users to local backends via director. diffstat: src/auth/auth-request.c | 11 +++++++++++ src/auth/auth-request.h | 1 + 2 files changed, 12 insertions(+), 0 deletions(-) diffs (39 lines): diff -r cf713cf9b7c0 -r 4bd9cadae9ea src/auth/auth-request.c --- a/src/auth/auth-request.c Sat Feb 25 06:41:59 2012 +0200 +++ b/src/auth/auth-request.c Sat Feb 25 07:08:27 2012 +0200 @@ -1148,6 +1148,12 @@ password back if using plaintext authentication. */ request->proxy = TRUE; value = NULL; + } else if (strcmp(name, "proxy_always") == 0) { + /* when proxy_maybe=yes and proxying wouldn't normally be done, + with this enabled proxy=y is still returned without host. + this can be used to make director set the host. */ + request->proxy_always = TRUE; + value = NULL; } else if (strcmp(name, "proxy_maybe") == 0) { /* like "proxy", but log in normally if we're proxying to ourself */ @@ -1466,6 +1472,11 @@ /* proxying to ourself - log in without proxying by dropping all the proxying fields. */ auth_request_proxy_finish_failure(request); + if (request->proxy_always) { + /* director adds the host */ + auth_stream_reply_add(request->extra_fields, + "proxy", NULL); + } } } diff -r cf713cf9b7c0 -r 4bd9cadae9ea src/auth/auth-request.h --- a/src/auth/auth-request.h Sat Feb 25 06:41:59 2012 +0200 +++ b/src/auth/auth-request.h Sat Feb 25 07:08:27 2012 +0200 @@ -105,6 +105,7 @@ unsigned int prefer_plain_credentials:1; unsigned int proxy:1; unsigned int proxy_maybe:1; + unsigned int proxy_always:1; unsigned int proxy_host_is_self:1; unsigned int valid_client_cert:1; unsigned int no_penalty:1; From dovecot at dovecot.org Sat Feb 25 07:08:47 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 07:08:47 +0200 Subject: dovecot-2.1: pop3 proxy: Fixed previous change not to hang. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/cf713cf9b7c0 changeset: 14195:cf713cf9b7c0 user: Timo Sirainen date: Sat Feb 25 06:41:59 2012 +0200 description: pop3 proxy: Fixed previous change not to hang. diffstat: src/pop3-login/pop3-proxy.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r ef7518f0bdbc -r cf713cf9b7c0 src/pop3-login/pop3-proxy.c --- a/src/pop3-login/pop3-proxy.c Sat Feb 25 06:39:00 2012 +0200 +++ b/src/pop3-login/pop3-proxy.c Sat Feb 25 06:41:59 2012 +0200 @@ -117,7 +117,7 @@ return -1; } client->proxy_state = POP3_PROXY_LOGIN1; - return 1; + return 0; case POP3_PROXY_LOGIN1: str = t_str_new(128); if (client->proxy_master_user == NULL) { From dovecot at dovecot.org Sat Feb 25 07:29:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 07:29:32 +0200 Subject: dovecot-2.0: imap-login: imap_id_* settings were ignored pre-login. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/b7e5a83866a4 changeset: 13061:b7e5a83866a4 user: Timo Sirainen date: Sat Feb 25 07:29:15 2012 +0200 description: imap-login: imap_id_* settings were ignored pre-login. diffstat: src/imap-login/client.c | 9 ++++----- src/imap-login/imap-login-settings.c | 6 +++++- src/imap-login/imap-login-settings.h | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diffs (65 lines): diff -r f2e9b20e21f8 -r b7e5a83866a4 src/imap-login/client.c --- a/src/imap-login/client.c Tue Feb 21 15:21:19 2012 +0200 +++ b/src/imap-login/client.c Sat Feb 25 07:29:15 2012 +0200 @@ -129,24 +129,23 @@ static int cmd_id(struct imap_client *client, const struct imap_arg *args) { - const char *env, *value; + const char *value; if (!client->id_logged) { client->id_logged = TRUE; if (client->common.trusted) client_update_info(client, args); - env = getenv("IMAP_ID_LOG"); - value = imap_id_args_get_log_reply(args, env); + value = imap_id_args_get_log_reply(args, client->set->imap_id_log); if (value != NULL) { client_log(&client->common, t_strdup_printf("ID sent: %s", value)); } } - env = getenv("IMAP_ID_SEND"); client_send_raw(&client->common, - t_strdup_printf("* ID %s\r\n", imap_id_reply_generate(env))); + t_strdup_printf("* ID %s\r\n", + imap_id_reply_generate(client->set->imap_id_send))); client_send_line(&client->common, CLIENT_CMD_REPLY_OK, "ID completed."); return 1; } diff -r f2e9b20e21f8 -r b7e5a83866a4 src/imap-login/imap-login-settings.c --- a/src/imap-login/imap-login-settings.c Tue Feb 21 15:21:19 2012 +0200 +++ b/src/imap-login/imap-login-settings.c Sat Feb 25 07:29:15 2012 +0200 @@ -55,12 +55,16 @@ static const struct setting_define imap_login_setting_defines[] = { DEF(SET_STR, imap_capability), + DEF(SET_STR, imap_id_send), + DEF(SET_STR, imap_id_log), SETTING_DEFINE_LIST_END }; static const struct imap_login_settings imap_login_default_settings = { - .imap_capability = "" + .imap_capability = "", + .imap_id_send = "", + .imap_id_log = "" }; static const struct setting_parser_info *imap_login_setting_dependencies[] = { diff -r f2e9b20e21f8 -r b7e5a83866a4 src/imap-login/imap-login-settings.h --- a/src/imap-login/imap-login-settings.h Tue Feb 21 15:21:19 2012 +0200 +++ b/src/imap-login/imap-login-settings.h Sat Feb 25 07:29:15 2012 +0200 @@ -3,6 +3,8 @@ struct imap_login_settings { const char *imap_capability; + const char *imap_id_send; + const char *imap_id_log; }; extern const struct setting_parser_info *imap_login_setting_roots[]; From dovecot at dovecot.org Sat Feb 25 07:29:41 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sat, 25 Feb 2012 07:29:41 +0200 Subject: dovecot-2.1: imap-login: imap_id_* settings were ignored pre-login. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/32ffa616f249 changeset: 14197:32ffa616f249 user: Timo Sirainen date: Sat Feb 25 07:29:15 2012 +0200 description: imap-login: imap_id_* settings were ignored pre-login. diffstat: src/imap-login/client.c | 9 ++++----- src/imap-login/imap-login-settings.c | 6 +++++- src/imap-login/imap-login-settings.h | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diffs (65 lines): diff -r 4bd9cadae9ea -r 32ffa616f249 src/imap-login/client.c --- a/src/imap-login/client.c Sat Feb 25 07:08:27 2012 +0200 +++ b/src/imap-login/client.c Sat Feb 25 07:29:15 2012 +0200 @@ -117,24 +117,23 @@ static int cmd_id(struct imap_client *client, const struct imap_arg *args) { - const char *env, *value; + const char *value; if (!client->id_logged) { client->id_logged = TRUE; if (client->common.trusted) client_update_info(client, args); - env = getenv("IMAP_ID_LOG"); - value = imap_id_args_get_log_reply(args, env); + value = imap_id_args_get_log_reply(args, client->set->imap_id_log); if (value != NULL) { client_log(&client->common, t_strdup_printf("ID sent: %s", value)); } } - env = getenv("IMAP_ID_SEND"); client_send_raw(&client->common, - t_strdup_printf("* ID %s\r\n", imap_id_reply_generate(env))); + t_strdup_printf("* ID %s\r\n", + imap_id_reply_generate(client->set->imap_id_send))); client_send_line(&client->common, CLIENT_CMD_REPLY_OK, "ID completed."); return 1; } diff -r 4bd9cadae9ea -r 32ffa616f249 src/imap-login/imap-login-settings.c --- a/src/imap-login/imap-login-settings.c Sat Feb 25 07:08:27 2012 +0200 +++ b/src/imap-login/imap-login-settings.c Sat Feb 25 07:29:15 2012 +0200 @@ -55,12 +55,16 @@ static const struct setting_define imap_login_setting_defines[] = { DEF(SET_STR, imap_capability), + DEF(SET_STR, imap_id_send), + DEF(SET_STR, imap_id_log), SETTING_DEFINE_LIST_END }; static const struct imap_login_settings imap_login_default_settings = { - .imap_capability = "" + .imap_capability = "", + .imap_id_send = "", + .imap_id_log = "" }; static const struct setting_parser_info *imap_login_setting_dependencies[] = { diff -r 4bd9cadae9ea -r 32ffa616f249 src/imap-login/imap-login-settings.h --- a/src/imap-login/imap-login-settings.h Sat Feb 25 07:08:27 2012 +0200 +++ b/src/imap-login/imap-login-settings.h Sat Feb 25 07:29:15 2012 +0200 @@ -3,6 +3,8 @@ struct imap_login_settings { const char *imap_capability; + const char *imap_id_send; + const char *imap_id_log; }; extern const struct setting_parser_info *imap_login_setting_roots[]; From dovecot at dovecot.org Sun Feb 26 04:59:58 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Sun, 26 Feb 2012 04:59:58 +0200 Subject: dovecot-2.2: lib-storage: Removed min_timeout parameter from mai... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/5e4e6c57c142 changeset: 14218:5e4e6c57c142 user: Timo Sirainen date: Sun Feb 26 04:59:36 2012 +0200 description: lib-storage: Removed min_timeout parameter from mailbox_notify_changes() It's now internally taken from mailbox_idle_check_interval setting. diffstat: src/imap/cmd-idle.c | 10 ++-------- src/lib-storage/index/imapc/imapc-storage.c | 5 +++-- src/lib-storage/index/index-mailbox-check.c | 5 +++-- src/lib-storage/mail-storage-private.h | 1 - src/lib-storage/mail-storage.c | 5 ++--- src/lib-storage/mail-storage.h | 10 +++++----- src/plugins/virtual/virtual-storage.c | 6 ++---- 7 files changed, 17 insertions(+), 25 deletions(-) diffs (148 lines): diff -r 36fc5b533562 -r 5e4e6c57c142 src/imap/cmd-idle.c --- a/src/imap/cmd-idle.c Sat Feb 25 07:36:11 2012 +0200 +++ b/src/imap/cmd-idle.c Sun Feb 26 04:59:36 2012 +0200 @@ -253,14 +253,8 @@ ctx->client = client; idle_add_keepalive_timeout(ctx); - if (client->mailbox != NULL) { - const struct mail_storage_settings *set; - - set = mailbox_get_settings(client->mailbox); - mailbox_notify_changes(client->mailbox, - set->mailbox_idle_check_interval, - idle_callback, ctx); - } + if (client->mailbox != NULL) + mailbox_notify_changes(client->mailbox, idle_callback, ctx); client_send_line(client, "+ idling"); io_remove(&client->io); diff -r 36fc5b533562 -r 5e4e6c57c142 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Sat Feb 25 07:36:11 2012 +0200 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sun Feb 26 04:59:36 2012 +0200 @@ -705,10 +705,11 @@ static void imapc_notify_changes(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; + const struct mail_storage_settings *set = box->storage->set; struct imapc_command *cmd; enum imapc_capability capa; - if (box->notify_min_interval == 0) { + if (box->notify_callback == NULL) { if (mbox->to_idle_check != NULL) timeout_remove(&mbox->to_idle_check); return; @@ -728,7 +729,7 @@ check for changes with NOOP every once in a while. */ i_assert(!imapc_client_is_running(mbox->storage->client)); mbox->to_idle_check = - timeout_add(box->notify_min_interval * 1000, + timeout_add(set->mailbox_idle_check_interval * 1000, imapc_idle_timeout, mbox); } } diff -r 36fc5b533562 -r 5e4e6c57c142 src/lib-storage/index/index-mailbox-check.c --- a/src/lib-storage/index/index-mailbox-check.c Sat Feb 25 07:36:11 2012 +0200 +++ b/src/lib-storage/index/index-mailbox-check.c Sun Feb 26 04:59:36 2012 +0200 @@ -67,12 +67,13 @@ void index_mailbox_check_add(struct mailbox *box, const char *path) { struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box); + const struct mail_storage_settings *set = box->storage->set; struct index_notify_file *file; struct stat st; struct io *io = NULL; struct index_notify_io *aio; - i_assert(box->notify_min_interval > 0); + i_assert(set->mailbox_idle_check_interval > 0); (void)io_add_notify(path, notify_callback, box, &io); if (io != NULL) { @@ -94,7 +95,7 @@ * when the filesystem is remote (NFS, ...) */ if (ibox->notify_to == NULL) { ibox->notify_to = - timeout_add(box->notify_min_interval * 1000, + timeout_add(set->mailbox_idle_check_interval * 1000, check_timeout, box); } } diff -r 36fc5b533562 -r 5e4e6c57c142 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Sat Feb 25 07:36:11 2012 +0200 +++ b/src/lib-storage/mail-storage-private.h Sun Feb 26 04:59:36 2012 +0200 @@ -241,7 +241,6 @@ enum mailbox_feature enabled_features; /* Mailbox notification settings: */ - unsigned int notify_min_interval; mailbox_notify_callback_t *notify_callback; void *notify_context; diff -r 36fc5b533562 -r 5e4e6c57c142 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sat Feb 25 07:36:11 2012 +0200 +++ b/src/lib-storage/mail-storage.c Sun Feb 26 04:59:36 2012 +0200 @@ -1343,10 +1343,9 @@ } #undef mailbox_notify_changes -void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval, +void mailbox_notify_changes(struct mailbox *box, mailbox_notify_callback_t *callback, void *context) { - box->notify_min_interval = min_interval; box->notify_callback = callback; box->notify_context = context; @@ -1355,7 +1354,7 @@ void mailbox_notify_changes_stop(struct mailbox *box) { - mailbox_notify_changes(box, 0, NULL, NULL); + mailbox_notify_changes(box, NULL, NULL); } struct mail_search_context * diff -r 36fc5b533562 -r 5e4e6c57c142 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Sat Feb 25 07:36:11 2012 +0200 +++ b/src/lib-storage/mail-storage.h Sun Feb 26 04:59:36 2012 +0200 @@ -485,16 +485,16 @@ int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags); /* Call given callback function when something changes in the mailbox. */ -void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval, +void mailbox_notify_changes(struct mailbox *box, mailbox_notify_callback_t *callback, void *context); #ifdef CONTEXT_TYPE_SAFETY -# define mailbox_notify_changes(box, min_interval, callback, context) \ +# define mailbox_notify_changes(box, callback, context) \ ({(void)(1 ? 0 : callback((struct mailbox *)NULL, context)); \ - mailbox_notify_changes(box, min_interval, \ + mailbox_notify_changes(box, \ (mailbox_notify_callback_t *)callback, context); }) #else -# define mailbox_notify_changes(box, min_interval, callback, context) \ - mailbox_notify_changes(box, min_interval, \ +# define mailbox_notify_changes(box, callback, context) \ + mailbox_notify_changes(box, \ (mailbox_notify_callback_t *)callback, context) #endif void mailbox_notify_changes_stop(struct mailbox *box); diff -r 36fc5b533562 -r 5e4e6c57c142 src/plugins/virtual/virtual-storage.c --- a/src/plugins/virtual/virtual-storage.c Sat Feb 25 07:36:11 2012 +0200 +++ b/src/plugins/virtual/virtual-storage.c Sun Feb 26 04:59:36 2012 +0200 @@ -391,10 +391,8 @@ if (box->notify_callback == NULL) mailbox_notify_changes_stop(bbox); - else { - mailbox_notify_changes(bbox, box->notify_min_interval, - virtual_notify_callback, box); - } + else + mailbox_notify_changes(bbox, virtual_notify_callback, box); } } From dovecot at dovecot.org Mon Feb 27 10:32:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 10:32:14 +0200 Subject: dovecot-2.2: imap: Made client_destroy() a virtual method. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e20af99c6d20 changeset: 14219:e20af99c6d20 user: Timo Sirainen date: Mon Feb 27 10:30:57 2012 +0200 description: imap: Made client_destroy() a virtual method. diffstat: src/imap/imap-client.c | 12 ++++++++++++ src/imap/imap-client.h | 25 ++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diffs (92 lines): diff -r 5e4e6c57c142 -r e20af99c6d20 src/imap/imap-client.c --- a/src/imap/imap-client.c Sun Feb 26 04:59:36 2012 +0200 +++ b/src/imap/imap-client.c Mon Feb 27 10:30:57 2012 +0200 @@ -20,6 +20,8 @@ #include extern struct mail_storage_callbacks mail_storage_callbacks; +extern struct imap_client_vfuncs imap_client_vfuncs; + struct imap_module_register imap_module_register = { 0 }; struct client *imap_clients = NULL; @@ -47,6 +49,7 @@ pool = pool_alloconly_create("imap client", 2048); client = p_new(pool, struct client, 1); client->pool = pool; + client->v = imap_client_vfuncs; client->set = set; client->service_user = service_user; client->fd_in = fd_in; @@ -165,6 +168,11 @@ void client_destroy(struct client *client, const char *reason) { + client->v.destroy(client, reason); +} + +static void client_default_destroy(struct client *client, const char *reason) +{ struct client_command_context *cmd; i_assert(!client->destroyed); @@ -997,3 +1005,7 @@ client_destroy(imap_clients, "Server shutting down."); } } + +struct imap_client_vfuncs imap_client_vfuncs = { + client_default_destroy +}; diff -r 5e4e6c57c142 -r e20af99c6d20 src/imap/imap-client.h --- a/src/imap/imap-client.h Sun Feb 26 04:59:36 2012 +0200 +++ b/src/imap/imap-client.h Mon Feb 27 10:30:57 2012 +0200 @@ -44,15 +44,6 @@ CLIENT_COMMAND_STATE_DONE }; -struct imap_module_register { - unsigned int id; -}; - -union imap_module_context { - struct imap_module_register *reg; -}; -extern struct imap_module_register imap_module_register; - struct client_command_context { struct client_command_context *prev, *next; struct client *client; @@ -96,9 +87,15 @@ struct message_size pos; }; +struct imap_client_vfuncs { + void (*destroy)(struct client *client, const char *reason); +}; + struct client { struct client *prev, *next; + struct imap_client_vfuncs v; + int fd_in, fd_out; struct io *io; struct istream *input; @@ -165,6 +162,16 @@ unsigned int modseqs_sent_since_sync:1; }; +struct imap_module_register { + unsigned int id; +}; + +union imap_module_context { + struct imap_client_vfuncs super; + struct imap_module_register *reg; +}; +extern struct imap_module_register imap_module_register; + extern struct client *imap_clients; extern unsigned int imap_client_count; From dovecot at dovecot.org Mon Feb 27 10:32:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 10:32:14 +0200 Subject: dovecot-2.2: pop3: Added module contexts to struct client, and m... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/771fab474b1c changeset: 14220:771fab474b1c user: Timo Sirainen date: Mon Feb 27 10:32:03 2012 +0200 description: pop3: Added module contexts to struct client, and made client_destroy() a virtual method. diffstat: src/pop3/main.c | 11 ++++++++++- src/pop3/pop3-client.c | 22 ++++++++++++++++++++-- src/pop3/pop3-client.h | 21 +++++++++++++++++++++ src/pop3/pop3-common.h | 9 ++++++++- 4 files changed, 59 insertions(+), 4 deletions(-) diffs (169 lines): diff -r e20af99c6d20 -r 771fab474b1c src/pop3/main.c --- a/src/pop3/main.c Mon Feb 27 10:30:57 2012 +0200 +++ b/src/pop3/main.c Mon Feb 27 10:32:03 2012 +0200 @@ -29,7 +29,16 @@ static struct mail_storage_service_ctx *storage_service; static struct master_login *master_login = NULL; -void (*hook_client_created)(struct client **client) = NULL; +pop3_client_created_func_t *hook_client_created = NULL; + +pop3_client_created_func_t * +pop3_client_created_hook_set(pop3_client_created_func_t *new_hook) +{ + pop3_client_created_func_t *old_hook = hook_client_created; + + hook_client_created = new_hook; + return old_hook; +} void pop3_refresh_proctitle(void) { diff -r e20af99c6d20 -r 771fab474b1c src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Mon Feb 27 10:30:57 2012 +0200 +++ b/src/pop3/pop3-client.c Mon Feb 27 10:32:03 2012 +0200 @@ -36,6 +36,10 @@ transaction. This allows the mailbox to become unlocked. */ #define CLIENT_COMMIT_TIMEOUT_MSECS (10*1000) +extern struct pop3_client_vfuncs pop3_client_vfuncs; + +struct pop3_module_register pop3_module_register = { 0 }; + struct client *pop3_clients; unsigned int pop3_client_count; @@ -281,13 +285,17 @@ enum mailbox_flags flags; const char *errmsg; enum mail_error error; + pool_t pool; /* always use nonblocking I/O */ net_set_nonblock(fd_in, TRUE); net_set_nonblock(fd_out, TRUE); - client = i_new(struct client, 1); + pool = pool_alloconly_create("pop3 client", 256); + client = p_new(pool, struct client, 1); + client->pool = pool; client->service_user = service_user; + client->v = pop3_client_vfuncs; client->set = set; client->fd_in = fd_in; client->fd_out = fd_out; @@ -295,6 +303,7 @@ client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE); o_stream_set_flush_callback(client->output, client_output, client); + p_array_init(&client->module_contexts, client->pool, 5); client->io = io_add(fd_in, IO_READ, client_input, client); client->last_input = ioloop_time; client->to_idle = timeout_add(CLIENT_IDLE_TIMEOUT_MSECS, @@ -458,6 +467,11 @@ void client_destroy(struct client *client, const char *reason) { + client->v.destroy(client, reason); +} + +static void client_default_destroy(struct client *client, const char *reason) +{ if (client->seen_change_count > 0) client_update_mails(client); @@ -512,7 +526,7 @@ if (client->fd_in != client->fd_out) net_disconnect(client->fd_out); mail_storage_service_user_free(&client->service_user); - i_free(client); + pool_unref(&client->pool); master_service_client_connection_destroyed(master_service); pop3_refresh_proctitle(); @@ -722,3 +736,7 @@ client_destroy(pop3_clients, "Server shutting down."); } } + +struct pop3_client_vfuncs pop3_client_vfuncs = { + client_default_destroy +}; diff -r e20af99c6d20 -r 771fab474b1c src/pop3/pop3-client.h --- a/src/pop3/pop3-client.h Mon Feb 27 10:30:57 2012 +0200 +++ b/src/pop3/pop3-client.h Mon Feb 27 10:32:03 2012 +0200 @@ -9,6 +9,11 @@ #define MSGS_BITMASK_SIZE(client) \ (((client)->messages_count + (CHAR_BIT-1)) / CHAR_BIT) +struct pop3_client_vfuncs { + void (*destroy)(struct client *client, const char *reason); + +}; + /* pop3_msn = 1..n in the POP3 protocol msgnum = 0..n-1 = pop3_msn-1 @@ -18,6 +23,8 @@ struct client { struct client *prev, *next; + struct pop3_client_vfuncs v; + int fd_in, fd_out; struct io *io; struct istream *input; @@ -27,6 +34,7 @@ command_func_t *cmd; void *cmd_context; + pool_t pool; struct mail_storage_service_user *service_user; struct mail_user *user; struct mail_namespace *inbox_ns; @@ -65,6 +73,9 @@ const struct mail_storage_settings *mail_set; enum uidl_keys uidl_keymask; + /* Module-specific contexts. */ + ARRAY_DEFINE(module_contexts, union pop3_module_context *); + unsigned int disconnected:1; unsigned int deleted:1; unsigned int waiting_input:1; @@ -72,6 +83,16 @@ unsigned int message_uidl_hashes_save:1; }; +struct pop3_module_register { + unsigned int id; +}; + +union pop3_module_context { + struct pop3_client_vfuncs super; + struct pop3_module_register *reg; +}; +extern struct pop3_module_register pop3_module_register; + extern struct client *pop3_clients; extern unsigned int pop3_client_count; diff -r e20af99c6d20 -r 771fab474b1c src/pop3/pop3-common.h --- a/src/pop3/pop3-common.h Mon Feb 27 10:30:57 2012 +0200 +++ b/src/pop3/pop3-common.h Mon Feb 27 10:32:03 2012 +0200 @@ -13,7 +13,14 @@ #include "pop3-client.h" #include "pop3-settings.h" -extern void (*hook_client_created)(struct client **client); +typedef void pop3_client_created_func_t(struct client **client); + +extern pop3_client_created_func_t *hook_client_created; + +/* Sets the hook_client_created and returns the previous hook, + which the new_hook should call if it's non-NULL. */ +pop3_client_created_func_t * +pop3_client_created_hook_set(pop3_client_created_func_t *new_hook); void pop3_refresh_proctitle(void); From dovecot at dovecot.org Mon Feb 27 10:36:14 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 10:36:14 +0200 Subject: dovecot-2.2: Minor code cleanup. Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/31119136ee6e changeset: 14221:31119136ee6e user: Timo Sirainen date: Mon Feb 27 10:36:09 2012 +0200 description: Minor code cleanup. diffstat: src/plugins/imap-acl/imap-acl-plugin.c | 2 +- src/plugins/imap-quota/imap-quota-plugin.c | 2 +- src/plugins/imap-zlib/imap-zlib-plugin.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diffs (36 lines): diff -r 771fab474b1c -r 31119136ee6e src/plugins/imap-acl/imap-acl-plugin.c --- a/src/plugins/imap-acl/imap-acl-plugin.c Mon Feb 27 10:32:03 2012 +0200 +++ b/src/plugins/imap-acl/imap-acl-plugin.c Mon Feb 27 10:36:09 2012 +0200 @@ -47,7 +47,7 @@ const char *imap_acl_plugin_version = DOVECOT_VERSION; static struct module *imap_acl_module; -static void (*next_hook_client_created)(struct client **client); +static imap_client_created_func_t *next_hook_client_created; static struct mailbox * acl_mailbox_open_as_admin(struct client_command_context *cmd, const char *name) diff -r 771fab474b1c -r 31119136ee6e src/plugins/imap-quota/imap-quota-plugin.c --- a/src/plugins/imap-quota/imap-quota-plugin.c Mon Feb 27 10:32:03 2012 +0200 +++ b/src/plugins/imap-quota/imap-quota-plugin.c Mon Feb 27 10:36:09 2012 +0200 @@ -17,7 +17,7 @@ const char *imap_quota_plugin_version = DOVECOT_VERSION; static struct module *imap_quota_module; -static void (*next_hook_client_created)(struct client **client); +static imap_client_created_func_t *next_hook_client_created; static const char * imap_quota_root_get_name(struct mail_user *user, struct mail_user *owner, diff -r 771fab474b1c -r 31119136ee6e src/plugins/imap-zlib/imap-zlib-plugin.c --- a/src/plugins/imap-zlib/imap-zlib-plugin.c Mon Feb 27 10:32:03 2012 +0200 +++ b/src/plugins/imap-zlib/imap-zlib-plugin.c Mon Feb 27 10:36:09 2012 +0200 @@ -25,7 +25,7 @@ const char *imap_zlib_plugin_version = DOVECOT_VERSION; static struct module *imap_zlib_module; -static void (*next_hook_client_created)(struct client **client); +static imap_client_created_func_t *next_hook_client_created; static MODULE_CONTEXT_DEFINE_INIT(imap_zlib_imap_module, &imap_module_register); From dovecot at dovecot.org Mon Feb 27 11:34:05 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 11:34:05 +0200 Subject: dovecot-2.2: lib-dns: dns_lookup() returns now the lookup struct... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/f5aa38f0a9ac changeset: 14222:f5aa38f0a9ac user: Timo Sirainen date: Mon Feb 27 11:33:34 2012 +0200 description: lib-dns: dns_lookup() returns now the lookup struct, and it can be aborted. Changed all dns_lookup() users also to abort the lookup when needed (previously it probably would have just accessed freed memory and crash). diffstat: src/auth/auth-request.c | 25 +++++++++++++++---------- src/auth/auth-request.h | 1 + src/lib-dns/dns-lookup.c | 8 ++++++++ src/lib-dns/dns-lookup.h | 13 +++++++++++-- src/lib-imap-client/imapc-connection.c | 10 +++++++--- src/lib-lda/lmtp-client.c | 8 +++++++- src/lib-storage/index/pop3c/pop3c-client.c | 14 ++++++++++---- 7 files changed, 59 insertions(+), 20 deletions(-) diffs (279 lines): diff -r 31119136ee6e -r f5aa38f0a9ac src/auth/auth-request.c --- a/src/auth/auth-request.c Mon Feb 27 10:36:09 2012 +0200 +++ b/src/auth/auth-request.c Mon Feb 27 11:33:34 2012 +0200 @@ -33,6 +33,12 @@ #define AUTH_DNS_WARN_MSECS 500 #define CACHED_PASSWORD_SCHEME "SHA1" +struct auth_request_proxy_dns_lookup_ctx { + struct auth_request *request; + auth_request_proxy_cb_t *callback; + struct dns_lookup *dns_lookup; +}; + unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX]; static void get_log_prefix(string_t *str, struct auth_request *auth_request, @@ -167,6 +173,8 @@ strlen(request->mech_password)); } + if (request->dns_lookup_ctx != NULL) + dns_lookup_abort(&request->dns_lookup_ctx->dns_lookup); if (request->to_abort != NULL) timeout_remove(&request->to_abort); if (request->to_penalty != NULL) @@ -1480,20 +1488,17 @@ } } -struct auth_request_proxy_dns_lookup_ctx { - struct auth_request *request; - auth_request_proxy_cb_t *callback; -}; - static void auth_request_proxy_dns_callback(const struct dns_lookup_result *result, - void *context) + struct auth_request_proxy_dns_lookup_ctx *ctx) { - struct auth_request_proxy_dns_lookup_ctx *ctx = context; struct auth_request *request = ctx->request; const char *host; unsigned int i; + request->dns_lookup_ctx = NULL; + ctx->dns_lookup = NULL; + host = auth_stream_reply_find(request->extra_fields, "host"); i_assert(host != NULL); @@ -1522,7 +1527,6 @@ } if (ctx->callback != NULL) ctx->callback(result->ret == 0, request); - i_free(ctx); } static int auth_request_proxy_host_lookup(struct auth_request *request, @@ -1557,10 +1561,11 @@ } } - ctx = i_new(struct auth_request_proxy_dns_lookup_ctx, 1); + ctx = p_new(request->pool, struct auth_request_proxy_dns_lookup_ctx, 1); ctx->request = request; - if (dns_lookup(host, &dns_set, auth_request_proxy_dns_callback, ctx) < 0) { + if (dns_lookup(host, &dns_set, auth_request_proxy_dns_callback, ctx, + &ctx->dns_lookup) < 0) { /* failed early */ request->internal_failure = TRUE; auth_request_proxy_finish_failure(request); diff -r 31119136ee6e -r f5aa38f0a9ac src/auth/auth-request.h --- a/src/auth/auth-request.h Mon Feb 27 10:36:09 2012 +0200 +++ b/src/auth/auth-request.h Mon Feb 27 11:33:34 2012 +0200 @@ -55,6 +55,7 @@ struct auth_stream_reply *extra_cache_fields; /* the whole userdb result reply */ struct auth_stream_reply *userdb_reply; + struct auth_request_proxy_dns_lookup_ctx *dns_lookup_ctx; const struct mech_module *mech; const struct auth_settings *set; diff -r 31119136ee6e -r f5aa38f0a9ac src/lib-dns/dns-lookup.c --- a/src/lib-dns/dns-lookup.c Mon Feb 27 10:36:09 2012 +0200 +++ b/src/lib-dns/dns-lookup.c Mon Feb 27 11:33:34 2012 +0200 @@ -121,6 +121,7 @@ #undef dns_lookup int dns_lookup(const char *host, const struct dns_lookup_settings *set, + struct dns_lookup **lookup_r, dns_lookup_callback_t *callback, void *context) { struct dns_lookup *lookup; @@ -162,6 +163,8 @@ lookup->context = context; if (gettimeofday(&lookup->start_time, NULL) < 0) i_fatal("gettimeofday() failed: %m"); + + *lookup_r = lookup; return 0; } @@ -182,3 +185,8 @@ i_free(lookup->path); i_free(lookup); } + +void dns_lookup_abort(struct dns_lookup **lookup) +{ + dns_lookup_free(lookup); +} diff -r 31119136ee6e -r f5aa38f0a9ac src/lib-dns/dns-lookup.h --- a/src/lib-dns/dns-lookup.h Mon Feb 27 10:36:09 2012 +0200 +++ b/src/lib-dns/dns-lookup.h Mon Feb 27 11:33:34 2012 +0200 @@ -1,6 +1,8 @@ #ifndef DNS_LOOKUP_H #define DNS_LOOKUP_H +struct dns_lookup; + struct dns_lookup_settings { const char *dns_client_socket_path; unsigned int timeout_msecs; @@ -22,11 +24,18 @@ typedef void dns_lookup_callback_t(const struct dns_lookup_result *result, void *context); +/* Do asynchronous DNS lookup via dns-client UNIX socket. Returns 0 if lookup + started, -1 if there was an error communicating with the UNIX socket. + When failing with -1, the callback is called before returning from the + function. */ int dns_lookup(const char *host, const struct dns_lookup_settings *set, + struct dns_lookup **lookup_r, dns_lookup_callback_t *callback, void *context); -#define dns_lookup(host, set, callback, context) \ +#define dns_lookup(host, set, callback, context, lookup_r) \ CONTEXT_CALLBACK2(dns_lookup, dns_lookup_callback_t, \ callback, const struct dns_lookup_result *, \ - context, host, set) + context, host, set, lookup_r) +/* Abort the DNS lookup without calling the callback. */ +void dns_lookup_abort(struct dns_lookup **lookup); #endif diff -r 31119136ee6e -r f5aa38f0a9ac src/lib-imap-client/imapc-connection.c --- a/src/lib-imap-client/imapc-connection.c Mon Feb 27 10:36:09 2012 +0200 +++ b/src/lib-imap-client/imapc-connection.c Mon Feb 27 11:33:34 2012 +0200 @@ -86,6 +86,7 @@ struct imap_parser *parser; struct timeout *to; struct timeout *to_output; + struct dns_lookup *dns_lookup; struct ssl_iostream *ssl_iostream; @@ -352,6 +353,8 @@ if (conn->client->set.debug) i_debug("imapc(%s): Disconnected", conn->name); + if (conn->dns_lookup != NULL) + dns_lookup_abort(&conn->dns_lookup); imapc_connection_lfiles_free(conn); imapc_connection_literal_reset(&conn->literal); if (conn->to != NULL) @@ -1315,9 +1318,9 @@ static void imapc_connection_dns_callback(const struct dns_lookup_result *result, - void *context) + struct imapc_connection *conn) { - struct imapc_connection *conn = context; + conn->dns_lookup = NULL; if (result->ret != 0) { i_error("imapc(%s): dns_lookup(%s) failed: %s", @@ -1385,7 +1388,8 @@ if (conn->ips_count == 0) { (void)dns_lookup(conn->client->set.host, &dns_set, - imapc_connection_dns_callback, conn); + imapc_connection_dns_callback, conn, + &conn->dns_lookup); } else { imapc_connection_connect_next_ip(conn); } diff -r 31119136ee6e -r f5aa38f0a9ac src/lib-lda/lmtp-client.c --- a/src/lib-lda/lmtp-client.c Mon Feb 27 10:36:09 2012 +0200 +++ b/src/lib-lda/lmtp-client.c Mon Feb 27 11:33:34 2012 +0200 @@ -49,6 +49,7 @@ string_t *input_multiline; const char **xclient_args; + struct dns_lookup *dns_lookup; struct istream *input; struct ostream *output; struct io *io; @@ -107,6 +108,8 @@ void lmtp_client_close(struct lmtp_client *client) { + if (client->dns_lookup != NULL) + dns_lookup_abort(&client->dns_lookup); if (client->io != NULL) io_remove(&client->io); if (client->input != NULL) @@ -600,6 +603,8 @@ static void lmtp_client_dns_done(const struct dns_lookup_result *result, struct lmtp_client *client) { + client->dns_lookup = NULL; + if (result->ret != 0) { i_error("lmtp client: DNS lookup of %s failed: %s", client->host, result->error); @@ -651,7 +656,8 @@ client->ip = ips[0]; } else { if (dns_lookup(host, &dns_lookup_set, - lmtp_client_dns_done, client) < 0) + lmtp_client_dns_done, client, + &client->dns_lookup) < 0) return -1; return 0; } diff -r 31119136ee6e -r f5aa38f0a9ac src/lib-storage/index/pop3c/pop3c-client.c --- a/src/lib-storage/index/pop3c/pop3c-client.c Mon Feb 27 10:36:09 2012 +0200 +++ b/src/lib-storage/index/pop3c/pop3c-client.c Mon Feb 27 11:33:34 2012 +0200 @@ -50,6 +50,7 @@ struct ostream *output, *raw_output; struct ssl_iostream *ssl_iostream; struct timeout *to; + struct dns_lookup *dns_lookup; enum pop3c_client_state state; enum pop3c_capability capabilities; @@ -66,7 +67,8 @@ }; static void -pop3c_dns_callback(const struct dns_lookup_result *result, void *context); +pop3c_dns_callback(const struct dns_lookup_result *result, + struct pop3c_client *client); struct pop3c_client * pop3c_client_init(const struct pop3c_client_settings *set) @@ -134,6 +136,8 @@ if (client->running) io_loop_stop(current_ioloop); + if (client->dns_lookup != NULL) + dns_lookup_abort(&client->dns_lookup); if (client->to != NULL) timeout_remove(&client->to); if (client->io != NULL) @@ -215,7 +219,8 @@ client->set.dns_client_socket_path; dns_set.timeout_msecs = POP3C_DNS_LOOKUP_TIMEOUT_MSECS; (void)dns_lookup(client->set.host, &dns_set, - pop3c_dns_callback, client); + pop3c_dns_callback, client, + &client->dns_lookup); } else if (client->to == NULL) { client->to = timeout_add(POP3C_COMMAND_TIMEOUT_MSECS, pop3c_client_timeout, client); @@ -542,9 +547,10 @@ } static void -pop3c_dns_callback(const struct dns_lookup_result *result, void *context) +pop3c_dns_callback(const struct dns_lookup_result *result, + struct pop3c_client *client) { - struct pop3c_client *client = context; + client->dns_lookup = NULL; if (result->ret != 0) { i_error("pop3c(%s): dns_lookup() failed: %s", From dovecot at dovecot.org Mon Feb 27 11:37:07 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 11:37:07 +0200 Subject: dovecot-2.2: dovecot-config: moved lib-auth and LIBDOVECOT_SERVI... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/ca0ef6efe583 changeset: 14223:ca0ef6efe583 user: Timo Sirainen date: Mon Feb 27 11:37:02 2012 +0200 description: dovecot-config: moved lib-auth and LIBDOVECOT_SERVICE_INCLUDEs to LIBDOVECOT_INCLUDE diffstat: dovecot-config.in.in | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diffs (17 lines): diff -r f5aa38f0a9ac -r ca0ef6efe583 dovecot-config.in.in --- a/dovecot-config.in.in Mon Feb 27 11:33:34 2012 +0200 +++ b/dovecot-config.in.in Mon Feb 27 11:37:02 2012 +0200 @@ -15,11 +15,10 @@ LIBDOVECOT_LDA_DEPS="@LIBDOVECOT_LDA@" LIBDOVECOT_STORAGE_DEPS="@LIBDOVECOT_STORAGE@" -LIBDOVECOT_INCLUDE="-I$(incdir) -I$(incdir)/src/lib -I$(incdir)/src/lib-dict -I$(incdir)/src/lib-dns -I$(incdir)/src/lib-mail -I$(incdir)/src/lib-imap -I$(incdir)/src/lib-fs -I$(incdir)/src/lib-charset" +LIBDOVECOT_INCLUDE="-I$(incdir) -I$(incdir)/src/lib -I$(incdir)/src/lib-dict -I$(incdir)/src/lib-dns -I$(incdir)/src/lib-mail -I$(incdir)/src/lib-imap -I$(incdir)/src/lib-fs -I$(incdir)/src/lib-charset -I$(incdir)/src/lib-auth -I$(incdir)/src/lib-master -I$(incdir)/src/lib-settings" LIBDOVECOT_LDA_INCLUDE="-I$(incdir)/src/lib-lda -I$(incdir)/src/lda" -LIBDOVECOT_SERVICE_INCLUDE="-I$(incdir)/src/lib-master -I$(incdir)/src/lib-settings" LIBDOVECOT_STORAGE_INCLUDE="-I$(incdir)/src/lib-index -I$(incdir)/src/lib-storage -I$(incdir)/src/lib-storage/index -I$(incdir)/src/lib-storage/index/raw" -LIBDOVECOT_LOGIN_INCLUDE="-I$(incdir)/src/lib-auth -I$(incdir)/src/login-common" +LIBDOVECOT_LOGIN_INCLUDE="-I$(incdir)/src/login-common" LIBDOVECOT_IMAP_INCLUDE="-I$(incdir)/src/imap" LIBDOVECOT_CONFIG_INCLUDE="-I$(incdir)/src/config" From dovecot at dovecot.org Mon Feb 27 11:48:25 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 11:48:25 +0200 Subject: dovecot-2.2: auth: Removed destuser check from proxy_maybe's "se... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/93dc749e1668 changeset: 14224:93dc749e1668 user: Timo Sirainen date: Mon Feb 27 11:48:18 2012 +0200 description: auth: Removed destuser check from proxy_maybe's "self" check. diffstat: src/auth/auth-request.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diffs (37 lines): diff -r ca0ef6efe583 -r 93dc749e1668 src/auth/auth-request.c --- a/src/auth/auth-request.c Mon Feb 27 11:37:02 2012 +0200 +++ b/src/auth/auth-request.c Mon Feb 27 11:48:18 2012 +0200 @@ -1431,23 +1431,28 @@ static bool auth_request_proxy_is_self(struct auth_request *request) { - const char *const *tmp, *port = NULL, *destuser = NULL; + const char *const *tmp, *port = NULL; if (!request->proxy_host_is_self) return FALSE; + /* check if the port is the same */ tmp = auth_stream_split(request->extra_fields); for (; *tmp != NULL; tmp++) { if (strncmp(*tmp, "port=", 5) == 0) port = *tmp + 5; - else if (strncmp(*tmp, "destuser=", 9) == 0) - destuser = *tmp + 9; } if (port != NULL && !str_uint_equals(port, request->local_port)) return FALSE; - return destuser == NULL || - strcmp(destuser, request->original_username) == 0; + /* don't check destuser. in some systems destuser is intentionally + changed to proxied connections, but that shouldn't affect the + proxying decision. + + it's unlikely any systems would actually want to proxy a connection + to itself only to change the username, since it can already be done + without proxying by changing the "user" field. */ + return TRUE; } static bool From dovecot at dovecot.org Mon Feb 27 12:02:21 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 12:02:21 +0200 Subject: dovecot-2.2: lib-lda: smtp_client_open() API changed to return s... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/e915b7e734e7 changeset: 14225:e915b7e734e7 user: Timo Sirainen date: Mon Feb 27 12:02:07 2012 +0200 description: lib-lda: smtp_client_open() API changed to return struct ostream, not FILE. diffstat: src/lib-lda/smtp-client.c | 59 +++++++++++++++++++++++++++------------------- src/lib-lda/smtp-client.h | 2 +- 2 files changed, 35 insertions(+), 26 deletions(-) diffs (192 lines): diff -r 93dc749e1668 -r e915b7e734e7 src/lib-lda/smtp-client.c --- a/src/lib-lda/smtp-client.c Mon Feb 27 11:48:18 2012 +0200 +++ b/src/lib-lda/smtp-client.c Mon Feb 27 12:02:07 2012 +0200 @@ -2,11 +2,13 @@ #include "lib.h" #include "ioloop.h" +#include "buffer.h" #include "str.h" #include "close-keep-errno.h" #include "safe-mkstemp.h" #include "execv-const.h" #include "istream.h" +#include "ostream.h" #include "master-service.h" #include "lmtp-client.h" #include "lda-settings.h" @@ -20,7 +22,9 @@ #define DEFAULT_SUBMISSION_PORT 25 struct smtp_client { - FILE *f; + struct ostream *output; + buffer_t *buf; + int temp_fd; pid_t pid; bool use_smtp; @@ -33,15 +37,17 @@ char *return_path; }; -static struct smtp_client *smtp_client_devnull(FILE **file_r) +static struct smtp_client *smtp_client_devnull(struct ostream **output_r) { struct smtp_client *client; + + client = i_new(struct smtp_client, 1); + client->buf = buffer_create_dynamic(default_pool, 1); + client->output = o_stream_create_buffer(client->buf); + o_stream_close(client->output); + client->pid = (pid_t)-1; - client = i_new(struct smtp_client, 1); - client->f = *file_r = fopen("/dev/null", "w"); - if (client->f == NULL) - i_fatal("fopen() failed: %m"); - client->pid = (pid_t)-1; + *output_r = client->output; return client; } @@ -76,7 +82,7 @@ static struct smtp_client * smtp_client_open_sendmail(const struct lda_settings *set, const char *destination, const char *return_path, - FILE **file_r) + struct ostream **output_r) { struct smtp_client *client; int fd[2]; @@ -84,13 +90,13 @@ if (pipe(fd) < 0) { i_error("pipe() failed: %m"); - return smtp_client_devnull(file_r); + return smtp_client_devnull(output_r); } if ((pid = fork()) == (pid_t)-1) { i_error("fork() failed: %m"); (void)close(fd[0]); (void)close(fd[1]); - return smtp_client_devnull(file_r); + return smtp_client_devnull(output_r); } if (pid == 0) { /* child */ @@ -100,10 +106,10 @@ (void)close(fd[0]); client = i_new(struct smtp_client, 1); - client->f = *file_r = fdopen(fd[1], "w"); + client->output = o_stream_create_fd(fd[1], IO_BLOCK_SIZE, TRUE); client->pid = pid; - if (client->f == NULL) - i_fatal("fdopen() failed: %m"); + + *output_r = client->output; return client; } @@ -137,7 +143,7 @@ struct smtp_client * smtp_client_open(const struct lda_settings *set, const char *destination, - const char *return_path, FILE **file_r) + const char *return_path, struct ostream **output_r) { struct smtp_client *client; const char *path; @@ -145,21 +151,22 @@ if (*set->submission_host == '\0') { return smtp_client_open_sendmail(set, destination, - return_path, file_r); + return_path, output_r); } if ((fd = create_temp_file(&path)) == -1) - return smtp_client_devnull(file_r); + return smtp_client_devnull(output_r); client = i_new(struct smtp_client, 1); client->set = set; client->temp_path = i_strdup(path); client->destination = i_strdup(destination); client->return_path = i_strdup(return_path); - client->f = *file_r = fdopen(fd, "w"); - if (client->f == NULL) - i_fatal("fdopen() failed: %m"); + client->temp_fd = fd; + client->output = o_stream_create_fd(fd, IO_BLOCK_SIZE, TRUE); client->use_smtp = TRUE; + + *output_r = client->output; return client; } @@ -167,7 +174,7 @@ { int ret = EX_TEMPFAIL, status; - fclose(client->f); + o_stream_destroy(&client->output); if (client->pid == (pid_t)-1) { /* smtp_client_open() failed already */ @@ -189,6 +196,8 @@ i_error("Sendmail process terminated abnormally, " "return status %d", status); } + if (client->buf != NULL) + buffer_free(&client->buf); i_free(client); return ret; } @@ -247,12 +256,12 @@ } } - if (fflush(smtp_client->f) != 0) { - i_error("fflush(%s) failed: %m", smtp_client->temp_path); + if (o_stream_flush(smtp_client->output) < 0) { + i_error("write(%s) failed: %m", smtp_client->temp_path); return -1; } - if (lseek(fileno(smtp_client->f), 0, SEEK_SET) < 0) { + if (o_stream_seek(smtp_client->output, 0) < 0) { i_error("lseek(%s) failed: %m", smtp_client->temp_path); return -1; } @@ -276,7 +285,7 @@ lmtp_client_add_rcpt(client, smtp_client->destination, rcpt_to_callback, data_callback, smtp_client); - input = i_stream_create_fd(fileno(smtp_client->f), (size_t)-1, FALSE); + input = i_stream_create_fd(smtp_client->temp_fd, (size_t)-1, FALSE); lmtp_client_send(client, input); i_stream_unref(&input); @@ -296,7 +305,7 @@ /* the mail has been written to a file. now actually send it. */ ret = smtp_client_send(client); - fclose(client->f); + o_stream_destroy(&client->output); i_free(client->return_path); i_free(client->destination); i_free(client->temp_path); diff -r 93dc749e1668 -r e915b7e734e7 src/lib-lda/smtp-client.h --- a/src/lib-lda/smtp-client.h Mon Feb 27 11:48:18 2012 +0200 +++ b/src/lib-lda/smtp-client.h Mon Feb 27 12:02:07 2012 +0200 @@ -5,7 +5,7 @@ struct smtp_client * smtp_client_open(const struct lda_settings *set, const char *destination, - const char *return_path, FILE **file_r); + const char *return_path, struct ostream **output_r); /* Returns sysexits-compatible return value */ int smtp_client_close(struct smtp_client *client); From dovecot at dovecot.org Mon Feb 27 13:34:30 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 13:34:30 +0200 Subject: dovecot-2.1: lib-ssl-iostream: Use SSL_LIBS when linking the sha... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/c07415305d9e changeset: 14198:c07415305d9e user: Timo Sirainen date: Mon Feb 27 13:34:20 2012 +0200 description: lib-ssl-iostream: Use SSL_LIBS when linking the shared library. diffstat: src/lib-ssl-iostream/Makefile.am | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (11 lines): diff -r 32ffa616f249 -r c07415305d9e src/lib-ssl-iostream/Makefile.am --- a/src/lib-ssl-iostream/Makefile.am Sat Feb 25 07:29:15 2012 +0200 +++ b/src/lib-ssl-iostream/Makefile.am Mon Feb 27 13:34:20 2012 +0200 @@ -30,6 +30,6 @@ pkglib_LTLIBRARIES = libdovecot-ssl.la libdovecot_ssl_la_SOURCES = -libdovecot_ssl_la_LIBADD = libssl_iostream.la ../lib/liblib.la $(MODULE_LIBS) +libdovecot_ssl_la_LIBADD = libssl_iostream.la ../lib/liblib.la $(MODULE_LIBS) $(SSL_LIBS) libdovecot_ssl_la_DEPENDENCIES = libssl_iostream.la libdovecot_ssl_la_LDFLAGS = -export-dynamic From dovecot at dovecot.org Mon Feb 27 14:38:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 14:38:16 +0200 Subject: dovecot-2.1: doveadm: Allow subcommands to specify '+' getopt pa... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/0d502dc7d265 changeset: 14199:0d502dc7d265 user: Timo Sirainen date: Mon Feb 27 14:37:45 2012 +0200 description: doveadm: Allow subcommands to specify '+' getopt parameter. diffstat: src/doveadm/doveadm-mail.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diffs (15 lines): diff -r c07415305d9e -r 0d502dc7d265 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Mon Feb 27 13:34:20 2012 +0200 +++ b/src/doveadm/doveadm-mail.c Mon Feb 27 14:37:45 2012 +0200 @@ -455,7 +455,10 @@ if (doveadm_debug) ctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_DEBUG; - getopt_args = t_strconcat("AS:u:", ctx->getopt_args, NULL); + getopt_args = "AS:u:"; + /* keep context's getopt_args first in case it contains '+' */ + if (ctx->getopt_args != NULL) + getopt_args = t_strconcat(ctx->getopt_args, getopt_args, NULL); ctx->cur_username = getenv("USER"); wildcard_user = NULL; while ((c = getopt(argc, argv, getopt_args)) > 0) { From dovecot at dovecot.org Mon Feb 27 14:38:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 14:38:16 +0200 Subject: dovecot-2.1: dsync: Fixes to handling legacy dsync parameters. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/d75b807afadc changeset: 14200:d75b807afadc user: Timo Sirainen date: Mon Feb 27 14:38:05 2012 +0200 description: dsync: Fixes to handling legacy dsync parameters. diffstat: src/doveadm/dsync/doveadm-dsync.c | 33 +++++++++++++++++++++++++-------- 1 files changed, 25 insertions(+), 8 deletions(-) diffs (94 lines): diff -r 0d502dc7d265 -r d75b807afadc src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 27 14:37:45 2012 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 27 14:38:05 2012 +0200 @@ -35,6 +35,7 @@ }; static const char *ssh_cmd = "ssh"; +static bool legacy_dsync = FALSE; static void run_cmd(const char *const *args, int *fd_in_r, int *fd_out_r) { @@ -87,13 +88,12 @@ array_append(&cmd_args, &p, 1); } - p = strchr(argv[0], '/'); - if (p == NULL) p = argv[0]; - if (strstr(p, "dsync") != NULL) { + if (legacy_dsync) { /* we're executing dsync */ p = "server"; } else { /* we're executing doveadm */ + abort(); p = "dsync-server"; } array_append(&cmd_args, &p, 1); @@ -307,7 +307,8 @@ switch (c) { case 'E': - /* dsync backup wrapper detection flag */ + /* dsync wrapper detection flag */ + legacy_dsync = TRUE; break; case 'f': ctx->brain_flags |= DSYNC_BRAIN_FLAG_FULL_SYNC; @@ -329,7 +330,7 @@ struct dsync_cmd_context *ctx; ctx = doveadm_mail_cmd_alloc(struct dsync_cmd_context); - ctx->ctx.getopt_args = "EfRm:"; + ctx->ctx.getopt_args = "+EfRm:"; ctx->ctx.v.parse_arg = cmd_mailbox_dsync_parse_arg; ctx->ctx.v.preinit = cmd_dsync_preinit; ctx->ctx.v.init = cmd_dsync_init; @@ -369,11 +370,27 @@ return 0; } +static bool +cmd_mailbox_dsync_server_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +{ + switch (c) { + case 'E': + /* dsync wrapper detection flag */ + legacy_dsync = TRUE; + break; + default: + return FALSE; + } + return TRUE; +} + static struct doveadm_mail_cmd_context *cmd_dsync_server_alloc(void) { struct doveadm_mail_cmd_context *ctx; ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); + ctx->getopt_args = "E"; + ctx->v.parse_arg = cmd_mailbox_dsync_server_parse_arg; ctx->v.run = cmd_dsync_server_run; return ctx; } @@ -500,9 +517,8 @@ } /* dsync flags */ - new_flags[0] = '-'; i = 1; - if (backup_flag) - new_flags[i++] = 'E'; + new_flags[0] = '-'; + new_flags[1] = 'E'; i = 2; if (flag_f) new_flags[i++] = 'f'; if (flag_R) @@ -528,6 +544,7 @@ i_assert(dest < max_argc); new_argv[dest] = NULL; + legacy_dsync = TRUE; *_argc = dest; *_argv = new_argv; optind = 1; From dovecot at dovecot.org Mon Feb 27 14:40:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 14:40:24 +0200 Subject: dovecot-2.1: dsync: Removed accidentally committed debug code. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/47dcf6a607a9 changeset: 14201:47dcf6a607a9 user: Timo Sirainen date: Mon Feb 27 14:40:19 2012 +0200 description: dsync: Removed accidentally committed debug code. diffstat: src/doveadm/dsync/doveadm-dsync.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diffs (11 lines): diff -r d75b807afadc -r 47dcf6a607a9 src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Mon Feb 27 14:38:05 2012 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Mon Feb 27 14:40:19 2012 +0200 @@ -93,7 +93,6 @@ p = "server"; } else { /* we're executing doveadm */ - abort(); p = "dsync-server"; } array_append(&cmd_args, &p, 1); From dovecot at dovecot.org Mon Feb 27 16:31:45 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 16:31:45 +0200 Subject: dovecot-2.1: mysql: Log idle time also for CR_SERVER_LOST errors. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/1999ae5c9699 changeset: 14202:1999ae5c9699 user: Timo Sirainen date: Mon Feb 27 16:31:33 2012 +0200 description: mysql: Log idle time also for CR_SERVER_LOST errors. diffstat: src/lib-sql/driver-mysql.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diffs (16 lines): diff -r 47dcf6a607a9 -r 1999ae5c9699 src/lib-sql/driver-mysql.c --- a/src/lib-sql/driver-mysql.c Mon Feb 27 14:40:19 2012 +0200 +++ b/src/lib-sql/driver-mysql.c Mon Feb 27 16:31:33 2012 +0200 @@ -464,9 +464,11 @@ struct mysql_db *db = (struct mysql_db *)_result->db; const char *errstr; unsigned int idle_time; + int err; + err = mysql_errno(db->mysql); errstr = mysql_error(db->mysql); - if (mysql_errno(db->mysql) == CR_SERVER_GONE_ERROR && + if ((err == CR_SERVER_GONE_ERROR || err == CR_SERVER_LOST) && db->last_success != 0) { idle_time = ioloop_time - db->last_success; errstr = t_strdup_printf("%s (idled for %u secs)", From dovecot at dovecot.org Mon Feb 27 16:54:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 16:54:03 +0200 Subject: dovecot-2.1: auth worker: When idle_kill timeout is reached, cha... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/5074680f321a changeset: 14203:5074680f321a user: Timo Sirainen date: Mon Feb 27 16:52:44 2012 +0200 description: auth worker: When idle_kill timeout is reached, change process title to indicate it. diffstat: src/auth/auth-worker-client.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (17 lines): diff -r 1999ae5c9699 -r 5074680f321a src/auth/auth-worker-client.c --- a/src/auth/auth-worker-client.c Mon Feb 27 16:31:33 2012 +0200 +++ b/src/auth/auth-worker-client.c Mon Feb 27 16:52:44 2012 +0200 @@ -19,6 +19,7 @@ #define CLIENT_STATE_HANDSHAKE "handshaking" #define CLIENT_STATE_IDLE "idling" +#define CLIENT_STATE_STOP "waiting for shutdown" struct auth_worker_client { int refcount; @@ -776,4 +777,5 @@ { if (auth_worker_client != NULL) o_stream_send_str(auth_worker_client->output, "SHUTDOWN\n"); + auth_worker_refresh_proctitle(CLIENT_STATE_STOP); } From dovecot at dovecot.org Mon Feb 27 16:54:03 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Mon, 27 Feb 2012 16:54:03 +0200 Subject: dovecot-2.1: auth worker: reset idle time after running a comman... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/3b328ffffdd4 changeset: 14204:3b328ffffdd4 user: Timo Sirainen date: Mon Feb 27 16:53:50 2012 +0200 description: auth worker: reset idle time after running a command, not before. diffstat: src/auth/auth-worker-client.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diffs (22 lines): diff -r 5074680f321a -r 3b328ffffdd4 src/auth/auth-worker-client.c --- a/src/auth/auth-worker-client.c Mon Feb 27 16:52:44 2012 +0200 +++ b/src/auth/auth-worker-client.c Mon Feb 27 16:53:50 2012 +0200 @@ -596,9 +596,6 @@ char *line; bool ret; - if (client->to_idle != NULL) - timeout_reset(client->to_idle); - switch (i_stream_read(client->input)) { case 0: return; @@ -656,6 +653,8 @@ break; } } + if (client->to_idle != NULL) + timeout_reset(client->to_idle); auth_worker_client_unref(&client); } From dovecot at dovecot.org Tue Feb 28 04:29:24 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Feb 2012 04:29:24 +0200 Subject: dovecot-2.1: fs layout: Mailbox listing returned duplicates when... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/07fc8baa0c9b changeset: 14205:07fc8baa0c9b user: Timo Sirainen date: Tue Feb 28 04:29:12 2012 +0200 description: fs layout: Mailbox listing returned duplicates when patterns contained a parent and its children. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 3b328ffffdd4 -r 07fc8baa0c9b src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Mon Feb 27 16:53:50 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Tue Feb 28 04:29:12 2012 +0200 @@ -360,7 +360,8 @@ childp = array_idx(&ctx->roots, i); parentlen = strlen(*parentp); if (strncmp(*parentp, *childp, parentlen) == 0 && - ((*childp)[parentlen] == ctx->sep || + (parentlen == 0 || + (*childp)[parentlen] == ctx->sep || (*childp)[parentlen] == '\0')) array_delete(&ctx->roots, i, 1); } From dovecot at dovecot.org Tue Feb 28 05:11:08 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Feb 2012 05:11:08 +0200 Subject: dovecot-2.0: fs layout: Mailbox listing returned duplicates when... Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/8f0c49f98e07 changeset: 13062:8f0c49f98e07 user: Timo Sirainen date: Tue Feb 28 05:10:41 2012 +0200 description: fs layout: Mailbox listing returned duplicates when patterns contained a parent and its children. This is an ugly patch to fix at least the most obvious cases. It's fixed properly in v2.1 code. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diffs (73 lines): diff -r b7e5a83866a4 -r 8f0c49f98e07 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Sat Feb 25 07:29:15 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Tue Feb 28 05:10:41 2012 +0200 @@ -36,6 +36,7 @@ struct mailbox_list_iterate_context ctx; ARRAY_DEFINE(valid_patterns, char *); + bool *patterns_used; struct imap_match_glob *glob; struct mailbox_tree_context *subs_tree; struct mailbox_tree_iterate_context *tree_iter; @@ -250,6 +251,7 @@ } } (void)array_append_space(&ctx->valid_patterns); /* NULL-terminate */ + ctx->patterns_used = i_new(bool, array_count(&ctx->valid_patterns)); if (array_count(&ctx->valid_patterns) == 1) { /* we've only invalid patterns (or INBOX) */ @@ -337,6 +339,7 @@ pool_unref(&ctx->info_pool); if (ctx->glob != NULL) imap_match_deinit(&ctx->glob); + i_free(ctx->patterns_used); i_free(ctx); return ret; @@ -560,7 +563,9 @@ struct mail_namespace *ns = ctx->ctx.list->ns; const char *fname = entry->fname; const char *list_path, *root_dir; + char *const *valid_patterns; enum imap_match_result match; + unsigned int i; struct stat st; int ret; @@ -598,6 +603,17 @@ if (ret <= 0) return ret; + /* ugly workaround to avoid duplicates with: a list "" (foo foo/bar) + this is fixed properly in v2.1 listing code */ + valid_patterns = array_idx(&ctx->valid_patterns, 0); + for (i = 0; valid_patterns[i] != NULL; i++) { + if (!ctx->patterns_used[i] && + strcmp(valid_patterns[i], list_path) == 0) { + ctx->patterns_used[i] = TRUE; + break; + } + } + if (ctx->dir->delayed_send) { /* send the parent directory first, then handle this file again if needed */ @@ -726,11 +742,13 @@ for (;;) { patterns = array_idx(&ctx->valid_patterns, 0); - if (patterns[dir->pattern_pos] == NULL) - return NULL; + do { + if (patterns[dir->pattern_pos] == NULL) + return NULL; - patterns += dir->pattern_pos; - dir->pattern_pos++; + patterns += dir->pattern_pos; + dir->pattern_pos++; + } while (ctx->patterns_used[dir->pattern_pos-1]); ret = pattern_get_path_pos(ctx, *patterns, dir->virtual_path, &pos); From dovecot at dovecot.org Tue Feb 28 05:14:10 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Feb 2012 05:14:10 +0200 Subject: dovecot-2.1: Compiler warning fixes Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/54aeb3853bae changeset: 14206:54aeb3853bae user: Timo Sirainen date: Tue Feb 28 05:14:00 2012 +0200 description: Compiler warning fixes diffstat: src/doveadm/dsync/doveadm-dsync.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diffs (34 lines): diff -r 07fc8baa0c9b -r 54aeb3853bae src/doveadm/dsync/doveadm-dsync.c --- a/src/doveadm/dsync/doveadm-dsync.c Tue Feb 28 04:29:12 2012 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Tue Feb 28 05:14:00 2012 +0200 @@ -370,7 +370,8 @@ } static bool -cmd_mailbox_dsync_server_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +cmd_mailbox_dsync_server_parse_arg(struct doveadm_mail_cmd_context *_ctx ATTR_UNUSED, + int c) { switch (c) { case 'E': @@ -414,7 +415,6 @@ char *p, *dup, new_flags[6]; int max_argc, src, dest, i, j; bool flag_f = FALSE, flag_R = FALSE, flag_m, flag_u, flag_C, has_arg; - bool backup_flag = FALSE; p = strrchr(argv[0], '/'); if (p == NULL) p = argv[0]; @@ -501,10 +501,9 @@ } if (strcmp(argv[src], "mirror") == 0) new_argv[dest] = "sync"; - else if (strcmp(argv[src], "backup") == 0) { - backup_flag = TRUE; + else if (strcmp(argv[src], "backup") == 0) new_argv[dest] = "backup"; - } else if (strcmp(argv[src], "server") == 0) + else if (strcmp(argv[src], "server") == 0) new_argv[dest] = "dsync-server"; else i_fatal("Invalid parameter: %s", argv[src]); From dovecot at dovecot.org Tue Feb 28 05:27:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Feb 2012 05:27:16 +0200 Subject: dovecot-2.2: pop3-login: Fixed APOP authentication, broken by re... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/864187d19761 changeset: 14226:864187d19761 user: Timo Sirainen date: Tue Feb 28 05:21:19 2012 +0200 description: pop3-login: Fixed APOP authentication, broken by recent changes. diffstat: src/pop3-login/client.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r e915b7e734e7 -r 864187d19761 src/pop3-login/client.c --- a/src/pop3-login/client.c Mon Feb 27 12:02:07 2012 +0200 +++ b/src/pop3-login/client.c Tue Feb 28 05:21:19 2012 +0200 @@ -198,6 +198,8 @@ str_append(str, "[XCLIENT] "); } str_append(str, client->set->login_greeting); + + pop3_client->apop_challenge = get_apop_challenge(pop3_client); if (pop3_client->apop_challenge != NULL) str_printfa(str, " %s", pop3_client->apop_challenge); client_send_reply(client, POP3_CMD_REPLY_OK, str_c(str)); From dovecot at dovecot.org Tue Feb 28 05:27:16 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Feb 2012 05:27:16 +0200 Subject: dovecot-2.2: lib-lda: Fixed mai forward/reject to work with the ... Message-ID: details: http://hg.dovecot.org/dovecot-2.2/rev/df631445f150 changeset: 14227:df631445f150 user: Timo Sirainen date: Tue Feb 28 05:27:03 2012 +0200 description: lib-lda: Fixed mai forward/reject to work with the new smtp_client_open() API. diffstat: src/lib-lda/mail-send.c | 116 +++++++++++++++++++++-------------------------- 1 files changed, 53 insertions(+), 63 deletions(-) diffs (202 lines): diff -r 864187d19761 -r df631445f150 src/lib-lda/mail-send.c --- a/src/lib-lda/mail-send.c Tue Feb 28 05:21:19 2012 +0200 +++ b/src/lib-lda/mail-send.c Tue Feb 28 05:27:03 2012 +0200 @@ -4,6 +4,7 @@ #include "ioloop.h" #include "hostpid.h" #include "istream.h" +#include "ostream.h" #include "str.h" #include "str-sanitize.h" #include "var-expand.h" @@ -55,12 +56,10 @@ struct mail *mail = ctx->src_mail; struct istream *input; struct smtp_client *smtp_client; - FILE *f; + struct ostream *output; const char *return_addr, *hdr; - const unsigned char *data; const char *value, *msgid, *orig_msgid, *boundary; string_t *str; - size_t size; int ret; if (mail_get_first_header(mail, "Message-ID", &orig_msgid) < 0) @@ -87,76 +86,75 @@ str_sanitize(reason, 512)); } - smtp_client = smtp_client_open(ctx->set, return_addr, NULL, &f); + smtp_client = smtp_client_open(ctx->set, return_addr, NULL, &output); msgid = mail_deliver_get_new_message_id(ctx); boundary = t_strdup_printf("%s/%s", my_pid, ctx->set->hostname); - fprintf(f, "Message-ID: %s\r\n", msgid); - fprintf(f, "Date: %s\r\n", message_date_create(ioloop_time)); - fprintf(f, "From: Mail Delivery Subsystem <%s>\r\n", - ctx->set->postmaster_address); - fprintf(f, "To: <%s>\r\n", return_addr); - fprintf(f, "MIME-Version: 1.0\r\n"); - fprintf(f, "Content-Type: " - "multipart/report; report-type=%s;\r\n" - "\tboundary=\"%s\"\r\n", - ctx->dsn ? "delivery-status" : "disposition-notification", - boundary); - - str = t_str_new(256); + str = t_str_new(512); + str_printfa(str, "Message-ID: %s\r\n", msgid); + str_printfa(str, "Date: %s\r\n", message_date_create(ioloop_time)); + str_printfa(str, "From: Mail Delivery Subsystem <%s>\r\n", + ctx->set->postmaster_address); + str_printfa(str, "To: <%s>\r\n", return_addr); + str_append(str, "MIME-Version: 1.0\r\n"); + str_printfa(str, "Content-Type: " + "multipart/report; report-type=%s;\r\n" + "\tboundary=\"%s\"\r\n", + ctx->dsn ? "delivery-status" : "disposition-notification", + boundary); + str_append(str, "Subject: "); var_expand(str, ctx->set->rejection_subject, get_var_expand_table(mail, reason, recipient)); - fprintf(f, "Subject: %s\r\n", str_c(str)); + str_append(str, "\r\n"); - fprintf(f, "Auto-Submitted: auto-replied (rejected)\r\n"); - fprintf(f, "Precedence: bulk\r\n"); - fprintf(f, "\r\nThis is a MIME-encapsulated message\r\n\r\n"); + str_append(str, "Auto-Submitted: auto-replied (rejected)\r\n"); + str_append(str, "Precedence: bulk\r\n"); + str_append(str, "\r\nThis is a MIME-encapsulated message\r\n\r\n"); /* human readable status report */ - fprintf(f, "--%s\r\n", boundary); - fprintf(f, "Content-Type: text/plain; charset=utf-8\r\n"); - fprintf(f, "Content-Disposition: inline\r\n"); - fprintf(f, "Content-Transfer-Encoding: 8bit\r\n\r\n"); + str_printfa(str, "--%s\r\n", boundary); + str_append(str, "Content-Type: text/plain; charset=utf-8\r\n"); + str_append(str, "Content-Disposition: inline\r\n"); + str_append(str, "Content-Transfer-Encoding: 8bit\r\n\r\n"); - str_truncate(str, 0); var_expand(str, ctx->set->rejection_reason, get_var_expand_table(mail, reason, recipient)); - fprintf(f, "%s\r\n", str_c(str)); + str_append(str, "\r\n"); if (ctx->dsn) { /* DSN status report: For LDA rejects. currently only used when user is out of quota */ - fprintf(f, "--%s\r\n" - "Content-Type: message/delivery-status\r\n\r\n", - boundary); - fprintf(f, "Reporting-MTA: dns; %s\r\n", - ctx->set->hostname); + str_printfa(str, "--%s\r\n" + "Content-Type: message/delivery-status\r\n\r\n", + boundary); + str_printfa(str, "Reporting-MTA: dns; %s\r\n", ctx->set->hostname); if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) - fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); - fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); - fprintf(f, "Action: failed\r\n"); - fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0"); + str_printfa(str, "Original-Recipient: rfc822; %s\r\n", hdr); + str_printfa(str, "Final-Recipient: rfc822; %s\r\n", recipient); + str_append(str, "Action: failed\r\n"); + str_printfa(str, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0"); } else { /* MDN status report: For Sieve "reject" */ - fprintf(f, "--%s\r\n" - "Content-Type: message/disposition-notification\r\n\r\n", - boundary); - fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n", - ctx->set->hostname); + str_printfa(str, "--%s\r\n" + "Content-Type: message/disposition-notification\r\n\r\n", + boundary); + str_printfa(str, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n", + ctx->set->hostname); if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0) - fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr); - fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient); + str_printfa(str, "Original-Recipient: rfc822; %s\r\n", hdr); + str_printfa(str, "Final-Recipient: rfc822; %s\r\n", recipient); if (orig_msgid != NULL) - fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid); - fprintf(f, "Disposition: " - "automatic-action/MDN-sent-automatically; deleted\r\n"); + str_printfa(str, "Original-Message-ID: %s\r\n", orig_msgid); + str_append(str, "Disposition: " + "automatic-action/MDN-sent-automatically; deleted\r\n"); } - fprintf(f, "\r\n"); + str_append(str, "\r\n"); /* original message's headers */ - fprintf(f, "--%s\r\nContent-Type: message/rfc822\r\n\r\n", boundary); + str_printfa(str, "--%s\r\nContent-Type: message/rfc822\r\n\r\n", boundary); + o_stream_send(output, str_data(str), str_len(str)); if (mail_get_hdr_stream(mail, NULL, &input) == 0) { /* Note: If you add more headers, they need to be sorted. @@ -173,17 +171,15 @@ N_ELEMENTS(exclude_headers), null_header_filter_callback, NULL); - while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) { - if (fwrite(data, size, 1, f) == 0) - break; - i_stream_skip(input, size); - } + ret = o_stream_send_istream(output, input); i_stream_unref(&input); i_assert(ret != 0); } - fprintf(f, "\r\n\r\n--%s--\r\n", boundary); + str_truncate(str, 0); + str_printfa(str, "\r\n\r\n--%s--\r\n", boundary); + o_stream_send(output, str_data(str), str_len(str)); return smtp_client_close(smtp_client); } @@ -193,11 +189,9 @@ "Return-Path" }; struct istream *input; + struct ostream *output; struct smtp_client *smtp_client; - FILE *f; - const unsigned char *data; const char *return_path; - size_t size; if (mail_get_stream(ctx->src_mail, NULL, NULL, &input) < 0) return -1; @@ -208,18 +202,14 @@ forwardto, return_path); } - smtp_client = smtp_client_open(ctx->set, forwardto, return_path, &f); + smtp_client = smtp_client_open(ctx->set, forwardto, return_path, &output); input = i_stream_create_header_filter(input, HEADER_FILTER_EXCLUDE | HEADER_FILTER_NO_CR, hide_headers, N_ELEMENTS(hide_headers), null_header_filter_callback, NULL); - while (i_stream_read_data(input, &data, &size, 0) > 0) { - if (fwrite(data, size, 1, f) == 0) - break; - i_stream_skip(input, size); - } + o_stream_send_istream(output, input); i_stream_unref(&input); return smtp_client_close(smtp_client); From dovecot at dovecot.org Tue Feb 28 06:53:21 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Feb 2012 06:53:21 +0200 Subject: dovecot-2.1: mailbox list indexes: Avoid unnecessary refresh fla... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ba2b4f8a1bb1 changeset: 14207:ba2b4f8a1bb1 user: Timo Sirainen date: Tue Feb 28 06:52:43 2012 +0200 description: mailbox list indexes: Avoid unnecessary refresh flag writes. diffstat: src/lib-storage/list/mailbox-list-index-status.c | 2 ++ src/lib-storage/list/mailbox-list-index-sync.c | 2 +- src/lib-storage/list/mailbox-list-index.c | 5 ++--- src/lib-storage/list/mailbox-list-index.h | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diffs (51 lines): diff -r 54aeb3853bae -r ba2b4f8a1bb1 src/lib-storage/list/mailbox-list-index-status.c --- a/src/lib-storage/list/mailbox-list-index-status.c Tue Feb 28 05:14:00 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-index-status.c Tue Feb 28 06:52:43 2012 +0200 @@ -289,6 +289,8 @@ struct mailbox_status status; uint32_t seq, seq1, seq2; + (void)mailbox_list_index_refresh(box->list); + node = mailbox_list_index_lookup(box->list, box->name); if (node == NULL) { mailbox_list_index_refresh_later(box->list); diff -r 54aeb3853bae -r ba2b4f8a1bb1 src/lib-storage/list/mailbox-list-index-sync.c --- a/src/lib-storage/list/mailbox-list-index-sync.c Tue Feb 28 05:14:00 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-index-sync.c Tue Feb 28 06:52:43 2012 +0200 @@ -301,7 +301,7 @@ T_BEGIN { mailbox_list_index_sync_names(&sync_ctx); } T_END; - } else { + } else if (mailbox_list_index_need_refresh(ilist, sync_ctx.view)) { /* we're synced, reset refresh flag */ struct mailbox_list_index_header new_hdr; diff -r 54aeb3853bae -r ba2b4f8a1bb1 src/lib-storage/list/mailbox-list-index.c --- a/src/lib-storage/list/mailbox-list-index.c Tue Feb 28 05:14:00 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-index.c Tue Feb 28 06:52:43 2012 +0200 @@ -197,9 +197,8 @@ return 0; } -static bool -mailbox_list_index_need_refresh(struct mailbox_list_index *ilist, - struct mail_index_view *view) +bool mailbox_list_index_need_refresh(struct mailbox_list_index *ilist, + struct mail_index_view *view) { const struct mailbox_list_index_header *hdr; const void *data; diff -r 54aeb3853bae -r ba2b4f8a1bb1 src/lib-storage/list/mailbox-list-index.h --- a/src/lib-storage/list/mailbox-list-index.h Tue Feb 28 05:14:00 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-index.h Tue Feb 28 06:52:43 2012 +0200 @@ -124,6 +124,8 @@ struct mailbox_list_index_node * mailbox_list_index_lookup(struct mailbox_list *list, const char *name); +bool mailbox_list_index_need_refresh(struct mailbox_list_index *ilist, + struct mail_index_view *view); int mailbox_list_index_refresh(struct mailbox_list *list); void mailbox_list_index_refresh_later(struct mailbox_list *list); From dovecot at dovecot.org Tue Feb 28 18:50:58 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Tue, 28 Feb 2012 18:50:58 +0200 Subject: dovecot-2.1: Show SEARCH=FUZZY in IMAP capabilities only when FT... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/bdc881838b00 changeset: 14208:bdc881838b00 user: Timo Sirainen date: Tue Feb 28 18:50:46 2012 +0200 description: Show SEARCH=FUZZY in IMAP capabilities only when FTS backend actually supports it. diffstat: configure.in | 2 +- src/imap/imap-client.c | 5 +++++ src/lib-storage/mail-user.h | 2 ++ src/plugins/fts-lucene/fts-backend-lucene.c | 3 ++- src/plugins/fts-solr/fts-backend-solr.c | 2 +- src/plugins/fts/fts-api-private.h | 4 +++- src/plugins/fts/fts-storage.c | 3 +++ 7 files changed, 17 insertions(+), 4 deletions(-) diffs (91 lines): diff -r ba2b4f8a1bb1 -r bdc881838b00 configure.in --- a/configure.in Tue Feb 28 06:52:43 2012 +0200 +++ b/configure.in Tue Feb 28 18:50:46 2012 +0200 @@ -2697,7 +2697,7 @@ dnl IDLE doesn't really belong to banner. It's there just to make Blackberries dnl happy, because otherwise BIS server disables push email. capability_banner="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE" -capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SEARCH=FUZZY SPECIAL-USE" +capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE" AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities) AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", IMAP capabilities advertised in banner) diff -r ba2b4f8a1bb1 -r bdc881838b00 src/imap/imap-client.c --- a/src/imap/imap-client.c Tue Feb 28 06:52:43 2012 +0200 +++ b/src/imap/imap-client.c Tue Feb 28 18:50:46 2012 +0200 @@ -82,6 +82,11 @@ str_append_c(client->capability_string, ' '); str_append(client->capability_string, set->imap_capability + 1); } + if (user->fuzzy_search) { + /* Enable FUZZY capability only when it actually has + a chance of working */ + str_append(client->capability_string, " SEARCH=FUZZY"); + } ident = mail_user_get_anvil_userip_ident(client->user); if (ident != NULL) { diff -r ba2b4f8a1bb1 -r bdc881838b00 src/lib-storage/mail-user.h --- a/src/lib-storage/mail-user.h Tue Feb 28 06:52:43 2012 +0200 +++ b/src/lib-storage/mail-user.h Tue Feb 28 18:50:46 2012 +0200 @@ -54,6 +54,8 @@ unsigned int mail_debug:1; /* If INBOX can't be opened, log an error, but only once. */ unsigned int inbox_open_error_logged:1; + /* Fuzzy search works for this user (FTS enabled) */ + unsigned int fuzzy_search:1; }; struct mail_user_module_register { diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts-lucene/fts-backend-lucene.c --- a/src/plugins/fts-lucene/fts-backend-lucene.c Tue Feb 28 06:52:43 2012 +0200 +++ b/src/plugins/fts-lucene/fts-backend-lucene.c Tue Feb 28 18:50:46 2012 +0200 @@ -552,7 +552,8 @@ struct fts_backend fts_backend_lucene = { .name = "lucene", - .flags = FTS_BACKEND_FLAG_BUILD_FULL_WORDS, + .flags = FTS_BACKEND_FLAG_BUILD_FULL_WORDS | + FTS_BACKEND_FLAG_FUZZY_SEARCH, { fts_backend_lucene_alloc, diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts-solr/fts-backend-solr.c --- a/src/plugins/fts-solr/fts-backend-solr.c Tue Feb 28 06:52:43 2012 +0200 +++ b/src/plugins/fts-solr/fts-backend-solr.c Tue Feb 28 18:50:46 2012 +0200 @@ -833,7 +833,7 @@ struct fts_backend fts_backend_solr = { .name = "solr", - .flags = 0, + .flags = FTS_BACKEND_FLAG_FUZZY_SEARCH, { fts_backend_solr_alloc, diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts/fts-api-private.h --- a/src/plugins/fts/fts-api-private.h Tue Feb 28 06:52:43 2012 +0200 +++ b/src/plugins/fts/fts-api-private.h Tue Feb 28 18:50:46 2012 +0200 @@ -57,7 +57,9 @@ preserving original case */ FTS_BACKEND_FLAG_BUILD_DTCASE = 0x02, /* Send only fully indexable words rather than randomly sized blocks */ - FTS_BACKEND_FLAG_BUILD_FULL_WORDS = 0x04 + FTS_BACKEND_FLAG_BUILD_FULL_WORDS = 0x04, + /* Fuzzy search works */ + FTS_BACKEND_FLAG_FUZZY_SEARCH = 0x08 }; struct fts_backend { diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts/fts-storage.c --- a/src/plugins/fts/fts-storage.c Tue Feb 28 06:52:43 2012 +0200 +++ b/src/plugins/fts/fts-storage.c Tue Feb 28 18:50:46 2012 +0200 @@ -637,6 +637,9 @@ struct fts_mailbox_list *flist; struct mailbox_list_vfuncs *v = list->vlast; + if ((backend->flags & FTS_BACKEND_FLAG_FUZZY_SEARCH) != 0) + list->ns->user->fuzzy_search = TRUE; + flist = p_new(list->pool, struct fts_mailbox_list, 1); flist->module_ctx.super = *v; flist->backend = backend; From dovecot at dovecot.org Wed Feb 29 12:53:32 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 29 Feb 2012 12:53:32 +0200 Subject: dovecot-2.1: fts-squat: Fixed search to actually work. Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/ee6f3f375dd3 changeset: 14209:ee6f3f375dd3 user: Timo Sirainen date: Wed Feb 29 12:53:21 2012 +0200 description: fts-squat: Fixed search to actually work. diffstat: src/plugins/fts-squat/fts-backend-squat.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diffs (28 lines): diff -r bdc881838b00 -r ee6f3f375dd3 src/plugins/fts-squat/fts-backend-squat.c --- a/src/plugins/fts-squat/fts-backend-squat.c Tue Feb 28 18:50:46 2012 +0200 +++ b/src/plugins/fts-squat/fts-backend-squat.c Wed Feb 29 12:53:21 2012 +0200 @@ -436,6 +436,7 @@ { struct squat_fts_backend *backend = (struct squat_fts_backend *)_backend; + bool first = TRUE; int ret; fts_backend_squat_set_box(backend, box); @@ -446,14 +447,14 @@ } for (; args != NULL; args = args->next) { - ret = squat_lookup_arg(backend, args, and_args, + ret = squat_lookup_arg(backend, args, first ? FALSE : and_args, &result->definite_uids, &result->maybe_uids); if (ret < 0) return -1; if (ret > 0) args->match_always = TRUE; - + first = FALSE; } return 0; } From dovecot at dovecot.org Wed Feb 29 13:04:36 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 29 Feb 2012 13:04:36 +0200 Subject: dovecot-2.1: mailbox_list_index=yes: Fixed mailbox listing when ... Message-ID: details: http://hg.dovecot.org/dovecot-2.1/rev/99cde8ce9991 changeset: 14210:99cde8ce9991 user: Timo Sirainen date: Wed Feb 29 13:04:24 2012 +0200 description: mailbox_list_index=yes: Fixed mailbox listing when not using default namespace settings. diffstat: src/lib-storage/list/mailbox-list-index-iter.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r ee6f3f375dd3 -r 99cde8ce9991 src/lib-storage/list/mailbox-list-index-iter.c --- a/src/lib-storage/list/mailbox-list-index-iter.c Wed Feb 29 12:53:21 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-index-iter.c Wed Feb 29 13:04:24 2012 +0200 @@ -51,7 +51,7 @@ str_append_c(ctx->path, ctx->sep); str_append(ctx->path, node->name); - ctx->info.name = str_c(ctx->path); + ctx->info.name = mailbox_list_get_vname(ctx->ctx.list, str_c(ctx->path)); ctx->info.flags = 0; if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0) ctx->info.flags |= MAILBOX_NONEXISTENT; From dovecot at dovecot.org Wed Feb 29 19:57:37 2012 From: dovecot at dovecot.org (dovecot at dovecot.org) Date: Wed, 29 Feb 2012 19:57:37 +0200 Subject: dovecot-2.0: fs layout: Crashfix to previous change. Message-ID: details: http://hg.dovecot.org/dovecot-2.0/rev/06555bd6d938 changeset: 13063:06555bd6d938 user: Timo Sirainen date: Wed Feb 29 19:57:26 2012 +0200 description: fs layout: Crashfix to previous change. diffstat: src/lib-storage/list/mailbox-list-fs-iter.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 8f0c49f98e07 -r 06555bd6d938 src/lib-storage/list/mailbox-list-fs-iter.c --- a/src/lib-storage/list/mailbox-list-fs-iter.c Tue Feb 28 05:10:41 2012 +0200 +++ b/src/lib-storage/list/mailbox-list-fs-iter.c Wed Feb 29 19:57:26 2012 +0200 @@ -741,8 +741,8 @@ } for (;;) { - patterns = array_idx(&ctx->valid_patterns, 0); do { + patterns = array_idx(&ctx->valid_patterns, 0); if (patterns[dir->pattern_pos] == NULL) return NULL; From pigeonhole at rename-it.nl Wed Feb 29 21:07:31 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 29 Feb 2012 20:07:31 +0100 Subject: dovecot-2.1-pigeonhole: Fixed bug that caused SunStudio CC compi... Message-ID: details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/9da3a8398ea4 changeset: 1605:9da3a8398ea4 user: Stephan Bosch date: Wed Feb 29 20:07:24 2012 +0100 description: Fixed bug that caused SunStudio CC compile failure (reported by Piotr Tarnowski). diffstat: src/lib-sieve/sieve.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r a4ea7e3f8d9e -r 9da3a8398ea4 src/lib-sieve/sieve.c --- a/src/lib-sieve/sieve.c Wed Feb 22 21:43:35 2012 +0100 +++ b/src/lib-sieve/sieve.c Wed Feb 29 20:07:24 2012 +0100 @@ -577,7 +577,8 @@ bool sieve_multiscript_run (struct sieve_multiscript *mscript, struct sieve_binary *sbin, - struct sieve_error_handler *ehandler, unsigned int flags, bool final) + struct sieve_error_handler *ehandler, enum sieve_runtime_flags flags, + bool final) { if ( !mscript->active ) return FALSE; From pigeonhole at rename-it.nl Wed Feb 29 23:52:02 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 29 Feb 2012 22:52:02 +0100 Subject: dovecot-2.2-pigeonhole: Fixed bug that caused SunStudio CC compi... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/7b8cc0897a79 changeset: 1604:7b8cc0897a79 user: Stephan Bosch date: Wed Feb 29 20:07:24 2012 +0100 description: Fixed bug that caused SunStudio CC compile failure (reported by Piotr Tarnowski). diffstat: src/lib-sieve/sieve.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r b4c69a7ae260 -r 7b8cc0897a79 src/lib-sieve/sieve.c --- a/src/lib-sieve/sieve.c Wed Feb 22 21:43:35 2012 +0100 +++ b/src/lib-sieve/sieve.c Wed Feb 29 20:07:24 2012 +0100 @@ -577,7 +577,8 @@ bool sieve_multiscript_run (struct sieve_multiscript *mscript, struct sieve_binary *sbin, - struct sieve_error_handler *ehandler, unsigned int flags, bool final) + struct sieve_error_handler *ehandler, enum sieve_runtime_flags flags, + bool final) { if ( !mscript->active ) return FALSE; From pigeonhole at rename-it.nl Wed Feb 29 23:52:02 2012 From: pigeonhole at rename-it.nl (pigeonhole at rename-it.nl) Date: Wed, 29 Feb 2012 22:52:02 +0100 Subject: dovecot-2.2-pigeonhole: Adjusted Sieve implementation and testsu... Message-ID: details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/b88a6d76839b changeset: 1605:b88a6d76839b user: Stephan Bosch date: Wed Feb 29 22:51:56 2012 +0100 description: Adjusted Sieve implementation and testsuite to Dovecot's new smtp_client_open() API. diffstat: src/lib-sieve-tool/mail-raw.c | 9 +- src/lib-sieve/cmd-redirect.c | 42 ++---- src/lib-sieve/edit-mail.c | 2 +- src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c | 151 +++++++++++++----------- src/lib-sieve/plugins/notify/cmd-notify.c | 109 ++++++++++------- src/lib-sieve/plugins/vacation/cmd-vacation.c | 63 +++++---- src/lib-sieve/rfc2822.c | 87 ++++---------- src/lib-sieve/rfc2822.h | 18 +- src/lib-sieve/sieve-actions.c | 128 +++++++++++---------- src/lib-sieve/sieve-smtp.c | 4 +- src/lib-sieve/sieve-smtp.h | 2 +- src/lib-sieve/sieve-types.h | 2 +- src/plugins/lda-sieve/lda-sieve-plugin.c | 5 +- src/sieve-tools/sieve-test.c | 9 +- src/testsuite/testsuite-smtp.c | 19 +- src/testsuite/testsuite-smtp.h | 2 +- 16 files changed, 335 insertions(+), 317 deletions(-) diffs (truncated from 1097 to 300 lines): diff -r 7b8cc0897a79 -r b88a6d76839b src/lib-sieve-tool/mail-raw.c --- a/src/lib-sieve-tool/mail-raw.c Wed Feb 29 20:07:24 2012 +0100 +++ b/src/lib-sieve-tool/mail-raw.c Wed Feb 29 22:51:56 2012 +0100 @@ -189,8 +189,13 @@ } if ( ret < 0 ) { - i_fatal("Can't open delivery mail as raw: %s", - mailbox_get_last_error(mailr->box, NULL)); + if ( mailfile == NULL ) { + i_fatal("Can't open delivery mail as raw: %s", + mailbox_get_last_error(mailr->box, NULL)); + } else { + i_fatal("Can't open delivery mail as raw (file=%s): %s", + mailfile, mailbox_get_last_error(mailr->box, NULL)); + } } mailr->trans = mailbox_transaction_begin(mailr->box, 0); diff -r 7b8cc0897a79 -r b88a6d76839b src/lib-sieve/cmd-redirect.c --- a/src/lib-sieve/cmd-redirect.c Wed Feb 29 20:07:24 2012 +0100 +++ b/src/lib-sieve/cmd-redirect.c Wed Feb 29 22:51:56 2012 +0100 @@ -5,8 +5,8 @@ #include "ioloop.h" #include "str-sanitize.h" #include "istream.h" -#include "istream-crlf.h" #include "istream-header-filter.h" +#include "ostream.h" #include "rfc2822.h" @@ -318,12 +318,9 @@ const struct sieve_script_env *senv = aenv->scriptenv; const char *sender = sieve_message_get_sender(msgctx); const char *recipient = sieve_message_get_final_recipient(msgctx); - struct istream *input, *crlf_input; + struct istream *input; + struct ostream *output; void *smtp_handle; - FILE *f; - const unsigned char *data; - size_t size; - int ret; /* Just to be sure */ if ( !sieve_smtp_available(senv) ) { @@ -336,30 +333,25 @@ return FALSE; /* Open SMTP transport */ - smtp_handle = sieve_smtp_open(senv, ctx->to_address, sender, &f); + smtp_handle = sieve_smtp_open(senv, ctx->to_address, sender, &output); /* Remove unwanted headers */ input = i_stream_create_header_filter - (input, HEADER_FILTER_EXCLUDE, hide_headers, - N_ELEMENTS(hide_headers), null_header_filter_callback, NULL); - - /* Make sure the message contains CRLF consistently */ - crlf_input = i_stream_create_crlf(input); + (input, HEADER_FILTER_EXCLUDE | HEADER_FILTER_NO_CR, hide_headers, + N_ELEMENTS(hide_headers), null_header_filter_callback, NULL); - /* Prepend sieve headers (should not affect signatures) */ - rfc2822_header_field_write(f, "X-Sieve", SIEVE_IMPLEMENTATION); - if ( recipient != NULL ) - rfc2822_header_field_write(f, "X-Sieve-Redirected-From", recipient); + T_BEGIN { + string_t *hdr = t_str_new(256); + + /* Prepend sieve headers (should not affect signatures) */ + rfc2822_header_write(hdr, "X-Sieve", SIEVE_IMPLEMENTATION); + if ( recipient != NULL ) + rfc2822_header_write(hdr, "X-Sieve-Redirected-From", recipient); + o_stream_send(output, str_data(hdr), str_len(hdr)); + } T_END; - /* Pipe the message to the outgoing SMTP transport */ - while ((ret = i_stream_read_data(crlf_input, &data, &size, 0)) > 0) { - if (fwrite(data, size, 1, f) == 0) - break; - i_stream_skip(crlf_input, size); - } - - i_stream_unref(&crlf_input); - i_stream_unref(&input); + o_stream_send_istream(output, input); + i_stream_unref(&input); /* Close SMTP transport */ if ( !sieve_smtp_close(senv, smtp_handle) ) { diff -r 7b8cc0897a79 -r b88a6d76839b src/lib-sieve/edit-mail.c --- a/src/lib-sieve/edit-mail.c Wed Feb 29 20:07:24 2012 +0100 +++ b/src/lib-sieve/edit-mail.c Wed Feb 29 22:51:56 2012 +0100 @@ -762,7 +762,7 @@ message_header_encode(value, enc_value); - lines = rfc2822_header_field_append + lines = rfc2822_header_append (data, field_name, str_c(enc_value), edmail->crlf, &field->body_offset); /* Copy to new field */ diff -r 7b8cc0897a79 -r b88a6d76839b src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c --- a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Wed Feb 29 20:07:24 2012 +0100 +++ b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Wed Feb 29 22:51:56 2012 +0100 @@ -23,6 +23,7 @@ #include "str.h" #include "ioloop.h" #include "str-sanitize.h" +#include "ostream.h" #include "message-date.h" #include "mail-storage.h" @@ -386,9 +387,11 @@ const char *body = mtctx->uri->body; string_t *to, *cc; const struct uri_mailto_recipient *recipients; + const struct uri_mailto_header_field *headers; void *smtp_handle; - unsigned int count, i; - FILE *f; + struct ostream *output; + string_t *msg; + unsigned int count, i, hcount, h; const char *outmsgid; /* Get recipients */ @@ -461,74 +464,81 @@ } } + msg = t_str_new(512); + outmsgid = sieve_message_get_new_id(senv); + + rfc2822_header_write(msg, "X-Sieve", SIEVE_IMPLEMENTATION); + rfc2822_header_write(msg, "Message-ID", outmsgid); + rfc2822_header_write(msg, "Date", message_date_create(ioloop_time)); + rfc2822_header_utf8_printf(msg, "Subject", "%s", subject); + + rfc2822_header_utf8_printf(msg, "From", "%s", from); + + if ( to != NULL ) + rfc2822_header_utf8_printf(msg, "To", "%s", str_c(to)); + + if ( cc != NULL ) + rfc2822_header_utf8_printf(msg, "Cc", "%s", str_c(cc)); + + rfc2822_header_printf(msg, "Auto-Submitted", + "auto-notified; owner-email=\"%s\"", recipient); + rfc2822_header_write(msg, "Precedence", "bulk"); + + /* Set importance */ + switch ( nact->importance ) { + case 1: + rfc2822_header_write(msg, "X-Priority", "1 (Highest)"); + rfc2822_header_write(msg, "Importance", "High"); + break; + case 3: + rfc2822_header_write(msg, "X-Priority", "5 (Lowest)"); + rfc2822_header_write(msg, "Importance", "Low"); + break; + case 2: + default: + rfc2822_header_write(msg, "X-Priority", "3 (Normal)"); + rfc2822_header_write(msg, "Importance", "Normal"); + break; + } + + /* Add custom headers */ + + headers = array_get(&mtctx->uri->headers, &hcount); + for ( h = 0; h < hcount; h++ ) { + const char *name = rfc2822_header_field_name_sanitize(headers[h].name); + + rfc2822_header_write(msg, name, headers[h].body); + } + + /* Generate message body */ + + rfc2822_header_write(msg, "MIME-Version", "1.0"); + if ( body != NULL ) { + if (_contains_8bit(body)) { + rfc2822_header_write + (msg, "Content-Type", "text/plain; charset=utf-8"); + rfc2822_header_write(msg, "Content-Transfer-Encoding", "8bit"); + } else { + rfc2822_header_write + (msg, "Content-Type", "text/plain; charset=us-ascii"); + rfc2822_header_write(msg, "Content-Transfer-Encoding", "7bit"); + } + str_printfa(msg, "\r\n%s\r\n", body); + + } else { + rfc2822_header_write + (msg, "Content-Type", "text/plain; charset=US-ASCII"); + rfc2822_header_write(msg, "Content-Transfer-Encoding", "7bit"); + + str_append(msg, "\r\nNotification of new message.\r\n"); + } + /* Send message to all recipients */ for ( i = 0; i < count; i++ ) { - const struct uri_mailto_header_field *headers; - unsigned int h, hcount; + smtp_handle = sieve_smtp_open + (senv, recipients[i].normalized, from_smtp, &output); - smtp_handle = sieve_smtp_open - (senv, recipients[i].normalized, from_smtp, &f); - outmsgid = sieve_message_get_new_id(senv); - - rfc2822_header_field_write(f, "X-Sieve", SIEVE_IMPLEMENTATION); - rfc2822_header_field_write(f, "Message-ID", outmsgid); - rfc2822_header_field_write(f, "Date", message_date_create(ioloop_time)); - rfc2822_header_field_utf8_printf(f, "Subject", "%s", subject); - - rfc2822_header_field_utf8_printf(f, "From", "%s", from); - - if ( to != NULL ) - rfc2822_header_field_utf8_printf(f, "To", "%s", str_c(to)); - - if ( cc != NULL ) - rfc2822_header_field_utf8_printf(f, "Cc", "%s", str_c(cc)); - - rfc2822_header_field_printf(f, "Auto-Submitted", - "auto-notified; owner-email=\"%s\"", recipient); - rfc2822_header_field_write(f, "Precedence", "bulk"); - - /* Set importance */ - switch ( nact->importance ) { - case 1: - rfc2822_header_field_write(f, "X-Priority", "1 (Highest)"); - rfc2822_header_field_write(f, "Importance", "High"); - break; - case 3: - rfc2822_header_field_write(f, "X-Priority", "5 (Lowest)"); - rfc2822_header_field_write(f, "Importance", "Low"); - break; - case 2: - default: - rfc2822_header_field_write(f, "X-Priority", "3 (Normal)"); - rfc2822_header_field_write(f, "Importance", "Normal"); - break; - } - - /* Add custom headers */ - - headers = array_get(&mtctx->uri->headers, &hcount); - for ( h = 0; h < hcount; h++ ) { - const char *name = rfc2822_header_field_name_sanitize(headers[h].name); - - rfc2822_header_field_write(f, name, headers[h].body); - } - - /* Generate message body */ - if ( body != NULL ) { - if (_contains_8bit(body)) { - rfc2822_header_field_write(f, "MIME-Version", "1.0"); - rfc2822_header_field_write - (f, "Content-Type", "text/plain; charset=UTF-8"); - rfc2822_header_field_write(f, "Content-Transfer-Encoding", "8bit"); - } - - fprintf(f, "\r\n"); - fprintf(f, "%s\r\n", body); - - } else { - fprintf(f, "\r\n"); - fprintf(f, "Notification of new message.\r\n"); - } + o_stream_send(output, str_data(msg), str_len(msg)); if ( sieve_smtp_close(senv, smtp_handle) ) { sieve_enotify_global_info(nenv, @@ -552,6 +562,7 @@ const char *const *headers; const char *sender = sieve_message_get_sender(nenv->msgctx); const char *recipient = sieve_message_get_final_recipient(nenv->msgctx); + bool result; /* Is the recipient unset? */ @@ -578,7 +589,11 @@ } } - return ntfy_mailto_send(nenv, nact, recipient); + T_BEGIN { + result = ntfy_mailto_send(nenv, nact, recipient); + } T_END; + + return result; } diff -r 7b8cc0897a79 -r b88a6d76839b src/lib-sieve/plugins/notify/cmd-notify.c --- a/src/lib-sieve/plugins/notify/cmd-notify.c Wed Feb 29 20:07:24 2012 +0100 +++ b/src/lib-sieve/plugins/notify/cmd-notify.c Wed Feb 29 22:51:56 2012 +0100