ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1076
Committed: Thu Feb 18 09:23:47 2010 UTC (14 years, 1 month ago) by michael
Original Path: ircd-hybrid-7.3/src/ircd_parser.y
File size: 88270 byte(s)
Log Message:
- Dropped support for old style 'operflag = yes|no;' configuration format

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

Properties

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