ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1389
Committed: Tue May 1 13:08:29 2012 UTC (11 years, 11 months ago) by michael
Original Path: ircd-hybrid-8/src/conf_parser.y
File size: 78547 byte(s)
Log Message:
- rename some struct AccessItem members

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

Properties

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