ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/conf_parser.y
Revision: 1157
Committed: Tue Aug 9 22:03:59 2011 UTC (12 years, 7 months ago) by michael
Original Path: ircd-hybrid-8/src/ircd_parser.y
File size: 88582 byte(s)
Log Message:
- preliminary services support

File Contents

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

Properties

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