Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Mon, 17 Apr 2000 17:07:01 +0000 (17:07 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Mon, 17 Apr 2000 17:07:01 +0000 (17:07 +0000)
Log message:

* ircd/gline.c: detect overlapping G-lines; if an existing, wider
gline expires after the new one will, we drop the new one,
otherwise we add the G-line after that one (so the wide one will
apply first); if the new one contains an existing G-line and if it
will expire after the existing one, we drop the existing one to
save memory

* ircd/m_gline.c (mo_gline): opers could issue remote local
glines when CONFIG_OPERCMDS was off; fixed

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@185 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/gline.c
ircd/m_gline.c

index c87c1cea6519b44d5df7cf4c53afdd56afa90115..b1ec2e7678d7018a42b694b34ddab79b2edbb1e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2000-04-17  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/gline.c: detect overlapping G-lines; if an existing, wider
+       gline expires after the new one will, we drop the new one,
+       otherwise we add the G-line after that one (so the wide one will
+       apply first); if the new one contains an existing G-line and if it
+       will expire after the existing one, we drop the existing one to
+       save memory
+
+       * ircd/m_gline.c (mo_gline): opers could issue remote local
+       glines when CONFIG_OPERCMDS was off; fixed
+
 2000-04-16  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/m_jupe.c (mo_jupe): allow target argument to be dropped if
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.92 2000-04-16 05:19:02 kev Exp $
+# $Id: ChangeLog,v 1.93 2000-04-17 17:07:01 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index f1ea9c26996a0e849c88009925c5cdbddb56cc6d..bdc50dfe9b0b8ae88e0f5e6115f4ba5ef6e370ef 100644 (file)
@@ -62,9 +62,32 @@ static struct Gline *
 make_gline(char *userhost, char *reason, time_t expire, time_t lastmod,
           unsigned int flags)
 {
-  struct Gline *gline;
+  struct Gline *gline, *sgline, *after = 0;
   char *user, *host;
 
+  if (!(flags & GLINE_BADCHAN)) { /* search for overlapping glines first */
+    canon_userhost(userhost, &user, &host, "*"); /* find user and host */
+
+    for (gline = GlobalGlineList; gline; gline = sgline) {
+      sgline = gline->gl_next;
+
+      if (gline->gl_expire <= CurrentTime)
+       gline_free(gline);
+      else if ((gline->gl_flags & GLINE_LOCAL) != (flags & GLINE_LOCAL))
+       continue;
+      else if (!mmatch(gline->gl_user, user) && /* gline contains new mask */
+              !mmatch(gline->gl_host, host)) {
+       if (expire <= gline->gl_expire) /* will expire before wider gline */
+         return 0;
+       else
+         after = gline; /* stick new gline after this one */
+      } else if (!mmatch(user, gline->gl_user) && /* new mask contains gline */
+                !mmatch(host, gline->gl_host) &&
+                gline->gl_expire <= expire) /* gline expires before new one */
+       gline_free(gline); /* save some memory */
+    }
+  }
+
   gline = (struct Gline *)MyMalloc(sizeof(struct Gline)); /* alloc memory */
   assert(0 != gline);
 
@@ -83,19 +106,25 @@ make_gline(char *userhost, char *reason, time_t expire, time_t lastmod,
       BadChanGlineList->gl_prev_p = &gline->gl_next;
     BadChanGlineList = gline;
   } else {
-    canon_userhost(userhost, &user, &host, "*"); /* find user and host */
-
     DupString(gline->gl_user, user); /* remember them... */
     DupString(gline->gl_host, host);
 
     if (check_if_ipmask(host)) /* mark if it's an IP mask */
       gline->gl_flags |= GLINE_IPMASK;
 
-    gline->gl_next = GlobalGlineList; /* then link it into list */
-    gline->gl_prev_p = &GlobalGlineList;
-    if (GlobalGlineList)
-      GlobalGlineList->gl_prev_p = &gline->gl_next;
-    GlobalGlineList = gline;
+    if (after) {
+      gline->gl_next = after->gl_next;
+      gline->gl_prev_p = &after->gl_next;
+      if (after->gl_next)
+       after->gl_next->gl_prev_p = &gline->gl_next;
+      after->gl_next = gline;
+    } else {
+      gline->gl_next = GlobalGlineList; /* then link it into list */
+      gline->gl_prev_p = &GlobalGlineList;
+      if (GlobalGlineList)
+       GlobalGlineList->gl_prev_p = &gline->gl_next;
+      GlobalGlineList = gline;
+    }
   }
 
   return gline;
@@ -226,6 +255,9 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
   /* make the gline */
   agline = make_gline(userhost, reason, expire, lastmod, flags);
 
+  if (!agline) /* if it overlapped, silently return */
+    return 0;
+
   propagate_gline(cptr, sptr, agline);
 
   if (GlineIsBadChan(agline))
index 7d82b5ab7c897c8115f4c36bdfd4dc5e6f9a64bb..81eac17814bb3bbc06a36f264353428ecf2f9b58 100644 (file)
@@ -254,6 +254,9 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
        return send_error_to_client(sptr, ERR_NOSUCHSERVER, target);
 
       if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
+#ifndef CONFIG_OPERCMDS
+       return send_error_to_client(sptr, ERR_DISABLED, "GLINE");
+#else
        if (!IsOper(sptr))
          return send_error_to_client(sptr, ERR_NOPRIVILEGES);
 
@@ -261,6 +264,7 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                      flags & GLINE_ACTIVE ? '?' : '-', mask, parv[3],
                      TStime(), reason);
        return 0;
+#endif
       }
 
       flags |= GLINE_LOCAL;