From: Timo Sirainen Date: Tue, 25 Mar 2025 09:18:36 +0000 (+0200) Subject: doveadm: Add who_filter.username_wildcards helper boolean X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b9845dcb0e41855f786a7a7558bcbdffc2fa23f;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Add who_filter.username_wildcards helper boolean Simplifies the next commit. --- diff --git a/src/doveadm/doveadm-kick.c b/src/doveadm/doveadm-kick.c index e04c925825..380467a013 100644 --- a/src/doveadm/doveadm-kick.c +++ b/src/doveadm/doveadm-kick.c @@ -153,7 +153,7 @@ static void cmd_kick(struct doveadm_cmd_context *cctx) if (ctx.who.filter.net_bits == 0 && ctx.who.filter.dest_ip.family == 0 && - strpbrk(ctx.who.filter.username, "*?") == NULL) { + !ctx.who.filter.username_wildcards) { /* kick a single [alternative] user's all connections */ p_array_init(&ctx.kicks, ctx.who.pool, 1); struct kick_session *session = array_append_space(&ctx.kicks); diff --git a/src/doveadm/doveadm-who.c b/src/doveadm/doveadm-who.c index 07fdb168ed..336112028c 100644 --- a/src/doveadm/doveadm-who.c +++ b/src/doveadm/doveadm-who.c @@ -180,6 +180,8 @@ who_parse_masks(struct who_context *ctx, const char *const *masks) return -1; } ctx->filter.username = masks[i]; + if (strpbrk(masks[i], "*?") != NULL) + ctx->filter.username_wildcards = TRUE; } } return 0; diff --git a/src/doveadm/doveadm-who.h b/src/doveadm/doveadm-who.h index 403b4abb73..f068b1c14f 100644 --- a/src/doveadm/doveadm-who.h +++ b/src/doveadm/doveadm-who.h @@ -16,6 +16,7 @@ struct who_line { struct who_filter { const char *username; + bool username_wildcards; const char *alt_username_field; unsigned int alt_username_idx;