auth-master-connection.c revision 9d75363d3fbabc2fbc2d80f06672e3ed8965804a
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#include "auth-common.h"
#include "array.h"
#include "hash.h"
#include "str.h"
#include "strescape.h"
#include "str-sanitize.h"
#include "hostpid.h"
#include "hex-binary.h"
#include "ioloop.h"
#include "network.h"
#include "istream.h"
#include "ostream.h"
#include "master-service.h"
#include "userdb.h"
#include "userdb-blocking.h"
#include "master-interface.h"
#include "auth-request-handler.h"
#include "auth-client-connection.h"
#include "auth-master-connection.h"
#include <unistd.h>
#include <stdlib.h>
#define MAX_INBUF_SIZE 1024
struct master_userdb_request {
struct auth_master_connection *conn;
unsigned int id;
struct auth_request *auth_request;
};
struct master_list_iter_ctx {
struct auth_master_connection *conn;
struct auth_userdb *userdb;
struct userdb_iterate_context *iter;
unsigned int id;
bool failed;
};
void *context)
{
const char *reply_str;
}
static bool
{
struct auth_client_connection *client_conn;
const char *const *list;
/* <id> <client-pid> <client-id> <cookie> */
i_error("BUG: Master sent broken REQUEST");
return FALSE;
}
i_error("BUG: Master sent broken REQUEST cookie");
return FALSE;
}
if (client_conn == NULL) {
i_error("Master requested auth for nonexisting client %u",
i_error("Master requested auth for client %u with invalid cookie",
} else if (!auth_request_handler_master_request(
i_error("Master requested auth for non-login client %u",
}
return TRUE;
}
static int
const char **error_r)
{
struct auth_request *auth_request;
unsigned int id;
/* <id> <userid> [<parameters>] */
return -1;
}
return 0;
}
arg = "";
} else {
arg++;
}
}
return -1;
}
return 1;
}
static void
struct auth_request *auth_request)
{
const char *value;
switch (result) {
if (auth_request->userdb_lookup_failed) {
}
break;
break;
case USERDB_RESULT_OK:
break;
}
}
static bool
{
struct auth_request *auth_request;
const char *error;
int ret;
&auth_request, &error);
if (ret <= 0) {
if (ret < 0)
return FALSE;
} else {
}
return TRUE;
}
static void
const unsigned char *credentials ATTR_UNUSED,
struct auth_request *auth_request)
{
switch (result) {
case PASSDB_RESULT_OK:
break;
break;
break;
}
}
static bool
{
struct auth_request *auth_request;
const char *error;
int ret;
&auth_request, &error);
if (ret <= 0) {
if (ret < 0)
return FALSE;
NULL, 0, auth_request);
} else {
}
return TRUE;
}
{
}
{
int ret;
return 1;
}
if (ret > 0)
return 1;
}
{
int ret;
do {
/* iteration is finished */
const char *str;
return;
}
/* continue iterating next userdb */
return;
}
T_BEGIN {
const char *str;
} T_END;
if (ret < 0) {
/* disconnected, don't bother finishing */
return;
}
}
static bool
{
struct master_list_iter_ctx *ctx;
const char *str;
unsigned int id;
/* <id> */
i_error("BUG: Master sent broken LIST");
return FALSE;
}
i_error("Trying to iterate users, but userdbs don't support it");
return TRUE;
}
return TRUE;
}
static bool
{
if (!conn->userdb_only) {
i_error("Authentication client trying to connect to "
"master socket");
return FALSE;
}
}
i_error("BUG: Unknown command in %s socket: %s",
return FALSE;
}
{
char *line;
bool ret;
case 0:
return;
case -1:
/* disconnected */
return;
case -2:
/* buffer full */
i_error("BUG: Master sent us more than %d bytes",
(int)MAX_INBUF_SIZE);
return;
}
if (!conn->version_received) {
return;
/* make sure the major version matches */
i_error("Master not compatible with this server "
"(mixed old and new binaries?)");
return;
}
}
T_BEGIN {
} T_END;
if (!ret) {
return;
}
}
}
{
/* transmit error, probably master died */
return 1;
}
/* allow input again */
}
return 1;
}
struct auth_master_connection *
{
struct auth_master_connection *conn;
const char *line;
my_pid);
return conn;
}
{
struct auth_master_connection *const *masters;
unsigned int idx;
return;
masters);
break;
}
}
i_error("close(): %m");
}
}
{
}
{
return;
}
void auth_master_connections_init(void)
{
}
void auth_master_connections_deinit(void)
{
struct auth_master_connection **masters;
unsigned int i, count;
for (i = count; i > 0; i--)
}