commands.c revision d41037c2b3e258e4e1fc73366d3fb191ffce64b6
/* Copyright (c) 2009-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "istream.h"
#include "istream-concat.h"
#include "ostream.h"
#include "istream-dot.h"
#include "safe-mkstemp.h"
#include "anvil-client.h"
#include "master-service.h"
#include "master-service-ssl.h"
#include "iostream-ssl.h"
#include "rfc822-parser.h"
#include "message-date.h"
#include "mail-storage-service.h"
#include "index/raw/raw-storage.h"
#include "lda-settings.h"
#include "lmtp-settings.h"
#include "lmtp-local.h"
#include "mail-deliver.h"
#include "message-address.h"
#include "main.h"
#include "client.h"
#include "commands.h"
#include "lmtp-proxy.h"
#define ERRSTR_TEMP_MAILBOX_FAIL "451 4.3.0 <%s> Temporary internal error"
/*
* EHLO command
*/
{
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);
}
if (client_is_trusted(client))
return 0;
}
/*
* STARTTLS command
*/
{
const char *error;
"443 5.5.1 TLS is already active.\r\n");
return 0;
}
"454 4.7.0 Internal error, TLS not available.\r\n");
return 0;
}
"220 2.0.0 Begin TLS negotiation now.\r\n");
return -1;
}
return 0;
}
/*
* MAIL command
*/
{
struct smtp_address *address;
const char *error;
return 0;
}
return 0;
}
return 0;
}
if (*args == ' ')
args++;
else if (*args != '\0') {
"Invalid character in path");
return 0;
}
/* [SP Mail-parameters] */
switch (pperror) {
break;
break;
default:
i_unreached();
}
return 0;
}
/* connect to anvil before dropping privileges */
}
return 0;
}
/*
* RCPT command
*/
{
struct smtp_address *address;
struct smtp_params_rcpt params;
char delim = '\0';
return 0;
}
return 0;
}
return 0;
}
if (*args == ' ')
args++;
else if (*args != '\0') {
"Invalid character in path");
return 0;
}
/* [SP Rcpt-parameters] */
switch (pperror) {
break;
break;
default:
i_unreached();
}
return 0;
}
¶ms) != 0)
return 0;
}
¶ms);
}
/*
* QUIT command
*/
{
/* don't log the (state name) for successful QUITs */
return -1;
}
/*
* VRFY command
*/
{
return 0;
}
/*
* RSET command
*/
{
return 0;
}
/*
* NOOP command
*/
{
return 0;
}
/*
* DATA command
*/
{
} else {
}
i_stream_unref(&inputs[0]);
return cinput;
}
{
}
static void client_proxy_finish(void *context)
{
}
{
/* headers for local deliveries only */
if (host[0] != '\0')
}
}
{
if (lmtp_local_rcpt_count(client) != 0)
} else {
}
}
{
int fd;
/* continue writing to file */
return -1;
return 0;
}
/* move everything to a temporary file. */
if (fd == -1) {
return -1;
}
/* we just want the fd, unlink it */
/* shouldn't happen.. */
i_close_fd(&fd);
return -1;
}
return -1;
}
return 0;
}
static int
{
return 0;
} else {
}
}
{
const unsigned char *data;
"Temporary internal failure");
return;
}
}
if (ret == 0)
return;
/* client probably disconnected */
return;
}
/* the ending "." line was seen. begin saving the mail. */
}
{
if (client_input_read(client) < 0)
return;
}
{
return 0;
}
if ((lmtp_local_rcpt_count(client) +
lmtp_proxy_rcpt_count(client)) == 0) {
return 0;
}
/* send the DATA reply immediately before we start handling any data */
return -1;
}
/*
* XCLIENT command
*/
{
const char *const *tmp;
in_port_t remote_port = 0;
if (!client_is_trusted(client)) {
return 0;
}
addr += 5;
}
}
}
if (!args_ok) {
return 0;
}
/* args ok, set them and reset the state */
if (remote_port != 0)
return 0;
}