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);
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;
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;