ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/conf_parser.y
Revision: 601
Committed: Sat May 13 16:59:28 2006 UTC (17 years, 10 months ago) by michael
Original Path: ircd-hybrid-7.2/src/ircd_parser.y
File size: 90205 byte(s)
Log Message:
- Removed dalloca.h

File Contents

# Content
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 "ircd.h"
32 #include "tools.h"
33 #include "list.h"
34 #include "s_conf.h"
35 #include "event.h"
36 #include "s_log.h"
37 #include "client.h" /* for UMODE_ALL only */
38 #include "pcre.h"
39 #include "irc_string.h"
40 #include "irc_getaddrinfo.h"
41 #include "sprintf_irc.h"
42 #include "memory.h"
43 #include "modules.h"
44 #include "s_serv.h" /* for CAP_LL / IsCapable */
45 #include "hostmask.h"
46 #include "send.h"
47 #include "listener.h"
48 #include "resv.h"
49 #include "numeric.h"
50 #include "s_user.h"
51
52 #ifdef HAVE_LIBCRYPTO
53 #include <openssl/rsa.h>
54 #include <openssl/bio.h>
55 #include <openssl/pem.h>
56 #endif
57
58 static char *class_name = NULL;
59 static struct ConfItem *yy_conf = NULL;
60 static struct AccessItem *yy_aconf = NULL;
61 static struct MatchItem *yy_match_item = NULL;
62 static struct ClassItem *yy_class = NULL;
63 static char *yy_class_name = NULL;
64
65 static dlink_list col_conf_list = { NULL, NULL, 0 };
66 static dlink_list hub_conf_list = { NULL, NULL, 0 };
67 static dlink_list leaf_conf_list = { NULL, NULL, 0 };
68 static unsigned int listener_flags = 0;
69 static unsigned int regex_ban = 0;
70 static char userbuf[IRCD_BUFSIZE];
71 static char hostbuf[IRCD_BUFSIZE];
72 static char reasonbuf[REASONLEN + 1];
73 static char gecos_name[REALLEN * 4];
74
75 extern dlink_list gdeny_items; /* XXX */
76
77 static char *resv_reason = NULL;
78 static char *listener_address = NULL;
79 static int not_atom = 0;
80
81 struct CollectItem
82 {
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 split_nuh_item nuh;
1081
1082 nuh.nuhmask = yylval.string;
1083 nuh.nickptr = NULL;
1084 nuh.userptr = userbuf;
1085 nuh.hostptr = hostbuf;
1086
1087 nuh.nicksize = 0;
1088 nuh.usersize = sizeof(userbuf);
1089 nuh.hostsize = sizeof(hostbuf);
1090
1091 split_nuh(&nuh);
1092
1093 if (yy_aconf->user == NULL)
1094 {
1095 DupString(yy_aconf->user, userbuf);
1096 DupString(yy_aconf->host, hostbuf);
1097 }
1098 else
1099 {
1100 struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1101
1102 DupString(yy_tmp->user, userbuf);
1103 DupString(yy_tmp->host, hostbuf);
1104
1105 dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1106 }
1107 }
1108 };
1109
1110 oper_password: PASSWORD '=' QSTRING ';'
1111 {
1112 if (ypass == 2)
1113 {
1114 if (yy_aconf->passwd != NULL)
1115 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1116
1117 MyFree(yy_aconf->passwd);
1118 DupString(yy_aconf->passwd, yylval.string);
1119 }
1120 };
1121
1122 oper_encrypted: ENCRYPTED '=' TBOOL ';'
1123 {
1124 if (ypass == 2)
1125 {
1126 if (yylval.number)
1127 SetConfEncrypted(yy_aconf);
1128 else
1129 ClearConfEncrypted(yy_aconf);
1130 }
1131 };
1132
1133 oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1134 {
1135 #ifdef HAVE_LIBCRYPTO
1136 if (ypass == 2)
1137 {
1138 BIO *file;
1139
1140 if (yy_aconf->rsa_public_key != NULL)
1141 {
1142 RSA_free(yy_aconf->rsa_public_key);
1143 yy_aconf->rsa_public_key = NULL;
1144 }
1145
1146 if (yy_aconf->rsa_public_key_file != NULL)
1147 {
1148 MyFree(yy_aconf->rsa_public_key_file);
1149 yy_aconf->rsa_public_key_file = NULL;
1150 }
1151
1152 DupString(yy_aconf->rsa_public_key_file, yylval.string);
1153 file = BIO_new_file(yylval.string, "r");
1154
1155 if (file == NULL)
1156 {
1157 yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1158 break;
1159 }
1160
1161 yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1162
1163 if (yy_aconf->rsa_public_key == NULL)
1164 {
1165 yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1166 break;
1167 }
1168
1169 BIO_set_close(file, BIO_CLOSE);
1170 BIO_free(file);
1171 }
1172 #endif /* HAVE_LIBCRYPTO */
1173 };
1174
1175 oper_class: CLASS '=' QSTRING ';'
1176 {
1177 if (ypass == 2)
1178 {
1179 MyFree(class_name);
1180 DupString(class_name, yylval.string);
1181 }
1182 };
1183
1184 oper_umodes: T_UMODES
1185 {
1186 if (ypass == 2)
1187 yy_aconf->modes = 0;
1188 } '=' oper_umodes_items ';' ;
1189
1190 oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1191 oper_umodes_item: T_BOTS
1192 {
1193 if (ypass == 2)
1194 yy_aconf->modes |= UMODE_BOTS;
1195 } | T_CCONN
1196 {
1197 if (ypass == 2)
1198 yy_aconf->modes |= UMODE_CCONN;
1199 } | T_DEAF
1200 {
1201 if (ypass == 2)
1202 yy_aconf->modes |= UMODE_DEAF;
1203 } | T_DEBUG
1204 {
1205 if (ypass == 2)
1206 yy_aconf->modes |= UMODE_DEBUG;
1207 } | T_FULL
1208 {
1209 if (ypass == 2)
1210 yy_aconf->modes |= UMODE_FULL;
1211 } | T_SKILL
1212 {
1213 if (ypass == 2)
1214 yy_aconf->modes |= UMODE_SKILL;
1215 } | T_NCHANGE
1216 {
1217 if (ypass == 2)
1218 yy_aconf->modes |= UMODE_NCHANGE;
1219 } | T_REJ
1220 {
1221 if (ypass == 2)
1222 yy_aconf->modes |= UMODE_REJ;
1223 } | T_UNAUTH
1224 {
1225 if (ypass == 2)
1226 yy_aconf->modes |= UMODE_UNAUTH;
1227 } | T_SPY
1228 {
1229 if (ypass == 2)
1230 yy_aconf->modes |= UMODE_SPY;
1231 } | T_EXTERNAL
1232 {
1233 if (ypass == 2)
1234 yy_aconf->modes |= UMODE_EXTERNAL;
1235 } | T_OPERWALL
1236 {
1237 if (ypass == 2)
1238 yy_aconf->modes |= UMODE_OPERWALL;
1239 } | T_SERVNOTICE
1240 {
1241 if (ypass == 2)
1242 yy_aconf->modes |= UMODE_SERVNOTICE;
1243 } | T_INVISIBLE
1244 {
1245 if (ypass == 2)
1246 yy_aconf->modes |= UMODE_INVISIBLE;
1247 } | T_WALLOP
1248 {
1249 if (ypass == 2)
1250 yy_aconf->modes |= UMODE_WALLOP;
1251 } | T_SOFTCALLERID
1252 {
1253 if (ypass == 2)
1254 yy_aconf->modes |= UMODE_SOFTCALLERID;
1255 } | T_CALLERID
1256 {
1257 if (ypass == 2)
1258 yy_aconf->modes |= UMODE_CALLERID;
1259 } | T_LOCOPS
1260 {
1261 if (ypass == 2)
1262 yy_aconf->modes |= UMODE_LOCOPS;
1263 };
1264
1265 oper_global_kill: GLOBAL_KILL '=' TBOOL ';'
1266 {
1267 if (ypass == 2)
1268 {
1269 if (yylval.number)
1270 yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1271 else
1272 yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1273 }
1274 };
1275
1276 oper_remote: REMOTE '=' TBOOL ';'
1277 {
1278 if (ypass == 2)
1279 {
1280 if (yylval.number)
1281 yy_aconf->port |= OPER_FLAG_REMOTE;
1282 else
1283 yy_aconf->port &= ~OPER_FLAG_REMOTE;
1284 }
1285 };
1286
1287 oper_remoteban: REMOTEBAN '=' TBOOL ';'
1288 {
1289 if (ypass == 2)
1290 {
1291 if (yylval.number)
1292 yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1293 else
1294 yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1295 }
1296 };
1297
1298 oper_kline: KLINE '=' TBOOL ';'
1299 {
1300 if (ypass == 2)
1301 {
1302 if (yylval.number)
1303 yy_aconf->port |= OPER_FLAG_K;
1304 else
1305 yy_aconf->port &= ~OPER_FLAG_K;
1306 }
1307 };
1308
1309 oper_xline: XLINE '=' TBOOL ';'
1310 {
1311 if (ypass == 2)
1312 {
1313 if (yylval.number)
1314 yy_aconf->port |= OPER_FLAG_X;
1315 else
1316 yy_aconf->port &= ~OPER_FLAG_X;
1317 }
1318 };
1319
1320 oper_unkline: UNKLINE '=' TBOOL ';'
1321 {
1322 if (ypass == 2)
1323 {
1324 if (yylval.number)
1325 yy_aconf->port |= OPER_FLAG_UNKLINE;
1326 else
1327 yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1328 }
1329 };
1330
1331 oper_gline: GLINE '=' TBOOL ';'
1332 {
1333 if (ypass == 2)
1334 {
1335 if (yylval.number)
1336 yy_aconf->port |= OPER_FLAG_GLINE;
1337 else
1338 yy_aconf->port &= ~OPER_FLAG_GLINE;
1339 }
1340 };
1341
1342 oper_nick_changes: NICK_CHANGES '=' TBOOL ';'
1343 {
1344 if (ypass == 2)
1345 {
1346 if (yylval.number)
1347 yy_aconf->port |= OPER_FLAG_N;
1348 else
1349 yy_aconf->port &= ~OPER_FLAG_N;
1350 }
1351 };
1352
1353 oper_die: DIE '=' TBOOL ';'
1354 {
1355 if (ypass == 2)
1356 {
1357 if (yylval.number)
1358 yy_aconf->port |= OPER_FLAG_DIE;
1359 else
1360 yy_aconf->port &= ~OPER_FLAG_DIE;
1361 }
1362 };
1363
1364 oper_rehash: REHASH '=' TBOOL ';'
1365 {
1366 if (ypass == 2)
1367 {
1368 if (yylval.number)
1369 yy_aconf->port |= OPER_FLAG_REHASH;
1370 else
1371 yy_aconf->port &= ~OPER_FLAG_REHASH;
1372 }
1373 };
1374
1375 oper_admin: ADMIN '=' TBOOL ';'
1376 {
1377 if (ypass == 2)
1378 {
1379 if (yylval.number)
1380 yy_aconf->port |= OPER_FLAG_ADMIN;
1381 else
1382 yy_aconf->port &= ~OPER_FLAG_ADMIN;
1383 }
1384 };
1385
1386 oper_hidden_admin: HIDDEN_ADMIN '=' TBOOL ';'
1387 {
1388 if (ypass == 2)
1389 {
1390 if (yylval.number)
1391 yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1392 else
1393 yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1394 }
1395 };
1396
1397 oper_hidden_oper: HIDDEN_OPER '=' TBOOL ';'
1398 {
1399 if (ypass == 2)
1400 {
1401 if (yylval.number)
1402 yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1403 else
1404 yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1405 }
1406 };
1407
1408 oper_operwall: T_OPERWALL '=' TBOOL ';'
1409 {
1410 if (ypass == 2)
1411 {
1412 if (yylval.number)
1413 yy_aconf->port |= OPER_FLAG_OPERWALL;
1414 else
1415 yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1416 }
1417 };
1418
1419 oper_flags: IRCD_FLAGS
1420 {
1421 } '=' oper_flags_items ';';
1422
1423 oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1424 oper_flags_item: NOT { not_atom = 1; } oper_flags_item_atom
1425 | { not_atom = 0; } oper_flags_item_atom;
1426
1427 oper_flags_item_atom: GLOBAL_KILL
1428 {
1429 if (ypass == 2)
1430 {
1431 if (not_atom)yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1432 else yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1433 }
1434 } | REMOTE
1435 {
1436 if (ypass == 2)
1437 {
1438 if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTE;
1439 else yy_aconf->port |= OPER_FLAG_REMOTE;
1440 }
1441 } | KLINE
1442 {
1443 if (ypass == 2)
1444 {
1445 if (not_atom) yy_aconf->port &= ~OPER_FLAG_K;
1446 else yy_aconf->port |= OPER_FLAG_K;
1447 }
1448 } | UNKLINE
1449 {
1450 if (ypass == 2)
1451 {
1452 if (not_atom) yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1453 else yy_aconf->port |= OPER_FLAG_UNKLINE;
1454 }
1455 } | XLINE
1456 {
1457 if (ypass == 2)
1458 {
1459 if (not_atom) yy_aconf->port &= ~OPER_FLAG_X;
1460 else yy_aconf->port |= OPER_FLAG_X;
1461 }
1462 } | GLINE
1463 {
1464 if (ypass == 2)
1465 {
1466 if (not_atom) yy_aconf->port &= ~OPER_FLAG_GLINE;
1467 else yy_aconf->port |= OPER_FLAG_GLINE;
1468 }
1469 } | DIE
1470 {
1471 if (ypass == 2)
1472 {
1473 if (not_atom) yy_aconf->port &= ~OPER_FLAG_DIE;
1474 else yy_aconf->port |= OPER_FLAG_DIE;
1475 }
1476 } | REHASH
1477 {
1478 if (ypass == 2)
1479 {
1480 if (not_atom) yy_aconf->port &= ~OPER_FLAG_REHASH;
1481 else yy_aconf->port |= OPER_FLAG_REHASH;
1482 }
1483 } | ADMIN
1484 {
1485 if (ypass == 2)
1486 {
1487 if (not_atom) yy_aconf->port &= ~OPER_FLAG_ADMIN;
1488 else yy_aconf->port |= OPER_FLAG_ADMIN;
1489 }
1490 } | HIDDEN_ADMIN
1491 {
1492 if (ypass == 2)
1493 {
1494 if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1495 else yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1496 }
1497 } | NICK_CHANGES
1498 {
1499 if (ypass == 2)
1500 {
1501 if (not_atom) yy_aconf->port &= ~OPER_FLAG_N;
1502 else yy_aconf->port |= OPER_FLAG_N;
1503 }
1504 } | T_OPERWALL
1505 {
1506 if (ypass == 2)
1507 {
1508 if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1509 else yy_aconf->port |= OPER_FLAG_OPERWALL;
1510 }
1511 } | OPER_SPY_T
1512 {
1513 if (ypass == 2)
1514 {
1515 if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPER_SPY;
1516 else yy_aconf->port |= OPER_FLAG_OPER_SPY;
1517 }
1518 } | HIDDEN_OPER
1519 {
1520 if (ypass == 2)
1521 {
1522 if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1523 else yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1524 }
1525 } | REMOTEBAN
1526 {
1527 if (ypass == 2)
1528 {
1529 if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1530 else yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1531 }
1532 } | ENCRYPTED
1533 {
1534 if (ypass == 2)
1535 {
1536 if (not_atom) ClearConfEncrypted(yy_aconf);
1537 else SetConfEncrypted(yy_aconf);
1538 }
1539 };
1540
1541
1542 /***************************************************************************
1543 * section class
1544 ***************************************************************************/
1545 class_entry: CLASS
1546 {
1547 if (ypass == 1)
1548 {
1549 yy_conf = make_conf_item(CLASS_TYPE);
1550 yy_class = (struct ClassItem *)map_to_conf(yy_conf);
1551 }
1552 } class_name_b '{' class_items '}' ';'
1553 {
1554 if (ypass == 1)
1555 {
1556 struct ConfItem *cconf;
1557 struct ClassItem *class = NULL;
1558
1559 if (yy_class_name == NULL)
1560 {
1561 delete_conf_item(yy_conf);
1562 }
1563 else
1564 {
1565 cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1566
1567 if (cconf != NULL) /* The class existed already */
1568 {
1569 rebuild_cidr_class(cconf, yy_class);
1570 class = (struct ClassItem *) map_to_conf(cconf);
1571 *class = *yy_class;
1572 delete_conf_item(yy_conf);
1573
1574 MyFree(cconf->name); /* Allows case change of class name */
1575 cconf->name = yy_class_name;
1576 }
1577 else /* Brand new class */
1578 {
1579 MyFree(yy_conf->name); /* just in case it was allocated */
1580 yy_conf->name = yy_class_name;
1581 }
1582 }
1583 yy_class_name = NULL;
1584 }
1585 };
1586
1587 class_name_b: | class_name_t;
1588
1589 class_items: class_items class_item | class_item;
1590 class_item: class_name |
1591 class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1592 class_ping_time |
1593 class_ping_warning |
1594 class_number_per_cidr |
1595 class_number_per_ip |
1596 class_connectfreq |
1597 class_max_number |
1598 class_max_global |
1599 class_max_local |
1600 class_max_ident |
1601 class_sendq |
1602 error ';' ;
1603
1604 class_name: NAME '=' QSTRING ';'
1605 {
1606 if (ypass == 1)
1607 {
1608 MyFree(yy_class_name);
1609 DupString(yy_class_name, yylval.string);
1610 }
1611 };
1612
1613 class_name_t: QSTRING
1614 {
1615 if (ypass == 1)
1616 {
1617 MyFree(yy_class_name);
1618 DupString(yy_class_name, yylval.string);
1619 }
1620 };
1621
1622 class_ping_time: PING_TIME '=' timespec ';'
1623 {
1624 if (ypass == 1)
1625 PingFreq(yy_class) = $3;
1626 };
1627
1628 class_ping_warning: PING_WARNING '=' timespec ';'
1629 {
1630 if (ypass == 1)
1631 PingWarning(yy_class) = $3;
1632 };
1633
1634 class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1635 {
1636 if (ypass == 1)
1637 MaxPerIp(yy_class) = $3;
1638 };
1639
1640 class_connectfreq: CONNECTFREQ '=' timespec ';'
1641 {
1642 if (ypass == 1)
1643 ConFreq(yy_class) = $3;
1644 };
1645
1646 class_max_number: MAX_NUMBER '=' NUMBER ';'
1647 {
1648 if (ypass == 1)
1649 MaxTotal(yy_class) = $3;
1650 };
1651
1652 class_max_global: MAX_GLOBAL '=' NUMBER ';'
1653 {
1654 if (ypass == 1)
1655 MaxGlobal(yy_class) = $3;
1656 };
1657
1658 class_max_local: MAX_LOCAL '=' NUMBER ';'
1659 {
1660 if (ypass == 1)
1661 MaxLocal(yy_class) = $3;
1662 };
1663
1664 class_max_ident: MAX_IDENT '=' NUMBER ';'
1665 {
1666 if (ypass == 1)
1667 MaxIdent(yy_class) = $3;
1668 };
1669
1670 class_sendq: SENDQ '=' sizespec ';'
1671 {
1672 if (ypass == 1)
1673 MaxSendq(yy_class) = $3;
1674 };
1675
1676 class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1677 {
1678 if (ypass == 1)
1679 CidrBitlenIPV4(yy_class) = $3;
1680 };
1681
1682 class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1683 {
1684 if (ypass == 1)
1685 CidrBitlenIPV6(yy_class) = $3;
1686 };
1687
1688 class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1689 {
1690 if (ypass == 1)
1691 NumberPerCidr(yy_class) = $3;
1692 };
1693
1694 /***************************************************************************
1695 * section listen
1696 ***************************************************************************/
1697 listen_entry: LISTEN
1698 {
1699 if (ypass == 2)
1700 {
1701 listener_address = NULL;
1702 listener_flags = 0;
1703 }
1704 } '{' listen_items '}' ';'
1705 {
1706 if (ypass == 2)
1707 {
1708 MyFree(listener_address);
1709 listener_address = NULL;
1710 }
1711 };
1712
1713 listen_flags: IRCD_FLAGS
1714 {
1715 listener_flags = 0;
1716 } '=' listen_flags_items ';';
1717
1718 listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1719 listen_flags_item: T_SSL
1720 {
1721 if (ypass == 2)
1722 listener_flags |= LISTENER_SSL;
1723 } | HIDDEN
1724 {
1725 if (ypass == 2)
1726 listener_flags |= LISTENER_HIDDEN;
1727 };
1728
1729 listen_items: listen_items listen_item | listen_item;
1730 listen_item: listen_port | listen_flags | listen_address | listen_host | error ';';
1731
1732 listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1733
1734 port_items: port_items ',' port_item | port_item;
1735
1736 port_item: NUMBER
1737 {
1738 if (ypass == 2)
1739 {
1740 if ((listener_flags & LISTENER_SSL))
1741 #ifdef HAVE_LIBCRYPTO
1742 if (!ServerInfo.ctx)
1743 #endif
1744 {
1745 yyerror("SSL not available - port closed");
1746 break;
1747 }
1748 add_listener($1, listener_address, listener_flags);
1749 }
1750 } | NUMBER TWODOTS NUMBER
1751 {
1752 if (ypass == 2)
1753 {
1754 int i;
1755
1756 if ((listener_flags & LISTENER_SSL))
1757 #ifdef HAVE_LIBCRYPTO
1758 if (!ServerInfo.ctx)
1759 #endif
1760 {
1761 yyerror("SSL not available - port closed");
1762 break;
1763 }
1764
1765 for (i = $1; i <= $3; ++i)
1766 add_listener(i, listener_address, listener_flags);
1767 }
1768 };
1769
1770 listen_address: IP '=' QSTRING ';'
1771 {
1772 if (ypass == 2)
1773 {
1774 MyFree(listener_address);
1775 DupString(listener_address, yylval.string);
1776 }
1777 };
1778
1779 listen_host: HOST '=' QSTRING ';'
1780 {
1781 if (ypass == 2)
1782 {
1783 MyFree(listener_address);
1784 DupString(listener_address, yylval.string);
1785 }
1786 };
1787
1788 /***************************************************************************
1789 * section auth
1790 ***************************************************************************/
1791 auth_entry: IRCD_AUTH
1792 {
1793 if (ypass == 2)
1794 {
1795 yy_conf = make_conf_item(CLIENT_TYPE);
1796 yy_aconf = map_to_conf(yy_conf);
1797 }
1798 else
1799 {
1800 MyFree(class_name);
1801 class_name = NULL;
1802 }
1803 } '{' auth_items '}' ';'
1804 {
1805 if (ypass == 2)
1806 {
1807 struct CollectItem *yy_tmp = NULL;
1808 dlink_node *ptr = NULL, *next_ptr = NULL;
1809
1810 if (yy_aconf->user && yy_aconf->host)
1811 {
1812 conf_add_class_to_conf(yy_conf, class_name);
1813 add_conf_by_address(CONF_CLIENT, yy_aconf);
1814 }
1815 else
1816 delete_conf_item(yy_conf);
1817
1818 /* copy over settings from first struct */
1819 DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1820 {
1821 struct AccessItem *new_aconf;
1822 struct ConfItem *new_conf;
1823
1824 new_conf = make_conf_item(CLIENT_TYPE);
1825 new_aconf = map_to_conf(new_conf);
1826
1827 yy_tmp = ptr->data;
1828
1829 assert(yy_tmp->user && yy_tmp->host);
1830
1831 if (yy_aconf->passwd != NULL)
1832 DupString(new_aconf->passwd, yy_aconf->passwd);
1833 if (yy_conf->name != NULL)
1834 DupString(new_conf->name, yy_conf->name);
1835 if (yy_aconf->passwd != NULL)
1836 DupString(new_aconf->passwd, yy_aconf->passwd);
1837
1838 new_aconf->flags = yy_aconf->flags;
1839 new_aconf->port = yy_aconf->port;
1840
1841 DupString(new_aconf->user, yy_tmp->user);
1842 collapse(new_aconf->user);
1843
1844 DupString(new_aconf->host, yy_tmp->host);
1845 collapse(new_aconf->host);
1846
1847 conf_add_class_to_conf(new_conf, class_name);
1848 add_conf_by_address(CONF_CLIENT, new_aconf);
1849 dlinkDelete(&yy_tmp->node, &col_conf_list);
1850 free_collect_item(yy_tmp);
1851 }
1852
1853 MyFree(class_name);
1854 class_name = NULL;
1855 yy_conf = NULL;
1856 yy_aconf = NULL;
1857 }
1858 };
1859
1860 auth_items: auth_items auth_item | auth_item;
1861 auth_item: auth_user | auth_passwd | auth_class | auth_flags |
1862 auth_kline_exempt | auth_need_ident |
1863 auth_exceed_limit | auth_no_tilde | auth_gline_exempt |
1864 auth_spoof | auth_spoof_notice |
1865 auth_redir_serv | auth_redir_port | auth_can_flood |
1866 auth_need_password | auth_encrypted | error ';' ;
1867
1868 auth_user: USER '=' QSTRING ';'
1869 {
1870 if (ypass == 2)
1871 {
1872 struct CollectItem *yy_tmp = NULL;
1873 struct split_nuh_item nuh;
1874
1875 nuh.nuhmask = yylval.string;
1876 nuh.nickptr = NULL;
1877 nuh.userptr = userbuf;
1878 nuh.hostptr = hostbuf;
1879
1880 nuh.nicksize = 0;
1881 nuh.usersize = sizeof(userbuf);
1882 nuh.hostsize = sizeof(hostbuf);
1883
1884 split_nuh(&nuh);
1885
1886 if (yy_aconf->user == NULL)
1887 {
1888 DupString(yy_aconf->user, userbuf);
1889 DupString(yy_aconf->host, hostbuf);
1890 }
1891 else
1892 {
1893 yy_tmp = MyMalloc(sizeof(struct CollectItem));
1894
1895 DupString(yy_tmp->user, userbuf);
1896 DupString(yy_tmp->host, hostbuf);
1897
1898 dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1899 }
1900 }
1901 };
1902
1903 /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1904
1905 auth_passwd: PASSWORD '=' QSTRING ';'
1906 {
1907 if (ypass == 2)
1908 {
1909 /* be paranoid */
1910 if (yy_aconf->passwd != NULL)
1911 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1912
1913 MyFree(yy_aconf->passwd);
1914 DupString(yy_aconf->passwd, yylval.string);
1915 }
1916 };
1917
1918 auth_spoof_notice: SPOOF_NOTICE '=' TBOOL ';'
1919 {
1920 if (ypass == 2)
1921 {
1922 if (yylval.number)
1923 yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1924 else
1925 yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1926 }
1927 };
1928
1929 auth_class: CLASS '=' QSTRING ';'
1930 {
1931 if (ypass == 2)
1932 {
1933 MyFree(class_name);
1934 DupString(class_name, yylval.string);
1935 }
1936 };
1937
1938 auth_encrypted: ENCRYPTED '=' TBOOL ';'
1939 {
1940 if (ypass == 2)
1941 {
1942 if (yylval.number)
1943 SetConfEncrypted(yy_aconf);
1944 else
1945 ClearConfEncrypted(yy_aconf);
1946 }
1947 };
1948
1949 auth_flags: IRCD_FLAGS
1950 {
1951 } '=' auth_flags_items ';';
1952
1953 auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1954 auth_flags_item: NOT { not_atom = 1; } auth_flags_item_atom
1955 | { not_atom = 0; } auth_flags_item_atom;
1956
1957 auth_flags_item_atom: SPOOF_NOTICE
1958 {
1959 if (ypass == 2)
1960 {
1961 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1962 else yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1963 }
1964
1965 } | EXCEED_LIMIT
1966 {
1967 if (ypass == 2)
1968 {
1969 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
1970 else yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1971 }
1972 } | KLINE_EXEMPT
1973 {
1974 if (ypass == 2)
1975 {
1976 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
1977 else yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1978 }
1979 } | NEED_IDENT
1980 {
1981 if (ypass == 2)
1982 {
1983 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
1984 else yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1985 }
1986 } | CAN_FLOOD
1987 {
1988 if (ypass == 2)
1989 {
1990 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
1991 else yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1992 }
1993 } | CAN_IDLE
1994 {
1995 if (ypass == 2)
1996 {
1997 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_IDLE_LINED;
1998 else yy_aconf->flags |= CONF_FLAGS_IDLE_LINED;
1999 }
2000 } | NO_TILDE
2001 {
2002 if (ypass == 2)
2003 {
2004 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
2005 else yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
2006 }
2007 } | GLINE_EXEMPT
2008 {
2009 if (ypass == 2)
2010 {
2011 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2012 else yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2013 }
2014 } | RESV_EXEMPT
2015 {
2016 if (ypass == 2)
2017 {
2018 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTRESV;
2019 else yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
2020 }
2021 } | NEED_PASSWORD
2022 {
2023 if (ypass == 2)
2024 {
2025 if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2026 else yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2027 }
2028 };
2029
2030 auth_kline_exempt: KLINE_EXEMPT '=' TBOOL ';'
2031 {
2032 if (ypass == 2)
2033 {
2034 if (yylval.number)
2035 yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
2036 else
2037 yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
2038 }
2039 };
2040
2041 auth_need_ident: NEED_IDENT '=' TBOOL ';'
2042 {
2043 if (ypass == 2)
2044 {
2045 if (yylval.number)
2046 yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
2047 else
2048 yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
2049 }
2050 };
2051
2052 auth_exceed_limit: EXCEED_LIMIT '=' TBOOL ';'
2053 {
2054 if (ypass == 2)
2055 {
2056 if (yylval.number)
2057 yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
2058 else
2059 yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
2060 }
2061 };
2062
2063 auth_can_flood: CAN_FLOOD '=' TBOOL ';'
2064 {
2065 if (ypass == 2)
2066 {
2067 if (yylval.number)
2068 yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
2069 else
2070 yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
2071 }
2072 };
2073
2074 auth_no_tilde: NO_TILDE '=' TBOOL ';'
2075 {
2076 if (ypass == 2)
2077 {
2078 if (yylval.number)
2079 yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
2080 else
2081 yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
2082 }
2083 };
2084
2085 auth_gline_exempt: GLINE_EXEMPT '=' TBOOL ';'
2086 {
2087 if (ypass == 2)
2088 {
2089 if (yylval.number)
2090 yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2091 else
2092 yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2093 }
2094 };
2095
2096 /* XXX - need check for illegal hostnames here */
2097 auth_spoof: SPOOF '=' QSTRING ';'
2098 {
2099 if (ypass == 2)
2100 {
2101 MyFree(yy_conf->name);
2102
2103 if (strlen(yylval.string) < HOSTLEN)
2104 {
2105 DupString(yy_conf->name, yylval.string);
2106 yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
2107 }
2108 else
2109 {
2110 ilog(L_ERROR, "Spoofs must be less than %d..ignoring it", HOSTLEN);
2111 yy_conf->name = NULL;
2112 }
2113 }
2114 };
2115
2116 auth_redir_serv: REDIRSERV '=' QSTRING ';'
2117 {
2118 if (ypass == 2)
2119 {
2120 yy_aconf->flags |= CONF_FLAGS_REDIR;
2121 MyFree(yy_conf->name);
2122 DupString(yy_conf->name, yylval.string);
2123 }
2124 };
2125
2126 auth_redir_port: REDIRPORT '=' NUMBER ';'
2127 {
2128 if (ypass == 2)
2129 {
2130 yy_aconf->flags |= CONF_FLAGS_REDIR;
2131 yy_aconf->port = $3;
2132 }
2133 };
2134
2135 auth_need_password: NEED_PASSWORD '=' TBOOL ';'
2136 {
2137 if (ypass == 2)
2138 {
2139 if (yylval.number)
2140 yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2141 else
2142 yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2143 }
2144 };
2145
2146
2147 /***************************************************************************
2148 * section resv
2149 ***************************************************************************/
2150 resv_entry: RESV
2151 {
2152 if (ypass == 2)
2153 {
2154 MyFree(resv_reason);
2155 resv_reason = NULL;
2156 }
2157 } '{' resv_items '}' ';'
2158 {
2159 if (ypass == 2)
2160 {
2161 MyFree(resv_reason);
2162 resv_reason = NULL;
2163 }
2164 };
2165
2166 resv_items: resv_items resv_item | resv_item;
2167 resv_item: resv_creason | resv_channel | resv_nick | error ';' ;
2168
2169 resv_creason: REASON '=' QSTRING ';'
2170 {
2171 if (ypass == 2)
2172 {
2173 MyFree(resv_reason);
2174 DupString(resv_reason, yylval.string);
2175 }
2176 };
2177
2178 resv_channel: CHANNEL '=' QSTRING ';'
2179 {
2180 if (ypass == 2)
2181 {
2182 if (IsChanPrefix(*yylval.string))
2183 {
2184 char def_reason[] = "No reason";
2185
2186 create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
2187 }
2188 }
2189 /* ignore it for now.. but we really should make a warning if
2190 * its an erroneous name --fl_ */
2191 };
2192
2193 resv_nick: NICK '=' QSTRING ';'
2194 {
2195 if (ypass == 2)
2196 {
2197 char def_reason[] = "No reason";
2198
2199 create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
2200 }
2201 };
2202
2203 /***************************************************************************
2204 * section shared, for sharing remote klines etc.
2205 ***************************************************************************/
2206 shared_entry: T_SHARED
2207 {
2208 if (ypass == 2)
2209 {
2210 yy_conf = make_conf_item(ULINE_TYPE);
2211 yy_match_item = map_to_conf(yy_conf);
2212 yy_match_item->action = SHARED_ALL;
2213 }
2214 } '{' shared_items '}' ';'
2215 {
2216 if (ypass == 2)
2217 {
2218 yy_conf = NULL;
2219 }
2220 };
2221
2222 shared_items: shared_items shared_item | shared_item;
2223 shared_item: shared_name | shared_user | shared_type | error ';' ;
2224
2225 shared_name: NAME '=' QSTRING ';'
2226 {
2227 if (ypass == 2)
2228 {
2229 MyFree(yy_conf->name);
2230 DupString(yy_conf->name, yylval.string);
2231 }
2232 };
2233
2234 shared_user: USER '=' QSTRING ';'
2235 {
2236 if (ypass == 2)
2237 {
2238 struct split_nuh_item nuh;
2239
2240 nuh.nuhmask = yylval.string;
2241 nuh.nickptr = NULL;
2242 nuh.userptr = userbuf;
2243 nuh.hostptr = hostbuf;
2244
2245 nuh.nicksize = 0;
2246 nuh.usersize = sizeof(userbuf);
2247 nuh.hostsize = sizeof(hostbuf);
2248
2249 split_nuh(&nuh);
2250
2251 DupString(yy_match_item->user, userbuf);
2252 DupString(yy_match_item->host, hostbuf);
2253 }
2254 };
2255
2256 shared_type: TYPE
2257 {
2258 if (ypass == 2)
2259 yy_match_item->action = 0;
2260 } '=' shared_types ';' ;
2261
2262 shared_types: shared_types ',' shared_type_item | shared_type_item;
2263 shared_type_item: KLINE
2264 {
2265 if (ypass == 2)
2266 yy_match_item->action |= SHARED_KLINE;
2267 } | TKLINE
2268 {
2269 if (ypass == 2)
2270 yy_match_item->action |= SHARED_TKLINE;
2271 } | UNKLINE
2272 {
2273 if (ypass == 2)
2274 yy_match_item->action |= SHARED_UNKLINE;
2275 } | XLINE
2276 {
2277 if (ypass == 2)
2278 yy_match_item->action |= SHARED_XLINE;
2279 } | TXLINE
2280 {
2281 if (ypass == 2)
2282 yy_match_item->action |= SHARED_TXLINE;
2283 } | T_UNXLINE
2284 {
2285 if (ypass == 2)
2286 yy_match_item->action |= SHARED_UNXLINE;
2287 } | RESV
2288 {
2289 if (ypass == 2)
2290 yy_match_item->action |= SHARED_RESV;
2291 } | TRESV
2292 {
2293 if (ypass == 2)
2294 yy_match_item->action |= SHARED_TRESV;
2295 } | T_UNRESV
2296 {
2297 if (ypass == 2)
2298 yy_match_item->action |= SHARED_UNRESV;
2299 } | T_LOCOPS
2300 {
2301 if (ypass == 2)
2302 yy_match_item->action |= SHARED_LOCOPS;
2303 } | T_ALL
2304 {
2305 if (ypass == 2)
2306 yy_match_item->action = SHARED_ALL;
2307 };
2308
2309 /***************************************************************************
2310 * section cluster
2311 ***************************************************************************/
2312 cluster_entry: T_CLUSTER
2313 {
2314 if (ypass == 2)
2315 {
2316 yy_conf = make_conf_item(CLUSTER_TYPE);
2317 yy_conf->flags = SHARED_ALL;
2318 }
2319 } '{' cluster_items '}' ';'
2320 {
2321 if (ypass == 2)
2322 {
2323 if (yy_conf->name == NULL)
2324 DupString(yy_conf->name, "*");
2325 yy_conf = NULL;
2326 }
2327 };
2328
2329 cluster_items: cluster_items cluster_item | cluster_item;
2330 cluster_item: cluster_name | cluster_type | error ';' ;
2331
2332 cluster_name: NAME '=' QSTRING ';'
2333 {
2334 if (ypass == 2)
2335 DupString(yy_conf->name, yylval.string);
2336 };
2337
2338 cluster_type: TYPE
2339 {
2340 if (ypass == 2)
2341 yy_conf->flags = 0;
2342 } '=' cluster_types ';' ;
2343
2344 cluster_types: cluster_types ',' cluster_type_item | cluster_type_item;
2345 cluster_type_item: KLINE
2346 {
2347 if (ypass == 2)
2348 yy_conf->flags |= SHARED_KLINE;
2349 } | TKLINE
2350 {
2351 if (ypass == 2)
2352 yy_conf->flags |= SHARED_TKLINE;
2353 } | UNKLINE
2354 {
2355 if (ypass == 2)
2356 yy_conf->flags |= SHARED_UNKLINE;
2357 } | XLINE
2358 {
2359 if (ypass == 2)
2360 yy_conf->flags |= SHARED_XLINE;
2361 } | TXLINE
2362 {
2363 if (ypass == 2)
2364 yy_conf->flags |= SHARED_TXLINE;
2365 } | T_UNXLINE
2366 {
2367 if (ypass == 2)
2368 yy_conf->flags |= SHARED_UNXLINE;
2369 } | RESV
2370 {
2371 if (ypass == 2)
2372 yy_conf->flags |= SHARED_RESV;
2373 } | TRESV
2374 {
2375 if (ypass == 2)
2376 yy_conf->flags |= SHARED_TRESV;
2377 } | T_UNRESV
2378 {
2379 if (ypass == 2)
2380 yy_conf->flags |= SHARED_UNRESV;
2381 } | T_LOCOPS
2382 {
2383 if (ypass == 2)
2384 yy_conf->flags |= SHARED_LOCOPS;
2385 } | T_ALL
2386 {
2387 if (ypass == 2)
2388 yy_conf->flags = SHARED_ALL;
2389 };
2390
2391 /***************************************************************************
2392 * section connect
2393 ***************************************************************************/
2394 connect_entry: CONNECT
2395 {
2396 if (ypass == 2)
2397 {
2398 yy_conf = make_conf_item(SERVER_TYPE);
2399 yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
2400 yy_aconf->passwd = NULL;
2401 /* defaults */
2402 yy_aconf->port = PORTNUM;
2403
2404 if (ConfigFileEntry.burst_away)
2405 yy_aconf->flags = CONF_FLAGS_BURST_AWAY;
2406 }
2407 else
2408 {
2409 MyFree(class_name);
2410 class_name = NULL;
2411 }
2412 } connect_name_b '{' connect_items '}' ';'
2413 {
2414 if (ypass == 2)
2415 {
2416 struct CollectItem *yy_hconf=NULL;
2417 struct CollectItem *yy_lconf=NULL;
2418 dlink_node *ptr;
2419 dlink_node *next_ptr;
2420 #ifdef HAVE_LIBCRYPTO
2421 if (yy_aconf->host &&
2422 ((yy_aconf->passwd && yy_aconf->spasswd) ||
2423 (yy_aconf->rsa_public_key && IsConfCryptLink(yy_aconf))))
2424 #else /* !HAVE_LIBCRYPTO */
2425 if (yy_aconf->host && !IsConfCryptLink(yy_aconf) &&
2426 yy_aconf->passwd && yy_aconf->spasswd)
2427 #endif /* !HAVE_LIBCRYPTO */
2428 {
2429 if (conf_add_server(yy_conf, class_name) == -1)
2430 {
2431 delete_conf_item(yy_conf);
2432 yy_conf = NULL;
2433 yy_aconf = NULL;
2434 }
2435 }
2436 else
2437 {
2438 /* Even if yy_conf ->name is NULL
2439 * should still unhook any hub/leaf confs still pending
2440 */
2441 unhook_hub_leaf_confs();
2442
2443 if (yy_conf->name != NULL)
2444 {
2445 #ifndef HAVE_LIBCRYPTO
2446 if (IsConfCryptLink(yy_aconf))
2447 yyerror("Ignoring connect block -- no OpenSSL support");
2448 #else
2449 if (IsConfCryptLink(yy_aconf) && !yy_aconf->rsa_public_key)
2450 yyerror("Ignoring connect block -- missing key");
2451 #endif
2452 if (yy_aconf->host == NULL)
2453 yyerror("Ignoring connect block -- missing host");
2454 else if (!IsConfCryptLink(yy_aconf) &&
2455 (!yy_aconf->passwd || !yy_aconf->spasswd))
2456 yyerror("Ignoring connect block -- missing password");
2457 }
2458
2459
2460 /* XXX
2461 * This fixes a try_connections() core (caused by invalid class_ptr
2462 * pointers) reported by metalrock. That's an ugly fix, but there
2463 * is currently no better way. The entire config subsystem needs an
2464 * rewrite ASAP. make_conf_item() shouldn't really add things onto
2465 * a doubly linked list immediately without any sanity checks! -Michael
2466 */
2467 delete_conf_item(yy_conf);
2468
2469 yy_aconf = NULL;
2470 yy_conf = NULL;
2471 }
2472
2473 /*
2474 * yy_conf is still pointing at the server that is having
2475 * a connect block built for it. This means, y_aconf->name
2476 * points to the actual irc name this server will be known as.
2477 * Now this new server has a set or even just one hub_mask (or leaf_mask)
2478 * given in the link list at yy_hconf. Fill in the HUB confs
2479 * from this link list now.
2480 */
2481 DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
2482 {
2483 struct ConfItem *new_hub_conf;
2484 struct MatchItem *match_item;
2485
2486 yy_hconf = ptr->data;
2487
2488 /* yy_conf == NULL is a fatal error for this connect block! */
2489 if ((yy_conf != NULL) && (yy_conf->name != NULL))
2490 {
2491 new_hub_conf = make_conf_item(HUB_TYPE);
2492 match_item = (struct MatchItem *)map_to_conf(new_hub_conf);
2493 DupString(new_hub_conf->name, yy_conf->name);
2494 if (yy_hconf->user != NULL)
2495 DupString(match_item->user, yy_hconf->user);
2496 else
2497 DupString(match_item->user, "*");
2498 if (yy_hconf->host != NULL)
2499 DupString(match_item->host, yy_hconf->host);
2500 else
2501 DupString(match_item->host, "*");
2502 }
2503 dlinkDelete(&yy_hconf->node, &hub_conf_list);
2504 free_collect_item(yy_hconf);
2505 }
2506
2507 /* Ditto for the LEAF confs */
2508
2509 DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
2510 {
2511 struct ConfItem *new_leaf_conf;
2512 struct MatchItem *match_item;
2513
2514 yy_lconf = ptr->data;
2515
2516 if ((yy_conf != NULL) && (yy_conf->name != NULL))
2517 {
2518 new_leaf_conf = make_conf_item(LEAF_TYPE);
2519 match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
2520 DupString(new_leaf_conf->name, yy_conf->name);
2521 if (yy_lconf->user != NULL)
2522 DupString(match_item->user, yy_lconf->user);
2523 else
2524 DupString(match_item->user, "*");
2525 if (yy_lconf->host != NULL)
2526 DupString(match_item->host, yy_lconf->host);
2527 else
2528 DupString(match_item->host, "*");
2529 }
2530 dlinkDelete(&yy_lconf->node, &leaf_conf_list);
2531 free_collect_item(yy_lconf);
2532 }
2533 MyFree(class_name);
2534 class_name = NULL;
2535 yy_conf = NULL;
2536 yy_aconf = NULL;
2537 }
2538 };
2539
2540 connect_name_b: | connect_name_t;
2541 connect_items: connect_items connect_item | connect_item;
2542 connect_item: connect_name | connect_host | connect_vhost |
2543 connect_send_password | connect_accept_password |
2544 connect_aftype | connect_port |
2545 connect_fakename | connect_flags | connect_hub_mask |
2546 connect_leaf_mask | connect_class | connect_auto |
2547 connect_encrypted | connect_compressed | connect_cryptlink |
2548 connect_rsa_public_key_file | connect_cipher_preference |
2549 connect_topicburst | error ';' ;
2550
2551 connect_name: NAME '=' QSTRING ';'
2552 {
2553 if (ypass == 2)
2554 {
2555 if (yy_conf->name != NULL)
2556 yyerror("Multiple connect name entry");
2557
2558 MyFree(yy_conf->name);
2559 DupString(yy_conf->name, yylval.string);
2560 }
2561 };
2562
2563 connect_name_t: QSTRING
2564 {
2565 if (ypass == 2)
2566 {
2567 if (yy_conf->name != NULL)
2568 yyerror("Multiple connect name entry");
2569
2570 MyFree(yy_conf->name);
2571 DupString(yy_conf->name, yylval.string);
2572 }
2573 };
2574
2575 connect_host: HOST '=' QSTRING ';'
2576 {
2577 if (ypass == 2)
2578 {
2579 MyFree(yy_aconf->host);
2580 DupString(yy_aconf->host, yylval.string);
2581 }
2582 };
2583
2584 connect_vhost: VHOST '=' QSTRING ';'
2585 {
2586 if (ypass == 2)
2587 {
2588 struct addrinfo hints, *res;
2589
2590 memset(&hints, 0, sizeof(hints));
2591
2592 hints.ai_family = AF_UNSPEC;
2593 hints.ai_socktype = SOCK_STREAM;
2594 hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
2595
2596 if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
2597 ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
2598 else
2599 {
2600 assert(res != NULL);
2601
2602 memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2603 yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2604 yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2605 irc_freeaddrinfo(res);
2606 }
2607 }
2608 };
2609
2610 connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2611 {
2612 if (ypass == 2)
2613 {
2614 if ($3[0] == ':')
2615 yyerror("Server passwords cannot begin with a colon");
2616 else if (strchr($3, ' ') != NULL)
2617 yyerror("Server passwords cannot contain spaces");
2618 else {
2619 if (yy_aconf->spasswd != NULL)
2620 memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2621
2622 MyFree(yy_aconf->spasswd);
2623 DupString(yy_aconf->spasswd, yylval.string);
2624 }
2625 }
2626 };
2627
2628 connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2629 {
2630 if (ypass == 2)
2631 {
2632 if ($3[0] == ':')
2633 yyerror("Server passwords cannot begin with a colon");
2634 else if (strchr($3, ' ') != NULL)
2635 yyerror("Server passwords cannot contain spaces");
2636 else {
2637 if (yy_aconf->passwd != NULL)
2638 memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2639
2640 MyFree(yy_aconf->passwd);
2641 DupString(yy_aconf->passwd, yylval.string);
2642 }
2643 }
2644 };
2645
2646 connect_port: PORT '=' NUMBER ';'
2647 {
2648 if (ypass == 2)
2649 yy_aconf->port = $3;
2650 };
2651
2652 connect_aftype: AFTYPE '=' T_IPV4 ';'
2653 {
2654 if (ypass == 2)
2655 yy_aconf->aftype = AF_INET;
2656 } | AFTYPE '=' T_IPV6 ';'
2657 {
2658 #ifdef IPV6
2659 if (ypass == 2)
2660 yy_aconf->aftype = AF_INET6;
2661 #endif
2662 };
2663
2664 connect_fakename: FAKENAME '=' QSTRING ';'
2665 {
2666 if (ypass == 2)
2667 {
2668 MyFree(yy_aconf->fakename);
2669 DupString(yy_aconf->fakename, yylval.string);
2670 }
2671 };
2672
2673 connect_flags: IRCD_FLAGS
2674 {
2675 } '=' connect_flags_items ';';
2676
2677 connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2678 connect_flags_item: NOT { not_atom = 1; } connect_flags_item_atom
2679 | { not_atom = 0; } connect_flags_item_atom;
2680
2681 connect_flags_item_atom: LAZYLINK
2682 {
2683 if (ypass == 2)
2684 {
2685 if (not_atom)ClearConfLazyLink(yy_aconf);
2686 else SetConfLazyLink(yy_aconf);
2687 }
2688 } | COMPRESSED
2689 {
2690 if (ypass == 2)
2691 #ifndef HAVE_LIBZ
2692 yyerror("Ignoring flags = compressed; -- no zlib support");
2693 #else
2694 {
2695 if (not_atom)ClearConfCompressed(yy_aconf);
2696 else SetConfCompressed(yy_aconf);
2697 }
2698 #endif
2699 } | CRYPTLINK
2700 {
2701 if (ypass == 2)
2702 {
2703 if (not_atom)ClearConfCryptLink(yy_aconf);
2704 else SetConfCryptLink(yy_aconf);
2705 }
2706 } | AUTOCONN
2707 {
2708 if (ypass == 2)
2709 {
2710 if (not_atom)ClearConfAllowAutoConn(yy_aconf);
2711 else SetConfAllowAutoConn(yy_aconf);
2712 }
2713 } | BURST_AWAY
2714 {
2715 if (ypass == 2)
2716 {
2717 if (not_atom)ClearConfAwayBurst(yy_aconf);
2718 else SetConfAwayBurst(yy_aconf);
2719 }
2720 } | TOPICBURST
2721 {
2722 if (ypass == 2)
2723 {
2724 if (not_atom)ClearConfTopicBurst(yy_aconf);
2725 else SetConfTopicBurst(yy_aconf);
2726 }
2727 }
2728 ;
2729
2730 connect_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
2731 {
2732 #ifdef HAVE_LIBCRYPTO
2733 if (ypass == 2)
2734 {
2735 BIO *file;
2736
2737 if (yy_aconf->rsa_public_key != NULL)
2738 {
2739 RSA_free(yy_aconf->rsa_public_key);
2740 yy_aconf->rsa_public_key = NULL;
2741 }
2742
2743 if (yy_aconf->rsa_public_key_file != NULL)
2744 {
2745 MyFree(yy_aconf->rsa_public_key_file);
2746 yy_aconf->rsa_public_key_file = NULL;
2747 }
2748
2749 DupString(yy_aconf->rsa_public_key_file, yylval.string);
2750
2751 if ((file = BIO_new_file(yylval.string, "r")) == NULL)
2752 {
2753 yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
2754 break;
2755 }
2756
2757 yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
2758
2759 if (yy_aconf->rsa_public_key == NULL)
2760 {
2761 yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
2762 break;
2763 }
2764
2765 BIO_set_close(file, BIO_CLOSE);
2766 BIO_free(file);
2767 }
2768 #endif /* HAVE_LIBCRYPTO */
2769 };
2770
2771 connect_encrypted: ENCRYPTED '=' TBOOL ';'
2772 {
2773 if (ypass == 2)
2774 {
2775 if (yylval.number)
2776 yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2777 else
2778 yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2779 }
2780 };
2781
2782 connect_cryptlink: CRYPTLINK '=' TBOOL ';'
2783 {
2784 if (ypass == 2)
2785 {
2786 if (yylval.number)
2787 yy_aconf->flags |= CONF_FLAGS_CRYPTLINK;
2788 else
2789 yy_aconf->flags &= ~CONF_FLAGS_CRYPTLINK;
2790 }
2791 };
2792
2793 connect_compressed: COMPRESSED '=' TBOOL ';'
2794 {
2795 if (ypass == 2)
2796 {
2797 if (yylval.number)
2798 #ifndef HAVE_LIBZ
2799 yyerror("Ignoring compressed=yes; -- no zlib support");
2800 #else
2801 yy_aconf->flags |= CONF_FLAGS_COMPRESSED;
2802 #endif
2803 else
2804 yy_aconf->flags &= ~CONF_FLAGS_COMPRESSED;
2805 }
2806 };
2807
2808 connect_auto: AUTOCONN '=' TBOOL ';'
2809 {
2810 if (ypass == 2)
2811 {
2812 if (yylval.number)
2813 yy_aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
2814 else
2815 yy_aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
2816 }
2817 };
2818
2819 connect_topicburst: TOPICBURST '=' TBOOL ';'
2820 {
2821 if (ypass == 2)
2822 {
2823 if (yylval.number)
2824 SetConfTopicBurst(yy_aconf);
2825 else
2826 ClearConfTopicBurst(yy_aconf);
2827 }
2828 };
2829
2830 connect_hub_mask: HUB_MASK '=' QSTRING ';'
2831 {
2832 if (ypass == 2)
2833 {
2834 struct CollectItem *yy_tmp;
2835
2836 yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2837 DupString(yy_tmp->host, yylval.string);
2838 DupString(yy_tmp->user, "*");
2839 dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2840 }
2841 };
2842
2843 connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2844 {
2845 if (ypass == 2)
2846 {
2847 struct CollectItem *yy_tmp;
2848
2849 yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2850 DupString(yy_tmp->host, yylval.string);
2851 DupString(yy_tmp->user, "*");
2852 dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2853 }
2854 };
2855
2856 connect_class: CLASS '=' QSTRING ';'
2857 {
2858 if (ypass == 2)
2859 {
2860 MyFree(class_name);
2861 DupString(class_name, yylval.string);
2862 }
2863 };
2864
2865 connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2866 {
2867 #ifdef HAVE_LIBCRYPTO
2868 if (ypass == 2)
2869 {
2870 struct EncCapability *ecap;
2871 const char *cipher_name;
2872 int found = 0;
2873
2874 yy_aconf->cipher_preference = NULL;
2875 cipher_name = yylval.string;
2876
2877 for (ecap = CipherTable; ecap->name; ecap++)
2878 {
2879 if ((irccmp(ecap->name, cipher_name) == 0) &&
2880 (ecap->cap & CAP_ENC_MASK))
2881 {
2882 yy_aconf->cipher_preference = ecap;
2883 found = 1;
2884 break;
2885 }
2886 }
2887
2888 if (!found)
2889 yyerror("Invalid cipher");
2890 }
2891 #else
2892 if (ypass == 2)
2893 yyerror("Ignoring cipher_preference -- no OpenSSL support");
2894 #endif
2895 };
2896
2897 /***************************************************************************
2898 * section kill
2899 ***************************************************************************/
2900 kill_entry: KILL
2901 {
2902 if (ypass == 2)
2903 {
2904 userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2905 regex_ban = 0;
2906 }
2907 } '{' kill_items '}' ';'
2908 {
2909 if (ypass == 2)
2910 {
2911 if (userbuf[0] && hostbuf[0])
2912 {
2913 if (regex_ban)
2914 {
2915 pcre *exp_user = NULL;
2916 pcre *exp_host = NULL;
2917 const char *errptr = NULL;
2918
2919 if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2920 !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2921 {
2922 ilog(L_ERROR, "Failed to add regular expression based K-Line: %s",
2923 errptr);
2924 break;
2925 }
2926
2927 yy_conf = make_conf_item(RKLINE_TYPE);
2928 yy_aconf = map_to_conf(yy_conf);
2929
2930 yy_aconf->regexuser = exp_user;
2931 yy_aconf->regexhost = exp_host;
2932
2933 DupString(yy_aconf->user, userbuf);
2934 DupString(yy_aconf->host, hostbuf);
2935
2936 if (reasonbuf[0])
2937 DupString(yy_aconf->reason, reasonbuf);
2938 else
2939 DupString(yy_aconf->reason, "No reason");
2940 }
2941 else
2942 {
2943 yy_conf = make_conf_item(KLINE_TYPE);
2944 yy_aconf = map_to_conf(yy_conf);
2945
2946 DupString(yy_aconf->user, userbuf);
2947 DupString(yy_aconf->host, hostbuf);
2948
2949 if (reasonbuf[0])
2950 DupString(yy_aconf->reason, reasonbuf);
2951 else
2952 DupString(yy_aconf->reason, "No reason");
2953 add_conf_by_address(CONF_KILL, yy_aconf);
2954 }
2955 }
2956 else
2957 delete_conf_item(yy_conf);
2958
2959 yy_conf = NULL;
2960 yy_aconf = NULL;
2961 }
2962 };
2963
2964 kill_type: TYPE
2965 {
2966 } '=' kill_type_items ';';
2967
2968 kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2969 kill_type_item: REGEX_T
2970 {
2971 if (ypass == 2)
2972 regex_ban = 1;
2973 };
2974
2975 kill_items: kill_items kill_item | kill_item;
2976 kill_item: kill_user | kill_reason | kill_type | error;
2977
2978 kill_user: USER '=' QSTRING ';'
2979 {
2980 if (ypass == 2)
2981 {
2982 struct split_nuh_item nuh;
2983
2984 nuh.nuhmask = yylval.string;
2985 nuh.nickptr = NULL;
2986 nuh.userptr = userbuf;
2987 nuh.hostptr = hostbuf;
2988
2989 nuh.nicksize = 0;
2990 nuh.usersize = sizeof(userbuf);
2991 nuh.hostsize = sizeof(hostbuf);
2992
2993 split_nuh(&nuh);
2994 }
2995 };
2996
2997 kill_reason: REASON '=' QSTRING ';'
2998 {
2999 if (ypass == 2)
3000 strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
3001 };
3002
3003 /***************************************************************************
3004 * section deny
3005 ***************************************************************************/
3006 deny_entry: DENY
3007 {
3008 if (ypass == 2)
3009 {
3010 yy_conf = make_conf_item(DLINE_TYPE);
3011 yy_aconf = map_to_conf(yy_conf);
3012 /* default reason */
3013 DupString(yy_aconf->reason, "No reason");
3014 }
3015 } '{' deny_items '}' ';'
3016 {
3017 if (ypass == 2)
3018 {
3019 if (yy_aconf->host && parse_netmask(yy_aconf->host, NULL, NULL) != HM_HOST)
3020 add_conf_by_address(CONF_DLINE, yy_aconf);
3021 else
3022 delete_conf_item(yy_conf);
3023 yy_conf = NULL;
3024 yy_aconf = NULL;
3025 }
3026 };
3027
3028 deny_items: deny_items deny_item | deny_item;
3029 deny_item: deny_ip | deny_reason | error;
3030
3031 deny_ip: IP '=' QSTRING ';'
3032 {
3033 if (ypass == 2)
3034 {
3035 MyFree(yy_aconf->host);
3036 DupString(yy_aconf->host, yylval.string);
3037 }
3038 };
3039
3040 deny_reason: REASON '=' QSTRING ';'
3041 {
3042 if (ypass == 2)
3043 {
3044 MyFree(yy_aconf->reason);
3045 DupString(yy_aconf->reason, yylval.string);
3046 }
3047 };
3048
3049 /***************************************************************************
3050 * section exempt
3051 ***************************************************************************/
3052 exempt_entry: EXEMPT '{' exempt_items '}' ';';
3053
3054 exempt_items: exempt_items exempt_item | exempt_item;
3055 exempt_item: exempt_ip | error;
3056
3057 exempt_ip: IP '=' QSTRING ';'
3058 {
3059 if (ypass == 2)
3060 {
3061 if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
3062 {
3063 yy_conf = make_conf_item(EXEMPTDLINE_TYPE);
3064 yy_aconf = map_to_conf(yy_conf);
3065 DupString(yy_aconf->host, yylval.string);
3066
3067 add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
3068
3069 yy_conf = NULL;
3070 yy_aconf = NULL;
3071 }
3072 }
3073 };
3074
3075 /***************************************************************************
3076 * section gecos
3077 ***************************************************************************/
3078 gecos_entry: GECOS
3079 {
3080 if (ypass == 2)
3081 {
3082 regex_ban = 0;
3083 reasonbuf[0] = gecos_name[0] = '\0';
3084 }
3085 } '{' gecos_items '}' ';'
3086 {
3087 if (ypass == 2)
3088 {
3089 if (gecos_name[0])
3090 {
3091 if (regex_ban)
3092 {
3093 pcre *exp_p = NULL;
3094 const char *errptr = NULL;
3095
3096 if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
3097 {
3098 ilog(L_ERROR, "Failed to add regular expression based X-Line: %s",
3099 errptr);
3100 break;
3101 }
3102
3103 yy_conf = make_conf_item(RXLINE_TYPE);
3104 yy_conf->regexpname = exp_p;
3105 }
3106 else
3107 yy_conf = make_conf_item(XLINE_TYPE);
3108
3109 yy_match_item = map_to_conf(yy_conf);
3110 DupString(yy_conf->name, gecos_name);
3111
3112 if (reasonbuf[0])
3113 DupString(yy_match_item->reason, reasonbuf);
3114 else
3115 DupString(yy_match_item->reason, "No reason");
3116 }
3117 }
3118 };
3119
3120 gecos_flags: TYPE
3121 {
3122 } '=' gecos_flags_items ';';
3123
3124 gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
3125 gecos_flags_item: REGEX_T
3126 {
3127 if (ypass == 2)
3128 regex_ban = 1;
3129 };
3130
3131 gecos_items: gecos_items gecos_item | gecos_item;
3132 gecos_item: gecos_name | gecos_reason | gecos_flags | error;
3133
3134 gecos_name: NAME '=' QSTRING ';'
3135 {
3136 if (ypass == 2)
3137 strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
3138 };
3139
3140 gecos_reason: REASON '=' QSTRING ';'
3141 {
3142 if (ypass == 2)
3143 strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
3144 };
3145
3146 /***************************************************************************
3147 * section general
3148 ***************************************************************************/
3149 general_entry: GENERAL
3150 '{' general_items '}' ';';
3151
3152 general_items: general_items general_item | general_item;
3153 general_item: general_hide_spoof_ips | general_ignore_bogus_ts |
3154 general_failed_oper_notice | general_anti_nick_flood |
3155 general_max_nick_time | general_max_nick_changes |
3156 general_max_accept | general_anti_spam_exit_message_time |
3157 general_ts_warn_delta | general_ts_max_delta |
3158 general_kill_chase_time_limit | general_kline_with_reason |
3159 general_kline_reason | general_invisible_on_connect |
3160 general_warn_no_nline | general_dots_in_ident |
3161 general_stats_o_oper_only | general_stats_k_oper_only |
3162 general_pace_wait | general_stats_i_oper_only |
3163 general_pace_wait_simple | general_stats_P_oper_only |
3164 general_short_motd | general_no_oper_flood |
3165 general_true_no_oper_flood | general_oper_pass_resv |
3166 general_idletime | general_message_locale |
3167 general_oper_only_umodes | general_max_targets |
3168 general_use_egd | general_egdpool_path |
3169 general_oper_umodes | general_caller_id_wait |
3170 general_opers_bypass_callerid | general_default_floodcount |
3171 general_min_nonwildcard | general_min_nonwildcard_simple |
3172 general_servlink_path | general_disable_remote_commands |
3173 general_default_cipher_preference |
3174 general_compression_level | general_client_flood |
3175 general_throttle_time | general_havent_read_conf |
3176 general_dot_in_ip6_addr | general_ping_cookie |
3177 general_disable_auth | general_burst_away |
3178 general_tkline_expire_notices | general_gline_min_cidr |
3179 general_gline_min_cidr6 | general_use_whois_actually |
3180 general_reject_hold_time | general_stats_e_disabled |
3181 error;
3182
3183
3184
3185 general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
3186 {
3187 ConfigFileEntry.gline_min_cidr = $3;
3188 };
3189
3190 general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
3191 {
3192 ConfigFileEntry.gline_min_cidr6 = $3;
3193 };
3194
3195 general_burst_away: BURST_AWAY '=' TBOOL ';'
3196 {
3197 ConfigFileEntry.burst_away = yylval.number;
3198 };
3199
3200 general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
3201 {
3202 ConfigFileEntry.use_whois_actually = yylval.number;
3203 };
3204
3205 general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
3206 {
3207 GlobalSetOptions.rejecttime = yylval.number;
3208 };
3209
3210 general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
3211 {
3212 ConfigFileEntry.tkline_expire_notices = yylval.number;
3213 };
3214
3215 general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' NUMBER ';'
3216 {
3217 ConfigFileEntry.kill_chase_time_limit = $3;
3218 };
3219
3220 general_hide_spoof_ips: HIDE_SPOOF_IPS '=' TBOOL ';'
3221 {
3222 ConfigFileEntry.hide_spoof_ips = yylval.number;
3223 };
3224
3225 general_ignore_bogus_ts: IGNORE_BOGUS_TS '=' TBOOL ';'
3226 {
3227 ConfigFileEntry.ignore_bogus_ts = yylval.number;
3228 };
3229
3230 general_disable_remote_commands: DISABLE_REMOTE_COMMANDS '=' TBOOL ';'
3231 {
3232 ConfigFileEntry.disable_remote = yylval.number;
3233 };
3234
3235 general_failed_oper_notice: FAILED_OPER_NOTICE '=' TBOOL ';'
3236 {
3237 ConfigFileEntry.failed_oper_notice = yylval.number;
3238 };
3239
3240 general_anti_nick_flood: ANTI_NICK_FLOOD '=' TBOOL ';'
3241 {
3242 ConfigFileEntry.anti_nick_flood = yylval.number;
3243 };
3244
3245 general_max_nick_time: MAX_NICK_TIME '=' timespec ';'
3246 {
3247 ConfigFileEntry.max_nick_time = $3;
3248 };
3249
3250 general_max_nick_changes: MAX_NICK_CHANGES '=' NUMBER ';'
3251 {
3252 ConfigFileEntry.max_nick_changes = $3;
3253 };
3254
3255 general_max_accept: MAX_ACCEPT '=' NUMBER ';'
3256 {
3257 ConfigFileEntry.max_accept = $3;
3258 };
3259
3260 general_anti_spam_exit_message_time: ANTI_SPAM_EXIT_MESSAGE_TIME '=' timespec ';'
3261 {
3262 ConfigFileEntry.anti_spam_exit_message_time = $3;
3263 };
3264
3265 general_ts_warn_delta: TS_WARN_DELTA '=' timespec ';'
3266 {
3267 ConfigFileEntry.ts_warn_delta = $3;
3268 };
3269
3270 general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
3271 {
3272 if (ypass == 2)
3273 ConfigFileEntry.ts_max_delta = $3;
3274 };
3275
3276 general_havent_read_conf: HAVENT_READ_CONF '=' NUMBER ';'
3277 {
3278 if (($3 > 0) && ypass == 1)
3279 {
3280 ilog(L_CRIT, "You haven't read your config file properly.");
3281 ilog(L_CRIT, "There is a line in the example conf that will kill your server if not removed.");
3282 ilog(L_CRIT, "Consider actually reading/editing the conf file, and removing this line.");
3283 exit(0);
3284 }
3285 };
3286
3287 general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
3288 {
3289 ConfigFileEntry.kline_with_reason = yylval.number;
3290 };
3291
3292 general_kline_reason: KLINE_REASON '=' QSTRING ';'
3293 {
3294 if (ypass == 2)
3295 {
3296 MyFree(ConfigFileEntry.kline_reason);
3297 DupString(ConfigFileEntry.kline_reason, yylval.string);
3298 }
3299 };
3300
3301 general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
3302 {
3303 ConfigFileEntry.invisible_on_connect = yylval.number;
3304 };
3305
3306 general_warn_no_nline: WARN_NO_NLINE '=' TBOOL ';'
3307 {
3308 ConfigFileEntry.warn_no_nline = yylval.number;
3309 };
3310
3311 general_stats_e_disabled: STATS_E_DISABLED '=' TBOOL ';'
3312 {
3313 ConfigFileEntry.stats_e_disabled = yylval.number;
3314 };
3315
3316 general_stats_o_oper_only: STATS_O_OPER_ONLY '=' TBOOL ';'
3317 {
3318 ConfigFileEntry.stats_o_oper_only = yylval.number;
3319 };
3320
3321 general_stats_P_oper_only: STATS_P_OPER_ONLY '=' TBOOL ';'
3322 {
3323 ConfigFileEntry.stats_P_oper_only = yylval.number;
3324 };
3325
3326 general_stats_k_oper_only: STATS_K_OPER_ONLY '=' TBOOL ';'
3327 {
3328 ConfigFileEntry.stats_k_oper_only = 2 * yylval.number;
3329 } | STATS_K_OPER_ONLY '=' TMASKED ';'
3330 {
3331 ConfigFileEntry.stats_k_oper_only = 1;
3332 };
3333
3334 general_stats_i_oper_only: STATS_I_OPER_ONLY '=' TBOOL ';'
3335 {
3336 ConfigFileEntry.stats_i_oper_only = 2 * yylval.number;
3337 } | STATS_I_OPER_ONLY '=' TMASKED ';'
3338 {
3339 ConfigFileEntry.stats_i_oper_only = 1;
3340 };
3341
3342 general_pace_wait: PACE_WAIT '=' timespec ';'
3343 {
3344 ConfigFileEntry.pace_wait = $3;
3345 };
3346
3347 general_caller_id_wait: CALLER_ID_WAIT '=' timespec ';'
3348 {
3349 ConfigFileEntry.caller_id_wait = $3;
3350 };
3351
3352 general_opers_bypass_callerid: OPERS_BYPASS_CALLERID '=' TBOOL ';'
3353 {
3354 ConfigFileEntry.opers_bypass_callerid = yylval.number;
3355 };
3356
3357 general_pace_wait_simple: PACE_WAIT_SIMPLE '=' timespec ';'
3358 {
3359 ConfigFileEntry.pace_wait_simple = $3;
3360 };
3361
3362 general_short_motd: SHORT_MOTD '=' TBOOL ';'
3363 {
3364 ConfigFileEntry.short_motd = yylval.number;
3365 };
3366
3367 general_no_oper_flood: NO_OPER_FLOOD '=' TBOOL ';'
3368 {
3369 ConfigFileEntry.no_oper_flood = yylval.number;
3370 };
3371
3372 general_true_no_oper_flood: TRUE_NO_OPER_FLOOD '=' TBOOL ';'
3373 {
3374 ConfigFileEntry.true_no_oper_flood = yylval.number;
3375 };
3376
3377 general_oper_pass_resv: OPER_PASS_RESV '=' TBOOL ';'
3378 {
3379 ConfigFileEntry.oper_pass_resv = yylval.number;
3380 };
3381
3382 general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
3383 {
3384 if (ypass == 2)
3385 {
3386 if (strlen(yylval.string) > LOCALE_LENGTH-2)
3387 yylval.string[LOCALE_LENGTH-1] = '\0';
3388
3389 set_locale(yylval.string);
3390 }
3391 };
3392
3393 general_idletime: IDLETIME '=' timespec ';'
3394 {
3395 ConfigFileEntry.idletime = $3;
3396 };
3397
3398 general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
3399 {
3400 ConfigFileEntry.dots_in_ident = $3;
3401 };
3402
3403 general_max_targets: MAX_TARGETS '=' NUMBER ';'
3404 {
3405 ConfigFileEntry.max_targets = $3;
3406 };
3407
3408 general_servlink_path: SERVLINK_PATH '=' QSTRING ';'
3409 {
3410 if (ypass == 2)
3411 {
3412 MyFree(ConfigFileEntry.servlink_path);
3413 DupString(ConfigFileEntry.servlink_path, yylval.string);
3414 }
3415 };
3416
3417 general_default_cipher_preference: DEFAULT_CIPHER_PREFERENCE '=' QSTRING ';'
3418 {
3419 #ifdef HAVE_LIBCRYPTO
3420 if (ypass == 2)
3421 {
3422 struct EncCapability *ecap;
3423 const char *cipher_name;
3424 int found = 0;
3425
3426 ConfigFileEntry.default_cipher_preference = NULL;
3427 cipher_name = yylval.string;
3428
3429 for (ecap = CipherTable; ecap->name; ecap++)
3430 {
3431 if ((irccmp(ecap->name, cipher_name) == 0) &&
3432 (ecap->cap & CAP_ENC_MASK))
3433 {
3434 ConfigFileEntry.default_cipher_preference = ecap;
3435 found = 1;
3436 break;
3437 }
3438 }
3439
3440 if (!found)
3441 yyerror("Invalid cipher");
3442 }
3443 #else
3444 if (ypass == 2)
3445 yyerror("Ignoring default_cipher_preference -- no OpenSSL support");
3446 #endif
3447 };
3448
3449 general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
3450 {
3451 if (ypass == 2)
3452 {
3453 ConfigFileEntry.compression_level = $3;
3454 #ifndef HAVE_LIBZ
3455 yyerror("Ignoring compression_level -- no zlib support");
3456 #else
3457 if ((ConfigFileEntry.compression_level < 1) ||
3458 (ConfigFileEntry.compression_level > 9))
3459 {
3460 yyerror("Ignoring invalid compression_level, using default");
3461 ConfigFileEntry.compression_level = 0;
3462 }
3463 #endif
3464 }
3465 };
3466
3467 general_use_egd: USE_EGD '=' TBOOL ';'
3468 {
3469 ConfigFileEntry.use_egd = yylval.number;
3470 };
3471
3472 general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
3473 {
3474 if (ypass == 2)
3475 {
3476 MyFree(ConfigFileEntry.egdpool_path);
3477 DupString(ConfigFileEntry.egdpool_path, yylval.string);
3478 }
3479 };
3480
3481 general_ping_cookie: PING_COOKIE '=' TBOOL ';'
3482 {
3483 ConfigFileEntry.ping_cookie = yylval.number;
3484 };
3485
3486 general_disable_auth: DISABLE_AUTH '=' TBOOL ';'
3487 {
3488 ConfigFileEntry.disable_auth = yylval.number;
3489 };
3490
3491 general_throttle_time: THROTTLE_TIME '=' timespec ';'
3492 {
3493 ConfigFileEntry.throttle_time = yylval.number;
3494 };
3495
3496 general_oper_umodes: OPER_UMODES
3497 {
3498 ConfigFileEntry.oper_umodes = 0;
3499 } '=' umode_oitems ';' ;
3500
3501 umode_oitems: umode_oitems ',' umode_oitem | umode_oitem;
3502 umode_oitem: T_BOTS
3503 {
3504 ConfigFileEntry.oper_umodes |= UMODE_BOTS;
3505 } | T_CCONN
3506 {
3507 ConfigFileEntry.oper_umodes |= UMODE_CCONN;
3508 } | T_DEAF
3509 {
3510 ConfigFileEntry.oper_umodes |= UMODE_DEAF;
3511 } | T_DEBUG
3512 {
3513 ConfigFileEntry.oper_umodes |= UMODE_DEBUG;
3514 } | T_FULL
3515 {
3516 ConfigFileEntry.oper_umodes |= UMODE_FULL;
3517 } | T_SKILL
3518 {
3519 ConfigFileEntry.oper_umodes |= UMODE_SKILL;
3520 } | T_NCHANGE
3521 {
3522 ConfigFileEntry.oper_umodes |= UMODE_NCHANGE;
3523 } | T_REJ
3524 {
3525 ConfigFileEntry.oper_umodes |= UMODE_REJ;
3526 } | T_UNAUTH
3527 {
3528 ConfigFileEntry.oper_umodes |= UMODE_UNAUTH;
3529 } | T_SPY
3530 {
3531 ConfigFileEntry.oper_umodes |= UMODE_SPY;
3532 } | T_EXTERNAL
3533 {
3534 ConfigFileEntry.oper_umodes |= UMODE_EXTERNAL;
3535 } | T_OPERWALL
3536 {
3537 ConfigFileEntry.oper_umodes |= UMODE_OPERWALL;
3538 } | T_SERVNOTICE
3539 {
3540 ConfigFileEntry.oper_umodes |= UMODE_SERVNOTICE;
3541 } | T_INVISIBLE
3542 {
3543 ConfigFileEntry.oper_umodes |= UMODE_INVISIBLE;
3544 } | T_WALLOP
3545 {
3546 ConfigFileEntry.oper_umodes |= UMODE_WALLOP;
3547 } | T_SOFTCALLERID
3548 {
3549 ConfigFileEntry.oper_umodes |= UMODE_SOFTCALLERID;
3550 } | T_CALLERID
3551 {
3552 ConfigFileEntry.oper_umodes |= UMODE_CALLERID;
3553 } | T_LOCOPS
3554 {
3555 ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
3556 };
3557
3558 general_oper_only_umodes: OPER_ONLY_UMODES
3559 {
3560 ConfigFileEntry.oper_only_umodes = 0;
3561 } '=' umode_items ';' ;
3562
3563 umode_items: umode_items ',' umode_item | umode_item;
3564 umode_item: T_BOTS
3565 {
3566 ConfigFileEntry.oper_only_umodes |= UMODE_BOTS;
3567 } | T_CCONN
3568 {
3569 ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
3570 } | T_DEAF
3571 {
3572 ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
3573 } | T_DEBUG
3574 {
3575 ConfigFileEntry.oper_only_umodes |= UMODE_DEBUG;
3576 } | T_FULL
3577 {
3578 ConfigFileEntry.oper_only_umodes |= UMODE_FULL;
3579 } | T_SKILL
3580 {
3581 ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
3582 } | T_NCHANGE
3583 {
3584 ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
3585 } | T_REJ
3586 {
3587 ConfigFileEntry.oper_only_umodes |= UMODE_REJ;
3588 } | T_UNAUTH
3589 {
3590 ConfigFileEntry.oper_only_umodes |= UMODE_UNAUTH;
3591 } | T_SPY
3592 {
3593 ConfigFileEntry.oper_only_umodes |= UMODE_SPY;
3594 } | T_EXTERNAL
3595 {
3596 ConfigFileEntry.oper_only_umodes |= UMODE_EXTERNAL;
3597 } | T_OPERWALL
3598 {
3599 ConfigFileEntry.oper_only_umodes |= UMODE_OPERWALL;
3600 } | T_SERVNOTICE
3601 {
3602 ConfigFileEntry.oper_only_umodes |= UMODE_SERVNOTICE;
3603 } | T_INVISIBLE
3604 {
3605 ConfigFileEntry.oper_only_umodes |= UMODE_INVISIBLE;
3606 } | T_WALLOP
3607 {
3608 ConfigFileEntry.oper_only_umodes |= UMODE_WALLOP;
3609 } | T_SOFTCALLERID
3610 {
3611 ConfigFileEntry.oper_only_umodes |= UMODE_SOFTCALLERID;
3612 } | T_CALLERID
3613 {
3614 ConfigFileEntry.oper_only_umodes |= UMODE_CALLERID;
3615 } | T_LOCOPS
3616 {
3617 ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
3618 };
3619
3620 general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
3621 {
3622 ConfigFileEntry.min_nonwildcard = $3;
3623 };
3624
3625 general_min_nonwildcard_simple: MIN_NONWILDCARD_SIMPLE '=' NUMBER ';'
3626 {
3627 ConfigFileEntry.min_nonwildcard_simple = $3;
3628 };
3629
3630 general_default_floodcount: DEFAULT_FLOODCOUNT '=' NUMBER ';'
3631 {
3632 ConfigFileEntry.default_floodcount = $3;
3633 };
3634
3635 general_client_flood: T_CLIENT_FLOOD '=' sizespec ';'
3636 {
3637 ConfigFileEntry.client_flood = $3;
3638 };
3639
3640 general_dot_in_ip6_addr: DOT_IN_IP6_ADDR '=' TBOOL ';'
3641 {
3642 ConfigFileEntry.dot_in_ip6_addr = yylval.number;
3643 };
3644
3645 /***************************************************************************
3646 * section glines
3647 ***************************************************************************/
3648 gline_entry: GLINES
3649 {
3650 if (ypass == 2)
3651 {
3652 yy_conf = make_conf_item(GDENY_TYPE);
3653 yy_aconf = map_to_conf(yy_conf);
3654 }
3655 } '{' gline_items '}' ';'
3656 {
3657 if (ypass == 2)
3658 {
3659 /*
3660 * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3661 * end we will have one extra, so we should free it.
3662 */
3663 if (yy_conf->name == NULL || yy_aconf->user == NULL)
3664 {
3665 delete_conf_item(yy_conf);
3666 yy_conf = NULL;
3667 yy_aconf = NULL;
3668 }
3669 }
3670 };
3671
3672 gline_items: gline_items gline_item | gline_item;
3673 gline_item: gline_enable |
3674 gline_duration |
3675 gline_logging |
3676 gline_user |
3677 gline_server |
3678 gline_action |
3679 error;
3680
3681 gline_enable: ENABLE '=' TBOOL ';'
3682 {
3683 if (ypass == 2)
3684 ConfigFileEntry.glines = yylval.number;
3685 };
3686
3687 gline_duration: DURATION '=' timespec ';'
3688 {
3689 if (ypass == 2)
3690 ConfigFileEntry.gline_time = $3;
3691 };
3692
3693 gline_logging: LOGGING
3694 {
3695 if (ypass == 2)
3696 ConfigFileEntry.gline_logging = 0;
3697 } '=' gline_logging_types ';';
3698 gline_logging_types: gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3699 gline_logging_type_item: T_REJECT
3700 {
3701 if (ypass == 2)
3702 ConfigFileEntry.gline_logging |= GDENY_REJECT;
3703 } | T_BLOCK
3704 {
3705 if (ypass == 2)
3706 ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3707 };
3708
3709 gline_user: USER '=' QSTRING ';'
3710 {
3711 if (ypass == 2)
3712 {
3713 struct split_nuh_item nuh;
3714
3715 nuh.nuhmask = yylval.string;
3716 nuh.nickptr = NULL;
3717 nuh.userptr = userbuf;
3718 nuh.hostptr = hostbuf;
3719
3720 nuh.nicksize = 0;
3721 nuh.usersize = sizeof(userbuf);
3722 nuh.hostsize = sizeof(hostbuf);
3723
3724 split_nuh(&nuh);
3725
3726 if (yy_aconf->user == NULL)
3727 {
3728 DupString(yy_aconf->user, userbuf);
3729 DupString(yy_aconf->host, hostbuf);
3730 }
3731 else
3732 {
3733 struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
3734
3735 DupString(yy_tmp->user, userbuf);
3736 DupString(yy_tmp->host, hostbuf);
3737
3738 dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3739 }
3740 }
3741 };
3742
3743 gline_server: NAME '=' QSTRING ';'
3744 {
3745 if (ypass == 2)
3746 {
3747 MyFree(yy_conf->name);
3748 DupString(yy_conf->name, yylval.string);
3749 }
3750 };
3751
3752 gline_action: ACTION
3753 {
3754 if (ypass == 2)
3755 yy_aconf->flags = 0;
3756 } '=' gdeny_types ';'
3757 {
3758 if (ypass == 2)
3759 {
3760 struct CollectItem *yy_tmp = NULL;
3761 dlink_node *ptr, *next_ptr;
3762
3763 DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3764 {
3765 struct AccessItem *new_aconf;
3766 struct ConfItem *new_conf;
3767
3768 yy_tmp = ptr->data;
3769 new_conf = make_conf_item(GDENY_TYPE);
3770 new_aconf = map_to_conf(new_conf);
3771
3772 new_aconf->flags = yy_aconf->flags;
3773
3774 if (yy_conf->name != NULL)
3775 DupString(new_conf->name, yy_conf->name);
3776 else
3777 DupString(new_conf->name, "*");
3778 if (yy_aconf->user != NULL)
3779 DupString(new_aconf->user, yy_tmp->user);
3780 else
3781 DupString(new_aconf->user, "*");
3782 if (yy_aconf->host != NULL)
3783 DupString(new_aconf->host, yy_tmp->host);
3784 else
3785 DupString(new_aconf->host, "*");
3786
3787 dlinkDelete(&yy_tmp->node, &col_conf_list);
3788 }
3789
3790 /*
3791 * In case someone has fed us with more than one action= after user/name
3792 * which would leak memory -Michael
3793 */
3794 if (yy_conf->name == NULL || yy_aconf->user == NULL)
3795 delete_conf_item(yy_conf);
3796
3797 yy_conf = make_conf_item(GDENY_TYPE);
3798 yy_aconf = map_to_conf(yy_conf);
3799 }
3800 };
3801
3802 gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3803 gdeny_type_item: T_REJECT
3804 {
3805 if (ypass == 2)
3806 yy_aconf->flags |= GDENY_REJECT;
3807 } | T_BLOCK
3808 {
3809 if (ypass == 2)
3810 yy_aconf->flags |= GDENY_BLOCK;
3811 };
3812
3813 /***************************************************************************
3814 * section channel
3815 ***************************************************************************/
3816 channel_entry: CHANNEL
3817 '{' channel_items '}' ';';
3818
3819 channel_items: channel_items channel_item | channel_item;
3820 channel_item: channel_disable_local_channels | channel_use_except |
3821 channel_use_invex | channel_use_knock |
3822 channel_max_bans | channel_knock_delay |
3823 channel_knock_delay_channel | channel_max_chans_per_user |
3824 channel_quiet_on_ban | channel_default_split_user_count |
3825 channel_default_split_server_count |
3826 channel_no_create_on_split | channel_restrict_channels |
3827 channel_no_join_on_split | channel_burst_topicwho |
3828 channel_jflood_count | channel_jflood_time |
3829 error;
3830
3831 channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
3832 {
3833 ConfigChannel.restrict_channels = yylval.number;
3834 };
3835
3836 channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
3837 {
3838 ConfigChannel.disable_local_channels = yylval.number;
3839 };
3840
3841 channel_use_except: USE_EXCEPT '=' TBOOL ';'
3842 {
3843 ConfigChannel.use_except = yylval.number;
3844 };
3845
3846 channel_use_invex: USE_INVEX '=' TBOOL ';'
3847 {
3848 ConfigChannel.use_invex = yylval.number;
3849 };
3850
3851 channel_use_knock: USE_KNOCK '=' TBOOL ';'
3852 {
3853 ConfigChannel.use_knock = yylval.number;
3854 };
3855
3856 channel_knock_delay: KNOCK_DELAY '=' timespec ';'
3857 {
3858 ConfigChannel.knock_delay = $3;
3859 };
3860
3861 channel_knock_delay_channel: KNOCK_DELAY_CHANNEL '=' timespec ';'
3862 {
3863 ConfigChannel.knock_delay_channel = $3;
3864 };
3865
3866 channel_max_chans_per_user: MAX_CHANS_PER_USER '=' NUMBER ';'
3867 {
3868 ConfigChannel.max_chans_per_user = $3;
3869 };
3870
3871 channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
3872 {
3873 ConfigChannel.quiet_on_ban = yylval.number;
3874 };
3875
3876 channel_max_bans: MAX_BANS '=' NUMBER ';'
3877 {
3878 ConfigChannel.max_bans = $3;
3879 };
3880
3881 channel_default_split_user_count: DEFAULT_SPLIT_USER_COUNT '=' NUMBER ';'
3882 {
3883 ConfigChannel.default_split_user_count = $3;
3884 };
3885
3886 channel_default_split_server_count: DEFAULT_SPLIT_SERVER_COUNT '=' NUMBER ';'
3887 {
3888 ConfigChannel.default_split_server_count = $3;
3889 };
3890
3891 channel_no_create_on_split: NO_CREATE_ON_SPLIT '=' TBOOL ';'
3892 {
3893 ConfigChannel.no_create_on_split = yylval.number;
3894 };
3895
3896 channel_no_join_on_split: NO_JOIN_ON_SPLIT '=' TBOOL ';'
3897 {
3898 ConfigChannel.no_join_on_split = yylval.number;
3899 };
3900
3901 channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3902 {
3903 ConfigChannel.burst_topicwho = yylval.number;
3904 };
3905
3906 channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
3907 {
3908 GlobalSetOptions.joinfloodcount = yylval.number;
3909 };
3910
3911 channel_jflood_time: JOIN_FLOOD_TIME '=' timespec ';'
3912 {
3913 GlobalSetOptions.joinfloodtime = yylval.number;
3914 };
3915
3916 /***************************************************************************
3917 * section serverhide
3918 ***************************************************************************/
3919 serverhide_entry: SERVERHIDE
3920 '{' serverhide_items '}' ';';
3921
3922 serverhide_items: serverhide_items serverhide_item | serverhide_item;
3923 serverhide_item: serverhide_flatten_links | serverhide_hide_servers |
3924 serverhide_links_delay |
3925 serverhide_disable_hidden |
3926 serverhide_hidden | serverhide_hidden_name |
3927 serverhide_hide_server_ips |
3928 error;
3929
3930 serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
3931 {
3932 if (ypass == 2)
3933 ConfigServerHide.flatten_links = yylval.number;
3934 };
3935
3936 serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
3937 {
3938 if (ypass == 2)
3939 ConfigServerHide.hide_servers = yylval.number;
3940 };
3941
3942 serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
3943 {
3944 if (ypass == 2)
3945 {
3946 MyFree(ConfigServerHide.hidden_name);
3947 DupString(ConfigServerHide.hidden_name, yylval.string);
3948 }
3949 };
3950
3951 serverhide_links_delay: LINKS_DELAY '=' timespec ';'
3952 {
3953 if (ypass == 2)
3954 {
3955 if (($3 > 0) && ConfigServerHide.links_disabled == 1)
3956 {
3957 eventAddIsh("write_links_file", write_links_file, NULL, $3);
3958 ConfigServerHide.links_disabled = 0;
3959 }
3960
3961 ConfigServerHide.links_delay = $3;
3962 }
3963 };
3964
3965 serverhide_hidden: HIDDEN '=' TBOOL ';'
3966 {
3967 if (ypass == 2)
3968 ConfigServerHide.hidden = yylval.number;
3969 };
3970
3971 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3972 {
3973 if (ypass == 2)
3974 ConfigServerHide.disable_hidden = yylval.number;
3975 };
3976
3977 serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
3978 {
3979 if (ypass == 2)
3980 ConfigServerHide.hide_server_ips = yylval.number;
3981 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision