]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-login: Rename "master auth" structs/defines/functions to "login"
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 4 Apr 2020 21:27:52 +0000 (00:27 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 28 Jun 2022 08:10:53 +0000 (08:10 +0000)
 * master_auth -> login_client_list
 * master_auth_connection -> login_connection
 * master_auth_request -> login_request
 * master_auth_reply -> login_reply
 * master_auth_request_params -> login_client_request_params
 * MASTER_AUTH_* mostly to LOGIN_REQUEST_*, but also LOGIN_REPLY_* and LOGIN_CLIENT_*

18 files changed:
src/auth/auth-client-connection.h
src/auth/auth-master-connection.c
src/doveadm/doveadm-auth.c
src/imap/main.c
src/lib-login/login-client.c
src/lib-login/login-client.h
src/lib-login/master-login-auth.c
src/lib-login/master-login-auth.h
src/lib-login/master-login.c
src/lib-login/master-login.h
src/lib-login/test-master-login-auth.c
src/login-common/client-common.c
src/login-common/client-common.h
src/login-common/login-common.h
src/login-common/main.c
src/login-common/sasl-server.c
src/pop3/main.c
src/submission/main.c

index 8590827fd78a34da99a7f11af550d8482cad85a2..7283746c80c3ab736245082adc446170b2177569 100644 (file)
@@ -17,7 +17,7 @@ struct auth_client_connection {
        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;
index a08ada43dd920098df5133e7a7216b75ed704e5a..ea54d0a793881cbfe1bfc27cd312665a9f82982d 100644 (file)
@@ -107,7 +107,7 @@ master_input_request(struct auth_master_connection *conn, const char *args)
        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>] */
index 02fe788e4828b574d959b7406d9ccedd8e4d8390..14ea1eadd2e44318f03939c113afc678d408f911 100644 (file)
@@ -404,26 +404,26 @@ cmd_auth_master_input(const char *auth_master_socket_path,
                      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);
index db0da45c3573bfd98777e9b678b94d5dab1031d7..587a0ffa417c605ff0e0e6f303a48ad12d214cc1 100644 (file)
@@ -360,7 +360,7 @@ login_client_connected(const struct master_login_client *login_client,
        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);
@@ -372,9 +372,9 @@ login_client_connected(const struct master_login_client *login_client,
        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,
@@ -393,7 +393,7 @@ login_client_connected(const struct master_login_client *login_client,
                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,
index 61ff1862161707ca5b78dd0371b185e0d851087f..3094777600ce99a9a6a365453b5f81780259aed1 100644 (file)
 
 #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;
@@ -29,14 +29,14 @@ struct master_auth_connection {
        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;
 
@@ -44,33 +44,33 @@ struct master_auth {
        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)
@@ -88,7 +88,7 @@ master_auth_connection_deinit(struct master_auth_connection **_conn)
 }
 
 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;
 
@@ -101,28 +101,28 @@ conn_error(struct master_auth_connection *conn, const char *fmt, ...)
        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,
@@ -136,7 +136,7 @@ static void master_auth_connection_input(struct master_auth_connection *conn)
                                return;
                        conn_error(conn, "read() failed: %m");
                }
-               master_auth_connection_deinit(&conn);
+               login_connection_deinit(&conn);
                return;
        }
 
@@ -156,22 +156,22 @@ static void master_auth_connection_input(struct master_auth_connection *conn)
                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;
@@ -179,25 +179,25 @@ void master_auth_request(struct master_auth *auth,
        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);
@@ -218,19 +218,19 @@ void master_auth_request(struct master_auth *auth,
                        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;
        }
 
@@ -244,27 +244,28 @@ void master_auth_request(struct master_auth *auth,
                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;
 }
index a167e89f1f564f4443fa3b732f96efd766ab1d29..a6b038f0f5d934390c18cd3d22fb4d9335e51a00 100644 (file)
@@ -1,37 +1,36 @@
-#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;
 
@@ -39,7 +38,7 @@ struct master_auth_request {
        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. */
@@ -55,47 +54,48 @@ struct master_auth_request {
        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
index 056de7e24321d8f6b722ccd6fe8431c3d54e576d..4f56c0a8007c799679d1603920f3e47776014eeb 100644 (file)
@@ -33,7 +33,7 @@ struct master_login_auth_request {
        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;
@@ -159,7 +159,7 @@ request_internal_failure(struct master_login_auth *auth,
                         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)
@@ -378,7 +378,7 @@ master_login_auth_lookup_request(struct master_login_auth *auth,
        }
        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;
@@ -548,7 +548,7 @@ master_login_auth_send_request(struct master_login_auth *auth,
 
        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;
@@ -566,7 +566,7 @@ master_login_auth_send_request(struct master_login_auth *auth,
 }
 
 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)
 {
@@ -578,7 +578,7 @@ void master_login_auth_request(struct master_login_auth *auth,
                        /* 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;
                }
index d08732b86d1076d9a6ed5b46e36f0defe438e032..c90d13df941b67d559616715d5f803d42ee492ed 100644 (file)
@@ -1,7 +1,7 @@
 #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,
@@ -20,7 +20,7 @@ void master_login_auth_set_timeout(struct master_login_auth *auth,
    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);
index 7e8a19ba26bbd55ec8e515942a2bfdd7f207a0e5..53d839ef3797673f690a949d27192a1906e64a04 100644 (file)
@@ -151,8 +151,8 @@ conn_error(struct master_login_connection *conn, const char *fmt, ...)
 
 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;
@@ -180,7 +180,7 @@ master_login_conn_read_request(struct master_login_connection *conn,
        }
 
        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;
                }
@@ -421,22 +421,22 @@ master_login_auth_callback(const char *const *auth_args, const char *errormsg,
 {
        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);
@@ -469,10 +469,10 @@ master_login_auth_callback(const char *const *auth_args, const char *errormsg,
 
 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;
 
index 722b37ba464d085287745b124bd9f1e1eeb7156e..c4348538338990a97be8730301409a9aee14a1a2 100644 (file)
@@ -16,7 +16,7 @@ struct master_login_client {
        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];
 };
index 6bc53af1a4adc160fdb69a075417bd4a4fa8d8ba..6c4c5848c98a8d8df78a3c5f8b0dc08eaba983e4 100644 (file)
@@ -695,7 +695,7 @@ test_client_request_callback(const char *const *auth_args ATTR_UNUSED,
 
 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;
@@ -710,7 +710,7 @@ test_client_request_run(struct master_login_auth *auth, struct ioloop *ioloop,
 
        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);
        }
@@ -729,29 +729,29 @@ test_client_request_parallel(pid_t client_pid, unsigned int concurrency,
                             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);
index 0bc4a5efcfa73416b4ee43224c237e89d7f13d26..0209c1dd2e4590583ae4cf0f96eefdd12d96e688 100644 (file)
@@ -343,7 +343,8 @@ void client_destroy(struct client *client, const char *reason)
                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) {
index 7ad29cc929fc50ec39f9f2cdd2697e7bc70dd41f..3ae69f6032cdac50da77be24a303f0f5ab9101d2 100644 (file)
@@ -19,7 +19,7 @@ struct module;
    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. */
index cd6f5fbac32c899b978b3cc48c841dbac6b8496c..2de6126568d1d95f4678bd19eedae2a9eb160053 100644 (file)
@@ -48,7 +48,7 @@ extern struct login_module_register login_module_register;
 
 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;
index f68f52bd9a6d8e1541ce287c8ededab161bf8e3a..404ad06c32ac1eeb290feb372c922494ef658ead 100644 (file)
@@ -35,7 +35,7 @@ static struct event_category event_category_auth = {
 
 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;
@@ -428,7 +428,8 @@ static void main_init(const char *login_socket)
                                       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();
 
@@ -444,7 +445,7 @@ static void main_deinit(void)
        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)
index bb650ba9067199acaf274dd5058b2c06fe5f8596..0a2f1f6258c5c34301493992ee2af9e8c527ebdf 100644 (file)
@@ -28,7 +28,7 @@
 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
@@ -130,7 +130,7 @@ call_client_callback(struct client *client, enum sasl_server_reply reply,
 }
 
 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;
@@ -140,10 +140,10 @@ master_auth_callback(const struct master_auth_reply *reply, void *context)
        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;
                }
@@ -157,8 +157,8 @@ master_auth_callback(const struct master_auth_reply *reply, void *context)
 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;
@@ -179,13 +179,13 @@ static int master_send_request(struct anvil_request *anvil_request)
        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);
@@ -207,8 +207,8 @@ static int master_send_request(struct anvil_request *anvil_request)
        params.socket_path = client->postlogin_socket_path;
        params.request = req;
        params.data = buf->data;
-       master_auth_request(master_auth, &params, master_auth_callback,
-                           client, &client->master_tag);
+       login_client_request(login_client_list, &params, login_callback,
+                            client, &client->master_tag);
        if (close_fd)
                i_close_fd(&fd);
        return 0;
@@ -263,7 +263,7 @@ anvil_check_too_many_connections(struct client *client,
 
        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 ||
index fd4eb06bb054d798f2e19f7ddfd4359c91ea06f1..317dba74f4f03f6557195bdcd322c364836be344 100644 (file)
@@ -268,7 +268,7 @@ login_client_connected(const struct master_login_client *login_client,
 {
        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;
 
@@ -281,9 +281,9 @@ login_client_connected(const struct master_login_client *login_client,
        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,
index b0e349f1840b42e0753fd37d08c453be6facb3e4..e8545da6d61563eb34c4a17b2982eaf6d2db8571 100644 (file)
@@ -141,7 +141,7 @@ extract_input_data_field(const unsigned char **data, size_t *data_len,
 
 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)
 {
@@ -149,7 +149,7 @@ client_create_from_input(const struct mail_storage_service_input *input,
        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;
@@ -247,7 +247,7 @@ login_client_connected(const struct master_login_client *login_client,
                       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;
 
@@ -260,9 +260,9 @@ login_client_connected(const struct master_login_client *login_client,
        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,