]> jfr.im git - irc/rqf/shadowircd.git/blob - src/newconf.c
Removal of ancient SVN ID's part one
[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 #endif
630
631 /* all is ok, put it on oper_conf_list */
632 rb_dlinkMoveNode(ptr, &yy_oper_list, &oper_conf_list);
633 }
634
635 free_oper_conf(yy_oper);
636 yy_oper = NULL;
637
638 return 0;
639 }
640
641 static void
642 conf_set_oper_flags(void *data)
643 {
644 conf_parm_t *args = data;
645
646 set_modes_from_table(&yy_oper->flags, "flag", oper_table, args);
647 }
648
649 static void
650 conf_set_oper_fingerprint(void *data)
651 {
652 yy_oper->certfp = rb_strdup((char *) data);
653 }
654
655 static void
656 conf_set_oper_privset(void *data)
657 {
658 yy_oper->privset = privilegeset_get((char *) data);
659 }
660
661 static void
662 conf_set_oper_user(void *data)
663 {
664 struct oper_conf *yy_tmpoper;
665 char *p;
666 char *host = (char *) data;
667
668 yy_tmpoper = make_oper_conf();
669
670 if((p = strchr(host, '@')))
671 {
672 *p++ = '\0';
673
674 yy_tmpoper->username = rb_strdup(host);
675 yy_tmpoper->host = rb_strdup(p);
676 }
677 else
678 {
679
680 yy_tmpoper->username = rb_strdup("*");
681 yy_tmpoper->host = rb_strdup(host);
682 }
683
684 if(EmptyString(yy_tmpoper->username) || EmptyString(yy_tmpoper->host))
685 {
686 conf_report_error("Ignoring user -- missing username/host");
687 free_oper_conf(yy_tmpoper);
688 return;
689 }
690
691 rb_dlinkAddAlloc(yy_tmpoper, &yy_oper_list);
692 }
693
694 static void
695 conf_set_oper_password(void *data)
696 {
697 if(yy_oper->passwd)
698 {
699 memset(yy_oper->passwd, 0, strlen(yy_oper->passwd));
700 rb_free(yy_oper->passwd);
701 }
702
703 yy_oper->passwd = rb_strdup((char *) data);
704 }
705
706 static void
707 conf_set_oper_rsa_public_key_file(void *data)
708 {
709 #ifdef HAVE_LIBCRYPTO
710 rb_free(yy_oper->rsa_pubkey_file);
711 yy_oper->rsa_pubkey_file = rb_strdup((char *) data);
712 #else
713 conf_report_error("Warning -- ignoring rsa_public_key_file (OpenSSL support not available");
714 #endif
715 }
716
717 static void
718 conf_set_oper_umodes(void *data)
719 {
720 set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data);
721 }
722
723 static void
724 conf_set_oper_snomask(void *data)
725 {
726 yy_oper->snomask = parse_snobuf_to_mask(0, (const char *) data);
727 }
728
729 static void
730 conf_set_oper_vhost(void *data)
731 {
732 yy_oper->vhost = rb_strdup((char *) data);
733 }
734
735 static void
736 conf_set_oper_swhois(void *data)
737 {
738 yy_oper->swhois = rb_strdup((char *) data);
739 }
740
741 static void
742 conf_set_oper_operstring(void *data)
743 {
744 yy_oper->operstring = rb_strdup((char *) data);
745 }
746
747 static int
748 conf_begin_class(struct TopConf *tc)
749 {
750 if(yy_class)
751 free_class(yy_class);
752
753 yy_class = make_class();
754 return 0;
755 }
756
757 static int
758 conf_end_class(struct TopConf *tc)
759 {
760 if(conf_cur_block_name != NULL)
761 yy_class->class_name = rb_strdup(conf_cur_block_name);
762
763 if(EmptyString(yy_class->class_name))
764 {
765 conf_report_error("Ignoring connect block -- missing name.");
766 return 0;
767 }
768
769 add_class(yy_class);
770 yy_class = NULL;
771 return 0;
772 }
773
774 static void
775 conf_set_class_ping_time(void *data)
776 {
777 yy_class->ping_freq = *(unsigned int *) data;
778 }
779
780 static void
781 conf_set_class_cidr_ipv4_bitlen(void *data)
782 {
783 unsigned int maxsize = 32;
784 if(*(unsigned int *) data > maxsize)
785 conf_report_error
786 ("class::cidr_ipv4_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
787 *(unsigned int *) data, maxsize);
788 else
789 yy_class->cidr_ipv4_bitlen = *(unsigned int *) data;
790
791 }
792
793 #ifdef RB_IPV6
794 static void
795 conf_set_class_cidr_ipv6_bitlen(void *data)
796 {
797 unsigned int maxsize = 128;
798 if(*(unsigned int *) data > maxsize)
799 conf_report_error
800 ("class::cidr_ipv6_bitlen argument exceeds maxsize (%d > %d) - ignoring.",
801 *(unsigned int *) data, maxsize);
802 else
803 yy_class->cidr_ipv6_bitlen = *(unsigned int *) data;
804
805 }
806 #endif
807
808 static void
809 conf_set_class_number_per_cidr(void *data)
810 {
811 yy_class->cidr_amount = *(unsigned int *) data;
812 }
813
814 static void
815 conf_set_class_number_per_ip(void *data)
816 {
817 yy_class->max_local = *(unsigned int *) data;
818 }
819
820
821 static void
822 conf_set_class_number_per_ip_global(void *data)
823 {
824 yy_class->max_global = *(unsigned int *) data;
825 }
826
827 static void
828 conf_set_class_number_per_ident(void *data)
829 {
830 yy_class->max_ident = *(unsigned int *) data;
831 }
832
833 static void
834 conf_set_class_connectfreq(void *data)
835 {
836 yy_class->con_freq = *(unsigned int *) data;
837 }
838
839 static void
840 conf_set_class_max_number(void *data)
841 {
842 yy_class->max_total = *(unsigned int *) data;
843 }
844
845 static void
846 conf_set_class_sendq(void *data)
847 {
848 yy_class->max_sendq = *(unsigned int *) data;
849 }
850
851 static char *listener_address;
852
853 static int
854 conf_begin_listen(struct TopConf *tc)
855 {
856 rb_free(listener_address);
857 listener_address = NULL;
858 return 0;
859 }
860
861 static int
862 conf_end_listen(struct TopConf *tc)
863 {
864 rb_free(listener_address);
865 listener_address = NULL;
866 return 0;
867 }
868
869
870
871 static void
872 conf_set_listen_port_both(void *data, int ssl)
873 {
874 conf_parm_t *args = data;
875 for (; args; args = args->next)
876 {
877 if((args->type & CF_MTYPE) != CF_INT)
878 {
879 conf_report_error
880 ("listener::port argument is not an integer " "-- ignoring.");
881 continue;
882 }
883 if(listener_address == NULL)
884 {
885 add_listener(args->v.number, listener_address, AF_INET, ssl);
886 #ifdef RB_IPV6
887 add_listener(args->v.number, listener_address, AF_INET6, ssl);
888 #endif
889 }
890 else
891 {
892 int family;
893 #ifdef RB_IPV6
894 if(strchr(listener_address, ':') != NULL)
895 family = AF_INET6;
896 else
897 #endif
898 family = AF_INET;
899
900 add_listener(args->v.number, listener_address, family, ssl);
901
902 }
903
904 }
905 }
906
907 static void
908 conf_set_listen_port(void *data)
909 {
910 conf_set_listen_port_both(data, 0);
911 }
912
913 static void
914 conf_set_listen_sslport(void *data)
915 {
916 conf_set_listen_port_both(data, 1);
917 }
918
919 static void
920 conf_set_listen_address(void *data)
921 {
922 rb_free(listener_address);
923 listener_address = rb_strdup(data);
924 }
925
926 static int
927 conf_begin_auth(struct TopConf *tc)
928 {
929 rb_dlink_node *ptr;
930 rb_dlink_node *next_ptr;
931
932 if(yy_aconf)
933 free_conf(yy_aconf);
934
935 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head)
936 {
937 free_conf(ptr->data);
938 rb_dlinkDestroy(ptr, &yy_aconf_list);
939 }
940
941 yy_aconf = make_conf();
942 yy_aconf->status = CONF_CLIENT;
943
944 return 0;
945 }
946
947 static int
948 conf_end_auth(struct TopConf *tc)
949 {
950 struct ConfItem *yy_tmp, *found_conf;
951 rb_dlink_node *ptr;
952 rb_dlink_node *next_ptr;
953
954 if(EmptyString(yy_aconf->info.name))
955 yy_aconf->info.name = rb_strdup("NOMATCH");
956
957 /* didnt even get one ->host? */
958 if(EmptyString(yy_aconf->host))
959 {
960 conf_report_error("Ignoring auth block -- missing user@host");
961 return 0;
962 }
963
964 /* so the stacking works in order.. */
965 collapse(yy_aconf->user);
966 collapse(yy_aconf->host);
967 conf_add_class_to_conf(yy_aconf);
968 if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL)
969 conf_report_error("Ignoring redundant auth block (after *@*)");
970 else if ((found_conf = find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) &&
971 (!found_conf->spasswd || (yy_aconf->spasswd &&
972 0 == irccmp(found_conf->spasswd, yy_aconf->spasswd))))
973 conf_report_error("Ignoring duplicate auth block for %s@%s",
974 yy_aconf->user, yy_aconf->host);
975 else
976 add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf->spasswd, yy_aconf);
977
978 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head)
979 {
980 yy_tmp = ptr->data;
981
982 if(yy_aconf->passwd)
983 yy_tmp->passwd = rb_strdup(yy_aconf->passwd);
984
985 if(yy_aconf->spasswd)
986 yy_tmp->spasswd = rb_strdup(yy_aconf->spasswd);
987
988 /* this will always exist.. */
989 yy_tmp->info.name = rb_strdup(yy_aconf->info.name);
990
991 if(yy_aconf->className)
992 yy_tmp->className = rb_strdup(yy_aconf->className);
993
994 yy_tmp->flags = yy_aconf->flags;
995 yy_tmp->port = yy_aconf->port;
996
997 collapse(yy_tmp->user);
998 collapse(yy_tmp->host);
999
1000 conf_add_class_to_conf(yy_tmp);
1001
1002 if (find_exact_conf_by_address("*", CONF_CLIENT, "*"))
1003 conf_report_error("Ignoring redundant auth block (after *@*)");
1004 else if (find_exact_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user))
1005 conf_report_error("Ignoring duplicate auth block for %s@%s",
1006 yy_tmp->user, yy_tmp->host);
1007 else
1008 add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp->spasswd, yy_tmp);
1009 rb_dlinkDestroy(ptr, &yy_aconf_list);
1010 }
1011
1012 yy_aconf = NULL;
1013 return 0;
1014 }
1015
1016 static void
1017 conf_set_auth_user(void *data)
1018 {
1019 struct ConfItem *yy_tmp;
1020 char *p;
1021
1022 /* The first user= line doesn't allocate a new conf */
1023 if(!EmptyString(yy_aconf->host))
1024 {
1025 yy_tmp = make_conf();
1026 yy_tmp->status = CONF_CLIENT;
1027 }
1028 else
1029 yy_tmp = yy_aconf;
1030
1031 if((p = strchr(data, '@')))
1032 {
1033 *p++ = '\0';
1034
1035 yy_tmp->user = rb_strdup(data);
1036 yy_tmp->host = rb_strdup(p);
1037 }
1038 else
1039 {
1040 yy_tmp->user = rb_strdup("*");
1041 yy_tmp->host = rb_strdup(data);
1042 }
1043
1044 if(yy_aconf != yy_tmp)
1045 rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list);
1046 }
1047
1048 static void
1049 conf_set_auth_auth_user(void *data)
1050 {
1051 if(yy_aconf->spasswd)
1052 memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
1053 rb_free(yy_aconf->spasswd);
1054 yy_aconf->spasswd = rb_strdup(data);
1055 }
1056
1057 static void
1058 conf_set_auth_passwd(void *data)
1059 {
1060 if(yy_aconf->passwd)
1061 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1062 rb_free(yy_aconf->passwd);
1063 yy_aconf->passwd = rb_strdup(data);
1064 }
1065
1066 static void
1067 conf_set_auth_autojoin(void *data)
1068 {
1069 if(yy_aconf->autojoin)
1070 memset(yy_aconf->autojoin, 0, strlen(yy_aconf->autojoin));
1071 rb_free(yy_aconf->autojoin);
1072 yy_aconf->autojoin = rb_strdup(data);
1073 }
1074
1075 static void
1076 conf_set_auth_autojoin_opers(void *data)
1077 {
1078 if(yy_aconf->autojoin_opers)
1079 memset(yy_aconf->autojoin_opers, 0, strlen(yy_aconf->autojoin_opers));
1080 rb_free(yy_aconf->autojoin_opers);
1081 yy_aconf->autojoin_opers = rb_strdup(data);
1082 }
1083
1084 static void
1085 conf_set_auth_spoof(void *data)
1086 {
1087 char *p;
1088 char *user = NULL;
1089 char *host = NULL;
1090
1091 host = data;
1092
1093 /* user@host spoof */
1094 if((p = strchr(host, '@')) != NULL)
1095 {
1096 *p = '\0';
1097 user = data;
1098 host = p+1;
1099
1100 if(EmptyString(user))
1101 {
1102 conf_report_error("Warning -- spoof ident empty.");
1103 return;
1104 }
1105
1106 if(strlen(user) > USERLEN)
1107 {
1108 conf_report_error("Warning -- spoof ident length invalid.");
1109 return;
1110 }
1111
1112 if(!valid_username(user))
1113 {
1114 conf_report_error("Warning -- invalid spoof (ident).");
1115 return;
1116 }
1117
1118 /* this must be restored! */
1119 *p = '@';
1120 }
1121
1122 if(EmptyString(host))
1123 {
1124 conf_report_error("Warning -- spoof host empty.");
1125 return;
1126 }
1127
1128 if(strlen(host) > HOSTLEN)
1129 {
1130 conf_report_error("Warning -- spoof host length invalid.");
1131 return;
1132 }
1133
1134 if(!valid_hostname(host))
1135 {
1136 conf_report_error("Warning -- invalid spoof (host).");
1137 return;
1138 }
1139
1140 rb_free(yy_aconf->info.name);
1141 yy_aconf->info.name = rb_strdup(data);
1142 yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
1143 }
1144
1145 static void
1146 conf_set_auth_flags(void *data)
1147 {
1148 conf_parm_t *args = data;
1149
1150 set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args);
1151 }
1152
1153 static void
1154 conf_set_auth_redir_serv(void *data)
1155 {
1156 yy_aconf->flags |= CONF_FLAGS_REDIR;
1157 rb_free(yy_aconf->info.name);
1158 yy_aconf->info.name = rb_strdup(data);
1159 }
1160
1161 static void
1162 conf_set_auth_redir_port(void *data)
1163 {
1164 int port = *(unsigned int *) data;
1165
1166 yy_aconf->flags |= CONF_FLAGS_REDIR;
1167 yy_aconf->port = port;
1168 }
1169
1170 static void
1171 conf_set_auth_class(void *data)
1172 {
1173 rb_free(yy_aconf->className);
1174 yy_aconf->className = rb_strdup(data);
1175 }
1176
1177 /* ok, shared_oper handles the stacking, shared_flags handles adding
1178 * things.. so all we need to do when we start and end a shared block, is
1179 * clean up anything thats been left over.
1180 */
1181 static int
1182 conf_cleanup_shared(struct TopConf *tc)
1183 {
1184 rb_dlink_node *ptr, *next_ptr;
1185
1186 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
1187 {
1188 free_remote_conf(ptr->data);
1189 rb_dlinkDestroy(ptr, &yy_shared_list);
1190 }
1191
1192 if(yy_shared != NULL)
1193 {
1194 free_remote_conf(yy_shared);
1195 yy_shared = NULL;
1196 }
1197
1198 return 0;
1199 }
1200
1201 static void
1202 conf_set_shared_oper(void *data)
1203 {
1204 conf_parm_t *args = data;
1205 const char *username;
1206 char *p;
1207
1208 if(yy_shared != NULL)
1209 free_remote_conf(yy_shared);
1210
1211 yy_shared = make_remote_conf();
1212
1213 if(args->next != NULL)
1214 {
1215 if((args->type & CF_MTYPE) != CF_QSTRING)
1216 {
1217 conf_report_error("Ignoring shared::oper -- server is not a qstring");
1218 return;
1219 }
1220
1221 yy_shared->server = rb_strdup(args->v.string);
1222 args = args->next;
1223 }
1224 else
1225 yy_shared->server = rb_strdup("*");
1226
1227 if((args->type & CF_MTYPE) != CF_QSTRING)
1228 {
1229 conf_report_error("Ignoring shared::oper -- oper is not a qstring");
1230 return;
1231 }
1232
1233 if((p = strchr(args->v.string, '@')) == NULL)
1234 {
1235 conf_report_error("Ignoring shared::oper -- oper is not a user@host");
1236 return;
1237 }
1238
1239 username = args->v.string;
1240 *p++ = '\0';
1241
1242 if(EmptyString(p))
1243 yy_shared->host = rb_strdup("*");
1244 else
1245 yy_shared->host = rb_strdup(p);
1246
1247 if(EmptyString(username))
1248 yy_shared->username = rb_strdup("*");
1249 else
1250 yy_shared->username = rb_strdup(username);
1251
1252 rb_dlinkAddAlloc(yy_shared, &yy_shared_list);
1253 yy_shared = NULL;
1254 }
1255
1256 static void
1257 conf_set_shared_flags(void *data)
1258 {
1259 conf_parm_t *args = data;
1260 int flags = 0;
1261 rb_dlink_node *ptr, *next_ptr;
1262
1263 if(yy_shared != NULL)
1264 free_remote_conf(yy_shared);
1265
1266 set_modes_from_table(&flags, "flag", shared_table, args);
1267
1268 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
1269 {
1270 yy_shared = ptr->data;
1271
1272 yy_shared->flags = flags;
1273 rb_dlinkDestroy(ptr, &yy_shared_list);
1274 rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list);
1275 }
1276
1277 yy_shared = NULL;
1278 }
1279
1280 static int
1281 conf_begin_connect(struct TopConf *tc)
1282 {
1283 if(yy_server)
1284 free_server_conf(yy_server);
1285
1286 yy_server = make_server_conf();
1287 yy_server->port = PORTNUM;
1288 yy_server->flags |= SERVER_TB;
1289
1290 if(conf_cur_block_name != NULL)
1291 yy_server->name = rb_strdup(conf_cur_block_name);
1292
1293 return 0;
1294 }
1295
1296 static int
1297 conf_end_connect(struct TopConf *tc)
1298 {
1299 if(EmptyString(yy_server->name))
1300 {
1301 conf_report_error("Ignoring connect block -- missing name.");
1302 return 0;
1303 }
1304
1305 if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name))
1306 {
1307 conf_report_error("Ignoring connect block for %s -- name is equal to my own name.",
1308 yy_server->name);
1309 return 0;
1310 }
1311
1312 if(EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd))
1313 {
1314 conf_report_error("Ignoring connect block for %s -- missing password.",
1315 yy_server->name);
1316 return 0;
1317 }
1318
1319 if(EmptyString(yy_server->host))
1320 {
1321 conf_report_error("Ignoring connect block for %s -- missing host.",
1322 yy_server->name);
1323 return 0;
1324 }
1325
1326 #ifndef HAVE_LIBZ
1327 if(ServerConfCompressed(yy_server))
1328 {
1329 conf_report_error("Ignoring connect::flags::compressed -- zlib not available.");
1330 yy_server->flags &= ~SERVER_COMPRESSED;
1331 }
1332 #endif
1333
1334 add_server_conf(yy_server);
1335 rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list);
1336
1337 yy_server = NULL;
1338 return 0;
1339 }
1340
1341 static void
1342 conf_set_connect_host(void *data)
1343 {
1344 rb_free(yy_server->host);
1345 yy_server->host = rb_strdup(data);
1346 if (strchr(yy_server->host, ':'))
1347 yy_server->aftype = AF_INET6;
1348 }
1349
1350 static void
1351 conf_set_connect_vhost(void *data)
1352 {
1353 if(rb_inet_pton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0)
1354 {
1355 conf_report_error("Invalid netmask for server vhost (%s)",
1356 (char *) data);
1357 return;
1358 }
1359
1360 yy_server->flags |= SERVER_VHOSTED;
1361 }
1362
1363 static void
1364 conf_set_connect_send_password(void *data)
1365 {
1366 if(yy_server->spasswd)
1367 {
1368 memset(yy_server->spasswd, 0, strlen(yy_server->spasswd));
1369 rb_free(yy_server->spasswd);
1370 }
1371
1372 yy_server->spasswd = rb_strdup(data);
1373 }
1374
1375 static void
1376 conf_set_connect_accept_password(void *data)
1377 {
1378 if(yy_server->passwd)
1379 {
1380 memset(yy_server->passwd, 0, strlen(yy_server->passwd));
1381 rb_free(yy_server->passwd);
1382 }
1383 yy_server->passwd = rb_strdup(data);
1384 }
1385
1386 static void
1387 conf_set_connect_port(void *data)
1388 {
1389 int port = *(unsigned int *) data;
1390
1391 if(port < 1)
1392 port = PORTNUM;
1393
1394 yy_server->port = port;
1395 }
1396
1397 static void
1398 conf_set_connect_aftype(void *data)
1399 {
1400 char *aft = data;
1401
1402 if(strcasecmp(aft, "ipv4") == 0)
1403 yy_server->aftype = AF_INET;
1404 #ifdef RB_IPV6
1405 else if(strcasecmp(aft, "ipv6") == 0)
1406 yy_server->aftype = AF_INET6;
1407 #endif
1408 else
1409 conf_report_error("connect::aftype '%s' is unknown.", aft);
1410 }
1411
1412 static void
1413 conf_set_connect_flags(void *data)
1414 {
1415 conf_parm_t *args = data;
1416
1417 /* note, we allow them to set compressed, then remove it later if
1418 * they do and LIBZ isnt available
1419 */
1420 set_modes_from_table(&yy_server->flags, "flag", connect_table, args);
1421 }
1422
1423 static void
1424 conf_set_connect_hub_mask(void *data)
1425 {
1426 struct remote_conf *yy_hub;
1427
1428 if(EmptyString(yy_server->name))
1429 return;
1430
1431 yy_hub = make_remote_conf();
1432 yy_hub->flags = CONF_HUB;
1433
1434 yy_hub->host = rb_strdup(data);
1435 yy_hub->server = rb_strdup(yy_server->name);
1436 rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list);
1437 }
1438
1439 static void
1440 conf_set_connect_leaf_mask(void *data)
1441 {
1442 struct remote_conf *yy_leaf;
1443
1444 if(EmptyString(yy_server->name))
1445 return;
1446
1447 yy_leaf = make_remote_conf();
1448 yy_leaf->flags = CONF_LEAF;
1449
1450 yy_leaf->host = rb_strdup(data);
1451 yy_leaf->server = rb_strdup(yy_server->name);
1452 rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list);
1453 }
1454
1455 static void
1456 conf_set_connect_class(void *data)
1457 {
1458 rb_free(yy_server->class_name);
1459 yy_server->class_name = rb_strdup(data);
1460 }
1461
1462 static void
1463 conf_set_exempt_ip(void *data)
1464 {
1465 struct ConfItem *yy_tmp;
1466
1467 if(parse_netmask(data, NULL, NULL) == HM_HOST)
1468 {
1469 conf_report_error("Ignoring exempt -- invalid exempt::ip.");
1470 return;
1471 }
1472
1473 yy_tmp = make_conf();
1474 yy_tmp->passwd = rb_strdup("*");
1475 yy_tmp->host = rb_strdup(data);
1476 yy_tmp->status = CONF_EXEMPTDLINE;
1477 add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, NULL, yy_tmp);
1478 }
1479
1480 static int
1481 conf_cleanup_cluster(struct TopConf *tc)
1482 {
1483 rb_dlink_node *ptr, *next_ptr;
1484
1485 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head)
1486 {
1487 free_remote_conf(ptr->data);
1488 rb_dlinkDestroy(ptr, &yy_cluster_list);
1489 }
1490
1491 if(yy_shared != NULL)
1492 {
1493 free_remote_conf(yy_shared);
1494 yy_shared = NULL;
1495 }
1496
1497 return 0;
1498 }
1499
1500 static void
1501 conf_set_cluster_name(void *data)
1502 {
1503 if(yy_shared != NULL)
1504 free_remote_conf(yy_shared);
1505
1506 yy_shared = make_remote_conf();
1507 yy_shared->server = rb_strdup(data);
1508 rb_dlinkAddAlloc(yy_shared, &yy_cluster_list);
1509
1510 yy_shared = NULL;
1511 }
1512
1513 static void
1514 conf_set_cluster_flags(void *data)
1515 {
1516 conf_parm_t *args = data;
1517 int flags = 0;
1518 rb_dlink_node *ptr, *next_ptr;
1519
1520 if(yy_shared != NULL)
1521 free_remote_conf(yy_shared);
1522
1523 set_modes_from_table(&flags, "flag", cluster_table, args);
1524
1525 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head)
1526 {
1527 yy_shared = ptr->data;
1528 yy_shared->flags = flags;
1529 rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list);
1530 rb_dlinkDestroy(ptr, &yy_cluster_list);
1531 }
1532
1533 yy_shared = NULL;
1534 }
1535
1536 static void
1537 conf_set_general_havent_read_conf(void *data)
1538 {
1539 if(*(unsigned int *) data)
1540 {
1541 conf_report_error("You haven't read your config file properly.");
1542 conf_report_error
1543 ("There is a line in the example conf that will kill your server if not removed.");
1544 conf_report_error
1545 ("Consider actually reading/editing the conf file, and removing this line.");
1546 if (!testing_conf)
1547 exit(0);
1548 }
1549 }
1550
1551 static void
1552 conf_set_general_hide_error_messages(void *data)
1553 {
1554 char *val = data;
1555
1556 if(strcasecmp(val, "yes") == 0)
1557 ConfigFileEntry.hide_error_messages = 2;
1558 else if(strcasecmp(val, "opers") == 0)
1559 ConfigFileEntry.hide_error_messages = 1;
1560 else if(strcasecmp(val, "no") == 0)
1561 ConfigFileEntry.hide_error_messages = 0;
1562 else
1563 conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val);
1564 }
1565
1566 static void
1567 conf_set_general_kline_delay(void *data)
1568 {
1569 ConfigFileEntry.kline_delay = *(unsigned int *) data;
1570
1571 /* THIS MUST BE HERE to stop us being unable to check klines */
1572 kline_queued = 0;
1573 }
1574
1575 static void
1576 conf_set_general_stats_k_oper_only(void *data)
1577 {
1578 char *val = data;
1579
1580 if(strcasecmp(val, "yes") == 0)
1581 ConfigFileEntry.stats_k_oper_only = 2;
1582 else if(strcasecmp(val, "masked") == 0)
1583 ConfigFileEntry.stats_k_oper_only = 1;
1584 else if(strcasecmp(val, "no") == 0)
1585 ConfigFileEntry.stats_k_oper_only = 0;
1586 else
1587 conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val);
1588 }
1589
1590 static void
1591 conf_set_general_stats_i_oper_only(void *data)
1592 {
1593 char *val = data;
1594
1595 if(strcasecmp(val, "yes") == 0)
1596 ConfigFileEntry.stats_i_oper_only = 2;
1597 else if(strcasecmp(val, "masked") == 0)
1598 ConfigFileEntry.stats_i_oper_only = 1;
1599 else if(strcasecmp(val, "no") == 0)
1600 ConfigFileEntry.stats_i_oper_only = 0;
1601 else
1602 conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val);
1603 }
1604
1605 static void
1606 conf_set_general_compression_level(void *data)
1607 {
1608 #ifdef HAVE_LIBZ
1609 ConfigFileEntry.compression_level = *(unsigned int *) data;
1610
1611 if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9))
1612 {
1613 conf_report_error
1614 ("Invalid general::compression_level %d -- using default.",
1615 ConfigFileEntry.compression_level);
1616 ConfigFileEntry.compression_level = 0;
1617 }
1618 #else
1619 conf_report_error("Ignoring general::compression_level -- zlib not available.");
1620 #endif
1621 }
1622
1623 static void
1624 conf_set_general_default_umodes(void *data)
1625 {
1626 char *pm;
1627 int what = MODE_ADD, flag;
1628
1629 ConfigFileEntry.default_umodes = 0;
1630 for (pm = (char *) data; *pm; pm++)
1631 {
1632 switch (*pm)
1633 {
1634 case '+':
1635 what = MODE_ADD;
1636 break;
1637 case '-':
1638 what = MODE_DEL;
1639 break;
1640
1641 /* don't allow +o */
1642 case 'o':
1643 case 'S':
1644 case ' ':
1645 break;
1646
1647 default:
1648 if ((flag = user_modes[(unsigned char) *pm]))
1649 {
1650 /* Proper value has probably not yet been set
1651 * so don't check oper_only_umodes -- jilles */
1652 if (what == MODE_ADD)
1653 ConfigFileEntry.default_umodes |= flag;
1654 else
1655 ConfigFileEntry.default_umodes &= ~flag;
1656 }
1657 break;
1658 }
1659 }
1660 }
1661
1662 static void
1663 conf_set_general_oper_umodes(void *data)
1664 {
1665 set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data);
1666 }
1667
1668 static void
1669 conf_set_general_oper_only_umodes(void *data)
1670 {
1671 set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data);
1672 }
1673
1674 static void
1675 conf_set_general_oper_snomask(void *data)
1676 {
1677 char *pm;
1678 int what = MODE_ADD, flag;
1679
1680 ConfigFileEntry.oper_snomask = 0;
1681 for (pm = (char *) data; *pm; pm++)
1682 {
1683 switch (*pm)
1684 {
1685 case '+':
1686 what = MODE_ADD;
1687 break;
1688 case '-':
1689 what = MODE_DEL;
1690 break;
1691
1692 default:
1693 if ((flag = snomask_modes[(unsigned char) *pm]))
1694 {
1695 if (what == MODE_ADD)
1696 ConfigFileEntry.oper_snomask |= flag;
1697 else
1698 ConfigFileEntry.oper_snomask &= ~flag;
1699 }
1700 break;
1701 }
1702 }
1703 }
1704
1705 static void
1706 conf_set_serverhide_links_delay(void *data)
1707 {
1708 int val = *(unsigned int *) data;
1709
1710 ConfigServerHide.links_delay = val;
1711 }
1712
1713 static int
1714 conf_begin_service(struct TopConf *tc)
1715 {
1716 struct Client *target_p;
1717 rb_dlink_node *ptr;
1718
1719 RB_DLINK_FOREACH(ptr, global_serv_list.head)
1720 {
1721 target_p = ptr->data;
1722
1723 target_p->flags &= ~FLAGS_SERVICE;
1724 }
1725
1726 return 0;
1727 }
1728
1729 static void
1730 conf_set_service_name(void *data)
1731 {
1732 struct Client *target_p;
1733 const char *s;
1734 char *tmp;
1735 int dots = 0;
1736
1737 for(s = data; *s != '\0'; s++)
1738 {
1739 if(!IsServChar(*s))
1740 {
1741 conf_report_error("Ignoring service::name "
1742 "-- bogus servername.");
1743 return;
1744 }
1745 else if(*s == '.')
1746 dots++;
1747 }
1748
1749 if(!dots)
1750 {
1751 conf_report_error("Ignoring service::name -- must contain '.'");
1752 return;
1753 }
1754
1755 tmp = rb_strdup(data);
1756 rb_dlinkAddAlloc(tmp, &service_list);
1757
1758 if((target_p = find_server(NULL, tmp)))
1759 target_p->flags |= FLAGS_SERVICE;
1760 }
1761
1762 static int
1763 conf_begin_alias(struct TopConf *tc)
1764 {
1765 yy_alias = rb_malloc(sizeof(struct alias_entry));
1766
1767 if (conf_cur_block_name != NULL)
1768 yy_alias->name = rb_strdup(conf_cur_block_name);
1769
1770 yy_alias->flags = 0;
1771 yy_alias->hits = 0;
1772
1773 return 0;
1774 }
1775
1776 static int
1777 conf_end_alias(struct TopConf *tc)
1778 {
1779 if (yy_alias == NULL)
1780 return -1;
1781
1782 if (yy_alias->name == NULL)
1783 {
1784 conf_report_error("Ignoring alias -- must have a name.");
1785
1786 rb_free(yy_alias);
1787
1788 return -1;
1789 }
1790
1791 if (yy_alias->target == NULL)
1792 {
1793 conf_report_error("Ignoring alias -- must have a target.");
1794
1795 rb_free(yy_alias);
1796
1797 return -1;
1798 }
1799
1800 irc_dictionary_add(alias_dict, yy_alias->name, yy_alias);
1801
1802 return 0;
1803 }
1804
1805 static void
1806 conf_set_alias_name(void *data)
1807 {
1808 if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */
1809 return;
1810
1811 yy_alias->name = rb_strdup(data);
1812 }
1813
1814 static void
1815 conf_set_alias_target(void *data)
1816 {
1817 if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */
1818 return;
1819
1820 yy_alias->target = rb_strdup(data);
1821 }
1822
1823 static void
1824 conf_set_blacklist_host(void *data)
1825 {
1826 yy_blacklist_host = rb_strdup(data);
1827 }
1828
1829 static void
1830 conf_set_blacklist_reason(void *data)
1831 {
1832 yy_blacklist_reason = rb_strdup(data);
1833
1834 if (yy_blacklist_host && yy_blacklist_reason)
1835 {
1836 new_blacklist(yy_blacklist_host, yy_blacklist_reason);
1837 rb_free(yy_blacklist_host);
1838 rb_free(yy_blacklist_reason);
1839 yy_blacklist_host = NULL;
1840 yy_blacklist_reason = NULL;
1841 }
1842 }
1843
1844 /* public functions */
1845
1846
1847 void
1848 conf_report_error(const char *fmt, ...)
1849 {
1850 va_list ap;
1851 char msg[IRCD_BUFSIZE + 1] = { 0 };
1852
1853 va_start(ap, fmt);
1854 rb_vsnprintf(msg, IRCD_BUFSIZE, fmt, ap);
1855 va_end(ap);
1856
1857 if (testing_conf)
1858 {
1859 fprintf(stderr, "\"%s\", line %d: %s\n", current_file, lineno + 1, msg);
1860 return;
1861 }
1862
1863 ierror("\"%s\", line %d: %s", current_file, lineno + 1, msg);
1864 sendto_realops_snomask(SNO_GENERAL, L_ALL, "\"%s\", line %d: %s", current_file, lineno + 1, msg);
1865 }
1866
1867 int
1868 conf_start_block(char *block, char *name)
1869 {
1870 if((conf_cur_block = find_top_conf(block)) == NULL)
1871 {
1872 conf_report_error("Configuration block '%s' is not defined.", block);
1873 return -1;
1874 }
1875
1876 if(name)
1877 conf_cur_block_name = rb_strdup(name);
1878 else
1879 conf_cur_block_name = NULL;
1880
1881 if(conf_cur_block->tc_sfunc)
1882 if(conf_cur_block->tc_sfunc(conf_cur_block) < 0)
1883 return -1;
1884
1885 return 0;
1886 }
1887
1888 int
1889 conf_end_block(struct TopConf *tc)
1890 {
1891 if(tc->tc_efunc)
1892 return tc->tc_efunc(tc);
1893
1894 rb_free(conf_cur_block_name);
1895 return 0;
1896 }
1897
1898 static void
1899 conf_set_generic_int(void *data, void *location)
1900 {
1901 *((int *) location) = *((unsigned int *) data);
1902 }
1903
1904 static void
1905 conf_set_generic_string(void *data, int len, void *location)
1906 {
1907 char **loc = location;
1908 char *input = data;
1909
1910 if(len && strlen(input) > (unsigned int)len)
1911 input[len] = '\0';
1912
1913 rb_free(*loc);
1914 *loc = rb_strdup(input);
1915 }
1916
1917 int
1918 conf_call_set(struct TopConf *tc, char *item, conf_parm_t * value, int type)
1919 {
1920 struct ConfEntry *cf;
1921 conf_parm_t *cp;
1922
1923 if(!tc)
1924 return -1;
1925
1926 if((cf = find_conf_item(tc, item)) == NULL)
1927 {
1928 conf_report_error
1929 ("Non-existant configuration setting %s::%s.", tc->tc_name, (char *) item);
1930 return -1;
1931 }
1932
1933 /* if it takes one thing, make sure they only passed one thing,
1934 and handle as needed. */
1935 if(value->type & CF_FLIST && !cf->cf_type & CF_FLIST)
1936 {
1937 conf_report_error
1938 ("Option %s::%s does not take a list of values.", tc->tc_name, item);
1939 return -1;
1940 }
1941
1942 cp = value->v.list;
1943
1944
1945 if(CF_TYPE(value->v.list->type) != CF_TYPE(cf->cf_type))
1946 {
1947 /* if it expects a string value, but we got a yesno,
1948 * convert it back
1949 */
1950 if((CF_TYPE(value->v.list->type) == CF_YESNO) &&
1951 (CF_TYPE(cf->cf_type) == CF_STRING))
1952 {
1953 value->v.list->type = CF_STRING;
1954
1955 if(cp->v.number == 1)
1956 cp->v.string = rb_strdup("yes");
1957 else
1958 cp->v.string = rb_strdup("no");
1959 }
1960
1961 /* maybe it's a CF_TIME and they passed CF_INT --
1962 should still be valid */
1963 else if(!((CF_TYPE(value->v.list->type) == CF_INT) &&
1964 (CF_TYPE(cf->cf_type) == CF_TIME)))
1965 {
1966 conf_report_error
1967 ("Wrong type for %s::%s (expected %s, got %s)",
1968 tc->tc_name, (char *) item,
1969 conf_strtype(cf->cf_type), conf_strtype(value->v.list->type));
1970 return -1;
1971 }
1972 }
1973
1974 if(cf->cf_type & CF_FLIST)
1975 {
1976 #if 0
1977 if(cf->cf_arg)
1978 conf_set_generic_list(value->v.list, cf->cf_arg);
1979 else
1980 #endif
1981 /* just pass it the extended argument list */
1982 cf->cf_func(value->v.list);
1983 }
1984 else
1985 {
1986 /* it's old-style, needs only one arg */
1987 switch (cf->cf_type)
1988 {
1989 case CF_INT:
1990 case CF_TIME:
1991 case CF_YESNO:
1992 if(cf->cf_arg)
1993 conf_set_generic_int(&cp->v.number, cf->cf_arg);
1994 else
1995 cf->cf_func(&cp->v.number);
1996 break;
1997 case CF_STRING:
1998 case CF_QSTRING:
1999 if(EmptyString(cp->v.string))
2000 conf_report_error("Ignoring %s::%s -- empty field",
2001 tc->tc_name, item);
2002 else if(cf->cf_arg)
2003 conf_set_generic_string(cp->v.string, cf->cf_len, cf->cf_arg);
2004 else
2005 cf->cf_func(cp->v.string);
2006 break;
2007 }
2008 }
2009
2010
2011 return 0;
2012 }
2013
2014 int
2015 add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *))
2016 {
2017 struct TopConf *tc;
2018 struct ConfEntry *cf;
2019
2020 if((tc = find_top_conf(topconf)) == NULL)
2021 return -1;
2022
2023 if((cf = find_conf_item(tc, name)) != NULL)
2024 return -1;
2025
2026 cf = rb_malloc(sizeof(struct ConfEntry));
2027
2028 cf->cf_name = name;
2029 cf->cf_type = type;
2030 cf->cf_func = func;
2031 cf->cf_arg = NULL;
2032
2033 rb_dlinkAddAlloc(cf, &tc->tc_items);
2034
2035 return 0;
2036 }
2037
2038 int
2039 remove_conf_item(const char *topconf, const char *name)
2040 {
2041 struct TopConf *tc;
2042 struct ConfEntry *cf;
2043 rb_dlink_node *ptr;
2044
2045 if((tc = find_top_conf(topconf)) == NULL)
2046 return -1;
2047
2048 if((cf = find_conf_item(tc, name)) == NULL)
2049 return -1;
2050
2051 if((ptr = rb_dlinkFind(cf, &tc->tc_items)) == NULL)
2052 return -1;
2053
2054 rb_dlinkDestroy(ptr, &tc->tc_items);
2055 rb_free(cf);
2056
2057 return 0;
2058 }
2059
2060 /* *INDENT-OFF* */
2061 static struct ConfEntry conf_serverinfo_table[] =
2062 {
2063 { "description", CF_QSTRING, NULL, 0, &ServerInfo.description },
2064 { "network_desc", CF_QSTRING, NULL, 0, &ServerInfo.network_desc },
2065 { "helpchan", CF_QSTRING, NULL, 0, &ServerInfo.helpchan },
2066 { "helpurl", CF_QSTRING, NULL, 0, &ServerInfo.helpurl },
2067 { "hub", CF_YESNO, NULL, 0, &ServerInfo.hub },
2068
2069 { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL },
2070 { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL },
2071 { "sid", CF_QSTRING, conf_set_serverinfo_sid, 0, NULL },
2072 { "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL },
2073 { "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL },
2074
2075 { "ssl_private_key", CF_QSTRING, NULL, 0, &ServerInfo.ssl_private_key },
2076 { "ssl_ca_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_ca_cert },
2077 { "ssl_cert", CF_QSTRING, NULL, 0, &ServerInfo.ssl_cert },
2078 { "ssl_dh_params", CF_QSTRING, NULL, 0, &ServerInfo.ssl_dh_params },
2079 { "ssld_count", CF_INT, NULL, 0, &ServerInfo.ssld_count },
2080
2081 { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients },
2082
2083 { "\0", 0, NULL, 0, NULL }
2084 };
2085
2086 static struct ConfEntry conf_admin_table[] =
2087 {
2088 { "name", CF_QSTRING, NULL, 200, &AdminInfo.name },
2089 { "description",CF_QSTRING, NULL, 200, &AdminInfo.description },
2090 { "email", CF_QSTRING, NULL, 200, &AdminInfo.email },
2091 { "\0", 0, NULL, 0, NULL }
2092 };
2093
2094 static struct ConfEntry conf_log_table[] =
2095 {
2096 { "fname_userlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_userlog },
2097 { "fname_fuserlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_fuserlog },
2098 { "fname_operlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operlog },
2099 { "fname_foperlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_foperlog },
2100 { "fname_serverlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_serverlog },
2101 { "fname_killlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_killlog },
2102 { "fname_klinelog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_klinelog },
2103 { "fname_operspylog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_operspylog },
2104 { "fname_ioerrorlog", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.fname_ioerrorlog },
2105 { "\0", 0, NULL, 0, NULL }
2106 };
2107
2108 static struct ConfEntry conf_operator_table[] =
2109 {
2110 { "rsa_public_key_file", CF_QSTRING, conf_set_oper_rsa_public_key_file, 0, NULL },
2111 { "flags", CF_STRING | CF_FLIST, conf_set_oper_flags, 0, NULL },
2112 { "umodes", CF_STRING | CF_FLIST, conf_set_oper_umodes, 0, NULL },
2113 { "privset", CF_QSTRING, conf_set_oper_privset, 0, NULL },
2114 { "snomask", CF_QSTRING, conf_set_oper_snomask, 0, NULL },
2115 { "vhost", CF_QSTRING, conf_set_oper_vhost, 0, NULL },
2116 { "swhois", CF_QSTRING, conf_set_oper_swhois, 0, NULL },
2117 { "operstring", CF_QSTRING, conf_set_oper_operstring, 0, NULL },
2118 { "user", CF_QSTRING, conf_set_oper_user, 0, NULL },
2119 { "password", CF_QSTRING, conf_set_oper_password, 0, NULL },
2120 { "fingerprint", CF_QSTRING, conf_set_oper_fingerprint, 0, NULL },
2121 { "\0", 0, NULL, 0, NULL }
2122 };
2123
2124 static struct ConfEntry conf_privset_table[] =
2125 {
2126 { "extends", CF_QSTRING, conf_set_privset_extends, 0, NULL },
2127 { "privs", CF_STRING | CF_FLIST, conf_set_privset_privs, 0, NULL },
2128 { "\0", 0, NULL, 0, NULL }
2129 };
2130
2131 static struct ConfEntry conf_class_table[] =
2132 {
2133 { "ping_time", CF_TIME, conf_set_class_ping_time, 0, NULL },
2134 { "cidr_ipv4_bitlen", CF_INT, conf_set_class_cidr_ipv4_bitlen, 0, NULL },
2135 #ifdef RB_IPV6
2136 { "cidr_ipv6_bitlen", CF_INT, conf_set_class_cidr_ipv6_bitlen, 0, NULL },
2137 #endif
2138 { "number_per_cidr", CF_INT, conf_set_class_number_per_cidr, 0, NULL },
2139 { "number_per_ip", CF_INT, conf_set_class_number_per_ip, 0, NULL },
2140 { "number_per_ip_global", CF_INT,conf_set_class_number_per_ip_global, 0, NULL },
2141 { "number_per_ident", CF_INT, conf_set_class_number_per_ident, 0, NULL },
2142 { "connectfreq", CF_TIME, conf_set_class_connectfreq, 0, NULL },
2143 { "max_number", CF_INT, conf_set_class_max_number, 0, NULL },
2144 { "sendq", CF_TIME, conf_set_class_sendq, 0, NULL },
2145 { "\0", 0, NULL, 0, NULL }
2146 };
2147
2148 static struct ConfEntry conf_auth_table[] =
2149 {
2150 { "user", CF_QSTRING, conf_set_auth_user, 0, NULL },
2151 { "auth_user", CF_QSTRING, conf_set_auth_auth_user, 0, NULL },
2152 { "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL },
2153 { "class", CF_QSTRING, conf_set_auth_class, 0, NULL },
2154 { "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL },
2155 { "autojoin", CF_QSTRING, conf_set_auth_autojoin, 0, NULL },
2156 { "autojoin_opers", CF_QSTRING, conf_set_auth_autojoin_opers, 0, NULL },
2157 { "redirserv", CF_QSTRING, conf_set_auth_redir_serv, 0, NULL },
2158 { "redirport", CF_INT, conf_set_auth_redir_port, 0, NULL },
2159 { "flags", CF_STRING | CF_FLIST, conf_set_auth_flags, 0, NULL },
2160 { "\0", 0, NULL, 0, NULL }
2161 };
2162
2163 static struct ConfEntry conf_connect_table[] =
2164 {
2165 { "send_password", CF_QSTRING, conf_set_connect_send_password, 0, NULL },
2166 { "accept_password", CF_QSTRING, conf_set_connect_accept_password, 0, NULL },
2167 { "flags", CF_STRING | CF_FLIST, conf_set_connect_flags, 0, NULL },
2168 { "host", CF_QSTRING, conf_set_connect_host, 0, NULL },
2169 { "vhost", CF_QSTRING, conf_set_connect_vhost, 0, NULL },
2170 { "port", CF_INT, conf_set_connect_port, 0, NULL },
2171 { "aftype", CF_STRING, conf_set_connect_aftype, 0, NULL },
2172 { "hub_mask", CF_QSTRING, conf_set_connect_hub_mask, 0, NULL },
2173 { "leaf_mask", CF_QSTRING, conf_set_connect_leaf_mask, 0, NULL },
2174 { "class", CF_QSTRING, conf_set_connect_class, 0, NULL },
2175 { "\0", 0, NULL, 0, NULL }
2176 };
2177
2178 static struct ConfEntry conf_general_table[] =
2179 {
2180 { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL },
2181 { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL },
2182 { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL },
2183 { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL },
2184 { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL },
2185 { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL },
2186 { "kline_delay", CF_TIME, conf_set_general_kline_delay, 0, NULL },
2187 { "stats_k_oper_only", CF_STRING, conf_set_general_stats_k_oper_only, 0, NULL },
2188 { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL },
2189 { "default_umodes", CF_QSTRING, conf_set_general_default_umodes, 0, NULL },
2190
2191 { "default_operstring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operstring },
2192 { "default_adminstring",CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_adminstring },
2193 { "default_operhost", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.default_operhost },
2194 { "static_quit", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.static_quit },
2195 { "servicestring", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.servicestring },
2196 { "egdpool_path", CF_QSTRING, NULL, MAXPATHLEN, &ConfigFileEntry.egdpool_path },
2197 { "kline_reason", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.kline_reason },
2198 { "identify_service", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifyservice },
2199 { "identify_command", CF_QSTRING, NULL, REALLEN, &ConfigFileEntry.identifycommand },
2200
2201 { "anti_spam_exit_message_time", CF_TIME, NULL, 0, &ConfigFileEntry.anti_spam_exit_message_time },
2202 { "use_part_messages", CF_YESNO, NULL, 0, &ConfigFileEntry.use_part_messages },
2203 { "disable_fake_channels", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_fake_channels },
2204 { "min_nonwildcard_simple", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard_simple },
2205 { "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines },
2206 { "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices },
2207
2208 { "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood },
2209 { "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away },
2210 { "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait },
2211 { "client_exit", CF_YESNO, NULL, 0, &ConfigFileEntry.client_exit },
2212 { "client_flood", CF_INT, NULL, 0, &ConfigFileEntry.client_flood },
2213 { "collision_fnc", CF_YESNO, NULL, 0, &ConfigFileEntry.collision_fnc },
2214 { "connect_timeout", CF_TIME, NULL, 0, &ConfigFileEntry.connect_timeout },
2215 { "default_floodcount", CF_INT, NULL, 0, &ConfigFileEntry.default_floodcount },
2216 { "default_ident_timeout", CF_INT, NULL, 0, &ConfigFileEntry.default_ident_timeout },
2217 { "disable_auth", CF_YESNO, NULL, 0, &ConfigFileEntry.disable_auth },
2218 { "dots_in_ident", CF_INT, NULL, 0, &ConfigFileEntry.dots_in_ident },
2219 { "failed_oper_notice", CF_YESNO, NULL, 0, &ConfigFileEntry.failed_oper_notice },
2220 { "global_snotices", CF_YESNO, NULL, 0, &ConfigFileEntry.global_snotices },
2221 { "hide_spoof_ips", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_spoof_ips },
2222 { "dline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.dline_with_reason },
2223 { "kline_with_reason", CF_YESNO, NULL, 0, &ConfigFileEntry.kline_with_reason },
2224 { "map_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.map_oper_only },
2225 { "max_accept", CF_INT, NULL, 0, &ConfigFileEntry.max_accept },
2226 { "max_monitor", CF_INT, NULL, 0, &ConfigFileEntry.max_monitor },
2227 { "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time },
2228 { "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes },
2229 { "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets },
2230 { "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard },
2231 { "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay },
2232 { "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood },
2233 { "true_no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.true_no_oper_flood },
2234 { "operspy_admin_only", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_admin_only },
2235 { "operspy_dont_care_user_info", CF_YESNO, NULL, 0, &ConfigFileEntry.operspy_dont_care_user_info },
2236 { "secret_channels_in_whois", CF_YESNO, NULL, 0, &ConfigFileEntry.secret_channels_in_whois },
2237 { "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait },
2238 { "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple },
2239 { "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie },
2240 { "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count },
2241 { "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time },
2242 { "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration },
2243 { "throttle_count", CF_INT, NULL, 0, &ConfigFileEntry.throttle_count },
2244 { "throttle_duration", CF_TIME, NULL, 0, &ConfigFileEntry.throttle_duration },
2245 { "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd },
2246 { "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only },
2247 { "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled },
2248 { "stats_h_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_h_oper_only },
2249 { "stats_o_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_o_oper_only },
2250 { "stats_P_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_P_oper_only },
2251 { "stats_y_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_y_oper_only },
2252 { "target_change", CF_YESNO, NULL, 0, &ConfigFileEntry.target_change },
2253 { "ts_max_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_max_delta },
2254 { "use_egd", CF_YESNO, NULL, 0, &ConfigFileEntry.use_egd },
2255 { "ts_warn_delta", CF_TIME, NULL, 0, &ConfigFileEntry.ts_warn_delta },
2256 { "use_whois_actually", CF_YESNO, NULL, 0, &ConfigFileEntry.use_whois_actually },
2257 { "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline },
2258 { "use_propagated_bans",CF_YESNO, NULL, 0, &ConfigFileEntry.use_propagated_bans },
2259 { "expire_override_time", CF_TIME, NULL, 0, &ConfigFileEntry.expire_override_time},
2260 { "\0", 0, NULL, 0, NULL }
2261 };
2262
2263 static struct ConfEntry conf_channel_table[] =
2264 {
2265 { "autochanmodes", CF_QSTRING, NULL, 0, &ConfigChannel.autochanmodes },
2266 { "exemptchanops", CF_QSTRING, NULL, 0, &ConfigChannel.exemptchanops },
2267 { "default_split_user_count", CF_INT, NULL, 0, &ConfigChannel.default_split_user_count },
2268 { "default_split_server_count", CF_INT, NULL, 0, &ConfigChannel.default_split_server_count },
2269 { "burst_topicwho", CF_YESNO, NULL, 0, &ConfigChannel.burst_topicwho },
2270 { "kick_on_split_riding", CF_YESNO, NULL, 0, &ConfigChannel.kick_on_split_riding },
2271 { "knock_delay", CF_TIME, NULL, 0, &ConfigChannel.knock_delay },
2272 { "knock_delay_channel",CF_TIME, NULL, 0, &ConfigChannel.knock_delay_channel },
2273 { "max_bans", CF_INT, NULL, 0, &ConfigChannel.max_bans },
2274 { "max_bans_large", CF_INT, NULL, 0, &ConfigChannel.max_bans_large },
2275 { "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user },
2276 { "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split },
2277 { "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split },
2278 { "only_ascii_channels", CF_YESNO, NULL, 0, &ConfigChannel.only_ascii_channels },
2279 { "cycle_host_change", CF_YESNO, NULL, 0, &ConfigChannel.cycle_host_change },
2280 { "host_in_topic", CF_YESNO, NULL, 0, &ConfigChannel.host_in_topic },
2281 { "use_halfop", CF_YESNO, NULL, 0, &ConfigChannel.use_halfop },
2282 { "use_admin", CF_YESNO, NULL, 0, &ConfigChannel.use_admin },
2283 { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except },
2284 { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex },
2285 { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock },
2286 { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward },
2287 { "use_local_channels", CF_YESNO, NULL, 0, &ConfigChannel.use_local_channels },
2288 { "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart },
2289 { "exempt_cmode_c", CF_YESNO, NULL, 0, &ConfigChannel.exempt_cmode_c },
2290 { "exempt_cmode_C", CF_YESNO, NULL, 0, &ConfigChannel.exempt_cmode_C },
2291 { "exempt_cmode_D", CF_YESNO, NULL, 0, &ConfigChannel.exempt_cmode_D },
2292 { "exempt_cmode_T", CF_YESNO, NULL, 0, &ConfigChannel.exempt_cmode_T },
2293 { "exempt_cmode_N", CF_YESNO, NULL, 0, &ConfigChannel.exempt_cmode_N },
2294 { "exempt_cmode_G", CF_YESNO, NULL, 0, &ConfigChannel.exempt_cmode_G },
2295 { "exempt_cmode_K", CF_YESNO, NULL, 0, &ConfigChannel.exempt_cmode_K },
2296 { "\0", 0, NULL, 0, NULL }
2297 };
2298
2299 static struct ConfEntry conf_serverhide_table[] =
2300 {
2301 { "disable_hidden", CF_YESNO, NULL, 0, &ConfigServerHide.disable_hidden },
2302 { "flatten_links", CF_YESNO, NULL, 0, &ConfigServerHide.flatten_links },
2303 { "hidden", CF_YESNO, NULL, 0, &ConfigServerHide.hidden },
2304 { "links_delay", CF_TIME, conf_set_serverhide_links_delay, 0, NULL },
2305 { "\0", 0, NULL, 0, NULL }
2306 };
2307 /* *INDENT-ON* */
2308
2309 void
2310 newconf_init()
2311 {
2312 add_top_conf("modules", NULL, NULL, NULL);
2313 add_conf_item("modules", "path", CF_QSTRING, conf_set_modules_path);
2314 add_conf_item("modules", "module", CF_QSTRING, conf_set_modules_module);
2315
2316 add_top_conf("serverinfo", NULL, NULL, conf_serverinfo_table);
2317 add_top_conf("admin", NULL, NULL, conf_admin_table);
2318 add_top_conf("log", NULL, NULL, conf_log_table);
2319 add_top_conf("operator", conf_begin_oper, conf_end_oper, conf_operator_table);
2320 add_top_conf("class", conf_begin_class, conf_end_class, conf_class_table);
2321 add_top_conf("privset", NULL, NULL, conf_privset_table);
2322
2323 add_top_conf("listen", conf_begin_listen, conf_end_listen, NULL);
2324 add_conf_item("listen", "port", CF_INT | CF_FLIST, conf_set_listen_port);
2325 add_conf_item("listen", "sslport", CF_INT | CF_FLIST, conf_set_listen_sslport);
2326 add_conf_item("listen", "ip", CF_QSTRING, conf_set_listen_address);
2327 add_conf_item("listen", "host", CF_QSTRING, conf_set_listen_address);
2328
2329 add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table);
2330
2331 add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL);
2332 add_conf_item("shared", "oper", CF_QSTRING|CF_FLIST, conf_set_shared_oper);
2333 add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags);
2334
2335 add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table);
2336
2337 add_top_conf("exempt", NULL, NULL, NULL);
2338 add_conf_item("exempt", "ip", CF_QSTRING, conf_set_exempt_ip);
2339
2340 add_top_conf("cluster", conf_cleanup_cluster, conf_cleanup_cluster, NULL);
2341 add_conf_item("cluster", "name", CF_QSTRING, conf_set_cluster_name);
2342 add_conf_item("cluster", "flags", CF_STRING | CF_FLIST, conf_set_cluster_flags);
2343
2344 add_top_conf("general", NULL, NULL, conf_general_table);
2345 add_top_conf("channel", NULL, NULL, conf_channel_table);
2346 add_top_conf("serverhide", NULL, NULL, conf_serverhide_table);
2347
2348 add_top_conf("service", conf_begin_service, NULL, NULL);
2349 add_conf_item("service", "name", CF_QSTRING, conf_set_service_name);
2350
2351 add_top_conf("alias", conf_begin_alias, conf_end_alias, NULL);
2352 add_conf_item("alias", "name", CF_QSTRING, conf_set_alias_name);
2353 add_conf_item("alias", "target", CF_QSTRING, conf_set_alias_target);
2354
2355 add_top_conf("blacklist", NULL, NULL, NULL);
2356 add_conf_item("blacklist", "host", CF_QSTRING, conf_set_blacklist_host);
2357 add_conf_item("blacklist", "reject_reason", CF_QSTRING, conf_set_blacklist_reason);
2358 }