]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm-server: Add client_connection.preauthenticated
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 8 Nov 2017 12:04:12 +0000 (14:04 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 18 Jan 2018 07:11:04 +0000 (09:11 +0200)
src/doveadm/client-connection.c
src/doveadm/client-connection.h

index cd077e3934f63366a151e7148250ec83deba6007..5c1d89831687fe0a05285e4e0700f308885e7668 100644 (file)
@@ -596,18 +596,23 @@ static int client_connection_init_ssl(struct client_connection *conn)
        return 0;
 }
 
-static void
-client_connection_send_auth_handshake(struct client_connection *
-                                     conn, int listen_fd)
+static bool
+client_connection_is_preauthenticated(int listen_fd)
 {
        const char *listen_path;
        struct stat st;
 
        /* we'll have to do this with stat(), because at least in Linux
           fstat() always returns mode as 0777 */
-       if (net_getunixname(listen_fd, &listen_path) == 0 &&
-           stat(listen_path, &st) == 0 && S_ISSOCK(st.st_mode) &&
-           (st.st_mode & 0777) == 0600) {
+       return net_getunixname(listen_fd, &listen_path) == 0 &&
+               stat(listen_path, &st) == 0 && S_ISSOCK(st.st_mode) &&
+               (st.st_mode & 0777) == 0600;
+}
+
+static void
+client_connection_send_auth_handshake(struct client_connection *conn)
+{
+       if (conn->preauthenticated) {
                /* no need for client to authenticate */
                conn->authenticated = TRUE;
                o_stream_nsend(conn->output, "+\n", 2);
@@ -665,7 +670,10 @@ client_connection_create(int fd, int listen_fd, bool ssl)
                        return NULL;
                }
        }
-       client_connection_send_auth_handshake(conn, listen_fd);
+       conn->preauthenticated =
+               client_connection_is_preauthenticated(listen_fd);
+       client_connection_send_auth_handshake(conn);
+
        client_connection_set_proctitle(conn, "");
 
        return conn;
index 78a38a3e43f455069c0e2fd3c4d6c9e48998c021..b0e087b109ba12bb1ddc2772788d724126ccd315 100644 (file)
@@ -21,6 +21,7 @@ struct client_connection {
        const struct doveadm_settings *set;
 
        unsigned int handshaked:1;
+       unsigned int preauthenticated:1;
        unsigned int authenticated:1;
        unsigned int io_setup:1;
        unsigned int use_multiplex:1;