From: Markus Valentin Date: Thu, 1 Dec 2022 10:13:16 +0000 (+0100) Subject: dict: Implement DICT_PROTOCOL_CMD_HIDE_LOG_VALUES for dict and dict-proxy X-Git-Tag: 2.4.0~3310 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ddf4bb6a7ec461569476a52b4a67255507d1569;p=thirdparty%2Fdovecot%2Fcore.git dict: Implement DICT_PROTOCOL_CMD_HIDE_LOG_VALUES for dict and dict-proxy --- diff --git a/src/dict/dict-commands.c b/src/dict/dict-commands.c index 9fe536d4e0..d4a3f99df1 100644 --- a/src/dict/dict-commands.c +++ b/src/dict/dict-commands.c @@ -5,6 +5,7 @@ #include "ostream.h" #include "str.h" #include "strescape.h" +#include "str-parse.h" #include "stats-dist.h" #include "time-util.h" #include "dict-private.h" @@ -597,6 +598,27 @@ static int cmd_timestamp(struct dict_connection_cmd *cmd, const char *const *arg return 0; } +static int +cmd_hide_log_values(struct dict_connection_cmd *cmd, const char *const *args) +{ + struct dict_connection_transaction *trans; + const char *error; + bool value; + + /* */ + if (str_array_length(args) != 2 || + str_parse_get_bool(args[1], &value, &error) < 0) { + e_error(cmd->event, "HIDE_LOG_VALUES: broken input"); + return -1; + } + + if (dict_connection_transaction_lookup_parse(cmd->conn, args[0], &trans) < 0) + return -1; + + dict_transaction_set_hide_log_values(trans->ctx, value); + return 0; +} + static const struct dict_cmd_func cmds[] = { { DICT_PROTOCOL_CMD_LOOKUP, cmd_lookup }, { DICT_PROTOCOL_CMD_ITERATE, cmd_iterate }, @@ -607,6 +629,7 @@ static const struct dict_cmd_func cmds[] = { { DICT_PROTOCOL_CMD_UNSET, cmd_unset }, { DICT_PROTOCOL_CMD_ATOMIC_INC, cmd_atomic_inc }, { DICT_PROTOCOL_CMD_TIMESTAMP, cmd_timestamp }, + { DICT_PROTOCOL_CMD_HIDE_LOG_VALUES, cmd_hide_log_values }, { 0, NULL } }; diff --git a/src/lib-dict/dict-client.c b/src/lib-dict/dict-client.c index 2ecaa1ecfd..8f1d68af75 100644 --- a/src/lib-dict/dict-client.c +++ b/src/lib-dict/dict-client.c @@ -1478,6 +1478,21 @@ static void client_dict_set_timestamp(struct dict_transaction_context *_ctx, client_dict_send_transaction_query(ctx, query); } +static void client_dict_set_hide_log_values(struct dict_transaction_context *_ctx, + bool hide_log_values) +{ + struct client_dict_transaction_context *ctx = + container_of(_ctx, struct client_dict_transaction_context, ctx); + const char *query; + + query = t_strdup_printf("%c%u\t%s", + DICT_PROTOCOL_CMD_HIDE_LOG_VALUES, + ctx->id, + hide_log_values ? "yes" : "no"); + + client_dict_send_transaction_query(ctx, query); +} + struct dict dict_driver_client = { .name = "proxy", .flags = DICT_DRIVER_FLAG_SUPPORT_EXPIRE_SECS, @@ -1498,5 +1513,6 @@ struct dict dict_driver_client = { .lookup_async = client_dict_lookup_async, .switch_ioloop = client_dict_switch_ioloop, .set_timestamp = client_dict_set_timestamp, + .set_hide_log_values = client_dict_set_hide_log_values, } }; diff --git a/src/lib-dict/dict-client.h b/src/lib-dict/dict-client.h index 909529a758..2bb940db8b 100644 --- a/src/lib-dict/dict-client.h +++ b/src/lib-dict/dict-client.h @@ -25,6 +25,7 @@ enum dict_protocol_cmd { DICT_PROTOCOL_CMD_UNSET = 'U', /* */ DICT_PROTOCOL_CMD_ATOMIC_INC = 'A', /* */ DICT_PROTOCOL_CMD_TIMESTAMP = 'T', /* */ + DICT_PROTOCOL_CMD_HIDE_LOG_VALUES = 'V', /* */ }; enum dict_protocol_reply {