From: Aki Tuomi Date: Mon, 20 Feb 2017 16:58:21 +0000 (+0200) Subject: auth: Accept client_id from auth client X-Git-Tag: 2.3.0.rc1~1927 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8dac1be6a0c3adbbce5887ca395f418194c6c06;p=thirdparty%2Fdovecot%2Fcore.git auth: Accept client_id from auth client Client ID contains the ID client request string for IMAP. --- diff --git a/src/auth/auth-request.c b/src/auth/auth-request.c index 8c7dba9c3e..e4ab9ccdde 100644 --- a/src/auth/auth-request.c +++ b/src/auth/auth-request.c @@ -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() */ diff --git a/src/auth/auth-request.h b/src/auth/auth-request.h index 7b35a3c2b0..8ca2c6ebc4 100644 --- a/src/auth/auth-request.h +++ b/src/auth/auth-request.h @@ -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; diff --git a/src/lib-auth/auth-client-request.c b/src/lib-auth/auth-client-request.c index 79a172c7f2..33ae334aca 100644 --- a/src/lib-auth/auth-client-request.c +++ b/src/lib-auth/auth-client-request.c @@ -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); diff --git a/src/lib-auth/auth-client.h b/src/lib-auth/auth-client.h index 45b346bb01..f38c60b7a5 100644 --- a/src/lib-auth/auth-client.h +++ b/src/lib-auth/auth-client.h @@ -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; diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index 41eb9728d6..6b30b9e8d7 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -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; diff --git a/src/login-common/sasl-server.c b/src/login-common/sasl-server.c index 348d3430e3..3cf6afd0cb 100644 --- a/src/login-common/sasl-server.c +++ b/src/login-common/sasl-server.c @@ -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 =