ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.0beta2/src/conf_parser.y
Revision: 1715
Committed: Mon Dec 24 15:19:32 2012 UTC (13 years, 7 months ago) by michael
Original Path: ircd-hybrid/trunk/src/conf_parser.y
File size: 71362 byte(s)
Log Message:
- Improved WEBIRC authentication; added 'webirc' to auth::flags

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

Properties

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