]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Accept client_id from auth client
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 20 Feb 2017 16:58:21 +0000 (18:58 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Sun, 19 Mar 2017 16:57:46 +0000 (18:57 +0200)
Client ID contains the ID client request string
for IMAP.

src/auth/auth-request.c
src/auth/auth-request.h
src/lib-auth/auth-client-request.c
src/lib-auth/auth-client.h
src/login-common/client-common.h
src/login-common/sasl-server.c

index 8c7dba9c3e490f56c8cfe0a42f908b3cafd6a81d..e4ab9ccddeecc9dde87c157babfc71e7c73854ea 100644 (file)
@@ -357,6 +357,8 @@ void auth_request_export(struct auth_request *request, string_t *dest)
                str_append(dest, "\tsuccessful");
        if (request->mech_name != NULL)
                auth_str_add_keyvalue(dest, "mech", request->mech_name);
+       if (request->client_id != NULL)
+               auth_str_add_keyvalue(dest, "client_id", request->client_id);
        /* export passdb extra fields */
        auth_request_export_fields(dest, request->extra_fields, "passdb_");
        /* export any userdb fields */
@@ -403,6 +405,8 @@ bool auth_request_import_info(struct auth_request *request,
                request->session_id = p_strdup(request->pool, value);
        else if (strcmp(key, "debug") == 0)
                request->debug = TRUE;
+       else if (strcmp(key, "client_id") == 0)
+               request->client_id = p_strdup(request->pool, value);
        else
                return FALSE;
        /* NOTE: keep in sync with auth_request_export() */
index 7b35a3c2b0c6546917ba5e4f0982167a39af4cc1..8ca2c6ebc47a1b264b11163a61e432f9801780a5 100644 (file)
@@ -74,7 +74,7 @@ struct auth_request {
        time_t delay_until;
        pid_t session_pid;
 
-       const char *service, *mech_name, *session_id, *local_name;
+       const char *service, *mech_name, *session_id, *local_name, *client_id;
        struct ip_addr local_ip, remote_ip, real_local_ip, real_remote_ip;
        in_port_t local_port, remote_port, real_local_port, real_remote_port;
 
index 79a172c7f2a140e859e0e3c4dcc0714d2a846dcf..33ae334acab24b6f5584b6b45ca5ff790efebfc7 100644 (file)
@@ -85,6 +85,11 @@ static void auth_server_send_new_request(struct auth_server_connection *conn,
                str_append(str, "\tlocal_name=");
                str_append_tabescaped(str, info->local_name);
        }
+       if (info->client_id != NULL &&
+           *info->client_id != '\0') {
+               str_append(str, "\tclient_id=");
+               str_append_tabescaped(str, info->client_id);
+       }
        if (info->initial_resp_base64 != NULL) {
                str_append(str, "\tresp=");
                str_append_tabescaped(str, info->initial_resp_base64);
index 45b346bb016e99146bb758244b243ea399b97ee9..f38c60b7a5dafc99ec0f611d0b603d480ec1e515 100644 (file)
@@ -42,6 +42,7 @@ struct auth_request_info {
        const char *session_id;
        const char *cert_username;
        const char *local_name;
+       const char *client_id;
        enum auth_request_flags flags;
 
        struct ip_addr local_ip, remote_ip, real_local_ip, real_remote_ip;
index 41eb9728d66ba45b025224ceca1587b98f28076c..6b30b9e8d7e627d5f8053dfd0d90283f054fb831 100644 (file)
@@ -142,6 +142,7 @@ struct client {
        const struct master_service_ssl_settings *ssl_set;
        const char *session_id, *listener_name, *postlogin_socket_path;
        const char *local_name;
+       string_t *client_id;
 
        int fd;
        struct istream *input;
index 348d3430e39f463995d5842615445517c9ec06e2..3cf6afd0cbccf669684d58a87d86d498486a034f 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
 
 #include "login-common.h"
+#include "str.h"
 #include "base64.h"
 #include "buffer.h"
 #include "hex-binary.h"
@@ -366,6 +367,8 @@ void sasl_server_auth_begin(struct client *client,
        info.real_remote_ip = client->real_remote_ip;
        info.real_local_port = client->real_local_port;
        info.real_remote_port = client->real_remote_port;
+       if (client->client_id != NULL)
+               info.client_id = str_c(client->client_id);
        info.initial_resp_base64 = initial_resp_base64;
 
        client->auth_request =