From: Aki Tuomi Date: Mon, 27 Feb 2017 17:04:55 +0000 (+0200) Subject: doveadm: Fix allow-empty-mailbox-name handling X-Git-Tag: 2.3.0.rc1~1987 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9384ef699a57687ce6dbdae7d686181f4791b1e5;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Fix allow-empty-mailbox-name handling It was supposed to be handled for metadata commands only. Broken in 26c41874cf6019c3e39f0ed630b2a07a92b2635f --- diff --git a/src/doveadm/doveadm-mail-mailbox-metadata.c b/src/doveadm/doveadm-mail-mailbox-metadata.c index 5abce9a60f..b53d903f35 100644 --- a/src/doveadm/doveadm-mail-mailbox-metadata.c +++ b/src/doveadm/doveadm-mail-mailbox-metadata.c @@ -15,6 +15,7 @@ struct metadata_cmd_context { const char *key; struct mail_attribute_value value; bool empty_mailbox_name; + bool allow_empty_mailbox_name; }; static int @@ -27,7 +28,7 @@ cmd_mailbox_metadata_open_mailbox(struct metadata_cmd_context *mctx, 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 @@ cmd_mailbox_metadata_set_init(struct doveadm_mail_cmd_context *_ctx, 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 @@ static struct doveadm_mail_cmd_context *cmd_mailbox_metadata_unset_alloc(void) 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; } @@ -226,6 +245,7 @@ static struct doveadm_mail_cmd_context *cmd_mailbox_metadata_get_alloc(void) 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; @@ -304,6 +324,7 @@ static struct doveadm_mail_cmd_context *cmd_mailbox_metadata_list_alloc(void) 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; diff --git a/src/doveadm/doveadm-mail.c b/src/doveadm/doveadm-mail.c index c0b9e6be12..26a5a2beb8 100644 --- a/src/doveadm/doveadm-mail.c +++ b/src/doveadm/doveadm-mail.c @@ -1023,10 +1023,6 @@ doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx) } 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 */ diff --git a/src/doveadm/doveadm-mail.h b/src/doveadm/doveadm-mail.h index 7295e69175..b1e935fef0 100644 --- a/src/doveadm/doveadm-mail.h +++ b/src/doveadm/doveadm-mail.h @@ -101,9 +101,6 @@ struct doveadm_mail_cmd_context { bool add_username_header:1; /* Running from CLI doveadm (not doveadm-server) */ bool cli:1; - - /* Allow empty mailbox name - to allow access to server attributes */ - bool allow_empty_mailbox_name:1; }; struct doveadm_mail_cmd {