Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2005-04-17 02:58:08 UTC

Modified files:
     ChangeLog doc/example.conf include/s_conf.h ircd/ircd_parser.y
     ircd/s_conf.c ircd/s_err.c ircd/s_stats.c

Log message:

Make realname Kill blocks more predictable, and add username="x" field.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.598 ircu2.10/ChangeLog:1.599
--- ircu2.10/ChangeLog:1.598    Sat Apr 16 19:18:55 2005
+++ ircu2.10/ChangeLog  Sat Apr 16 19:57:55 2005
@@ -1,3 +1,24 @@
+2005-04-16  Michael Poole <[EMAIL PROTECTED]>
+
+       * doc/example.conf (Kill): Document newly supported syntax.
+
+       * include/s_conf.h (DenyConf): Split realname mask into its own
+       field.  Remove the unused DENY_FLAGS_{IP,REALNAME}.
+
+       * ircd/ircd_parser.y (Kill): Only require one of usermask,
+       hostmask, realmask to be set for a valid block.
+       (killitem): Add new production killusername.
+
+       * ircd/s_conf.c (conf_erase_deny_list): Free realmask field.
+       (find_kill): Rearrange slightly to clarify control flow.
+
+       * ircd/s_err.c (RPL_STATSKLINE): Stick usermask before hostmask,
+       so the old usermask field can be adopted for realname mask.  Add
+       double quotes around the realmask field.
+
+       * ircd/s_stats.c (report_deny_list): Do so.
+       (stats_klines): Likewise.
+
 2005-04-17  Perry Lorier <[EMAIL PROTECTED]>
        
        * tools/convert-conf.py: Fix lots of conversion problems with
Index: ircu2.10/doc/example.conf
diff -u ircu2.10/doc/example.conf:1.53 ircu2.10/doc/example.conf:1.54
--- ircu2.10/doc/example.conf:1.53      Fri Apr 15 18:53:09 2005
+++ ircu2.10/doc/example.conf   Sat Apr 16 19:57:56 2005
@@ -483,8 +483,12 @@
 Kill { host = "*.au"; reason = "Please use a nearer server"; };
 Kill { host = "*.edu"; reason = "Please use a nearer server"; };
 
