ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1250
Committed: Sat Oct 1 10:48:16 2011 UTC (12 years, 5 months ago) by michael
Original Path: ircd-hybrid-8/src/ircd_parser.y
File size: 84901 byte(s)
Log Message:
- A file size of 'unlimited' can now be specified for log files

File Contents

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

Properties

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