From 412d3ea818d573b2f305bfc586373b998b9dbc5d Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 6 Dec 2024 23:28:23 +0900 Subject: [PATCH] in_forward: Support empty_shared_key parameter (#9681) * in_forward: Support empty_shared_key parameter --------- Signed-off-by: Hiroshi Hatake --- plugins/in_forward/fw.c | 7 ++++++- plugins/in_forward/fw.h | 1 + plugins/in_forward/fw_config.c | 11 +++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/in_forward/fw.c b/plugins/in_forward/fw.c index 20c3946b5ff..e692f674cd1 100644 --- a/plugins/in_forward/fw.c +++ b/plugins/in_forward/fw.c @@ -415,7 +415,7 @@ static struct flb_config_map config_map[] = { }, { FLB_CONFIG_MAP_STR, "shared_key", NULL, - 0, FLB_FALSE, 0, + 0, FLB_TRUE, offsetof(struct flb_in_fw_config, shared_key), "Shared key for authentication" }, { @@ -448,6 +448,11 @@ static struct flb_config_map config_map[] = { 0, FLB_TRUE, offsetof(struct flb_in_fw_config, buffer_max_size), "The maximum buffer memory size used to receive a Forward message." }, + { + FLB_CONFIG_MAP_BOOL, "empty_shared_key", "false", + 0, FLB_TRUE, offsetof(struct flb_in_fw_config, empty_shared_key), + "Set an empty shared key for authentication" + }, {0} }; diff --git a/plugins/in_forward/fw.h b/plugins/in_forward/fw.h index 4cd270e27a2..032371b7d3a 100644 --- a/plugins/in_forward/fw.h +++ b/plugins/in_forward/fw.h @@ -63,6 +63,7 @@ struct flb_in_fw_config { flb_sds_t shared_key; /* shared key */ flb_sds_t self_hostname; /* hostname used in certificate */ struct mk_list users; /* username and password pairs */ + int empty_shared_key; /* use an empty string as shared key */ int coll_fd; struct flb_downstream *downstream; /* Client manager */ diff --git a/plugins/in_forward/fw_config.c b/plugins/in_forward/fw_config.c index b3a22931ffd..f1b33136587 100644 --- a/plugins/in_forward/fw_config.c +++ b/plugins/in_forward/fw_config.c @@ -86,12 +86,11 @@ struct flb_in_fw_config *fw_config_init(struct flb_input_instance *i_ins) } /* Shared Key */ - p = flb_input_get_property("shared_key", i_ins); - if (p) { - config->shared_key = flb_sds_create(p); - } - else { - config->shared_key = NULL; + if (config->empty_shared_key) { + if (config->shared_key) { + flb_sds_destroy(config->shared_key); + } + config->shared_key = flb_sds_create(""); } /* Self Hostname */