From be709b9f4ed5e03f8ad9fff4dc334cb5b906ed6d Mon Sep 17 00:00:00 2001 From: Markus Valentin Date: Thu, 1 Dec 2022 11:03:26 +0100 Subject: [PATCH] lib-dict: Add .set_hide_log_values() to dict vfuncs This is used to set hide_log_values in dict op settings. --- src/lib-dict/dict-private.h | 4 ++++ src/lib-dict/dict.c | 10 ++++++++++ src/lib-dict/dict.h | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/lib-dict/dict-private.h b/src/lib-dict/dict-private.h index e5ec5e3d64..735417558b 100644 --- a/src/lib-dict/dict-private.h +++ b/src/lib-dict/dict-private.h @@ -48,6 +48,8 @@ struct dict_vfuncs { bool (*switch_ioloop)(struct dict *dict); void (*set_timestamp)(struct dict_transaction_context *ctx, const struct timespec *ts); + void (*set_hide_log_values)(struct dict_transaction_context *ctx, + bool hide_log_values); }; struct dict_commit_callback_ctx; @@ -55,6 +57,8 @@ struct dict_commit_callback_ctx; struct dict_op_settings_private { char *username; char *home_dir; + + bool hide_log_values; }; struct dict { diff --git a/src/lib-dict/dict.c b/src/lib-dict/dict.c index cdaec09ee0..bda34ae752 100644 --- a/src/lib-dict/dict.c +++ b/src/lib-dict/dict.c @@ -507,6 +507,15 @@ void dict_transaction_no_slowness_warning(struct dict_transaction_context *ctx) ctx->no_slowness_warning = TRUE; } +void dict_transaction_set_hide_log_values(struct dict_transaction_context *ctx, + bool hide_log_values) +{ + /* Apply hide_log_values to the current transactions dict op settings */ + ctx->set.hide_log_values = hide_log_values; + if (ctx->dict->v.set_hide_log_values != NULL) + ctx->dict->v.set_hide_log_values(ctx, hide_log_values); +} + void dict_transaction_set_timestamp(struct dict_transaction_context *ctx, const struct timespec *ts) { @@ -750,6 +759,7 @@ void dict_op_settings_dup(const struct dict_op_settings *source, i_zero(dest_r); dest_r->username = i_strdup(source->username); dest_r->home_dir = i_strdup(source->home_dir); + dest_r->hide_log_values = source->hide_log_values; } void dict_op_settings_private_free(struct dict_op_settings_private *set) diff --git a/src/lib-dict/dict.h b/src/lib-dict/dict.h index 8e4b39e51f..8cac9c7393 100644 --- a/src/lib-dict/dict.h +++ b/src/lib-dict/dict.h @@ -41,6 +41,9 @@ struct dict_op_settings { const char *username; /* home directory for the user, if known */ const char *home_dir; + + /* Hide values when logging about this transaction. */ + bool hide_log_values; }; struct dict_lookup_result { @@ -157,6 +160,11 @@ void dict_transaction_no_slowness_warning(struct dict_transaction_context *ctx); dict-sql with Cassandra backend does anything with this. */ void dict_transaction_set_timestamp(struct dict_transaction_context *ctx, const struct timespec *ts); + +/* Set hide_log_values for the transaction. Currently only + dict-sql with Cassandra backend does anything with this. */ +void dict_transaction_set_hide_log_values(struct dict_transaction_context *ctx, + bool hide_log_values); /* Commit the transaction. Returns 1 if ok, 0 if dict_atomic_inc() was used on a nonexistent key, -1 if failed. */ int dict_transaction_commit(struct dict_transaction_context **ctx, -- 2.47.3