ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1650
Committed: Sat Nov 10 20:57:51 2012 UTC (11 years, 4 months ago) by michael
File size: 70973 byte(s)
Log Message:
- Fixed few bugs that have been introduced with config rewrite
- Set some reasonable default values right after a class has been created

File Contents

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

Properties

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