From: Karl Fleischmann Date: Wed, 9 Feb 2022 09:04:36 +0000 (+0100) Subject: imap: Remove X-STATE command X-Git-Tag: 2.4.0~4459 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=26c03fe6abeb7ab9caf37dfa49f4b9edb41cb242;p=thirdparty%2Fdovecot%2Fcore.git imap: Remove X-STATE command This was a Dovecot-specific extension that never even worked. It simply answered "NO Command is disabled for now." --- diff --git a/src/imap/Makefile.am b/src/imap/Makefile.am index 0a45fd3926..3570b66b75 100644 --- a/src/imap/Makefile.am +++ b/src/imap/Makefile.am @@ -65,8 +65,7 @@ cmds = \ cmd-unselect.c \ cmd-unsubscribe.c \ cmd-urlfetch.c \ - cmd-x-cancel.c \ - cmd-x-state.c + cmd-x-cancel.c common_sources = \ $(cmds) \ diff --git a/src/imap/cmd-x-state.c b/src/imap/cmd-x-state.c deleted file mode 100644 index 880999833a..0000000000 --- a/src/imap/cmd-x-state.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */ - -#include "imap-common.h" -#include "base64.h" -#include "str.h" -#include "imap-commands.h" -#include "imap-state.h" - -bool cmd_x_state(struct client_command_context *cmd) -{ - /* FIXME: state importing can cause unnecessarily large memory usage - by specifying an old modseq, because the EXPUNGE/FETCH replies - aren't currently sent asynchronously. so this command is disabled - for now. */ -#if 0 - const struct imap_arg *args; - const char *str, *error; - buffer_t *state, *state_encoded; - int ret; - - if (!client_read_args(cmd, 0, 0, &args)) - return FALSE; - - state = buffer_create_dynamic(cmd->pool, 256); - if (imap_arg_get_astring(&args[0], &str)) { - if (cmd->client->mailbox != NULL) { - client_send_tagline(cmd, - "BAD Can't be used in SELECTED state"); - return TRUE; - } - if (base64_decode(str, strlen(str), NULL, state) < 0) - ret = 0; - else { - ret = imap_state_import_external(cmd->client, - state->data, state->used, &error); - } - if (ret < 0) { - client_send_tagline(cmd, t_strdup_printf( - "NO Failed to restore state: %s", error)); - } else if (ret == 0) { - client_send_tagline(cmd, t_strdup_printf( - "BAD Broken state: %s", error)); - } else { - client_send_tagline(cmd, "OK State imported."); - } - return TRUE; - } else if (args[0].type == IMAP_ARG_EOL) { - if (!imap_state_export_external(cmd->client, state, &error)) { - client_send_tagline(cmd, t_strdup_printf( - "NO Can't save state: %s", error)); - return TRUE; - } - state_encoded = buffer_create_dynamic(cmd->pool, - MAX_BASE64_ENCODED_SIZE(state->used)+10); - str_append(state_encoded, "* STATE "); - base64_encode(state->data, state->used, state_encoded); - client_send_line(cmd->client, str_c(state_encoded)); - client_send_tagline(cmd, "OK State exported."); - return TRUE; - } else { - client_send_command_error(cmd, "Invalid arguments."); - return TRUE; - } -#else - client_send_command_error(cmd, "Command is disabled for now."); - return TRUE; -#endif -} diff --git a/src/imap/imap-commands.c b/src/imap/imap-commands.c index b78d0a17a7..8280e5cdbb 100644 --- a/src/imap/imap-commands.c +++ b/src/imap/imap-commands.c @@ -77,7 +77,6 @@ static const struct command imap_ext_commands[] = { { "UID THREAD", cmd_thread, COMMAND_FLAG_BREAKS_SEQS }, { "UNSELECT", cmd_unselect, COMMAND_FLAG_BREAKS_MAILBOX }, { "X-CANCEL", cmd_x_cancel, 0 }, - { "X-STATE", cmd_x_state, COMMAND_FLAG_REQUIRES_SYNC }, { "XLIST", cmd_list, 0 }, /* IMAP URLAUTH (RFC4467): */ { "GENURLAUTH", cmd_genurlauth, 0 }, diff --git a/src/imap/imap-commands.h b/src/imap/imap-commands.h index 651a6df9d0..df28a65a03 100644 --- a/src/imap/imap-commands.h +++ b/src/imap/imap-commands.h @@ -122,7 +122,6 @@ bool cmd_uid_expunge(struct client_command_context *cmd); bool cmd_move(struct client_command_context *cmd); bool cmd_unselect(struct client_command_context *cmd); bool cmd_x_cancel(struct client_command_context *cmd); -bool cmd_x_state(struct client_command_context *cmd); /* IMAP URLAUTH (RFC4467): */ bool cmd_genurlauth(struct client_command_context *cmd); diff --git a/src/imap/imap-state.c b/src/imap/imap-state.c index 2b064ec809..2298bafc9f 100644 --- a/src/imap/imap-state.c +++ b/src/imap/imap-state.c @@ -91,7 +91,7 @@ import_seq_range(const unsigned char **data, const unsigned char *end, int imap_state_export_internal(struct client *client, buffer_t *dest, const char **error_r) { - /* the only IMAP command we allow running is IDLE or X-STATE */ + /* the only IMAP command we allow running is IDLE */ if (client->command_queue_size > 1) { *error_r = "Multiple commands in progress"; return 0; @@ -107,19 +107,6 @@ int imap_state_export_internal(struct client *client, buffer_t *dest, return client->v.state_export(client, TRUE, dest, error_r); } -int imap_state_export_external(struct client *client, buffer_t *dest, - const char **error_r) -{ - if (client->command_queue_size > 1) { - *error_r = "Multiple commands in progress"; - return 0; - } - - i_assert(client->command_queue_size == 1); - i_assert(strcmp(client->command_queue->name, "X-STATE") == 0); - return client->v.state_export(client, FALSE, dest, error_r); -} - static int imap_state_import(struct client *client, bool internal, const unsigned char *data, size_t size, const char **error_r) diff --git a/src/imap/imap-state.h b/src/imap/imap-state.h index ee0037607e..f95337e4cb 100644 --- a/src/imap/imap-state.h +++ b/src/imap/imap-state.h @@ -5,8 +5,6 @@ 0 if state couldn't be exported, -1 if temporary internal error error. */ int imap_state_export_internal(struct client *client, buffer_t *dest, const char **error_r); -int imap_state_export_external(struct client *client, buffer_t *dest, - const char **error_r); /* Returns 1 if ok, 0 if state was corrupted, -1 if other error. Internal state comes from another Dovecot component, which can override IP addresses,