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

Properties

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