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-8/src/s_conf.c (file contents), Revision 1176 by michael, Sun Aug 14 11:24:24 2011 UTC vs.
ircd-hybrid/trunk/src/conf.c (file contents), Revision 1623 by michael, Thu Nov 1 13:24:43 2012 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_conf.c: Configuration file functions.
3 > *  conf.c: Configuration file functions.
4   *
5   *  Copyright (C) 2002 by the past and present ircd coders, and others.
6   *
# Line 26 | Line 26
26   #include "list.h"
27   #include "ircd_defs.h"
28   #include "balloc.h"
29 < #include "s_conf.h"
29 > #include "conf.h"
30   #include "s_serv.h"
31   #include "resv.h"
32   #include "channel.h"
33   #include "client.h"
34 #include "common.h"
34   #include "event.h"
36 #include "hash.h"
35   #include "hook.h"
36   #include "irc_string.h"
39 #include "sprintf_irc.h"
37   #include "s_bsd.h"
38   #include "ircd.h"
39   #include "listener.h"
# Line 44 | Line 41
41   #include "modules.h"
42   #include "numeric.h"
43   #include "fdlist.h"
44 < #include "s_log.h"
44 > #include "log.h"
45   #include "send.h"
46   #include "s_gline.h"
50 #include "fileio.h"
47   #include "memory.h"
48   #include "irc_res.h"
49   #include "userhost.h"
50   #include "s_user.h"
51   #include "channel_mode.h"
52 + #include "parse.h"
53 + #include "s_misc.h"
54 + #include "conf_db.h"
55  
56   struct Callback *client_check_cb = NULL;
57   struct config_server_hide ConfigServerHide;
# Line 61 | Line 60 | struct config_server_hide ConfigServerHi
60   dlink_list service_items = { NULL, NULL, 0 };
61   dlink_list server_items  = { NULL, NULL, 0 };
62   dlink_list cluster_items = { NULL, NULL, 0 };
64 dlink_list hub_items     = { NULL, NULL, 0 };
65 dlink_list leaf_items    = { NULL, NULL, 0 };
63   dlink_list oconf_items   = { NULL, NULL, 0 };
64   dlink_list uconf_items   = { NULL, NULL, 0 };
65   dlink_list xconf_items   = { NULL, NULL, 0 };
# Line 70 | Line 67 | dlink_list rxconf_items  = { NULL, NULL,
67   dlink_list rkconf_items  = { NULL, NULL, 0 };
68   dlink_list nresv_items   = { NULL, NULL, 0 };
69   dlink_list class_items   = { NULL, NULL, 0 };
73 dlink_list gdeny_items   = { NULL, NULL, 0 };
70  
75 dlink_list temporary_klines  = { NULL, NULL, 0 };
76 dlink_list temporary_dlines  = { NULL, NULL, 0 };
77 dlink_list temporary_xlines  = { NULL, NULL, 0 };
78 dlink_list temporary_rklines = { NULL, NULL, 0 };
79 dlink_list temporary_glines  = { NULL, NULL, 0 };
80 dlink_list temporary_rxlines = { NULL, NULL, 0 };
71   dlink_list temporary_resv = { NULL, NULL, 0 };
72  
73   extern unsigned int lineno;
74   extern char linebuf[];
75   extern char conffilebuf[IRCD_BUFSIZE];
86 extern char yytext[];
76   extern int yyparse(); /* defined in y.tab.c */
77  
78   struct conf_parser_context conf_parser_ctx = { 0, 0, NULL };
79  
80   /* internally defined functions */
81 < static void lookup_confhost(struct ConfItem *);
93 < static void set_default_conf(void);
94 < static void validate_conf(void);
95 < static void read_conf(FBFILE *);
81 > static void read_conf(FILE *);
82   static void clear_out_old_conf(void);
83   static void flush_deleted_I_P(void);
84   static void expire_tklines(dlink_list *);
# Line 101 | Line 87 | static int hash_ip(struct irc_ssaddr *);
87   static int verify_access(struct Client *, const char *);
88   static int attach_iline(struct Client *, struct ConfItem *);
89   static struct ip_entry *find_or_add_ip(struct irc_ssaddr *);
104 static void parse_conf_file(int, int);
90   static dlink_list *map_to_list(ConfType);
91   static struct AccessItem *find_regexp_kline(const char *[]);
92   static int find_user_host(struct Client *, char *, char *, char *, unsigned int);
# Line 174 | Line 159 | conf_dns_callback(void *vptr, const stru
159    aconf->dns_pending = 0;
160  
161    if (addr != NULL)
162 <    memcpy(&aconf->ipnum, addr, sizeof(aconf->ipnum));
162 >    memcpy(&aconf->addr, addr, sizeof(aconf->addr));
163    else
164      aconf->dns_failed = 1;
165   }
# Line 262 | Line 247 | make_conf_item(ConfType type)
247      aconf->status = status;
248      break;
249  
265  case LEAF_TYPE:
266    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
267                                       sizeof(struct MatchItem));
268    dlinkAdd(conf, &conf->node, &leaf_items);
269    break;
270
271  case HUB_TYPE:
272    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
273                                       sizeof(struct MatchItem));
274    dlinkAdd(conf, &conf->node, &hub_items);
275    break;
276
250    case ULINE_TYPE:
251      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
252                                         sizeof(struct MatchItem));
253      dlinkAdd(conf, &conf->node, &uconf_items);
254      break;
255  
283  case GDENY_TYPE:
284    conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
285                                       sizeof(struct AccessItem));
286    dlinkAdd(conf, &conf->node, &gdeny_items);
287    break;
288
256    case XLINE_TYPE:
257      conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) +
258                                         sizeof(struct MatchItem));
# Line 335 | Line 302 | make_conf_item(ConfType type)
302  
303      aclass = map_to_conf(conf);
304      aclass->active = 1;
305 <    ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY;
306 <    PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
307 <    MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
308 <    MaxSendq(aclass) = DEFAULT_SENDQ;
305 >    aclass->con_freq = DEFAULT_CONNECTFREQUENCY;
306 >    aclass->ping_freq = DEFAULT_PINGFREQUENCY;
307 >    aclass->max_total = MAXIMUM_LINKS_DEFAULT;
308 >    aclass->max_sendq = DEFAULT_SENDQ;
309 >    aclass->max_recvq = DEFAULT_RECVQ;
310  
311      break;
312  
# Line 356 | Line 324 | make_conf_item(ConfType type)
324   void
325   delete_conf_item(struct ConfItem *conf)
326   {
327 <  dlink_node *m = NULL;
327 >  dlink_node *m = NULL, *m_next = NULL;
328    struct MatchItem *match_item;
329    struct AccessItem *aconf;
330    ConfType type = conf->type;
# Line 386 | Line 354 | delete_conf_item(struct ConfItem *conf)
354      MyFree(aconf->passwd);
355      MyFree(aconf->spasswd);
356      MyFree(aconf->reason);
389    MyFree(aconf->oper_reason);
357      MyFree(aconf->user);
358      MyFree(aconf->host);
359   #ifdef HAVE_LIBCRYPTO
360 +    MyFree(aconf->cipher_list);
361 +
362      if (aconf->rsa_public_key)
363        RSA_free(aconf->rsa_public_key);
364      MyFree(aconf->rsa_public_key_file);
# Line 415 | Line 384 | delete_conf_item(struct ConfItem *conf)
384  
385      case SERVER_TYPE:
386        aconf = map_to_conf(conf);
387 +
388 +      DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head)
389 +      {
390 +        MyFree(m->data);
391 +        free_dlink_node(m);
392 +      }
393 +
394 +      DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head)
395 +      {
396 +        MyFree(m->data);
397 +        free_dlink_node(m);  
398 +      }
399 +
400        if (!IsConfIllegal(aconf))
401          dlinkDelete(&conf->node, &server_items);
402        MyFree(conf);
# Line 425 | Line 407 | delete_conf_item(struct ConfItem *conf)
407      }
408      break;
409  
428  case HUB_TYPE:
429    match_item = map_to_conf(conf);
430    MyFree(match_item->user);
431    MyFree(match_item->host);
432    MyFree(match_item->reason);
433    MyFree(match_item->oper_reason);
434    /* If marked illegal, its already been pulled off of the hub_items list */
435    if (!match_item->illegal)
436      dlinkDelete(&conf->node, &hub_items);
437    MyFree(conf);
438    break;
439
440  case LEAF_TYPE:
441    match_item = map_to_conf(conf);
442    MyFree(match_item->user);
443    MyFree(match_item->host);
444    MyFree(match_item->reason);
445    MyFree(match_item->oper_reason);
446    /* If marked illegal, its already been pulled off of the leaf_items list */
447    if (!match_item->illegal)
448      dlinkDelete(&conf->node, &leaf_items);
449    MyFree(conf);
450    break;
451
410    case ULINE_TYPE:
411      match_item = map_to_conf(conf);
412      MyFree(match_item->user);
413      MyFree(match_item->host);
414      MyFree(match_item->reason);
457    MyFree(match_item->oper_reason);
415      dlinkDelete(&conf->node, &uconf_items);
416      MyFree(conf);
417      break;
# Line 464 | Line 421 | delete_conf_item(struct ConfItem *conf)
421      MyFree(match_item->user);
422      MyFree(match_item->host);
423      MyFree(match_item->reason);
467    MyFree(match_item->oper_reason);
424      dlinkDelete(&conf->node, &xconf_items);
425      MyFree(conf);
426      break;
# Line 476 | Line 432 | delete_conf_item(struct ConfItem *conf)
432      MyFree(aconf->user);
433      MyFree(aconf->host);
434      MyFree(aconf->reason);
479    MyFree(aconf->oper_reason);
435      dlinkDelete(&conf->node, &rkconf_items);
436      MyFree(conf);
437      break;
# Line 487 | Line 442 | delete_conf_item(struct ConfItem *conf)
442      MyFree(match_item->user);
443      MyFree(match_item->host);
444      MyFree(match_item->reason);
490    MyFree(match_item->oper_reason);
445      dlinkDelete(&conf->node, &rxconf_items);
446      MyFree(conf);
447      break;
# Line 497 | Line 451 | delete_conf_item(struct ConfItem *conf)
451      MyFree(match_item->user);
452      MyFree(match_item->host);
453      MyFree(match_item->reason);
500    MyFree(match_item->oper_reason);
454      dlinkDelete(&conf->node, &nresv_items);
455  
456      if (conf->flags & CONF_FLAGS_TEMPORARY)
# Line 507 | Line 460 | delete_conf_item(struct ConfItem *conf)
460      MyFree(conf);
461      break;
462  
510  case GDENY_TYPE:
511    aconf = map_to_conf(conf);
512    MyFree(aconf->user);
513    MyFree(aconf->host);
514    dlinkDelete(&conf->node, &gdeny_items);
515    MyFree(conf);
516    break;
517
463    case CLUSTER_TYPE:
464      dlinkDelete(&conf->node, &cluster_items);
465      MyFree(conf);
# Line 571 | Line 516 | static const unsigned int shared_bit_tab
516   * side effects -
517   */
518   void
519 < report_confitem_types(struct Client *source_p, ConfType type, int temp)
519 > report_confitem_types(struct Client *source_p, ConfType type)
520   {
521 <  dlink_node *ptr = NULL;
521 >  dlink_node *ptr = NULL, *dptr = NULL;
522    struct ConfItem *conf = NULL;
523    struct AccessItem *aconf = NULL;
524    struct MatchItem *matchitem = NULL;
525    struct ClassItem *classitem = NULL;
526    char buf[12];
527    char *p = NULL;
583  const char *pfx = NULL;
528  
529    switch (type)
530    {
587  case GDENY_TYPE:
588    DLINK_FOREACH(ptr, gdeny_items.head)
589    {
590      conf = ptr->data;
591      aconf = map_to_conf(conf);
592
593      p = buf;
594
595      if (aconf->flags & GDENY_BLOCK)
596        *p++ = 'B';
597      else
598        *p++ = 'b';
599
600      if (aconf->flags & GDENY_REJECT)
601        *p++ = 'R';
602      else
603        *p++ = 'r';
604
605      *p = '\0';
606
607      sendto_one(source_p, ":%s %d %s V %s@%s %s %s",
608                 me.name, RPL_STATSDEBUG, source_p->name,
609                 aconf->user, aconf->host, conf->name, buf);
610    }
611    break;
612
531    case XLINE_TYPE:
532      DLINK_FOREACH(ptr, xconf_items.head)
533      {
# Line 632 | Line 550 | report_confitem_types(struct Client *sou
550  
551        sendto_one(source_p, form_str(RPL_STATSXLINE),
552                   me.name, source_p->name,
553 <                 matchitem->hold ? "xR": "XR", matchitem->count,
553 >                 "XR", matchitem->count,
554                   conf->name, matchitem->reason);
555      }
556      break;
557  
558    case RKLINE_TYPE:
641    pfx = temp ? "kR" : "KR";
642
559      DLINK_FOREACH(ptr, rkconf_items.head)
560      {
561        aconf = map_to_conf((conf = ptr->data));
562  
647      if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY))
648        continue;
649
563        sendto_one(source_p, form_str(RPL_STATSKLINE), me.name,
564 <                 source_p->name, pfx, aconf->host, aconf->user,
565 <                 aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
564 >                 source_p->name, "KR", aconf->host, aconf->user,
565 >                 aconf->reason);
566      }
567      break;
568   #endif
# Line 697 | Line 610 | report_confitem_types(struct Client *sou
610        aconf = map_to_conf(conf);
611  
612        /* Don't allow non opers to see oper privs */
613 <      if (IsOper(source_p))
613 >      if (HasUMode(source_p, UMODE_OPER))
614          sendto_one(source_p, form_str(RPL_STATSOLINE),
615                     me.name, source_p->name, 'O', aconf->user, aconf->host,
616                     conf->name, oper_privs_as_string(aconf->port),
# Line 717 | Line 630 | report_confitem_types(struct Client *sou
630        classitem = map_to_conf(conf);
631        sendto_one(source_p, form_str(RPL_STATSYLINE),
632                   me.name, source_p->name, 'Y',
633 <                 conf->name, PingFreq(classitem),
634 <                 ConFreq(classitem),
635 <                 MaxTotal(classitem), MaxSendq(classitem),
636 <                 CurrUserCount(classitem),
633 >                 conf->name, classitem->ping_freq,
634 >                 classitem->con_freq,
635 >                 classitem->max_total, classitem->max_sendq,
636 >                 classitem->max_recvq,
637 >                 classitem->curr_user_count,
638 >                 classitem->number_per_cidr, classitem->cidr_bitlen_ipv4,
639 >                 classitem->number_per_cidr, classitem->cidr_bitlen_ipv6,
640                   classitem->active ? "active" : "disabled");
641      }
642      break;
# Line 750 | Line 666 | report_confitem_types(struct Client *sou
666  
667        if (IsConfAllowAutoConn(aconf))
668          *p++ = 'A';
669 <      if (IsConfCryptLink(aconf))
670 <        *p++ = 'C';
755 <      if (IsConfTopicBurst(aconf))
756 <        *p++ = 'T';
757 <      if (IsConfCompressed(aconf))
758 <        *p++ = 'Z';
669 >      if (IsConfSSL(aconf))
670 >        *p++ = 'S';
671        if (buf[0] == '\0')
672          *p++ = '*';
673  
# Line 764 | Line 676 | report_confitem_types(struct Client *sou
676        /*
677         * Allow admins to see actual ips unless hide_server_ips is enabled
678         */
679 <      if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p))
679 >      if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
680          sendto_one(source_p, form_str(RPL_STATSCLINE),
681                     me.name, source_p->name, 'C', aconf->host,
682                     buf, conf->name, aconf->port,
# Line 778 | Line 690 | report_confitem_types(struct Client *sou
690      break;
691  
692    case HUB_TYPE:
693 <    DLINK_FOREACH(ptr, hub_items.head)
693 >    DLINK_FOREACH(ptr, server_items.head)
694      {
695        conf = ptr->data;
696 <      matchitem = map_to_conf(conf);
697 <      sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
698 <                 source_p->name, 'H', matchitem->host, conf->name, 0, "*");
696 >      aconf = map_to_conf(conf);
697 >
698 >      DLINK_FOREACH(dptr, aconf->hub_list.head)
699 >        sendto_one(source_p, form_str(RPL_STATSHLINE), me.name,
700 >                   source_p->name, 'H', dptr->data, conf->name, 0, "*");
701      }
702      break;
703  
704    case LEAF_TYPE:
705 <    DLINK_FOREACH(ptr, leaf_items.head)
705 >    DLINK_FOREACH(ptr, server_items.head)
706      {
707        conf = ptr->data;
708 <      matchitem = map_to_conf(conf);
709 <      sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
710 <                 source_p->name, 'L', matchitem->host, conf->name, 0, "*");
708 >      aconf = map_to_conf(conf);
709 >
710 >      DLINK_FOREACH(dptr, aconf->leaf_list.head)
711 >        sendto_one(source_p, form_str(RPL_STATSLLINE), me.name,
712 >                   source_p->name, 'L', dptr->data, conf->name, 0, "*");
713      }
714      break;
715  
# Line 831 | Line 747 | check_client(va_list args)
747  
748    /* I'm already in big trouble if source_p->localClient is NULL -db */
749    if ((i = verify_access(source_p, username)))
750 <    ilog(L_INFO, "Access denied: %s[%s]",
750 >    ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]",
751           source_p->name, source_p->sockhost);
752  
753    switch (i)
754    {
755      case TOO_MANY:
756 <      sendto_realops_flags(UMODE_FULL, L_ALL,
756 >      sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
757                             "Too many on IP for %s (%s).",
758                             get_client_name(source_p, SHOW_IP),
759                             source_p->sockhost);
760 <      ilog(L_INFO,"Too many connections on IP from %s.",
760 >      ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
761             get_client_name(source_p, SHOW_IP));
762        ++ServerStats.is_ref;
763        exit_client(source_p, &me, "No more connections allowed on that IP");
764        break;
765  
766      case I_LINE_FULL:
767 <      sendto_realops_flags(UMODE_FULL, L_ALL,
768 <                           "I-line is full for %s (%s).",
767 >      sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
768 >                           "auth{} block is full for %s (%s).",
769                             get_client_name(source_p, SHOW_IP),
770                             source_p->sockhost);
771 <      ilog(L_INFO,"Too many connections from %s.",
771 >      ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
772             get_client_name(source_p, SHOW_IP));
773        ++ServerStats.is_ref;
774        exit_client(source_p, &me,
# Line 863 | Line 779 | check_client(va_list args)
779        ++ServerStats.is_ref;
780        /* jdc - lists server name & port connections are on */
781        /*       a purely cosmetical change */
782 <      sendto_realops_flags(UMODE_UNAUTH, L_ALL,
782 >      sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
783                             "Unauthorized client connection from %s [%s] on [%s/%u].",
784                             get_client_name(source_p, SHOW_IP),
785                             source_p->sockhost,
786                             source_p->localClient->listener->name,
787                             source_p->localClient->listener->port);
788 <      ilog(L_INFO,
788 >      ilog(LOG_TYPE_IRCD,
789            "Unauthorized client connection from %s on [%s/%u].",
790            get_client_name(source_p, SHOW_IP),
791            source_p->localClient->listener->name,
792            source_p->localClient->listener->port);
793  
794 <      /* XXX It is prolematical whether it is better to use the
879 <       * capture reject code here or rely on the connecting too fast code.
880 <       * - Dianora
881 <       */
882 <      if (REJECT_HOLD_TIME > 0)
883 <      {
884 <        sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server",
885 <                   me.name, source_p->name);
886 <        source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
887 <        SetCaptured(source_p);
888 <      }
889 <      else
890 <        exit_client(source_p, &me, "You are not authorized to use this server");
794 >      exit_client(source_p, &me, "You are not authorized to use this server");
795        break;
796  
797     case BANNED_CLIENT:
798 <     /*
895 <      * Don't exit them immediately, play with them a bit.
896 <      * - Dianora
897 <      */
898 <     if (REJECT_HOLD_TIME > 0)
899 <     {
900 <       source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
901 <       SetCaptured(source_p);
902 <     }
903 <     else
904 <       exit_client(source_p, &me, "Banned");
798 >     exit_client(source_p, &me, "Banned");
799       ++ServerStats.is_ref;
800       break;
801  
# Line 974 | Line 868 | verify_access(struct Client *client_p, c
868          conf = unmap_conf_item(aconf);
869  
870          if (!ConfigFileEntry.hide_spoof_ips && IsConfSpoofNotice(aconf))
871 <          sendto_realops_flags(UMODE_ALL, L_ADMIN, "%s spoofing: %s as %s",
871 >          sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
872 >                               "%s spoofing: %s as %s",
873                                 client_p->name, client_p->host, conf->name);
874          strlcpy(client_p->host, conf->name, sizeof(client_p->host));
875          SetIPSpoof(client_p);
# Line 989 | Line 884 | verify_access(struct Client *client_p, c
884        if (IsConfGline(aconf))
885          sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name,
886                     client_p->name);
887 <      if (ConfigFileEntry.kline_with_reason)
888 <        sendto_one(client_p, ":%s NOTICE %s :*** Banned %s",
994 <                  me.name, client_p->name, aconf->reason);
887 >      sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s",
888 >                 me.name, client_p->name, aconf->reason);
889        return(BANNED_CLIENT);
890      }
891    }
# Line 1032 | Line 926 | attach_iline(struct Client *client_p, st
926     * setting a_limit_reached if any limit is reached.
927     * - Dianora
928     */
929 <  if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass))
929 >  if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total)
930      a_limit_reached = 1;
931 <  else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass))
931 >  else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip)
932      a_limit_reached = 1;
933 <  else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass))
933 >  else if (aclass->max_local != 0 && local >= aclass->max_local)
934      a_limit_reached = 1;
935 <  else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass))
935 >  else if (aclass->max_global != 0 && global >= aclass->max_global)
936      a_limit_reached = 1;
937 <  else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) &&
937 >  else if (aclass->max_ident != 0 && ident >= aclass->max_ident &&
938             client_p->username[0] != '~')
939      a_limit_reached = 1;
940  
# Line 1303 | Line 1197 | detach_conf(struct Client *client_p, Con
1197    struct ClassItem *aclass;
1198    struct AccessItem *aconf;
1199    struct ConfItem *aclass_conf;
1306  struct MatchItem *match_item;
1200  
1201    DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head)
1202    {
# Line 1323 | Line 1216 | detach_conf(struct Client *client_p, Con
1216  
1217          assert(aconf->clients > 0);
1218  
1219 <        if ((aclass_conf = ClassPtr(aconf)) != NULL)
1219 >        if ((aclass_conf = aconf->class_ptr) != NULL)
1220          {
1221            aclass = map_to_conf(aclass_conf);
1222  
# Line 1339 | Line 1232 | detach_conf(struct Client *client_p, Con
1232            delete_conf_item(conf);
1233  
1234          break;
1342
1343      case LEAF_TYPE:
1344      case HUB_TYPE:
1345        match_item = map_to_conf(conf);
1346        if (match_item->ref_count == 0 && match_item->illegal)
1347          delete_conf_item(conf);
1348        break;
1235        default:
1236          break;
1237        }
# Line 1371 | Line 1257 | detach_conf(struct Client *client_p, Con
1257   int
1258   attach_conf(struct Client *client_p, struct ConfItem *conf)
1259   {
1260 +  struct AccessItem *aconf = map_to_conf(conf);
1261 +  struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1262 +
1263    if (dlinkFind(&client_p->localClient->confs, conf) != NULL)
1264      return 1;
1265  
1266 <  if (conf->type == CLIENT_TYPE ||
1267 <      conf->type == SERVER_TYPE ||
1379 <      conf->type == OPER_TYPE)
1380 <  {
1381 <    struct AccessItem *aconf = map_to_conf(conf);
1382 <    struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1266 >  if (IsConfIllegal(aconf)) /* TBV: can't happen */
1267 >    return NOT_AUTHORIZED;
1268  
1269 <    if (IsConfIllegal(aconf))
1270 <      return NOT_AUTHORIZED;
1269 >  if (conf->type == CLIENT_TYPE)
1270 >    if (cidr_limit_reached(IsConfExemptLimits(aconf),
1271 >                           &client_p->localClient->ip, aclass))
1272 >      return TOO_MANY;    /* Already at maximum allowed */
1273  
1274 <    if (conf->type == CLIENT_TYPE)
1275 <      if (cidr_limit_reached(IsConfExemptLimits(aconf),
1389 <                             &client_p->localClient->ip, aclass))
1390 <        return TOO_MANY;    /* Already at maximum allowed */
1391 <
1392 <    CurrUserCount(aclass)++;
1393 <    aconf->clients++;
1394 <  }
1395 <  else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE)
1396 <  {
1397 <    struct MatchItem *match_item = map_to_conf(conf);
1398 <    match_item->ref_count++;
1399 <  }
1274 >  aclass->curr_user_count++;
1275 >  aconf->clients++;
1276  
1277    dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs);
1278  
# Line 1485 | Line 1361 | find_conf_exact(ConfType type, const cha
1361      {
1362        struct ClassItem *aclass = map_to_conf(aconf->class_ptr);
1363  
1364 <      if (aconf->clients >= MaxTotal(aclass))
1364 >      if (aconf->clients >= aclass->max_total)
1365          continue;
1366      }
1367  
# Line 1672 | Line 1548 | find_matching_name_conf(ConfType type, c
1548   * side effects - looks for an exact match on name field
1549   */
1550   struct ConfItem *
1551 < find_exact_name_conf(ConfType type, const char *name,
1551 > find_exact_name_conf(ConfType type, const struct Client *who, const char *name,
1552                       const char *user, const char *host)
1553   {
1554    dlink_node *ptr = NULL;
# Line 1713 | Line 1589 | find_exact_name_conf(ConfType type, cons
1589      DLINK_FOREACH(ptr, list_p->head)
1590      {
1591        conf = ptr->data;
1592 <      aconf = (struct AccessItem *)map_to_conf(conf);
1592 >      aconf = map_to_conf(conf);
1593 >
1594        if (EmptyString(conf->name))
1595 <        continue;
1596 <    
1597 <      if (irccmp(conf->name, name) == 0)
1595 >        continue;
1596 >
1597 >      if (!irccmp(conf->name, name))
1598        {
1599 <        if ((user == NULL && (host == NULL)))
1600 <          return (conf);
1601 <        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1602 <          return (conf);
1603 <        if (match(aconf->user, user) && match(aconf->host, host))
1604 <          return (conf);
1599 >        if (!who)
1600 >          return conf;
1601 >        if (EmptyString(aconf->user) || EmptyString(aconf->host))
1602 >          return conf;
1603 >        if (match(aconf->user, who->username))
1604 >        {
1605 >          switch (aconf->type)
1606 >          {
1607 >            case HM_HOST:
1608 >              if (match(aconf->host, who->host) || match(aconf->host, who->sockhost))
1609 >                return conf;
1610 >              break;
1611 >            case HM_IPV4:
1612 >              if (who->localClient->aftype == AF_INET)
1613 >                if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits))
1614 >                  return conf;
1615 >              break;
1616 > #ifdef IPV6
1617 >            case HM_IPV6:
1618 >              if (who->localClient->aftype == AF_INET6)
1619 >                if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits))
1620 >                  return conf;
1621 >              break;
1622 > #endif
1623 >            default:
1624 >              assert(0);
1625 >          }
1626 >        }
1627        }
1628      }
1629 +
1630      break;
1631  
1632    case SERVER_TYPE:
# Line 1779 | Line 1679 | int
1679   rehash(int sig)
1680   {
1681    if (sig != 0)
1682 <    sendto_realops_flags(UMODE_ALL, L_ALL,
1682 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1683                           "Got signal SIGHUP, reloading ircd.conf file");
1684  
1685    restart_resolver();
# Line 1799 | Line 1699 | rehash(int sig)
1699    flush_deleted_I_P();
1700  
1701    rehashed_klines = 1;
1702 <
1702 > /* XXX */
1703    if (ConfigLoggingEntry.use_logging)
1704 <    reopen_log(logFileName);
1704 >    log_close_all();
1705  
1706    return(0);
1707   }
# Line 1848 | Line 1748 | set_default_conf(void)
1748    AdminInfo.email = NULL;
1749    AdminInfo.description = NULL;
1750  
1751 <  set_log_level(L_NOTICE);
1751 >  log_close_all();
1752 >
1753    ConfigLoggingEntry.use_logging = 1;
1754 <  ConfigLoggingEntry.operlog[0] = '\0';
1755 <  ConfigLoggingEntry.userlog[0] = '\0';
1756 <  ConfigLoggingEntry.klinelog[0] = '\0';
1856 <  ConfigLoggingEntry.glinelog[0] = '\0';
1857 <  ConfigLoggingEntry.killlog[0] = '\0';
1858 <  ConfigLoggingEntry.operspylog[0] = '\0';
1859 <  ConfigLoggingEntry.ioerrlog[0] = '\0';
1860 <  ConfigLoggingEntry.failed_operlog[0] = '\0';
1861 <
1862 <  ConfigChannel.disable_fake_channels = NO;
1863 <  ConfigChannel.restrict_channels = NO;
1864 <  ConfigChannel.disable_local_channels = NO;
1865 <  ConfigChannel.use_invex = YES;
1866 <  ConfigChannel.use_except = YES;
1867 <  ConfigChannel.use_knock = YES;
1754 >
1755 >  ConfigChannel.disable_fake_channels = 0;
1756 >  ConfigChannel.restrict_channels = 0;
1757    ConfigChannel.knock_delay = 300;
1758    ConfigChannel.knock_delay_channel = 60;
1759 <  ConfigChannel.max_chans_per_user = 15;
1760 <  ConfigChannel.quiet_on_ban = YES;
1759 >  ConfigChannel.max_chans_per_user = 25;
1760 >  ConfigChannel.max_chans_per_oper = 50;
1761 >  ConfigChannel.quiet_on_ban = 1;
1762    ConfigChannel.max_bans = 25;
1763    ConfigChannel.default_split_user_count = 0;
1764    ConfigChannel.default_split_server_count = 0;
1765 <  ConfigChannel.no_join_on_split = NO;
1766 <  ConfigChannel.no_create_on_split = NO;
1877 <  ConfigChannel.burst_topicwho = YES;
1765 >  ConfigChannel.no_join_on_split = 0;
1766 >  ConfigChannel.no_create_on_split = 0;
1767  
1768 <  ConfigServerHide.flatten_links = NO;
1768 >  ConfigServerHide.flatten_links = 0;
1769    ConfigServerHide.links_delay = 300;
1770 <  ConfigServerHide.hidden = NO;
1771 <  ConfigServerHide.disable_hidden = NO;
1883 <  ConfigServerHide.hide_servers = NO;
1770 >  ConfigServerHide.hidden = 0;
1771 >  ConfigServerHide.hide_servers = 0;
1772    DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT);
1773 <  ConfigServerHide.hide_server_ips = NO;
1773 >  ConfigServerHide.hide_server_ips = 0;
1774  
1775    
1776    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1777    ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT;
1778 +  ConfigFileEntry.glines = 0;
1779 +  ConfigFileEntry.gline_time = 12 * 3600;
1780 +  ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
1781    ConfigFileEntry.gline_min_cidr = 16;
1782    ConfigFileEntry.gline_min_cidr6 = 48;
1783 <  ConfigFileEntry.invisible_on_connect = YES;
1784 <  ConfigFileEntry.burst_away = NO;
1785 <  ConfigFileEntry.use_whois_actually = YES;
1786 <  ConfigFileEntry.tkline_expire_notices = YES;
1787 <  ConfigFileEntry.hide_spoof_ips = YES;
1788 <  ConfigFileEntry.ignore_bogus_ts = NO;
1898 <  ConfigFileEntry.disable_auth = NO;
1899 <  ConfigFileEntry.disable_remote = NO;
1783 >  ConfigFileEntry.invisible_on_connect = 1;
1784 >  ConfigFileEntry.tkline_expire_notices = 1;
1785 >  ConfigFileEntry.hide_spoof_ips = 1;
1786 >  ConfigFileEntry.ignore_bogus_ts = 0;
1787 >  ConfigFileEntry.disable_auth = 0;
1788 >  ConfigFileEntry.disable_remote = 0;
1789    ConfigFileEntry.kill_chase_time_limit = 90;
1790    ConfigFileEntry.default_floodcount = 8;
1791 <  ConfigFileEntry.failed_oper_notice = YES;
1791 >  ConfigFileEntry.failed_oper_notice = 1;
1792    ConfigFileEntry.dots_in_ident = 0;
1793    ConfigFileEntry.min_nonwildcard = 4;
1794    ConfigFileEntry.min_nonwildcard_simple = 3;
1795    ConfigFileEntry.max_accept = 20;
1796 <  ConfigFileEntry.anti_nick_flood = NO;
1796 >  ConfigFileEntry.anti_nick_flood = 0;
1797    ConfigFileEntry.max_nick_time = 20;
1798    ConfigFileEntry.max_nick_changes = 5;
1799    ConfigFileEntry.anti_spam_exit_message_time = 0;
1800    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1801    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1802 <  ConfigFileEntry.kline_with_reason = YES;
1803 <  ConfigFileEntry.kline_reason = NULL;
1915 <  ConfigFileEntry.warn_no_nline = YES;
1916 <  ConfigFileEntry.stats_o_oper_only = NO;
1802 >  ConfigFileEntry.warn_no_nline = 1;
1803 >  ConfigFileEntry.stats_o_oper_only = 0;
1804    ConfigFileEntry.stats_k_oper_only = 1;  /* masked */
1805    ConfigFileEntry.stats_i_oper_only = 1;  /* masked */
1806 <  ConfigFileEntry.stats_P_oper_only = NO;
1806 >  ConfigFileEntry.stats_P_oper_only = 0;
1807    ConfigFileEntry.caller_id_wait = 60;
1808 <  ConfigFileEntry.opers_bypass_callerid = NO;
1808 >  ConfigFileEntry.opers_bypass_callerid = 0;
1809    ConfigFileEntry.pace_wait = 10;
1810    ConfigFileEntry.pace_wait_simple = 1;
1811 <  ConfigFileEntry.short_motd = NO;
1812 <  ConfigFileEntry.ping_cookie = NO;
1813 <  ConfigFileEntry.no_oper_flood = NO;
1814 <  ConfigFileEntry.true_no_oper_flood = NO;
1815 <  ConfigFileEntry.oper_pass_resv = YES;
1929 <  ConfigFileEntry.glines = NO;
1930 <  ConfigFileEntry.gline_time = 12 * 3600;
1811 >  ConfigFileEntry.short_motd = 0;
1812 >  ConfigFileEntry.ping_cookie = 0;
1813 >  ConfigFileEntry.no_oper_flood = 0;
1814 >  ConfigFileEntry.true_no_oper_flood = 0;
1815 >  ConfigFileEntry.oper_pass_resv = 1;
1816    ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT;
1932  ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT;
1817    ConfigFileEntry.oper_only_umodes = UMODE_DEBUG;
1818    ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE |
1819      UMODE_OPERWALL | UMODE_WALLOP;
1820 <  DupString(ConfigFileEntry.servlink_path, SLPATH);
1937 < #ifdef HAVE_LIBCRYPTO
1938 <  /* jdc -- This is our default value for a cipher.  According to the
1939 <   *        CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported
1940 <   *        under all circumstances if cryptlinks are enabled.  So,
1941 <   *        this will be our default.
1942 <   *
1943 <   *        NOTE: I apologise for the hard-coded value of "1" (BF/128).
1944 <   *              This should be moved into a find_cipher() routine.
1945 <   */
1946 <  ConfigFileEntry.default_cipher_preference = &CipherTable[1];
1947 < #endif
1948 <  ConfigFileEntry.use_egd = NO;
1820 >  ConfigFileEntry.use_egd = 0;
1821    ConfigFileEntry.egdpool_path = NULL;
1950 #ifdef HAVE_LIBZ
1951  ConfigFileEntry.compression_level = 0;
1952 #endif
1822    ConfigFileEntry.throttle_time = 10;
1823   }
1824  
1825 + static void
1826 + validate_conf(void)
1827 + {
1828 +  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
1829 +    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1830 +
1831 +  if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1832 +    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1833 +
1834 +  if (ServerInfo.network_name == NULL)
1835 +    DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1836 +
1837 +  if (ServerInfo.network_desc == NULL)
1838 +    DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1839 +
1840 +  if (ConfigFileEntry.service_name == NULL)
1841 +    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
1842 +
1843 +  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
1844 + }
1845 +
1846   /* read_conf()
1847   *
1848   * inputs       - file descriptor pointing to config file to use
# Line 1960 | Line 1850 | set_default_conf(void)
1850   * side effects - Read configuration file.
1851   */
1852   static void
1853 < read_conf(FBFILE *file)
1853 > read_conf(FILE *file)
1854   {
1855    lineno = 0;
1856  
# Line 1968 | Line 1858 | read_conf(FBFILE *file)
1858    conf_parser_ctx.pass = 1;
1859    yyparse();          /* pick up the classes first */
1860  
1861 <  fbrewind(file);
1861 >  rewind(file);
1862  
1863    conf_parser_ctx.pass = 2;
1864    yyparse();          /* Load the values from the conf */
# Line 1977 | Line 1867 | read_conf(FBFILE *file)
1867    check_class();      /* Make sure classes are valid */
1868   }
1869  
1980 static void
1981 validate_conf(void)
1982 {
1983  if (ConfigFileEntry.ts_warn_delta < TS_WARN_DELTA_MIN)
1984    ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
1985
1986  if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN)
1987    ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT;
1988
1989  if (ConfigFileEntry.servlink_path == NULL)
1990    DupString(ConfigFileEntry.servlink_path, SLPATH);
1991
1992  if (ServerInfo.network_name == NULL)
1993    DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT);
1994
1995  if (ServerInfo.network_desc == NULL)
1996    DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT);
1997
1998  if (ConfigFileEntry.service_name == NULL)
1999    DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT);
2000
2001  if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) ||
2002      (ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX))
2003    ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX;
2004
2005  ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN);
2006 }
2007
1870   /* lookup_confhost()
1871   *
1872   * start DNS lookups of all hostnames in the conf
# Line 2018 | Line 1880 | lookup_confhost(struct ConfItem *conf)
1880  
1881    aconf = map_to_conf(conf);
1882  
1883 <  if (EmptyString(aconf->host) ||
2022 <      EmptyString(aconf->user))
1883 >  if (has_wildcards(aconf->host))
1884    {
1885 <    ilog(L_ERROR, "Host/server name error: (%s) (%s)",
1885 >    ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)",
1886           aconf->host, conf->name);
1887      return;
1888    }
1889  
2029  if (strchr(aconf->host, '*') ||
2030      strchr(aconf->host, '?'))
2031    return;
2032
1890    /* Do name lookup now on hostnames given and store the
1891     * ip numbers in conf structure.
1892     */
# Line 2049 | Line 1906 | lookup_confhost(struct ConfItem *conf)
1906  
1907    assert(res != NULL);
1908  
1909 <  memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen);
1910 <  aconf->ipnum.ss_len = res->ai_addrlen;
1911 <  aconf->ipnum.ss.ss_family = res->ai_family;
1909 >  memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen);
1910 >  aconf->addr.ss_len = res->ai_addrlen;
1911 >  aconf->addr.ss.ss_family = res->ai_family;
1912    freeaddrinfo(res);
1913   }
1914  
# Line 2129 | Line 1986 | find_kill(struct Client *client_p)
1986  
1987    assert(client_p != NULL);
1988  
1989 <  aconf = find_kline_conf(client_p->host, client_p->username,
1990 <                          &client_p->localClient->ip,
1991 <                          client_p->localClient->aftype);
1989 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
1990 >                               CONF_KLINE, client_p->localClient->aftype,
1991 >                               client_p->username, NULL, 1);
1992    if (aconf == NULL)
1993      aconf = find_regexp_kline(uhi);
1994  
1995 <  if (aconf && (aconf->status & CONF_KLINE))
2139 <    return aconf;
2140 <
2141 <  return NULL;
1995 >  return aconf;
1996   }
1997  
1998   struct AccessItem *
# Line 2148 | Line 2002 | find_gline(struct Client *client_p)
2002  
2003    assert(client_p != NULL);
2004  
2005 <  aconf = find_gline_conf(client_p->host, client_p->username,
2006 <                          &client_p->localClient->ip,
2007 <                          client_p->localClient->aftype);
2008 <
2155 <  if (aconf && (aconf->status & CONF_GLINE))
2156 <    return aconf;
2157 <
2158 <  return NULL;
2005 >  aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
2006 >                               CONF_GLINE, client_p->localClient->aftype,
2007 >                               client_p->username, NULL, 1);
2008 >  return aconf;
2009   }
2010  
2011   /* add_temp_line()
# Line 2168 | Line 2018 | find_gline(struct Client *client_p)
2018   void
2019   add_temp_line(struct ConfItem *conf)
2020   {
2021 <  struct AccessItem *aconf;
2172 <
2173 <  if (conf->type == DLINE_TYPE)
2174 <  {
2175 <    aconf = map_to_conf(conf);
2176 <    SetConfTemporary(aconf);
2177 <    dlinkAdd(conf, &conf->node, &temporary_dlines);
2178 <    MyFree(aconf->user);
2179 <    aconf->user = NULL;
2180 <    add_conf_by_address(CONF_DLINE, aconf);
2181 <  }
2182 <  else if (conf->type == KLINE_TYPE)
2183 <  {
2184 <    aconf = map_to_conf(conf);
2185 <    SetConfTemporary(aconf);
2186 <    dlinkAdd(conf, &conf->node, &temporary_klines);
2187 <    add_conf_by_address(CONF_KILL, aconf);
2188 <  }
2189 <  else if (conf->type == GLINE_TYPE)
2190 <  {
2191 <    aconf = map_to_conf(conf);
2192 <    SetConfTemporary(aconf);
2193 <    dlinkAdd(conf, &conf->node, &temporary_glines);
2194 <    add_conf_by_address(CONF_GLINE, aconf);
2195 <  }
2196 <  else if (conf->type == XLINE_TYPE)
2197 <  {
2198 <    conf->flags |= CONF_FLAGS_TEMPORARY;
2199 <    dlinkAdd(conf, make_dlink_node(), &temporary_xlines);
2200 <  }
2201 <  else if (conf->type == RXLINE_TYPE)
2202 <  {
2203 <    conf->flags |= CONF_FLAGS_TEMPORARY;
2204 <    dlinkAdd(conf, make_dlink_node(), &temporary_rxlines);
2205 <  }
2206 <  else if (conf->type == RKLINE_TYPE)
2207 <  {
2208 <    conf->flags |= CONF_FLAGS_TEMPORARY;
2209 <    dlinkAdd(conf, make_dlink_node(), &temporary_rklines);
2210 <  }
2211 <  else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2021 >  if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE))
2022    {
2023      conf->flags |= CONF_FLAGS_TEMPORARY;
2024      dlinkAdd(conf, make_dlink_node(), &temporary_resv);
# Line 2225 | Line 2035 | add_temp_line(struct ConfItem *conf)
2035   void
2036   cleanup_tklines(void *notused)
2037   {
2038 <  expire_tklines(&temporary_glines);
2039 <  expire_tklines(&temporary_klines);
2230 <  expire_tklines(&temporary_dlines);
2231 <  expire_tklines(&temporary_xlines);
2232 <  expire_tklines(&temporary_rxlines);
2233 <  expire_tklines(&temporary_rklines);
2038 >  hostmask_expire_temporary();
2039 >  expire_tklines(&xconf_items);
2040    expire_tklines(&temporary_resv);
2041   }
2042  
# Line 2248 | Line 2054 | expire_tklines(dlink_list *tklist)
2054    struct ConfItem *conf;
2055    struct MatchItem *xconf;
2056    struct MatchItem *nconf;
2251  struct AccessItem *aconf;
2057    struct ResvChannel *cconf;
2058  
2059    DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head)
2060    {
2061      conf = ptr->data;
2257    if (conf->type == GLINE_TYPE ||
2258        conf->type == KLINE_TYPE ||
2259        conf->type == DLINE_TYPE)
2260    {
2261      aconf = (struct AccessItem *)map_to_conf(conf);
2262      if (aconf->hold <= CurrentTime)
2263      {
2264        /* XXX - Do we want GLINE expiry notices?? */
2265        /* Alert opers that a TKline expired - Hwy */
2266        if (ConfigFileEntry.tkline_expire_notices)
2267        {
2268          if (aconf->status & CONF_KILL)
2269          {
2270            sendto_realops_flags(UMODE_ALL, L_ALL,
2271                                 "Temporary K-line for [%s@%s] expired",
2272                                 (aconf->user) ? aconf->user : "*",
2273                                 (aconf->host) ? aconf->host : "*");
2274          }
2275          else if (conf->type == DLINE_TYPE)
2276          {
2277            sendto_realops_flags(UMODE_ALL, L_ALL,
2278                                 "Temporary D-line for [%s] expired",
2279                                 (aconf->host) ? aconf->host : "*");
2280          }
2281        }
2062  
2063 <        dlinkDelete(ptr, tklist);
2284 <        delete_one_address_conf(aconf->host, aconf);
2285 <      }
2286 <    }
2287 <    else if (conf->type == XLINE_TYPE ||
2288 <             conf->type == RXLINE_TYPE)
2063 >    if (conf->type == XLINE_TYPE)
2064      {
2065 +      if (!IsConfTemporary(conf))
2066 +        continue;
2067 +
2068        xconf = (struct MatchItem *)map_to_conf(conf);
2069        if (xconf->hold <= CurrentTime)
2070        {
2071          if (ConfigFileEntry.tkline_expire_notices)
2072 <          sendto_realops_flags(UMODE_ALL, L_ALL,
2073 <                               "Temporary X-line for [%s] %sexpired", conf->name,
2296 <                               conf->type == RXLINE_TYPE ? "(REGEX) " : "");
2297 <        dlinkDelete(ptr, tklist);
2298 <        free_dlink_node(ptr);
2072 >          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2073 >                               "Temporary X-line for [%s] expired", conf->name);
2074          delete_conf_item(conf);
2075        }
2076      }
2302    else if (conf->type == RKLINE_TYPE)
2303    {
2304      aconf = map_to_conf(conf);
2305      if (aconf->hold <= CurrentTime)
2306      {
2307        if (ConfigFileEntry.tkline_expire_notices)
2308           sendto_realops_flags(UMODE_ALL, L_ALL,
2309                                "Temporary K-line for [%s@%s] (REGEX) expired",
2310                                (aconf->user) ? aconf->user : "*",
2311                                (aconf->host) ? aconf->host : "*");
2312        dlinkDelete(ptr, tklist);
2313        free_dlink_node(ptr);
2314        delete_conf_item(conf);
2315      }
2316    }
2077      else if (conf->type == NRESV_TYPE)
2078      {
2079        nconf = (struct MatchItem *)map_to_conf(conf);
2080        if (nconf->hold <= CurrentTime)
2081        {
2082          if (ConfigFileEntry.tkline_expire_notices)
2083 <          sendto_realops_flags(UMODE_ALL, L_ALL,
2083 >          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2084                                 "Temporary RESV for [%s] expired", conf->name);
2085          dlinkDelete(ptr, tklist);
2086          free_dlink_node(ptr);
# Line 2333 | Line 2093 | expire_tklines(dlink_list *tklist)
2093        if (cconf->hold <= CurrentTime)
2094        {
2095          if (ConfigFileEntry.tkline_expire_notices)
2096 <          sendto_realops_flags(UMODE_ALL, L_ALL,
2096 >          sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2097                                 "Temporary RESV for [%s] expired", cconf->name);
2098          delete_channel_resv(cconf);
2099        }
# Line 2350 | Line 2110 | expire_tklines(dlink_list *tklist)
2110   static const struct oper_privs
2111   {
2112    const unsigned int oprivs;
2353  const unsigned int hidden;
2113    const unsigned char c;
2114   } flag_list[] = {
2115 <  { OPER_FLAG_ADMIN,       OPER_FLAG_HIDDEN_ADMIN,  'A' },
2116 <  { OPER_FLAG_REMOTEBAN,   0,                       'B' },
2117 <  { OPER_FLAG_DIE,         0,                       'D' },
2118 <  { OPER_FLAG_GLINE,       0,                       'G' },
2119 <  { OPER_FLAG_REHASH,      0,                       'H' },
2120 <  { OPER_FLAG_K,           0,                       'K' },
2121 <  { OPER_FLAG_OPERWALL,    0,                       'L' },
2122 <  { OPER_FLAG_N,           0,                       'N' },
2123 <  { OPER_FLAG_GLOBAL_KILL, 0,                       'O' },
2124 <  { OPER_FLAG_REMOTE,      0,                       'R' },
2125 <  { OPER_FLAG_OPER_SPY,    0,                       'S' },
2126 <  { OPER_FLAG_UNKLINE,     0,                       'U' },
2127 <  { OPER_FLAG_X,           0,                       'X' },
2128 <  { 0, 0, '\0' }
2115 >  { OPER_FLAG_ADMIN,       'A' },
2116 >  { OPER_FLAG_REMOTEBAN,   'B' },
2117 >  { OPER_FLAG_DIE,         'D' },
2118 >  { OPER_FLAG_GLINE,       'G' },
2119 >  { OPER_FLAG_REHASH,      'H' },
2120 >  { OPER_FLAG_K,           'K' },
2121 >  { OPER_FLAG_OPERWALL,    'L' },
2122 >  { OPER_FLAG_N,           'N' },
2123 >  { OPER_FLAG_GLOBAL_KILL, 'O' },
2124 >  { OPER_FLAG_REMOTE,      'R' },
2125 >  { OPER_FLAG_OPER_SPY,    'S' },
2126 >  { OPER_FLAG_UNKLINE,     'U' },
2127 >  { OPER_FLAG_X,           'X' },
2128 >  { 0, '\0' }
2129   };
2130  
2131   char *
# Line 2378 | Line 2137 | oper_privs_as_string(const unsigned int
2137  
2138    for (; flag_list[i].oprivs; ++i)
2139    {
2140 <    if ((port & flag_list[i].oprivs) &&
2382 <        (port & flag_list[i].hidden) == 0)
2140 >    if (port & flag_list[i].oprivs)
2141        *privs_ptr++ = flag_list[i].c;
2142      else
2143        *privs_ptr++ = ToLowerTab[flag_list[i].c];
# Line 2396 | Line 2154 | oper_privs_as_string(const unsigned int
2154   *         "oper" is server name for remote opers
2155   * Side effects: None.
2156   */
2157 < char *
2157 > const char *
2158   get_oper_name(const struct Client *client_p)
2159   {
2160 <  dlink_node *cnode;
2403 <  struct ConfItem *conf;
2404 <  struct AccessItem *aconf;
2405 <
2160 >  dlink_node *cnode = NULL;
2161    /* +5 for !,@,{,} and null */
2162    static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
2163  
2164    if (MyConnect(client_p))
2165    {
2166 <    DLINK_FOREACH(cnode, client_p->localClient->confs.head)
2166 >    if ((cnode = client_p->localClient->confs.head))
2167      {
2168 <      conf = cnode->data;
2169 <      aconf = map_to_conf(conf);
2168 >      struct ConfItem *conf = cnode->data;
2169 >      const struct AccessItem *aconf = map_to_conf(conf);
2170  
2171        if (IsConfOperator(aconf))
2172        {
# Line 2446 | Line 2201 | read_conf_files(int cold)
2201    char chanlimit[32];
2202  
2203    conf_parser_ctx.boot = cold;
2204 <  filename = get_conf_name(CONF_TYPE);
2204 >  filename = ConfigFileEntry.configfile;
2205  
2206    /* We need to know the initial filename for the yyerror() to report
2207       FIXME: The full path is in conffilenamebuf first time since we
# Line 2456 | Line 2211 | read_conf_files(int cold)
2211    */
2212    strlcpy(conffilebuf, filename, sizeof(conffilebuf));
2213  
2214 <  if ((conf_parser_ctx.conf_file = fbopen(filename, "r")) == NULL)
2214 >  if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
2215    {
2216      if (cold)
2217      {
2218 <      ilog(L_CRIT, "Unable to read configuration file '%s': %s",
2218 >      ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
2219             filename, strerror(errno));
2220        exit(-1);
2221      }
2222      else
2223      {
2224 <      sendto_realops_flags(UMODE_ALL, L_ALL,
2224 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2225                             "Unable to read configuration file '%s': %s",
2226                             filename, strerror(errno));
2227        return;
# Line 2477 | Line 2232 | read_conf_files(int cold)
2232      clear_out_old_conf();
2233  
2234    read_conf(conf_parser_ctx.conf_file);
2235 <  fbclose(conf_parser_ctx.conf_file);
2235 >  fclose(conf_parser_ctx.conf_file);
2236  
2237    add_isupport("NETWORK", ServerInfo.network_name, -1);
2238 <  snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d",
2239 <           ConfigChannel.use_except ? "e" : "",
2485 <           ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans);
2238 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%d",
2239 >           ConfigChannel.max_bans);
2240    add_isupport("MAXLIST", chanmodes, -1);
2241    add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets);
2242  
2243 <  if (ConfigChannel.disable_local_channels)
2490 <    add_isupport("CHANTYPES", "#", -1);
2491 <  else
2492 <    add_isupport("CHANTYPES", "#&", -1);
2243 >  add_isupport("CHANTYPES", "#", -1);
2244  
2245 <  snprintf(chanlimit, sizeof(chanlimit), "%s:%d",
2495 <           ConfigChannel.disable_local_channels ? "#" : "#&",
2245 >  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
2246             ConfigChannel.max_chans_per_user);
2247    add_isupport("CHANLIMIT", chanlimit, -1);
2248 <  snprintf(chanmodes, sizeof(chanmodes), "%s%s%s",
2249 <           ConfigChannel.use_except ? "e" : "",
2500 <           ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS");
2248 >  snprintf(chanmodes, sizeof(chanmodes), "%s",
2249 >           "beI,k,l,imnprstORS");
2250    add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN);
2251  
2252 <  if (ConfigChannel.use_except)
2253 <    add_isupport("EXCEPTS", "e", -1);
2505 <  if (ConfigChannel.use_invex)
2506 <    add_isupport("INVEX", "I", -1);
2252 >  add_isupport("EXCEPTS", "e", -1);
2253 >  add_isupport("INVEX", "I", -1);
2254    add_isupport("CHANMODES", chanmodes, -1);
2255  
2256    /*
# Line 2511 | Line 2258 | read_conf_files(int cold)
2258     * on strlen(form_str(RPL_ISUPPORT))
2259     */
2260    rebuild_isupport_message_line();
2514
2515 #ifdef HAVE_LIBPCRE
2516  parse_conf_file(RKLINE_TYPE, cold);
2517  parse_conf_file(RXLINE_TYPE, cold);
2518 #endif
2519  parse_conf_file(KLINE_TYPE, cold);
2520  parse_conf_file(DLINE_TYPE, cold);
2521  parse_conf_file(XLINE_TYPE, cold);
2522  parse_conf_file(NRESV_TYPE, cold);
2523  parse_conf_file(CRESV_TYPE, cold);
2524 }
2525
2526 /* parse_conf_file()
2527 *
2528 * inputs       - type of conf file to parse
2529 * output       - none
2530 * side effects - conf file for givenconf type is opened and read then parsed
2531 */
2532 static void
2533 parse_conf_file(int type, int cold)
2534 {
2535  FBFILE *file = NULL;
2536  const char *filename = get_conf_name(type);
2537
2538  if ((file = fbopen(filename, "r")) == NULL)
2539  {
2540    if (cold)
2541      ilog(L_ERROR, "Unable to read configuration file '%s': %s",
2542           filename, strerror(errno));
2543    else
2544      sendto_realops_flags(UMODE_ALL, L_ALL,
2545                    "Unable to read configuration file '%s': %s",
2546                           filename, strerror(errno));
2547  }
2548  else
2549  {
2550    parse_csv_file(file, type);
2551    fbclose(file);
2552  }
2261   }
2262  
2263   /* clear_out_old_conf()
# Line 2565 | Line 2273 | clear_out_old_conf(void)
2273    struct ConfItem *conf;
2274    struct AccessItem *aconf;
2275    struct ClassItem *cltmp;
2568  struct MatchItem *match_item;
2276    dlink_list *free_items [] = {
2277 <    &server_items,   &oconf_items,    &hub_items, &leaf_items,
2277 >    &server_items,   &oconf_items,
2278       &uconf_items,   &xconf_items, &rxconf_items, &rkconf_items,
2279 <     &nresv_items, &cluster_items,  &gdeny_items, &service_items, NULL
2279 >     &nresv_items, &cluster_items,  &service_items, NULL
2280    };
2281  
2282    dlink_list ** iterator = free_items; /* C is dumb */
# Line 2612 | Line 2319 | clear_out_old_conf(void)
2319            delete_conf_item(conf);
2320          }
2321        }
2615      else if (conf->type == CLIENT_TYPE)
2616      {
2617        aconf = map_to_conf(conf);
2618
2619        if (aconf->clients != 0)
2620        {
2621          SetConfIllegal(aconf);
2622        }
2623        else
2624        {
2625          delete_conf_item(conf);
2626        }
2627      }
2322        else if (conf->type == XLINE_TYPE  ||
2323                 conf->type == RXLINE_TYPE ||
2324                 conf->type == RKLINE_TYPE)
# Line 2638 | Line 2332 | clear_out_old_conf(void)
2332        }
2333        else
2334        {
2641        if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE))
2642        {
2643          match_item = map_to_conf(conf);
2644          if (match_item->ref_count <= 0)
2645            delete_conf_item(conf);
2646          else
2647          {
2648            match_item->illegal = 1;
2649            dlinkDelete(&conf->node, *iterator);
2650          }
2651        }
2652        else
2335            delete_conf_item(conf);
2336        }
2337      }
# Line 2690 | Line 2372 | clear_out_old_conf(void)
2372  
2373    MyFree(ServerInfo.rsa_private_key_file);
2374    ServerInfo.rsa_private_key_file = NULL;
2375 +
2376 +  if (ServerInfo.server_ctx)
2377 +    SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2|
2378 +                                               SSL_OP_NO_SSLv3|
2379 +                                               SSL_OP_NO_TLSv1);
2380 +  if (ServerInfo.client_ctx)
2381 +    SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2|
2382 +                                               SSL_OP_NO_SSLv3|
2383 +                                               SSL_OP_NO_TLSv1);
2384   #endif
2385  
2386    /* clean out old resvs from the conf */
# Line 2715 | Line 2406 | clear_out_old_conf(void)
2406    MyFree(ConfigFileEntry.service_name);
2407    ConfigFileEntry.service_name = NULL;
2408  
2718  MyFree(ConfigFileEntry.servlink_path);
2719  ConfigFileEntry.servlink_path = NULL;
2720 #ifdef HAVE_LIBCRYPTO
2721  ConfigFileEntry.default_cipher_preference = NULL;
2722 #endif /* HAVE_LIBCRYPTO */
2409    delete_isupport("INVEX");
2410    delete_isupport("EXCEPTS");
2411   }
# Line 2763 | Line 2449 | flush_deleted_I_P(void)
2449    }
2450   }
2451  
2766 /* get_conf_name()
2767 *
2768 * inputs       - type of conf file to return name of file for
2769 * output       - pointer to filename for type of conf
2770 * side effects - none
2771 */
2772 const char *
2773 get_conf_name(ConfType type)
2774 {
2775  switch (type)
2776  {
2777    case CONF_TYPE:
2778      return ConfigFileEntry.configfile;
2779      break;
2780    case KLINE_TYPE:
2781      return ConfigFileEntry.klinefile;
2782      break;
2783    case RKLINE_TYPE:
2784      return ConfigFileEntry.rklinefile;
2785      break;
2786    case DLINE_TYPE:
2787      return ConfigFileEntry.dlinefile;
2788      break;
2789    case XLINE_TYPE:
2790      return ConfigFileEntry.xlinefile;
2791      break;
2792    case RXLINE_TYPE:
2793      return ConfigFileEntry.rxlinefile;
2794      break;
2795    case CRESV_TYPE:
2796      return ConfigFileEntry.cresvfile;
2797      break;
2798    case NRESV_TYPE:
2799      return ConfigFileEntry.nresvfile;
2800      break;
2801    case GLINE_TYPE:
2802      return ConfigFileEntry.glinefile;
2803      break;
2804
2805    default:
2806      return NULL;  /* This should NEVER HAPPEN since we call this function
2807                       only with the above values, this will cause us to core
2808                       at some point if this happens so we know where it was */
2809  }
2810 }
2811
2452   #define BAD_PING (-1)
2453  
2454   /* get_conf_ping()
# Line 2830 | Line 2470 | get_conf_ping(struct ConfItem *conf, int
2470      if (aconf->class_ptr != NULL)
2471      {
2472        aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr);
2473 <      *pingwarn = PingWarning(aclass);
2474 <      return PingFreq(aclass);
2473 >      *pingwarn = aclass->ping_warning;
2474 >      return aclass->ping_freq;
2475      }
2476    }
2477  
# Line 2847 | Line 2487 | get_conf_ping(struct ConfItem *conf, int
2487   const char *
2488   get_client_class(struct Client *target_p)
2489   {
2490 <  dlink_node *ptr;
2491 <  struct ConfItem *conf;
2492 <  struct AccessItem *aconf;
2490 >  dlink_node *cnode = NULL;
2491 >  struct AccessItem *aconf = NULL;
2492 >
2493 >  assert(!IsMe(target_p));
2494  
2495 <  if (target_p != NULL && !IsMe(target_p) &&
2855 <      target_p->localClient->confs.head != NULL)
2495 >  if ((cnode = target_p->localClient->confs.head))
2496    {
2497 <    DLINK_FOREACH(ptr, target_p->localClient->confs.head)
2858 <    {
2859 <      conf = ptr->data;
2497 >    struct ConfItem *conf = cnode->data;
2498  
2499 <      if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE ||
2500 <          conf->type == OPER_TYPE)
2501 <      {
2502 <        aconf = (struct AccessItem *) map_to_conf(conf);
2503 <        if (aconf->class_ptr != NULL)
2504 <          return aconf->class_ptr->name;
2867 <      }
2868 <    }
2499 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2500 >          (conf->type == OPER_TYPE));
2501 >
2502 >    aconf = map_to_conf(conf);
2503 >    if (aconf->class_ptr != NULL)
2504 >      return aconf->class_ptr->name;
2505    }
2506  
2507    return "default";
# Line 2881 | Line 2517 | get_client_class(struct Client *target_p
2517   int
2518   get_client_ping(struct Client *target_p, int *pingwarn)
2519   {
2520 <  int ping;
2521 <  struct ConfItem *conf;
2886 <  dlink_node *nlink;
2520 >  int ping = 0;
2521 >  dlink_node *cnode = NULL;
2522  
2523 <  if (target_p->localClient->confs.head != NULL)
2524 <    DLINK_FOREACH(nlink, target_p->localClient->confs.head)
2525 <    {
2891 <      conf = nlink->data;
2523 >  if ((cnode = target_p->localClient->confs.head))
2524 >  {
2525 >    struct ConfItem *conf = cnode->data;
2526  
2527 <      if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2528 <          (conf->type == OPER_TYPE))
2529 <      {
2530 <        ping = get_conf_ping(conf, pingwarn);
2531 <        if (ping > 0)
2532 <          return ping;
2533 <      }
2900 <    }
2527 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2528 >          (conf->type == OPER_TYPE));
2529 >
2530 >    ping = get_conf_ping(conf, pingwarn);
2531 >    if (ping > 0)
2532 >      return ping;
2533 >  }
2534  
2535    *pingwarn = 0;
2536    return DEFAULT_PINGFREQUENCY;
# Line 2914 | Line 2547 | find_class(const char *classname)
2547   {
2548    struct ConfItem *conf;
2549  
2550 <  if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL)
2550 >  if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL)
2551      return conf;
2552  
2553    return class_default;
# Line 2935 | Line 2568 | check_class(void)
2568    {
2569      struct ClassItem *aclass = map_to_conf(ptr->data);
2570  
2571 <    if (!aclass->active && !CurrUserCount(aclass))
2571 >    if (!aclass->active && !aclass->curr_user_count)
2572      {
2573        destroy_cidr_class(aclass);
2574        delete_conf_item(ptr->data);
# Line 2959 | Line 2592 | init_class(void)
2592    aclass = map_to_conf(class_default);
2593    aclass->active = 1;
2594    DupString(class_default->name, "default");
2595 <  ConFreq(aclass)  = DEFAULT_CONNECTFREQUENCY;
2596 <  PingFreq(aclass) = DEFAULT_PINGFREQUENCY;
2597 <  MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT;
2598 <  MaxSendq(aclass) = DEFAULT_SENDQ;
2595 >  aclass->con_freq  = DEFAULT_CONNECTFREQUENCY;
2596 >  aclass->ping_freq = DEFAULT_PINGFREQUENCY;
2597 >  aclass->max_total = MAXIMUM_LINKS_DEFAULT;
2598 >  aclass->max_sendq = DEFAULT_SENDQ;
2599 >  aclass->max_recvq = DEFAULT_RECVQ;
2600  
2601    client_check_cb = register_callback("check_client", check_client);
2602   }
# Line 2977 | Line 2611 | unsigned int
2611   get_sendq(struct Client *client_p)
2612   {
2613    unsigned int sendq = DEFAULT_SENDQ;
2614 <  dlink_node *ptr;
2981 <  struct ConfItem *conf;
2614 >  dlink_node *cnode;
2615    struct ConfItem *class_conf;
2616    struct ClassItem *aclass;
2617    struct AccessItem *aconf;
2618  
2619 <  if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head))
2619 >  assert(!IsMe(client_p));
2620 >
2621 >  if ((cnode = client_p->localClient->confs.head))
2622    {
2623 <    DLINK_FOREACH(ptr, client_p->localClient->confs.head)
2624 <    {
2625 <      conf = ptr->data;
2626 <      if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE)
2627 <          || (conf->type == CLIENT_TYPE))
2628 <      {
2629 <        aconf = (struct AccessItem *)map_to_conf(conf);
2630 <        if ((class_conf = aconf->class_ptr) == NULL)
2631 <          continue;
2632 <        aclass = (struct ClassItem *)map_to_conf(class_conf);
2633 <        sendq = MaxSendq(aclass);
2634 <        return sendq;
2635 <      }
3001 <    }
2623 >    struct ConfItem *conf = cnode->data;
2624 >
2625 >    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2626 >          (conf->type == OPER_TYPE));
2627 >
2628 >    aconf = map_to_conf(conf);
2629 >
2630 >    if ((class_conf = aconf->class_ptr) == NULL)
2631 >      return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */
2632 >
2633 >    aclass = map_to_conf(class_conf);
2634 >    sendq = aclass->max_sendq;
2635 >    return sendq;
2636    }
2637 +
2638    /* XXX return a default?
2639     * if here, then there wasn't an attached conf with a sendq
2640     * that is very bad -Dianora
# Line 3007 | Line 2642 | get_sendq(struct Client *client_p)
2642    return DEFAULT_SENDQ;
2643   }
2644  
2645 + unsigned int
2646 + get_recvq(struct Client *client_p)
2647 + {
2648 +  unsigned int recvq = DEFAULT_RECVQ;
2649 +  dlink_node *cnode;
2650 +  struct ConfItem *class_conf;
2651 +  struct ClassItem *aclass;
2652 +  struct AccessItem *aconf;
2653 +
2654 +  assert(!IsMe(client_p));
2655 +
2656 +  if ((cnode = client_p->localClient->confs.head))
2657 +  {
2658 +    struct ConfItem *conf = cnode->data;
2659 +
2660 +    assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) ||
2661 +          (conf->type == OPER_TYPE));
2662 +
2663 +    aconf = map_to_conf(conf);
2664 +
2665 +    if ((class_conf = aconf->class_ptr) == NULL)
2666 +      return DEFAULT_RECVQ; /* TBV: shouldn't be possible at all */
2667 +
2668 +    aclass = map_to_conf(class_conf);
2669 +    recvq = aclass->max_recvq;
2670 +    return recvq;
2671 +  }
2672 +
2673 +  /* XXX return a default?
2674 +   * if here, then there wasn't an attached conf with a recvq
2675 +   * that is very bad -Dianora
2676 +   */
2677 +  return DEFAULT_RECVQ;
2678 + }
2679 +
2680   /* conf_add_class_to_conf()
2681   *
2682   * inputs       - pointer to config item
# Line 3024 | Line 2694 | conf_add_class_to_conf(struct ConfItem *
2694      aconf->class_ptr = class_default;
2695  
2696      if (conf->type == CLIENT_TYPE)
2697 <      sendto_realops_flags(UMODE_ALL, L_ALL,
2697 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2698                             "Warning *** Defaulting to default class for %s@%s",
2699                             aconf->user, aconf->host);
2700      else
2701 <      sendto_realops_flags(UMODE_ALL, L_ALL,
2701 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2702                             "Warning *** Defaulting to default class for %s",
2703                             conf->name);
2704    }
# Line 3041 | Line 2711 | conf_add_class_to_conf(struct ConfItem *
2711    if (aconf->class_ptr == NULL || !class->active)
2712    {
2713      if (conf->type == CLIENT_TYPE)
2714 <      sendto_realops_flags(UMODE_ALL, L_ALL,
2714 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2715                             "Warning *** Defaulting to default class for %s@%s",
2716                             aconf->user, aconf->host);
2717      else
2718 <      sendto_realops_flags(UMODE_ALL, L_ALL,
2718 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2719                             "Warning *** Defaulting to default class for %s",
2720                             conf->name);
2721      aconf->class_ptr = class_default;
# Line 3062 | Line 2732 | conf_add_class_to_conf(struct ConfItem *
2732   int
2733   conf_add_server(struct ConfItem *conf, const char *class_name)
2734   {
2735 <  struct AccessItem *aconf;
3066 <  struct split_nuh_item nuh;
3067 <  char conf_user[USERLEN + 1];
3068 <  char conf_host[HOSTLEN + 1];
3069 <
3070 <  aconf = map_to_conf(conf);
2735 >  struct AccessItem *aconf = map_to_conf(conf);
2736  
2737    conf_add_class_to_conf(conf, class_name);
2738  
2739    if (!aconf->host || !conf->name)
2740    {
2741 <    sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
2742 <    ilog(L_WARN, "Bad connect block");
2741 >    sendto_realops_flags(UMODE_ALL, L_ALL,  SEND_NOTICE,
2742 >                         "Bad connect block");
2743 >    ilog(LOG_TYPE_IRCD, "Bad connect block");
2744      return -1;
2745    }
2746  
2747 <  if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf))
2747 >  if (EmptyString(aconf->passwd))
2748    {
2749 <    sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s",
2749 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
2750 >                         "Bad connect block, name %s",
2751                           conf->name);
2752 <    ilog(L_WARN, "Bad connect block, host %s", conf->name);
2752 >    ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name);
2753      return -1;
2754    }
2755  
3089  nuh.nuhmask  = aconf->host;
3090  nuh.nickptr  = NULL;
3091  nuh.userptr  = conf_user;
3092  nuh.hostptr  = conf_host;
3093
3094  nuh.nicksize = 0;
3095  nuh.usersize = sizeof(conf_user);
3096  nuh.hostsize = sizeof(conf_host);
3097
3098  split_nuh(&nuh);
3099
3100  MyFree(aconf->host);
3101  aconf->host = NULL;
3102
3103  DupString(aconf->user, conf_user); /* somehow username checking for servers
3104                                 got lost in H6/7, will have to be re-added */
3105  DupString(aconf->host, conf_host);
3106
2756    lookup_confhost(conf);
2757  
2758    return 0;
# Line 3124 | Line 2773 | yyerror(const char *msg)
2773      return;
2774  
2775    strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
2776 <  sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s",
2776 >  sendto_realops_flags(UMODE_ALL, L_ALL,  SEND_NOTICE,
2777 >                       "\"%s\", line %u: %s: %s",
2778                         conffilebuf, lineno + 1, msg, newlinebuf);
2779 <  ilog(L_WARN, "\"%s\", line %u: %s: %s",
2779 >  ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
2780         conffilebuf, lineno + 1, msg, newlinebuf);
2781   }
2782  
3133 int
3134 conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb)
3135 {
3136  if (fbgets(lbuf, max_size, fb) == NULL)
3137    return 0;
3138
3139  return strlen(lbuf);
3140 }
3141
3142 int
3143 conf_yy_fatal_error(const char *msg)
3144 {
3145  return 0;
3146 }
3147
2783   /*
2784   * valid_tkline()
2785   *
# Line 3344 | Line 2979 | parse_aline(const char *cmd, struct Clie
2979          return -1;
2980        }
2981  
2982 <      if (!IsOperRemoteBan(source_p))
2982 >      if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
2983        {
2984          sendto_one(source_p, form_str(ERR_NOPRIVS),
2985                     me.name, source_p->name, "remoteban");
# Line 3381 | Line 3016 | parse_aline(const char *cmd, struct Clie
3016        return -1;
3017      }
3018  
3019 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p))
3019 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
3020        return -1;
3021    }
3022    else
3023 <    if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p))
3023 >    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
3024        return -1;
3025  
3026    if (reason != NULL)
# Line 3393 | Line 3028 | parse_aline(const char *cmd, struct Clie
3028      if (parc != 0 && !EmptyString(*parv))
3029      {
3030        *reason = *parv;
3031 <      if (!valid_comment(source_p, *reason, YES))
3031 >      if (!valid_comment(source_p, *reason, 1))
3032          return -1;
3033      }
3034      else
# Line 3450 | Line 3085 | find_user_host(struct Client *source_p,
3085      
3086      return 1;
3087    }
3088 <  else if (!(flags & NOUSERLOOKUP))
3088 >  else
3089    {
3090      /* Try to find user@host mask from nick */
3091      /* Okay to use source_p as the first param, because source_p == client_p */
# Line 3524 | Line 3159 | match_conf_password(const char *password
3159   {
3160    const char *encr = NULL;
3161  
3162 <  if (password == NULL || aconf->passwd == NULL)
3162 >  if (EmptyString(password) || EmptyString(aconf->passwd))
3163      return 0;
3164  
3165    if (aconf->flags & CONF_FLAGS_ENCRYPTED)
3166 <  {
3532 <    /* use first two chars of the password they send in as salt */
3533 <    /* If the password in the conf is MD5, and ircd is linked
3534 <     * to scrypt on FreeBSD, or the standard crypt library on
3535 <     * glibc Linux, then this code will work fine on generating
3536 <     * the proper encrypted hash for comparison.
3537 <     */
3538 <    if (*aconf->passwd)
3539 <      encr = crypt(password, aconf->passwd);
3540 <    else
3541 <      encr = "";
3542 <  }
3166 >    encr = crypt(password, aconf->passwd);
3167    else
3168      encr = password;
3169  
# Line 3552 | Line 3176 | match_conf_password(const char *password
3176   * inputs       - client sending the cluster
3177   *              - command name "KLINE" "XLINE" etc.
3178   *              - capab -- CAP_KLN etc. from s_serv.h
3179 < *              - cluster type -- CLUSTER_KLINE etc. from s_conf.h
3179 > *              - cluster type -- CLUSTER_KLINE etc. from conf.h
3180   *              - pattern and args to send along
3181   * output       - none
3182   * side effects - Take source_p send the pattern with args given
# Line 3712 | Line 3336 | cidr_limit_reached(int over_rule,
3336    dlink_node *ptr = NULL;
3337    struct CidrItem *cidr;
3338  
3339 <  if (NumberPerCidr(aclass) <= 0)
3339 >  if (aclass->number_per_cidr <= 0)
3340      return 0;
3341  
3342    if (ip->ss.ss_family == AF_INET)
3343    {
3344 <    if (CidrBitlenIPV4(aclass) <= 0)
3344 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3345        return 0;
3346  
3347      DLINK_FOREACH(ptr, aclass->list_ipv4.head)
3348      {
3349        cidr = ptr->data;
3350 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3350 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3351        {
3352 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3352 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3353            return -1;
3354          cidr->number_on_this_cidr++;
3355          return 0;
# Line 3734 | Line 3358 | cidr_limit_reached(int over_rule,
3358      cidr = MyMalloc(sizeof(struct CidrItem));
3359      cidr->number_on_this_cidr = 1;
3360      cidr->mask = *ip;
3361 <    mask_addr(&cidr->mask, CidrBitlenIPV4(aclass));
3361 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4);
3362      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4);
3363    }
3364   #ifdef IPV6
3365 <  else if (CidrBitlenIPV6(aclass) > 0)
3365 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3366    {
3367      DLINK_FOREACH(ptr, aclass->list_ipv6.head)
3368      {
3369        cidr = ptr->data;
3370 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3370 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3371        {
3372 <        if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass)))
3372 >        if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr))
3373            return -1;
3374          cidr->number_on_this_cidr++;
3375          return 0;
# Line 3754 | Line 3378 | cidr_limit_reached(int over_rule,
3378      cidr = MyMalloc(sizeof(struct CidrItem));
3379      cidr->number_on_this_cidr = 1;
3380      cidr->mask = *ip;
3381 <    mask_addr(&cidr->mask, CidrBitlenIPV6(aclass));
3381 >    mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6);
3382      dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6);
3383    }
3384   #endif
# Line 3776 | Line 3400 | remove_from_cidr_check(struct irc_ssaddr
3400    dlink_node *next_ptr = NULL;
3401    struct CidrItem *cidr;
3402  
3403 <  if (NumberPerCidr(aclass) == 0)
3403 >  if (aclass->number_per_cidr == 0)
3404      return;
3405  
3406    if (ip->ss.ss_family == AF_INET)
3407    {
3408 <    if (CidrBitlenIPV4(aclass) <= 0)
3408 >    if (aclass->cidr_bitlen_ipv4 <= 0)
3409        return;
3410  
3411      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head)
3412      {
3413        cidr = ptr->data;
3414 <      if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass)))
3414 >      if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4))
3415        {
3416          cidr->number_on_this_cidr--;
3417          if (cidr->number_on_this_cidr == 0)
# Line 3800 | Line 3424 | remove_from_cidr_check(struct irc_ssaddr
3424      }
3425    }
3426   #ifdef IPV6
3427 <  else if (CidrBitlenIPV6(aclass) > 0)
3427 >  else if (aclass->cidr_bitlen_ipv6 > 0)
3428    {
3429      DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
3430      {
3431        cidr = ptr->data;
3432 <      if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass)))
3432 >      if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6))
3433        {
3434          cidr->number_on_this_cidr--;
3435          if (cidr->number_on_this_cidr == 0)
# Line 3868 | Line 3492 | rebuild_cidr_class(struct ConfItem *conf
3492   {
3493    struct ClassItem *old_class = map_to_conf(conf);
3494  
3495 <  if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0)
3495 >  if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0)
3496    {
3497 <    if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0)
3497 >    if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0)
3498        rebuild_cidr_list(AF_INET, conf, new_class,
3499                          &old_class->list_ipv4, &new_class->list_ipv4,
3500 <                        CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class));
3500 >                        old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4);
3501  
3502   #ifdef IPV6
3503 <    if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0)
3503 >    if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0)
3504        rebuild_cidr_list(AF_INET6, conf, new_class,
3505                          &old_class->list_ipv6, &new_class->list_ipv6,
3506 <                        CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class));
3506 >                        old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6);
3507   #endif
3508    }
3509  

Diff Legend

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