]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Add "auth-legacy" listener type
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 3 Feb 2025 08:03:42 +0000 (10:03 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:16 +0000 (12:34 +0200)
This is needed at least by Exim authentication until it gets updated.

src/auth/auth-client-connection.c
src/auth/auth-client-connection.h
src/auth/main.c

index b890ba35373a9d04ba31c83c2f3de418439fa8de..99f00d4ed1476f30323996104a61718295462bed 100644 (file)
@@ -188,6 +188,9 @@ static void auth_client_finish_handshake(struct auth_client_connection *conn)
        const char *mechanisms, *mechanisms_cbind = "";
        string_t *str;
 
+       if (conn->handshake_finished)
+               return;
+
        if (conn->token_auth) {
                mechanisms = t_strconcat("MECH\t",
                        mech_dovecot_token.mech_name, "\tprivate\n", NULL);
@@ -206,6 +209,7 @@ static void auth_client_finish_handshake(struct auth_client_connection *conn)
        str_append(str, "\nDONE\n");
 
        o_stream_nsend(conn->conn.output, str_data(str), str_len(str));
+       conn->handshake_finished = TRUE;
 }
 
 static int auth_client_handshake_args(struct connection *conn, const char *const *args)
@@ -352,6 +356,9 @@ void auth_client_connection_create(struct auth *auth, int fd, const char *name,
                    conn->conn.list->set.major_version,
                    conn->conn.list->set.minor_version);
        o_stream_nsend(conn->conn.output, str_data(str), str_len(str));
+
+       if ((flags & AUTH_CLIENT_CONNECTION_FLAG_LEGACY) != 0)
+               auth_client_finish_handshake(conn);
 }
 
 static void auth_client_connection_unref(struct auth_client_connection **_conn)
index 463eb36fefc8df7bcd8bdcb7439d61cf00b09ce1..136c39f09d45fbb10b3b11eba0bf074909f9cd6c 100644 (file)
@@ -8,6 +8,7 @@
 enum auth_client_connection_flags {
        AUTH_CLIENT_CONNECTION_FLAG_LOGIN_REQUESTS = BIT(0),
        AUTH_CLIENT_CONNECTION_FLAG_TOKEN_AUTH = BIT(1),
+       AUTH_CLIENT_CONNECTION_FLAG_LEGACY = BIT(2),
 };
 
 struct auth_client_connection {
@@ -24,6 +25,7 @@ struct auth_client_connection {
        bool login_requests:1;
        bool version_received:1;
        bool token_auth:1;
+       bool handshake_finished:1;
 };
 void auth_client_connection_create(struct auth *auth, int fd, const char *name,
                                   enum auth_client_connection_flags flags);
index 5338ff6b49d2032be37ad9bf4ef520a031a25792..9810c96cf20f35d8eeabe3b88e99c0957b0760e4 100644 (file)
@@ -40,6 +40,7 @@
 
 enum auth_socket_type {
        AUTH_SOCKET_AUTH,
+       AUTH_SOCKET_AUTH_LEGACY,
        AUTH_SOCKET_LOGIN,
        AUTH_SOCKET_MASTER,
        AUTH_SOCKET_USERDB,
@@ -56,6 +57,7 @@ struct auth_socket_listener {
 
 static const char *const auth_socket_type_names[] = {
        "auth",
+       "auth-legacy",
        "login",
        "master",
        "userdb",
@@ -331,6 +333,10 @@ static void client_connected(struct master_service_connection *conn)
        case AUTH_SOCKET_AUTH:
                auth_client_connection_create(auth, conn->fd, conn->name, 0);
                break;
+       case AUTH_SOCKET_AUTH_LEGACY:
+               auth_client_connection_create(auth, conn->fd, conn->name,
+                       AUTH_CLIENT_CONNECTION_FLAG_LEGACY);
+               break;
        case AUTH_SOCKET_TOKEN_LOGIN:
                auth_client_connection_create(auth, conn->fd, conn->name,
                        AUTH_CLIENT_CONNECTION_FLAG_LOGIN_REQUESTS |