struct ssl_iostream *ssl_iostream;
bool handshaked:1;
+ bool preauthenticated:1;
bool authenticated:1;
bool io_setup:1;
bool use_multiplex:1;
return 0;
}
-static void
-client_connection_tcp_send_auth_handshake(struct client_connection_tcp *
- 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_tcp_send_auth_handshake(struct client_connection_tcp *conn)
+{
+ if (conn->preauthenticated) {
/* no need for client to authenticate */
conn->authenticated = TRUE;
o_stream_nsend(conn->output, "+\n", 2);
return NULL;
}
}
- client_connection_tcp_send_auth_handshake(conn, listen_fd);
+ conn->preauthenticated =
+ client_connection_is_preauthenticated(listen_fd);
+ client_connection_tcp_send_auth_handshake(conn);
client_connection_set_proctitle(&conn->conn, "");
return &conn->conn;