client-common.h revision b84eff65e25ae86dfd6f798386577209b94838c6
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen#include "master-login.h" /* for LOGIN_MAX_SESSION_ID_LEN */
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen/* max. size of input buffer. this means:
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen IMAP: Max. length of command's all parameters. SASL-IR is read into
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen a separate larger buffer.
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen POP3: Max. length of a command line (spec says 512 would be enough)
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen (MASTER_AUTH_MAX_DATA_SIZE - LOGIN_MAX_MASTER_PREFIX_LEN - \
cd56a23e21f1df3f79648cf07e2f4385e2fadebbTimo Sirainen/* max. size of output buffer. if it gets full, the client is disconnected.
cd56a23e21f1df3f79648cf07e2f4385e2fadebbTimo Sirainen SASL authentication gives the largest output. */
cd56a23e21f1df3f79648cf07e2f4385e2fadebbTimo Sirainen/* Max. length of SASL authentication buffer. */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* Disconnect client after this many milliseconds if it hasn't managed
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen to log in yet. */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen#define CLIENT_LOGIN_TIMEOUT_MSECS (MASTER_LOGIN_TIMEOUT_SECS*1000)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "Waiting for authentication process to respond.."
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen "Waiting for authentication master process to respond.."
7662010b03ffe5f2a6ecf4b4eb220d1c65efea76Timo Sirainen /* for proxying */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* all the key=value fields returned by passdb */
0a49b316fc729e5d57268ffa63c7122ac73f994cTimo Sirainen const char *const *all_fields;
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen void (*create)(struct client *client, void **other_sets);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen void (*notify_auth_ready)(struct client *client);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen void (*notify_disconnect)(struct client *client,
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen const char *text);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen void (*notify_starttls)(struct client *client,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen void (*auth_send_challenge)(struct client *client, const char *data);
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen void (*auth_parse_response)(struct client *client);
c9bf63e9094761767a63ac6b189bcf60bcffdc44Timo Sirainen const char *text);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*proxy_parse_line)(struct client *client, const char *line);
9e095dd6a77097356aca8216356d4d71ef1bea45Timo Sirainen void (*proxy_error)(struct client *client, const char *text);
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainen const char *(*proxy_get_state)(struct client *client);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen bool (*input_next_cmd)(struct client *client);
0a0cd45a633112a2ae6aad801c1e6afe53ab95deTimo Sirainen /* this pool gets free'd once proxying starts */
2524ef7b34965a1b1895d6140fd8296bf57c78d2Timo Sirainen const struct master_service_ssl_settings *ssl_set;
0892446b45c195461bb7be6599f02d97e1e2c9b2Timo Sirainen const char *session_id, *listener_name, *postlogin_socket_path;
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen char *proxy_user, *proxy_master_user, *proxy_password;
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen const char *const *auth_passdb_args;
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen /* Module-specific contexts. */
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen ARRAY(union login_client_module_context *) module_contexts;
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen char *virtual_user, *virtual_user_orig, *virtual_auth_user;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* passdb user_* fields are set here after a successful auth.
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen This is a NULL-terminated array where fields are in the same order
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen as in global_alt_usernames. If some field doesn't exist, it's "".
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen Can also be NULL if there are no user_* fields. */
e3fc1874694a8ddba9552ec23f9952f74f33d1d5Timo Sirainen void (*client_allocated)(struct client *client);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainentypedef void login_client_allocated_func_t(struct client *client);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenvoid login_client_hooks_add(struct module *module,
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainenvoid login_client_hooks_remove(const struct login_client_hooks *hooks);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen const struct master_service_ssl_settings *ssl_set,
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainenvoid client_destroy(struct client *client, const char *reason);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainenvoid client_destroy_success(struct client *client, const char *reason);
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainenvoid client_destroy_internal_failure(struct client *client);
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainenbool client_unref(struct client **client) ATTR_NOWARN_UNUSED_RESULT;
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainenvoid client_cmd_starttls(struct client *client);
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainenunsigned int clients_get_count(void) ATTR_PURE;
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainenvoid client_add_forward_field(struct client *client, const char *key,
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainen const char *value);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenvoid client_log(struct client *client, const char *msg);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenvoid client_log_err(struct client *client, const char *msg);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainenvoid client_log_warn(struct client *client, const char *msg);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenconst char *client_get_extra_disconnect_reason(struct client *client);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenvoid client_auth_respond(struct client *client, const char *response);
c9bf63e9094761767a63ac6b189bcf60bcffdc44Timo Sirainenbool client_is_tls_enabled(struct client *client);
c9bf63e9094761767a63ac6b189bcf60bcffdc44Timo Sirainenvoid client_auth_fail(struct client *client, const char *text);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainenconst char *client_get_session_id(struct client *client);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainenvoid client_notify_auth_ready(struct client *client);
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainenvoid client_notify_status(struct client *client, bool bad, const char *text);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainenvoid client_notify_disconnect(struct client *client,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen const char *text);
548e394330621952db0f03dd667b70184c4a37b6Timo Sirainenvoid client_send_raw_data(struct client *client, const void *data, size_t size);
548e394330621952db0f03dd667b70184c4a37b6Timo Sirainenvoid client_send_raw(struct client *client, const char *data);
7d207b1e77a7b5e3fda640e353acfc86d261fedfTimo Sirainenvoid client_common_send_raw_data(struct client *client,
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenvoid client_common_default_free(struct client *client);
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenvoid client_set_auth_waiting(struct client *client);
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenvoid client_auth_send_challenge(struct client *client, const char *data);
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenvoid client_auth_parse_response(struct client *client);
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenint client_auth_begin(struct client *client, const char *mech_name,
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenbool client_check_plaintext_auth(struct client *client, bool pass_sent);
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenint client_auth_read_line(struct client *client);
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenvoid client_proxy_finish_destroy_client(struct client *client);
68a4946b12583b88fa802e52ebee45cd96056772Timo Sirainenvoid client_proxy_log_failure(struct client *client, const char *line);
7e1f68ad71d3485f1882142837b01f7a98ca8467Timo Sirainenvoid client_proxy_failed(struct client *client, bool send_line);
68a4946b12583b88fa802e52ebee45cd96056772Timo Sirainenconst char *client_proxy_get_state(struct client *client);