client-common.h revision 56af9dd10e7e6caeaca64395bad3f882b28ecdff
#ifndef CLIENT_COMMON_H
#define CLIENT_COMMON_H
struct module;
#include "net.h"
#include "login-proxy.h"
#include "sasl-server.h"
#include "master-login.h" /* for LOGIN_MAX_SESSION_ID_LEN */
#define LOGIN_MAX_SESSION_ID_LEN 64
#define LOGIN_MAX_MASTER_PREFIX_LEN 128
#define LOGIN_MAX_CLIENT_ID_LEN 256
/* max. size of input buffer. this means:
IMAP: Max. length of command's all parameters. SASL-IR is read into
a separate larger buffer.
POP3: Max. length of a command line (spec says 512 would be enough)
*/
#define LOGIN_MAX_INBUF_SIZE \
/* max. size of output buffer. if it gets full, the client is disconnected.
SASL authentication gives the largest output. */
#define LOGIN_MAX_OUTBUF_SIZE 4096
/* Max. length of SASL authentication buffer. */
#define LOGIN_MAX_AUTH_BUF_SIZE 8192
/* Disconnect client after this many milliseconds if it hasn't managed
to log in yet. */
#define AUTH_SERVER_WAITING_MSG \
"Waiting for authentication process to respond.."
#define AUTH_MASTER_WAITING_MSG \
"Waiting for authentication master process to respond.."
struct master_service_connection;
enum client_disconnect_reason {
};
enum client_auth_fail_code {
};
enum client_auth_result {
};
struct client_auth_reply {
const char *master_user, *reason;
/* for proxying */
unsigned int proxy_timeout_msecs;
unsigned int proxy_refresh_secs;
/* all the key=value fields returned by passdb */
const char *const *all_fields;
bool proxy:1;
bool proxy_nopipelining:1;
bool proxy_not_trusted:1;
bool nologin:1;
};
struct client_vfuncs {
const char *text);
enum client_auth_result result,
const struct client_auth_reply *reply,
const char *text);
};
struct client {
/* this pool gets free'd once proxying starts */
struct client_vfuncs v;
struct client_vfuncs *vlast;
int refcount;
const struct login_settings *set;
const struct master_service_ssl_settings *ssl_set;
const char *local_name;
int fd;
struct timeout *to_auth_waiting;
struct timeout *to_disconnect;
unsigned char *master_data_prefix;
unsigned int master_data_prefix_len;
struct login_proxy *login_proxy;
const struct dsasl_client_mech *proxy_mech;
struct dsasl_client *proxy_sasl_client;
unsigned int proxy_ttl;
char *auth_mech_name;
struct auth_client_request *auth_request;
const char *sasl_final_resp;
const char *const *auth_passdb_args;
unsigned int master_auth_id;
unsigned int master_tag;
unsigned int bad_counter;
unsigned int auth_attempts, auth_successes;
/* Module-specific contexts. */
/* passdb user_* fields are set here after a successful auth.
This is a NULL-terminated array where fields are in the same order
as in global_alt_usernames. If some field doesn't exist, it's "".
Can also be NULL if there are no user_* fields. */
const char **alt_usernames;
bool destroyed:1;
bool input_blocked:1;
bool login_success:1;
bool starttls:1;
bool tls:1;
bool secured:1;
bool trusted:1;
bool ssl_servername_settings_read:1;
bool banner_sent:1;
bool authenticating:1;
bool auth_try_aborted:1;
bool auth_initializing:1;
bool auth_process_comm_fail:1;
bool proxy_auth_failed:1;
bool proxy_nopipelining:1;
bool proxy_not_trusted:1;
bool auth_waiting:1;
bool notified_auth_ready:1;
bool notified_disconnect:1;
/* ... */
};
union login_client_module_context {
struct client_vfuncs super;
struct login_module_register *reg;
};
struct login_client_hooks {
};
const struct login_client_hooks *hooks);
struct client *
const struct master_service_connection *conn,
const struct login_settings *set,
const struct master_service_ssl_settings *ssl_set,
void **other_sets);
unsigned int clients_get_count(void) ATTR_PURE;
const char *value);
const char *text);
const char *init_resp);
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