ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1547
Committed: Sun Sep 30 17:50:03 2012 UTC (11 years, 5 months ago) by michael
Original Path: ircd-hybrid-8/src/conf_parser.y
File size: 73699 byte(s)
Log Message:
- Removed general::use_whois_actually configuration directive. This is
  now enabled by default

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

Properties

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