/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "net.h"
#include "ioloop.h"
#include "hostpid.h"
#include "istream.h"
#include "ostream.h"
#include "llist.h"
#include "hex-binary.h"
#include "hash.h"
#include "str.h"
#include "strescape.h"
#include "master-interface.h"
#include "master-service.h"
#include "master-auth.h"
#include "master-login-auth.h"
struct master_login_auth_request {
unsigned int id;
unsigned int auth_id;
unsigned int client_pid;
void *context;
};
struct master_login_auth {
const char *auth_socket_path;
int refcount;
int fd;
unsigned int id_counter;
/* linked list of requests, ordered by create_stamp */
};
struct master_login_auth *
{
return auth;
}
static void
const char *reason)
{
i_error("%s (client-pid=%u client-id=%u)",
}
{
"Disconnected from auth server, aborting");
}
}
}
{
return;
}
{
}
{
}
{
const char *reason;
auth_get_next_timeout_secs(auth) == 0) {
"Auth server request timed out after %u secs",
}
}
{
}
}
static void
struct master_login_auth_request *request)
{
bool update_timeout;
if (update_timeout) {
}
}
static struct master_login_auth_request *
unsigned int id)
{
return NULL;
}
return NULL;
}
return request;
}
static bool
{
const char *const *list;
unsigned int id;
/* <id> <userid> [..] */
i_error("Auth server sent corrupted USER line");
return FALSE;
}
}
return TRUE;
}
static bool
const char *args)
{
unsigned int id;
i_error("Auth server sent corrupted NOTFOUND line");
return FALSE;
}
"Authenticated user not found from userdb, "
"auth lookup id=%u", id);
}
return TRUE;
}
static bool
const char *args_line)
{
unsigned int i, id;
i_error("Auth server sent broken FAIL line");
return FALSE;
}
}
"Internal auth failure");
} else {
i_error("Internal auth failure: %s "
"(client-pid=%u client-id=%u)",
}
}
return TRUE;
}
{
const char *line;
bool ret;
case 0:
return;
case -1:
/* disconnected. stop accepting new connections, because in
default configuration we no longer have permissions to
connect back to auth-master */
return;
case -2:
/* buffer full */
i_error("Auth server sent us too long line");
return;
}
if (!auth->version_received) {
return;
/* make sure the major version matches */
i_error("Authentication server not compatible with "
"master process (mixed old and new binaries?)");
return;
}
}
if (!auth->spid_received) {
return;
i_error("Authentication server didn't "
"send valid SPID as expected: %s", line);
return;
}
}
else
break;
}
}
}
static int
{
int fd;
if (fd == -1) {
i_error("net_connect_unix(%s) failed: %m",
return -1;
}
return 0;
}
static bool
struct master_login_auth_request *req)
{
/* auth server was restarted. don't even attempt a login. */
i_warning("Auth server restarted (pid %u -> %u), aborting auth",
(unsigned int)auth->auth_server_pid);
return FALSE;
}
return TRUE;
}
{
}
}
static void
struct master_login_auth_request *req)
{
return;
}
if (auth->request_auth_token)
}
const struct master_auth_request *req,
void *context)
{
unsigned int id;
if (master_login_auth_connect(auth) < 0) {
/* we couldn't connect to auth now,
so we probably can't in future either. */
context);
return;
}
t_strdup_printf("VERSION\t%u\t%u\n",
}
if (id == 0)
id++;
}
{
}