/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "imap-common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "path-util.h"
#include "str.h"
#include "base64.h"
#include "process-title.h"
#include "randgen.h"
#include "restrict-access.h"
#include "write-full.h"
#include "settings-parser.h"
#include "master-interface.h"
#include "master-service.h"
#include "master-login.h"
#include "mail-user.h"
#include "mail-storage-service.h"
#include "smtp-submit-settings.h"
#include "imap-master-client.h"
#include "imap-resp-code.h"
#include "imap-commands.h"
#include "imap-fetch.h"
#include <stdio.h>
#include <unistd.h>
#define IS_STANDALONE() \
.name = "imap",
};
{
return old_hook;
}
void imap_refresh_proctitle(void)
{
bool wait_output;
if (!verbose_proctitle)
return;
switch (imap_client_count) {
case 0:
break;
case 1:
}
wait_output = FALSE;
continue;
}
wait_output = TRUE;
}
if (wait_output) {
}
break;
default:
break;
}
}
{
return;
}
static void imap_die(void)
{
unsigned int stop_msecs;
if (last_io <= stop_timestamp)
else {
}
}
}
struct client_input {
const char *tag;
const unsigned char *input;
bool send_untagged_capability;
};
static void
struct client_input *input_r)
{
if (data[0] == '1')
}
}
static void
{
if (client_input_size > 0) {
if (input.input_size > 0 &&
i_panic("Couldn't add client input to stream");
} else {
/* IMAPLOGINTAG environment is compatible with mailfront */
}
"* PREAUTH [CAPABILITY ",
} else if (input.send_untagged_capability) {
/* client doesn't seem to understand tagged capabilities. send
untagged instead and hope that it works. */
} else {
}
}
static void
{
/* try to condense any responses into as few packets as possible */
(void)client_handle_input(client);
/* we could have already handled LOGOUT, or we might need to continue
pending ambiguous commands. */
if (client->disconnected)
else
}
{
const char *errstr;
});
service_input = *input;
event_unref(&event);
return -1;
}
if (imap_set->verbose_proctitle)
&errstr) <= 0 ||
&errstr) <= 0) {
event_unref(&event);
return -1;
}
event_unref(&event);
return 0;
}
{
i_fatal("USER environment missing");
if (input_base64 == NULL)
else {
}
/* client may be destroyed now */
}
static void
const char *username, const char *const *extra_fields)
{
const char *error;
if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SECURED) != 0)
if ((flags & MAIL_AUTH_REQUEST_FLAG_CONN_SSL_SECURED) != 0)
strlen(MSG_BYE_INTERNAL_ERROR)) < 0) {
i_error("write(client) failed: %m");
}
i_close_fd(&fd);
return;
}
if ((flags & MAIL_AUTH_REQUEST_FLAG_TLS_COMPRESSION) != 0)
/* finish initializing the user (see comment in main()) */
strlen(MSG_BYE_INTERNAL_ERROR)) < 0)
i_error("write_full(client) failed: %m");
return;
}
/* client may be destroyed now */
}
const char *errormsg)
{
const char *msg;
/* ignored */
}
}
{
/* when running standalone, we shouldn't even get here */
/* restoring existing IMAP connection (e.g. from imap-idle) */
} else {
}
}
{
};
/*
* We include MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES so
* that the mail_user initialization is fast and we can
* quickly send back the OK response to LOGIN/AUTHENTICATE.
* Otherwise we risk a very slow namespace initialization to
* cause client timeouts on login.
*/
int c;
if (IS_STANDALONE() && getuid() == 0 &&
printf("* BAD [ALERT] imap binary must not be started from "
"inetd, use imap-login instead.\n");
return 1;
}
if (IS_STANDALONE()) {
} else {
}
while ((c = master_getopt(master_service)) > 0) {
switch (c) {
case 'a':
break;
case 't':
break;
case 'u':
break;
case 'D':
imap_debug = TRUE;
break;
default:
return FATAL_DEFAULT;
}
}
/* plugins may want to add commands, so this needs to be called early */
const char *error;
}
if (!IS_STANDALONE())
/* NOTE: login_set.*_socket_path are now invalid due to data stack
having been freed */
/* fake that we're running, so we know if client was destroyed
while handling its initial input */
if (IS_STANDALONE()) {
T_BEGIN {
} T_END;
} else {
}
if (master_login != NULL)
return 0;
}