doveadm-connection.c revision e34d170f8f0e084bd94bfbc1a7085ece67e508df
/* Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "network.h"
#include "istream.h"
#include "ostream.h"
#include "array.h"
#include "str.h"
#include "llist.h"
#include "master-service.h"
#include "user-directory.h"
#include "mail-host.h"
#include "director.h"
#include "director-host.h"
#include "director-request.h"
#include "director-connection.h"
#include "doveadm-connection.h"
#include <unistd.h>
#define DOVEADM_PROTOCOL_VERSION_MAJOR 1
#define DOVEADM_HANDSHAKE "VERSION\tdirector-doveadm\t1\t0\n"
#define MAX_VALID_VHOST_COUNT 1000
struct doveadm_connection {
int fd;
unsigned int handshaked:1;
};
static struct doveadm_connection *doveadm_connections;
{
(*hostp)->user_count);
}
}
{
struct mail_host_list *orig_hosts_list;
unsigned int i, j, orig_hosts_count, cur_hosts_count;
int ret;
/* the hosts are sorted by IP */
for (i = j = 0; i < orig_hosts_count && j < cur_hosts_count; ) {
if (ret == 0)
i++, j++;
else if (ret > 0)
j++;
else {
i++;
}
}
for (; i < orig_hosts_count; i++)
}
{
struct director_host *const *hostp;
const char *type;
type = "removed";
type = "self";
else if (left)
else if (right)
type = "right";
else
type = "";
(unsigned long)last_failed);
}
}
static bool
{
const char *const *args;
struct director_host *host;
i_error("doveadm sent invalid DIRECTOR-ADD parameters");
return FALSE;
}
}
return TRUE;
}
static bool
{
const char *const *args;
struct director_host *host;
unsigned int port = 0;
i_error("doveadm sent invalid DIRECTOR-REMOVE parameters");
return FALSE;
}
else {
}
return TRUE;
}
static bool
{
const char *const *args;
unsigned int vhost_count = -1U;
return FALSE;
}
return TRUE;
}
if (vhost_count != -1U)
return TRUE;
}
static bool
{
i_error("doveadm sent invalid HOST-REMOVE parameters");
return FALSE;
}
else {
}
return TRUE;
}
static void
{
}
}
static bool
{
if (*line == '\0') {
return TRUE;
}
i_error("doveadm sent invalid HOST-FLUSH parameters");
return FALSE;
}
else {
}
return TRUE;
}
static bool
{
unsigned int username_hash;
/* get user's current host */
else {
}
/* get host if it wasn't in user directory */
else
/* get host with default configuration */
else
return TRUE;
}
static bool
{
struct user_directory_iter *iter;
if (*line != '\0') {
i_error("doveadm sent invalid USER-LIST parameters");
return FALSE;
}
} else {
}
"%u\t%u\t%s\n",
} T_END;
}
return TRUE;
}
static bool
{
unsigned int username_hash;
const char *const *args;
return FALSE;
}
return TRUE;
}
return TRUE;
}
return TRUE;
}
{
if (!conn->handshaked) {
return;
}
i_error("doveadm not compatible with this server "
"(mixed old and new binaries?)");
return;
}
}
args = "";
} else {
args++;
}
else {
}
}
}
struct doveadm_connection *
{
struct doveadm_connection *conn;
return conn;
}
{
i_error("close(doveadm connection) failed: %m");
}
void doveadm_connections_deinit(void)
{
while (doveadm_connections != NULL) {
}
}