login-common.h revision a87eeb418cb3776380a1e1ffa8a9127e2b181ff0
7cb128dc4cae2a03a742f63ba7afee23c78e3af0Phil Carmody#ifndef LOGIN_COMMON_H
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#define LOGIN_COMMON_H
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#include "lib.h"
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#include "net.h"
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#include "login-settings.h"
a8fe899601735459641edae975c0fa08be8482e2Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen/* Used only for string sanitization */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#define MAX_MECH_NAME 64
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#define AUTH_FAILED_MSG "Authentication failed."
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#define AUTH_TEMP_FAILED_MSG "Temporary authentication failure."
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#define AUTH_PLAINTEXT_DISABLED_MSG \
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen "Plaintext authentication disallowed on non-secure (SSL/TLS) connections."
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#define LOGIN_DEFAULT_SOCKET "login"
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#define LOGIN_TOKEN_DEFAULT_SOCKET "tokenlogin"
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenstruct login_binary {
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen /* e.g. imap, pop3 */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen const char *protocol;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen /* e.g. imap-login, pop3-login */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen const char *process_name;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen /* e.g. 143, 110 */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen in_port_t default_port;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen /* e.g. 993, 995. if there is no ssl port, use 0. */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen in_port_t default_ssl_port;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen /* if value is NULL, LOGIN_DEFAULT_SOCKET is used as the default */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen const char *default_login_socket;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen const struct client_vfuncs *client_vfuncs;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen void (*preinit)(void);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen void (*init)(void);
44f93baa7b8dca7d00bf187cd3db1c15eed384d2Timo Sirainen void (*deinit)(void);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen bool sasl_support_final_reply;
44f93baa7b8dca7d00bf187cd3db1c15eed384d2Timo Sirainen};
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenstruct login_module_register {
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen unsigned int id;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen};
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern struct login_module_register login_module_register;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern const struct login_binary *login_binary;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern struct auth_client *auth_client;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern struct master_auth *master_auth;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern bool closing_down, login_debug;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern struct anvil_client *anvil;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern const char *login_rawlog_dir;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern unsigned int initial_service_count;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen/* NULL-terminated array of all alt_usernames seen so far. Existing fields are
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen never removed. */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern ARRAY_TYPE(string) global_alt_usernames;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern const struct login_settings *global_login_settings;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern const struct master_service_ssl_settings *global_ssl_settings;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern void **global_other_settings;
e27db67b4549773e5015643e776bda9e7025719fTimo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern const struct ip_addr *login_source_ips;
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenextern unsigned int login_source_ips_idx, login_source_ips_count;
e27db67b4549773e5015643e776bda9e7025719fTimo Sirainen
e27db67b4549773e5015643e776bda9e7025719fTimo Sirainenvoid login_refresh_proctitle(void);
e27db67b4549773e5015643e776bda9e7025719fTimo Sirainenvoid login_client_destroyed(void);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
e27db67b4549773e5015643e776bda9e7025719fTimo Sirainen/* Call to guarantee that the "anvil" global variable is initialized. */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenvoid login_anvil_init(void);
e27db67b4549773e5015643e776bda9e7025719fTimo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenint login_binary_run(const struct login_binary *binary,
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen int argc, char *argv[]);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen#endif
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen