client-common.h revision 2f7c73483ff5474a74a83a646f82e1b60f687680
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#ifndef CLIENT_COMMON_H
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define CLIENT_COMMON_H
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct module;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "net.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "login-proxy.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "sasl-server.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "master-login.h" /* for LOGIN_MAX_SESSION_ID_LEN */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define LOGIN_MAX_SESSION_ID_LEN 64
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define LOGIN_MAX_MASTER_PREFIX_LEN 128
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define LOGIN_MAX_CLIENT_ID_LEN 256
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch/* max. size of input buffer. this means:
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch IMAP: Max. length of command's all parameters. SASL-IR is read into
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch a separate larger buffer.
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch POP3: Max. length of a command line (spec says 512 would be enough)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch*/
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define LOGIN_MAX_INBUF_SIZE \
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch (MASTER_AUTH_MAX_DATA_SIZE - LOGIN_MAX_MASTER_PREFIX_LEN - \
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch LOGIN_MAX_SESSION_ID_LEN)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch/* max. size of output buffer. if it gets full, the client is disconnected.
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch SASL authentication gives the largest output. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define LOGIN_MAX_OUTBUF_SIZE 4096
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch/* Max. length of SASL authentication buffer. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define LOGIN_MAX_AUTH_BUF_SIZE 8192
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
1e9296de32c9ddda40f33c06556cd568ddadf71fTimo Sirainen/* Disconnect client after this many milliseconds if it hasn't managed
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch to log in yet. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define CLIENT_LOGIN_TIMEOUT_MSECS (MASTER_LOGIN_TIMEOUT_SECS*1000)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define AUTH_SERVER_WAITING_MSG \
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch "Waiting for authentication process to respond.."
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define AUTH_MASTER_WAITING_MSG \
1e9296de32c9ddda40f33c06556cd568ddadf71fTimo Sirainen "Waiting for authentication master process to respond.."
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct master_service_connection;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschenum client_disconnect_reason {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_DISCONNECT_TIMEOUT,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_DISCONNECT_SYSTEM_SHUTDOWN,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_DISCONNECT_RESOURCE_CONSTRAINT,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_DISCONNECT_INTERNAL_ERROR
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschenum client_auth_fail_code {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_FAIL_CODE_NONE = 0,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_FAIL_CODE_AUTHZFAILED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_FAIL_CODE_TEMPFAIL,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_FAIL_CODE_USER_DISABLED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_FAIL_CODE_PASS_EXPIRED,
1e9296de32c9ddda40f33c06556cd568ddadf71fTimo Sirainen CLIENT_AUTH_FAIL_CODE_INVALID_BASE64,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_FAIL_CODE_LOGIN_DISABLED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_FAIL_CODE_MECH_INVALID,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_FAIL_CODE_MECH_SSL_REQUIRED,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen};
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainenenum client_auth_result {
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_RESULT_SUCCESS,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_RESULT_REFERRAL_SUCCESS,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_RESULT_REFERRAL_NOLOGIN,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_RESULT_ABORTED,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_RESULT_AUTHFAILED,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_RESULT_AUTHFAILED_REASON,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen CLIENT_AUTH_RESULT_AUTHZFAILED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_RESULT_TEMPFAIL,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_RESULT_PASS_EXPIRED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_RESULT_SSL_REQUIRED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_RESULT_INVALID_BASE64,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_RESULT_LOGIN_DISABLED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_RESULT_MECH_INVALID,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch CLIENT_AUTH_RESULT_MECH_SSL_REQUIRED
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct client_auth_reply {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *master_user, *reason;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum client_auth_fail_code fail_code;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* for proxying */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *host, *hostip, *source_ip;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *destuser, *password, *proxy_mech;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch in_port_t port;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int proxy_timeout_msecs;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int proxy_refresh_secs;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum login_proxy_ssl_flags ssl_flags;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* all the key=value fields returned by passdb */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *const *all_fields;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
91a482473f200152d6713181c0e36f7a4f03ef6dTimo Sirainen bool proxy:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool proxy_nopipelining:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool proxy_not_trusted:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool nologin:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct client_vfuncs {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct client *(*alloc)(pool_t pool);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*create)(struct client *client, void **other_sets);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*destroy)(struct client *client);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*notify_auth_ready)(struct client *client);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*notify_disconnect)(struct client *client,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum client_disconnect_reason reason,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *text);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*notify_status)(struct client *client,
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen bool bad, const char *text);
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen void (*notify_starttls)(struct client *client,
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen bool success, const char *text);
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen void (*starttls)(struct client *client);
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen void (*input)(struct client *client);
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen void (*auth_send_challenge)(struct client *client, const char *data);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*auth_parse_response)(struct client *client);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*auth_result)(struct client *client,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum client_auth_result result,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const struct client_auth_reply *reply,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *text);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*proxy_reset)(struct client *client);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch int (*proxy_parse_line)(struct client *client, const char *line);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*proxy_error)(struct client *client, const char *text);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *(*proxy_get_state)(struct client *client);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct client {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct client *prev, *next;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch pool_t pool;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* this pool gets free'd once proxying starts */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch pool_t preproxy_pool;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct client_vfuncs v;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct client_vfuncs *vlast;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch time_t created;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch int refcount;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ip_addr local_ip;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ip_addr ip;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ip_addr real_remote_ip, real_local_ip;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch in_port_t local_port, remote_port;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch in_port_t real_local_port, real_remote_port;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ssl_proxy *ssl_proxy;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const struct login_settings *set;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const struct master_service_ssl_settings *ssl_set;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *session_id, *listener_name, *postlogin_socket_path;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *local_name;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch string_t *client_id;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch int fd;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct istream *input;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ostream *output;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct io *io;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct timeout *to_auth_waiting;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct timeout *to_disconnect;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned char *master_data_prefix;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int master_data_prefix_len;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct login_proxy *login_proxy;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch char *proxy_user, *proxy_master_user, *proxy_password;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const struct dsasl_client_mech *proxy_mech;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct dsasl_client *proxy_sasl_client;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int proxy_ttl;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch char *auth_mech_name;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct auth_client_request *auth_request;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch string_t *auth_response;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch time_t auth_first_started, auth_finished;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *sasl_final_resp;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *const *auth_passdb_args;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int master_auth_id;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int master_tag;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch sasl_server_callback_t *sasl_callback;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int bad_counter;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int auth_attempts, auth_successes;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum client_auth_fail_code last_auth_fail;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch pid_t mail_pid;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* Module-specific contexts. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch ARRAY(union login_client_module_context *) module_contexts;
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch char *virtual_user, *virtual_user_orig, *virtual_auth_user;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* passdb user_* fields are set here after a successful auth.
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch This is a NULL-terminated array where fields are in the same order
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen as in global_alt_usernames. If some field doesn't exist, it's "".
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch Can also be NULL if there are no user_* fields. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char **alt_usernames;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool destroyed:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool input_blocked:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool login_success:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool starttls:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool tls:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool secured:1;
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen bool trusted:1;
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen bool ssl_servername_settings_read:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool authenticating:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool auth_try_aborted:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool auth_initializing:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool auth_process_comm_fail:1;
b37e11d37fb1ebf50511eef5d9d96d1205818458Stephan Bosch bool proxy_auth_failed:1;
b37e11d37fb1ebf50511eef5d9d96d1205818458Stephan Bosch bool proxy_nopipelining:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool proxy_not_trusted:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool auth_waiting:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool notified_auth_ready:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool notified_disconnect:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* ... */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainenunion login_client_module_context {
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen struct client_vfuncs super;
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen struct login_module_register *reg;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainenstruct login_client_hooks {
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen void (*client_allocated)(struct client *client);
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen};
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainenextern struct client *clients;
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainentypedef void login_client_allocated_func_t(struct client *client);
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainenvoid login_client_hooks_add(struct module *module,
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen const struct login_client_hooks *hooks);
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainenvoid login_client_hooks_remove(const struct login_client_hooks *hooks);
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen
struct client *
client_create(int fd, bool ssl, pool_t pool,
const struct master_service_connection *conn,
const struct login_settings *set,
const struct master_service_ssl_settings *ssl_set,
void **other_sets);
void client_destroy(struct client *client, const char *reason);
void client_destroy_success(struct client *client, const char *reason);
void client_destroy_internal_failure(struct client *client);
void client_ref(struct client *client);
bool client_unref(struct client **client) ATTR_NOWARN_UNUSED_RESULT;
void client_cmd_starttls(struct client *client);
unsigned int clients_get_count(void) ATTR_PURE;
void client_set_title(struct client *client);
void client_log(struct client *client, const char *msg);
void client_log_err(struct client *client, const char *msg);
void client_log_warn(struct client *client, const char *msg);
const char *client_get_extra_disconnect_reason(struct client *client);
void client_auth_respond(struct client *client, const char *response);
void client_auth_abort(struct client *client);
bool client_is_tls_enabled(struct client *client);
void client_auth_fail(struct client *client, const char *text);
const char *client_get_session_id(struct client *client);
bool client_read(struct client *client);
void client_input(struct client *client);
void client_notify_auth_ready(struct client *client);
void client_notify_status(struct client *client, bool bad, const char *text);
void client_notify_disconnect(struct client *client,
enum client_disconnect_reason reason,
const char *text);
void client_send_raw_data(struct client *client, const void *data, size_t size);
void client_send_raw(struct client *client, const char *data);
void client_set_auth_waiting(struct client *client);
void client_auth_send_challenge(struct client *client, const char *data);
void client_auth_parse_response(struct client *client);
int client_auth_begin(struct client *client, const char *mech_name,
const char *init_resp);
bool client_check_plaintext_auth(struct client *client, bool pass_sent);
int client_auth_read_line(struct client *client);
void client_proxy_finish_destroy_client(struct client *client);
void client_proxy_log_failure(struct client *client, const char *line);
void client_proxy_failed(struct client *client, bool send_line);
const char *client_proxy_get_state(struct client *client);
void clients_notify_auth_connected(void);
void client_destroy_oldest(void);
void clients_destroy_all(void);
void clients_destroy_all_reason(const char *reason);
void client_common_init(void);
void client_common_deinit(void);
#endif