]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp, lmtp, submission: Move adding "(state=%s)" in disconnection reason to lib...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 5 Mar 2021 15:03:11 +0000 (17:03 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Mar 2021 11:19:09 +0000 (11:19 +0000)
The following changes will break this in submission and lmtp. The state
will be reset before conn_disconnect() is called, so they would always log
state=READY.

src/lib-smtp/smtp-server-connection.c
src/lib-smtp/smtp-server.c
src/lib-smtp/smtp-server.h
src/lmtp/lmtp-client.c
src/submission-login/client.c
src/submission/submission-client.c

index c0ee9428ed4ba5cfa3ca97bec1018612915fbb13..c462238f5a953a19e9f6523b2992d4beb2aad074 100644 (file)
@@ -1074,6 +1074,10 @@ smtp_server_connection_disconnect(struct smtp_server_connection *conn,
                reason = t_strdup_printf("%s (unfinished %s command)",
                        reason, cmd->reg->name);
        }
+       if (!conn->set.no_state_in_reason) {
+               reason = t_strdup_printf("%s (state=%s)", reason,
+                       smtp_server_state_names[conn->state.state]);
+       }
 
        e_debug(conn->event, "Disconnected: %s", reason);
        conn->disconnect_reason = i_strdup(reason);
index d70c61b74ea775282eb50011b60cf9f144e71359..f48b60a15915f8dee2767b16e3742cf30587d715 100644 (file)
@@ -84,6 +84,7 @@ struct smtp_server *smtp_server_init(const struct smtp_server_settings *set)
        server->set.rcpt_domain_optional = set->rcpt_domain_optional;
        server->set.mail_path_allow_broken = set->mail_path_allow_broken;
        server->set.debug = set->debug;
+       server->set.no_state_in_reason = set->no_state_in_reason;
 
        /* There is no event log prefix added here, since the server itself does
           not log anything. */
index 0e91c6b83593df88108aaa9cedcf411ab7caca52..e7f29830936e4f0000abede90019c1d7dbfd1e9b 100644 (file)
@@ -396,6 +396,8 @@ struct smtp_server_settings {
        /* The path provided to the RCPT command does not need to have the
           domain part. */
        bool rcpt_domain_optional:1;
+       /* Don't include "(state=%s)" in the disconnection reason string. */
+       bool no_state_in_reason:1;
 };
 
 struct smtp_server_stats {
index 498367f3d07380c3fc2f27150d6be9c7de71a686..c55e4f78013737056ff4a70eea1aea970c2eb173 100644 (file)
@@ -291,9 +291,8 @@ void client_disconnect(struct client *client, const char *enh_code,
 
        if (reason == NULL)
                reason = "Connection closed";
-       e_info(client->event, "Disconnect from %s: %s (state=%s)",
-              client_remote_id(client), reason,
-                               smtp_server_state_names[client->state.state]);
+       e_info(client->event, "Disconnect from %s: %s",
+              client_remote_id(client), reason);
 
        if (conn != NULL) {
                smtp_server_connection_terminate(
index 43ae9ee7c05bd9928a1b8280f4b7d6b7d2be2127..479eb0d806c4cae33c2698141295d4b2312c750e 100644 (file)
@@ -256,6 +256,9 @@ static void submission_login_init(void)
        smtp_server_set.protocol = SMTP_PROTOCOL_SMTP;
        smtp_server_set.max_pipelined_commands = 5;
        smtp_server_set.max_bad_commands = CLIENT_MAX_BAD_COMMANDS;
+       /* Pre-auth state is always logged either as GREETING or READY.
+          It's not very useful. */
+       smtp_server_set.no_state_in_reason = TRUE;
        smtp_server = smtp_server_init(&smtp_server_set);
 }
 
index c40f6d34749776d3669f3fda8a4a3be5d0ccbbba..bda83b3b25691b5556d766e07eefb0009a47c821 100644 (file)
@@ -468,10 +468,9 @@ void client_disconnect(struct client *client, const char *enh_code,
                log_reason = reason = "Connection closed";
        else
                log_reason = t_str_oneline(reason);
-       i_info("Disconnect from %s: %s %s (state=%s)",
+       i_info("Disconnect from %s: %s %s",
               client_remote_id(client),
-              log_reason, client_stats(client),
-              smtp_server_state_names[client->state.state]);
+              log_reason, client_stats(client));
 
        conn = client->conn;
        client->conn = NULL;