2 * ircd_parser.y: A yacc/bison parser for ircd config files.
3 * This is part of ircu, an Internet Relay Chat server.
4 * The contents of this file are Copyright 2001 Diane Bruce,
5 * Andrew Miller, the ircd-hybrid team and the ircu team.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * $Id: ircd_parser.y 1907 2009-02-09 04:11:04Z entrope $
29 #include "ircd_features.h"
34 #include "ircd_alloc.h"
35 #include "ircd_chattr.h"
37 #include "ircd_reply.h"
38 #include "ircd_snprintf.h"
39 #include "ircd_string.h"
60 #include <arpa/inet.h>
62 #define MAX_STRINGS 80 /* Maximum number of feature params. */
63 #define USE_IPV4 (1 << 16)
64 #define USE_IPV6 (1 << 17)
66 extern struct LocalConf localConf;
67 extern struct DenyConf* denyConfList;
68 extern struct CRuleConf* cruleConfList;
69 extern struct ServerConf* serverConfList;
70 extern struct s_map* GlobalServiceMapList;
71 extern struct qline* GlobalQuarantineList;
74 /* Now all the globals we need :/... */
75 int tping, tconn, maxlinks, sendq, port, invert, stringno, flags, maxchans, iauth_required = 0;
76 char *name, *pass, *host, *ip, *username, *origin, *hub_limit;
78 char *stringlist[MAX_STRINGS];
79 struct ListenerFlags listen_flags;
80 struct ConnectionClass *c_class;
81 struct DenyConf *dconf;
82 struct ServerConf *sconf;
85 struct Privs privs_dirty;
86 struct webirc_block *webirc;
88 static void parse_error(char *pattern,...) {
89 static char error_buffer[1024];
92 ircd_vsnprintf(NULL, error_buffer, sizeof(error_buffer), pattern, vl);
94 yyerror(error_buffer);
97 static void free_slist(struct SLink **link) {
99 while (*link != NULL) {
100 next = (*link)->next;
101 MyFree((*link)->value.cp);
109 %token <text> QSTRING
177 %token TOK_IPV4 TOK_IPV6
188 /* and now a lot of privileges... */
189 %token TPRIV_CHAN_LIMIT TPRIV_MODE_LCHAN TPRIV_DEOP_LCHAN TPRIV_WALK_LCHAN
190 %token TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE
191 %token TPRIV_GLINE TPRIV_LOCAL_GLINE TPRIV_LOCAL_JUPE TPRIV_LOCAL_BADCHAN
192 %token TPRIV_LOCAL_OPMODE TPRIV_OPMODE TPRIV_SET TPRIV_WHOX TPRIV_BADCHAN
193 %token TPRIV_SEE_CHAN TPRIV_SHOW_INVIS TPRIV_SHOW_ALL_INVIS TPRIV_PROPAGATE
194 %token TPRIV_UNLIMIT_QUERY TPRIV_DISPLAY TPRIV_SEE_OPERS TPRIV_WIDE_GLINE
195 %token TPRIV_FORCE_OPMODE TPRIV_FORCE_LOCAL_OPMODE TPRIV_APASS_OPMODE
196 %token TPRIV_LIST_CHAN TPRIV_SEE_IDLETIME TPRIV_UMODE_NETSERV
197 %token TPRIV_UMODE_NOCHAN TPRIV_UMODE_NOIDLE TPRIV_UMODE_CHSERV TPRIV_UMODE_XTRAOP
198 %token TPRIV_FLOOD TPRIV_HALFFLOOD TPRIV_UNLIMITED_TARGET TPRIV_UMODE_OVERRIDECC
199 %token TPRIV_HIDE_IDLETIME TPRIV_NOAMSG_OVERRIDE
200 /* and some types... */
202 %type <num> timespec timefactor factoredtimes factoredtime
203 %type <num> expr yesorno privtype address_family
213 /* Blocks in the config file... */
214 blocks: blocks block | block;
215 block: adminblock | generalblock | classblock | connectblock |
216 uworldblock | operblock | portblock | jupeblock | clientblock |
217 killblock | cruleblock | motdblock | featuresblock | quarantineblock |
218 pseudoblock | iauthblock | forwardsblock | webircblock | sslblock | error ';';
220 /* The timespec, sizespec and expr was ripped straight from
222 timespec: expr | factoredtimes;
224 factoredtimes: factoredtimes factoredtime
229 factoredtime: expr timefactor
234 timefactor: SECONDS { $$ = 1; }
235 | MINUTES { $$ = 60; }
236 | HOURS { $$ = 60 * 60; }
237 | DAYS { $$ = 60 * 60 * 24; }
238 | WEEKS { $$ = 60 * 60 * 24 * 7; }
239 | MONTHS { $$ = 60 * 60 * 24 * 7 * 4; }
240 | YEARS { $$ = 60 * 60 * 24 * 365; }
241 | DECADES { $$ = 60 * 60 * 24 * 365 * 10; };
254 $$ = $1 * 1024 * 1024;
257 $$ = $1 * 1024 * 1024 * 1024;
260 $$ = $1 * 1024 * 1024 * 1024;
264 /* this is an arithmetic expression */
281 /* leave this out until we find why it makes BSD yacc dump core -larne
282 | '-' expr %prec NEG {
290 jupeblock: JUPE '{' jupeitems '}' ';' ;
291 jupeitems: jupeitem jupeitems | jupeitem;
293 jupenick: NICK '=' QSTRING ';'
299 generalblock: GENERAL
301 /* Zero out the vhost addresses, in case they were removed. */
302 memset(&VirtualHost_v4.addr, 0, sizeof(VirtualHost_v4.addr));
303 memset(&VirtualHost_v6.addr, 0, sizeof(VirtualHost_v6.addr));
304 } '{' generalitems '}' ';' {
305 if (localConf.name == NULL)
306 parse_error("Your General block must contain a name.");
307 if (localConf.numeric == 0)
308 parse_error("Your General block must contain a numeric (between 1 and 4095).");
310 generalitems: generalitem generalitems | generalitem;
311 generalitem: generalnumeric | generalname | generalvhost | generaldesc
312 | generaldnsvhost | generaldnsserver;
314 generalnumeric: NUMERIC '=' NUMBER ';'
316 if (localConf.numeric == 0)
317 localConf.numeric = $3;
318 else if (localConf.numeric != $3)
319 parse_error("Redefinition of server numeric %i (%i)", $3,
323 generalname: NAME '=' QSTRING ';'
325 if (localConf.name == NULL)
328 if (strcmp(localConf.name, $3))
329 parse_error("Redefinition of server name %s (%s)", $3,
335 generaldesc: DESCRIPTION '=' QSTRING ';'
337 MyFree(localConf.description);
338 localConf.description = $3;
339 ircd_strncpy(cli_info(&me), $3, REALLEN);
342 generalvhost: VHOST '=' QSTRING ';'
344 struct irc_in_addr addr;
347 if (!strcmp(vhost, "*")) {
348 /* This traditionally meant bind to all interfaces and connect
349 * from the default. */
350 } else if (!ircd_aton(&addr, vhost))
351 parse_error("Invalid virtual host '%s'.", vhost);
352 else if (irc_in_addr_is_ipv4(&addr))
353 memcpy(&VirtualHost_v4.addr, &addr, sizeof(addr));
355 memcpy(&VirtualHost_v6.addr, &addr, sizeof(addr));
359 generaldnsvhost: DNS VHOST '=' address_family QSTRING ';'
361 struct irc_in_addr addr;
365 if (!strcmp(vhost, "*")) {
366 /* Let the operating system assign the default. */
367 } else if (!ircd_aton(&addr, vhost))
368 parse_error("Invalid DNS virtual host '%s'.", vhost);
371 if ((families & USE_IPV4)
372 || (!families && irc_in_addr_is_ipv4(&addr)))
373 memcpy(&VirtualHost_dns_v4.addr, &addr, sizeof(addr));
374 if ((families & USE_IPV6)
375 || (!families && !irc_in_addr_is_ipv4(&addr)))
376 memcpy(&VirtualHost_dns_v6.addr, &addr, sizeof(addr));
381 generaldnsserver: DNS SERVER '=' QSTRING ';'
385 add_nameserver(server);
391 MyFree(localConf.location1);
392 MyFree(localConf.location2);
393 MyFree(localConf.contact);
394 localConf.location1 = localConf.location2 = localConf.contact = NULL;
396 '{' adminitems '}' ';'
398 if (localConf.location1 == NULL)
399 DupString(localConf.location1, "");
400 if (localConf.location2 == NULL)
401 DupString(localConf.location2, "");
402 if (localConf.contact == NULL)
403 DupString(localConf.contact, "");
405 adminitems: adminitems adminitem | adminitem;
406 adminitem: adminlocation | admincontact;
407 adminlocation: LOCATION '=' QSTRING ';'
409 if (localConf.location1 == NULL)
410 localConf.location1 = $3;
411 else if (localConf.location2 == NULL)
412 localConf.location2 = $3;
413 else /* Otherwise just drop it. -A1kmm */
416 admincontact: CONTACT '=' QSTRING ';'
418 MyFree(localConf.contact);
419 localConf.contact = $3;
425 } '{' classitems '}' ';'
429 struct ConnectionClass *c_class;
430 add_class(name, tping, tconn, maxlinks, sendq, maxchans);
431 c_class = find_class(name);
432 MyFree(c_class->default_umode);
433 c_class->default_umode = pass;
434 memcpy(&c_class->privs, &privs, sizeof(c_class->privs));
435 memcpy(&c_class->privs_dirty, &privs_dirty, sizeof(c_class->privs_dirty));
438 parse_error("Missing name in class block");
445 memset(&privs, 0, sizeof(privs));
446 memset(&privs_dirty, 0, sizeof(privs_dirty));
448 classitems: classitem classitems | classitem;
449 classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
450 classsendq | classusermode | priv | maxchans;
451 classname: NAME '=' QSTRING ';'
456 maxchans: MAXCHANS '=' expr ';'
460 classpingfreq: PINGFREQ '=' timespec ';'
464 classconnfreq: CONNECTFREQ '=' timespec ';'
468 classmaxlinks: MAXLINKS '=' expr ';'
472 classsendq: SENDQ '=' sizespec ';'
476 classusermode: USERMODE '=' QSTRING ';'
482 connectblock: CONNECT
484 flags = CONF_AUTOCONNECT;
485 } '{' connectitems '}' ';'
487 struct ConfItem *aconf = NULL;
489 parse_error("Missing name in connect block");
490 else if (pass == NULL)
491 parse_error("Missing password in connect block");
492 else if (strlen(pass) > PASSWDLEN)
493 parse_error("Password too long in connect block");
494 else if (host == NULL)
495 parse_error("Missing host in connect block");
496 else if (strchr(host, '*') || strchr(host, '?'))
497 parse_error("Invalid host '%s' in connect block", host);
498 else if (c_class == NULL)
499 parse_error("Missing or non-existent class in connect block");
501 aconf = make_conf(CONF_SERVER);
503 aconf->origin_name = origin;
504 aconf->passwd = pass;
505 aconf->conn_class = c_class;
506 aconf->address.port = port;
508 /* If the user specified a hub allowance, but not maximum links,
509 * allow an effectively unlimited number of hops.
511 aconf->maximum = (hub_limit != NULL && maxlinks == 0) ? 65535 : maxlinks;
512 aconf->hub_limit = hub_limit;
513 aconf->flags = flags;
514 lookup_confhost(aconf);
523 name = pass = host = origin = hub_limit = NULL;
525 port = flags = maxlinks = 0;
527 connectitems: connectitem connectitems | connectitem;
528 connectitem: connectname | connectpass | connectclass | connecthost
529 | connectport | connectvhost | connectleaf | connecthub
530 | connecthublimit | connectmaxhops | connectauto | connectsecure;
531 connectname: NAME '=' QSTRING ';'
536 connectpass: PASS '=' QSTRING ';'
541 connectclass: CLASS '=' QSTRING ';'
543 c_class = find_class($3);
545 parse_error("No such connection class '%s' for Connect block", $3);
548 connecthost: HOST '=' QSTRING ';'
553 connectport: PORT '=' NUMBER ';'
557 connectvhost: VHOST '=' QSTRING ';'
562 connectleaf: LEAF ';'
569 DupString(hub_limit, "*");
571 connecthublimit: HUB '=' QSTRING ';'
576 connectmaxhops: MAXHOPS '=' expr ';'
580 connectauto: AUTOCONNECT '=' YES ';' { flags |= CONF_AUTOCONNECT; }
581 | AUTOCONNECT '=' NO ';' { flags &= ~CONF_AUTOCONNECT; };
582 connectsecure: SECURE '=' YES ';' { flags |= CONF_SECURE; }
583 | SECURE '=' NO ';' { flags &= ~CONF_SECURE; };
585 uworldblock: UWORLD '{' uworlditems '}' ';';
586 uworlditems: uworlditem uworlditems | uworlditem;
587 uworlditem: uworldname;
588 uworldname: NAME '=' QSTRING ';'
590 make_conf(CONF_UWORLD)->host = $3;
593 operblock: OPER '{' operitems '}' ';'
595 struct ConfItem *aconf = NULL;
599 parse_error("Missing name in operator block");
600 else if (pass == NULL)
601 parse_error("Missing password in operator block");
602 /* Do not check password length because it may be crypted. */
603 else if (hosts == NULL)
604 parse_error("Missing host(s) in operator block");
605 else if (c_class == NULL)
606 parse_error("Invalid or missing class in operator block");
607 else if (!FlagHas(&privs_dirty, PRIV_PROPAGATE)
608 && !FlagHas(&c_class->privs_dirty, PRIV_PROPAGATE))
609 parse_error("Operator block for %s and class %s have no LOCAL setting", name, c_class->cc_name);
610 else for (link = hosts; link != NULL; link = link->next) {
611 aconf = make_conf(CONF_OPERATOR);
612 DupString(aconf->name, name);
613 DupString(aconf->passwd, pass);
614 conf_parse_userhost(aconf, link->value.cp);
615 aconf->conn_class = c_class;
616 memcpy(&aconf->privs, &privs, sizeof(aconf->privs));
617 memcpy(&aconf->privs_dirty, &privs_dirty, sizeof(aconf->privs_dirty));
624 memset(&privs, 0, sizeof(privs));
625 memset(&privs_dirty, 0, sizeof(privs_dirty));
627 operitems: operitem | operitems operitem;
628 operitem: opername | operpass | operhost | operclass | priv;
629 opername: NAME '=' QSTRING ';'
634 operpass: PASS '=' QSTRING ';'
639 operhost: HOST '=' QSTRING ';'
643 if (!strchr($3, '@'))
646 link->value.cp = (char*) MyMalloc((uh_len = strlen($3)+3));
647 ircd_snprintf(0, link->value.cp, uh_len, "*@%s", $3);
650 DupString(link->value.cp, $3);
655 operclass: CLASS '=' QSTRING ';'
657 c_class = find_class($3);
659 parse_error("No such connection class '%s' for Operator block", $3);
663 priv: privtype '=' yesorno ';'
665 FlagSet(&privs_dirty, $1);
666 if (($3 == 1) ^ invert)
673 privtype: TPRIV_CHAN_LIMIT { $$ = PRIV_CHAN_LIMIT; } |
674 TPRIV_MODE_LCHAN { $$ = PRIV_MODE_LCHAN; } |
675 TPRIV_DEOP_LCHAN { $$ = PRIV_DEOP_LCHAN; } |
676 TPRIV_WALK_LCHAN { $$ = PRIV_WALK_LCHAN; } |
677 TPRIV_SEE_IDLETIME { $$ = PRIV_SEE_IDLETIME; } |
678 TPRIV_HIDE_IDLETIME { $$ = PRIV_HIDE_IDLETIME; } |
679 TPRIV_UMODE_NOCHAN { $$ = PRIV_UMODE_NOCHAN; } |
680 TPRIV_UMODE_NOIDLE { $$ = PRIV_UMODE_NOIDLE; } |
681 TPRIV_UMODE_CHSERV { $$ = PRIV_UMODE_CHSERV; } |
682 TPRIV_UMODE_XTRAOP { $$ = PRIV_UMODE_XTRAOP; } |
683 TPRIV_UMODE_NETSERV { $$ = PRIV_UMODE_NETSERV; } |
684 TPRIV_FLOOD { $$ = PRIV_FLOOD; } |
685 TPRIV_HALFFLOOD { $$ = PRIV_HALFFLOOD; } |
686 TPRIV_UNLIMITED_TARGET { $$ = PRIV_UNLIMITED_TARGET; } |
687 TPRIV_UMODE_OVERRIDECC { $$ = PRIV_UMODE_OVERRIDECC; } |
688 KILL { $$ = PRIV_KILL; } |
689 TPRIV_LOCAL_KILL { $$ = PRIV_LOCAL_KILL; } |
690 TPRIV_REHASH { $$ = PRIV_REHASH; } |
691 TPRIV_RESTART { $$ = PRIV_RESTART; } |
692 TPRIV_DIE { $$ = PRIV_DIE; } |
693 TPRIV_GLINE { $$ = PRIV_GLINE; } |
694 TPRIV_LOCAL_GLINE { $$ = PRIV_LOCAL_GLINE; } |
695 JUPE { $$ = PRIV_JUPE; } |
696 TPRIV_LOCAL_JUPE { $$ = PRIV_LOCAL_JUPE; } |
697 TPRIV_LOCAL_OPMODE { $$ = PRIV_LOCAL_OPMODE; } |
698 TPRIV_OPMODE { $$ = PRIV_OPMODE; }|
699 TPRIV_SET { $$ = PRIV_SET; } |
700 TPRIV_WHOX { $$ = PRIV_WHOX; } |
701 TPRIV_BADCHAN { $$ = PRIV_BADCHAN; } |
702 TPRIV_LOCAL_BADCHAN { $$ = PRIV_LOCAL_BADCHAN; } |
703 TPRIV_SEE_CHAN { $$ = PRIV_SEE_CHAN; } |
704 TPRIV_SHOW_INVIS { $$ = PRIV_SHOW_INVIS; } |
705 TPRIV_SHOW_ALL_INVIS { $$ = PRIV_SHOW_ALL_INVIS; } |
706 TPRIV_PROPAGATE { $$ = PRIV_PROPAGATE; } |
707 TPRIV_UNLIMIT_QUERY { $$ = PRIV_UNLIMIT_QUERY; } |
708 TPRIV_DISPLAY { $$ = PRIV_DISPLAY; } |
709 TPRIV_SEE_OPERS { $$ = PRIV_SEE_OPERS; } |
710 TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; } |
711 TPRIV_LIST_CHAN { $$ = PRIV_LIST_CHAN; } |
712 LOCAL { $$ = PRIV_PROPAGATE; invert = 1; } |
713 TPRIV_FORCE_OPMODE { $$ = PRIV_FORCE_OPMODE; } |
714 TPRIV_FORCE_LOCAL_OPMODE { $$ = PRIV_FORCE_LOCAL_OPMODE; } |
715 TPRIV_NOAMSG_OVERRIDE { $$ = PRIV_NOAMSG_OVERRIDE; } |
716 TPRIV_APASS_OPMODE { $$ = PRIV_APASS_OPMODE; } ;
718 yesorno: YES { $$ = 1; } | NO { $$ = 0; };
720 /* not a recursive definition because some pedant will just come along
721 * and whine that the parser accepts "ipv4 ipv4 ipv4 ipv4"
725 | TOK_IPV4 { $$ = USE_IPV4; }
726 | TOK_IPV6 { $$ = USE_IPV6; }
727 | TOK_IPV4 TOK_IPV6 { $$ = USE_IPV4 | USE_IPV6; }
728 | TOK_IPV6 TOK_IPV4 { $$ = USE_IPV6 | USE_IPV4; }
731 /* The port block... */
732 portblock: PORT '{' portitems '}' ';' {
733 struct ListenerFlags flags_here;
738 DupString(link->value.cp, "*");
743 for (link = hosts; link != NULL; link = link->next) {
744 memcpy(&flags_here, &listen_flags, sizeof(&flags_here));
745 switch (link->flags & (USE_IPV4 | USE_IPV6)) {
747 FlagSet(&flags_here, LISTEN_IPV4);
750 FlagSet(&flags_here, LISTEN_IPV6);
752 default: /* 0 or USE_IPV4|USE_IPV6 */
753 FlagSet(&flags_here, LISTEN_IPV4);
754 FlagSet(&flags_here, LISTEN_IPV6);
757 if (link->flags & 65535)
758 port = link->flags & 65535;
759 add_listener(port, link->value.cp, pass, &flags_here);
763 memset(&listen_flags, 0, sizeof(listen_flags));
767 portitems: portitem portitems | portitem;
768 portitem: portnumber | portvhost | portvhostnumber | portmask | portserver | porthidden | portsecure;
769 portnumber: PORT '=' address_family NUMBER ';'
771 if ($4 < 1 || $4 > 65535) {
772 parse_error("Port %d is out of range", port);
775 if (hosts && (0 == (hosts->flags & 65535)))
776 hosts->flags = (hosts->flags & ~65535) | port;
780 portvhost: VHOST '=' address_family QSTRING ';'
785 link->flags = $3 | port;
790 portvhostnumber: VHOST '=' address_family QSTRING NUMBER ';'
792 if ($5 < 1 || $5 > 65535) {
793 parse_error("Port %d is out of range", port);
798 link->flags = $3 | $5;
804 portmask: MASK '=' QSTRING ';'
810 portserver: SERVER '=' YES ';'
812 FlagSet(&listen_flags, LISTEN_SERVER);
813 } | SERVER '=' NO ';'
815 FlagClr(&listen_flags, LISTEN_SERVER);
818 porthidden: HIDDEN '=' YES ';'
820 FlagSet(&listen_flags, LISTEN_HIDDEN);
821 } | HIDDEN '=' NO ';'
823 FlagClr(&listen_flags, LISTEN_HIDDEN);
826 portsecure: SECURE '=' YES ';'
828 FlagSet(&listen_flags, LISTEN_SSL);
829 } | SECURE '=' NO ';'
831 FlagClr(&listen_flags, LISTEN_SSL);
839 '{' clientitems '}' ';'
841 struct ConfItem *aconf = 0;
842 struct irc_in_addr addr;
843 unsigned char addrbits = 0;
846 parse_error("Invalid or missing class in Client block");
847 else if (pass && strlen(pass) > PASSWDLEN)
848 parse_error("Password too long in connect block");
849 else if (ip && !ipmask_parse(ip, &addr, &addrbits))
850 parse_error("Invalid IP address %s in Client block", ip);
852 aconf = make_conf(CONF_CLIENT);
853 aconf->username = username;
856 memcpy(&aconf->address.addr, &addr, sizeof(aconf->address.addr));
858 memset(&aconf->address.addr, 0, sizeof(aconf->address.addr));
859 aconf->address.port = port;
860 aconf->addrbits = addrbits;
862 aconf->conn_class = c_class;
863 aconf->maximum = maxlinks;
864 aconf->passwd = pass;
880 clientitems: clientitem clientitems | clientitem;
881 clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks | clientport;
882 clienthost: HOST '=' QSTRING ';'
884 char *sep = strchr($3, '@');
889 DupString(host, sep);
895 clientip: IP '=' QSTRING ';'
898 sep = strchr($3, '@');
909 clientusername: USERNAME '=' QSTRING ';'
914 clientclass: CLASS '=' QSTRING ';'
916 c_class = find_class($3);
918 parse_error("No such connection class '%s' for Client block", $3);
921 clientpass: PASS '=' QSTRING ';'
926 clientmaxlinks: MAXLINKS '=' expr ';'
930 clientport: PORT '=' expr ';'
937 dconf = (struct DenyConf*) MyCalloc(1, sizeof(*dconf));
938 } '{' killitems '}' ';'
940 if (dconf->usermask || dconf->hostmask ||dconf->realmask) {
941 dconf->next = denyConfList;
942 denyConfList = dconf;
946 MyFree(dconf->usermask);
947 MyFree(dconf->hostmask);
948 MyFree(dconf->realmask);
949 MyFree(dconf->message);
951 parse_error("Kill block must match on at least one of username, host or realname");
955 killitems: killitem killitems | killitem;
956 killitem: killuhost | killreal | killusername | killreasonfile | killreason;
957 killuhost: HOST '=' QSTRING ';'
960 MyFree(dconf->hostmask);
961 MyFree(dconf->usermask);
962 if ((h = strchr($3, '@')) == NULL)
964 DupString(dconf->usermask, "*");
965 dconf->hostmask = $3;
970 DupString(dconf->hostmask, h);
971 dconf->usermask = $3;
973 ipmask_parse(dconf->hostmask, &dconf->address, &dconf->bits);
976 killusername: USERNAME '=' QSTRING ';'
978 MyFree(dconf->usermask);
979 dconf->usermask = $3;
982 killreal: REAL '=' QSTRING ';'
984 MyFree(dconf->realmask);
985 dconf->realmask = $3;
988 killreason: REASON '=' QSTRING ';'
990 dconf->flags &= ~DENY_FLAGS_FILE;
991 MyFree(dconf->message);
995 killreasonfile: TFILE '=' QSTRING ';'
997 dconf->flags |= DENY_FLAGS_FILE;
998 MyFree(dconf->message);
1005 } '{' cruleitems '}' ';'
1007 struct CRuleNode *node = NULL;
1011 parse_error("Missing server(s) in crule block");
1012 else if (pass == NULL)
1013 parse_error("Missing rule in crule block");
1014 else if ((node = crule_parse(pass)) == NULL)
1015 parse_error("Invalid rule '%s' in crule block", pass);
1016 else for (link = hosts; link != NULL; link = link->next)
1018 struct CRuleConf *p = (struct CRuleConf*) MyMalloc(sizeof(*p));
1020 node = crule_parse(pass);
1021 DupString(p->hostmask, link->value.cp);
1022 DupString(p->rule, pass);
1026 p->next = cruleConfList;
1035 cruleitems: cruleitem cruleitems | cruleitem;
1036 cruleitem: cruleserver | crulerule | cruleall;
1038 cruleserver: SERVER '=' QSTRING ';'
1042 link->value.cp = $3;
1047 crulerule: RULE '=' QSTRING ';'
1053 cruleall: ALL '=' YES ';'
1061 motdblock: MOTD '{' motditems '}' ';'
1065 for (link = hosts; link != NULL; link = link->next)
1066 motd_add(link->value.cp, pass);
1072 motditems: motditem motditems | motditem;
1073 motditem: motdhost | motdfile;
1074 motdhost: HOST '=' QSTRING ';'
1078 link->value.cp = $3;
1083 motdfile: TFILE '=' QSTRING ';'
1089 featuresblock: FEATURES '{' featureitems '}' ';';
1090 featureitems: featureitems featureitem | featureitem;
1092 featureitem: QSTRING
1096 } '=' stringlist ';' {
1098 feature_set(NULL, (const char * const *)stringlist, stringno);
1099 for (ii = 0; ii < stringno; ++ii)
1100 MyFree(stringlist[ii]);
1103 stringlist: stringlist extrastring | extrastring;
1104 extrastring: QSTRING
1106 if (stringno < MAX_STRINGS)
1107 stringlist[stringno++] = $1;
1112 quarantineblock: QUARANTINE '{' quarantineitems '}' ';';
1113 quarantineitems: quarantineitems quarantineitem | quarantineitem;
1114 quarantineitem: QSTRING '=' QSTRING ';'
1116 struct qline *qconf = MyCalloc(1, sizeof(*qconf));
1119 qconf->next = GlobalQuarantineList;
1120 GlobalQuarantineList = qconf;
1123 pseudoblock: PSEUDO QSTRING '{'
1125 smap = MyCalloc(1, sizeof(struct s_map));
1133 parse_error("Missing name in pseudo %s block", smap->command);
1134 else if (!smap->services)
1135 parse_error("Missing nick in pseudo %s block", smap->command);
1136 else if (!strIsAlpha(smap->command))
1137 parse_error("Pseudo command %s invalid: must all be letters", smap->command);
1140 if (valid && register_mapping(smap))
1142 smap->next = GlobalServiceMapList;
1143 GlobalServiceMapList = smap;
1152 pseudoitems: pseudoitem pseudoitems | pseudoitem;
1153 pseudoitem: pseudoname | pseudoprepend | pseudonick | pseudoflags;
1154 pseudoname: NAME '=' QSTRING ';'
1159 pseudoprepend: PREPEND '=' QSTRING ';'
1161 MyFree(smap->prepend);
1164 pseudonick: NICK '=' QSTRING ';'
1166 char *sep = strchr($3, '@');
1169 size_t slen = strlen($3);
1170 struct nick_host *nh = MyMalloc(sizeof(*nh) + slen);
1171 memcpy(nh->nick, $3, slen + 1);
1172 nh->nicklen = sep - $3;
1173 nh->next = smap->services;
1174 smap->services = nh;
1178 pseudoflags: FAST ';'
1180 smap->flags |= SMAP_FAST;
1183 iauthblock: IAUTH '{' iauthitems '}' ';'
1185 auth_spawn(stringno, stringlist, iauth_required);
1186 while (stringno > 0)
1189 MyFree(stringlist[stringno]);
1194 iauthitems: iauthitem iauthitems | iauthitem;
1195 iauthitem: iauthprogram | iauthrequired;
1196 iauthprogram: PROGRAM '='
1198 while (stringno > 0)
1201 MyFree(stringlist[stringno]);
1205 iauthrequired: REQUIRED '=' yesorno ';'
1207 iauth_required = $3;
1210 forwardsblock: FORWARDS {
1212 for(ii = 0; ii < 256; ++ii) {
1213 MyFree(GlobalForwards[ii]);
1215 } '{' forwarditems '}' ';';
1216 forwarditems: forwarditems forwarditem | forwarditem;
1217 forwarditem: QSTRING '=' QSTRING ';'
1219 unsigned char ch = $1[0];
1220 MyFree(GlobalForwards[ch]);
1221 GlobalForwards[ch] = $3;
1225 webircblock: WEBIRC {
1226 /* If we read a new webirc block, we create a new block. */
1227 webirc = webirc_block();
1228 } '{' webircitems '}' ';' {
1229 /* check for integrity */
1230 if(!webirc->name[0]) {
1231 parse_error("Every WebIRC block needs at least a name entry.");
1232 webirc_list_clear(webirc);
1237 webirc_establish(webirc);
1241 webircitems: webircitems webircitem | webircitem;
1242 webircitem: webircpass | webirchost | webircnhost | webircspoof | webircnspoof | webircname;
1243 webircpass: PASS '=' QSTRING ';' {
1245 if((len = strlen($3)) > 0)
1246 webirc_set(webirc, WEBIRC_PASS, $3, len, 0);
1249 webirchost: HOST '=' QSTRING ';' {
1251 if((len = strlen($3)) > 0)
1252 webirc_set(webirc, WEBIRC_HOST, $3, len, 0);
1255 webircnhost: HOST '!' '=' QSTRING ';' {
1257 if((len = strlen($4)) > 0)
1258 webirc_set(webirc, WEBIRC_HOST, $4, len, 1);
1261 webircspoof: SPOOF '=' QSTRING ';' {
1263 if((len = strlen($3)) > 0)
1264 webirc_set(webirc, WEBIRC_SPOOF, $3, len, 0);
1267 webircnspoof: SPOOF '!' '=' QSTRING ';' {
1269 if((len = strlen($4)) > 0)
1270 webirc_set(webirc, WEBIRC_SPOOF, $4, len, 1);
1273 webircname: NAME '=' QSTRING ';' {
1275 if(webirc->name[0]) {
1277 parse_error("Only one name entry per WebIRC is allowed.");
1279 else if((len = strlen($3)) > NICKLEN) {
1281 parse_error("WebIRC block name length is limited to NICKLEN.");
1284 if((len = strlen($3)) > 0) {
1285 strcpy(webirc->name, $3);
1286 webirc->name[len] = '\0';
1292 sslblock: SSL '{' sslitems '}' ';' ;
1293 sslitems: sslitems sslitem | sslitem;
1294 sslitem: sslcert | sslcacert;
1295 sslcert: CERT '=' QSTRING ';' {
1299 sslcacert: CACERT '=' QSTRING ';' {