+# You can also kill based on username.
+Kill { username = "sub7"; realname = "s*7*"; reason = "You are infected with a 
Trojan";
+
 # The file can contain for example, a reason, a link to the
-# server rules and a contact address.
+# server rules and a contact address.  Note the combination
+# of username and host in the host field.
 Kill
 {
  host = "[EMAIL PROTECTED]";
Index: ircu2.10/include/s_conf.h
diff -u ircu2.10/include/s_conf.h:1.31 ircu2.10/include/s_conf.h:1.32
--- ircu2.10/include/s_conf.h:1.31      Fri Apr  8 20:37:15 2005
+++ ircu2.10/include/s_conf.h   Sat Apr 16 19:57:57 2005
@@ -1,6 +1,6 @@
 /** @file s_conf.h
  * @brief ircd configuration file API.
- * @version $Id: s_conf.h,v 1.31 2005/04/09 03:37:15 entrope Exp $
+ * @version $Id: s_conf.h,v 1.32 2005/04/17 02:57:57 entrope Exp $
  */
 #ifndef INCLUDED_s_conf_h
 #define INCLUDED_s_conf_h
@@ -80,17 +80,16 @@
 /** Local K-line structure. */
 struct DenyConf {
   struct DenyConf*    next;     /**< Next DenyConf in #denyConfList. */
-  char*               hostmask; /**< Mask for realname, IP or hostname. */
+  char*               hostmask; /**< Mask for  IP or hostname. */
   char*               message;  /**< Message to send to denied users. */
   char*               usermask; /**< Mask for client's username. */
+  char*               realmask; /**< Mask for realname. */
   struct irc_in_addr  address;  /**< Address for IP-based denies. */
   unsigned int        flags;    /**< Interpretation flags for the above.  */
   unsigned char       bits;     /**< Number of bits for ipkills */
 };
 
 #define DENY_FLAGS_FILE     0x0001 /**< Comment is a filename */
-#define DENY_FLAGS_IP       0x0002 /**< K-line by IP address */
-#define DENY_FLAGS_REALNAME 0x0004 /**< K-line by real name */
 
 /** Local server configuration. */
 struct LocalConf {
Index: ircu2.10/ircd/ircd_parser.y
diff -u ircu2.10/ircd/ircd_parser.y:1.46 ircu2.10/ircd/ircd_parser.y:1.47
--- ircu2.10/ircd/ircd_parser.y:1.46    Sat Apr 16 06:17:19 2005
+++ ircu2.10/ircd/ircd_parser.y Sat Apr 16 19:57:57 2005
@@ -17,7 +17,7 @@
  *  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.46 2005/04/16 13:17:19 entrope Exp $
+ * $Id: ircd_parser.y,v 1.47 2005/04/17 02:57:57 entrope Exp $
  */
 %{
 
@@ -732,16 +732,15 @@
   dconf = (struct DenyConf*) MyCalloc(1, sizeof(*dconf));
 } '{' killitems '}'
 {
-  if (dconf->hostmask != NULL)
-  {
-    if (dconf->usermask == NULL)
-      DupString(dconf->usermask, "*");
+  if (dconf->usermask || dconf->hostmask ||dconf->realmask) {
     dconf->next = denyConfList;
     denyConfList = dconf;
   }
   else
   {
+    MyFree(dconf->usermask);
     MyFree(dconf->hostmask);
+    MyFree(dconf->realmask);
     MyFree(dconf->message);
     MyFree(dconf);
     parse_error("Bad kill block");
@@ -749,11 +748,10 @@
   dconf = NULL;
 } ';';
 killitems: killitem killitems | killitem;
-killitem: killuhost | killreal | killreasonfile | killreason | error;
+killitem: killuhost | killreal | killusername | killreasonfile | killreason | 
error;
 killuhost: HOST '=' QSTRING ';'
 {
   char *u, *h;
-  dconf->flags &= ~DENY_FLAGS_REALNAME;
   MyFree(dconf->hostmask);
   MyFree(dconf->usermask);
   if ((h = strchr($3, '@')) == NULL)
@@ -771,13 +769,16 @@
   ipmask_parse(dconf->hostmask, &dconf->address, &dconf->bits);
 };
 
+killusername: USERNAME '=' QSTRING ';'
+{
+  MyFree(dconf->usermask);
+  DupString(dconf->usermask, $3);
+};
+
 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, $3);
+ MyFree(dconf->realmask);
+ DupString(dconf->realmask, $3);
 };
 
 killreason: REASON '=' QSTRING ';'
Index: ircu2.10/ircd/s_conf.c
diff -u ircu2.10/ircd/s_conf.c:1.74 ircu2.10/ircd/s_conf.c:1.75
--- ircu2.10/ircd/s_conf.c:1.74 Sat Apr 16 06:17:19 2005
+++ ircu2.10/ircd/s_conf.c      Sat Apr 16 19:57:57 2005
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief ircd configuration file driver
- * @version $Id: s_conf.c,v 1.74 2005/04/16 13:17:19 entrope Exp $
+ * @version $Id: s_conf.c,v 1.75 2005/04/17 02:57:57 entrope Exp $
  */
 #include "config.h"
 
@@ -756,6 +756,7 @@
     MyFree(p->hostmask);
     MyFree(p->usermask);
     MyFree(p->message);
+    MyFree(p->realmask);
     MyFree(p);
   }
   denyConfList = 0;
@@ -1016,28 +1017,16 @@
    *             -- Isomer
    */
   for (deny = denyConfList; deny; deny = deny->next) {
-    if (0 != match(deny->usermask, name))
+    if (deny->usermask && match(deny->usermask, name))
+      continue;
+    if (deny->realmask && match(deny->realmask, realname))
+      continue;
+    if (deny->bits > 0) {
+      if (!ipmask_check(&cli_ip(cptr), &deny->address, deny->bits))
+        continue;
+    } else if (deny->hostmask && match(deny->hostmask, host))
       continue;
 
-    if (EmptyString(deny->hostmask))
-      break;
-
-    if (deny->flags & DENY_FLAGS_REALNAME) { /* K: by real name */
-      if (0 == match(deny->hostmask, realname))
-       break;
-    } else if (deny->flags & DENY_FLAGS_IP) { /* k: by IP */
-#ifdef DEBUGMODE
-      char tbuf1[SOCKIPLEN], tbuf2[SOCKIPLEN];
-      Debug((DEBUG_DEBUG, "ip: %s network: %s/%u",
-             ircd_ntoa_r(tbuf1, &cli_ip(cptr)), ircd_ntoa_r(tbuf2, 
&deny->address), deny->bits));
-#endif
-      if (ipmask_check(&cli_ip(cptr), &deny->address, deny->bits))
-        break;
-    }
-    else if (0 == match(deny->hostmask, host))
-      break;
-  }
-  if (deny) {
     if (EmptyString(deny->message))
       send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP,
                  ":Connection from your host is refused on this server.");
@@ -1047,19 +1036,17 @@
       else
         send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.", 
deny->message);
     }
