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