Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Thu, 13 Apr 2000 15:58:22 +0000 (15:58 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Thu, 13 Apr 2000 15:58:22 +0000 (15:58 +0000)
Log message:

Ok, with the exception of m_stats, being worked on by GW, this should
complete the actual coding of the gline patch; server still won't
compile until GW commits his changes, though, and I haven't compile-
checked the rest (GW promised to do that ;)

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

ChangeLog
include/handlers.h
ircd/gline.c
ircd/m_gline.c
ircd/parse.c
ircd/s_serv.c
ircd/s_user.c

index 5dbfba807b4a2eb627cfb3de0ca9feed9705eb7e..4dc058b18ffab03acd628dffd2e90de966399fa1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2000-04-13  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * include/handlers.h: declare m_gline()
+
+       * ircd/parse.c: gline can be called by users, but it only lists
+       the glines.
+
+       * ircd/s_user.c (set_nick_name): resend gline if a remote server
+       introduces a glined client
+
+       * ircd/s_serv.c (server_estab): burst glines, too
+
+       * ircd/gline.c: fix up all the expire times to be offsets;
+       simplify gline_resend()
+
+       * ircd/m_gline.c: begin coding replacements for ms_gline(),
+       mo_gline(), and m_gline()
+
+       * ircd/gline.c (gline_add): allow *@#channel to work correctly;
+       also, prohibit local BADCHANs if LOCAL_BADCHAN not defined
+
 2000-04-13  Greg Sikorski <gte@atomicrevs.demon.co.uk>
 
        * tools/Bouncer/*: Add comments/documentation/tags.
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.77 2000-04-13 05:53:48 gte Exp $
+# $Id: ChangeLog,v 1.78 2000-04-13 15:58:22 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 7a4c4d0355f8a7af869bec0075e038d81fa88831..3889074befb0eac496c4bfd284385e80a84dc266 100644 (file)
@@ -88,6 +88,7 @@ extern int m_admin(struct Client*, struct Client*, int, char*[]);
 extern int m_away(struct Client*, struct Client*, int, char*[]);
 extern int m_cnotice(struct Client*, struct Client*, int, char*[]);
 extern int m_cprivmsg(struct Client*, struct Client*, int, char*[]);
+extern int m_gline(struct Client*, struct Client*, int, char*[]);
 extern int m_help(struct Client*, struct Client*, int, char*[]);
 extern int m_ignore(struct Client*, struct Client*, int, char*[]);
 extern int m_info(struct Client*, struct Client*, int, char*[]);
index 911fa26bbd024bc342cdd82f7fae5b5e62246f5c..33e72a39d8cf80285baf532d6cf301a73f2755ab 100644 (file)
@@ -147,7 +147,8 @@ propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
                       GlineIsActive(gline) ? '+' : '-', gline->gl_user,
                       GlineIsBadChan(gline) ? "" : "@",
                       GlineIsBadChan(gline) ? "" : gline->gl_host,
-                      gline->gl_expire, gline->gl_lastmod, gline->gl_reason);
+                      gline->gl_expire - TStime(), gline->gl_lastmod,
+                      gline->gl_reason);
   } else {
     if (gline->gl_lastmod)
       sendto_serv_butone(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT " "
@@ -155,7 +156,7 @@ propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
                         GlineIsActive(gline) ? '+' : '-', gline->gl_user,
                         GlineIsBadChan(gline) ? "" : "@",
                         GlineIsBadChan(gline) ? "" : gline->gl_host,
-                        gline->gl_expire, gline->gl_lastmod,
+                        gline->gl_expire - TStime(), gline->gl_lastmod,
                         gline->gl_reason);
     else
       sendto_serv_butone(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT
@@ -163,7 +164,7 @@ propagate_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
                         GlineIsActive(gline) ? '+' : '-', gline->gl_user,
                         GlineIsBadChan(gline) ? "" : "@",
                         GlineIsBadChan(gline) ? "" : gline->gl_host,
-                        gline->gl_expire, gline->gl_reason);
+                        gline->gl_expire - TStime(), gline->gl_reason);
   }
 }
 
@@ -188,10 +189,20 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
 
   expire += TStime(); /* convert from lifetime to timestamp */
 
+  /* NO_OLD_GLINE allows *@#channel to work correctly */
 #ifdef BADCHAN
-  if (*userhost == '#' || *userhost == '&' || *userhost == '+')
+  if (*userhost == '#' || *userhost == '&' || *userhost == '+'
+# ifndef NO_OLD_GLINE
+      || userhost[2] == '#' || userhost[2] == '&' || userhost[2] == '+'
+# endif /* OLD_GLINE */
+      ) {
+# ifndef LOCAL_BADCHAN
+    if (flags & GLINE_LOCAL)
+      return 0;
+# endif
     flags |= GLINE_BADCHAN;
-#endif
+  }
+#endif /* BADCHAN */
 
   /* Inform ops... */
   sendto_op_mask(SNO_GLINE, "%s adding %s %s for %s, expiring at "
@@ -414,7 +425,7 @@ gline_burst(struct Client *cptr)
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
       sendto_one(cptr, "%s " TOK_GLINE " * %c%s@%s " TIME_T_FMT " " TIME_T_FMT
                 " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
-                gline->gl_user, gline->gl_host, gline->gl_expire,
+                gline->gl_user, gline->gl_host, gline->gl_expire - TStime(),
                 gline->gl_lastmod, gline->gl_reason);
   }
 
@@ -426,8 +437,8 @@ gline_burst(struct Client *cptr)
     else if (!GlineIsLocal(gline) && gline->gl_lastmod)
       sendto_one(cptr, "%s " TOK_GLINE " * %c%s " TIME_T_FMT " " TIME_T_FMT
                 " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
-                gline->gl_user, gline->gl_expire, gline->gl_lastmod,
-                gline->gl_reason);
+                gline->gl_user, gline->gl_expire - TStime(),
+                gline->gl_lastmod, gline->gl_reason);
   }
 }
 
@@ -437,16 +448,11 @@ gline_resend(struct Client *cptr, struct Gline *gline)
   if (GlineIsLocal(gline) || !gline->gl_lastmod)
     return 0;
 
-  if (GlineIsBadChan(gline))
-    sendto_one(cptr, "%s " TOK_GLINE " * %c%s " TIME_T_FMT " " TIME_T_FMT
-              " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
-              gline->gl_user, gline->gl_expire, gline->gl_lastmod,
-              gline->gl_reason);
-  else
-    sendto_one(cptr, "%s " TOK_GLINE " * %c%s@%s " TIME_T_FMT " " TIME_T_FMT
-              " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
-              gline->gl_user, gline->gl_host, gline->gl_expire,
-              gline->gl_lastmod, gline->gl_reason);
+  sendto_one(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT " " TIME_T_FMT
+            " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
+            gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
+            GlineIsBadChan(gline) ? "" : gline->gl_host,
+            gline->gl_expire - TStime(), gline->gl_lastmod, gline->gl_reason);
 
   return 0;
 }
index aad3d0a8d672e9f44b199e2f7e17466af89b9b3f..c2980c187ea536d6ecc0dda8a7b4ba665505f3ae 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+/*
+ * ms_gline - server message handler
+ *
+ * parv[0] = Sender prefix
+ * parv[1] = Target: server numeric
+ * parv[2] = (+|-)<G-line mask>
+ * parv[3] = G-line lifetime
+ *
+ * From Uworld:
+ *
+ * parv[4] = Comment
+ *
+ * From somewhere else:
+ *
+ * parv[4] = Last modification time
+ * parv[5] = Comment
+ *
+ */
+int
+ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+  struct Client *acptr = 0;
+  struct Gline *agline;
+  unsigned int flags = 0;
+  time_t expire_off, lastmod = 0;
+  char *mask = parv[2], *target = parv[1], *reason;
+
+  if (parc == 4) {
+    if (!find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD))
+      return need_more_params(sptr, "GLINE");
+
+    reason = parv[4];
+    flags |= GLINE_FORCE;
+  } else if (parc >= 5) {
+    lastmod = atoi(parv[4]);
+    reason = parv[5];
+  } else
+    return need_more_params(sptr, "GLINE");
+
+  if (!(target[0] == '*' && target[1] == '\0')) {
+    if (!(acptr = FindNServer(target)))
+      return 0; /* no such server */
+
+    if (!IsMe(acptr)) { /* manually propagate */
+      if (IsServer(sptr)) {
+       if (!lastmod)
+         sendto_one(acptr, "%s " TOK_GLINE " %s %s %s :%s", NumServ(sptr),
+                    target, mask, parv[3], reason);
+       else
+         sendto_one(acptr, "%s " TOK_GLINE " %s %s %s %s :%s", NumServ(sptr),
+                    target, mask, parv[3], parv[4], reason);
+      } else
+       sendto_one(acptr, "%s%s " TOK_GLINE " %s %s %s %s :%s", NumNick(sptr),
+                  target, mask, parv[3], parv[4], reason);
+
+      return 0;
+    }
+
+    flags |= GLINE_LOCAL;
+  }
+
+  if (*server == '-')
+    server++;
+  else if (*server == '+') {
+    flags |= GLINE_ACTIVE;
+    server++;
+  } else
+    flags |= GLINE_ACTIVE;
+
+  expire_off = atoi(parv[3]);
+
+  agline = gline_find(mask, GLINE_ANY);
+
+  if (agline) {
+    if (GlineIsLocal(agline) && !(flags & GLINE_LOCAL)) /* global over local */
+      gline_free(agline);
+    else if (!lastmod || GlineLastMod(agline) < lastmod) { /* new mod */
+      if (flags & GLINE_ACTIVE)
+       return gline_activate(cptr, sptr, agline, lastmod);
+      else
+       return gline_deactivate(cptr, sptr, agline, lastmod);
+    } else if (GlineLastMod(agline) == lastmod)
+      return 0;
+    else
+      return gline_resend(cptr, agline); /* other server desynched WRT gline */
+  }
+
+  return gline_add(cptr, sptr, mask, reason, expire_off, lastmod, flags);
+}
+
+/*
+ * mo_gline - oper message handler
+ *
+ * parv[0] = Sender prefix
+ * parv[1] = [[+|-]<G-line mask>]
+ *
+ * Old style:
+ *
+ * parv[2] = [Expiration offset]
+ * parv[3] = [Comment]
+ *
+ * New style:
+ *
+ * parv[2] = [target]
+ * parv[3] = [Expiration offset]
+ * parv[4] = [Comment]
+ *
+ */
+int
+mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+  struct Client *acptr = 0;
+  struct Gline *agline;
+  unsigned int flags = 0;
+  time_t expire_off;
+  char *mask = parv[1], *target = 0, *reason;
+
+  if (parc < 2)
+    return gline_list(sptr, 0);
+
+  if (*mask == '+') {
+    flags |= GLINE_ACTIVE;
+    mask++;
+  } else if (*mask == '-')
+    mask++;
+  else
+    return gline_list(sptr, mask);
+
+#ifndef LOCOP_LGLINE
+  if (!IsOper(sptr)) {
+    send_error_to_client(sptr, ERR_NOPRIVILEGES);
+    return 0;
+  }
+#endif
+
+  if (parc == 3) {
+    expire_off = atoi(parv[2]);
+    reason = parv[3];
+    flags |= GLINE_LOCAL;
+  } else if (parc >= 4) {
+    target = parv[2];
+    expire_off = atoi(parv[3]);
+    reason = parv[4];
+  } else
+    return need_more_params(sptr, "GLINE");
+
+  if (target) {
+    if (!(target[0] == '*' && target[1] == '\0')) {
+      if (!(acptr = find_match_server(target))) {
+       send_error_to_client(sptr, ERR_NOSUCHSERVER, target);
+       return 0;
+      }
+
+      if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
+       if (!IsOper(sptr)) {
+         send_error_to_client(sptr, ERR_NOPRIVILEGES);
+         return 0;
+       }
+
+       sendto_one(acptr, "%s%s " TOK_GLINE " %s %c%s %s " TIME_T_FMT " :%s",
+                  NumNick(sptr), NumServ(acptr),
+                  flags & GLINE_ACTIVE ? '?' : '-', mask, parv[3], TStime(),
+                  reason);
+       return 0;
+      }
+
+      flags |= GLINE_LOCAL;
+    } else if (!IsOper(sptr)) {
+      send_error_to_client(sptr, ERR_NOPRIVILEGES);
+      return 0;
+    }
+  }
+
+  agline = gline_find(mask, GLINE_ANY);
+
+  if (agline) {
+    if (GlineIsLocal(agline) && !(flags & GLINE_LOCAL)) /* global over local */
+      gline_free(agline);
+    else {
+      if (flags & GLINE_ACTIVE)
+       return gline_activate(cptr, sptr, agline, TStime());
+      else
+       return gline_deactivate(cptr, sptr, agline, TStime());
+    }
+  }
+
+  return gline_add(cptr, sptr, mask, reason, expire_off, TStime(), flags);
+}
+
+/*
+ * m_gline - user message handler
+ *
+ * parv[0] = Sender prefix
+ * parv[1] = [<server name>]
+ *
+ */
+int
+m_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+  if (parc < 2)
+    return gline_list(sptr, 0);
+
+  return gline_list(sptr, parv[1]);
+}
+
+#if 0
 /*
  * ms_gline - server message handler
  *
@@ -1130,3 +1336,4 @@ int m_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
 #endif /* 0 */
 
