From 10afc1ce1c87fe55368f3dbed5ea2e1e231244dc Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Tue, 19 Sep 2023 10:22:11 +0300 Subject: [PATCH] quota: quota-status - Allow empty recipient in END-OF-MESSAGE state When a message has multiple recipients, a policy server server will receive an empty "recipient=" list in the END-OF-MESSAGE state, which needs to be accepted in quota-status server. Adapted from patch made by Jesse Norell --- src/plugins/quota/quota-status.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/quota/quota-status.c b/src/plugins/quota/quota-status.c index 7c8d4edd38..826c183dce 100644 --- a/src/plugins/quota/quota-status.c +++ b/src/plugins/quota/quota-status.c @@ -100,7 +100,9 @@ quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r) static int client_check_mta_state(struct quota_client *client) { - if (client->state == NULL || strcasecmp(client->state, "RCPT") == 0) + if (client->state == NULL || + strcasecmp(client->state, "RCPT") == 0 || + strcasecmp(client->state, "END-OF-MESSAGE") == 0) return 0; if (!client->warned_bad_state) { @@ -124,6 +126,16 @@ static void client_handle_request(struct quota_client *client) string_t *resp; int ret; + /* this comes in with multiple recipient, and we can reply + dunno here. It provides the number of recipients that Postfix + accepted for the current message */ + if (client->state != NULL && client->recipient == NULL && + strcasecmp(client->state, "END-OF-MESSAGE") == 0) { + e_debug(client->event, "Response: action=DUNNO"); + o_stream_nsend_str(client->conn.output, "action=DUNNO\n\n"); + return; + } + if (client_check_mta_state(client) < 0 || client->recipient == NULL) { e_debug(client->event, "Response: action=DUNNO"); o_stream_nsend_str(client->conn.output, "action=DUNNO\n\n"); @@ -229,7 +241,7 @@ static int client_input_line(struct connection *conn, const char *line) } if (str_begins(line, "recipient=", &value)) { if (client->recipient == NULL) - client->recipient = i_strdup(value); + client->recipient = i_strdup_empty(value); } else if (str_begins(line, "size=", &value)) { if (str_to_uoff(value, &client->size) < 0) client->size = 0; -- 2.47.3