client-common.h revision 97db4761382024093f441e4bc78ba8b6a056504d
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#ifndef CLIENT_COMMON_H
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#define CLIENT_COMMON_H
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
c3a636e4c9ae776e0eed06b6d7ad1ccfb6003afdTimo Sirainen#include "network.h"
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#include "sasl-server.h"
fa2a11210f20fb8998ed656f75e163191c8047e6Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen/* max. size of input buffer. this means:
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
abf015c9682f0f723db87a7c97bc284ef814818fTimo Sirainen SASL: Max SASL request length from client
fa2a11210f20fb8998ed656f75e163191c8047e6Timo Sirainen IMAP: Max. length of a single parameter
fa2a11210f20fb8998ed656f75e163191c8047e6Timo Sirainen POP3: Max. length of a command line (spec says 512 would be enough)
fa2a11210f20fb8998ed656f75e163191c8047e6Timo Sirainen*/
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#define LOGIN_MAX_INBUF_SIZE 4096
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenstruct client {
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct client *prev, *next;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen pool_t pool;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct ip_addr local_ip;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct ip_addr ip;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen unsigned int local_port, remote_port;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct ssl_proxy *proxy;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen const struct login_settings *set;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen int fd;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct istream *input;
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen const char *auth_command_tag;
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen char *auth_mech_name;
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen struct auth_request *auth_request;
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen unsigned int master_tag;
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen sasl_server_callback_t *sasl_callback;
c3a636e4c9ae776e0eed06b6d7ad1ccfb6003afdTimo Sirainen
c3a636e4c9ae776e0eed06b6d7ad1ccfb6003afdTimo Sirainen unsigned int auth_attempts;
c3a636e4c9ae776e0eed06b6d7ad1ccfb6003afdTimo Sirainen pid_t mail_pid;
c3a636e4c9ae776e0eed06b6d7ad1ccfb6003afdTimo Sirainen
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainen char *virtual_user;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen unsigned int tls:1;
fa2433aebcf3fccfa30ca9eed9b1a9166cf92ee2Timo Sirainen unsigned int secured:1;
fa2433aebcf3fccfa30ca9eed9b1a9166cf92ee2Timo Sirainen unsigned int trusted:1;
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainen unsigned int proxying:1;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen unsigned int authenticating:1;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen unsigned int auth_tried_disabled_plaintext:1;
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainen /* ... */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen};
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainenextern struct client *clients;
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainen
d1fff80640050631b06bfab904a34b2ad24601e8Timo Sirainenstruct client *client_create(int fd, bool ssl, pool_t pool,
d1fff80640050631b06bfab904a34b2ad24601e8Timo Sirainen const struct login_settings *set,
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainen const struct ip_addr *local_ip,
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainen const struct ip_addr *remote_ip);
2fb9ae42f9e36388ec6db24188b9108434043fd0Timo Sirainen
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainenvoid client_link(struct client *client);
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainenvoid client_unlink(struct client *client);
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainenunsigned int clients_get_count(void) ATTR_PURE;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_syslog(struct client *client, const char *msg);
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainenvoid client_syslog_err(struct client *client, const char *msg);
2eb2cf8eeb763bd5ca9b6848dce32f0303e88ec1Timo Sirainenconst char *client_get_extra_disconnect_reason(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenbool client_is_trusted(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid clients_notify_auth_connected(void);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_destroy_oldest(void);
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainenvoid clients_destroy_all(void);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainenvoid clients_init(void);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid clients_deinit(void);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#endif
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen