1 #ifndef LOGIN_COMMON_H
2 #define LOGIN_COMMON_H
3 
4 #include "lib.h"
5 #include "net.h"
6 #include "login-settings.h"
7 
8 /* Used only for string sanitization */
9 #define MAX_MECH_NAME 64
10 
11 #define AUTH_FAILED_MSG "Authentication failed."
12 #define AUTH_TEMP_FAILED_MSG "Temporary authentication failure."
13 #define AUTH_PLAINTEXT_DISABLED_MSG \
14 	"Plaintext authentication disallowed on non-secure (SSL/TLS) connections."
15 
16 #define LOGIN_DEFAULT_SOCKET "login"
17 #define LOGIN_TOKEN_DEFAULT_SOCKET "tokenlogin"
18 
19 struct login_binary {
20 	/* e.g. imap, pop3 */
21 	const char *protocol;
22 	/* e.g. imap-login, pop3-login */
23 	const char *process_name;
24 
25 	/* e.g. 143, 110 */
26 	in_port_t default_port;
27 	/* e.g. 993, 995. if there is no ssl port, use 0. */
28 	in_port_t default_ssl_port;
29 
30 	/* if value is NULL, LOGIN_DEFAULT_SOCKET is used as the default */
31 	const char *default_login_socket;
32 
33 	struct event_category event_category;
34 
35 	const struct client_vfuncs *client_vfuncs;
36 	void (*preinit)(void);
37 	void (*init)(void);
38 	void (*deinit)(void);
39 
40 	bool sasl_support_final_reply:1;
41 	bool anonymous_login_acceptable:1;
42 };
43 
44 struct login_module_register {
45 	unsigned int id;
46 };
47 extern struct login_module_register login_module_register;
48 
49 extern struct login_binary *login_binary;
50 extern struct auth_client *auth_client;
51 extern struct master_auth *master_auth;
52 extern bool closing_down, login_debug;
53 extern struct anvil_client *anvil;
54 extern const char *login_rawlog_dir;
55 extern unsigned int initial_service_count;
56 /* NULL-terminated array of all alt_usernames seen so far. Existing fields are
57    never removed. */
58 extern ARRAY_TYPE(string) global_alt_usernames;
59 extern bool login_ssl_initialized;
60 
61 extern const struct login_settings *global_login_settings;
62 extern const struct master_service_ssl_settings *global_ssl_settings;
63 extern void **global_other_settings;
64 
65 extern const struct ip_addr *login_source_ips;
66 extern unsigned int login_source_ips_idx, login_source_ips_count;
67 extern struct event *event_auth;
68 
69 
70 void login_refresh_proctitle(void);
71 void login_client_destroyed(void);
72 
73 /* Call to guarantee that the "anvil" global variable is initialized. */
74 void login_anvil_init(void);
75 
76 int login_binary_run(struct login_binary *binary,
77 		     int argc, char *argv[]);
78 
79 #endif
80