Mercurial > dovecot > core-2.2
changeset 20783:d4e87f66fdea
doveadm-import: Add -U parameter to specify source user
When doing import, you can specify which user to use
as source user.
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Thu, 29 Sep 2016 10:17:05 +0300 |
parents | f2f0495af580 |
children | 16517812f2cb |
files | src/doveadm/doveadm-mail-import.c |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/doveadm-mail-import.c Thu Sep 29 10:15:24 2016 +0300 +++ b/src/doveadm/doveadm-mail-import.c Thu Sep 29 10:17:05 2016 +0300 @@ -14,6 +14,7 @@ struct doveadm_mail_cmd_context ctx; const char *src_location; + const char *src_username; struct mail_user *src_user; const char *dest_parent; bool subscribe; @@ -163,7 +164,9 @@ /* create a user for accessing the source storage */ memset(&input, 0, sizeof(input)); input.module = "mail"; - input.username = dest_user->username; + input.username = ctx->src_username != NULL ? + ctx->src_username : + dest_user->username; input.flags_override_add = MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES | MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS; @@ -227,6 +230,9 @@ struct import_cmd_context *ctx = (struct import_cmd_context *)_ctx; switch (c) { + case 'U': + ctx->src_username = p_strdup(_ctx->pool, optarg); + break; case 's': ctx->subscribe = TRUE; break; @@ -252,9 +258,10 @@ struct doveadm_cmd_ver2 doveadm_cmd_import_ver2 = { .name = "import", .mail_cmd = cmd_import_alloc, - .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "[-s] <source mail location> <dest parent mailbox> <search query>", + .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "[-U source-user] [-s] <source mail location> <dest parent mailbox> <search query>", DOVEADM_CMD_PARAMS_START DOVEADM_CMD_MAIL_COMMON +DOVEADM_CMD_PARAM('U', "source-user", CMD_PARAM_STR, 0) DOVEADM_CMD_PARAM('s', "subscribe", CMD_PARAM_BOOL, 0) DOVEADM_CMD_PARAM('\0', "source-location", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL) DOVEADM_CMD_PARAM('\0', "dest-parent-mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)