/[svn]/ircd-hybrid-7.2/src/ircd_parser.y
ViewVC logotype

Contents of /ircd-hybrid-7.2/src/ircd_parser.y

Parent Directory Parent Directory | Revision Log Revision Log


Revision 584 - (show annotations)
Sun May 7 15:26:45 2006 UTC (14 years, 8 months ago) by michael
File size: 89035 byte(s)
- Added new general::stats_e_disabled configuration option.  Known from RB,
  all it does is to disable "STATS e", which is a good idea if you have any
  exempted server ips.
- Updated RELNOTES

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * ircd_parser.y: Parses the ircd configuration file.
4 *
5 * Copyright (C) 2005 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 %{
26
27 #define YY_NO_UNPUT
28 #include <sys/types.h>
29
30 #include "stdinc.h"
31 #include "dalloca.h"
32 #include "ircd.h"
33 #include "tools.h"
34 #include "list.h"
35 #include "s_conf.h"
36 #include "event.h"
37 #include "s_log.h"
38 #include "client.h" /* for UMODE_ALL only */
39 #include "pcre.h"
40 #include "irc_string.h"
41 #include "irc_getaddrinfo.h"
42 #include "sprintf_irc.h"
43 #include "memory.h"
44 #include "modules.h"
45 #include "s_serv.h" /* for CAP_LL / IsCapable */
46 #include "hostmask.h"
47 #include "send.h"
48 #include "listener.h"
49 #include "resv.h"
50 #include "numeric.h"
51 #include "s_user.h"
52
53 #ifdef HAVE_LIBCRYPTO
54 #include <openssl/rsa.h>
55 #include <openssl/bio.h>
56 #include <openssl/pem.h>
57 #endif
58
59 static char *class_name = NULL;
60 static struct ConfItem *yy_conf = NULL;
61 static struct AccessItem *yy_aconf = NULL;
62 static struct MatchItem *yy_match_item = NULL;
63 static struct ClassItem *yy_class = NULL;
64 static char *yy_class_name = NULL;
65
66 static dlink_list col_conf_list = { NULL, NULL, 0 };
67 static dlink_list hub_conf_list = { NULL, NULL, 0 };
68 static dlink_list leaf_conf_list = { NULL, NULL, 0 };
69 static unsigned int listener_flags = 0;
70 static unsigned int regex_ban = 0;
71 static char userbuf[IRCD_BUFSIZE];
72 static char hostbuf[IRCD_BUFSIZE];
73 static char reasonbuf[REASONLEN + 1];
74 static char gecos_name[REALLEN * 4];
75
76 extern dlink_list gdeny_items; /* XXX */
77
78 static char *resv_reason = NULL;
79 static char *listener_address = NULL;
80 static int not_atom = 0;
81
82 struct CollectItem {
83 dlink_node node;
84 char *name;
85 char *user;
86 char *host;
87 char *passwd;
88 int port;
89 int flags;
90 #ifdef HAVE_LIBCRYPTO
91 char *rsa_public_key_file;
92 RSA *rsa_public_key;
93 #endif
94 };
95
96 static void
97 free_collect_item(struct CollectItem *item)
98 {
99 MyFree(item->name);
100 MyFree(item->user);
101 MyFree(item->host);
102 MyFree(item->passwd);
103 #ifdef HAVE_LIBCRYPTO
104 MyFree(item->rsa_public_key_file);
105 #endif
106 MyFree(item);
107 }
108
109 static void
110 unhook_hub_leaf_confs(void)
111 {
112 dlink_node *ptr;
113 dlink_node *next_ptr;
114 struct CollectItem *yy_hconf;
115 struct CollectItem *yy_lconf;
116
117 DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
118 {
119 yy_hconf = ptr->data;
120 dlinkDelete(&yy_hconf->node, &hub_conf_list);
121 free_collect_item(yy_hconf);
122 }
123
124 DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
125 {
126 yy_lconf = ptr->data;
127 dlinkDelete(&yy_lconf->node, &leaf_conf_list);
128 free_collect_item(yy_lconf);
129 }
130 }
131
132 %}
133
134 %union {
135 int number;
136 char *string;
137 }
138
139 %token ACCEPT_PASSWORD
140 %token ACTION
141 %token ADMIN
142 %token AFTYPE
143 %token T_ALLOW
144 %token ANTI_NICK_FLOOD
145 %token ANTI_SPAM_EXIT_MESSAGE_TIME
146 %token AUTOCONN
147 %token T_BLOCK
148 %token BURST_AWAY
149 %token BURST_TOPICWHO
150 %token BYTES KBYTES MBYTES GBYTES TBYTES
151 %token CALLER_ID_WAIT
152 %token CAN_FLOOD
153 %token CAN_IDLE
154 %token CHANNEL
155 %token CIDR_BITLEN_IPV4
156 %token CIDR_BITLEN_IPV6
157 %token CIPHER_PREFERENCE
158 %token CLASS
159 %token COMPRESSED
160 %token COMPRESSION_LEVEL
161 %token CONNECT
162 %token CONNECTFREQ
163 %token CRYPTLINK
164 %token DEFAULT_CIPHER_PREFERENCE
165 %token DEFAULT_FLOODCOUNT
166 %token DEFAULT_SPLIT_SERVER_COUNT
167 %token DEFAULT_SPLIT_USER_COUNT
168 %token DENY
169 %token DESCRIPTION
170 %token DIE
171 %token DISABLE_AUTH
172 %token DISABLE_HIDDEN
173 %token DISABLE_LOCAL_CHANNELS
174 %token DISABLE_REMOTE_COMMANDS
175 %token DOT_IN_IP6_ADDR
176 %token DOTS_IN_IDENT
177 %token DURATION
178 %token EGDPOOL_PATH
179 %token EMAIL
180 %token ENABLE
181 %token ENCRYPTED
182 %token EXCEED_LIMIT
183 %token EXEMPT
184 %token FAILED_OPER_NOTICE
185 %token FAKENAME
186 %token IRCD_FLAGS
187 %token FLATTEN_LINKS
188 %token FFAILED_OPERLOG
189 %token FKILLLOG
190 %token FKLINELOG
191 %token FGLINELOG
192 %token FIOERRLOG
193 %token FOPERLOG
194 %token FOPERSPYLOG
195 %token FUSERLOG
196 %token GECOS
197 %token GENERAL
198 %token GLINE
199 %token GLINES
200 %token GLINE_EXEMPT
201 %token GLINE_LOG
202 %token GLINE_TIME
203 %token GLINE_MIN_CIDR
204 %token GLINE_MIN_CIDR6
205 %token GLOBAL_KILL
206 %token IRCD_AUTH
207 %token NEED_IDENT
208 %token HAVENT_READ_CONF
209 %token HIDDEN
210 %token HIDDEN_ADMIN
211 %token HIDDEN_NAME
212 %token HIDDEN_OPER
213 %token HIDE_SERVER_IPS
214 %token HIDE_SERVERS
215 %token HIDE_SPOOF_IPS
216 %token HOST
217 %token HUB
218 %token HUB_MASK
219 %token IDLETIME
220 %token IGNORE_BOGUS_TS
221 %token INVISIBLE_ON_CONNECT
222 %token IP
223 %token KILL
224 %token KILL_CHASE_TIME_LIMIT
225 %token KLINE
226 %token KLINE_EXEMPT
227 %token KLINE_REASON
228 %token KLINE_WITH_REASON
229 %token KNOCK_DELAY
230 %token KNOCK_DELAY_CHANNEL
231 %token LAZYLINK
232 %token LEAF_MASK
233 %token LINKS_DELAY
234 %token LISTEN
235 %token T_LOG
236 %token LOGGING
237 %token LOG_LEVEL
238 %token MAX_ACCEPT
239 %token MAX_BANS
240 %token MAX_CHANS_PER_USER
241 %token MAX_GLOBAL
242 %token MAX_IDENT
243 %token MAX_LOCAL
244 %token MAX_NICK_CHANGES
245 %token MAX_NICK_TIME
246 %token MAX_NUMBER
247 %token MAX_TARGETS
248 %token MESSAGE_LOCALE
249 %token MIN_NONWILDCARD
250 %token MIN_NONWILDCARD_SIMPLE
251 %token MODULE
252 %token MODULES
253 %token NAME
254 %token NEED_PASSWORD
255 %token NETWORK_DESC
256 %token NETWORK_NAME
257 %token NICK
258 %token NICK_CHANGES
259 %token NO_CREATE_ON_SPLIT
260 %token NO_JOIN_ON_SPLIT
261 %token NO_OPER_FLOOD
262 %token NO_TILDE
263 %token NOT
264 %token NUMBER
265 %token NUMBER_PER_IDENT
266 %token NUMBER_PER_CIDR
267 %token NUMBER_PER_IP
268 %token NUMBER_PER_IP_GLOBAL
269 %token OPERATOR
270 %token OPERS_BYPASS_CALLERID
271 %token OPER_LOG
272 %token OPER_ONLY_UMODES
273 %token OPER_PASS_RESV
274 %token OPER_SPY_T
275 %token OPER_UMODES
276 %token JOIN_FLOOD_COUNT
277 %token JOIN_FLOOD_TIME
278 %token PACE_WAIT
279 %token PACE_WAIT_SIMPLE
280 %token PASSWORD
281 %token PATH
282 %token PING_COOKIE
283 %token PING_TIME
284 %token PING_WARNING
285 %token PORT
286 %token QSTRING
287 %token QUIET_ON_BAN
288 %token REASON
289 %token REDIRPORT
290 %token REDIRSERV
291 %token REGEX_T
292 %token REHASH
293 %token TREJECT_HOLD_TIME
294 %token REMOTE
295 %token REMOTEBAN
296 %token RESTRICT_CHANNELS
297 %token RESTRICTED
298 %token RSA_PRIVATE_KEY_FILE
299 %token RSA_PUBLIC_KEY_FILE
300 %token SSL_CERTIFICATE_FILE
301 %token RESV
302 %token RESV_EXEMPT
303 %token SECONDS MINUTES HOURS DAYS WEEKS
304 %token SENDQ
305 %token SEND_PASSWORD
306 %token SERVERHIDE
307 %token SERVERINFO
308 %token SERVLINK_PATH
309 %token IRCD_SID
310 %token TKLINE_EXPIRE_NOTICES
311 %token T_SHARED
312 %token T_CLUSTER
313 %token TYPE
314 %token SHORT_MOTD
315 %token SILENT
316 %token SPOOF
317 %token SPOOF_NOTICE
318 %token STATS_E_DISABLED
319 %token STATS_I_OPER_ONLY
320 %token STATS_K_OPER_ONLY
321 %token STATS_O_OPER_ONLY
322 %token STATS_P_OPER_ONLY
323 %token TBOOL
324 %token TMASKED
325 %token T_REJECT
326 %token TS_MAX_DELTA
327 %token TS_WARN_DELTA
328 %token TWODOTS
329 %token T_ALL
330 %token T_BOTS
331 %token T_SOFTCALLERID
332 %token T_CALLERID
333 %token T_CCONN
334 %token T_CLIENT_FLOOD
335 %token T_DEAF
336 %token T_DEBUG
337 %token T_DRONE
338 %token T_EXTERNAL
339 %token T_FULL
340 %token T_INVISIBLE
341 %token T_IPV4
342 %token T_IPV6
343 %token T_LOCOPS
344 %token T_LOGPATH
345 %token T_L_CRIT
346 %token T_L_DEBUG
347 %token T_L_ERROR
348 %token T_L_INFO
349 %token T_L_NOTICE
350 %token T_L_TRACE
351 %token T_L_WARN
352 %token T_MAX_CLIENTS
353 %token T_NCHANGE
354 %token T_OPERWALL
355 %token T_REJ
356 %token T_SERVNOTICE
357 %token T_SKILL
358 %token T_SPY
359 %token T_SSL
360 %token T_UMODES
361 %token T_UNAUTH
362 %token T_UNRESV
363 %token T_UNXLINE
364 %token T_WALLOP
365 %token THROTTLE_TIME
366 %token TOPICBURST
367 %token TRUE_NO_OPER_FLOOD
368 %token TKLINE
369 %token TXLINE
370 %token TRESV
371 %token UNKLINE
372 %token USER
373 %token USE_EGD
374 %token USE_EXCEPT
375 %token USE_INVEX
376 %token USE_KNOCK
377 %token USE_LOGGING
378 %token USE_WHOIS_ACTUALLY
379 %token VHOST
380 %token VHOST6
381 %token XLINE
382 %token WARN
383 %token WARN_NO_NLINE
384
385 %type <string> QSTRING
386 %type <number> NUMBER
387 %type <number> timespec
388 %type <number> timespec_
389 %type <number> sizespec
390 %type <number> sizespec_
391
392 %%
393 conf:
394 | conf conf_item
395 ;
396
397 conf_item: admin_entry
398 | logging_entry
399 | oper_entry
400 | channel_entry
401 | class_entry
402 | listen_entry
403 | auth_entry
404 | serverinfo_entry
405 | serverhide_entry
406 | resv_entry
407 | shared_entry
408 | cluster_entry
409 | connect_entry
410 | kill_entry
411 | deny_entry
412 | exempt_entry
413 | general_entry
414 | gline_entry
415 | gecos_entry
416 | modules_entry
417 | error ';'
418 | error '}'
419 ;
420
421
422 timespec_: { $$ = 0; } | timespec;
423 timespec: NUMBER timespec_
424 {
425 $$ = $1 + $2;
426 }
427 | NUMBER SECONDS timespec_
428 {
429 $$ = $1 + $3;
430 }
431 | NUMBER MINUTES timespec_
432 {
433 $$ = $1 * 60 + $3;
434 }
435 | NUMBER HOURS timespec_
436 {
437 $$ = $1 * 60 * 60 + $3;
438 }
439 | NUMBER DAYS timespec_
440 {
441 $$ = $1 * 60 * 60 * 24 + $3;
442 }
443 | NUMBER WEEKS timespec_
444 {
445 $$ = $1 * 60 * 60 * 24 * 7 + $3;
446 }
447 ;
448
449 sizespec_: { $$ = 0; } | sizespec;
450 sizespec: NUMBER sizespec_ { $$ = $1 + $2; }
451 | NUMBER BYTES sizespec_ { $$ = $1 + $3; }
452 | NUMBER KBYTES sizespec_ { $$ = $1 * 1024 + $3; }
453 | NUMBER MBYTES sizespec_ { $$ = $1 * 1024 * 1024 + $3; }
454 ;
455
456
457 /***************************************************************************
458 * section modules
459 ***************************************************************************/
460 modules_entry: MODULES
461 '{' modules_items '}' ';';
462
463 modules_items: modules_items modules_item | modules_item;
464 modules_item: modules_module | modules_path | error ';' ;
465
466 modules_module: MODULE '=' QSTRING ';'
467 {
468 #ifndef STATIC_MODULES /* NOOP in the static case */
469 if (ypass == 2)
470 {
471 char *m_bn;
472
473 m_bn = basename(yylval.string);
474
475 /* I suppose we should just ignore it if it is already loaded(since
476 * otherwise we would flood the opers on rehash) -A1kmm.
477 */
478 add_conf_module(yylval.string);
479 }
480 #endif
481 };
482
483 modules_path: PATH '=' QSTRING ';'
484 {
485 #ifndef STATIC_MODULES
486 if (ypass == 2)
487 mod_add_path(yylval.string);
488 #endif
489 };
490
491 /***************************************************************************
492 * section serverinfo
493 ***************************************************************************/
494 serverinfo_entry: SERVERINFO
495 '{' serverinfo_items '}' ';';
496
497 serverinfo_items: serverinfo_items serverinfo_item |
498 serverinfo_item ;
499 serverinfo_item: serverinfo_name | serverinfo_vhost |
500 serverinfo_hub | serverinfo_description |
501 serverinfo_network_name | serverinfo_network_desc |
502 serverinfo_max_clients |
503 serverinfo_rsa_private_key_file | serverinfo_vhost6 |
504 serverinfo_sid | serverinfo_ssl_certificate_file |
505 error ';' ;
506
507 serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
508 {
509 #ifdef HAVE_LIBCRYPTO
510 if (ypass == 2 && ServerInfo.ctx)
511 {
512 if (!ServerInfo.rsa_private_key_file)
513 {
514 yyerror("No rsa_private_key_file specified, SSL disabled");
515 break;
516 }
517
518 if (SSL_CTX_use_certificate_file(ServerInfo.ctx,
519 yylval.string, SSL_FILETYPE_PEM) <= 0)
520 {
521 yyerror(ERR_lib_error_string(ERR_get_error()));
522 break;
523 }
524
525 if (SSL_CTX_use_PrivateKey_file(ServerInfo.ctx,
526 ServerInfo.rsa_private_key_file, SSL_FILETYPE_PEM) <= 0)
527 {
528 yyerror(ERR_lib_error_string(ERR_get_error()));
529 break;
530 }
531
532 if (!SSL_CTX_check_private_key(ServerInfo.ctx))
533 {
534 yyerror("RSA private key does not match the SSL certificate public key!");
535 break;
536 }
537 }
538 #endif
539 };
540
541 serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
542 {
543 #ifdef HAVE_LIBCRYPTO
544 if (ypass == 1)
545 {
546 BIO *file;
547
548 if (ServerInfo.rsa_private_key)
549 {
550 RSA_free(ServerInfo.rsa_private_key);
551 ServerInfo.rsa_private_key = NULL;
552 }
553
554 if (ServerInfo.rsa_private_key_file)
555 {
556 MyFree(ServerInfo.rsa_private_key_file);
557 ServerInfo.rsa_private_key_file = NULL;
558 }
559
560 DupString(ServerInfo.rsa_private_key_file, yylval.string);
561
562 if ((file = BIO_new_file(yylval.string, "r")) == NULL)
563 {
564 yyerror("File open failed, ignoring");
565 break;
566 }
567
568 ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
569 0, NULL);
570
571 BIO_set_close(file, BIO_CLOSE);
572 BIO_free(file);
573
574 if (ServerInfo.rsa_private_key == NULL)
575 {
576 yyerror("Couldn't extract key, ignoring");
577 break;
578 }
579
580 if (!RSA_check_key(ServerInfo.rsa_private_key))
581 {
582 RSA_free(ServerInfo.rsa_private_key);
583 ServerInfo.rsa_private_key = NULL;
584
585 yyerror("Invalid key, ignoring");
586 break;
587 }
588
589 /* require 2048 bit (256 byte) key */
590 if (RSA_size(ServerInfo.rsa_private_key) != 256)
591 {
592 RSA_free(ServerInfo.rsa_private_key);
593 ServerInfo.rsa_private_key = NULL;
594
595 yyerror("Not a 2048 bit key, ignoring");
596 }
597 }
598 #endif
599 };
600
601 serverinfo_name: NAME '=' QSTRING ';'
602 {
603 /* this isn't rehashable */
604 if (ypass == 2)
605 {
606 if (ServerInfo.name == NULL)
607 {
608 /* the ircd will exit() in main() if we dont set one */
609 if (strlen(yylval.string) <= HOSTLEN)
610 DupString(ServerInfo.name, yylval.string);
611 }
612 }
613 };
614
615 serverinfo_sid: IRCD_SID '=' QSTRING ';'
616 {
617 /* this isn't rehashable */
618 if (ypass == 2 && !ServerInfo.sid)
619 {
620 if (valid_sid(yylval.string))
621 DupString(ServerInfo.sid, yylval.string);
622 else
623 {
624 ilog(L_ERROR, "Ignoring config file entry SID -- invalid SID. Aborting.");
625 exit(0);
626 }
627 }
628 };
629
630 serverinfo_description: DESCRIPTION '=' QSTRING ';'
631 {
632 if (ypass == 2)
633 {
634 MyFree(ServerInfo.description);
635 DupString(ServerInfo.description,yylval.string);
636 }
637 };
638
639 serverinfo_network_name: NETWORK_NAME '=' QSTRING ';'
640 {
641 if (ypass == 2)
642 {
643 char *p;
644
645 if ((p = strchr(yylval.string, ' ')) != NULL)
646 p = '\0';
647
648 MyFree(ServerInfo.network_name);
649 DupString(ServerInfo.network_name, yylval.string);
650 }
651 };
652
653 serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
654 {
655 if (ypass == 2)
656 {
657 MyFree(ServerInfo.network_desc);
658 DupString(ServerInfo.network_desc, yylval.string);
659 }
660 };
661
662 serverinfo_vhost: VHOST '=' QSTRING ';'
663 {
664 if (ypass == 2 && *yylval.string != '*')
665 {
666 struct addrinfo hints, *res;
667
668 memset(&hints, 0, sizeof(hints));
669
670 hints.ai_family = AF_UNSPEC;
671 hints.ai_socktype = SOCK_STREAM;
672 hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
673
674 if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
675 ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
676 else
677 {
678 assert(res != NULL);
679
680 memcpy(&ServerInfo.ip, res->ai_addr, res->ai_addrlen);
681 ServerInfo.ip.ss.ss_family = res->ai_family;
682 ServerInfo.ip.ss_len = res->ai_addrlen;
683 irc_freeaddrinfo(res);
684
685 ServerInfo.specific_ipv4_vhost = 1;
686 }
687 }
688 };
689
690 serverinfo_vhost6: VHOST6 '=' QSTRING ';'
691 {
692 #ifdef IPV6
693 if (ypass == 2 && *yylval.string != '*')
694 {
695 struct addrinfo hints, *res;
696
697 memset(&hints, 0, sizeof(hints));
698
699 hints.ai_family = AF_UNSPEC;
700 hints.ai_socktype = SOCK_STREAM;
701 hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
702
703 if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
704 ilog(L_ERROR, "Invalid netmask for server vhost6(%s)", yylval.string);
705 else
706 {
707 assert(res != NULL);
708
709 memcpy(&ServerInfo.ip6, res->ai_addr, res->ai_addrlen);
710 ServerInfo.ip6.ss.ss_family = res->ai_family;
711 ServerInfo.ip6.ss_len = res->ai_addrlen;
712 irc_freeaddrinfo(res);
713
714 ServerInfo.specific_ipv6_vhost = 1;
715 }
716 }
717 #endif
718 };
719
720 serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
721 {
722 if (ypass == 2)
723 {
724 recalc_fdlimit(NULL);
725
726 if ($3 < MAXCLIENTS_MIN)
727 {
728 char buf[IRCD_BUFSIZE];
729 ircsprintf(buf, "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
730 yyerror(buf);
731 }
732 else if ($3 > MAXCLIENTS_MAX)
733 {
734 char buf[IRCD_BUFSIZE];
735 ircsprintf(buf, "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
736 yyerror(buf);
737 }
738 else
739 ServerInfo.max_clients = $3;
740 }
741 };
742
743 serverinfo_hub: HUB '=' TBOOL ';'
744 {
745 if (ypass == 2)
746 {
747 if (yylval.number)
748 {
749 /* Don't become a hub if we have a lazylink active. */
750 if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
751 {
752 sendto_realops_flags(UMODE_ALL, L_ALL,
753 "Ignoring config file line hub=yes; "
754 "due to active LazyLink (%s)", uplink->name);
755 }
756 else
757 {
758 ServerInfo.hub = 1;
759 uplink = NULL;
760 delete_capability("HUB");
761 add_capability("HUB", CAP_HUB, 1);
762 }
763 }
764 else if (ServerInfo.hub)
765 {
766 dlink_node *ptr = NULL;
767
768 ServerInfo.hub = 0;
769 delete_capability("HUB");
770
771 /* Don't become a leaf if we have a lazylink active. */
772 DLINK_FOREACH(ptr, serv_list.head)
773 {
774 const struct Client *acptr = ptr->data;
775 if (MyConnect(acptr) && IsCapable(acptr, CAP_LL))
776 {
777 sendto_realops_flags(UMODE_ALL, L_ALL,
778 "Ignoring config file line hub=no; "
779 "due to active LazyLink (%s)",
780 acptr->name);
781 add_capability("HUB", CAP_HUB, 1);
782 ServerInfo.hub = 1;
783 break;
784 }
785 }
786 }
787 }
788 };
789
790 /***************************************************************************
791 * admin section
792 ***************************************************************************/
793 admin_entry: ADMIN '{' admin_items '}' ';' ;
794
795 admin_items: admin_items admin_item | admin_item;
796 admin_item: admin_name | admin_description |
797 admin_email | error ';' ;
798
799 admin_name: NAME '=' QSTRING ';'
800 {
801 if (ypass == 2)
802 {
803 MyFree(AdminInfo.name);
804 DupString(AdminInfo.name, yylval.string);
805 }
806 };
807
808 admin_email: EMAIL '=' QSTRING ';'
809 {
810 if (ypass == 2)
811 {
812 MyFree(AdminInfo.email);
813 DupString(AdminInfo.email, yylval.string);
814 }
815 };
816
817 admin_description: DESCRIPTION '=' QSTRING ';'
818 {
819 if (ypass == 2)
820 {
821 MyFree(AdminInfo.description);
822 DupString(AdminInfo.description, yylval.string);
823 }
824 };
825
826 /***************************************************************************
827 * section logging
828 ***************************************************************************/
829 /* XXX */
830 logging_entry: LOGGING '{' logging_items '}' ';' ;
831
832 logging_items: logging_items logging_item |
833 logging_item ;
834
835 logging_item: logging_path | logging_oper_log |
836 logging_log_level |
837 logging_use_logging | logging_fuserlog |
838 logging_foperlog | logging_fglinelog |
839 logging_fklinelog | logging_killlog |
840 logging_foperspylog | logging_ioerrlog |
841 logging_ffailed_operlog |
842 error ';' ;
843
844 logging_path: T_LOGPATH '=' QSTRING ';'
845 {
846 };
847
848 logging_oper_log: OPER_LOG '=' QSTRING ';'
849 {
850 };
851
852 logging_fuserlog: FUSERLOG '=' QSTRING ';'
853 {
854 if (ypass == 2)
855 strlcpy(ConfigLoggingEntry.userlog, yylval.string,
856 sizeof(ConfigLoggingEntry.userlog));
857 };
858
859 logging_ffailed_operlog: FFAILED_OPERLOG '=' QSTRING ';'
860 {
861 if (ypass == 2)
862 strlcpy(ConfigLoggingEntry.failed_operlog, yylval.string,
863 sizeof(ConfigLoggingEntry.failed_operlog));
864 };
865
866 logging_foperlog: FOPERLOG '=' QSTRING ';'
867 {
868 if (ypass == 2)
869 strlcpy(ConfigLoggingEntry.operlog, yylval.string,
870 sizeof(ConfigLoggingEntry.operlog));
871 };
872
873 logging_foperspylog: FOPERSPYLOG '=' QSTRING ';'
874 {
875 if (ypass == 2)
876 strlcpy(ConfigLoggingEntry.operspylog, yylval.string,
877 sizeof(ConfigLoggingEntry.operspylog));
878 };
879
880 logging_fglinelog: FGLINELOG '=' QSTRING ';'
881 {
882 if (ypass == 2)
883 strlcpy(ConfigLoggingEntry.glinelog, yylval.string,
884 sizeof(ConfigLoggingEntry.glinelog));
885 };
886
887 logging_fklinelog: FKLINELOG '=' QSTRING ';'
888 {
889 if (ypass == 2)
890 strlcpy(ConfigLoggingEntry.klinelog, yylval.string,
891 sizeof(ConfigLoggingEntry.klinelog));
892 };
893
894 logging_ioerrlog: FIOERRLOG '=' QSTRING ';'
895 {
896 if (ypass == 2)
897 strlcpy(ConfigLoggingEntry.ioerrlog, yylval.string,
898 sizeof(ConfigLoggingEntry.ioerrlog));
899 };
900
901 logging_killlog: FKILLLOG '=' QSTRING ';'
902 {
903 if (ypass == 2)
904 strlcpy(ConfigLoggingEntry.killlog, yylval.string,
905 sizeof(ConfigLoggingEntry.killlog));
906 };
907
908 logging_log_level: LOG_LEVEL '=' T_L_CRIT ';'
909 {
910 if (ypass == 2)
911 set_log_level(L_CRIT);
912 } | LOG_LEVEL '=' T_L_ERROR ';'
913 {
914 if (ypass == 2)
915 set_log_level(L_ERROR);
916 } | LOG_LEVEL '=' T_L_WARN ';'
917 {
918 if (ypass == 2)
919 set_log_level(L_WARN);
920 } | LOG_LEVEL '=' T_L_NOTICE ';'
921 {
922 if (ypass == 2)
923 set_log_level(L_NOTICE);
924 } | LOG_LEVEL '=' T_L_TRACE ';'
925 {
926 if (ypass == 2)
927 set_log_level(L_TRACE);
928 } | LOG_LEVEL '=' T_L_INFO ';'
929 {
930 if (ypass == 2)
931 set_log_level(L_INFO);
932 } | LOG_LEVEL '=' T_L_DEBUG ';'
933 {
934 if (ypass == 2)
935 set_log_level(L_DEBUG);
936 };
937
938 logging_use_logging: USE_LOGGING '=' TBOOL ';'
939 {
940 if (ypass == 2)
941 ConfigLoggingEntry.use_logging = yylval.number;
942 };
943
944 /***************************************************************************
945 * section oper
946 ***************************************************************************/
947 oper_entry: OPERATOR
948 {
949 if (ypass == 2)
950 {
951 yy_conf = make_conf_item(OPER_TYPE);
952 yy_aconf = map_to_conf(yy_conf);
953 SetConfEncrypted(yy_aconf); /* Yes, the default is encrypted */
954 }
955 else
956 {
957 MyFree(class_name);
958 class_name = NULL;
959 }
960 } oper_name_b '{' oper_items '}' ';'
961 {
962 if (ypass == 2)
963 {
964 struct CollectItem *yy_tmp;
965 dlink_node *ptr;
966 dlink_node *next_ptr;
967
968 conf_add_class_to_conf(yy_conf, class_name);
969
970 /* Now, make sure there is a copy of the "base" given oper
971 * block in each of the collected copies
972 */
973
974 DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
975 {
976 struct AccessItem *new_aconf;
977 struct ConfItem *new_conf;
978 yy_tmp = ptr->data;
979
980 new_conf = make_conf_item(OPER_TYPE);
981 new_aconf = (struct AccessItem *)map_to_conf(new_conf);
982
983 new_aconf->flags = yy_aconf->flags;
984
985 if (yy_conf->name != NULL)
986 DupString(new_conf->name, yy_conf->name);
987 if (yy_tmp->user != NULL)
988 DupString(new_aconf->user, yy_tmp->user);
989 else
990 DupString(new_aconf->user, "*");
991 if (yy_tmp->host != NULL)
992 DupString(new_aconf->host, yy_tmp->host);
993 else
994 DupString(new_aconf->host, "*");
995 conf_add_class_to_conf(new_conf, class_name);
996 if (yy_aconf->passwd != NULL)
997 DupString(new_aconf->passwd, yy_aconf->passwd);
998
999 new_aconf->port = yy_aconf->port;
1000 #ifdef HAVE_LIBCRYPTO
1001 if (yy_aconf->rsa_public_key_file != NULL)
1002 {
1003 BIO *file;
1004
1005 DupString(new_aconf->rsa_public_key_file,
1006 yy_aconf->rsa_public_key_file);
1007
1008 file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
1009 new_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file,
1010 NULL, 0, NULL);
1011 BIO_set_close(file, BIO_CLOSE);
1012 BIO_free(file);
1013 }
1014 #endif
1015
1016 #ifdef HAVE_LIBCRYPTO
1017 if (yy_tmp->name && (yy_tmp->passwd || yy_aconf->rsa_public_key)
1018 && yy_tmp->host)
1019 #else
1020 if (yy_tmp->name && yy_tmp->passwd && yy_tmp->host)
1021 #endif
1022 {
1023 conf_add_class_to_conf(new_conf, class_name);
1024 if (yy_tmp->name != NULL)
1025 DupString(new_conf->name, yy_tmp->name);
1026 }
1027
1028 dlinkDelete(&yy_tmp->node, &col_conf_list);
1029 free_collect_item(yy_tmp);
1030 }
1031
1032 yy_conf = NULL;
1033 yy_aconf = NULL;
1034
1035
1036 MyFree(class_name);
1037 class_name = NULL;
1038 }
1039 };
1040
1041 oper_name_b: | oper_name_t;
1042 oper_items: oper_items oper_item | oper_item;
1043 oper_item: oper_name | oper_user | oper_password | oper_hidden_admin |
1044 oper_hidden_oper | oper_umodes |
1045 oper_class | oper_global_kill | oper_remote |
1046 oper_kline | oper_xline | oper_unkline |
1047 oper_gline | oper_nick_changes | oper_remoteban |
1048 oper_die | oper_rehash | oper_admin | oper_operwall |
1049 oper_encrypted | oper_rsa_public_key_file |
1050 oper_flags | error ';' ;
1051
1052 oper_name: NAME '=' QSTRING ';'
1053 {
1054 if (ypass == 2)
1055 {
1056 if (strlen(yylval.string) > OPERNICKLEN)
1057 yylval.string[OPERNICKLEN] = '\0';
1058
1059 MyFree(yy_conf->name);
1060 DupString(yy_conf->name, yylval.string);
1061 }
1062 };
1063
1064 oper_name_t: QSTRING
1065 {
1066 if (ypass == 2)
1067 {
1068 if (strlen(yylval.string) > OPERNICKLEN)
1069 yylval.string[OPERNICKLEN] = '\0';
1070
1071 MyFree(yy_conf->name);
1072 DupString(yy_conf->name, yylval.string);
1073 }
1074 };
1075
1076 oper_user: USER '=' QSTRING ';'
1077 {
1078 if (ypass == 2)
1079 {
1080 struct CollectItem *yy_tmp;
1081
1082 if (yy_aconf->user == NULL)
1083 {
1084 split_nuh(yylval.string, NULL, &yy_aconf->user, &yy_aconf->host);
1085 }
1086 else
1087 {
1088 yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
1089 split_nuh(yylval.string, NULL, &yy_tmp->user, &yy_tmp->host);
1090 dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1091 }
1092 }
1093 };
1094
1095 oper_password: PASSWORD '=' QSTRING ';'
1096 {
1097 if (ypass == 2)
1098 {
1099 if (yy_aconf->passwd != NULL)
1100 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1101
1102 MyFree(yy_aconf->passwd);
1103 DupString(yy_aconf->passwd, yylval.string);
1104 }
1105 };
1106
1107 oper_encrypted: ENCRYPTED '=' TBOOL ';'
1108 {
1109 if (ypass == 2)
1110 {
1111 if (yylval.number)
1112 SetConfEncrypted(yy_aconf);
1113 else
1114 ClearConfEncrypted(yy_aconf);
1115 }
1116 };
1117
1118 oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1119 {
1120 #ifdef HAVE_LIBCRYPTO
1121 if (ypass == 2)
1122 {
1123 BIO *file;
1124
1125 if (yy_aconf->rsa_public_key != NULL)
1126 {
1127 RSA_free(yy_aconf->rsa_public_key);
1128 yy_aconf->rsa_public_key = NULL;
1129 }
1130
1131 if (yy_aconf->rsa_public_key_file != NULL)
1132 {
1133 MyFree(yy_aconf->rsa_public_key_file);
1134 yy_aconf->rsa_public_key_file = NULL;
1135 }
1136
1137 DupString(yy_aconf->rsa_public_key_file, yylval.string);
1138 file = BIO_new_file(yylval.string, "r");
1139
1140 if (file == NULL)
1141 {
1142 yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1143 break;
1144 }
1145
1146 yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1147
1148 if (yy_aconf->rsa_public_key == NULL)
1149 {
1150 yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1151 break;
1152 }
1153
1154 BIO_set_close(file, BIO_CLOSE);
1155 BIO_free(file);
1156 }
1157 #endif /* HAVE_LIBCRYPTO */
1158 };
1159
1160 oper_class: CLASS '=' QSTRING ';'
1161 {
1162 if (ypass == 2)
1163 {
1164 MyFree(class_name);
1165 DupString(class_name, yylval.string);
1166 }
1167 };
1168
1169 oper_umodes: T_UMODES
1170 {
1171 if (ypass == 2)
1172 yy_aconf->modes = 0;
1173 } '=' oper_umodes_items ';' ;
1174
1175 oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1176 oper_umodes_item: T_BOTS
1177 {
1178 if (ypass == 2)
1179 yy_aconf->modes |= UMODE_BOTS;
1180 } | T_CCONN
1181 {
1182 if (ypass == 2)
1183 yy_aconf->modes |= UMODE_CCONN;
1184 } | T_DEAF
1185 {
1186 if (ypass == 2)
1187 yy_aconf->modes |= UMODE_DEAF;
1188 } | T_DEBUG
1189 {
1190 if (ypass == 2)
1191 yy_aconf->modes |= UMODE_DEBUG;
1192 } | T_FULL
1193 {
1194 if (ypass == 2)
1195 yy_aconf->modes |= UMODE_FULL;
1196 } | T_SKILL
1197 {
1198 if (ypass == 2)
1199 yy_aconf->modes |= UMODE_SKILL;
1200 } | T_NCHANGE
1201 {
1202 if (ypass == 2)
1203 yy_aconf->modes |= UMODE_NCHANGE;
1204 } | T_REJ
1205 {
1206 if (ypass == 2)
1207 yy_aconf->modes |= UMODE_REJ;
1208 } | T_UNAUTH
1209 {
1210 if (ypass == 2)
1211 yy_aconf->modes |= UMODE_UNAUTH;
1212 } | T_SPY
1213 {
1214 if (ypass == 2)
1215 yy_aconf->modes |= UMODE_SPY;
1216 } | T_EXTERNAL
1217 {
1218 if (ypass == 2)
1219 yy_aconf->modes |= UMODE_EXTERNAL;
1220 } | T_OPERWALL
1221 {
1222 if (ypass == 2)
1223 yy_aconf->modes |= UMODE_OPERWALL;
1224 } | T_SERVNOTICE
1225 {
1226 if (ypass == 2)
1227 yy_aconf->modes |= UMODE_SERVNOTICE;
1228 } | T_INVISIBLE
1229 {
1230 if (ypass == 2)
1231 yy_aconf->modes |= UMODE_INVISIBLE;
1232 } | T_WALLOP
1233 {
1234 if (ypass == 2)
1235 yy_aconf->modes |= UMODE_WALLOP;
1236 } | T_SOFTCALLERID
1237 {
1238 if (ypass == 2)
1239 yy_aconf->modes |= UMODE_SOFTCALLERID;
1240 } | T_CALLERID
1241 {
1242 if (ypass == 2)
1243 yy_aconf->modes |= UMODE_CALLERID;
1244 } | T_LOCOPS
1245 {
1246 if (ypass == 2)
1247 yy_aconf->modes |= UMODE_LOCOPS;
1248 };
1249
1250 oper_global_kill: GLOBAL_KILL '=' TBOOL ';'
1251 {
1252 if (ypass == 2)
1253 {
1254 if (yylval.number)
1255 yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1256 else
1257 yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1258 }
1259 };
1260
1261 oper_remote: REMOTE '=' TBOOL ';'
1262 {
1263 if (ypass == 2)
1264 {
1265 if (yylval.number)
1266 yy_aconf->port |= OPER_FLAG_REMOTE;
1267 else
1268 yy_aconf->port &= ~OPER_FLAG_REMOTE;
1269 }
1270 };
1271
1272 oper_remoteban: REMOTEBAN '=' TBOOL ';'
1273 {
1274 if (ypass == 2)
1275 {
1276 if (yylval.number)
1277 yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1278 else
1279 yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1280 }
1281 };
1282
1283 oper_kline: KLINE '=' TBOOL ';'
1284 {
1285 if (ypass == 2)
1286 {
1287 if (yylval.number)
1288 yy_aconf->port |= OPER_FLAG_K;
1289 else
1290 yy_aconf->port &= ~OPER_FLAG_K;
1291 }
1292 };
1293
1294 oper_xline: XLINE '=' TBOOL ';'
1295 {
1296 if (ypass == 2)
1297 {
1298 if (yylval.number)
1299 yy_aconf->port |= OPER_FLAG_X;
1300 else
1301 yy_aconf->port &= ~OPER_FLAG_X;
1302 }
1303 };
1304
1305 oper_unkline: UNKLINE '=' TBOOL ';'
1306 {
1307 if (ypass == 2)
1308 {
1309 if (yylval.number)
1310 yy_aconf->port |= OPER_FLAG_UNKLINE;
1311 else
1312 yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1313 }
1314 };
1315
1316 oper_gline: GLINE '=' TBOOL ';'
1317 {
1318 if (ypass == 2)
1319 {
1320 if (yylval.number)
1321 yy_aconf->port |= OPER_FLAG_GLINE;
1322 else
1323 yy_aconf->port &= ~OPER_FLAG_GLINE;
1324 }
1325 };
1326
1327 oper_nick_changes: NICK_CHANGES '=' TBOOL ';'
1328 {
1329 if (ypass == 2)
1330 {
1331 if (yylval.number)
1332 yy_aconf->port |= OPER_FLAG_N;
1333 else
1334 yy_aconf->port &= ~OPER_FLAG_N;
1335 }
1336 };
1337
1338 oper_die: DIE '=' TBOOL ';'
1339 {
1340 if (ypass == 2)
1341 {
1342 if (yylval.number)
1343 yy_aconf->port |= OPER_FLAG_DIE;
1344 else
1345 yy_aconf->port &= ~OPER_FLAG_DIE;
1346 }
1347 };
1348
1349 oper_rehash: REHASH '=' TBOOL ';'
1350 {
1351 if (ypass == 2)
1352 {
1353 if (yylval.number)
1354 yy_aconf->port |= OPER_FLAG_REHASH;
1355 else
1356 yy_aconf->port &= ~OPER_FLAG_REHASH;
1357 }
1358 };
1359
1360 oper_admin: ADMIN '=' TBOOL ';'
1361 {
1362 if (ypass == 2)
1363 {
1364 if (yylval.number)
1365 yy_aconf->port |= OPER_FLAG_ADMIN;
1366 else
1367 yy_aconf->port &= ~OPER_FLAG_ADMIN;
1368 }
1369 };
1370
1371 oper_hidden_admin: HIDDEN_ADMIN '=' TBOOL ';'
1372 {
1373 if (ypass == 2)
1374 {
1375 if (yylval.number)
1376 yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1377 else
1378 yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1379 }
1380 };
1381
1382 oper_hidden_oper: HIDDEN_OPER '=' TBOOL ';'
1383 {
1384 if (ypass == 2)
1385 {
1386 if (yylval.number)
1387 yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1388 else
1389 yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1390 }
1391 };
1392
1393 oper_operwall: T_OPERWALL '=' TBOOL ';'
1394 {
1395 if (ypass == 2)
1396 {
1397 if (yylval.number)
1398 yy_aconf->port |= OPER_FLAG_OPERWALL;
1399 else
1400 yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1401 }
1402 };
1403
1404 oper_flags: IRCD_FLAGS
1405 {
1406 } '=' oper_flags_items ';';
1407
1408 oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1409 oper_flags_item: NOT { not_atom = 1; } oper_flags_item_atom
1410 | { not_atom = 0; } oper_flags_item_atom;
1411
1412 oper_flags_item_atom: GLOBAL_KILL
1413 {
1414 if (ypass == 2)
1415 {
1416 if (not_atom)yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1417 else yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1418 }
1419 } | REMOTE
1420 {
1421 if (ypass == 2)
1422 {
1423 if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTE;
1424 else yy_aconf->port |= OPER_FLAG_REMOTE;
1425 }
1426 } | KLINE
1427 {
1428 if (ypass == 2)
1429 {
1430 if (not_atom) yy_aconf->port &= ~OPER_FLAG_K;
1431 else yy_aconf->port |= OPER_FLAG_K;
1432 }
1433 } | UNKLINE
1434 {
1435 if (ypass == 2)
1436 {
1437 if (not_atom) yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1438 else yy_aconf->port |= OPER_FLAG_UNKLINE;
1439 }
1440 } | XLINE
1441 {
1442 if (ypass == 2)
1443 {
1444 if (not_atom) yy_aconf->port &= ~OPER_FLAG_X;
1445 else yy_aconf->port |= OPER_FLAG_X;
1446 }
1447 } | GLINE
1448 {
1449 if (ypass == 2)
1450 {
1451 if (not_atom) yy_aconf->port &= ~OPER_FLAG_GLINE;
1452 else yy_aconf->port |= OPER_FLAG_GLINE;
1453 }
1454 } | DIE
1455 {
1456 if (ypass == 2)
1457 {
1458 if (not_atom) yy_aconf->port &= ~OPER_FLAG_DIE;
1459 else yy_aconf->port |= OPER_FLAG_DIE;
1460 }
1461 } | REHASH
1462 {
1463 if (ypass == 2)
1464 {
1465 if (not_atom) yy_aconf->port &= ~OPER_FLAG_REHASH;
1466 else yy_aconf->port |= OPER_FLAG_REHASH;
1467 }
1468 } | ADMIN
1469 {
1470 if (ypass == 2)
1471 {
1472 if (not_atom) yy_aconf->port &= ~OPER_FLAG_ADMIN;
1473 else yy_aconf->port |= OPER_FLAG_ADMIN;
1474 }
1475 } | HIDDEN_ADMIN
1476 {
1477 if (ypass == 2)
1478 {
1479 if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1480 else yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1481 }
1482 } | NICK_CHANGES
1483 {
1484 if (ypass == 2)
1485 {
1486 if (not_atom) yy_aconf->port &= ~OPER_FLAG_N;
1487 else yy_aconf->port |= OPER_FLAG_N;
1488 }
1489 } | T_OPERWALL
1490 {
1491 if (ypass == 2)
1492 {
1493 if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1494 else yy_aconf->port |= OPER_FLAG_OPERWALL;
1495 }
1496 } | OPER_SPY_T
1497 {
1498 if (ypass == 2)
1499 {
1500 if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPER_SPY;
1501 else yy_aconf->port |= OPER_FLAG_OPER_SPY;
1502 }
1503 } | HIDDEN_OPER
1504 {
1505 if (ypass == 2)
1506 {
1507 if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1508 else yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1509 }
1510 } | REMOTEBAN
1511 {
1512 if (ypass == 2)
1513 {
1514 if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1515 else yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1516 }
1517 } | ENCRYPTED
1518 {
1519 if (ypass == 2)
1520 {
1521 if (not_atom) ClearConfEncrypted(yy_aconf);
1522 else SetConfEncrypted(yy_aconf);
1523 }
1524 };
1525
1526
1527 /***************************************************************************
1528 * section class
1529 ***************************************************************************/
1530 class_entry: CLASS
1531 {
1532 if (ypass == 1)
1533 {
1534 yy_conf = make_conf_item(CLASS_TYPE);
1535 yy_class = (struct ClassItem *)map_to_conf(yy_conf);
1536 }
1537 } class_name_b '{' class_items '}' ';'
1538 {
1539 if (ypass == 1)
1540 {
1541 struct ConfItem *cconf;
1542 struct ClassItem *class = NULL;
1543
1544 if (yy_class_name == NULL)
1545 {
1546 delete_conf_item(yy_conf);
1547 }
1548 else
1549 {
1550 cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1551
1552 if (cconf != NULL) /* The class existed already */
1553 {
1554 rebuild_cidr_class(cconf, yy_class);
1555 class = (struct ClassItem *) map_to_conf(cconf);
1556 *class = *yy_class;
1557 delete_conf_item(yy_conf);
1558
1559 MyFree(cconf->name); /* Allows case change of class name */
1560 cconf->name = yy_class_name;
1561 }
1562 else /* Brand new class */
1563 {
1564 MyFree(yy_conf->name); /* just in case it was allocated */
1565 yy_conf->name = yy_class_name;
1566 }
1567 }
1568 yy_class_name = NULL;
1569 }
1570 };
1571
1572 class_name_b: | class_name_t;
1573
1574 class_items: class_items class_item | class_item;
1575 class_item: class_name |
1576 class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1577 class_ping_time |
1578 class_ping_warning |
1579 class_number_per_cidr |
1580 class_number_per_ip |
1581 class_connectfreq |
1582 class_max_number |
1583 class_max_global |
1584 class_max_local |
1585 class_max_ident |
1586 class_sendq |
1587 error ';' ;
1588
1589 class_name: NAME '=' QSTRING ';'
1590 {
1591 if (ypass == 1)
1592 {
1593 MyFree(yy_class_name);
1594 DupString(yy_class_name, yylval.string);
1595 }
1596 };
1597
1598 class_name_t: QSTRING
1599 {
1600 if (ypass == 1)
1601 {
1602 MyFree(yy_class_name);
1603 DupString(yy_class_name, yylval.string);
1604 }
1605 };
1606
1607 class_ping_time: PING_TIME '=' timespec ';'
1608 {
1609 if (ypass == 1)
1610 PingFreq(yy_class) = $3;
1611 };
1612
1613 class_ping_warning: PING_WARNING '=' timespec ';'
1614 {
1615 if (ypass == 1)
1616 PingWarning(yy_class) = $3;
1617 };
1618
1619 class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1620 {
1621 if (ypass == 1)
1622 MaxPerIp(yy_class) = $3;
1623 };
1624
1625 class_connectfreq: CONNECTFREQ '=' timespec ';'
1626 {
1627 if (ypass == 1)
1628 ConFreq(yy_class) = $3;
1629 };
1630
1631 class_max_number: MAX_NUMBER '=' NUMBER ';'
1632 {
1633 if (ypass == 1)
1634 MaxTotal(yy_class) = $3;
1635 };
1636
1637 class_max_global: MAX_GLOBAL '=' NUMBER ';'
1638 {
1639 if (ypass == 1)
1640 MaxGlobal(yy_class) = $3;
1641 };
1642
1643 class_max_local: MAX_LOCAL '=' NUMBER ';'
1644 {
1645 if (ypass == 1)
1646 MaxLocal(yy_class) = $3;
1647 };
1648
1649 class_max_ident: MAX_IDENT '=' NUMBER ';'
1650 {
1651 if (ypass == 1)
1652 MaxIdent(yy_class) = $3;
1653 };
1654
1655 class_sendq: SENDQ '=' sizespec ';'
1656 {
1657 if (ypass == 1)
1658 MaxSendq(yy_class) = $3;
1659 };
1660
1661 class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1662 {
1663 if (ypass == 1)
1664 CidrBitlenIPV4(yy_class) = $3;
1665 };
1666
1667 class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1668 {
1669 if (ypass == 1)
1670 CidrBitlenIPV6(yy_class) = $3;
1671 };
1672
1673 class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1674 {
1675 if (ypass == 1)
1676 NumberPerCidr(yy_class) = $3;
1677 };
1678
1679 /***************************************************************************
1680 * section listen
1681 ***************************************************************************/
1682 listen_entry: LISTEN
1683 {
1684 if (ypass == 2)
1685 {
1686 listener_address = NULL;
1687 listener_flags = 0;
1688 }
1689 } '{' listen_items '}' ';'
1690 {
1691 if (ypass == 2)
1692 {
1693 MyFree(listener_address);
1694 listener_address = NULL;
1695 }
1696 };
1697
1698 listen_flags: IRCD_FLAGS
1699 {
1700 listener_flags = 0;
1701 } '=' listen_flags_items ';';
1702
1703 listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1704 listen_flags_item: T_SSL
1705 {
1706 if (ypass == 2)
1707 listener_flags |= LISTENER_SSL;
1708 } | HIDDEN
1709 {
1710 if (ypass == 2)
1711 listener_flags |= LISTENER_HIDDEN;
1712 };
1713
1714 listen_items: listen_items listen_item | listen_item;
1715 listen_item: listen_port | listen_flags | listen_address | listen_host | error ';';
1716
1717 listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1718
1719 port_items: port_items ',' port_item | port_item;
1720
1721 port_item: NUMBER
1722 {
1723 if (ypass == 2)
1724 {
1725 if ((listener_flags & LISTENER_SSL))
1726 #ifdef HAVE_LIBCRYPTO
1727 if (!ServerInfo.ctx)
1728 #endif
1729 {
1730 yyerror("SSL not available - port closed");
1731 break;
1732 }
1733 add_listener($1, listener_address, listener_flags);
1734 }
1735 } | NUMBER TWODOTS NUMBER
1736 {
1737 if (ypass == 2)
1738 {
1739 int i;
1740
1741 if ((listener_flags & LISTENER_SSL))
1742 #ifdef HAVE_LIBCRYPTO
1743 if (!ServerInfo.ctx)
1744 #endif
1745 {
1746 yyerror("SSL not available - port closed");
1747 break;
1748 }
1749
1750 for (i = $1; i <= $3; ++i)
1751 add_listener(i, listener_address, listener_flags);
1752 }
1753 };
1754
1755 listen_address: IP '=' QSTRING ';'
1756 {
1757 if (ypass == 2)
1758 {
1759 MyFree(listener_address);
1760 DupString(listener_address, yylval.string);
1761 }
1762 };
1763
1764 listen_host: HOST '=' QSTRING ';'
1765 {
1766 if (ypass == 2)
1767 {
1768 MyFree(listener_address);
1769 DupString(listener_address, yylval.string);
1770 }
1771 };
1772
1773 /***************************************************************************
1774 * section auth
1775 ***************************************************************************/
1776 auth_entry: IRCD_AUTH
1777 {
1778 if (ypass == 2)
1779 {
1780 yy_conf = make_conf_item(CLIENT_TYPE);
1781 yy_aconf = map_to_conf(yy_conf);
1782 }
1783 else
1784 {
1785 MyFree(class_name);
1786 class_name = NULL;
1787 }
1788 } '{' auth_items '}' ';'
1789 {
1790 if (ypass == 2)
1791 {
1792 struct CollectItem *yy_tmp = NULL;
1793 dlink_node *ptr = NULL, *next_ptr = NULL;
1794
1795 if (yy_aconf->user && yy_aconf->host)
1796 {
1797 conf_add_class_to_conf(yy_conf, class_name);
1798 add_conf_by_address(CONF_CLIENT, yy_aconf);
1799 }
1800 else
1801 delete_conf_item(yy_conf);
1802
1803 /* copy over settings from first struct */
1804 DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1805 {
1806 struct AccessItem *new_aconf;
1807 struct ConfItem *new_conf;
1808
1809 new_conf = make_conf_item(CLIENT_TYPE);
1810 new_aconf = map_to_conf(new_conf);
1811
1812 yy_tmp = ptr->data;
1813
1814 assert(yy_tmp->user && yy_tmp->host);
1815
1816 if (yy_aconf->passwd != NULL)
1817 DupString(new_aconf->passwd, yy_aconf->passwd);
1818 if (yy_conf->name != NULL)
1819 DupString(new_conf->name, yy_conf->name);
1820 if (yy_aconf->passwd != NULL)
1821 DupString(new_aconf->passwd, yy_aconf->passwd);
1822
1823 new_aconf->flags = yy_aconf->flags;
1824 new_aconf->port = yy_aconf->port;
1825
1826 DupString(new_aconf->user, yy_tmp->user);
1827 collapse(new_aconf->user);
1828
1829 DupString(new_aconf->host, yy_tmp->host);
1830 collapse(new_aconf->host);
1831
1832 conf_add_class_to_conf(new_conf, class_name);
1833 add_conf_by_address(CONF_CLIENT, new_aconf);
1834 dlinkDelete(&yy_tmp->node, &col_conf_list);
1835 free_collect_item(yy_tmp);
1836 }
1837
1838 MyFree(class_name);
1839 class_name = NULL;
1840 yy_conf = NULL;
1841 yy_aconf = NULL;
1842 }
1843 };
1844
1845 auth_items: auth_items auth_item | auth_item;
1846 auth_item: auth_user | auth_passwd | auth_class | auth_flags |
1847 auth_kline_exempt | auth_need_ident |
1848 auth_exceed_limit | auth_no_tilde | auth_gline_exempt |
1849 auth_spoof | auth_spoof_notice |
1850 auth_redir_serv | auth_redir_port | auth_can_flood |
1851 auth_need_password | auth_encrypted | error ';' ;
1852
1853 auth_user: USER '=' QSTRING ';'
1854 {
1855 if (ypass == 2)
1856 {
1857 struct CollectItem *yy_tmp;
1858
1859 if (yy_aconf->user == NULL)
1860 split_nuh(yylval.string, NULL, &yy_aconf->user, &yy_aconf->host);
1861 else
1862 {
1863 yy_tmp = MyMalloc(sizeof(struct CollectItem));
1864 split_nuh(yylval.string, NULL, &yy_tmp->user, &yy_tmp->host);
1865 dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1866 }
1867 }
1868 };
1869
1870 /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1871
1872 auth_passwd: PASSWORD '=' QSTRING ';'
1873 {
1874 if (ypass == 2)
1875 {
1876 /* be paranoid */
1877 if (yy_aconf->passwd != NULL)
1878 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1879
1880 MyFree(yy_aconf->passwd);
1881 DupString(yy_aconf->passwd, yylval.string);
1882 }
1883 };
1884
1885 auth_spoof_notice: SPOOF_NOTICE '=' TBOOL ';'
1886 {
1887 if (ypass == 2)
1888 {
1889 if (yylval.number)
1890 yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1891 else
1892 yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1893 }
1894 };
1895
1896 auth_class: CLASS '=' QSTRING ';'
1897 {
1898 if (ypass == 2)
1899 {
1900 MyFree(class_name);
1901 DupString(class_name, yylval.string);
1902 }
1903 };
1904
1905 auth_encrypted: ENCRYPTED '=' TBOOL ';'
1906 {
1907 if (ypass == 2)
1908 {
1909 if (yylval.number)
1910 SetConfEncrypted(yy_aconf);
1911 else
1912 ClearConfEncrypted(yy_aconf);
1913 }
1914 };
1915
1916 auth_flags: IRCD_FLAGS
1917 {
1918 } '=' auth_flags_items ';';
1919
1920 auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1921 auth_flags_item: NOT { not_atom = 1; } auth_flags_item_atom
1922 | { not_atom = 0; } auth_flags_item_atom;
1923
1924 auth_flags_item_atom: SPOOF_NOTICE
1925 {
1926 if (ypass == 2)
1927 {
1928 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1929 else yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1930 }
1931
1932 } | EXCEED_LIMIT
1933 {
1934 if (ypass == 2)
1935 {
1936 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
1937 else yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1938 }
1939 } | KLINE_EXEMPT
1940 {
1941 if (ypass == 2)
1942 {
1943 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
1944 else yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1945 }
1946 } | NEED_IDENT
1947 {
1948 if (ypass == 2)
1949 {
1950 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
1951 else yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1952 }
1953 } | CAN_FLOOD
1954 {
1955 if (ypass == 2)
1956 {
1957 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
1958 else yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1959 }
1960 } | CAN_IDLE
1961 {
1962 if (ypass == 2)
1963 {
1964 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_IDLE_LINED;
1965 else yy_aconf->flags |= CONF_FLAGS_IDLE_LINED;
1966 }
1967 } | NO_TILDE
1968 {
1969 if (ypass == 2)
1970 {
1971 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
1972 else yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1973 }
1974 } | GLINE_EXEMPT
1975 {
1976 if (ypass == 2)
1977 {
1978 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
1979 else yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1980 }
1981 } | RESV_EXEMPT
1982 {
1983 if (ypass == 2)
1984 {
1985 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTRESV;
1986 else yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1987 }
1988 } | NEED_PASSWORD
1989 {
1990 if (ypass == 2)
1991 {
1992 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
1993 else yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1994 }
1995 };
1996
1997 auth_kline_exempt: KLINE_EXEMPT '=' TBOOL ';'
1998 {
1999 if (ypass == 2)
2000 {
2001 if (yylval.number)
2002 yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
2003 else
2004 yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
2005 }
2006 };
2007
2008 auth_need_ident: NEED_IDENT '=' TBOOL ';'
2009 {
2010 if (ypass == 2)
2011 {
2012 if (yylval.number)
2013 yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
2014 else
2015 yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
2016 }
2017 };
2018
2019 auth_exceed_limit: EXCEED_LIMIT '=' TBOOL ';'
2020 {
2021 if (ypass == 2)
2022 {
2023 if (yylval.number)
2024 yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
2025 else
2026 yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
2027 }
2028 };
2029
2030 auth_can_flood: CAN_FLOOD '=' TBOOL ';'
2031 {
2032 if (ypass == 2)
2033 {
2034 if (yylval.number)
2035 yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
2036 else
2037 yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
2038 }
2039 };
2040
2041 auth_no_tilde: NO_TILDE '=' TBOOL ';'
2042 {
2043 if (ypass == 2)
2044 {
2045 if (yylval.number)
2046 yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
2047 else
2048 yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
2049 }
2050 };
2051
2052 auth_gline_exempt: GLINE_EXEMPT '=' TBOOL ';'
2053 {
2054 if (ypass == 2)
2055 {
2056 if (yylval.number)
2057 yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2058 else
2059 yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2060 }
2061 };
2062
2063 /* XXX - need check for illegal hostnames here */
2064 auth_spoof: SPOOF '=' QSTRING ';'
2065 {
2066 if (ypass == 2)
2067 {
2068 MyFree(yy_conf->name);
2069
2070 if (strlen(yylval.string) < HOSTLEN)
2071 {
2072 DupString(yy_conf->name, yylval.string);
2073 yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
2074 }
2075 else
2076 {
2077 ilog(L_ERROR, "Spoofs must be less than %d..ignoring it", HOSTLEN);
2078 yy_conf->name = NULL;
2079 }
2080 }
2081 };
2082
2083 auth_redir_serv: REDIRSERV '=' QSTRING ';'
2084 {
2085 if (ypass == 2)
2086 {
2087 yy_aconf->flags |= CONF_FLAGS_REDIR;
2088 MyFree(yy_conf->name);
2089 DupString(yy_conf->name, yylval.string);
2090 }
2091 };
2092
2093 auth_redir_port: REDIRPORT '=' NUMBER ';'
2094 {
2095 if (ypass == 2)
2096 {
2097 yy_aconf->flags |= CONF_FLAGS_REDIR;
2098 yy_aconf->port = $3;
2099 }
2100 };
2101
2102 auth_need_password: NEED_PASSWORD '=' TBOOL ';'
2103 {
2104 if (ypass == 2)
2105 {
2106 if (yylval.number)
2107 yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2108 else
2109 yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2110 }
2111 };
2112
2113
2114 /***************************************************************************
2115 * section resv
2116 ***************************************************************************/
2117 resv_entry: RESV
2118 {
2119 if (ypass == 2)
2120 {
2121 MyFree(resv_reason);
2122 resv_reason = NULL;
2123 }
2124 } '{' resv_items '}' ';'
2125 {
2126 if (ypass == 2)
2127 {
2128 MyFree(resv_reason);
2129 resv_reason = NULL;
2130 }
2131 };
2132
2133 resv_items: resv_items resv_item | resv_item;
2134 resv_item: resv_creason | resv_channel | resv_nick | error ';' ;
2135
2136 resv_creason: REASON '=' QSTRING ';'
2137 {
2138 if (ypass == 2)
2139 {
2140 MyFree(resv_reason);
2141 DupString(resv_reason, yylval.string);
2142 }
2143 };
2144
2145 resv_channel: CHANNEL '=' QSTRING ';'
2146 {
2147 if (ypass == 2)
2148 {
2149 if (IsChanPrefix(*yylval.string))
2150 {
2151 char def_reason[] = "No reason";
2152
2153 create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
2154 }
2155 }
2156 /* ignore it for now.. but we really should make a warning if
2157 * its an erroneous name --fl_ */
2158 };
2159
2160 resv_nick: NICK '=' QSTRING ';'
2161 {
2162 if (ypass == 2)
2163 {
2164 char def_reason[] = "No reason";
2165
2166 create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
2167 }
2168 };
2169
2170 /***************************************************************************
2171 * section shared, for sharing remote klines etc.
2172 ***************************************************************************/
2173 shared_entry: T_SHARED
2174 {
2175 if (ypass == 2)
2176 {
2177 yy_conf = make_conf_item(ULINE_TYPE);
2178 yy_match_item = map_to_conf(yy_conf);
2179 yy_match_item->action = SHARED_ALL;
2180 }
2181 } '{' shared_items '}' ';'
2182 {
2183 if (ypass == 2)
2184 {
2185 yy_conf = NULL;
2186 }
2187 };
2188
2189 shared_items: shared_items shared_item | shared_item;
2190 shared_item: shared_name | shared_user | shared_type | error ';' ;
2191
2192 shared_name: NAME '=' QSTRING ';'
2193 {
2194 if (ypass == 2)
2195 {
2196 MyFree(yy_conf->name);
2197 DupString(yy_conf->name, yylval.string);
2198 }
2199 };
2200
2201 shared_user: USER '=' QSTRING ';'
2202 {
2203 if (ypass == 2)
2204 {
2205 split_nuh(yylval.string, NULL, &yy_match_item->user, &yy_match_item->host);
2206 }
2207 };
2208
2209 shared_type: TYPE
2210 {
2211 if (ypass == 2)
2212 yy_match_item->action = 0;
2213 } '=' shared_types ';' ;
2214
2215 shared_types: shared_types ',' shared_type_item | shared_type_item;
2216 shared_type_item: KLINE
2217 {
2218 if (ypass == 2)
2219 yy_match_item->action |= SHARED_KLINE;
2220 } | TKLINE
2221 {
2222 if (ypass == 2)
2223 yy_match_item->action |= SHARED_TKLINE;
2224 } | UNKLINE
2225 {
2226 if (ypass == 2)
2227 yy_match_item->action |= SHARED_UNKLINE;
2228 } | XLINE
2229 {
2230 if (ypass == 2)
2231 yy_match_item->action |= SHARED_XLINE;
2232 } | TXLINE
2233 {
2234 if (ypass == 2)
2235 yy_match_item->action |= SHARED_TXLINE;
2236 } | T_UNXLINE
2237 {
2238 if (ypass == 2)
2239 yy_match_item->action |= SHARED_UNXLINE;
2240 } | RESV
2241 {
2242 if (ypass == 2)
2243 yy_match_item->action |= SHARED_RESV;
2244 } | TRESV
2245 {
2246 if (ypass == 2)
2247 yy_match_item->action |= SHARED_TRESV;
2248 } | T_UNRESV
2249 {
2250 if (ypass == 2)
2251 yy_match_item->action |= SHARED_UNRESV;
2252 } | T_LOCOPS
2253 {
2254 if (ypass == 2)
2255 yy_match_item->action |= SHARED_LOCOPS;
2256 } | T_ALL
2257 {
2258 if (ypass == 2)
2259 yy_match_item->action = SHARED_ALL;
2260 };
2261
2262 /***************************************************************************
2263 * section cluster
2264 ***************************************************************************/
2265 cluster_entry: T_CLUSTER
2266 {
2267 if (ypass == 2)
2268 {
2269 yy_conf = make_conf_item(CLUSTER_TYPE);
2270 yy_conf->flags = SHARED_ALL;
2271 }
2272 } '{' cluster_items '}' ';'
2273 {
2274 if (ypass == 2)
2275 {
2276 if (yy_conf->name == NULL)
2277 DupString(yy_conf->name, "*");
2278 yy_conf = NULL;
2279 }
2280 };
2281
2282 cluster_items: cluster_items cluster_item | cluster_item;
2283 cluster_item: cluster_name | cluster_type | error ';' ;
2284
2285 cluster_name: NAME '=' QSTRING ';'
2286 {
2287 if (ypass == 2)
2288 DupString(yy_conf->name, yylval.string);
2289 };
2290
2291 cluster_type: TYPE
2292 {
2293 if (ypass == 2)
2294 yy_conf->flags = 0;
2295 } '=' cluster_types ';' ;
2296
2297 cluster_types: cluster_types ',' cluster_type_item | cluster_type_item;
2298 cluster_type_item: KLINE
2299 {
2300 if (ypass == 2)
2301 yy_conf->flags |= SHARED_KLINE;
2302 } | TKLINE
2303 {
2304 if (ypass == 2)
2305 yy_conf->flags |= SHARED_TKLINE;
2306 } | UNKLINE
2307 {
2308 if (ypass == 2)
2309 yy_conf->flags |= SHARED_UNKLINE;
2310 } | XLINE
2311 {
2312 if (ypass == 2)
2313 yy_conf->flags |= SHARED_XLINE;
2314 } | TXLINE
2315 {
2316 if (ypass == 2)
2317 yy_conf->flags |= SHARED_TXLINE;
2318 } | T_UNXLINE
2319 {
2320 if (ypass == 2)
2321 yy_conf->flags |= SHARED_UNXLINE;
2322 } | RESV
2323 {
2324 if (ypass == 2)
2325 yy_conf->flags |= SHARED_RESV;
2326 } | TRESV
2327 {
2328 if (ypass == 2)
2329 yy_conf->flags |= SHARED_TRESV;
2330 } | T_UNRESV
2331 {
2332 if (ypass == 2)
2333 yy_conf->flags |= SHARED_UNRESV;
2334 } | T_LOCOPS
2335 {
2336 if (ypass == 2)
2337 yy_conf->flags |= SHARED_LOCOPS;
2338 } | T_ALL
2339 {
2340 if (ypass == 2)
2341 yy_conf->flags = SHARED_ALL;
2342 };
2343
2344 /***************************************************************************
2345 * section connect
2346 ***************************************************************************/
2347 connect_entry: CONNECT
2348 {
2349 if (ypass == 2)
2350 {
2351 yy_conf = make_conf_item(SERVER_TYPE);
2352 yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
2353 yy_aconf->passwd = NULL;
2354 /* defaults */
2355 yy_aconf->port = PORTNUM;
2356
2357 if (ConfigFileEntry.burst_away)
2358 yy_aconf->flags = CONF_FLAGS_BURST_AWAY;
2359 }
2360 else
2361 {
2362 MyFree(class_name);
2363 class_name = NULL;
2364 }
2365 } connect_name_b '{' connect_items '}' ';'
2366 {
2367 if (ypass == 2)
2368 {
2369 struct CollectItem *yy_hconf=NULL;
2370 struct CollectItem *yy_lconf=NULL;
2371 dlink_node *ptr;
2372 dlink_node *next_ptr;
2373 #ifdef HAVE_LIBCRYPTO
2374 if (yy_aconf->host &&
2375 ((yy_aconf->passwd && yy_aconf->spasswd) ||
2376 (yy_aconf->rsa_public_key && IsConfCryptLink(yy_aconf))))
2377 #else /* !HAVE_LIBCRYPTO */
2378 if (yy_aconf->host && !IsConfCryptLink(yy_aconf) &&
2379 yy_aconf->passwd && yy_aconf->spasswd)
2380 #endif /* !HAVE_LIBCRYPTO */
2381 {
2382 if (conf_add_server(yy_conf, scount, class_name) >= 0)
2383 {
2384 ++scount;
2385 }
2386 else
2387 {
2388 delete_conf_item(yy_conf);
2389 yy_conf = NULL;
2390 yy_aconf = NULL;
2391 }
2392 }
2393 else
2394 {
2395 /* Even if yy_conf ->name is NULL
2396 * should still unhook any hub/leaf confs still pending
2397 */
2398 unhook_hub_leaf_confs();
2399
2400 if (yy_conf->name != NULL)
2401 {
2402 #ifndef HAVE_LIBCRYPTO
2403 if (IsConfCryptLink(yy_aconf))
2404 yyerror("Ignoring connect block -- no OpenSSL support");
2405 #else
2406 if (IsConfCryptLink(yy_aconf) && !yy_aconf->rsa_public_key)
2407 yyerror("Ignoring connect block -- missing key");
2408 #endif
2409 if (yy_aconf->host == NULL)
2410 yyerror("Ignoring connect block -- missing host");
2411 else if (!IsConfCryptLink(yy_aconf) &&
2412 (!yy_aconf->passwd || !yy_aconf->spasswd))
2413 yyerror("Ignoring connect block -- missing password");
2414 }
2415
2416
2417 /* XXX
2418 * This fixes a try_connections() core (caused by invalid class_ptr
2419 * pointers) reported by metalrock. That's an ugly fix, but there
2420 * is currently no better way. The entire config subsystem needs an
2421 * rewrite ASAP. make_conf_item() shouldn't really add things onto
2422 * a doubly linked list immediately without any sanity checks! -Michael
2423 */
2424 delete_conf_item(yy_conf);
2425
2426 yy_aconf = NULL;
2427 yy_conf = NULL;
2428 }
2429
2430 /*
2431 * yy_conf is still pointing at the server that is having
2432 * a connect block built for it. This means, y_aconf->name
2433 * points to the actual irc name this server will be known as.
2434 * Now this new server has a set or even just one hub_mask (or leaf_mask)
2435 * given in the link list at yy_hconf. Fill in the HUB confs
2436 * from this link list now.
2437 */
2438 DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
2439 {
2440 struct ConfItem *new_hub_conf;
2441 struct MatchItem *match_item;
2442
2443 yy_hconf = ptr->data;
2444
2445 /* yy_conf == NULL is a fatal error for this connect block! */
2446 if ((yy_conf != NULL) && (yy_conf->name != NULL))
2447 {
2448 new_hub_conf = make_conf_item(HUB_TYPE);
2449 match_item = (struct MatchItem *)map_to_conf(new_hub_conf);
2450 DupString(new_hub_conf->name, yy_conf->name);
2451 if (yy_hconf->user != NULL)
2452 DupString(match_item->user, yy_hconf->user);
2453 else
2454 DupString(match_item->user, "*");
2455 if (yy_hconf->host != NULL)
2456 DupString(match_item->host, yy_hconf->host);
2457 else
2458 DupString(match_item->host, "*");
2459 }
2460 dlinkDelete(&yy_hconf->node, &hub_conf_list);
2461 free_collect_item(yy_hconf);
2462 }
2463
2464 /* Ditto for the LEAF confs */
2465
2466 DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
2467 {
2468 struct ConfItem *new_leaf_conf;
2469 struct MatchItem *match_item;
2470
2471 yy_lconf = ptr->data;
2472
2473 if ((yy_conf != NULL) && (yy_conf->name != NULL))
2474 {
2475 new_leaf_conf = make_conf_item(LEAF_TYPE);
2476 match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
2477 DupString(new_leaf_conf->name, yy_conf->name);
2478 if (yy_lconf->user != NULL)
2479 DupString(match_item->user, yy_lconf->user);
2480 else
2481 DupString(match_item->user, "*");
2482 if (yy_lconf->host != NULL)
2483 DupString(match_item->host, yy_lconf->host);
2484 else
2485 DupString(match_item->host, "*");
2486 }
2487 dlinkDelete(&yy_lconf->node, &leaf_conf_list);
2488 free_collect_item(yy_lconf);
2489 }
2490 MyFree(class_name);
2491 class_name = NULL;
2492 yy_conf = NULL;
2493 yy_aconf = NULL;
2494 }
2495 };
2496
2497 connect_name_b: | connect_name_t;
2498 connect_items: connect_items connect_item | connect_item;
2499 connect_item: connect_name | connect_host | connect_vhost |
2500 connect_send_password | connect_accept_password |
2501 connect_aftype | connect_port |
2502 connect_fakename | connect_flags | connect_hub_mask |
2503 connect_leaf_mask | connect_class | connect_auto |
2504 connect_encrypted | connect_compressed | connect_cryptlink |
2505 connect_rsa_public_key_file | connect_cipher_preference |
2506 connect_topicburst | error ';' ;
2507
2508 connect_name: NAME '=' QSTRING ';'
2509 {
2510 if (ypass == 2)
2511 {
2512 if (yy_conf->name != NULL)
2513 yyerror("Multiple connect name entry");
2514
2515 MyFree(yy_conf->name);
2516 DupString(yy_conf->name, yylval.string);
2517 }
2518 };
2519
2520 connect_name_t: QSTRING
2521 {
2522 if (ypass == 2)
2523 {
2524 if (yy_conf->name != NULL)
2525 yyerror("Multiple connect name entry");
2526
2527 MyFree(yy_conf->name);
2528 DupString(yy_conf->name, yylval.string);
2529 }
2530 };
2531
2532 connect_host: HOST '=' QSTRING ';'
2533 {
2534 if (ypass == 2)
2535 {
2536 MyFree(yy_aconf->host);
2537 DupString(yy_aconf->host, yylval.string);
2538 }
2539 };
2540
2541 connect_vhost: VHOST '=' QSTRING ';'
2542 {
2543 if (ypass == 2)
2544 {
2545 struct addrinfo hints, *res;
2546
2547 memset(&hints, 0, sizeof(hints));
2548
2549 hints.ai_family = AF_UNSPEC;
2550 hints.ai_socktype = SOCK_STREAM;
2551 hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
2552
2553 if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
2554 ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
2555 else
2556 {
2557 assert(res != NULL);
2558
2559 memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2560 yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2561 yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2562 irc_freeaddrinfo(res);
2563 }
2564 }
2565 };
2566
2567 connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2568 {
2569 if (ypass == 2)
2570 {
2571 if ($3[0] == ':')
2572 yyerror("Server passwords cannot begin with a colon");
2573 else if (strchr($3, ' ') != NULL)
2574 yyerror("Server passwords cannot contain spaces");
2575 else {
2576 if (yy_aconf->spasswd != NULL)
2577 memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2578
2579 MyFree(yy_aconf->spasswd);
2580 DupString(yy_aconf->spasswd, yylval.string);
2581 }
2582 }
2583 };
2584
2585 connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2586 {
2587 if (ypass == 2)
2588 {
2589 if ($3[0] == ':')
2590 yyerror("Server passwords cannot begin with a colon");
2591 else if (strchr($3, ' ') != NULL)
2592 yyerror("Server passwords cannot contain spaces");
2593 else {
2594 if (yy_aconf->passwd != NULL)
2595 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2596
2597 MyFree(yy_aconf->passwd);
2598 DupString(yy_aconf->passwd, yylval.string);
2599 }
2600 }
2601 };
2602
2603 connect_port: PORT '=' NUMBER ';'
2604 {
2605 if (ypass == 2)
2606 yy_aconf->port = $3;
2607 };
2608
2609 connect_aftype: AFTYPE '=' T_IPV4 ';'
2610 {
2611 if (ypass == 2)
2612 yy_aconf->aftype = AF_INET;
2613 } | AFTYPE '=' T_IPV6 ';'
2614 {
2615 #ifdef IPV6
2616 if (ypass == 2)
2617 yy_aconf->aftype = AF_INET6;
2618 #endif
2619 };
2620
2621 connect_fakename: FAKENAME '=' QSTRING ';'
2622 {
2623 if (ypass == 2)
2624 {
2625 MyFree(yy_aconf->fakename);
2626 DupString(yy_aconf->fakename, yylval.string);
2627 }
2628 };
2629
2630 connect_flags: IRCD_FLAGS
2631 {
2632 } '=' connect_flags_items ';';
2633
2634 connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2635 connect_flags_item: NOT { not_atom = 1; } connect_flags_item_atom
2636 | { not_atom = 0; } connect_flags_item_atom;
2637
2638 connect_flags_item_atom: LAZYLINK
2639 {
2640 if (ypass == 2)
2641 {
2642 if (not_atom)ClearConfLazyLink(yy_aconf);
2643 else SetConfLazyLink(yy_aconf);
2644 }
2645 } | COMPRESSED
2646 {
2647 if (ypass == 2)
2648 #ifndef HAVE_LIBZ
2649 yyerror("Ignoring flags = compressed; -- no zlib support");
2650 #else
2651 {
2652 if (not_atom)ClearConfCompressed(yy_aconf);
2653 else SetConfCompressed(yy_aconf);
2654 }
2655 #endif
2656 } | CRYPTLINK
2657 {
2658 if (ypass == 2)
2659 {
2660 if (not_atom)ClearConfCryptLink(yy_aconf);
2661 else SetConfCryptLink(yy_aconf);
2662 }
2663 } | AUTOCONN
2664 {
2665 if (ypass == 2)
2666 {
2667 if (not_atom)ClearConfAllowAutoConn(yy_aconf);
2668 else SetConfAllowAutoConn(yy_aconf);
2669 }
2670 } | BURST_AWAY
2671 {
2672 if (ypass == 2)
2673 {
2674 if (not_atom)ClearConfAwayBurst(yy_aconf);
2675 else SetConfAwayBurst(yy_aconf);
2676 }
2677 } | TOPICBURST
2678 {
2679 if (ypass == 2)
2680 {
2681 if (not_atom)ClearConfTopicBurst(yy_aconf);
2682 else SetConfTopicBurst(yy_aconf);
2683 }
2684 }
2685 ;
2686
2687 connect_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
2688 {
2689 #ifdef HAVE_LIBCRYPTO
2690 if (ypass == 2)
2691 {
2692 BIO *file;
2693
2694 if (yy_aconf->rsa_public_key != NULL)
2695 {
2696 RSA_free(yy_aconf->rsa_public_key);
2697 yy_aconf->rsa_public_key = NULL;
2698 }
2699
2700 if (yy_aconf->rsa_public_key_file != NULL)
2701 {
2702 MyFree(yy_aconf->rsa_public_key_file);
2703 yy_aconf->rsa_public_key_file = NULL;
2704 }
2705
2706 DupString(yy_aconf->rsa_public_key_file, yylval.string);
2707
2708 if ((file = BIO_new_file(yylval.string, "r")) == NULL)
2709 {
2710 yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
2711 break;
2712 }
2713
2714 yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
2715
2716 if (yy_aconf->rsa_public_key == NULL)
2717 {
2718 yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
2719 break;
2720 }
2721
2722 BIO_set_close(file, BIO_CLOSE);
2723 BIO_free(file);
2724 }
2725 #endif /* HAVE_LIBCRYPTO */
2726 };
2727
2728 connect_encrypted: ENCRYPTED '=' TBOOL ';'
2729 {
2730 if (ypass == 2)
2731 {
2732 if (yylval.number)
2733 yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2734 else
2735 yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2736 }
2737 };
2738
2739 connect_cryptlink: CRYPTLINK '=' TBOOL ';'
2740 {
2741 if (ypass == 2)
2742 {
2743 if (yylval.number)
2744 yy_aconf->flags |= CONF_FLAGS_CRYPTLINK;
2745 else
2746 yy_aconf->flags &= ~CONF_FLAGS_CRYPTLINK;
2747 }
2748 };
2749
2750 connect_compressed: COMPRESSED '=' TBOOL ';'
2751 {
2752 if (ypass == 2)
2753 {
2754 if (yylval.number)
2755 #ifndef HAVE_LIBZ
2756 yyerror("Ignoring compressed=yes; -- no zlib support");
2757 #else
2758 yy_aconf->flags |= CONF_FLAGS_COMPRESSED;
2759 #endif
2760 else
2761 yy_aconf->flags &= ~CONF_FLAGS_COMPRESSED;
2762 }
2763 };
2764
2765 connect_auto: AUTOCONN '=' TBOOL ';'
2766 {
2767 if (ypass == 2)
2768 {
2769 if (yylval.number)
2770 yy_aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
2771 else
2772 yy_aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
2773 }
2774 };
2775
2776 connect_topicburst: TOPICBURST '=' TBOOL ';'
2777 {
2778 if (ypass == 2)
2779 {
2780 if (yylval.number)
2781 SetConfTopicBurst(yy_aconf);
2782 else
2783 ClearConfTopicBurst(yy_aconf);
2784 }
2785 };
2786
2787 connect_hub_mask: HUB_MASK '=' QSTRING ';'
2788 {
2789 if (ypass == 2)
2790 {
2791 struct CollectItem *yy_tmp;
2792
2793 yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2794 DupString(yy_tmp->host, yylval.string);
2795 DupString(yy_tmp->user, "*");
2796 dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2797 }
2798 };
2799
2800 connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2801 {
2802 if (ypass == 2)
2803 {
2804 struct CollectItem *yy_tmp;
2805
2806 yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2807 DupString(yy_tmp->host, yylval.string);
2808 DupString(yy_tmp->user, "*");
2809 dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2810 }
2811 };
2812
2813 connect_class: CLASS '=' QSTRING ';'
2814 {
2815 if (ypass == 2)
2816 {
2817 MyFree(class_name);
2818 DupString(class_name, yylval.string);
2819 }
2820 };
2821
2822 connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2823 {
2824 #ifdef HAVE_LIBCRYPTO
2825 if (ypass == 2)
2826 {
2827 struct EncCapability *ecap;
2828 const char *cipher_name;
2829 int found = 0;
2830
2831 yy_aconf->cipher_preference = NULL;
2832 cipher_name = yylval.string;
2833
2834 for (ecap = CipherTable; ecap->name; ecap++)
2835 {
2836 if ((irccmp(ecap->name, cipher_name) == 0) &&
2837 (ecap->cap & CAP_ENC_MASK))
2838 {
2839 yy_aconf->cipher_preference = ecap;
2840 found = 1;
2841 break;
2842 }
2843 }
2844
2845 if (!found)
2846 yyerror("Invalid cipher");
2847 }
2848 #else
2849 if (ypass == 2)
2850 yyerror("Ignoring cipher_preference -- no OpenSSL support");
2851 #endif
2852 };
2853
2854 /***************************************************************************
2855 * section kill
2856 ***************************************************************************/
2857 kill_entry: KILL
2858 {
2859 if (ypass == 2)
2860 {
2861 userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2862 regex_ban = 0;
2863 }
2864 } '{' kill_items '}' ';'
2865 {
2866 if (ypass == 2)
2867 {
2868 if (userbuf[0] && hostbuf[0])
2869 {
2870 if (regex_ban)
2871 {
2872 pcre *exp_user = NULL;
2873 pcre *exp_host = NULL;
2874 const char *errptr = NULL;
2875
2876 if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2877 !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2878 {
2879 ilog(L_ERROR, "Failed to add regular expression based K-Line: %s", errptr);
2880 break;
2881 }
2882
2883 yy_conf = make_conf_item(RKLINE_TYPE);
2884 yy_aconf->regexuser = exp_user;
2885 yy_aconf->regexhost = exp_host;
2886
2887 DupString(yy_aconf->user, userbuf);
2888 DupString(yy_aconf->host, hostbuf);
2889
2890 if (reasonbuf[0])
2891 DupString(yy_aconf->reason, reasonbuf);
2892 else
2893 DupString(yy_aconf->reason, "No reason");
2894 }
2895 else
2896 {
2897 yy_conf = make_conf_item(KLINE_TYPE);
2898 yy_aconf = map_to_conf(yy_conf);
2899
2900 DupString(yy_aconf->user, userbuf);
2901 DupString(yy_aconf->host, hostbuf);
2902
2903 if (reasonbuf[0])
2904 DupString(yy_aconf->reason, reasonbuf);
2905 else
2906 DupString(yy_aconf->reason, "No reason");
2907 add_conf_by_address(CONF_KILL, yy_aconf);
2908 }
2909 }
2910 else
2911 delete_conf_item(yy_conf);
2912
2913 yy_conf = NULL;
2914 yy_aconf = NULL;
2915 }
2916 };
2917
2918 kill_type: TYPE
2919 {
2920 } '=' kill_type_items ';';
2921
2922 kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2923 kill_type_item: REGEX_T
2924 {
2925 if (ypass == 2)
2926 regex_ban = 1;
2927 };
2928
2929 kill_items: kill_items kill_item | kill_item;
2930 kill_item: kill_user | kill_reason | kill_type | error;
2931
2932 kill_user: USER '=' QSTRING ';'
2933 {
2934 if (ypass == 2)
2935 {
2936 char *user = NULL, *host = NULL;
2937
2938 split_nuh(yylval.string, NULL, &user, &host);
2939
2940 strlcpy(userbuf, user, sizeof(userbuf));
2941 strlcpy(hostbuf, host, sizeof(hostbuf));
2942
2943 MyFree(user);
2944 MyFree(host);
2945 }
2946 };
2947
2948 kill_reason: REASON '=' QSTRING ';'
2949 {
2950 if (ypass == 2)
2951 strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2952 };
2953
2954 /***************************************************************************
2955 * section deny
2956 ***************************************************************************/
2957 deny_entry: DENY
2958 {
2959 if (ypass == 2)
2960 {
2961 yy_conf = make_conf_item(DLINE_TYPE);
2962 yy_aconf = map_to_conf(yy_conf);
2963 /* default reason */
2964 DupString(yy_aconf->reason, "No reason");
2965 }
2966 } '{' deny_items '}' ';'
2967 {
2968 if (ypass == 2)
2969 {
2970 if (yy_aconf->host && parse_netmask(yy_aconf->host, NULL, NULL) != HM_HOST)
2971 add_conf_by_address(CONF_DLINE, yy_aconf);
2972 else
2973 delete_conf_item(yy_conf);
2974 yy_conf = NULL;
2975 yy_aconf = NULL;
2976 }
2977 };
2978
2979 deny_items: deny_items deny_item | deny_item;
2980 deny_item: deny_ip | deny_reason | error;
2981
2982 deny_ip: IP '=' QSTRING ';'
2983 {
2984 if (ypass == 2)
2985 {
2986 MyFree(yy_aconf->host);
2987 DupString(yy_aconf->host, yylval.string);
2988 }
2989 };
2990
2991 deny_reason: REASON '=' QSTRING ';'
2992 {
2993 if (ypass == 2)
2994 {
2995 MyFree(yy_aconf->reason);
2996 DupString(yy_aconf->reason, yylval.string);
2997 }
2998 };
2999
3000 /***************************************************************************
3001 * section exempt
3002 ***************************************************************************/
3003 exempt_entry: EXEMPT '{' exempt_items '}' ';';
3004
3005 exempt_items: exempt_items exempt_item | exempt_item;
3006 exempt_item: exempt_ip | error;
3007
3008 exempt_ip: IP '=' QSTRING ';'
3009 {
3010 if (ypass == 2)
3011 {
3012 if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
3013 {
3014 yy_conf = make_conf_item(EXEMPTDLINE_TYPE);
3015 yy_aconf = map_to_conf(yy_conf);
3016 DupString(yy_aconf->host, yylval.string);
3017
3018 add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
3019
3020 yy_conf = NULL;
3021 yy_aconf = NULL;
3022 }
3023 }
3024 };
3025
3026 /***************************************************************************
3027 * section gecos
3028 ***************************************************************************/
3029 gecos_entry: GECOS
3030 {
3031 if (ypass == 2)
3032 {
3033 regex_ban = 0;
3034 reasonbuf[0] = gecos_name[0] = '\0';
3035 }
3036 } '{' gecos_items '}' ';'
3037 {
3038 if (ypass == 2)
3039 {
3040 if (gecos_name[0])
3041 {
3042 if (regex_ban)
3043 {
3044 pcre *exp_p = NULL;
3045 const char *errptr = NULL;
3046
3047 if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
3048 {
3049 ilog(L_ERROR, "Failed to add regular expression based X-Line: %s", errptr);
3050 break;
3051 }
3052
3053 yy_conf = make_conf_item(RXLINE_TYPE);
3054 yy_conf->regexpname = exp_p;
3055 }
3056 else
3057 yy_conf = make_conf_item(XLINE_TYPE);
3058
3059 yy_match_item = map_to_conf(yy_conf);
3060 DupString(yy_conf->name, gecos_name);
3061
3062 if (reasonbuf[0])
3063 DupString(yy_match_item->reason, reasonbuf);
3064 else
3065 DupString(yy_match_item->reason, "No reason");
3066 }
3067 }
3068 };
3069
3070 gecos_flags: TYPE
3071 {
3072 } '=' gecos_flags_items ';';
3073
3074 gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
3075 gecos_flags_item: REGEX_T
3076 {
3077 if (ypass == 2)
3078 regex_ban = 1;
3079 };
3080
3081 gecos_items: gecos_items gecos_item | gecos_item;
3082 gecos_item: gecos_name | gecos_reason | gecos_flags | error;
3083
3084 gecos_name: NAME '=' QSTRING ';'
3085 {
3086 if (ypass == 2)
3087 strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
3088 };
3089
3090 gecos_reason: REASON '=' QSTRING ';'
3091 {
3092 if (ypass == 2)
3093 strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
3094 };
3095
3096 /***************************************************************************
3097 * section general
3098 ***************************************************************************/
3099 general_entry: GENERAL
3100 '{' general_items '}' ';';
3101
3102 general_items: general_items general_item | general_item;
3103 general_item: general_hide_spoof_ips | general_ignore_bogus_ts |
3104 general_failed_oper_notice | general_anti_nick_flood |
3105 general_max_nick_time | general_max_nick_changes |
3106 general_max_accept | general_anti_spam_exit_message_time |
3107 general_ts_warn_delta | general_ts_max_delta |
3108 general_kill_chase_time_limit | general_kline_with_reason |
3109 general_kline_reason | general_invisible_on_connect |
3110 general_warn_no_nline | general_dots_in_ident |
3111 general_stats_o_oper_only | general_stats_k_oper_only |
3112 general_pace_wait | general_stats_i_oper_only |
3113 general_pace_wait_simple | general_stats_P_oper_only |
3114 general_short_motd | general_no_oper_flood |
3115 general_true_no_oper_flood | general_oper_pass_resv |
3116 general_idletime | general_message_locale |
3117 general_oper_only_umodes | general_max_targets |
3118 general_use_egd | general_egdpool_path |
3119 general_oper_umodes | general_caller_id_wait |
3120 general_opers_bypass_callerid | general_default_floodcount |
3121 general_min_nonwildcard | general_min_nonwildcard_simple |
3122 general_servlink_path | general_disable_remote_commands |
3123 general_default_cipher_preference |
3124 general_compression_level | general_client_flood |
3125 general_throttle_time | general_havent_read_conf |
3126 general_dot_in_ip6_addr | general_ping_cookie |
3127 general_disable_auth | general_burst_away |
3128 general_tkline_expire_notices | general_gline_min_cidr |
3129 general_gline_min_cidr6 | general_use_whois_actually |
3130 general_reject_hold_time | general_stats_e_disabled |
3131 error;
3132
3133
3134
3135 general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
3136 {
3137 ConfigFileEntry.gline_min_cidr = $3;
3138 };
3139
3140 general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
3141 {
3142 ConfigFileEntry.gline_min_cidr6 = $3;
3143 };
3144
3145 general_burst_away: BURST_AWAY '=' TBOOL ';'
3146 {
3147 ConfigFileEntry.burst_away = yylval.number;
3148 };
3149
3150 general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
3151 {
3152 ConfigFileEntry.use_whois_actually = yylval.number;
3153 };
3154
3155 general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
3156 {
3157 GlobalSetOptions.rejecttime = yylval.number;
3158 };
3159
3160 general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
3161 {
3162 ConfigFileEntry.tkline_expire_notices = yylval.number;
3163 };
3164
3165 general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' NUMBER ';'
3166 {
3167 ConfigFileEntry.kill_chase_time_limit = $3;
3168 };
3169
3170 general_hide_spoof_ips: HIDE_SPOOF_IPS '=' TBOOL ';'
3171 {
3172 ConfigFileEntry.hide_spoof_ips = yylval.number;
3173 };
3174
3175 general_ignore_bogus_ts: IGNORE_BOGUS_TS '=' TBOOL ';'
3176 {
3177 ConfigFileEntry.ignore_bogus_ts = yylval.number;
3178 };
3179
3180 general_disable_remote_commands: DISABLE_REMOTE_COMMANDS '=' TBOOL ';'
3181 {
3182 ConfigFileEntry.disable_remote = yylval.number;
3183 };
3184
3185 general_failed_oper_notice: FAILED_OPER_NOTICE '=' TBOOL ';'
3186 {
3187 ConfigFileEntry.failed_oper_notice = yylval.number;
3188 };
3189
3190 general_anti_nick_flood: ANTI_NICK_FLOOD '=' TBOOL ';'
3191 {
3192 ConfigFileEntry.anti_nick_flood = yylval.number;
3193 };
3194
3195 general_max_nick_time: MAX_NICK_TIME '=' timespec ';'
3196 {
3197 ConfigFileEntry.max_nick_time = $3;
3198 };
3199
3200 general_max_nick_changes: MAX_NICK_CHANGES '=' NUMBER ';'
3201 {
3202 ConfigFileEntry.max_nick_changes = $3;
3203 };
3204
3205 general_max_accept: MAX_ACCEPT '=' NUMBER ';'
3206 {
3207 ConfigFileEntry.max_accept = $3;
3208 };
3209
3210 general_anti_spam_exit_message_time: ANTI_SPAM_EXIT_MESSAGE_TIME '=' timespec ';'
3211 {
3212 ConfigFileEntry.anti_spam_exit_message_time = $3;
3213 };
3214
3215 general_ts_warn_delta: TS_WARN_DELTA '=' timespec ';'
3216 {
3217 ConfigFileEntry.ts_warn_delta = $3;
3218 };
3219
3220 general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
3221 {
3222 if (ypass == 2)
3223 ConfigFileEntry.ts_max_delta = $3;
3224 };
3225
3226 general_havent_read_conf: HAVENT_READ_CONF '=' NUMBER ';'
3227 {
3228 if (($3 > 0) && ypass == 1)
3229 {
3230 ilog(L_CRIT, "You haven't read your config file properly.");
3231 ilog(L_CRIT, "There is a line in the example conf that will kill your server if not removed.");
3232 ilog(L_CRIT, "Consider actually reading/editing the conf file, and removing this line.");
3233 exit(0);
3234 }
3235 };
3236
3237 general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
3238 {
3239 ConfigFileEntry.kline_with_reason = yylval.number;
3240 };
3241
3242 general_kline_reason: KLINE_REASON '=' QSTRING ';'
3243 {
3244 if (ypass == 2)
3245 {
3246 MyFree(ConfigFileEntry.kline_reason);
3247 DupString(ConfigFileEntry.kline_reason, yylval.string);
3248 }
3249 };
3250
3251 general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
3252 {
3253 ConfigFileEntry.invisible_on_connect = yylval.number;
3254 };
3255
3256 general_warn_no_nline: WARN_NO_NLINE '=' TBOOL ';'
3257 {
3258 ConfigFileEntry.warn_no_nline = yylval.number;
3259 };
3260
3261 general_stats_e_disabled: STATS_E_DISABLED '=' TBOOL ';'
3262 {
3263 ConfigFileEntry.stats_e_disabled = yylval.number;
3264 };
3265
3266 general_stats_o_oper_only: STATS_O_OPER_ONLY '=' TBOOL ';'
3267 {
3268 ConfigFileEntry.stats_o_oper_only = yylval.number;
3269 };
3270
3271 general_stats_P_oper_only: STATS_P_OPER_ONLY '=' TBOOL ';'
3272 {
3273 ConfigFileEntry.stats_P_oper_only = yylval.number;
3274 };
3275
3276 general_stats_k_oper_only: STATS_K_OPER_ONLY '=' TBOOL ';'
3277 {
3278 ConfigFileEntry.stats_k_oper_only = 2 * yylval.number;
3279 } | STATS_K_OPER_ONLY '=' TMASKED ';'
3280 {
3281 ConfigFileEntry.stats_k_oper_only = 1;
3282 };
3283
3284 general_stats_i_oper_only: STATS_I_OPER_ONLY '=' TBOOL ';'
3285 {
3286 ConfigFileEntry.stats_i_oper_only = 2 * yylval.number;
3287 } | STATS_I_OPER_ONLY '=' TMASKED ';'
3288 {
3289 ConfigFileEntry.stats_i_oper_only = 1;
3290 };
3291
3292 general_pace_wait: PACE_WAIT '=' timespec ';'
3293 {
3294 ConfigFileEntry.pace_wait = $3;
3295 };
3296
3297 general_caller_id_wait: CALLER_ID_WAIT '=' timespec ';'
3298 {
3299 ConfigFileEntry.caller_id_wait = $3;
3300 };
3301
3302 general_opers_bypass_callerid: OPERS_BYPASS_CALLERID '=' TBOOL ';'
3303 {
3304 ConfigFileEntry.opers_bypass_callerid = yylval.number;
3305 };
3306
3307 general_pace_wait_simple: PACE_WAIT_SIMPLE '=' timespec ';'
3308 {
3309 ConfigFileEntry.pace_wait_simple = $3;
3310 };
3311
3312 general_short_motd: SHORT_MOTD '=' TBOOL ';'
3313 {
3314 ConfigFileEntry.short_motd = yylval.number;
3315 };
3316
3317 general_no_oper_flood: NO_OPER_FLOOD '=' TBOOL ';'
3318 {
3319 ConfigFileEntry.no_oper_flood = yylval.number;
3320 };
3321
3322 general_true_no_oper_flood: TRUE_NO_OPER_FLOOD '=' TBOOL ';'
3323 {
3324 ConfigFileEntry.true_no_oper_flood = yylval.number;
3325 };
3326
3327 general_oper_pass_resv: OPER_PASS_RESV '=' TBOOL ';'
3328 {
3329 ConfigFileEntry.oper_pass_resv = yylval.number;
3330 };
3331
3332 general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
3333 {
3334 if (ypass == 2)
3335 {
3336 if (strlen(yylval.string) > LOCALE_LENGTH-2)
3337 yylval.string[LOCALE_LENGTH-1] = '\0';
3338
3339 set_locale(yylval.string);
3340 }
3341 };
3342
3343 general_idletime: IDLETIME '=' timespec ';'
3344 {
3345 ConfigFileEntry.idletime = $3;
3346 };
3347
3348 general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
3349 {
3350 ConfigFileEntry.dots_in_ident = $3;
3351 };
3352
3353 general_max_targets: MAX_TARGETS '=' NUMBER ';'
3354 {
3355 ConfigFileEntry.max_targets = $3;
3356 };
3357
3358 general_servlink_path: SERVLINK_PATH '=' QSTRING ';'
3359 {
3360 if (ypass == 2)
3361 {
3362 MyFree(ConfigFileEntry.servlink_path);
3363 DupString(ConfigFileEntry.servlink_path, yylval.string);
3364 }
3365 };
3366
3367 general_default_cipher_preference: DEFAULT_CIPHER_PREFERENCE '=' QSTRING ';'
3368 {
3369 #ifdef HAVE_LIBCRYPTO
3370 if (ypass == 2)
3371 {
3372 struct EncCapability *ecap;
3373 const char *cipher_name;
3374 int found = 0;
3375
3376 ConfigFileEntry.default_cipher_preference = NULL;
3377 cipher_name = yylval.string;
3378
3379 for (ecap = CipherTable; ecap->name; ecap++)
3380 {
3381 if ((irccmp(ecap->name, cipher_name) == 0) &&
3382 (ecap->cap & CAP_ENC_MASK))
3383 {
3384 ConfigFileEntry.default_cipher_preference = ecap;
3385 found = 1;
3386 break;
3387 }
3388 }
3389
3390 if (!found)
3391 yyerror("Invalid cipher");
3392 }
3393 #else
3394 if (ypass == 2)
3395 yyerror("Ignoring default_cipher_preference -- no OpenSSL support");
3396 #endif
3397 };
3398
3399 general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
3400 {
3401 if (ypass == 2)
3402 {
3403 ConfigFileEntry.compression_level = $3;
3404 #ifndef HAVE_LIBZ
3405 yyerror("Ignoring compression_level -- no zlib support");
3406 #else
3407 if ((ConfigFileEntry.compression_level < 1) ||
3408 (ConfigFileEntry.compression_level > 9))
3409 {
3410 yyerror("Ignoring invalid compression_level, using default");
3411 ConfigFileEntry.compression_level = 0;
3412 }
3413 #endif
3414 }
3415 };
3416
3417 general_use_egd: USE_EGD '=' TBOOL ';'
3418 {
3419 ConfigFileEntry.use_egd = yylval.number;
3420 };
3421
3422 general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
3423 {
3424 if (ypass == 2)
3425 {
3426 MyFree(ConfigFileEntry.egdpool_path);
3427 DupString(ConfigFileEntry.egdpool_path, yylval.string);
3428 }
3429 };
3430
3431 general_ping_cookie: PING_COOKIE '=' TBOOL ';'
3432 {
3433 ConfigFileEntry.ping_cookie = yylval.number;
3434 };
3435
3436 general_disable_auth: DISABLE_AUTH '=' TBOOL ';'
3437 {
3438 ConfigFileEntry.disable_auth = yylval.number;
3439 };
3440
3441 general_throttle_time: THROTTLE_TIME '=' timespec ';'
3442 {
3443 ConfigFileEntry.throttle_time = yylval.number;
3444 };
3445
3446 general_oper_umodes: OPER_UMODES
3447 {
3448 ConfigFileEntry.oper_umodes = 0;
3449 } '=' umode_oitems ';' ;
3450
3451 umode_oitems: umode_oitems ',' umode_oitem | umode_oitem;
3452 umode_oitem: T_BOTS
3453 {
3454 ConfigFileEntry.oper_umodes |= UMODE_BOTS;
3455 } | T_CCONN
3456 {
3457 ConfigFileEntry.oper_umodes |= UMODE_CCONN;
3458 } | T_DEAF
3459 {
3460 ConfigFileEntry.oper_umodes |= UMODE_DEAF;
3461 } | T_DEBUG
3462 {
3463 ConfigFileEntry.oper_umodes |= UMODE_DEBUG;
3464 } | T_FULL
3465 {
3466 ConfigFileEntry.oper_umodes |= UMODE_FULL;
3467 } | T_SKILL
3468 {
3469 ConfigFileEntry.oper_umodes |= UMODE_SKILL;
3470 } | T_NCHANGE
3471 {
3472 ConfigFileEntry.oper_umodes |= UMODE_NCHANGE;
3473 } | T_REJ
3474 {
3475 ConfigFileEntry.oper_umodes |= UMODE_REJ;
3476 } | T_UNAUTH
3477 {
3478 ConfigFileEntry.oper_umodes |= UMODE_UNAUTH;
3479 } | T_SPY
3480 {
3481 ConfigFileEntry.oper_umodes |= UMODE_SPY;
3482 } | T_EXTERNAL
3483 {
3484 ConfigFileEntry.oper_umodes |= UMODE_EXTERNAL;
3485 } | T_OPERWALL
3486 {
3487 ConfigFileEntry.oper_umodes |= UMODE_OPERWALL;
3488 } | T_SERVNOTICE
3489 {
3490 ConfigFileEntry.oper_umodes |= UMODE_SERVNOTICE;
3491 } | T_INVISIBLE
3492 {
3493 ConfigFileEntry.oper_umodes |= UMODE_INVISIBLE;
3494 } | T_WALLOP
3495 {
3496 ConfigFileEntry.oper_umodes |= UMODE_WALLOP;
3497 } | T_SOFTCALLERID
3498 {
3499 ConfigFileEntry.oper_umodes |= UMODE_SOFTCALLERID;
3500 } | T_CALLERID
3501 {
3502 ConfigFileEntry.oper_umodes |= UMODE_CALLERID;
3503 } | T_LOCOPS
3504 {
3505 ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
3506 };
3507
3508 general_oper_only_umodes: OPER_ONLY_UMODES
3509 {
3510 ConfigFileEntry.oper_only_umodes = 0;
3511 } '=' umode_items ';' ;
3512
3513 umode_items: umode_items ',' umode_item | umode_item;
3514 umode_item: T_BOTS
3515 {
3516 ConfigFileEntry.oper_only_umodes |= UMODE_BOTS;
3517 } | T_CCONN
3518 {
3519 ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
3520 } | T_DEAF
3521 {
3522 ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
3523 } | T_DEBUG
3524 {
3525 ConfigFileEntry.oper_only_umodes |= UMODE_DEBUG;
3526 } | T_FULL
3527 {
3528 ConfigFileEntry.oper_only_umodes |= UMODE_FULL;
3529 } | T_SKILL
3530 {
3531 ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
3532 } | T_NCHANGE
3533 {
3534 ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
3535 } | T_REJ
3536 {
3537 ConfigFileEntry.oper_only_umodes |= UMODE_REJ;
3538 } | T_UNAUTH
3539 {
3540 ConfigFileEntry.oper_only_umodes |= UMODE_UNAUTH;
3541 } | T_SPY
3542 {
3543 ConfigFileEntry.oper_only_umodes |= UMODE_SPY;
3544 } | T_EXTERNAL
3545 {
3546 ConfigFileEntry.oper_only_umodes |= UMODE_EXTERNAL;
3547 } | T_OPERWALL
3548 {
3549 ConfigFileEntry.oper_only_umodes |= UMODE_OPERWALL;
3550 } | T_SERVNOTICE
3551 {
3552 ConfigFileEntry.oper_only_umodes |= UMODE_SERVNOTICE;
3553 } | T_INVISIBLE
3554 {
3555 ConfigFileEntry.oper_only_umodes |= UMODE_INVISIBLE;
3556 } | T_WALLOP
3557 {
3558 ConfigFileEntry.oper_only_umodes |= UMODE_WALLOP;
3559 } | T_SOFTCALLERID
3560 {
3561 ConfigFileEntry.oper_only_umodes |= UMODE_SOFTCALLERID;
3562 } | T_CALLERID
3563 {
3564 ConfigFileEntry.oper_only_umodes |= UMODE_CALLERID;
3565 } | T_LOCOPS
3566 {
3567 ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
3568 };
3569
3570 general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
3571 {
3572 ConfigFileEntry.min_nonwildcard = $3;
3573 };
3574
3575 general_min_nonwildcard_simple: MIN_NONWILDCARD_SIMPLE '=' NUMBER ';'
3576 {
3577 ConfigFileEntry.min_nonwildcard_simple = $3;
3578 };
3579
3580 general_default_floodcount: DEFAULT_FLOODCOUNT '=' NUMBER ';'
3581 {
3582 ConfigFileEntry.default_floodcount = $3;
3583 };
3584
3585 general_client_flood: T_CLIENT_FLOOD '=' sizespec ';'
3586 {
3587 ConfigFileEntry.client_flood = $3;
3588 };
3589
3590 general_dot_in_ip6_addr: DOT_IN_IP6_ADDR '=' TBOOL ';'
3591 {
3592 ConfigFileEntry.dot_in_ip6_addr = yylval.number;
3593 };
3594
3595 /***************************************************************************
3596 * section glines
3597 ***************************************************************************/
3598 gline_entry: GLINES
3599 {
3600 if (ypass == 2)
3601 {
3602 yy_conf = make_conf_item(GDENY_TYPE);
3603 yy_aconf = map_to_conf(yy_conf);
3604 }
3605 } '{' gline_items '}' ';'
3606 {
3607 if (ypass == 2)
3608 {
3609 /*
3610 * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3611 * end we will have one extra, so we should free it.
3612 */
3613 if (yy_conf->name == NULL || yy_aconf->user == NULL)
3614 {
3615 delete_conf_item(yy_conf);
3616 yy_conf = NULL;
3617 yy_aconf = NULL;
3618 }
3619 }
3620 };
3621
3622 gline_items: gline_items gline_item | gline_item;
3623 gline_item: gline_enable |
3624 gline_duration |
3625 gline_logging |
3626 gline_user |
3627 gline_server |
3628 gline_action |
3629 error;
3630
3631 gline_enable: ENABLE '=' TBOOL ';'
3632 {
3633 if (ypass == 2)
3634 ConfigFileEntry.glines = yylval.number;
3635 };
3636
3637 gline_duration: DURATION '=' timespec ';'
3638 {
3639 if (ypass == 2)
3640 ConfigFileEntry.gline_time = $3;
3641 };
3642
3643 gline_logging: LOGGING
3644 {
3645 if (ypass == 2)
3646 ConfigFileEntry.gline_logging = 0;
3647 } '=' gline_logging_types ';';
3648 gline_logging_types: gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3649 gline_logging_type_item: T_REJECT
3650 {
3651 if (ypass == 2)
3652 ConfigFileEntry.gline_logging |= GDENY_REJECT;
3653 } | T_BLOCK
3654 {
3655 if (ypass == 2)
3656 ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3657 };
3658
3659 gline_user: USER '=' QSTRING ';'
3660 {
3661 if (ypass == 2)
3662 {
3663 struct CollectItem *yy_tmp = NULL;
3664
3665 if (yy_aconf->user == NULL)
3666 {
3667 split_nuh(yylval.string, NULL, &yy_aconf->user, &yy_aconf->host);
3668 }
3669 else
3670 {
3671 yy_tmp = MyMalloc(sizeof(struct CollectItem));
3672 split_nuh(yylval.string, NULL, &yy_tmp->user, &yy_tmp->host);
3673 dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3674 }
3675 }
3676 };
3677
3678 gline_server: NAME '=' QSTRING ';'
3679 {
3680 if (ypass == 2)
3681 {
3682 MyFree(yy_conf->name);
3683 DupString(yy_conf->name, yylval.string);
3684 }
3685 };
3686
3687 gline_action: ACTION
3688 {
3689 if (ypass == 2)
3690 yy_aconf->flags = 0;
3691 } '=' gdeny_types ';'
3692 {
3693 if (ypass == 2)
3694 {
3695 struct CollectItem *yy_tmp = NULL;
3696 dlink_node *ptr, *next_ptr;
3697
3698 DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3699 {
3700 struct AccessItem *new_aconf;
3701 struct ConfItem *new_conf;
3702
3703 yy_tmp = ptr->data;
3704 new_conf = make_conf_item(GDENY_TYPE);
3705 new_aconf = map_to_conf(new_conf);
3706
3707 new_aconf->flags = yy_aconf->flags;
3708
3709 if (yy_conf->name != NULL)
3710 DupString(new_conf->name, yy_conf->name);
3711 else
3712 DupString(new_conf->name, "*");
3713 if (yy_aconf->user != NULL)
3714 DupString(new_aconf->user, yy_tmp->user);
3715 else
3716 DupString(new_aconf->user, "*");
3717 if (yy_aconf->host != NULL)
3718 DupString(new_aconf->host, yy_tmp->host);
3719 else
3720 DupString(new_aconf->host, "*");
3721
3722 dlinkDelete(&yy_tmp->node, &col_conf_list);
3723 }
3724
3725 /*
3726 * In case someone has fed us with more than one action= after user/name
3727 * which would leak memory -Michael
3728 */
3729 if (yy_conf->name == NULL || yy_aconf->user == NULL)
3730 delete_conf_item(yy_conf);
3731
3732 yy_conf = make_conf_item(GDENY_TYPE);
3733 yy_aconf = map_to_conf(yy_conf);
3734 }
3735 };
3736
3737 gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3738 gdeny_type_item: T_REJECT
3739 {
3740 if (ypass == 2)
3741 yy_aconf->flags |= GDENY_REJECT;
3742 } | T_BLOCK
3743 {
3744 if (ypass == 2)
3745 yy_aconf->flags |= GDENY_BLOCK;
3746 };
3747
3748 /***************************************************************************
3749 * section channel
3750 ***************************************************************************/
3751 channel_entry: CHANNEL
3752 '{' channel_items '}' ';';
3753
3754 channel_items: channel_items channel_item | channel_item;
3755 channel_item: channel_disable_local_channels | channel_use_except |
3756 channel_use_invex | channel_use_knock |
3757 channel_max_bans | channel_knock_delay |
3758 channel_knock_delay_channel | channel_max_chans_per_user |
3759 channel_quiet_on_ban | channel_default_split_user_count |
3760 channel_default_split_server_count |
3761 channel_no_create_on_split | channel_restrict_channels |
3762 channel_no_join_on_split | channel_burst_topicwho |
3763 channel_jflood_count | channel_jflood_time |
3764 error;
3765
3766 channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
3767 {
3768 ConfigChannel.restrict_channels = yylval.number;
3769 };
3770
3771 channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
3772 {
3773 ConfigChannel.disable_local_channels = yylval.number;
3774 };
3775
3776 channel_use_except: USE_EXCEPT '=' TBOOL ';'
3777 {
3778 ConfigChannel.use_except = yylval.number;
3779 };
3780
3781 channel_use_invex: USE_INVEX '=' TBOOL ';'
3782 {
3783 ConfigChannel.use_invex = yylval.number;
3784 };
3785
3786 channel_use_knock: USE_KNOCK '=' TBOOL ';'
3787 {
3788 ConfigChannel.use_knock = yylval.number;
3789 };
3790
3791 channel_knock_delay: KNOCK_DELAY '=' timespec ';'
3792 {
3793 ConfigChannel.knock_delay = $3;
3794 };
3795
3796 channel_knock_delay_channel: KNOCK_DELAY_CHANNEL '=' timespec ';'
3797 {
3798 ConfigChannel.knock_delay_channel = $3;
3799 };
3800
3801 channel_max_chans_per_user: MAX_CHANS_PER_USER '=' NUMBER ';'
3802 {
3803 ConfigChannel.max_chans_per_user = $3;
3804 };
3805
3806 channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
3807 {
3808 ConfigChannel.quiet_on_ban = yylval.number;
3809 };
3810
3811 channel_max_bans: MAX_BANS '=' NUMBER ';'
3812 {
3813 ConfigChannel.max_bans = $3;
3814 };
3815
3816 channel_default_split_user_count: DEFAULT_SPLIT_USER_COUNT '=' NUMBER ';'
3817 {
3818 ConfigChannel.default_split_user_count = $3;
3819 };
3820
3821 channel_default_split_server_count: DEFAULT_SPLIT_SERVER_COUNT '=' NUMBER ';'
3822 {
3823 ConfigChannel.default_split_server_count = $3;
3824 };
3825
3826 channel_no_create_on_split: NO_CREATE_ON_SPLIT '=' TBOOL ';'
3827 {
3828 ConfigChannel.no_create_on_split = yylval.number;
3829 };
3830
3831 channel_no_join_on_split: NO_JOIN_ON_SPLIT '=' TBOOL ';'
3832 {
3833 ConfigChannel.no_join_on_split = yylval.number;
3834 };
3835
3836 channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3837 {
3838 ConfigChannel.burst_topicwho = yylval.number;
3839 };
3840
3841 channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
3842 {
3843 GlobalSetOptions.joinfloodcount = yylval.number;
3844 };
3845
3846 channel_jflood_time: JOIN_FLOOD_TIME '=' timespec ';'
3847 {
3848 GlobalSetOptions.joinfloodtime = yylval.number;
3849 };
3850
3851 /***************************************************************************
3852 * section serverhide
3853 ***************************************************************************/
3854 serverhide_entry: SERVERHIDE
3855 '{' serverhide_items '}' ';';
3856
3857 serverhide_items: serverhide_items serverhide_item | serverhide_item;
3858 serverhide_item: serverhide_flatten_links | serverhide_hide_servers |
3859 serverhide_links_delay |
3860 serverhide_disable_hidden |
3861 serverhide_hidden | serverhide_hidden_name |
3862 serverhide_hide_server_ips |
3863 error;
3864
3865 serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
3866 {
3867 if (ypass == 2)
3868 ConfigServerHide.flatten_links = yylval.number;
3869 };
3870
3871 serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
3872 {
3873 if (ypass == 2)
3874 ConfigServerHide.hide_servers = yylval.number;
3875 };
3876
3877 serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
3878 {
3879 if (ypass == 2)
3880 {
3881 MyFree(ConfigServerHide.hidden_name);
3882 DupString(ConfigServerHide.hidden_name, yylval.string);
3883 }
3884 };
3885
3886 serverhide_links_delay: LINKS_DELAY '=' timespec ';'
3887 {
3888 if (ypass == 2)
3889 {
3890 if (($3 > 0) && ConfigServerHide.links_disabled == 1)
3891 {
3892 eventAddIsh("write_links_file", write_links_file, NULL, $3);
3893 ConfigServerHide.links_disabled = 0;
3894 }
3895
3896 ConfigServerHide.links_delay = $3;
3897 }
3898 };
3899
3900 serverhide_hidden: HIDDEN '=' TBOOL ';'
3901 {
3902 if (ypass == 2)
3903 ConfigServerHide.hidden = yylval.number;
3904 };
3905
3906 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3907 {
3908 if (ypass == 2)
3909 ConfigServerHide.disable_hidden = yylval.number;
39