/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "login-common.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "randgen.h"
#include "module-dir.h"
#include "process-title.h"
#include "restrict-access.h"
#include "restrict-process-size.h"
#include "master-auth.h"
#include "master-service.h"
#include "master-interface.h"
#include "iostream-ssl.h"
#include "client-common.h"
#include "access-lookup.h"
#include "anvil-client.h"
#include "auth-client.h"
#include "dsasl-client.h"
#include "master-service-ssl-settings.h"
#include "login-proxy.h"
#include <unistd.h>
#include <syslog.h>
struct login_access_lookup {
};
unsigned int initial_service_count;
bool login_ssl_initialized;
void **global_other_settings;
static const char *post_login_socket;
{
}
void login_refresh_proctitle(void)
{
const char *addr;
return;
/* clients_get_count() includes all the clients being served.
Inside that there are 3 groups:
1. pre-login clients
2. post-login clients being proxied to remote hosts
3. post-login clients being proxied to post-login processes
connections, so we're assuming that they're the same. */
if (clients_get_count() == 0) {
/* no clients */
if (login_proxies_get_detached_count() > 0) {
/* show detached proxies only if they exist, so
non-proxy servers don't unnecessarily show them. */
}
if (clients_get_fd_proxies_count() > 0) {
/* show post-login proxies only if they exist, so
proxy-only servers don't unnecessarily show them. */
}
} else {
if (addr[0] != '\0')
if (client->fd_proxying)
else
}
}
{
}
void login_client_destroyed(void)
{
}
}
static void login_die(void)
{
if (!auth_client_is_connected(auth_client)) {
/* we don't have auth client, and we might never get one */
}
}
static void
{
void **other_sets;
if (client_init_ssl(client) < 0) {
return;
}
}
}
{
i_error("close(client) failed: %m");
}
}
{
if (!success) {
i_info("access(%s): Client refused (rip=%s)",
} else {
lookup->next_socket++;
}
}
{
/* last one */
return;
}
}
{
char c;
int ret;
if (ret <= 0) {
i_info("access(%s): Client disconnected during lookup (rip=%s)",
} else {
/* actual input. stop listening until lookup is done. */
}
}
{
const char *access_sockets =
/* log the connection's IP address in case we crash. it's of
course possible that another earlier client causes the
crash, but this is better than nothing. */
}
/* make sure we're connected (or attempting to connect) to auth */
if (*access_sockets == '\0') {
/* no access checks */
return;
}
}
{
if (connected) {
} else if (shutting_down)
else if (!auth_connected_once) {
/* auth disconnected without having ever succeeded, so the
auth process is probably misconfigured. no point in
keeping the client connections hanging. */
clients_destroy_all_reason("Disconnected: Auth process broken");
}
}
static bool anvil_reconnect_callback(void)
{
/* we got disconnected from anvil. we can't reconnect to it since we're
chrooted, so just die after we've finished handling the current
connections. */
return FALSE;
}
void login_anvil_init(void)
{
return;
i_fatal("Couldn't connect to anvil");
}
static const struct ip_addr *
{
const char *const *tmp;
unsigned int i, tmp_ips_count;
int ret;
if (ips_str[0] == '?') {
/* try binding to the IP immediately. if it doesn't
work, skip it. (this allows using the same config file for
all the servers.) */
ips_str++;
}
if (ret != 0) {
i_error("login_source_ips: net_gethostbyname(%s) failed: %s",
continue;
}
for (i = 0; i < tmp_ips_count; i++) {
continue;
}
}
}
static void login_load_modules(void)
{
return;
&mod_set);
}
static void login_ssl_init(void)
{
const char *error;
return;
}
static void main_preinit(void)
{
unsigned int max_fds;
/* Initialize SSL proxy so it can read certificate and private
key file. */
/* set the number of fds we want to use. it may get increased or
decreased. leave a couple of extra fds for auth sockets and such.
worst case each connection can use:
- 1 for client
- 1 for login proxy
- 2 for client-side ssl proxy
- 2 for server-side ssl proxy (with login proxy)
However, login process nowadays supports plugins, there are rawlogs
and so on. Don't enforce the fd limit anymore, but use this value
for optimizing the ioloop's fd table size.
*/
/* read the login_source_ips before chrooting so it can access
if (login_source_ips_count > 0) {
/* randomize the initial index in case service_count=1
(although in that case it's unlikely this setting is
even used..) */
}
if (login_debug)
if (restrict_access_get_current_chroot() == NULL) {
if (chdir("login") < 0)
i_fatal("chdir(login) failed: %m");
}
if (login_rawlog_dir != NULL &&
i_error("access(%s, wx) failed: %m - disabling rawlog",
}
}
{
/* make sure we can't fork() */
FALSE);
login_binary->init();
}
static void main_deinit(void)
{
login_binary->deinit();
char **strp;
}
{
const char *login_socket;
int c;
"Dl:R:S");
while ((c = master_getopt(master_service)) > 0) {
switch (c) {
case 'D':
login_debug = TRUE;
break;
case 'l':
break;
case 'R':
break;
case 'S':
break;
default:
return FATAL_DEFAULT;
}
}
login_binary->preinit();
main_preinit();
main_deinit();
return 0;
}