]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* This code is in the public domain. |
cda8e9b8 | 2 | * $Id: newconf.c 3550 2007-08-09 06:47:26Z nenolod $ |
212380e3 AC |
3 | */ |
4 | ||
5 | #include "stdinc.h" | |
6 | ||
7 | #ifdef HAVE_LIBCRYPTO | |
8 | #include <openssl/pem.h> | |
9 | #include <openssl/rsa.h> | |
10 | #endif | |
11 | ||
212380e3 | 12 | #include "newconf.h" |
212380e3 | 13 | #include "ircd_defs.h" |
212380e3 | 14 | #include "common.h" |
4016731b | 15 | #include "logger.h" |
212380e3 AC |
16 | #include "s_conf.h" |
17 | #include "s_user.h" | |
18 | #include "s_newconf.h" | |
19 | #include "send.h" | |
20 | #include "setup.h" | |
21 | #include "modules.h" | |
22 | #include "listener.h" | |
23 | #include "hostmask.h" | |
24 | #include "s_serv.h" | |
212380e3 AC |
25 | #include "hash.h" |
26 | #include "cache.h" | |
27 | #include "ircd.h" | |
28 | #include "snomask.h" | |
29 | #include "blacklist.h" | |
c6d72037 | 30 | #include "sslproc.h" |
f8606875 | 31 | #include "privilege.h" |
212380e3 AC |
32 | |
33 | #define CF_TYPE(x) ((x) & CF_MTYPE) | |
34 | ||
35 | struct TopConf *conf_cur_block; | |
36 | static char *conf_cur_block_name; | |
37 | ||
330fc5c1 | 38 | static rb_dlink_list conf_items; |
212380e3 AC |
39 | |
40 | static struct ConfItem *yy_aconf = NULL; | |
41 | ||
42 | static struct Class *yy_class = NULL; | |
43 | ||
44 | static struct remote_conf *yy_shared = NULL; | |
45 | static struct server_conf *yy_server = NULL; | |
46 | ||
330fc5c1 AC |
47 | static rb_dlink_list yy_aconf_list; |
48 | static rb_dlink_list yy_oper_list; | |
49 | static rb_dlink_list yy_shared_list; | |
50 | static rb_dlink_list yy_cluster_list; | |
212380e3 AC |
51 | static struct oper_conf *yy_oper = NULL; |
52 | ||
53 | static struct alias_entry *yy_alias = NULL; | |
54 | ||
55 | static char *yy_blacklist_host = NULL; | |
56 | static char *yy_blacklist_reason = NULL; | |
0a1e77c2 EM |
57 | static int yy_blacklist_ipv4 = 1; |
58 | static int yy_blacklist_ipv6 = 0; | |
59 | ||
f8606875 | 60 | static char *yy_privset_extends = NULL; |
212380e3 AC |
61 | |
62 | static const char * | |
63 | conf_strtype(int type) | |
64 | { | |
65 | switch (type & CF_MTYPE) | |
66 | { | |
67 | case CF_INT: | |
68 | return "integer value"; | |
69 | case CF_STRING: | |
70 | return "unquoted string"; | |
71 | case CF_YESNO: | |
72 | return "yes/no value"; | |
73 | case CF_QSTRING: | |
74 | return "quoted string"; | |
75 | case CF_TIME: | |
76 | return "time/size value"; | |
77 | default: | |
78 | return "unknown type"; | |
79 | } | |
80 | } | |
81 | ||
82 | int | |
83 | add_top_conf(const char *name, int (*sfunc) (struct TopConf *), | |
84 | int (*efunc) (struct TopConf *), struct ConfEntry *items) | |
85 | { | |
86 | struct TopConf *tc; | |
87 | ||
eddc2ab6 | 88 | tc = rb_malloc(sizeof(struct TopConf)); |
212380e3 | 89 | |
d7f753cd | 90 | tc->tc_name = name; |
212380e3 AC |
91 | tc->tc_sfunc = sfunc; |
92 | tc->tc_efunc = efunc; | |
93 | tc->tc_entries = items; | |
94 | ||
330fc5c1 | 95 | rb_dlinkAddAlloc(tc, &conf_items); |
212380e3 AC |
96 | return 0; |
97 | } | |
98 | ||
99 | struct TopConf * | |
100 | find_top_conf(const char *name) | |
101 | { | |
330fc5c1 | 102 | rb_dlink_node *d; |
212380e3 AC |
103 | struct TopConf *tc; |
104 | ||
5cefa1d6 | 105 | RB_DLINK_FOREACH(d, conf_items.head) |
212380e3 AC |
106 | { |
107 | tc = d->data; | |
108 | if(strcasecmp(tc->tc_name, name) == 0) | |
109 | return tc; | |
110 | } | |
111 | ||
112 | return NULL; | |
113 | } | |
114 | ||
115 | ||
116 | struct ConfEntry * | |
117 | find_conf_item(const struct TopConf *top, const char *name) | |
118 | { | |
119 | struct ConfEntry *cf; | |
330fc5c1 | 120 | rb_dlink_node *d; |
212380e3 AC |
121 | |
122 | if(top->tc_entries) | |
123 | { | |
124 | int i; | |
125 | ||
126 | for(i = 0; top->tc_entries[i].cf_type; i++) | |
127 | { | |
128 | cf = &top->tc_entries[i]; | |
129 | ||
130 | if(!strcasecmp(cf->cf_name, name)) | |
131 | return cf; | |
132 | } | |
133 | } | |
134 | ||
5cefa1d6 | 135 | RB_DLINK_FOREACH(d, top->tc_items.head) |
212380e3 AC |
136 | { |
137 | cf = d->data; | |
138 | if(strcasecmp(cf->cf_name, name) == 0) | |
139 | return cf; | |
140 | } | |
141 | ||
142 | return NULL; | |
143 | } | |
144 | ||
145 | int | |
146 | remove_top_conf(char *name) | |
147 | { | |
148 | struct TopConf *tc; | |
330fc5c1 | 149 | rb_dlink_node *ptr; |
212380e3 AC |
150 | |
151 | if((tc = find_top_conf(name)) == NULL) | |
152 | return -1; | |
153 | ||
330fc5c1 | 154 | if((ptr = rb_dlinkFind(tc, &conf_items)) == NULL) |
212380e3 AC |
155 | return -1; |
156 | ||
330fc5c1 | 157 | rb_dlinkDestroy(ptr, &conf_items); |
637c4932 | 158 | rb_free(tc); |
212380e3 AC |
159 | |
160 | return 0; | |
161 | } | |
162 | ||
163 | static void | |
164 | conf_set_serverinfo_name(void *data) | |
165 | { | |
166 | if(ServerInfo.name == NULL) | |
167 | { | |
168 | const char *s; | |
169 | int dots = 0; | |
170 | ||
171 | for(s = data; *s != '\0'; s++) | |
172 | { | |
173 | if(!IsServChar(*s)) | |
174 | { | |
175 | conf_report_error("Ignoring serverinfo::name " | |
176 | "-- bogus servername."); | |
177 | return; | |
178 | } | |
179 | else if(*s == '.') | |
180 | ++dots; | |
181 | } | |
182 | ||
183 | if(!dots) | |
184 | { | |
185 | conf_report_error("Ignoring serverinfo::name -- must contain '.'"); | |
186 | return; | |
187 | } | |
188 | ||
189 | s = data; | |
190 | ||
191 | if(IsDigit(*s)) | |
192 | { | |
193 | conf_report_error("Ignoring serverinfo::name -- cannot begin with digit."); | |
194 | return; | |
195 | } | |
196 | ||
197 | /* the ircd will exit() in main() if we dont set one */ | |
198 | if(strlen(s) <= HOSTLEN) | |
47a03750 | 199 | ServerInfo.name = rb_strdup((char *) data); |
212380e3 AC |
200 | } |
201 | } | |
202 | ||
203 | static void | |
204 | conf_set_serverinfo_sid(void *data) | |
205 | { | |
206 | char *sid = data; | |
207 | ||
208 | if(ServerInfo.sid[0] == '\0') | |
209 | { | |
210 | if(!IsDigit(sid[0]) || !IsIdChar(sid[1]) || | |
211 | !IsIdChar(sid[2]) || sid[3] != '\0') | |
212 | { | |
213 | conf_report_error("Ignoring serverinfo::sid " | |
214 | "-- bogus sid."); | |
215 | return; | |
216 | } | |
217 | ||
218 | strcpy(ServerInfo.sid, sid); | |
219 | } | |
220 | } | |
221 | ||
222 | static void | |
223 | conf_set_serverinfo_network_name(void *data) | |
224 | { | |
225 | char *p; | |
226 | ||
227 | if((p = strchr((char *) data, ' '))) | |
228 | *p = '\0'; | |
229 | ||
637c4932 | 230 | rb_free(ServerInfo.network_name); |
47a03750 | 231 | ServerInfo.network_name = rb_strdup((char *) data); |
212380e3 AC |
232 | } |
233 | ||
234 | static void | |
235 | conf_set_serverinfo_vhost(void *data) | |
236 | { | |
caa4d9d2 | 237 | if(rb_inet_pton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0) |
212380e3 AC |
238 | { |
239 | conf_report_error("Invalid netmask for server IPv4 vhost (%s)", (char *) data); | |
240 | return; | |
241 | } | |
242 | ServerInfo.ip.sin_family = AF_INET; | |
243 | ServerInfo.specific_ipv4_vhost = 1; | |
244 | } | |
245 | ||
246 | static void | |
247 | conf_set_serverinfo_vhost6(void *data) | |
248 | { | |
ccda6e3f | 249 | #ifdef RB_IPV6 |
caa4d9d2 | 250 | if(rb_inet_pton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0) |
212380e3 AC |
251 | { |
252 | conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data); | |
253 | return; | |
254 | } | |
255 | ||
256 | ServerInfo.specific_ipv6_vhost = 1; | |
257 | ServerInfo.ip6.sin6_family = AF_INET6; | |
258 | #else | |
259 | conf_report_error("Warning -- ignoring serverinfo::vhost6 -- IPv6 support not available."); | |
260 | #endif | |
261 | } | |
262 | ||
b583faf9 AC |
263 | static void |
264 | conf_set_serverinfo_nicklen(void *data) | |
265 | { | |
7b42eab6 | 266 | ConfigFileEntry.nicklen = (*(unsigned int *) data) + 1; |
b583faf9 AC |
267 | |
268 | if (ConfigFileEntry.nicklen > NICKLEN) | |
269 | { | |
270 | conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)", | |
ca8ff483 | 271 | ConfigFileEntry.nicklen - 1, NICKLEN - 1); |
b583faf9 AC |
272 | ConfigFileEntry.nicklen = NICKLEN; |
273 | } | |
ca8ff483 JT |
274 | else if (ConfigFileEntry.nicklen < 9 + 1) |
275 | { | |
276 | conf_report_error("Warning -- serverinfo::nicklen is too low (%u) -- forcing 9", | |
277 | ConfigFileEntry.nicklen); | |
278 | ConfigFileEntry.nicklen = 9 + 1; | |
279 | } | |
b583faf9 AC |
280 | } |
281 | ||
212380e3 AC |
282 | static void |
283 | conf_set_modules_module(void *data) | |
284 | { | |
285 | #ifndef STATIC_MODULES | |
286 | char *m_bn; | |
287 | ||
b7a689d1 | 288 | m_bn = rb_basename((char *) data); |
212380e3 AC |
289 | |
290 | if(findmodule_byname(m_bn) != -1) | |
291 | return; | |
292 | ||
293 | load_one_module((char *) data, 0); | |
294 | ||
637c4932 | 295 | rb_free(m_bn); |
212380e3 AC |
296 | #else |
297 | conf_report_error("Ignoring modules::module -- loadable module support not present."); | |
298 | #endif | |
299 | } | |
300 | ||
301 | static void | |
302 | conf_set_modules_path(void *data) | |
303 | { | |
304 | #ifndef STATIC_MODULES | |
305 | mod_add_path((char *) data); | |
306 | #else | |
307 | conf_report_error("Ignoring modules::path -- loadable module support not present."); | |
308 | #endif | |
309 | } | |
310 | ||
311 | struct mode_table | |
312 | { | |
313 | const char *name; | |
314 | int mode; | |
315 | }; | |
316 | ||
317 | /* *INDENT-OFF* */ | |
318 | static struct mode_table umode_table[] = { | |
319 | {"callerid", UMODE_CALLERID }, | |
320 | {"deaf", UMODE_DEAF }, | |
321 | {"invisible", UMODE_INVISIBLE }, | |
322 | {"locops", UMODE_LOCOPS }, | |
323 | {"noforward", UMODE_NOFORWARD }, | |
324 | {"regonlymsg", UMODE_REGONLYMSG}, | |
325 | {"servnotice", UMODE_SERVNOTICE}, | |
326 | {"wallop", UMODE_WALLOP }, | |
327 | {"operwall", UMODE_OPERWALL }, | |
328 | {NULL, 0} | |
329 | }; | |
330 | ||
19c13ce5 | 331 | static struct mode_table oper_table[] = { |
212380e3 | 332 | {"encrypted", OPER_ENCRYPTED }, |
b1594414 | 333 | {"need_ssl", OPER_NEEDSSL }, |
212380e3 AC |
334 | {NULL, 0} |
335 | }; | |
336 | ||
337 | static struct mode_table auth_table[] = { | |
338 | {"encrypted", CONF_FLAGS_ENCRYPTED }, | |
339 | {"spoof_notice", CONF_FLAGS_SPOOF_NOTICE }, | |
340 | {"exceed_limit", CONF_FLAGS_NOLIMIT }, | |
341 | {"dnsbl_exempt", CONF_FLAGS_EXEMPTDNSBL }, | |
342 | {"kline_exempt", CONF_FLAGS_EXEMPTKLINE }, | |
212380e3 AC |
343 | {"flood_exempt", CONF_FLAGS_EXEMPTFLOOD }, |
344 | {"spambot_exempt", CONF_FLAGS_EXEMPTSPAMBOT }, | |
345 | {"shide_exempt", CONF_FLAGS_EXEMPTSHIDE }, | |
346 | {"jupe_exempt", CONF_FLAGS_EXEMPTJUPE }, | |
347 | {"resv_exempt", CONF_FLAGS_EXEMPTRESV }, | |
348 | {"no_tilde", CONF_FLAGS_NO_TILDE }, | |
349 | {"need_ident", CONF_FLAGS_NEED_IDENTD }, | |
350 | {"have_ident", CONF_FLAGS_NEED_IDENTD }, | |
b1594414 | 351 | {"need_ssl", CONF_FLAGS_NEED_SSL }, |
212380e3 AC |
352 | {"need_sasl", CONF_FLAGS_NEED_SASL }, |
353 | {NULL, 0} | |
354 | }; | |
355 | ||
356 | static struct mode_table connect_table[] = { | |
357 | { "autoconn", SERVER_AUTOCONN }, | |
358 | { "compressed", SERVER_COMPRESSED }, | |
359 | { "encrypted", SERVER_ENCRYPTED }, | |
360 | { "topicburst", SERVER_TB }, | |
c6d72037 | 361 | { "ssl", SERVER_SSL }, |
212380e3 AC |
362 | { NULL, 0 }, |
363 | }; | |
364 | ||
365 | static struct mode_table cluster_table[] = { | |
366 | { "kline", SHARED_PKLINE }, | |
367 | { "tkline", SHARED_TKLINE }, | |
368 | { "unkline", SHARED_UNKLINE }, | |
369 | { "locops", SHARED_LOCOPS }, | |
370 | { "xline", SHARED_PXLINE }, | |
371 | { "txline", SHARED_TXLINE }, | |
372 | { "unxline", SHARED_UNXLINE }, | |
373 | { "resv", SHARED_PRESV }, | |
374 | { "tresv", SHARED_TRESV }, | |
375 | { "unresv", SHARED_UNRESV }, | |
376 | { "all", CLUSTER_ALL }, | |
377 | {NULL, 0} | |
378 | }; | |
379 | ||
380 | static struct mode_table shared_table[] = | |
381 | { | |
382 | { "kline", SHARED_PKLINE|SHARED_TKLINE }, | |
383 | { "xline", SHARED_PXLINE|SHARED_TXLINE }, | |
384 | { "resv", SHARED_PRESV|SHARED_TRESV }, | |
f5cb68d5 VY |
385 | { "dline", SHARED_PDLINE|SHARED_TDLINE }, |
386 | { "tdline", SHARED_TDLINE }, | |
387 | { "pdline", SHARED_PDLINE }, | |
388 | { "undline", SHARED_UNDLINE }, | |
212380e3 AC |
389 | { "tkline", SHARED_TKLINE }, |
390 | { "unkline", SHARED_UNKLINE }, | |
391 | { "txline", SHARED_TXLINE }, | |
392 | { "unxline", SHARED_UNXLINE }, | |
393 | { "tresv", SHARED_TRESV }, | |
394 | { "unresv", SHARED_UNRESV }, | |
395 | { "locops", SHARED_LOCOPS }, | |
396 | { "rehash", SHARED_REHASH }, | |
397 | { "all", SHARED_ALL }, | |
398 | { "none", 0 }, | |
399 | {NULL, 0} | |
400 | }; | |
401 | /* *INDENT-ON* */ | |
402 | ||
403 | static int | |
404 | find_umode(struct mode_table *tab, const char *name) | |
405 | { | |
406 | int i; | |
407 | ||
408 | for (i = 0; tab[i].name; i++) | |
409 | { | |
410 | if(strcmp(tab[i].name, name) == 0) | |
411 | return tab[i].mode; | |
412 | } | |
413 | ||
414 | return -1; | |
415 | } | |
416 | ||
417 | static void | |
418 | set_modes_from_table(int *modes, const char *whatis, struct mode_table *tab, conf_parm_t * args) | |
419 | { | |
420 | for (; args; args = args->next) | |
421 | { | |
422 | const char *umode; | |
423 | int dir = 1; | |
424 | int mode; | |
425 | ||
426 | if((args->type & CF_MTYPE) != CF_STRING) | |
427 | { | |
428 | conf_report_error("Warning -- %s is not a string; ignoring.", whatis); | |
429 | continue; | |
430 | } | |
431 | ||
432 | umode = args->v.string; | |
433 | ||
434 | if(*umode == '~') | |
435 | { | |
436 | dir = 0; | |
437 | umode++; | |
438 | } | |
439 | ||
440 | mode = find_umode(tab, umode); | |
441 | ||
442 | if(mode == -1) | |
443 | { | |
444 | conf_report_error("Warning -- unknown %s %s.", whatis, args->v.string); | |
445 | continue; | |
446 | } | |
447 | ||
448 | if(mode) | |
449 | { | |
450 | if(dir) | |
451 | *modes |= mode; | |
452 | else | |
453 | *modes &= ~mode; | |
454 | } | |
455 | else | |
456 | *modes = 0; | |
457 | } | |
458 | } | |
459 | ||
f8606875 AC |
460 | static void |
461 | conf_set_privset_extends(void *data) | |
462 | { | |
463 | yy_privset_extends = rb_strdup((char *) data); | |
464 | } | |
465 | ||
466 | static void | |
467 | conf_set_privset_privs(void *data) | |
468 | { | |
469 | char *privs = NULL; | |
470 | conf_parm_t *args = data; | |
471 | ||
472 | for (; args; args = args->next) | |
473 | { | |
474 | if (privs == NULL) | |
475 | privs = rb_strdup(args->v.string); | |
476 | else | |
477 | { | |
478 | char *privs_old = privs; | |
479 | ||
480 | privs = rb_malloc(strlen(privs_old) + 1 + strlen(args->v.string) + 1); | |
065f67db | 481 | strcpy(privs, privs_old); |
f8606875 AC |
482 | strcat(privs, " "); |
483 | strcat(privs, args->v.string); | |
484 | ||
485 | rb_free(privs_old); | |
486 | } | |
487 | } | |
488 | ||
489 | if (privs) | |
490 | { | |
491 | if (yy_privset_extends) | |
492 | { | |
493 | struct PrivilegeSet *set = privilegeset_get(yy_privset_extends); | |
494 | ||
495 | if (!set) | |
496 | { | |
49b0375d | 497 | conf_report_error("Warning -- unknown parent privilege set %s for %s; assuming defaults", yy_privset_extends, conf_cur_block_name); |
f8606875 | 498 | |
49b0375d | 499 | set = privilegeset_get("default"); |
f8606875 AC |
500 | } |
501 | ||
502 | privilegeset_extend(set, conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
503 | ||
504 | rb_free(yy_privset_extends); | |
505 | yy_privset_extends = NULL; | |
506 | } | |
507 | else | |
508 | privilegeset_set_new(conf_cur_block_name != NULL ? conf_cur_block_name : "<unknown>", privs, 0); | |
509 | ||
510 | rb_free(privs); | |
511 | } | |
512 | } | |
513 | ||
212380e3 AC |
514 | static int |
515 | conf_begin_oper(struct TopConf *tc) | |
516 | { | |
330fc5c1 | 517 | rb_dlink_node *ptr; |
637c4932 | 518 | rb_dlink_node *next_ptr; |
212380e3 AC |
519 | |
520 | if(yy_oper != NULL) | |
521 | { | |
522 | free_oper_conf(yy_oper); | |
523 | yy_oper = NULL; | |
524 | } | |
525 | ||
637c4932 | 526 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
527 | { |
528 | free_oper_conf(ptr->data); | |
330fc5c1 | 529 | rb_dlinkDestroy(ptr, &yy_oper_list); |
212380e3 AC |
530 | } |
531 | ||
532 | yy_oper = make_oper_conf(); | |
10847f65 | 533 | yy_oper->flags |= OPER_ENCRYPTED; |
212380e3 AC |
534 | |
535 | return 0; | |
536 | } | |
537 | ||
538 | static int | |
539 | conf_end_oper(struct TopConf *tc) | |
540 | { | |
541 | struct oper_conf *yy_tmpoper; | |
330fc5c1 | 542 | rb_dlink_node *ptr; |
637c4932 | 543 | rb_dlink_node *next_ptr; |
212380e3 AC |
544 | |
545 | if(conf_cur_block_name != NULL) | |
546 | { | |
547 | if(strlen(conf_cur_block_name) > OPERNICKLEN) | |
548 | conf_cur_block_name[OPERNICKLEN] = '\0'; | |
549 | ||
47a03750 | 550 | yy_oper->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
551 | } |
552 | ||
553 | if(EmptyString(yy_oper->name)) | |
554 | { | |
555 | conf_report_error("Ignoring operator block -- missing name."); | |
556 | return 0; | |
557 | } | |
558 | ||
559 | #ifdef HAVE_LIBCRYPTO | |
560 | if(EmptyString(yy_oper->passwd) && EmptyString(yy_oper->rsa_pubkey_file)) | |
561 | #else | |
562 | if(EmptyString(yy_oper->passwd)) | |
563 | #endif | |
564 | { | |
565 | conf_report_error("Ignoring operator block for %s -- missing password", | |
566 | yy_oper->name); | |
567 | return 0; | |
568 | } | |
569 | ||
7d5acab7 JT |
570 | |
571 | if (!yy_oper->privset) | |
572 | yy_oper->privset = privilegeset_get("default"); | |
573 | ||
212380e3 AC |
574 | /* now, yy_oper_list contains a stack of oper_conf's with just user |
575 | * and host in, yy_oper contains the rest of the information which | |
576 | * we need to copy into each element in yy_oper_list | |
577 | */ | |
637c4932 | 578 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) |
212380e3 AC |
579 | { |
580 | yy_tmpoper = ptr->data; | |
581 | ||
47a03750 | 582 | yy_tmpoper->name = rb_strdup(yy_oper->name); |
212380e3 AC |
583 | |
584 | /* could be an rsa key instead.. */ | |
585 | if(!EmptyString(yy_oper->passwd)) | |
47a03750 | 586 | yy_tmpoper->passwd = rb_strdup(yy_oper->passwd); |
212380e3 AC |
587 | |
588 | yy_tmpoper->flags = yy_oper->flags; | |
589 | yy_tmpoper->umodes = yy_oper->umodes; | |
590 | yy_tmpoper->snomask = yy_oper->snomask; | |
22c3b270 | 591 | yy_tmpoper->privset = yy_oper->privset; |
212380e3 AC |
592 | |
593 | #ifdef HAVE_LIBCRYPTO | |
594 | if(yy_oper->rsa_pubkey_file) | |
595 | { | |
596 | BIO *file; | |
597 | ||
598 | if((file = BIO_new_file(yy_oper->rsa_pubkey_file, "r")) == NULL) | |
599 | { | |
600 | conf_report_error("Ignoring operator block for %s -- " | |
601 | "rsa_public_key_file cant be opened", | |
602 | yy_tmpoper->name); | |
603 | return 0; | |
604 | } | |
605 | ||
606 | yy_tmpoper->rsa_pubkey = | |
607 | (RSA *) PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL); | |
608 | ||
c422d2a0 | 609 | (void)BIO_set_close(file, BIO_CLOSE); |
212380e3 AC |
610 | BIO_free(file); |
611 | ||
612 | if(yy_tmpoper->rsa_pubkey == NULL) | |
613 | { | |
614 | conf_report_error("Ignoring operator block for %s -- " | |
615 | "rsa_public_key_file key invalid; check syntax", | |
616 | yy_tmpoper->name); | |
617 | return 0; | |
618 | } | |
619 | } | |
63c7a68e EM |
620 | |
621 | if(!EmptyString(yy_oper->certfp)) | |
462ae9d7 | 622 | yy_tmpoper->certfp = rb_strdup(yy_oper->certfp); |
212380e3 AC |
623 | #endif |
624 | ||
625 | /* all is ok, put it on oper_conf_list */ | |
330fc5c1 | 626 | rb_dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list); |
212380e3 AC |
627 | } |
628 | ||
629 | free_oper_conf(yy_oper); | |
630 | yy_oper = NULL; | |
631 | ||
632 | return 0; | |
633 | } | |
634 | ||
635 | static void | |
636 | conf_set_oper_flags(void *data) | |
637 | { | |
638 | conf_parm_t *args = data; | |
639 | ||
19c13ce5 | 640 | set_modes_from_table(&yy_oper->flags, "flag", oper_table, args); |
212380e3 AC |
641 | } |
642 | ||
ff31db84 AC |
643 | static void |
644 | conf_set_oper_fingerprint(void *data) | |
645 | { | |
462ae9d7 JT |
646 | if (yy_oper->certfp) |
647 | rb_free(yy_oper->certfp); | |
ff31db84 AC |
648 | yy_oper->certfp = rb_strdup((char *) data); |
649 | } | |
650 | ||
22c3b270 AC |
651 | static void |
652 | conf_set_oper_privset(void *data) | |
653 | { | |
654 | yy_oper->privset = privilegeset_get((char *) data); | |
655 | } | |
656 | ||
212380e3 AC |
657 | static void |
658 | conf_set_oper_user(void *data) | |
659 | { | |
660 | struct oper_conf *yy_tmpoper; | |
661 | char *p; | |
662 | char *host = (char *) data; | |
663 | ||
664 | yy_tmpoper = make_oper_conf(); | |
665 | ||
666 | if((p = strchr(host, '@'))) | |
667 | { | |
668 | *p++ = '\0'; | |
669 | ||
47a03750 VY |
670 | yy_tmpoper->username = rb_strdup(host); |
671 | yy_tmpoper->host = rb_strdup(p); | |
212380e3 AC |
672 | } |
673 | else | |
674 | { | |
675 | ||
47a03750 VY |
676 | yy_tmpoper->username = rb_strdup("*"); |
677 | yy_tmpoper->host = rb_strdup(host); | |
212380e3 AC |
678 | } |
679 | ||
680 | if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host)) | |
681 | { | |
682 | conf_report_error("Ignoring user -- missing username/host"); | |
683 | free_oper_conf(yy_tmpoper); | |
684 | return; | |
685 | } | |
686 | ||
330fc5c1 | 687 | rb_dlinkAddAlloc(yy_tmpoper, &yy_oper_list); |
212380e3 AC |
688 | } |
689 | ||
690 | static void | |
691 | conf_set_oper_password(void *data) | |
692 | { | |
693 | if(yy_oper->passwd) | |
694 | { | |
695 | memset(yy_oper->passwd, 0, strlen(yy_oper->passwd)); | |
637c4932 | 696 | rb_free(yy_oper->passwd); |
212380e3 AC |
697 | } |
698 | ||
47a03750 | 699 | yy_oper->passwd = rb_strdup((char *) data); |
212380e3 AC |
700 | } |
701 | ||
702 | static void | |
703 | conf_set_oper_rsa_public_key_file(void *data) | |
704 | { | |
705 | #ifdef HAVE_LIBCRYPTO | |
637c4932 | 706 | rb_free(yy_oper->rsa_pubkey_file); |
47a03750 | 707 | yy_oper->rsa_pubkey_file = rb_strdup((char *) data); |
212380e3 AC |
708 | #else |
709 | conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available"); | |
710 | #endif | |
711 | } | |
712 | ||
713 | static void | |
714 | conf_set_oper_umodes(void *data) | |
715 | { | |
716 | set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data); | |
717 | } | |
718 | ||
719 | static void | |
720 | conf_set_oper_snomask(void *data) | |
721 | { | |
722 | yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data); | |
723 | } | |
724 | ||
725 | static int | |
726 | conf_begin_class(struct TopConf *tc) | |
727 | { | |
728 | if(yy_class) | |
729 | free_class(yy_class); | |
730 | ||
731 | yy_class = make_class(); | |
732 | return 0; | |
733 | } | |
734 | ||
735 | static int | |
736 | conf_end_class(struct TopConf *tc) | |
737 | { | |
738 | if(conf_cur_block_name != NULL) | |
47a03750 | 739 | yy_class->class_name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
740 | |
741 | if(EmptyString(yy_class->class_name)) | |
742 | { | |
743 | conf_report_error("Ignoring connect block -- missing name."); | |
744 | return 0; | |
745 | } | |
746 | ||
747 | add_class(yy_class); | |
748 | yy_class = NULL; | |
749 | return 0; | |
750 | } | |
751 | ||
752 | static void | |
753 | conf_set_class_ping_time(void *data) | |
754 | { | |
755 | yy_class->ping_freq = *(unsigned int *) data; | |
756 | } | |
757 | ||
758 | static void | |
e33e589c | 759 | conf_set_class_cidr_ipv4_bitlen(void *data) |
212380e3 | 760 | { |
e33e589c JT |
761 | unsigned int maxsize = 32; |
762 | if(*(unsigned int *) data > maxsize) | |
763 | conf_report_error | |
764 | ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.", | |
765 | *(unsigned int *) data, maxsize); | |
766 | else | |
767 | yy_class->cidr_ipv4_bitlen = *(unsigned int *) data; | |
768 | ||
769 | } | |
770 | ||
ccda6e3f | 771 | #ifdef RB_IPV6 |
e33e589c JT |
772 | static void |
773 | conf_set_class_cidr_ipv6_bitlen(void *data) | |
774 | { | |
212380e3 | 775 | unsigned int maxsize = 128; |
212380e3 AC |
776 | if(*(unsigned int *) data > maxsize) |
777 | conf_report_error | |
e33e589c | 778 | ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.", |
212380e3 AC |
779 | *(unsigned int *) data, maxsize); |
780 | else | |
e33e589c | 781 | yy_class->cidr_ipv6_bitlen = *(unsigned int *) data; |
212380e3 AC |
782 | |
783 | } | |
e33e589c JT |
784 | #endif |
785 | ||
212380e3 AC |
786 | static void |
787 | conf_set_class_number_per_cidr(void *data) | |
788 | { | |
789 | yy_class->cidr_amount = *(unsigned int *) data; | |
790 | } | |
791 | ||
792 | static void | |
793 | conf_set_class_number_per_ip(void *data) | |
794 | { | |
795 | yy_class->max_local = *(unsigned int *) data; | |
796 | } | |
797 | ||
798 | ||
799 | static void | |
800 | conf_set_class_number_per_ip_global(void *data) | |
801 | { | |
802 | yy_class->max_global = *(unsigned int *) data; | |
803 | } | |
804 | ||
805 | static void | |
806 | conf_set_class_number_per_ident(void *data) | |
807 | { | |
808 | yy_class->max_ident = *(unsigned int *) data; | |
809 | } | |
810 | ||
811 | static void | |
812 | conf_set_class_connectfreq(void *data) | |
813 | { | |
814 | yy_class->con_freq = *(unsigned int *) data; | |
815 | } | |
816 | ||
817 | static void | |
818 | conf_set_class_max_number(void *data) | |
819 | { | |
820 | yy_class->max_total = *(unsigned int *) data; | |
821 | } | |
822 | ||
823 | static void | |
824 | conf_set_class_sendq(void *data) | |
825 | { | |
826 | yy_class->max_sendq = *(unsigned int *) data; | |
827 | } | |
828 | ||
829 | static char *listener_address; | |
830 | ||
831 | static int | |
832 | conf_begin_listen(struct TopConf *tc) | |
833 | { | |
637c4932 | 834 | rb_free(listener_address); |
212380e3 AC |
835 | listener_address = NULL; |
836 | return 0; | |
837 | } | |
838 | ||
839 | static int | |
840 | conf_end_listen(struct TopConf *tc) | |
841 | { | |
637c4932 | 842 | rb_free(listener_address); |
212380e3 AC |
843 | listener_address = NULL; |
844 | return 0; | |
845 | } | |
846 | ||
c6d72037 VY |
847 | |
848 | ||
212380e3 | 849 | static void |
c6d72037 | 850 | conf_set_listen_port_both(void *data, int ssl) |
212380e3 AC |
851 | { |
852 | conf_parm_t *args = data; | |
853 | for (; args; args = args->next) | |
854 | { | |
855 | if((args->type & CF_MTYPE) != CF_INT) | |
856 | { | |
857 | conf_report_error | |
858 | ("listener::port argument is not an integer " "-- ignoring."); | |
859 | continue; | |
860 | } | |
861 | if(listener_address == NULL) | |
862 | { | |
c6d72037 | 863 | add_listener(args->v.number, listener_address, AF_INET, ssl); |
ccda6e3f | 864 | #ifdef RB_IPV6 |
c6d72037 | 865 | add_listener(args->v.number, listener_address, AF_INET6, ssl); |
212380e3 AC |
866 | #endif |
867 | } | |
868 | else | |
869 | { | |
870 | int family; | |
ccda6e3f | 871 | #ifdef RB_IPV6 |
212380e3 AC |
872 | if(strchr(listener_address, ':') != NULL) |
873 | family = AF_INET6; | |
874 | else | |
875 | #endif | |
876 | family = AF_INET; | |
877 | ||
c6d72037 | 878 | add_listener(args->v.number, listener_address, family, ssl); |
212380e3 AC |
879 | |
880 | } | |
881 | ||
882 | } | |
883 | } | |
884 | ||
8bd5767b JT |
885 | static void |
886 | conf_set_listen_port(void *data) | |
887 | { | |
888 | conf_set_listen_port_both(data, 0); | |
889 | } | |
890 | ||
891 | static void | |
892 | conf_set_listen_sslport(void *data) | |
893 | { | |
894 | conf_set_listen_port_both(data, 1); | |
c6d72037 VY |
895 | } |
896 | ||
212380e3 AC |
897 | static void |
898 | conf_set_listen_address(void *data) | |
899 | { | |
637c4932 | 900 | rb_free(listener_address); |
47a03750 | 901 | listener_address = rb_strdup(data); |
212380e3 AC |
902 | } |
903 | ||
904 | static int | |
905 | conf_begin_auth(struct TopConf *tc) | |
906 | { | |
330fc5c1 | 907 | rb_dlink_node *ptr; |
637c4932 | 908 | rb_dlink_node *next_ptr; |
212380e3 AC |
909 | |
910 | if(yy_aconf) | |
911 | free_conf(yy_aconf); | |
912 | ||
637c4932 | 913 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
914 | { |
915 | free_conf(ptr->data); | |
330fc5c1 | 916 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
917 | } |
918 | ||
919 | yy_aconf = make_conf(); | |
920 | yy_aconf->status = CONF_CLIENT; | |
921 | ||
922 | return 0; | |
923 | } | |
924 | ||
925 | static int | |
926 | conf_end_auth(struct TopConf *tc) | |
927 | { | |
3d1f32c0 | 928 | struct ConfItem *yy_tmp, *found_conf; |
330fc5c1 | 929 | rb_dlink_node *ptr; |
637c4932 | 930 | rb_dlink_node *next_ptr; |
212380e3 | 931 | |
27f616dd JT |
932 | if(EmptyString(yy_aconf->info.name)) |
933 | yy_aconf->info.name = rb_strdup("NOMATCH"); | |
212380e3 AC |
934 | |
935 | /* didnt even get one ->host? */ | |
936 | if(EmptyString(yy_aconf->host)) | |
937 | { | |
938 | conf_report_error("Ignoring auth block -- missing user@host"); | |
939 | return 0; | |
940 | } | |
941 | ||
942 | /* so the stacking works in order.. */ | |
943 | collapse(yy_aconf->user); | |
944 | collapse(yy_aconf->host); | |
945 | conf_add_class_to_conf(yy_aconf); | |
3d1f32c0 | 946 | if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) |
6e5e2b00 | 947 | conf_report_error("Ignoring redundant auth block (after *@*)"); |
3d1f32c0 | 948 | else if ((found_conf = find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) && |
5f2df251 | 949 | (!found_conf->spasswd || (yy_aconf->spasswd && |
3d1f32c0 | 950 | 0 == irccmp(found_conf->spasswd, yy_aconf->spasswd)))) |
6e5e2b00 JT |
951 | conf_report_error("Ignoring duplicate auth block for %s@%s", |
952 | yy_aconf->user, yy_aconf->host); | |
953 | else | |
954 | add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf->spasswd, yy_aconf); | |
212380e3 | 955 | |
637c4932 | 956 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) |
212380e3 AC |
957 | { |
958 | yy_tmp = ptr->data; | |
959 | ||
960 | if(yy_aconf->passwd) | |
47a03750 | 961 | yy_tmp->passwd = rb_strdup(yy_aconf->passwd); |
212380e3 | 962 | |
40c1fd47 VY |
963 | if(yy_aconf->spasswd) |
964 | yy_tmp->spasswd = rb_strdup(yy_aconf->spasswd); | |
965 | ||
212380e3 | 966 | /* this will always exist.. */ |
27f616dd | 967 | yy_tmp->info.name = rb_strdup(yy_aconf->info.name); |
212380e3 AC |
968 | |
969 | if(yy_aconf->className) | |
47a03750 | 970 | yy_tmp->className = rb_strdup(yy_aconf->className); |
212380e3 AC |
971 | |
972 | yy_tmp->flags = yy_aconf->flags; | |
973 | yy_tmp->port = yy_aconf->port; | |
974 | ||
975 | collapse(yy_tmp->user); | |
976 | collapse(yy_tmp->host); | |
977 | ||
978 | conf_add_class_to_conf(yy_tmp); | |
979 | ||
6e5e2b00 JT |
980 | if (find_exact_conf_by_address("*", CONF_CLIENT, "*")) |
981 | conf_report_error("Ignoring redundant auth block (after *@*)"); | |
982 | else if (find_exact_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user)) | |
983 | conf_report_error("Ignoring duplicate auth block for %s@%s", | |
984 | yy_tmp->user, yy_tmp->host); | |
985 | else | |
986 | add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp->spasswd, yy_tmp); | |
330fc5c1 | 987 | rb_dlinkDestroy(ptr, &yy_aconf_list); |
212380e3 AC |
988 | } |
989 | ||
990 | yy_aconf = NULL; | |
991 | return 0; | |
992 | } | |
993 | ||
994 | static void | |
995 | conf_set_auth_user(void *data) | |
996 | { | |
997 | struct ConfItem *yy_tmp; | |
998 | char *p; | |
999 | ||
1000 | /* The first user= line doesn't allocate a new conf */ | |
1001 | if(!EmptyString(yy_aconf->host)) | |
1002 | { | |
1003 | yy_tmp = make_conf(); | |
1004 | yy_tmp->status = CONF_CLIENT; | |
1005 | } | |
1006 | else | |
1007 | yy_tmp = yy_aconf; | |
1008 | ||
1009 | if((p = strchr(data, '@'))) | |
1010 | { | |
1011 | *p++ = '\0'; | |
1012 | ||
47a03750 VY |
1013 | yy_tmp->user = rb_strdup(data); |
1014 | yy_tmp->host = rb_strdup(p); | |
212380e3 AC |
1015 | } |
1016 | else | |
1017 | { | |
47a03750 VY |
1018 | yy_tmp->user = rb_strdup("*"); |
1019 | yy_tmp->host = rb_strdup(data); | |
212380e3 AC |
1020 | } |
1021 | ||
1022 | if(yy_aconf != yy_tmp) | |
330fc5c1 | 1023 | rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list); |
212380e3 AC |
1024 | } |
1025 | ||
40c1fd47 VY |
1026 | static void |
1027 | conf_set_auth_auth_user(void *data) | |
1028 | { | |
1029 | if(yy_aconf->spasswd) | |
1030 | memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd)); | |
1031 | rb_free(yy_aconf->spasswd); | |
1032 | yy_aconf->spasswd = rb_strdup(data); | |
1033 | } | |
1034 | ||
212380e3 AC |
1035 | static void |
1036 | conf_set_auth_passwd(void *data) | |
1037 | { | |
1038 | if(yy_aconf->passwd) | |
1039 | memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd)); | |
637c4932 | 1040 | rb_free(yy_aconf->passwd); |
47a03750 | 1041 | yy_aconf->passwd = rb_strdup(data); |
212380e3 AC |
1042 | } |
1043 | ||
1044 | static void | |
1045 | conf_set_auth_spoof(void *data) | |
1046 | { | |
1047 | char *p; | |
1048 | char *user = NULL; | |
1049 | char *host = NULL; | |
1050 | ||
1051 | host = data; | |
1052 | ||
1053 | /* user@host spoof */ | |
1054 | if((p = strchr(host, '@')) != NULL) | |
1055 | { | |
1056 | *p = '\0'; | |
1057 | user = data; | |
1058 | host = p+1; | |
1059 | ||
1060 | if(EmptyString(user)) | |
1061 | { | |
1062 | conf_report_error("Warning -- spoof ident empty."); | |
1063 | return; | |
1064 | } | |
1065 | ||
1066 | if(strlen(user) > USERLEN) | |
1067 | { | |
1068 | conf_report_error("Warning -- spoof ident length invalid."); | |
1069 | return; | |
1070 | } | |
1071 | ||
1072 | if(!valid_username(user)) | |
1073 | { | |
1074 | conf_report_error("Warning -- invalid spoof (ident)."); | |
1075 | return; | |
1076 | } | |
1077 | ||
1078 | /* this must be restored! */ | |
1079 | *p = '@'; | |
1080 | } | |
1081 | ||
1082 | if(EmptyString(host)) | |
1083 | { | |
1084 | conf_report_error("Warning -- spoof host empty."); | |
1085 | return; | |
1086 | } | |
1087 | ||
1088 | if(strlen(host) > HOSTLEN) | |
1089 | { | |
1090 | conf_report_error("Warning -- spoof host length invalid."); | |
1091 | return; | |
1092 | } | |
1093 | ||
1094 | if(!valid_hostname(host)) | |
1095 | { | |
1096 | conf_report_error("Warning -- invalid spoof (host)."); | |
1097 | return; | |
1098 | } | |
1099 | ||
27f616dd JT |
1100 | rb_free(yy_aconf->info.name); |
1101 | yy_aconf->info.name = rb_strdup(data); | |
212380e3 AC |
1102 | yy_aconf->flags |= CONF_FLAGS_SPOOF_IP; |
1103 | } | |
1104 | ||
1105 | static void | |
1106 | conf_set_auth_flags(void *data) | |
1107 | { | |
1108 | conf_parm_t *args = data; | |
1109 | ||
1110 | set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args); | |
1111 | } | |
1112 | ||
1113 | static void | |
1114 | conf_set_auth_redir_serv(void *data) | |
1115 | { | |
1116 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
27f616dd JT |
1117 | rb_free(yy_aconf->info.name); |
1118 | yy_aconf->info.name = rb_strdup(data); | |
212380e3 AC |
1119 | } |
1120 | ||
1121 | static void | |
1122 | conf_set_auth_redir_port(void *data) | |
1123 | { | |
1124 | int port = *(unsigned int *) data; | |
1125 | ||
1126 | yy_aconf->flags |= CONF_FLAGS_REDIR; | |
1127 | yy_aconf->port = port; | |
1128 | } | |
1129 | ||
1130 | static void | |
1131 | conf_set_auth_class(void *data) | |
1132 | { | |
637c4932 | 1133 | rb_free(yy_aconf->className); |
47a03750 | 1134 | yy_aconf->className = rb_strdup(data); |
212380e3 AC |
1135 | } |
1136 | ||
1137 | /* ok, shared_oper handles the stacking, shared_flags handles adding | |
1138 | * things.. so all we need to do when we start and end a shared block, is | |
1139 | * clean up anything thats been left over. | |
1140 | */ | |
1141 | static int | |
1142 | conf_cleanup_shared(struct TopConf *tc) | |
1143 | { | |
637c4932 | 1144 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1145 | |
637c4932 | 1146 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1147 | { |
1148 | free_remote_conf(ptr->data); | |
330fc5c1 | 1149 | rb_dlinkDestroy(ptr, &yy_shared_list); |
212380e3 AC |
1150 | } |
1151 | ||
1152 | if(yy_shared != NULL) | |
1153 | { | |
1154 | free_remote_conf(yy_shared); | |
1155 | yy_shared = NULL; | |
1156 | } | |
1157 | ||
1158 | return 0; | |
1159 | } | |
1160 | ||
1161 | static void | |
1162 | conf_set_shared_oper(void *data) | |
1163 | { | |
1164 | conf_parm_t *args = data; | |
1165 | const char *username; | |
1166 | char *p; | |
1167 | ||
1168 | if(yy_shared != NULL) | |
1169 | free_remote_conf(yy_shared); | |
1170 | ||
1171 | yy_shared = make_remote_conf(); | |
1172 | ||
1173 | if(args->next != NULL) | |
1174 | { | |
1175 | if((args->type & CF_MTYPE) != CF_QSTRING) | |
1176 | { | |
1177 | conf_report_error("Ignoring shared::oper -- server is not a qstring"); | |
1178 | return; | |
1179 | } | |
1180 | ||
47a03750 | 1181 | yy_shared->server = rb_strdup(args->v.string); |
212380e3 AC |
1182 | args = args->next; |
1183 | } | |
1184 | else | |
47a03750 | 1185 | yy_shared->server = rb_strdup("*"); |
212380e3 AC |
1186 | |
1187 | if((args->type & CF_MTYPE) != CF_QSTRING) | |
1188 | { | |
1189 | conf_report_error("Ignoring shared::oper -- oper is not a qstring"); | |
1190 | return; | |
1191 | } | |
1192 | ||
1193 | if((p = strchr(args->v.string, '@')) == NULL) | |
1194 | { | |
1195 | conf_report_error("Ignoring shard::oper -- oper is not a user@host"); | |
1196 | return; | |
1197 | } | |
1198 | ||
1199 | username = args->v.string; | |
1200 | *p++ = '\0'; | |
1201 | ||
1202 | if(EmptyString(p)) | |
47a03750 | 1203 | yy_shared->host = rb_strdup("*"); |
212380e3 | 1204 | else |
47a03750 | 1205 | yy_shared->host = rb_strdup(p); |
212380e3 AC |
1206 | |
1207 | if(EmptyString(username)) | |
47a03750 | 1208 | yy_shared->username = rb_strdup("*"); |
212380e3 | 1209 | else |
47a03750 | 1210 | yy_shared->username = rb_strdup(username); |
212380e3 | 1211 | |
330fc5c1 | 1212 | rb_dlinkAddAlloc(yy_shared, &yy_shared_list); |
212380e3 AC |
1213 | yy_shared = NULL; |
1214 | } | |
1215 | ||
1216 | static void | |
1217 | conf_set_shared_flags(void *data) | |
1218 | { | |
1219 | conf_parm_t *args = data; | |
1220 | int flags = 0; | |
637c4932 | 1221 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1222 | |
1223 | if(yy_shared != NULL) | |
1224 | free_remote_conf(yy_shared); | |
1225 | ||
1226 | set_modes_from_table(&flags, "flag", shared_table, args); | |
1227 | ||
637c4932 | 1228 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) |
212380e3 AC |
1229 | { |
1230 | yy_shared = ptr->data; | |
1231 | ||
1232 | yy_shared->flags = flags; | |
330fc5c1 AC |
1233 | rb_dlinkDestroy(ptr, &yy_shared_list); |
1234 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list); | |
212380e3 AC |
1235 | } |
1236 | ||
1237 | yy_shared = NULL; | |
1238 | } | |
1239 | ||
1240 | static int | |
1241 | conf_begin_connect(struct TopConf *tc) | |
1242 | { | |
1243 | if(yy_server) | |
1244 | free_server_conf(yy_server); | |
1245 | ||
1246 | yy_server = make_server_conf(); | |
1247 | yy_server->port = PORTNUM; | |
5aa453a4 | 1248 | yy_server->flags |= SERVER_TB; |
212380e3 AC |
1249 | |
1250 | if(conf_cur_block_name != NULL) | |
47a03750 | 1251 | yy_server->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1252 | |
1253 | return 0; | |
1254 | } | |
1255 | ||
1256 | static int | |
1257 | conf_end_connect(struct TopConf *tc) | |
1258 | { | |
1259 | if(EmptyString(yy_server->name)) | |
1260 | { | |
1261 | conf_report_error("Ignoring connect block -- missing name."); | |
1262 | return 0; | |
1263 | } | |
1264 | ||
1265 | if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name)) | |
1266 | { | |
1267 | conf_report_error("Ignoring connect block for %s -- name is equal to my own name.", | |
1268 | yy_server->name); | |
1269 | return 0; | |
1270 | } | |
1271 | ||
ff0cc1e6 | 1272 | if((EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd)) && EmptyString(yy_server->certfp)) |
212380e3 | 1273 | { |
c8f26906 | 1274 | conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.", |
212380e3 AC |
1275 | yy_server->name); |
1276 | return 0; | |
1277 | } | |
1278 | ||
1279 | if(EmptyString(yy_server->host)) | |
1280 | { | |
1281 | conf_report_error("Ignoring connect block for %s -- missing host.", | |
1282 | yy_server->name); | |
1283 | return 0; | |
1284 | } | |
1285 | ||
1286 | #ifndef HAVE_LIBZ | |
1287 | if(ServerConfCompressed(yy_server)) | |
1288 | { | |
1289 | conf_report_error("Ignoring connect::flags::compressed -- zlib not available."); | |
1290 | yy_server->flags &= ~SERVER_COMPRESSED; | |
1291 | } | |
1292 | #endif | |
1293 | ||
1294 | add_server_conf(yy_server); | |
330fc5c1 | 1295 | rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list); |
212380e3 AC |
1296 | |
1297 | yy_server = NULL; | |
1298 | return 0; | |
1299 | } | |
1300 | ||
1301 | static void | |
1302 | conf_set_connect_host(void *data) | |
1303 | { | |
637c4932 | 1304 | rb_free(yy_server->host); |
47a03750 | 1305 | yy_server->host = rb_strdup(data); |
212380e3 AC |
1306 | if (strchr(yy_server->host, ':')) |
1307 | yy_server->aftype = AF_INET6; | |
1308 | } | |
1309 | ||
1310 | static void | |
1311 | conf_set_connect_vhost(void *data) | |
1312 | { | |
caa4d9d2 | 1313 | if(rb_inet_pton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0) |
212380e3 AC |
1314 | { |
1315 | conf_report_error("Invalid netmask for server vhost (%s)", | |
1316 | (char *) data); | |
1317 | return; | |
1318 | } | |
1319 | ||
1320 | yy_server->flags |= SERVER_VHOSTED; | |
1321 | } | |
1322 | ||
1323 | static void | |
1324 | conf_set_connect_send_password(void *data) | |
1325 | { | |
1326 | if(yy_server->spasswd) | |
1327 | { | |
1328 | memset(yy_server->spasswd, 0, strlen(yy_server->spasswd)); | |
637c4932 | 1329 | rb_free(yy_server->spasswd); |
212380e3 AC |
1330 | } |
1331 | ||
47a03750 | 1332 | yy_server->spasswd = rb_strdup(data); |
212380e3 AC |
1333 | } |
1334 | ||
1335 | static void | |
1336 | conf_set_connect_accept_password(void *data) | |
1337 | { | |
1338 | if(yy_server->passwd) | |
1339 | { | |
1340 | memset(yy_server->passwd, 0, strlen(yy_server->passwd)); | |
637c4932 | 1341 | rb_free(yy_server->passwd); |
212380e3 | 1342 | } |
47a03750 | 1343 | yy_server->passwd = rb_strdup(data); |
212380e3 AC |
1344 | } |
1345 | ||
ff0cc1e6 AC |
1346 | static void |
1347 | conf_set_connect_fingerprint(void *data) | |
1348 | { | |
462ae9d7 JT |
1349 | if (yy_server->certfp) |
1350 | rb_free(yy_server->certfp); | |
ff0cc1e6 AC |
1351 | yy_server->certfp = rb_strdup((char *) data); |
1352 | ||
1353 | /* force SSL to be enabled if fingerprint is enabled. */ | |
1354 | yy_server->flags |= SERVER_SSL; | |
1355 | } | |
1356 | ||
212380e3 AC |
1357 | static void |
1358 | conf_set_connect_port(void *data) | |
1359 | { | |
1360 | int port = *(unsigned int *) data; | |
1361 | ||
1362 | if(port < 1) | |
1363 | port = PORTNUM; | |
1364 | ||
1365 | yy_server->port = port; | |
1366 | } | |
1367 | ||
1368 | static void | |
1369 | conf_set_connect_aftype(void *data) | |
1370 | { | |
1371 | char *aft = data; | |
1372 | ||
1373 | if(strcasecmp(aft, "ipv4") == 0) | |
1374 | yy_server->aftype = AF_INET; | |
ccda6e3f | 1375 | #ifdef RB_IPV6 |
212380e3 AC |
1376 | else if(strcasecmp(aft, "ipv6") == 0) |
1377 | yy_server->aftype = AF_INET6; | |
1378 | #endif | |
1379 | else | |
1380 | conf_report_error("connect::aftype '%s' is unknown.", aft); | |
1381 | } | |
1382 | ||
1383 | static void | |
1384 | conf_set_connect_flags(void *data) | |
1385 | { | |
1386 | conf_parm_t *args = data; | |
1387 | ||
1388 | /* note, we allow them to set compressed, then remove it later if | |
1389 | * they do and LIBZ isnt available | |
1390 | */ | |
1391 | set_modes_from_table(&yy_server->flags, "flag", connect_table, args); | |
1392 | } | |
1393 | ||
1394 | static void | |
1395 | conf_set_connect_hub_mask(void *data) | |
1396 | { | |
1397 | struct remote_conf *yy_hub; | |
1398 | ||
1399 | if(EmptyString(yy_server->name)) | |
1400 | return; | |
1401 | ||
1402 | yy_hub = make_remote_conf(); | |
1403 | yy_hub->flags = CONF_HUB; | |
1404 | ||
47a03750 VY |
1405 | yy_hub->host = rb_strdup(data); |
1406 | yy_hub->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1407 | rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list); |
212380e3 AC |
1408 | } |
1409 | ||
1410 | static void | |
1411 | conf_set_connect_leaf_mask(void *data) | |
1412 | { | |
1413 | struct remote_conf *yy_leaf; | |
1414 | ||
1415 | if(EmptyString(yy_server->name)) | |
1416 | return; | |
1417 | ||
1418 | yy_leaf = make_remote_conf(); | |
1419 | yy_leaf->flags = CONF_LEAF; | |
1420 | ||
47a03750 VY |
1421 | yy_leaf->host = rb_strdup(data); |
1422 | yy_leaf->server = rb_strdup(yy_server->name); | |
330fc5c1 | 1423 | rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list); |
212380e3 AC |
1424 | } |
1425 | ||
1426 | static void | |
1427 | conf_set_connect_class(void *data) | |
1428 | { | |
637c4932 | 1429 | rb_free(yy_server->class_name); |
47a03750 | 1430 | yy_server->class_name = rb_strdup(data); |
212380e3 AC |
1431 | } |
1432 | ||
1433 | static void | |
1434 | conf_set_exempt_ip(void *data) | |
1435 | { | |
1436 | struct ConfItem *yy_tmp; | |
1437 | ||
1438 | if(parse_netmask(data, NULL, NULL) == HM_HOST) | |
1439 | { | |
1440 | conf_report_error("Ignoring exempt -- invalid exempt::ip."); | |
1441 | return; | |
1442 | } | |
1443 | ||
1444 | yy_tmp = make_conf(); | |
47a03750 VY |
1445 | yy_tmp->passwd = rb_strdup("*"); |
1446 | yy_tmp->host = rb_strdup(data); | |
212380e3 | 1447 | yy_tmp->status = CONF_EXEMPTDLINE; |
40c1fd47 | 1448 | add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, NULL, yy_tmp); |
212380e3 AC |
1449 | } |
1450 | ||
1451 | static int | |
1452 | conf_cleanup_cluster(struct TopConf *tc) | |
1453 | { | |
637c4932 | 1454 | rb_dlink_node *ptr, *next_ptr; |
212380e3 | 1455 | |
637c4932 | 1456 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1457 | { |
1458 | free_remote_conf(ptr->data); | |
330fc5c1 | 1459 | rb_dlinkDestroy(ptr, &yy_cluster_list); |
212380e3 AC |
1460 | } |
1461 | ||
1462 | if(yy_shared != NULL) | |
1463 | { | |
1464 | free_remote_conf(yy_shared); | |
1465 | yy_shared = NULL; | |
1466 | } | |
1467 | ||
1468 | return 0; | |
1469 | } | |
1470 | ||
1471 | static void | |
1472 | conf_set_cluster_name(void *data) | |
1473 | { | |
1474 | if(yy_shared != NULL) | |
1475 | free_remote_conf(yy_shared); | |
1476 | ||
1477 | yy_shared = make_remote_conf(); | |
47a03750 | 1478 | yy_shared->server = rb_strdup(data); |
330fc5c1 | 1479 | rb_dlinkAddAlloc(yy_shared, &yy_cluster_list); |
212380e3 AC |
1480 | |
1481 | yy_shared = NULL; | |
1482 | } | |
1483 | ||
1484 | static void | |
1485 | conf_set_cluster_flags(void *data) | |
1486 | { | |
1487 | conf_parm_t *args = data; | |
1488 | int flags = 0; | |
637c4932 | 1489 | rb_dlink_node *ptr, *next_ptr; |
212380e3 AC |
1490 | |
1491 | if(yy_shared != NULL) | |
1492 | free_remote_conf(yy_shared); | |
1493 | ||
1494 | set_modes_from_table(&flags, "flag", cluster_table, args); | |
1495 | ||
637c4932 | 1496 | RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) |
212380e3 AC |
1497 | { |
1498 | yy_shared = ptr->data; | |
1499 | yy_shared->flags = flags; | |
330fc5c1 AC |
1500 | rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list); |
1501 | rb_dlinkDestroy(ptr, &yy_cluster_list); | |
212380e3 AC |
1502 | } |
1503 | ||
1504 | yy_shared = NULL; | |
1505 | } | |
1506 | ||
1507 | static void | |
1508 | conf_set_general_havent_read_conf(void *data) | |
1509 | { | |
1510 | if(*(unsigned int *) data) | |
1511 | { | |
1512 | conf_report_error("You haven't read your config file properly."); | |
1513 | conf_report_error | |
1514 | ("There is a line in the example conf that will kill your server if not removed."); | |
1515 | conf_report_error | |
1516 | ("Consider actually reading/editing the conf file, and removing this line."); | |
1517 | if (!testing_conf) | |
1518 | exit(0); | |
1519 | } | |
1520 | } | |
1521 | ||
1522 | static void | |
1523 | conf_set_general_hide_error_messages(void *data) | |
1524 | { | |
1525 | char *val = data; | |
1526 | ||
1527 | if(strcasecmp(val, "yes") == 0) | |
1528 | ConfigFileEntry.hide_error_messages = 2; | |
1529 | else if(strcasecmp(val, "opers") == 0) | |
1530 | ConfigFileEntry.hide_error_messages = 1; | |
1531 | else if(strcasecmp(val, "no") == 0) | |
1532 | ConfigFileEntry.hide_error_messages = 0; | |
1533 | else | |
1534 | conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val); | |
1535 | } | |
1536 | ||
1537 | static void | |
1538 | conf_set_general_kline_delay(void *data) | |
1539 | { | |
1540 | ConfigFileEntry.kline_delay = *(unsigned int *) data; | |
1541 | ||
1542 | /* THIS MUST BE HERE to stop us being unable to check klines */ | |
1543 | kline_queued = 0; | |
1544 | } | |
1545 | ||
1546 | static void | |
1547 | conf_set_general_stats_k_oper_only(void *data) | |
1548 | { | |
1549 | char *val = data; | |
1550 | ||
1551 | if(strcasecmp(val, "yes") == 0) | |
1552 | ConfigFileEntry.stats_k_oper_only = 2; | |
1553 | else if(strcasecmp(val, "masked") == 0) | |
1554 | ConfigFileEntry.stats_k_oper_only = 1; | |
1555 | else if(strcasecmp(val, "no") == 0) | |
1556 | ConfigFileEntry.stats_k_oper_only = 0; | |
1557 | else | |
1558 | conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val); | |
1559 | } | |
1560 | ||
1561 | static void | |
1562 | conf_set_general_stats_i_oper_only(void *data) | |
1563 | { | |
1564 | char *val = data; | |
1565 | ||
1566 | if(strcasecmp(val, "yes") == 0) | |
1567 | ConfigFileEntry.stats_i_oper_only = 2; | |
1568 | else if(strcasecmp(val, "masked") == 0) | |
1569 | ConfigFileEntry.stats_i_oper_only = 1; | |
1570 | else if(strcasecmp(val, "no") == 0) | |
1571 | ConfigFileEntry.stats_i_oper_only = 0; | |
1572 | else | |
1573 | conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val); | |
1574 | } | |
1575 | ||
1576 | static void | |
1577 | conf_set_general_compression_level(void *data) | |
1578 | { | |
1579 | #ifdef HAVE_LIBZ | |
1580 | ConfigFileEntry.compression_level = *(unsigned int *) data; | |
1581 | ||
1582 | if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9)) | |
1583 | { | |
1584 | conf_report_error | |
1585 | ("Invalid general::compression_level %d -- using default.", | |
1586 | ConfigFileEntry.compression_level); | |
1587 | ConfigFileEntry.compression_level = 0; | |
1588 | } | |
1589 | #else | |
1590 | conf_report_error("Ignoring general::compression_level -- zlib not available."); | |
1591 | #endif | |
1592 | } | |
1593 | ||
1594 | static void | |
1595 | conf_set_general_default_umodes(void *data) | |
1596 | { | |
1597 | char *pm; | |
1598 | int what = MODE_ADD, flag; | |
1599 | ||
1600 | ConfigFileEntry.default_umodes = 0; | |
1601 | for (pm = (char *) data; *pm; pm++) | |
1602 | { | |
1603 | switch (*pm) | |
1604 | { | |
1605 | case '+': | |
1606 | what = MODE_ADD; | |
1607 | break; | |
1608 | case '-': | |
1609 | what = MODE_DEL; | |
1610 | break; | |
1611 | ||
1612 | /* don't allow +o */ | |
1613 | case 'o': | |
1614 | case 'S': | |
5fabe513 | 1615 | case 'Z': |
212380e3 AC |
1616 | case ' ': |
1617 | break; | |
1618 | ||
1619 | default: | |
1620 | if ((flag = user_modes[(unsigned char) *pm])) | |
1621 | { | |
1622 | /* Proper value has probably not yet been set | |
1623 | * so don't check oper_only_umodes -- jilles */ | |
1624 | if (what == MODE_ADD) | |
1625 | ConfigFileEntry.default_umodes |= flag; | |
1626 | else | |
1627 | ConfigFileEntry.default_umodes &= ~flag; | |
1628 | } | |
1629 | break; | |
1630 | } | |
1631 | } | |
1632 | } | |
1633 | ||
1634 | static void | |
1635 | conf_set_general_oper_umodes(void *data) | |
1636 | { | |
1637 | set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data); | |
1638 | } | |
1639 | ||
1640 | static void | |
1641 | conf_set_general_oper_only_umodes(void *data) | |
1642 | { | |
1643 | set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data); | |
1644 | } | |
1645 | ||
1646 | static void | |
1647 | conf_set_general_oper_snomask(void *data) | |
1648 | { | |
1649 | char *pm; | |
1650 | int what = MODE_ADD, flag; | |
1651 | ||
1652 | ConfigFileEntry.oper_snomask = 0; | |
1653 | for (pm = (char *) data; *pm; pm++) | |
1654 | { | |
1655 | switch (*pm) | |
1656 | { | |
1657 | case '+': | |
1658 | what = MODE_ADD; | |
1659 | break; | |
1660 | case '-': | |
1661 | what = MODE_DEL; | |
1662 | break; | |
1663 | ||
1664 | default: | |
1665 | if ((flag = snomask_modes[(unsigned char) *pm])) | |
1666 | { | |
1667 | if (what == MODE_ADD) | |
1668 | ConfigFileEntry.oper_snomask |= flag; | |
1669 | else | |
1670 | ConfigFileEntry.oper_snomask &= ~flag; | |
1671 | } | |
1672 | break; | |
1673 | } | |
1674 | } | |
1675 | } | |
1676 | ||
1677 | static void | |
1678 | conf_set_serverhide_links_delay(void *data) | |
1679 | { | |
1680 | int val = *(unsigned int *) data; | |
1681 | ||
212380e3 AC |
1682 | ConfigServerHide.links_delay = val; |
1683 | } | |
1684 | ||
1685 | static int | |
1686 | conf_begin_service(struct TopConf *tc) | |
1687 | { | |
1688 | struct Client *target_p; | |
330fc5c1 | 1689 | rb_dlink_node *ptr; |
212380e3 | 1690 | |
5cefa1d6 | 1691 | RB_DLINK_FOREACH(ptr, global_serv_list.head) |
212380e3 AC |
1692 | { |
1693 | target_p = ptr->data; | |
1694 | ||
1695 | target_p->flags &= ~FLAGS_SERVICE; | |
1696 | } | |
1697 | ||
1698 | return 0; | |
1699 | } | |
1700 | ||
1701 | static void | |
1702 | conf_set_service_name(void *data) | |
1703 | { | |
1704 | struct Client *target_p; | |
1705 | const char *s; | |
1706 | char *tmp; | |
1707 | int dots = 0; | |
1708 | ||
1709 | for(s = data; *s != '\0'; s++) | |
1710 | { | |
1711 | if(!IsServChar(*s)) | |
1712 | { | |
1713 | conf_report_error("Ignoring service::name " | |
1714 | "-- bogus servername."); | |
1715 | return; | |
1716 | } | |
1717 | else if(*s == '.') | |
1718 | dots++; | |
1719 | } | |
1720 | ||
1721 | if(!dots) | |
1722 | { | |
1723 | conf_report_error("Ignoring service::name -- must contain '.'"); | |
1724 | return; | |
1725 | } | |
1726 | ||
47a03750 | 1727 | tmp = rb_strdup(data); |
330fc5c1 | 1728 | rb_dlinkAddAlloc(tmp, &service_list); |
212380e3 AC |
1729 | |
1730 | if((target_p = find_server(NULL, tmp))) | |
1731 | target_p->flags |= FLAGS_SERVICE; | |
1732 | } | |
1733 | ||
212380e3 AC |
1734 | static int |
1735 | conf_begin_alias(struct TopConf *tc) | |
1736 | { | |
eddc2ab6 | 1737 | yy_alias = rb_malloc(sizeof(struct alias_entry)); |
212380e3 AC |
1738 | |
1739 | if (conf_cur_block_name != NULL) | |
47a03750 | 1740 | yy_alias->name = rb_strdup(conf_cur_block_name); |
212380e3 AC |
1741 | |
1742 | yy_alias->flags = 0; | |
1743 | yy_alias->hits = 0; | |
1744 | ||
1745 | return 0; | |
1746 | } | |
1747 | ||
1748 | static int | |
1749 | conf_end_alias(struct TopConf *tc) | |
1750 | { | |
212380e3 AC |
1751 | if (yy_alias == NULL) |
1752 | return -1; | |
1753 | ||
1754 | if (yy_alias->name == NULL) | |
1755 | { | |
1756 | conf_report_error("Ignoring alias -- must have a name."); | |
1757 | ||
637c4932 | 1758 | rb_free(yy_alias); |
212380e3 AC |
1759 | |
1760 | return -1; | |
1761 | } | |
1762 | ||
1763 | if (yy_alias->target == NULL) | |
1764 | { | |
1765 | conf_report_error("Ignoring alias -- must have a target."); | |
1766 | ||
637c4932 | 1767 | rb_free(yy_alias); |
212380e3 AC |
1768 | |
1769 | return -1; | |
1770 | } | |
1771 | ||
8ac75529 | 1772 | irc_dictionary_add(alias_dict, yy_alias->name, yy_alias); |
212380e3 AC |
1773 | |
1774 | return 0; | |
1775 | } | |
1776 | ||
1777 | static void | |
1778 | conf_set_alias_name(void *data) | |
1779 | { | |
1780 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1781 | return; | |
1782 | ||
47a03750 | 1783 | yy_alias->name = rb_strdup(data); |
212380e3 AC |
1784 | } |
1785 | ||
1786 | static void | |
1787 | conf_set_alias_target(void *data) | |
1788 | { | |
1789 | if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ | |
1790 | return; | |
1791 | ||
47a03750 | 1792 | yy_alias->target = rb_strdup(data); |
212380e3 AC |
1793 | } |
1794 | ||
1795 | static void | |
1796 | conf_set_blacklist_host(void *data) | |
1797 | { | |
47a03750 | 1798 | yy_blacklist_host = rb_strdup(data); |
212380e3 AC |
1799 | } |
1800 | ||
0a1e77c2 EM |
1801 | static void |
1802 | conf_set_blacklist_type(void *data) | |
1803 | { | |
1804 | conf_parm_t *args = data; | |
1805 | ||
1806 | /* Don't assume we have either if we got here */ | |
1807 | yy_blacklist_ipv4 = 0; | |
1808 | yy_blacklist_ipv6 = 0; | |
1809 | ||
1810 | for (; args; args = args->next) | |
1811 | { | |
1812 | if (!strcasecmp(args->v.string, "ipv4")) | |
1813 | yy_blacklist_ipv4 = 1; | |
1814 | else if (!strcasecmp(args->v.string, "ipv6")) | |
1815 | yy_blacklist_ipv6 = 1; | |
1816 | else | |
1817 | conf_report_error("blacklist::type has unknown address family %s", | |
1818 | args->v.string); | |
1819 | } | |
1820 | ||
1821 | /* If we have neither, just default to IPv4 */ | |
1822 | if (!yy_blacklist_ipv4 && !yy_blacklist_ipv6) | |
1823 | { | |
1824 | conf_report_error("blacklist::type has neither IPv4 nor IPv6 (defaulting to IPv4)"); | |
1825 | yy_blacklist_ipv4 = 1; | |
1826 | } | |
1827 | } | |
1828 | ||
212380e3 AC |
1829 | static void |
1830 | conf_set_blacklist_reason(void *data) | |
1831 | { | |
47a03750 | 1832 | yy_blacklist_reason = rb_strdup(data); |
212380e3 AC |
1833 | |
1834 | if (yy_blacklist_host && yy_blacklist_reason) | |
1835 | { | |
0a1e77c2 EM |
1836 | if (yy_blacklist_ipv6) |
1837 | { | |
1838 | /* Make sure things fit (64 = alnum count + dots) */ | |
1839 | if ((64 + strlen(yy_blacklist_host)) > IRCD_RES_HOSTLEN) | |
1840 | { | |
1841 | conf_report_error("blacklist::host %s results in IPv6 queries that are too long", | |
1842 | yy_blacklist_host); | |
1843 | goto cleanup_bl; | |
1844 | } | |
1845 | } | |
1846 | /* Avoid doing redundant check, IPv6 is bigger than IPv4 --Elizabeth */ | |
1847 | if (yy_blacklist_ipv4 && !yy_blacklist_ipv6) | |
1848 | { | |
1849 | /* Make sure things fit (16 = number of nums + dots) */ | |
1850 | if ((16 + strlen(yy_blacklist_host)) > IRCD_RES_HOSTLEN) | |
1851 | { | |
1852 | conf_report_error("blacklist::host %s results in IPv4 queries that are too long", | |
1853 | yy_blacklist_host); | |
1854 | goto cleanup_bl; | |
1855 | } | |
1856 | } | |
1857 | ||
1858 | new_blacklist(yy_blacklist_host, yy_blacklist_reason, yy_blacklist_ipv4, yy_blacklist_ipv6); | |
1859 | ||
1860 | cleanup_bl: | |
637c4932 VY |
1861 | rb_free(yy_blacklist_host); |
1862 | rb_free(yy_blacklist_reason); | |
212380e3 AC |
1863 | yy_blacklist_host = NULL; |
1864 | yy_blacklist_reason = NULL; | |
0a1e77c2 EM |
1865 | yy_blacklist_ipv4 = 1; |
1866 | yy_blacklist_ipv6 = 0; | |
212380e3 AC |
1867 | } |
1868 | } | |
1869 | ||
1870 | /* public functions */ | |
1871 | ||
1872 | ||
1873 | void | |
1874 | conf_report_error(const char *fmt, ...) | |
1875 | { | |
1876 | va_list ap; | |
1877 | char msg[IRCD_BUFSIZE + 1] = { 0 }; | |
1878 | ||
1879 | va_start(ap, fmt); | |
afdc068c | 1880 | rb_vsnprintf(msg, IRCD_BUFSIZE, fmt, ap); |
212380e3 AC |
1881 | va_end(ap); |
1882 | ||
1883 | if (testing_conf) | |
1884 | { | |
1885 | fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg); | |
1886 | return; | |
1887 | } | |
1888 | ||
1889 | ierror("\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
1890 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "\"%s\", line %d: %s", current_file, lineno + 1, msg); | |
1891 | } | |
1892 | ||
1893 | int | |
1894 | conf_start_block(char *block, char *name) | |
1895 | { | |
1896 | if((conf_cur_block = find_top_conf(block)) == NULL) | |
1897 | { | |
1898 | conf_report_error("Configuration block '%s' is not defined.", block); | |
1899 | return -1; | |
1900 | } | |
1901 | ||
1902 | if(name) | |
47a03750 | 1903 | conf_cur_block_name = rb_strdup(name); |
212380e3 AC |
1904 | else |
1905 | conf_cur_block_name = NULL; | |
1906 | ||
1907 | if(conf_cur_block->tc_sfunc) | |
1908 | if(conf_cur_block->tc_sfunc(conf_cur_block) < 0) | |
1909 | return -1; | |
1910 | ||
1911 | return 0; | |
1912 | } | |
1913 | ||
1914 | int | |
1915 | conf_end_block(struct TopConf *tc) | |
1916 | { | |
1917 | if(tc->tc_efunc) | |
1918 | return tc->tc_efunc(tc); | |
1919 | ||
637c4932 | 1920 | rb_free(conf_cur_block_name); |
212380e3 AC |
1921 | return 0; |
1922 | } | |
1923 | ||
1924 | static void | |
1925 | conf_set_generic_int(void *data, void *location) | |
1926 | { | |
1927 | *((int *) location) = *((unsigned int *) data); | |
1928 | } | |
1929 | ||
1930 | static void | |
1931 | conf_set_generic_string(void *data, int len, void *location) | |
1932 | { | |
1933 | char **loc = location; | |
1934 | char *input = data; | |
1935 | ||
2e819b6b | 1936 | if(len && strlen(input) > (unsigned int)len) |
212380e3 AC |
1937 | input[len] = '\0'; |
1938 | ||
637c4932 | 1939 | rb_free(*loc); |
47a03750 | 1940 | *loc = rb_strdup(input); |
212380e3 AC |
1941 | } |
1942 | ||
1943 | int | |
1944 | conf_call_set(struct TopConf *tc, char *item, conf_parm_t * value, int type) | |
1945 | { | |
1946 | struct ConfEntry *cf; | |
1947 | conf_parm_t *cp; | |
1948 | ||
1949 | if(!tc) | |
1950 | return -1; | |
1951 | ||
1952 | if((cf = find_conf_item(tc, item)) == NULL) | |
1953 | { | |
1954 | conf_report_error | |
1955 | ("Non-existant configuration setting %s::%s.", tc->tc_name, (char *) item); | |
1956 | return -1; | |
1957 | } | |
1958 | ||
1959 | /* if it takes one thing, make sure they only passed one thing, | |
1960 | and handle as needed. */ | |
ed45dfe6 | 1961 | if((value->v.list->type & CF_FLIST) && !(cf->cf_type & CF_FLIST)) |
212380e3 AC |
1962 | { |
1963 | conf_report_error | |
1964 | ("Option %s::%s does not take a list of values.", tc->tc_name, item); | |
1965 | return -1; | |
1966 | } | |
1967 | ||
1968 | cp = value->v.list; | |
1969 | ||
1970 | ||
1971 | if(CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type)) | |
1972 | { | |
1973 | /* if it expects a string value, but we got a yesno, | |
1974 | * convert it back | |
1975 | */ | |
1976 | if((CF_TYPE(value->v.list->type) == CF_YESNO) && | |
1977 | (CF_TYPE(cf->cf_type) == CF_STRING)) | |
1978 | { | |
1979 | value->v.list->type = CF_STRING; | |
1980 | ||
1981 | if(cp->v.number == 1) | |
47a03750 | 1982 | cp->v.string = rb_strdup("yes"); |
212380e3 | 1983 | else |
47a03750 | 1984 | cp->v.string = rb_strdup("no"); |
212380e3 AC |
1985 | } |
1986 | ||
1987 | /* maybe it's a CF_TIME and they passed CF_INT -- | |
1988 | should still be valid */ | |
1989 | else if(!((CF_TYPE(value->v.list->type) == CF_INT) && | |
1990 | (CF_TYPE(cf->cf_type) == CF_TIME))) | |
1991 | { | |
1992 | conf_report_error | |
1993 | ("Wrong type for %s::%s (expected %s, got %s)", | |
1994 | tc->tc_name, (char *) item, | |
1995 | conf_strtype(cf->cf_type), conf_strtype(value->v.list->type)); | |
1996 | return -1; | |
1997 | } | |
1998 | } | |
1999 | ||
2000 | if(cf->cf_type & CF_FLIST) | |
2001 | { | |
2002 | #if 0 | |
2003 | if(cf->cf_arg) | |
2004 | conf_set_generic_list(value->v.list, cf->cf_arg); | |
2005 | else | |
2006 | #endif | |
2007 | /* just pass it the extended argument list */ | |
2008 | cf->cf_func(value->v.list); | |
2009 | } | |
2010 | else | |
2011 | { | |
2012 | /* it's old-style, needs only one arg */ | |
2013 | switch (cf->cf_type) | |
2014 | { | |
2015 | case CF_INT: | |
2016 | case CF_TIME: | |
2017 | case CF_YESNO: | |
2018 | if(cf->cf_arg) | |
2019 | conf_set_generic_int(&cp->v.number, cf->cf_arg); | |
2020 | else | |
2021 | cf->cf_func(&cp->v.number); | |
2022 | break; | |
2023 | case CF_STRING: | |
2024 | case CF_QSTRING: | |
2025 | if(EmptyString(cp->v.string)) | |
2026 | conf_report_error("Ignoring %s::%s -- empty field", | |
2027 | tc->tc_name, item); | |
2028 | else if(cf->cf_arg) | |
2029 | conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg); | |
2030 | else | |
2031 | cf->cf_func(cp->v.string); | |
2032 | break; | |
2033 | } | |
2034 | } | |
2035 | ||
2036 | ||
2037 | return 0; | |
2038 | } | |
2039 | ||
2040 | int | |
2041 | add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *)) | |
2042 | { | |
2043 | struct TopConf *tc; | |
2044 | struct ConfEntry *cf; | |
2045 | ||
2046 | if((tc = find_top_conf(topconf)) == NULL) | |
2047 | return -1; | |
2048 | ||
2049 | if((cf = find_conf_item(tc, name)) != NULL) | |
2050 | return -1; | |
2051 | ||
eddc2ab6 | 2052 | cf = rb_malloc(sizeof(struct ConfEntry)); |
212380e3 | 2053 | |
d7f753cd | 2054 | cf->cf_name = name; |
212380e3 AC |
2055 | cf->cf_type = type; |
2056 | cf->cf_func = func; | |
2057 | cf->cf_arg = NULL; | |
2058 | ||
330fc5c1 | 2059 | rb_dlinkAddAlloc(cf, &tc->tc_items); |
212380e3 AC |
2060 | |
2061 | return 0; | |
2062 | } | |
2063 | ||
2064 | int | |
2065 | remove_conf_item(const char *topconf, const char *name) | |
2066 | { | |
2067 | struct TopConf *tc; | |
2068 | struct ConfEntry *cf; | |
330fc5c1 | 2069 | rb_dlink_node *ptr; |
212380e3 AC |
2070 | |
2071 | if((tc = find_top_conf(topconf)) == NULL) | |
2072 | return -1; | |
2073 | ||
2074 | if((cf = find_conf_item(tc, name)) == NULL) | |
2075 | return -1; | |
2076 | ||
330fc5c1 | 2077 | if((ptr = rb_dlinkFind(cf, &tc->tc_items)) == NULL) |
212380e3 AC |
2078 | return -1; |
2079 | ||
330fc5c1 | 2080 | rb_dlinkDestroy(ptr, &tc->tc_items); |
637c4932 | 2081 | rb_free(cf); |
212380e3 AC |
2082 | |
2083 | return 0; | |
2084 | } | |
2085 | ||
2086 | /* *INDENT-OFF* */ | |
2087 | static struct ConfEntry conf_serverinfo_table[] = | |
2088 | { | |
2089 | { "description", CF_QSTRING, NULL, 0, &ServerInfo.description }, | |
2090 | { "network_desc", CF_QSTRING, NULL, 0, &ServerInfo.network_desc }, | |
2091 | { "hub", CF_YESNO, NULL, 0, &ServerInfo.hub }, | |
212380e3 AC |
2092 | |
2093 | { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL }, | |
2094 | { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL }, | |
2095 | { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL }, | |
2096 | { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL }, | |
2097 | { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL }, | |
2098 | ||
8bd5767b JT |
2099 | { "ssl_private_key", CF_QSTRING, NULL, 0, &ServerInfo.ssl_private_key }, |
2100 | { "ssl_ca_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_ca_cert }, | |
2101 | { "ssl_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cert }, | |
2102 | { "ssl_dh_params", CF_QSTRING, NULL, 0, &ServerInfo.ssl_dh_params }, | |
c6d72037 VY |
2103 | { "ssld_count", CF_INT, NULL, 0, &ServerInfo.ssld_count }, |
2104 | ||
101db4c4 | 2105 | { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients }, |
c2d96fcb | 2106 | |
b583faf9 AC |
2107 | { "nicklen", CF_INT, conf_set_serverinfo_nicklen, 0, NULL }, |
2108 | ||
212380e3 AC |
2109 | { "\0", 0, NULL, 0, NULL } |
2110 | }; | |
2111 | ||
2112 | static struct ConfEntry conf_admin_table[] = | |
2113 | { | |
2114 | { "name", CF_QSTRING, NULL, 200, &AdminInfo.name }, | |
2115 | { "description",CF_QSTRING, NULL, 200, &AdminInfo.description }, | |
2116 | { "email", CF_QSTRING, NULL, 200, &AdminInfo.email }, | |
2117 | { "\0", 0, NULL, 0, NULL } | |
2118 | }; | |
2119 | ||
2120 | static struct ConfEntry conf_log_table[] = | |
2121 | { | |
d74fa5b5 JT |
2122 | { "fname_userlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_userlog }, |
2123 | { "fname_fuserlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_fuserlog }, | |
2124 | { "fname_operlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_operlog }, | |
2125 | { "fname_foperlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_foperlog }, | |
2126 | { "fname_serverlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_serverlog }, | |
2127 | { "fname_killlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_killlog }, | |
2128 | { "fname_klinelog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_klinelog }, | |
2129 | { "fname_operspylog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_operspylog }, | |
2130 | { "fname_ioerrorlog", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.fname_ioerrorlog }, | |
212380e3 AC |
2131 | { "\0", 0, NULL, 0, NULL } |
2132 | }; | |
2133 | ||
2134 | static struct ConfEntry conf_operator_table[] = | |
2135 | { | |
2136 | { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL }, | |
2137 | { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL }, | |
2138 | { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL }, | |
22c3b270 | 2139 | { "privset", CF_QSTRING, conf_set_oper_privset, 0, NULL }, |
212380e3 AC |
2140 | { "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL }, |
2141 | { "user", CF_QSTRING, conf_set_oper_user, 0, NULL }, | |
2142 | { "password", CF_QSTRING, conf_set_oper_password, 0, NULL }, | |
ff31db84 | 2143 | { "fingerprint", CF_QSTRING, conf_set_oper_fingerprint, 0, NULL }, |
212380e3 AC |
2144 | { "\0", 0, NULL, 0, NULL } |
2145 | }; | |
2146 | ||
f8606875 AC |
2147 | static struct ConfEntry conf_privset_table[] = |
2148 | { | |
2149 | { "extends", CF_QSTRING, conf_set_privset_extends, 0, NULL }, | |
2150 | { "privs", CF_STRING | CF_FLIST, conf_set_privset_privs, 0, NULL }, | |
2151 | { "\0", 0, NULL, 0, NULL } | |
2152 | }; | |
2153 | ||
212380e3 AC |
2154 | static struct ConfEntry conf_class_table[] = |
2155 | { | |
2156 | { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL }, | |
e33e589c JT |
2157 | { "cidr_ipv4_bitlen", CF_INT, conf_set_class_cidr_ipv4_bitlen, 0, NULL }, |
2158 | #ifdef RB_IPV6 | |
2159 | { "cidr_ipv6_bitlen", CF_INT, conf_set_class_cidr_ipv6_bitlen, 0, NULL }, | |
2160 | #endif | |
212380e3 AC |
2161 | { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL }, |
2162 | { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL }, | |
2163 | { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL }, | |
2164 | { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL }, | |
2165 | { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL }, | |
2166 | { "max_number", CF_INT, conf_set_class_max_number, 0, NULL }, | |
2167 | { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL }, | |
2168 | { "\0", 0, NULL, 0, NULL } | |
2169 | }; | |
2170 | ||
2171 | static struct ConfEntry conf_auth_table[] = | |
2172 | { | |
2173 | { "user", CF_QSTRING, conf_set_auth_user, 0, NULL }, | |
40c1fd47 | 2174 | { "auth_user", CF_QSTRING, conf_set_auth_auth_user, 0, NULL }, |
212380e3 AC |
2175 | { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL }, |
2176 | { "class", CF_QSTRING, conf_set_auth_class, 0, NULL }, | |
2177 | { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL }, | |
2178 | { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL }, | |
2179 | { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL }, | |
2180 | { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL }, | |
2181 | { "\0", 0, NULL, 0, NULL } | |
2182 | }; | |
2183 | ||
2184 | static struct ConfEntry conf_connect_table[] = | |
2185 | { | |
2186 | { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL }, | |
2187 | { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL }, | |
ff0cc1e6 | 2188 | { "fingerprint", CF_QSTRING, conf_set_connect_fingerprint, 0, NULL }, |
212380e3 AC |
2189 | { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL }, |
2190 | { "host", CF_QSTRING, conf_set_connect_host, 0, NULL }, | |
2191 | { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL }, | |
2192 | { "port", CF_INT, conf_set_connect_port, 0, NULL }, | |
2193 | { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL }, | |
2194 | { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL }, | |
2195 | { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL }, | |
2196 | { "class", CF_QSTRING, conf_set_connect_class, 0, NULL }, | |
2197 | { "\0", 0, NULL, 0, NULL } | |
2198 | }; | |
2199 | ||
2200 | static struct ConfEntry conf_general_table[] = | |
2201 | { | |
2202 | { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL }, | |
2203 | { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL }, | |
2204 | { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL }, | |
2205 | { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL }, | |
2206 | { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL }, | |
2207 | { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL }, | |
2208 | { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL }, | |
2209 | { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL }, | |
2210 | { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL }, | |
2211 | { "default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL }, | |
2212 | ||
2213 | { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring }, | |
2214 | { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring }, | |
2215 | { "servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring }, | |
d74fa5b5 | 2216 | { "egdpool_path", CF_QSTRING, NULL, PATH_MAX, &ConfigFileEntry.egdpool_path }, |
212380e3 AC |
2217 | { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason }, |
2218 | { "identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice }, | |
2219 | { "identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand }, | |
212380e3 AC |
2220 | |
2221 | { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time }, | |
2222 | { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels }, | |
2223 | { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple }, | |
2224 | { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines }, | |
2225 | { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices }, | |
2226 | ||
2227 | { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood }, | |
2228 | { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away }, | |
2229 | { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait }, | |
2230 | { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit }, | |
212380e3 AC |
2231 | { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc }, |
2232 | { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout }, | |
2233 | { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount }, | |
944b0584 | 2234 | { "default_ident_timeout", CF_INT, NULL, 0, &ConfigFileEntry.default_ident_timeout }, |
212380e3 | 2235 | { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth }, |
212380e3 AC |
2236 | { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident }, |
2237 | { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice }, | |
212380e3 | 2238 | { "global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices }, |
212380e3 AC |
2239 | { "hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips }, |
2240 | { "dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason }, | |
2241 | { "kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason }, | |
2242 | { "map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only }, | |
2243 | { "max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept }, | |
2244 | { "max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor }, | |
2245 | { "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time }, | |
2246 | { "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes }, | |
2247 | { "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets }, | |
2248 | { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard }, | |
2249 | { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay }, | |
2250 | { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood }, | |
2251 | { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only }, | |
2252 | { "operspy_dont_care_user_info", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_dont_care_user_info }, | |
2253 | { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait }, | |
2254 | { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple }, | |
2255 | { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie }, | |
2256 | { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count }, | |
2257 | { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time }, | |
2258 | { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration }, | |
43946961 JT |
2259 | { "throttle_count", CF_INT, NULL, 0, &ConfigFileEntry.throttle_count }, |
2260 | { "throttle_duration", CF_TIME, NULL, 0, &ConfigFileEntry.throttle_duration }, | |
212380e3 AC |
2261 | { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd }, |
2262 | { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only }, | |
2263 | { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled }, | |
2264 | { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only }, | |
2265 | { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only }, | |
2266 | { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only }, | |
2267 | { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only }, | |
2268 | { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change }, | |
2269 | { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta }, | |
2270 | { "use_egd", CF_YESNO, NULL, 0, &ConfigFileEntry.use_egd }, | |
2271 | { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta }, | |
2272 | { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually }, | |
2273 | { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline }, | |
1702b694 | 2274 | { "use_propagated_bans",CF_YESNO, NULL, 0, &ConfigFileEntry.use_propagated_bans }, |
e6e54763 SB |
2275 | { "client_flood_max_lines", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_max_lines }, |
2276 | { "client_flood_burst_rate", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_burst_rate }, | |
2277 | { "client_flood_burst_max", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_burst_max }, | |
2278 | { "client_flood_message_num", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_message_num }, | |
2279 | { "client_flood_message_time", CF_INT, NULL, 0, &ConfigFileEntry.client_flood_message_time }, | |
e88a1f1b | 2280 | { "max_ratelimit_tokens", CF_INT, NULL, 0, &ConfigFileEntry.max_ratelimit_tokens }, |
212380e3 AC |
2281 | { "\0", 0, NULL, 0, NULL } |
2282 | }; | |
2283 | ||
2284 | static struct ConfEntry conf_channel_table[] = | |
2285 | { | |
2286 | { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count }, | |
2287 | { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count }, | |
2288 | { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho }, | |
212380e3 AC |
2289 | { "kick_on_split_riding", CF_YESNO, NULL, 0, &ConfigChannel.kick_on_split_riding }, |
2290 | { "knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay }, | |
2291 | { "knock_delay_channel",CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel }, | |
2292 | { "max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans }, | |
2293 | { "max_bans_large", CF_INT, NULL, 0, &ConfigChannel.max_bans_large }, | |
2294 | { "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user }, | |
2295 | { "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split }, | |
2296 | { "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split }, | |
6865c0b0 | 2297 | { "only_ascii_channels", CF_YESNO, NULL, 0, &ConfigChannel.only_ascii_channels }, |
212380e3 AC |
2298 | { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except }, |
2299 | { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex }, | |
2da6f6eb | 2300 | { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward }, |
212380e3 | 2301 | { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock }, |
c2c25552 | 2302 | { "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart }, |
717238d2 | 2303 | { "channel_target_change", CF_YESNO, NULL, 0, &ConfigChannel.channel_target_change }, |
341f971e | 2304 | { "disable_local_channels", CF_YESNO, NULL, 0, &ConfigChannel.disable_local_channels }, |
212380e3 AC |
2305 | { "\0", 0, NULL, 0, NULL } |
2306 | }; | |
2307 | ||
2308 | static struct ConfEntry conf_serverhide_table[] = | |
2309 | { | |
2310 | { "disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden }, | |
2311 | { "flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links }, | |
2312 | { "hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden }, | |
2313 | { "links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL }, | |
2314 | { "\0", 0, NULL, 0, NULL } | |
2315 | }; | |
2316 | /* *INDENT-ON* */ | |
2317 | ||
2318 | void | |
2319 | newconf_init() | |
2320 | { | |
2321 | add_top_conf("modules", NULL, NULL, NULL); | |
2322 | add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path); | |
2323 | add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module); | |
2324 | ||
2325 | add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table); | |
2326 | add_top_conf("admin", NULL, NULL, conf_admin_table); | |
2327 | add_top_conf("log", NULL, NULL, conf_log_table); | |
2328 | add_top_conf("operator", conf_begin_oper, conf_end_oper, conf_operator_table); | |
2329 | add_top_conf("class", conf_begin_class, conf_end_class, conf_class_table); | |
f8606875 | 2330 | add_top_conf("privset", NULL, NULL, conf_privset_table); |
212380e3 AC |
2331 | |
2332 | add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL); | |
2333 | add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port); | |
c6d72037 | 2334 | add_conf_item("listen", "sslport", CF_INT | CF_FLIST, conf_set_listen_sslport); |
212380e3 AC |
2335 | add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address); |
2336 | add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address); | |
2337 | ||
2338 | add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table); | |
2339 | ||
2340 | add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL); | |
2341 | add_conf_item("shared", "oper", CF_QSTRING|CF_FLIST, conf_set_shared_oper); | |
2342 | add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags); | |
2343 | ||
2344 | add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table); | |
2345 | ||
2346 | add_top_conf("exempt", NULL, NULL, NULL); | |
2347 | add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip); | |
2348 | ||
2349 | add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL); | |
2350 | add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name); | |
2351 | add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags); | |
2352 | ||
2353 | add_top_conf("general", NULL, NULL, conf_general_table); | |
2354 | add_top_conf("channel", NULL, NULL, conf_channel_table); | |
2355 | add_top_conf("serverhide", NULL, NULL, conf_serverhide_table); | |
2356 | ||
2357 | add_top_conf("service", conf_begin_service, NULL, NULL); | |
2358 | add_conf_item("service", "name", CF_QSTRING, conf_set_service_name); | |
2359 | ||
2360 | add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL); | |
2361 | add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name); | |
2362 | add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target); | |
2363 | ||
2364 | add_top_conf("blacklist", NULL, NULL, NULL); | |
2365 | add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host); | |
0a1e77c2 | 2366 | add_conf_item("blacklist", "type", CF_STRING | CF_FLIST, conf_set_blacklist_type); |
212380e3 AC |
2367 | add_conf_item("blacklist", "reject_reason", CF_QSTRING, conf_set_blacklist_reason); |
2368 | } |