+    return -1;
   }
-  else if ((agline = gline_lookup(cptr, 0))) {
+
+  if ((agline = gline_lookup(cptr, 0))) {
     /*
      * find active glines
      * added a check against the user's IP address to find_gline() -Kev
      */
     send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.", 
GlineReason(agline));
-  }
-
-  if (deny)
-    return -1;
-  if (agline)
     return -2;
+  }
 
   return 0;
 }
Index: ircu2.10/ircd/s_err.c
diff -u ircu2.10/ircd/s_err.c:1.65 ircu2.10/ircd/s_err.c:1.66
--- ircu2.10/ircd/s_err.c:1.65  Wed Apr  6 19:10:23 2005
+++ ircu2.10/ircd/s_err.c       Sat Apr 16 19:57:57 2005
@@ -18,7 +18,7 @@
  */
 /** @file
  * @brief Error handling support.
- * @version $Id: s_err.c,v 1.65 2005/04/07 02:10:23 entrope Exp $
+ * @version $Id: s_err.c,v 1.66 2005/04/17 02:57:57 entrope Exp $
  */
 #include "config.h"
 
@@ -464,7 +464,7 @@
 /* 215 */
   { RPL_STATSILINE, "I %s %d %s%s %d %s", "215" },
 /* 216 */
-  { RPL_STATSKLINE, "%c %s \"%s\" %s 0 0", "216" },
+  { RPL_STATSKLINE, "%c [EMAIL PROTECTED] \"%s\" \"%s\" 0 0", "216" },
 /* 217 */
   { RPL_STATSPLINE, "P %d %d %s %s", "217" },
 /* 218 */
Index: ircu2.10/ircd/s_stats.c
diff -u ircu2.10/ircd/s_stats.c:1.37 ircu2.10/ircd/s_stats.c:1.38
--- ircu2.10/ircd/s_stats.c:1.37        Fri Apr 15 18:53:11 2005
+++ ircu2.10/ircd/s_stats.c     Sat Apr 16 19:57:57 2005
@@ -62,7 +62,7 @@
 /** @file
  * @brief Report configuration lines and other statistics from this
  * server.
- * @version $Id: s_stats.c,v 1.37 2005/04/16 01:53:11 entrope Exp $
+ * @version $Id: s_stats.c,v 1.38 2005/04/17 02:57:57 entrope Exp $
  *
  * Note: The info is reported in the order the server uses
  *       it--not reversed as in ircd.conf!
@@ -194,8 +194,11 @@
 {
   const struct DenyConf* p = conf_get_deny_list();
   for ( ; p; p = p->next)
-    send_reply(to, RPL_STATSKLINE, (p->flags & DENY_FLAGS_IP) ? 'k' : 'K',
-               p->hostmask, p->message, p->usermask);
+    send_reply(to, RPL_STATSKLINE, p->bits > 0 ? 'k' : 'K',
+               p->usermask ? p->usermask : "*",
+               p->hostmask ? p->hostmask : "*",
+               p->message ? p->message : "(none)",
+               p->realmask ? p->realmask : "*");
 }
 
 /** Report K/k-lines to a user.
@@ -246,9 +249,11 @@
         (wilds && !mmatch(host, conf->hostmask) &&
          (!user || !mmatch(user, conf->usermask))))
     {
-      send_reply(sptr, RPL_STATSKLINE,
-                 (conf->flags & DENY_FLAGS_IP) ? 'k' : 'K',
-                 conf->hostmask, conf->message, conf->usermask);
+      send_reply(sptr, RPL_STATSKLINE, conf->bits > 0 ? 'k' : 'K',
+                 conf->usermask ? conf->usermask : "*",
+                 conf->hostmask ? conf->hostmask : "*",
+                 conf->message ? conf->message : "(none)",
+                 conf->realmask ? conf->realmask : "*");
       if (--count == 0)
         return;
     }
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to