bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "login-common.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "base64.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "buffer.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "ioloop.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "istream.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "ostream.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "randgen.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "hostpid.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "safe-memset.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "str.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "strescape.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "master-service.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "master-service-ssl-settings.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "client.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "client-authenticate.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "auth-client.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "submission-proxy.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#include "submission-login-settings.h"
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch/* Disconnect client when it sends too many bad commands */
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch#define CLIENT_MAX_BAD_COMMANDS 10
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic const struct smtp_server_callbacks smtp_callbacks;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic struct smtp_server *smtp_server = NULL;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
9249c80276766fdc4d31fc3eebc22fba7d53d77cStephan Boschstatic int submission_login_start_tls(void *conn_ctx,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct istream **input, struct ostream **output)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
0afd9a9acab584e770ffcd6a0e1e02e2d18d360aJosef 'Jeff' Sipek struct submission_client *subm_client = conn_ctx;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct client *client = &subm_client->common;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->starttls = TRUE;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (client_init_ssl(client) < 0) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client_notify_disconnect(client,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch CLIENT_DISCONNECT_INTERNAL_ERROR,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch "TLS initialization failed.");
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client_destroy(client,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch "Disconnected: TLS initialization failed.");
9249c80276766fdc4d31fc3eebc22fba7d53d77cStephan Bosch return -1;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch }
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch login_refresh_proctitle();
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch *input = client->input;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch *output = client->output;
9249c80276766fdc4d31fc3eebc22fba7d53d77cStephan Bosch return 0;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic struct client *submission_client_alloc(pool_t pool)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct submission_client *subm_client;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch subm_client = p_new(pool, struct submission_client, 1);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch return &subm_client->common;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void submission_client_create(struct client *client,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch void **other_sets)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch static const char *const xclient_extensions[] =
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch { "SESSION", "FORWARD", NULL };
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct submission_client *subm_client =
c4588e66e80482994cf0fbc45251cb8e9db6404dJosef 'Jeff' Sipek container_of(client, struct submission_client, common);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct smtp_server_settings smtp_set;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch subm_client->set = other_sets[0];
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch i_zero(&smtp_set);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_set.capabilities = SMTP_CAPABILITY_SIZE |
e1f52248b04b91cf1b5c8f55719391f03198242bStephan Bosch SMTP_CAPABILITY_ENHANCEDSTATUSCODES | SMTP_CAPABILITY_AUTH |
e1f52248b04b91cf1b5c8f55719391f03198242bStephan Bosch SMTP_CAPABILITY_XCLIENT;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (client_is_tls_enabled(client))
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_set.capabilities |= SMTP_CAPABILITY_STARTTLS;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_set.hostname = subm_client->set->hostname;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_set.login_greeting = client->set->login_greeting;
df957821a4b2e2d8708aa35cfe30860ee71af686Stephan Bosch smtp_set.tls_required = !client->secured &&
df957821a4b2e2d8708aa35cfe30860ee71af686Stephan Bosch (strcmp(client->ssl_set->ssl, "required") == 0);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_set.xclient_extensions = xclient_extensions;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_set.debug = client->set->auth_debug;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch subm_client->conn = smtp_server_connection_create_from_streams(
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server, client->input, client->output,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch &client->real_remote_ip, client->real_remote_port,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch &smtp_set, &smtp_callbacks, subm_client);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void submission_client_destroy(struct client *client)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct submission_client *subm_client =
c4588e66e80482994cf0fbc45251cb8e9db6404dJosef 'Jeff' Sipek container_of(client, struct submission_client, common);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (subm_client->conn != NULL)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_connection_close(&subm_client->conn, NULL);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch i_free_and_null(subm_client->proxy_xclient);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void submission_client_notify_auth_ready(struct client *client)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct submission_client *subm_client =
c4588e66e80482994cf0fbc45251cb8e9db6404dJosef 'Jeff' Sipek container_of(client, struct submission_client, common);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
40a926a1aeae93b3d4944b56eacb013d3059b549Stephan Bosch smtp_server_connection_start(subm_client->conn);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschsubmission_client_notify_disconnect(struct client *_client,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch enum client_disconnect_reason reason,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch const char *text)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
c4588e66e80482994cf0fbc45251cb8e9db6404dJosef 'Jeff' Sipek struct submission_client *client =
c4588e66e80482994cf0fbc45251cb8e9db6404dJosef 'Jeff' Sipek container_of(_client, struct submission_client, common);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct smtp_server_connection *conn;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch conn = client->conn;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->conn = NULL;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (conn != NULL) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch switch (reason) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch case CLIENT_DISCONNECT_TIMEOUT:
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_connection_terminate(&conn, "4.4.2", text);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch break;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch case CLIENT_DISCONNECT_SYSTEM_SHUTDOWN:
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_connection_terminate(&conn, "4.3.2", text);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch break;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch case CLIENT_DISCONNECT_INTERNAL_ERROR:
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch default:
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_connection_terminate(&conn, "4.0.0", text);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch break;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch }
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch }
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschclient_connection_cmd_xclient(void *context,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct smtp_server_cmd_ctx *cmd,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct smtp_proxy_data *data)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch unsigned int i;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
0afd9a9acab584e770ffcd6a0e1e02e2d18d360aJosef 'Jeff' Sipek struct submission_client *client = context;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->common.ip = data->source_ip;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->common.remote_port = data->source_port;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->common.proxy_ttl = data->ttl_plus_1;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch for (i = 0; i < data->extra_fields_count; i++) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch const char *name = data->extra_fields[i].name;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch const char *value = data->extra_fields[i].value;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (strcasecmp(name, "FORWARD") == 0) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch size_t value_len = strlen(value);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (client->common.forward_fields != NULL) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch str_truncate(client->common.forward_fields, 0);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch } else {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->common.forward_fields = str_new(
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->common.preproxy_pool,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch MAX_BASE64_DECODED_SIZE(value_len));
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (base64_decode(value, value_len, NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->common.forward_fields) < 0) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_reply(cmd, 501, "5.5.4",
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch "Invalid FORWARD parameter");
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch }
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch }
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch } else if (strcasecmp(name, "SESSION") == 0) {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (client->common.session_id != NULL)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch continue;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->common.session_id =
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch p_strdup(client->common.pool, value);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch }
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch }
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void client_connection_disconnect(void *context, const char *reason)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
0afd9a9acab584e770ffcd6a0e1e02e2d18d360aJosef 'Jeff' Sipek struct submission_client *client = context;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client_disconnect(&client->common, reason);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void client_connection_destroy(void *context)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
0afd9a9acab584e770ffcd6a0e1e02e2d18d360aJosef 'Jeff' Sipek struct submission_client *client = context;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch if (client->conn == NULL)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch return;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client->conn = NULL;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch client_destroy(&client->common, NULL);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic bool client_connection_is_trusted(void *context)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
0afd9a9acab584e770ffcd6a0e1e02e2d18d360aJosef 'Jeff' Sipek struct submission_client *client = context;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch return client->common.trusted;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void submission_login_die(void)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch /* do nothing. submission connections typically die pretty quick anyway.
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch */
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void submission_login_preinit(void)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch login_set_roots = submission_login_setting_roots;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void submission_login_init(void)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch struct smtp_server_settings smtp_server_set;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch /* override the default login_die() */
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch master_service_set_die_callback(master_service, submission_login_die);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch /* initialize SMTP server */
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch i_zero(&smtp_server_set);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_set.protocol = SMTP_PROTOCOL_SMTP;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_set.max_pipelined_commands = 5;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_set.max_bad_commands = CLIENT_MAX_BAD_COMMANDS;
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server = smtp_server_init(&smtp_server_set);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic void submission_login_deinit(void)
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch clients_destroy_all();
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch smtp_server_deinit(&smtp_server);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic const struct smtp_server_callbacks smtp_callbacks = {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_cmd_helo = cmd_helo,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_start_tls = submission_login_start_tls,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_cmd_auth = cmd_auth,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_cmd_auth_continue = cmd_auth_continue,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_cmd_xclient = client_connection_cmd_xclient,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_disconnect = client_connection_disconnect,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_destroy = client_connection_destroy,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .conn_is_trusted = client_connection_is_trusted
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch};
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic struct client_vfuncs submission_client_vfuncs = {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_client_alloc,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_client_create,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_client_destroy,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_client_notify_auth_ready,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_client_notify_disconnect,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_client_auth_send_challenge,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_client_auth_result,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_proxy_reset,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_proxy_parse_line,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_proxy_error,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch submission_proxy_get_state,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch NULL
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch};
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschstatic const struct login_binary submission_login_binary = {
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .protocol = "submission",
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .process_name = "submission-login",
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .default_port = 587,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .client_vfuncs = &submission_client_vfuncs,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .preinit = submission_login_preinit,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .init = submission_login_init,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .deinit = submission_login_deinit,
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch .sasl_support_final_reply = FALSE
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch};
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Boschint main(int argc, char *argv[])
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch{
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch return login_binary_run(&submission_login_binary, argc, argv);
2cbbe9b4829adb184c83dbf780316f4144559054Stephan Bosch}