+#endif /* 0 */
index c5d562adb8f7ee459f2bc3ed5514df7e67ab513f..64e9d0f1c13b8dda5fcfceaf45daadd06abd8ea0 100644 (file)
@@ -437,7 +437,7 @@ struct Message msgtab[] = {
     TOK_GLINE,
     0, MAXPARA, MFLG_SLOW, 0,
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
-    { m_unregistered, m_not_oper, ms_gline, mo_gline, m_ignore }
+    { m_unregistered, m_gline, ms_gline, mo_gline, m_ignore }
   },
   {
     MSG_JUPE,
index c74be252b4fd2adb710278d6794d360c7092d830..a2912b597b3a1305574ce63c57873df26d2733c8 100644 (file)
@@ -27,6 +27,7 @@
 #include "channel.h"
 #include "client.h"
 #include "crule.h"
+#include "gline.h"
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
@@ -272,6 +273,7 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf)
       send_channel_modes(cptr, chptr);
   }
   jupe_burst(cptr);
+  gline_burst(cptr);
   sendto_one(cptr, "%s EB", NumServ(&me));
   return 0;
 }
index a09321b05f1a3cb53ffbd2ea211ee511524be095..b2f3cd4165c0d977eaee613a3a171f3487b0be78 100644 (file)
@@ -27,6 +27,7 @@
 #include "channel.h"
 #include "class.h"
 #include "client.h"
+#include "gline.h"
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
@@ -687,6 +688,7 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
   if (IsServer(sptr)) {
     int   i;
     const char* p;
+    struct Gline *gline;
 
     /*
      * A server introducing a new client, change source
@@ -725,6 +727,8 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
     ircd_strncpy(new_client->username, parv[4], USERLEN);
     ircd_strncpy(new_client->user->host, parv[5], HOSTLEN);
     ircd_strncpy(new_client->info, parv[parc - 1], REALLEN);
+    if ((gline = gline_lookup(new_client)) && GlineIsActive(gline))
+      gline_resend(cptr, gline);
     return register_user(cptr, new_client, new_client->name, parv[4]);
   }
   else if (sptr->name[0]) {