doveadm-mail-server.c revision d03a871a77f8ec36f48f5fea98d810e51b186fdb
/* Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hash.h"
#include "str.h"
#include "strescape.h"
#include "ioloop.h"
#include "master-service.h"
#include "auth-master.h"
#include "mail-storage.h"
#include "mail-storage-service.h"
#include "server-connection.h"
#include "doveadm-settings.h"
#include "doveadm-print.h"
#include "doveadm-server.h"
#include "doveadm-mail.h"
#define DOVEADM_SERVER_CONNECTIONS_MAX 4
#define DOVEADM_SERVER_QUEUE_MAX 16
#define DOVEADM_MAIL_SERVER_FAILED() \
static pool_t server_pool;
static struct doveadm_mail_cmd_context *cmd_ctx;
static bool internal_failure = FALSE;
const char *username);
static struct doveadm_server *
{
struct doveadm_server *server;
char *dup_name;
if (!hash_table_is_created(servers)) {
}
}
return server;
}
static struct server_connection *
{
struct server_connection *const *connp;
if (server_connection_is_idle(*connp))
return *connp;
}
return NULL;
}
{
struct server_connection *const *connp;
if (!server_connection_is_idle(*connp))
return TRUE;
}
return FALSE;
}
{
struct doveadm_server *server;
switch (reply) {
return;
i_error("No such user");
break;
case SERVER_CMD_REPLY_FAIL:
break;
case SERVER_CMD_REPLY_OK:
break;
}
}
}
}
const char *username)
{
unsigned int i;
/* <flags> <username> <command> [<args>] */
if (doveadm_debug)
else if (doveadm_verbose)
}
}
{
do {
}
static int
const struct mail_storage_service_input *input,
{
struct auth_master_connection *auth_conn;
struct auth_user_info info;
const char *proxy_host, *const *fields;
unsigned int i;
bool proxying;
int ret;
return 0;
/* make sure we have an auth connection */
if (ret < 0) {
"because doveadm_proxy_port is set)",
*error_r);
} else if (ret == 0) {
/* user not found from passdb. it could be in userdb though,
so just continue with the default host */
} else {
}
if (!proxying)
ret = 0;
else if (proxy_host == NULL) {
*error_r = "Proxy is missing destination host";
ret = -1;
} else {
}
}
pool_unref(&pool);
return ret;
}
const struct mail_storage_service_input *input,
const char **error_r)
{
struct doveadm_server *server;
struct server_connection *conn;
const char *host;
char *username_dup;
int ret;
if (ret < 0)
return -1;
if (ret == 0 &&
/* run it ourself */
return 0;
}
/* server sends the sticky headers for each row as well,
so undo any sticks we might have added already */
else
} else {
}
*error_r = "doveadm server failure";
}
static struct doveadm_server *doveadm_server_find_used(void)
{
struct hash_iterate_context *iter;
char *key;
struct doveadm_server *server;
break;
}
}
return ret;
}
static void doveadm_servers_destroy_all_connections(void)
{
struct hash_iterate_context *iter;
char *key;
struct doveadm_server *server;
}
}
}
void doveadm_mail_server_flush(void)
{
struct doveadm_server *server;
if (!hash_table_is_created(servers)) {
return;
}
i_error("Aborted");
if (DOVEADM_MAIL_SERVER_FAILED())
}