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