1 /* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
2 
3 #include "lib.h"
4 #include "buffer.h"
5 #include "settings-parser.h"
6 #include "service-settings.h"
7 #include "stats-settings.h"
8 
9 /* <settings checks> */
10 static struct file_listener_settings old_stats_unix_listeners_array[] = {
11 	{ "old-stats", 0600, "", "" }
12 };
13 static struct file_listener_settings *old_stats_unix_listeners[] = {
14 	&old_stats_unix_listeners_array[0]
15 };
16 static buffer_t old_stats_unix_listeners_buf = {
17 	{ { old_stats_unix_listeners, sizeof(old_stats_unix_listeners) } }
18 };
19 static struct file_listener_settings old_stats_fifo_listeners_array[] = {
20 	{ "old-stats-mail", 0600, "", "" },
21 	{ "old-stats-user", 0600, "", "" }
22 };
23 static struct file_listener_settings *old_stats_fifo_listeners[] = {
24 	&old_stats_fifo_listeners_array[0],
25 	&old_stats_fifo_listeners_array[1]
26 };
27 static buffer_t old_stats_fifo_listeners_buf = {
28 	{ { old_stats_fifo_listeners, sizeof(old_stats_fifo_listeners) } }
29 };
30 /* </settings checks> */
31 
32 struct service_settings old_stats_service_settings = {
33 	.name = "old-stats",
34 	.protocol = "",
35 	.type = "",
36 	.executable = "old-stats",
37 	.user = "$default_internal_user",
38 	.group = "",
39 	.privileged_group = "",
40 	.extra_groups = "",
41 	.chroot = "empty",
42 
43 	.drop_priv_before_exec = FALSE,
44 
45 	.process_min_avail = 0,
46 	.process_limit = 1,
47 	.client_limit = 0,
48 	.service_count = 0,
49 	.idle_kill = UINT_MAX,
50 	.vsz_limit = UOFF_T_MAX,
51 
52 	.unix_listeners = { { &old_stats_unix_listeners_buf,
53 			      sizeof(old_stats_unix_listeners[0]) } },
54 	.fifo_listeners = { { &old_stats_fifo_listeners_buf,
55 			      sizeof(old_stats_fifo_listeners[0]) } },
56 	.inet_listeners = ARRAY_INIT,
57 
58 	.process_limit_1 = TRUE
59 };
60 
61 /* we're kind of kludging here to avoid "stats_" prefix in the struct fields */
62 #undef DEF
63 #define DEF(type, name) \
64 	SETTING_DEFINE_STRUCT_##type("old_stats_"#name, name, struct old_stats_settings)
65 
66 static const struct setting_define old_stats_setting_defines[] = {
67 	DEF(SIZE, memory_limit),
68 	DEF(TIME, command_min_time),
69 	DEF(TIME, session_min_time),
70 	DEF(TIME, user_min_time),
71 	DEF(TIME, domain_min_time),
72 	DEF(TIME, ip_min_time),
73 	DEF(STR, carbon_server),
74 	DEF(TIME, carbon_interval),
75 	DEF(STR, carbon_name),
76 	SETTING_DEFINE_LIST_END
77 };
78 
79 const struct old_stats_settings old_stats_default_settings = {
80 	.memory_limit = 1024*1024*16,
81 
82 	.command_min_time = 60,
83 	.session_min_time = 60*15,
84 	.user_min_time = 60*60,
85 	.domain_min_time = 60*60*12,
86 	.ip_min_time = 60*60*12,
87 
88 	.carbon_interval = 30,
89 	.carbon_server = "",
90 	.carbon_name = ""
91 };
92 
93 const struct setting_parser_info old_stats_setting_parser_info = {
94 	.module_name = "stats",
95 	.defines = old_stats_setting_defines,
96 	.defaults = &old_stats_default_settings,
97 
98 	.type_offset = SIZE_MAX,
99 	.struct_size = sizeof(struct old_stats_settings),
100 
101 	.parent_offset = SIZE_MAX
102 };
103 
104 const struct old_stats_settings *stats_settings;
105