ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1632
Committed: Sun Nov 4 15:37:10 2012 UTC (11 years, 4 months ago) by michael
File size: 71825 byte(s)
Log Message:
- Initial rewrite of the configuration subsystem

File Contents

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

Properties

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