ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1121
Committed: Sun Jan 9 11:03:03 2011 UTC (15 years, 6 months ago) by michael
Original Path: ircd-hybrid-7.3/src/ircd_parser.y
File size: 87779 byte(s)
Log Message:
- removed all instances of STATIC_MODULES since we don't have
  static modules anymore
- removed m_mkpasswd module from contrib

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

Properties

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