ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 1324
Committed: Fri Mar 30 21:40:38 2012 UTC (14 years, 3 months ago) by michael
Original Path: ircd-hybrid-8/src/conf_parser.y
File size: 81581 byte(s)
Log Message:
- Remove log::timestamp configuration directive. Timestamps are now enabled by default.
- Timestamps are iso8601 now

File Contents

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

Properties

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