auth-process.c revision ad56ed098867ae42af11132577b9ad3f1c5c17df
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "network.h"
#include "obuffer.h"
#include "restrict-access.h"
#include "auth-process.h"
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
typedef struct _WaitingRequest WaitingRequest;
struct _AuthProcess {
char *name;
int fd;
unsigned int reply_pos;
char reply_buf[sizeof(AuthCookieReplyData)];
};
struct _WaitingRequest {
int id;
void *context;
};
static AuthProcess *processes;
static void auth_process_destroy(AuthProcess *p);
{
}
{
i_warning("imap-auth %ld sent us unrequested reply for id %d",
return;
}
i_fatal("imap-auth %ld sent invalid id for reply "
"(got %d, expecting %d)",
}
/* auth process isn't trusted, validate all data to make sure
it's not trying to exploit us */
i_error("auth: Received corrupted data");
return;
}
}
{
AuthProcess *p = context;
int ret;
if (ret < 0) {
/* disconnected */
return;
}
return;
/* reply is now read */
p->reply_pos = 0;
}
{
AuthProcess *p;
sizeof(AuthCookieRequestData)*100,
p->next_request = &p->requests;
processes = p;
return p;
}
static void auth_process_destroy(AuthProcess *p)
{
AuthProcess **pos;
if (*pos == p) {
break;
}
}
}
o_buffer_unref(p->outbuf);
i_free(p);
}
{
const char *path;
/* create communication to process with a socket pair
FIXME: pipe() would work as well, would it be better? */
i_error("socketpair() failed: %m");
return -1;
}
if (pid < 0) {
i_error("fork() failed: %m");
return -1;
}
if (pid != 0) {
/* master */
return pid;
}
/* create socket for listening auth requests from imap-login */
if (listen_fd == -1)
/* set correct permissions */
/* move master communication handle to 0 */
i_fatal("login: dup2() failed: %m");
/* move login communication handle to 1 */
i_fatal("login: dup2() failed: %m");
stderr it can't go anywhere where it could cause harm */
i_fatal("login: dup2() failed: %m");
/* setup access environment - needs to be done after
clean_child_process() since it clears environment */
/* set other environment */
NULL));
/* hide the path, it's ugly */
return -1;
}
{
AuthProcess *p;
return p;
}
return NULL;
}
unsigned char cookie[AUTH_COOKIE_SIZE],
{
}
static int auth_process_get_count(const char *name)
{
AuthProcess *p;
int count = 0;
count++;
}
return count;
}
void auth_processes_cleanup(void)
{
AuthProcess *p;
}
void auth_processes_destroy_all(void)
{
}
}
{
int count;
(void)create_auth_process(config);
}
}
void auth_processes_init(void)
{
}
void auth_processes_deinit(void)
{
}