dovecot-2.2: Merged changes from v2.1 tree.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Apr 5 00:13:34 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/249305f71c73
changeset: 16198:249305f71c73
user: Timo Sirainen <tss at iki.fi>
date: Fri Apr 05 00:13:16 2013 +0300
description:
Merged changes from v2.1 tree.
diffstat:
.hgsigs | 1 +
.hgtags | 1 +
configure.ac | 3 +
src/auth/auth-request.c | 43 +++++-
src/doveadm/Makefile.am | 1 +
src/doveadm/doveadm-mail-batch.c | 162 +++++++++++++++++++++++
src/doveadm/doveadm-mail.c | 54 +++++--
src/doveadm/doveadm-mail.h | 4 +
src/lib-index/mail-index-transaction-update.c | 4 +-
src/lib-master/mountpoint-list.c | 2 +
src/lib-storage/index/cydir/cydir-storage.c | 2 +-
src/lib-storage/index/dbox-common/dbox-storage.c | 2 +-
src/lib-storage/index/maildir/maildir-storage.c | 2 +-
src/lib-storage/index/mbox/mbox-storage.c | 2 +-
src/lib-storage/index/pop3c/pop3c-storage.c | 2 +-
src/lib-storage/index/raw/raw-storage.c | 2 +-
src/lib-storage/list/mailbox-list-delete.c | 8 +-
src/lib-storage/list/mailbox-list-fs.c | 4 +-
src/lib-storage/list/mailbox-list-maildir.c | 4 +-
src/lib-storage/mailbox-list-private.h | 4 +
src/lib/macros.h | 8 +
src/plugins/acl/acl-mailbox.c | 2 +-
src/plugins/quota/quota-status.c | 36 +++-
src/plugins/virtual/virtual-config.c | 2 +-
24 files changed, 309 insertions(+), 46 deletions(-)
diffs (truncated from 735 to 300 lines):
diff -r c67d787164fa -r 249305f71c73 .hgsigs
--- a/.hgsigs Thu Apr 04 23:35:27 2013 +0300
+++ b/.hgsigs Fri Apr 05 00:13:16 2013 +0300
@@ -58,6 +58,7 @@
b314c97d4bbffd01b20f8492592aa422c13e3d55 0 iEYEABECAAYFAlEJlGMACgkQyUhSUUBVismNdQCgggPP/dt1duU1CMYfkpE4Kyc9Ju0An0kphokRqrtppkeqg7pF1JR01Mgq
fc75811f3c08d80ed339cbb4d37c66f549542ba7 0 iEYEABECAAYFAlEU+CEACgkQyUhSUUBViskh9QCgnqPHUkNvtOioWxo4W7fXjCFLVAwAnR9Z26jgBpoejXDkgwT07wdfYiL3
018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 0 iEYEABECAAYFAlEmOJEACgkQyUhSUUBVismawgCfbfY6KuH+/AauPkRZs4ish20YeV8Ani5DMLh02DUyJvDIpVPJMmTn2Mu/
+582108c190f88597c5215279cb66f74673144c9b 0 iEUEABECAAYFAlFd69UACgkQyUhSUUBVisk/aQCYyYU9JcDM3SrTZu1oJuS26IAnZACeM400zLRROTaM6QYBVKTqTnfpuBY=
508d46f858153c85ae777e87e1c5143a534a51fe 0 iEYEABECAAYFAlErhDkACgkQyUhSUUBViskRdwCeJ61F0qLZ/3xxIQruTujzo0AEWK0An3PH7nkTY7ouyBdUr0QCra5KLXEZ
e62fa121f4a2db3348fd79bb176dd363cc1224bf 0 iEYEABECAAYFAlErsAwACgkQyUhSUUBVismarACbBffm3XY21sfkTsbmF8o8udtRZk4An0ofYy2VminZ3S8EFApHymk/UpNv
11bd79bf4866b0d728b25717134a6ba972505746 0 iEYEABECAAYFAlFKFqsACgkQyUhSUUBVismbSwCdHgMYWjcwcTM7fD4v6wTd/8/8ZEsAn2THId1zYspMTEMtDg0rlrvjlht4
diff -r c67d787164fa -r 249305f71c73 .hgtags
--- a/.hgtags Thu Apr 04 23:35:27 2013 +0300
+++ b/.hgtags Fri Apr 05 00:13:16 2013 +0300
@@ -95,6 +95,7 @@
b314c97d4bbffd01b20f8492592aa422c13e3d55 2.1.14
fc75811f3c08d80ed339cbb4d37c66f549542ba7 2.1.15
018de2aa893a040256cb8cd92b1fc9f3f2bbd09f 2.2.beta2
+582108c190f88597c5215279cb66f74673144c9b 2.1.16
508d46f858153c85ae777e87e1c5143a534a51fe 2.2.rc1
e62fa121f4a2db3348fd79bb176dd363cc1224bf 2.2.rc2
11bd79bf4866b0d728b25717134a6ba972505746 2.2.rc3
diff -r c67d787164fa -r 249305f71c73 configure.ac
--- a/configure.ac Thu Apr 04 23:35:27 2013 +0300
+++ b/configure.ac Fri Apr 05 00:13:16 2013 +0300
@@ -297,6 +297,9 @@
AC_DEFINE_UNQUOTED(DOVECOT_STRING, "$PACKAGE_STRING", Dovecot string)
AC_DEFINE_UNQUOTED(DOVECOT_VERSION, "$PACKAGE_VERSION", Dovecot version)
+AC_DEFINE([DOVECOT_VERSION_MAJOR], regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\)], [\1]), [Dovecot major version])
+AC_DEFINE([DOVECOT_VERSION_MINOR], regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\)], [\2]), [Dovecot minor version])
+
AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h inttypes.h \
sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h \
diff -r c67d787164fa -r 249305f71c73 src/auth/auth-request.c
--- a/src/auth/auth-request.c Thu Apr 04 23:35:27 2013 +0300
+++ b/src/auth/auth-request.c Fri Apr 05 00:13:16 2013 +0300
@@ -1304,6 +1304,18 @@
return TRUE;
}
+static void
+auth_request_passdb_import(struct auth_request *request, const char *args,
+ const char *key_prefix, const char *default_scheme)
+{
+ const char *const *arg, *field;
+
+ for (arg = t_strsplit(args, "\t"); *arg != NULL; arg++) {
+ field = t_strconcat(key_prefix, *arg, NULL);
+ auth_request_set_field_keyvalue(request, field, default_scheme);
+ }
+}
+
void auth_request_set_field(struct auth_request *request,
const char *name, const char *value,
const char *default_scheme)
@@ -1350,6 +1362,17 @@
request->passdb_password = NULL;
auth_fields_add(request->extra_fields, name, value, 0);
return;
+ } else if (strcmp(name, "passdb_import") == 0) {
+ auth_request_passdb_import(request, value, "", default_scheme);
+ return;
+ if (strcmp(name, "userdb_userdb_import") == 0) {
+ /* we need can't put the whole userdb_userdb_import
+ value to extra_cache_fields or it doesn't work
+ properly. so handle this explicitly. */
+ auth_request_passdb_import(request, value,
+ "userdb_", default_scheme);
+ return;
+ }
} else {
/* these fields are returned to client */
auth_fields_add(request->extra_fields, name, value, 0);
@@ -1422,6 +1445,24 @@
}
}
+static void
+auth_request_userdb_import(struct auth_request *request, const char *args)
+{
+ const char *key, *value, *const *arg;
+
+ for (arg = t_strsplit(args, "\t"); *arg != NULL; arg++) {
+ value = strchr(*arg, '=');
+ if (value == NULL) {
+ key = *arg;
+ value = "";
+ } else {
+ key = t_strdup_until(*arg, value);
+ value++;
+ }
+ auth_request_set_userdb_field(request, key, value);
+ }
+}
+
void auth_request_set_userdb_field(struct auth_request *request,
const char *name, const char *value)
{
@@ -1451,7 +1492,7 @@
auth_request_set_uidgid_file(request, value);
return;
} else if (strcmp(name, "userdb_import") == 0) {
- auth_fields_import(request->userdb_reply, value, 0);
+ auth_request_userdb_import(request, value);
return;
} else if (strcmp(name, "system_user") == 0) {
/* FIXME: the system_user is for backwards compatibility */
diff -r c67d787164fa -r 249305f71c73 src/doveadm/Makefile.am
--- a/src/doveadm/Makefile.am Thu Apr 04 23:35:27 2013 +0300
+++ b/src/doveadm/Makefile.am Fri Apr 05 00:13:16 2013 +0300
@@ -61,6 +61,7 @@
common = \
doveadm-mail.c \
doveadm-mail-altmove.c \
+ doveadm-mail-batch.c \
doveadm-mail-expunge.c \
doveadm-mail-fetch.c \
doveadm-mail-import.c \
diff -r c67d787164fa -r 249305f71c73 src/doveadm/doveadm-mail-batch.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/doveadm/doveadm-mail-batch.c Fri Apr 05 00:13:16 2013 +0300
@@ -0,0 +1,162 @@
+/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "array.h"
+#include "doveadm-mail.h"
+
+#include <unistd.h>
+
+struct batch_cmd_context {
+ struct doveadm_mail_cmd_context ctx;
+ ARRAY(struct doveadm_mail_cmd_context *) commands;
+};
+
+static int cmd_batch_prerun(struct doveadm_mail_cmd_context *_ctx,
+ struct mail_storage_service_user *service_user,
+ const char **error_r)
+{
+ struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
+ struct doveadm_mail_cmd_context *const *cmdp;
+ int ret = 0;
+
+ array_foreach(&ctx->commands, cmdp) {
+ if ((*cmdp)->v.prerun != NULL &&
+ (*cmdp)->v.prerun(*cmdp, service_user, error_r) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ return ret;
+}
+
+static int cmd_batch_run(struct doveadm_mail_cmd_context *_ctx,
+ struct mail_user *user)
+{
+ struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
+ struct doveadm_mail_cmd_context *const *cmdp;
+ int ret = 0;
+
+ array_foreach(&ctx->commands, cmdp) {
+ if ((*cmdp)->v.run(*cmdp, user) < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ return ret;
+}
+
+static void
+cmd_batch_add(struct batch_cmd_context *batchctx,
+ int argc, const char *const *argv)
+{
+ struct doveadm_mail_cmd_context *subctx;
+ const struct doveadm_mail_cmd *cmd;
+ const char *getopt_args;
+ int c;
+
+ cmd = doveadm_mail_cmd_find_from_argv(argv[0], &argc, &argv);
+ if (cmd == NULL) {
+ i_fatal_status(EX_USAGE, "doveadm batch: Unknown subcommand %s",
+ argv[1]);
+ }
+
+ subctx = doveadm_mail_cmd_init(cmd, doveadm_settings);
+ subctx->full_args = argv + 1;
+ subctx->service_flags |= batchctx->ctx.service_flags;
+
+ optind = 1;
+ getopt_args = subctx->getopt_args != NULL ? subctx->getopt_args : "";
+ while ((c = getopt(argc, (void *)argv, getopt_args)) > 0) {
+ if (subctx->v.parse_arg == NULL ||
+ !subctx->v.parse_arg(subctx, c))
+ doveadm_mail_help(cmd);
+ }
+ argv += optind;
+ if (argv[0] != NULL && cmd->usage_args == NULL) {
+ i_fatal_status(EX_USAGE, "doveadm %s: Unknown parameter: %s",
+ cmd->name, argv[0]);
+ }
+ subctx->args = argv;
+ if (subctx->v.preinit != NULL)
+ subctx->v.preinit(subctx);
+ array_append(&batchctx->commands, &subctx, 1);
+}
+
+static void
+cmd_batch_preinit(struct doveadm_mail_cmd_context *_ctx)
+{
+ const char *const *args = _ctx->args;
+ struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
+ ARRAY_TYPE(const_string) sep_args;
+ const char *sep = args[0];
+ unsigned int i, start;
+ int argc;
+ const char *const *argv;
+
+ if (sep == NULL || args[1] == NULL)
+ doveadm_mail_help_name("batch");
+ args++;
+
+ p_array_init(&ctx->commands, _ctx->pool, 8);
+ p_array_init(&sep_args, _ctx->pool, 16);
+ for (i = start = 0;; i++) {
+ if (args[i] != NULL && strcmp(args[i], sep) != 0) {
+ array_append(&sep_args, &args[i], 1);
+ continue;
+ }
+ if (i > start) {
+ (void)array_append_space(&sep_args);
+ argc = i - start;
+ argv = array_idx(&sep_args, start);
+ cmd_batch_add(ctx, argc, argv);
+ start = i+1;
+ }
+ if (args[i] == NULL)
+ break;
+ }
+ (void)array_append_space(&sep_args);
+}
+
+static void
+cmd_batch_init(struct doveadm_mail_cmd_context *_ctx,
+ const char *const args[] ATTR_UNUSED)
+{
+ struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
+ struct doveadm_mail_cmd_context *const *cmdp;
+ struct batch_cmd_context *subctx;
+
+ array_foreach(&ctx->commands, cmdp) {
+ subctx = (struct batch_cmd_context *)*cmdp;
+ subctx->ctx.storage_service = _ctx->storage_service;
+ if (subctx->ctx.v.init != NULL)
+ subctx->ctx.v.init(&subctx->ctx, subctx->ctx.args);
+ }
+}
+
+static void cmd_batch_deinit(struct doveadm_mail_cmd_context *_ctx)
+{
+ struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
+ struct doveadm_mail_cmd_context *const *cmdp;
+
+ array_foreach(&ctx->commands, cmdp) {
+ if ((*cmdp)->v.deinit != NULL)
+ (*cmdp)->v.deinit(*cmdp);
+ }
+}
+
+static struct doveadm_mail_cmd_context *cmd_batch_alloc(void)
+{
+ struct batch_cmd_context *ctx;
+
+ ctx = doveadm_mail_cmd_alloc(struct batch_cmd_context);
+ ctx->ctx.v.preinit = cmd_batch_preinit;
+ ctx->ctx.v.init = cmd_batch_init;
+ ctx->ctx.v.prerun = cmd_batch_prerun;
+ ctx->ctx.v.run = cmd_batch_run;
+ ctx->ctx.v.deinit = cmd_batch_deinit;
+ return &ctx->ctx;
+}
+
+struct doveadm_mail_cmd cmd_batch = {
+ cmd_batch_alloc, "batch", "<sep> <cmd1> [<sep> <cmd2> [..]]"
+};
diff -r c67d787164fa -r 249305f71c73 src/doveadm/doveadm-mail.c
--- a/src/doveadm/doveadm-mail.c Thu Apr 04 23:35:27 2013 +0300
+++ b/src/doveadm/doveadm-mail.c Fri Apr 05 00:13:16 2013 +0300
@@ -539,59 +539,78 @@
}
static bool
-doveadm_mail_try_run_multi_word(const struct doveadm_mail_cmd *cmd,
- const char *cmdname, int argc, char *argv[])
+doveadm_mail_cmd_try_find_multi_word(const struct doveadm_mail_cmd *cmd,
+ const char *cmdname, int *argc,
+ const char *const **argv)
{
unsigned int len;
More information about the dovecot-cvs
mailing list