client-connection.c revision 1172b608624245a5b05ca299d3279e34003ed308
/* Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "base64.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "strescape.h"
#include "settings-parser.h"
#include "iostream-ssl.h"
#include "master-service.h"
#include "master-service-ssl.h"
#include "master-service-settings.h"
#include "mail-storage-service.h"
#include "doveadm-util.h"
#include "doveadm-server.h"
#include "doveadm-mail.h"
#include "doveadm-print.h"
#include "doveadm-settings.h"
#include "client-connection.h"
#include <unistd.h>
static struct doveadm_mail_cmd_context *
doveadm_mail_cmd_server_parse(const char *cmd_name,
const struct doveadm_settings *set,
const struct mail_storage_service_input *input,
{
struct doveadm_mail_cmd_context *ctx;
const struct doveadm_mail_cmd *cmd;
const char *getopt_args;
bool add_username_header = FALSE;
int c;
return NULL;
}
ctx->service_flags |=
if (doveadm_debug)
switch (c) {
case 'A':
break;
case 'S':
/* ignore */
break;
case 'u':
break;
default:
i_error("doveadm %s: "
"Client sent unknown parameter: %c",
return NULL;
}
}
}
optind = 1;
i_error("doveadm %s: Client sent unknown parameter: %s",
return NULL;
}
if (doveadm_print_is_initialized() && add_username_header) {
}
return ctx;
}
static void
struct doveadm_mail_cmd_context *ctx,
const struct mail_storage_service_input *input)
{
const char *error;
int ret;
if (ret < 0) {
} else if (ret == 0) {
/* maybe not an error, but not a full success either */
} else {
}
/* clear all headers */
}
const char *cmd_name)
{
return TRUE;
T_BEGIN {
const char *const *cmds =
break;
}
}
} T_END;
return ret;
}
{
struct mail_storage_service_input input;
struct doveadm_mail_cmd_context *ctx;
unsigned int argc;
if (argc < 3) {
i_error("doveadm client: No command given");
return FALSE;
}
/* leave the command name as args[0] so getopt() works */
args += 2;
argc -= 2;
switch (*flags) {
case 'D':
break;
case 'v':
break;
default:
return FALSE;
}
}
i_error("doveadm client isn't allowed to use command: %s",
cmd_name);
return FALSE;
}
/* make sure client_connection_input() isn't called by the ioloop that
is going to be run by doveadm_mail_cmd_server_run() */
else
/* flush the output and disconnect */
return TRUE;
}
static int
{
const unsigned char *data;
return -1;
return 0;
}
i_error("doveadm_password not set, "
"remote authentication disabled");
return -1;
}
/* FIXME: some day we should probably let auth process do this and
support all kinds of authentication */
i_error("doveadm client attempted non-PLAIN authentication");
return -1;
}
i_error("doveadm client sent invalid base64 auth PLAIN data");
return -1;
}
i_error("doveadm client didn't authenticate as 'doveadm'");
return -1;
}
i_error("doveadm client authenticated with wrong password");
return -1;
}
return 1;
}
{
const char *line;
int ret;
if (!conn->handshaked) {
return;
}
i_error("doveadm client not compatible with this server "
"(mixed old and new binaries?)");
return;
}
}
if (!conn->authenticated) {
if (ret < 0) {
}
return;
}
}
T_BEGIN {
char **args;
} T_END;
}
}
{
const struct setting_parser_info *set_roots[] = {
};
struct master_service_settings_input input;
struct master_service_settings_output output;
const char *error;
void *set;
return -1;
}
return 0;
}
{
&conn->ssl_iostream) < 0)
return -1;
i_error("SSL handshake failed: %s",
return -1;
}
return 0;
}
static void
{
const char *listen_path;
/* we'll have to do this with stat(), because at least in Linux
fstat() always returns mode as 0777 */
/* no need for client to authenticate */
} else {
}
}
struct client_connection *
{
struct client_connection *conn;
unsigned int port;
if (client_connection_read_settings(conn) < 0) {
return NULL;
}
if (ssl) {
if (client_connection_init_ssl(conn) < 0) {
return NULL;
}
}
return conn;
}
{
i_error("close(client) failed: %m");
}
{
}