From: Timo Sirainen Date: Thu, 23 Mar 2017 18:16:44 +0000 (+0200) Subject: imap-login: Move forward_fields updating code to login-common X-Git-Tag: 2.3.0.rc1~1871 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4ec7cb598805b1387dc3aab59ec8f32d8cc24e1;p=thirdparty%2Fdovecot%2Fcore.git imap-login: Move forward_fields updating code to login-common This allows using the new client_add_forward_field() in e.g. plugins. --- diff --git a/src/imap-login/imap-login-client.c b/src/imap-login/imap-login-client.c index 79f1c1a284..326840d491 100644 --- a/src/imap-login/imap-login-client.c +++ b/src/imap-login/imap-login-client.c @@ -7,7 +7,6 @@ #include "ostream.h" #include "safe-memset.h" #include "str.h" -#include "strescape.h" #include "imap-parser.h" #include "imap-id.h" #include "imap-resp-code.h" @@ -202,15 +201,7 @@ client_update_info(struct imap_client *client, } } else if (strncasecmp(key, "x-forward-", 10) == 0) { /* handle extra field */ - if (client->common.forward_fields == NULL) - client->common.forward_fields = str_new(client->common.preproxy_pool, 32); - else - str_append_c(client->common.forward_fields, '\t'); - /* prefixing is done by auth process */ - str_append_tabescaped(client->common.forward_fields, - key+10); - str_append_c(client->common.forward_fields, '='); - str_append_tabescaped(client->common.forward_fields, value); + client_add_forward_field(&client->common, key+10, value); } else { return FALSE; } diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index 7bb23831df..2b6fa76c60 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -11,6 +11,7 @@ #include "hook-build.h" #include "buffer.h" #include "str.h" +#include "strescape.h" #include "base64.h" #include "str-sanitize.h" #include "safe-memset.h" @@ -486,6 +487,19 @@ unsigned int clients_get_count(void) return clients_count; } +void client_add_forward_field(struct client *client, const char *key, + const char *value) +{ + if (client->forward_fields == NULL) + client->forward_fields = str_new(client->preproxy_pool, 32); + else + str_append_c(client->forward_fields, '\t'); + /* prefixing is done by auth process */ + str_append_tabescaped(client->forward_fields, key); + str_append_c(client->forward_fields, '='); + str_append_tabescaped(client->forward_fields, value); +} + const char *client_get_session_id(struct client *client) { buffer_t *buf, *base64_buf; diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index 7a92e9655f..f3d188e7a4 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -242,6 +242,8 @@ void client_cmd_starttls(struct client *client); unsigned int clients_get_count(void) ATTR_PURE; +void client_add_forward_field(struct client *client, const char *key, + const char *value); void client_set_title(struct client *client); void client_log(struct client *client, const char *msg); void client_log_err(struct client *client, const char *msg);