Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Mon, 12 Feb 2001 18:47:45 +0000 (18:47 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Mon, 12 Feb 2001 18:47:45 +0000 (18:47 +0000)
Log message:

Fix G-line bugs reguarding U-lined servers that Maniac- pointed out; fix a
bug in /list

1) If a new server signed on and a U-lined server re-issued a G-line,
   intermediate servers would not pass on that message.  Logic has been
   added to detect that it's a re-issued G-line, and the existing G-line is
   repropagated.  Note that the expire time used is the time we think the
   G-line has left, not what the U-lined server tells us.
2) If a U-lined server attempted to revoke a G-line, and we didn't have
   that G-line, not only would we ignore the message, we would fail to
   propagate it and return a "not enough parameters" reply.  Corrected by
   manually repropagating the G-line removal.
3) If a U-lined server attempted to add (or update, or re-issue) a G-line
   we knew about, that G-line's lastmod time would be updated, causing us
   to no longer consider the G-line as having been issued by a U-lined
   server.  This causes promotions we don't want occuring.  Corrected by
   prohibiting lastmod updates when the existing lastmod is 0.
4) The /list command would not deal properly with "LIST #channel", but
   would do the right thing if we did "LIST #channel <anything else>".
   This was just a logic inversion problem--I said "parc != 2" when I meant
   "parc == 2".

Testing:

The /list command now works correctly.  G-lines issued by U-lined servers
are doing the right thing.  I have not checked that G-lines issued by opers
are still working correctly, so this needs to be checked.  Also, all forms
of local G-line need to be double-checked.

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

ChangeLog
include/gline.h
ircd/gline.c
ircd/m_gline.c
ircd/m_list.c

index 76d6d35b372b85884fc069455b8bac6d6d2360d1..2494ab15a873cd9735beaab6b40a2d86b7ff5c39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2001-02-12  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/m_gline.c (ms_gline): propagate a G-line that happened to
+       have been added by a U-lined server, rather than going through the
+       activate/deactivate logic; propagate G-line removals by U-lined
+       servers as well
+
+       * ircd/gline.c: rename propagate_gline() to gline_propagate();
+       make gline_propagate() return an int 0 (convenience return); only
+       update lastmod in gline_activate() and gline_deactivate() if the
+       current lastmod is non-zero, since 0 lastmod is our flag of a
+       U-lined server having added a G-line
+
+       * include/gline.h (gline_propagate): exporting the G-line
+       propagation function
+
+       * ircd/m_list.c (m_list): duh; permit explicit channel name
+       specification only when /list gets two arguments ("Kev
+       #wasteland") rather than when /list gets more than two
+       arguments--nice braino
+
 2001-01-29  Thomas Helvey <twhelvey1@home.com>
 
        * ircd/ircd_reply.c (need_more_params): fix bug that allowed
index 4a904664b0f57a88058a18d2844b13d7c1ef2a39..d0dc65aaf9c53603f1b5c03e9e71d7063ffe51ed 100644 (file)
@@ -75,6 +75,8 @@ struct Gline {
 #define GlineReason(g)         ((g)->gl_reason)
 #define GlineLastMod(g)                ((g)->gl_lastmod)
 
+extern int gline_propagate(struct Client *cptr, struct Client *sptr,
+                          struct Gline *gline);
 extern int gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
                     char *reason, time_t expire, time_t lastmod,
                     unsigned int flags);
index 6746af259568eb9f72fbb5397f823957c183f879..86821456d3cfa45e5cfa1e2cdbe79d0f0f382baa 100644 (file)
@@ -199,11 +199,11 @@ do_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
   return retval;
 }
 
-static void
-propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
+int
+gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline)
 {
   if (GlineIsLocal(gline) || (IsUser(sptr) && !gline->gl_lastmod))
-    return;
+    return 0;
 
   if (gline->gl_lastmod)
     sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
@@ -219,6 +219,8 @@ propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
                          gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
                          GlineIsBadChan(gline) ? "" : gline->gl_host,
                          gline->gl_expire - CurrentTime, gline->gl_reason);
