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