dovecot-2.2: lib-storage: Added mail_storage_service_input.sessi...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Nov 18 19:06:48 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/e976d6f988ec
changeset: 19397:e976d6f988ec
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 18 21:03:41 2015 +0200
description:
lib-storage: Added mail_storage_service_input.session_id_prefix
This should make it easier to pass through the original session_id to worker
process sessions. Especially if these sessions are somewhat short-lived it
can be useful to assign them a unique session ID while still being able to
match it to the parent's session ID.
diffstat:
src/lib-storage/mail-storage-service.c | 19 ++++++++++++++-----
src/lib-storage/mail-storage-service.h | 4 ++++
2 files changed, 18 insertions(+), 5 deletions(-)
diffs (62 lines):
diff -r 626758356cce -r e976d6f988ec src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c Wed Nov 18 20:50:55 2015 +0200
+++ b/src/lib-storage/mail-storage-service.c Wed Nov 18 21:03:41 2015 +0200
@@ -1071,10 +1071,15 @@
i_set_failure_prefix("%s", str_c(str));
}
-static const char *mail_storage_service_generate_session_id(pool_t pool)
+static const char *
+mail_storage_service_generate_session_id(pool_t pool, const char *prefix)
{
guid_128_t guid;
- string_t *str = str_new(pool, MAX_BASE64_ENCODED_SIZE(sizeof(guid)));
+ unsigned int prefix_len = prefix == NULL ? 0 : strlen(prefix);
+ string_t *str = str_new(pool, MAX_BASE64_ENCODED_SIZE(prefix_len + 1 + sizeof(guid)));
+
+ if (prefix != NULL)
+ str_printfa(str, "%s-", prefix);
guid_128_generate(guid);
base64_encode(guid, sizeof(guid), str);
@@ -1187,7 +1192,8 @@
user->input.session_id = p_strdup(user_pool, input->session_id);
if (user->input.session_id == NULL) {
user->input.session_id =
- mail_storage_service_generate_session_id(user_pool);
+ mail_storage_service_generate_session_id(user_pool,
+ input->session_id_prefix);
}
user->user_info = user_info;
user->flags = flags;
@@ -1250,10 +1256,13 @@
/* no user yet. log prefix should be just "imap:" or something
equally unhelpful. we don't know the proper log format yet,
but initialize it to something better until we know it. */
+ const char *session_id =
+ input->session_id != NULL ? input->session_id :
+ (input->session_id_prefix != NULL ?
+ input->session_id_prefix : NULL);
i_set_failure_prefix("%s(%s%s,%s)",
master_service_get_name(ctx->service), input->username,
- input->session_id == NULL ? "" :
- t_strdup_printf(",%s", input->session_id),
+ session_id == NULL ? "" : t_strdup_printf(",%s", session_id),
input->remote_ip.family == 0 ? "" :
t_strdup_printf(",%s", net_ip2addr(&input->remote_ip)));
update_log_prefix = TRUE;
diff -r 626758356cce -r e976d6f988ec src/lib-storage/mail-storage-service.h
--- a/src/lib-storage/mail-storage-service.h Wed Nov 18 20:50:55 2015 +0200
+++ b/src/lib-storage/mail-storage-service.h Wed Nov 18 21:03:41 2015 +0200
@@ -40,7 +40,11 @@
const char *module;
const char *service;
const char *username;
+ /* If set, use this string as the session ID */
const char *session_id;
+ /* If set, use this string as the session ID prefix, but also append
+ a unique session ID suffix to it. */
+ const char *session_id_prefix;
struct ip_addr local_ip, remote_ip;
in_port_t local_port, remote_port;
More information about the dovecot-cvs
mailing list