ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1176
Committed: Sun Aug 14 11:24:24 2011 UTC (14 years, 11 months ago) by michael
Original Path: ircd-hybrid-8/src/ircd_parser.y
File size: 88315 byte(s)
Log Message:
- remove idle-time klines
- rename LocalUser.last to LocalUser.last_privmsg
- m_message.c: reset source_p->last_privmsg even if a client is messaging itself


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

Properties

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