dovecot-2.0: imap-login: If imap_capability is set, use it.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Oct 21 01:11:09 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/9a71228ea41c
changeset: 10111:9a71228ea41c
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 20 18:11:00 2009 -0400
description:
imap-login: If imap_capability is set, use it.
diffstat:
15 files changed, 168 insertions(+), 36 deletions(-)
src/imap-login/Makefile.am | 3 ++
src/imap-login/client.c | 21 +++++++++-----
src/imap-login/client.h | 1
src/imap-login/imap-login-settings.c | 48 ++++++++++++++++++++++++++++++++++
src/imap-login/imap-login-settings.h | 10 +++++++
src/login-common/client-common.c | 10 +++----
src/login-common/client-common.h | 10 +++----
src/login-common/common.h | 1
src/login-common/login-settings.c | 26 ++++++++++++------
src/login-common/login-settings.h | 6 ++--
src/login-common/main.c | 13 +++++----
src/pop3-login/Makefile.am | 3 ++
src/pop3-login/client.c | 8 +++--
src/pop3-login/pop3-login-settings.c | 38 ++++++++++++++++++++++++++
src/pop3-login/pop3-login-settings.h | 6 ++++
diffs (truncated from 462 to 300 lines):
diff -r ac674fc9de57 -r 9a71228ea41c src/imap-login/Makefile.am
--- a/src/imap-login/Makefile.am Tue Oct 20 18:04:06 2009 -0400
+++ b/src/imap-login/Makefile.am Tue Oct 20 18:11:00 2009 -0400
@@ -4,6 +4,7 @@ pkglibexec_PROGRAMS = imap-login
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
+ -I$(top_srcdir)/src/lib-settings \
-I$(top_srcdir)/src/lib-auth \
-I$(top_srcdir)/src/lib-imap \
-I$(top_srcdir)/src/lib-master \
@@ -19,9 +20,11 @@ imap_login_SOURCES = \
imap_login_SOURCES = \
client.c \
client-authenticate.c \
+ imap-login-settings.c \
imap-proxy.c
noinst_HEADERS = \
client.h \
client-authenticate.h \
+ imap-login-settings.h \
imap-proxy.h
diff -r ac674fc9de57 -r 9a71228ea41c src/imap-login/client.c
--- a/src/imap-login/client.c Tue Oct 20 18:04:06 2009 -0400
+++ b/src/imap-login/client.c Tue Oct 20 18:11:00 2009 -0400
@@ -19,6 +19,7 @@
#include "auth-client.h"
#include "ssl-proxy.h"
#include "imap-proxy.h"
+#include "imap-login-settings.h"
#include <stdlib.h>
@@ -57,10 +58,13 @@ bool client_skip_line(struct imap_client
static const char *get_capability(struct client *client)
{
- const char *auths;
-
+ struct imap_client *imap_client = (struct imap_client *)client;
+ const char *auths, *cap_str;
+
+ 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(CAPABILITY_BANNER_STRING,
+ return t_strconcat(cap_str,
(ssl_initialized && !client->tls) ? " STARTTLS" : "",
client->set->disable_plaintext_auth &&
!client->secured ? " LOGINDISABLED" : "",
@@ -306,10 +310,11 @@ static struct client *imap_client_alloc(
return &imap_client->common;
}
-static void imap_client_create(struct client *client)
-{
- struct imap_client *imap_client = (struct imap_client *)client;
-
+static void imap_client_create(struct client *client, void **other_sets)
+{
+ struct imap_client *imap_client = (struct imap_client *)client;
+
+ imap_client->set = other_sets[0];
imap_client->parser =
imap_parser_create(imap_client->common.input,
imap_client->common.output, MAX_IMAP_LINE);
@@ -419,7 +424,7 @@ imap_client_send_line(struct client *cli
void clients_init(void)
{
- /* Nothing to initialize for IMAP */
+ login_set_roots = imap_login_setting_roots;
}
void clients_deinit(void)
diff -r ac674fc9de57 -r 9a71228ea41c src/imap-login/client.h
--- a/src/imap-login/client.h Tue Oct 20 18:04:06 2009 -0400
+++ b/src/imap-login/client.h Tue Oct 20 18:11:00 2009 -0400
@@ -7,6 +7,7 @@ struct imap_client {
struct imap_client {
struct client common;
+ const struct imap_login_settings *set;
struct imap_parser *parser;
char *proxy_backend_capability;
diff -r ac674fc9de57 -r 9a71228ea41c src/imap-login/imap-login-settings.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/imap-login/imap-login-settings.c Tue Oct 20 18:11:00 2009 -0400
@@ -0,0 +1,48 @@
+/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "settings-parser.h"
+#include "login-settings.h"
+#include "imap-login-settings.h"
+
+#include <stddef.h>
+
+#undef DEF
+#define DEF(type, name) \
+ { type, #name, offsetof(struct imap_login_settings, name), NULL }
+
+static struct setting_define imap_login_setting_defines[] = {
+ DEF(SET_STR, imap_capability),
+
+ SETTING_DEFINE_LIST_END
+};
+
+static struct imap_login_settings imap_login_default_settings = {
+ MEMBER(imap_capability) ""
+};
+
+static struct setting_parser_info *imap_login_setting_dependencies[] = {
+ &login_setting_parser_info,
+ NULL
+};
+
+static struct setting_parser_info imap_login_setting_parser_info = {
+ MEMBER(module_name) "imap-login",
+ MEMBER(defines) imap_login_setting_defines,
+ MEMBER(defaults) &imap_login_default_settings,
+
+ MEMBER(type_offset) (size_t)-1,
+ MEMBER(struct_size) sizeof(struct imap_login_settings),
+
+ MEMBER(parent_offset) (size_t)-1,
+ MEMBER(parent) NULL,
+
+ MEMBER(check_func) NULL,
+ MEMBER(dependencies) imap_login_setting_dependencies
+};
+
+const struct setting_parser_info *imap_login_setting_roots[] = {
+ &login_setting_parser_info,
+ &imap_login_setting_parser_info,
+ NULL
+};
diff -r ac674fc9de57 -r 9a71228ea41c src/imap-login/imap-login-settings.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/imap-login/imap-login-settings.h Tue Oct 20 18:11:00 2009 -0400
@@ -0,0 +1,10 @@
+#ifndef IMAP_LOGIN_SETTINGS_H
+#define IMAP_LOGIN_SETTINGS_H
+
+struct imap_login_settings {
+ const char *imap_capability;
+};
+
+extern const struct setting_parser_info *imap_login_setting_roots[];
+
+#endif
diff -r ac674fc9de57 -r 9a71228ea41c src/login-common/client-common.c
--- a/src/login-common/client-common.c Tue Oct 20 18:04:06 2009 -0400
+++ b/src/login-common/client-common.c Tue Oct 20 18:11:00 2009 -0400
@@ -37,10 +37,10 @@ static void client_open_streams(struct c
o_stream_create_fd(client->fd, LOGIN_MAX_OUTBUF_SIZE, FALSE);
}
-struct client *client_create(int fd, bool ssl, pool_t pool,
- const struct login_settings *set,
- const struct ip_addr *local_ip,
- const struct ip_addr *remote_ip)
+struct client *
+client_create(int fd, bool ssl, pool_t pool,
+ const struct login_settings *set, void **other_sets,
+ const struct ip_addr *local_ip, const struct ip_addr *remote_ip)
{
struct client *client;
@@ -78,7 +78,7 @@ struct client *client_create(int fd, boo
client_idle_disconnect_timeout, client);
client_open_streams(client);
- client->v.create(client);
+ client->v.create(client, other_sets);
if (auth_client_is_connected(auth_client))
client->v.send_greeting(client);
diff -r ac674fc9de57 -r 9a71228ea41c src/login-common/client-common.h
--- a/src/login-common/client-common.h Tue Oct 20 18:04:06 2009 -0400
+++ b/src/login-common/client-common.h Tue Oct 20 18:11:00 2009 -0400
@@ -53,7 +53,7 @@ struct client_auth_reply {
struct client_vfuncs {
struct client *(*alloc)(pool_t pool);
- void (*create)(struct client *client);
+ void (*create)(struct client *client, void **other_sets);
void (*destroy)(struct client *client);
void (*send_greeting)(struct client *client);
void (*starttls)(struct client *client);
@@ -126,10 +126,10 @@ extern struct client *clients;
extern struct client *clients;
extern struct client_vfuncs client_vfuncs;
-struct client *client_create(int fd, bool ssl, pool_t pool,
- const struct login_settings *set,
- const struct ip_addr *local_ip,
- const struct ip_addr *remote_ip);
+struct client *
+client_create(int fd, bool ssl, pool_t pool,
+ const struct login_settings *set, void **other_sets,
+ const struct ip_addr *local_ip, const struct ip_addr *remote_ip);
void client_destroy(struct client *client, const char *reason);
void client_destroy_success(struct client *client, const char *reason);
void client_destroy_internal_failure(struct client *client);
diff -r ac674fc9de57 -r 9a71228ea41c src/login-common/common.h
--- a/src/login-common/common.h Tue Oct 20 18:04:06 2009 -0400
+++ b/src/login-common/common.h Tue Oct 20 18:11:00 2009 -0400
@@ -21,6 +21,7 @@ extern int anvil_fd;
extern int anvil_fd;
extern const struct login_settings *global_login_settings;
+extern void **global_other_settings;
void login_process_preinit(void);
diff -r ac674fc9de57 -r 9a71228ea41c src/login-common/login-settings.c
--- a/src/login-common/login-settings.c Tue Oct 20 18:04:06 2009 -0400
+++ b/src/login-common/login-settings.c Tue Oct 20 18:11:00 2009 -0400
@@ -84,10 +84,12 @@ struct setting_parser_info login_setting
MEMBER(check_func) login_settings_check
};
-const struct setting_parser_info *login_set_roots[] = {
+static const struct setting_parser_info *default_login_set_roots[] = {
&login_setting_parser_info,
NULL
};
+
+const struct setting_parser_info **login_set_roots = default_login_set_roots;
/* <settings checks> */
static int ssl_settings_check(void *_set ATTR_UNUSED, const char **error_r)
@@ -156,16 +158,17 @@ struct login_settings *
struct login_settings *
login_settings_read(struct master_service *service, pool_t pool,
const struct ip_addr *local_ip,
- const struct ip_addr *remote_ip)
+ const struct ip_addr *remote_ip,
+ void ***other_settings_r)
{
struct master_service_settings_input input;
const char *error;
void **sets;
- struct login_settings *set;
+ unsigned int i;
memset(&input, 0, sizeof(input));
input.roots = login_set_roots;
- input.module = "login";
+ input.module = login_process_name;
input.service = login_protocol;
if (local_ip != NULL)
@@ -180,8 +183,15 @@ login_settings_read(struct master_servic
i_fatal("Error reading configuration: %s", error);
sets = master_service_settings_get_others(service);
- set = settings_dup(&login_setting_parser_info, sets[0], pool);
- if (!login_settings_check(set, pool, &error))
- i_fatal("login_settings_check() failed: %s", error);
- return set;
+ for (i = 0; sets[i] != NULL; i++) {
+ sets[i] = settings_dup(input.roots[i], sets[i], pool);
+ if (!settings_check(input.roots[i], pool, sets[i], &error)) {
+ const char *name = input.roots[i]->module_name;
+ i_fatal("settings_check(%s) failed: %s",
+ name != NULL ? name : "unknown", error);
+ }
+ }
+
+ *other_settings_r = sets + 1;
+ return sets[0];
}
diff -r ac674fc9de57 -r 9a71228ea41c src/login-common/login-settings.h
--- a/src/login-common/login-settings.h Tue Oct 20 18:04:06 2009 -0400
+++ b/src/login-common/login-settings.h Tue Oct 20 18:11:00 2009 -0400
@@ -32,11 +32,13 @@ struct login_settings {
char *const *log_format_elements_split;
};
-extern const struct setting_parser_info *login_set_roots[];
+extern const struct setting_parser_info **login_set_roots;
+extern struct setting_parser_info login_setting_parser_info;
struct login_settings *
login_settings_read(struct master_service *service, pool_t pool,
const struct ip_addr *local_ip,
- const struct ip_addr *remote_ip);
+ const struct ip_addr *remote_ip,
+ void ***other_settings_r);
#endif
diff -r ac674fc9de57 -r 9a71228ea41c src/login-common/main.c
--- a/src/login-common/main.c Tue Oct 20 18:04:06 2009 -0400
+++ b/src/login-common/main.c Tue Oct 20 18:11:00 2009 -0400
@@ -24,6 +24,7 @@ int anvil_fd = -1;
int anvil_fd = -1;
More information about the dovecot-cvs
mailing list