Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_gline.c
index e0d0f9aaf560ebbc15c36c6d415f7a3163a5d1de..ab60a1a81b6d7e96f4f438e2f4ad7a3b2302ddd3 100644 (file)
@@ -86,6 +86,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_features.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
@@ -95,9 +96,8 @@
 #include "s_conf.h"
 #include "s_misc.h"
 #include "send.h"
-#include "support.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <stdlib.h>
 #include <string.h>
 
@@ -126,27 +126,34 @@ 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 == '!') {
+  if (*mask == '!')
+  {
     mask++;
-
-    if (HasPriv(sptr, PRIV_WIDE_GLINE))
-      flags |= GLINE_OPERFORCE;
+    flags |= GLINE_OPERFORCE; /* assume oper had WIDE_GLINE */
   }
 
-  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 (IsServer(sptr))
+    flags |= GLINE_FORCE;
+
   if (!(target[0] == '*' && target[1] == '\0')) {
     if (!(acptr = FindNServer(target)))
       return 0; /* no such server */
@@ -263,12 +270,16 @@ 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");
 
@@ -280,17 +291,17 @@ mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                      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))
     return send_reply(sptr, ERR_DISABLED, "GLINE");
 
+  if (!HasPriv(sptr, (flags & GLINE_LOCAL ? PRIV_LOCAL_GLINE : PRIV_GLINE)))
+    return send_reply(sptr, ERR_NOPRIVILEGES);
+
   agline = gline_find(mask, GLINE_ANY | GLINE_EXACT);
 
   if (agline) {