ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1302
Committed: Wed Mar 21 17:48:54 2012 UTC (13 years, 5 months ago) by michael
Original Path: ircd-hybrid-8/src/ircd_parser.y
File size: 80018 byte(s)
Log Message:
- remove servlink in preparation for tls links/compression

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

Properties

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