Lets hope that I did this right :)
authorDanny Mitchell <danny@chatsystems.com>
Sun, 28 Nov 1999 01:36:32 +0000 (01:36 +0000)
committerDanny Mitchell <danny@chatsystems.com>
Sun, 28 Nov 1999 01:36:32 +0000 (01:36 +0000)
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
config/config-sh.in
include/list.h
include/patchlevel.h
include/s_conf.h
ircd/channel.c
ircd/list.c
ircd/opercmds.c
ircd/s_conf.c
ircd/s_debug.c

index c4782e384325539e41df0d73680995b24d8db7d4..209dba1566e8d6746e7d20eb4bda461c0f7a444d 100644 (file)
--- 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
index dee97490841f8aed5fa1dc3a81ba4b252f7f111c..3fabcb4f7c02bde8a3860dc16b67621f27946da3 100644 (file)
@@ -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'
index ef61f3a88382c37ca60acac51b04084eab57f024..5f3a5f972b1613bbc0a03b71e64ec40049cfc0db 100644 (file)
@@ -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 */
index 700d74fb2487690c52cc571a811691187990480d..531b25fda251d1202ffacf2eb79e891d6f9cca26 100644 (file)
@@ -49,7 +49,7 @@
                \
                \
                \
-               ""
+               ".bc"
 
 /*
  * Deliberate empty lines
index e67aa4a7b9db0edd316a3d36dc56de884a61f239..bedc3dc113219a136a38601672781688327b207d 100644 (file)
@@ -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;
index c917cdcbe37ef7414d8e18da63fc22a2ec673eec..cbd44d92202f1beb158d6e3f9aa48d5a3d8516f2 100644 (file)
@@ -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.
index 36d4030bedd874c5419e61330807ec3722e15d04..2e4a23bcafa79a34be70ffea403a4076ede35ab6 100644 (file)
@@ -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)
 {
index 53098fdb6029c94f82ff2951ab225e6d568a0a87..96e8d5158181dc4d086eee5ea5adda0bedb8e8c9 100644 (file)
@@ -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 */
     }
   }
index 4c5e3f23646fa0829dc5d96a02e73d44b04f9295..3409ef99384020e147fdd12e17731efd71b62c49 100644 (file)
@@ -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;
index 39940ae0f0bfecfc85474636390e99a45ee39a72..9a4b0519ab58917e89d6bc1c2f3d5c834c60ff26 100644 (file)
@@ -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