Mercurial > dovecot > original-hg > dovecot-2.1
changeset 11919:ac31be20d279
imap: imap_capability = +foo only adds new capabilities instead of replacing everything.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 02 Aug 2010 16:25:19 +0100 |
parents | 59af5fd42221 |
children | 7c4b4f07d64e |
files | doc/example-config/conf.d/20-imap.conf src/imap-login/client-authenticate.c src/imap-login/client-authenticate.h src/imap-login/client.c src/imap/imap-client.c |
diffstat | 5 files changed, 32 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/example-config/conf.d/20-imap.conf Mon Aug 02 15:33:00 2010 +0100 +++ b/doc/example-config/conf.d/20-imap.conf Mon Aug 02 16:25:19 2010 +0100 @@ -20,7 +20,8 @@ # %o - total number of bytes sent to client #imap_logout_format = bytes=%i/%o - # Override the IMAP CAPABILITY response. + # Override the IMAP CAPABILITY response. If the value begins with '+', + # add the given capabilities on top of the defaults (e.g. +XFOO XBAR). #imap_capability = # How long to wait between "OK Still here" notifications when client is
--- a/src/imap-login/client-authenticate.c Mon Aug 02 15:33:00 2010 +0100 +++ b/src/imap-login/client-authenticate.c Mon Aug 02 16:25:19 2010 +0100 @@ -18,21 +18,17 @@ #include <stdlib.h> -const char *client_authenticate_get_capabilities(struct client *client) +void client_authenticate_get_capabilities(struct client *client, string_t *str) { const struct auth_mech_desc *mech; unsigned int i, count; - string_t *str; - str = t_str_new(128); mech = sasl_server_get_advertised_mechs(client, &count); for (i = 0; i < count; i++) { str_append_c(str, ' '); str_append(str, "AUTH="); str_append(str, mech[i].name); } - - return str_c(str); } bool imap_client_auth_handle_reply(struct client *client,
--- a/src/imap-login/client-authenticate.h Mon Aug 02 15:33:00 2010 +0100 +++ b/src/imap-login/client-authenticate.h Mon Aug 02 16:25:19 2010 +0100 @@ -3,7 +3,7 @@ struct imap_arg; -const char *client_authenticate_get_capabilities(struct client *client); +void client_authenticate_get_capabilities(struct client *client, string_t *str); bool imap_client_auth_handle_reply(struct client *client, const struct client_auth_reply *reply);
--- a/src/imap-login/client.c Mon Aug 02 15:33:00 2010 +0100 +++ b/src/imap-login/client.c Mon Aug 02 16:25:19 2010 +0100 @@ -62,16 +62,25 @@ static const char *get_capability(struct client *client) { struct imap_client *imap_client = (struct imap_client *)client; - const char *auths, *cap_str; + string_t *cap_str = t_str_new(256); - cap_str = *imap_client->set->imap_capability != '\0' ? - imap_client->set->imap_capability : CAPABILITY_BANNER_STRING; - auths = client_authenticate_get_capabilities(client); - return t_strconcat(cap_str, - (ssl_initialized && !client->tls) ? " STARTTLS" : "", - client->set->disable_plaintext_auth && - !client->secured ? " LOGINDISABLED" : "", - auths, NULL); + if (*imap_client->set->imap_capability == '\0') + str_append(cap_str, CAPABILITY_BANNER_STRING); + else if (*imap_client->set->imap_capability != '+') + str_append(cap_str, imap_client->set->imap_capability); + else { + str_append(cap_str, CAPABILITY_BANNER_STRING); + str_append_c(cap_str, ' '); + str_append(cap_str, imap_client->set->imap_capability + 1); + } + + if (ssl_initialized && !client->tls) + str_append(cap_str, " STARTTLS"); + if (client->set->disable_plaintext_auth && !client->secured) + str_append(cap_str, " LOGINDISABLED"); + + client_authenticate_get_capabilities(client, cap_str); + return str_c(cap_str); } static int cmd_capability(struct imap_client *imap_client)
--- a/src/imap/imap-client.c Mon Aug 02 15:33:00 2010 +0100 +++ b/src/imap/imap-client.c Mon Aug 02 16:25:19 2010 +0100 @@ -72,8 +72,16 @@ client->capability_string = str_new(client->pool, sizeof(CAPABILITY_STRING)+64); - str_append(client->capability_string, *set->imap_capability != '\0' ? - set->imap_capability : CAPABILITY_STRING); + + if (*set->imap_capability == '\0') + str_append(client->capability_string, CAPABILITY_STRING); + else if (*set->imap_capability != '+') + str_append(client->capability_string, set->imap_capability); + else { + str_append(client->capability_string, CAPABILITY_STRING); + str_append_c(client->capability_string, ' '); + str_append(client->capability_string, set->imap_capability + 1); + } ident = mail_user_get_anvil_userip_ident(client->user); if (ident != NULL) {