Mercurial > dovecot > core-2.2
changeset 21708:a7295bb1a998
doveadm: Fix allow-empty-mailbox-name handling
It was supposed to be handled for metadata commands only.
Broken in 26c41874cf6019c3e39f0ed630b2a07a92b2635f
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Mon, 27 Feb 2017 19:04:55 +0200 |
parents | 6441d69cdfb6 |
children | 27554e9ede9f |
files | src/doveadm/doveadm-mail-mailbox-metadata.c src/doveadm/doveadm-mail.c src/doveadm/doveadm-mail.h |
diffstat | 3 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/doveadm-mail-mailbox-metadata.c Mon Feb 27 14:21:48 2017 +0200 +++ b/src/doveadm/doveadm-mail-mailbox-metadata.c Mon Feb 27 19:04:55 2017 +0200 @@ -15,6 +15,7 @@ const char *key; struct mail_attribute_value value; bool empty_mailbox_name; + bool allow_empty_mailbox_name; }; static int @@ -27,7 +28,7 @@ mctx->empty_mailbox_name = mctx->mailbox[0] == '\0'; if (mctx->empty_mailbox_name) { - if (!mctx->ctx.allow_empty_mailbox_name) { + if (!mctx->allow_empty_mailbox_name) { i_error("Failed to %s: %s", op, "mailbox name cannot be empty"); mctx->ctx.exit_code = EX_USAGE; @@ -135,12 +136,29 @@ ctx->value.value = p_strdup(_ctx->pool, args[2]); } +static bool +cmd_mailbox_metadata_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c) +{ + struct metadata_cmd_context *ctx = + (struct metadata_cmd_context *)_ctx; + + switch (c) { + case 's': + ctx->allow_empty_mailbox_name = TRUE; + break; + default: + return FALSE; + } + return TRUE; +} + static struct doveadm_mail_cmd_context *cmd_mailbox_metadata_set_alloc(void) { struct metadata_cmd_context *ctx; ctx = doveadm_mail_cmd_alloc(struct metadata_cmd_context); ctx->ctx.v.init = cmd_mailbox_metadata_set_init; + ctx->ctx.v.parse_arg = cmd_mailbox_metadata_parse_arg; ctx->ctx.v.run = cmd_mailbox_metadata_set_run; return &ctx->ctx; } @@ -166,6 +184,7 @@ ctx = doveadm_mail_cmd_alloc(struct metadata_cmd_context); ctx->ctx.v.init = cmd_mailbox_metadata_unset_init; + ctx->ctx.v.parse_arg = cmd_mailbox_metadata_parse_arg; ctx->ctx.v.run = cmd_mailbox_metadata_set_run; return &ctx->ctx; } @@ -230,6 +249,7 @@ ctx = doveadm_mail_cmd_alloc(struct metadata_cmd_context); ctx->ctx.v.init = cmd_mailbox_metadata_get_init; + ctx->ctx.v.parse_arg = cmd_mailbox_metadata_parse_arg; ctx->ctx.v.run = cmd_mailbox_metadata_get_run; doveadm_print_init(DOVEADM_PRINT_TYPE_FLOW); return &ctx->ctx; @@ -308,6 +328,7 @@ ctx = doveadm_mail_cmd_alloc(struct metadata_cmd_context); ctx->ctx.v.init = cmd_mailbox_metadata_list_init; + ctx->ctx.v.parse_arg = cmd_mailbox_metadata_parse_arg; ctx->ctx.v.run = cmd_mailbox_metadata_list_run; doveadm_print_init(DOVEADM_PRINT_TYPE_FLOW); return &ctx->ctx;
--- a/src/doveadm/doveadm-mail.c Mon Feb 27 14:21:48 2017 +0200 +++ b/src/doveadm/doveadm-mail.c Mon Feb 27 19:04:55 2017 +0200 @@ -1024,10 +1024,6 @@ } mctx->cmd_input = arg->value.v_istream; i_stream_ref(mctx->cmd_input); - } else if (strcmp(arg->name, "allow-empty-mailbox-name") == 0) { - /* allow an empty mailbox name - to access server - attributes */ - mctx->allow_empty_mailbox_name = arg->value.v_bool; /* Keep all named special parameters above this line */
--- a/src/doveadm/doveadm-mail.h Mon Feb 27 14:21:48 2017 +0200 +++ b/src/doveadm/doveadm-mail.h Mon Feb 27 19:04:55 2017 +0200 @@ -101,9 +101,6 @@ unsigned int add_username_header:1; /* Running from CLI doveadm (not doveadm-server) */ unsigned int cli:1; - - /* Allow empty mailbox name - to allow access to server attributes */ - unsigned int allow_empty_mailbox_name:1; }; struct doveadm_mail_cmd {