From 48d52cc47c32d2b41c9b032cdab69e1ca08a8320 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 3 Dec 2024 23:05:04 +0900 Subject: [PATCH 1/2] in_forward: Support empty_shared_key parameter Signed-off-by: Hiroshi Hatake --- plugins/in_forward/fw.c | 5 +++++ plugins/in_forward/fw.h | 1 + plugins/in_forward/fw_config.c | 13 ++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/in_forward/fw.c b/plugins/in_forward/fw.c index 20c3946b5ff..2a78e028a76 100644 --- a/plugins/in_forward/fw.c +++ b/plugins/in_forward/fw.c @@ -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..85995afb753 100644 --- a/plugins/in_forward/fw_config.c +++ b/plugins/in_forward/fw_config.c @@ -86,8 +86,19 @@ struct flb_in_fw_config *fw_config_init(struct flb_input_instance *i_ins) } /* Shared Key */ + p = flb_input_get_property("empty_shared_key", i_ins); + if (p && flb_utils_bool(p)) { + config->empty_shared_key = FLB_TRUE; + } + else { + config->empty_shared_key = FLB_FALSE; + } + p = flb_input_get_property("shared_key", i_ins); - if (p) { + if (config->empty_shared_key) { + config->shared_key = flb_sds_create(""); + } + else if (p) { config->shared_key = flb_sds_create(p); } else { From fcda5799ea8fe8f90e92d793ca4dec5f22f78d02 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 6 Dec 2024 15:34:12 +0900 Subject: [PATCH 2/2] in_forward: Address review comments Signed-off-by: Hiroshi Hatake --- plugins/in_forward/fw.c | 2 +- plugins/in_forward/fw_config.c | 18 +++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/plugins/in_forward/fw.c b/plugins/in_forward/fw.c index 2a78e028a76..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" }, { diff --git a/plugins/in_forward/fw_config.c b/plugins/in_forward/fw_config.c index 85995afb753..f1b33136587 100644 --- a/plugins/in_forward/fw_config.c +++ b/plugins/in_forward/fw_config.c @@ -86,24 +86,12 @@ struct flb_in_fw_config *fw_config_init(struct flb_input_instance *i_ins) } /* Shared Key */ - p = flb_input_get_property("empty_shared_key", i_ins); - if (p && flb_utils_bool(p)) { - config->empty_shared_key = FLB_TRUE; - } - else { - config->empty_shared_key = FLB_FALSE; - } - - p = flb_input_get_property("shared_key", i_ins); if (config->empty_shared_key) { + if (config->shared_key) { + flb_sds_destroy(config->shared_key); + } config->shared_key = flb_sds_create(""); } - else if (p) { - config->shared_key = flb_sds_create(p); - } - else { - config->shared_key = NULL; - } /* Self Hostname */ p = flb_input_get_property("self_hostname", i_ins);