ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1118
Committed: Thu Jan 6 13:39:10 2011 UTC (13 years, 2 months ago) by michael
Original Path: ircd-hybrid-7.3/src/ircd_parser.y
File size: 88075 byte(s)
Log Message:
- cleanup and sanitize m_server.c. remove hostmasking. Improve TS6 suppport

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 IRCD_FLAGS
184     %token FLATTEN_LINKS
185     %token FFAILED_OPERLOG
186     %token FKILLLOG
187     %token FKLINELOG
188     %token FGLINELOG
189     %token FIOERRLOG
190     %token FOPERLOG
191     %token FOPERSPYLOG
192     %token FUSERLOG
193     %token GECOS
194     %token GENERAL
195     %token GLINE
196     %token GLINES
197     %token GLINE_EXEMPT
198     %token GLINE_LOG
199     %token GLINE_TIME
200     %token GLINE_MIN_CIDR
201     %token GLINE_MIN_CIDR6
202     %token GLOBAL_KILL
203     %token IRCD_AUTH
204     %token NEED_IDENT
205     %token HAVENT_READ_CONF
206     %token HIDDEN
207     %token HIDDEN_ADMIN
208     %token HIDDEN_NAME
209     %token HIDDEN_OPER
210     %token HIDE_SERVER_IPS
211     %token HIDE_SERVERS
212     %token HIDE_SPOOF_IPS
213     %token HOST
214     %token HUB
215     %token HUB_MASK
216     %token IDLETIME
217     %token IGNORE_BOGUS_TS
218     %token INVISIBLE_ON_CONNECT
219     %token IP
220     %token KILL
221     %token KILL_CHASE_TIME_LIMIT
222     %token KLINE
223     %token KLINE_EXEMPT
224     %token KLINE_REASON
225     %token KLINE_WITH_REASON
226     %token KNOCK_DELAY
227     %token KNOCK_DELAY_CHANNEL
228     %token LEAF_MASK
229     %token LINKS_DELAY
230     %token LISTEN
231     %token T_LOG
232     %token LOGGING
233     %token LOG_LEVEL
234     %token MAX_ACCEPT
235     %token MAX_BANS
236     %token MAX_CHANS_PER_USER
237     %token MAX_GLOBAL
238     %token MAX_IDENT
239     %token MAX_LOCAL
240     %token MAX_NICK_CHANGES
241     %token MAX_NICK_TIME
242     %token MAX_NUMBER
243     %token MAX_TARGETS
244 michael 876 %token MAX_WATCH
245 adx 30 %token MESSAGE_LOCALE
246     %token MIN_NONWILDCARD
247     %token MIN_NONWILDCARD_SIMPLE
248     %token MODULE
249     %token MODULES
250     %token NAME
251     %token NEED_PASSWORD
252     %token NETWORK_DESC
253     %token NETWORK_NAME
254     %token NICK
255     %token NICK_CHANGES
256     %token NO_CREATE_ON_SPLIT
257     %token NO_JOIN_ON_SPLIT
258     %token NO_OPER_FLOOD
259     %token NO_TILDE
260     %token NOT
261     %token NUMBER
262     %token NUMBER_PER_IDENT
263     %token NUMBER_PER_CIDR
264     %token NUMBER_PER_IP
265     %token NUMBER_PER_IP_GLOBAL
266     %token OPERATOR
267     %token OPERS_BYPASS_CALLERID
268     %token OPER_LOG
269     %token OPER_ONLY_UMODES
270     %token OPER_PASS_RESV
271     %token OPER_SPY_T
272     %token OPER_UMODES
273     %token JOIN_FLOOD_COUNT
274     %token JOIN_FLOOD_TIME
275     %token PACE_WAIT
276     %token PACE_WAIT_SIMPLE
277     %token PASSWORD
278     %token PATH
279     %token PING_COOKIE
280     %token PING_TIME
281     %token PING_WARNING
282     %token PORT
283     %token QSTRING
284     %token QUIET_ON_BAN
285     %token REASON
286     %token REDIRPORT
287     %token REDIRSERV
288     %token REGEX_T
289     %token REHASH
290     %token TREJECT_HOLD_TIME
291     %token REMOTE
292     %token REMOTEBAN
293     %token RESTRICT_CHANNELS
294     %token RESTRICTED
295     %token RSA_PRIVATE_KEY_FILE
296     %token RSA_PUBLIC_KEY_FILE
297     %token SSL_CERTIFICATE_FILE
298 michael 967 %token T_SSL_CONNECTION_METHOD
299     %token T_SSLV3
300     %token T_TLSV1
301 adx 30 %token RESV
302     %token RESV_EXEMPT
303     %token SECONDS MINUTES HOURS DAYS WEEKS
304     %token SENDQ
305     %token SEND_PASSWORD
306     %token SERVERHIDE
307     %token SERVERINFO
308     %token SERVLINK_PATH
309     %token IRCD_SID
310     %token TKLINE_EXPIRE_NOTICES
311     %token T_SHARED
312     %token T_CLUSTER
313     %token TYPE
314     %token SHORT_MOTD
315     %token SILENT
316     %token SPOOF
317     %token SPOOF_NOTICE
318 michael 584 %token STATS_E_DISABLED
319 adx 30 %token STATS_I_OPER_ONLY
320     %token STATS_K_OPER_ONLY
321     %token STATS_O_OPER_ONLY
322     %token STATS_P_OPER_ONLY
323     %token TBOOL
324     %token TMASKED
325     %token T_REJECT
326     %token TS_MAX_DELTA
327     %token TS_WARN_DELTA
328     %token TWODOTS
329     %token T_ALL
330     %token T_BOTS
331     %token T_SOFTCALLERID
332     %token T_CALLERID
333     %token T_CCONN
334 db 849 %token T_CCONN_FULL
335 adx 30 %token T_CLIENT_FLOOD
336     %token T_DEAF
337     %token T_DEBUG
338     %token T_DRONE
339     %token T_EXTERNAL
340     %token T_FULL
341     %token T_INVISIBLE
342     %token T_IPV4
343     %token T_IPV6
344     %token T_LOCOPS
345     %token T_LOGPATH
346     %token T_L_CRIT
347     %token T_L_DEBUG
348     %token T_L_ERROR
349     %token T_L_INFO
350     %token T_L_NOTICE
351     %token T_L_TRACE
352     %token T_L_WARN
353     %token T_MAX_CLIENTS
354     %token T_NCHANGE
355     %token T_OPERWALL
356     %token T_REJ
357 michael 900 %token T_SERVER
358 adx 30 %token T_SERVNOTICE
359     %token T_SKILL
360     %token T_SPY
361     %token T_SSL
362 michael 56 %token T_UMODES
363 adx 30 %token T_UNAUTH
364     %token T_UNRESV
365     %token T_UNXLINE
366     %token T_WALLOP
367     %token THROTTLE_TIME
368     %token TOPICBURST
369     %token TRUE_NO_OPER_FLOOD
370     %token TKLINE
371     %token TXLINE
372     %token TRESV
373     %token UNKLINE
374     %token USER
375     %token USE_EGD
376     %token USE_EXCEPT
377     %token USE_INVEX
378     %token USE_KNOCK
379     %token USE_LOGGING
380     %token USE_WHOIS_ACTUALLY
381     %token VHOST
382     %token VHOST6
383     %token XLINE
384     %token WARN
385     %token WARN_NO_NLINE
386    
387     %type <string> QSTRING
388     %type <number> NUMBER
389     %type <number> timespec
390     %type <number> timespec_
391     %type <number> sizespec
392     %type <number> sizespec_
393    
394     %%
395     conf:
396     | conf conf_item
397     ;
398    
399     conf_item: admin_entry
400     | logging_entry
401     | oper_entry
402     | channel_entry
403     | class_entry
404     | listen_entry
405     | auth_entry
406     | serverinfo_entry
407     | serverhide_entry
408     | resv_entry
409     | shared_entry
410     | cluster_entry
411     | connect_entry
412     | kill_entry
413     | deny_entry
414     | exempt_entry
415     | general_entry
416     | gline_entry
417     | gecos_entry
418     | modules_entry
419     | error ';'
420     | error '}'
421     ;
422    
423    
424     timespec_: { $$ = 0; } | timespec;
425     timespec: NUMBER timespec_
426     {
427     $$ = $1 + $2;
428     }
429     | NUMBER SECONDS timespec_
430     {
431     $$ = $1 + $3;
432     }
433     | NUMBER MINUTES timespec_
434     {
435     $$ = $1 * 60 + $3;
436     }
437     | NUMBER HOURS timespec_
438     {
439     $$ = $1 * 60 * 60 + $3;
440     }
441     | NUMBER DAYS timespec_
442     {
443     $$ = $1 * 60 * 60 * 24 + $3;
444     }
445     | NUMBER WEEKS timespec_
446     {
447     $$ = $1 * 60 * 60 * 24 * 7 + $3;
448     }
449     ;
450    
451     sizespec_: { $$ = 0; } | sizespec;
452     sizespec: NUMBER sizespec_ { $$ = $1 + $2; }
453     | NUMBER BYTES sizespec_ { $$ = $1 + $3; }
454     | NUMBER KBYTES sizespec_ { $$ = $1 * 1024 + $3; }
455     | NUMBER MBYTES sizespec_ { $$ = $1 * 1024 * 1024 + $3; }
456     ;
457    
458    
459     /***************************************************************************
460     * section modules
461     ***************************************************************************/
462     modules_entry: MODULES
463     '{' modules_items '}' ';';
464    
465     modules_items: modules_items modules_item | modules_item;
466     modules_item: modules_module | modules_path | error ';' ;
467    
468     modules_module: MODULE '=' QSTRING ';'
469     {
470     #ifndef STATIC_MODULES /* NOOP in the static case */
471 michael 967 if (conf_parser_ctx.pass == 2)
472 michael 978 add_conf_module(libio_basename(yylval.string));
473 adx 30 #endif
474     };
475    
476     modules_path: PATH '=' QSTRING ';'
477     {
478     #ifndef STATIC_MODULES
479 michael 967 if (conf_parser_ctx.pass == 2)
480 adx 30 mod_add_path(yylval.string);
481     #endif
482     };
483    
484    
485 michael 967 serverinfo_entry: SERVERINFO '{' serverinfo_items '}' ';';
486    
487     serverinfo_items: serverinfo_items serverinfo_item | serverinfo_item ;
488 adx 30 serverinfo_item: serverinfo_name | serverinfo_vhost |
489     serverinfo_hub | serverinfo_description |
490     serverinfo_network_name | serverinfo_network_desc |
491     serverinfo_max_clients |
492     serverinfo_rsa_private_key_file | serverinfo_vhost6 |
493     serverinfo_sid | serverinfo_ssl_certificate_file |
494 michael 967 serverinfo_ssl_connection_method |
495 adx 30 error ';' ;
496    
497 michael 967
498     serverinfo_ssl_connection_method: T_SSL_CONNECTION_METHOD
499     {
500 michael 1024 #ifdef HAVE_LIBCRYPTO
501 michael 967 if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
502     ServerInfo.tls_version = 0;
503 michael 1024 #endif
504 michael 967 } '=' method_types ';'
505     {
506 michael 1024 #ifdef HAVE_LIBCRYPTO
507 michael 967 if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
508     {
509     if (!(ServerInfo.tls_version & CONF_SERVER_INFO_TLS_VERSION_SSLV3))
510     SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
511     if (!(ServerInfo.tls_version & CONF_SERVER_INFO_TLS_VERSION_TLSV1))
512     SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
513     }
514 michael 1024 #endif
515 michael 967 };
516    
517     method_types: method_types ',' method_type_item | method_type_item;
518     method_type_item: T_SSLV3
519     {
520 michael 1024 #ifdef HAVE_LIBCRYPTO
521 michael 967 if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
522     ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_SSLV3;
523 michael 1024 #endif
524 michael 967 } | T_TLSV1
525     {
526 michael 1024 #ifdef HAVE_LIBCRYPTO
527 michael 967 if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
528     ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_TLSV1;
529 michael 1024 #endif
530 michael 967 };
531    
532 adx 30 serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
533     {
534     #ifdef HAVE_LIBCRYPTO
535 michael 967 if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
536 adx 30 {
537     if (!ServerInfo.rsa_private_key_file)
538     {
539     yyerror("No rsa_private_key_file specified, SSL disabled");
540     break;
541     }
542    
543 michael 967 if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
544     SSL_FILETYPE_PEM) <= 0)
545 adx 30 {
546     yyerror(ERR_lib_error_string(ERR_get_error()));
547     break;
548     }
549    
550 michael 967 if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
551     SSL_FILETYPE_PEM) <= 0)
552 adx 30 {
553     yyerror(ERR_lib_error_string(ERR_get_error()));
554     break;
555     }
556    
557 michael 967 if (!SSL_CTX_check_private_key(ServerInfo.server_ctx))
558 adx 30 {
559 michael 967 yyerror(ERR_lib_error_string(ERR_get_error()));
560 adx 30 break;
561     }
562     }
563     #endif
564     };
565    
566     serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
567     {
568     #ifdef HAVE_LIBCRYPTO
569 michael 967 if (conf_parser_ctx.pass == 1)
570 adx 30 {
571     BIO *file;
572    
573     if (ServerInfo.rsa_private_key)
574     {
575     RSA_free(ServerInfo.rsa_private_key);
576     ServerInfo.rsa_private_key = NULL;
577     }
578    
579     if (ServerInfo.rsa_private_key_file)
580     {
581     MyFree(ServerInfo.rsa_private_key_file);
582     ServerInfo.rsa_private_key_file = NULL;
583     }
584    
585     DupString(ServerInfo.rsa_private_key_file, yylval.string);
586    
587     if ((file = BIO_new_file(yylval.string, "r")) == NULL)
588     {
589     yyerror("File open failed, ignoring");
590     break;
591     }
592    
593     ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
594     0, NULL);
595    
596     BIO_set_close(file, BIO_CLOSE);
597     BIO_free(file);
598    
599     if (ServerInfo.rsa_private_key == NULL)
600     {
601     yyerror("Couldn't extract key, ignoring");
602     break;
603     }
604    
605     if (!RSA_check_key(ServerInfo.rsa_private_key))
606     {
607     RSA_free(ServerInfo.rsa_private_key);
608     ServerInfo.rsa_private_key = NULL;
609    
610     yyerror("Invalid key, ignoring");
611     break;
612     }
613    
614     /* require 2048 bit (256 byte) key */
615     if (RSA_size(ServerInfo.rsa_private_key) != 256)
616     {
617     RSA_free(ServerInfo.rsa_private_key);
618     ServerInfo.rsa_private_key = NULL;
619    
620     yyerror("Not a 2048 bit key, ignoring");
621     }
622     }
623     #endif
624     };
625    
626     serverinfo_name: NAME '=' QSTRING ';'
627     {
628     /* this isn't rehashable */
629 michael 1117 if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
630 adx 30 {
631 michael 1117 if (valid_servname(yylval.string))
632     DupString(ServerInfo.name, yylval.string);
633     else
634 adx 30 {
635 michael 1117 ilog(L_ERROR, "Ignoring serverinfo::name -- invalid name. Aborting.");
636     exit(0);
637 adx 30 }
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 michael 1117 ilog(L_ERROR, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
651 adx 30 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 1118 connect_aftype | connect_port |
2310 michael 1076 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_flags: IRCD_FLAGS
2429     {
2430     } '=' connect_flags_items ';';
2431    
2432     connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2433 db 136 connect_flags_item: NOT { not_atom = 1; } connect_flags_item_atom
2434     | { not_atom = 0; } connect_flags_item_atom;
2435 adx 30
2436 michael 885 connect_flags_item_atom: COMPRESSED
2437 adx 30 {
2438 michael 967 if (conf_parser_ctx.pass == 2)
2439 adx 30 #ifndef HAVE_LIBZ
2440     yyerror("Ignoring flags = compressed; -- no zlib support");
2441     #else
2442     {
2443     if (not_atom)ClearConfCompressed(yy_aconf);
2444     else SetConfCompressed(yy_aconf);
2445     }
2446     #endif
2447     } | CRYPTLINK
2448     {
2449 michael 967 if (conf_parser_ctx.pass == 2)
2450 adx 30 {
2451     if (not_atom)ClearConfCryptLink(yy_aconf);
2452     else SetConfCryptLink(yy_aconf);
2453     }
2454     } | AUTOCONN
2455     {
2456 michael 967 if (conf_parser_ctx.pass == 2)
2457 adx 30 {
2458     if (not_atom)ClearConfAllowAutoConn(yy_aconf);
2459     else SetConfAllowAutoConn(yy_aconf);
2460     }
2461     } | BURST_AWAY
2462     {
2463 michael 967 if (conf_parser_ctx.pass == 2)
2464 adx 30 {
2465     if (not_atom)ClearConfAwayBurst(yy_aconf);
2466     else SetConfAwayBurst(yy_aconf);
2467     }
2468     } | TOPICBURST
2469     {
2470 michael 967 if (conf_parser_ctx.pass == 2)
2471 adx 30 {
2472     if (not_atom)ClearConfTopicBurst(yy_aconf);
2473     else SetConfTopicBurst(yy_aconf);
2474     }
2475     }
2476     ;
2477    
2478     connect_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
2479     {
2480     #ifdef HAVE_LIBCRYPTO
2481 michael 967 if (conf_parser_ctx.pass == 2)
2482 adx 30 {
2483     BIO *file;
2484    
2485     if (yy_aconf->rsa_public_key != NULL)
2486     {
2487     RSA_free(yy_aconf->rsa_public_key);
2488     yy_aconf->rsa_public_key = NULL;
2489     }
2490    
2491     if (yy_aconf->rsa_public_key_file != NULL)
2492     {
2493     MyFree(yy_aconf->rsa_public_key_file);
2494     yy_aconf->rsa_public_key_file = NULL;
2495     }
2496    
2497     DupString(yy_aconf->rsa_public_key_file, yylval.string);
2498    
2499     if ((file = BIO_new_file(yylval.string, "r")) == NULL)
2500     {
2501     yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
2502     break;
2503     }
2504    
2505     yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
2506    
2507     if (yy_aconf->rsa_public_key == NULL)
2508     {
2509     yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
2510     break;
2511     }
2512    
2513     BIO_set_close(file, BIO_CLOSE);
2514     BIO_free(file);
2515     }
2516     #endif /* HAVE_LIBCRYPTO */
2517     };
2518    
2519     connect_encrypted: ENCRYPTED '=' TBOOL ';'
2520     {
2521 michael 967 if (conf_parser_ctx.pass == 2)
2522 adx 30 {
2523     if (yylval.number)
2524     yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2525     else
2526     yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2527     }
2528     };
2529    
2530     connect_hub_mask: HUB_MASK '=' QSTRING ';'
2531     {
2532 michael 967 if (conf_parser_ctx.pass == 2)
2533 adx 30 {
2534     struct CollectItem *yy_tmp;
2535    
2536     yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2537     DupString(yy_tmp->host, yylval.string);
2538     DupString(yy_tmp->user, "*");
2539     dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2540     }
2541     };
2542    
2543     connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2544     {
2545 michael 967 if (conf_parser_ctx.pass == 2)
2546 adx 30 {
2547     struct CollectItem *yy_tmp;
2548    
2549     yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2550     DupString(yy_tmp->host, yylval.string);
2551     DupString(yy_tmp->user, "*");
2552     dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2553     }
2554     };
2555    
2556     connect_class: CLASS '=' QSTRING ';'
2557     {
2558 michael 967 if (conf_parser_ctx.pass == 2)
2559 adx 30 {
2560     MyFree(class_name);
2561     DupString(class_name, yylval.string);
2562     }
2563     };
2564    
2565     connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2566     {
2567     #ifdef HAVE_LIBCRYPTO
2568 michael 967 if (conf_parser_ctx.pass == 2)
2569 adx 30 {
2570     struct EncCapability *ecap;
2571     const char *cipher_name;
2572     int found = 0;
2573    
2574     yy_aconf->cipher_preference = NULL;
2575     cipher_name = yylval.string;
2576    
2577     for (ecap = CipherTable; ecap->name; ecap++)
2578     {
2579     if ((irccmp(ecap->name, cipher_name) == 0) &&
2580     (ecap->cap & CAP_ENC_MASK))
2581     {
2582     yy_aconf->cipher_preference = ecap;
2583     found = 1;
2584     break;
2585     }
2586     }
2587    
2588     if (!found)
2589     yyerror("Invalid cipher");
2590     }
2591     #else
2592 michael 967 if (conf_parser_ctx.pass == 2)
2593 adx 30 yyerror("Ignoring cipher_preference -- no OpenSSL support");
2594     #endif
2595     };
2596    
2597     /***************************************************************************
2598     * section kill
2599     ***************************************************************************/
2600     kill_entry: KILL
2601     {
2602 michael 967 if (conf_parser_ctx.pass == 2)
2603 adx 30 {
2604     userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2605     regex_ban = 0;
2606     }
2607     } '{' kill_items '}' ';'
2608     {
2609 michael 967 if (conf_parser_ctx.pass == 2)
2610 adx 30 {
2611     if (userbuf[0] && hostbuf[0])
2612     {
2613     if (regex_ban)
2614     {
2615 michael 1009 #ifdef HAVE_LIBPCRE
2616     void *exp_user = NULL;
2617     void *exp_host = NULL;
2618 adx 30 const char *errptr = NULL;
2619    
2620     if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2621     !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2622     {
2623 michael 595 ilog(L_ERROR, "Failed to add regular expression based K-Line: %s",
2624     errptr);
2625 adx 30 break;
2626     }
2627    
2628 michael 1005 yy_aconf = map_to_conf(make_conf_item(RKLINE_TYPE));
2629 adx 30 yy_aconf->regexuser = exp_user;
2630     yy_aconf->regexhost = exp_host;
2631    
2632     DupString(yy_aconf->user, userbuf);
2633     DupString(yy_aconf->host, hostbuf);
2634    
2635     if (reasonbuf[0])
2636     DupString(yy_aconf->reason, reasonbuf);
2637     else
2638     DupString(yy_aconf->reason, "No reason");
2639 michael 1009 #else
2640     ilog(L_ERROR, "Failed to add regular expression based K-Line: no PCRE support");
2641     break;
2642     #endif
2643 adx 30 }
2644     else
2645     {
2646 michael 1005 yy_aconf = map_to_conf(make_conf_item(KLINE_TYPE));
2647 adx 30
2648     DupString(yy_aconf->user, userbuf);
2649     DupString(yy_aconf->host, hostbuf);
2650    
2651     if (reasonbuf[0])
2652     DupString(yy_aconf->reason, reasonbuf);
2653     else
2654     DupString(yy_aconf->reason, "No reason");
2655     add_conf_by_address(CONF_KILL, yy_aconf);
2656     }
2657     }
2658    
2659     yy_aconf = NULL;
2660     }
2661     };
2662    
2663     kill_type: TYPE
2664     {
2665     } '=' kill_type_items ';';
2666    
2667     kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2668     kill_type_item: REGEX_T
2669     {
2670 michael 967 if (conf_parser_ctx.pass == 2)
2671 adx 30 regex_ban = 1;
2672     };
2673    
2674     kill_items: kill_items kill_item | kill_item;
2675     kill_item: kill_user | kill_reason | kill_type | error;
2676    
2677     kill_user: USER '=' QSTRING ';'
2678     {
2679 michael 967 if (conf_parser_ctx.pass == 2)
2680 adx 30 {
2681 michael 593 struct split_nuh_item nuh;
2682 adx 30
2683 michael 593 nuh.nuhmask = yylval.string;
2684     nuh.nickptr = NULL;
2685     nuh.userptr = userbuf;
2686     nuh.hostptr = hostbuf;
2687 adx 30
2688 michael 593 nuh.nicksize = 0;
2689     nuh.usersize = sizeof(userbuf);
2690     nuh.hostsize = sizeof(hostbuf);
2691 adx 30
2692 michael 593 split_nuh(&nuh);
2693 adx 30 }
2694     };
2695    
2696     kill_reason: REASON '=' QSTRING ';'
2697     {
2698 michael 967 if (conf_parser_ctx.pass == 2)
2699 adx 30 strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2700     };
2701    
2702     /***************************************************************************
2703     * section deny
2704     ***************************************************************************/
2705     deny_entry: DENY
2706     {
2707 michael 967 if (conf_parser_ctx.pass == 2)
2708 michael 1005 hostbuf[0] = reasonbuf[0] = '\0';
2709 adx 30 } '{' deny_items '}' ';'
2710     {
2711 michael 967 if (conf_parser_ctx.pass == 2)
2712 adx 30 {
2713 michael 1005 if (hostbuf[0] && parse_netmask(hostbuf, NULL, NULL) != HM_HOST)
2714     {
2715     yy_aconf = map_to_conf(make_conf_item(DLINE_TYPE));
2716     DupString(yy_aconf->host, hostbuf);
2717    
2718     if (reasonbuf[0])
2719     DupString(yy_aconf->reason, reasonbuf);
2720     else
2721     DupString(yy_aconf->reason, "No reason");
2722 adx 30 add_conf_by_address(CONF_DLINE, yy_aconf);
2723 michael 1005 yy_aconf = NULL;
2724     }
2725 adx 30 }
2726     };
2727    
2728     deny_items: deny_items deny_item | deny_item;
2729     deny_item: deny_ip | deny_reason | error;
2730    
2731     deny_ip: IP '=' QSTRING ';'
2732     {
2733 michael 967 if (conf_parser_ctx.pass == 2)
2734 michael 1005 strlcpy(hostbuf, yylval.string, sizeof(hostbuf));
2735 adx 30 };
2736    
2737     deny_reason: REASON '=' QSTRING ';'
2738     {
2739 michael 967 if (conf_parser_ctx.pass == 2)
2740 michael 1005 strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2741 adx 30 };
2742    
2743     /***************************************************************************
2744     * section exempt
2745     ***************************************************************************/
2746     exempt_entry: EXEMPT '{' exempt_items '}' ';';
2747    
2748     exempt_items: exempt_items exempt_item | exempt_item;
2749     exempt_item: exempt_ip | error;
2750    
2751     exempt_ip: IP '=' QSTRING ';'
2752     {
2753 michael 967 if (conf_parser_ctx.pass == 2)
2754 adx 30 {
2755     if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2756     {
2757 michael 1005 yy_aconf = map_to_conf(make_conf_item(EXEMPTDLINE_TYPE));
2758 adx 30 DupString(yy_aconf->host, yylval.string);
2759    
2760     add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
2761     yy_aconf = NULL;
2762     }
2763     }
2764     };
2765    
2766     /***************************************************************************
2767     * section gecos
2768     ***************************************************************************/
2769     gecos_entry: GECOS
2770     {
2771 michael 967 if (conf_parser_ctx.pass == 2)
2772 adx 30 {
2773     regex_ban = 0;
2774     reasonbuf[0] = gecos_name[0] = '\0';
2775     }
2776     } '{' gecos_items '}' ';'
2777     {
2778 michael 967 if (conf_parser_ctx.pass == 2)
2779 adx 30 {
2780     if (gecos_name[0])
2781     {
2782     if (regex_ban)
2783     {
2784 michael 1009 #ifdef HAVE_LIBPCRE
2785     void *exp_p = NULL;
2786 adx 30 const char *errptr = NULL;
2787    
2788     if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2789     {
2790 michael 595 ilog(L_ERROR, "Failed to add regular expression based X-Line: %s",
2791     errptr);
2792 adx 30 break;
2793     }
2794    
2795     yy_conf = make_conf_item(RXLINE_TYPE);
2796     yy_conf->regexpname = exp_p;
2797 michael 1009 #else
2798     ilog(L_ERROR, "Failed to add regular expression based X-Line: no PCRE support");
2799     break;
2800     #endif
2801 adx 30 }
2802     else
2803     yy_conf = make_conf_item(XLINE_TYPE);
2804    
2805     yy_match_item = map_to_conf(yy_conf);
2806     DupString(yy_conf->name, gecos_name);
2807    
2808     if (reasonbuf[0])
2809     DupString(yy_match_item->reason, reasonbuf);
2810     else
2811     DupString(yy_match_item->reason, "No reason");
2812     }
2813     }
2814     };
2815    
2816     gecos_flags: TYPE
2817     {
2818     } '=' gecos_flags_items ';';
2819    
2820     gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2821     gecos_flags_item: REGEX_T
2822     {
2823 michael 967 if (conf_parser_ctx.pass == 2)
2824 adx 30 regex_ban = 1;
2825     };
2826    
2827     gecos_items: gecos_items gecos_item | gecos_item;
2828     gecos_item: gecos_name | gecos_reason | gecos_flags | error;
2829    
2830     gecos_name: NAME '=' QSTRING ';'
2831     {
2832 michael 967 if (conf_parser_ctx.pass == 2)
2833 adx 30 strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2834     };
2835    
2836     gecos_reason: REASON '=' QSTRING ';'
2837     {
2838 michael 967 if (conf_parser_ctx.pass == 2)
2839 adx 30 strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2840     };
2841    
2842     /***************************************************************************
2843     * section general
2844     ***************************************************************************/
2845     general_entry: GENERAL
2846     '{' general_items '}' ';';
2847    
2848     general_items: general_items general_item | general_item;
2849     general_item: general_hide_spoof_ips | general_ignore_bogus_ts |
2850     general_failed_oper_notice | general_anti_nick_flood |
2851     general_max_nick_time | general_max_nick_changes |
2852     general_max_accept | general_anti_spam_exit_message_time |
2853     general_ts_warn_delta | general_ts_max_delta |
2854     general_kill_chase_time_limit | general_kline_with_reason |
2855     general_kline_reason | general_invisible_on_connect |
2856     general_warn_no_nline | general_dots_in_ident |
2857     general_stats_o_oper_only | general_stats_k_oper_only |
2858     general_pace_wait | general_stats_i_oper_only |
2859     general_pace_wait_simple | general_stats_P_oper_only |
2860     general_short_motd | general_no_oper_flood |
2861     general_true_no_oper_flood | general_oper_pass_resv |
2862     general_idletime | general_message_locale |
2863     general_oper_only_umodes | general_max_targets |
2864     general_use_egd | general_egdpool_path |
2865     general_oper_umodes | general_caller_id_wait |
2866     general_opers_bypass_callerid | general_default_floodcount |
2867     general_min_nonwildcard | general_min_nonwildcard_simple |
2868     general_servlink_path | general_disable_remote_commands |
2869     general_default_cipher_preference |
2870     general_compression_level | general_client_flood |
2871     general_throttle_time | general_havent_read_conf |
2872 michael 1072 general_ping_cookie |
2873 adx 30 general_disable_auth | general_burst_away |
2874     general_tkline_expire_notices | general_gline_min_cidr |
2875     general_gline_min_cidr6 | general_use_whois_actually |
2876 michael 584 general_reject_hold_time | general_stats_e_disabled |
2877 michael 876 general_max_watch |
2878 adx 30 error;
2879    
2880    
2881 michael 876 general_max_watch: MAX_WATCH '=' NUMBER ';'
2882     {
2883     ConfigFileEntry.max_watch = $3;
2884     };
2885 adx 30
2886     general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2887     {
2888     ConfigFileEntry.gline_min_cidr = $3;
2889     };
2890    
2891     general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2892     {
2893     ConfigFileEntry.gline_min_cidr6 = $3;
2894     };
2895    
2896     general_burst_away: BURST_AWAY '=' TBOOL ';'
2897     {
2898     ConfigFileEntry.burst_away = yylval.number;
2899     };
2900    
2901     general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2902     {
2903     ConfigFileEntry.use_whois_actually = yylval.number;
2904     };
2905    
2906     general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2907     {
2908     GlobalSetOptions.rejecttime = yylval.number;
2909     };
2910    
2911     general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
2912     {
2913     ConfigFileEntry.tkline_expire_notices = yylval.number;
2914     };
2915    
2916 michael 1074 general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' timespec ';'
2917 adx 30 {
2918     ConfigFileEntry.kill_chase_time_limit = $3;
2919     };
2920    
2921     general_hide_spoof_ips: HIDE_SPOOF_IPS '=' TBOOL ';'
2922     {
2923     ConfigFileEntry.hide_spoof_ips = yylval.number;
2924     };
2925    
2926     general_ignore_bogus_ts: IGNORE_BOGUS_TS '=' TBOOL ';'
2927     {
2928     ConfigFileEntry.ignore_bogus_ts = yylval.number;
2929     };
2930    
2931     general_disable_remote_commands: DISABLE_REMOTE_COMMANDS '=' TBOOL ';'
2932     {
2933     ConfigFileEntry.disable_remote = yylval.number;
2934     };
2935    
2936     general_failed_oper_notice: FAILED_OPER_NOTICE '=' TBOOL ';'
2937     {
2938     ConfigFileEntry.failed_oper_notice = yylval.number;
2939     };
2940    
2941     general_anti_nick_flood: ANTI_NICK_FLOOD '=' TBOOL ';'
2942     {
2943     ConfigFileEntry.anti_nick_flood = yylval.number;
2944     };
2945    
2946     general_max_nick_time: MAX_NICK_TIME '=' timespec ';'
2947     {
2948     ConfigFileEntry.max_nick_time = $3;
2949     };
2950    
2951     general_max_nick_changes: MAX_NICK_CHANGES '=' NUMBER ';'
2952     {
2953     ConfigFileEntry.max_nick_changes = $3;
2954     };
2955    
2956     general_max_accept: MAX_ACCEPT '=' NUMBER ';'
2957     {
2958     ConfigFileEntry.max_accept = $3;
2959     };
2960    
2961     general_anti_spam_exit_message_time: ANTI_SPAM_EXIT_MESSAGE_TIME '=' timespec ';'
2962     {
2963     ConfigFileEntry.anti_spam_exit_message_time = $3;
2964     };
2965    
2966     general_ts_warn_delta: TS_WARN_DELTA '=' timespec ';'
2967     {
2968     ConfigFileEntry.ts_warn_delta = $3;
2969     };
2970    
2971     general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
2972     {
2973 michael 967 if (conf_parser_ctx.pass == 2)
2974 adx 30 ConfigFileEntry.ts_max_delta = $3;
2975     };
2976    
2977     general_havent_read_conf: HAVENT_READ_CONF '=' NUMBER ';'
2978     {
2979 michael 967 if (($3 > 0) && conf_parser_ctx.pass == 1)
2980 adx 30 {
2981     ilog(L_CRIT, "You haven't read your config file properly.");
2982     ilog(L_CRIT, "There is a line in the example conf that will kill your server if not removed.");
2983     ilog(L_CRIT, "Consider actually reading/editing the conf file, and removing this line.");
2984     exit(0);
2985     }
2986     };
2987    
2988     general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
2989     {
2990     ConfigFileEntry.kline_with_reason = yylval.number;
2991     };
2992    
2993     general_kline_reason: KLINE_REASON '=' QSTRING ';'
2994     {
2995 michael 967 if (conf_parser_ctx.pass == 2)
2996 adx 30 {
2997     MyFree(ConfigFileEntry.kline_reason);
2998     DupString(ConfigFileEntry.kline_reason, yylval.string);
2999     }
3000     };
3001    
3002     general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
3003     {
3004     ConfigFileEntry.invisible_on_connect = yylval.number;
3005     };
3006    
3007     general_warn_no_nline: WARN_NO_NLINE '=' TBOOL ';'
3008     {
3009     ConfigFileEntry.warn_no_nline = yylval.number;
3010     };
3011    
3012 michael 584 general_stats_e_disabled: STATS_E_DISABLED '=' TBOOL ';'
3013     {
3014     ConfigFileEntry.stats_e_disabled = yylval.number;
3015     };
3016    
3017 adx 30 general_stats_o_oper_only: STATS_O_OPER_ONLY '=' TBOOL ';'
3018     {
3019     ConfigFileEntry.stats_o_oper_only = yylval.number;
3020     };
3021    
3022     general_stats_P_oper_only: STATS_P_OPER_ONLY '=' TBOOL ';'
3023     {
3024     ConfigFileEntry.stats_P_oper_only = yylval.number;
3025     };
3026    
3027     general_stats_k_oper_only: STATS_K_OPER_ONLY '=' TBOOL ';'
3028     {
3029     ConfigFileEntry.stats_k_oper_only = 2 * yylval.number;
3030     } | STATS_K_OPER_ONLY '=' TMASKED ';'
3031     {
3032     ConfigFileEntry.stats_k_oper_only = 1;
3033     };
3034    
3035     general_stats_i_oper_only: STATS_I_OPER_ONLY '=' TBOOL ';'
3036     {
3037     ConfigFileEntry.stats_i_oper_only = 2 * yylval.number;
3038     } | STATS_I_OPER_ONLY '=' TMASKED ';'
3039     {
3040     ConfigFileEntry.stats_i_oper_only = 1;
3041     };
3042    
3043     general_pace_wait: PACE_WAIT '=' timespec ';'
3044     {
3045     ConfigFileEntry.pace_wait = $3;
3046     };
3047    
3048     general_caller_id_wait: CALLER_ID_WAIT '=' timespec ';'
3049     {
3050     ConfigFileEntry.caller_id_wait = $3;
3051     };
3052    
3053     general_opers_bypass_callerid: OPERS_BYPASS_CALLERID '=' TBOOL ';'
3054     {
3055     ConfigFileEntry.opers_bypass_callerid = yylval.number;
3056     };
3057    
3058     general_pace_wait_simple: PACE_WAIT_SIMPLE '=' timespec ';'
3059     {
3060     ConfigFileEntry.pace_wait_simple = $3;
3061     };
3062    
3063     general_short_motd: SHORT_MOTD '=' TBOOL ';'
3064     {
3065     ConfigFileEntry.short_motd = yylval.number;
3066     };
3067    
3068     general_no_oper_flood: NO_OPER_FLOOD '=' TBOOL ';'
3069     {
3070     ConfigFileEntry.no_oper_flood = yylval.number;
3071     };
3072    
3073     general_true_no_oper_flood: TRUE_NO_OPER_FLOOD '=' TBOOL ';'
3074     {
3075     ConfigFileEntry.true_no_oper_flood = yylval.number;
3076     };
3077    
3078     general_oper_pass_resv: OPER_PASS_RESV '=' TBOOL ';'
3079     {
3080     ConfigFileEntry.oper_pass_resv = yylval.number;
3081     };
3082    
3083     general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
3084     {
3085 michael 967 if (conf_parser_ctx.pass == 2)
3086 adx 30 {
3087     if (strlen(yylval.string) > LOCALE_LENGTH-2)
3088     yylval.string[LOCALE_LENGTH-1] = '\0';
3089    
3090     set_locale(yylval.string);
3091     }
3092     };
3093    
3094     general_idletime: IDLETIME '=' timespec ';'
3095     {
3096     ConfigFileEntry.idletime = $3;
3097     };
3098    
3099     general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
3100     {
3101     ConfigFileEntry.dots_in_ident = $3;
3102     };
3103    
3104     general_max_targets: MAX_TARGETS '=' NUMBER ';'
3105     {
3106     ConfigFileEntry.max_targets = $3;
3107     };
3108    
3109     general_servlink_path: SERVLINK_PATH '=' QSTRING ';'
3110     {
3111 michael 967 if (conf_parser_ctx.pass == 2)
3112 adx 30 {
3113     MyFree(ConfigFileEntry.servlink_path);
3114     DupString(ConfigFileEntry.servlink_path, yylval.string);
3115     }
3116     };
3117    
3118     general_default_cipher_preference: DEFAULT_CIPHER_PREFERENCE '=' QSTRING ';'
3119     {
3120     #ifdef HAVE_LIBCRYPTO
3121 michael 967 if (conf_parser_ctx.pass == 2)
3122 adx 30 {
3123     struct EncCapability *ecap;
3124     const char *cipher_name;
3125     int found = 0;
3126    
3127     ConfigFileEntry.default_cipher_preference = NULL;
3128     cipher_name = yylval.string;
3129    
3130     for (ecap = CipherTable; ecap->name; ecap++)
3131     {
3132     if ((irccmp(ecap->name, cipher_name) == 0) &&
3133     (ecap->cap & CAP_ENC_MASK))
3134     {
3135     ConfigFileEntry.default_cipher_preference = ecap;
3136     found = 1;
3137     break;
3138     }
3139     }
3140    
3141     if (!found)
3142     yyerror("Invalid cipher");
3143     }
3144     #else
3145 michael 967 if (conf_parser_ctx.pass == 2)
3146 adx 30 yyerror("Ignoring default_cipher_preference -- no OpenSSL support");
3147     #endif
3148     };
3149    
3150     general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
3151     {
3152 michael 967 if (conf_parser_ctx.pass == 2)
3153 adx 30 {
3154     ConfigFileEntry.compression_level = $3;
3155     #ifndef HAVE_LIBZ
3156     yyerror("Ignoring compression_level -- no zlib support");
3157     #else
3158     if ((ConfigFileEntry.compression_level < 1) ||
3159     (ConfigFileEntry.compression_level > 9))
3160     {
3161     yyerror("Ignoring invalid compression_level, using default");
3162     ConfigFileEntry.compression_level = 0;
3163     }
3164     #endif
3165     }
3166     };
3167    
3168     general_use_egd: USE_EGD '=' TBOOL ';'
3169     {
3170     ConfigFileEntry.use_egd = yylval.number;
3171     };
3172    
3173     general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
3174     {
3175 michael 967 if (conf_parser_ctx.pass == 2)
3176 adx 30 {
3177     MyFree(ConfigFileEntry.egdpool_path);
3178     DupString(ConfigFileEntry.egdpool_path, yylval.string);
3179     }
3180     };
3181    
3182     general_ping_cookie: PING_COOKIE '=' TBOOL ';'
3183     {
3184     ConfigFileEntry.ping_cookie = yylval.number;
3185     };
3186    
3187     general_disable_auth: DISABLE_AUTH '=' TBOOL ';'
3188     {
3189     ConfigFileEntry.disable_auth = yylval.number;
3190     };
3191    
3192     general_throttle_time: THROTTLE_TIME '=' timespec ';'
3193     {
3194     ConfigFileEntry.throttle_time = yylval.number;
3195     };
3196    
3197     general_oper_umodes: OPER_UMODES
3198     {
3199     ConfigFileEntry.oper_umodes = 0;
3200     } '=' umode_oitems ';' ;
3201    
3202     umode_oitems: umode_oitems ',' umode_oitem | umode_oitem;
3203     umode_oitem: T_BOTS
3204     {
3205     ConfigFileEntry.oper_umodes |= UMODE_BOTS;
3206     } | T_CCONN
3207     {
3208     ConfigFileEntry.oper_umodes |= UMODE_CCONN;
3209 db 849 } | T_CCONN_FULL
3210     {
3211     ConfigFileEntry.oper_umodes |= UMODE_CCONN_FULL;
3212 adx 30 } | T_DEAF
3213     {
3214     ConfigFileEntry.oper_umodes |= UMODE_DEAF;
3215     } | T_DEBUG
3216     {
3217     ConfigFileEntry.oper_umodes |= UMODE_DEBUG;
3218     } | T_FULL
3219     {
3220     ConfigFileEntry.oper_umodes |= UMODE_FULL;
3221     } | T_SKILL
3222     {
3223     ConfigFileEntry.oper_umodes |= UMODE_SKILL;
3224     } | T_NCHANGE
3225     {
3226     ConfigFileEntry.oper_umodes |= UMODE_NCHANGE;
3227     } | T_REJ
3228     {
3229     ConfigFileEntry.oper_umodes |= UMODE_REJ;
3230     } | T_UNAUTH
3231     {
3232     ConfigFileEntry.oper_umodes |= UMODE_UNAUTH;
3233     } | T_SPY
3234     {
3235     ConfigFileEntry.oper_umodes |= UMODE_SPY;
3236     } | T_EXTERNAL
3237     {
3238     ConfigFileEntry.oper_umodes |= UMODE_EXTERNAL;
3239     } | T_OPERWALL
3240     {
3241     ConfigFileEntry.oper_umodes |= UMODE_OPERWALL;
3242     } | T_SERVNOTICE
3243     {
3244     ConfigFileEntry.oper_umodes |= UMODE_SERVNOTICE;
3245     } | T_INVISIBLE
3246     {
3247     ConfigFileEntry.oper_umodes |= UMODE_INVISIBLE;
3248     } | T_WALLOP
3249     {
3250     ConfigFileEntry.oper_umodes |= UMODE_WALLOP;
3251     } | T_SOFTCALLERID
3252     {
3253     ConfigFileEntry.oper_umodes |= UMODE_SOFTCALLERID;
3254     } | T_CALLERID
3255     {
3256     ConfigFileEntry.oper_umodes |= UMODE_CALLERID;
3257     } | T_LOCOPS
3258     {
3259     ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
3260     };
3261    
3262     general_oper_only_umodes: OPER_ONLY_UMODES
3263     {
3264     ConfigFileEntry.oper_only_umodes = 0;
3265     } '=' umode_items ';' ;
3266    
3267     umode_items: umode_items ',' umode_item | umode_item;
3268     umode_item: T_BOTS
3269     {
3270     ConfigFileEntry.oper_only_umodes |= UMODE_BOTS;
3271     } | T_CCONN
3272     {
3273     ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
3274 db 853 } | T_CCONN_FULL
3275     {
3276     ConfigFileEntry.oper_only_umodes |= UMODE_CCONN_FULL;
3277 adx 30 } | T_DEAF
3278     {
3279     ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
3280     } | T_DEBUG
3281     {
3282     ConfigFileEntry.oper_only_umodes |= UMODE_DEBUG;
3283     } | T_FULL
3284     {
3285     ConfigFileEntry.oper_only_umodes |= UMODE_FULL;
3286     } | T_SKILL
3287     {
3288     ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
3289     } | T_NCHANGE
3290     {
3291     ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
3292     } | T_REJ
3293     {
3294     ConfigFileEntry.oper_only_umodes |= UMODE_REJ;
3295     } | T_UNAUTH
3296     {
3297     ConfigFileEntry.oper_only_umodes |= UMODE_UNAUTH;
3298     } | T_SPY
3299     {
3300     ConfigFileEntry.oper_only_umodes |= UMODE_SPY;
3301     } | T_EXTERNAL
3302     {
3303     ConfigFileEntry.oper_only_umodes |= UMODE_EXTERNAL;
3304     } | T_OPERWALL
3305     {
3306     ConfigFileEntry.oper_only_umodes |= UMODE_OPERWALL;
3307     } | T_SERVNOTICE
3308     {
3309     ConfigFileEntry.oper_only_umodes |= UMODE_SERVNOTICE;
3310     } | T_INVISIBLE
3311     {
3312     ConfigFileEntry.oper_only_umodes |= UMODE_INVISIBLE;
3313     } | T_WALLOP
3314     {
3315     ConfigFileEntry.oper_only_umodes |= UMODE_WALLOP;
3316     } | T_SOFTCALLERID
3317     {
3318     ConfigFileEntry.oper_only_umodes |= UMODE_SOFTCALLERID;
3319     } | T_CALLERID
3320     {
3321     ConfigFileEntry.oper_only_umodes |= UMODE_CALLERID;
3322     } | T_LOCOPS
3323     {
3324     ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
3325     };
3326    
3327     general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
3328     {
3329     ConfigFileEntry.min_nonwildcard = $3;
3330     };
3331    
3332     general_min_nonwildcard_simple: MIN_NONWILDCARD_SIMPLE '=' NUMBER ';'
3333     {
3334     ConfigFileEntry.min_nonwildcard_simple = $3;
3335     };
3336    
3337     general_default_floodcount: DEFAULT_FLOODCOUNT '=' NUMBER ';'
3338     {
3339     ConfigFileEntry.default_floodcount = $3;
3340     };
3341    
3342     general_client_flood: T_CLIENT_FLOOD '=' sizespec ';'
3343     {
3344     ConfigFileEntry.client_flood = $3;
3345     };
3346    
3347    
3348     /***************************************************************************
3349     * section glines
3350     ***************************************************************************/
3351     gline_entry: GLINES
3352     {
3353 michael 967 if (conf_parser_ctx.pass == 2)
3354 adx 30 {
3355     yy_conf = make_conf_item(GDENY_TYPE);
3356 michael 102 yy_aconf = map_to_conf(yy_conf);
3357 adx 30 }
3358     } '{' gline_items '}' ';'
3359     {
3360 michael 967 if (conf_parser_ctx.pass == 2)
3361 adx 30 {
3362     /*
3363     * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3364     * end we will have one extra, so we should free it.
3365     */
3366 michael 102 if (yy_conf->name == NULL || yy_aconf->user == NULL)
3367 adx 30 {
3368 michael 102 delete_conf_item(yy_conf);
3369 adx 30 yy_conf = NULL;
3370     yy_aconf = NULL;
3371     }
3372     }
3373     };
3374    
3375     gline_items: gline_items gline_item | gline_item;
3376     gline_item: gline_enable |
3377     gline_duration |
3378     gline_logging |
3379     gline_user |
3380     gline_server |
3381     gline_action |
3382     error;
3383    
3384     gline_enable: ENABLE '=' TBOOL ';'
3385     {
3386 michael 967 if (conf_parser_ctx.pass == 2)
3387 adx 30 ConfigFileEntry.glines = yylval.number;
3388     };
3389    
3390     gline_duration: DURATION '=' timespec ';'
3391     {
3392 michael 967 if (conf_parser_ctx.pass == 2)
3393 adx 30 ConfigFileEntry.gline_time = $3;
3394     };
3395    
3396     gline_logging: LOGGING
3397     {
3398 michael 967 if (conf_parser_ctx.pass == 2)
3399 adx 30 ConfigFileEntry.gline_logging = 0;
3400     } '=' gline_logging_types ';';
3401     gline_logging_types: gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3402     gline_logging_type_item: T_REJECT
3403     {
3404 michael 967 if (conf_parser_ctx.pass == 2)
3405 adx 30 ConfigFileEntry.gline_logging |= GDENY_REJECT;
3406     } | T_BLOCK
3407     {
3408 michael 967 if (conf_parser_ctx.pass == 2)
3409 adx 30 ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3410     };
3411    
3412     gline_user: USER '=' QSTRING ';'
3413     {
3414 michael 967 if (conf_parser_ctx.pass == 2)
3415 adx 30 {
3416 michael 593 struct split_nuh_item nuh;
3417 adx 30
3418 michael 593 nuh.nuhmask = yylval.string;
3419     nuh.nickptr = NULL;
3420     nuh.userptr = userbuf;
3421     nuh.hostptr = hostbuf;
3422    
3423     nuh.nicksize = 0;
3424     nuh.usersize = sizeof(userbuf);
3425     nuh.hostsize = sizeof(hostbuf);
3426    
3427     split_nuh(&nuh);
3428    
3429 adx 30 if (yy_aconf->user == NULL)
3430     {
3431 michael 593 DupString(yy_aconf->user, userbuf);
3432     DupString(yy_aconf->host, hostbuf);
3433 adx 30 }
3434     else
3435     {
3436 michael 593 struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
3437    
3438     DupString(yy_tmp->user, userbuf);
3439     DupString(yy_tmp->host, hostbuf);
3440    
3441 adx 30 dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3442     }
3443     }
3444     };
3445    
3446     gline_server: NAME '=' QSTRING ';'
3447     {
3448 michael 967 if (conf_parser_ctx.pass == 2)
3449 adx 30 {
3450     MyFree(yy_conf->name);
3451     DupString(yy_conf->name, yylval.string);
3452     }
3453     };
3454    
3455     gline_action: ACTION
3456     {
3457 michael 967 if (conf_parser_ctx.pass == 2)
3458 adx 30 yy_aconf->flags = 0;
3459     } '=' gdeny_types ';'
3460     {
3461 michael 967 if (conf_parser_ctx.pass == 2)
3462 adx 30 {
3463 michael 102 struct CollectItem *yy_tmp = NULL;
3464 adx 30 dlink_node *ptr, *next_ptr;
3465    
3466     DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3467     {
3468     struct AccessItem *new_aconf;
3469     struct ConfItem *new_conf;
3470    
3471     yy_tmp = ptr->data;
3472     new_conf = make_conf_item(GDENY_TYPE);
3473 michael 102 new_aconf = map_to_conf(new_conf);
3474 adx 30
3475     new_aconf->flags = yy_aconf->flags;
3476    
3477     if (yy_conf->name != NULL)
3478     DupString(new_conf->name, yy_conf->name);
3479     else
3480     DupString(new_conf->name, "*");
3481     if (yy_aconf->user != NULL)
3482     DupString(new_aconf->user, yy_tmp->user);
3483     else
3484     DupString(new_aconf->user, "*");
3485     if (yy_aconf->host != NULL)
3486     DupString(new_aconf->host, yy_tmp->host);
3487     else
3488     DupString(new_aconf->host, "*");
3489    
3490     dlinkDelete(&yy_tmp->node, &col_conf_list);
3491     }
3492 michael 102
3493     /*
3494     * In case someone has fed us with more than one action= after user/name
3495     * which would leak memory -Michael
3496     */
3497     if (yy_conf->name == NULL || yy_aconf->user == NULL)
3498     delete_conf_item(yy_conf);
3499    
3500     yy_conf = make_conf_item(GDENY_TYPE);
3501     yy_aconf = map_to_conf(yy_conf);
3502 adx 30 }
3503     };
3504    
3505     gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3506     gdeny_type_item: T_REJECT
3507     {
3508 michael 967 if (conf_parser_ctx.pass == 2)
3509 adx 30 yy_aconf->flags |= GDENY_REJECT;
3510     } | T_BLOCK
3511     {
3512 michael 967 if (conf_parser_ctx.pass == 2)
3513 adx 30 yy_aconf->flags |= GDENY_BLOCK;
3514     };
3515    
3516     /***************************************************************************
3517     * section channel
3518     ***************************************************************************/
3519     channel_entry: CHANNEL
3520     '{' channel_items '}' ';';
3521    
3522     channel_items: channel_items channel_item | channel_item;
3523     channel_item: channel_disable_local_channels | channel_use_except |
3524     channel_use_invex | channel_use_knock |
3525     channel_max_bans | channel_knock_delay |
3526 adx 201 channel_knock_delay_channel | channel_max_chans_per_user |
3527     channel_quiet_on_ban | channel_default_split_user_count |
3528     channel_default_split_server_count |
3529     channel_no_create_on_split | channel_restrict_channels |
3530     channel_no_join_on_split | channel_burst_topicwho |
3531     channel_jflood_count | channel_jflood_time |
3532 michael 632 channel_disable_fake_channels | error;
3533 adx 30
3534 michael 632 channel_disable_fake_channels: DISABLE_FAKE_CHANNELS '=' TBOOL ';'
3535     {
3536     ConfigChannel.disable_fake_channels = yylval.number;
3537     };
3538    
3539 adx 30 channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
3540     {
3541     ConfigChannel.restrict_channels = yylval.number;
3542     };
3543    
3544     channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
3545     {
3546     ConfigChannel.disable_local_channels = yylval.number;
3547     };
3548    
3549     channel_use_except: USE_EXCEPT '=' TBOOL ';'
3550     {
3551     ConfigChannel.use_except = yylval.number;
3552     };
3553    
3554     channel_use_invex: USE_INVEX '=' TBOOL ';'
3555     {
3556     ConfigChannel.use_invex = yylval.number;
3557     };
3558    
3559     channel_use_knock: USE_KNOCK '=' TBOOL ';'
3560     {
3561     ConfigChannel.use_knock = yylval.number;
3562     };
3563    
3564     channel_knock_delay: KNOCK_DELAY '=' timespec ';'
3565     {
3566     ConfigChannel.knock_delay = $3;
3567     };
3568    
3569     channel_knock_delay_channel: KNOCK_DELAY_CHANNEL '=' timespec ';'
3570     {
3571     ConfigChannel.knock_delay_channel = $3;
3572     };
3573    
3574     channel_max_chans_per_user: MAX_CHANS_PER_USER '=' NUMBER ';'
3575     {
3576     ConfigChannel.max_chans_per_user = $3;
3577     };
3578    
3579     channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
3580     {
3581     ConfigChannel.quiet_on_ban = yylval.number;
3582     };
3583    
3584     channel_max_bans: MAX_BANS '=' NUMBER ';'
3585     {
3586     ConfigChannel.max_bans = $3;
3587     };
3588    
3589     channel_default_split_user_count: DEFAULT_SPLIT_USER_COUNT '=' NUMBER ';'
3590     {
3591     ConfigChannel.default_split_user_count = $3;
3592     };
3593    
3594     channel_default_split_server_count: DEFAULT_SPLIT_SERVER_COUNT '=' NUMBER ';'
3595     {
3596     ConfigChannel.default_split_server_count = $3;
3597     };
3598    
3599     channel_no_create_on_split: NO_CREATE_ON_SPLIT '=' TBOOL ';'
3600     {
3601     ConfigChannel.no_create_on_split = yylval.number;
3602     };
3603    
3604     channel_no_join_on_split: NO_JOIN_ON_SPLIT '=' TBOOL ';'
3605     {
3606     ConfigChannel.no_join_on_split = yylval.number;
3607     };
3608    
3609     channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3610     {
3611     ConfigChannel.burst_topicwho = yylval.number;
3612     };
3613    
3614     channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
3615     {
3616     GlobalSetOptions.joinfloodcount = yylval.number;
3617     };
3618    
3619     channel_jflood_time: JOIN_FLOOD_TIME '=' timespec ';'
3620     {
3621     GlobalSetOptions.joinfloodtime = yylval.number;
3622     };
3623    
3624     /***************************************************************************
3625     * section serverhide
3626     ***************************************************************************/
3627     serverhide_entry: SERVERHIDE
3628     '{' serverhide_items '}' ';';
3629    
3630     serverhide_items: serverhide_items serverhide_item | serverhide_item;
3631     serverhide_item: serverhide_flatten_links | serverhide_hide_servers |
3632     serverhide_links_delay |
3633     serverhide_disable_hidden |
3634     serverhide_hidden | serverhide_hidden_name |
3635     serverhide_hide_server_ips |
3636     error;
3637    
3638     serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
3639     {
3640 michael 967 if (conf_parser_ctx.pass == 2)
3641 adx 30 ConfigServerHide.flatten_links = yylval.number;
3642     };
3643    
3644     serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
3645     {
3646 michael 967 if (conf_parser_ctx.pass == 2)
3647 adx 30 ConfigServerHide.hide_servers = yylval.number;
3648     };
3649    
3650     serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
3651     {
3652 michael 967 if (conf_parser_ctx.pass == 2)
3653 adx 30 {
3654     MyFree(ConfigServerHide.hidden_name);
3655     DupString(ConfigServerHide.hidden_name, yylval.string);
3656     }
3657     };
3658    
3659     serverhide_links_delay: LINKS_DELAY '=' timespec ';'
3660     {
3661 michael 967 if (conf_parser_ctx.pass == 2)
3662 adx 30 {
3663     if (($3 > 0) && ConfigServerHide.links_disabled == 1)
3664     {
3665     eventAddIsh("write_links_file", write_links_file, NULL, $3);
3666     ConfigServerHide.links_disabled = 0;
3667     }
3668    
3669     ConfigServerHide.links_delay = $3;
3670     }
3671     };
3672    
3673     serverhide_hidden: HIDDEN '=' TBOOL ';'
3674     {
3675 michael 967 if (conf_parser_ctx.pass == 2)
3676 adx 30 ConfigServerHide.hidden = yylval.number;
3677     };
3678    
3679     serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3680     {
3681 michael 967 if (conf_parser_ctx.pass == 2)
3682 adx 30 ConfigServerHide.disable_hidden = yylval.number;
3683     };
3684    
3685     serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
3686     {
3687 michael 967 if (conf_parser_ctx.pass == 2)
3688 adx 30 ConfigServerHide.hide_server_ips = yylval.number;
3689     };

Properties

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