]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Include session ID in log line prefix.
authorTimo Sirainen <tss@iki.fi>
Sat, 28 Apr 2012 14:41:14 +0000 (17:41 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 28 Apr 2012 14:41:14 +0000 (17:41 +0300)
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/login-settings.c
src/login-common/sasl-server.c

index a6394fe32fe21f55e68ea4d9aaadfb2f5963289e..e34f71aaeb4851dffca88be530d38a830c0ed492 100644 (file)
@@ -237,6 +237,8 @@ bool auth_request_import_info(struct auth_request *request,
                request->local_port = atoi(value);
        else if (strcmp(key, "rport") == 0)
                request->remote_port = atoi(value);
+       else if (strcmp(key, "session") == 0)
+               request->session_id = p_strdup(request->pool, value);
        else
                return FALSE;
        return TRUE;
@@ -1856,6 +1858,8 @@ static void get_log_prefix(string_t *str, struct auth_request *auth_request,
        }
        if (auth_request->requested_login_user != NULL)
                str_append(str, ",master");
+       if (auth_request->session_id != NULL)
+               str_printfa(str, ",<%s>", auth_request->session_id);
        str_append(str, "): ");
 }
 
index 1ba3c768f326a721f54bad3f90ceef72409a624f..c218979949b52995a59460204167a6fa3a33db40 100644 (file)
@@ -71,7 +71,7 @@ struct auth_request {
        unsigned int id;
        time_t last_access;
 
-       const char *service, *mech_name;
+       const char *service, *mech_name, *session_id;
        struct ip_addr local_ip, remote_ip;
        unsigned int local_port, remote_port;
 
index 430292a626d8d532d23a58b3e20257fc1d6b7757..ceb79a6798370b8e5348690b9ef1bb6cb2205929 100644 (file)
@@ -44,6 +44,10 @@ static void auth_server_send_new_request(struct auth_server_connection *conn,
        if ((info->flags & AUTH_REQUEST_FLAG_VALID_CLIENT_CERT) != 0)
                str_append(str, "\tvalid-client-cert");
 
+       if (info->session_id != NULL) {
+               str_append(str, "\tsession=");
+               str_tabescape_write(str, info->session_id);
+       }
        if (info->cert_username != NULL) {
                str_append(str, "\tcert_username=");
                str_tabescape_write(str, info->cert_username);
@@ -82,6 +86,8 @@ auth_client_request_new(struct auth_client *client,
        request->request_info = *request_info;
        request->request_info.mech = p_strdup(pool, request_info->mech);
        request->request_info.service = p_strdup(pool, request_info->service);
+       request->request_info.session_id =
+               p_strdup_empty(pool, request_info->session_id);
        request->request_info.cert_username =
                p_strdup_empty(pool, request_info->cert_username);
        request->request_info.initial_resp_base64 =
index 77904ac87e3284d6c17644747ad0bf9e52c11651..6282aa02fafcb0962d181806707ad53bdb9edc74 100644 (file)
@@ -37,6 +37,7 @@ struct auth_connect_id {
 struct auth_request_info {
        const char *mech;
        const char *service;
+       const char *session_id;
        const char *cert_username;
        enum auth_request_flags flags;
 
index ff028eebbede35fcc6bbbb93002dbb79bd91baca..df34108bea1291b3236596bb45184b72017a2320 100644 (file)
@@ -56,7 +56,7 @@ static const struct setting_define login_setting_defines[] = {
 static const struct login_settings login_default_settings = {
        .login_trusted_networks = "",
        .login_greeting = PACKAGE_NAME" ready.",
-       .login_log_format_elements = "user=<%u> method=%m rip=%r lip=%l mpid=%e %c",
+       .login_log_format_elements = "user=<%u> method=%m rip=%r lip=%l mpid=%e %c session=<%{session}>",
        .login_log_format = "%$: %s",
        .login_access_sockets = "",
        .director_username_hash = "%u",
index 3ae0e519eaf4ff69679871aa840ea49455e0a06a..b0faba65bf80d51076c54f09e4b122535a8b031b 100644 (file)
@@ -318,6 +318,7 @@ void sasl_server_auth_begin(struct client *client,
        memset(&info, 0, sizeof(info));
        info.mech = mech->name;
        info.service = service;
+       info.session_id = client_get_session_id(client);
        info.cert_username = client->ssl_proxy == NULL ? NULL :
                ssl_proxy_get_peer_name(client->ssl_proxy);
        info.flags = client_get_auth_flags(client);