- The big forward port. I probably broke lots of stuff, so please look over any
[ircu2.10.12-pk.git] / ircd / m_gline.c
index e1aa27dc0f4bf6f91c8fb1490092b4f705bf3a20..cee85ac400df69597cf3903a97ca4589efdbc12a 100644 (file)
  */
 #include "config.h"
 
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
 #include "client.h"
 #include "gline.h"
 #include "hash.h"
@@ -134,18 +126,29 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   struct Gline *agline;
   unsigned int flags = 0;
   time_t expire_off, lastmod = 0;
-  char *mask = parv[2], *target = parv[1], *reason;
+  char *mask = parv[2], *target = parv[1], *reason = "No reason";
+
+  if (*mask == '!')
+  {
+    mask++;
+    flags |= GLINE_OPERFORCE;
+  }
 
-  if ((parc == 3 && *mask == '-') || parc == 5) {
+  if ((parc == 3 && *mask == '-') || parc == 5)
+  {
     if (!find_conf_byhost(cli_confs(cptr), cli_name(sptr), CONF_UWORLD))
       return need_more_params(sptr, "GLINE");
 
-    reason = parv[4];
+    if (parc > 4)
+      reason = parv[4];
     flags |= GLINE_FORCE;
-  } else if (parc > 5) {
+  }
+  else if (parc > 5)
+  {
     lastmod = atoi(parv[4]);
     reason = parv[5];
-  } else
+  }
+  else
     return need_more_params(sptr, "GLINE");
 
   if (!(target[0] == '*' && target[1] == '\0')) {
@@ -158,8 +161,9 @@ ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                      (parc == 3) ? "%C %s" : "%C %s %s :%s", acptr, mask,
                      parv[3], reason);
       else
-       sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s %s %s :%s", acptr, mask,
-                     parv[3], parv[4], reason);
+       sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%s %s %s :%s", acptr,
+                     flags & GLINE_OPERFORCE ? "!" : "", mask, parv[3],
+                     parv[4], reason);
 
       return 0;
     }
@@ -236,6 +240,13 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   if (parc < 2)
     return gline_list(sptr, 0);
 
+  if (*mask == '!') {
+    mask++;
+
+    if (HasPriv(sptr, PRIV_WIDE_GLINE))
+      flags |= GLINE_OPERFORCE;
+  }
+
   if (*mask == '+') {
     flags |= GLINE_ACTIVE;
     mask++;
@@ -256,28 +267,30 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   } else
     return need_more_params(sptr, "GLINE");
 
-  if (target) {
-    if (!(target[0] == '*' && target[1] == '\0')) {
+  if (target)
+  {
+    if (!(target[0] == '*' && target[1] == '\0'))
+    {
       if (!(acptr = find_match_server(target)))
        return send_reply(sptr, ERR_NOSUCHSERVER, target);
 
-      if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
+      /* manually propagate, since we don't set it */
+      if (!IsMe(acptr))
+      {
        if (!feature_bool(FEAT_CONFIG_OPERCMDS))
          return send_reply(sptr, ERR_DISABLED, "GLINE");
 
        if (!HasPriv(sptr, PRIV_GLINE))
          return send_reply(sptr, ERR_NOPRIVILEGES);
 
-       sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %c%s %s %Tu :%s", acptr,
+       sendcmdto_one(sptr, CMD_GLINE, acptr, "%C %s%c%s %s %Tu :%s", acptr,
+                     flags & GLINE_OPERFORCE ? "!" : "",
                      flags & GLINE_ACTIVE ? '+' : '-', mask, parv[3],
                      TStime(), reason);
        return 0;
-      } else if (!HasPriv(sptr, PRIV_LOCAL_GLINE))
-       return send_reply(sptr, ERR_NOPRIVILEGES);
-
+      }
       flags |= GLINE_LOCAL;
-    } else if (!HasPriv(sptr, PRIV_GLINE))
-      return send_reply(sptr, ERR_NOPRIVILEGES);
+    }
   }
 
   if (!(flags & GLINE_LOCAL) && !feature_bool(FEAT_CONFIG_OPERCMDS))
@@ -285,6 +298,9 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
   agline = gline_find(mask, GLINE_ANY | GLINE_EXACT);
 
+  if (!HasPriv(sptr, (flags & GLINE_LOCAL ? PRIV_LOCAL_GLINE : PRIV_GLINE)))
+    return send_reply(sptr, ERR_NOPRIVILEGES);
+
   if (agline) {
     if (GlineIsLocal(agline) && !(flags & GLINE_LOCAL)) /* global over local */
       gline_free(agline);