deliver.c revision 70c181da837ed85fc5b0426c010b65609bda5329
/* Copyright (C) 2005 Timo Sirainen */
/* FIXME: pretty ugly thing. */
#include "lib.h"
#include "lib-signals.h"
#include "ioloop.h"
#include "env-util.h"
#include "network.h"
#include "restrict-access.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "var-expand.h"
#include "mail-storage.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <pwd.h>
#include <sysexits.h>
#define DEFAULT_AUTH_SOCKET_PATH "/var/run/dovecot/auth-master"
#define MAX_INBUF_SIZE 8192
#define MAX_OUTBUF_SIZE 512
struct auth_connection {
int fd;
unsigned int handshaked:1;
};
static int return_value = EX_SOFTWARE;
{
}
{
struct mailbox_sync_context *ctx;
struct mailbox_sync_rec sync_rec;
struct mailbox_status status;
;
}
struct save_mail_context {
struct mail_save_context *save_ctx;
int ret;
};
static void save_mail_input(void *context)
{
}
}
{
struct mailbox_transaction_context *t;
struct save_mail_context ctx;
int ret = 0;
return FALSE;
if (sync_quick(box) < 0) {
return FALSE;
}
if (ret < 0)
else
if (ret < 0)
else
ret = mailbox_transaction_commit(t, 0);
return ret;
}
{
}
static void auth_parse_input(const char *args)
{
const char *const *tmp;
}
}
static void auth_input(void *context)
{
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;
}
}
}
else {
i_error("BUG: Unexpected input from auth master: %s",
line);
}
}
}
{
struct auth_connection *conn;
int fd;
if (fd < 0) {
return NULL;
}
return conn;
}
{
struct auth_connection *conn;
return EX_TEMPFAIL;
t_strconcat("VERSION\t1\t0\n"
"service=deliver\n", NULL));
return return_value;
}
static void config_file_init(const char *path)
{
int fd;
if (fd < 0)
t_push();
if (*line == '#')
continue;
continue;
do {
value++;
} while (*value == ' ');
}
t_pop();
}
static const struct var_expand_table *
{
static struct var_expand_table static_tab[] = {
{ 'u', NULL },
{ 'n', NULL },
{ 'd', NULL },
{ 's', NULL },
{ 'h', NULL },
{ 'l', NULL },
{ 'r', NULL },
{ 'p', NULL },
{ '\0', NULL }
};
struct var_expand_table *tab;
return tab;
}
static const char *
{
const char *p;
/* it's either type:data or just data */
if (p != NULL) {
while (env != p) {
env++;
}
}
/* expand home */
}
/* expand %vars */
}
{
const char *auth_socket = DEFAULT_AUTH_SOCKET_PATH;
const char *destination, *mail;
const struct var_expand_table *table;
enum mail_storage_flags flags;
struct mail_storage *storage;
int i, ret;
const char *str;
lib_init();
destination = NULL;
for (i = 1; i < argc; i++) {
/* destination user */
i++;
if (i == argc) {
"Missing destination argument");
}
destination = argv[i];
/* auth master socket path */
i++;
if (i == argc) {
"Missing auth socket path argument");
}
auth_socket = argv[i];
} else {
}
}
if (destination != NULL) {
if (ret != 0)
return ret;
} else if (geteuid() != 0) {
/* we're non-root. get our username. */
}
if (destination == NULL) {
"destination user parameter (-d user) not given");
}
flags = 0;
/*FIXME:if ((uidl_keymask & UIDL_MD5) != 0)
flags |= MAIL_STORAGE_FLAG_KEEP_HEADER_MD5;*/
else
/* FIXME: how should we handle namespaces? */
flags, lock_method);
"Failed to create storage for '%s' with mail '%s'",
}
net_set_nonblock(0, TRUE);
return EX_TEMPFAIL;
lib_deinit();
return EX_OK;
}