Skip to content

Commit 5bf6923

Browse files
cosmo0920edsiper
authored andcommitted
in_forward: Fix user authentication mechanism to align Fluentd behavior
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 4d9593e commit 5bf6923

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

plugins/in_forward/fw.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ static int in_fw_init(struct flb_input_instance *ins,
333333
return -1;
334334
}
335335

336+
/* Users-only configuration must be rejected unless a (possibly empty) shared key is enabled. */
337+
if (mk_list_size(&ctx->users) > 0 &&
338+
ctx->shared_key == NULL &&
339+
ctx->empty_shared_key == FLB_FALSE) {
340+
flb_plg_error(ctx->ins, "security.users is set but no shared_key or empty_shared_key");
341+
fw_config_destroy(ctx);
342+
return -1;
343+
}
344+
336345
flb_input_downstream_set(ctx->downstream, ctx->ins);
337346

338347
flb_net_socket_nonblocking(ctx->downstream->server_fd);

plugins/in_forward/fw_conn.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,18 @@ struct fw_conn *fw_conn_add(struct flb_connection *connection, struct flb_in_fw_
142142
}
143143

144144
conn->handshake_status = FW_HANDSHAKE_ESTABLISHED;
145-
if (ctx->shared_key != NULL) {
145+
/*
146+
* Always force the secure-forward handshake when:
147+
* - a shared key is configured, or
148+
* - empty_shared_key is enabled (empty string shared key), or
149+
* - user authentication is configured (users > 0).
150+
*
151+
* This closes the gap where "users-only" previously skipped authentication entirely.
152+
*/
153+
conn->handshake_status = FW_HANDSHAKE_ESTABLISHED; /* default */
154+
if (ctx->shared_key != NULL ||
155+
ctx->empty_shared_key == FLB_TRUE ||
156+
mk_list_size(&ctx->users) > 0) {
146157
conn->handshake_status = FW_HANDSHAKE_HELO;
147158
helo = flb_calloc(1, sizeof(struct flb_in_fw_helo));
148159
if (!helo) {

0 commit comments

Comments
 (0)