auth-client.c revision b8d232d88018c5cafd2f3be5a181d318137a45f2
/* 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-client.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
static int return_value;
struct auth_connection {
int fd;
const char *auth_socket;
const char *user;
unsigned int handshaked:1;
};
{
i_error("close() failed: %m");
}
{
char *p;
if (*p == '\0')
return TRUE;
}
return FALSE;
return TRUE;
}
{
char *p;
if (*p == '\0')
return TRUE;
}
return FALSE;
return TRUE;
}
{
const char *const *tmp, *extra_groups;
unsigned int len;
if (debug)
if (uid == 0) {
i_error("userdb(%s) returned 0 as uid",
}
if (gid == 0) {
i_error("userdb(%s) returned 0 as gid",
}
} else {
}
}
i_error("mail_uid setting is invalid");
return;
}
}
if (uid == 0) {
return;
}
i_error("mail_gid setting is invalid");
return;
}
}
if (gid == 0) {
return;
}
if (chroot_dir != NULL) {
/* strip chroot dir from home dir */
}
}
if (extra_groups != NULL) {
extra_groups, NULL));
}
}
{
const char *line;
case 0:
return;
case -1:
/* disconnected */
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;
}
}
}
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);
}
}
}
{
struct auth_connection *conn;
/* max. 1 second wait here. */
break;
/* busy. wait for a while. */
}
if (fd == -1) {
return NULL;
}
return conn;
}
{
if (!conn->handshaked)
i_error("Connecting to dovecot-auth timed out");
else
i_error("User request from dovecot-auth timed out");
}
const char *auth_socket,
{
struct auth_connection *conn;
return EX_TEMPFAIL;
t_strconcat("VERSION\t1\t0\n"
"service=deliver\n", NULL));
return return_value;
}