From b6521be94946bdb488f23c71754ea34a29757b8f Mon Sep 17 00:00:00 2001 From: Danny Mitchell Date: Sun, 28 Nov 1999 01:36:32 +0000 Subject: [PATCH] Lets hope that I did this right :) BADCHAN patch, Remote usage defaults YES, local usage defaults NO. Warning is given, LOCAL USAGE is NOT approved for undernet. Author: WT Log message: git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@7 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 5 +- config/config-sh.in | 11 +++++ include/list.h | 3 ++ include/patchlevel.h | 2 +- include/s_conf.h | 1 + ircd/channel.c | 10 +++- ircd/list.c | 39 ++++++++++++++- ircd/opercmds.c | 114 ++++++++++++++++++++++++++++++------------- ircd/s_conf.c | 1 + ircd/s_debug.c | 6 +++ 10 files changed, 155 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4782e3..209dba1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,15 @@ # # ChangeLog for Undernet ircu Servers # -# $Id: ChangeLog,v 1.2 1999-11-25 02:07:53 bleep Exp $ +# $Id: ChangeLog,v 1.3 1999-11-28 01:36:25 danny Exp $ # # Please insert new entries on the top of the list, a one or two line comment # is sufficient. Please include your name on the entries we know who to blame. # Please keep lines < 80 chars. #------------------------------------------------------------------------------- +* list.h list.c s_conf.h s_conf.c opercmds.c: + badchan patch 2 seperate settings, allow global, and allow local. + currently allow_local is 'unapproved' for use on undernet. --WildThang * ircd.h, s_serv.h, s_debug.h, ircd.c, s_user.c, s_bsd.c: removed STAT_MASTER/BOOT_OPER code, original patch by Isomer --Bleep * s_user.c (m_nick): removed redundant check for acptr --Bleep diff --git a/config/config-sh.in b/config/config-sh.in index dee9749..3fabcb4 100644 --- a/config/config-sh.in +++ b/config/config-sh.in @@ -227,6 +227,17 @@ comment 'Logging (filenames are either full paths or files within DPATH)' if [ "$CONFIG_LOG_WHOX" = "y" ]; then string ' Give the path and(or) filename of this log file' WPATH 'whox.log' fi + + comment 'Bad Channel G-Lines allow operators to add channel masks to a list which prohibits local clients from being able joining channels which match the mask. Remote BadChan Glines allow Uworld to add or remove channels from the servers internal list of badchans' + WT_BADCHAN=y + bool 'Do you want to enable Bad Channel G-lines' WT_BADCHAN + if [ "$WT_BADCHAN" = "y" ]; then + echo " " + echo " WARNING DO _NOT_ USE LOCAL BADCHANNEL GLINES ON UNDERNET" + echo " Use of LOCAL BAD Channel G-Lines can be cause for REMOVAL" + bool 'Allow LOCAL BAD Channel G-lines' WT_LOCAL_BADCHAN + fi + bool 'Do you want to log G-lines to a separate file' CONFIG_LOG_GLINES if [ "$CONFIG_LOG_GLINES" = "y" ]; then string ' Give the path and(or) filename of this log file' GPATH 'gline.log' diff --git a/include/list.h b/include/list.h index ef61f3a..5f3a5f9 100644 --- a/include/list.h +++ b/include/list.h @@ -66,5 +66,8 @@ extern aGline *make_gline(int is_ipmask, char *host, char *reason, char *name, extern aGline *find_gline(aClient *cptr, aGline **pgline); extern void free_gline(aGline *agline, aGline *pgline); extern void send_listinfo(aClient *cptr, char *name); +#ifdef WT_BADCHAN +extern int bad_channel(char *name); +#endif #endif /* LIST_H */ diff --git a/include/patchlevel.h b/include/patchlevel.h index 700d74f..531b25f 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -49,7 +49,7 @@ \ \ \ - "" + ".bc" /* * Deliberate empty lines diff --git a/include/s_conf.h b/include/s_conf.h index e67aa4a..bedc3dc 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -116,6 +116,7 @@ extern aMotdItem *read_motd(char *motdfile); extern aConfItem *conf; extern aGline *gline; +extern aGline *badchan; extern struct tm motd_tm; extern aMotdItem *motd; extern aMotdItem *rmotd; diff --git a/ircd/channel.c b/ircd/channel.c index c917cdc..cbd44d9 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -2263,7 +2263,15 @@ int m_join(aClient *cptr, aClient *sptr, int parc, char *parv[]) } if (MyConnect(sptr)) - { + { +#ifdef WT_BADCHAN + if(bad_channel(name) && !IsAnOper(sptr)) + { + sendto_one(sptr, err_str(ERR_CHANNELISFULL), me.name, parv[0],name); + continue; + } +#endif + /* * Local client is first to enter previously nonexistant * channel so make them (rightfully) the Channel Operator. diff --git a/ircd/list.c b/ircd/list.c index 36d4030..2e4a23b 100644 --- a/ircd/list.c +++ b/ircd/list.c @@ -389,6 +389,10 @@ aGline *make_gline(int is_ipmask, char *host, char *reason, char *name, time_t expire) { Reg4 aGline *agline; +#ifdef WT_BADCHAN + int gtype=0; + if(*host == '#') gtype=1; /* BAD CHANNEL GLINE */ +#endif agline = (struct Gline *)RunMalloc(sizeof(aGline)); /* alloc memory */ DupString(agline->host, host); /* copy vital information */ @@ -398,6 +402,13 @@ aGline *make_gline(int is_ipmask, char *host, char *reason, agline->gflags = GLINE_ACTIVE; /* gline is active */ if (is_ipmask) SetGlineIsIpMask(agline); + +#ifdef WT_BADCHAN + if(gtype) + { agline->next = badchan; /* link it into the list */ + return (badchan = agline); + } +#endif agline->next = gline; /* link it into the list */ return (gline = agline); } @@ -442,7 +453,16 @@ void free_gline(aGline *agline, aGline *pgline) if (pgline) pgline->next = agline->next; /* squeeze agline out */ else - gline = agline->next; + { +#ifdef WT_BADCHAN + if(*agline->host =='#') + { + badchan = agline->next; + } + else +#endif + gline = agline->next; + } RunFree(agline->host); /* and free up the memory */ RunFree(agline->reason); @@ -450,6 +470,23 @@ void free_gline(aGline *agline, aGline *pgline) RunFree(agline); } +#ifdef WT_BADCHAN +int bad_channel(char *name) +{ aGline *agline; + + agline=badchan; + while(agline) + { + if ((agline->gflags&GLINE_ACTIVE) && (agline->expire >TStime()) && + !mmatch(agline->host,name)) + { return 1; + } + agline=agline->next; + } + return 0; +} +#endif + #ifdef DEBUGMODE void send_listinfo(aClient *cptr, char *name) { diff --git a/ircd/opercmds.c b/ircd/opercmds.c index 53098fd..96e8d51 100644 --- a/ircd/opercmds.c +++ b/ircd/opercmds.c @@ -1470,27 +1470,38 @@ static void add_gline(aClient *sptr, int ip_mask, char *host, char *comment, { aClient *acptr; aGline *agline; - int fd; + int fd,gtype=0; +#ifdef WT_BADCHAN + if(*host=='#') + gtype=1; /* BAD CHANNEL */ +#endif /* Inform ops */ sendto_op_mask(SNO_GLINE, - "%s adding %sGLINE for %s@%s, expiring at " TIME_T_FMT ": %s", sptr->name, - local ? "local " : "", user, host, expire, comment); + "%s adding %s%s for %s@%s, expiring at " TIME_T_FMT ": %s", sptr->name, + local ? "local " : "", + gtype ? "BADCHAN":"GLINE", user, host, expire, comment); #ifdef GPATH write_log(GPATH, - "# " TIME_T_FMT " %s adding %s GLINE for %s@%s, expiring at " TIME_T_FMT + "# " TIME_T_FMT " %s adding %s %s for %s@%s, expiring at " TIME_T_FMT ": %s\n", TStime(), sptr->name, local ? "local" : "global", - user, host, expire, comment); + gtype ? "BADCHAN" : "GLINE", user, host, expire, comment); /* this can be inserted into the conf */ - write_log(GPATH, "%c:%s:%s:%s\n", ip_mask ? 'k' : 'K', host, comment, user); + if(!gtype) + write_log(GPATH, "%c:%s:%s:%s\n", ip_mask ? 'k' : 'K', host, comment, + user); #endif /* GPATH */ agline = make_gline(ip_mask, host, comment, user, expire); if (local) SetGlineIsLocal(agline); +#ifdef WT_BADCHAN + if(gtype) return; +#endif + for (fd = highest_fd; fd >= 0; --fd) /* get the users! */ if ((acptr = loc_clients[fd]) && !IsMe(acptr)) { @@ -1548,7 +1559,7 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) aGline *agline, *a2gline; char *user, *host; - int active, ip_mask; + int active, ip_mask,gtype = 0; time_t expire = 0; /* Remove expired G-lines */ @@ -1565,6 +1576,23 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) a2gline = agline; } +#ifdef WT_BADCHAN + /* Remove expired bad channels */ + for (agline = badchan, a2gline = NULL; agline; agline = agline->next) + { + if (agline->expire <= TStime()) + { + free_gline(agline, a2gline); + agline = a2gline ? a2gline : badchan; + if (!agline) + break; + continue; + } + a2gline = agline; + } +#endif + + if (IsServer(cptr)) { if (find_conf_host(cptr->confs, sptr->name, CONF_UWORLD)) @@ -1585,9 +1613,9 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) parv[2]++; /* step past mode indicator */ /* forward the message appropriately */ - if (!strCasediff(parv[1], "*")) + if (!strCasediff(parv[1], "*")) /* global! */ sendto_serv_butone(cptr, active ? ":%s GLINE %s +%s %s :%s" : - ":%s GLINE %s -%s", parv[0], parv[1], parv[2], parv[3], parv[4]); /* global! */ + ":%s GLINE %s -%s", parv[0], parv[1], parv[2], parv[3], parv[4]); else if (( #if 1 /* @@ -1625,8 +1653,12 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) *(host++) = '\0'; /* break up string at the '@' */ } ip_mask = check_if_ipmask(host); /* Store this boolean */ +#ifdef WT_BADCHAN + if(*host == '#') gtype=1; /* BAD CHANNEL GLINE */ +#endif - for (agline = gline, a2gline = NULL; agline; agline = agline->next) + for (agline = (gtype)?badchan:gline, a2gline = NULL; agline; + agline = agline->next) { if (!strCasediff(agline->name, user) && !strCasediff(agline->host, host)) @@ -1636,12 +1668,14 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) if (!active && agline) { /* removing the gline */ - sendto_op_mask(SNO_GLINE, "%s removing GLINE for %s@%s", parv[0], - agline->name, agline->host); /* notify opers */ + /* notify opers */ + sendto_op_mask(SNO_GLINE, "%s removing %s for %s@%s", parv[0], + gtype?"BADCHAN":"GLINE",agline->name, agline->host); #ifdef GPATH - write_log(GPATH, "# " TIME_T_FMT " %s removing GLINE for %s@%s\n", - TStime(), parv[0], agline->name, agline->host); + write_log(GPATH, "# " TIME_T_FMT " %s removing %s for %s@%s\n", + TStime(), parv[0], gtype?"BADCHAN":"GLINE",agline->name, + agline->host); #endif /* GPATH */ free_gline(agline, a2gline); /* remove the gline */ @@ -1653,20 +1687,22 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) { /* new expire time? */ /* yes, notify the opers */ sendto_op_mask(SNO_GLINE, - "%s resetting expiration time on GLINE for %s@%s to " TIME_T_FMT, - parv[0], agline->name, agline->host, expire); + "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT, + parv[0], gtype?"BADCHAN":"GLINE",agline->name, agline->host, + expire); #ifdef GPATH write_log(GPATH, "# " TIME_T_FMT " %s resetting expiration time " - "on GLINE for %s@%s to " TIME_T_FMT "\n", - TStime(), parv[0], agline->name, agline->host, expire); + "on %s for %s@%s to " TIME_T_FMT "\n", + TStime(), parv[0], gtype?"BADCHAN":"GLINE", + agline->name, agline->host, expire); #endif /* GPATH */ agline->expire = expire; /* reset the expire time */ } else if (!agline) { /* create gline */ - for (agline = gline; agline; agline = agline->next) + for (agline = gtype?badchan:gline; agline; agline = agline->next) if (!mmatch(agline->name, user) && (ip_mask ? GlineIsIpMask(agline) : !GlineIsIpMask(agline)) && !mmatch(agline->host, host)) @@ -1731,8 +1767,17 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) *(host++) = '\0'; /* break up string at the '@' */ } ip_mask = check_if_ipmask(host); /* Store this boolean */ +#ifdef WT_BADCHAN + if(*host == '#') +#ifndef WT_LOCAL_BADCHAN + return 0; +#else + gtype=1; /* BAD CHANNEL */ +#endif +#endif - for (agline = gline, a2gline = NULL; agline; agline = agline->next) + for (agline = gtype?badchan:gline, a2gline = NULL; agline; + agline = agline->next) { if (!mmatch(agline->name, user) && (ip_mask ? GlineIsIpMask(agline) : !GlineIsIpMask(agline)) && @@ -1787,12 +1832,13 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) else if (GlineIsLocal(agline)) { /* Remove local G-line */ - sendto_op_mask(SNO_GLINE, "%s removed local GLINE for %s@%s", - parv[0], agline->name, agline->host); + sendto_op_mask(SNO_GLINE, "%s removed local %s for %s@%s", + parv[0], gtype?"BADCHAN":"GLINE",agline->name, agline->host); #ifdef GPATH write_log(GPATH, "# " TIME_T_FMT - " %s!%s@%s removed local GLINE for %s@%s\n", + " %s!%s@%s removed local %s for %s@%s\n", TStime(), parv[0], cptr->user->username, cptr->user->host, + gtype?"BADCHAN":"GLINE", agline->name, agline->host); #endif /* GPATH */ free_gline(agline, a2gline); /* remove the gline */ @@ -1811,30 +1857,32 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) /* inform the operators what's up */ if (active != -1) { /* changing the activation */ - sendto_op_mask(SNO_GLINE, !expire ? "%s %sactivating GLINE for %s@%s" : - "%s %sactivating GLINE for %s@%s and " + sendto_op_mask(SNO_GLINE, !expire ? "%s %sactivating %s for %s@%s" : + "%s %sactivating %s for %s@%s and " "resetting expiration time to " TIME_T_FMT, - parv[0], active ? "re" : "de", agline->name, + parv[0], active ? "re" : "de", gtype?"BADCHAN":"GLINE",agline->name, agline->host, agline->expire); #ifdef GPATH write_log(GPATH, !expire ? "# " TIME_T_FMT " %s!%s@%s %sactivating " - "GLINE for %s@%s\n" : "# " TIME_T_FMT " %s!%s@%s %sactivating GLINE " + "%s for %s@%s\n" : "# " TIME_T_FMT " %s!%s@%s %sactivating %s " "for %s@%s and resetting expiration time to " TIME_T_FMT "\n", TStime(), parv[0], cptr->user->username, cptr->user->host, - active ? "re" : "de", agline->name, agline->host, agline->expire); + active ? "re" : "de", gtype?"BADCHAN":"GLINE",agline->name, + agline->host, agline->expire); #endif /* GPATH */ } else if (expire) { /* changing only the expiration */ sendto_op_mask(SNO_GLINE, - "%s resetting expiration time on GLINE for %s@%s to " TIME_T_FMT, - parv[0], agline->name, agline->host, agline->expire); + "%s resetting expiration time on %s for %s@%s to " TIME_T_FMT, + parv[0], gtype?"BADCHAN":"GLINE",agline->name, agline->host, + agline->expire); #ifdef GPATH write_log(GPATH, "# " TIME_T_FMT " %s!%s@%s resetting expiration " - "time on GLINE for %s@%s to " TIME_T_FMT "\n", TStime(), parv[0], - cptr->user->username, cptr->user->host, agline->name, - agline->host, agline->expire); + "time on %s for %s@%s to " TIME_T_FMT "\n", TStime(), parv[0], + cptr->user->username, cptr->user->host,gtype?"BADCHAN":"GLINE", + agline->name, agline->host, agline->expire); #endif /* GPATH */ } } diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 4c5e3f2..3409ef9 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -81,6 +81,7 @@ static void killcomment(aClient *sptr, char *parv, char *filename); aConfItem *conf = NULL; aGline *gline = NULL; +aGline *badchan = NULL; aMotdItem *motd = NULL; aMotdItem *rmotd = NULL; atrecord *tdata = NULL; diff --git a/ircd/s_debug.c b/ircd/s_debug.c index 39940ae..9a4b051 100644 --- a/ircd/s_debug.c +++ b/ircd/s_debug.c @@ -158,6 +158,12 @@ char serveropts[] = { #ifdef VIRTUAL_HOST 'v', #endif +#ifdef WT_BADCHAN + 'W', +#ifdef WT_LOCAL_BADCHAN + 't', +#endif +#endif #ifdef UNIXPORT 'X', #endif -- 2.20.1