ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1366
Committed: Tue Apr 24 18:35:34 2012 UTC (13 years, 4 months ago) by michael
Original Path: ircd-hybrid-8/src/conf_parser.y
File size: 81683 byte(s)
Log Message:
- Cleanup conf_add_server(). Remove traces of obsolete username verification
  for incoming server connections.

File Contents

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

Properties

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