ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1542
Committed: Sat Sep 29 20:31:35 2012 UTC (11 years, 6 months ago) by michael
Original Path: ircd-hybrid-8/src/conf_parser.y
File size: 73876 byte(s)
Log Message:
- Fixed an off-by-one with spoofs. Spoofs are now also checked for
  invalid characters.

File Contents

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

Properties

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