auth-connection.c revision 0388fd5e0bf6654ea25299fd63f2ee8e5ce2913f
effcbdb12c7ef892f1fd92a745cb33a08ca4ba30Stephen Gallagher/* Copyright (c) 2010-2015 Dovecot authors, see the included COPYING file */
55d80b1301fe969fb4ba2b9481027887b9462dbbJakub Hrozekstatic struct auth_connection *auth_connections;
55d80b1301fe969fb4ba2b9481027887b9462dbbJakub Hrozekstatic void auth_connection_disconnected(struct auth_connection **conn);
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekstatic void auth_connection_input(struct auth_connection *conn)
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek /* disconnected */
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek i_error("Auth server disconnected unexpectedly");
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek /* buffer full */
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek i_error("BUG: Auth server sent us more than %d bytes",
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek while ((line = i_stream_next_line(conn->input)) != NULL) {
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekstruct auth_connection *auth_connection_init(const char *path)
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekvoid auth_connection_set_callback(struct auth_connection *conn,
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekint auth_connection_connect(struct auth_connection *conn)
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek conn->fd = net_connect_unix_with_retries(conn->path, 1000);
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek conn->input = i_stream_create_fd(conn->fd, AUTH_CLIENT_MAX_LINE_LENGTH,
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek conn->output = o_stream_create_fd(conn->fd, (size_t)-1, FALSE);
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek o_stream_set_no_error_handling(conn->output, TRUE);
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek conn->io = io_add(conn->fd, IO_READ, auth_connection_input, conn);
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekvoid auth_connection_deinit(struct auth_connection **_conn)
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekstatic void auth_connection_disconnected(struct auth_connection **_conn)
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozek /* notify callback. it should deinit this connection */
ebc6ab564dc2a0a2b08c42d727fc403dde4a2dc9Jakub Hrozekstruct ostream *auth_connection_send(struct auth_connection *conn)