1 | /* |
1 | /* |
2 | * conf.C: Configuration processing. |
2 | * conf.C: Configuration processing. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
4 | * |
4 | * |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
6 | */ |
6 | */ |
7 | |
7 | |
8 | static char const rcsid[] = "$Id: conf.C,v 1.3 2007/07/21 13:23:21 pippijn Exp $"; |
8 | static char const rcsid[] = "$Id: conf.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; |
9 | |
9 | |
10 | #include "atheme.h" |
10 | #include "atheme.h" |
|
|
11 | #include <ermyth/crypto.h> |
|
|
12 | #include <ermyth/database.h> |
|
|
13 | #include <ermyth/module.h> |
11 | #include <account/myuser.h> |
14 | #include <account/myuser.h> |
12 | #include <account/mychan.h> |
15 | #include <account/mychan.h> |
13 | #include <account/chanacs.h> |
16 | #include <account/chanacs.h> |
14 | #include "uplink.h" |
17 | #include "uplink.h" |
15 | #include "pmodule.h" |
18 | #include "pmodule.h" |
16 | #include "privs.h" |
19 | #include "privs.h" |
|
|
20 | |
|
|
21 | ConfTable::callbacks ConfTable::callback; |
17 | |
22 | |
18 | #define PARAM_ERROR(ce) \ |
23 | #define PARAM_ERROR(ce) \ |
19 | { \ |
24 | { \ |
20 | slog(LG_INFO, "%s:%i: no parameter for " \ |
25 | slog(LG_INFO, "%s:%i: no parameter for " \ |
21 | "configuration option: %s", \ |
26 | "configuration option: %s", \ |
22 | (ce)->ce_fileptr->cf_filename, \ |
27 | (ce)->ce_fileptr->cf_filename, \ |
23 | (ce)->ce_varlinenum, (ce)->ce_varname); \ |
28 | (ce)->ce_varlinenum, (ce)->ce_varname); \ |
24 | return 1; \ |
29 | return 1; \ |
25 | } |
30 | } |
26 | |
31 | |
27 | static int c_serverinfo (config_entry_t *); |
32 | static int c_serverinfo (config_entry_t *); |
28 | static int c_cservice (config_entry_t *); |
|
|
29 | static int c_gservice (config_entry_t *); |
|
|
30 | static int c_oservice (config_entry_t *); |
|
|
31 | static int c_general (config_entry_t *); |
33 | static int c_general (config_entry_t *); |
32 | static int c_database (config_entry_t *); |
34 | static int c_database (config_entry_t *); |
33 | static int c_uplink (config_entry_t *); |
35 | static int c_uplink (config_entry_t *); |
34 | static int c_nickserv (config_entry_t *); |
36 | static int c_chanserv (config_entry_t *); |
35 | static int c_saslserv (config_entry_t *); |
37 | static int c_globserv (config_entry_t *); |
|
|
38 | static int c_operserv (config_entry_t *); |
36 | static int c_memoserv (config_entry_t *); |
39 | static int c_memoserv (config_entry_t *); |
37 | static int c_gameserv (config_entry_t *); |
40 | static int c_gameserv (config_entry_t *); |
|
|
41 | static int c_nickserv (config_entry_t *); |
|
|
42 | static int c_saslserv (config_entry_t *); |
38 | static int c_loadmodule (config_entry_t *); |
43 | static int c_loadmodule (config_entry_t *); |
|
|
44 | static int c_backend (config_entry_t *); |
|
|
45 | static int c_crypto (config_entry_t *); |
|
|
46 | static int c_protocol (config_entry_t *); |
39 | static int c_operclass (config_entry_t *); |
47 | static int c_operclass (config_entry_t *); |
40 | static int c_operator (config_entry_t *); |
48 | static int c_operator (config_entry_t *); |
41 | static int c_logfile (config_entry_t *); |
49 | static int c_logfile (config_entry_t *); |
42 | |
50 | |
43 | static int c_si_name (config_entry_t *); |
51 | static int c_si_name (config_entry_t *); |
44 | static int c_si_desc (config_entry_t *); |
52 | static int c_si_desc (config_entry_t *); |
45 | static int c_si_numeric (config_entry_t *); |
53 | static int c_si_numeric (config_entry_t *); |
46 | static int c_si_vhost (config_entry_t *); |
54 | static int c_si_vhost (config_entry_t *); |
47 | static int c_si_recontime (config_entry_t *); |
55 | static int c_si_recontime (config_entry_t *); |
48 | static int c_si_restarttime (config_entry_t *); |
56 | static int c_si_restarttime (config_entry_t *); |
49 | static int c_si_netname (config_entry_t *); |
57 | static int c_si_netname (config_entry_t *); |
50 | static int c_si_hidehostsuffix (config_entry_t *); |
58 | static int c_si_hidehostsuffix (config_entry_t *); |
51 | static int c_si_adminname (config_entry_t *); |
59 | static int c_si_adminname (config_entry_t *); |
52 | static int c_si_adminemail (config_entry_t *); |
60 | static int c_si_adminemail (config_entry_t *); |
53 | static int c_si_mta (config_entry_t *); |
61 | static int c_si_mta (config_entry_t *); |
54 | static int c_si_loglevel (config_entry_t *); |
62 | static int c_si_loglevel (config_entry_t *); |
55 | static int c_si_maxlogins (config_entry_t *); |
63 | static int c_si_maxlogins (config_entry_t *); |
56 | static int c_si_maxusers (config_entry_t *); |
64 | static int c_si_maxusers (config_entry_t *); |
57 | static int c_si_maxnicks (config_entry_t *); |
65 | static int c_si_maxnicks (config_entry_t *); |
58 | static int c_si_maxchans (config_entry_t *); |
66 | static int c_si_maxchans (config_entry_t *); |
59 | static int c_si_emaillimit (config_entry_t *); |
67 | static int c_si_emaillimit (config_entry_t *); |
60 | static int c_si_emailtime (config_entry_t *); |
68 | static int c_si_emailtime (config_entry_t *); |
61 | static int c_si_auth (config_entry_t *); |
69 | static int c_si_auth (config_entry_t *); |
62 | static int c_si_mdlimit (config_entry_t *); |
70 | static int c_si_mdlimit (config_entry_t *); |
63 | static int c_si_casemapping (config_entry_t *); |
71 | static int c_si_casemapping (config_entry_t *); |
64 | |
72 | |
65 | /* CService client information. */ |
73 | /* ChanServ client information. */ |
66 | static int c_ci_nick (config_entry_t *); |
74 | static int c_ci_nick (config_entry_t *); |
67 | static int c_ci_user (config_entry_t *); |
75 | static int c_ci_user (config_entry_t *); |
68 | static int c_ci_host (config_entry_t *); |
76 | static int c_ci_host (config_entry_t *); |
69 | static int c_ci_real (config_entry_t *); |
77 | static int c_ci_real (config_entry_t *); |
70 | static int c_ci_fantasy (config_entry_t *); |
78 | static int c_ci_fantasy (config_entry_t *); |
71 | static int c_ci_vop (config_entry_t *); |
79 | static int c_ci_vop (config_entry_t *); |
72 | static int c_ci_hop (config_entry_t *); |
80 | static int c_ci_hop (config_entry_t *); |
73 | static int c_ci_aop (config_entry_t *); |
81 | static int c_ci_aop (config_entry_t *); |
74 | static int c_ci_sop (config_entry_t *); |
82 | static int c_ci_sop (config_entry_t *); |
75 | static int c_ci_changets (config_entry_t *); |
83 | static int c_ci_changets (config_entry_t *); |
76 | static int c_ci_trigger (config_entry_t *); |
84 | static int c_ci_trigger (config_entry_t *); |
77 | static int c_ci_expire (config_entry_t *); |
85 | static int c_ci_expire (config_entry_t *); |
78 | static int c_ci_maxchanacs (config_entry_t *); |
86 | static int c_ci_maxchanacs (config_entry_t *); |
|
|
87 | static int c_ci_maxfounders (config_entry_t *); |
79 | |
88 | |
80 | /* GService client information. */ |
89 | /* GlobServ client information. */ |
81 | static int c_gl_nick (config_entry_t *); |
90 | static int c_gl_nick (config_entry_t *); |
82 | static int c_gl_user (config_entry_t *); |
91 | static int c_gl_user (config_entry_t *); |
83 | static int c_gl_host (config_entry_t *); |
92 | static int c_gl_host (config_entry_t *); |
84 | static int c_gl_real (config_entry_t *); |
93 | static int c_gl_real (config_entry_t *); |
85 | |
94 | |
86 | /* OService client information. */ |
95 | /* OperServ client information. */ |
87 | static int c_oi_nick (config_entry_t *); |
96 | static int c_oi_nick (config_entry_t *); |
88 | static int c_oi_user (config_entry_t *); |
97 | static int c_oi_user (config_entry_t *); |
89 | static int c_oi_host (config_entry_t *); |
98 | static int c_oi_host (config_entry_t *); |
90 | static int c_oi_real (config_entry_t *); |
99 | static int c_oi_real (config_entry_t *); |
91 | |
100 | |
92 | /* NickServ client information. */ |
101 | /* NickServ client information. */ |
93 | static int c_ni_nick (config_entry_t *); |
102 | static int c_ni_nick (config_entry_t *); |
94 | static int c_ni_user (config_entry_t *); |
103 | static int c_ni_user (config_entry_t *); |
95 | static int c_ni_host (config_entry_t *); |
104 | static int c_ni_host (config_entry_t *); |
96 | static int c_ni_real (config_entry_t *); |
105 | static int c_ni_real (config_entry_t *); |
97 | static int c_ni_spam (config_entry_t *); |
106 | static int c_ni_spam (config_entry_t *); |
98 | static int c_ni_no_nick_ownership (config_entry_t *); |
107 | static int c_ni_no_nick_ownership (config_entry_t *); |
99 | static int c_ni_expire (config_entry_t *); |
108 | static int c_ni_expire (config_entry_t *); |
100 | |
109 | |
101 | /* SaslServ client information. */ |
110 | /* SaslServ client information. */ |
102 | static int c_ss_nick (config_entry_t *); |
111 | static int c_ss_nick (config_entry_t *); |
103 | static int c_ss_user (config_entry_t *); |
112 | static int c_ss_user (config_entry_t *); |
104 | static int c_ss_host (config_entry_t *); |
113 | static int c_ss_host (config_entry_t *); |
105 | static int c_ss_real (config_entry_t *); |
114 | static int c_ss_real (config_entry_t *); |
106 | |
115 | |
107 | /* MemoServ client information. */ |
116 | /* MemoServ client information. */ |
108 | static int c_ms_nick (config_entry_t *); |
117 | static int c_ms_nick (config_entry_t *); |
109 | static int c_ms_user (config_entry_t *); |
118 | static int c_ms_user (config_entry_t *); |
110 | static int c_ms_host (config_entry_t *); |
119 | static int c_ms_host (config_entry_t *); |
111 | static int c_ms_real (config_entry_t *); |
120 | static int c_ms_real (config_entry_t *); |
112 | |
121 | |
113 | /* GameServ client information. */ |
122 | /* GameServ client information. */ |
114 | static int c_gs_nick (config_entry_t *); |
123 | static int c_gs_nick (config_entry_t *); |
115 | static int c_gs_user (config_entry_t *); |
124 | static int c_gs_user (config_entry_t *); |
116 | static int c_gs_host (config_entry_t *); |
125 | static int c_gs_host (config_entry_t *); |
117 | static int c_gs_real (config_entry_t *); |
126 | static int c_gs_real (config_entry_t *); |
118 | |
127 | |
119 | /* Database information. */ |
128 | /* Database information. */ |
120 | static int c_db_user (config_entry_t *); |
129 | static int c_db_user (config_entry_t *); |
121 | static int c_db_host (config_entry_t *); |
130 | static int c_db_host (config_entry_t *); |
122 | static int c_db_password (config_entry_t *); |
131 | static int c_db_password (config_entry_t *); |
123 | static int c_db_database (config_entry_t *); |
132 | static int c_db_database (config_entry_t *); |
124 | static int c_db_port (config_entry_t *); |
133 | static int c_db_port (config_entry_t *); |
125 | |
134 | |
126 | static int c_gi_chan (config_entry_t *); |
135 | static int c_gi_chan (config_entry_t *); |
127 | static int c_gi_silent (config_entry_t *); |
136 | static int c_gi_silent (config_entry_t *); |
128 | static int c_gi_verbose_wallops (config_entry_t *); |
137 | static int c_gi_verbose_wallops (config_entry_t *); |
129 | static int c_gi_use_privmsg (config_entry_t *); |
138 | static int c_gi_use_privmsg (config_entry_t *); |
130 | static int c_gi_join_chans (config_entry_t *); |
139 | static int c_gi_join_chans (config_entry_t *); |
131 | static int c_gi_leave_chans (config_entry_t *); |
140 | static int c_gi_leave_chans (config_entry_t *); |
132 | static int c_gi_uflags (config_entry_t *); |
141 | static int c_gi_uflags (config_entry_t *); |
133 | static int c_gi_cflags (config_entry_t *); |
142 | static int c_gi_cflags (config_entry_t *); |
134 | static int c_gi_raw (config_entry_t *); |
143 | static int c_gi_raw (config_entry_t *); |
135 | static int c_gi_flood_msgs (config_entry_t *); |
144 | static int c_gi_flood_msgs (config_entry_t *); |
136 | static int c_gi_flood_time (config_entry_t *); |
145 | static int c_gi_flood_time (config_entry_t *); |
137 | static int c_gi_kline_time (config_entry_t *); |
146 | static int c_gi_kline_time (config_entry_t *); |
138 | static int c_gi_commit_interval (config_entry_t *); |
147 | static int c_gi_commit_interval (config_entry_t *); |
139 | static int c_gi_expire (config_entry_t *); |
148 | static int c_gi_expire (config_entry_t *); |
140 | static int c_gi_secure (config_entry_t *); |
149 | static int c_gi_secure (config_entry_t *); |
141 | |
150 | static int c_gi_default_clone_limit (config_entry_t *); |
142 | static BlockHeap *conftable_heap; |
|
|
143 | |
151 | |
144 | /* *INDENT-OFF* */ |
152 | /* *INDENT-OFF* */ |
145 | |
153 | |
146 | static Token uflags[] = { |
154 | static Token uflags[] = { |
147 | { "HOLD", MU_HOLD }, |
155 | { "HOLD", MU_HOLD }, |
… | |
… | |
157 | { "SECURE", MC_SECURE }, |
165 | { "SECURE", MC_SECURE }, |
158 | { "VERBOSE", MC_VERBOSE }, |
166 | { "VERBOSE", MC_VERBOSE }, |
159 | { "KEEPTOPIC", MC_KEEPTOPIC }, |
167 | { "KEEPTOPIC", MC_KEEPTOPIC }, |
160 | { "VERBOSE_OPS", MC_VERBOSE_OPS }, |
168 | { "VERBOSE_OPS", MC_VERBOSE_OPS }, |
161 | { "TOPICLOCK", MC_TOPICLOCK }, |
169 | { "TOPICLOCK", MC_TOPICLOCK }, |
162 | { "GUARD", MC_GUARD }, |
170 | { "GUARD", MC_GUARD }, |
163 | { "NONE", 0 }, |
171 | { "NONE", 0 }, |
164 | { NULL, 0 } |
172 | { NULL, 0 } |
165 | }; |
173 | }; |
166 | |
174 | |
167 | static Token logflags[] = { |
175 | static Token logflags[] = { |
168 | { "DEBUG", LG_ALL }, |
176 | { "DEBUG", LG_ALL }, |
169 | { "TRACE", LG_INFO | LG_ERROR | LG_CMD_ALL | LG_NETWORK | LG_WALLOPS | LG_REGISTER }, |
177 | { "TRACE", LG_INFO | LG_ERROR | LG_CMD_ALL | LG_NETWORK | LG_WALLOPS | LG_REGISTER }, |
170 | { "MISC", LG_INFO | LG_ERROR | LG_CMD_ADMIN | LG_CMD_REGISTER | LG_CMD_SET | LG_NETWORK | LG_WALLOPS | LG_REGISTER }, |
178 | { "MISC", LG_INFO | LG_ERROR | LG_CMD_ADMIN | LG_CMD_REGISTER | LG_CMD_SET | LG_NETWORK | LG_WALLOPS | LG_REGISTER }, |
171 | { "NOTICE", LG_INFO | LG_ERROR | LG_CMD_ADMIN | LG_CMD_REGISTER | LG_NETWORK | LG_REGISTER }, |
179 | { "NOTICE", LG_INFO | LG_ERROR | LG_CMD_ADMIN | LG_CMD_REGISTER | LG_NETWORK | LG_REGISTER }, |
172 | { "ALL", LG_ALL }, |
180 | { "ALL", LG_ALL }, |
173 | { "INFO", LG_INFO }, |
181 | { "INFO", LG_INFO }, |
174 | { "ERROR", LG_ERROR }, |
182 | { "ERROR", LG_ERROR }, |
175 | { "COMMANDS", LG_CMD_ALL }, |
183 | { "COMMANDS", LG_CMD_ALL }, |
176 | { "ADMIN", LG_CMD_ADMIN }, |
184 | { "ADMIN", LG_CMD_ADMIN }, |
177 | { "REGISTER", LG_CMD_REGISTER | LG_REGISTER }, |
185 | { "REGISTER", LG_CMD_REGISTER | LG_REGISTER }, |
178 | { "SET", LG_CMD_SET }, |
186 | { "SET", LG_CMD_SET }, |
179 | { "NETWORK", LG_NETWORK }, |
187 | { "NETWORK", LG_NETWORK }, |
180 | { "WALLOPS", LG_WALLOPS }, |
188 | { "WALLOPS", LG_WALLOPS }, |
181 | { "RAWDATA", LG_RAWDATA }, |
189 | { "RAWDATA", LG_RAWDATA }, |
182 | { NULL, 0 } |
190 | { NULL, 0 } |
183 | }; |
191 | }; |
184 | |
192 | |
185 | list_t confblocks; |
193 | static list_t confblocks; |
186 | list_t conf_si_table; |
194 | static list_t conf_si_table; |
187 | list_t conf_ci_table; |
195 | static list_t conf_ci_table; |
188 | list_t conf_gl_table; |
196 | static list_t conf_gl_table; |
189 | list_t conf_oi_table; |
197 | static list_t conf_oi_table; |
190 | list_t conf_ni_table; |
198 | static list_t conf_ni_table; |
191 | list_t conf_db_table; |
199 | static list_t conf_db_table; |
192 | list_t conf_gi_table; |
200 | static list_t conf_gi_table; |
193 | list_t conf_ms_table; |
201 | static list_t conf_ms_table; |
194 | list_t conf_la_table; |
202 | static list_t conf_la_table; |
195 | list_t conf_ss_table; |
203 | static list_t conf_ss_table; |
196 | list_t conf_gs_table; |
204 | static list_t conf_gs_table; |
197 | |
205 | |
198 | /* *INDENT-ON* */ |
206 | /* *INDENT-ON* */ |
199 | |
207 | |
200 | static void |
208 | static void |
201 | conf_report_error (config_entry_t *ce, const char *fmt, ...) |
209 | conf_report_error (config_entry_t *ce, char const * const fmt, ...) |
202 | { |
210 | { |
203 | va_list va; |
211 | va_list va; |
204 | char buf[BUFSIZE]; |
212 | char buf[BUFSIZE]; |
205 | |
213 | |
206 | return_if_fail (ce != NULL); |
214 | return_if_fail (ce != NULL); |
… | |
… | |
222 | ConfTable *ct = NULL; |
230 | ConfTable *ct = NULL; |
223 | |
231 | |
224 | for (cfptr = cfp; cfptr; cfptr = cfptr->cf_next) |
232 | for (cfptr = cfp; cfptr; cfptr = cfptr->cf_next) |
225 | { |
233 | { |
226 | for (ce = cfptr->cf_entries; ce; ce = ce->ce_next) |
234 | for (ce = cfptr->cf_entries; ce; ce = ce->ce_next) |
227 | { |
235 | { |
228 | LIST_FOREACH (tn, confblocks.head) |
236 | LIST_FOREACH (tn, confblocks.head) |
229 | { |
237 | { |
230 | ct = static_cast<ConfTable *> (tn->data); |
238 | ct = static_cast<ConfTable *> (tn->data); |
231 | |
239 | |
232 | if (!strcasecmp (ct->name, ce->ce_varname)) |
240 | if (!strcasecmp (ct->name, ce->ce_varname)) |
233 | { |
241 | { |
234 | ct->handler (ce); |
242 | ct->handler (ce); |
235 | break; |
243 | break; |
236 | } |
244 | } |
237 | } |
245 | } |
238 | |
246 | |
239 | if (ct == NULL) |
247 | if (ct == NULL) |
240 | conf_report_error (ce, "invalid configuration option: %s", ce->ce_varname); |
248 | conf_report_error (ce, "invalid configuration option: %s", ce->ce_varname); |
241 | } |
249 | } |
242 | } |
250 | } |
243 | } |
251 | } |
244 | |
252 | |
245 | bool |
253 | bool |
246 | conf_parse (char *file) |
254 | conf_parse (char *file) |
… | |
… | |
256 | } |
264 | } |
257 | |
265 | |
258 | conf_process (cfp); |
266 | conf_process (cfp); |
259 | config_free (cfp); |
267 | config_free (cfp); |
260 | |
268 | |
261 | if (!pmodule_loaded) |
269 | if (!protocol::handler::loaded) |
262 | { |
270 | { |
263 | slog (LG_ERROR, "No protocol module loaded, aborting"); |
271 | slog (LG_ERROR, "No protocol module loaded, aborting"); |
264 | exit (EXIT_FAILURE); |
272 | exit (EXIT_FAILURE); |
265 | } |
273 | } |
266 | |
274 | |
267 | hook_call_event ("config_ready", NULL); |
275 | ConfTable::callback.ready (); |
268 | return true; |
276 | return true; |
269 | } |
277 | } |
270 | |
278 | |
271 | void |
279 | void |
272 | conf_init (void) |
280 | conf_init (void) |
273 | { |
281 | { |
274 | if (me.netname) |
282 | me.init (); |
275 | free (me.netname); |
|
|
276 | if (me.hidehostsuffix) |
|
|
277 | free (me.hidehostsuffix); |
|
|
278 | if (me.adminname) |
|
|
279 | free (me.adminname); |
|
|
280 | if (me.adminemail) |
|
|
281 | free (me.adminemail); |
|
|
282 | if (me.mta) |
|
|
283 | free (me.mta); |
|
|
284 | if (chansvs.nick) |
283 | if (chansvs.nick) |
285 | free (chansvs.nick); |
284 | sfree (chansvs.nick); |
286 | if (config_options.chan) |
285 | if (config_options.chan) |
287 | free (config_options.chan); |
286 | sfree (config_options.chan); |
288 | if (config_options.global) |
287 | if (config_options.global) |
289 | free (config_options.global); |
288 | sfree (config_options.global); |
290 | if (config_options.languagefile) |
289 | if (config_options.languagefile) |
291 | free (config_options.languagefile); |
290 | sfree (config_options.languagefile); |
292 | |
291 | |
293 | me.netname = me.hidehostsuffix = me.adminname = me.adminemail = me.mta = chansvs.nick = config_options.chan = config_options.global = config_options.languagefile = NULL; |
292 | chansvs.nick = config_options.chan = config_options.global = config_options.languagefile = NULL; |
294 | |
293 | |
295 | me.recontime = me.restarttime = me.maxlogins = me.maxusers = me.maxnicks = me.maxchans = me.emaillimit = me.emailtime = config_options.flood_msgs = config_options.flood_time = config_options.kline_time = config_options.commit_interval = 0; |
294 | config_options.flood_msgs = config_options.flood_time = config_options.kline_time = config_options.commit_interval = 0; |
296 | |
295 | |
297 | nicksvs.expiry = chansvs.expiry = 0; |
296 | nicksvs.expiry = chansvs.expiry = 0; |
298 | |
297 | |
299 | config_options.defuflags = config_options.defcflags = 0x00000000; |
298 | config_options.defuflags = config_options.defcflags = 0x00000000; |
300 | |
299 | |
… | |
… | |
311 | chansvs.ca_hop = CA_HOP_DEF & ca_all; |
310 | chansvs.ca_hop = CA_HOP_DEF & ca_all; |
312 | chansvs.ca_aop = CA_AOP_DEF & ca_all; |
311 | chansvs.ca_aop = CA_AOP_DEF & ca_all; |
313 | chansvs.ca_sop = CA_SOP_DEF & ca_all; |
312 | chansvs.ca_sop = CA_SOP_DEF & ca_all; |
314 | chansvs.changets = false; |
313 | chansvs.changets = false; |
315 | if (chansvs.trigger != NULL) |
314 | if (chansvs.trigger != NULL) |
316 | free (chansvs.trigger); |
315 | sfree (chansvs.trigger); |
317 | chansvs.trigger = sstrdup ("!"); |
316 | chansvs.trigger = sstrdup ("!"); |
318 | chansvs.maxchanacs = 0; |
317 | chansvs.maxchanacs = 0; |
|
|
318 | chansvs.maxfounders = 4; |
319 | |
319 | |
320 | if (!(runflags & RF_REHASHING)) |
320 | if (!(runflags & RF_REHASHING)) |
321 | { |
321 | { |
322 | if (me.name) |
322 | if (me.name) |
323 | free (me.name); |
323 | sfree (me.name); |
324 | if (me.desc) |
324 | if (me.desc) |
325 | free (me.desc); |
325 | sfree (me.desc); |
326 | if (me.vhost) |
326 | if (me.vhost) |
327 | free (me.vhost); |
327 | sfree (me.vhost); |
328 | if (chansvs.user) |
328 | if (chansvs.user) |
329 | free (chansvs.user); |
329 | sfree (chansvs.user); |
330 | if (chansvs.host) |
330 | if (chansvs.host) |
331 | free (chansvs.host); |
331 | sfree (chansvs.host); |
332 | if (chansvs.real) |
332 | if (chansvs.real) |
333 | free (chansvs.real); |
333 | sfree (chansvs.real); |
334 | |
334 | |
335 | me.name = me.desc = me.vhost = chansvs.user = chansvs.host = chansvs.real = NULL; |
335 | me.name = me.desc = me.vhost = chansvs.user = chansvs.host = chansvs.real = NULL; |
336 | |
336 | |
337 | set_match_mapping (MATCH_RFC1459); /* default to RFC compliancy */ |
337 | set_match_mapping (MATCH_RFC1459); /* default to RFC compliancy */ |
338 | } |
338 | } |
339 | } |
339 | } |
340 | |
340 | |
341 | int |
341 | int |
342 | subblock_handler (config_entry_t *ce, list_t *entries) |
342 | subblock_handler (config_entry_t *ce, list_t *entries) |
… | |
… | |
346 | |
346 | |
347 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
347 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
348 | { |
348 | { |
349 | LIST_FOREACH (tn, entries->head) |
349 | LIST_FOREACH (tn, entries->head) |
350 | { |
350 | { |
351 | ct = static_cast<ConfTable *> (tn->data); |
351 | ct = static_cast<ConfTable *> (tn->data); |
352 | |
352 | |
353 | if (!strcasecmp (ct->name, ce->ce_varname)) |
353 | if (!strcasecmp (ct->name, ce->ce_varname)) |
354 | { |
354 | { |
355 | ct->handler (ce); |
355 | ct->handler (ce); |
356 | break; |
356 | break; |
357 | } |
357 | } |
358 | } |
358 | } |
359 | |
359 | |
360 | if (ct == NULL) |
360 | if (ct == NULL) |
361 | conf_report_error (ce, "invalid configuration option: %s", ce->ce_varname); |
361 | conf_report_error (ce, "invalid configuration option: %s", ce->ce_varname); |
362 | } |
362 | } |
363 | return 0; |
363 | return 0; |
364 | } |
364 | } |
365 | |
365 | |
366 | struct ConfTable * |
366 | struct ConfTable * |
367 | find_top_conf (char *name) |
367 | find_top_conf (char const * const name) |
368 | { |
368 | { |
369 | node_t *n; |
369 | node_t *n; |
370 | ConfTable *ct; |
370 | ConfTable *ct; |
371 | |
371 | |
372 | LIST_FOREACH (n, confblocks.head) |
372 | LIST_FOREACH (n, confblocks.head) |
… | |
… | |
379 | |
379 | |
380 | return NULL; |
380 | return NULL; |
381 | } |
381 | } |
382 | |
382 | |
383 | struct ConfTable * |
383 | struct ConfTable * |
384 | find_conf_item (char *name, list_t *conflist) |
384 | find_conf_item (char const * const name, list_t *conflist) |
385 | { |
385 | { |
386 | node_t *n; |
386 | node_t *n; |
387 | ConfTable *ct; |
387 | ConfTable *ct; |
388 | |
388 | |
389 | LIST_FOREACH (n, conflist->head) |
389 | LIST_FOREACH (n, conflist->head) |
… | |
… | |
396 | |
396 | |
397 | return NULL; |
397 | return NULL; |
398 | } |
398 | } |
399 | |
399 | |
400 | void |
400 | void |
401 | add_top_conf (char *name, int (*handler) (config_entry_t *ce)) |
401 | add_top_conf (char const * const name, int (*handler) (config_entry_t *ce)) |
402 | { |
402 | { |
403 | ConfTable *ct; |
403 | ConfTable *ct; |
404 | |
404 | |
405 | if ((ct = find_top_conf (name))) |
405 | if ((ct = find_top_conf (name))) |
406 | { |
406 | { |
407 | slog (LG_DEBUG, "add_top_conf(): duplicate config block '%s'.", name); |
407 | slog (LG_DEBUG, "add_top_conf(): duplicate config block '%s'.", name); |
408 | return; |
408 | return; |
409 | } |
409 | } |
410 | |
410 | |
411 | ct = static_cast<ConfTable *> (BlockHeapAlloc (conftable_heap)); |
411 | ct = new ConfTable (name, 1, handler); |
412 | |
|
|
413 | ct->name = sstrdup (name); |
|
|
414 | ct->rehashable = 1; |
|
|
415 | ct->handler = handler; |
|
|
416 | |
412 | |
417 | node_add (ct, node_create (), &confblocks); |
413 | node_add (ct, node_create (), &confblocks); |
418 | } |
414 | } |
419 | |
415 | |
420 | void |
416 | void |
421 | add_conf_item (char *name, list_t *conflist, int (*handler) (config_entry_t *ce)) |
417 | add_conf_item (char const * const name, list_t *conflist, int (*handler) (config_entry_t *ce)) |
422 | { |
418 | { |
423 | ConfTable *ct; |
419 | ConfTable *ct; |
424 | |
420 | |
425 | if ((ct = find_conf_item (name, conflist))) |
421 | if ((ct = find_conf_item (name, conflist))) |
426 | { |
422 | { |
427 | slog (LG_DEBUG, "add_conf_item(): duplicate item %s", name); |
423 | slog (LG_DEBUG, "add_conf_item(): duplicate item %s", name); |
428 | return; |
424 | return; |
429 | } |
425 | } |
430 | |
426 | |
431 | ct = static_cast<ConfTable *> (BlockHeapAlloc (conftable_heap)); |
427 | ct = new ConfTable (name, 1, handler); |
432 | |
|
|
433 | ct->name = sstrdup (name); |
|
|
434 | ct->rehashable = 1; |
|
|
435 | ct->handler = handler; |
|
|
436 | |
428 | |
437 | node_add (ct, node_create (), conflist); |
429 | node_add (ct, node_create (), conflist); |
438 | } |
430 | } |
439 | |
431 | |
440 | void |
432 | void |
441 | del_top_conf (char *name) |
433 | del_top_conf (char const * const name) |
442 | { |
434 | { |
443 | node_t *n; |
435 | node_t *n; |
444 | ConfTable *ct; |
436 | ConfTable *ct; |
445 | |
437 | |
446 | if (!(ct = find_top_conf (name))) |
438 | if (!(ct = find_top_conf (name))) |
… | |
… | |
450 | } |
442 | } |
451 | |
443 | |
452 | n = node_find (ct, &confblocks); |
444 | n = node_find (ct, &confblocks); |
453 | node_del (n, &confblocks); |
445 | node_del (n, &confblocks); |
454 | |
446 | |
455 | free (ct->name); |
447 | delete ct; |
456 | |
|
|
457 | BlockHeapFree (conftable_heap, ct); |
|
|
458 | } |
448 | } |
459 | |
449 | |
460 | void |
450 | void |
461 | del_conf_item (char *name, list_t *conflist) |
451 | del_conf_item (char const * const name, list_t *conflist) |
462 | { |
452 | { |
463 | node_t *n; |
453 | node_t *n; |
464 | ConfTable *ct; |
454 | ConfTable *ct; |
465 | |
455 | |
466 | if (!(ct = find_conf_item (name, conflist))) |
456 | if (!(ct = find_conf_item (name, conflist))) |
… | |
… | |
470 | } |
460 | } |
471 | |
461 | |
472 | n = node_find (ct, conflist); |
462 | n = node_find (ct, conflist); |
473 | node_del (n, conflist); |
463 | node_del (n, conflist); |
474 | |
464 | |
475 | free (ct->name); |
465 | delete ct; |
476 | |
|
|
477 | BlockHeapFree (conftable_heap, ct); |
|
|
478 | } |
466 | } |
479 | |
467 | |
480 | /* stolen from Sentinel */ |
468 | /* stolen from Sentinel */ |
481 | int |
469 | #define TOKEN_UNMATCHED -1 |
|
|
470 | #define TOKEN_ERROR -2 |
|
|
471 | |
|
|
472 | static int |
482 | token_to_value (struct Token token_table[], char *token) |
473 | token_to_value (struct Token token_table[], char *token) |
483 | { |
474 | { |
484 | int i; |
475 | int i; |
485 | |
476 | |
486 | if ((token_table != NULL) && (token != NULL)) |
477 | if ((token_table != NULL) && (token != NULL)) |
487 | { |
478 | { |
488 | for (i = 0; token_table[i].text != NULL; i++) |
479 | for (i = 0; token_table[i].text != NULL; i++) |
489 | { |
480 | { |
490 | if (strcasecmp (token_table[i].text, token) == 0) |
481 | if (strcasecmp (token_table[i].text, token) == 0) |
491 | { |
482 | { |
492 | return token_table[i].value; |
483 | return token_table[i].value; |
493 | } |
484 | } |
494 | } |
485 | } |
495 | /* If no match... */ |
486 | /* If no match... */ |
496 | return TOKEN_UNMATCHED; |
487 | return TOKEN_UNMATCHED; |
497 | } |
488 | } |
498 | |
489 | |
499 | /* Otherwise... */ |
490 | /* Otherwise... */ |
… | |
… | |
501 | } |
492 | } |
502 | |
493 | |
503 | void |
494 | void |
504 | init_newconf (void) |
495 | init_newconf (void) |
505 | { |
496 | { |
|
|
497 | #if 0 |
506 | conftable_heap = BlockHeapCreate (sizeof (struct ConfTable), 32); |
498 | conftable_heap = BlockHeapCreate (sizeof (struct ConfTable), 32); |
507 | |
499 | #endif |
508 | if (!conftable_heap) |
|
|
509 | { |
|
|
510 | slog (LG_ERROR, "init_newconf(): block allocator failure."); |
|
|
511 | exit (EXIT_FAILURE); |
|
|
512 | } |
|
|
513 | |
500 | |
514 | /* First we set up the blocks. */ |
501 | /* First we set up the blocks. */ |
515 | add_top_conf ("SERVERINFO", c_serverinfo); |
502 | add_top_conf ("SERVERINFO", c_serverinfo); |
516 | add_top_conf ("CHANSERV", c_cservice); |
503 | add_top_conf ("CHANSERV", c_chanserv); |
517 | add_top_conf ("CSERVICE", c_cservice); |
|
|
518 | add_top_conf ("GLOBAL", c_gservice); |
504 | add_top_conf ("GLOBAL", c_globserv); |
519 | add_top_conf ("GSERVICE", c_gservice); |
|
|
520 | add_top_conf ("OPERSERV", c_oservice); |
505 | add_top_conf ("OPERSERV", c_operserv); |
521 | add_top_conf ("OSERVICE", c_oservice); |
|
|
522 | add_top_conf ("NICKSERV", c_nickserv); |
506 | add_top_conf ("NICKSERV", c_nickserv); |
523 | add_top_conf ("SASLSERV", c_saslserv); |
507 | add_top_conf ("SASLSERV", c_saslserv); |
524 | add_top_conf ("MEMOSERV", c_memoserv); |
508 | add_top_conf ("MEMOSERV", c_memoserv); |
525 | add_top_conf ("GAMESERV", c_gameserv); |
509 | add_top_conf ("GAMESERV", c_gameserv); |
526 | add_top_conf ("UPLINK", c_uplink); |
510 | add_top_conf ("UPLINK", c_uplink); |
527 | add_top_conf ("GENERAL", c_general); |
511 | add_top_conf ("GENERAL", c_general); |
528 | add_top_conf ("DATABASE", c_database); |
512 | add_top_conf ("DATABASE", c_database); |
529 | add_top_conf ("LOADMODULE", c_loadmodule); |
513 | add_top_conf ("LOADMODULE", c_loadmodule); |
|
|
514 | add_top_conf ("BACKEND", c_backend); |
|
|
515 | add_top_conf ("CRYPTO", c_crypto); |
|
|
516 | add_top_conf ("PROTOCOL", c_protocol); |
530 | add_top_conf ("OPERCLASS", c_operclass); |
517 | add_top_conf ("OPERCLASS", c_operclass); |
531 | add_top_conf ("OPERATOR", c_operator); |
518 | add_top_conf ("OPERATOR", c_operator); |
532 | add_top_conf ("LOGFILE", c_logfile); |
519 | add_top_conf ("LOGFILE", c_logfile); |
533 | |
520 | |
534 | /* Now we fill in the information */ |
521 | /* Now we fill in the information */ |
… | |
… | |
569 | add_conf_item ("FLOOD_MSGS", &conf_gi_table, c_gi_flood_msgs); |
556 | add_conf_item ("FLOOD_MSGS", &conf_gi_table, c_gi_flood_msgs); |
570 | add_conf_item ("FLOOD_TIME", &conf_gi_table, c_gi_flood_time); |
557 | add_conf_item ("FLOOD_TIME", &conf_gi_table, c_gi_flood_time); |
571 | add_conf_item ("KLINE_TIME", &conf_gi_table, c_gi_kline_time); |
558 | add_conf_item ("KLINE_TIME", &conf_gi_table, c_gi_kline_time); |
572 | add_conf_item ("COMMIT_INTERVAL", &conf_gi_table, c_gi_commit_interval); |
559 | add_conf_item ("COMMIT_INTERVAL", &conf_gi_table, c_gi_commit_interval); |
573 | add_conf_item ("EXPIRE", &conf_gi_table, c_gi_expire); |
560 | add_conf_item ("EXPIRE", &conf_gi_table, c_gi_expire); |
|
|
561 | add_conf_item ("DEFAULT_CLONE_LIMIT", &conf_gi_table, c_gi_default_clone_limit); |
574 | |
562 | |
575 | /* chanserv{} block */ |
563 | /* chanserv{} block */ |
576 | add_conf_item ("NICK", &conf_ci_table, c_ci_nick); |
564 | add_conf_item ("NICK", &conf_ci_table, c_ci_nick); |
577 | add_conf_item ("USER", &conf_ci_table, c_ci_user); |
565 | add_conf_item ("USER", &conf_ci_table, c_ci_user); |
578 | add_conf_item ("HOST", &conf_ci_table, c_ci_host); |
566 | add_conf_item ("HOST", &conf_ci_table, c_ci_host); |
… | |
… | |
584 | add_conf_item ("SOP", &conf_ci_table, c_ci_sop); |
572 | add_conf_item ("SOP", &conf_ci_table, c_ci_sop); |
585 | add_conf_item ("CHANGETS", &conf_ci_table, c_ci_changets); |
573 | add_conf_item ("CHANGETS", &conf_ci_table, c_ci_changets); |
586 | add_conf_item ("TRIGGER", &conf_ci_table, c_ci_trigger); |
574 | add_conf_item ("TRIGGER", &conf_ci_table, c_ci_trigger); |
587 | add_conf_item ("EXPIRE", &conf_ci_table, c_ci_expire); |
575 | add_conf_item ("EXPIRE", &conf_ci_table, c_ci_expire); |
588 | add_conf_item ("MAXCHANACS", &conf_ci_table, c_ci_maxchanacs); |
576 | add_conf_item ("MAXCHANACS", &conf_ci_table, c_ci_maxchanacs); |
|
|
577 | add_conf_item ("MAXFOUNDERS", &conf_ci_table, c_ci_maxfounders); |
589 | |
578 | |
590 | /* global{} block */ |
579 | /* global{} block */ |
591 | add_conf_item ("NICK", &conf_gl_table, c_gl_nick); |
580 | add_conf_item ("NICK", &conf_gl_table, c_gl_nick); |
592 | add_conf_item ("USER", &conf_gl_table, c_gl_user); |
581 | add_conf_item ("USER", &conf_gl_table, c_gl_user); |
593 | add_conf_item ("HOST", &conf_gl_table, c_gl_host); |
582 | add_conf_item ("HOST", &conf_gl_table, c_gl_host); |
… | |
… | |
635 | } |
624 | } |
636 | |
625 | |
637 | static int |
626 | static int |
638 | c_serverinfo (config_entry_t *ce) |
627 | c_serverinfo (config_entry_t *ce) |
639 | { |
628 | { |
640 | subblock_handler (ce, &conf_si_table); |
629 | return subblock_handler (ce, &conf_si_table); |
641 | return 0; |
|
|
642 | } |
630 | } |
643 | |
631 | |
644 | static int |
632 | static int |
645 | c_cservice (config_entry_t *ce) |
633 | c_chanserv (config_entry_t *ce) |
646 | { |
634 | { |
647 | subblock_handler (ce, &conf_ci_table); |
635 | return subblock_handler (ce, &conf_ci_table); |
648 | return 0; |
|
|
649 | } |
636 | } |
650 | |
637 | |
651 | static int |
638 | static int |
652 | c_gservice (config_entry_t *ce) |
639 | c_globserv (config_entry_t *ce) |
653 | { |
640 | { |
654 | subblock_handler (ce, &conf_gl_table); |
641 | return subblock_handler (ce, &conf_gl_table); |
655 | return 0; |
|
|
656 | } |
642 | } |
657 | |
643 | |
658 | static int |
644 | static int |
659 | c_oservice (config_entry_t *ce) |
645 | c_operserv (config_entry_t *ce) |
660 | { |
646 | { |
661 | subblock_handler (ce, &conf_oi_table); |
647 | return subblock_handler (ce, &conf_oi_table); |
662 | return 0; |
|
|
663 | } |
648 | } |
664 | |
649 | |
665 | static int |
650 | static int |
666 | c_nickserv (config_entry_t *ce) |
651 | c_nickserv (config_entry_t *ce) |
667 | { |
652 | { |
668 | subblock_handler (ce, &conf_ni_table); |
653 | return subblock_handler (ce, &conf_ni_table); |
669 | return 0; |
|
|
670 | } |
654 | } |
671 | |
655 | |
672 | static int |
656 | static int |
673 | c_saslserv (config_entry_t *ce) |
657 | c_saslserv (config_entry_t *ce) |
674 | { |
658 | { |
675 | subblock_handler (ce, &conf_ss_table); |
659 | return subblock_handler (ce, &conf_ss_table); |
676 | return 0; |
|
|
677 | } |
660 | } |
678 | |
661 | |
679 | static int |
662 | static int |
680 | c_memoserv (config_entry_t *ce) |
663 | c_memoserv (config_entry_t *ce) |
681 | { |
664 | { |
682 | subblock_handler (ce, &conf_ms_table); |
665 | return subblock_handler (ce, &conf_ms_table); |
683 | return 0; |
|
|
684 | } |
666 | } |
685 | |
667 | |
686 | static int |
668 | static int |
687 | c_gameserv (config_entry_t *ce) |
669 | c_gameserv (config_entry_t *ce) |
688 | { |
670 | { |
689 | subblock_handler (ce, &conf_gs_table); |
671 | return subblock_handler (ce, &conf_gs_table); |
690 | return 0; |
|
|
691 | } |
672 | } |
692 | |
673 | |
693 | static int |
674 | static int |
694 | c_database (config_entry_t *ce) |
675 | c_database (config_entry_t *ce) |
695 | { |
676 | { |
696 | subblock_handler (ce, &conf_db_table); |
677 | return subblock_handler (ce, &conf_db_table); |
697 | return 0; |
|
|
698 | } |
678 | } |
699 | |
679 | |
700 | static int |
680 | static int |
701 | c_loadmodule (config_entry_t *ce) |
681 | c_protocol (config_entry_t *ce) |
702 | { |
682 | { |
703 | char pathbuf[4096]; |
|
|
704 | char *name; |
683 | char *name; |
705 | |
684 | |
706 | if (cold_start == false) |
685 | if (cold_start == false) |
707 | return 0; |
686 | return 0; |
708 | |
687 | |
709 | if (ce->ce_vardata == NULL) |
688 | if (ce->ce_vardata == NULL) |
710 | PARAM_ERROR (ce); |
689 | PARAM_ERROR (ce); |
711 | |
690 | |
712 | name = ce->ce_vardata; |
691 | name = ce->ce_vardata; |
713 | |
692 | |
714 | if (*name == '/') |
693 | typedef factory::factory_mgr<protocol::handler> protocol_factory; |
715 | { |
694 | protocol_factory &f = protocol_factory::instance (); |
716 | module_load (name); |
695 | |
|
|
696 | if (!f.provides (name)) |
|
|
697 | PARAM_ERROR (ce); |
|
|
698 | |
|
|
699 | phandler = f.create (name); |
|
|
700 | |
|
|
701 | return 0; |
|
|
702 | } |
|
|
703 | |
|
|
704 | static int |
|
|
705 | c_loadmodule (config_entry_t *ce) |
|
|
706 | { |
|
|
707 | char *name; |
|
|
708 | |
|
|
709 | if (cold_start == false) |
717 | return 0; |
710 | return 0; |
|
|
711 | |
|
|
712 | if (ce->ce_vardata == NULL) |
|
|
713 | PARAM_ERROR (ce); |
|
|
714 | |
|
|
715 | name = ce->ce_vardata; |
|
|
716 | |
|
|
717 | if (!modules::provides (name)) |
718 | } |
718 | { |
719 | else |
719 | dbg << "No such module\n"; |
|
|
720 | PARAM_ERROR (ce); |
720 | { |
721 | } |
721 | snprintf (pathbuf, 4096, "%s/%s", MODDIR, name); |
722 | |
722 | module_load (pathbuf); |
723 | modules::enable (name); |
|
|
724 | |
|
|
725 | return 0; |
|
|
726 | } |
|
|
727 | |
|
|
728 | static int |
|
|
729 | c_crypto (config_entry_t *ce) |
|
|
730 | { |
|
|
731 | char *name; |
|
|
732 | |
|
|
733 | if (cold_start == false) |
723 | return 0; |
734 | return 0; |
724 | } |
735 | |
|
|
736 | if (ce->ce_vardata == NULL) |
|
|
737 | PARAM_ERROR (ce); |
|
|
738 | |
|
|
739 | name = ce->ce_vardata; |
|
|
740 | |
|
|
741 | typedef factory::factory_mgr<crypto::handler> crypto_factory; |
|
|
742 | crypto_factory &f = crypto_factory::instance (); |
|
|
743 | |
|
|
744 | if (!f.provides (name)) |
|
|
745 | PARAM_ERROR (ce); |
|
|
746 | |
|
|
747 | crypter = f.create (name); |
|
|
748 | |
|
|
749 | return 0; |
|
|
750 | } |
|
|
751 | |
|
|
752 | static int |
|
|
753 | c_backend (config_entry_t *ce) |
|
|
754 | { |
|
|
755 | char *name; |
|
|
756 | |
|
|
757 | if (cold_start == false) |
|
|
758 | return 0; |
|
|
759 | |
|
|
760 | if (ce->ce_vardata == NULL) |
|
|
761 | PARAM_ERROR (ce); |
|
|
762 | |
|
|
763 | name = ce->ce_vardata; |
|
|
764 | |
|
|
765 | typedef factory::factory_mgr<database::handler> backend_factory; |
|
|
766 | backend_factory &f = backend_factory::instance (); |
|
|
767 | |
|
|
768 | if (!f.provides (name)) |
|
|
769 | PARAM_ERROR (ce); |
|
|
770 | |
|
|
771 | backend = f.create (name); |
|
|
772 | |
|
|
773 | return 0; |
725 | } |
774 | } |
726 | |
775 | |
727 | static int |
776 | static int |
728 | c_uplink (config_entry_t *ce) |
777 | c_uplink (config_entry_t *ce) |
729 | { |
778 | { |
… | |
… | |
744 | name = sstrdup (ce->ce_vardata); |
793 | name = sstrdup (ce->ce_vardata); |
745 | |
794 | |
746 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
795 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
747 | { |
796 | { |
748 | if (!strcasecmp ("HOST", ce->ce_varname)) |
797 | if (!strcasecmp ("HOST", ce->ce_varname)) |
749 | { |
798 | { |
750 | if (ce->ce_vardata == NULL) |
799 | if (ce->ce_vardata == NULL) |
751 | PARAM_ERROR (ce); |
800 | PARAM_ERROR (ce); |
752 | |
801 | |
753 | host = sstrdup (ce->ce_vardata); |
802 | host = sstrdup (ce->ce_vardata); |
754 | } |
803 | } |
755 | else if (!strcasecmp ("VHOST", ce->ce_varname)) |
804 | else if (!strcasecmp ("VHOST", ce->ce_varname)) |
756 | { |
805 | { |
757 | if (ce->ce_vardata == NULL) |
806 | if (ce->ce_vardata == NULL) |
758 | PARAM_ERROR (ce); |
807 | PARAM_ERROR (ce); |
759 | |
808 | |
760 | vhost = sstrdup (ce->ce_vardata); |
809 | vhost = sstrdup (ce->ce_vardata); |
761 | } |
810 | } |
762 | else if (!strcasecmp ("PASSWORD", ce->ce_varname)) |
811 | else if (!strcasecmp ("PASSWORD", ce->ce_varname)) |
763 | { |
812 | { |
764 | if (ce->ce_vardata == NULL) |
813 | if (ce->ce_vardata == NULL) |
765 | PARAM_ERROR (ce); |
814 | PARAM_ERROR (ce); |
766 | |
815 | |
767 | password = sstrdup (ce->ce_vardata); |
816 | password = sstrdup (ce->ce_vardata); |
768 | } |
817 | } |
769 | else if (!strcasecmp ("PORT", ce->ce_varname)) |
818 | else if (!strcasecmp ("PORT", ce->ce_varname)) |
770 | { |
819 | { |
771 | if (ce->ce_vardata == NULL) |
820 | if (ce->ce_vardata == NULL) |
772 | PARAM_ERROR (ce); |
821 | PARAM_ERROR (ce); |
773 | |
822 | |
774 | port = ce->ce_vardatanum; |
823 | port = ce->ce_vardatanum; |
775 | } |
824 | } |
776 | else |
825 | else |
777 | { |
826 | { |
778 | slog (LG_ERROR, "%s:%d: Invalid configuration option uplink::%s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_varname); |
827 | slog (LG_ERROR, "%s:%d: Invalid configuration option uplink::%s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_varname); |
779 | continue; |
828 | continue; |
780 | } |
829 | } |
781 | } |
830 | } |
782 | |
831 | |
783 | uplink_add (name, host, password, vhost, port); |
832 | uplink_add (name, host, password, vhost, port); |
784 | |
833 | |
785 | free (name); |
834 | sfree (name); |
786 | free (host); |
835 | sfree (host); |
787 | free (password); |
836 | sfree (password); |
788 | free (vhost); |
837 | sfree (vhost); |
789 | |
838 | |
790 | return 0; |
839 | return 0; |
791 | } |
840 | } |
792 | |
841 | |
793 | static int |
842 | static int |
… | |
… | |
804 | name = ce->ce_vardata; |
853 | name = ce->ce_vardata; |
805 | |
854 | |
806 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
855 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
807 | { |
856 | { |
808 | if (!strcasecmp ("PRIVS", ce->ce_varname)) |
857 | if (!strcasecmp ("PRIVS", ce->ce_varname)) |
809 | { |
858 | { |
810 | if (ce->ce_vardata == NULL && ce->ce_entries == NULL) |
859 | if (ce->ce_vardata == NULL && ce->ce_entries == NULL) |
811 | PARAM_ERROR (ce); |
860 | PARAM_ERROR (ce); |
812 | |
861 | |
813 | if (ce->ce_entries == NULL) |
862 | if (ce->ce_entries == NULL) |
814 | { |
863 | { |
815 | if (privs == NULL) |
864 | if (privs == NULL) |
816 | privs = sstrdup (ce->ce_vardata); |
865 | privs = sstrdup (ce->ce_vardata); |
817 | else |
866 | else |
818 | { |
867 | { |
819 | newprivs = static_cast<char *> (smalloc (strlen (privs) + 1 + strlen (ce->ce_vardata) + 1)); |
868 | newprivs = alloc<char> (strlen (privs) + 1 + strlen (ce->ce_vardata) + 1); |
820 | strcpy (newprivs, privs); |
869 | strcpy (newprivs, privs); |
821 | strcat (newprivs, " "); |
870 | strcat (newprivs, " "); |
822 | strcat (newprivs, ce->ce_vardata); |
871 | strcat (newprivs, ce->ce_vardata); |
823 | free (privs); |
872 | sfree (privs); |
824 | privs = newprivs; |
873 | privs = newprivs; |
825 | } |
874 | } |
826 | } |
875 | } |
827 | else |
876 | else |
828 | { |
877 | { |
829 | config_entry_t *conf_p; |
878 | config_entry_t *conf_p; |
830 | /* |
879 | /* |
831 | * New definition format for operclasses. |
880 | * New definition format for operclasses. |
832 | * |
881 | * |
833 | * operclass "sra" { |
882 | * operclass "sra" { |
834 | * privs = { |
883 | * privs = { |
835 | * special:ircop; |
884 | * special:ircop; |
836 | * }; |
885 | * }; |
837 | * }; |
886 | * }; |
838 | * |
887 | * |
839 | * - nenolod |
888 | * - nenolod |
840 | */ |
889 | */ |
841 | for (conf_p = ce->ce_entries; conf_p; conf_p = conf_p->ce_next) |
890 | for (conf_p = ce->ce_entries; conf_p; conf_p = conf_p->ce_next) |
842 | { |
891 | { |
843 | if (privs == NULL) |
892 | if (privs == NULL) |
844 | privs = sstrdup (conf_p->ce_varname); |
893 | privs = sstrdup (conf_p->ce_varname); |
845 | else |
894 | else |
846 | { |
895 | { |
847 | newprivs = static_cast<char *> (smalloc (strlen (privs) + 1 + strlen (conf_p->ce_varname) + 1)); |
896 | newprivs = alloc<char> (strlen (privs) + 1 + strlen (conf_p->ce_varname) + 1); |
848 | strcpy (newprivs, privs); |
897 | strcpy (newprivs, privs); |
849 | strcat (newprivs, " "); |
898 | strcat (newprivs, " "); |
850 | strcat (newprivs, conf_p->ce_varname); |
899 | strcat (newprivs, conf_p->ce_varname); |
851 | free (privs); |
900 | sfree (privs); |
852 | privs = newprivs; |
901 | privs = newprivs; |
853 | } |
902 | } |
854 | } |
903 | } |
855 | } |
904 | } |
856 | } |
905 | } |
857 | else if (!strcasecmp ("NEEDOPER", ce->ce_varname)) |
906 | else if (!strcasecmp ("NEEDOPER", ce->ce_varname)) |
858 | flags |= OPERCLASS_NEEDOPER; |
907 | flags |= OPERCLASS_NEEDOPER; |
859 | else |
908 | else |
860 | { |
909 | { |
861 | slog (LG_ERROR, "%s:%d: Invalid configuration option operclass::%s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_varname); |
910 | slog (LG_ERROR, "%s:%d: Invalid configuration option operclass::%s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_varname); |
862 | continue; |
911 | continue; |
863 | } |
912 | } |
864 | } |
913 | } |
865 | |
914 | |
866 | operclass = operclass_add (name, privs ? privs : ""); |
915 | operclass = operclass_add (name, privs ? privs : ""); |
867 | if (operclass != NULL) |
916 | if (operclass != NULL) |
868 | operclass->flags |= flags; |
917 | operclass->flags |= flags; |
869 | free (privs); |
918 | sfree (privs); |
870 | return 0; |
919 | return 0; |
871 | } |
920 | } |
872 | |
921 | |
873 | static int |
922 | static int |
874 | c_operator (config_entry_t *ce) |
923 | c_operator (config_entry_t *ce) |
… | |
… | |
884 | name = ce->ce_vardata; |
933 | name = ce->ce_vardata; |
885 | |
934 | |
886 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
935 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
887 | { |
936 | { |
888 | if (!strcasecmp ("OPERCLASS", ce->ce_varname)) |
937 | if (!strcasecmp ("OPERCLASS", ce->ce_varname)) |
889 | { |
938 | { |
890 | if (ce->ce_vardata == NULL) |
939 | if (ce->ce_vardata == NULL) |
891 | PARAM_ERROR (ce); |
940 | PARAM_ERROR (ce); |
892 | |
941 | |
893 | operclass = operclass_find (ce->ce_vardata); |
942 | operclass = operclass_find (ce->ce_vardata); |
894 | if (operclass == NULL) |
943 | if (operclass == NULL) |
895 | slog (LG_ERROR, "%s:%d: invalid operclass %s for operator %s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_vardata, name); |
944 | slog (LG_ERROR, "%s:%d: invalid operclass %s for operator %s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_vardata, name); |
896 | } |
945 | } |
897 | else |
946 | else |
898 | { |
947 | { |
899 | slog (LG_ERROR, "%s:%d: Invalid configuration option operator::%s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_varname); |
948 | slog (LG_ERROR, "%s:%d: Invalid configuration option operator::%s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_varname); |
900 | continue; |
949 | continue; |
901 | } |
950 | } |
902 | } |
951 | } |
903 | |
952 | |
904 | if (operclass != NULL) |
953 | if (operclass != NULL) |
905 | soper_add (name, operclass->name, SOPER_CONF); |
954 | soper_add (name, operclass->name, SOPER_CONF); |
906 | else |
955 | else |
… | |
… | |
909 | } |
958 | } |
910 | |
959 | |
911 | static int |
960 | static int |
912 | c_general (config_entry_t *ce) |
961 | c_general (config_entry_t *ce) |
913 | { |
962 | { |
914 | subblock_handler (ce, &conf_gi_table); |
963 | return subblock_handler (ce, &conf_gi_table); |
915 | return 0; |
|
|
916 | } |
964 | } |
917 | |
965 | |
918 | static int |
966 | static int |
919 | c_si_name (config_entry_t *ce) |
967 | c_si_name (config_entry_t *ce) |
920 | { |
968 | { |
… | |
… | |
932 | { |
980 | { |
933 | if (ce->ce_vardata == NULL) |
981 | if (ce->ce_vardata == NULL) |
934 | PARAM_ERROR (ce); |
982 | PARAM_ERROR (ce); |
935 | |
983 | |
936 | if (me.desc != NULL) |
984 | if (me.desc != NULL) |
937 | free (me.desc); |
985 | sfree (me.desc); |
938 | me.desc = sstrdup (ce->ce_vardata); |
986 | me.desc = sstrdup (ce->ce_vardata); |
939 | |
987 | |
940 | return 0; |
988 | return 0; |
941 | } |
989 | } |
942 | |
990 | |
… | |
… | |
1061 | if (ce->ce_vardata != NULL) |
1109 | if (ce->ce_vardata != NULL) |
1062 | { |
1110 | { |
1063 | val = token_to_value (logflags, ce->ce_vardata); |
1111 | val = token_to_value (logflags, ce->ce_vardata); |
1064 | |
1112 | |
1065 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1113 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1066 | mask |= val; |
1114 | mask |= val; |
1067 | else |
1115 | else |
1068 | { |
1116 | { |
1069 | slog (LG_INFO, "%s:%d: unknown flag: %s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_vardata); |
1117 | slog (LG_INFO, "%s:%d: unknown flag: %s", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_vardata); |
1070 | } |
1118 | } |
1071 | } |
1119 | } |
1072 | for (flce = ce->ce_entries; flce; flce = flce->ce_next) |
1120 | for (flce = ce->ce_entries; flce; flce = flce->ce_next) |
1073 | { |
1121 | { |
1074 | val = token_to_value (logflags, flce->ce_varname); |
1122 | val = token_to_value (logflags, flce->ce_varname); |
1075 | |
1123 | |
1076 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1124 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1077 | mask |= val; |
1125 | mask |= val; |
1078 | else |
1126 | else |
1079 | { |
1127 | { |
1080 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1128 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1081 | } |
1129 | } |
1082 | } |
1130 | } |
1083 | log_master_set_mask (mask); |
1131 | log_master_set_mask (mask); |
1084 | |
1132 | |
1085 | return 0; |
1133 | return 0; |
1086 | } |
1134 | } |
… | |
… | |
1188 | { |
1236 | { |
1189 | if (ce->ce_vardata == NULL) |
1237 | if (ce->ce_vardata == NULL) |
1190 | PARAM_ERROR (ce); |
1238 | PARAM_ERROR (ce); |
1191 | |
1239 | |
1192 | if (chansvs.nick != NULL) |
1240 | if (chansvs.nick != NULL) |
1193 | free (chansvs.nick); |
1241 | sfree (chansvs.nick); |
1194 | chansvs.nick = sstrdup (ce->ce_vardata); |
1242 | chansvs.nick = sstrdup (ce->ce_vardata); |
1195 | |
1243 | |
1196 | return 0; |
1244 | return 0; |
1197 | } |
1245 | } |
1198 | |
1246 | |
… | |
… | |
1201 | { |
1249 | { |
1202 | if (ce->ce_vardata == NULL) |
1250 | if (ce->ce_vardata == NULL) |
1203 | PARAM_ERROR (ce); |
1251 | PARAM_ERROR (ce); |
1204 | |
1252 | |
1205 | if (chansvs.user != NULL) |
1253 | if (chansvs.user != NULL) |
1206 | free (chansvs.user); |
1254 | sfree (chansvs.user); |
1207 | chansvs.user = sstrdup (ce->ce_vardata); |
1255 | chansvs.user = sstrdup (ce->ce_vardata); |
1208 | |
1256 | |
1209 | return 0; |
1257 | return 0; |
1210 | } |
1258 | } |
1211 | |
1259 | |
… | |
… | |
1214 | { |
1262 | { |
1215 | if (ce->ce_vardata == NULL) |
1263 | if (ce->ce_vardata == NULL) |
1216 | PARAM_ERROR (ce); |
1264 | PARAM_ERROR (ce); |
1217 | |
1265 | |
1218 | if (chansvs.host != NULL) |
1266 | if (chansvs.host != NULL) |
1219 | free (chansvs.host); |
1267 | sfree (chansvs.host); |
1220 | chansvs.host = sstrdup (ce->ce_vardata); |
1268 | chansvs.host = sstrdup (ce->ce_vardata); |
1221 | |
1269 | |
1222 | return 0; |
1270 | return 0; |
1223 | } |
1271 | } |
1224 | |
1272 | |
… | |
… | |
1227 | { |
1275 | { |
1228 | if (ce->ce_vardata == NULL) |
1276 | if (ce->ce_vardata == NULL) |
1229 | PARAM_ERROR (ce); |
1277 | PARAM_ERROR (ce); |
1230 | |
1278 | |
1231 | if (chansvs.real != NULL) |
1279 | if (chansvs.real != NULL) |
1232 | free (chansvs.real); |
1280 | sfree (chansvs.real); |
1233 | chansvs.real = sstrdup (ce->ce_vardata); |
1281 | chansvs.real = sstrdup (ce->ce_vardata); |
1234 | |
1282 | |
1235 | return 0; |
1283 | return 0; |
1236 | } |
1284 | } |
1237 | |
1285 | |
… | |
… | |
1302 | { |
1350 | { |
1303 | if (ce->ce_vardata == NULL) |
1351 | if (ce->ce_vardata == NULL) |
1304 | PARAM_ERROR (ce); |
1352 | PARAM_ERROR (ce); |
1305 | |
1353 | |
1306 | if (chansvs.trigger != NULL) |
1354 | if (chansvs.trigger != NULL) |
1307 | free (chansvs.trigger); |
1355 | sfree (chansvs.trigger); |
1308 | chansvs.trigger = sstrdup (ce->ce_vardata); |
1356 | chansvs.trigger = sstrdup (ce->ce_vardata); |
1309 | |
1357 | |
1310 | return 0; |
1358 | return 0; |
1311 | } |
1359 | } |
1312 | |
1360 | |
… | |
… | |
1331 | |
1379 | |
1332 | return 0; |
1380 | return 0; |
1333 | } |
1381 | } |
1334 | |
1382 | |
1335 | static int |
1383 | static int |
|
|
1384 | c_ci_maxfounders (config_entry_t *ce) |
|
|
1385 | { |
|
|
1386 | if (ce->ce_vardata == NULL) |
|
|
1387 | PARAM_ERROR (ce); |
|
|
1388 | |
|
|
1389 | chansvs.maxfounders = ce->ce_vardatanum; |
|
|
1390 | |
|
|
1391 | return 0; |
|
|
1392 | } |
|
|
1393 | |
|
|
1394 | static int |
1336 | c_gi_chan (config_entry_t *ce) |
1395 | c_gi_chan (config_entry_t *ce) |
1337 | { |
1396 | { |
1338 | if (ce->ce_vardata == NULL) |
1397 | if (ce->ce_vardata == NULL) |
1339 | PARAM_ERROR (ce); |
1398 | PARAM_ERROR (ce); |
1340 | |
1399 | |
… | |
… | |
1395 | int val; |
1454 | int val; |
1396 | |
1455 | |
1397 | val = token_to_value (uflags, flce->ce_varname); |
1456 | val = token_to_value (uflags, flce->ce_varname); |
1398 | |
1457 | |
1399 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1458 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1400 | config_options.defuflags |= val; |
1459 | config_options.defuflags |= val; |
1401 | |
1460 | |
1402 | else |
1461 | else |
1403 | { |
1462 | { |
1404 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1463 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1405 | } |
1464 | } |
1406 | } |
1465 | } |
1407 | |
1466 | |
1408 | return 0; |
1467 | return 0; |
1409 | } |
1468 | } |
1410 | |
1469 | |
… | |
… | |
1418 | int val; |
1477 | int val; |
1419 | |
1478 | |
1420 | val = token_to_value (cflags, flce->ce_varname); |
1479 | val = token_to_value (cflags, flce->ce_varname); |
1421 | |
1480 | |
1422 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1481 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1423 | config_options.defcflags |= val; |
1482 | config_options.defcflags |= val; |
1424 | |
1483 | |
1425 | else |
1484 | else |
1426 | { |
1485 | { |
1427 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1486 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1428 | } |
1487 | } |
1429 | } |
1488 | } |
1430 | |
1489 | |
1431 | if (config_options.defcflags & MC_TOPICLOCK) |
1490 | if (config_options.defcflags & MC_TOPICLOCK) |
1432 | config_options.defcflags |= MC_KEEPTOPIC; |
1491 | config_options.defcflags |= MC_KEEPTOPIC; |
1433 | |
1492 | |
… | |
… | |
1498 | |
1557 | |
1499 | return 0; |
1558 | return 0; |
1500 | } |
1559 | } |
1501 | |
1560 | |
1502 | static int |
1561 | static int |
|
|
1562 | c_gi_default_clone_limit (config_entry_t *ce) |
|
|
1563 | { |
|
|
1564 | if (ce->ce_vardata == NULL) |
|
|
1565 | PARAM_ERROR (ce); |
|
|
1566 | |
|
|
1567 | config_options.default_clone_limit = ce->ce_vardatanum; |
|
|
1568 | |
|
|
1569 | return 0; |
|
|
1570 | } |
|
|
1571 | |
|
|
1572 | static int |
1503 | c_oi_nick (config_entry_t *ce) |
1573 | c_oi_nick (config_entry_t *ce) |
1504 | { |
1574 | { |
1505 | if (ce->ce_vardata == NULL) |
1575 | if (ce->ce_vardata == NULL) |
1506 | PARAM_ERROR (ce); |
1576 | PARAM_ERROR (ce); |
1507 | |
1577 | |
1508 | if (opersvs.nick != NULL) |
1578 | if (opersvs.nick != NULL) |
1509 | free (opersvs.nick); |
1579 | sfree (opersvs.nick); |
1510 | opersvs.nick = sstrdup (ce->ce_vardata); |
1580 | opersvs.nick = sstrdup (ce->ce_vardata); |
1511 | |
1581 | |
1512 | return 0; |
1582 | return 0; |
1513 | } |
1583 | } |
1514 | |
1584 | |
… | |
… | |
1517 | { |
1587 | { |
1518 | if (ce->ce_vardata == NULL) |
1588 | if (ce->ce_vardata == NULL) |
1519 | PARAM_ERROR (ce); |
1589 | PARAM_ERROR (ce); |
1520 | |
1590 | |
1521 | if (opersvs.user != NULL) |
1591 | if (opersvs.user != NULL) |
1522 | free (opersvs.user); |
1592 | sfree (opersvs.user); |
1523 | opersvs.user = sstrdup (ce->ce_vardata); |
1593 | opersvs.user = sstrdup (ce->ce_vardata); |
1524 | |
1594 | |
1525 | return 0; |
1595 | return 0; |
1526 | } |
1596 | } |
1527 | |
1597 | |
… | |
… | |
1530 | { |
1600 | { |
1531 | if (ce->ce_vardata == NULL) |
1601 | if (ce->ce_vardata == NULL) |
1532 | PARAM_ERROR (ce); |
1602 | PARAM_ERROR (ce); |
1533 | |
1603 | |
1534 | if (opersvs.host != NULL) |
1604 | if (opersvs.host != NULL) |
1535 | free (opersvs.host); |
1605 | sfree (opersvs.host); |
1536 | opersvs.host = sstrdup (ce->ce_vardata); |
1606 | opersvs.host = sstrdup (ce->ce_vardata); |
1537 | |
1607 | |
1538 | return 0; |
1608 | return 0; |
1539 | } |
1609 | } |
1540 | |
1610 | |
… | |
… | |
1543 | { |
1613 | { |
1544 | if (ce->ce_vardata == NULL) |
1614 | if (ce->ce_vardata == NULL) |
1545 | PARAM_ERROR (ce); |
1615 | PARAM_ERROR (ce); |
1546 | |
1616 | |
1547 | if (opersvs.real != NULL) |
1617 | if (opersvs.real != NULL) |
1548 | free (opersvs.real); |
1618 | sfree (opersvs.real); |
1549 | opersvs.real = sstrdup (ce->ce_vardata); |
1619 | opersvs.real = sstrdup (ce->ce_vardata); |
1550 | |
1620 | |
1551 | return 0; |
1621 | return 0; |
1552 | } |
1622 | } |
1553 | |
1623 | |
… | |
… | |
1556 | { |
1626 | { |
1557 | if (ce->ce_vardata == NULL) |
1627 | if (ce->ce_vardata == NULL) |
1558 | PARAM_ERROR (ce); |
1628 | PARAM_ERROR (ce); |
1559 | |
1629 | |
1560 | if (nicksvs.nick != NULL) |
1630 | if (nicksvs.nick != NULL) |
1561 | free (nicksvs.nick); |
1631 | sfree (nicksvs.nick); |
1562 | nicksvs.nick = sstrdup (ce->ce_vardata); |
1632 | nicksvs.nick = sstrdup (ce->ce_vardata); |
1563 | |
1633 | |
1564 | return 0; |
1634 | return 0; |
1565 | } |
1635 | } |
1566 | |
1636 | |
… | |
… | |
1569 | { |
1639 | { |
1570 | if (ce->ce_vardata == NULL) |
1640 | if (ce->ce_vardata == NULL) |
1571 | PARAM_ERROR (ce); |
1641 | PARAM_ERROR (ce); |
1572 | |
1642 | |
1573 | if (nicksvs.user != NULL) |
1643 | if (nicksvs.user != NULL) |
1574 | free (nicksvs.user); |
1644 | sfree (nicksvs.user); |
1575 | nicksvs.user = sstrdup (ce->ce_vardata); |
1645 | nicksvs.user = sstrdup (ce->ce_vardata); |
1576 | |
1646 | |
1577 | return 0; |
1647 | return 0; |
1578 | } |
1648 | } |
1579 | |
1649 | |
… | |
… | |
1582 | { |
1652 | { |
1583 | if (ce->ce_vardata == NULL) |
1653 | if (ce->ce_vardata == NULL) |
1584 | PARAM_ERROR (ce); |
1654 | PARAM_ERROR (ce); |
1585 | |
1655 | |
1586 | if (nicksvs.host != NULL) |
1656 | if (nicksvs.host != NULL) |
1587 | free (nicksvs.host); |
1657 | sfree (nicksvs.host); |
1588 | nicksvs.host = sstrdup (ce->ce_vardata); |
1658 | nicksvs.host = sstrdup (ce->ce_vardata); |
1589 | |
1659 | |
1590 | return 0; |
1660 | return 0; |
1591 | } |
1661 | } |
1592 | |
1662 | |
… | |
… | |
1595 | { |
1665 | { |
1596 | if (ce->ce_vardata == NULL) |
1666 | if (ce->ce_vardata == NULL) |
1597 | PARAM_ERROR (ce); |
1667 | PARAM_ERROR (ce); |
1598 | |
1668 | |
1599 | if (nicksvs.real != NULL) |
1669 | if (nicksvs.real != NULL) |
1600 | free (nicksvs.real); |
1670 | sfree (nicksvs.real); |
1601 | nicksvs.real = sstrdup (ce->ce_vardata); |
1671 | nicksvs.real = sstrdup (ce->ce_vardata); |
1602 | |
1672 | |
1603 | return 0; |
1673 | return 0; |
1604 | } |
1674 | } |
1605 | |
1675 | |
… | |
… | |
1633 | { |
1703 | { |
1634 | if (ce->ce_vardata == NULL) |
1704 | if (ce->ce_vardata == NULL) |
1635 | PARAM_ERROR (ce); |
1705 | PARAM_ERROR (ce); |
1636 | |
1706 | |
1637 | if (saslsvs.nick != NULL) |
1707 | if (saslsvs.nick != NULL) |
1638 | free (saslsvs.nick); |
1708 | sfree (saslsvs.nick); |
1639 | saslsvs.nick = sstrdup (ce->ce_vardata); |
1709 | saslsvs.nick = sstrdup (ce->ce_vardata); |
1640 | |
1710 | |
1641 | return 0; |
1711 | return 0; |
1642 | } |
1712 | } |
1643 | |
1713 | |
… | |
… | |
1646 | { |
1716 | { |
1647 | if (ce->ce_vardata == NULL) |
1717 | if (ce->ce_vardata == NULL) |
1648 | PARAM_ERROR (ce); |
1718 | PARAM_ERROR (ce); |
1649 | |
1719 | |
1650 | if (saslsvs.user != NULL) |
1720 | if (saslsvs.user != NULL) |
1651 | free (saslsvs.user); |
1721 | sfree (saslsvs.user); |
1652 | saslsvs.user = sstrdup (ce->ce_vardata); |
1722 | saslsvs.user = sstrdup (ce->ce_vardata); |
1653 | |
1723 | |
1654 | return 0; |
1724 | return 0; |
1655 | } |
1725 | } |
1656 | |
1726 | |
… | |
… | |
1659 | { |
1729 | { |
1660 | if (ce->ce_vardata == NULL) |
1730 | if (ce->ce_vardata == NULL) |
1661 | PARAM_ERROR (ce); |
1731 | PARAM_ERROR (ce); |
1662 | |
1732 | |
1663 | if (saslsvs.host != NULL) |
1733 | if (saslsvs.host != NULL) |
1664 | free (saslsvs.host); |
1734 | sfree (saslsvs.host); |
1665 | saslsvs.host = sstrdup (ce->ce_vardata); |
1735 | saslsvs.host = sstrdup (ce->ce_vardata); |
1666 | |
1736 | |
1667 | return 0; |
1737 | return 0; |
1668 | } |
1738 | } |
1669 | |
1739 | |
… | |
… | |
1672 | { |
1742 | { |
1673 | if (ce->ce_vardata == NULL) |
1743 | if (ce->ce_vardata == NULL) |
1674 | PARAM_ERROR (ce); |
1744 | PARAM_ERROR (ce); |
1675 | |
1745 | |
1676 | if (saslsvs.real != NULL) |
1746 | if (saslsvs.real != NULL) |
1677 | free (saslsvs.real); |
1747 | sfree (saslsvs.real); |
1678 | saslsvs.real = sstrdup (ce->ce_vardata); |
1748 | saslsvs.real = sstrdup (ce->ce_vardata); |
1679 | |
1749 | |
1680 | return 0; |
1750 | return 0; |
1681 | } |
1751 | } |
1682 | |
1752 | |
… | |
… | |
1685 | { |
1755 | { |
1686 | if (ce->ce_vardata == NULL) |
1756 | if (ce->ce_vardata == NULL) |
1687 | PARAM_ERROR (ce); |
1757 | PARAM_ERROR (ce); |
1688 | |
1758 | |
1689 | if (memosvs.nick != NULL) |
1759 | if (memosvs.nick != NULL) |
1690 | free (memosvs.nick); |
1760 | sfree (memosvs.nick); |
1691 | memosvs.nick = sstrdup (ce->ce_vardata); |
1761 | memosvs.nick = sstrdup (ce->ce_vardata); |
1692 | |
1762 | |
1693 | return 0; |
1763 | return 0; |
1694 | } |
1764 | } |
1695 | |
1765 | |
… | |
… | |
1698 | { |
1768 | { |
1699 | if (ce->ce_vardata == NULL) |
1769 | if (ce->ce_vardata == NULL) |
1700 | PARAM_ERROR (ce); |
1770 | PARAM_ERROR (ce); |
1701 | |
1771 | |
1702 | if (memosvs.user != NULL) |
1772 | if (memosvs.user != NULL) |
1703 | free (memosvs.user); |
1773 | sfree (memosvs.user); |
1704 | memosvs.user = sstrdup (ce->ce_vardata); |
1774 | memosvs.user = sstrdup (ce->ce_vardata); |
1705 | |
1775 | |
1706 | return 0; |
1776 | return 0; |
1707 | } |
1777 | } |
1708 | |
1778 | |
… | |
… | |
1711 | { |
1781 | { |
1712 | if (ce->ce_vardata == NULL) |
1782 | if (ce->ce_vardata == NULL) |
1713 | PARAM_ERROR (ce); |
1783 | PARAM_ERROR (ce); |
1714 | |
1784 | |
1715 | if (memosvs.host != NULL) |
1785 | if (memosvs.host != NULL) |
1716 | free (memosvs.host); |
1786 | sfree (memosvs.host); |
1717 | memosvs.host = sstrdup (ce->ce_vardata); |
1787 | memosvs.host = sstrdup (ce->ce_vardata); |
1718 | |
1788 | |
1719 | return 0; |
1789 | return 0; |
1720 | } |
1790 | } |
1721 | |
1791 | |
… | |
… | |
1724 | { |
1794 | { |
1725 | if (ce->ce_vardata == NULL) |
1795 | if (ce->ce_vardata == NULL) |
1726 | PARAM_ERROR (ce); |
1796 | PARAM_ERROR (ce); |
1727 | |
1797 | |
1728 | if (memosvs.real != NULL) |
1798 | if (memosvs.real != NULL) |
1729 | free (memosvs.real); |
1799 | sfree (memosvs.real); |
1730 | memosvs.real = sstrdup (ce->ce_vardata); |
1800 | memosvs.real = sstrdup (ce->ce_vardata); |
1731 | |
1801 | |
1732 | return 0; |
1802 | return 0; |
1733 | } |
1803 | } |
1734 | |
1804 | |
… | |
… | |
1737 | { |
1807 | { |
1738 | if (ce->ce_vardata == NULL) |
1808 | if (ce->ce_vardata == NULL) |
1739 | PARAM_ERROR (ce); |
1809 | PARAM_ERROR (ce); |
1740 | |
1810 | |
1741 | if (gamesvs.nick != NULL) |
1811 | if (gamesvs.nick != NULL) |
1742 | free (gamesvs.nick); |
1812 | sfree (gamesvs.nick); |
1743 | gamesvs.nick = sstrdup (ce->ce_vardata); |
1813 | gamesvs.nick = sstrdup (ce->ce_vardata); |
1744 | |
1814 | |
1745 | return 0; |
1815 | return 0; |
1746 | } |
1816 | } |
1747 | |
1817 | |
… | |
… | |
1750 | { |
1820 | { |
1751 | if (ce->ce_vardata == NULL) |
1821 | if (ce->ce_vardata == NULL) |
1752 | PARAM_ERROR (ce); |
1822 | PARAM_ERROR (ce); |
1753 | |
1823 | |
1754 | if (gamesvs.user != NULL) |
1824 | if (gamesvs.user != NULL) |
1755 | free (gamesvs.user); |
1825 | sfree (gamesvs.user); |
1756 | gamesvs.user = sstrdup (ce->ce_vardata); |
1826 | gamesvs.user = sstrdup (ce->ce_vardata); |
1757 | |
1827 | |
1758 | return 0; |
1828 | return 0; |
1759 | } |
1829 | } |
1760 | |
1830 | |
… | |
… | |
1763 | { |
1833 | { |
1764 | if (ce->ce_vardata == NULL) |
1834 | if (ce->ce_vardata == NULL) |
1765 | PARAM_ERROR (ce); |
1835 | PARAM_ERROR (ce); |
1766 | |
1836 | |
1767 | if (gamesvs.host != NULL) |
1837 | if (gamesvs.host != NULL) |
1768 | free (gamesvs.host); |
1838 | sfree (gamesvs.host); |
1769 | gamesvs.host = sstrdup (ce->ce_vardata); |
1839 | gamesvs.host = sstrdup (ce->ce_vardata); |
1770 | |
1840 | |
1771 | return 0; |
1841 | return 0; |
1772 | } |
1842 | } |
1773 | |
1843 | |
… | |
… | |
1776 | { |
1846 | { |
1777 | if (ce->ce_vardata == NULL) |
1847 | if (ce->ce_vardata == NULL) |
1778 | PARAM_ERROR (ce); |
1848 | PARAM_ERROR (ce); |
1779 | |
1849 | |
1780 | if (gamesvs.real != NULL) |
1850 | if (gamesvs.real != NULL) |
1781 | free (gamesvs.real); |
1851 | sfree (gamesvs.real); |
1782 | gamesvs.real = sstrdup (ce->ce_vardata); |
1852 | gamesvs.real = sstrdup (ce->ce_vardata); |
1783 | |
1853 | |
1784 | return 0; |
1854 | return 0; |
1785 | } |
1855 | } |
1786 | |
1856 | |
… | |
… | |
1789 | { |
1859 | { |
1790 | if (ce->ce_vardata == NULL) |
1860 | if (ce->ce_vardata == NULL) |
1791 | PARAM_ERROR (ce); |
1861 | PARAM_ERROR (ce); |
1792 | |
1862 | |
1793 | if (globsvs.nick != NULL) |
1863 | if (globsvs.nick != NULL) |
1794 | free (globsvs.nick); |
1864 | sfree (globsvs.nick); |
1795 | globsvs.nick = sstrdup (ce->ce_vardata); |
1865 | globsvs.nick = sstrdup (ce->ce_vardata); |
1796 | |
1866 | |
1797 | return 0; |
1867 | return 0; |
1798 | } |
1868 | } |
1799 | |
1869 | |
… | |
… | |
1802 | { |
1872 | { |
1803 | if (ce->ce_vardata == NULL) |
1873 | if (ce->ce_vardata == NULL) |
1804 | PARAM_ERROR (ce); |
1874 | PARAM_ERROR (ce); |
1805 | |
1875 | |
1806 | if (globsvs.user != NULL) |
1876 | if (globsvs.user != NULL) |
1807 | free (globsvs.user); |
1877 | sfree (globsvs.user); |
1808 | globsvs.user = sstrdup (ce->ce_vardata); |
1878 | globsvs.user = sstrdup (ce->ce_vardata); |
1809 | |
1879 | |
1810 | return 0; |
1880 | return 0; |
1811 | } |
1881 | } |
1812 | |
1882 | |
… | |
… | |
1815 | { |
1885 | { |
1816 | if (ce->ce_vardata == NULL) |
1886 | if (ce->ce_vardata == NULL) |
1817 | PARAM_ERROR (ce); |
1887 | PARAM_ERROR (ce); |
1818 | |
1888 | |
1819 | if (globsvs.host != NULL) |
1889 | if (globsvs.host != NULL) |
1820 | free (globsvs.host); |
1890 | sfree (globsvs.host); |
1821 | globsvs.host = sstrdup (ce->ce_vardata); |
1891 | globsvs.host = sstrdup (ce->ce_vardata); |
1822 | |
1892 | |
1823 | return 0; |
1893 | return 0; |
1824 | } |
1894 | } |
1825 | |
1895 | |
… | |
… | |
1828 | { |
1898 | { |
1829 | if (ce->ce_vardata == NULL) |
1899 | if (ce->ce_vardata == NULL) |
1830 | PARAM_ERROR (ce); |
1900 | PARAM_ERROR (ce); |
1831 | |
1901 | |
1832 | if (globsvs.real != NULL) |
1902 | if (globsvs.real != NULL) |
1833 | free (globsvs.real); |
1903 | sfree (globsvs.real); |
1834 | globsvs.real = sstrdup (ce->ce_vardata); |
1904 | globsvs.real = sstrdup (ce->ce_vardata); |
1835 | |
1905 | |
1836 | return 0; |
1906 | return 0; |
1837 | } |
1907 | } |
1838 | |
1908 | |
… | |
… | |
1841 | { |
1911 | { |
1842 | if (ce->ce_vardata == NULL) |
1912 | if (ce->ce_vardata == NULL) |
1843 | PARAM_ERROR (ce); |
1913 | PARAM_ERROR (ce); |
1844 | |
1914 | |
1845 | if (database_options.user != NULL) |
1915 | if (database_options.user != NULL) |
1846 | free (database_options.user); |
1916 | sfree (database_options.user); |
1847 | database_options.user = sstrdup (ce->ce_vardata); |
1917 | database_options.user = sstrdup (ce->ce_vardata); |
1848 | |
1918 | |
1849 | return 0; |
1919 | return 0; |
1850 | } |
1920 | } |
1851 | |
1921 | |
… | |
… | |
1854 | { |
1924 | { |
1855 | if (ce->ce_vardata == NULL) |
1925 | if (ce->ce_vardata == NULL) |
1856 | PARAM_ERROR (ce); |
1926 | PARAM_ERROR (ce); |
1857 | |
1927 | |
1858 | if (database_options.host != NULL) |
1928 | if (database_options.host != NULL) |
1859 | free (database_options.host); |
1929 | sfree (database_options.host); |
1860 | database_options.host = sstrdup (ce->ce_vardata); |
1930 | database_options.host = sstrdup (ce->ce_vardata); |
1861 | |
1931 | |
1862 | return 0; |
1932 | return 0; |
1863 | } |
1933 | } |
1864 | |
1934 | |
… | |
… | |
1867 | { |
1937 | { |
1868 | if (ce->ce_vardata == NULL) |
1938 | if (ce->ce_vardata == NULL) |
1869 | PARAM_ERROR (ce); |
1939 | PARAM_ERROR (ce); |
1870 | |
1940 | |
1871 | if (database_options.pass != NULL) |
1941 | if (database_options.pass != NULL) |
1872 | free (database_options.pass); |
1942 | sfree (database_options.pass); |
1873 | database_options.pass = sstrdup (ce->ce_vardata); |
1943 | database_options.pass = sstrdup (ce->ce_vardata); |
1874 | |
1944 | |
1875 | return 0; |
1945 | return 0; |
1876 | } |
1946 | } |
1877 | |
1947 | |
… | |
… | |
1880 | { |
1950 | { |
1881 | if (ce->ce_vardata == NULL) |
1951 | if (ce->ce_vardata == NULL) |
1882 | PARAM_ERROR (ce); |
1952 | PARAM_ERROR (ce); |
1883 | |
1953 | |
1884 | if (database_options.database != NULL) |
1954 | if (database_options.database != NULL) |
1885 | free (database_options.database); |
1955 | sfree (database_options.database); |
1886 | database_options.database = sstrdup (ce->ce_vardata); |
1956 | database_options.database = sstrdup (ce->ce_vardata); |
1887 | |
1957 | |
1888 | return 0; |
1958 | return 0; |
1889 | } |
1959 | } |
1890 | |
1960 | |
… | |
… | |
1913 | int val; |
1983 | int val; |
1914 | |
1984 | |
1915 | val = token_to_value (logflags, flce->ce_varname); |
1985 | val = token_to_value (logflags, flce->ce_varname); |
1916 | |
1986 | |
1917 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1987 | if ((val != TOKEN_UNMATCHED) && (val != TOKEN_ERROR)) |
1918 | logval |= val; |
1988 | logval |= val; |
1919 | else |
1989 | else |
1920 | { |
1990 | { |
1921 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1991 | slog (LG_INFO, "%s:%d: unknown flag: %s", flce->ce_fileptr->cf_filename, flce->ce_varlinenum, flce->ce_varname); |
1922 | } |
1992 | } |
1923 | } |
1993 | } |
1924 | |
1994 | |
1925 | logfile_new (ce->ce_vardata, logval); |
1995 | logfile_new (ce->ce_vardata, logval); |
1926 | |
1996 | |
1927 | return 0; |
1997 | return 0; |
… | |
… | |
1958 | |
2028 | |
1959 | /* now reload */ |
2029 | /* now reload */ |
1960 | log_open (); |
2030 | log_open (); |
1961 | conf_process (cfp); |
2031 | conf_process (cfp); |
1962 | config_free (cfp); |
2032 | config_free (cfp); |
1963 | hook_call_event ("config_ready", NULL); |
2033 | ConfTable::callback.ready (); |
1964 | |
2034 | |
1965 | /* now recheck */ |
2035 | /* now recheck */ |
1966 | if (!conf_check ()) |
2036 | if (!conf_check ()) |
1967 | { |
2037 | { |
1968 | slog (LG_ERROR, "conf_rehash(): conf file was malformed, aborting rehash"); |
2038 | slog (LG_ERROR, "conf_rehash(): conf file was malformed, aborting rehash"); |
1969 | |
2039 | |
1970 | /* freeing the new conf strings */ |
2040 | /* freeing the new conf strings */ |
1971 | free (chansvs.nick); |
2041 | sfree (chansvs.nick); |
1972 | me.destroy (); |
2042 | me.fini (); |
1973 | |
2043 | |
1974 | /* return everything to the way it was before */ |
2044 | /* return everything to the way it was before */ |
1975 | me = hold_me; |
2045 | me = hold_me; |
1976 | |
2046 | |
1977 | /* not fully ok, oh well */ |
2047 | /* not fully ok, oh well */ |
1978 | unmark_all_illegal (); |
2048 | unmark_all_illegal (); |
1979 | |
2049 | |
1980 | free (oldsnoop); |
2050 | sfree (oldsnoop); |
1981 | |
2051 | |
1982 | runflags &= ~RF_REHASHING; |
2052 | runflags &= ~RF_REHASHING; |
1983 | return false; |
2053 | return false; |
1984 | } |
2054 | } |
1985 | |
2055 | |
1986 | if (oldsnoop != NULL || config_options.chan != NULL) |
2056 | if (oldsnoop != NULL || config_options.chan != NULL) |
1987 | { |
2057 | { |
1988 | if (config_options.chan == NULL) |
2058 | if (config_options.chan == NULL) |
1989 | partall (oldsnoop); |
2059 | partall (oldsnoop); |
1990 | else if (oldsnoop == NULL) |
2060 | else if (oldsnoop == NULL) |
1991 | joinall (config_options.chan); |
2061 | joinall (config_options.chan); |
1992 | else if (strcmp (oldsnoop, config_options.chan)) |
2062 | else if (strcmp (oldsnoop, config_options.chan)) |
1993 | { |
2063 | { |
1994 | partall (oldsnoop); |
2064 | partall (oldsnoop); |
1995 | joinall (config_options.chan); |
2065 | joinall (config_options.chan); |
1996 | } |
2066 | } |
1997 | } |
2067 | } |
1998 | |
2068 | |
1999 | remove_illegals (); |
2069 | remove_illegals (); |
2000 | |
2070 | |
2001 | free (oldsnoop); |
2071 | sfree (oldsnoop); |
2002 | |
2072 | |
2003 | runflags &= ~RF_REHASHING; |
2073 | runflags &= ~RF_REHASHING; |
2004 | return true; |
2074 | return true; |
2005 | } |
2075 | } |
2006 | |
2076 | |
… | |
… | |
2069 | } |
2139 | } |
2070 | |
2140 | |
2071 | if (!me.maxnicks) |
2141 | if (!me.maxnicks) |
2072 | { |
2142 | { |
2073 | if (!nicksvs.no_nick_ownership) |
2143 | if (!nicksvs.no_nick_ownership) |
2074 | slog (LG_INFO, "conf_check(): no `maxnicks' set in %s; " "defaulting to 5", config_file); |
2144 | slog (LG_INFO, "conf_check(): no `maxnicks' set in %s; " "defaulting to 5", config_file); |
2075 | me.maxnicks = 5; |
2145 | me.maxnicks = 5; |
2076 | } |
2146 | } |
2077 | |
2147 | |
2078 | if (!me.maxchans) |
2148 | if (!me.maxchans) |
2079 | { |
2149 | { |
… | |
… | |
2126 | chansvs.ca_sop = CA_SOP_DEF & ca_all; |
2196 | chansvs.ca_sop = CA_SOP_DEF & ca_all; |
2127 | } |
2197 | } |
2128 | |
2198 | |
2129 | if (config_options.flood_msgs && !config_options.flood_time) |
2199 | if (config_options.flood_msgs && !config_options.flood_time) |
2130 | config_options.flood_time = 10; |
2200 | config_options.flood_time = 10; |
2131 | |
2201 | |
|
|
2202 | if (!config_options.default_clone_limit) |
|
|
2203 | config_options.default_clone_limit = 6; |
|
|
2204 | |
2132 | /* recall that commit_interval is in seconds */ |
2205 | /* recall that commit_interval is in seconds */ |
2133 | if ((!config_options.commit_interval) || (config_options.commit_interval < 60) || (config_options.commit_interval > 3600)) |
2206 | if ((!config_options.commit_interval) || (config_options.commit_interval < 60) || (config_options.commit_interval > 3600)) |
2134 | { |
2207 | { |
2135 | slog (LG_INFO, "conf_check(): invalid `commit_interval' set in %s; " "defaulting to 5 minutes", config_file); |
2208 | slog (LG_INFO, "conf_check(): invalid `commit_interval' set in %s; " "defaulting to 5 minutes", config_file); |
2136 | config_options.commit_interval = 300; |
2209 | config_options.commit_interval = 300; |