ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/conf_parser.y
Revision: 1316
Committed: Tue Mar 27 17:05:51 2012 UTC (12 years ago) by michael
File size: 81755 byte(s)
Log Message:
- Removed 'ssl_server_protocol' configuration directive and
  added 'ssl_client_method' and 'ssl_server_method' instead.

  Both of these options can now be changed at runtime.

- src/Makefile.am: swapped order of conf_parser.y and conf_lexer.l
- Update example configuration files

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

Properties

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