ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
Revision: 671
Committed: Tue Jun 13 07:15:38 2006 UTC (20 years, 3 months ago) by michael
Original Path: ircd-hybrid-7.2/src/ircd_parser.y
File size: 90550 byte(s)
Log Message:
- Fixed class limit bug as spotted by stu.  ("REHASH" would always reset
  current user count)
- Made "STATS y|Y" show inactive (deleted) classes that still have attached
  clients

File Contents

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

Properties

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