/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "lib-signals.h"
#include "str.h"
#include "base64.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "strescape.h"
#include "iostream-ssl.h"
#include "ostream-multiplex.h"
#include "master-service.h"
#include "master-service-ssl.h"
#include "mail-storage-service.h"
#include "doveadm-util.h"
#include "doveadm-mail.h"
#include "doveadm-print.h"
#include "doveadm-server.h"
#include "client-connection-private.h"
#include <unistd.h>
struct client_connection_tcp {
int fd;
};
static void
static void
static void
static void ATTR_FORMAT(2, 0)
{
if (doveadm_client != NULL &&
char c;
bool corked;
/* prevent re-entering this code if
any of the following code causes logging */
/* since we can get here from just about anywhere, make sure
the log ostream uses the connection's ioloop. */
if (!corked)
}
}
if (corked)
} T_END;
case LOG_TYPE_DEBUG:
break;
case LOG_TYPE_INFO:
break;
case LOG_TYPE_WARNING:
case LOG_TYPE_ERROR:
break;
default:
i_unreached();
}
}
static void doveadm_server_capture_logs(void)
{
}
static void doveadm_server_restore_logs(void)
{
}
static void
{
if (doveadm_exit_code == 0) {
return;
}
} else {
i_error("BUG: Command '%s' returned unknown error code %d",
}
}
static void
struct doveadm_cmd_context *cctx)
{
}
static void
const struct doveadm_cmd *cmd)
{
}
static int
const struct doveadm_settings *set,
struct doveadm_cmd_context *cctx,
struct doveadm_mail_cmd_context **mctx_r)
{
const char *getopt_args;
int c;
mctx->service_flags |=
if (doveadm_debug)
switch (c) {
case 'A':
case 'F':
break;
case 'S':
/* ignore */
break;
case 'u':
break;
default:
i_error("doveadm %s: "
"Client sent unknown parameter: %c",
return -1;
}
}
}
i_error("doveadm %s: Client sent unknown parameter: %s",
return -1;
}
}
}
if (doveadm_print_is_initialized() && add_username_header) {
}
return 0;
}
static void
struct doveadm_mail_cmd_context *mctx)
{
const char *error;
int ret;
if (ret < 0) {
} else if (ret == 0) {
/* maybe not an error, but not a full success either */
} else {
}
}
const char *cmd_name,
struct doveadm_cmd_context *cctx)
{
return -1;
}
} else {
return -1;
}
} else {
}
/* some commands will want to call io_loop_run(), but we're already
running one and we can't call the original one recursively, so
create a new ioloop. */
else
/* clear all headers */
return doveadm_exit_code == 0 ? 0 : -1;
}
const char *const *args)
{
if (argc < 3) {
i_error("doveadm client: No command given");
return FALSE;
}
doveadm_exit_code = 0;
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;
}
/* Disable IO while running a command. This is required for commands
that do IO themselves (e.g. dsync-server). */
/* flush the output and possibly run next command */
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 */
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 *error;
}
}
static void
{
const char *line;
int ret;
unsigned int minor;
if (!conn->handshaked) {
}
return;
}
i_error("doveadm client not compatible with this server "
"(mixed old and new binaries?)");
return;
}
if (minor > 0) {
/* send version reply */
}
}
if (!conn->authenticated) {
if (ret < 0) {
}
return;
}
}
if (conn->use_multiplex) {
o_stream_unref(&os);
}
}
T_BEGIN {
const char *const *args;
} T_END;
}
}
static int
{
const char *error;
return -1;
}
i_error("SSL handshake failed: %s",
return -1;
}
return 0;
}
static bool
{
const char *listen_path;
/* we'll have to do this with stat(), because at least in Linux
fstat() always returns mode as 0777 */
}
static void
{
if (conn->preauthenticated) {
/* no need for client to authenticate */
} else {
}
}
static void
{
(struct client_connection_tcp *)_conn;
}
}
struct client_connection *
{
return NULL;
}
if (ssl) {
if (client_connection_tcp_init_ssl(conn) < 0) {
return NULL;
}
}
/* add IO after SSL istream is created */
}
static void
{
}