client-common.h revision b045b66988bfbaa2795791e42ee724fae6f0db1c
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#include "master-login.h" /* for LOGIN_MAX_SESSION_ID_LEN */
fa2a11210f20fb8998ed656f75e163191c8047e6Timo Sirainen/* max. size of input buffer. this means:
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen IMAP: Max. length of command's all parameters. SASL-IR is read into
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen a separate larger buffer.
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen POP3: Max. length of a command line (spec says 512 would be enough)
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen (MASTER_AUTH_MAX_DATA_SIZE - LOGIN_MAX_MASTER_PREFIX_LEN - \
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen/* max. size of output buffer. if it gets full, the client is disconnected.
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen SASL authentication gives the largest output. */
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen/* Max. length of SASL authentication buffer. */
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen/* Disconnect client after this many milliseconds if it hasn't managed
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen to log in yet. */
542e28b384a6b26695f3e8de38fd5727d06f3333Timo Sirainen#define CLIENT_LOGIN_TIMEOUT_MSECS (MASTER_LOGIN_TIMEOUT_SECS*1000)
c3a636e4c9ae776e0eed06b6d7ad1ccfb6003afdTimo Sirainen "Waiting for authentication process to respond.."
c3a636e4c9ae776e0eed06b6d7ad1ccfb6003afdTimo Sirainen "Waiting for authentication master process to respond.."
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainen /* for proxying */
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainen /* all the key=value fields returned by passdb */
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainen const char *const *all_fields;
265cb53cf8d5cb35edd4c4ff086ca6165605b708Timo Sirainen void (*create)(struct client *client, void **other_sets);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen void (*notify_auth_ready)(struct client *client);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen void (*notify_disconnect)(struct client *client,
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen const char *text);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen void (*notify_starttls)(struct client *client,
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen void (*auth_send_challenge)(struct client *client, const char *data);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen void (*auth_parse_response)(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen const char *text);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen int (*proxy_parse_line)(struct client *client, const char *line);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen void (*proxy_error)(struct client *client, const char *text);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen const char *(*proxy_get_state)(struct client *client);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen /* this pool gets free'd once proxying starts */
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen const struct master_service_ssl_settings *ssl_set;
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen const char *session_id, *listener_name, *postlogin_socket_path;
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen char *proxy_user, *proxy_master_user, *proxy_password;
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen const char *const *auth_passdb_args;
1f5597beba229acd914e30a6da3c0e62d83b6e8fTimo Sirainen /* Module-specific contexts. */
1f5597beba229acd914e30a6da3c0e62d83b6e8fTimo Sirainen ARRAY(union login_client_module_context *) module_contexts;
1f5597beba229acd914e30a6da3c0e62d83b6e8fTimo Sirainen char *virtual_user, *virtual_user_orig, *virtual_auth_user;
1f5597beba229acd914e30a6da3c0e62d83b6e8fTimo Sirainen /* passdb user_* fields are set here after a successful auth.
47569a4b2b4d3cc55e786177798c922c3c44233dTimo Sirainen This is a NULL-terminated array where fields are in the same order
47569a4b2b4d3cc55e786177798c922c3c44233dTimo Sirainen as in global_alt_usernames. If some field doesn't exist, it's "".
47569a4b2b4d3cc55e786177798c922c3c44233dTimo Sirainen Can also be NULL if there are no user_* fields. */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen void (*client_allocated)(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainentypedef void login_client_allocated_func_t(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid login_client_hooks_add(struct module *module,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid login_client_hooks_remove(const struct login_client_hooks *hooks);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainen const struct master_service_ssl_settings *ssl_set,
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenvoid client_destroy(struct client *client, const char *reason);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_destroy_success(struct client *client, const char *reason);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_destroy_internal_failure(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenbool client_unref(struct client **client) ATTR_NOWARN_UNUSED_RESULT;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_cmd_starttls(struct client *client);
f3e17726502b6cf1912f30aae7e283b5d31ea69cTimo Sirainenunsigned int clients_get_count(void) ATTR_PURE;
f3e17726502b6cf1912f30aae7e283b5d31ea69cTimo Sirainenvoid client_log(struct client *client, const char *msg);
f3e17726502b6cf1912f30aae7e283b5d31ea69cTimo Sirainenvoid client_log_err(struct client *client, const char *msg);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainenvoid client_log_warn(struct client *client, const char *msg);
f3e17726502b6cf1912f30aae7e283b5d31ea69cTimo Sirainenconst char *client_get_extra_disconnect_reason(struct client *client);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenvoid client_auth_respond(struct client *client, const char *response);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenbool client_is_tls_enabled(struct client *client);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenvoid client_auth_fail(struct client *client, const char *text);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenconst char *client_get_session_id(struct client *client);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenvoid client_notify_auth_ready(struct client *client);
e30b9e07f9657c35ca09ac36d57d60cbe2ebbc66Timo Sirainenvoid client_notify_status(struct client *client, bool bad, const char *text);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_notify_disconnect(struct client *client,
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainen const char *text);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_send_raw_data(struct client *client, const void *data, size_t size);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenvoid client_send_raw(struct client *client, const char *data);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_set_auth_waiting(struct client *client);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainenvoid client_auth_send_challenge(struct client *client, const char *data);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_auth_parse_response(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenint client_auth_begin(struct client *client, const char *mech_name,
e438c85a6b0f77889e25913bbbba808d6078282dStephan Boschbool client_check_plaintext_auth(struct client *client, bool pass_sent);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenint client_auth_read_line(struct client *client);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenvoid client_proxy_finish_destroy_client(struct client *client);
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainenvoid client_proxy_log_failure(struct client *client, const char *line);
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainenvoid client_proxy_failed(struct client *client, bool send_line);
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainenconst char *client_proxy_get_state(struct client *client);