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 \
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
#include "auth-client.h"
#include "ssl-proxy.h"
#include "imap-proxy.h"
+#include "imap-login-settings.h"
#include <stdlib.h>
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" : "",
return &imap_client->common;
}
-static void imap_client_create(struct 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);
void clients_init(void)
{
- /* Nothing to initialize for IMAP */
+ login_set_roots = imap_login_setting_roots;
}
void clients_deinit(void)
struct imap_client {
struct client common;
+ const struct imap_login_settings *set;
struct imap_parser *parser;
char *proxy_backend_capability;
--- /dev/null
+/* 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
+};
--- /dev/null
+#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
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;
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);
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);
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);
extern int anvil_fd;
extern const struct login_settings *global_login_settings;
+extern void **global_other_settings;
void login_process_preinit(void);
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)
{
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)
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];
}
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
int anvil_fd = -1;
const struct login_settings *global_login_settings;
+void **global_other_settings;
static bool ssl_connections = FALSE;
unsigned int local_port;
pool_t pool;
int fd_ssl;
+ void **other_sets;
if (net_getsockname(conn->fd, &local_ip, &local_port) < 0) {
memset(&local_ip, 0, sizeof(local_ip));
pool = pool_alloconly_create("login client", 3*1024);
set = login_settings_read(master_service, pool, &local_ip,
- &conn->remote_ip);
+ &conn->remote_ip, &other_sets);
if (!ssl_connections && !conn->ssl) {
- client = client_create(conn->fd, FALSE, pool, set, &local_ip,
- &conn->remote_ip);
+ client = client_create(conn->fd, FALSE, pool, set, other_sets,
+ &local_ip, &conn->remote_ip);
} else {
fd_ssl = ssl_proxy_new(conn->fd, &conn->remote_ip, set, &proxy);
if (fd_ssl == -1) {
return;
}
- client = client_create(fd_ssl, TRUE, pool, set,
+ client = client_create(fd_ssl, TRUE, pool, set, other_sets,
&local_ip, &conn->remote_ip);
client->ssl_proxy = proxy;
ssl_proxy_set_client(proxy, client);
process_title_init(argv, envp);
set_pool = pool_alloconly_create("global login settings", 4096);
global_login_settings =
- login_settings_read(master_service, set_pool, NULL, NULL);
+ login_settings_read(master_service, set_pool, NULL, NULL,
+ &global_other_settings);
/* main_preinit() needs to know the client limit, which is set by
this. so call it first. */
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
+ -I$(top_srcdir)/src/lib-settings \
-I$(top_srcdir)/src/lib-auth \
-I$(top_srcdir)/src/lib-master \
-I$(top_srcdir)/src/login-common
pop3_login_SOURCES = \
client.c \
client-authenticate.c \
+ pop3-login-settings.c \
pop3-proxy.c
noinst_HEADERS = \
client.h \
client-authenticate.h \
+ pop3-login-settings.h \
pop3-proxy.h
#include "istream.h"
#include "ostream.h"
#include "randgen.h"
+#include "hostpid.h"
#include "safe-memset.h"
#include "str.h"
#include "strescape.h"
#include "auth-client.h"
#include "ssl-proxy.h"
#include "pop3-proxy.h"
-#include "hostpid.h"
+#include "pop3-login-settings.h"
/* Disconnect client when it sends too many bad commands */
#define CLIENT_MAX_BAD_COMMANDS 10
return &pop3_client->common;
}
-static void pop3_client_create(struct client *client ATTR_UNUSED)
+static void pop3_client_create(struct client *client ATTR_UNUSED,
+ void **other_sets ATTR_UNUSED)
{
}
void clients_init(void)
{
- /* Nothing to initialize for POP3 */
+ login_set_roots = pop3_login_setting_roots;
}
void clients_deinit(void)
--- /dev/null
+/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "settings-parser.h"
+#include "login-settings.h"
+#include "pop3-login-settings.h"
+
+#include <stddef.h>
+
+static struct setting_define pop3_login_setting_defines[] = {
+ SETTING_DEFINE_LIST_END
+};
+
+static struct setting_parser_info *pop3_login_setting_dependencies[] = {
+ &login_setting_parser_info,
+ NULL
+};
+
+struct setting_parser_info pop3_login_setting_parser_info = {
+ MEMBER(module_name) "pop3-login",
+ MEMBER(defines) pop3_login_setting_defines,
+ MEMBER(defaults) NULL,
+
+ MEMBER(type_offset) (size_t)-1,
+ MEMBER(struct_size) 0,
+
+ MEMBER(parent_offset) (size_t)-1,
+ MEMBER(parent) NULL,
+
+ MEMBER(check_func) NULL,
+ MEMBER(dependencies) pop3_login_setting_dependencies
+};
+
+const struct setting_parser_info *pop3_login_setting_roots[] = {
+ &login_setting_parser_info,
+ &pop3_login_setting_parser_info,
+ NULL
+};
--- /dev/null
+#ifndef POP3_LOGIN_SETTINGS_H
+#define POP3_LOGIN_SETTINGS_H
+
+extern const struct setting_parser_info *pop3_login_setting_roots[];
+
+#endif