commands.c revision 4818cf6ae9cda663ad68823fd83b18ac380a8a4d
/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "strescape.h"
#include "hostpid.h"
#include "istream.h"
#include "istream-concat.h"
#include "ostream.h"
#include "istream-dot.h"
#include "safe-mkstemp.h"
#include "master-service.h"
#include "rfc822-parser.h"
#include "message-date.h"
#include "auth-master.h"
#include "mail-storage-service.h"
#include "index/raw/raw-storage.h"
#include "lda-settings.h"
#include "lmtp-settings.h"
#include "mail-deliver.h"
#include "main.h"
#include "client.h"
#include "commands.h"
#include "lmtp-proxy.h"
#include <stdlib.h>
#define ERRSTR_TEMP_MAILBOX_FAIL "451 4.3.0 <%s> Temporary internal error"
#define ERRSTR_TEMP_USERDB_FAIL "451 4.3.0 <%s> Temporary user lookup failure"
{
struct rfc822_parser_context parser;
const char *p;
int ret = 0;
if (*args == '\0') {
return 0;
}
/* domain / address-literal */
NULL);
if (*args != '[')
else {
if (*p == '\\' || *p == '[')
break;
}
if (strcmp(p, "]") != 0)
ret = -1;
}
if (ret < 0) {
str_truncate(domain, 0);
}
return 0;
}
{
unsigned int len;
return 0;
}
addr = "";
else {
argv++;
}
return 0;
}
else {
"501 5.5.4 Unsupported options");
return 0;
}
}
return 0;
}
{
const struct mail_recipient *rcpt;
return TRUE;
}
return FALSE;
}
static bool
{
if (p == NULL) {
value = "";
} else {
value = p + 1;
}
if (!port_set)
} else {
return FALSE;
}
/* changing the username */
} else {
/* just ignore it */
}
}
i_error("proxy: host not given");
return FALSE;
}
return proxying;
}
static bool
const struct lmtp_proxy_settings *set)
{
return FALSE;
return FALSE;
return FALSE;
return TRUE;
}
{
struct auth_master_connection *auth_conn;
struct lmtp_proxy_settings set;
struct auth_user_info info;
struct mail_storage_service_input input;
int ret;
if (ret <= 0) {
pool_unref(&pool);
if (ret < 0) {
address);
return TRUE;
} else {
/* user not found from passdb. try userdb also. */
return FALSE;
}
}
/* not proxying this user */
pool_unref(&pool);
return FALSE;
}
pool_unref(&pool);
return FALSE;
}
if (client->mail_body_8bitmime)
args = " BODY=8BITMIME";
else if (client->mail_body_7bit)
args = " BODY=7BIT";
else
args = "";
}
else
pool_unref(&pool);
return TRUE;
}
static const char *lmtp_unescape_address(const char *name)
{
const char *p;
if (*name != '"')
return name;
/* quoted-string local-part. drop the quotes unless there's a
'@' character inside or there's an error. */
if (*p == '\0')
return name;
if (*p == '\\') {
if (p[1] == '\0') {
/* error */
return name;
}
p++;
}
if (*p == '@')
return name;
str_append_c(str, *p);
}
p++;
if (*p != '@' && *p != '\0')
return name;
str_append(str, p);
}
{
struct mail_recipient rcpt;
struct mail_storage_service_input input;
unsigned int len;
int ret = 0;
return 0;
}
addr = "";
else {
argv++;
}
return 0;
}
return 0;
}
return 0;
}
return 0;
}
if (ret < 0) {
return 0;
}
if (ret == 0) {
"550 5.1.1 <%s> User doesn't exist", name);
return 0;
}
return 0;
}
{
return -1;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
static int
{
struct mail_deliver_context dctx;
struct mail_storage *storage;
void **sets;
const char *error;
enum mail_error mail_error;
int ret;
&error) < 0) {
return -1;
}
}
ret = 0;
/* This shouldn't happen */
i_error("BUG: Saving failed to unknown storage");
ret = -1;
} else {
if (mail_error == MAIL_ERROR_NOSPACE) {
"452 4.2.2" : "552 5.2.2",
} else {
}
ret = -1;
}
return ret;
}
{
const struct mail_recipient *rcpts;
unsigned int count;
int ret;
src_mail);
if (ret == 0)
return TRUE;
/* failed. try the next one. */
}
return FALSE;
}
{
const struct mail_recipient *rcpt;
}
{
FALSE);
} else {
}
i_stream_unref(&inputs[0]);
return cinput;
}
{
static const char *wanted_headers[] = {
"From", "To", "Message-ID", "Subject", "Return-Path",
};
struct raw_mailbox *raw_box;
struct mailbox_header_lookup_ctx *headers_ctx;
enum mail_error error;
"Dovecot Delivery Mail", input,
if (mailbox_open(box) < 0 ||
i_error("Can't open delivery mail as raw: %s",
mailbox_close(&box);
return -1;
}
0, headers_ctx);
return 0;
}
static void
{
return;
/* save the message to the first recipient's mailbox */
return;
else
/* use the first saved message to save it elsewhere too.
this might allow hard linking the files. */
mailbox_close(&box);
}
}
{
}
static void client_proxy_finish(void *context)
{
}
{
const char *host;
const struct mail_recipient *rcpt =
}
}
{
}
return ret;
}
{
int fd;
/* continue writing to file */
return -1;
return 0;
}
/* move everything to a temporary file. FIXME: it really shouldn't
be in /tmp.. */
if (fd == -1)
return -1;
/* we just want the fd, unlink it */
/* shouldn't happen.. */
return -1;
}
return -1;
return 0;
}
static int
{
return 0;
} else {
}
}
{
const unsigned char *data;
"Temporary internal failure");
return;
}
}
if (ret == 0)
return;
}
{
if (client_input_read(client) < 0)
return;
}
{
return 0;
}
return 0;
}
} else {
}
return -1;
}