auth-master.c revision fc71e94957d0c2959a609450a2f303640d681858
/* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "network.h"
#include "istream.h"
#include "ostream.h"
#include "env-util.h"
#include "restrict-access.h"
#include "auth-master.h"
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <sysexits.h>
#define AUTH_REQUEST_TIMEOUT 60
#define MAX_INBUF_SIZE 8192
#define MAX_OUTBUF_SIZE 512
struct auth_connection {
int fd;
const char *auth_socket;
const char *user;
struct auth_user_reply *user_reply;
int return_value;
unsigned int handshaked:1;
bool debug;
};
{
struct auth_connection *conn;
/* max. 1 second wait here. */
break;
/* busy. wait for a while. */
}
if (fd == -1) {
return NULL;
}
return conn;
}
{
return;
i_error("close() failed: %m");
}
{
}
{
const char *const *tmp;
const char *chroot_dir = NULL;
} else {
}
}
else
}
{
const char *line;
case 0:
return;
case -1:
/* disconnected */
i_error("Auth lookup disconnected unexpectedly");
return;
case -2:
/* buffer full */
i_error("BUG: Auth master sent us more than %d bytes",
return;
}
if (!conn->handshaked) {
i_error("Auth master version mismatch");
return;
}
break;
}
}
}
conn->return_value = 0;
i_error("Auth lookup returned failure");
i_error("%s is an auth client socket. "
"It should be a master socket.",
conn->auth_socket);
} else {
i_error("BUG: Unexpected input from auth master: %s",
line);
}
}
}
{
if (!conn->handshaked)
i_error("Connecting to dovecot-auth timed out");
else
i_error("User request from dovecot-auth timed out");
}
const char *user,
const char *service,
struct auth_user_reply *reply_r)
{
return -1;
t_strconcat("VERSION\t1\t0\n"
NULL));
return conn->return_value;
}