]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Add user_director_hash field to passdb lookup replies
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 4 Jan 2022 16:03:41 +0000 (18:03 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 8 Feb 2022 09:48:24 +0000 (10:48 +0100)
This can be used as alt-username to kick users by the hash.

src/director/director-request.c
src/director/director-request.h
src/director/director.h
src/director/login-connection.c

index af41f7f33e17d33f107f8bbda2be358beb091278..ae3009ca4e56ca3e59f866a84c259034ea9a3a32 100644 (file)
@@ -119,7 +119,8 @@ static void director_request_timeout(struct director *dir)
 
                array_pop_front(&dir->pending_requests);
                T_BEGIN {
-                       request->callback(NULL, NULL, errormsg, request->context);
+                       request->callback(NULL, NULL, 0, errormsg,
+                                         request->context);
                } T_END;
                director_request_free(request);
        }
@@ -137,7 +138,8 @@ void director_request(struct director *dir, const char *username,
 
        if (!director_get_username_hash(dir, username,
                                        &username_hash)) {
-               callback(NULL, NULL, "Failed to expand director_username_hash", context);
+               callback(NULL, NULL, 0,
+                        "Failed to expand director_username_hash", context);
                return;
        }
 
@@ -333,6 +335,7 @@ static bool director_request_continue_real(struct director_request *request)
        director_update_user(dir, dir->self_host, user);
        T_BEGIN {
                request->callback(user->host, user->host->hostname,
+                                 request->username_hash,
                                  NULL, request->context);
        } T_END;
        director_request_free(request);
index e6fff802df2129670735ea6346d9a34b3df97b56..67da7e622984b98626f7d4167ddfe7b43d310e4e 100644 (file)
@@ -6,7 +6,8 @@ struct director_request;
 
 typedef void
 director_request_callback(const struct mail_host *host, const char *hostname,
-                         const char *errormsg, void *context);
+                         unsigned int username_hash, const char *errormsg,
+                         void *context);
 
 void director_request(struct director *dir, const char *username,
                      const char *tag,
index 8f2d2a1e23be3af077de5c35a1e33dc1998b9dff..172dab81e585f22a906faaacf238e929ae3462b9 100644 (file)
@@ -8,6 +8,8 @@
 #define DIRECTOR_VERSION_MAJOR 1
 #define DIRECTOR_VERSION_MINOR 9
 
+#define DIRECTOR_ALT_USER_FIELD_NAME "user_director_hash"
+
 /* weak users supported in protocol */
 #define DIRECTOR_VERSION_WEAK_USERS 1
 /* director ring remove supported */
index 78de3b9372a87cecd87afa2e18bd6bdae3ed4c2e..3b3d04d6949df2f303a6e95530c614245c85bc7e 100644 (file)
@@ -135,7 +135,8 @@ static bool login_host_request_is_self(struct login_host_request *request,
 
 static void
 login_host_callback(const struct mail_host *host, const char *hostname,
-                   const char *errormsg, void *context)
+                   unsigned int username_hash, const char *errormsg,
+                   void *context)
 {
        struct login_host_request *request = context;
        struct director *dir = request->conn->dir;
@@ -173,6 +174,8 @@ login_host_callback(const struct mail_host *host, const char *hostname,
                        str_append(str, "\thostip=");
                        str_append(str, host->ip_str);
                }
+               str_printfa(str, "\t"DIRECTOR_ALT_USER_FIELD_NAME"=%u",
+                           username_hash);
                line = str_c(str);
        }
        login_connection_send_line(request->conn, line);