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-7.2/src/s_conf.c (file contents), Revision 201 by adx, Tue Nov 1 11:41:52 2005 UTC vs.
ircd-hybrid-8/src/s_conf.c (file contents), Revision 1303 by michael, Fri Mar 23 10:52:19 2012 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 + #include "list.h"
27   #include "ircd_defs.h"
28 < #include "tools.h"
28 > #include "balloc.h"
29   #include "s_conf.h"
30   #include "s_serv.h"
31   #include "resv.h"
31 #include "s_stats.h"
32   #include "channel.h"
33   #include "client.h"
34 #include "common.h"
34   #include "event.h"
35   #include "hash.h"
36   #include "hook.h"
37   #include "irc_string.h"
38   #include "sprintf_irc.h"
39   #include "s_bsd.h"
41 #include "irc_getnameinfo.h"
42 #include "irc_getaddrinfo.h"
40   #include "ircd.h"
44 #include "list.h"
41   #include "listener.h"
42   #include "hostmask.h"
43   #include "modules.h"
# Line 56 | Line 52
52   #include "userhost.h"
53   #include "s_user.h"
54   #include "channel_mode.h"
55 + #include "parse.h"
56 + #include "s_misc.h"
57  
58   struct Callback *client_check_cb = NULL;
59   struct config_server_hide ConfigServerHide;
60  
61   /* general conf items link list root, other than k lines etc. */
62 + dlink_list service_items = { NULL, NULL, 0 };
63   dlink_list server_items  = { NULL, NULL, 0 };
64   dlink_list cluster_items = { NULL, NULL, 0 };
65   dlink_list hub_items     = { NULL, NULL, 0 };
# Line 87 | Line 86 | extern char linebuf[];
86   extern char conffilebuf[IRCD_BUFSIZE];
87   extern char yytext[];
88   extern int yyparse(); /* defined in y.tab.c */
89 < unsigned int scount = 0; /* used by yyparse(), etc */
90 < int ypass  = 1; /* used by yyparse()      */
89 >
90 > struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
91  
92   /* internally defined functions */
93   static void lookup_confhost(struct ConfItem *);
# Line 117 | Line 116 | static void destroy_cidr_class(struct Cl
116  
117   static void flags_to_ascii(unsigned int, const unsigned int[], char *, int);
118  
120 FBFILE *conf_fbfile_in = NULL;
121
119   /* address of default class conf */
120   static struct ConfItem *class_default;
121  
# Line 141 | Line 138 | static BlockHeap *ip_entry_heap = NULL;
138   static int ip_entries_count = 0;
139  
140  
141 < inline void *
141 > void *
142   map_to_conf(struct ConfItem *aconf)
143   {
144    void *conf;
145 <  conf = (void *)((unsigned long)aconf +
146 <                  (unsigned long)sizeof(struct ConfItem));
145 >  conf = (void *)((uintptr_t)aconf +
146 >                  (uintptr_t)sizeof(struct ConfItem));
147    return(conf);
148   }
149  
150 < inline struct ConfItem *
150 > struct ConfItem *
151   unmap_conf_item(void *aconf)
152   {
153    struct ConfItem *conf;
154  
155 <  conf = (struct ConfItem *)((unsigned long)aconf -
156 <                             (unsigned long)sizeof(struct ConfItem));
155 >  conf = (struct ConfItem *)((uintptr_t)aconf -
156 >                             (uintptr_t)sizeof(struct ConfItem));
157    return(conf);
158   }
159  
# Line 171 | Line 168 | unmap_conf_item(void *aconf)
168   * if successful save hp in the conf item it was called with
169   */
170   static void
171 < conf_dns_callback(void *vptr, struct DNSReply *reply)
171 > conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
172   {
173 <  struct AccessItem *aconf = (struct AccessItem *)vptr;
177 <  struct ConfItem *conf;
173 >  struct AccessItem *aconf = vptr;
174  
175 <  MyFree(aconf->dns_query);
180 <  aconf->dns_query = NULL;
175 >  aconf->dns_pending = 0;
176  
177 <  if (reply != NULL)
178 <    memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr));
179 <  else {
180 <    ilog(L_NOTICE, "Host not found: %s, ignoring connect{} block",
186 <         aconf->host);
187 <    conf = unmap_conf_item(aconf);
188 <    sendto_realops_flags(UMODE_ALL, L_ALL,
189 <                         "Ignoring connect{} block for %s - host not found",
190 <                         conf->name);
191 <    delete_conf_item(conf);
192 <  }
177 >  if (addr != NULL)
178 >    memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum));
179 >  else
180 >    aconf->dns_failed = 1;
181   }
182  
183   /* conf_dns_lookup()
# Line 201 | Line 189 | conf_dns_callback(void *vptr, struct DNS
189   static void
190   conf_dns_lookup(struct AccessItem *aconf)
191   {
192 <  if (aconf->dns_query == NULL)
192 >  if (!aconf->dns_pending)
193    {
194 <    aconf->dns_query = MyMalloc(sizeof(struct DNSQuery));
195 <    aconf->dns_query->ptr = aconf;
208 <    aconf->dns_query->callback = conf_dns_callback;
209 <    gethost_byname(aconf->host, aconf->dns_query);
194 >    aconf->dns_pending = 1;
195 >    gethost_byname(conf_dns_callback, aconf, aconf->host);
196    }
197   }
198  
# Line 306 | Line 292 | make_conf_item(ConfType type)
292                                         sizeof(struct MatchItem));
293      dlinkAdd(conf, &conf->node, &xconf_items);
294      break;
295 <
295 > #ifdef HAVE_LIBPCRE
296    case RXLINE_TYPE:
297      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
298                                         sizeof(struct MatchItem));
# Line 320 | Line 306 | make_conf_item(ConfType type)
306      aconf->status = CONF_KLINE;
307      dlinkAdd(conf, &conf->node, &rkconf_items);
308      break;
309 <
309 > #endif
310    case CLUSTER_TYPE:
311      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem));
312      dlinkAdd(conf, &conf->node, &cluster_items);
# Line 337 | Line 323 | make_conf_item(ConfType type)
323      dlinkAdd(conf, &conf->node, &nresv_items);
324      break;
325  
326 +  case SERVICE_TYPE:
327 +    status = CONF_SERVICE;
328 +    conf = MyMalloc(sizeof(struct ConfItem));
329 +    dlinkAdd(conf, &conf->node, &service_items);
330 +    break;
331 +
332    case CLASS_TYPE:
333 <    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
334 <                                       sizeof(struct ClassItem));
333 >    conf = MyMalloc(sizeof(struct ConfItem) +
334 >                           sizeof(struct ClassItem));
335      dlinkAdd(conf, &conf->node, &class_items);
336 <    aclass = (struct ClassItem *)map_to_conf(conf);
337 <    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
336 >
337 >    aclass = map_to_conf(conf);
338 >    aclass->active = 1;
339 >    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
340      PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
341      MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
342      MaxSendq(aclass) = DEFAULT_SENDQ;
343 <    CurrUserCount(aclass) = 0;
343 >
344      break;
345  
346    default:
# Line 357 | Line 351 | make_conf_item(ConfType type)
351    /* XXX Yes, this will core if default is hit. I want it to for now - db */
352    conf->type = type;
353  
354 <  return(conf);
354 >  return conf;
355   }
356  
357   void
358   delete_conf_item(struct ConfItem *conf)
359   {
360 +  dlink_node *m = NULL;
361    struct MatchItem *match_item;
362    struct AccessItem *aconf;
363    ConfType type = conf->type;
# Line 381 | Line 376 | delete_conf_item(struct ConfItem *conf)
376    case SERVER_TYPE:
377      aconf = map_to_conf(conf);
378  
379 <    if (aconf->dns_query != NULL)
380 <    {
386 <      delete_resolver_queries(aconf->dns_query);
387 <      MyFree(aconf->dns_query);
388 <    }
379 >    if (aconf->dns_pending)
380 >      delete_resolver_queries(aconf);
381      if (aconf->passwd != NULL)
382        memset(aconf->passwd, 0, strlen(aconf->passwd));
383      if (aconf->spasswd != NULL)
# Line 398 | Line 390 | delete_conf_item(struct ConfItem *conf)
390      MyFree(aconf->oper_reason);
391      MyFree(aconf->user);
392      MyFree(aconf->host);
401    MyFree(aconf->fakename);
393   #ifdef HAVE_LIBCRYPTO
394      if (aconf->rsa_public_key)
395        RSA_free(aconf->rsa_public_key);
# Line 478 | Line 469 | delete_conf_item(struct ConfItem *conf)
469      dlinkDelete(&conf->node, &xconf_items);
470      MyFree(conf);
471      break;
472 <
472 > #ifdef HAVE_LIBPCRE
473    case RKLINE_TYPE:
474      aconf = map_to_conf(conf);
475      MyFree(aconf->regexuser);
# Line 501 | Line 492 | delete_conf_item(struct ConfItem *conf)
492      dlinkDelete(&conf->node, &rxconf_items);
493      MyFree(conf);
494      break;
495 <
495 > #endif
496    case NRESV_TYPE:
497      match_item = map_to_conf(conf);
498      MyFree(match_item->user);
# Line 509 | Line 500 | delete_conf_item(struct ConfItem *conf)
500      MyFree(match_item->reason);
501      MyFree(match_item->oper_reason);
502      dlinkDelete(&conf->node, &nresv_items);
503 +
504 +    if (conf->flags & CONF_FLAGS_TEMPORARY)
505 +      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
506 +        free_dlink_node(m);
507 +
508      MyFree(conf);
509      break;
510  
# Line 526 | Line 522 | delete_conf_item(struct ConfItem *conf)
522      break;
523  
524    case CRESV_TYPE:
525 +    if (conf->flags & CONF_FLAGS_TEMPORARY)
526 +      if ((m = dlinkFindDelete(&temporary_resv, conf)) != NULL)
527 +        free_dlink_node(m);
528 +
529      MyFree(conf);
530      break;
531  
# Line 534 | Line 534 | delete_conf_item(struct ConfItem *conf)
534      MyFree(conf);
535      break;
536  
537 +  case SERVICE_TYPE:
538 +    dlinkDelete(&conf->node, &service_items);
539 +    MyFree(conf);
540 +    break;
541 +
542    default:
543      break;
544    }
# Line 576 | Line 581 | report_confitem_types(struct Client *sou
581    struct ClassItem *classitem = NULL;
582    char buf[12];
583    char *p = NULL;
584 +  const char *pfx = NULL;
585  
586    switch (type)
587    {
# Line 618 | Line 624 | report_confitem_types(struct Client *sou
624      }
625      break;
626  
627 + #ifdef HAVE_LIBPCRE
628    case RXLINE_TYPE:
629      DLINK_FOREACH(ptr, rxconf_items.head)
630      {
# Line 632 | Line 639 | report_confitem_types(struct Client *sou
639      break;
640  
641    case RKLINE_TYPE:
642 <    p = temp ? "Rk" : "RK";
642 >    pfx = temp ? "kR" : "KR";
643  
644      DLINK_FOREACH(ptr, rkconf_items.head)
645      {
# Line 642 | Line 649 | report_confitem_types(struct Client *sou
649          continue;
650  
651        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
652 <                 source_p->name, p, aconf->host, aconf->user,
652 >                 source_p->name, pfx, aconf->host, aconf->user,
653                   aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
654      }
655      break;
656 + #endif
657  
658    case ULINE_TYPE:
659      DLINK_FOREACH(ptr, uconf_items.head)
# Line 690 | Line 698 | report_confitem_types(struct Client *sou
698        aconf = map_to_conf(conf);
699  
700        /* Don't allow non opers to see oper privs */
701 <      if (IsOper(source_p))
701 >      if (HasUMode(source_p, UMODE_OPER))
702          sendto_one(source_p, form_str(RPL_STATSOLINE),
703                     me.name, source_p->name, 'O', aconf->user, aconf->host,
704                     conf->name, oper_privs_as_string(aconf->port),
# Line 712 | Line 720 | report_confitem_types(struct Client *sou
720                   me.name, source_p->name, 'Y',
721                   conf->name, PingFreq(classitem),
722                   ConFreq(classitem),
723 <                 MaxTotal(classitem), MaxSendq(classitem));
723 >                 MaxTotal(classitem), MaxSendq(classitem),
724 >                 CurrUserCount(classitem),
725 >                 classitem->active ? "active" : "disabled");
726      }
727      break;
728  
# Line 720 | Line 730 | report_confitem_types(struct Client *sou
730    case CLIENT_TYPE:
731      break;
732  
733 +  case SERVICE_TYPE:
734 +    DLINK_FOREACH(ptr, service_items.head)
735 +    {
736 +      conf = ptr->data;
737 +      sendto_one(source_p, form_str(RPL_STATSSERVICE),
738 +                 me.name, source_p->name, 'S', "*", conf->name, 0, 0);
739 +    }
740 +    break;
741 +
742    case SERVER_TYPE:
743      DLINK_FOREACH(ptr, server_items.head)
744      {
# Line 732 | Line 751 | report_confitem_types(struct Client *sou
751  
752        if (IsConfAllowAutoConn(aconf))
753          *p++ = 'A';
754 <      if (IsConfCryptLink(aconf))
755 <        *p++ = 'C';
737 <      if (IsConfLazyLink(aconf))
738 <        *p++ = 'L';
739 <      if (aconf->fakename)
740 <        *p++ = 'M';
754 >      if (IsConfSSL(aconf))
755 >        *p++ = 'S';
756        if (IsConfTopicBurst(aconf))
757          *p++ = 'T';
743      if (IsConfCompressed(aconf))
744        *p++ = 'Z';
758        if (buf[0] == '\0')
759          *p++ = '*';
760  
761        *p = '\0';
762  
763 <      /* Allow admins to see actual ips
764 <       * unless hide_server_ips is enabled
763 >      /*
764 >       * Allow admins to see actual ips unless hide_server_ips is enabled
765         */
766 <      if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
766 >      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
767          sendto_one(source_p, form_str(RPL_STATSCLINE),
768                     me.name, source_p->name, 'C', aconf->host,
769                     buf, conf->name, aconf->port,
# Line 790 | Line 803 | report_confitem_types(struct Client *sou
803    case CRESV_TYPE:
804    case NRESV_TYPE:
805    case CLUSTER_TYPE:
806 +  default:
807      break;
808    }
809   }
# Line 816 | Line 830 | check_client(va_list args)
830  
831    /* I'm already in big trouble if source_p->localClient is NULL -db */
832    if ((i = verify_access(source_p, username)))
833 <  {
820 <    ilog(L_INFO, "Access denied: %s[%s]",
833 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
834           source_p->name, source_p->sockhost);
822  }
835  
836    switch (i)
837    {
826    case IRCD_SOCKET_ERROR:
827      exit_client(source_p, &me, "Socket Error");
828      break;
829
838      case TOO_MANY:
839        sendto_realops_flags(UMODE_FULL, L_ALL,
840                             "Too many on IP for %s (%s).",
841                             get_client_name(source_p, SHOW_IP),
842                             source_p->sockhost);
843 <      ilog(L_INFO,"Too many connections on IP from %s.",
843 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
844             get_client_name(source_p, SHOW_IP));
845 <      ServerStats->is_ref++;
845 >      ++ServerStats.is_ref;
846        exit_client(source_p, &me, "No more connections allowed on that IP");
847        break;
848  
# Line 843 | Line 851 | check_client(va_list args)
851                             "I-line is full for %s (%s).",
852                             get_client_name(source_p, SHOW_IP),
853                             source_p->sockhost);
854 <      ilog(L_INFO,"Too many connections from %s.",
854 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
855             get_client_name(source_p, SHOW_IP));
856 <       ServerStats->is_ref++;
856 >      ++ServerStats.is_ref;
857        exit_client(source_p, &me,
858                  "No more connections allowed in your connection class");
859        break;
860  
861      case NOT_AUTHORIZED:
862 <    {
855 <      static char ipaddr[HOSTIPLEN];
856 <      ServerStats->is_ref++;
862 >      ++ServerStats.is_ref;
863        /* jdc - lists server name & port connections are on */
864        /*       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);
865        sendto_realops_flags(UMODE_UNAUTH, L_ALL,
866                             "Unauthorized client connection from %s [%s] on [%s/%u].",
867                             get_client_name(source_p, SHOW_IP),
868 <                           ipaddr,
868 >                           source_p->sockhost,
869                             source_p->localClient->listener->name,
870                             source_p->localClient->listener->port);
871 <      ilog(L_INFO,
871 >      ilog(LOG_TYPE_IRCD,
872            "Unauthorized client connection from %s on [%s/%u].",
873            get_client_name(source_p, SHOW_IP),
874            source_p->localClient->listener->name,
# Line 875 | Line 878 | check_client(va_list args)
878         * capture reject code here or rely on the connecting too fast code.
879         * - Dianora
880         */
881 <      if(REJECT_HOLD_TIME > 0)
881 >      if (REJECT_HOLD_TIME > 0)
882        {
883          sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",
884                     me.name, source_p->name);
# Line 885 | Line 888 | check_client(va_list args)
888        else
889          exit_client(source_p, &me, "You are not authorized to use this server");
890        break;
891 <    }
889 <
891 >
892     case BANNED_CLIENT:
893       /*
894        * Don't exit them immediately, play with them a bit.
# Line 899 | Line 901 | check_client(va_list args)
901       }
902       else
903         exit_client(source_p, &me, "Banned");
904 <     ServerStats->is_ref++;
904 >     ++ServerStats.is_ref;
905       break;
906  
907     case 0:
# Line 1016 | Line 1018 | attach_iline(struct Client *client_p, st
1018    ip_found->count++;
1019    SetIpHash(client_p);
1020  
1021 <  aconf = (struct AccessItem *)map_to_conf(conf);
1021 >  aconf = map_to_conf(conf);
1022    if (aconf->class_ptr == NULL)
1023      return NOT_AUTHORIZED;  /* If class is missing, this is best */
1024  
1025 <  aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
1025 >  aclass = map_to_conf(aconf->class_ptr);
1026  
1027    count_user_host(client_p->username, client_p->host,
1028                    &global, &local, &ident);
# Line 1031 | Line 1033 | attach_iline(struct Client *client_p, st
1033     */
1034    if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
1035      a_limit_reached = 1;
1036 <  else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass))
1036 >  else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))
1037      a_limit_reached = 1;
1038    else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
1039      a_limit_reached = 1;
# Line 1044 | Line 1046 | attach_iline(struct Client *client_p, st
1046    if (a_limit_reached)
1047    {
1048      if (!IsConfExemptLimits(aconf))
1049 <      return TOO_MANY;  /* Already at maximum allowed */
1049 >      return TOO_MANY;   /* Already at maximum allowed */
1050  
1051      sendto_one(client_p,
1052                 ":%s NOTICE %s :*** Your connection class is full, "
# Line 1193 | Line 1195 | hash_ip(struct irc_ssaddr *addr)
1195    {
1196      struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
1197      int hash;
1198 <    u_int32_t ip;
1198 >    uint32_t ip;
1199  
1200      ip   = ntohl(v4->sin_addr.s_addr);
1201      hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1);
# Line 1204 | Line 1206 | hash_ip(struct irc_ssaddr *addr)
1206    {
1207      int hash;
1208      struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr;
1209 <    u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr;
1209 >    uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr;
1210  
1211      hash  = ip[0] ^ ip[3];
1212      hash ^= hash >> 16;  
# Line 1228 | Line 1230 | hash_ip(struct irc_ssaddr *addr)
1230   * used in the hash.
1231   */
1232   void
1233 < count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored)
1233 > count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored)
1234   {
1235    struct ip_entry *ptr;
1236    int i;
# Line 1316 | Line 1318 | detach_conf(struct Client *client_p, Con
1318        case CLIENT_TYPE:
1319        case OPER_TYPE:
1320        case SERVER_TYPE:
1321 <        aconf = (struct AccessItem *)map_to_conf(conf);
1321 >        aconf = map_to_conf(conf);
1322 >
1323 >        assert(aconf->clients > 0);
1324 >
1325          if ((aclass_conf = ClassPtr(aconf)) != NULL)
1326          {
1327 <          aclass = (struct ClassItem *)map_to_conf(aclass_conf);
1327 >          aclass = map_to_conf(aclass_conf);
1328 >
1329 >          assert(aclass->curr_user_count > 0);
1330  
1331            if (conf->type == CLIENT_TYPE)
1332              remove_from_cidr_check(&client_p->localClient->ip, aclass);
1333 <
1327 <          if (CurrUserCount(aclass) > 0)
1328 <            aclass->curr_user_count--;
1329 <          if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0)
1333 >          if (--aclass->curr_user_count == 0 && aclass->active == 0)
1334              delete_conf_item(aclass_conf);
1335          }
1336  
1337 <        /* Please, no ioccc entries - Dianora */
1334 <        if (aconf->clients > 0)
1335 <          --aconf->clients;
1336 <        if (aconf->clients == 0 && IsConfIllegal(aconf))
1337 >        if (--aconf->clients == 0 && IsConfIllegal(aconf))
1338            delete_conf_item(conf);
1339 +
1340          break;
1341 +
1342        case LEAF_TYPE:
1343        case HUB_TYPE:
1344 <        match_item = (struct MatchItem *)map_to_conf(conf);
1344 >        match_item = map_to_conf(conf);
1345          if (match_item->ref_count == 0 && match_item->illegal)
1346            delete_conf_item(conf);
1347          break;
# Line 1367 | Line 1370 | detach_conf(struct Client *client_p, Con
1370   int
1371   attach_conf(struct Client *client_p, struct ConfItem *conf)
1372   {
1370  struct AccessItem *aconf;
1371  struct MatchItem *match_item;
1372
1373    if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
1374      return 1;
1375  
# Line 1377 | Line 1377 | attach_conf(struct Client *client_p, str
1377        conf->type == SERVER_TYPE ||
1378        conf->type == OPER_TYPE)
1379    {
1380 <    aconf = (struct AccessItem *)map_to_conf(conf);
1380 >    struct AccessItem *aconf = map_to_conf(conf);
1381 >    struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1382  
1383      if (IsConfIllegal(aconf))
1384        return NOT_AUTHORIZED;
1385  
1386      if (conf->type == CLIENT_TYPE)
1386    {
1387      struct ClassItem *aclass;
1388      aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
1389
1387        if (cidr_limit_reached(IsConfExemptLimits(aconf),
1388                               &client_p->localClient->ip, aclass))
1389 <        return TOO_MANY;  /* Already at maximum allowed */
1393 <
1394 <      CurrUserCount(aclass)++;
1395 <    }
1389 >        return TOO_MANY;    /* Already at maximum allowed */
1390  
1391 +    CurrUserCount(aclass)++;
1392      aconf->clients++;
1393    }
1394    else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
1395    {
1396 <    match_item = (struct MatchItem *)map_to_conf(conf);
1396 >    struct MatchItem *match_item = map_to_conf(conf);
1397      match_item->ref_count++;
1398    }
1399  
# Line 1432 | Line 1427 | attach_connect_block(struct Client *clie
1427    DLINK_FOREACH(ptr, server_items.head)
1428    {
1429      conf = ptr->data;
1430 <    aconf = (struct AccessItem *)map_to_conf(conf);
1430 >    aconf = map_to_conf(conf);
1431  
1432      if (match(conf->name, name) == 0 || match(aconf->host, host) == 0)
1433        continue;
# Line 1472 | Line 1467 | find_conf_exact(ConfType type, const cha
1467  
1468      if (conf->name == NULL)
1469        continue;
1470 <    aconf = (struct AccessItem *)map_to_conf(conf);
1470 >    aconf = map_to_conf(conf);
1471      if (aconf->host == NULL)
1472        continue;
1473      if (irccmp(conf->name, name) != 0)
# Line 1483 | Line 1478 | find_conf_exact(ConfType type, const cha
1478      ** socket host) matches *either* host or name field
1479      ** of the configuration.
1480      */
1481 <    if (!match(aconf->host, host) || !match(aconf->user,user)
1487 <        || irccmp(conf->name, name) )
1481 >    if (!match(aconf->host, host) || !match(aconf->user, user))
1482        continue;
1483      if (type == OPER_TYPE)
1484      {
1485 <      struct ClassItem *aclass;
1485 >      struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1486  
1487 <      aclass = (struct ClassItem *)aconf->class_ptr;
1494 <      if (aconf->clients < MaxTotal(aclass))
1495 <        return conf;
1496 <      else
1487 >      if (aconf->clients >= MaxTotal(aclass))
1488          continue;
1489      }
1490 <    else
1491 <      return conf;
1490 >
1491 >    return conf;
1492    }
1493 +
1494    return NULL;
1495   }
1496  
# Line 1564 | Line 1556 | map_to_list(ConfType type)
1556    case SERVER_TYPE:
1557      return(&server_items);
1558      break;
1559 +  case SERVICE_TYPE:
1560 +    return(&service_items);
1561 +    break;
1562    case CLUSTER_TYPE:
1563      return(&cluster_items);
1564      break;
# Line 1599 | Line 1594 | find_matching_name_conf(ConfType type, c
1594  
1595    switch (type)
1596    {
1597 <    case RXLINE_TYPE:
1597 > #ifdef HAVE_LIBPCRE
1598 >  case RXLINE_TYPE:
1599        DLINK_FOREACH(ptr, list_p->head)
1600        {
1601          conf = ptr->data;
# Line 1609 | Line 1605 | find_matching_name_conf(ConfType type, c
1605            return conf;
1606        }
1607        break;
1608 + #endif
1609 +  case SERVICE_TYPE:
1610 +    DLINK_FOREACH(ptr, list_p->head)
1611 +    {
1612 +      conf = ptr->data;
1613 +
1614 +      if (EmptyString(conf->name))
1615 +        continue;
1616 +      if ((name != NULL) && !irccmp(name, conf->name))
1617 +        return conf;
1618 +    }
1619 +    break;
1620  
1621    case XLINE_TYPE:
1622    case ULINE_TYPE:
# Line 1663 | Line 1671 | find_matching_name_conf(ConfType type, c
1671   * side effects - looks for an exact match on name field
1672   */
1673   struct ConfItem *
1674 < find_exact_name_conf(ConfType type, const char *name,
1674 > find_exact_name_conf(ConfType type, const struct Client *who, const char *name,
1675                       const char *user, const char *host)
1676   {
1677    dlink_node *ptr = NULL;
# Line 1704 | Line 1712 | find_exact_name_conf(ConfType type, cons
1712      DLINK_FOREACH(ptr, list_p->head)
1713      {
1714        conf = ptr->data;
1715 <      aconf = (struct AccessItem *)map_to_conf(conf);
1715 >      aconf = map_to_conf(conf);
1716 >
1717        if (EmptyString(conf->name))
1718 <        continue;
1719 <    
1720 <      if (irccmp(conf->name, name) == 0)
1718 >        continue;
1719 >
1720 >      if (!irccmp(conf->name, name))
1721        {
1722 <        if ((user == NULL && (host == NULL)))
1723 <          return (conf);
1724 <        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1725 <          return (conf);
1726 <        if (match(aconf->user, user) && match(aconf->host, host))
1727 <          return (conf);
1722 >        if (!who)
1723 >          return conf;
1724 >        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1725 >          return conf;
1726 >        if (match(aconf->user, who->username))
1727 >        {
1728 >          switch (aconf->type)
1729 >          {
1730 >            case HM_HOST:
1731 >              if (match(aconf->host, who->host) || match(aconf->host, who->sockhost))
1732 >                return conf;
1733 >              break;
1734 >            case HM_IPV4:
1735 >              if (who->localClient->aftype == AF_INET)
1736 >                if (match_ipv4(&who->localClient->ip, &aconf->ipnum, aconf->bits))
1737 >                  return conf;
1738 >              break;
1739 > #ifdef IPV6
1740 >            case HM_IPV6:
1741 >              if (who->localClient->aftype == AF_INET6)
1742 >                if (match_ipv6(&who->localClient->ip, &aconf->ipnum, aconf->bits))
1743 >                  return conf;
1744 >              break;
1745 > #endif
1746 >            default:
1747 >              assert(0);
1748 >          }
1749 >        }
1750        }
1751      }
1752 +
1753      break;
1754  
1755    case SERVER_TYPE:
# Line 1773 | Line 1805 | rehash(int sig)
1805      sendto_realops_flags(UMODE_ALL, L_ALL,
1806                           "Got signal SIGHUP, reloading ircd.conf file");
1807  
1776 #ifndef _WIN32
1808    restart_resolver();
1809 < #endif
1809 >
1810    /* don't close listeners until we know we can go ahead with the rehash */
1811  
1812    /* Check to see if we magically got(or lost) IPv6 support */
# Line 1786 | Line 1817 | rehash(int sig)
1817    if (ServerInfo.description != NULL)
1818      strlcpy(me.info, ServerInfo.description, sizeof(me.info));
1819  
1789 #ifndef STATIC_MODULES
1820    load_conf_modules();
1791 #endif
1821  
1822    flush_deleted_I_P();
1823  
1824    rehashed_klines = 1;
1825 <
1825 > /* XXX */
1826    if (ConfigLoggingEntry.use_logging)
1827 <    reopen_log(logFileName);
1827 >    log_close_all();
1828  
1829    return(0);
1830   }
# Line 1834 | Line 1863 | set_default_conf(void)
1863    ServerInfo.specific_ipv6_vhost = 0;
1864  
1865    ServerInfo.max_clients = MAXCLIENTS_MAX;
1866 <  /* Don't reset hub, as that will break lazylinks */
1867 <  /* ServerInfo.hub = NO; */
1866 >
1867 >  ServerInfo.hub = 0;
1868    ServerInfo.dns_host.sin_addr.s_addr = 0;
1869    ServerInfo.dns_host.sin_port = 0;
1870    AdminInfo.name = NULL;
1871    AdminInfo.email = NULL;
1872    AdminInfo.description = NULL;
1873  
1874 <  set_log_level(L_NOTICE);
1874 >  log_close_all();
1875 >
1876    ConfigLoggingEntry.use_logging = 1;
1877 <  ConfigLoggingEntry.operlog[0] = '\0';
1878 <  ConfigLoggingEntry.userlog[0] = '\0';
1879 <  ConfigLoggingEntry.klinelog[0] = '\0';
1880 <  ConfigLoggingEntry.glinelog[0] = '\0';
1881 <  ConfigLoggingEntry.killlog[0] = '\0';
1882 <  ConfigLoggingEntry.operspylog[0] = '\0';
1883 <  ConfigLoggingEntry.ioerrlog[0] = '\0';
1884 <  ConfigLoggingEntry.failed_operlog[0] = '\0';
1855 <
1856 <  ConfigChannel.restrict_channels = NO;
1857 <  ConfigChannel.disable_local_channels = NO;
1858 <  ConfigChannel.use_invex = YES;
1859 <  ConfigChannel.use_except = YES;
1860 <  ConfigChannel.use_knock = YES;
1877 >  ConfigLoggingEntry.timestamp = 1;
1878 >
1879 >  ConfigChannel.disable_fake_channels = 0;
1880 >  ConfigChannel.restrict_channels = 0;
1881 >  ConfigChannel.disable_local_channels = 0;
1882 >  ConfigChannel.use_invex = 1;
1883 >  ConfigChannel.use_except = 1;
1884 >  ConfigChannel.use_knock = 1;
1885    ConfigChannel.knock_delay = 300;
1886    ConfigChannel.knock_delay_channel = 60;
1887    ConfigChannel.max_chans_per_user = 15;
1888 <  ConfigChannel.quiet_on_ban = YES;
1888 >  ConfigChannel.quiet_on_ban = 1;
1889    ConfigChannel.max_bans = 25;
1890    ConfigChannel.default_split_user_count = 0;
1891    ConfigChannel.default_split_server_count = 0;
1892 <  ConfigChannel.no_join_on_split = NO;
1893 <  ConfigChannel.no_create_on_split = NO;
1894 <  ConfigChannel.burst_topicwho = YES;
1892 >  ConfigChannel.no_join_on_split = 0;
1893 >  ConfigChannel.no_create_on_split = 0;
1894 >  ConfigChannel.burst_topicwho = 1;
1895  
1896 <  ConfigServerHide.flatten_links = NO;
1896 >  ConfigServerHide.flatten_links = 0;
1897    ConfigServerHide.links_delay = 300;
1898 <  ConfigServerHide.hidden = NO;
1899 <  ConfigServerHide.disable_hidden = NO;
1900 <  ConfigServerHide.hide_servers = NO;
1898 >  ConfigServerHide.hidden = 0;
1899 >  ConfigServerHide.disable_hidden = 0;
1900 >  ConfigServerHide.hide_servers = 0;
1901    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1902 <  ConfigServerHide.hide_server_ips = NO;
1902 >  ConfigServerHide.hide_server_ips = 0;
1903  
1904 +  
1905 +  DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1906 +  ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1907    ConfigFileEntry.gline_min_cidr = 16;
1908    ConfigFileEntry.gline_min_cidr6 = 48;
1909 <  ConfigFileEntry.invisible_on_connect = YES;
1910 <  ConfigFileEntry.burst_away = NO;
1911 <  ConfigFileEntry.use_whois_actually = YES;
1912 <  ConfigFileEntry.tkline_expire_notices = YES;
1913 <  ConfigFileEntry.hide_spoof_ips = YES;
1914 <  ConfigFileEntry.ignore_bogus_ts = NO;
1915 <  ConfigFileEntry.disable_auth = NO;
1916 <  ConfigFileEntry.disable_remote = NO;
1909 >  ConfigFileEntry.invisible_on_connect = 1;
1910 >  ConfigFileEntry.burst_away = 0;
1911 >  ConfigFileEntry.use_whois_actually = 1;
1912 >  ConfigFileEntry.tkline_expire_notices = 1;
1913 >  ConfigFileEntry.hide_spoof_ips = 1;
1914 >  ConfigFileEntry.ignore_bogus_ts = 0;
1915 >  ConfigFileEntry.disable_auth = 0;
1916 >  ConfigFileEntry.disable_remote = 0;
1917    ConfigFileEntry.kill_chase_time_limit = 90;
1918 <  ConfigFileEntry.default_floodcount = 8; /* XXX */
1919 <  ConfigFileEntry.failed_oper_notice = YES;
1920 <  ConfigFileEntry.dots_in_ident = 0;      /* XXX */
1894 <  ConfigFileEntry.dot_in_ip6_addr = YES;
1918 >  ConfigFileEntry.default_floodcount = 8;
1919 >  ConfigFileEntry.failed_oper_notice = 1;
1920 >  ConfigFileEntry.dots_in_ident = 0;
1921    ConfigFileEntry.min_nonwildcard = 4;
1922    ConfigFileEntry.min_nonwildcard_simple = 3;
1923    ConfigFileEntry.max_accept = 20;
1924 <  ConfigFileEntry.anti_nick_flood = NO;   /* XXX */
1924 >  ConfigFileEntry.anti_nick_flood = 0;
1925    ConfigFileEntry.max_nick_time = 20;
1926    ConfigFileEntry.max_nick_changes = 5;
1927 <  ConfigFileEntry.anti_spam_exit_message_time = 0;  /* XXX */
1927 >  ConfigFileEntry.anti_spam_exit_message_time = 0;
1928    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1929 <  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;  /* XXX */
1930 <  ConfigFileEntry.kline_with_reason = YES;
1929 >  ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1930 >  ConfigFileEntry.kline_with_reason = 1;
1931    ConfigFileEntry.kline_reason = NULL;
1932 <  ConfigFileEntry.warn_no_nline = YES;
1933 <  ConfigFileEntry.stats_o_oper_only = NO; /* XXX */
1932 >  ConfigFileEntry.warn_no_nline = 1;
1933 >  ConfigFileEntry.stats_o_oper_only = 0;
1934    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1935    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1936 <  ConfigFileEntry.stats_P_oper_only = NO;
1936 >  ConfigFileEntry.stats_P_oper_only = 0;
1937    ConfigFileEntry.caller_id_wait = 60;
1938 <  ConfigFileEntry.opers_bypass_callerid = NO;
1938 >  ConfigFileEntry.opers_bypass_callerid = 0;
1939    ConfigFileEntry.pace_wait = 10;
1940    ConfigFileEntry.pace_wait_simple = 1;
1941 <  ConfigFileEntry.short_motd = NO;
1942 <  ConfigFileEntry.ping_cookie = NO;
1943 <  ConfigFileEntry.no_oper_flood = NO;     /* XXX */
1944 <  ConfigFileEntry.true_no_oper_flood = NO;  /* XXX */
1945 <  ConfigFileEntry.oper_pass_resv = YES;
1946 <  ConfigFileEntry.glines = NO;            /* XXX */
1947 <  ConfigFileEntry.gline_time = 12 * 3600; /* XXX */
1922 <  ConfigFileEntry.idletime = 0;
1941 >  ConfigFileEntry.short_motd = 0;
1942 >  ConfigFileEntry.ping_cookie = 0;
1943 >  ConfigFileEntry.no_oper_flood = 0;
1944 >  ConfigFileEntry.true_no_oper_flood = 0;
1945 >  ConfigFileEntry.oper_pass_resv = 1;
1946 >  ConfigFileEntry.glines = 0;
1947 >  ConfigFileEntry.gline_time = 12 * 3600;
1948    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1949    ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1950 <  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;  /* XXX */
1951 <  ConfigFileEntry.oper_umodes = UMODE_LOCOPS | UMODE_SERVNOTICE |
1952 <    UMODE_OPERWALL | UMODE_WALLOP;        /* XXX */
1953 <  DupString(ConfigFileEntry.servlink_path, SLPATH);
1929 < #ifdef HAVE_LIBCRYPTO
1930 <  /* jdc -- This is our default value for a cipher.  According to the
1931 <   *        CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
1932 <   *        under all circumstances if cryptlinks are enabled.  So,
1933 <   *        this will be our default.
1934 <   *
1935 <   *        NOTE: I apologise for the hard-coded value of "1" (BF/128).
1936 <   *              This should be moved into a find_cipher() routine.
1937 <   */
1938 <  ConfigFileEntry.default_cipher_preference = &CipherTable[1];
1939 < #endif
1940 <  ConfigFileEntry.use_egd = NO;
1950 >  ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1951 >  ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1952 >    UMODE_OPERWALL | UMODE_WALLOP;
1953 >  ConfigFileEntry.use_egd = 0;
1954    ConfigFileEntry.egdpool_path = NULL;
1942 #ifdef HAVE_LIBZ
1943  ConfigFileEntry.compression_level = 0;
1944 #endif
1955    ConfigFileEntry.throttle_time = 10;
1956   }
1957  
# Line 1954 | Line 1964 | set_default_conf(void)
1964   static void
1965   read_conf(FBFILE *file)
1966   {
1967 <  scount = lineno = 0;
1967 >  lineno = 0;
1968  
1969    set_default_conf(); /* Set default values prior to conf parsing */
1970 <  ypass = 1;
1970 >  conf_parser_ctx.pass = 1;
1971    yyparse();          /* pick up the classes first */
1972  
1973    fbrewind(file);
1974  
1975 <  ypass = 2;
1975 >  conf_parser_ctx.pass = 2;
1976    yyparse();          /* Load the values from the conf */
1977    validate_conf();    /* Check to make sure some values are still okay. */
1978                        /* Some global values are also loaded here. */
# Line 1978 | Line 1988 | validate_conf(void)
1988    if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1989      ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1990  
1981  if (ConfigFileEntry.servlink_path == NULL)
1982    DupString(ConfigFileEntry.servlink_path, SLPATH);
1983
1991    if (ServerInfo.network_name == NULL)
1992      DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1993  
1994    if (ServerInfo.network_desc == NULL)
1995      DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1996  
1997 +  if (ConfigFileEntry.service_name == NULL)
1998 +    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1999 +
2000    if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
2001        (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
2002      ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
2003 +
2004 +  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
2005   }
2006  
2007   /* lookup_confhost()
# Line 2008 | Line 2020 | lookup_confhost(struct ConfItem *conf)
2020    if (EmptyString(aconf->host) ||
2021        EmptyString(aconf->user))
2022    {
2023 <    ilog(L_ERROR, "Host/server name error: (%s) (%s)",
2023 >    ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)",
2024           aconf->host, conf->name);
2025      return;
2026    }
# Line 2028 | Line 2040 | lookup_confhost(struct ConfItem *conf)
2040    /* Get us ready for a bind() and don't bother doing dns lookup */
2041    hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
2042  
2043 <  if (irc_getaddrinfo(aconf->host, NULL, &hints, &res))
2043 >  if (getaddrinfo(aconf->host, NULL, &hints, &res))
2044    {
2045      conf_dns_lookup(aconf);
2046      return;
# Line 2039 | Line 2051 | lookup_confhost(struct ConfItem *conf)
2051    memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen);
2052    aconf->ipnum.ss_len = res->ai_addrlen;
2053    aconf->ipnum.ss.ss_family = res->ai_family;
2054 <  irc_freeaddrinfo(res);
2054 >  freeaddrinfo(res);
2055   }
2056  
2057   /* conf_connect_allowed()
# Line 2078 | Line 2090 | conf_connect_allowed(struct irc_ssaddr *
2090   static struct AccessItem *
2091   find_regexp_kline(const char *uhi[])
2092   {
2093 + #ifdef HAVE_LIBPCRE
2094    const dlink_node *ptr = NULL;
2095  
2096    DLINK_FOREACH(ptr, rkconf_items.head)
# Line 2092 | Line 2105 | find_regexp_kline(const char *uhi[])
2105           !ircd_pcre_exec(aptr->regexhost, uhi[2])))
2106        return aptr;
2107    }
2108 <
2108 > #endif
2109    return NULL;
2110   }
2111  
# Line 2266 | Line 2279 | expire_tklines(dlink_list *tklist)
2279            }
2280          }
2281  
2282 +        dlinkDelete(ptr, tklist);
2283          delete_one_address_conf(aconf->host, aconf);
2270        dlinkDelete(ptr, tklist);
2284        }
2285      }
2286      else if (conf->type == XLINE_TYPE ||
# Line 2321 | Line 2334 | expire_tklines(dlink_list *tklist)
2334          if (ConfigFileEntry.tkline_expire_notices)
2335            sendto_realops_flags(UMODE_ALL, L_ALL,
2336                                 "Temporary RESV for [%s] expired", cconf->name);
2337 <        dlinkDelete(ptr, tklist);
2325 <        free_dlink_node(ptr);
2326 <        delete_conf_item(conf);
2337 >        delete_channel_resv(cconf);
2338        }
2339      }
2340    }
# Line 2338 | Line 2349 | expire_tklines(dlink_list *tklist)
2349   static const struct oper_privs
2350   {
2351    const unsigned int oprivs;
2341  const unsigned int hidden;
2352    const unsigned char c;
2353   } flag_list[] = {
2354 <  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2355 <  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2356 <  { OPER_FLAG_DIE,         0,                       'D' },
2357 <  { OPER_FLAG_GLINE,       0,                       'G' },
2358 <  { OPER_FLAG_REHASH,      0,                       'H' },
2359 <  { OPER_FLAG_K,           0,                       'K' },
2360 <  { OPER_FLAG_OPERWALL,    0,                       'L' },
2361 <  { OPER_FLAG_N,           0,                       'N' },
2362 <  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2363 <  { OPER_FLAG_REMOTE,      0,                       'R' },
2364 <  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2365 <  { OPER_FLAG_UNKLINE,     0,                       'U' },
2366 <  { OPER_FLAG_X,           0,                       'X' },
2367 <  { 0, 0, '\0' }
2354 >  { OPER_FLAG_ADMIN,       'A' },
2355 >  { OPER_FLAG_REMOTEBAN,   'B' },
2356 >  { OPER_FLAG_DIE,         'D' },
2357 >  { OPER_FLAG_GLINE,       'G' },
2358 >  { OPER_FLAG_REHASH,      'H' },
2359 >  { OPER_FLAG_K,           'K' },
2360 >  { OPER_FLAG_OPERWALL,    'L' },
2361 >  { OPER_FLAG_N,           'N' },
2362 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2363 >  { OPER_FLAG_REMOTE,      'R' },
2364 >  { OPER_FLAG_OPER_SPY,    'S' },
2365 >  { OPER_FLAG_UNKLINE,     'U' },
2366 >  { OPER_FLAG_X,           'X' },
2367 >  { 0, '\0' }
2368   };
2369  
2370   char *
# Line 2366 | Line 2376 | oper_privs_as_string(const unsigned int
2376  
2377    for (; flag_list[i].oprivs; ++i)
2378    {
2379 <    if ((port & flag_list[i].oprivs) &&
2370 <        (port & flag_list[i].hidden) == 0)
2379 >    if (port & flag_list[i].oprivs)
2380        *privs_ptr++ = flag_list[i].c;
2381      else
2382        *privs_ptr++ = ToLowerTab[flag_list[i].c];
# Line 2392 | Line 2401 | get_oper_name(const struct Client *clien
2401    struct AccessItem *aconf;
2402  
2403    /* +5 for !,@,{,} and null */
2404 <  static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5];
2404 >  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2405  
2406    if (MyConnect(client_p))
2407    {
# Line 2403 | Line 2412 | get_oper_name(const struct Client *clien
2412  
2413        if (IsConfOperator(aconf))
2414        {
2415 <        ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2416 <                   client_p->username, client_p->host,
2408 <                   conf->name);
2415 >        snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2416 >                 client_p->username, client_p->host, conf->name);
2417          return buffer;
2418        }
2419      }
# Line 2416 | Line 2424 | get_oper_name(const struct Client *clien
2424      assert(0); /* Oper without oper conf! */
2425    }
2426  
2427 <  ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name,
2428 <             client_p->username, client_p->host, client_p->servptr->name);
2427 >  snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name,
2428 >           client_p->username, client_p->host, client_p->servptr->name);
2429    return buffer;
2430   }
2431  
# Line 2434 | Line 2442 | read_conf_files(int cold)
2442    char chanmodes[32];
2443    char chanlimit[32];
2444  
2445 +  conf_parser_ctx.boot = cold;
2446    filename = get_conf_name(CONF_TYPE);
2447  
2448    /* We need to know the initial filename for the yyerror() to report
# Line 2444 | Line 2453 | read_conf_files(int cold)
2453    */
2454    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2455  
2456 <  if ((conf_fbfile_in = fbopen(filename, "r")) == NULL)
2456 >  if ((conf_parser_ctx.conf_file = fbopen(filename, "r")) == NULL)
2457    {
2458      if (cold)
2459      {
2460 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2460 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2461             filename, strerror(errno));
2462        exit(-1);
2463      }
# Line 2464 | Line 2473 | read_conf_files(int cold)
2473    if (!cold)
2474      clear_out_old_conf();
2475  
2476 <  read_conf(conf_fbfile_in);
2477 <  fbclose(conf_fbfile_in);
2476 >  read_conf(conf_parser_ctx.conf_file);
2477 >  fbclose(conf_parser_ctx.conf_file);
2478  
2479    add_isupport("NETWORK", ServerInfo.network_name, -1);
2480 <  ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "",
2481 <             ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2480 >  snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d",
2481 >           ConfigChannel.use_except ? "e" : "",
2482 >           ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2483    add_isupport("MAXLIST", chanmodes, -1);
2484    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
2485 +
2486    if (ConfigChannel.disable_local_channels)
2487      add_isupport("CHANTYPES", "#", -1);
2488    else
2489      add_isupport("CHANTYPES", "#&", -1);
2490 <  ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&",
2491 <             ConfigChannel.max_chans_per_user);
2490 >
2491 >  snprintf(chanlimit, sizeof(chanlimit), "%s:%d",
2492 >           ConfigChannel.disable_local_channels ? "#" : "#&",
2493 >           ConfigChannel.max_chans_per_user);
2494    add_isupport("CHANLIMIT", chanlimit, -1);
2495 <  ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "",
2496 <             ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst");
2495 >  snprintf(chanmodes, sizeof(chanmodes), "%s%s%s",
2496 >           ConfigChannel.use_except ? "e" : "",
2497 >           ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS");
2498    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2499 +
2500    if (ConfigChannel.use_except)
2501      add_isupport("EXCEPTS", "e", -1);
2502    if (ConfigChannel.use_invex)
# Line 2494 | Line 2509 | read_conf_files(int cold)
2509     */
2510    rebuild_isupport_message_line();
2511  
2512 <  parse_conf_file(KLINE_TYPE, cold);
2512 > #ifdef HAVE_LIBPCRE
2513    parse_conf_file(RKLINE_TYPE, cold);
2514 +  parse_conf_file(RXLINE_TYPE, cold);
2515 + #endif
2516 +  parse_conf_file(KLINE_TYPE, cold);
2517    parse_conf_file(DLINE_TYPE, cold);
2518    parse_conf_file(XLINE_TYPE, cold);
2501  parse_conf_file(RXLINE_TYPE, cold);
2519    parse_conf_file(NRESV_TYPE, cold);
2520    parse_conf_file(CRESV_TYPE, cold);
2521   }
# Line 2518 | Line 2535 | parse_conf_file(int type, int cold)
2535    if ((file = fbopen(filename, "r")) == NULL)
2536    {
2537      if (cold)
2538 <      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2538 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2539             filename, strerror(errno));
2540      else
2541        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 2549 | Line 2566 | clear_out_old_conf(void)
2566    dlink_list *free_items [] = {
2567      &server_items,   &oconf_items,    &hub_items, &leaf_items,
2568       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
2569 <     &nresv_items, &cluster_items,  &gdeny_items, NULL
2569 >     &nresv_items, &cluster_items,  &gdeny_items, &service_items, NULL
2570    };
2571  
2572    dlink_list ** iterator = free_items; /* C is dumb */
# Line 2566 | Line 2583 | clear_out_old_conf(void)
2583        /* XXX This is less than pretty */
2584        if (conf->type == SERVER_TYPE)
2585        {
2586 <        aconf = (struct AccessItem *)map_to_conf(conf);
2586 >        aconf = map_to_conf(conf);
2587 >
2588          if (aconf->clients != 0)
2589          {
2590            SetConfIllegal(aconf);
# Line 2579 | Line 2597 | clear_out_old_conf(void)
2597        }
2598        else if (conf->type == OPER_TYPE)
2599        {
2600 <        aconf = (struct AccessItem *)map_to_conf(conf);
2600 >        aconf = map_to_conf(conf);
2601 >
2602          if (aconf->clients != 0)
2603          {
2604            SetConfIllegal(aconf);
# Line 2592 | Line 2611 | clear_out_old_conf(void)
2611        }
2612        else if (conf->type == CLIENT_TYPE)
2613        {
2614 <        aconf = (struct AccessItem *)map_to_conf(conf);
2614 >        aconf = map_to_conf(conf);
2615 >
2616          if (aconf->clients != 0)
2617          {
2618            SetConfIllegal(aconf);
# Line 2617 | Line 2637 | clear_out_old_conf(void)
2637        {
2638          if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2639          {
2640 <          match_item = (struct MatchItem *)map_to_conf(conf);
2641 <          if ((match_item->ref_count <= 0))
2640 >          match_item = map_to_conf(conf);
2641 >          if (match_item->ref_count <= 0)
2642              delete_conf_item(conf);
2643            else
2644            {
# Line 2632 | Line 2652 | clear_out_old_conf(void)
2652      }
2653    }
2654  
2655 <  /* don't delete the class table, rather mark all entries
2655 >  /*
2656 >   * don't delete the class table, rather mark all entries
2657     * for deletion. The table is cleaned up by check_class. - avalon
2658     */
2659    DLINK_FOREACH(ptr, class_items.head)
2660    {
2661 <    conf = ptr->data;
2662 <    cltmp = (struct ClassItem *)map_to_conf(conf);
2661 >    cltmp = map_to_conf(ptr->data);
2662 >
2663      if (ptr != class_items.tail)  /* never mark the "default" class */
2664 <      MaxTotal(cltmp) = -1;
2664 >      cltmp->active = 0;
2665    }
2666  
2667    clear_out_address_conf();
2668  
2669    /* clean out module paths */
2649 #ifndef STATIC_MODULES
2670    mod_clear_paths();
2651 #endif
2671  
2672    /* clean out ServerInfo */
2673    MyFree(ServerInfo.description);
# Line 2690 | Line 2709 | clear_out_old_conf(void)
2709     */
2710  
2711    /* clean out general */
2712 <  MyFree(ConfigFileEntry.servlink_path);
2713 <  ConfigFileEntry.servlink_path = NULL;
2714 < #ifdef HAVE_LIBCRYPTO
2696 <  ConfigFileEntry.default_cipher_preference = NULL;
2697 < #endif /* HAVE_LIBCRYPTO */
2712 >  MyFree(ConfigFileEntry.service_name);
2713 >  ConfigFileEntry.service_name = NULL;
2714 >
2715    delete_isupport("INVEX");
2716    delete_isupport("EXCEPTS");
2717   }
# Line 2889 | Line 2906 | find_class(const char *classname)
2906   {
2907    struct ConfItem *conf;
2908  
2909 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2910 <    return(conf);
2909 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2910 >    return conf;
2911  
2912    return class_default;
2913   }
# Line 2904 | Line 2921 | find_class(const char *classname)
2921   void
2922   check_class(void)
2923   {
2924 <  dlink_node *ptr;
2908 <  dlink_node *next_ptr;
2909 <  struct ConfItem *conf;
2910 <  struct ClassItem *aclass;
2924 >  dlink_node *ptr = NULL, *next_ptr = NULL;
2925  
2926    DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head)
2927    {
2928 <    conf = ptr->data;
2915 <    aclass = (struct ClassItem *)map_to_conf(conf);
2928 >    struct ClassItem *aclass = map_to_conf(ptr->data);
2929  
2930 <    if (MaxTotal(aclass) < 0)
2930 >    if (!aclass->active && !CurrUserCount(aclass))
2931      {
2932        destroy_cidr_class(aclass);
2933 <      if (CurrUserCount(aclass) > 0)
2921 <        dlinkDelete(&conf->node, &class_items);
2922 <      else
2923 <        delete_conf_item(conf);
2933 >      delete_conf_item(ptr->data);
2934      }
2935    }
2936   }
# Line 2937 | Line 2947 | init_class(void)
2947    struct ClassItem *aclass;
2948  
2949    class_default = make_conf_item(CLASS_TYPE);
2950 <  aclass = (struct ClassItem *)map_to_conf(class_default);
2950 >
2951 >  aclass = map_to_conf(class_default);
2952 >  aclass->active = 1;
2953    DupString(class_default->name, "default");
2954    ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2955    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
# Line 2953 | Line 2965 | init_class(void)
2965   * output       - sendq for this client as found from its class
2966   * side effects - NONE
2967   */
2968 < unsigned long
2968 > unsigned int
2969   get_sendq(struct Client *client_p)
2970   {
2971 <  unsigned long sendq = DEFAULT_SENDQ;
2971 >  unsigned int sendq = DEFAULT_SENDQ;
2972    dlink_node *ptr;
2973    struct ConfItem *conf;
2974    struct ConfItem *class_conf;
# Line 2996 | Line 3008 | get_sendq(struct Client *client_p)
3008   void
3009   conf_add_class_to_conf(struct ConfItem *conf, const char *class_name)
3010   {
3011 <  struct AccessItem *aconf;
3012 <  struct ClassItem *aclass;
3001 <
3002 <  aconf = (struct AccessItem *)map_to_conf(conf);
3011 >  struct AccessItem *aconf = map_to_conf(conf);
3012 >  struct ClassItem *class = NULL;
3013  
3014    if (class_name == NULL)
3015    {
3016      aconf->class_ptr = class_default;
3017 +
3018      if (conf->type == CLIENT_TYPE)
3019        sendto_realops_flags(UMODE_ALL, L_ALL,
3020                             "Warning *** Defaulting to default class for %s@%s",
# Line 3014 | Line 3025 | conf_add_class_to_conf(struct ConfItem *
3025                             conf->name);
3026    }
3027    else
3017  {
3028      aconf->class_ptr = find_class(class_name);
3019  }
3029  
3030 <  if (aconf->class_ptr == NULL)
3030 >  if (aconf->class_ptr)
3031 >    class = map_to_conf(aconf->class_ptr);
3032 >
3033 >  if (aconf->class_ptr == NULL || !class->active)
3034    {
3035      if (conf->type == CLIENT_TYPE)
3036        sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 3030 | Line 3042 | conf_add_class_to_conf(struct ConfItem *
3042                             conf->name);
3043      aconf->class_ptr = class_default;
3044    }
3033  else
3034  {
3035    aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
3036    if (MaxTotal(aclass) < 0)
3037    {
3038      aconf->class_ptr = class_default;
3039    }
3040  }
3045   }
3046  
3043 #define MAXCONFLINKS 150
3044
3047   /* conf_add_server()
3048   *
3049   * inputs       - pointer to config item
# Line 3050 | Line 3052 | conf_add_class_to_conf(struct ConfItem *
3052   * side effects - Add a connect block
3053   */
3054   int
3055 < conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name)
3055 > conf_add_server(struct ConfItem *conf, const char *class_name)
3056   {
3057    struct AccessItem *aconf;
3058 <  char *orig_host;
3058 >  struct split_nuh_item nuh;
3059 >  char conf_user[USERLEN + 1];
3060 >  char conf_host[HOSTLEN + 1];
3061  
3062    aconf = map_to_conf(conf);
3063  
3064    conf_add_class_to_conf(conf, class_name);
3065  
3066 <  if (lcount > MAXCONFLINKS || !aconf->host || !conf->name)
3066 >  if (!aconf->host || !conf->name)
3067    {
3068      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
3069 <    ilog(L_WARN, "Bad connect block");
3069 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
3070      return -1;
3071    }
3072  
3073 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
3073 >  if (EmptyString(aconf->passwd))
3074    {
3075      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
3076                           conf->name);
3077 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
3077 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
3078      return -1;
3079    }
3080  
3081 <  orig_host = aconf->host;
3082 <  split_nuh(orig_host, NULL, &aconf->user, &aconf->host);
3083 <  MyFree(orig_host);
3081 >  nuh.nuhmask  = aconf->host;
3082 >  nuh.nickptr  = NULL;
3083 >  nuh.userptr  = conf_user;
3084 >  nuh.hostptr  = conf_host;
3085 >
3086 >  nuh.nicksize = 0;
3087 >  nuh.usersize = sizeof(conf_user);
3088 >  nuh.hostsize = sizeof(conf_host);
3089 >
3090 >  split_nuh(&nuh);
3091 >
3092 >  MyFree(aconf->host);
3093 >  aconf->host = NULL;
3094 >
3095 >  DupString(aconf->user, conf_user); /* somehow username checking for servers
3096 >                                 got lost in H6/7, will have to be re-added */
3097 >  DupString(aconf->host, conf_host);
3098 >
3099    lookup_confhost(conf);
3100  
3101    return 0;
3102   }
3103  
3085 /* conf_add_d_conf()
3086 *
3087 * inputs       - pointer to config item
3088 * output       - NONE
3089 * side effects - Add a d/D line
3090 */
3091 void
3092 conf_add_d_conf(struct AccessItem *aconf)
3093 {
3094  if (aconf->host == NULL)
3095    return;
3096
3097  aconf->user = NULL;
3098
3099  /* XXX - Should 'd' ever be in the old conf? For new conf we don't
3100   *       need this anyway, so I will disable it for now... -A1kmm
3101   */
3102  if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST)
3103  {
3104    ilog(L_WARN, "Invalid Dline %s ignored", aconf->host);
3105    free_access_item(aconf);
3106  }
3107  else
3108  {
3109    /* XXX ensure user is NULL */
3110    MyFree(aconf->user);
3111    aconf->user = NULL;
3112    add_conf_by_address(CONF_DLINE, aconf);
3113  }
3114 }
3115
3104   /* yyerror()
3105   *
3106   * inputs       - message from parser
# Line 3124 | Line 3112 | yyerror(const char *msg)
3112   {
3113    char newlinebuf[IRCD_BUFSIZE];
3114  
3115 <  if (ypass != 1)
3115 >  if (conf_parser_ctx.pass != 1)
3116      return;
3117  
3118    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
3119    sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
3120                         conffilebuf, lineno + 1, msg, newlinebuf);
3121 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
3121 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
3122         conffilebuf, lineno + 1, msg, newlinebuf);
3123   }
3124  
# Line 3160 | Line 3148 | conf_yy_fatal_error(const char *msg)
3148   * Originally written by Dianora (Diane, db@db.net)
3149   */
3150   time_t
3151 < valid_tkline(char *p, int minutes)
3151 > valid_tkline(const char *p, int minutes)
3152   {
3153    time_t result = 0;
3154  
3155 <  while (*p)
3155 >  for (; *p; ++p)
3156    {
3157 <    if (IsDigit(*p))
3170 <    {
3171 <      result *= 10;
3172 <      result += ((*p) & 0xF);
3173 <      p++;
3174 <    }
3175 <    else
3157 >    if (!IsDigit(*p))
3158        return 0;
3159 +
3160 +    result *= 10;
3161 +    result += ((*p) & 0xF);
3162    }
3163  
3164 <  /* in the degenerate case where oper does a /quote kline 0 user@host :reason
3164 >  /*
3165 >   * In the degenerate case where oper does a /quote kline 0 user@host :reason
3166     * i.e. they specifically use 0, I am going to return 1 instead
3167     * as a return value of non-zero is used to flag it as a temporary kline
3168     */
3183
3169    if (result == 0)
3170      result = 1;
3171  
# Line 3281 | Line 3266 | valid_wild_card(struct Client *source_p,
3266   *                if target_server is NULL and an "ON" is found error
3267   *                is reported.
3268   *                if reason pointer is NULL ignore pointer,
3269 < *                this allows usee of parse_a_line in unkline etc.
3269 > *                this allows use of parse_a_line in unkline etc.
3270   *
3271   * - Dianora
3272   */
# Line 3351 | Line 3336 | parse_aline(const char *cmd, struct Clie
3336          return -1;
3337        }
3338  
3339 <      if (!IsOperRemoteBan(source_p))
3339 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
3340        {
3341          sendto_one(source_p, form_str(ERR_NOPRIVS),
3342                     me.name, source_p->name, "remoteban");
# Line 3388 | Line 3373 | parse_aline(const char *cmd, struct Clie
3373        return -1;
3374      }
3375  
3376 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3376 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3377        return -1;
3378    }
3379    else
3380 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3380 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3381        return -1;
3382  
3383    if (reason != NULL)
3384    {
3385 <    if (parc != 0)
3385 >    if (parc != 0 && !EmptyString(*parv))
3386      {
3387        *reason = *parv;
3388 <      if (!valid_comment(source_p, *reason, YES))
3388 >      if (!valid_comment(source_p, *reason, 1))
3389          return -1;
3390      }
3391      else
# Line 3436 | Line 3421 | find_user_host(struct Client *source_p,
3421    {
3422      /* Explicit user@host mask given */
3423  
3424 <    if(hostp != NULL)                            /* I'm a little user@host */
3424 >    if (hostp != NULL)                            /* I'm a little user@host */
3425      {
3426        *(hostp++) = '\0';                       /* short and squat */
3427        if (*user_host_or_nick)
# Line 3567 | Line 3552 | match_conf_password(const char *password
3552   */
3553   void
3554   cluster_a_line(struct Client *source_p, const char *command,
3555 <               int capab, int cluster_type, const char *pattern, ...)
3555 >               int capab, int cluster_type, const char *pattern, ...)
3556   {
3557    va_list args;
3558    char buffer[IRCD_BUFSIZE];
3559 <  struct ConfItem *conf;
3575 <  dlink_node *ptr;
3559 >  const dlink_node *ptr = NULL;
3560  
3561    va_start(args, pattern);
3562    vsnprintf(buffer, sizeof(buffer), pattern, args);
# Line 3580 | Line 3564 | cluster_a_line(struct Client *source_p,
3564  
3565    DLINK_FOREACH(ptr, cluster_items.head)
3566    {
3567 <    conf = ptr->data;
3567 >    const struct ConfItem *conf = ptr->data;
3568  
3569      if (conf->flags & cluster_type)
3586    {
3570        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
3571                           "%s %s %s", command, conf->name, buffer);
3589    }
3572    }
3573   }
3574  
# Line 3618 | Line 3600 | cluster_a_line(struct Client *source_p,
3600   * @                            *       *       *
3601   * !                            *       *       *
3602   */
3621
3603   void
3604 < split_nuh(char *mask, char **nick, char **user, char **host)
3604 > split_nuh(struct split_nuh_item *const iptr)
3605   {
3606    char *p = NULL, *q = NULL;
3607  
3608 <  if ((p = strchr(mask, '!')) != NULL)
3608 >  if (iptr->nickptr)
3609 >    strlcpy(iptr->nickptr, "*", iptr->nicksize);
3610 >  if (iptr->userptr)
3611 >    strlcpy(iptr->userptr, "*", iptr->usersize);
3612 >  if (iptr->hostptr)
3613 >    strlcpy(iptr->hostptr, "*", iptr->hostsize);
3614 >
3615 >  if ((p = strchr(iptr->nuhmask, '!')))
3616    {
3617      *p = '\0';
3630    if (nick != NULL)
3631    {
3632      if (*mask != '\0')
3633        *nick = xstrldup(mask, NICKLEN);
3634      else
3635        DupString(*nick, "*");
3636    }
3618  
3619 <    if ((q = strchr(++p, '@')) != NULL)
3620 <    {
3621 <      *q = '\0';
3619 >    if (iptr->nickptr && *iptr->nuhmask != '\0')
3620 >      strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3621 >
3622 >    if ((q = strchr(++p, '@'))) {
3623 >      *q++ = '\0';
3624  
3625        if (*p != '\0')
3626 <        *user = xstrldup(p, USERLEN+1);
3644 <      else
3645 <        DupString(*user, "*");
3626 >        strlcpy(iptr->userptr, p, iptr->usersize);
3627  
3628 <      if (*++q != '\0')
3629 <        *host = xstrldup(q, HOSTLEN+1);
3649 <      else
3650 <        DupString(*host, "*");
3628 >      if (*q != '\0')
3629 >        strlcpy(iptr->hostptr, q, iptr->hostsize);
3630      }
3631      else
3632      {
3633        if (*p != '\0')
3634 <        *user = xstrldup(p, USERLEN+1);
3656 <      else
3657 <        DupString(*user, "*");
3658 <
3659 <      DupString(*host, "*");
3634 >        strlcpy(iptr->userptr, p, iptr->usersize);
3635      }
3636    }
3637 <  else  /* No ! found so lets look for a user@host */
3637 >  else
3638    {
3639 <    if ((p = strchr(mask, '@')) != NULL)        /* if found a @ */
3639 >    /* No ! found so lets look for a user@host */
3640 >    if ((p = strchr(iptr->nuhmask, '@')))
3641      {
3642 <      if (nick != NULL)
3643 <        DupString(*nick, "*");
3668 <      *p = '\0';
3642 >      /* if found a @ */
3643 >      *p++ = '\0';
3644  
3645 <      if (*mask != '\0')
3646 <        *user = xstrldup(mask, USERLEN+1);
3672 <      else
3673 <        DupString(*user, "*");
3645 >      if (*iptr->nuhmask != '\0')
3646 >        strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
3647  
3648 <      if (*++p != '\0')
3649 <        *host = xstrldup(p, HOSTLEN+1);
3677 <      else
3678 <        DupString(*host, "*");
3648 >      if (*p != '\0')
3649 >        strlcpy(iptr->hostptr, p, iptr->hostsize);
3650      }
3651 <    else                                        /* no @ found */
3651 >    else
3652      {
3653 <      if (nick != NULL)
3654 <      {
3655 <        if (strpbrk(mask, ".:"))
3685 <        {
3686 <          DupString(*nick, "*");
3687 <          *host = xstrldup(mask, HOSTLEN+1);
3688 <        }
3689 <        else
3690 <        {
3691 <          *nick = xstrldup(mask, NICKLEN);
3692 <          DupString(*host, "*");
3693 <        }
3694 <
3695 <        DupString(*user, "*");
3696 <      }
3653 >      /* no @ found */
3654 >      if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
3655 >        strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
3656        else
3657 <      {
3699 <        DupString(*user, "*");
3700 <        *host = xstrldup(mask, HOSTLEN+1);
3701 <      }
3657 >        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3658      }
3659    }
3660   }
# Line 3725 | Line 3681 | flags_to_ascii(unsigned int flags, const
3681    {
3682      if (flags & mask)
3683        *p++ = bit_table[i];
3684 <    else if(lowerit)
3684 >    else if (lowerit)
3685        *p++ = ToLower(bit_table[i]);
3686    }
3687    *p = '\0';
# Line 3932 | Line 3888 | rebuild_cidr_class(struct ConfItem *conf
3888   static void
3889   destroy_cidr_list(dlink_list *list)
3890   {
3891 <  dlink_node *ptr = NULL;
3936 <  dlink_node *next_ptr = NULL;
3937 <  struct CidrItem *cidr;
3891 >  dlink_node *ptr = NULL, *next_ptr = NULL;
3892  
3893    DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
3894    {
3941    cidr = ptr->data;
3895      dlinkDelete(ptr, list);
3896 <    MyFree(cidr);
3896 >    MyFree(ptr->data);
3897    }
3898   }
3899  

Diff Legend

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