ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.1.x/src/conf_parser.y
Revision: 2184
Committed: Tue Jun 4 12:26:53 2013 UTC (10 years, 10 months ago) by michael
File size: 73679 byte(s)
Log Message:
- Removed usermode +C

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

Properties

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