ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/src/ircd_parser.y
Revision: 208
Committed: Tue Nov 1 15:38:03 2005 UTC (20 years, 9 months ago) by adx
File size: 87898 byte(s)
Log Message:
+ an attempt to fix the HUB capability mess, we _should_ be able
  to establish an LL link now

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

Properties

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