+
+  return 0;
 }
 
 int 
@@ -275,7 +277,7 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
   if (!agline) /* if it overlapped, silently return */
     return 0;
 
-  propagate_gline(cptr, sptr, agline);
+  gline_propagate(cptr, sptr, agline);
 
   if (GlineIsBadChan(agline))
     return 0;
@@ -298,10 +300,12 @@ gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
   else {
     gline->gl_flags |= GLINE_ACTIVE;
 
-    if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
-      gline->gl_lastmod++;
-    else
-      gline->gl_lastmod = lastmod;
+    if (gline->gl_lastmod) {
+      if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
+       gline->gl_lastmod++;
+      else
+       gline->gl_lastmod = lastmod;
+    }
   }
 
   if ((saveflags & GLINE_ACTMASK) == GLINE_ACTIVE)
@@ -324,7 +328,7 @@ gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
            gline->gl_expire + TSoffset, gline->gl_reason);
 
   if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
-    propagate_gline(cptr, sptr, gline);
+    gline_propagate(cptr, sptr, gline);
 
   return GlineIsBadChan(gline) ? 0 : do_gline(cptr, sptr, gline);
 }
@@ -353,10 +357,12 @@ gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
     else {
       gline->gl_flags &= ~GLINE_ACTIVE;
 
-      if (gline->gl_lastmod >= lastmod)
-       gline->gl_lastmod++;
-      else
-       gline->gl_lastmod = lastmod;
+      if (gline->gl_lastmod) {
+       if (gline->gl_lastmod >= lastmod)
+         gline->gl_lastmod++;
+       else
+         gline->gl_lastmod = lastmod;
+      }
     }
 
     if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE)
@@ -380,7 +386,7 @@ gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
            gline->gl_expire + TSoffset, gline->gl_reason);
 
   if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
-    propagate_gline(cptr, sptr, gline);
+    gline_propagate(cptr, sptr, gline);
 
   /* if it's a local gline or a Uworld gline (and not locally deactivated).. */
   if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL)))
index 6a5f1e037cc0cb135cc78b89718c50394f49d8f4..cc87f3ceb17ee5b4687635f4d38d984a6721e5cf 100644 (file)
@@ -180,6 +180,8 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   if (agline) {
     if (GlineIsLocal(agline) && !(flags & GLINE_LOCAL)) /* global over local */
       gline_free(agline);
+    else if (!lastmod && ((flags & GLINE_ACTIVE) == GlineIsRemActive(agline)))
+      return gline_propagate(cptr, sptr, agline);
     else if (!lastmod || GlineLastMod(agline) < lastmod) { /* new mod */
       if (flags & GLINE_ACTIVE)
        return gline_activate(cptr, sptr, agline, lastmod, flags);
@@ -189,6 +191,13 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       return 0;
     else
       return gline_resend(cptr, agline); /* other server desynched WRT gline */
+  } else if (parc == 3 && !(flags & GLINE_ACTIVE)) {
+    /* U-lined server removing a G-line we don't have; propagate the removal
+     * anyway.
+     */
+    if (!(flags & GLINE_LOCAL))
+      sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* -%s", mask);
+    return 0;
   } else if (parc < 5)
     return need_more_params(sptr, "GLINE");
 
index 6007f7e172d0b56e709ce0f0916d4ea63cb3d2ee..0270d00f1637913ff603176ac139a6eb2b38e440 100644 (file)
@@ -295,7 +295,7 @@ int m_list(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     args = la_init; /* initialize argument to blank slate */
 
     for (param = 1; parv[param]; param++) { /* process each parameter */
-      switch (param_parse(sptr, parv[param], &args, parc != 2)) {
+      switch (param_parse(sptr, parv[param], &args, parc == 2)) {
       case LPARAM_ERROR: /* error encountered, usage already sent, return */
        return 0;
        break;