[IRC-Dev CVS] [CVS] Module ircdh: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2003-01-19 21:20:47
|
CVSROOT : /cvsroot/irc-dev Module : ircdh Commit time: 2003-01-19 21:20:42 UTC Modified files: ChangeLog acconfig.h config.h.in include/class.h include/patchlevel.h include/s_conf.h ircd/.cvsignore ircd/Makefile.in ircd/class.c ircd/ircd.c ircd/m_trace.c ircd/motd.c ircd/s_conf.c ircd/s_err.c ircd/s_stats.c Added files: ircd/ircd_lexer.l ircd/ircd_parser.y Log message: 2003-01-19 Toni Garcia <zo...@ir...> 1.0.alpha16 * ircd/s_conf.c: Clase Alfanumerica y nuevo ircd.conf. * ircd/m_trace.c: Clase Alfanumerica. * ircd/ircd_lexer.l: Parseador lexico para el ircd.conf mediante LEX. * ircd/ircd_parser.y: Parseador del nuevo ircd.conf mediante YACC. * include/s_conf.h: Clase Alfanumerica. * {include|ircd}/class.h: La clase pasa de numerica a alfanumerica, o sea puedo poner Clase "Oper" por ejemplo. ---------------------- diff included ---------------------- Index: ircdh/ChangeLog diff -u ircdh/ChangeLog:1.10 ircdh/ChangeLog:1.11 --- ircdh/ChangeLog:1.10 Sun Jan 19 11:37:57 2003 +++ ircdh/ChangeLog Sun Jan 19 13:20:25 2003 @@ -1,3 +1,18 @@ +2003-01-19 Toni Garcia <zo...@ir...> 1.0.alpha16 + * ircd/s_conf.c: Clase Alfanumerica y nuevo ircd.conf. + + * ircd/m_trace.c: Clase Alfanumerica. + + * ircd/ircd_lexer.l: Parseador lexico para el ircd.conf mediante LEX. + + * ircd/ircd_parser.y: Parseador del nuevo ircd.conf mediante YACC. + + * include/s_conf.h: Clase Alfanumerica. + + * {include|ircd}/class.h: La clase pasa de numerica a alfanumerica, o sea + puedo poner Clase "Oper" por ejemplo. + + 2003-01-19 Toni Garcia <zo...@ir...> 1.0.alpha15 * Make Depend. Index: ircdh/acconfig.h diff -u ircdh/acconfig.h:1.1 ircdh/acconfig.h:1.2 --- ircdh/acconfig.h:1.1 Sat Jan 18 11:09:00 2003 +++ ircdh/acconfig.h Sun Jan 19 13:20:25 2003 @@ -1,7 +1,7 @@ #ifndef INCLUDED_config_h #define INCLUDED_config_h /* - * IRC - Internet Relay Chat, include/config.h + * IRC - Internet Relay Chat, acconfig.h * Copyright (C) 2000 Kevin L. Mitchell <kl...@mi...> * * This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: acconfig.h,v 1.1 2003/01/18 19:09:00 zolty Exp $ + * $Id: acconfig.h,v 1.2 2003/01/19 21:20:25 zolty Exp $ */ @TOP@ Index: ircdh/config.h.in diff -u ircdh/config.h.in:1.1 ircdh/config.h.in:1.2 --- ircdh/config.h.in:1.1 Sat Jan 18 11:09:00 2003 +++ ircdh/config.h.in Sun Jan 19 13:20:25 2003 @@ -2,7 +2,7 @@ #ifndef INCLUDED_config_h #define INCLUDED_config_h /* - * IRC - Internet Relay Chat, include/config.h + * IRC - Internet Relay Chat, acconfig.h * Copyright (C) 2000 Kevin L. Mitchell <kl...@mi...> * * This program is free software; you can redistribute it and/or modify @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: config.h.in,v 1.1 2003/01/18 19:09:00 zolty Exp $ + * $Id: config.h.in,v 1.2 2003/01/19 21:20:25 zolty Exp $ */ /* Define to `int' if <sys/types.h> doesn't define. */ Index: ircdh/include/class.h diff -u ircdh/include/class.h:1.4 ircdh/include/class.h:1.5 --- ircdh/include/class.h:1.4 Sat Jan 18 11:09:02 2003 +++ ircdh/include/class.h Sun Jan 19 13:20:26 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: class.h,v 1.4 2003/01/18 19:09:02 zolty Exp $ + * $Id: class.h,v 1.5 2003/01/19 21:20:26 zolty Exp $ */ #ifndef INCLUDED_class_h #define INCLUDED_class_h @@ -35,7 +35,7 @@ */ struct ConnectionClass { struct ConnectionClass *next; - int cc_class; + char *cc_name; unsigned int max_sendq; short ping_freq; short conn_freq; @@ -48,14 +48,14 @@ * Macro's */ -#define ConClass(x) ((x)->cc_class) +#define ConClass(x) ((x)->cc_name) #define PingFreq(x) ((x)->ping_freq) #define ConFreq(x) ((x)->conn_freq) #define MaxLinks(x) ((x)->max_links) #define MaxSendq(x) ((x)->max_sendq) #define Links(x) ((x)->ref_count) -#define ConfClass(x) ((x)->conn_class->cc_class) +#define ConfClass(x) ((x)->conn_class->cc_name) #define ConfPingFreq(x) ((x)->conn_class->ping_freq) #define ConfConFreq(x) ((x)->conn_class->conn_freq) #define ConfMaxLinks(x) ((x)->conn_class->max_links) @@ -72,14 +72,14 @@ extern void class_mark_delete(void); extern void class_delete_marked(void); -extern struct ConnectionClass *find_class(unsigned int cclass); +extern struct ConnectionClass *find_class(const char *name); extern struct ConnectionClass *make_class(void); extern void free_class(struct ConnectionClass *tmp); extern unsigned int get_con_freq(struct ConnectionClass *clptr); -extern unsigned int get_conf_class(const struct ConfItem *aconf); +extern char *get_conf_class(const struct ConfItem *aconf); extern int get_conf_ping(const struct ConfItem *aconf); -extern unsigned int get_client_class(struct Client *acptr); -extern void add_class(unsigned int conclass, unsigned int ping, +extern char *get_client_class(struct Client *acptr); +extern void add_class(char *name, unsigned int ping, unsigned int confreq, unsigned int maxli, unsigned int sendq); extern void check_class(void); extern void report_classes(struct Client *sptr, struct StatDesc *sd, int stat, Index: ircdh/include/patchlevel.h diff -u ircdh/include/patchlevel.h:1.10 ircdh/include/patchlevel.h:1.11 --- ircdh/include/patchlevel.h:1.10 Sun Jan 19 11:37:57 2003 +++ ircdh/include/patchlevel.h Sun Jan 19 13:20:26 2003 @@ -15,10 +15,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: patchlevel.h,v 1.10 2003/01/19 19:37:57 zolty Exp $ + * $Id: patchlevel.h,v 1.11 2003/01/19 21:20:26 zolty Exp $ * */ -#define PATCHLEVEL ".alpha15" +#define PATCHLEVEL ".alpha16" #define RELEASE "1.0" Index: ircdh/include/s_conf.h diff -u ircdh/include/s_conf.h:1.7 ircdh/include/s_conf.h:1.8 --- ircdh/include/s_conf.h:1.7 Sun Jan 19 11:37:58 2003 +++ ircdh/include/s_conf.h Sun Jan 19 13:20:26 2003 @@ -1,7 +1,7 @@ /* * s_conf.h * - * $Id: s_conf.h,v 1.7 2003/01/19 19:37:58 zolty Exp $ + * $Id: s_conf.h,v 1.8 2003/01/19 21:20:26 zolty Exp $ */ #ifndef INCLUDED_s_conf_h #define INCLUDED_s_conf_h @@ -17,6 +17,7 @@ #include <netinet/in.h> /* struct in_addr */ #define INCLUDED_netinet_in_h #endif +#include "client.h" struct Client; struct SLink; @@ -67,6 +68,9 @@ int dns_pending; /* a dns request is pending */ unsigned short port; char bits; /* Number of bits for ipkills */ + struct Privs privs; /* Priviledges for opers. */ + /* Used to detect if a privilege has been touched. */ + struct Privs privs_dirty; }; struct ServerConf { @@ -204,6 +208,9 @@ extern int find_restrict(struct Client *cptr); extern struct MotdItem *read_motd(const char *motdfile); extern char *find_quarantine(const char *chname); +extern void lookup_confhost(struct ConfItem *aconf); + +extern void yyerror(const char *msg); /* MIRAR */ #ifdef ESNET_NEG Index: ircdh/ircd/.cvsignore diff -u ircdh/ircd/.cvsignore:1.2 ircdh/ircd/.cvsignore:1.3 --- ircdh/ircd/.cvsignore:1.2 Thu Oct 24 02:57:52 2002 +++ ircdh/ircd/.cvsignore Sun Jan 19 13:20:28 2003 @@ -5,3 +5,7 @@ chkconf table_gen chattr.tab.c +lex.yy.c +y.tab.c +y.tab.h + Index: ircdh/ircd/Makefile.in diff -u ircdh/ircd/Makefile.in:1.12 ircdh/ircd/Makefile.in:1.13 --- ircdh/ircd/Makefile.in:1.12 Sun Jan 19 11:37:58 2003 +++ ircdh/ircd/Makefile.in Sun Jan 19 13:20:28 2003 @@ -38,6 +38,8 @@ CHGRP = chgrp MKDIR = mkdir TOUCH = touch +LEX = flex +YACC = bison -y GREP = grep OSDEP_C = @OSDEP_C@ ENGINE_C = @ENGINE_C@ @@ -100,6 +102,7 @@ ircd_tea.c \ ircd_xopen.c \ jupe.c \ + lex.yy.c \ list.c \ listener.c \ m_account.c \ @@ -210,15 +213,15 @@ userload.c \ watch.c \ whocmds.c \ - whowas.c + whowas.c \ + y.tab.c -CHKCONF_SRC = chkconf.c SRC = ${IRCD_SRC} ${OSDEP_C} ${ENGINE_C} OBJS = ${SRC:%.c=%.o} -DEP_SRC = ${IRCD_SRC} ${OSDEP_SRC} ${ENGINE_SRC} ${CHKCONF_SRC} +DEP_SRC = ${IRCD_SRC} ${OSDEP_SRC} ${ENGINE_SRC} all: ( cd ..; make -f Makefile ) @@ -228,7 +231,7 @@ .c.o: ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ -build: ircd chkconf +build: ircd ircd: ${OBJS} ../include/patchlevel.h version.o ${PURIFY} ${CC} ${LDFLAGS} ${OBJS} version.o ${RINGLOG_O} ${LDFLAGS} ${LIBS} \ @@ -257,6 +260,12 @@ chattr.tab.c: table_gen ./table_gen > chattr.tab.c +lex.yy.c: ircd_lexer.l y.tab.h + ${LEX} ${srcdir}/ircd_lexer.l + +y.tab.c y.tab.h: ircd_parser.y + ${YACC} -d ${srcdir}/ircd_parser.y + chkcrule.o: crule.c ${CC} ${CFLAGS} ${CPPFLAGS} -DCR_CHKCONF -o chkcrule.o -c \ ${srcdir}/crule.c @@ -361,7 +370,7 @@ @echo "Please remove the contents of ${DPATH} manually" clean: - ${RM} -f *.o *.bak ircd version.c chkconf ircd_osdep.c chattr.tab.c table_gen + ${RM} -f *.o *.bak ircd version.c chkconf ircd_osdep.c chattr.tab.c table_gen y.tab.* lex.yy.* distclean: clean ${RM} -f Makefile stamp-m @@ -423,7 +432,8 @@ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/ircd.h \ ../include/struct.h ../include/ircd_alloc.h ../include/ircd_features.h \ - ../include/ircd_reply.h ../include/list.h ../include/numeric.h \ + ../include/ircd_reply.h ../include/ircd_string.h \ + ../include/ircd_chattr.h ../include/list.h ../include/numeric.h \ ../include/s_conf.h ../include/s_debug.h ../include/send.h client.o: client.c ../config.h ../include/client.h ../include/ircd_defs.h \ ../include/dbuf.h ../include/msgq.h ../include/ircd_events.h \ @@ -517,7 +527,8 @@ ../include/s_debug.h ../include/send.h ircd_signal.o: ircd_signal.c ../config.h ../include/ircd.h \ ../include/struct.h ../include/ircd_defs.h ../include/ircd_events.h \ - ../include/ircd_signal.h ../include/s_conf.h + ../include/ircd_signal.h ../include/s_conf.h ../include/client.h \ + ../include/dbuf.h ../include/msgq.h ../include/ircd_handler.h ircd_snprintf.o: ircd_snprintf.c ../config.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h ../include/channel.h \ @@ -537,6 +548,8 @@ ../include/numeric.h ../include/numnicks.h ../include/s_bsd.h \ ../include/s_misc.h ../include/send.h ../include/support.h \ ../include/sys.h +lex.yy.o: lex.yy.c ../include/ircd.h ../include/struct.h \ + ../include/ircd_defs.h y.tab.h list.o: list.c ../config.h ../include/class.h ../include/client.h \ ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ ../include/ircd_events.h ../include/ircd_handler.h \ @@ -1226,10 +1239,10 @@ ../include/s_debug.h ../include/s_misc.h ../include/s_user.h \ ../include/send.h ../include/support.h ../include/sys.h \ ../include/uping.h ../include/version.h -s_conf.o: s_conf.c ../config.h ../include/s_conf.h ../include/IPcheck.h \ - ../include/class.h ../include/client.h ../include/ircd_defs.h \ - ../include/dbuf.h ../include/msgq.h ../include/ircd_events.h \ - ../include/ircd_handler.h ../include/crule.h ../include/ircd_features.h \ +s_conf.o: s_conf.c ../config.h ../include/s_conf.h ../include/client.h \ + ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ + ../include/ircd_events.h ../include/ircd_handler.h ../include/IPcheck.h \ + ../include/class.h ../include/crule.h ../include/ircd_features.h \ ../include/fileio.h ../include/gline.h ../include/hash.h \ ../include/ircd.h ../include/struct.h ../include/ircd_alloc.h \ ../include/ircd_chattr.h ../include/ircd_log.h ../include/ircd_reply.h \ @@ -1367,6 +1380,19 @@ ../include/numeric.h ../include/s_debug.h ../include/s_misc.h \ ../include/s_user.h ../include/send.h ../include/support.h \ ../include/sys.h ../include/msg.h +y.tab.o: y.tab.c ../config.h ../include/s_conf.h ../include/client.h \ + ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ + ../include/ircd_events.h ../include/ircd_handler.h ../include/class.h \ + ../include/crule.h ../include/ircd_features.h ../include/fileio.h \ + ../include/gline.h ../include/hash.h ../include/ircd.h \ + ../include/struct.h ../include/ircd_alloc.h ../include/ircd_chattr.h \ + ../include/ircd_log.h ../include/ircd_reply.h \ + ../include/ircd_snprintf.h ../include/ircd_string.h ../include/list.h \ + ../include/listener.h ../include/match.h ../include/motd.h \ + ../include/numeric.h ../include/numnicks.h ../include/opercmds.h \ + ../include/parse.h ../include/res.h ../include/s_bsd.h \ + ../include/s_debug.h ../include/s_misc.h ../include/send.h \ + ../include/support.h ../include/sys.h os_bsd.o: os_bsd.c ../config.h ../include/ircd_osdep.h ../include/msgq.h \ ../include/ircd_defs.h os_linux.o: os_linux.c ../config.h ../include/ircd_osdep.h \ @@ -1391,9 +1417,3 @@ engine_select.o: engine_select.c ../config.h ../include/ircd_events.h \ ../include/ircd.h ../include/struct.h ../include/ircd_defs.h \ ../include/ircd_log.h ../include/s_debug.h -chkconf.o: chkconf.c ../config.h ../include/s_conf.h ../include/client.h \ - ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \ - ../include/ircd_events.h ../include/ircd_handler.h ../include/class.h \ - ../include/fileio.h ../include/ircd.h ../include/struct.h \ - ../include/ircd_alloc.h ../include/ircd_chattr.h \ - ../include/ircd_string.h ../include/sys.h Index: ircdh/ircd/class.c diff -u ircdh/ircd/class.c:1.4 ircdh/ircd/class.c:1.5 --- ircdh/ircd/class.c:1.4 Sun Jan 19 11:37:58 2003 +++ ircdh/ircd/class.c Sun Jan 19 13:20:29 2003 @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: class.c,v 1.4 2003/01/19 19:37:58 zolty Exp $ + * $Id: class.c,v 1.5 2003/01/19 21:20:29 zolty Exp $ */ #include "config.h" @@ -26,6 +26,7 @@ #include "ircd_alloc.h" #include "ircd_features.h" #include "ircd_reply.h" +#include "ircd_string.h" #include "list.h" #include "numeric.h" #include "s_conf.h" @@ -52,8 +53,8 @@ struct ConnectionClass *tmp; tmp = (struct ConnectionClass *)MyMalloc(sizeof(struct ConnectionClass)); + tmp->ref_count = 1; assert(0 != tmp); - tmp->ref_count = 0; ++connClassAllocCount; return tmp; } @@ -63,6 +64,8 @@ if (p) { assert(0 == p->valid); + if (p->cc_name) + MyFree(p->cc_name); MyFree(p); --connClassAllocCount; } @@ -76,7 +79,8 @@ if (!connClassList) connClassList = (struct ConnectionClass *)make_class(); - ConClass(connClassList) = 0; + /* We had better not try and free this... */ + ConClass(connClassList) = "default"; PingFreq(connClassList) = feature_int(FEAT_PINGFREQUENCY); ConFreq(connClassList) = feature_int(FEAT_CONNECTFREQUENCY); MaxLinks(connClassList) = feature_int(FEAT_MAXIMUM_LINKS); @@ -116,7 +120,7 @@ for (prev = cl = connClassList; cl; cl = prev->next) { - Debug((DEBUG_DEBUG, "Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %d", + Debug((DEBUG_DEBUG, "Class %s : CF: %d PF: %d ML: %d LI: %d SQ: %d", ConClass(cl), ConFreq(cl), PingFreq(cl), MaxLinks(cl), Links(cl), MaxSendq(cl))); /* @@ -127,20 +131,20 @@ else { prev->next = cl->next; - if (0 == cl->ref_count) + if (0 == --cl->ref_count) free_class(cl); } } } -unsigned int get_conf_class(const struct ConfItem *aconf) +char *get_conf_class(const struct ConfItem *aconf) { if ((aconf) && (aconf->conn_class)) return (ConfClass(aconf)); Debug((DEBUG_DEBUG, "No Class For %s", (aconf) ? aconf->name : "*No Conf*")); - return (BAD_CONF_CLASS); + return NULL; } int get_conf_ping(const struct ConfItem *aconf) @@ -154,29 +158,25 @@ return -1; } -unsigned int get_client_class(struct Client *acptr) +char *get_client_class(struct Client *acptr) { struct SLink *tmp; struct ConnectionClass *cl; - unsigned int retc = BAD_CLIENT_CLASS; + /* Return the most recent(first on LL) client class... */ if (acptr && !IsMe(acptr) && (cli_confs(acptr))) for (tmp = cli_confs(acptr); tmp; tmp = tmp->next) { #if 1 - if (!tmp->value.aconf || !(cl = tmp->value.aconf->conn_class)) + if (tmp->value.aconf && (cl = tmp->value.aconf->conn_class)) #else /* PArche /OPER */ if (!tmp->value.aconf || !(cl = tmp->value.aconf->conn_class) || !(tmp->value.aconf->status & (CONF_CLIENT | CONF_SERVER))) #endif - continue; - if (ConClass(cl) > retc || retc == BAD_CLIENT_CLASS) - retc = ConClass(cl); + return ConClass(cl); } - Debug((DEBUG_DEBUG, "Returning Class %d For %s", retc, cli_name(acptr))); - - return (retc); + return "(null->class)"; } unsigned int get_con_freq(struct ConnectionClass *clptr) @@ -194,24 +194,28 @@ * if no present entry is found, then create a new one and add it in * immeadiately after the first one (class 0). */ -void add_class(unsigned int conClass, unsigned int ping, unsigned int confreq, +void add_class(char *name, unsigned int ping, unsigned int confreq, unsigned int maxli, unsigned int sendq) { struct ConnectionClass *t; struct ConnectionClass *p; - t = find_class(conClass); - if ((t == connClassList) && (conClass != 0)) + t = find_class(name); + if ((t == connClassList) && (name != NULL)) { p = (struct ConnectionClass *)make_class(); p->next = t->next; t->next = p; } else + { + if (ConClass(t) != NULL) + MyFree(ConClass(t)); p = t; - Debug((DEBUG_DEBUG, "Add Class %u: cf: %u pf: %u ml: %u sq: %d", - conClass, confreq, ping, maxli, sendq)); - ConClass(p) = conClass; + } + Debug((DEBUG_DEBUG, "Add Class %s: cf: %u pf: %u ml: %u sq: %d", + name, confreq, ping, maxli, sendq)); + ConClass(p) = name; ConFreq(p) = confreq; PingFreq(p) = ping; MaxLinks(p) = maxli; @@ -221,13 +225,13 @@ Links(p) = 0; } -struct ConnectionClass *find_class(unsigned int cclass) +struct ConnectionClass *find_class(const char *name) { struct ConnectionClass *cltmp; for (cltmp = connClassList; cltmp; cltmp = cltmp->next) { - if (ConClass(cltmp) == cclass) + if (!ircd_strcmp(ConClass(cltmp), name)) return cltmp; } return connClassList; @@ -265,7 +269,7 @@ !(tmp->value.aconf->status & (CONF_CLIENT | CONF_SERVER))) #endif continue; - if (ConClass(cl) != BAD_CLIENT_CLASS) + if (ConClass(cl) != NULL) { cli_max_sendq(cptr) = MaxSendq(cl); return cli_max_sendq(cptr); Index: ircdh/ircd/ircd.c diff -u ircdh/ircd/ircd.c:1.9 ircdh/ircd/ircd.c:1.10 --- ircdh/ircd/ircd.c:1.9 Sat Jan 18 14:54:31 2003 +++ ircdh/ircd/ircd.c Sun Jan 19 13:20:29 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: ircd.c,v 1.9 2003/01/18 22:54:31 zolty Exp $ + * $Id: ircd.c,v 1.10 2003/01/19 21:20:29 zolty Exp $ */ #include "config.h" @@ -248,7 +248,7 @@ struct ConnectionClass *cltmp; struct ConfItem *con_conf = 0; struct Jupe *ajupe; - unsigned int con_class = 0; + char *con_class = NULL; assert(ET_EXPIRE == ev_type(ev)); assert(0 != ev_timer(ev)); Index: ircdh/ircd/ircd_lexer.l diff -u /dev/null ircdh/ircd/ircd_lexer.l:1.1 --- /dev/null Sun Jan 19 13:20:46 2003 +++ ircdh/ircd/ircd_lexer.l Sun Jan 19 13:20:30 2003 @@ -0,0 +1,153 @@ +/* + * ircd_parser.y: A yacc/bison parser for ircd config files. + * This is part of ircu, an Internet Relay Chat server. + * The contents of this file are Copyright(C) 2001 by Andrew Miller, the + * ircd-hybrid team and the ircu team. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + * $Id: ircd_lexer.l,v 1.1 2003/01/19 21:20:30 zolty Exp $ + */ + +%{ +#include <unistd.h> +#include <stdio.h> +#include "ircd.h" +#include "y.tab.h" + +extern int lineno; + +void +init_lexer(void) +{ + yyin = fopen(configfile, "r"); + if (yyin == NULL) + yy_fatal_error("Could not open the configuration file."); + YY_NEW_FILE; + lineno = 1; +} + +%} +%option noyywrap +%option case-insensitive +%option nounput + + +WHITE [ \t\r]+ +SHCOMMENT #[^\n]* +NUMBER [0-9]+ +QSTRING \"[^"\n]+[\"\n] +%% + +{QSTRING} {yytext[yyleng-1] = 0; yylval.text = yytext+1; return QSTRING;} +{NUMBER} {yylval.num = strtoul(yytext, NULL, 10); return NUMBER;} +{WHITE} ; +{SHCOMMENT} ; + +admin return ADMIN; +administrator return ADMIN; +general return GENERAL; +location return LOCATION; +contact return CONTACT; +connect return CONNECT; +class return CLASS; +pingfreq return PINGFREQ; +connectfreq return CONNECTFREQ; +maxlinks return MAXLINKS; +sendq return SENDQ; +name return NAME; +host return HOST; +password return PASS; +pass return PASS; +seconds return SECONDS; +minutes return MINUTES; +hours return HOURS; +days return DAYS; +weeks return WEEKS; +months return MONTHS; +years return YEARS; +decades return DECADES; +bytes return BYTES; +b return BYTES; +kbytes return KBYTES; +kilobytes return KBYTES; +kb return KBYTES; +mbytes return MBYTES; +megabytes return MBYTES; +mb return MBYTES; +gbytes return GBYTES; +gigabytes return GBYTES; +gb return GBYTES; +tbytes return TBYTES; +terabytes return TBYTES; +tb return TBYTES; +port return PORT; +server return SERVER; +yes return YES; +no return NO; +hub return HUB; +leaf return LEAF; +uworld return UWORLD; +operator return OPER; +oper return OPER; +local return LOCAL; +vhost return VHOST; +mask return MASK; +hidden return HIDDEN; +motd return MOTD; +numeric return NUMERIC; +nick return NICK; +jupe return JUPE; +description return DESCRIPTION; +client return CLIENT; +real return REAL; +realname return REAL; +reason return REASON; +file return TFILE; +rule return RULE; +all return ALL; +ip return IP; +crule return CRULE; +kill return KILL; +quarantine return QUARANTINE; +features return FEATURES; +channel return CHANNEL; +bypass_local_channel_limits return TPRIV_CHAN_LIMIT; +set_local_channel_modes return TPRIV_MODE_LCHAN; +protected_local_channel return TPRIV_DEOP_LCHAN; +bypass_join_local_channels return TPRIV_WALK_LCHAN; +global_kill return TPRIV_KILL; +local_kill return TPRIV_LOCAL_KILL; +rehash return TPRIV_REHASH; +restart return TPRIV_RESTART; +die return TPRIV_DIE; +gline return TPRIV_GLINE; +local_gline return TPRIV_LOCAL_GLINE; +jupe_server return TPRIV_JUPE; +local_jupe_server return TPRIV_LOCAL_JUPE; +hack_channel_modes return TPRIV_OPMODE; +change_settings return TPRIV_SET; +extended_who_information return TPRIV_WHOX; +gline_channels return TPRIV_BADCHAN; +local_gline_channels return TPRIV_LOCAL_BADCHAN; +see_private_channels return TPRIV_SEE_CHAN; +see_invisible_users return TPRIV_SHOW_INVIS; +list_all_invisible_users return TPRIV_SHOW_ALL_INVIS; +globally_opered return TPRIV_PROPAGATE; +unlimited_who_queries return TPRIV_UNLIMIT_QUERY; +oper_status_display return TPRIV_DISPLAY; +see_other_opers return TPRIV_SEE_OPERS; +wide_glines return TPRIV_WIDE_GLINE; +\n lineno++; +. return yytext[0]; Index: ircdh/ircd/ircd_parser.y diff -u /dev/null ircdh/ircd/ircd_parser.y:1.1 --- /dev/null Sun Jan 19 13:20:46 2003 +++ ircdh/ircd/ircd_parser.y Sun Jan 19 13:20:30 2003 @@ -0,0 +1,907 @@ +/* + * ircd_parser.y: A yacc/bison parser for ircd config files. + * This is part of ircu, an Internet Relay Chat server. + * The contents of this file are Copyright(C) 2001 by Andrew Miller, the + * ircd-hybrid team and the ircu team. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + * $Id: ircd_parser.y,v 1.1 2003/01/19 21:20:30 zolty Exp $ + */ +%{ + +#include "config.h" +#include "s_conf.h" +#include "class.h" +#include "client.h" +#include "crule.h" +#include "ircd_features.h" +#include "fileio.h" +#include "gline.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_alloc.h" +#include "ircd_chattr.h" +#include "ircd_log.h" +#include "ircd_reply.h" +#include "ircd_snprintf.h" +#include "ircd_string.h" +#include "list.h" +#include "listener.h" +#include "match.h" +#include "motd.h" +#include "numeric.h" +#include "numnicks.h" +#include "opercmds.h" +#include "parse.h" +#include "res.h" +#include "s_bsd.h" +#include "s_conf.h" +#include "s_debug.h" +#include "s_misc.h" +#include "send.h" +#include "struct.h" +#include "support.h" +#include "sys.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <arpa/inet.h> +#define MAX_STRINGS 80 /* Maximum number of feature params. */ + extern struct LocalConf localConf; + extern struct DenyConf* denyConfList; + extern struct CRuleConf* cruleConfList; + extern struct ServerConf* serverConfList; + extern struct qline *GlobalQuarantineList; + + + int yylex(void); + /* Now all the globals we need :/... */ + int tping, tconn, maxlinks, sendq, port; + int stringno; + char *name, *pass, *host; + char *stringlist[MAX_STRINGS]; + struct ConnectionClass *c_class; + struct ConfItem *aconf; + struct DenyConf *dconf; + struct ServerConf *sconf; + struct qline *qconf = NULL; +%} + +%token <text> QSTRING +%token <num> NUMBER +%token <text> FNAME + +%token GENERAL +%token ADMIN +%token LOCATION +%token CONTACT +%token CONNECT +%token CLASS +%token CHANNEL +%token PINGFREQ +%token CONNECTFREQ +%token MAXLINKS +%token SENDQ +%token NAME +%token HOST +%token PASS +%token LOCAL +%token SECONDS +%token MINUTES +%token HOURS +%token DAYS +%token WEEKS +%token MONTHS +%token YEARS +%token DECADES +%token BYTES +%token KBYTES +%token MBYTES +%token GBYTES +%token TBYTES +%token SERVER +%token PORT +%token MASK +%token HUB +%token LEAF +%token UWORLD +%token YES +%token NO +%token OPER +%token PORT +%token VHOST +%token MASK +%token HIDDEN +%token MOTD +%token JUPE +%token NICK +%token NUMERIC +%token DESCRIPTION +%token CLIENT +%token KILL +%token CRULE +%token REAL +%token REASON +%token TFILE +%token RULE +%token ALL +%token IP +%token FEATURES +%token QUARANTINE +/* and now a lot of priviledges... */ +%token TPRIV_CHAN_LIMIT, TPRIV_MODE_LCHAN, TPRIV_DEOP_LCHAN, TPRIV_WALK_LCHAN +%token TPRIV_KILL, TPRIV_LOCAL_KILL, TPRIV_REHASH, TPRIV_RESTART, TPRIV_DIE +%token TPRIV_GLINE, TPRIV_LOCAL_GLINE, TPRIV_JUPE, TPRIV_LOCAL_JUPE +%token TPRIV_LOCAL_OPMODE, TPRIV_OPMODE, TPRIV_SET, TPRIV_WHOX, TPRIV_BADCHAN +%token TPRIV_LOCAL_BADCHAN +%token TPRIV_SEE_CHAN, TPRIV_SHOW_INVIS, TPRIV_SHOW_ALL_INVIS, TPRIV_PROPAGATE +%token TPRIV_UNLIMIT_QUERY, TPRIV_DISPLAY, TPRIV_SEE_OPERS, TPRIV_WIDE_GLINE +/* and some types... */ +%type <num> sizespec +%type <num> timespec, timefactor, factoredtimes, factoredtime +%type <num> expr, yesorno, privtype +%left '+' '-' +%left '*' '/' + +%union{ + char *text; + int num; +} + +%% +/* Blocks in the config file... */ +blocks: blocks block | block; +block: adminblock | generalblock | classblock | connectblock | + serverblock | operblock | portblock | jupeblock | clientblock | + killblock | cruleblock | motdblock | featuresblock | quarantineblock; + +/* The timespec, sizespec and expr was ripped straight from + * ircd-hybrid-7. */ +timespec: expr | factoredtimes; + +factoredtimes: factoredtimes factoredtime +{ + $$ = $1 + $2; +} | factoredtime; + +factoredtime: expr timefactor +{ + $$ = $1 * $2; +}; + +timefactor: SECONDS { $$ = 1; } +| MINUTES { $$ = 60; } +| HOURS { $$ = 60 * 60; } +| DAYS { $$ = 60 * 60 * 24; } +| WEEKS { $$ = 60 * 60 * 24 * 7; } +| MONTHS { $$ = 60 * 60 * 24 * 7 * 4; } +| YEARS { $$ = 60 * 60 * 24 * 365; } +| DECADES { $$ = 60 * 60 * 24 * 365 * 10; }; + + +sizespec: expr + = { + $$ = $1; + } + | expr BYTES + = { + $$ = $1; + } + | expr KBYTES + = { + $$ = $1 * 1024; + } + | expr MBYTES + = { + $$ = $1 * 1024 * 1024; + } + | expr GBYTES + = { + $$ = $1 * 1024 * 1024 * 1024; + } + | expr TBYTES + = { + $$ = $1 * 1024 * 1024 * 1024; + } + ; + +/* this is an arithmatic expression */ +expr: NUMBER + = { + $$ = $1; + } + | expr '+' expr + = { + $$ = $1 + $3; + } + | expr '-' expr + = { + $$ = $1 - $3; + } + | expr '*' expr + = { + $$ = $1 * $3; + } + | expr '/' expr + = { + $$ = $1 / $3; + } +/* leave this out until we find why it makes BSD yacc dump core -larne + | '-' expr %prec NEG + = { + $$ = -$2; + } */ + | '(' expr ')' + = { + $$ = $2; + } + ; + +jupeblock: JUPE '{' jupeitems '}' ';' ; +jupeitems: jupeitem jupeitems | jupeitem; +jupeitem: jupenick; +jupenick: NICK '=' QSTRING +{ + addNickJupes(yylval.text); +} ';'; + +generalblock: GENERAL '{' generalitems '}' ';' ; +generalitems: generalitem generalitems | generalitem; +generalitem: generalnumeric | generalname | generalvhost | generaldesc; +generalnumeric: NUMERIC '=' NUMBER ';' +{ + if (localConf.numeric == 0) + localConf.numeric = yylval.num; +}; + +generalname: NAME '=' QSTRING ';' +{ + if (localConf.name == NULL) + DupString(localConf.name, yylval.text); +}; + +generaldesc: DESCRIPTION '=' QSTRING ';' +{ + MyFree(localConf.description); + DupString(localConf.description, yylval.text); + ircd_strncpy(cli_info(&me), yylval.text, REALLEN); +}; + +generalvhost: VHOST '=' QSTRING ';' +{ + if (INADDR_NONE == + (localConf.vhost_address.s_addr = inet_addr(yylval.text))) + localConf.vhost_address.s_addr = INADDR_ANY; +}; + +adminblock: ADMIN '{' adminitems '}' +{ + if (localConf.location1 == NULL) + DupString(localConf.location1, ""); + if (localConf.location2 == NULL) + DupString(localConf.location2, ""); + if (localConf.contact == NULL) + DupString(localConf.contact, ""); +} ';'; +adminitems: adminitems adminitem | adminitem; +adminitem: adminlocation | admincontact; +adminlocation: LOCATION '=' QSTRING ';' +{ + if (localConf.location1 == NULL) + DupString(localConf.location1, yylval.text); + else if (localConf.location2 == NULL) + DupString(localConf.location2, yylval.text); + /* Otherwise just drop it. -A1kmm */ +}; +admincontact: CONTACT '=' QSTRING ';' +{ + if (localConf.contact != NULL) + MyFree(localConf.contact); + DupString(localConf.contact, yylval.text); +}; + +classblock: CLASS { + name = NULL; + tping = 90; + tconn = 0; + maxlinks = 0; + sendq = 0; +} '{' classitems '}' +{ + if (name != NULL) + { + add_class(name, tping, tconn, maxlinks, sendq); + } +} ';'; +classitems: classitem classitems | classitem; +classitem: classname | classpingfreq | classconnfreq | classmaxlinks | + classsendq; +classname: NAME '=' QSTRING ';' +{ + MyFree(name); + DupString(name, yylval.text); +}; +classpingfreq: PINGFREQ '=' timespec ';' +{ + tping = yylval.num; +}; +classconnfreq: CONNECTFREQ '=' timespec ';' +{ + tconn = yylval.num; +}; +classmaxlinks: MAXLINKS '=' expr ';' +{ + maxlinks = yylval.num; +}; +classsendq: SENDQ '=' sizespec ';' +{ + sendq = yylval.num; +}; + +connectblock: CONNECT +{ + name = pass = host = NULL; + c_class = NULL; + port = 0; +} '{' connectitems '}' +{ + if (name != NULL && pass != NULL && host != NULL && c_class != NULL && + /*ccount < MAXCONFLINKS &&*/ !strchr(host, '*') && + !strchr(host, '?')) + { + aconf = make_conf(); + aconf->status = CONF_SERVER; + aconf->name = name; + aconf->passwd = pass; + aconf->conn_class = c_class; + aconf->port = port; + aconf->status = CONF_SERVER; + aconf->host = host; + aconf->next = GlobalConfList; + aconf->ipnum.s_addr = INADDR_NONE; + lookup_confhost(aconf); + GlobalConfList = aconf; + } + else + { + MyFree(name); + MyFree(pass); + MyFree(host); + name = pass = host = NULL; + } +}';'; +connectitems: connectitem connectitems | connectitem; +connectitem: connectname | connectpass | connectclass | connecthost + | connectport; +connectname: NAME '=' QSTRING ';' +{ + MyFree(name); + DupString(name, yylval.text); +}; +connectpass: PASS '=' QSTRING ';' +{ + MyFree(pass); + DupString(pass, yylval.text); +}; +connectclass: CLASS '=' QSTRING ';' +{ + c_class = find_class(yylval.text); +}; +connecthost: HOST '=' QSTRING ';' +{ + MyFree(host); + DupString(host, yylval.text); +}; +connectport: PORT '=' NUMBER ';' +{ + port = yylval.num; +}; + +serverblock: SERVER +{ + aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf)); + memset(aconf, 0, sizeof(*aconf)); +} '{' serveritems '}' +{ + if (aconf->status == 0) + { + MyFree(aconf->host); + MyFree(aconf->name); + MyFree(aconf); + aconf = NULL; + } + else + { + aconf->next = GlobalConfList; + GlobalConfList = aconf; + } +} ';'; +serveritems: serveritem serveritems | serveritem; +serveritem: servername | servermask | serverhub | serverleaf | + serveruworld; +servername: NAME '=' QSTRING +{ + MyFree(aconf->name); + DupString(aconf->name, yylval.text); +} ';' ; +servermask: MASK '=' QSTRING +{ + MyFree(aconf->host); + DupString(aconf->host, yylval.text); +} ';' ; +/* XXX - perhaps we should do this the hybrid way in connect blocks + * instead -A1kmm. */ +serverhub: HUB '=' YES ';' +{ + aconf->status |= CONF_HUB; + aconf->status &= ~CONF_LEAF; +} +| HUB '=' NO +{ + aconf->status &= ~CONF_HUB; +} ';'; +serverleaf: LEAF '=' YES ';' +{ + if (!(aconf->status & CONF_HUB && aconf->status & CONF_UWORLD)) + aconf->status |= CONF_LEAF; +} +| LEAF '=' NO ';' +{ + aconf->status &= ~CONF_LEAF; +}; +serveruworld: UWORLD '=' YES ';' +{ + aconf->status |= CONF_UWORLD; + aconf->status &= ~CONF_LEAF; +} +| UWORLD '=' NO ';' +{ + aconf->status &= ~CONF_UWORLD; +}; + +operblock: OPER +{ + aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf)); + memset(aconf, 0, sizeof(*aconf)); + aconf->status = CONF_OPERATOR; +} '{' operitems '}' ';' +{ + if (aconf->name != NULL && aconf->passwd != NULL && aconf->host != NULL) + { + aconf->next = GlobalConfList; + GlobalConfList = aconf; + } + else + { + log_write(LS_CONFIG, L_ERROR, 0, "operator blocks need a name, password, and host."); + MyFree(aconf->name); + MyFree(aconf->passwd); + MyFree(aconf->host); + MyFree(aconf); + aconf = NULL; + } +}; +operitems: operitem | operitems operitem; +operitem: opername | operpass | operlocal | operhost | operclass | operpriv; + +opername: NAME '=' QSTRING ';' +{ + MyFree(aconf->name); + DupString(aconf->name, yylval.text); +}; + +operpass: PASS '=' QSTRING ';' +{ + MyFree(aconf->passwd); + DupString(aconf->passwd, yylval.text); +}; + +operlocal: LOCAL '=' YES ';' +{ + /* XXX it would be good to get rid of local operators and add same + * permission values here. But for now, I am just going with local + * opers... */ + aconf->status = CONF_LOCOP; +} | LOCAL '=' NO ';' +{ + aconf->status = CONF_OPERATOR; +}; + +operhost: HOST '=' QSTRING ';' +{ + MyFree(aconf->host); + if (!strchr(yylval.text, '@')) + { + int uh_len; + char *b = (char*) MyMalloc((uh_len = strlen(yylval.text)+3)); + ircd_snprintf(0, b, uh_len, "*@%s", yylval.text); + aconf->host = b; + } + else + DupString(aconf->host, yylval.text); +}; + +operclass: CLASS '=' QSTRING ';' +{ + aconf->conn_class = find_class(yylval.text); +}; + +operpriv: privtype '=' yesorno ';' +{ + if ($3 == 1) + { + PrivSet(&aconf->privs_dirty, $1); + PrivSet(&aconf->privs, $1); + } + else + { + PrivSet(&aconf->privs_dirty, $1); + PrivClr(&aconf->privs, $1); + } +}; + +privtype: TPRIV_CHAN_LIMIT { $$ = PRIV_CHAN_LIMIT; } | + TPRIV_MODE_LCHAN { $$ = PRIV_MODE_LCHAN; } | + TPRIV_DEOP_LCHAN { $$ = PRIV_DEOP_LCHAN; } | + TPRIV_WALK_LCHAN { $$ = PRIV_WALK_LCHAN; } | + TPRIV_KILL { $$ = PRIV_KILL; } | + TPRIV_LOCAL_KILL { $$ = PRIV_LOCAL_KILL; } | + TPRIV_REHASH { $$ = PRIV_REHASH; } | + TPRIV_RESTART { $$ = PRIV_RESTART; } | + TPRIV_DIE { $$ = PRIV_DIE; } | + TPRIV_GLINE { $$ = PRIV_GLINE; } | + TPRIV_LOCAL_GLINE { $$ = PRIV_LOCAL_GLINE; } | + TPRIV_JUPE { $$ = PRIV_JUPE; } | + TPRIV_LOCAL_JUPE { $$ = PRIV_LOCAL_JUPE; } | + TPRIV_LOCAL_OPMODE { $$ = PRIV_LOCAL_OPMODE; } | + TPRIV_OPMODE { $$ = PRIV_OPMODE; }| + TPRIV_SET { $$ = PRIV_SET; } | + TPRIV_WHOX { $$ = PRIV_WHOX; } | + TPRIV_BADCHAN { $$ = PRIV_BADCHAN; } | + TPRIV_LOCAL_BADCHAN { $$ = TPRIV_LOCAL_BADCHAN; } | + TPRIV_SEE_CHAN { $$ = PRIV_SEE_CHAN; } | + TPRIV_SHOW_INVIS { $$ = PRIV_SHOW_INVIS; } | + TPRIV_SHOW_ALL_INVIS { $$ = PRIV_SHOW_ALL_INVIS; } | + TPRIV_PROPAGATE { $$ = PRIV_PROPAGATE; } | + TPRIV_UNLIMIT_QUERY { $$ = PRIV_UNLIMIT_QUERY; } | + TPRIV_DISPLAY { $$ = PRIV_DISPLAY; } | + TPRIV_SEE_OPERS { $$ = PRIV_SEE_OPERS; } | + TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; }; + +yesorno: YES { $$ = 1; } | NO { $$ = 0; }; + +/* The port block... */ +portblock: PORT { + port = 0; + host = NULL; + /* Hijack these for is_server, is_hidden to cut down on globals... */ + tconn = 0; + tping = 0; + /* and this for mask... */ + pass = NULL; +} '{' portitems '}' ';' +{ + if (port > 0 && port <= 0xFFFF) + { + add_listener(port, host, pass, tconn, tping); + host = pass = NULL; + } + else + { + MyFree(host); + MyFree(pass); + } +}; +portitems: portitem portitems | portitem; +portitem: portnumber | portvhost | portmask | portserver | porthidden; +portnumber: PORT '=' NUMBER ';' +{ + port = yylval.num; +}; + +portvhost: VHOST '=' QSTRING ';' +{ + MyFree(host); + DupString(host, yylval.text); +}; + +portmask: MASK '=' QSTRING ';' +{ + MyFree(pass); + DupString(pass, yylval.text); +}; + +portserver: SERVER '=' YES ';' +{ + tconn = -1; +} | SERVER '=' NO ';' +{ + tconn = 0; +}; + +porthidden: HIDDEN '=' YES ';' +{ + tping = -1; +} | HIDDEN '=' NO ';' +{ + tping = 0; +}; + +clientblock: CLIENT +{ + aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf)); + memset(aconf, 0, sizeof(*aconf)); + aconf->status = CONF_CLIENT; +} '{' clientitems '}' +{ + if ((aconf->host != NULL || aconf->name!=NULL)) + { + if (aconf->host == NULL) + DupString(aconf->host, ""); + if (aconf->name == NULL) + DupString(aconf->name, ""); + if (aconf->conn_class == NULL) + aconf->conn_class = find_class("default"); + aconf->next = GlobalConfList; + GlobalConfList = aconf; + aconf = NULL; + } + else + { + MyFree(aconf->host); + MyFree(aconf->passwd); + MyFree(aconf); + aconf = NULL; + } +} ';'; +clientitems: clientitem clientitems | clientitem; +clientitem: clienthost | clientclass | clientpass | clientip; +clientip: IP '=' QSTRING ';' +{ + MyFree(aconf->host); + DupString(aconf->host, yylval.text); +}; + +clienthost: HOST '=' QSTRING ';' +{ + MyFree(aconf->name); + DupString(aconf->name, yylval.text); +}; + +clientclass: CLASS '=' QSTRING ';' +{ + aconf->conn_class = find_class(yylval.text); +}; + +clientpass: PASS '=' QSTRING ';' +{ + MyFree(aconf->passwd); + DupString(aconf->passwd, yylval.text); +}; + +killblock: KILL +{ + dconf = (struct DenyConf*) MyMalloc(sizeof(*dconf)); + memset(dconf, 0, sizeof(*dconf)); +} '{' killitems '}' +{ + if (dconf->hostmask != NULL) + { + if (dconf->usermask == NULL) + DupString(dconf->usermask, "*"); + dconf->next = denyConfList; + denyConfList = dconf; + dconf = NULL; + } + else + { + MyFree(dconf->hostmask); + MyFree(dconf->message); + MyFree(dconf); + dconf = NULL; + } +} ';'; +killitems: killitem killitems | killitem; +killitem: killuhost | killreal | killreasonfile | killreason; +killuhost: HOST '=' QSTRING ';' +{ + char *u, *h; + dconf->flags &= ~DENY_FLAGS_REALNAME; + MyFree(dconf->hostmask); + MyFree(dconf->usermask); + if ((h = strchr(yylval.text, '@')) == NULL) + { + u = "*"; + h = yylval.text; + } + else + { + u = yylval.text; + h++; + } + DupString(dconf->hostmask, h); + DupString(dconf->usermask, u); + if (strchr(yylval.text, '.')) + { + int c_class; + char ipname[16]; + int ad[4] = { 0 }; + int bits2 = 0; + dconf->flags |= DENY_FLAGS_IP; + c_class = sscanf(dconf->hostmask, "%d.%d.%d.%d/%d", + &ad[0], &ad[1], &ad[2], &ad[3], &bits2); + if (c_class != 5) { + dconf->bits = c_class * 8; + } + else { + dconf->bits = bits2; + } + ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1], + ad[2], ad[3]); + dconf->address = inet_addr(ipname); + } +}; + +killreal: REAL '=' QSTRING ';' +{ + dconf->flags &= ~DENY_FLAGS_IP; + dconf->flags |= DENY_FLAGS_REALNAME; + MyFree(dconf->hostmask); + /* Leave usermask so you can specify user and real... */ + DupString(dconf->hostmask, yylval.text); +}; + +killreason: REASON '=' QSTRING ';' +{ + dconf->flags &= DENY_FLAGS_FILE; + MyFree(dconf->message); + DupString(dconf->message, yylval.text); +}; + +killreasonfile: TFILE '=' QSTRING ';' +{ + dconf->flags |= DENY_FLAGS_FILE; + MyFree(dconf->message); + DupString(dconf->message, yylval.text); +}; + +cruleblock: CRULE +{ + host = pass = NULL; + tconn = CRULE_AUTO; +} '{' cruleitems '}' +{ + struct CRuleNode *node; + if (host != NULL && pass != NULL && (node=crule_parse(pass)) != NULL) + { + struct CRuleConf *p = (struct CRuleConf*) MyMalloc(sizeof(*p)); + p->hostmask = host; + p->rule = pass; + p->type = tconn; + p->node = node; + p->next = cruleConfList; + cruleConfList = p; + } + else + { + MyFree(host); + MyFree(pass); + } +} ';'; + +cruleitems: cruleitem cruleitems | cruleitem; +cruleitem: cruleserver | crulerule | cruleall; + +cruleserver: SERVER '=' QSTRING ';' +{ + MyFree(host); + collapse(yylval.text); + DupString(host, yylval.text); +}; + +crulerule: RULE '=' QSTRING ';' +{ + MyFree(pass); + DupString(pass, yylval.text); +}; + +cruleall: ALL '=' YES ';' +{ + tconn = CRULE_ALL; +} | ALL '=' NO ';' +{ + tconn = CRULE_AUTO; +}; + +motdblock: MOTD { + pass = host = NULL; +} '{' motditems '}' +{ + if (host != NULL && pass != NULL) + motd_add(host, pass); + MyFree(host); + MyFree(pass); + host = pass = NULL; +} ';'; + +motditems: motditem motditems | motditem; +motditem: motdhost | motdfile; +motdhost: HOST '=' QSTRING ';' +{ + DupString(host, yylval.text); +}; + +motdfile: TFILE '=' QSTRING ';' +{ + DupString(pass, yylval.text); +}; + +featuresblock: FEATURES '{' featureitems '}' ';'; +featureitems: featureitems featureitem | featureitem; + +featureitem: QSTRING +{ + stringlist[0] = $1; + stringno = 1; +} '=' stringlist ';'; + +stringlist: QSTRING +{ + stringlist[1] = $1; + stringno = 2; +} posextrastrings +{ + feature_set(NULL, (const char * const *)stringlist, stringno); +}; +posextrastrings: /* empty */ | extrastrings; +extrastrings: extrastrings extrastring | extrastring; +extrastring: QSTRING +{ + if (stringno < MAX_STRINGS) + stringlist[stringno++] = $1; +}; + +quarantineblock: QUARANTINE '{' +{ + if (qconf != NULL) + qconf = (struct qline*) MyMalloc(sizeof(*qconf)); + else + { + if (qconf->chname != NULL) + MyFree(qconf->chname); + if (qconf->reason != NULL) + MyFree(qconf->reason); + } + memset(qconf, 0, sizeof(*qconf)); +} quarantineitems '}' ';' +{ + if (qconf->chname == NULL || qconf->reason == NULL) + { + log_write(LS_CONFIG, L_ERROR, 0, "quarantine blocks need a channel name " + "and a reason."); + return 0; + } + qconf->next = GlobalQuarantineList; + GlobalQuarantineList = qconf; + qconf = NULL; +}; + +quarantineitems: CHANNEL NAME '=' QSTRING ';' +{ + DupString(qconf->chname, yylval.text); +} | REASON '=' QSTRING ';' +{ + DupString(qconf->reason, yylval.text); +}; Index: ircdh/ircd/m_trace.c diff -u ircdh/ircd/m_trace.c:1.2 ircdh/ircd/m_trace.c:1.3 --- ircdh/ircd/m_trace.c:1.2 Sat Jan 18 11:09:08 2003 +++ ircdh/ircd/m_trace.c Sun Jan 19 13:20:30 2003 @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: m_trace.c,v 1.2 2003/01/18 19:09:08 zolty Exp $ + * $Id: m_trace.c,v 1.3 2003/01/19 21:20:30 zolty Exp $ */ /* @@ -205,7 +205,7 @@ for (i = 0; i <= HighestFd; i++) { - unsigned int conClass; + const char *conClass; if (!(acptr = LocalClientArray[i])) /* Local Connection? */ continue; @@ -430,7 +430,7 @@ for (i = 0; i <= HighestFd; i++) { - unsigned int conClass; + const char *conClass; if (!(acptr = LocalClientArray[i])) /* Local Connection? */ continue; @@ -653,7 +653,7 @@ for (i = 0; i <= HighestFd; i++) { - unsigned int conClass; + const char *conClass; if (!(acptr = LocalClientArray[i])) /* Local Connection? */ continue; Index: ircdh/ircd/motd.c diff -u ircdh/ircd/motd.c:1.1 ircdh/ircd/motd.c:1.2 --- ircdh/ircd/motd.c:1.1 Sat Jan 18 11:09:10 2003 +++ ircdh/ircd/motd.c Sun Jan 19 13:20:31 2003 @@ -21,7 +21,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: motd.c,v 1.1 2003/01/18 19:09:10 zolty Exp $ + * $Id: motd.c,v 1.2 2003/01/19 21:20:31 zolty Exp $ */ #include "config.h" @@ -236,21 +236,21 @@ static struct Motd *motd_lookup(struct Client *cptr) { struct Motd *ptr; - int class = -1; + char *c_class = NULL; assert(0 != cptr); if (!MyUser(cptr)) /* not my user, always return remote motd */ return MotdList.remote; - class = get_client_class(cptr); + c_class = get_client_class(cptr); - /* check the T-lines first */ + /* check the motd blocks first */ for (ptr = MotdList.other; ptr; ptr = ptr->next) { - if (ptr->type == MOTD_CLASS && ptr->id.class == class) + if (ptr->type == MOTD_CLASS && !match(ptr->id.hostmask, c_class)) return ptr; - else if (ptr->type == MOTD_HOSTMASK && + else if (ptr->type == MOTD_HOSTMASK && c_class != NULL && !match(ptr->id.hostmask, cli_sockhost(cptr))) return ptr; } Index: ircdh/ircd/s_conf.c diff -u ircdh/ircd/s_conf.c:1.11 ircdh/ircd/s_conf.c:1.12 --- ircdh/ircd/s_conf.c:1.11 Sat Jan 18 14:54:33 2003 +++ ircdh/ircd/s_conf.c Sun Jan 19 13:20:31 2003 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: s_conf.c,v 1.11 2003/01/18 22:54:33 zolty Exp $ + * $Id: s_conf.c,v 1.12 2003/01/19 21:20:31 zolty Exp $ */ #include "config.h" @@ -73,9 +73,12 @@ int GlobalConfCount = 0; struct qline *GlobalQuarantineList = 0; +void yyparse(void); +int conf_fd, lineno; + static struct LocalConf localConf; static struct CRuleConf *cruleConfList; -static struct ServerConf *serverConfList; +/* static struct ServerConf *serverConfList; */ static struct DenyConf *denyConfList; #ifdef ESNET_NEG struct ConfItem *conf_negociacion = 0; @@ -246,7 +249,7 @@ * Do (start) DNS lookups of all hostnames in the conf line and convert * an IP addresses in a.b.c.d number for to IP#s. */ -static void lookup_confhost(struct ConfItem *aconf) +void lookup_confhost(struct ConfItem *aconf) { struct DNSReply *reply; @@ -667,6 +670,7 @@ * * - looks for a match on all given fields. */ +#if 0 static struct ConfItem *find_conf_entry(struct ConfItem *aconf, unsigned int mask) { @@ -765,7 +769,9 @@ /* port vhost mask */ add_listener(atoi(fields[4]), fields[2], fields[1], is_server, is_hidden); } +#endif +#if 0 void conf_add_quarantine(const char *const *fields, int count) { struct qline *qline; @@ -780,6 +786,7 @@ qline->next = GlobalQuarantineList; GlobalQuarantineList = qline; } +#endif char *find_quarantine(const char *chname) { @@ -803,6 +810,7 @@ } } +#if 0 void conf_add_local(const char *const *fields, int count) { if (count < 6 || EmptyString(fields[1]) || EmptyString(fields[5])) @@ -891,6 +899,7 @@ cruleConfList = p; } } +#endif void conf_erase_crule_list(void) { @@ -913,6 +922,7 @@ return cruleConfList; } +#if 0 void conf_add_server(const char *const *fields, int count) { struct ServerConf *server; @@ -1015,6 +1025,7 @@ conf->next = denyConfList; denyConfList = conf; } +#endif void conf_erase_deny_list(void) { @@ -1047,8 +1058,21 @@ #define MAXCONFLINKS 150 +extern FILE *yyin; +void init_lexer(void); + int read_configuration_file(void) { + feature_unmark(); /* unmark all features for resetting later */ + /* Now just open an fd. The buffering isn't really needed... */ + init_lexer(); + yyparse(); + fclose(yyin); + yyin = NULL; + feature_mark(); /* reset unmarked features */ + return 1; + +#if 0 enum { MAX_FIELDS = 15 }; char *src; @@ -1392,6 +1416,15 @@ prepara_negociaciones(); #endif return 1; +#endif /* 0 */ +} + +void yyerror(const char *msg) +{ + sendto_opmask_butone(0, SNO_ALL, "Config file parse error line %d: %s", + lineno, msg); + log_write(LS_CONFIG, L_ERROR, 0, "Config file parse error line %d: %s", + lineno, msg); } /* Index: ircdh/ircd/s_err.c diff -u ircdh/ircd/s_err.c:1.8 ircdh/ircd/s_err.c:1.9 --- ircdh/ircd/s_err.c:1.8 Sat Jan 18 14:54:33 2003 +++ ircdh/ircd/s_err.c Sun Jan 19 13:20:31 2003 @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: s_err.c,v 1.8 2003/01/18 22:54:33 zolty Exp $ + * $Id: s_err.c,v 1.9 2003/01/19 21:20:31 zolty Exp $ */ #include "config.h" @@ -440,23 +440,23 @@ /* 200 */ {RPL_TRACELINK, "Link %s.%s %s %s", "200"}, /* 201 */ - {RPL_TRACECONNECTING, "Try. %d %s", "201"}, + {RPL_TRACECONNECTING, "Try. %s %s", "201"}, /* 202 */ - {RPL_TRACEHANDSHAKE, "H.S. %d %s", "202"}, + {RPL_TRACEHANDSHAKE, "H.S. %s %s", "202"}, /* 203 */ - {RPL_TRACEUNKNOWN, "???? %d %s", "203"}, + {RPL_TRACEUNKNOWN, "???? %s %s", "203"}, /* 204 */ - {RPL_TRACEOPERATOR, "Oper %d %s %ld", "204"}, + {RPL_TRACEOPERATOR, "Oper %s %s %ld", "204"}, /* 205 */ - {RPL_TRACEUSER, "User %d %s %ld", "205"}, + {RPL_TRACEUSER, "User %s %s %ld", "205"}, /* 206 */ - {RPL_TRACESERVER, "Serv %d %dS %dC %s %s!%s@%s %ld %ld", "206"}, + {RPL_TRACESERVER, "Serv %s %dS %dC %s %s!%s@%s %ld %ld", "206"}, /* 207 */ {0}, /* 208 */ {RPL_TRACENEWTYPE, "<newtype> 0 %s", "208"}, /* 209 */ - {RPL_TRACECLASS, "Class %d %d", "209"}, + {RPL_TRACECLASS, "Class %s %d", "209"}, /* 210 */ {0}, /* 211 */ @@ -464,17 +464,17 @@ /* 212 */ {RPL_STATSCOMMANDS, "%s %u %u", "212"}, /* 213 */ - {RPL_STATSCLINE, "%c %s * %s %d %d", "213"}, + {RPL_STATSCLINE, "%c %s * %s %d %s", "213"}, /* 214 */ {RPL_STATSNLINE, "%c %s * %s %d %d", "214"}, /* 215 */ - {RPL_STATSILINE, "%c %s * %s %d %d", "215"}, + {RPL_STATSILINE, "%c %s * %s %d %s", "215"}, /* 216 */ {RPL_STATSKLINE, "%c %s \"%s\" %s 0 0", "216"}, /* 217 */ {RPL_STATSPLINE, "P %d %d %s %s", "217"}, /* 218 */ - {RPL_STATSYLINE, "%c %d %d %d %ld (%d) %d", "218"}, + {RPL_STATSYLINE, "%c %s %d %d %ld (%d) %d", "218"}, /* 219 */ {RPL_ENDOFSTATS, "%c :End of /STATS report", "219"}, /* 220 */ Index: ircdh/ircd/s_stats.c diff -u ircdh/ircd/s_stats.c:1.2 ircdh/ircd/s_stats.c:1.3 --- ircdh/ircd/s_stats.c:1.2 Sat Jan 18 14:54:33 2003 +++ ircdh/ircd/s_stats.c Sun Jan 19 13:20:31 2003 @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: s_stats.c,v 1.2 2003/01/18 22:54:33 zolty Exp $ + * $Id: s_stats.c,v 1.3 2003/01/19 21:20:31 zolty Exp $ */ #include "config.h" @@ -115,6 +115,15 @@ send_reply(sptr, p[1], c, host, pass, name, port, get_conf_class(tmp)); else if ((tmp->status & (CONF_SERVER | CONF_HUB))) send_reply(sptr, p[1], c, "*", name, port, get_conf_class(tmp)); + else if ((tmp->status & CONF_CLIENT)) + { + if (tmp->passwd && IsDigit(*tmp->passwd) && (!tmp->passwd[1] || + (IsDigit(tmp->passwd[1]) && !tmp->passwd[2]))) + send_reply(sptr, p[1], c, host, pass, name, port, + get_conf_class(tmp)); + else + send_reply(sptr, p[1], c, host, "*", name, port, get_conf_class(tmp)); + } else send_reply(sptr, p[1], c, host, name, port, get_conf_class(tmp)); } ----------------------- End of diff ----------------------- |