doveadm-mail-server.c revision ae369149607cd8b9e3f6afdcf7c16cff1abdda54
/* Copyright (c) 2010-2014 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() \
struct doveadm_mail_server_cmd {
struct server_connection *conn;
char *username;
};
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;
}
void *context)
{
struct doveadm_server *server =
switch (exit_code) {
case 0:
break;
i_error("%s: Command %s failed for %s: %s",
return;
case EX_NOUSER:
break;
default:
break;
}
struct server_connection *conn;
}
}
}
const char *username)
{
struct doveadm_mail_server_cmd *servercmd;
unsigned int i;
/* <flags> <username> <command> [<args>] */
if (doveadm_debug)
else if (doveadm_verbose)
}
}
{
do {
}
static int
const struct mail_storage_service_input *input,
const char **error_r)
{
struct auth_master_connection *auth_conn;
struct auth_user_info info;
unsigned int i, proxy_port;
bool proxying;
int ret;
return 0;
/* make sure we have an auth connection */
if (ret < 0) {
"because doveadm_port is set)",
} else if (ret == 0) {
/* user not found from passdb. it could be in userdb though,
so just continue with the default host */
} else {
proxy_port = 0;
}
}
if (!proxying)
ret = 0;
else if (proxy_host == NULL) {
"%s (maybe set auth_socket_path=director-userdb)",
*error_r);
}
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;
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())
}