ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 876
Committed: Wed Oct 24 21:51:21 2007 UTC (16 years, 5 months ago) by michael
Original Path: ircd-hybrid-7.2/src/ircd_parser.y
File size: 90921 byte(s)
Log Message:
Backported WATCH

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

Properties

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