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