]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 21 Mar 2017 09:51:25 +0000 (11:51 +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 25085143fd5686566d23c2a8fd01965b880418e2..9ba63e498684da89a7638fac1f0b058f84591db0 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 */
@@ -401,6 +403,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 c99d840f9dfd8712b23611d9e77c98e36df754a1..0d794c3a3311277a9fedbc385a974e238ca7fed1 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 292e570c047cee47d14750050a7b5883e4e06526..9641f7ea4d96403aa2a8cc9e4029cd5064f62dad 100644 (file)
@@ -125,6 +125,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 93747f8717e8ea74194003d6f35457c2709c6f4a..7f206e2e16f3cddda9ec197c725dc21d98434501 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"
@@ -370,6 +371,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 =