ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1752
Committed: Wed Jan 16 19:17:40 2013 UTC (13 years, 6 months ago) by michael
File size: 72841 byte(s)
Log Message:
- Forward-port -r1740 [Fixed yyerror() not reporting configuration errors
  in some cases]

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

Properties

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