ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf.c
(Generate patch)

Comparing:
ircd-hybrid/src/s_conf.c (file contents), Revision 33 by knight, Sun Oct 2 20:50:00 2005 UTC vs.
ircd-hybrid-7.2/src/s_conf.c (file contents), Revision 948 by michael, Tue Jul 21 17:34:06 2009 UTC

# Line 28 | Line 28
28   #include "s_conf.h"
29   #include "s_serv.h"
30   #include "resv.h"
31 #include "s_stats.h"
31   #include "channel.h"
32   #include "client.h"
33   #include "common.h"
# Line 38 | Line 37
37   #include "irc_string.h"
38   #include "sprintf_irc.h"
39   #include "s_bsd.h"
41 #include "irc_getnameinfo.h"
40   #include "irc_getaddrinfo.h"
41   #include "ircd.h"
42   #include "list.h"
# Line 87 | Line 85 | extern char linebuf[];
85   extern char conffilebuf[IRCD_BUFSIZE];
86   extern char yytext[];
87   extern int yyparse(); /* defined in y.tab.c */
88 < unsigned int scount = 0; /* used by yyparse(), etc */
91 < int ypass  = 1; /* used by yyparse()      */
88 > int ypass = 1; /* used by yyparse()      */
89  
90   /* internally defined functions */
91   static void lookup_confhost(struct ConfItem *);
# Line 298 | Line 295 | make_conf_item(ConfType type)
295    case GDENY_TYPE:
296      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
297                                         sizeof(struct AccessItem));
298 <    dlinkAddTail(conf, &conf->node, &gdeny_items);
298 >    dlinkAdd(conf, &conf->node, &gdeny_items);
299      break;
300  
301    case XLINE_TYPE:
# Line 338 | Line 335 | make_conf_item(ConfType type)
335      break;
336  
337    case CLASS_TYPE:
338 <    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
339 <                                       sizeof(struct ClassItem));
338 >    conf = MyMalloc(sizeof(struct ConfItem) +
339 >                           sizeof(struct ClassItem));
340      dlinkAdd(conf, &conf->node, &class_items);
341 <    aclass = (struct ClassItem *)map_to_conf(conf);
342 <    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
341 >
342 >    aclass = map_to_conf(conf);
343 >    aclass->active = 1;
344 >    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
345      PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
346      MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
347      MaxSendq(aclass) = DEFAULT_SENDQ;
348 <    CurrUserCount(aclass) = 0;
348 >
349      break;
350  
351    default:
# Line 357 | Line 356 | make_conf_item(ConfType type)
356    /* XXX Yes, this will core if default is hit. I want it to for now - db */
357    conf->type = type;
358  
359 <  return(conf);
359 >  return conf;
360   }
361  
362   void
363   delete_conf_item(struct ConfItem *conf)
364   {
365 +  dlink_node *m = NULL;
366    struct MatchItem *match_item;
367    struct AccessItem *aconf;
368    ConfType type = conf->type;
# Line 509 | Line 509 | delete_conf_item(struct ConfItem *conf)
509      MyFree(match_item->reason);
510      MyFree(match_item->oper_reason);
511      dlinkDelete(&conf->node, &nresv_items);
512 +
513 +    if (conf->flags & CONF_FLAGS_TEMPORARY)
514 +      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
515 +        free_dlink_node(m);
516 +
517      MyFree(conf);
518      break;
519  
# Line 526 | Line 531 | delete_conf_item(struct ConfItem *conf)
531      break;
532  
533    case CRESV_TYPE:
534 +    if (conf->flags & CONF_FLAGS_TEMPORARY)
535 +      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
536 +        free_dlink_node(m);
537 +
538      MyFree(conf);
539      break;
540  
# Line 576 | Line 585 | report_confitem_types(struct Client *sou
585    struct ClassItem *classitem = NULL;
586    char buf[12];
587    char *p = NULL;
588 +  const char *pfx = NULL;
589  
590    switch (type)
591    {
# Line 632 | Line 642 | report_confitem_types(struct Client *sou
642      break;
643  
644    case RKLINE_TYPE:
645 <    p = temp ? "Rk" : "RK";
645 >    pfx = temp ? "kR" : "KR";
646  
647      DLINK_FOREACH(ptr, rkconf_items.head)
648      {
# Line 642 | Line 652 | report_confitem_types(struct Client *sou
652          continue;
653  
654        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
655 <                 source_p->name, p, aconf->host, aconf->user,
655 >                 source_p->name, pfx, aconf->host, aconf->user,
656                   aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
657      }
658      break;
# Line 712 | Line 722 | report_confitem_types(struct Client *sou
722                   me.name, source_p->name, 'Y',
723                   conf->name, PingFreq(classitem),
724                   ConFreq(classitem),
725 <                 MaxTotal(classitem), MaxSendq(classitem));
725 >                 MaxTotal(classitem), MaxSendq(classitem),
726 >                 CurrUserCount(classitem),
727 >                 classitem->active ? "active" : "disabled");
728      }
729      break;
730  
# Line 734 | Line 746 | report_confitem_types(struct Client *sou
746          *p++ = 'A';
747        if (IsConfCryptLink(aconf))
748          *p++ = 'C';
737      if (IsConfLazyLink(aconf))
738        *p++ = 'L';
749        if (aconf->fakename)
750          *p++ = 'M';
751        if (IsConfTopicBurst(aconf))
# Line 747 | Line 757 | report_confitem_types(struct Client *sou
757  
758        *p = '\0';
759  
760 <      /* Allow admins to see actual ips
761 <       * unless hide_server_ips is enabled
760 >      /*
761 >       * Allow admins to see actual ips unless hide_server_ips is enabled
762         */
763        if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
764          sendto_one(source_p, form_str(RPL_STATSCLINE),
# Line 816 | Line 826 | check_client(va_list args)
826  
827    /* I'm already in big trouble if source_p->localClient is NULL -db */
828    if ((i = verify_access(source_p, username)))
819  {
829      ilog(L_INFO, "Access denied: %s[%s]",
830           source_p->name, source_p->sockhost);
822  }
831  
832    switch (i)
833    {
826    case IRCD_SOCKET_ERROR:
827      exit_client(source_p, &me, "Socket Error");
828      break;
829
834      case TOO_MANY:
835        sendto_realops_flags(UMODE_FULL, L_ALL,
836                             "Too many on IP for %s (%s).",
# Line 834 | Line 838 | check_client(va_list args)
838                             source_p->sockhost);
839        ilog(L_INFO,"Too many connections on IP from %s.",
840             get_client_name(source_p, SHOW_IP));
841 <      ServerStats->is_ref++;
841 >      ++ServerStats.is_ref;
842        exit_client(source_p, &me, "No more connections allowed on that IP");
843        break;
844  
# Line 845 | Line 849 | check_client(va_list args)
849                             source_p->sockhost);
850        ilog(L_INFO,"Too many connections from %s.",
851             get_client_name(source_p, SHOW_IP));
852 <       ServerStats->is_ref++;
852 >      ++ServerStats.is_ref;
853        exit_client(source_p, &me,
854                  "No more connections allowed in your connection class");
855        break;
856  
857      case NOT_AUTHORIZED:
858 <    {
855 <      static char ipaddr[HOSTIPLEN];
856 <      ServerStats->is_ref++;
858 >      ++ServerStats.is_ref;
859        /* jdc - lists server name & port connections are on */
860        /*       a purely cosmetical change */
859      irc_getnameinfo((struct sockaddr*)&source_p->localClient->ip,
860            source_p->localClient->ip.ss_len, ipaddr, HOSTIPLEN, NULL, 0,
861            NI_NUMERICHOST);
861        sendto_realops_flags(UMODE_UNAUTH, L_ALL,
862                             "Unauthorized client connection from %s [%s] on [%s/%u].",
863                             get_client_name(source_p, SHOW_IP),
864 <                           ipaddr,
864 >                           source_p->sockhost,
865                             source_p->localClient->listener->name,
866                             source_p->localClient->listener->port);
867        ilog(L_INFO,
# Line 875 | Line 874 | check_client(va_list args)
874         * capture reject code here or rely on the connecting too fast code.
875         * - Dianora
876         */
877 <      if(REJECT_HOLD_TIME > 0)
877 >      if (REJECT_HOLD_TIME > 0)
878        {
879          sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",
880                     me.name, source_p->name);
# Line 885 | Line 884 | check_client(va_list args)
884        else
885          exit_client(source_p, &me, "You are not authorized to use this server");
886        break;
887 <    }
889 <
887 >
888     case BANNED_CLIENT:
889       /*
890        * Don't exit them immediately, play with them a bit.
# Line 899 | Line 897 | check_client(va_list args)
897       }
898       else
899         exit_client(source_p, &me, "Banned");
900 <     ServerStats->is_ref++;
900 >     ++ServerStats.is_ref;
901       break;
902  
903     case 0:
# Line 1016 | Line 1014 | attach_iline(struct Client *client_p, st
1014    ip_found->count++;
1015    SetIpHash(client_p);
1016  
1017 <  aconf = (struct AccessItem *)map_to_conf(conf);
1017 >  aconf = map_to_conf(conf);
1018    if (aconf->class_ptr == NULL)
1019      return NOT_AUTHORIZED;  /* If class is missing, this is best */
1020  
1021 <  aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
1021 >  aclass = map_to_conf(aconf->class_ptr);
1022  
1023    count_user_host(client_p->username, client_p->host,
1024                    &global, &local, &ident);
# Line 1031 | Line 1029 | attach_iline(struct Client *client_p, st
1029     */
1030    if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
1031      a_limit_reached = 1;
1032 <  else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass))
1032 >  else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))
1033      a_limit_reached = 1;
1034    else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
1035      a_limit_reached = 1;
# Line 1044 | Line 1042 | attach_iline(struct Client *client_p, st
1042    if (a_limit_reached)
1043    {
1044      if (!IsConfExemptLimits(aconf))
1045 <      return TOO_MANY;  /* Already at maximum allowed */
1045 >      return TOO_MANY;   /* Already at maximum allowed */
1046  
1047      sendto_one(client_p,
1048                 ":%s NOTICE %s :*** Your connection class is full, "
# Line 1228 | Line 1226 | hash_ip(struct irc_ssaddr *addr)
1226   * used in the hash.
1227   */
1228   void
1229 < count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored)
1229 > count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
1230   {
1231    struct ip_entry *ptr;
1232    int i;
# Line 1316 | Line 1314 | detach_conf(struct Client *client_p, Con
1314        case CLIENT_TYPE:
1315        case OPER_TYPE:
1316        case SERVER_TYPE:
1317 <        aconf = (struct AccessItem *)map_to_conf(conf);
1317 >        aconf = map_to_conf(conf);
1318 >
1319 >        assert(aconf->clients > 0);
1320 >
1321          if ((aclass_conf = ClassPtr(aconf)) != NULL)
1322          {
1323 <          aclass = (struct ClassItem *)map_to_conf(aclass_conf);
1323 >          aclass = map_to_conf(aclass_conf);
1324 >
1325 >          assert(aclass->curr_user_count > 0);
1326  
1327            if (conf->type == CLIENT_TYPE)
1328              remove_from_cidr_check(&client_p->localClient->ip, aclass);
1329 <
1327 <          if (CurrUserCount(aclass) > 0)
1328 <            aclass->curr_user_count--;
1329 <          if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0)
1329 >          if (--aclass->curr_user_count == 0 && aclass->active == 0)
1330              delete_conf_item(aclass_conf);
1331          }
1332  
1333 <        /* Please, no ioccc entries - Dianora */
1334 <        if (aconf->clients > 0)
1335 <          --aconf->clients;
1336 <        if (aconf->clients == 0 && IsConfIllegal(aconf))
1333 >        if (--aconf->clients == 0 && IsConfIllegal(aconf))
1334            delete_conf_item(conf);
1335 +
1336          break;
1337 +
1338        case LEAF_TYPE:
1339        case HUB_TYPE:
1340 <        match_item = (struct MatchItem *)map_to_conf(conf);
1340 >        match_item = map_to_conf(conf);
1341          if (match_item->ref_count == 0 && match_item->illegal)
1342            delete_conf_item(conf);
1343          break;
# Line 1367 | Line 1366 | detach_conf(struct Client *client_p, Con
1366   int
1367   attach_conf(struct Client *client_p, struct ConfItem *conf)
1368   {
1370  struct AccessItem *aconf;
1371  struct MatchItem *match_item;
1372
1369    if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
1370      return 1;
1371  
# Line 1377 | Line 1373 | attach_conf(struct Client *client_p, str
1373        conf->type == SERVER_TYPE ||
1374        conf->type == OPER_TYPE)
1375    {
1376 <    aconf = (struct AccessItem *)map_to_conf(conf);
1376 >    struct AccessItem *aconf = map_to_conf(conf);
1377 >    struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1378  
1379      if (IsConfIllegal(aconf))
1380        return NOT_AUTHORIZED;
1381  
1382      if (conf->type == CLIENT_TYPE)
1386    {
1387      struct ClassItem *aclass;
1388      aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
1389
1383        if (cidr_limit_reached(IsConfExemptLimits(aconf),
1384                               &client_p->localClient->ip, aclass))
1385 <        return TOO_MANY;  /* Already at maximum allowed */
1393 <
1394 <      CurrUserCount(aclass)++;
1395 <    }
1385 >        return TOO_MANY;    /* Already at maximum allowed */
1386  
1387 +    CurrUserCount(aclass)++;
1388      aconf->clients++;
1389    }
1390    else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
1391    {
1392 <    match_item = (struct MatchItem *)map_to_conf(conf);
1392 >    struct MatchItem *match_item = map_to_conf(conf);
1393      match_item->ref_count++;
1394    }
1395  
# Line 1432 | Line 1423 | attach_connect_block(struct Client *clie
1423    DLINK_FOREACH(ptr, server_items.head)
1424    {
1425      conf = ptr->data;
1426 <    aconf = (struct AccessItem *)map_to_conf(conf);
1426 >    aconf = map_to_conf(conf);
1427  
1428      if (match(conf->name, name) == 0 || match(aconf->host, host) == 0)
1429        continue;
# Line 1472 | Line 1463 | find_conf_exact(ConfType type, const cha
1463  
1464      if (conf->name == NULL)
1465        continue;
1466 <    aconf = (struct AccessItem *)map_to_conf(conf);
1466 >    aconf = map_to_conf(conf);
1467      if (aconf->host == NULL)
1468        continue;
1469      if (irccmp(conf->name, name) != 0)
# Line 1483 | Line 1474 | find_conf_exact(ConfType type, const cha
1474      ** socket host) matches *either* host or name field
1475      ** of the configuration.
1476      */
1477 <    if (!match(aconf->host, host) || !match(aconf->user,user)
1487 <        || irccmp(conf->name, name) )
1477 >    if (!match(aconf->host, host) || !match(aconf->user, user))
1478        continue;
1479      if (type == OPER_TYPE)
1480      {
1481 <      struct ClassItem *aclass;
1481 >      struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1482  
1483 <      aclass = (struct ClassItem *)aconf->class_ptr;
1494 <      if (aconf->clients < MaxTotal(aclass))
1495 <        return conf;
1496 <      else
1483 >      if (aconf->clients >= MaxTotal(aclass))
1484          continue;
1485      }
1486 <    else
1487 <      return conf;
1486 >
1487 >    return conf;
1488    }
1489 +
1490    return NULL;
1491   }
1492  
# Line 1853 | Line 1841 | set_default_conf(void)
1841    ConfigLoggingEntry.ioerrlog[0] = '\0';
1842    ConfigLoggingEntry.failed_operlog[0] = '\0';
1843  
1844 +  ConfigChannel.disable_fake_channels = NO;
1845    ConfigChannel.restrict_channels = NO;
1846    ConfigChannel.disable_local_channels = NO;
1847    ConfigChannel.use_invex = YES;
# Line 1860 | Line 1849 | set_default_conf(void)
1849    ConfigChannel.use_knock = YES;
1850    ConfigChannel.knock_delay = 300;
1851    ConfigChannel.knock_delay_channel = 60;
1863  ConfigChannel.invite_ops_only = YES;
1852    ConfigChannel.max_chans_per_user = 15;
1853    ConfigChannel.quiet_on_ban = YES;
1854    ConfigChannel.max_bans = 25;
# Line 1878 | Line 1866 | set_default_conf(void)
1866    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1867    ConfigServerHide.hide_server_ips = NO;
1868  
1869 +  
1870 +  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1871    ConfigFileEntry.gline_min_cidr = 16;
1872    ConfigFileEntry.gline_min_cidr6 = 48;
1873    ConfigFileEntry.invisible_on_connect = YES;
# Line 1924 | Line 1914 | set_default_conf(void)
1914    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1915    ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1916    ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;  /* XXX */
1917 <  ConfigFileEntry.oper_umodes = UMODE_LOCOPS | UMODE_SERVNOTICE |
1917 >  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1918      UMODE_OPERWALL | UMODE_WALLOP;        /* XXX */
1919    DupString(ConfigFileEntry.servlink_path, SLPATH);
1920   #ifdef HAVE_LIBCRYPTO
# Line 1955 | Line 1945 | set_default_conf(void)
1945   static void
1946   read_conf(FBFILE *file)
1947   {
1948 <  scount = lineno = 0;
1948 >  lineno = 0;
1949  
1950    set_default_conf(); /* Set default values prior to conf parsing */
1951    ypass = 1;
# Line 1991 | Line 1981 | validate_conf(void)
1981    if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
1982        (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
1983      ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
1984 +
1985 +  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1986   }
1987  
1988   /* lookup_confhost()
# Line 2267 | Line 2259 | expire_tklines(dlink_list *tklist)
2259            }
2260          }
2261  
2262 +        dlinkDelete(ptr, tklist);
2263          delete_one_address_conf(aconf->host, aconf);
2271        dlinkDelete(ptr, tklist);
2264        }
2265      }
2266      else if (conf->type == XLINE_TYPE ||
# Line 2322 | Line 2314 | expire_tklines(dlink_list *tklist)
2314          if (ConfigFileEntry.tkline_expire_notices)
2315            sendto_realops_flags(UMODE_ALL, L_ALL,
2316                                 "Temporary RESV for [%s] expired", cconf->name);
2317 <        dlinkDelete(ptr, tklist);
2326 <        free_dlink_node(ptr);
2327 <        delete_conf_item(conf);
2317 >        delete_channel_resv(cconf);
2318        }
2319      }
2320    }
# Line 2332 | Line 2322 | expire_tklines(dlink_list *tklist)
2322  
2323   /* oper_privs_as_string()
2324   *
2325 < * inputs        - pointer to client_p or NULL
2325 > * inputs        - pointer to client_p
2326   * output        - pointer to static string showing oper privs
2327   * side effects  - return as string, the oper privs as derived from port
2328   */
2329 <
2330 < static const unsigned int oper_flags_table[] =
2331 <  { 'O', 'R', 'U', 'G', 'N', 'K', 'X', 'D', 'H', 'A' , 0 };
2329 > static const struct oper_privs
2330 > {
2331 >  const unsigned int oprivs;
2332 >  const unsigned int hidden;
2333 >  const unsigned char c;
2334 > } flag_list[] = {
2335 >  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2336 >  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2337 >  { OPER_FLAG_DIE,         0,                       'D' },
2338 >  { OPER_FLAG_GLINE,       0,                       'G' },
2339 >  { OPER_FLAG_REHASH,      0,                       'H' },
2340 >  { OPER_FLAG_K,           0,                       'K' },
2341 >  { OPER_FLAG_OPERWALL,    0,                       'L' },
2342 >  { OPER_FLAG_N,           0,                       'N' },
2343 >  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2344 >  { OPER_FLAG_REMOTE,      0,                       'R' },
2345 >  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2346 >  { OPER_FLAG_UNKLINE,     0,                       'U' },
2347 >  { OPER_FLAG_X,           0,                       'X' },
2348 >  { 0, 0, '\0' }
2349 > };
2350  
2351   char *
2352   oper_privs_as_string(const unsigned int port)
2353   {
2354 <  static char privs_out[12];
2354 >  static char privs_out[16];
2355 >  char *privs_ptr = privs_out;
2356 >  unsigned int i = 0;
2357 >
2358 >  for (; flag_list[i].oprivs; ++i)
2359 >  {
2360 >    if ((port & flag_list[i].oprivs) &&
2361 >        (port & flag_list[i].hidden) == 0)
2362 >      *privs_ptr++ = flag_list[i].c;
2363 >    else
2364 >      *privs_ptr++ = ToLowerTab[flag_list[i].c];
2365 >  }
2366 >
2367 >  *privs_ptr = '\0';
2368  
2348  if (port & OPER_FLAG_HIDDEN_ADMIN)
2349    flags_to_ascii(port & ~OPER_FLAG_ADMIN, oper_flags_table, privs_out, 1);
2350  else
2351    flags_to_ascii(port, oper_flags_table, privs_out, 1);
2369    return privs_out;
2370   }
2371  
# Line 2455 | Line 2472 | read_conf_files(int cold)
2472    add_isupport("CHANLIMIT", chanlimit, -1);
2473    ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "",
2474               ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst");
2475 <  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
2475 >  add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2476    if (ConfigChannel.use_except)
2477      add_isupport("EXCEPTS", "e", -1);
2478    if (ConfigChannel.use_invex)
# Line 2540 | Line 2557 | clear_out_old_conf(void)
2557        /* XXX This is less than pretty */
2558        if (conf->type == SERVER_TYPE)
2559        {
2560 <        aconf = (struct AccessItem *)map_to_conf(conf);
2560 >        aconf = map_to_conf(conf);
2561 >
2562          if (aconf->clients != 0)
2563          {
2564            SetConfIllegal(aconf);
# Line 2553 | Line 2571 | clear_out_old_conf(void)
2571        }
2572        else if (conf->type == OPER_TYPE)
2573        {
2574 <        aconf = (struct AccessItem *)map_to_conf(conf);
2574 >        aconf = map_to_conf(conf);
2575 >
2576          if (aconf->clients != 0)
2577          {
2578            SetConfIllegal(aconf);
# Line 2566 | Line 2585 | clear_out_old_conf(void)
2585        }
2586        else if (conf->type == CLIENT_TYPE)
2587        {
2588 <        aconf = (struct AccessItem *)map_to_conf(conf);
2588 >        aconf = map_to_conf(conf);
2589 >
2590          if (aconf->clients != 0)
2591          {
2592            SetConfIllegal(aconf);
# Line 2591 | Line 2611 | clear_out_old_conf(void)
2611        {
2612          if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2613          {
2614 <          match_item = (struct MatchItem *)map_to_conf(conf);
2615 <          if ((match_item->ref_count <= 0))
2614 >          match_item = map_to_conf(conf);
2615 >          if (match_item->ref_count <= 0)
2616              delete_conf_item(conf);
2617            else
2618            {
# Line 2606 | Line 2626 | clear_out_old_conf(void)
2626      }
2627    }
2628  
2629 <  /* don't delete the class table, rather mark all entries
2629 >  /*
2630 >   * don't delete the class table, rather mark all entries
2631     * for deletion. The table is cleaned up by check_class. - avalon
2632     */
2633    DLINK_FOREACH(ptr, class_items.head)
2634    {
2635 <    conf = ptr->data;
2636 <    cltmp = (struct ClassItem *)map_to_conf(conf);
2635 >    cltmp = map_to_conf(ptr->data);
2636 >
2637      if (ptr != class_items.tail)  /* never mark the "default" class */
2638 <      MaxTotal(cltmp) = -1;
2638 >      cltmp->active = 0;
2639    }
2640  
2641    clear_out_address_conf();
# Line 2687 | Line 2708 | flush_deleted_I_P(void)
2708    struct ConfItem *conf;
2709    struct AccessItem *aconf;
2710    dlink_list * free_items [] = {
2711 <    &server_items, &oconf_items, &hub_items, &leaf_items, NULL
2711 >    &server_items, &oconf_items, NULL
2712    };
2713    dlink_list ** iterator = free_items; /* C is dumb */
2714  
# Line 2864 | Line 2885 | find_class(const char *classname)
2885    struct ConfItem *conf;
2886  
2887    if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2888 <    return(conf);
2888 >    return conf;
2889  
2890    return class_default;
2891   }
# Line 2878 | Line 2899 | find_class(const char *classname)
2899   void
2900   check_class(void)
2901   {
2902 <  dlink_node *ptr;
2882 <  dlink_node *next_ptr;
2883 <  struct ConfItem *conf;
2884 <  struct ClassItem *aclass;
2902 >  dlink_node *ptr = NULL, *next_ptr = NULL;
2903  
2904    DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head)
2905    {
2906 <    conf = ptr->data;
2889 <    aclass = (struct ClassItem *)map_to_conf(conf);
2906 >    struct ClassItem *aclass = map_to_conf(ptr->data);
2907  
2908 <    if (MaxTotal(aclass) < 0)
2908 >    if (!aclass->active && !CurrUserCount(aclass))
2909      {
2910        destroy_cidr_class(aclass);
2911 <      if (CurrUserCount(aclass) > 0)
2895 <        dlinkDelete(&conf->node, &class_items);
2896 <      else
2897 <        delete_conf_item(conf);
2911 >      delete_conf_item(ptr->data);
2912      }
2913    }
2914   }
# Line 2911 | Line 2925 | init_class(void)
2925    struct ClassItem *aclass;
2926  
2927    class_default = make_conf_item(CLASS_TYPE);
2928 <  aclass = (struct ClassItem *)map_to_conf(class_default);
2928 >
2929 >  aclass = map_to_conf(class_default);
2930 >  aclass->active = 1;
2931    DupString(class_default->name, "default");
2932    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2933    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
# Line 2927 | Line 2943 | init_class(void)
2943   * output       - sendq for this client as found from its class
2944   * side effects - NONE
2945   */
2946 < unsigned long
2946 > unsigned int
2947   get_sendq(struct Client *client_p)
2948   {
2949 <  unsigned long sendq = DEFAULT_SENDQ;
2949 >  unsigned int sendq = DEFAULT_SENDQ;
2950    dlink_node *ptr;
2951    struct ConfItem *conf;
2952    struct ConfItem *class_conf;
# Line 2970 | Line 2986 | get_sendq(struct Client *client_p)
2986   void
2987   conf_add_class_to_conf(struct ConfItem *conf, const char *class_name)
2988   {
2989 <  struct AccessItem *aconf;
2990 <  struct ClassItem *aclass;
2975 <
2976 <  aconf = (struct AccessItem *)map_to_conf(conf);
2989 >  struct AccessItem *aconf = map_to_conf(conf);
2990 >  struct ClassItem *class = NULL;
2991  
2992    if (class_name == NULL)
2993    {
2994      aconf->class_ptr = class_default;
2995 +
2996      if (conf->type == CLIENT_TYPE)
2997        sendto_realops_flags(UMODE_ALL, L_ALL,
2998                             "Warning *** Defaulting to default class for %s@%s",
# Line 2988 | Line 3003 | conf_add_class_to_conf(struct ConfItem *
3003                             conf->name);
3004    }
3005    else
2991  {
3006      aconf->class_ptr = find_class(class_name);
2993  }
3007  
3008 <  if (aconf->class_ptr == NULL)
3008 >  if (aconf->class_ptr)
3009 >    class = map_to_conf(aconf->class_ptr);
3010 >
3011 >  if (aconf->class_ptr == NULL || !class->active)
3012    {
3013      if (conf->type == CLIENT_TYPE)
3014        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 3004 | Line 3020 | conf_add_class_to_conf(struct ConfItem *
3020                             conf->name);
3021      aconf->class_ptr = class_default;
3022    }
3007  else
3008  {
3009    aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
3010    if (MaxTotal(aclass) < 0)
3011    {
3012      aconf->class_ptr = class_default;
3013    }
3014  }
3023   }
3024  
3017 #define MAXCONFLINKS 150
3018
3025   /* conf_add_server()
3026   *
3027   * inputs       - pointer to config item
# Line 3024 | Line 3030 | conf_add_class_to_conf(struct ConfItem *
3030   * side effects - Add a connect block
3031   */
3032   int
3033 < conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name)
3033 > conf_add_server(struct ConfItem *conf, const char *class_name)
3034   {
3035    struct AccessItem *aconf;
3036 <  char *orig_host;
3036 >  struct split_nuh_item nuh;
3037 >  char conf_user[USERLEN + 1];
3038 >  char conf_host[HOSTLEN + 1];
3039  
3040    aconf = map_to_conf(conf);
3041  
3042    conf_add_class_to_conf(conf, class_name);
3043  
3044 <  if (lcount > MAXCONFLINKS || !aconf->host || !conf->name)
3044 >  if (!aconf->host || !conf->name)
3045    {
3046      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
3047      ilog(L_WARN, "Bad connect block");
# Line 3048 | Line 3056 | conf_add_server(struct ConfItem *conf, u
3056      return -1;
3057    }
3058  
3059 <  orig_host = aconf->host;
3060 <  split_nuh(orig_host, NULL, &aconf->user, &aconf->host);
3061 <  MyFree(orig_host);
3059 >  nuh.nuhmask  = aconf->host;
3060 >  nuh.nickptr  = NULL;
3061 >  nuh.userptr  = conf_user;
3062 >  nuh.hostptr  = conf_host;
3063 >
3064 >  nuh.nicksize = 0;
3065 >  nuh.usersize = sizeof(conf_user);
3066 >  nuh.hostsize = sizeof(conf_host);
3067 >
3068 >  split_nuh(&nuh);
3069 >
3070 >  MyFree(aconf->host);
3071 >  aconf->host = NULL;
3072 >
3073 >  DupString(aconf->user, conf_user); /* somehow username checking for servers
3074 >                                 got lost in H6/7, will have to be re-added */
3075 >  DupString(aconf->host, conf_host);
3076 >
3077    lookup_confhost(conf);
3078  
3079    return 0;
# Line 3255 | Line 3278 | valid_wild_card(struct Client *source_p,
3278   *                if target_server is NULL and an "ON" is found error
3279   *                is reported.
3280   *                if reason pointer is NULL ignore pointer,
3281 < *                this allows usee of parse_a_line in unkline etc.
3281 > *                this allows use of parse_a_line in unkline etc.
3282   *
3283   * - Dianora
3284   */
# Line 3371 | Line 3394 | parse_aline(const char *cmd, struct Clie
3394  
3395    if (reason != NULL)
3396    {
3397 <    if (parc != 0)
3397 >    if (parc != 0 && !EmptyString(*parv))
3398      {
3399        *reason = *parv;
3400        if (!valid_comment(source_p, *reason, YES))
# Line 3410 | Line 3433 | find_user_host(struct Client *source_p,
3433    {
3434      /* Explicit user@host mask given */
3435  
3436 <    if(hostp != NULL)                            /* I'm a little user@host */
3436 >    if (hostp != NULL)                            /* I'm a little user@host */
3437      {
3438        *(hostp++) = '\0';                       /* short and squat */
3439        if (*user_host_or_nick)
# Line 3541 | Line 3564 | match_conf_password(const char *password
3564   */
3565   void
3566   cluster_a_line(struct Client *source_p, const char *command,
3567 <               int capab, int cluster_type, const char *pattern, ...)
3567 >               int capab, int cluster_type, const char *pattern, ...)
3568   {
3569    va_list args;
3570    char buffer[IRCD_BUFSIZE];
3571 <  struct ConfItem *conf;
3549 <  dlink_node *ptr;
3571 >  const dlink_node *ptr = NULL;
3572  
3573    va_start(args, pattern);
3574    vsnprintf(buffer, sizeof(buffer), pattern, args);
# Line 3554 | Line 3576 | cluster_a_line(struct Client *source_p,
3576  
3577    DLINK_FOREACH(ptr, cluster_items.head)
3578    {
3579 <    conf = ptr->data;
3579 >    const struct ConfItem *conf = ptr->data;
3580  
3581      if (conf->flags & cluster_type)
3560    {
3582        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
3583                           "%s %s %s", command, conf->name, buffer);
3563    }
3584    }
3585   }
3586  
# Line 3592 | Line 3612 | cluster_a_line(struct Client *source_p,
3612   * @                            *       *       *
3613   * !                            *       *       *
3614   */
3595
3615   void
3616 < split_nuh(char *mask, char **nick, char **user, char **host)
3616 > split_nuh(struct split_nuh_item *const iptr)
3617   {
3618    char *p = NULL, *q = NULL;
3619  
3620 <  if ((p = strchr(mask, '!')) != NULL)
3620 >  if (iptr->nickptr)
3621 >    strlcpy(iptr->nickptr, "*", iptr->nicksize);
3622 >  if (iptr->userptr)
3623 >    strlcpy(iptr->userptr, "*", iptr->usersize);
3624 >  if (iptr->hostptr)
3625 >    strlcpy(iptr->hostptr, "*", iptr->hostsize);
3626 >
3627 >  if ((p = strchr(iptr->nuhmask, '!')))
3628    {
3629      *p = '\0';
3604    if (nick != NULL)
3605    {
3606      if (*mask != '\0')
3607        *nick = xstrldup(mask, NICKLEN);
3608      else
3609        DupString(*nick, "*");
3610    }
3630  
3631 <    if ((q = strchr(++p, '@')) != NULL)
3632 <    {
3633 <      *q = '\0';
3631 >    if (iptr->nickptr && *iptr->nuhmask != '\0')
3632 >      strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3633 >
3634 >    if ((q = strchr(++p, '@'))) {
3635 >      *q++ = '\0';
3636  
3637        if (*p != '\0')
3638 <        *user = xstrldup(p, USERLEN+1);
3618 <      else
3619 <        DupString(*user, "*");
3638 >        strlcpy(iptr->userptr, p, iptr->usersize);
3639  
3640 <      if (*++q != '\0')
3641 <        *host = xstrldup(q, HOSTLEN+1);
3623 <      else
3624 <        DupString(*host, "*");
3640 >      if (*q != '\0')
3641 >        strlcpy(iptr->hostptr, q, iptr->hostsize);
3642      }
3643      else
3644      {
3645        if (*p != '\0')
3646 <        *user = xstrldup(p, USERLEN+1);
3630 <      else
3631 <        DupString(*user, "*");
3632 <
3633 <      DupString(*host, "*");
3646 >        strlcpy(iptr->userptr, p, iptr->usersize);
3647      }
3648    }
3649 <  else  /* No ! found so lets look for a user@host */
3649 >  else
3650    {
3651 <    if ((p = strchr(mask, '@')) != NULL)        /* if found a @ */
3651 >    /* No ! found so lets look for a user@host */
3652 >    if ((p = strchr(iptr->nuhmask, '@')))
3653      {
3654 <      if (nick != NULL)
3655 <        DupString(*nick, "*");
3642 <      *p = '\0';
3654 >      /* if found a @ */
3655 >      *p++ = '\0';
3656  
3657 <      if (*mask != '\0')
3658 <        *user = xstrldup(mask, USERLEN+1);
3646 <      else
3647 <        DupString(*user, "*");
3657 >      if (*iptr->nuhmask != '\0')
3658 >        strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
3659  
3660 <      if (*++p != '\0')
3661 <        *host = xstrldup(p, HOSTLEN+1);
3651 <      else
3652 <        DupString(*host, "*");
3660 >      if (*p != '\0')
3661 >        strlcpy(iptr->hostptr, p, iptr->hostsize);
3662      }
3663 <    else                                        /* no @ found */
3663 >    else
3664      {
3665 <      if (nick != NULL)
3666 <      {
3667 <        if (strpbrk(mask, ".:"))
3659 <        {
3660 <          DupString(*nick, "*");
3661 <          *host = xstrldup(mask, HOSTLEN+1);
3662 <        }
3663 <        else
3664 <        {
3665 <          *nick = xstrldup(mask, NICKLEN);
3666 <          DupString(*host, "*");
3667 <        }
3668 <
3669 <        DupString(*user, "*");
3670 <      }
3665 >      /* no @ found */
3666 >      if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
3667 >        strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
3668        else
3669 <      {
3673 <        DupString(*user, "*");
3674 <        *host = xstrldup(mask, HOSTLEN+1);
3675 <      }
3669 >        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3670      }
3671    }
3672   }
# Line 3699 | Line 3693 | flags_to_ascii(unsigned int flags, const
3693    {
3694      if (flags & mask)
3695        *p++ = bit_table[i];
3696 <    else if(lowerit)
3696 >    else if (lowerit)
3697        *p++ = ToLower(bit_table[i]);
3698    }
3699    *p = '\0';
# Line 3906 | Line 3900 | rebuild_cidr_class(struct ConfItem *conf
3900   static void
3901   destroy_cidr_list(dlink_list *list)
3902   {
3903 <  dlink_node *ptr = NULL;
3910 <  dlink_node *next_ptr = NULL;
3911 <  struct CidrItem *cidr;
3903 >  dlink_node *ptr = NULL, *next_ptr = NULL;
3904  
3905    DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
3906    {
3915    cidr = ptr->data;
3907      dlinkDelete(ptr, list);
3908 <    MyFree(cidr);
3908 >    MyFree(ptr->data);
3909    }
3910   }
3911  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)