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