doveadm-connection.c revision 9058f3006fffd25835ad701e1b2c3c8faafd3c80
/* Copyright (c) 2010-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "net.h"
#include "istream.h"
#include "ostream.h"
#include "array.h"
#include "str.h"
#include "strescape.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);
(long)(*hostp)->last_updown_change);
}
}
{
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++)
}
{
if (!dir->ring_handshaked)
else if (dir->ring_synced)
else {
}
}
static void
{
else if (director_connection_is_synced(conn))
else
}
static void
const struct director_host *host,
{
else {
/* we might have a connection that is being connected */
struct director_connection *const *connp;
break;
}
}
}
}
{
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);
else
}
}
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;
i_error("doveadm sent invalid DIRECTOR-REMOVE parameters");
return FALSE;
}
else {
}
return TRUE;
}
static bool
bool update)
{
unsigned int vhost_count = UINT_MAX;
tag = "";
else
}
i_error("doveadm sent invalid %s parameters: %s",
return FALSE;
}
return TRUE;
}
if (update) {
return TRUE;
}
return TRUE;
"host is already being updated - try again later\n");
return TRUE;
}
if (vhost_count != UINT_MAX)
/* NOTE: we don't support changing a tag for an existing host.
it needs to be removed first. otherwise it would be a bit ugly to
handle. */
return TRUE;
}
static bool
{
}
static bool
{
}
static bool
const char *line)
{
i_error("doveadm sent invalid %s parameters: %s",
return FALSE;
}
return TRUE;
}
;
"host is already being updated - try again later\n");
return TRUE;
} else {
}
return TRUE;
}
static bool
{
i_error("doveadm sent invalid HOST-REMOVE parameters");
return FALSE;
}
else {
}
return TRUE;
}
static void
{
unsigned int total_user_count = 0;
}
i_warning("Flushed all backend hosts with %u users. This is an unsafe "
"operation and may cause the same users to end up in multiple backends.",
}
static bool
{
if (*line == '\0') {
return TRUE;
}
i_error("doveadm sent invalid HOST-FLUSH parameters");
return FALSE;
}
else {
}
return TRUE;
}
static void
{
struct user_directory_iter *iter;
continue;
} T_END;
}
}
static void
{
}
static bool
{
if (line[0] == '\0') {
return TRUE;
}
i_error("doveadm sent invalid HOST-RESET-USERS parameters");
return FALSE;
}
else {
}
return TRUE;
}
static bool
{
unsigned int username_hash;
username = "";
tag = "";
} else {
}
/* get user's current host */
else {
}
/* get host if it wasn't in user directory */
else
/* get host with default configuration */
username_hash, tag);
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;
}
static bool
{
const char *const *args;
return FALSE;
}
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) {
}
}