Prevent "GLINE +test", "GLINE +test" from creating duplicate G-lines.
[ircu2.10.12-pk.git] / ircd / gline.c
index 25b4ca1724b5b37b0048152317a218941589f7c9..5994e3eab4b86986752a7d8dee57cbd9ed83d28f 100644 (file)
 #include "msg.h"
 #include "numnicks.h"
 #include "numeric.h"
-#include "sys.h"    /* FALSE bleah */
 #include "whocmds.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <arpa/inet.h> /* for inet_ntoa */
 
 #define CHECK_APPROVED    0    /**< Mask is acceptable */
 #define CHECK_OVERRIDABLE  1   /**< Mask is acceptable, but not by default */
@@ -244,7 +242,7 @@ do_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
 
       /* let the ops know about it */
       sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
-                    get_client_name(acptr, TRUE));
+                           get_client_name(acptr, SHOW_IP));
 
       /* and get rid of him */
       if ((tval = exit_client_msg(cptr, acptr, &me, "G-lined (%s)",
@@ -643,10 +641,7 @@ gline_find(char *userhost, unsigned int flags)
     return 0;
 
   DupString(t_uh, userhost);
-  canon_userhost(t_uh, &user, &host, 0);
-
-  if (BadPtr(user))
-    return 0;
+  canon_userhost(t_uh, &user, &host, "*");
 
   for (gline = GlobalGlineList; gline; gline = sgline) {
     sgline = gline->gl_next;
@@ -659,14 +654,12 @@ gline_find(char *userhost, unsigned int flags)
     else if (flags & GLINE_EXACT) {
       if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
            || (!gline->gl_host && !host)) &&
-          ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
-          ircd_strcmp(gline->gl_user, user) == 0))
+          (ircd_strcmp(gline->gl_user, user) == 0))
        break;
     } else {
-      if (((gline->gl_host && host && ircd_strcmp(gline->gl_host, host) == 0)
+      if (((gline->gl_host && host && match(gline->gl_host, host) == 0)
            || (!gline->gl_host && !host)) &&
-         ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
-          match(gline->gl_user, user) == 0))
+         (match(gline->gl_user, user) == 0))
       break;
     }
   }