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