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