Author: Isomer <isomer@coders.net>
[ircu2.10.12-pk.git] / ircd / s_conf.c
index dbd0f02ab1020f7c9bf3a6e012dc10eb647df8ba..83b0b0fae09bedb0d2b82dbc7e6729e63ef49b6a 100644 (file)
@@ -158,13 +158,13 @@ static void killcomment(struct Client *sptr, char *parv, char *filename)
 {
   FBFILE*     file = NULL;
   char        line[80];
-  char*       tmp;
+  char*       tmp = NULL;
   struct stat sb;
   struct tm*  tm;
 
   if (NULL == (file = fbopen(filename, "r"))) {
     send_reply(sptr, ERR_NOMOTD);
-    send_reply(sptr, RPL_EXPLICIT | ERR_YOUREBANNEDCREEP,
+    send_reply(sptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP,
               ":Connection from your host is refused on this server.");
     return;
   }
@@ -177,7 +177,7 @@ static void killcomment(struct Client *sptr, char *parv, char *filename)
       *tmp = '\0';
     send_reply(sptr, RPL_MOTD, line);
   }
-  send_reply(sptr, RPL_EXPLICIT | ERR_YOUREBANNEDCREEP,
+  send_reply(sptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP,
             ":Connection from your host is refused on this server.");
   fbclose(file);
 }
@@ -486,32 +486,26 @@ static int validate_hostent(struct hostent* hp)
 
 /*
  * check_limit_and_attach - check client limits and attach I:line
+ *
+ * Made it accept 1 charactor, and 2 charactor limits (0->99 now), 
+ * and dislallow more than 255 people here as well as in ipcheck.
+ * removed the old "ONE" scheme too.
+ *  -- Isomer 2000-06-22
  */
 static enum AuthorizationCheckResult
 check_limit_and_attach(struct Client* cptr, struct ConfItem* aconf)
 {
+  int number = 255;
+  
   if (aconf->passwd) {
-    /* Special case: exactly one digit */
-    if (IsDigit(*aconf->passwd) && !aconf->passwd[1]) {
-      /*
-       * Refuse connections when there are already <digit>
-       * clients connected with the same IP number
-       */
-      unsigned short nr = *aconf->passwd - '0';
-      if (IPcheck_nr(cptr) > nr)
-        return ACR_TOO_MANY_FROM_IP; /* Already got nr with that ip# */
-    }
-#ifdef USEONE
-    else if (0 == strcmp(aconf->passwd, "ONE")) {
-      int i;
-      for (i = HighestFd; i > -1; --i) {
-        if (LocalClientArray[i] && MyUser(LocalClientArray[i]) &&
-            LocalClientArray[i]->ip.s_addr == cptr->ip.s_addr)
-          return ACR_TOO_MANY_FROM_IP; /* Already got one with that ip# */
-      }
-    }
-#endif
+    if (IsDigit(*aconf->passwd) && !aconf->passwd[1])
+      number = *aconf->passwd-'0';
+    else if (IsDigit(*aconf->passwd) && IsDigit(aconf->passwd[1]) && 
+             !aconf->passwd[2])
+      number = (*aconf->passwd-'0')*10+(aconf->passwd[1]-'0');
   }
+  if (ip_registry_count(cptr->ip.s_addr) > number)
+    return ACR_TOO_MANY_FROM_IP;
   return attach_conf(cptr, aconf);
 }
 
@@ -791,7 +785,7 @@ struct ConfItem* find_conf_byname(struct SLink* lp, const char* name,
 struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host,
                                   int statmask)
 {
-  struct ConfItem* tmp;
+  struct ConfItem* tmp = NULL;
   assert(0 != host);
 
   if (HOSTLEN < strlen(host))
@@ -969,10 +963,15 @@ int rehash(struct Client *cptr, int sig)
         attach_confs_byname(acptr, acptr->name,
                             CONF_HUB | CONF_LEAF | CONF_UWORLD);
       }
+      /* Because admin's are getting so uppity about people managing to
+       * get past K/G's etc, we'll "fix" the bug by actually explaining
+       * whats going on.
+       */
       if ((found_g = find_kill(acptr))) {
         sendto_opmask_butone(0, found_g == -2 ? SNO_GLINE : SNO_OPERKILL,
-                            found_g == -2 ? "G-line active for %s" :
-                            "K-line active for %s",
+                            found_g == -2 ? "G-line active for %s%s" :
+                            "K-line active for %s%s",
+                            IsUnknown(acptr) ? "Unregistered Client ":"",                   
                             get_client_name(acptr, HIDE_IP));
         if (exit_client(cptr, acptr, &me, found_g == -2 ? "G-lined" :
             "K-lined") == CPTR_KILLED)
@@ -1413,14 +1412,14 @@ int find_kill(struct Client *cptr)
     }
   }
   if (reply[0])
-    send_reply(cptr, RPL_EXPLICIT | ERR_YOUREBANNEDCREEP, reply);
+    send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, reply);
   else if (tmp) {
     if (EmptyString(tmp->passwd))
-      send_reply(cptr, RPL_EXPLICIT | ERR_YOUREBANNEDCREEP,
+      send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP,
                 ":Connection from your host is refused on this server.");
     else {
       if (*tmp->passwd == '"') {
-       send_reply(cptr, RPL_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%*s.",
+       send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%*s.",
                   strlen(tmp->passwd + 1) - 1, tmp->passwd + 1);
       }
       else if (*tmp->passwd == '!')
@@ -1429,7 +1428,7 @@ int find_kill(struct Client *cptr)
 #ifdef COMMENT_IS_FILE
         killcomment(cptr, cptr->name, tmp->passwd);
 #else
-       send_reply(cptr, RPL_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.",
+       send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.",
                   tmp->passwd);
 #endif
     }
@@ -1437,8 +1436,8 @@ int find_kill(struct Client *cptr)
 
   /* find active glines */
   /* added a check against the user's IP address to find_gline() -Kev */
-  else if ((agline = gline_lookup(cptr)) && GlineIsActive(agline))
-    send_reply(cptr, RPL_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.",
+  else if ((agline = gline_lookup(cptr, 0)) && GlineIsActive(agline))
+    send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.",
               GlineReason(agline));
   else
     agline = NULL;                /* if a gline was found, it was inactive */