/* Copyright (c) 2002-2016 Dovecot authors, see the included COPYING file */
#include "login-common.h"
+#include "array.h"
#include "hostpid.h"
#include "llist.h"
#include "istream.h"
static struct client *last_client = NULL;
static unsigned int clients_count = 0;
+static void empty_login_client_allocated_hook(struct client *client ATTR_UNUSED)
+{
+}
+static login_client_allocated_func_t *hook_client_allocated =
+ empty_login_client_allocated_hook;
+
+login_client_allocated_func_t *
+login_client_allocated_hook_set(login_client_allocated_func_t *new_hook)
+{
+ login_client_allocated_func_t *old_hook = hook_client_allocated;
+
+ hook_client_allocated = new_hook;
+ return old_hook;
+}
+
static void client_idle_disconnect_timeout(struct client *client)
{
const char *user_reason, *destroy_reason;
client->pool = pool;
client->set = set;
client->ssl_set = ssl_set;
+ p_array_init(&client->module_contexts, client->pool, 5);
client->fd = fd;
client->tls = ssl;
client_idle_disconnect_timeout, client);
client_open_streams(client);
+ hook_client_allocated(client);
client->v.create(client, other_sets);
if (auth_client_is_connected(auth_client))
unsigned int auth_attempts, auth_successes;
pid_t mail_pid;
+ /* Module-specific contexts. */
+ ARRAY(union login_client_module_context *) module_contexts;
+
char *virtual_user, *virtual_user_orig, *virtual_auth_user;
unsigned int destroyed:1;
unsigned int input_blocked:1;
/* ... */
};
+union login_client_module_context {
+ struct client_vfuncs super;
+ struct login_module_register *reg;
+};
+
extern struct client *clients;
+typedef void login_client_allocated_func_t(struct client *client);
+
+/* Sets the client allocation hook and returns the previous hook,
+ which the new hook should call. */
+login_client_allocated_func_t *
+login_client_allocated_hook_set(login_client_allocated_func_t *new_hook);
+
struct client *
client_create(int fd, bool ssl, pool_t pool,
const struct master_service_connection *conn,
bool sasl_support_final_reply;
};
+struct login_module_register {
+ unsigned int id;
+};
+extern struct login_module_register login_module_register;
+
extern const struct login_binary *login_binary;
extern struct auth_client *auth_client;
extern struct master_auth *master_auth;
struct anvil_client *anvil;
const char *login_rawlog_dir = NULL;
unsigned int initial_service_count;
+struct login_module_register login_module_register;
const struct login_settings *global_login_settings;
const struct master_service_ssl_settings *global_ssl_settings;