]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Moved connection information in struct mail_user into separate struct...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 9 Dec 2017 00:29:06 +0000 (01:29 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 11 Dec 2017 13:44:18 +0000 (15:44 +0200)
src/imap/cmd-idle.c
src/imap/imap-client-hibernate.c
src/imap/main.c
src/lib-storage/mail-user.c
src/lib-storage/mail-user.h
src/plugins/stats/mail-stats-connection.c
src/pop3/main.c

index 5f6f702d4253821229a7976c8a028538a78667ee..464c1b5714afb18ec41e54e4e85cac6ca773a7b8 100644 (file)
@@ -169,7 +169,7 @@ static void idle_add_keepalive_timeout(struct cmd_idle_context *ctx)
                return;
 
        interval = imap_keepalive_interval_msecs(client->user->username,
-                                                client->user->remote_ip,
+                                                client->user->conn.remote_ip,
                                                 interval);
 
        timeout_remove(&ctx->keepalive_to);
index 737f3bfbe0dbd673d06c48f8a21daf9f36cc3d15..6f425a8163c43f80b8818a4d5f68da585482c1e4 100644 (file)
@@ -69,10 +69,10 @@ static void imap_hibernate_write_cmd(struct client *client, string_t *cmd,
                str_printfa(cmd, "\tsession_created=%s",
                            dec2str(user->session_create_time));
        }
-       if (user->local_ip != NULL)
-               str_printfa(cmd, "\tlip=%s", net_ip2addr(user->local_ip));
-       if (user->remote_ip != NULL)
-               str_printfa(cmd, "\trip=%s", net_ip2addr(user->remote_ip));
+       if (user->conn.local_ip != NULL)
+               str_printfa(cmd, "\tlip=%s", net_ip2addr(user->conn.local_ip));
+       if (user->conn.remote_ip != NULL)
+               str_printfa(cmd, "\trip=%s", net_ip2addr(user->conn.remote_ip));
        if (client->userdb_fields != NULL) {
                string_t *userdb_fields = t_str_new(256);
                unsigned int i;
index 4c501ecd91350a5841b2ec9a3e3e62ef04ef10f2..4f67b5a9c1b5fe467f07ba4bc232dee8124d3d70 100644 (file)
@@ -66,9 +66,10 @@ void imap_refresh_proctitle(void)
        case 1:
                client = imap_clients;
                str_append(title, client->user->username);
-               if (client->user->remote_ip != NULL) {
+               if (client->user->conn.remote_ip != NULL) {
                        str_append_c(title, ' ');
-                       str_append(title, net_ip2addr(client->user->remote_ip));
+                       str_append(title,
+                                  net_ip2addr(client->user->conn.remote_ip));
                }
                wait_output = FALSE;
                for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) {
index ca04e3118007dab0811c09f06445488a4a397777..71d4c80ed863ca393b3e5f79a96a1c3db9fe7e87 100644 (file)
@@ -235,12 +235,12 @@ void mail_user_set_vars(struct mail_user *user, const char *service,
 
        user->service = p_strdup(user->pool, service);
        if (local_ip != NULL && local_ip->family != 0) {
-               user->local_ip = p_new(user->pool, struct ip_addr, 1);
-               *user->local_ip = *local_ip;
+               user->conn.local_ip = p_new(user->pool, struct ip_addr, 1);
+               *user->conn.local_ip = *local_ip;
        }
        if (remote_ip != NULL && remote_ip->family != 0) {
-               user->remote_ip = p_new(user->pool, struct ip_addr, 1);
-               *user->remote_ip = *remote_ip;
+               user->conn.remote_ip = p_new(user->pool, struct ip_addr, 1);
+               *user->conn.remote_ip = *remote_ip;
        }
 }
 
@@ -255,10 +255,10 @@ mail_user_var_expand_table(struct mail_user *user)
        const char *username =
                p_strdup(user->pool, t_strcut(user->username, '@'));
        const char *domain = i_strchr_to_next(user->username, '@');
-       const char *local_ip = user->local_ip == NULL ? NULL :
-               p_strdup(user->pool, net_ip2addr(user->local_ip));
-       const char *remote_ip = user->remote_ip == NULL ? NULL :
-               p_strdup(user->pool, net_ip2addr(user->remote_ip));
+       const char *local_ip = user->conn.local_ip == NULL ? NULL :
+               p_strdup(user->pool, net_ip2addr(user->conn.local_ip));
+       const char *remote_ip = user->conn.remote_ip == NULL ? NULL :
+               p_strdup(user->pool, net_ip2addr(user->conn.remote_ip));
 
        const char *auth_user, *auth_username, *auth_domain;
        if (user->auth_user == NULL) {
@@ -376,10 +376,10 @@ static int mail_user_userdb_lookup_home(struct mail_user *user)
 
        i_zero(&info);
        info.service = user->service;
-       if (user->local_ip != NULL)
-               info.local_ip = *user->local_ip;
-       if (user->remote_ip != NULL)
-               info.remote_ip = *user->remote_ip;
+       if (user->conn.local_ip != NULL)
+               info.local_ip = *user->conn.local_ip;
+       if (user->conn.remote_ip != NULL)
+               info.remote_ip = *user->conn.remote_ip;
 
        userdb_pool = pool_alloconly_create("userdb lookup", 2048);
        ret = auth_master_user_lookup(mail_user_auth_master_conn,
@@ -586,9 +586,9 @@ int mail_user_lock_file_create(struct mail_user *user, const char *lock_fname,
 
 const char *mail_user_get_anvil_userip_ident(struct mail_user *user)
 {
-       if (user->remote_ip == NULL)
+       if (user->conn.remote_ip == NULL)
                return NULL;
-       return t_strconcat(net_ip2addr(user->remote_ip), "/",
+       return t_strconcat(net_ip2addr(user->conn.remote_ip), "/",
                           str_tabescape(user->username), NULL);
 }
 
@@ -658,7 +658,7 @@ struct mail_user *mail_user_dup(struct mail_user *user)
        if (user->_home != NULL)
                mail_user_set_home(user2, user->_home);
        mail_user_set_vars(user2, user->service,
-                          user->local_ip, user->remote_ip);
+                          user->conn.local_ip, user->conn.remote_ip);
        user2->uid = user->uid;
        user2->gid = user->gid;
        user2->anonymous = user->anonymous;
index 3b3b0c11098b20fe6b1c4c235ba02fcec82fc513..d5d6786c26cf1005336cb6e96c03b644aa293ebc 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MAIL_USER_H
 #define MAIL_USER_H
 
+#include "net.h"
 #include "unichar.h"
 #include "mail-storage-settings.h"
 
@@ -16,6 +17,10 @@ struct mail_user_vfuncs {
        void (*stats_fill)(struct mail_user *user, struct stats *stats);
 };
 
+struct mail_user_connection_data {
+       struct ip_addr *local_ip, *remote_ip;
+};
+
 struct mail_user {
        pool_t pool;
        struct mail_user_vfuncs v, *vlast;
@@ -35,7 +40,7 @@ struct mail_user {
        gid_t gid;
        const char *service;
        const char *session_id;
-       struct ip_addr *local_ip, *remote_ip;
+       struct mail_user_connection_data conn;
        const char *auth_token, *auth_user;
        const char *const *userdb_fields;
        /* Timestamp when this session was initially created. Most importantly
index cb50e8f1b1e4d6f1b39db2229e6662dbf3ce8f7a..bf8004aaffaf425265e7d92245e14be2261439ef 100644 (file)
@@ -27,13 +27,13 @@ int mail_stats_connection_connect(struct stats_connection *conn,
        str_printfa(str, "\t%s", my_pid);
 
        /* optional fields */
-       if (user->local_ip != NULL) {
+       if (user->conn.local_ip != NULL) {
                str_append(str, "\tlip=");
-               str_append(str, net_ip2addr(user->local_ip));
+               str_append(str, net_ip2addr(user->conn.local_ip));
        }
-       if (user->remote_ip != NULL) {
+       if (user->conn.remote_ip != NULL) {
                str_append(str, "\trip=");
-               str_append(str, net_ip2addr(user->remote_ip));
+               str_append(str, net_ip2addr(user->conn.remote_ip));
        }
        str_append_c(str, '\n');
        return stats_connection_send(conn, str);
index 9796e684427df8faf65efdd7f2c79c19c4cdb953..daf91d9cee3330c3e7d80e92a58e4caf4de6f42c 100644 (file)
@@ -57,9 +57,10 @@ void pop3_refresh_proctitle(void)
        case 1:
                client = pop3_clients;
                str_append(title, client->user->username);
-               if (client->user->remote_ip != NULL) {
+               if (client->user->conn.remote_ip != NULL) {
                        str_append_c(title, ' ');
-                       str_append(title, net_ip2addr(client->user->remote_ip));
+                       str_append(title,
+                                  net_ip2addr(client->user->conn.remote_ip));
                }
                if (client->destroyed)
                        str_append(title, " (deinit)");