Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / s_conf.c
index 4be9c2a00c9a4df30fd4c646ef7ae2294335b066..49f56494f8d1a8e88b07a68c390d8c3bede04641 100644 (file)
@@ -19,8 +19,9 @@
  *
  * $Id$
  */
-#include "s_conf.h"
+#include "config.h"
 
+#include "s_conf.h"
 #include "IPcheck.h"
 #include "class.h"
 #include "client.h"
@@ -424,7 +425,7 @@ static int is_attached(struct ConfItem *aconf, struct Client *cptr)
 {
   struct SLink *lp;
 
-  for (lp = cptr->confs; lp; lp = lp->next) {
+  for (lp = cli_confs(cptr); lp; lp = lp->next) {
     if (lp->value.aconf == aconf)
       return 1;
   }
@@ -451,9 +452,9 @@ enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *
       ConfLinks(aconf) >= ConfMaxLinks(aconf) && ConfMaxLinks(aconf) > 0)
     return ACR_TOO_MANY_IN_CLASS;  /* Use this for printing error message */
   lp = make_link();
-  lp->next = cptr->confs;
+  lp->next = cli_confs(cptr);
   lp->value.aconf = aconf;
-  cptr->confs = lp;
+  cli_confs(cptr) = lp;
   ++aconf->clients;
   if (aconf->status & CONF_CLIENT_MASK)
     ConfLinks(aconf)++;
@@ -648,9 +649,6 @@ static struct ConfItem *find_conf_entry(struct ConfItem *aconf,
         (EmptyString(aconf->passwd) && !EmptyString(bconf->passwd)))
       continue;
     if (!EmptyString(bconf->passwd) && (!IsDigit(*bconf->passwd) || bconf->passwd[1])
-#ifdef USEONE
-        && 0 != ircd_strcmp(bconf->passwd, "ONE")
-#endif
         && 0 != ircd_strcmp(bconf->passwd, aconf->passwd))
       continue;
 
@@ -835,8 +833,8 @@ void conf_add_server(const char* const* fields, int count)
   server->next = serverConfList;
   serverConfList = server;
 
-  // if (INADDR_NONE == server->address.s_addr)
-    // lookup_confhost(server);
+  /* if (INADDR_NONE == server->address.s_addr) */
+    /* lookup_confhost(server); */
 }
 
 void conf_add_deny(const char* const* fields, int count, int ip_kill)
@@ -850,13 +848,16 @@ void conf_add_deny(const char* const* fields, int count, int ip_kill)
   assert(0 != conf);
   memset(conf, 0, sizeof(struct DenyConf));
 
+  if (fields[1][0] == '$' && fields[1][1] == 'R')
+    conf->flags |= DENY_FLAGS_REALNAME;
+
   DupString(conf->hostmask, fields[1]);
   collapse(conf->hostmask);
 
   if (!EmptyString(fields[2])) {
     const char* p = fields[2];
     if ('!' == *p) {
-      conf->is_file = 1;
+      conf->flags |= DENY_FLAGS_FILE;
       ++p;
     }
     DupString(conf->message, p);
@@ -886,9 +887,10 @@ void conf_add_deny(const char* const* fields, int count, int ip_kill)
     /*
      * This ensures endian correctness
      */
-    conf->s_addr = inet_addr(ipname);
+    conf->address = inet_addr(ipname);
     Debug((DEBUG_DEBUG, "IPkill: %s = %08x/%i (%08x)", ipname,
-           conf->s_addr, conf->bits, NETMASK(conf->bits)));
+           conf->address, conf->bits, NETMASK(conf->bits)));
+    conf->flags |= DENY_FLAGS_IP;
   }
   conf->next = denyConfList;
   denyConfList = conf;
@@ -944,6 +946,8 @@ int read_configuration_file(void)
     return 0;
   }
 
+  feature_unmark(); /* unmark all features for resetting later */
+
   while (fbgets(line, sizeof(line) - 1, file)) {
     if ('#' == *line || IsSpace(*line))
       continue;
@@ -1228,6 +1232,7 @@ int read_configuration_file(void)
     free_conf(aconf);
   fbclose(file);
   nextping = nextconnect = CurrentTime;
+  feature_mark(); /* reset unmarked features */
   return 1;
 }
 
@@ -1313,7 +1318,7 @@ int rehash(struct Client *cptr, int sig)
       if (IsServer(acptr)) {
         det_confs_butmask(acptr,
             ~(CONF_HUB | CONF_LEAF | CONF_UWORLD | CONF_ILLEGAL));
-        attach_confs_byname(acptr, acptr->name,
+        attach_confs_byname(acptr, cli_name(acptr),
                             CONF_HUB | CONF_LEAF | CONF_UWORLD);
       }
       /* Because admin's are getting so uppity about people managing to
@@ -1383,6 +1388,7 @@ int find_kill(struct Client *cptr)
 {
   const char*      host;
   const char*      name;
+  const char*      realname;
   struct DenyConf* deny;
   struct Gline*    agline = NULL;
 
@@ -1393,24 +1399,29 @@ int find_kill(struct Client *cptr)
 
   host = cli_sockhost(cptr);
   name = cli_user(cptr)->username;
+  realname = cli_info(cptr);
 
   assert(strlen(host) <= HOSTLEN);
   assert((name ? strlen(name) : 0) <= HOSTLEN);
-  
+  assert((realname ? strlen(realname) : 0) <= REALLEN);
+
   /* 2000-07-14: Rewrote this loop for massive speed increases.
    *             -- Isomer
    */
   for (deny = denyConfList; deny; deny = deny->next) {
     if (0 != match(deny->usermask, name))
       continue;
-            
+
     if (EmptyString(deny->hostmask))
       break;
-    
-    if (deny->ip_kill) { /* k: by IP */
+
+    if (deny->flags & DENY_FLAGS_REALNAME) { /* K: by real name */
+      if (0 == match(deny->hostmask + 2, realname))
+       break;
+    } else if (deny->flags & DENY_FLAGS_IP) { /* k: by IP */
       Debug((DEBUG_DEBUG, "ip: %08x network: %08x/%i mask: %08x",
-             cli_ip(cptr).s_addr, deny->s_addr, deny->bits, NETMASK(deny->bits)));
-      if ((cli_ip(cptr).s_addr & NETMASK(deny->bits)) == deny->s_addr)
+             cli_ip(cptr).s_addr, deny->address, deny->bits, NETMASK(deny->bits)));
+      if ((cli_ip(cptr).s_addr & NETMASK(deny->bits)) == deny->address)
         break;
     }
     else if (0 == match(deny->hostmask, host))
@@ -1421,7 +1432,7 @@ int find_kill(struct Client *cptr)
       send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP,
                  ":Connection from your host is refused on this server.");
     else {
-      if (deny->is_file)
+      if (deny->flags & DENY_FLAGS_FILE)
         killcomment(cptr, deny->message);
       else
         send_reply(cptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s.", deny->message);