ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/ircd_parser.y
Revision: 978
Committed: Sun Aug 9 09:47:58 2009 UTC (14 years, 8 months ago) by michael
Original Path: ircd-hybrid-7.2/src/ircd_parser.y
File size: 94339 byte(s)
Log Message:
- avoid using native basename() since some implementations may or may not modify passed data

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

Properties

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