ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/conf_parser.y
Revision: 1329
Committed: Sun Apr 1 12:02:12 2012 UTC (14 years, 6 months ago) by michael
File size: 81599 byte(s)
Log Message:
- Remove unused configure tests
- Fixed compile warning in conf_parser.c

File Contents

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

Properties

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