unsigned int version_minor;
unsigned int pid;
unsigned int connect_uid;
- uint8_t cookie[MASTER_AUTH_COOKIE_SIZE];
+ uint8_t cookie[LOGIN_REQUEST_COOKIE_SIZE];
struct auth_request_handler *request_handler;
bool login_requests:1;
struct auth_client_connection *client_conn;
const char *const *list, *const *params;
unsigned int id, client_pid, client_id;
- uint8_t cookie[MASTER_AUTH_COOKIE_SIZE];
+ uint8_t cookie[LOGIN_REQUEST_COOKIE_SIZE];
buffer_t buf;
/* <id> <client-pid> <client-id> <cookie> [<parameters>] */
struct authtest_input *input)
{
struct master_login_auth *master_auth;
- struct master_auth_request master_auth_req;
+ struct login_request login_req;
buffer_t buf;
- i_zero(&master_auth_req);
- master_auth_req.tag = 1;
- master_auth_req.auth_pid = input->auth_pid;
- master_auth_req.auth_id = input->auth_id;
- master_auth_req.client_pid = getpid();
- master_auth_req.local_ip = input->info.local_ip;
- master_auth_req.remote_ip = input->info.remote_ip;
-
- buffer_create_from_data(&buf, master_auth_req.cookie,
- sizeof(master_auth_req.cookie));
- if (strlen(input->auth_cookie) == MASTER_AUTH_COOKIE_SIZE*2)
+ i_zero(&login_req);
+ login_req.tag = 1;
+ login_req.auth_pid = input->auth_pid;
+ login_req.auth_id = input->auth_id;
+ login_req.client_pid = getpid();
+ login_req.local_ip = input->info.local_ip;
+ login_req.remote_ip = input->info.remote_ip;
+
+ buffer_create_from_data(&buf, login_req.cookie,
+ sizeof(login_req.cookie));
+ if (strlen(input->auth_cookie) == LOGIN_REQUEST_COOKIE_SIZE*2)
(void)hex_to_binary(input->auth_cookie, &buf);
input->success = FALSE;
master_auth = master_login_auth_init(auth_master_socket_path, FALSE);
io_loop_set_running(current_ioloop);
- master_login_auth_request(master_auth, &master_auth_req,
+ master_login_auth_request(master_auth, &login_req,
master_auth_callback, input);
if (io_loop_is_running(current_ioloop))
io_loop_run(current_ioloop);
struct mail_storage_service_input input;
struct client *client;
struct imap_login_request request;
- enum mail_auth_request_flags flags = login_client->auth_req.flags;
+ enum login_request_flags flags = login_client->auth_req.flags;
const char *error;
i_zero(&input);
input.username = username;
input.userdb_fields = extra_fields;
input.session_id = login_client->session_id;
- if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SECURED) != 0)
+ if ((flags & LOGIN_REQUEST_FLAG_CONN_SECURED) != 0)
input.conn_secured = TRUE;
- if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SSL_SECURED) != 0)
+ if ((flags & LOGIN_REQUEST_FLAG_CONN_SSL_SECURED) != 0)
input.conn_ssl_secured = TRUE;
client_parse_imap_login_request(login_client->data,
master_service_client_connection_destroyed(master_service);
return;
}
- if ((flags & MAIL_AUTH_REQUEST_FLAG_TLS_COMPRESSION) != 0)
+ if ((flags & LOGIN_REQUEST_FLAG_TLS_COMPRESSION) != 0)
client->tls_compression = TRUE;
if (request.input_size > 0) {
client_add_istream_prefix(client, request.input,
#define SOCKET_CONNECT_RETRY_MSECS 500
#define SOCKET_CONNECT_RETRY_WARNING_INTERVAL_SECS 2
-#define MASTER_AUTH_REQUEST_TIMEOUT_MSECS (MASTER_LOGIN_TIMEOUT_SECS/2*1000)
+#define LOGIN_CLIENT_REQUEST_TIMEOUT_MSECS (MASTER_LOGIN_TIMEOUT_SECS/2*1000)
-struct master_auth_connection {
- struct master_auth *auth;
+struct login_connection {
+ struct login_client_list *list;
unsigned int tag;
unsigned int client_pid, auth_id;
struct io *io;
struct timeout *to;
- char buf[sizeof(struct master_auth_reply)];
+ char buf[sizeof(struct login_reply)];
unsigned int buf_pos;
- master_auth_callback_t *callback;
+ login_client_request_callback_t *callback;
void *context;
};
-struct master_auth {
+struct login_client_list {
struct master_service *service;
pool_t pool;
time_t last_connect_warning;
unsigned int tag_counter;
- HASH_TABLE(void *, struct master_auth_connection *) connections;
+ HASH_TABLE(void *, struct login_connection *) connections;
};
-struct master_auth *
-master_auth_init(struct master_service *service, const char *path)
+struct login_client_list *
+login_client_list_init(struct master_service *service, const char *path)
{
- struct master_auth *auth;
+ struct login_client_list *list;
pool_t pool;
- pool = pool_alloconly_create("master auth", 1024);
- auth = p_new(pool, struct master_auth, 1);
- auth->pool = pool;
- auth->service = service;
- auth->default_path = p_strdup(pool, path);
- hash_table_create_direct(&auth->connections, pool, 0);
- return auth;
+ pool = pool_alloconly_create("login connection list", 1024);
+ list = p_new(pool, struct login_client_list, 1);
+ list->pool = pool;
+ list->service = service;
+ list->default_path = p_strdup(pool, path);
+ hash_table_create_direct(&list->connections, pool, 0);
+ return list;
}
static void
-master_auth_connection_deinit(struct master_auth_connection **_conn)
+login_connection_deinit(struct login_connection **_conn)
{
- struct master_auth_connection *conn = *_conn;
+ struct login_connection *conn = *_conn;
*_conn = NULL;
if (conn->tag != 0)
- hash_table_remove(conn->auth->connections,
+ hash_table_remove(conn->list->connections,
POINTER_CAST(conn->tag));
if (conn->callback != NULL)
}
static void ATTR_FORMAT(2, 3)
-conn_error(struct master_auth_connection *conn, const char *fmt, ...)
+conn_error(struct login_connection *conn, const char *fmt, ...)
{
va_list args;
va_end(args);
}
-void master_auth_deinit(struct master_auth **_auth)
+void login_client_list_deinit(struct login_client_list **_list)
{
- struct master_auth *auth = *_auth;
+ struct login_client_list *list = *_list;
struct hash_iterate_context *iter;
void *key;
- struct master_auth_connection *conn;
+ struct login_connection *conn;
- *_auth = NULL;
+ *_list = NULL;
- iter = hash_table_iterate_init(auth->connections);
- while (hash_table_iterate(iter, auth->connections, &key, &conn)) {
+ iter = hash_table_iterate_init(list->connections);
+ while (hash_table_iterate(iter, list->connections, &key, &conn)) {
conn->tag = 0;
- master_auth_connection_deinit(&conn);
+ login_connection_deinit(&conn);
}
hash_table_iterate_deinit(&iter);
- hash_table_destroy(&auth->connections);
- pool_unref(&auth->pool);
+ hash_table_destroy(&list->connections);
+ pool_unref(&list->pool);
}
-static void master_auth_connection_input(struct master_auth_connection *conn)
+static void login_connection_input(struct login_connection *conn)
{
- const struct master_auth_reply *reply;
+ const struct login_reply *reply;
int ret;
ret = read(conn->fd, conn->buf + conn->buf_pos,
return;
conn_error(conn, "read() failed: %m");
}
- master_auth_connection_deinit(&conn);
+ login_connection_deinit(&conn);
return;
}
conn->callback(reply, conn->context);
conn->callback = NULL;
}
- master_auth_connection_deinit(&conn);
+ login_connection_deinit(&conn);
}
-static void master_auth_connection_timeout(struct master_auth_connection *conn)
+static void login_connection_timeout(struct login_connection *conn)
{
- conn_error(conn, "Auth request timed out");
- master_auth_connection_deinit(&conn);
+ conn_error(conn, "Login request timed out");
+ login_connection_deinit(&conn);
}
-void master_auth_request(struct master_auth *auth,
- const struct master_auth_request_params *params,
- master_auth_callback_t *callback, void *context,
- unsigned int *tag_r)
+void login_client_request(struct login_client_list *list,
+ const struct login_client_request_params *params,
+ login_client_request_callback_t *callback,
+ void *context, unsigned int *tag_r)
{
- struct master_auth_connection *conn;
- struct master_auth_request req;
+ struct login_connection *conn;
+ struct login_request req;
buffer_t *buf;
struct stat st;
ssize_t ret;
i_assert(params->request.client_pid != 0);
i_assert(params->request.auth_pid != 0);
- conn = i_new(struct master_auth_connection, 1);
- conn->auth = auth;
+ conn = i_new(struct login_connection, 1);
+ conn->list = list;
conn->create_time = ioloop_timeval;
conn->callback = callback;
conn->context = context;
conn->path = params->socket_path != NULL ?
- i_strdup(params->socket_path) : i_strdup(auth->default_path);
+ i_strdup(params->socket_path) : i_strdup(list->default_path);
req = params->request;
- req.tag = ++auth->tag_counter;
+ req.tag = ++list->tag_counter;
if (req.tag == 0)
- req.tag = ++auth->tag_counter;
+ req.tag = ++list->tag_counter;
conn->client_pid = req.client_pid;
conn->auth_id = req.auth_id;
conn->remote_ip = req.remote_ip;
if (fstat(params->client_fd, &st) < 0)
- i_fatal("fstat(auth dest fd) failed: %m");
+ i_fatal("fstat(login dest fd) failed: %m");
req.ino = st.st_ino;
buf = t_buffer_create(sizeof(req) + req.data_size);
SOCKET_CONNECT_RETRY_MSECS);
io_loop_time_refresh();
if (conn->fd != -1 &&
- ioloop_time - auth->last_connect_warning >=
+ ioloop_time - list->last_connect_warning >=
SOCKET_CONNECT_RETRY_WARNING_INTERVAL_SECS) {
i_warning("net_connect_unix(%s) succeeded only after retrying - "
"took %lld us", conn->path,
timeval_diff_usecs(&ioloop_timeval, &start_time));
- auth->last_connect_warning = ioloop_time;
+ list->last_connect_warning = ioloop_time;
}
}
if (conn->fd == -1) {
conn_error(conn, "net_connect_unix(%s) failed: %m%s",
conn->path, errno != EAGAIN ? "" :
" - https://doc.dovecot.org/admin_manual/errors/socket_unavailable/");
- master_auth_connection_deinit(&conn);
+ login_connection_deinit(&conn);
return;
}
ret = -1;
}
if (ret < 0) {
- master_auth_connection_deinit(&conn);
+ login_connection_deinit(&conn);
return;
}
conn->tag = req.tag;
- conn->to = timeout_add(MASTER_AUTH_REQUEST_TIMEOUT_MSECS,
- master_auth_connection_timeout, conn);
+ conn->to = timeout_add(LOGIN_CLIENT_REQUEST_TIMEOUT_MSECS,
+ login_connection_timeout, conn);
conn->io = io_add(conn->fd, IO_READ,
- master_auth_connection_input, conn);
- i_assert(hash_table_lookup(auth->connections, POINTER_CAST(req.tag)) == NULL);
- hash_table_insert(auth->connections, POINTER_CAST(req.tag), conn);
+ login_connection_input, conn);
+ i_assert(hash_table_lookup(list->connections, POINTER_CAST(req.tag)) == NULL);
+ hash_table_insert(list->connections, POINTER_CAST(req.tag), conn);
*tag_r = req.tag;
}
-void master_auth_request_abort(struct master_auth *auth, unsigned int tag)
+void login_client_request_abort(struct login_client_list *list,
+ unsigned int tag)
{
- struct master_auth_connection *conn;
+ struct login_connection *conn;
- conn = hash_table_lookup(auth->connections, POINTER_CAST(tag));
+ conn = hash_table_lookup(list->connections, POINTER_CAST(tag));
if (conn == NULL)
- i_panic("master_auth_request_abort(): tag %u not found", tag);
+ i_panic("login_client_request_abort(): tag %u not found", tag);
conn->callback = NULL;
}
-#ifndef MASTER_AUTH_H
-#define MASTER_AUTH_H
+#ifndef LOGIN_CLIENT_H
+#define LOGIN_CLIENT_H
#include "net.h"
struct master_service;
/* Authentication client process's cookie size */
-#define MASTER_AUTH_COOKIE_SIZE (128/8)
+#define LOGIN_REQUEST_COOKIE_SIZE (128/8)
/* LOGIN_MAX_INBUF_SIZE should be based on this. Keep this large enough so that
LOGIN_MAX_INBUF_SIZE will be 1024+2 bytes. This is because IMAP ID command's
values may be max. 1024 bytes plus 2 for "" quotes. (Although it could be
even double of that when value is full of \" quotes, but for now lets not
make it too easy to waste memory..) */
-#define MASTER_AUTH_MAX_DATA_SIZE (1024 + 128 + 64 + 2)
+#define LOGIN_REQUEST_MAX_DATA_SIZE (1024 + 128 + 64 + 2)
-#define MASTER_AUTH_ERRMSG_INTERNAL_FAILURE \
+#define LOGIN_REQUEST_ERRMSG_INTERNAL_FAILURE \
"Internal error occurred. Refer to server log for more information."
-enum mail_auth_request_flags {
+enum login_request_flags {
/* Connection has TLS compression enabled */
- MAIL_AUTH_REQUEST_FLAG_TLS_COMPRESSION = BIT(0),
+ LOGIN_REQUEST_FLAG_TLS_COMPRESSION = BIT(0),
/* Connection is secure (SSL or just trusted) */
- MAIL_AUTH_REQUEST_FLAG_CONN_SECURED = BIT(1),
+ LOGIN_REQUEST_FLAG_CONN_SECURED = BIT(1),
/* Connection is secured using SSL specifically */
- MAIL_AUTH_REQUEST_FLAG_CONN_SSL_SECURED = BIT(2),
+ LOGIN_REQUEST_FLAG_CONN_SSL_SECURED = BIT(2),
/* This login is implicit; no command reply is expected */
- MAIL_AUTH_REQUEST_FLAG_IMPLICIT = BIT(3),
+ LOGIN_REQUEST_FLAG_IMPLICIT = BIT(3),
};
-/* Authentication request. File descriptor may be sent along with the
- request. */
-struct master_auth_request {
+/* Login request. File descriptor may be sent along with the request. */
+struct login_request {
/* Request tag. Reply is sent back using same tag. */
unsigned int tag;
pid_t auth_pid;
unsigned int auth_id;
unsigned int client_pid;
- uint8_t cookie[MASTER_AUTH_COOKIE_SIZE];
+ uint8_t cookie[LOGIN_REQUEST_COOKIE_SIZE];
/* Properties of the connection. The file descriptor
itself may be a local socketpair. */
ino_t ino;
};
-enum master_auth_status {
- MASTER_AUTH_STATUS_OK,
- MASTER_AUTH_STATUS_INTERNAL_ERROR
+enum login_reply_status {
+ LOGIN_REPLY_STATUS_OK,
+ LOGIN_REPLY_STATUS_INTERNAL_ERROR
};
-struct master_auth_reply {
+struct login_reply {
/* tag=0 are notifications from master */
unsigned int tag;
- enum master_auth_status status;
+ enum login_reply_status status;
/* PID of the post-login mail process handling this connection */
pid_t mail_pid;
};
-struct master_auth_request_params {
+struct login_client_request_params {
/* Client fd to transfer to post-login process or -1 if no fd is
wanted to be transferred. */
int client_fd;
- /* Override master_auth->default_path if non-NULL */
+ /* Override login_connection_list->default_path if non-NULL */
const char *socket_path;
- /* Authentication request that is sent to post-login process.
+ /* Login request that is sent to post-login process.
tag is ignored. */
- struct master_auth_request request;
+ struct login_request request;
/* Client input of size request.data_size */
const unsigned char *data;
};
-/* reply=NULL if the auth lookup was cancelled due to some error */
-typedef void master_auth_callback_t(const struct master_auth_reply *reply,
- void *context);
+/* reply=NULL if the login was cancelled due to some error */
+typedef void login_client_request_callback_t(const struct login_reply *reply,
+ void *context);
-struct master_auth *
-master_auth_init(struct master_service *service, const char *path);
-void master_auth_deinit(struct master_auth **auth);
+struct login_client_list *
+login_client_list_init(struct master_service *service, const char *path);
+void login_client_list_deinit(struct login_client_list **list);
-/* Send an authentication request. Returns tag which can be used to abort the
+/* Send a login request. Returns tag which can be used to abort the
request (ie. ignore the reply from master). */
-void master_auth_request(struct master_auth *auth,
- const struct master_auth_request_params *params,
- master_auth_callback_t *callback, void *context,
- unsigned int *tag_r);
-void master_auth_request_abort(struct master_auth *auth, unsigned int tag);
+void login_client_request(struct login_client_list *list,
+ const struct login_client_request_params *params,
+ login_client_request_callback_t *callback,
+ void *context, unsigned int *tag_r);
+void login_client_request_abort(struct login_client_list *list,
+ unsigned int tag);
#endif
pid_t auth_pid;
unsigned int auth_id;
unsigned int client_pid;
- uint8_t cookie[MASTER_AUTH_COOKIE_SIZE];
+ uint8_t cookie[LOGIN_REQUEST_COOKIE_SIZE];
master_login_auth_request_callback_t *callback;
void *context;
struct master_login_auth_request *request,
const char *reason)
{
- request_failure(auth, request, reason, MASTER_AUTH_ERRMSG_INTERNAL_FAILURE);
+ request_failure(auth, request, reason, LOGIN_REQUEST_ERRMSG_INTERNAL_FAILURE);
}
static void request_free(struct master_login_auth_request **_request)
}
master_login_auth_request_remove(auth, request);
if (request->aborted) {
- request->callback(NULL, MASTER_AUTH_ERRMSG_INTERNAL_FAILURE,
+ request->callback(NULL, LOGIN_REQUEST_ERRMSG_INTERNAL_FAILURE,
request->context);
request_free(&request);
return NULL;
if (!auth_request_check_spid(auth, req)) {
master_login_auth_request_remove(auth, req);
- req->callback(NULL, MASTER_AUTH_ERRMSG_INTERNAL_FAILURE,
+ req->callback(NULL, LOGIN_REQUEST_ERRMSG_INTERNAL_FAILURE,
req->context);
request_free(&req);
return;
}
void master_login_auth_request(struct master_login_auth *auth,
- const struct master_auth_request *req,
+ const struct login_request *req,
master_login_auth_request_callback_t *callback,
void *context)
{
/* we couldn't connect to auth now,
so we probably can't in future either. */
master_service_stop_new_connections(master_service);
- callback(NULL, MASTER_AUTH_ERRMSG_INTERNAL_FAILURE,
+ callback(NULL, LOGIN_REQUEST_ERRMSG_INTERNAL_FAILURE,
context);
return;
}
#ifndef MASTER_LOGIN_AUTH_H
#define MASTER_LOGIN_AUTH_H
-struct master_auth_request;
+struct login_request;
typedef void
master_login_auth_request_callback_t(const char *const *auth_args,
by performing verifying from auth that req is valid and doing the userdb
lookup. */
void master_login_auth_request(struct master_login_auth *auth,
- const struct master_auth_request *req,
+ const struct login_request *req,
master_login_auth_request_callback_t *callback,
void *context);
unsigned int master_login_auth_request_count(struct master_login_auth *auth);
static int
master_login_conn_read_request(struct master_login_connection *conn,
- struct master_auth_request *req_r,
- unsigned char data[MASTER_AUTH_MAX_DATA_SIZE],
+ struct login_request *req_r,
+ unsigned char data[LOGIN_REQUEST_MAX_DATA_SIZE],
int *client_fd_r)
{
struct stat st;
}
if (req_r->data_size != 0) {
- if (req_r->data_size > MASTER_AUTH_MAX_DATA_SIZE) {
+ if (req_r->data_size > LOGIN_REQUEST_MAX_DATA_SIZE) {
conn_error(conn, "Too large auth data_size sent");
return -1;
}
{
struct master_login_client *client = context;
struct master_login_connection *conn = client->conn;
- struct master_auth_reply reply;
+ struct login_reply reply;
const char *postlogin_socket_path;
i_assert(errormsg != NULL || auth_args != NULL);
i_zero(&reply);
reply.tag = client->auth_req.tag;
- reply.status = errormsg == NULL ? MASTER_AUTH_STATUS_OK :
- MASTER_AUTH_STATUS_INTERNAL_ERROR;
+ reply.status = errormsg == NULL ? LOGIN_REPLY_STATUS_OK :
+ LOGIN_REPLY_STATUS_INTERNAL_ERROR;
reply.mail_pid = getpid();
o_stream_nsend(conn->output, &reply, sizeof(reply));
if (errormsg != NULL || auth_args[0] == NULL) {
if (auth_args != NULL) {
i_error("login client: Username missing from auth reply");
- errormsg = MASTER_AUTH_ERRMSG_INTERNAL_FAILURE;
+ errormsg = LOGIN_REQUEST_ERRMSG_INTERNAL_FAILURE;
}
conn->login->failure_callback(client, errormsg);
master_login_client_free(&client);
static void master_login_conn_input(struct master_login_connection *conn)
{
- struct master_auth_request req;
+ struct login_request req;
struct master_login_client *client;
struct master_login *login = conn->login;
- unsigned char data[MASTER_AUTH_MAX_DATA_SIZE];
+ unsigned char data[LOGIN_REQUEST_MAX_DATA_SIZE];
size_t i, session_len = 0;
int ret, client_fd;
int fd;
struct timeval create_time;
- struct master_auth_request auth_req;
+ struct login_request auth_req;
char *session_id;
unsigned char data[FLEXIBLE_ARRAY_MEMBER];
};
static int
test_client_request_run(struct master_login_auth *auth, struct ioloop *ioloop,
- struct master_auth_request *auth_req,
+ struct login_request *login_req,
unsigned int concurrency, const char **error_r)
{
struct login_test login_test;
login_test.pending_requests = concurrency;
for (i = 0; i < concurrency; i++) {
- master_login_auth_request(auth, auth_req,
+ master_login_auth_request(auth, login_req,
test_client_request_callback,
&login_test);
}
bool retry, const char **error_r)
{
struct master_login_auth *auth;
- struct master_auth_request auth_req;
+ struct login_request login_req;
struct ioloop *ioloop;
int ret;
- i_zero(&auth_req);
- auth_req.tag = 99033;
- auth_req.auth_pid = 23234;
- auth_req.auth_id = 45521;
- auth_req.client_pid = client_pid;
- random_fill(auth_req.cookie, sizeof(auth_req.cookie));
- (void)net_addr2ip("10.0.0.15", &auth_req.local_ip);
- auth_req.local_port = 143;
- (void)net_addr2ip("10.0.0.211", &auth_req.remote_ip);
- auth_req.remote_port = 45546;
- auth_req.flags = MAIL_AUTH_REQUEST_FLAG_CONN_SSL_SECURED;
+ i_zero(&login_req);
+ login_req.tag = 99033;
+ login_req.auth_pid = 23234;
+ login_req.auth_id = 45521;
+ login_req.client_pid = client_pid;
+ random_fill(login_req.cookie, sizeof(login_req.cookie));
+ (void)net_addr2ip("10.0.0.15", &login_req.local_ip);
+ login_req.local_port = 143;
+ (void)net_addr2ip("10.0.0.211", &login_req.remote_ip);
+ login_req.remote_port = 45546;
+ login_req.flags = LOGIN_REQUEST_FLAG_CONN_SSL_SECURED;
ioloop = io_loop_create();
auth = master_login_auth_init(TEST_SOCKET, TRUE);
- ret = test_client_request_run(auth, ioloop, &auth_req, concurrency,
+ ret = test_client_request_run(auth, ioloop, &login_req, concurrency,
error_r);
if (ret < 0 && retry) {
- ret = test_client_request_run(auth, ioloop, &auth_req,
+ ret = test_client_request_run(auth, ioloop, &login_req,
concurrency, error_r);
}
master_login_auth_deinit(&auth);
i_assert(client->authenticating);
i_assert(client->refcount > 1);
client->authenticating = FALSE;
- master_auth_request_abort(master_auth, client->master_tag);
+ login_client_request_abort(login_client_list,
+ client->master_tag);
client->refcount--;
} else if (client->auth_request != NULL ||
client->anvil_query != NULL) {
POP3: Max. length of a command line (spec says 512 would be enough)
*/
#define LOGIN_MAX_INBUF_SIZE \
- (MASTER_AUTH_MAX_DATA_SIZE - LOGIN_MAX_MASTER_PREFIX_LEN - \
+ (LOGIN_REQUEST_MAX_DATA_SIZE - LOGIN_MAX_MASTER_PREFIX_LEN - \
LOGIN_MAX_SESSION_ID_LEN)
/* max. size of output buffer. if it gets full, the client is disconnected.
SASL authentication gives the largest output. */
extern struct login_binary *login_binary;
extern struct auth_client *auth_client;
-extern struct master_auth *master_auth;
+extern struct login_client_list *login_client_list;
extern bool closing_down, login_debug;
extern struct anvil_client *anvil;
extern const char *login_rawlog_dir;
struct login_binary *login_binary;
struct auth_client *auth_client;
-struct master_auth *master_auth;
+struct login_client_list *login_client_list;
bool closing_down, login_debug;
struct anvil_client *anvil;
const char *login_rawlog_dir = NULL;
FALSE);
auth_client_connect(auth_client);
auth_client_set_connect_notify(auth_client, auth_connect_notify, NULL);
- master_auth = master_auth_init(master_service, post_login_socket);
+ login_client_list = login_client_list_init(master_service,
+ post_login_socket);
login_binary->init();
login_binary->deinit();
module_dir_unload(&modules);
auth_client_deinit(&auth_client);
- master_auth_deinit(&master_auth);
+ login_client_list_deinit(&login_client_list);
char *str;
array_foreach_elem(&global_alt_usernames, str)
struct anvil_request {
struct client *client;
unsigned int auth_pid;
- unsigned char cookie[MASTER_AUTH_COOKIE_SIZE];
+ unsigned char cookie[LOGIN_REQUEST_COOKIE_SIZE];
};
static bool
}
static void
-master_auth_callback(const struct master_auth_reply *reply, void *context)
+login_callback(const struct login_reply *reply, void *context)
{
struct client *client = context;
enum sasl_server_reply sasl_reply = SASL_SERVER_REPLY_MASTER_FAILED;
client->authenticating = FALSE;
if (reply != NULL) {
switch (reply->status) {
- case MASTER_AUTH_STATUS_OK:
+ case LOGIN_REPLY_STATUS_OK:
sasl_reply = SASL_SERVER_REPLY_SUCCESS;
break;
- case MASTER_AUTH_STATUS_INTERNAL_ERROR:
+ case LOGIN_REPLY_STATUS_INTERNAL_ERROR:
sasl_reply = SASL_SERVER_REPLY_MASTER_FAILED;
break;
}
static int master_send_request(struct anvil_request *anvil_request)
{
struct client *client = anvil_request->client;
- struct master_auth_request_params params;
- struct master_auth_request req;
+ struct login_client_request_params params;
+ struct login_request req;
const unsigned char *data;
size_t size;
buffer_t *buf;
req.client_pid = getpid();
if (client->ssl_iostream != NULL &&
ssl_iostream_get_compression(client->ssl_iostream) != NULL)
- req.flags |= MAIL_AUTH_REQUEST_FLAG_TLS_COMPRESSION;
+ req.flags |= LOGIN_REQUEST_FLAG_TLS_COMPRESSION;
if (client->secured)
- req.flags |= MAIL_AUTH_REQUEST_FLAG_CONN_SECURED;
+ req.flags |= LOGIN_REQUEST_FLAG_CONN_SECURED;
if (client->ssl_secured)
- req.flags |= MAIL_AUTH_REQUEST_FLAG_CONN_SSL_SECURED;
+ req.flags |= LOGIN_REQUEST_FLAG_CONN_SSL_SECURED;
if (HAS_ALL_BITS(client->auth_flags, SASL_SERVER_AUTH_FLAG_IMPLICIT))
- req.flags |= MAIL_AUTH_REQUEST_FLAG_IMPLICIT;
+ req.flags |= LOGIN_REQUEST_FLAG_IMPLICIT;
memcpy(req.cookie, anvil_request->cookie, sizeof(req.cookie));
buf = t_buffer_create(256);
params.socket_path = client->postlogin_socket_path;
params.request = req;
params.data = buf->data;
- master_auth_request(master_auth, ¶ms, master_auth_callback,
- client, &client->master_tag);
+ login_client_request(login_client_list, ¶ms, login_callback,
+ client, &client->master_tag);
if (close_fd)
i_close_fd(&fd);
return 0;
buffer_create_from_data(&buf, req->cookie, sizeof(req->cookie));
cookie = auth_client_request_get_cookie(request);
- if (strlen(cookie) == MASTER_AUTH_COOKIE_SIZE*2)
+ if (strlen(cookie) == LOGIN_REQUEST_COOKIE_SIZE*2)
(void)hex_to_binary(cookie, &buf);
if (client->virtual_user == NULL ||
{
struct client *client;
struct mail_storage_service_input input;
- enum mail_auth_request_flags flags = login_client->auth_req.flags;
+ enum login_request_flags flags = login_client->auth_req.flags;
const char *error;
buffer_t input_buf;
input.username = username;
input.userdb_fields = extra_fields;
input.session_id = login_client->session_id;
- if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SECURED) != 0)
+ if ((flags & LOGIN_REQUEST_FLAG_CONN_SECURED) != 0)
input.conn_secured = TRUE;
- if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SSL_SECURED) != 0)
+ if ((flags & LOGIN_REQUEST_FLAG_CONN_SSL_SECURED) != 0)
input.conn_ssl_secured = TRUE;
buffer_create_from_const_data(&input_buf, login_client->data,
static int
client_create_from_input(const struct mail_storage_service_input *input,
- enum mail_auth_request_flags login_flags,
+ enum login_request_flags login_flags,
int fd_in, int fd_out, const buffer_t *input_buf,
const char **error_r)
{
struct mail_user *mail_user;
struct submission_settings *set;
bool no_greeting = HAS_ALL_BITS(login_flags,
- MAIL_AUTH_REQUEST_FLAG_IMPLICIT);
+ LOGIN_REQUEST_FLAG_IMPLICIT);
const char *errstr;
const char *helo = NULL;
struct smtp_proxy_data proxy_data;
const char *username, const char *const *extra_fields)
{
struct mail_storage_service_input input;
- enum mail_auth_request_flags flags = login_client->auth_req.flags;
+ enum login_request_flags flags = login_client->auth_req.flags;
const char *error;
buffer_t input_buf;
input.username = username;
input.userdb_fields = extra_fields;
input.session_id = login_client->session_id;
- if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SECURED) != 0)
+ if ((flags & LOGIN_REQUEST_FLAG_CONN_SECURED) != 0)
input.conn_secured = TRUE;
- if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SSL_SECURED) != 0)
+ if ((flags & LOGIN_REQUEST_FLAG_CONN_SSL_SECURED) != 0)
input.conn_ssl_secured = TRUE;
buffer_create_from_const_data(&input_buf, login_client->data,