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,
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;
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;
87 static void parse_error(char *pattern,...) {
88 static char error_buffer[1024];
91 ircd_vsnprintf(NULL, error_buffer, sizeof(error_buffer), pattern, vl);
93 yyerror(error_buffer);
96 static void free_slist(struct SLink **link) {
98 while (*link != NULL) {
100 MyFree((*link)->value.cp);
108 %token <text> QSTRING
176 %token TOK_IPV4 TOK_IPV6
182 /* and now a lot of privileges... */
183 %token TPRIV_CHAN_LIMIT TPRIV_MODE_LCHAN TPRIV_DEOP_LCHAN TPRIV_WALK_LCHAN
184 %token TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE
185 %token TPRIV_GLINE TPRIV_LOCAL_GLINE TPRIV_LOCAL_JUPE TPRIV_LOCAL_BADCHAN
186 %token TPRIV_LOCAL_OPMODE TPRIV_OPMODE TPRIV_SET TPRIV_WHOX TPRIV_BADCHAN
187 %token TPRIV_SEE_CHAN TPRIV_SHOW_INVIS TPRIV_SHOW_ALL_INVIS TPRIV_PROPAGATE
188 %token TPRIV_UNLIMIT_QUERY TPRIV_DISPLAY TPRIV_SEE_OPERS TPRIV_WIDE_GLINE
189 %token TPRIV_FORCE_OPMODE TPRIV_FORCE_LOCAL_OPMODE TPRIV_APASS_OPMODE
190 %token TPRIV_LIST_CHAN
191 /* and some types... */
193 %type <num> timespec timefactor factoredtimes factoredtime
194 %type <num> expr yesorno privtype address_family
204 /* Blocks in the config file... */
205 blocks: blocks block | block;
206 block: adminblock | generalblock | classblock | connectblock | sslblock |
207 uworldblock | operblock | portblock | jupeblock | clientblock |
208 killblock | cruleblock | motdblock | featuresblock | quarantineblock |
209 pseudoblock | iauthblock | error ';';
211 /* The timespec, sizespec and expr was ripped straight from
213 timespec: expr | factoredtimes;
215 factoredtimes: factoredtimes factoredtime
220 factoredtime: expr timefactor
225 timefactor: SECONDS { $$ = 1; }
226 | MINUTES { $$ = 60; }
227 | HOURS { $$ = 60 * 60; }
228 | DAYS { $$ = 60 * 60 * 24; }
229 | WEEKS { $$ = 60 * 60 * 24 * 7; }
230 | MONTHS { $$ = 60 * 60 * 24 * 7 * 4; }
231 | YEARS { $$ = 60 * 60 * 24 * 365; }
232 | DECADES { $$ = 60 * 60 * 24 * 365 * 10; };
245 $$ = $1 * 1024 * 1024;
248 $$ = $1 * 1024 * 1024 * 1024;
251 $$ = $1 * 1024 * 1024 * 1024;
255 /* this is an arithmetic expression */
272 /* leave this out until we find why it makes BSD yacc dump core -larne
273 | '-' expr %prec NEG {
281 jupeblock: JUPE '{' jupeitems '}' ';' ;
282 jupeitems: jupeitem jupeitems | jupeitem;
284 jupenick: NICK '=' QSTRING ';'
290 generalblock: GENERAL
292 /* Zero out the vhost addresses, in case they were removed. */
293 memset(&VirtualHost_v4.addr, 0, sizeof(VirtualHost_v4.addr));
294 memset(&VirtualHost_v6.addr, 0, sizeof(VirtualHost_v6.addr));
295 } '{' generalitems '}' ';' {
296 if (localConf.name == NULL)
297 parse_error("Your General block must contain a name.");
298 if (localConf.numeric == 0)
299 parse_error("Your General block must contain a numeric (between 1 and 4095).");
301 generalitems: generalitem generalitems | generalitem;
302 generalitem: generalnumeric | generalname | generalvhost | generaldesc
303 | generaldnsvhost | generaldnsserver;
305 generalnumeric: NUMERIC '=' NUMBER ';'
307 if (localConf.numeric == 0)
308 localConf.numeric = $3;
309 else if (localConf.numeric != $3)
310 parse_error("Redefinition of server numeric %i (%i)", $3,
314 generalname: NAME '=' QSTRING ';'
316 if (localConf.name == NULL)
319 if (strcmp(localConf.name, $3))
320 parse_error("Redefinition of server name %s (%s)", $3,
326 generaldesc: DESCRIPTION '=' QSTRING ';'
328 MyFree(localConf.description);
329 localConf.description = $3;
330 ircd_strncpy(cli_info(&me), $3, REALLEN);
333 generalvhost: VHOST '=' QSTRING ';'
335 struct irc_in_addr addr;
338 if (!strcmp(vhost, "*")) {
339 /* This traditionally meant bind to all interfaces and connect
340 * from the default. */
341 } else if (!ircd_aton(&addr, vhost))
342 parse_error("Invalid virtual host '%s'.", vhost);
343 else if (irc_in_addr_is_ipv4(&addr))
344 memcpy(&VirtualHost_v4.addr, &addr, sizeof(addr));
346 memcpy(&VirtualHost_v6.addr, &addr, sizeof(addr));
350 generaldnsvhost: DNS VHOST '=' address_family QSTRING ';'
352 struct irc_in_addr addr;
356 if (!strcmp(vhost, "*")) {
357 /* Let the operating system assign the default. */
358 } else if (!ircd_aton(&addr, vhost))
359 parse_error("Invalid DNS virtual host '%s'.", vhost);
362 if ((families & USE_IPV4)
363 || (!families && irc_in_addr_is_ipv4(&addr)))
364 memcpy(&VirtualHost_dns_v4.addr, &addr, sizeof(addr));
365 if ((families & USE_IPV6)
366 || (!families && !irc_in_addr_is_ipv4(&addr)))
367 memcpy(&VirtualHost_dns_v6.addr, &addr, sizeof(addr));
372 generaldnsserver: DNS SERVER '=' QSTRING ';'
376 add_nameserver(server);
382 MyFree(localConf.location1);
383 MyFree(localConf.location2);
384 MyFree(localConf.contact);
385 localConf.location1 = localConf.location2 = localConf.contact = NULL;
387 '{' adminitems '}' ';'
389 if (localConf.location1 == NULL)
390 DupString(localConf.location1, "");
391 if (localConf.location2 == NULL)
392 DupString(localConf.location2, "");
393 if (localConf.contact == NULL)
394 DupString(localConf.contact, "");
396 adminitems: adminitems adminitem | adminitem;
397 adminitem: adminlocation | admincontact;
398 adminlocation: LOCATION '=' QSTRING ';'
400 if (localConf.location1 == NULL)
401 localConf.location1 = $3;
402 else if (localConf.location2 == NULL)
403 localConf.location2 = $3;
404 else /* Otherwise just drop it. -A1kmm */
407 admincontact: CONTACT '=' QSTRING ';'
409 MyFree(localConf.contact);
410 localConf.contact = $3;
415 MyFree(localConf.sslcertfile);
416 MyFree(localConf.sslkeyfile);
417 MyFree(localConf.sslcafile);
418 localConf.sslcertfile = localConf.sslkeyfile = localConf.sslcafile = NULL;
422 if (localConf.sslcertfile == NULL)
423 DupString(localConf.sslcertfile, "");
424 if (localConf.sslkeyfile == NULL)
425 DupString(localConf.sslkeyfile, "");
426 if (localConf.sslcafile == NULL)
427 DupString(localConf.sslcafile, "");
429 sslitems: sslitems sslitem | sslitem;
430 sslitem: sslcertfile | sslkeyfile | sslcafile;
431 sslcertfile: CERTFILE '=' QSTRING ';'
433 MyFree(localConf.sslcertfile);
434 localConf.sslcertfile = $3;
436 sslkeyfile: KEYFILE '=' QSTRING ';'
438 MyFree(localConf.sslkeyfile);
439 localConf.sslkeyfile = $3;
441 sslcafile: CAFILE '=' QSTRING ';'
443 MyFree(localConf.sslcafile);
444 localConf.sslcafile = $3;
449 } '{' classitems '}' ';'
453 struct ConnectionClass *c_class;
454 add_class(name, tping, tconn, maxlinks, sendq);
455 c_class = find_class(name);
456 MyFree(c_class->default_umode);
457 c_class->default_umode = pass;
458 memcpy(&c_class->privs, &privs, sizeof(c_class->privs));
459 memcpy(&c_class->privs_dirty, &privs_dirty, sizeof(c_class->privs_dirty));
462 parse_error("Missing name in class block");
469 memset(&privs, 0, sizeof(privs));
470 memset(&privs_dirty, 0, sizeof(privs_dirty));
472 classitems: classitem classitems | classitem;
473 classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
474 classsendq | classusermode | priv;
475 classname: NAME '=' QSTRING ';'
480 classpingfreq: PINGFREQ '=' timespec ';'
484 classconnfreq: CONNECTFREQ '=' timespec ';'
488 classmaxlinks: MAXLINKS '=' expr ';'
492 classsendq: SENDQ '=' sizespec ';'
496 classusermode: USERMODE '=' QSTRING ';'
502 connectblock: CONNECT
504 flags = CONF_AUTOCONNECT;
505 } '{' connectitems '}' ';'
507 struct ConfItem *aconf = NULL;
509 parse_error("Missing name in connect block");
510 else if (pass == NULL)
511 parse_error("Missing password in connect block");
512 else if (strlen(pass) > PASSWDLEN)
513 parse_error("Password too long in connect block");
514 else if (host == NULL)
515 parse_error("Missing host in connect block");
516 else if (strchr(host, '*') || strchr(host, '?'))
517 parse_error("Invalid host '%s' in connect block", host);
518 else if (c_class == NULL)
519 parse_error("Missing or non-existent class in connect block");
521 aconf = make_conf(CONF_SERVER);
523 aconf->origin_name = origin;
524 aconf->passwd = pass;
525 aconf->conn_class = c_class;
526 aconf->address.port = port;
528 /* If the user specified a hub allowance, but not maximum links,
529 * allow an effectively unlimited number of hops.
531 aconf->maximum = (hub_limit != NULL && maxlinks == 0) ? 65535 : maxlinks;
532 aconf->hub_limit = hub_limit;
533 aconf->flags = flags;
534 lookup_confhost(aconf);
543 name = pass = host = origin = hub_limit = NULL;
545 port = flags = maxlinks = 0;
547 connectitems: connectitem connectitems | connectitem;
548 connectitem: connectname | connectpass | connectclass | connecthost
549 | connectport | connectvhost | connectleaf | connecthub
550 | connecthublimit | connectmaxhops | connectauto;
551 connectname: NAME '=' QSTRING ';'
556 connectpass: PASS '=' QSTRING ';'
561 connectclass: CLASS '=' QSTRING ';'
563 c_class = find_class($3);
565 parse_error("No such connection class '%s' for Connect block", $3);
568 connecthost: HOST '=' QSTRING ';'
573 connectport: PORT '=' NUMBER ';'
577 connectvhost: VHOST '=' QSTRING ';'
582 connectleaf: LEAF ';'
589 DupString(hub_limit, "*");
591 connecthublimit: HUB '=' QSTRING ';'
596 connectmaxhops: MAXHOPS '=' expr ';'
600 connectauto: AUTOCONNECT '=' YES ';' { flags |= CONF_AUTOCONNECT; }
601 | AUTOCONNECT '=' NO ';' { flags &= ~CONF_AUTOCONNECT; };
603 uworldblock: UWORLD '{' uworlditems '}' ';';
604 uworlditems: uworlditem uworlditems | uworlditem;
605 uworlditem: uworldname;
606 uworldname: NAME '=' QSTRING ';'
608 make_conf(CONF_UWORLD)->host = $3;
611 operblock: OPER '{' operitems '}' ';'
613 struct ConfItem *aconf = NULL;
617 parse_error("Missing name in operator block");
618 else if (pass == NULL)
619 parse_error("Missing password in operator block");
620 /* Do not check password length because it may be crypted. */
621 else if (hosts == NULL)
622 parse_error("Missing host(s) in operator block");
623 else if (c_class == NULL)
624 parse_error("Invalid or missing class in operator block");
625 else if (!FlagHas(&privs_dirty, PRIV_PROPAGATE)
626 && !FlagHas(&c_class->privs_dirty, PRIV_PROPAGATE))
627 parse_error("Operator block for %s and class %s have no LOCAL setting", name, c_class->cc_name);
628 else for (link = hosts; link != NULL; link = link->next) {
629 aconf = make_conf(CONF_OPERATOR);
630 DupString(aconf->name, name);
631 DupString(aconf->passwd, pass);
632 conf_parse_userhost(aconf, link->value.cp);
633 aconf->conn_class = c_class;
634 memcpy(&aconf->privs, &privs, sizeof(aconf->privs));
635 memcpy(&aconf->privs_dirty, &privs_dirty, sizeof(aconf->privs_dirty));
642 memset(&privs, 0, sizeof(privs));
643 memset(&privs_dirty, 0, sizeof(privs_dirty));
645 operitems: operitem | operitems operitem;
646 operitem: opername | operpass | operhost | operclass | priv;
647 opername: NAME '=' QSTRING ';'
652 operpass: PASS '=' QSTRING ';'
657 operhost: HOST '=' QSTRING ';'
661 if (!strchr($3, '@'))
664 link->value.cp = (char*) MyMalloc((uh_len = strlen($3)+3));
665 ircd_snprintf(0, link->value.cp, uh_len, "*@%s", $3);
668 DupString(link->value.cp, $3);
673 operclass: CLASS '=' QSTRING ';'
675 c_class = find_class($3);
677 parse_error("No such connection class '%s' for Operator block", $3);
681 priv: privtype '=' yesorno ';'
683 FlagSet(&privs_dirty, $1);
684 if (($3 == 1) ^ invert)
691 privtype: TPRIV_CHAN_LIMIT { $$ = PRIV_CHAN_LIMIT; } |
692 TPRIV_MODE_LCHAN { $$ = PRIV_MODE_LCHAN; } |
693 TPRIV_DEOP_LCHAN { $$ = PRIV_DEOP_LCHAN; } |
694 TPRIV_WALK_LCHAN { $$ = PRIV_WALK_LCHAN; } |
695 KILL { $$ = PRIV_KILL; } |
696 TPRIV_LOCAL_KILL { $$ = PRIV_LOCAL_KILL; } |
697 TPRIV_REHASH { $$ = PRIV_REHASH; } |
698 TPRIV_RESTART { $$ = PRIV_RESTART; } |
699 TPRIV_DIE { $$ = PRIV_DIE; } |
700 TPRIV_GLINE { $$ = PRIV_GLINE; } |
701 TPRIV_LOCAL_GLINE { $$ = PRIV_LOCAL_GLINE; } |
702 JUPE { $$ = PRIV_JUPE; } |
703 TPRIV_LOCAL_JUPE { $$ = PRIV_LOCAL_JUPE; } |
704 TPRIV_LOCAL_OPMODE { $$ = PRIV_LOCAL_OPMODE; } |
705 TPRIV_OPMODE { $$ = PRIV_OPMODE; }|
706 TPRIV_SET { $$ = PRIV_SET; } |
707 TPRIV_WHOX { $$ = PRIV_WHOX; } |
708 TPRIV_BADCHAN { $$ = PRIV_BADCHAN; } |
709 TPRIV_LOCAL_BADCHAN { $$ = PRIV_LOCAL_BADCHAN; } |
710 TPRIV_SEE_CHAN { $$ = PRIV_SEE_CHAN; } |
711 TPRIV_SHOW_INVIS { $$ = PRIV_SHOW_INVIS; } |
712 TPRIV_SHOW_ALL_INVIS { $$ = PRIV_SHOW_ALL_INVIS; } |
713 TPRIV_PROPAGATE { $$ = PRIV_PROPAGATE; } |
714 TPRIV_UNLIMIT_QUERY { $$ = PRIV_UNLIMIT_QUERY; } |
715 TPRIV_DISPLAY { $$ = PRIV_DISPLAY; } |
716 TPRIV_SEE_OPERS { $$ = PRIV_SEE_OPERS; } |
717 TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; } |
718 TPRIV_LIST_CHAN { $$ = PRIV_LIST_CHAN; } |
719 LOCAL { $$ = PRIV_PROPAGATE; invert = 1; } |
720 TPRIV_FORCE_OPMODE { $$ = PRIV_FORCE_OPMODE; } |
721 TPRIV_FORCE_LOCAL_OPMODE { $$ = PRIV_FORCE_LOCAL_OPMODE; } |
722 TPRIV_APASS_OPMODE { $$ = PRIV_APASS_OPMODE; } ;
724 yesorno: YES { $$ = 1; } | NO { $$ = 0; };
726 /* not a recursive definition because some pedant will just come along
727 * and whine that the parser accepts "ipv4 ipv4 ipv4 ipv4"
731 | TOK_IPV4 { $$ = USE_IPV4; }
732 | TOK_IPV6 { $$ = USE_IPV6; }
733 | TOK_IPV4 TOK_IPV6 { $$ = USE_IPV4 | USE_IPV6; }
734 | TOK_IPV6 TOK_IPV4 { $$ = USE_IPV6 | USE_IPV4; }
737 /* The port block... */
738 portblock: PORT '{' portitems '}' ';' {
739 struct ListenerFlags flags_here;
744 DupString(link->value.cp, "*");
749 for (link = hosts; link != NULL; link = link->next) {
750 memcpy(&flags_here, &listen_flags, sizeof(flags_here));
751 switch (link->flags & (USE_IPV4 | USE_IPV6)) {
753 FlagSet(&flags_here, LISTEN_IPV4);
756 FlagSet(&flags_here, LISTEN_IPV6);
758 default: /* 0 or USE_IPV4|USE_IPV6 */
759 FlagSet(&flags_here, LISTEN_IPV4);
760 FlagSet(&flags_here, LISTEN_IPV6);
764 if (link->flags & 65535)
765 port = link->flags & 65535;
766 add_listener(port, link->value.cp, pass, &flags_here);
770 memset(&listen_flags, 0, sizeof(listen_flags));
774 portitems: portitem portitems | portitem;
775 portitem: portnumber | portvhost | portvhostnumber | portmask | portserver | portssl | porthidden;
776 portnumber: PORT '=' address_family NUMBER ';'
778 if ($4 < 1 || $4 > 65535) {
779 parse_error("Port %d is out of range", port);
782 if (hosts && (0 == (hosts->flags & 65535)))
783 hosts->flags = (hosts->flags & ~65535) | port;
787 portvhost: VHOST '=' address_family QSTRING ';'
792 link->flags = $3 | port;
797 portvhostnumber: VHOST '=' address_family QSTRING NUMBER ';'
799 if ($5 < 1 || $5 > 65535) {
800 parse_error("Port %d is out of range", port);
805 link->flags = $3 | $5;
811 portmask: MASK '=' QSTRING ';'
817 portserver: SERVER '=' YES ';'
819 FlagSet(&listen_flags, LISTEN_SERVER);
820 } | SERVER '=' NO ';'
822 FlagClr(&listen_flags, LISTEN_SERVER);
825 portssl: SSL '=' YES ';'
827 FlagSet(&listen_flags, LISTEN_SSL);
830 FlagClr(&listen_flags, LISTEN_SSL);
833 porthidden: HIDDEN '=' YES ';'
835 FlagSet(&listen_flags, LISTEN_HIDDEN);
836 } | HIDDEN '=' NO ';'
838 FlagClr(&listen_flags, LISTEN_HIDDEN);
846 '{' clientitems '}' ';'
848 struct ConfItem *aconf = 0;
849 struct irc_in_addr addr;
850 unsigned char addrbits = 0;
853 parse_error("Invalid or missing class in Client block");
854 else if (pass && strlen(pass) > PASSWDLEN)
855 parse_error("Password too long in connect block");
856 else if (ip && !ipmask_parse(ip, &addr, &addrbits))
857 parse_error("Invalid IP address %s in Client block", ip);
859 aconf = make_conf(CONF_CLIENT);
860 aconf->username = username;
863 memcpy(&aconf->address.addr, &addr, sizeof(aconf->address.addr));
865 memset(&aconf->address.addr, 0, sizeof(aconf->address.addr));
866 aconf->address.port = port;
867 aconf->addrbits = addrbits;
869 aconf->conn_class = c_class;
870 aconf->maximum = maxlinks;
871 aconf->passwd = pass;
887 clientitems: clientitem clientitems | clientitem;
888 clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks | clientport;
889 clienthost: HOST '=' QSTRING ';'
891 char *sep = strchr($3, '@');
896 DupString(host, sep);
902 clientip: IP '=' QSTRING ';'
905 sep = strchr($3, '@');
916 clientusername: USERNAME '=' QSTRING ';'
921 clientclass: CLASS '=' QSTRING ';'
923 c_class = find_class($3);
925 parse_error("No such connection class '%s' for Client block", $3);
928 clientpass: PASS '=' QSTRING ';'
933 clientmaxlinks: MAXLINKS '=' expr ';'
937 clientport: PORT '=' expr ';'
944 dconf = (struct DenyConf*) MyCalloc(1, sizeof(*dconf));
945 } '{' killitems '}' ';'
947 if (dconf->usermask || dconf->hostmask ||dconf->realmask) {
948 dconf->next = denyConfList;
949 denyConfList = dconf;
953 MyFree(dconf->usermask);
954 MyFree(dconf->hostmask);
955 MyFree(dconf->realmask);
956 MyFree(dconf->message);
958 parse_error("Kill block must match on at least one of username, host or realname");
962 killitems: killitem killitems | killitem;
963 killitem: killuhost | killreal | killusername | killreasonfile | killreason;
964 killuhost: HOST '=' QSTRING ';'
967 MyFree(dconf->hostmask);
968 MyFree(dconf->usermask);
969 if ((h = strchr($3, '@')) == NULL)
971 DupString(dconf->usermask, "*");
972 dconf->hostmask = $3;
977 DupString(dconf->hostmask, h);
978 dconf->usermask = $3;
980 ipmask_parse(dconf->hostmask, &dconf->address, &dconf->bits);
983 killusername: USERNAME '=' QSTRING ';'
985 MyFree(dconf->usermask);
986 dconf->usermask = $3;
989 killreal: REAL '=' QSTRING ';'
991 MyFree(dconf->realmask);
992 dconf->realmask = $3;
995 killreason: REASON '=' QSTRING ';'
997 dconf->flags &= ~DENY_FLAGS_FILE;
998 MyFree(dconf->message);
1002 killreasonfile: TFILE '=' QSTRING ';'
1004 dconf->flags |= DENY_FLAGS_FILE;
1005 MyFree(dconf->message);
1006 dconf->message = $3;
1012 } '{' cruleitems '}' ';'
1014 struct CRuleNode *node = NULL;
1018 parse_error("Missing server(s) in crule block");
1019 else if (pass == NULL)
1020 parse_error("Missing rule in crule block");
1021 else if ((node = crule_parse(pass)) == NULL)
1022 parse_error("Invalid rule '%s' in crule block", pass);
1023 else for (link = hosts; link != NULL; link = link->next)
1025 struct CRuleConf *p = (struct CRuleConf*) MyMalloc(sizeof(*p));
1027 node = crule_parse(pass);
1028 DupString(p->hostmask, link->value.cp);
1029 DupString(p->rule, pass);
1033 p->next = cruleConfList;
1042 cruleitems: cruleitem cruleitems | cruleitem;
1043 cruleitem: cruleserver | crulerule | cruleall;
1045 cruleserver: SERVER '=' QSTRING ';'
1049 link->value.cp = $3;
1054 crulerule: RULE '=' QSTRING ';'
1060 cruleall: ALL '=' YES ';'
1068 motdblock: MOTD '{' motditems '}' ';'
1072 for (link = hosts; link != NULL; link = link->next)
1073 motd_add(link->value.cp, pass);
1079 motditems: motditem motditems | motditem;
1080 motditem: motdhost | motdfile;
1081 motdhost: HOST '=' QSTRING ';'
1085 link->value.cp = $3;
1090 motdfile: TFILE '=' QSTRING ';'
1096 featuresblock: FEATURES '{' featureitems '}' ';';
1097 featureitems: featureitems featureitem | featureitem;
1099 featureitem: QSTRING
1103 } '=' stringlist ';' {
1105 feature_set(NULL, (const char * const *)stringlist, stringno);
1106 for (ii = 0; ii < stringno; ++ii)
1107 MyFree(stringlist[ii]);
1110 stringlist: stringlist extrastring | extrastring;
1111 extrastring: QSTRING
1113 if (stringno < MAX_STRINGS)
1114 stringlist[stringno++] = $1;
1119 quarantineblock: QUARANTINE '{' quarantineitems '}' ';';
1120 quarantineitems: quarantineitems quarantineitem | quarantineitem;
1121 quarantineitem: QSTRING '=' QSTRING ';'
1123 struct qline *qconf = MyCalloc(1, sizeof(*qconf));
1126 qconf->next = GlobalQuarantineList;
1127 GlobalQuarantineList = qconf;
1130 pseudoblock: PSEUDO QSTRING '{'
1132 smap = MyCalloc(1, sizeof(struct s_map));
1140 parse_error("Missing name in pseudo %s block", smap->command);
1141 else if (!smap->services)
1142 parse_error("Missing nick in pseudo %s block", smap->command);
1143 else if (!strIsAlpha(smap->command))
1144 parse_error("Pseudo command %s invalid: must all be letters", smap->command);
1147 if (valid && register_mapping(smap))
1149 smap->next = GlobalServiceMapList;
1150 GlobalServiceMapList = smap;
1159 pseudoitems: pseudoitem pseudoitems | pseudoitem;
1160 pseudoitem: pseudoname | pseudoprepend | pseudonick | pseudoflags;
1161 pseudoname: NAME '=' QSTRING ';'
1166 pseudoprepend: PREPEND '=' QSTRING ';'
1168 MyFree(smap->prepend);
1171 pseudonick: NICK '=' QSTRING ';'
1173 char *sep = strchr($3, '@');
1176 size_t slen = strlen($3);
1177 struct nick_host *nh = MyMalloc(sizeof(*nh) + slen);
1178 memcpy(nh->nick, $3, slen + 1);
1179 nh->nicklen = sep - $3;
1180 nh->next = smap->services;
1181 smap->services = nh;
1185 pseudoflags: FAST ';'
1187 smap->flags |= SMAP_FAST;
1190 iauthblock: IAUTH '{' iauthitems '}' ';'
1192 auth_spawn(stringno, stringlist);
1193 while (stringno > 0)
1196 MyFree(stringlist[stringno]);
1200 iauthitems: iauthitem iauthitems | iauthitem;
1201 iauthitem: iauthprogram;
1202 iauthprogram: PROGRAM '='
1204 while (stringno > 0)
1207 MyFree(stringlist[stringno]);